vue-tippy 4.13.0 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/src/components/Tippy.d.ts +421 -0
  2. package/dist/src/components/Tippy.d.ts.map +1 -0
  3. package/dist/src/components/TippySingleton.d.ts +266 -0
  4. package/dist/src/components/TippySingleton.d.ts.map +1 -0
  5. package/dist/src/composables/index.d.ts +4 -0
  6. package/dist/src/composables/index.d.ts.map +1 -0
  7. package/dist/src/composables/useSingleton.d.ts +6 -0
  8. package/dist/src/composables/useSingleton.d.ts.map +1 -0
  9. package/dist/src/composables/useTippy.d.ts +27 -0
  10. package/dist/src/composables/useTippy.d.ts.map +1 -0
  11. package/dist/src/composables/useTippyComponent.d.ts +8 -0
  12. package/dist/src/composables/useTippyComponent.d.ts.map +1 -0
  13. package/dist/src/directive/index.d.ts +4 -0
  14. package/dist/src/directive/index.d.ts.map +1 -0
  15. package/dist/src/index.d.ts +13 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/plugin/index.d.ts +4 -0
  18. package/dist/src/plugin/index.d.ts.map +1 -0
  19. package/dist/src/types/index.d.ts +21 -0
  20. package/dist/src/types/index.d.ts.map +1 -0
  21. package/dist/vue-tippy.cjs +4789 -0
  22. package/dist/vue-tippy.d.ts +750 -0
  23. package/dist/vue-tippy.esm-browser.js +4460 -0
  24. package/dist/vue-tippy.esm.js +31 -6
  25. package/dist/vue-tippy.iife.js +4792 -0
  26. package/dist/vue-tippy.iife.prod.js +6 -0
  27. package/dist/vue-tippy.min.js +1 -1
  28. package/dist/vue-tippy.mjs +4460 -0
  29. package/dist/vue-tippy.prod.cjs +4473 -0
  30. package/dist/vue-tippy.umd.js +31 -6
  31. package/package.json +1 -1
  32. package/src/components/Tippy.vue +21 -15
  33. package/src/components/TippyNoStyles.vue +21 -15
  34. package/src/index.js +2 -0
@@ -0,0 +1,4792 @@
1
+ /*!
2
+ * vue-tippy v6.0.0-alpha.63
3
+ * (c) 2022
4
+ * @license MIT
5
+ */
6
+ var VueTippy = (function (exports, vue) {
7
+ 'use strict';
8
+
9
+ var top = 'top';
10
+ var bottom = 'bottom';
11
+ var right = 'right';
12
+ var left = 'left';
13
+ var auto = 'auto';
14
+ var basePlacements = [top, bottom, right, left];
15
+ var start = 'start';
16
+ var end = 'end';
17
+ var clippingParents = 'clippingParents';
18
+ var viewport = 'viewport';
19
+ var popper = 'popper';
20
+ var reference = 'reference';
21
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
22
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
23
+ }, []);
24
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
25
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
26
+ }, []); // modifiers that need to read the DOM
27
+
28
+ var beforeRead = 'beforeRead';
29
+ var read = 'read';
30
+ var afterRead = 'afterRead'; // pure-logic modifiers
31
+
32
+ var beforeMain = 'beforeMain';
33
+ var main = 'main';
34
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
35
+
36
+ var beforeWrite = 'beforeWrite';
37
+ var write = 'write';
38
+ var afterWrite = 'afterWrite';
39
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
40
+
41
+ function getNodeName(element) {
42
+ return element ? (element.nodeName || '').toLowerCase() : null;
43
+ }
44
+
45
+ function getWindow(node) {
46
+ if (node == null) {
47
+ return window;
48
+ }
49
+
50
+ if (node.toString() !== '[object Window]') {
51
+ var ownerDocument = node.ownerDocument;
52
+ return ownerDocument ? ownerDocument.defaultView || window : window;
53
+ }
54
+
55
+ return node;
56
+ }
57
+
58
+ function isElement(node) {
59
+ var OwnElement = getWindow(node).Element;
60
+ return node instanceof OwnElement || node instanceof Element;
61
+ }
62
+
63
+ function isHTMLElement(node) {
64
+ var OwnElement = getWindow(node).HTMLElement;
65
+ return node instanceof OwnElement || node instanceof HTMLElement;
66
+ }
67
+
68
+ function isShadowRoot(node) {
69
+ // IE 11 has no ShadowRoot
70
+ if (typeof ShadowRoot === 'undefined') {
71
+ return false;
72
+ }
73
+
74
+ var OwnElement = getWindow(node).ShadowRoot;
75
+ return node instanceof OwnElement || node instanceof ShadowRoot;
76
+ }
77
+
78
+ // and applies them to the HTMLElements such as popper and arrow
79
+
80
+ function applyStyles(_ref) {
81
+ var state = _ref.state;
82
+ Object.keys(state.elements).forEach(function (name) {
83
+ var style = state.styles[name] || {};
84
+ var attributes = state.attributes[name] || {};
85
+ var element = state.elements[name]; // arrow is optional + virtual elements
86
+
87
+ if (!isHTMLElement(element) || !getNodeName(element)) {
88
+ return;
89
+ } // Flow doesn't support to extend this property, but it's the most
90
+ // effective way to apply styles to an HTMLElement
91
+ // $FlowFixMe[cannot-write]
92
+
93
+
94
+ Object.assign(element.style, style);
95
+ Object.keys(attributes).forEach(function (name) {
96
+ var value = attributes[name];
97
+
98
+ if (value === false) {
99
+ element.removeAttribute(name);
100
+ } else {
101
+ element.setAttribute(name, value === true ? '' : value);
102
+ }
103
+ });
104
+ });
105
+ }
106
+
107
+ function effect(_ref2) {
108
+ var state = _ref2.state;
109
+ var initialStyles = {
110
+ popper: {
111
+ position: state.options.strategy,
112
+ left: '0',
113
+ top: '0',
114
+ margin: '0'
115
+ },
116
+ arrow: {
117
+ position: 'absolute'
118
+ },
119
+ reference: {}
120
+ };
121
+ Object.assign(state.elements.popper.style, initialStyles.popper);
122
+ state.styles = initialStyles;
123
+
124
+ if (state.elements.arrow) {
125
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
126
+ }
127
+
128
+ return function () {
129
+ Object.keys(state.elements).forEach(function (name) {
130
+ var element = state.elements[name];
131
+ var attributes = state.attributes[name] || {};
132
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
133
+
134
+ var style = styleProperties.reduce(function (style, property) {
135
+ style[property] = '';
136
+ return style;
137
+ }, {}); // arrow is optional + virtual elements
138
+
139
+ if (!isHTMLElement(element) || !getNodeName(element)) {
140
+ return;
141
+ }
142
+
143
+ Object.assign(element.style, style);
144
+ Object.keys(attributes).forEach(function (attribute) {
145
+ element.removeAttribute(attribute);
146
+ });
147
+ });
148
+ };
149
+ } // eslint-disable-next-line import/no-unused-modules
150
+
151
+
152
+ var applyStyles$1 = {
153
+ name: 'applyStyles',
154
+ enabled: true,
155
+ phase: 'write',
156
+ fn: applyStyles,
157
+ effect: effect,
158
+ requires: ['computeStyles']
159
+ };
160
+
161
+ function getBasePlacement(placement) {
162
+ return placement.split('-')[0];
163
+ }
164
+
165
+ var max = Math.max;
166
+ var min = Math.min;
167
+ var round = Math.round;
168
+
169
+ function getBoundingClientRect(element, includeScale) {
170
+ if (includeScale === void 0) {
171
+ includeScale = false;
172
+ }
173
+
174
+ var rect = element.getBoundingClientRect();
175
+ var scaleX = 1;
176
+ var scaleY = 1;
177
+
178
+ if (isHTMLElement(element) && includeScale) {
179
+ var offsetHeight = element.offsetHeight;
180
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
181
+ // Fallback to 1 in case both values are `0`
182
+
183
+ if (offsetWidth > 0) {
184
+ scaleX = round(rect.width) / offsetWidth || 1;
185
+ }
186
+
187
+ if (offsetHeight > 0) {
188
+ scaleY = round(rect.height) / offsetHeight || 1;
189
+ }
190
+ }
191
+
192
+ return {
193
+ width: rect.width / scaleX,
194
+ height: rect.height / scaleY,
195
+ top: rect.top / scaleY,
196
+ right: rect.right / scaleX,
197
+ bottom: rect.bottom / scaleY,
198
+ left: rect.left / scaleX,
199
+ x: rect.left / scaleX,
200
+ y: rect.top / scaleY
201
+ };
202
+ }
203
+
204
+ // means it doesn't take into account transforms.
205
+
206
+ function getLayoutRect(element) {
207
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
208
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
209
+
210
+ var width = element.offsetWidth;
211
+ var height = element.offsetHeight;
212
+
213
+ if (Math.abs(clientRect.width - width) <= 1) {
214
+ width = clientRect.width;
215
+ }
216
+
217
+ if (Math.abs(clientRect.height - height) <= 1) {
218
+ height = clientRect.height;
219
+ }
220
+
221
+ return {
222
+ x: element.offsetLeft,
223
+ y: element.offsetTop,
224
+ width: width,
225
+ height: height
226
+ };
227
+ }
228
+
229
+ function contains(parent, child) {
230
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
231
+
232
+ if (parent.contains(child)) {
233
+ return true;
234
+ } // then fallback to custom implementation with Shadow DOM support
235
+ else if (rootNode && isShadowRoot(rootNode)) {
236
+ var next = child;
237
+
238
+ do {
239
+ if (next && parent.isSameNode(next)) {
240
+ return true;
241
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
242
+
243
+
244
+ next = next.parentNode || next.host;
245
+ } while (next);
246
+ } // Give up, the result is false
247
+
248
+
249
+ return false;
250
+ }
251
+
252
+ function getComputedStyle(element) {
253
+ return getWindow(element).getComputedStyle(element);
254
+ }
255
+
256
+ function isTableElement(element) {
257
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
258
+ }
259
+
260
+ function getDocumentElement(element) {
261
+ // $FlowFixMe[incompatible-return]: assume body is always available
262
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
263
+ element.document) || window.document).documentElement;
264
+ }
265
+
266
+ function getParentNode(element) {
267
+ if (getNodeName(element) === 'html') {
268
+ return element;
269
+ }
270
+
271
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
272
+ // $FlowFixMe[incompatible-return]
273
+ // $FlowFixMe[prop-missing]
274
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
275
+ element.parentNode || ( // DOM Element detected
276
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
277
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
278
+ getDocumentElement(element) // fallback
279
+
280
+ );
281
+ }
282
+
283
+ function getTrueOffsetParent(element) {
284
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
285
+ getComputedStyle(element).position === 'fixed') {
286
+ return null;
287
+ }
288
+
289
+ return element.offsetParent;
290
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
291
+ // return the containing block
292
+
293
+
294
+ function getContainingBlock(element) {
295
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
296
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
297
+
298
+ if (isIE && isHTMLElement(element)) {
299
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
300
+ var elementCss = getComputedStyle(element);
301
+
302
+ if (elementCss.position === 'fixed') {
303
+ return null;
304
+ }
305
+ }
306
+
307
+ var currentNode = getParentNode(element);
308
+
309
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
310
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
311
+ // create a containing block.
312
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
313
+
314
+ 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') {
315
+ return currentNode;
316
+ } else {
317
+ currentNode = currentNode.parentNode;
318
+ }
319
+ }
320
+
321
+ return null;
322
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
323
+ // such as table ancestors and cross browser bugs.
324
+
325
+
326
+ function getOffsetParent(element) {
327
+ var window = getWindow(element);
328
+ var offsetParent = getTrueOffsetParent(element);
329
+
330
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
331
+ offsetParent = getTrueOffsetParent(offsetParent);
332
+ }
333
+
334
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
335
+ return window;
336
+ }
337
+
338
+ return offsetParent || getContainingBlock(element) || window;
339
+ }
340
+
341
+ function getMainAxisFromPlacement(placement) {
342
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
343
+ }
344
+
345
+ function within(min$1, value, max$1) {
346
+ return max(min$1, min(value, max$1));
347
+ }
348
+ function withinMaxClamp(min, value, max) {
349
+ var v = within(min, value, max);
350
+ return v > max ? max : v;
351
+ }
352
+
353
+ function getFreshSideObject() {
354
+ return {
355
+ top: 0,
356
+ right: 0,
357
+ bottom: 0,
358
+ left: 0
359
+ };
360
+ }
361
+
362
+ function mergePaddingObject(paddingObject) {
363
+ return Object.assign({}, getFreshSideObject(), paddingObject);
364
+ }
365
+
366
+ function expandToHashMap(value, keys) {
367
+ return keys.reduce(function (hashMap, key) {
368
+ hashMap[key] = value;
369
+ return hashMap;
370
+ }, {});
371
+ }
372
+
373
+ var toPaddingObject = function toPaddingObject(padding, state) {
374
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
375
+ placement: state.placement
376
+ })) : padding;
377
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
378
+ };
379
+
380
+ function arrow(_ref) {
381
+ var _state$modifiersData$;
382
+
383
+ var state = _ref.state,
384
+ name = _ref.name,
385
+ options = _ref.options;
386
+ var arrowElement = state.elements.arrow;
387
+ var popperOffsets = state.modifiersData.popperOffsets;
388
+ var basePlacement = getBasePlacement(state.placement);
389
+ var axis = getMainAxisFromPlacement(basePlacement);
390
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
391
+ var len = isVertical ? 'height' : 'width';
392
+
393
+ if (!arrowElement || !popperOffsets) {
394
+ return;
395
+ }
396
+
397
+ var paddingObject = toPaddingObject(options.padding, state);
398
+ var arrowRect = getLayoutRect(arrowElement);
399
+ var minProp = axis === 'y' ? top : left;
400
+ var maxProp = axis === 'y' ? bottom : right;
401
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
402
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
403
+ var arrowOffsetParent = getOffsetParent(arrowElement);
404
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
405
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
406
+ // outside of the popper bounds
407
+
408
+ var min = paddingObject[minProp];
409
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
410
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
411
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
412
+
413
+ var axisProp = axis;
414
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
415
+ }
416
+
417
+ function effect$1(_ref2) {
418
+ var state = _ref2.state,
419
+ options = _ref2.options;
420
+ var _options$element = options.element,
421
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
422
+
423
+ if (arrowElement == null) {
424
+ return;
425
+ } // CSS selector
426
+
427
+
428
+ if (typeof arrowElement === 'string') {
429
+ arrowElement = state.elements.popper.querySelector(arrowElement);
430
+
431
+ if (!arrowElement) {
432
+ return;
433
+ }
434
+ }
435
+
436
+ {
437
+ if (!isHTMLElement(arrowElement)) {
438
+ console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
439
+ }
440
+ }
441
+
442
+ if (!contains(state.elements.popper, arrowElement)) {
443
+ {
444
+ console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
445
+ }
446
+
447
+ return;
448
+ }
449
+
450
+ state.elements.arrow = arrowElement;
451
+ } // eslint-disable-next-line import/no-unused-modules
452
+
453
+
454
+ var arrow$1 = {
455
+ name: 'arrow',
456
+ enabled: true,
457
+ phase: 'main',
458
+ fn: arrow,
459
+ effect: effect$1,
460
+ requires: ['popperOffsets'],
461
+ requiresIfExists: ['preventOverflow']
462
+ };
463
+
464
+ function getVariation(placement) {
465
+ return placement.split('-')[1];
466
+ }
467
+
468
+ var unsetSides = {
469
+ top: 'auto',
470
+ right: 'auto',
471
+ bottom: 'auto',
472
+ left: 'auto'
473
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
474
+ // Zooming can change the DPR, but it seems to report a value that will
475
+ // cleanly divide the values into the appropriate subpixels.
476
+
477
+ function roundOffsetsByDPR(_ref) {
478
+ var x = _ref.x,
479
+ y = _ref.y;
480
+ var win = window;
481
+ var dpr = win.devicePixelRatio || 1;
482
+ return {
483
+ x: round(x * dpr) / dpr || 0,
484
+ y: round(y * dpr) / dpr || 0
485
+ };
486
+ }
487
+
488
+ function mapToStyles(_ref2) {
489
+ var _Object$assign2;
490
+
491
+ var popper = _ref2.popper,
492
+ popperRect = _ref2.popperRect,
493
+ placement = _ref2.placement,
494
+ variation = _ref2.variation,
495
+ offsets = _ref2.offsets,
496
+ position = _ref2.position,
497
+ gpuAcceleration = _ref2.gpuAcceleration,
498
+ adaptive = _ref2.adaptive,
499
+ roundOffsets = _ref2.roundOffsets,
500
+ isFixed = _ref2.isFixed;
501
+
502
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
503
+ _ref3$x = _ref3.x,
504
+ x = _ref3$x === void 0 ? 0 : _ref3$x,
505
+ _ref3$y = _ref3.y,
506
+ y = _ref3$y === void 0 ? 0 : _ref3$y;
507
+
508
+ var hasX = offsets.hasOwnProperty('x');
509
+ var hasY = offsets.hasOwnProperty('y');
510
+ var sideX = left;
511
+ var sideY = top;
512
+ var win = window;
513
+
514
+ if (adaptive) {
515
+ var offsetParent = getOffsetParent(popper);
516
+ var heightProp = 'clientHeight';
517
+ var widthProp = 'clientWidth';
518
+
519
+ if (offsetParent === getWindow(popper)) {
520
+ offsetParent = getDocumentElement(popper);
521
+
522
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
523
+ heightProp = 'scrollHeight';
524
+ widthProp = 'scrollWidth';
525
+ }
526
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
527
+
528
+
529
+ offsetParent = offsetParent;
530
+
531
+ if (placement === top || (placement === left || placement === right) && variation === end) {
532
+ sideY = bottom;
533
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
534
+ offsetParent[heightProp];
535
+ y -= offsetY - popperRect.height;
536
+ y *= gpuAcceleration ? 1 : -1;
537
+ }
538
+
539
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
540
+ sideX = right;
541
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
542
+ offsetParent[widthProp];
543
+ x -= offsetX - popperRect.width;
544
+ x *= gpuAcceleration ? 1 : -1;
545
+ }
546
+ }
547
+
548
+ var commonStyles = Object.assign({
549
+ position: position
550
+ }, adaptive && unsetSides);
551
+
552
+ if (gpuAcceleration) {
553
+ var _Object$assign;
554
+
555
+ 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));
556
+ }
557
+
558
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
559
+ }
560
+
561
+ function computeStyles(_ref4) {
562
+ var state = _ref4.state,
563
+ options = _ref4.options;
564
+ var _options$gpuAccelerat = options.gpuAcceleration,
565
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
566
+ _options$adaptive = options.adaptive,
567
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
568
+ _options$roundOffsets = options.roundOffsets,
569
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
570
+
571
+ {
572
+ var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
573
+
574
+ if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
575
+ return transitionProperty.indexOf(property) >= 0;
576
+ })) {
577
+ 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(' '));
578
+ }
579
+ }
580
+
581
+ var commonStyles = {
582
+ placement: getBasePlacement(state.placement),
583
+ variation: getVariation(state.placement),
584
+ popper: state.elements.popper,
585
+ popperRect: state.rects.popper,
586
+ gpuAcceleration: gpuAcceleration,
587
+ isFixed: state.options.strategy === 'fixed'
588
+ };
589
+
590
+ if (state.modifiersData.popperOffsets != null) {
591
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
592
+ offsets: state.modifiersData.popperOffsets,
593
+ position: state.options.strategy,
594
+ adaptive: adaptive,
595
+ roundOffsets: roundOffsets
596
+ })));
597
+ }
598
+
599
+ if (state.modifiersData.arrow != null) {
600
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
601
+ offsets: state.modifiersData.arrow,
602
+ position: 'absolute',
603
+ adaptive: false,
604
+ roundOffsets: roundOffsets
605
+ })));
606
+ }
607
+
608
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
609
+ 'data-popper-placement': state.placement
610
+ });
611
+ } // eslint-disable-next-line import/no-unused-modules
612
+
613
+
614
+ var computeStyles$1 = {
615
+ name: 'computeStyles',
616
+ enabled: true,
617
+ phase: 'beforeWrite',
618
+ fn: computeStyles,
619
+ data: {}
620
+ };
621
+
622
+ var passive = {
623
+ passive: true
624
+ };
625
+
626
+ function effect$2(_ref) {
627
+ var state = _ref.state,
628
+ instance = _ref.instance,
629
+ options = _ref.options;
630
+ var _options$scroll = options.scroll,
631
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
632
+ _options$resize = options.resize,
633
+ resize = _options$resize === void 0 ? true : _options$resize;
634
+ var window = getWindow(state.elements.popper);
635
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
636
+
637
+ if (scroll) {
638
+ scrollParents.forEach(function (scrollParent) {
639
+ scrollParent.addEventListener('scroll', instance.update, passive);
640
+ });
641
+ }
642
+
643
+ if (resize) {
644
+ window.addEventListener('resize', instance.update, passive);
645
+ }
646
+
647
+ return function () {
648
+ if (scroll) {
649
+ scrollParents.forEach(function (scrollParent) {
650
+ scrollParent.removeEventListener('scroll', instance.update, passive);
651
+ });
652
+ }
653
+
654
+ if (resize) {
655
+ window.removeEventListener('resize', instance.update, passive);
656
+ }
657
+ };
658
+ } // eslint-disable-next-line import/no-unused-modules
659
+
660
+
661
+ var eventListeners = {
662
+ name: 'eventListeners',
663
+ enabled: true,
664
+ phase: 'write',
665
+ fn: function fn() {},
666
+ effect: effect$2,
667
+ data: {}
668
+ };
669
+
670
+ var hash = {
671
+ left: 'right',
672
+ right: 'left',
673
+ bottom: 'top',
674
+ top: 'bottom'
675
+ };
676
+ function getOppositePlacement(placement) {
677
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
678
+ return hash[matched];
679
+ });
680
+ }
681
+
682
+ var hash$1 = {
683
+ start: 'end',
684
+ end: 'start'
685
+ };
686
+ function getOppositeVariationPlacement(placement) {
687
+ return placement.replace(/start|end/g, function (matched) {
688
+ return hash$1[matched];
689
+ });
690
+ }
691
+
692
+ function getWindowScroll(node) {
693
+ var win = getWindow(node);
694
+ var scrollLeft = win.pageXOffset;
695
+ var scrollTop = win.pageYOffset;
696
+ return {
697
+ scrollLeft: scrollLeft,
698
+ scrollTop: scrollTop
699
+ };
700
+ }
701
+
702
+ function getWindowScrollBarX(element) {
703
+ // If <html> has a CSS width greater than the viewport, then this will be
704
+ // incorrect for RTL.
705
+ // Popper 1 is broken in this case and never had a bug report so let's assume
706
+ // it's not an issue. I don't think anyone ever specifies width on <html>
707
+ // anyway.
708
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
709
+ // this (e.g. Edge 2019, IE11, Safari)
710
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
711
+ }
712
+
713
+ function getViewportRect(element) {
714
+ var win = getWindow(element);
715
+ var html = getDocumentElement(element);
716
+ var visualViewport = win.visualViewport;
717
+ var width = html.clientWidth;
718
+ var height = html.clientHeight;
719
+ var x = 0;
720
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
721
+ // can be obscured underneath it.
722
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
723
+ // if it isn't open, so if this isn't available, the popper will be detected
724
+ // to overflow the bottom of the screen too early.
725
+
726
+ if (visualViewport) {
727
+ width = visualViewport.width;
728
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
729
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
730
+ // errors due to floating point numbers, so we need to check precision.
731
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
732
+ // Feature detection fails in mobile emulation mode in Chrome.
733
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
734
+ // 0.001
735
+ // Fallback here: "Not Safari" userAgent
736
+
737
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
738
+ x = visualViewport.offsetLeft;
739
+ y = visualViewport.offsetTop;
740
+ }
741
+ }
742
+
743
+ return {
744
+ width: width,
745
+ height: height,
746
+ x: x + getWindowScrollBarX(element),
747
+ y: y
748
+ };
749
+ }
750
+
751
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
752
+
753
+ function getDocumentRect(element) {
754
+ var _element$ownerDocumen;
755
+
756
+ var html = getDocumentElement(element);
757
+ var winScroll = getWindowScroll(element);
758
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
759
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
760
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
761
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
762
+ var y = -winScroll.scrollTop;
763
+
764
+ if (getComputedStyle(body || html).direction === 'rtl') {
765
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
766
+ }
767
+
768
+ return {
769
+ width: width,
770
+ height: height,
771
+ x: x,
772
+ y: y
773
+ };
774
+ }
775
+
776
+ function isScrollParent(element) {
777
+ // Firefox wants us to check `-x` and `-y` variations as well
778
+ var _getComputedStyle = getComputedStyle(element),
779
+ overflow = _getComputedStyle.overflow,
780
+ overflowX = _getComputedStyle.overflowX,
781
+ overflowY = _getComputedStyle.overflowY;
782
+
783
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
784
+ }
785
+
786
+ function getScrollParent(node) {
787
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
788
+ // $FlowFixMe[incompatible-return]: assume body is always available
789
+ return node.ownerDocument.body;
790
+ }
791
+
792
+ if (isHTMLElement(node) && isScrollParent(node)) {
793
+ return node;
794
+ }
795
+
796
+ return getScrollParent(getParentNode(node));
797
+ }
798
+
799
+ /*
800
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
801
+ until we get to the top window object. This list is what we attach scroll listeners
802
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
803
+ reference element's position.
804
+ */
805
+
806
+ function listScrollParents(element, list) {
807
+ var _element$ownerDocumen;
808
+
809
+ if (list === void 0) {
810
+ list = [];
811
+ }
812
+
813
+ var scrollParent = getScrollParent(element);
814
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
815
+ var win = getWindow(scrollParent);
816
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
817
+ var updatedList = list.concat(target);
818
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
819
+ updatedList.concat(listScrollParents(getParentNode(target)));
820
+ }
821
+
822
+ function rectToClientRect(rect) {
823
+ return Object.assign({}, rect, {
824
+ left: rect.x,
825
+ top: rect.y,
826
+ right: rect.x + rect.width,
827
+ bottom: rect.y + rect.height
828
+ });
829
+ }
830
+
831
+ function getInnerBoundingClientRect(element) {
832
+ var rect = getBoundingClientRect(element);
833
+ rect.top = rect.top + element.clientTop;
834
+ rect.left = rect.left + element.clientLeft;
835
+ rect.bottom = rect.top + element.clientHeight;
836
+ rect.right = rect.left + element.clientWidth;
837
+ rect.width = element.clientWidth;
838
+ rect.height = element.clientHeight;
839
+ rect.x = rect.left;
840
+ rect.y = rect.top;
841
+ return rect;
842
+ }
843
+
844
+ function getClientRectFromMixedType(element, clippingParent) {
845
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
846
+ } // A "clipping parent" is an overflowable container with the characteristic of
847
+ // clipping (or hiding) overflowing elements with a position different from
848
+ // `initial`
849
+
850
+
851
+ function getClippingParents(element) {
852
+ var clippingParents = listScrollParents(getParentNode(element));
853
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
854
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
855
+
856
+ if (!isElement(clipperElement)) {
857
+ return [];
858
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
859
+
860
+
861
+ return clippingParents.filter(function (clippingParent) {
862
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body' && (canEscapeClipping ? getComputedStyle(clippingParent).position !== 'static' : true);
863
+ });
864
+ } // Gets the maximum area that the element is visible in due to any number of
865
+ // clipping parents
866
+
867
+
868
+ function getClippingRect(element, boundary, rootBoundary) {
869
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
870
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
871
+ var firstClippingParent = clippingParents[0];
872
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
873
+ var rect = getClientRectFromMixedType(element, clippingParent);
874
+ accRect.top = max(rect.top, accRect.top);
875
+ accRect.right = min(rect.right, accRect.right);
876
+ accRect.bottom = min(rect.bottom, accRect.bottom);
877
+ accRect.left = max(rect.left, accRect.left);
878
+ return accRect;
879
+ }, getClientRectFromMixedType(element, firstClippingParent));
880
+ clippingRect.width = clippingRect.right - clippingRect.left;
881
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
882
+ clippingRect.x = clippingRect.left;
883
+ clippingRect.y = clippingRect.top;
884
+ return clippingRect;
885
+ }
886
+
887
+ function computeOffsets(_ref) {
888
+ var reference = _ref.reference,
889
+ element = _ref.element,
890
+ placement = _ref.placement;
891
+ var basePlacement = placement ? getBasePlacement(placement) : null;
892
+ var variation = placement ? getVariation(placement) : null;
893
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
894
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
895
+ var offsets;
896
+
897
+ switch (basePlacement) {
898
+ case top:
899
+ offsets = {
900
+ x: commonX,
901
+ y: reference.y - element.height
902
+ };
903
+ break;
904
+
905
+ case bottom:
906
+ offsets = {
907
+ x: commonX,
908
+ y: reference.y + reference.height
909
+ };
910
+ break;
911
+
912
+ case right:
913
+ offsets = {
914
+ x: reference.x + reference.width,
915
+ y: commonY
916
+ };
917
+ break;
918
+
919
+ case left:
920
+ offsets = {
921
+ x: reference.x - element.width,
922
+ y: commonY
923
+ };
924
+ break;
925
+
926
+ default:
927
+ offsets = {
928
+ x: reference.x,
929
+ y: reference.y
930
+ };
931
+ }
932
+
933
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
934
+
935
+ if (mainAxis != null) {
936
+ var len = mainAxis === 'y' ? 'height' : 'width';
937
+
938
+ switch (variation) {
939
+ case start:
940
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
941
+ break;
942
+
943
+ case end:
944
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
945
+ break;
946
+ }
947
+ }
948
+
949
+ return offsets;
950
+ }
951
+
952
+ function detectOverflow(state, options) {
953
+ if (options === void 0) {
954
+ options = {};
955
+ }
956
+
957
+ var _options = options,
958
+ _options$placement = _options.placement,
959
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
960
+ _options$boundary = _options.boundary,
961
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
962
+ _options$rootBoundary = _options.rootBoundary,
963
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
964
+ _options$elementConte = _options.elementContext,
965
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
966
+ _options$altBoundary = _options.altBoundary,
967
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
968
+ _options$padding = _options.padding,
969
+ padding = _options$padding === void 0 ? 0 : _options$padding;
970
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
971
+ var altContext = elementContext === popper ? reference : popper;
972
+ var popperRect = state.rects.popper;
973
+ var element = state.elements[altBoundary ? altContext : elementContext];
974
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
975
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
976
+ var popperOffsets = computeOffsets({
977
+ reference: referenceClientRect,
978
+ element: popperRect,
979
+ strategy: 'absolute',
980
+ placement: placement
981
+ });
982
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
983
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
984
+ // 0 or negative = within the clipping rect
985
+
986
+ var overflowOffsets = {
987
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
988
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
989
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
990
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
991
+ };
992
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
993
+
994
+ if (elementContext === popper && offsetData) {
995
+ var offset = offsetData[placement];
996
+ Object.keys(overflowOffsets).forEach(function (key) {
997
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
998
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
999
+ overflowOffsets[key] += offset[axis] * multiply;
1000
+ });
1001
+ }
1002
+
1003
+ return overflowOffsets;
1004
+ }
1005
+
1006
+ function computeAutoPlacement(state, options) {
1007
+ if (options === void 0) {
1008
+ options = {};
1009
+ }
1010
+
1011
+ var _options = options,
1012
+ placement = _options.placement,
1013
+ boundary = _options.boundary,
1014
+ rootBoundary = _options.rootBoundary,
1015
+ padding = _options.padding,
1016
+ flipVariations = _options.flipVariations,
1017
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1018
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1019
+ var variation = getVariation(placement);
1020
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1021
+ return getVariation(placement) === variation;
1022
+ }) : basePlacements;
1023
+ var allowedPlacements = placements$1.filter(function (placement) {
1024
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1025
+ });
1026
+
1027
+ if (allowedPlacements.length === 0) {
1028
+ allowedPlacements = placements$1;
1029
+
1030
+ {
1031
+ console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
1032
+ }
1033
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1034
+
1035
+
1036
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1037
+ acc[placement] = detectOverflow(state, {
1038
+ placement: placement,
1039
+ boundary: boundary,
1040
+ rootBoundary: rootBoundary,
1041
+ padding: padding
1042
+ })[getBasePlacement(placement)];
1043
+ return acc;
1044
+ }, {});
1045
+ return Object.keys(overflows).sort(function (a, b) {
1046
+ return overflows[a] - overflows[b];
1047
+ });
1048
+ }
1049
+
1050
+ function getExpandedFallbackPlacements(placement) {
1051
+ if (getBasePlacement(placement) === auto) {
1052
+ return [];
1053
+ }
1054
+
1055
+ var oppositePlacement = getOppositePlacement(placement);
1056
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1057
+ }
1058
+
1059
+ function flip(_ref) {
1060
+ var state = _ref.state,
1061
+ options = _ref.options,
1062
+ name = _ref.name;
1063
+
1064
+ if (state.modifiersData[name]._skip) {
1065
+ return;
1066
+ }
1067
+
1068
+ var _options$mainAxis = options.mainAxis,
1069
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1070
+ _options$altAxis = options.altAxis,
1071
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1072
+ specifiedFallbackPlacements = options.fallbackPlacements,
1073
+ padding = options.padding,
1074
+ boundary = options.boundary,
1075
+ rootBoundary = options.rootBoundary,
1076
+ altBoundary = options.altBoundary,
1077
+ _options$flipVariatio = options.flipVariations,
1078
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1079
+ allowedAutoPlacements = options.allowedAutoPlacements;
1080
+ var preferredPlacement = state.options.placement;
1081
+ var basePlacement = getBasePlacement(preferredPlacement);
1082
+ var isBasePlacement = basePlacement === preferredPlacement;
1083
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1084
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1085
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1086
+ placement: placement,
1087
+ boundary: boundary,
1088
+ rootBoundary: rootBoundary,
1089
+ padding: padding,
1090
+ flipVariations: flipVariations,
1091
+ allowedAutoPlacements: allowedAutoPlacements
1092
+ }) : placement);
1093
+ }, []);
1094
+ var referenceRect = state.rects.reference;
1095
+ var popperRect = state.rects.popper;
1096
+ var checksMap = new Map();
1097
+ var makeFallbackChecks = true;
1098
+ var firstFittingPlacement = placements[0];
1099
+
1100
+ for (var i = 0; i < placements.length; i++) {
1101
+ var placement = placements[i];
1102
+
1103
+ var _basePlacement = getBasePlacement(placement);
1104
+
1105
+ var isStartVariation = getVariation(placement) === start;
1106
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1107
+ var len = isVertical ? 'width' : 'height';
1108
+ var overflow = detectOverflow(state, {
1109
+ placement: placement,
1110
+ boundary: boundary,
1111
+ rootBoundary: rootBoundary,
1112
+ altBoundary: altBoundary,
1113
+ padding: padding
1114
+ });
1115
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1116
+
1117
+ if (referenceRect[len] > popperRect[len]) {
1118
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1119
+ }
1120
+
1121
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1122
+ var checks = [];
1123
+
1124
+ if (checkMainAxis) {
1125
+ checks.push(overflow[_basePlacement] <= 0);
1126
+ }
1127
+
1128
+ if (checkAltAxis) {
1129
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1130
+ }
1131
+
1132
+ if (checks.every(function (check) {
1133
+ return check;
1134
+ })) {
1135
+ firstFittingPlacement = placement;
1136
+ makeFallbackChecks = false;
1137
+ break;
1138
+ }
1139
+
1140
+ checksMap.set(placement, checks);
1141
+ }
1142
+
1143
+ if (makeFallbackChecks) {
1144
+ // `2` may be desired in some cases – research later
1145
+ var numberOfChecks = flipVariations ? 3 : 1;
1146
+
1147
+ var _loop = function _loop(_i) {
1148
+ var fittingPlacement = placements.find(function (placement) {
1149
+ var checks = checksMap.get(placement);
1150
+
1151
+ if (checks) {
1152
+ return checks.slice(0, _i).every(function (check) {
1153
+ return check;
1154
+ });
1155
+ }
1156
+ });
1157
+
1158
+ if (fittingPlacement) {
1159
+ firstFittingPlacement = fittingPlacement;
1160
+ return "break";
1161
+ }
1162
+ };
1163
+
1164
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1165
+ var _ret = _loop(_i);
1166
+
1167
+ if (_ret === "break") break;
1168
+ }
1169
+ }
1170
+
1171
+ if (state.placement !== firstFittingPlacement) {
1172
+ state.modifiersData[name]._skip = true;
1173
+ state.placement = firstFittingPlacement;
1174
+ state.reset = true;
1175
+ }
1176
+ } // eslint-disable-next-line import/no-unused-modules
1177
+
1178
+
1179
+ var flip$1 = {
1180
+ name: 'flip',
1181
+ enabled: true,
1182
+ phase: 'main',
1183
+ fn: flip,
1184
+ requiresIfExists: ['offset'],
1185
+ data: {
1186
+ _skip: false
1187
+ }
1188
+ };
1189
+
1190
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1191
+ if (preventedOffsets === void 0) {
1192
+ preventedOffsets = {
1193
+ x: 0,
1194
+ y: 0
1195
+ };
1196
+ }
1197
+
1198
+ return {
1199
+ top: overflow.top - rect.height - preventedOffsets.y,
1200
+ right: overflow.right - rect.width + preventedOffsets.x,
1201
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1202
+ left: overflow.left - rect.width - preventedOffsets.x
1203
+ };
1204
+ }
1205
+
1206
+ function isAnySideFullyClipped(overflow) {
1207
+ return [top, right, bottom, left].some(function (side) {
1208
+ return overflow[side] >= 0;
1209
+ });
1210
+ }
1211
+
1212
+ function hide(_ref) {
1213
+ var state = _ref.state,
1214
+ name = _ref.name;
1215
+ var referenceRect = state.rects.reference;
1216
+ var popperRect = state.rects.popper;
1217
+ var preventedOffsets = state.modifiersData.preventOverflow;
1218
+ var referenceOverflow = detectOverflow(state, {
1219
+ elementContext: 'reference'
1220
+ });
1221
+ var popperAltOverflow = detectOverflow(state, {
1222
+ altBoundary: true
1223
+ });
1224
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1225
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1226
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1227
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1228
+ state.modifiersData[name] = {
1229
+ referenceClippingOffsets: referenceClippingOffsets,
1230
+ popperEscapeOffsets: popperEscapeOffsets,
1231
+ isReferenceHidden: isReferenceHidden,
1232
+ hasPopperEscaped: hasPopperEscaped
1233
+ };
1234
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1235
+ 'data-popper-reference-hidden': isReferenceHidden,
1236
+ 'data-popper-escaped': hasPopperEscaped
1237
+ });
1238
+ } // eslint-disable-next-line import/no-unused-modules
1239
+
1240
+
1241
+ var hide$1 = {
1242
+ name: 'hide',
1243
+ enabled: true,
1244
+ phase: 'main',
1245
+ requiresIfExists: ['preventOverflow'],
1246
+ fn: hide
1247
+ };
1248
+
1249
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1250
+ var basePlacement = getBasePlacement(placement);
1251
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1252
+
1253
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1254
+ placement: placement
1255
+ })) : offset,
1256
+ skidding = _ref[0],
1257
+ distance = _ref[1];
1258
+
1259
+ skidding = skidding || 0;
1260
+ distance = (distance || 0) * invertDistance;
1261
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1262
+ x: distance,
1263
+ y: skidding
1264
+ } : {
1265
+ x: skidding,
1266
+ y: distance
1267
+ };
1268
+ }
1269
+
1270
+ function offset(_ref2) {
1271
+ var state = _ref2.state,
1272
+ options = _ref2.options,
1273
+ name = _ref2.name;
1274
+ var _options$offset = options.offset,
1275
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1276
+ var data = placements.reduce(function (acc, placement) {
1277
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1278
+ return acc;
1279
+ }, {});
1280
+ var _data$state$placement = data[state.placement],
1281
+ x = _data$state$placement.x,
1282
+ y = _data$state$placement.y;
1283
+
1284
+ if (state.modifiersData.popperOffsets != null) {
1285
+ state.modifiersData.popperOffsets.x += x;
1286
+ state.modifiersData.popperOffsets.y += y;
1287
+ }
1288
+
1289
+ state.modifiersData[name] = data;
1290
+ } // eslint-disable-next-line import/no-unused-modules
1291
+
1292
+
1293
+ var offset$1 = {
1294
+ name: 'offset',
1295
+ enabled: true,
1296
+ phase: 'main',
1297
+ requires: ['popperOffsets'],
1298
+ fn: offset
1299
+ };
1300
+
1301
+ function popperOffsets(_ref) {
1302
+ var state = _ref.state,
1303
+ name = _ref.name;
1304
+ // Offsets are the actual position the popper needs to have to be
1305
+ // properly positioned near its reference element
1306
+ // This is the most basic placement, and will be adjusted by
1307
+ // the modifiers in the next step
1308
+ state.modifiersData[name] = computeOffsets({
1309
+ reference: state.rects.reference,
1310
+ element: state.rects.popper,
1311
+ strategy: 'absolute',
1312
+ placement: state.placement
1313
+ });
1314
+ } // eslint-disable-next-line import/no-unused-modules
1315
+
1316
+
1317
+ var popperOffsets$1 = {
1318
+ name: 'popperOffsets',
1319
+ enabled: true,
1320
+ phase: 'read',
1321
+ fn: popperOffsets,
1322
+ data: {}
1323
+ };
1324
+
1325
+ function getAltAxis(axis) {
1326
+ return axis === 'x' ? 'y' : 'x';
1327
+ }
1328
+
1329
+ function preventOverflow(_ref) {
1330
+ var state = _ref.state,
1331
+ options = _ref.options,
1332
+ name = _ref.name;
1333
+ var _options$mainAxis = options.mainAxis,
1334
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1335
+ _options$altAxis = options.altAxis,
1336
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1337
+ boundary = options.boundary,
1338
+ rootBoundary = options.rootBoundary,
1339
+ altBoundary = options.altBoundary,
1340
+ padding = options.padding,
1341
+ _options$tether = options.tether,
1342
+ tether = _options$tether === void 0 ? true : _options$tether,
1343
+ _options$tetherOffset = options.tetherOffset,
1344
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1345
+ var overflow = detectOverflow(state, {
1346
+ boundary: boundary,
1347
+ rootBoundary: rootBoundary,
1348
+ padding: padding,
1349
+ altBoundary: altBoundary
1350
+ });
1351
+ var basePlacement = getBasePlacement(state.placement);
1352
+ var variation = getVariation(state.placement);
1353
+ var isBasePlacement = !variation;
1354
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1355
+ var altAxis = getAltAxis(mainAxis);
1356
+ var popperOffsets = state.modifiersData.popperOffsets;
1357
+ var referenceRect = state.rects.reference;
1358
+ var popperRect = state.rects.popper;
1359
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1360
+ placement: state.placement
1361
+ })) : tetherOffset;
1362
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1363
+ mainAxis: tetherOffsetValue,
1364
+ altAxis: tetherOffsetValue
1365
+ } : Object.assign({
1366
+ mainAxis: 0,
1367
+ altAxis: 0
1368
+ }, tetherOffsetValue);
1369
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1370
+ var data = {
1371
+ x: 0,
1372
+ y: 0
1373
+ };
1374
+
1375
+ if (!popperOffsets) {
1376
+ return;
1377
+ }
1378
+
1379
+ if (checkMainAxis) {
1380
+ var _offsetModifierState$;
1381
+
1382
+ var mainSide = mainAxis === 'y' ? top : left;
1383
+ var altSide = mainAxis === 'y' ? bottom : right;
1384
+ var len = mainAxis === 'y' ? 'height' : 'width';
1385
+ var offset = popperOffsets[mainAxis];
1386
+ var min$1 = offset + overflow[mainSide];
1387
+ var max$1 = offset - overflow[altSide];
1388
+ var additive = tether ? -popperRect[len] / 2 : 0;
1389
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1390
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1391
+ // outside the reference bounds
1392
+
1393
+ var arrowElement = state.elements.arrow;
1394
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1395
+ width: 0,
1396
+ height: 0
1397
+ };
1398
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1399
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1400
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1401
+ // to include its full size in the calculation. If the reference is small
1402
+ // and near the edge of a boundary, the popper can overflow even if the
1403
+ // reference is not overflowing as well (e.g. virtual elements with no
1404
+ // width or height)
1405
+
1406
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1407
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1408
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1409
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1410
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1411
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1412
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1413
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1414
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1415
+ popperOffsets[mainAxis] = preventedOffset;
1416
+ data[mainAxis] = preventedOffset - offset;
1417
+ }
1418
+
1419
+ if (checkAltAxis) {
1420
+ var _offsetModifierState$2;
1421
+
1422
+ var _mainSide = mainAxis === 'x' ? top : left;
1423
+
1424
+ var _altSide = mainAxis === 'x' ? bottom : right;
1425
+
1426
+ var _offset = popperOffsets[altAxis];
1427
+
1428
+ var _len = altAxis === 'y' ? 'height' : 'width';
1429
+
1430
+ var _min = _offset + overflow[_mainSide];
1431
+
1432
+ var _max = _offset - overflow[_altSide];
1433
+
1434
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1435
+
1436
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1437
+
1438
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1439
+
1440
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1441
+
1442
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1443
+
1444
+ popperOffsets[altAxis] = _preventedOffset;
1445
+ data[altAxis] = _preventedOffset - _offset;
1446
+ }
1447
+
1448
+ state.modifiersData[name] = data;
1449
+ } // eslint-disable-next-line import/no-unused-modules
1450
+
1451
+
1452
+ var preventOverflow$1 = {
1453
+ name: 'preventOverflow',
1454
+ enabled: true,
1455
+ phase: 'main',
1456
+ fn: preventOverflow,
1457
+ requiresIfExists: ['offset']
1458
+ };
1459
+
1460
+ function getHTMLElementScroll(element) {
1461
+ return {
1462
+ scrollLeft: element.scrollLeft,
1463
+ scrollTop: element.scrollTop
1464
+ };
1465
+ }
1466
+
1467
+ function getNodeScroll(node) {
1468
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1469
+ return getWindowScroll(node);
1470
+ } else {
1471
+ return getHTMLElementScroll(node);
1472
+ }
1473
+ }
1474
+
1475
+ function isElementScaled(element) {
1476
+ var rect = element.getBoundingClientRect();
1477
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1478
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1479
+ return scaleX !== 1 || scaleY !== 1;
1480
+ } // Returns the composite rect of an element relative to its offsetParent.
1481
+ // Composite means it takes into account transforms as well as layout.
1482
+
1483
+
1484
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1485
+ if (isFixed === void 0) {
1486
+ isFixed = false;
1487
+ }
1488
+
1489
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1490
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1491
+ var documentElement = getDocumentElement(offsetParent);
1492
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1493
+ var scroll = {
1494
+ scrollLeft: 0,
1495
+ scrollTop: 0
1496
+ };
1497
+ var offsets = {
1498
+ x: 0,
1499
+ y: 0
1500
+ };
1501
+
1502
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1503
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1504
+ isScrollParent(documentElement)) {
1505
+ scroll = getNodeScroll(offsetParent);
1506
+ }
1507
+
1508
+ if (isHTMLElement(offsetParent)) {
1509
+ offsets = getBoundingClientRect(offsetParent, true);
1510
+ offsets.x += offsetParent.clientLeft;
1511
+ offsets.y += offsetParent.clientTop;
1512
+ } else if (documentElement) {
1513
+ offsets.x = getWindowScrollBarX(documentElement);
1514
+ }
1515
+ }
1516
+
1517
+ return {
1518
+ x: rect.left + scroll.scrollLeft - offsets.x,
1519
+ y: rect.top + scroll.scrollTop - offsets.y,
1520
+ width: rect.width,
1521
+ height: rect.height
1522
+ };
1523
+ }
1524
+
1525
+ function order(modifiers) {
1526
+ var map = new Map();
1527
+ var visited = new Set();
1528
+ var result = [];
1529
+ modifiers.forEach(function (modifier) {
1530
+ map.set(modifier.name, modifier);
1531
+ }); // On visiting object, check for its dependencies and visit them recursively
1532
+
1533
+ function sort(modifier) {
1534
+ visited.add(modifier.name);
1535
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1536
+ requires.forEach(function (dep) {
1537
+ if (!visited.has(dep)) {
1538
+ var depModifier = map.get(dep);
1539
+
1540
+ if (depModifier) {
1541
+ sort(depModifier);
1542
+ }
1543
+ }
1544
+ });
1545
+ result.push(modifier);
1546
+ }
1547
+
1548
+ modifiers.forEach(function (modifier) {
1549
+ if (!visited.has(modifier.name)) {
1550
+ // check for visited object
1551
+ sort(modifier);
1552
+ }
1553
+ });
1554
+ return result;
1555
+ }
1556
+
1557
+ function orderModifiers(modifiers) {
1558
+ // order based on dependencies
1559
+ var orderedModifiers = order(modifiers); // order based on phase
1560
+
1561
+ return modifierPhases.reduce(function (acc, phase) {
1562
+ return acc.concat(orderedModifiers.filter(function (modifier) {
1563
+ return modifier.phase === phase;
1564
+ }));
1565
+ }, []);
1566
+ }
1567
+
1568
+ function debounce(fn) {
1569
+ var pending;
1570
+ return function () {
1571
+ if (!pending) {
1572
+ pending = new Promise(function (resolve) {
1573
+ Promise.resolve().then(function () {
1574
+ pending = undefined;
1575
+ resolve(fn());
1576
+ });
1577
+ });
1578
+ }
1579
+
1580
+ return pending;
1581
+ };
1582
+ }
1583
+
1584
+ function format(str) {
1585
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1586
+ args[_key - 1] = arguments[_key];
1587
+ }
1588
+
1589
+ return [].concat(args).reduce(function (p, c) {
1590
+ return p.replace(/%s/, c);
1591
+ }, str);
1592
+ }
1593
+
1594
+ var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
1595
+ var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
1596
+ var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
1597
+ function validateModifiers(modifiers) {
1598
+ modifiers.forEach(function (modifier) {
1599
+ [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
1600
+ .filter(function (value, index, self) {
1601
+ return self.indexOf(value) === index;
1602
+ }).forEach(function (key) {
1603
+ switch (key) {
1604
+ case 'name':
1605
+ if (typeof modifier.name !== 'string') {
1606
+ console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
1607
+ }
1608
+
1609
+ break;
1610
+
1611
+ case 'enabled':
1612
+ if (typeof modifier.enabled !== 'boolean') {
1613
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
1614
+ }
1615
+
1616
+ break;
1617
+
1618
+ case 'phase':
1619
+ if (modifierPhases.indexOf(modifier.phase) < 0) {
1620
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
1621
+ }
1622
+
1623
+ break;
1624
+
1625
+ case 'fn':
1626
+ if (typeof modifier.fn !== 'function') {
1627
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
1628
+ }
1629
+
1630
+ break;
1631
+
1632
+ case 'effect':
1633
+ if (modifier.effect != null && typeof modifier.effect !== 'function') {
1634
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
1635
+ }
1636
+
1637
+ break;
1638
+
1639
+ case 'requires':
1640
+ if (modifier.requires != null && !Array.isArray(modifier.requires)) {
1641
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
1642
+ }
1643
+
1644
+ break;
1645
+
1646
+ case 'requiresIfExists':
1647
+ if (!Array.isArray(modifier.requiresIfExists)) {
1648
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
1649
+ }
1650
+
1651
+ break;
1652
+
1653
+ case 'options':
1654
+ case 'data':
1655
+ break;
1656
+
1657
+ default:
1658
+ console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
1659
+ return "\"" + s + "\"";
1660
+ }).join(', ') + "; but \"" + key + "\" was provided.");
1661
+ }
1662
+
1663
+ modifier.requires && modifier.requires.forEach(function (requirement) {
1664
+ if (modifiers.find(function (mod) {
1665
+ return mod.name === requirement;
1666
+ }) == null) {
1667
+ console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
1668
+ }
1669
+ });
1670
+ });
1671
+ });
1672
+ }
1673
+
1674
+ function uniqueBy(arr, fn) {
1675
+ var identifiers = new Set();
1676
+ return arr.filter(function (item) {
1677
+ var identifier = fn(item);
1678
+
1679
+ if (!identifiers.has(identifier)) {
1680
+ identifiers.add(identifier);
1681
+ return true;
1682
+ }
1683
+ });
1684
+ }
1685
+
1686
+ function mergeByName(modifiers) {
1687
+ var merged = modifiers.reduce(function (merged, current) {
1688
+ var existing = merged[current.name];
1689
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1690
+ options: Object.assign({}, existing.options, current.options),
1691
+ data: Object.assign({}, existing.data, current.data)
1692
+ }) : current;
1693
+ return merged;
1694
+ }, {}); // IE11 does not support Object.values
1695
+
1696
+ return Object.keys(merged).map(function (key) {
1697
+ return merged[key];
1698
+ });
1699
+ }
1700
+
1701
+ var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
1702
+ 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.';
1703
+ var DEFAULT_OPTIONS = {
1704
+ placement: 'bottom',
1705
+ modifiers: [],
1706
+ strategy: 'absolute'
1707
+ };
1708
+
1709
+ function areValidElements() {
1710
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1711
+ args[_key] = arguments[_key];
1712
+ }
1713
+
1714
+ return !args.some(function (element) {
1715
+ return !(element && typeof element.getBoundingClientRect === 'function');
1716
+ });
1717
+ }
1718
+
1719
+ function popperGenerator(generatorOptions) {
1720
+ if (generatorOptions === void 0) {
1721
+ generatorOptions = {};
1722
+ }
1723
+
1724
+ var _generatorOptions = generatorOptions,
1725
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
1726
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1727
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
1728
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1729
+ return function createPopper(reference, popper, options) {
1730
+ if (options === void 0) {
1731
+ options = defaultOptions;
1732
+ }
1733
+
1734
+ var state = {
1735
+ placement: 'bottom',
1736
+ orderedModifiers: [],
1737
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1738
+ modifiersData: {},
1739
+ elements: {
1740
+ reference: reference,
1741
+ popper: popper
1742
+ },
1743
+ attributes: {},
1744
+ styles: {}
1745
+ };
1746
+ var effectCleanupFns = [];
1747
+ var isDestroyed = false;
1748
+ var instance = {
1749
+ state: state,
1750
+ setOptions: function setOptions(setOptionsAction) {
1751
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1752
+ cleanupModifierEffects();
1753
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1754
+ state.scrollParents = {
1755
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1756
+ popper: listScrollParents(popper)
1757
+ }; // Orders the modifiers based on their dependencies and `phase`
1758
+ // properties
1759
+
1760
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1761
+
1762
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
1763
+ return m.enabled;
1764
+ }); // Validate the provided modifiers so that the consumer will get warned
1765
+ // if one of the modifiers is invalid for any reason
1766
+
1767
+ {
1768
+ var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
1769
+ var name = _ref.name;
1770
+ return name;
1771
+ });
1772
+ validateModifiers(modifiers);
1773
+
1774
+ if (getBasePlacement(state.options.placement) === auto) {
1775
+ var flipModifier = state.orderedModifiers.find(function (_ref2) {
1776
+ var name = _ref2.name;
1777
+ return name === 'flip';
1778
+ });
1779
+
1780
+ if (!flipModifier) {
1781
+ console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
1782
+ }
1783
+ }
1784
+
1785
+ var _getComputedStyle = getComputedStyle(popper),
1786
+ marginTop = _getComputedStyle.marginTop,
1787
+ marginRight = _getComputedStyle.marginRight,
1788
+ marginBottom = _getComputedStyle.marginBottom,
1789
+ marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
1790
+ // cause bugs with positioning, so we'll warn the consumer
1791
+
1792
+
1793
+ if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
1794
+ return parseFloat(margin);
1795
+ })) {
1796
+ 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(' '));
1797
+ }
1798
+ }
1799
+
1800
+ runModifierEffects();
1801
+ return instance.update();
1802
+ },
1803
+ // Sync update – it will always be executed, even if not necessary. This
1804
+ // is useful for low frequency updates where sync behavior simplifies the
1805
+ // logic.
1806
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
1807
+ // prefer the async Popper#update method
1808
+ forceUpdate: function forceUpdate() {
1809
+ if (isDestroyed) {
1810
+ return;
1811
+ }
1812
+
1813
+ var _state$elements = state.elements,
1814
+ reference = _state$elements.reference,
1815
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1816
+ // anymore
1817
+
1818
+ if (!areValidElements(reference, popper)) {
1819
+ {
1820
+ console.error(INVALID_ELEMENT_ERROR);
1821
+ }
1822
+
1823
+ return;
1824
+ } // Store the reference and popper rects to be read by modifiers
1825
+
1826
+
1827
+ state.rects = {
1828
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1829
+ popper: getLayoutRect(popper)
1830
+ }; // Modifiers have the ability to reset the current update cycle. The
1831
+ // most common use case for this is the `flip` modifier changing the
1832
+ // placement, which then needs to re-run all the modifiers, because the
1833
+ // logic was previously ran for the previous placement and is therefore
1834
+ // stale/incorrect
1835
+
1836
+ state.reset = false;
1837
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1838
+ // is filled with the initial data specified by the modifier. This means
1839
+ // it doesn't persist and is fresh on each update.
1840
+ // To ensure persistent data, use `${name}#persistent`
1841
+
1842
+ state.orderedModifiers.forEach(function (modifier) {
1843
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1844
+ });
1845
+ var __debug_loops__ = 0;
1846
+
1847
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
1848
+ {
1849
+ __debug_loops__ += 1;
1850
+
1851
+ if (__debug_loops__ > 100) {
1852
+ console.error(INFINITE_LOOP_ERROR);
1853
+ break;
1854
+ }
1855
+ }
1856
+
1857
+ if (state.reset === true) {
1858
+ state.reset = false;
1859
+ index = -1;
1860
+ continue;
1861
+ }
1862
+
1863
+ var _state$orderedModifie = state.orderedModifiers[index],
1864
+ fn = _state$orderedModifie.fn,
1865
+ _state$orderedModifie2 = _state$orderedModifie.options,
1866
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1867
+ name = _state$orderedModifie.name;
1868
+
1869
+ if (typeof fn === 'function') {
1870
+ state = fn({
1871
+ state: state,
1872
+ options: _options,
1873
+ name: name,
1874
+ instance: instance
1875
+ }) || state;
1876
+ }
1877
+ }
1878
+ },
1879
+ // Async and optimistically optimized update – it will not be executed if
1880
+ // not necessary (debounced to run at most once-per-tick)
1881
+ update: debounce(function () {
1882
+ return new Promise(function (resolve) {
1883
+ instance.forceUpdate();
1884
+ resolve(state);
1885
+ });
1886
+ }),
1887
+ destroy: function destroy() {
1888
+ cleanupModifierEffects();
1889
+ isDestroyed = true;
1890
+ }
1891
+ };
1892
+
1893
+ if (!areValidElements(reference, popper)) {
1894
+ {
1895
+ console.error(INVALID_ELEMENT_ERROR);
1896
+ }
1897
+
1898
+ return instance;
1899
+ }
1900
+
1901
+ instance.setOptions(options).then(function (state) {
1902
+ if (!isDestroyed && options.onFirstUpdate) {
1903
+ options.onFirstUpdate(state);
1904
+ }
1905
+ }); // Modifiers have the ability to execute arbitrary code before the first
1906
+ // update cycle runs. They will be executed in the same order as the update
1907
+ // cycle. This is useful when a modifier adds some persistent data that
1908
+ // other modifiers need to use, but the modifier is run after the dependent
1909
+ // one.
1910
+
1911
+ function runModifierEffects() {
1912
+ state.orderedModifiers.forEach(function (_ref3) {
1913
+ var name = _ref3.name,
1914
+ _ref3$options = _ref3.options,
1915
+ options = _ref3$options === void 0 ? {} : _ref3$options,
1916
+ effect = _ref3.effect;
1917
+
1918
+ if (typeof effect === 'function') {
1919
+ var cleanupFn = effect({
1920
+ state: state,
1921
+ name: name,
1922
+ instance: instance,
1923
+ options: options
1924
+ });
1925
+
1926
+ var noopFn = function noopFn() {};
1927
+
1928
+ effectCleanupFns.push(cleanupFn || noopFn);
1929
+ }
1930
+ });
1931
+ }
1932
+
1933
+ function cleanupModifierEffects() {
1934
+ effectCleanupFns.forEach(function (fn) {
1935
+ return fn();
1936
+ });
1937
+ effectCleanupFns = [];
1938
+ }
1939
+
1940
+ return instance;
1941
+ };
1942
+ }
1943
+
1944
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1945
+ var createPopper = /*#__PURE__*/popperGenerator({
1946
+ defaultModifiers: defaultModifiers
1947
+ }); // eslint-disable-next-line import/no-unused-modules
1948
+
1949
+ /**!
1950
+ * tippy.js v6.3.7
1951
+ * (c) 2017-2021 atomiks
1952
+ * MIT License
1953
+ */
1954
+
1955
+ var ROUND_ARROW = '<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>';
1956
+ var BOX_CLASS = "tippy-box";
1957
+ var CONTENT_CLASS = "tippy-content";
1958
+ var BACKDROP_CLASS = "tippy-backdrop";
1959
+ var ARROW_CLASS = "tippy-arrow";
1960
+ var SVG_ARROW_CLASS = "tippy-svg-arrow";
1961
+ var TOUCH_OPTIONS = {
1962
+ passive: true,
1963
+ capture: true
1964
+ };
1965
+ var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO() {
1966
+ return document.body;
1967
+ };
1968
+
1969
+ function hasOwnProperty(obj, key) {
1970
+ return {}.hasOwnProperty.call(obj, key);
1971
+ }
1972
+ function getValueAtIndexOrReturn(value, index, defaultValue) {
1973
+ if (Array.isArray(value)) {
1974
+ var v = value[index];
1975
+ return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
1976
+ }
1977
+
1978
+ return value;
1979
+ }
1980
+ function isType(value, type) {
1981
+ var str = {}.toString.call(value);
1982
+ return str.indexOf('[object') === 0 && str.indexOf(type + "]") > -1;
1983
+ }
1984
+ function invokeWithArgsOrReturn(value, args) {
1985
+ return typeof value === 'function' ? value.apply(void 0, args) : value;
1986
+ }
1987
+ function debounce$1(fn, ms) {
1988
+ // Avoid wrapping in `setTimeout` if ms is 0 anyway
1989
+ if (ms === 0) {
1990
+ return fn;
1991
+ }
1992
+
1993
+ var timeout;
1994
+ return function (arg) {
1995
+ clearTimeout(timeout);
1996
+ timeout = setTimeout(function () {
1997
+ fn(arg);
1998
+ }, ms);
1999
+ };
2000
+ }
2001
+ function removeProperties(obj, keys) {
2002
+ var clone = Object.assign({}, obj);
2003
+ keys.forEach(function (key) {
2004
+ delete clone[key];
2005
+ });
2006
+ return clone;
2007
+ }
2008
+ function splitBySpaces(value) {
2009
+ return value.split(/\s+/).filter(Boolean);
2010
+ }
2011
+ function normalizeToArray(value) {
2012
+ return [].concat(value);
2013
+ }
2014
+ function pushIfUnique(arr, value) {
2015
+ if (arr.indexOf(value) === -1) {
2016
+ arr.push(value);
2017
+ }
2018
+ }
2019
+ function unique(arr) {
2020
+ return arr.filter(function (item, index) {
2021
+ return arr.indexOf(item) === index;
2022
+ });
2023
+ }
2024
+ function getBasePlacement$1(placement) {
2025
+ return placement.split('-')[0];
2026
+ }
2027
+ function arrayFrom(value) {
2028
+ return [].slice.call(value);
2029
+ }
2030
+ function removeUndefinedProps(obj) {
2031
+ return Object.keys(obj).reduce(function (acc, key) {
2032
+ if (obj[key] !== undefined) {
2033
+ acc[key] = obj[key];
2034
+ }
2035
+
2036
+ return acc;
2037
+ }, {});
2038
+ }
2039
+
2040
+ function div() {
2041
+ return document.createElement('div');
2042
+ }
2043
+ function isElement$1(value) {
2044
+ return ['Element', 'Fragment'].some(function (type) {
2045
+ return isType(value, type);
2046
+ });
2047
+ }
2048
+ function isNodeList(value) {
2049
+ return isType(value, 'NodeList');
2050
+ }
2051
+ function isMouseEvent(value) {
2052
+ return isType(value, 'MouseEvent');
2053
+ }
2054
+ function isReferenceElement(value) {
2055
+ return !!(value && value._tippy && value._tippy.reference === value);
2056
+ }
2057
+ function getArrayOfElements(value) {
2058
+ if (isElement$1(value)) {
2059
+ return [value];
2060
+ }
2061
+
2062
+ if (isNodeList(value)) {
2063
+ return arrayFrom(value);
2064
+ }
2065
+
2066
+ if (Array.isArray(value)) {
2067
+ return value;
2068
+ }
2069
+
2070
+ return arrayFrom(document.querySelectorAll(value));
2071
+ }
2072
+ function setTransitionDuration(els, value) {
2073
+ els.forEach(function (el) {
2074
+ if (el) {
2075
+ el.style.transitionDuration = value + "ms";
2076
+ }
2077
+ });
2078
+ }
2079
+ function setVisibilityState(els, state) {
2080
+ els.forEach(function (el) {
2081
+ if (el) {
2082
+ el.setAttribute('data-state', state);
2083
+ }
2084
+ });
2085
+ }
2086
+ function getOwnerDocument(elementOrElements) {
2087
+ var _element$ownerDocumen;
2088
+
2089
+ var _normalizeToArray = normalizeToArray(elementOrElements),
2090
+ element = _normalizeToArray[0]; // Elements created via a <template> have an ownerDocument with no reference to the body
2091
+
2092
+
2093
+ return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
2094
+ }
2095
+ function isCursorOutsideInteractiveBorder(popperTreeData, event) {
2096
+ var clientX = event.clientX,
2097
+ clientY = event.clientY;
2098
+ return popperTreeData.every(function (_ref) {
2099
+ var popperRect = _ref.popperRect,
2100
+ popperState = _ref.popperState,
2101
+ props = _ref.props;
2102
+ var interactiveBorder = props.interactiveBorder;
2103
+ var basePlacement = getBasePlacement$1(popperState.placement);
2104
+ var offsetData = popperState.modifiersData.offset;
2105
+
2106
+ if (!offsetData) {
2107
+ return true;
2108
+ }
2109
+
2110
+ var topDistance = basePlacement === 'bottom' ? offsetData.top.y : 0;
2111
+ var bottomDistance = basePlacement === 'top' ? offsetData.bottom.y : 0;
2112
+ var leftDistance = basePlacement === 'right' ? offsetData.left.x : 0;
2113
+ var rightDistance = basePlacement === 'left' ? offsetData.right.x : 0;
2114
+ var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
2115
+ var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
2116
+ var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
2117
+ var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
2118
+ return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
2119
+ });
2120
+ }
2121
+ function updateTransitionEndListener(box, action, listener) {
2122
+ var method = action + "EventListener"; // some browsers apparently support `transition` (unprefixed) but only fire
2123
+ // `webkitTransitionEnd`...
2124
+
2125
+ ['transitionend', 'webkitTransitionEnd'].forEach(function (event) {
2126
+ box[method](event, listener);
2127
+ });
2128
+ }
2129
+ /**
2130
+ * Compared to xxx.contains, this function works for dom structures with shadow
2131
+ * dom
2132
+ */
2133
+
2134
+ function actualContains(parent, child) {
2135
+ var target = child;
2136
+
2137
+ while (target) {
2138
+ var _target$getRootNode;
2139
+
2140
+ if (parent.contains(target)) {
2141
+ return true;
2142
+ }
2143
+
2144
+ target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
2145
+ }
2146
+
2147
+ return false;
2148
+ }
2149
+
2150
+ var currentInput = {
2151
+ isTouch: false
2152
+ };
2153
+ var lastMouseMoveTime = 0;
2154
+ /**
2155
+ * When a `touchstart` event is fired, it's assumed the user is using touch
2156
+ * input. We'll bind a `mousemove` event listener to listen for mouse input in
2157
+ * the future. This way, the `isTouch` property is fully dynamic and will handle
2158
+ * hybrid devices that use a mix of touch + mouse input.
2159
+ */
2160
+
2161
+ function onDocumentTouchStart() {
2162
+ if (currentInput.isTouch) {
2163
+ return;
2164
+ }
2165
+
2166
+ currentInput.isTouch = true;
2167
+
2168
+ if (window.performance) {
2169
+ document.addEventListener('mousemove', onDocumentMouseMove);
2170
+ }
2171
+ }
2172
+ /**
2173
+ * When two `mousemove` event are fired consecutively within 20ms, it's assumed
2174
+ * the user is using mouse input again. `mousemove` can fire on touch devices as
2175
+ * well, but very rarely that quickly.
2176
+ */
2177
+
2178
+ function onDocumentMouseMove() {
2179
+ var now = performance.now();
2180
+
2181
+ if (now - lastMouseMoveTime < 20) {
2182
+ currentInput.isTouch = false;
2183
+ document.removeEventListener('mousemove', onDocumentMouseMove);
2184
+ }
2185
+
2186
+ lastMouseMoveTime = now;
2187
+ }
2188
+ /**
2189
+ * When an element is in focus and has a tippy, leaving the tab/window and
2190
+ * returning causes it to show again. For mouse users this is unexpected, but
2191
+ * for keyboard use it makes sense.
2192
+ * TODO: find a better technique to solve this problem
2193
+ */
2194
+
2195
+ function onWindowBlur() {
2196
+ var activeElement = document.activeElement;
2197
+
2198
+ if (isReferenceElement(activeElement)) {
2199
+ var instance = activeElement._tippy;
2200
+
2201
+ if (activeElement.blur && !instance.state.isVisible) {
2202
+ activeElement.blur();
2203
+ }
2204
+ }
2205
+ }
2206
+ function bindGlobalEventListeners() {
2207
+ document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);
2208
+ window.addEventListener('blur', onWindowBlur);
2209
+ }
2210
+
2211
+ var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
2212
+ var isIE11 = isBrowser ? // @ts-ignore
2213
+ !!window.msCrypto : false;
2214
+
2215
+ function createMemoryLeakWarning(method) {
2216
+ var txt = method === 'destroy' ? 'n already-' : ' ';
2217
+ return [method + "() was called on a" + txt + "destroyed instance. This is a no-op but", 'indicates a potential memory leak.'].join(' ');
2218
+ }
2219
+ function clean(value) {
2220
+ var spacesAndTabs = /[ \t]{2,}/g;
2221
+ var lineStartWithSpaces = /^[ \t]*/gm;
2222
+ return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
2223
+ }
2224
+
2225
+ function getDevMessage(message) {
2226
+ return clean("\n %ctippy.js\n\n %c" + clean(message) + "\n\n %c\uD83D\uDC77\u200D This is a development-only message. It will be removed in production.\n ");
2227
+ }
2228
+
2229
+ function getFormattedMessage(message) {
2230
+ return [getDevMessage(message), // title
2231
+ 'color: #00C584; font-size: 1.3em; font-weight: bold;', // message
2232
+ 'line-height: 1.5', // footer
2233
+ 'color: #a6a095;'];
2234
+ } // Assume warnings and errors never have the same message
2235
+
2236
+ var visitedMessages;
2237
+
2238
+ {
2239
+ resetVisitedMessages();
2240
+ }
2241
+
2242
+ function resetVisitedMessages() {
2243
+ visitedMessages = new Set();
2244
+ }
2245
+ function warnWhen(condition, message) {
2246
+ if (condition && !visitedMessages.has(message)) {
2247
+ var _console;
2248
+
2249
+ visitedMessages.add(message);
2250
+
2251
+ (_console = console).warn.apply(_console, getFormattedMessage(message));
2252
+ }
2253
+ }
2254
+ function errorWhen(condition, message) {
2255
+ if (condition && !visitedMessages.has(message)) {
2256
+ var _console2;
2257
+
2258
+ visitedMessages.add(message);
2259
+
2260
+ (_console2 = console).error.apply(_console2, getFormattedMessage(message));
2261
+ }
2262
+ }
2263
+ function validateTargets(targets) {
2264
+ var didPassFalsyValue = !targets;
2265
+ var didPassPlainObject = Object.prototype.toString.call(targets) === '[object Object]' && !targets.addEventListener;
2266
+ errorWhen(didPassFalsyValue, ['tippy() was passed', '`' + String(targets) + '`', 'as its targets (first) argument. Valid types are: String, Element,', 'Element[], or NodeList.'].join(' '));
2267
+ errorWhen(didPassPlainObject, ['tippy() was passed a plain object which is not supported as an argument', 'for virtual positioning. Use props.getReferenceClientRect instead.'].join(' '));
2268
+ }
2269
+
2270
+ var pluginProps = {
2271
+ animateFill: false,
2272
+ followCursor: false,
2273
+ inlinePositioning: false,
2274
+ sticky: false
2275
+ };
2276
+ var renderProps = {
2277
+ allowHTML: false,
2278
+ animation: 'fade',
2279
+ arrow: true,
2280
+ content: '',
2281
+ inertia: false,
2282
+ maxWidth: 350,
2283
+ role: 'tooltip',
2284
+ theme: '',
2285
+ zIndex: 9999
2286
+ };
2287
+ var defaultProps = Object.assign({
2288
+ appendTo: TIPPY_DEFAULT_APPEND_TO,
2289
+ aria: {
2290
+ content: 'auto',
2291
+ expanded: 'auto'
2292
+ },
2293
+ delay: 0,
2294
+ duration: [300, 250],
2295
+ getReferenceClientRect: null,
2296
+ hideOnClick: true,
2297
+ ignoreAttributes: false,
2298
+ interactive: false,
2299
+ interactiveBorder: 2,
2300
+ interactiveDebounce: 0,
2301
+ moveTransition: '',
2302
+ offset: [0, 10],
2303
+ onAfterUpdate: function onAfterUpdate() {},
2304
+ onBeforeUpdate: function onBeforeUpdate() {},
2305
+ onCreate: function onCreate() {},
2306
+ onDestroy: function onDestroy() {},
2307
+ onHidden: function onHidden() {},
2308
+ onHide: function onHide() {},
2309
+ onMount: function onMount() {},
2310
+ onShow: function onShow() {},
2311
+ onShown: function onShown() {},
2312
+ onTrigger: function onTrigger() {},
2313
+ onUntrigger: function onUntrigger() {},
2314
+ onClickOutside: function onClickOutside() {},
2315
+ placement: 'top',
2316
+ plugins: [],
2317
+ popperOptions: {},
2318
+ render: null,
2319
+ showOnCreate: false,
2320
+ touch: true,
2321
+ trigger: 'mouseenter focus',
2322
+ triggerTarget: null
2323
+ }, pluginProps, renderProps);
2324
+ var defaultKeys = Object.keys(defaultProps);
2325
+ var setDefaultProps = function setDefaultProps(partialProps) {
2326
+ /* istanbul ignore else */
2327
+ {
2328
+ validateProps(partialProps, []);
2329
+ }
2330
+
2331
+ var keys = Object.keys(partialProps);
2332
+ keys.forEach(function (key) {
2333
+ defaultProps[key] = partialProps[key];
2334
+ });
2335
+ };
2336
+ function getExtendedPassedProps(passedProps) {
2337
+ var plugins = passedProps.plugins || [];
2338
+ var pluginProps = plugins.reduce(function (acc, plugin) {
2339
+ var name = plugin.name,
2340
+ defaultValue = plugin.defaultValue;
2341
+
2342
+ if (name) {
2343
+ var _name;
2344
+
2345
+ acc[name] = passedProps[name] !== undefined ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
2346
+ }
2347
+
2348
+ return acc;
2349
+ }, {});
2350
+ return Object.assign({}, passedProps, pluginProps);
2351
+ }
2352
+ function getDataAttributeProps(reference, plugins) {
2353
+ var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
2354
+ plugins: plugins
2355
+ }))) : defaultKeys;
2356
+ var props = propKeys.reduce(function (acc, key) {
2357
+ var valueAsString = (reference.getAttribute("data-tippy-" + key) || '').trim();
2358
+
2359
+ if (!valueAsString) {
2360
+ return acc;
2361
+ }
2362
+
2363
+ if (key === 'content') {
2364
+ acc[key] = valueAsString;
2365
+ } else {
2366
+ try {
2367
+ acc[key] = JSON.parse(valueAsString);
2368
+ } catch (e) {
2369
+ acc[key] = valueAsString;
2370
+ }
2371
+ }
2372
+
2373
+ return acc;
2374
+ }, {});
2375
+ return props;
2376
+ }
2377
+ function evaluateProps(reference, props) {
2378
+ var out = Object.assign({}, props, {
2379
+ content: invokeWithArgsOrReturn(props.content, [reference])
2380
+ }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));
2381
+ out.aria = Object.assign({}, defaultProps.aria, out.aria);
2382
+ out.aria = {
2383
+ expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,
2384
+ content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content
2385
+ };
2386
+ return out;
2387
+ }
2388
+ function validateProps(partialProps, plugins) {
2389
+ if (partialProps === void 0) {
2390
+ partialProps = {};
2391
+ }
2392
+
2393
+ if (plugins === void 0) {
2394
+ plugins = [];
2395
+ }
2396
+
2397
+ var keys = Object.keys(partialProps);
2398
+ keys.forEach(function (prop) {
2399
+ var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps));
2400
+ var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); // Check if the prop exists in `plugins`
2401
+
2402
+ if (didPassUnknownProp) {
2403
+ didPassUnknownProp = plugins.filter(function (plugin) {
2404
+ return plugin.name === prop;
2405
+ }).length === 0;
2406
+ }
2407
+
2408
+ warnWhen(didPassUnknownProp, ["`" + prop + "`", "is not a valid prop. You may have spelled it incorrectly, or if it's", 'a plugin, forgot to pass it in an array as props.plugins.', '\n\n', 'All props: https://atomiks.github.io/tippyjs/v6/all-props/\n', 'Plugins: https://atomiks.github.io/tippyjs/v6/plugins/'].join(' '));
2409
+ });
2410
+ }
2411
+
2412
+ var innerHTML = function innerHTML() {
2413
+ return 'innerHTML';
2414
+ };
2415
+
2416
+ function dangerouslySetInnerHTML(element, html) {
2417
+ element[innerHTML()] = html;
2418
+ }
2419
+
2420
+ function createArrowElement(value) {
2421
+ var arrow = div();
2422
+
2423
+ if (value === true) {
2424
+ arrow.className = ARROW_CLASS;
2425
+ } else {
2426
+ arrow.className = SVG_ARROW_CLASS;
2427
+
2428
+ if (isElement$1(value)) {
2429
+ arrow.appendChild(value);
2430
+ } else {
2431
+ dangerouslySetInnerHTML(arrow, value);
2432
+ }
2433
+ }
2434
+
2435
+ return arrow;
2436
+ }
2437
+
2438
+ function setContent(content, props) {
2439
+ if (isElement$1(props.content)) {
2440
+ dangerouslySetInnerHTML(content, '');
2441
+ content.appendChild(props.content);
2442
+ } else if (typeof props.content !== 'function') {
2443
+ if (props.allowHTML) {
2444
+ dangerouslySetInnerHTML(content, props.content);
2445
+ } else {
2446
+ content.textContent = props.content;
2447
+ }
2448
+ }
2449
+ }
2450
+ function getChildren(popper) {
2451
+ var box = popper.firstElementChild;
2452
+ var boxChildren = arrayFrom(box.children);
2453
+ return {
2454
+ box: box,
2455
+ content: boxChildren.find(function (node) {
2456
+ return node.classList.contains(CONTENT_CLASS);
2457
+ }),
2458
+ arrow: boxChildren.find(function (node) {
2459
+ return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
2460
+ }),
2461
+ backdrop: boxChildren.find(function (node) {
2462
+ return node.classList.contains(BACKDROP_CLASS);
2463
+ })
2464
+ };
2465
+ }
2466
+ function render(instance) {
2467
+ var popper = div();
2468
+ var box = div();
2469
+ box.className = BOX_CLASS;
2470
+ box.setAttribute('data-state', 'hidden');
2471
+ box.setAttribute('tabindex', '-1');
2472
+ var content = div();
2473
+ content.className = CONTENT_CLASS;
2474
+ content.setAttribute('data-state', 'hidden');
2475
+ setContent(content, instance.props);
2476
+ popper.appendChild(box);
2477
+ box.appendChild(content);
2478
+ onUpdate(instance.props, instance.props);
2479
+
2480
+ function onUpdate(prevProps, nextProps) {
2481
+ var _getChildren = getChildren(popper),
2482
+ box = _getChildren.box,
2483
+ content = _getChildren.content,
2484
+ arrow = _getChildren.arrow;
2485
+
2486
+ if (nextProps.theme) {
2487
+ box.setAttribute('data-theme', nextProps.theme);
2488
+ } else {
2489
+ box.removeAttribute('data-theme');
2490
+ }
2491
+
2492
+ if (typeof nextProps.animation === 'string') {
2493
+ box.setAttribute('data-animation', nextProps.animation);
2494
+ } else {
2495
+ box.removeAttribute('data-animation');
2496
+ }
2497
+
2498
+ if (nextProps.inertia) {
2499
+ box.setAttribute('data-inertia', '');
2500
+ } else {
2501
+ box.removeAttribute('data-inertia');
2502
+ }
2503
+
2504
+ box.style.maxWidth = typeof nextProps.maxWidth === 'number' ? nextProps.maxWidth + "px" : nextProps.maxWidth;
2505
+
2506
+ if (nextProps.role) {
2507
+ box.setAttribute('role', nextProps.role);
2508
+ } else {
2509
+ box.removeAttribute('role');
2510
+ }
2511
+
2512
+ if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
2513
+ setContent(content, instance.props);
2514
+ }
2515
+
2516
+ if (nextProps.arrow) {
2517
+ if (!arrow) {
2518
+ box.appendChild(createArrowElement(nextProps.arrow));
2519
+ } else if (prevProps.arrow !== nextProps.arrow) {
2520
+ box.removeChild(arrow);
2521
+ box.appendChild(createArrowElement(nextProps.arrow));
2522
+ }
2523
+ } else if (arrow) {
2524
+ box.removeChild(arrow);
2525
+ }
2526
+ }
2527
+
2528
+ return {
2529
+ popper: popper,
2530
+ onUpdate: onUpdate
2531
+ };
2532
+ } // Runtime check to identify if the render function is the default one; this
2533
+ // way we can apply default CSS transitions logic and it can be tree-shaken away
2534
+
2535
+ render.$$tippy = true;
2536
+
2537
+ var idCounter = 1;
2538
+ var mouseMoveListeners = []; // Used by `hideAll()`
2539
+
2540
+ var mountedInstances = [];
2541
+ function createTippy(reference, passedProps) {
2542
+ var props = evaluateProps(reference, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
2543
+ // 🔒 Private members
2544
+ // ===========================================================================
2545
+
2546
+ var showTimeout;
2547
+ var hideTimeout;
2548
+ var scheduleHideAnimationFrame;
2549
+ var isVisibleFromClick = false;
2550
+ var didHideDueToDocumentMouseDown = false;
2551
+ var didTouchMove = false;
2552
+ var ignoreOnFirstUpdate = false;
2553
+ var lastTriggerEvent;
2554
+ var currentTransitionEndListener;
2555
+ var onFirstUpdate;
2556
+ var listeners = [];
2557
+ var debouncedOnMouseMove = debounce$1(onMouseMove, props.interactiveDebounce);
2558
+ var currentTarget; // ===========================================================================
2559
+ // 🔑 Public members
2560
+ // ===========================================================================
2561
+
2562
+ var id = idCounter++;
2563
+ var popperInstance = null;
2564
+ var plugins = unique(props.plugins);
2565
+ var state = {
2566
+ // Is the instance currently enabled?
2567
+ isEnabled: true,
2568
+ // Is the tippy currently showing and not transitioning out?
2569
+ isVisible: false,
2570
+ // Has the instance been destroyed?
2571
+ isDestroyed: false,
2572
+ // Is the tippy currently mounted to the DOM?
2573
+ isMounted: false,
2574
+ // Has the tippy finished transitioning in?
2575
+ isShown: false
2576
+ };
2577
+ var instance = {
2578
+ // properties
2579
+ id: id,
2580
+ reference: reference,
2581
+ popper: div(),
2582
+ popperInstance: popperInstance,
2583
+ props: props,
2584
+ state: state,
2585
+ plugins: plugins,
2586
+ // methods
2587
+ clearDelayTimeouts: clearDelayTimeouts,
2588
+ setProps: setProps,
2589
+ setContent: setContent,
2590
+ show: show,
2591
+ hide: hide,
2592
+ hideWithInteractivity: hideWithInteractivity,
2593
+ enable: enable,
2594
+ disable: disable,
2595
+ unmount: unmount,
2596
+ destroy: destroy
2597
+ }; // TODO: Investigate why this early return causes a TDZ error in the tests —
2598
+ // it doesn't seem to happen in the browser
2599
+
2600
+ /* istanbul ignore if */
2601
+
2602
+ if (!props.render) {
2603
+ {
2604
+ errorWhen(true, 'render() function has not been supplied.');
2605
+ }
2606
+
2607
+ return instance;
2608
+ } // ===========================================================================
2609
+ // Initial mutations
2610
+ // ===========================================================================
2611
+
2612
+
2613
+ var _props$render = props.render(instance),
2614
+ popper = _props$render.popper,
2615
+ onUpdate = _props$render.onUpdate;
2616
+
2617
+ popper.setAttribute('data-tippy-root', '');
2618
+ popper.id = "tippy-" + instance.id;
2619
+ instance.popper = popper;
2620
+ reference._tippy = instance;
2621
+ popper._tippy = instance;
2622
+ var pluginsHooks = plugins.map(function (plugin) {
2623
+ return plugin.fn(instance);
2624
+ });
2625
+ var hasAriaExpanded = reference.hasAttribute('aria-expanded');
2626
+ addListeners();
2627
+ handleAriaExpandedAttribute();
2628
+ handleStyles();
2629
+ invokeHook('onCreate', [instance]);
2630
+
2631
+ if (props.showOnCreate) {
2632
+ scheduleShow();
2633
+ } // Prevent a tippy with a delay from hiding if the cursor left then returned
2634
+ // before it started hiding
2635
+
2636
+
2637
+ popper.addEventListener('mouseenter', function () {
2638
+ if (instance.props.interactive && instance.state.isVisible) {
2639
+ instance.clearDelayTimeouts();
2640
+ }
2641
+ });
2642
+ popper.addEventListener('mouseleave', function () {
2643
+ if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {
2644
+ getDocument().addEventListener('mousemove', debouncedOnMouseMove);
2645
+ }
2646
+ });
2647
+ return instance; // ===========================================================================
2648
+ // 🔒 Private methods
2649
+ // ===========================================================================
2650
+
2651
+ function getNormalizedTouchSettings() {
2652
+ var touch = instance.props.touch;
2653
+ return Array.isArray(touch) ? touch : [touch, 0];
2654
+ }
2655
+
2656
+ function getIsCustomTouchBehavior() {
2657
+ return getNormalizedTouchSettings()[0] === 'hold';
2658
+ }
2659
+
2660
+ function getIsDefaultRenderFn() {
2661
+ var _instance$props$rende;
2662
+
2663
+ // @ts-ignore
2664
+ return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
2665
+ }
2666
+
2667
+ function getCurrentTarget() {
2668
+ return currentTarget || reference;
2669
+ }
2670
+
2671
+ function getDocument() {
2672
+ var parent = getCurrentTarget().parentNode;
2673
+ return parent ? getOwnerDocument(parent) : document;
2674
+ }
2675
+
2676
+ function getDefaultTemplateChildren() {
2677
+ return getChildren(popper);
2678
+ }
2679
+
2680
+ function getDelay(isShow) {
2681
+ // For touch or keyboard input, force `0` delay for UX reasons
2682
+ // Also if the instance is mounted but not visible (transitioning out),
2683
+ // ignore delay
2684
+ if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === 'focus') {
2685
+ return 0;
2686
+ }
2687
+
2688
+ return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
2689
+ }
2690
+
2691
+ function handleStyles(fromHide) {
2692
+ if (fromHide === void 0) {
2693
+ fromHide = false;
2694
+ }
2695
+
2696
+ popper.style.pointerEvents = instance.props.interactive && !fromHide ? '' : 'none';
2697
+ popper.style.zIndex = "" + instance.props.zIndex;
2698
+ }
2699
+
2700
+ function invokeHook(hook, args, shouldInvokePropsHook) {
2701
+ if (shouldInvokePropsHook === void 0) {
2702
+ shouldInvokePropsHook = true;
2703
+ }
2704
+
2705
+ pluginsHooks.forEach(function (pluginHooks) {
2706
+ if (pluginHooks[hook]) {
2707
+ pluginHooks[hook].apply(pluginHooks, args);
2708
+ }
2709
+ });
2710
+
2711
+ if (shouldInvokePropsHook) {
2712
+ var _instance$props;
2713
+
2714
+ (_instance$props = instance.props)[hook].apply(_instance$props, args);
2715
+ }
2716
+ }
2717
+
2718
+ function handleAriaContentAttribute() {
2719
+ var aria = instance.props.aria;
2720
+
2721
+ if (!aria.content) {
2722
+ return;
2723
+ }
2724
+
2725
+ var attr = "aria-" + aria.content;
2726
+ var id = popper.id;
2727
+ var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2728
+ nodes.forEach(function (node) {
2729
+ var currentValue = node.getAttribute(attr);
2730
+
2731
+ if (instance.state.isVisible) {
2732
+ node.setAttribute(attr, currentValue ? currentValue + " " + id : id);
2733
+ } else {
2734
+ var nextValue = currentValue && currentValue.replace(id, '').trim();
2735
+
2736
+ if (nextValue) {
2737
+ node.setAttribute(attr, nextValue);
2738
+ } else {
2739
+ node.removeAttribute(attr);
2740
+ }
2741
+ }
2742
+ });
2743
+ }
2744
+
2745
+ function handleAriaExpandedAttribute() {
2746
+ if (hasAriaExpanded || !instance.props.aria.expanded) {
2747
+ return;
2748
+ }
2749
+
2750
+ var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2751
+ nodes.forEach(function (node) {
2752
+ if (instance.props.interactive) {
2753
+ node.setAttribute('aria-expanded', instance.state.isVisible && node === getCurrentTarget() ? 'true' : 'false');
2754
+ } else {
2755
+ node.removeAttribute('aria-expanded');
2756
+ }
2757
+ });
2758
+ }
2759
+
2760
+ function cleanupInteractiveMouseListeners() {
2761
+ getDocument().removeEventListener('mousemove', debouncedOnMouseMove);
2762
+ mouseMoveListeners = mouseMoveListeners.filter(function (listener) {
2763
+ return listener !== debouncedOnMouseMove;
2764
+ });
2765
+ }
2766
+
2767
+ function onDocumentPress(event) {
2768
+ // Moved finger to scroll instead of an intentional tap outside
2769
+ if (currentInput.isTouch) {
2770
+ if (didTouchMove || event.type === 'mousedown') {
2771
+ return;
2772
+ }
2773
+ }
2774
+
2775
+ var actualTarget = event.composedPath && event.composedPath()[0] || event.target; // Clicked on interactive popper
2776
+
2777
+ if (instance.props.interactive && actualContains(popper, actualTarget)) {
2778
+ return;
2779
+ } // Clicked on the event listeners target
2780
+
2781
+
2782
+ if (normalizeToArray(instance.props.triggerTarget || reference).some(function (el) {
2783
+ return actualContains(el, actualTarget);
2784
+ })) {
2785
+ if (currentInput.isTouch) {
2786
+ return;
2787
+ }
2788
+
2789
+ if (instance.state.isVisible && instance.props.trigger.indexOf('click') >= 0) {
2790
+ return;
2791
+ }
2792
+ } else {
2793
+ invokeHook('onClickOutside', [instance, event]);
2794
+ }
2795
+
2796
+ if (instance.props.hideOnClick === true) {
2797
+ instance.clearDelayTimeouts();
2798
+ instance.hide(); // `mousedown` event is fired right before `focus` if pressing the
2799
+ // currentTarget. This lets a tippy with `focus` trigger know that it
2800
+ // should not show
2801
+
2802
+ didHideDueToDocumentMouseDown = true;
2803
+ setTimeout(function () {
2804
+ didHideDueToDocumentMouseDown = false;
2805
+ }); // The listener gets added in `scheduleShow()`, but this may be hiding it
2806
+ // before it shows, and hide()'s early bail-out behavior can prevent it
2807
+ // from being cleaned up
2808
+
2809
+ if (!instance.state.isMounted) {
2810
+ removeDocumentPress();
2811
+ }
2812
+ }
2813
+ }
2814
+
2815
+ function onTouchMove() {
2816
+ didTouchMove = true;
2817
+ }
2818
+
2819
+ function onTouchStart() {
2820
+ didTouchMove = false;
2821
+ }
2822
+
2823
+ function addDocumentPress() {
2824
+ var doc = getDocument();
2825
+ doc.addEventListener('mousedown', onDocumentPress, true);
2826
+ doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
2827
+ doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
2828
+ doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
2829
+ }
2830
+
2831
+ function removeDocumentPress() {
2832
+ var doc = getDocument();
2833
+ doc.removeEventListener('mousedown', onDocumentPress, true);
2834
+ doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
2835
+ doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
2836
+ doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
2837
+ }
2838
+
2839
+ function onTransitionedOut(duration, callback) {
2840
+ onTransitionEnd(duration, function () {
2841
+ if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {
2842
+ callback();
2843
+ }
2844
+ });
2845
+ }
2846
+
2847
+ function onTransitionedIn(duration, callback) {
2848
+ onTransitionEnd(duration, callback);
2849
+ }
2850
+
2851
+ function onTransitionEnd(duration, callback) {
2852
+ var box = getDefaultTemplateChildren().box;
2853
+
2854
+ function listener(event) {
2855
+ if (event.target === box) {
2856
+ updateTransitionEndListener(box, 'remove', listener);
2857
+ callback();
2858
+ }
2859
+ } // Make callback synchronous if duration is 0
2860
+ // `transitionend` won't fire otherwise
2861
+
2862
+
2863
+ if (duration === 0) {
2864
+ return callback();
2865
+ }
2866
+
2867
+ updateTransitionEndListener(box, 'remove', currentTransitionEndListener);
2868
+ updateTransitionEndListener(box, 'add', listener);
2869
+ currentTransitionEndListener = listener;
2870
+ }
2871
+
2872
+ function on(eventType, handler, options) {
2873
+ if (options === void 0) {
2874
+ options = false;
2875
+ }
2876
+
2877
+ var nodes = normalizeToArray(instance.props.triggerTarget || reference);
2878
+ nodes.forEach(function (node) {
2879
+ node.addEventListener(eventType, handler, options);
2880
+ listeners.push({
2881
+ node: node,
2882
+ eventType: eventType,
2883
+ handler: handler,
2884
+ options: options
2885
+ });
2886
+ });
2887
+ }
2888
+
2889
+ function addListeners() {
2890
+ if (getIsCustomTouchBehavior()) {
2891
+ on('touchstart', onTrigger, {
2892
+ passive: true
2893
+ });
2894
+ on('touchend', onMouseLeave, {
2895
+ passive: true
2896
+ });
2897
+ }
2898
+
2899
+ splitBySpaces(instance.props.trigger).forEach(function (eventType) {
2900
+ if (eventType === 'manual') {
2901
+ return;
2902
+ }
2903
+
2904
+ on(eventType, onTrigger);
2905
+
2906
+ switch (eventType) {
2907
+ case 'mouseenter':
2908
+ on('mouseleave', onMouseLeave);
2909
+ break;
2910
+
2911
+ case 'focus':
2912
+ on(isIE11 ? 'focusout' : 'blur', onBlurOrFocusOut);
2913
+ break;
2914
+
2915
+ case 'focusin':
2916
+ on('focusout', onBlurOrFocusOut);
2917
+ break;
2918
+ }
2919
+ });
2920
+ }
2921
+
2922
+ function removeListeners() {
2923
+ listeners.forEach(function (_ref) {
2924
+ var node = _ref.node,
2925
+ eventType = _ref.eventType,
2926
+ handler = _ref.handler,
2927
+ options = _ref.options;
2928
+ node.removeEventListener(eventType, handler, options);
2929
+ });
2930
+ listeners = [];
2931
+ }
2932
+
2933
+ function onTrigger(event) {
2934
+ var _lastTriggerEvent;
2935
+
2936
+ var shouldScheduleClickHide = false;
2937
+
2938
+ if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
2939
+ return;
2940
+ }
2941
+
2942
+ var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === 'focus';
2943
+ lastTriggerEvent = event;
2944
+ currentTarget = event.currentTarget;
2945
+ handleAriaExpandedAttribute();
2946
+
2947
+ if (!instance.state.isVisible && isMouseEvent(event)) {
2948
+ // If scrolling, `mouseenter` events can be fired if the cursor lands
2949
+ // over a new target, but `mousemove` events don't get fired. This
2950
+ // causes interactive tooltips to get stuck open until the cursor is
2951
+ // moved
2952
+ mouseMoveListeners.forEach(function (listener) {
2953
+ return listener(event);
2954
+ });
2955
+ } // Toggle show/hide when clicking click-triggered tooltips
2956
+
2957
+
2958
+ if (event.type === 'click' && (instance.props.trigger.indexOf('mouseenter') < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
2959
+ shouldScheduleClickHide = true;
2960
+ } else {
2961
+ scheduleShow(event);
2962
+ }
2963
+
2964
+ if (event.type === 'click') {
2965
+ isVisibleFromClick = !shouldScheduleClickHide;
2966
+ }
2967
+
2968
+ if (shouldScheduleClickHide && !wasFocused) {
2969
+ scheduleHide(event);
2970
+ }
2971
+ }
2972
+
2973
+ function onMouseMove(event) {
2974
+ var target = event.target;
2975
+ var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target);
2976
+
2977
+ if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {
2978
+ return;
2979
+ }
2980
+
2981
+ var popperTreeData = getNestedPopperTree().concat(popper).map(function (popper) {
2982
+ var _instance$popperInsta;
2983
+
2984
+ var instance = popper._tippy;
2985
+ var state = (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.state;
2986
+
2987
+ if (state) {
2988
+ return {
2989
+ popperRect: popper.getBoundingClientRect(),
2990
+ popperState: state,
2991
+ props: props
2992
+ };
2993
+ }
2994
+
2995
+ return null;
2996
+ }).filter(Boolean);
2997
+
2998
+ if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
2999
+ cleanupInteractiveMouseListeners();
3000
+ scheduleHide(event);
3001
+ }
3002
+ }
3003
+
3004
+ function onMouseLeave(event) {
3005
+ var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick;
3006
+
3007
+ if (shouldBail) {
3008
+ return;
3009
+ }
3010
+
3011
+ if (instance.props.interactive) {
3012
+ instance.hideWithInteractivity(event);
3013
+ return;
3014
+ }
3015
+
3016
+ scheduleHide(event);
3017
+ }
3018
+
3019
+ function onBlurOrFocusOut(event) {
3020
+ if (instance.props.trigger.indexOf('focusin') < 0 && event.target !== getCurrentTarget()) {
3021
+ return;
3022
+ } // If focus was moved to within the popper
3023
+
3024
+
3025
+ if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {
3026
+ return;
3027
+ }
3028
+
3029
+ scheduleHide(event);
3030
+ }
3031
+
3032
+ function isEventListenerStopped(event) {
3033
+ return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0 : false;
3034
+ }
3035
+
3036
+ function createPopperInstance() {
3037
+ destroyPopperInstance();
3038
+ var _instance$props2 = instance.props,
3039
+ popperOptions = _instance$props2.popperOptions,
3040
+ placement = _instance$props2.placement,
3041
+ offset = _instance$props2.offset,
3042
+ getReferenceClientRect = _instance$props2.getReferenceClientRect,
3043
+ moveTransition = _instance$props2.moveTransition;
3044
+ var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;
3045
+ var computedReference = getReferenceClientRect ? {
3046
+ getBoundingClientRect: getReferenceClientRect,
3047
+ contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
3048
+ } : reference;
3049
+ var tippyModifier = {
3050
+ name: '$$tippy',
3051
+ enabled: true,
3052
+ phase: 'beforeWrite',
3053
+ requires: ['computeStyles'],
3054
+ fn: function fn(_ref2) {
3055
+ var state = _ref2.state;
3056
+
3057
+ if (getIsDefaultRenderFn()) {
3058
+ var _getDefaultTemplateCh = getDefaultTemplateChildren(),
3059
+ box = _getDefaultTemplateCh.box;
3060
+
3061
+ ['placement', 'reference-hidden', 'escaped'].forEach(function (attr) {
3062
+ if (attr === 'placement') {
3063
+ box.setAttribute('data-placement', state.placement);
3064
+ } else {
3065
+ if (state.attributes.popper["data-popper-" + attr]) {
3066
+ box.setAttribute("data-" + attr, '');
3067
+ } else {
3068
+ box.removeAttribute("data-" + attr);
3069
+ }
3070
+ }
3071
+ });
3072
+ state.attributes.popper = {};
3073
+ }
3074
+ }
3075
+ };
3076
+ var modifiers = [{
3077
+ name: 'offset',
3078
+ options: {
3079
+ offset: offset
3080
+ }
3081
+ }, {
3082
+ name: 'preventOverflow',
3083
+ options: {
3084
+ padding: {
3085
+ top: 2,
3086
+ bottom: 2,
3087
+ left: 5,
3088
+ right: 5
3089
+ }
3090
+ }
3091
+ }, {
3092
+ name: 'flip',
3093
+ options: {
3094
+ padding: 5
3095
+ }
3096
+ }, {
3097
+ name: 'computeStyles',
3098
+ options: {
3099
+ adaptive: !moveTransition
3100
+ }
3101
+ }, tippyModifier];
3102
+
3103
+ if (getIsDefaultRenderFn() && arrow) {
3104
+ modifiers.push({
3105
+ name: 'arrow',
3106
+ options: {
3107
+ element: arrow,
3108
+ padding: 3
3109
+ }
3110
+ });
3111
+ }
3112
+
3113
+ modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
3114
+ instance.popperInstance = createPopper(computedReference, popper, Object.assign({}, popperOptions, {
3115
+ placement: placement,
3116
+ onFirstUpdate: onFirstUpdate,
3117
+ modifiers: modifiers
3118
+ }));
3119
+ }
3120
+
3121
+ function destroyPopperInstance() {
3122
+ if (instance.popperInstance) {
3123
+ instance.popperInstance.destroy();
3124
+ instance.popperInstance = null;
3125
+ }
3126
+ }
3127
+
3128
+ function mount() {
3129
+ var appendTo = instance.props.appendTo;
3130
+ var parentNode; // By default, we'll append the popper to the triggerTargets's parentNode so
3131
+ // it's directly after the reference element so the elements inside the
3132
+ // tippy can be tabbed to
3133
+ // If there are clipping issues, the user can specify a different appendTo
3134
+ // and ensure focus management is handled correctly manually
3135
+
3136
+ var node = getCurrentTarget();
3137
+
3138
+ if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === 'parent') {
3139
+ parentNode = node.parentNode;
3140
+ } else {
3141
+ parentNode = invokeWithArgsOrReturn(appendTo, [node]);
3142
+ } // The popper element needs to exist on the DOM before its position can be
3143
+ // updated as Popper needs to read its dimensions
3144
+
3145
+
3146
+ if (!parentNode.contains(popper)) {
3147
+ parentNode.appendChild(popper);
3148
+ }
3149
+
3150
+ instance.state.isMounted = true;
3151
+ createPopperInstance();
3152
+ /* istanbul ignore else */
3153
+
3154
+ {
3155
+ // Accessibility check
3156
+ warnWhen(instance.props.interactive && appendTo === defaultProps.appendTo && node.nextElementSibling !== popper, ['Interactive tippy element may not be accessible via keyboard', 'navigation because it is not directly after the reference element', 'in the DOM source order.', '\n\n', 'Using a wrapper <div> or <span> tag around the reference element', 'solves this by creating a new parentNode context.', '\n\n', 'Specifying `appendTo: document.body` silences this warning, but it', 'assumes you are using a focus management solution to handle', 'keyboard navigation.', '\n\n', 'See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity'].join(' '));
3157
+ }
3158
+ }
3159
+
3160
+ function getNestedPopperTree() {
3161
+ return arrayFrom(popper.querySelectorAll('[data-tippy-root]'));
3162
+ }
3163
+
3164
+ function scheduleShow(event) {
3165
+ instance.clearDelayTimeouts();
3166
+
3167
+ if (event) {
3168
+ invokeHook('onTrigger', [instance, event]);
3169
+ }
3170
+
3171
+ addDocumentPress();
3172
+ var delay = getDelay(true);
3173
+
3174
+ var _getNormalizedTouchSe = getNormalizedTouchSettings(),
3175
+ touchValue = _getNormalizedTouchSe[0],
3176
+ touchDelay = _getNormalizedTouchSe[1];
3177
+
3178
+ if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {
3179
+ delay = touchDelay;
3180
+ }
3181
+
3182
+ if (delay) {
3183
+ showTimeout = setTimeout(function () {
3184
+ instance.show();
3185
+ }, delay);
3186
+ } else {
3187
+ instance.show();
3188
+ }
3189
+ }
3190
+
3191
+ function scheduleHide(event) {
3192
+ instance.clearDelayTimeouts();
3193
+ invokeHook('onUntrigger', [instance, event]);
3194
+
3195
+ if (!instance.state.isVisible) {
3196
+ removeDocumentPress();
3197
+ return;
3198
+ } // For interactive tippies, scheduleHide is added to a document.body handler
3199
+ // from onMouseLeave so must intercept scheduled hides from mousemove/leave
3200
+ // events when trigger contains mouseenter and click, and the tip is
3201
+ // currently shown as a result of a click.
3202
+
3203
+
3204
+ if (instance.props.trigger.indexOf('mouseenter') >= 0 && instance.props.trigger.indexOf('click') >= 0 && ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 && isVisibleFromClick) {
3205
+ return;
3206
+ }
3207
+
3208
+ var delay = getDelay(false);
3209
+
3210
+ if (delay) {
3211
+ hideTimeout = setTimeout(function () {
3212
+ if (instance.state.isVisible) {
3213
+ instance.hide();
3214
+ }
3215
+ }, delay);
3216
+ } else {
3217
+ // Fixes a `transitionend` problem when it fires 1 frame too
3218
+ // late sometimes, we don't want hide() to be called.
3219
+ scheduleHideAnimationFrame = requestAnimationFrame(function () {
3220
+ instance.hide();
3221
+ });
3222
+ }
3223
+ } // ===========================================================================
3224
+ // 🔑 Public methods
3225
+ // ===========================================================================
3226
+
3227
+
3228
+ function enable() {
3229
+ instance.state.isEnabled = true;
3230
+ }
3231
+
3232
+ function disable() {
3233
+ // Disabling the instance should also hide it
3234
+ // https://github.com/atomiks/tippy.js-react/issues/106
3235
+ instance.hide();
3236
+ instance.state.isEnabled = false;
3237
+ }
3238
+
3239
+ function clearDelayTimeouts() {
3240
+ clearTimeout(showTimeout);
3241
+ clearTimeout(hideTimeout);
3242
+ cancelAnimationFrame(scheduleHideAnimationFrame);
3243
+ }
3244
+
3245
+ function setProps(partialProps) {
3246
+ /* istanbul ignore else */
3247
+ {
3248
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));
3249
+ }
3250
+
3251
+ if (instance.state.isDestroyed) {
3252
+ return;
3253
+ }
3254
+
3255
+ invokeHook('onBeforeUpdate', [instance, partialProps]);
3256
+ removeListeners();
3257
+ var prevProps = instance.props;
3258
+ var nextProps = evaluateProps(reference, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
3259
+ ignoreAttributes: true
3260
+ }));
3261
+ instance.props = nextProps;
3262
+ addListeners();
3263
+
3264
+ if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
3265
+ cleanupInteractiveMouseListeners();
3266
+ debouncedOnMouseMove = debounce$1(onMouseMove, nextProps.interactiveDebounce);
3267
+ } // Ensure stale aria-expanded attributes are removed
3268
+
3269
+
3270
+ if (prevProps.triggerTarget && !nextProps.triggerTarget) {
3271
+ normalizeToArray(prevProps.triggerTarget).forEach(function (node) {
3272
+ node.removeAttribute('aria-expanded');
3273
+ });
3274
+ } else if (nextProps.triggerTarget) {
3275
+ reference.removeAttribute('aria-expanded');
3276
+ }
3277
+
3278
+ handleAriaExpandedAttribute();
3279
+ handleStyles();
3280
+
3281
+ if (onUpdate) {
3282
+ onUpdate(prevProps, nextProps);
3283
+ }
3284
+
3285
+ if (instance.popperInstance) {
3286
+ createPopperInstance(); // Fixes an issue with nested tippies if they are all getting re-rendered,
3287
+ // and the nested ones get re-rendered first.
3288
+ // https://github.com/atomiks/tippyjs-react/issues/177
3289
+ // TODO: find a cleaner / more efficient solution(!)
3290
+
3291
+ getNestedPopperTree().forEach(function (nestedPopper) {
3292
+ // React (and other UI libs likely) requires a rAF wrapper as it flushes
3293
+ // its work in one
3294
+ requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
3295
+ });
3296
+ }
3297
+
3298
+ invokeHook('onAfterUpdate', [instance, partialProps]);
3299
+ }
3300
+
3301
+ function setContent(content) {
3302
+ instance.setProps({
3303
+ content: content
3304
+ });
3305
+ }
3306
+
3307
+ function show() {
3308
+ /* istanbul ignore else */
3309
+ {
3310
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));
3311
+ } // Early bail-out
3312
+
3313
+
3314
+ var isAlreadyVisible = instance.state.isVisible;
3315
+ var isDestroyed = instance.state.isDestroyed;
3316
+ var isDisabled = !instance.state.isEnabled;
3317
+ var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
3318
+ var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
3319
+
3320
+ if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
3321
+ return;
3322
+ } // Normalize `disabled` behavior across browsers.
3323
+ // Firefox allows events on disabled elements, but Chrome doesn't.
3324
+ // Using a wrapper element (i.e. <span>) is recommended.
3325
+
3326
+
3327
+ if (getCurrentTarget().hasAttribute('disabled')) {
3328
+ return;
3329
+ }
3330
+
3331
+ invokeHook('onShow', [instance], false);
3332
+
3333
+ if (instance.props.onShow(instance) === false) {
3334
+ return;
3335
+ }
3336
+
3337
+ instance.state.isVisible = true;
3338
+
3339
+ if (getIsDefaultRenderFn()) {
3340
+ popper.style.visibility = 'visible';
3341
+ }
3342
+
3343
+ handleStyles();
3344
+ addDocumentPress();
3345
+
3346
+ if (!instance.state.isMounted) {
3347
+ popper.style.transition = 'none';
3348
+ } // If flipping to the opposite side after hiding at least once, the
3349
+ // animation will use the wrong placement without resetting the duration
3350
+
3351
+
3352
+ if (getIsDefaultRenderFn()) {
3353
+ var _getDefaultTemplateCh2 = getDefaultTemplateChildren(),
3354
+ box = _getDefaultTemplateCh2.box,
3355
+ content = _getDefaultTemplateCh2.content;
3356
+
3357
+ setTransitionDuration([box, content], 0);
3358
+ }
3359
+
3360
+ onFirstUpdate = function onFirstUpdate() {
3361
+ var _instance$popperInsta2;
3362
+
3363
+ if (!instance.state.isVisible || ignoreOnFirstUpdate) {
3364
+ return;
3365
+ }
3366
+
3367
+ ignoreOnFirstUpdate = true; // reflow
3368
+
3369
+ void popper.offsetHeight;
3370
+ popper.style.transition = instance.props.moveTransition;
3371
+
3372
+ if (getIsDefaultRenderFn() && instance.props.animation) {
3373
+ var _getDefaultTemplateCh3 = getDefaultTemplateChildren(),
3374
+ _box = _getDefaultTemplateCh3.box,
3375
+ _content = _getDefaultTemplateCh3.content;
3376
+
3377
+ setTransitionDuration([_box, _content], duration);
3378
+ setVisibilityState([_box, _content], 'visible');
3379
+ }
3380
+
3381
+ handleAriaContentAttribute();
3382
+ handleAriaExpandedAttribute();
3383
+ pushIfUnique(mountedInstances, instance); // certain modifiers (e.g. `maxSize`) require a second update after the
3384
+ // popper has been positioned for the first time
3385
+
3386
+ (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
3387
+ invokeHook('onMount', [instance]);
3388
+
3389
+ if (instance.props.animation && getIsDefaultRenderFn()) {
3390
+ onTransitionedIn(duration, function () {
3391
+ instance.state.isShown = true;
3392
+ invokeHook('onShown', [instance]);
3393
+ });
3394
+ }
3395
+ };
3396
+
3397
+ mount();
3398
+ }
3399
+
3400
+ function hide() {
3401
+ /* istanbul ignore else */
3402
+ {
3403
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));
3404
+ } // Early bail-out
3405
+
3406
+
3407
+ var isAlreadyHidden = !instance.state.isVisible;
3408
+ var isDestroyed = instance.state.isDestroyed;
3409
+ var isDisabled = !instance.state.isEnabled;
3410
+ var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
3411
+
3412
+ if (isAlreadyHidden || isDestroyed || isDisabled) {
3413
+ return;
3414
+ }
3415
+
3416
+ invokeHook('onHide', [instance], false);
3417
+
3418
+ if (instance.props.onHide(instance) === false) {
3419
+ return;
3420
+ }
3421
+
3422
+ instance.state.isVisible = false;
3423
+ instance.state.isShown = false;
3424
+ ignoreOnFirstUpdate = false;
3425
+ isVisibleFromClick = false;
3426
+
3427
+ if (getIsDefaultRenderFn()) {
3428
+ popper.style.visibility = 'hidden';
3429
+ }
3430
+
3431
+ cleanupInteractiveMouseListeners();
3432
+ removeDocumentPress();
3433
+ handleStyles(true);
3434
+
3435
+ if (getIsDefaultRenderFn()) {
3436
+ var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),
3437
+ box = _getDefaultTemplateCh4.box,
3438
+ content = _getDefaultTemplateCh4.content;
3439
+
3440
+ if (instance.props.animation) {
3441
+ setTransitionDuration([box, content], duration);
3442
+ setVisibilityState([box, content], 'hidden');
3443
+ }
3444
+ }
3445
+
3446
+ handleAriaContentAttribute();
3447
+ handleAriaExpandedAttribute();
3448
+
3449
+ if (instance.props.animation) {
3450
+ if (getIsDefaultRenderFn()) {
3451
+ onTransitionedOut(duration, instance.unmount);
3452
+ }
3453
+ } else {
3454
+ instance.unmount();
3455
+ }
3456
+ }
3457
+
3458
+ function hideWithInteractivity(event) {
3459
+ /* istanbul ignore else */
3460
+ {
3461
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hideWithInteractivity'));
3462
+ }
3463
+
3464
+ getDocument().addEventListener('mousemove', debouncedOnMouseMove);
3465
+ pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
3466
+ debouncedOnMouseMove(event);
3467
+ }
3468
+
3469
+ function unmount() {
3470
+ /* istanbul ignore else */
3471
+ {
3472
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));
3473
+ }
3474
+
3475
+ if (instance.state.isVisible) {
3476
+ instance.hide();
3477
+ }
3478
+
3479
+ if (!instance.state.isMounted) {
3480
+ return;
3481
+ }
3482
+
3483
+ destroyPopperInstance(); // If a popper is not interactive, it will be appended outside the popper
3484
+ // tree by default. This seems mainly for interactive tippies, but we should
3485
+ // find a workaround if possible
3486
+
3487
+ getNestedPopperTree().forEach(function (nestedPopper) {
3488
+ nestedPopper._tippy.unmount();
3489
+ });
3490
+
3491
+ if (popper.parentNode) {
3492
+ popper.parentNode.removeChild(popper);
3493
+ }
3494
+
3495
+ mountedInstances = mountedInstances.filter(function (i) {
3496
+ return i !== instance;
3497
+ });
3498
+ instance.state.isMounted = false;
3499
+ invokeHook('onHidden', [instance]);
3500
+ }
3501
+
3502
+ function destroy() {
3503
+ /* istanbul ignore else */
3504
+ {
3505
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));
3506
+ }
3507
+
3508
+ if (instance.state.isDestroyed) {
3509
+ return;
3510
+ }
3511
+
3512
+ instance.clearDelayTimeouts();
3513
+ instance.unmount();
3514
+ removeListeners();
3515
+ delete reference._tippy;
3516
+ instance.state.isDestroyed = true;
3517
+ invokeHook('onDestroy', [instance]);
3518
+ }
3519
+ }
3520
+
3521
+ function tippy(targets, optionalProps) {
3522
+ if (optionalProps === void 0) {
3523
+ optionalProps = {};
3524
+ }
3525
+
3526
+ var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
3527
+ /* istanbul ignore else */
3528
+
3529
+ {
3530
+ validateTargets(targets);
3531
+ validateProps(optionalProps, plugins);
3532
+ }
3533
+
3534
+ bindGlobalEventListeners();
3535
+ var passedProps = Object.assign({}, optionalProps, {
3536
+ plugins: plugins
3537
+ });
3538
+ var elements = getArrayOfElements(targets);
3539
+ /* istanbul ignore else */
3540
+
3541
+ {
3542
+ var isSingleContentElement = isElement$1(passedProps.content);
3543
+ var isMoreThanOneReferenceElement = elements.length > 1;
3544
+ warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ['tippy() was passed an Element as the `content` prop, but more than', 'one tippy instance was created by this invocation. This means the', 'content element will only be appended to the last tippy instance.', '\n\n', 'Instead, pass the .innerHTML of the element, or use a function that', 'returns a cloned version of the element instead.', '\n\n', '1) content: element.innerHTML\n', '2) content: () => element.cloneNode(true)'].join(' '));
3545
+ }
3546
+
3547
+ var instances = elements.reduce(function (acc, reference) {
3548
+ var instance = reference && createTippy(reference, passedProps);
3549
+
3550
+ if (instance) {
3551
+ acc.push(instance);
3552
+ }
3553
+
3554
+ return acc;
3555
+ }, []);
3556
+ return isElement$1(targets) ? instances[0] : instances;
3557
+ }
3558
+
3559
+ tippy.defaultProps = defaultProps;
3560
+ tippy.setDefaultProps = setDefaultProps;
3561
+ tippy.currentInput = currentInput;
3562
+
3563
+ // every time the popper is destroyed (i.e. a new target), removing the styles
3564
+ // and causing transitions to break for singletons when the console is open, but
3565
+ // most notably for non-transform styles being used, `gpuAcceleration: false`.
3566
+
3567
+ var applyStylesModifier = Object.assign({}, applyStyles$1, {
3568
+ effect: function effect(_ref) {
3569
+ var state = _ref.state;
3570
+ var initialStyles = {
3571
+ popper: {
3572
+ position: state.options.strategy,
3573
+ left: '0',
3574
+ top: '0',
3575
+ margin: '0'
3576
+ },
3577
+ arrow: {
3578
+ position: 'absolute'
3579
+ },
3580
+ reference: {}
3581
+ };
3582
+ Object.assign(state.elements.popper.style, initialStyles.popper);
3583
+ state.styles = initialStyles;
3584
+
3585
+ if (state.elements.arrow) {
3586
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
3587
+ } // intentionally return no cleanup function
3588
+ // return () => { ... }
3589
+
3590
+ }
3591
+ });
3592
+
3593
+ var createSingleton = function createSingleton(tippyInstances, optionalProps) {
3594
+ var _optionalProps$popper;
3595
+
3596
+ if (optionalProps === void 0) {
3597
+ optionalProps = {};
3598
+ }
3599
+
3600
+ /* istanbul ignore else */
3601
+ {
3602
+ errorWhen(!Array.isArray(tippyInstances), ['The first argument passed to createSingleton() must be an array of', 'tippy instances. The passed value was', String(tippyInstances)].join(' '));
3603
+ }
3604
+
3605
+ var individualInstances = tippyInstances;
3606
+ var references = [];
3607
+ var triggerTargets = [];
3608
+ var currentTarget;
3609
+ var overrides = optionalProps.overrides;
3610
+ var interceptSetPropsCleanups = [];
3611
+ var shownOnCreate = false;
3612
+
3613
+ function setTriggerTargets() {
3614
+ triggerTargets = individualInstances.map(function (instance) {
3615
+ return normalizeToArray(instance.props.triggerTarget || instance.reference);
3616
+ }).reduce(function (acc, item) {
3617
+ return acc.concat(item);
3618
+ }, []);
3619
+ }
3620
+
3621
+ function setReferences() {
3622
+ references = individualInstances.map(function (instance) {
3623
+ return instance.reference;
3624
+ });
3625
+ }
3626
+
3627
+ function enableInstances(isEnabled) {
3628
+ individualInstances.forEach(function (instance) {
3629
+ if (isEnabled) {
3630
+ instance.enable();
3631
+ } else {
3632
+ instance.disable();
3633
+ }
3634
+ });
3635
+ }
3636
+
3637
+ function interceptSetProps(singleton) {
3638
+ return individualInstances.map(function (instance) {
3639
+ var originalSetProps = instance.setProps;
3640
+
3641
+ instance.setProps = function (props) {
3642
+ originalSetProps(props);
3643
+
3644
+ if (instance.reference === currentTarget) {
3645
+ singleton.setProps(props);
3646
+ }
3647
+ };
3648
+
3649
+ return function () {
3650
+ instance.setProps = originalSetProps;
3651
+ };
3652
+ });
3653
+ } // have to pass singleton, as it maybe undefined on first call
3654
+
3655
+
3656
+ function prepareInstance(singleton, target) {
3657
+ var index = triggerTargets.indexOf(target); // bail-out
3658
+
3659
+ if (target === currentTarget) {
3660
+ return;
3661
+ }
3662
+
3663
+ currentTarget = target;
3664
+ var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {
3665
+ acc[prop] = individualInstances[index].props[prop];
3666
+ return acc;
3667
+ }, {});
3668
+ singleton.setProps(Object.assign({}, overrideProps, {
3669
+ getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {
3670
+ var _references$index;
3671
+
3672
+ return (_references$index = references[index]) == null ? void 0 : _references$index.getBoundingClientRect();
3673
+ }
3674
+ }));
3675
+ }
3676
+
3677
+ enableInstances(false);
3678
+ setReferences();
3679
+ setTriggerTargets();
3680
+ var plugin = {
3681
+ fn: function fn() {
3682
+ return {
3683
+ onDestroy: function onDestroy() {
3684
+ enableInstances(true);
3685
+ },
3686
+ onHidden: function onHidden() {
3687
+ currentTarget = null;
3688
+ },
3689
+ onClickOutside: function onClickOutside(instance) {
3690
+ if (instance.props.showOnCreate && !shownOnCreate) {
3691
+ shownOnCreate = true;
3692
+ currentTarget = null;
3693
+ }
3694
+ },
3695
+ onShow: function onShow(instance) {
3696
+ if (instance.props.showOnCreate && !shownOnCreate) {
3697
+ shownOnCreate = true;
3698
+ prepareInstance(instance, references[0]);
3699
+ }
3700
+ },
3701
+ onTrigger: function onTrigger(instance, event) {
3702
+ prepareInstance(instance, event.currentTarget);
3703
+ }
3704
+ };
3705
+ }
3706
+ };
3707
+ var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ['overrides']), {
3708
+ plugins: [plugin].concat(optionalProps.plugins || []),
3709
+ triggerTarget: triggerTargets,
3710
+ popperOptions: Object.assign({}, optionalProps.popperOptions, {
3711
+ modifiers: [].concat(((_optionalProps$popper = optionalProps.popperOptions) == null ? void 0 : _optionalProps$popper.modifiers) || [], [applyStylesModifier])
3712
+ })
3713
+ }));
3714
+ var originalShow = singleton.show;
3715
+
3716
+ singleton.show = function (target) {
3717
+ originalShow(); // first time, showOnCreate or programmatic call with no params
3718
+ // default to showing first instance
3719
+
3720
+ if (!currentTarget && target == null) {
3721
+ return prepareInstance(singleton, references[0]);
3722
+ } // triggered from event (do nothing as prepareInstance already called by onTrigger)
3723
+ // programmatic call with no params when already visible (do nothing again)
3724
+
3725
+
3726
+ if (currentTarget && target == null) {
3727
+ return;
3728
+ } // target is index of instance
3729
+
3730
+
3731
+ if (typeof target === 'number') {
3732
+ return references[target] && prepareInstance(singleton, references[target]);
3733
+ } // target is a child tippy instance
3734
+
3735
+
3736
+ if (individualInstances.indexOf(target) >= 0) {
3737
+ var ref = target.reference;
3738
+ return prepareInstance(singleton, ref);
3739
+ } // target is a ReferenceElement
3740
+
3741
+
3742
+ if (references.indexOf(target) >= 0) {
3743
+ return prepareInstance(singleton, target);
3744
+ }
3745
+ };
3746
+
3747
+ singleton.showNext = function () {
3748
+ var first = references[0];
3749
+
3750
+ if (!currentTarget) {
3751
+ return singleton.show(0);
3752
+ }
3753
+
3754
+ var index = references.indexOf(currentTarget);
3755
+ singleton.show(references[index + 1] || first);
3756
+ };
3757
+
3758
+ singleton.showPrevious = function () {
3759
+ var last = references[references.length - 1];
3760
+
3761
+ if (!currentTarget) {
3762
+ return singleton.show(last);
3763
+ }
3764
+
3765
+ var index = references.indexOf(currentTarget);
3766
+ var target = references[index - 1] || last;
3767
+ singleton.show(target);
3768
+ };
3769
+
3770
+ var originalSetProps = singleton.setProps;
3771
+
3772
+ singleton.setProps = function (props) {
3773
+ overrides = props.overrides || overrides;
3774
+ originalSetProps(props);
3775
+ };
3776
+
3777
+ singleton.setInstances = function (nextInstances) {
3778
+ enableInstances(true);
3779
+ interceptSetPropsCleanups.forEach(function (fn) {
3780
+ return fn();
3781
+ });
3782
+ individualInstances = nextInstances;
3783
+ enableInstances(false);
3784
+ setReferences();
3785
+ setTriggerTargets();
3786
+ interceptSetPropsCleanups = interceptSetProps(singleton);
3787
+ singleton.setProps({
3788
+ triggerTarget: triggerTargets
3789
+ });
3790
+ };
3791
+
3792
+ interceptSetPropsCleanups = interceptSetProps(singleton);
3793
+ return singleton;
3794
+ };
3795
+
3796
+ var animateFill = {
3797
+ name: 'animateFill',
3798
+ defaultValue: false,
3799
+ fn: function fn(instance) {
3800
+ var _instance$props$rende;
3801
+
3802
+ // @ts-ignore
3803
+ if (!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy)) {
3804
+ {
3805
+ errorWhen(instance.props.animateFill, 'The `animateFill` plugin requires the default render function.');
3806
+ }
3807
+
3808
+ return {};
3809
+ }
3810
+
3811
+ var _getChildren = getChildren(instance.popper),
3812
+ box = _getChildren.box,
3813
+ content = _getChildren.content;
3814
+
3815
+ var backdrop = instance.props.animateFill ? createBackdropElement() : null;
3816
+ return {
3817
+ onCreate: function onCreate() {
3818
+ if (backdrop) {
3819
+ box.insertBefore(backdrop, box.firstElementChild);
3820
+ box.setAttribute('data-animatefill', '');
3821
+ box.style.overflow = 'hidden';
3822
+ instance.setProps({
3823
+ arrow: false,
3824
+ animation: 'shift-away'
3825
+ });
3826
+ }
3827
+ },
3828
+ onMount: function onMount() {
3829
+ if (backdrop) {
3830
+ var transitionDuration = box.style.transitionDuration;
3831
+ var duration = Number(transitionDuration.replace('ms', '')); // The content should fade in after the backdrop has mostly filled the
3832
+ // tooltip element. `clip-path` is the other alternative but is not
3833
+ // well-supported and is buggy on some devices.
3834
+
3835
+ content.style.transitionDelay = Math.round(duration / 10) + "ms";
3836
+ backdrop.style.transitionDuration = transitionDuration;
3837
+ setVisibilityState([backdrop], 'visible');
3838
+ }
3839
+ },
3840
+ onShow: function onShow() {
3841
+ if (backdrop) {
3842
+ backdrop.style.transitionDuration = '0ms';
3843
+ }
3844
+ },
3845
+ onHide: function onHide() {
3846
+ if (backdrop) {
3847
+ setVisibilityState([backdrop], 'hidden');
3848
+ }
3849
+ }
3850
+ };
3851
+ }
3852
+ };
3853
+
3854
+ function createBackdropElement() {
3855
+ var backdrop = div();
3856
+ backdrop.className = BACKDROP_CLASS;
3857
+ setVisibilityState([backdrop], 'hidden');
3858
+ return backdrop;
3859
+ }
3860
+
3861
+ var mouseCoords = {
3862
+ clientX: 0,
3863
+ clientY: 0
3864
+ };
3865
+ var activeInstances = [];
3866
+
3867
+ function storeMouseCoords(_ref) {
3868
+ var clientX = _ref.clientX,
3869
+ clientY = _ref.clientY;
3870
+ mouseCoords = {
3871
+ clientX: clientX,
3872
+ clientY: clientY
3873
+ };
3874
+ }
3875
+
3876
+ function addMouseCoordsListener(doc) {
3877
+ doc.addEventListener('mousemove', storeMouseCoords);
3878
+ }
3879
+
3880
+ function removeMouseCoordsListener(doc) {
3881
+ doc.removeEventListener('mousemove', storeMouseCoords);
3882
+ }
3883
+
3884
+ var followCursor = {
3885
+ name: 'followCursor',
3886
+ defaultValue: false,
3887
+ fn: function fn(instance) {
3888
+ var reference = instance.reference;
3889
+ var doc = getOwnerDocument(instance.props.triggerTarget || reference);
3890
+ var isInternalUpdate = false;
3891
+ var wasFocusEvent = false;
3892
+ var isUnmounted = true;
3893
+ var prevProps = instance.props;
3894
+
3895
+ function getIsInitialBehavior() {
3896
+ return instance.props.followCursor === 'initial' && instance.state.isVisible;
3897
+ }
3898
+
3899
+ function addListener() {
3900
+ doc.addEventListener('mousemove', onMouseMove);
3901
+ }
3902
+
3903
+ function removeListener() {
3904
+ doc.removeEventListener('mousemove', onMouseMove);
3905
+ }
3906
+
3907
+ function unsetGetReferenceClientRect() {
3908
+ isInternalUpdate = true;
3909
+ instance.setProps({
3910
+ getReferenceClientRect: null
3911
+ });
3912
+ isInternalUpdate = false;
3913
+ }
3914
+
3915
+ function onMouseMove(event) {
3916
+ // If the instance is interactive, avoid updating the position unless it's
3917
+ // over the reference element
3918
+ var isCursorOverReference = event.target ? reference.contains(event.target) : true;
3919
+ var followCursor = instance.props.followCursor;
3920
+ var clientX = event.clientX,
3921
+ clientY = event.clientY;
3922
+ var rect = reference.getBoundingClientRect();
3923
+ var relativeX = clientX - rect.left;
3924
+ var relativeY = clientY - rect.top;
3925
+
3926
+ if (isCursorOverReference || !instance.props.interactive) {
3927
+ instance.setProps({
3928
+ // @ts-ignore - unneeded DOMRect properties
3929
+ getReferenceClientRect: function getReferenceClientRect() {
3930
+ var rect = reference.getBoundingClientRect();
3931
+ var x = clientX;
3932
+ var y = clientY;
3933
+
3934
+ if (followCursor === 'initial') {
3935
+ x = rect.left + relativeX;
3936
+ y = rect.top + relativeY;
3937
+ }
3938
+
3939
+ var top = followCursor === 'horizontal' ? rect.top : y;
3940
+ var right = followCursor === 'vertical' ? rect.right : x;
3941
+ var bottom = followCursor === 'horizontal' ? rect.bottom : y;
3942
+ var left = followCursor === 'vertical' ? rect.left : x;
3943
+ return {
3944
+ width: right - left,
3945
+ height: bottom - top,
3946
+ top: top,
3947
+ right: right,
3948
+ bottom: bottom,
3949
+ left: left
3950
+ };
3951
+ }
3952
+ });
3953
+ }
3954
+ }
3955
+
3956
+ function create() {
3957
+ if (instance.props.followCursor) {
3958
+ activeInstances.push({
3959
+ instance: instance,
3960
+ doc: doc
3961
+ });
3962
+ addMouseCoordsListener(doc);
3963
+ }
3964
+ }
3965
+
3966
+ function destroy() {
3967
+ activeInstances = activeInstances.filter(function (data) {
3968
+ return data.instance !== instance;
3969
+ });
3970
+
3971
+ if (activeInstances.filter(function (data) {
3972
+ return data.doc === doc;
3973
+ }).length === 0) {
3974
+ removeMouseCoordsListener(doc);
3975
+ }
3976
+ }
3977
+
3978
+ return {
3979
+ onCreate: create,
3980
+ onDestroy: destroy,
3981
+ onBeforeUpdate: function onBeforeUpdate() {
3982
+ prevProps = instance.props;
3983
+ },
3984
+ onAfterUpdate: function onAfterUpdate(_, _ref2) {
3985
+ var followCursor = _ref2.followCursor;
3986
+
3987
+ if (isInternalUpdate) {
3988
+ return;
3989
+ }
3990
+
3991
+ if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
3992
+ destroy();
3993
+
3994
+ if (followCursor) {
3995
+ create();
3996
+
3997
+ if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
3998
+ addListener();
3999
+ }
4000
+ } else {
4001
+ removeListener();
4002
+ unsetGetReferenceClientRect();
4003
+ }
4004
+ }
4005
+ },
4006
+ onMount: function onMount() {
4007
+ if (instance.props.followCursor && !wasFocusEvent) {
4008
+ if (isUnmounted) {
4009
+ onMouseMove(mouseCoords);
4010
+ isUnmounted = false;
4011
+ }
4012
+
4013
+ if (!getIsInitialBehavior()) {
4014
+ addListener();
4015
+ }
4016
+ }
4017
+ },
4018
+ onTrigger: function onTrigger(_, event) {
4019
+ if (isMouseEvent(event)) {
4020
+ mouseCoords = {
4021
+ clientX: event.clientX,
4022
+ clientY: event.clientY
4023
+ };
4024
+ }
4025
+
4026
+ wasFocusEvent = event.type === 'focus';
4027
+ },
4028
+ onHidden: function onHidden() {
4029
+ if (instance.props.followCursor) {
4030
+ unsetGetReferenceClientRect();
4031
+ removeListener();
4032
+ isUnmounted = true;
4033
+ }
4034
+ }
4035
+ };
4036
+ }
4037
+ };
4038
+
4039
+ function getProps(props, modifier) {
4040
+ var _props$popperOptions;
4041
+
4042
+ return {
4043
+ popperOptions: Object.assign({}, props.popperOptions, {
4044
+ modifiers: [].concat((((_props$popperOptions = props.popperOptions) == null ? void 0 : _props$popperOptions.modifiers) || []).filter(function (_ref) {
4045
+ var name = _ref.name;
4046
+ return name !== modifier.name;
4047
+ }), [modifier])
4048
+ })
4049
+ };
4050
+ }
4051
+
4052
+ var inlinePositioning = {
4053
+ name: 'inlinePositioning',
4054
+ defaultValue: false,
4055
+ fn: function fn(instance) {
4056
+ var reference = instance.reference;
4057
+
4058
+ function isEnabled() {
4059
+ return !!instance.props.inlinePositioning;
4060
+ }
4061
+
4062
+ var placement;
4063
+ var cursorRectIndex = -1;
4064
+ var isInternalUpdate = false;
4065
+ var triedPlacements = [];
4066
+ var modifier = {
4067
+ name: 'tippyInlinePositioning',
4068
+ enabled: true,
4069
+ phase: 'afterWrite',
4070
+ fn: function fn(_ref2) {
4071
+ var state = _ref2.state;
4072
+
4073
+ if (isEnabled()) {
4074
+ if (triedPlacements.indexOf(state.placement) !== -1) {
4075
+ triedPlacements = [];
4076
+ }
4077
+
4078
+ if (placement !== state.placement && triedPlacements.indexOf(state.placement) === -1) {
4079
+ triedPlacements.push(state.placement);
4080
+ instance.setProps({
4081
+ // @ts-ignore - unneeded DOMRect properties
4082
+ getReferenceClientRect: function getReferenceClientRect() {
4083
+ return _getReferenceClientRect(state.placement);
4084
+ }
4085
+ });
4086
+ }
4087
+
4088
+ placement = state.placement;
4089
+ }
4090
+ }
4091
+ };
4092
+
4093
+ function _getReferenceClientRect(placement) {
4094
+ return getInlineBoundingClientRect(getBasePlacement$1(placement), reference.getBoundingClientRect(), arrayFrom(reference.getClientRects()), cursorRectIndex);
4095
+ }
4096
+
4097
+ function setInternalProps(partialProps) {
4098
+ isInternalUpdate = true;
4099
+ instance.setProps(partialProps);
4100
+ isInternalUpdate = false;
4101
+ }
4102
+
4103
+ function addModifier() {
4104
+ if (!isInternalUpdate) {
4105
+ setInternalProps(getProps(instance.props, modifier));
4106
+ }
4107
+ }
4108
+
4109
+ return {
4110
+ onCreate: addModifier,
4111
+ onAfterUpdate: addModifier,
4112
+ onTrigger: function onTrigger(_, event) {
4113
+ if (isMouseEvent(event)) {
4114
+ var rects = arrayFrom(instance.reference.getClientRects());
4115
+ var cursorRect = rects.find(function (rect) {
4116
+ return rect.left - 2 <= event.clientX && rect.right + 2 >= event.clientX && rect.top - 2 <= event.clientY && rect.bottom + 2 >= event.clientY;
4117
+ });
4118
+ var index = rects.indexOf(cursorRect);
4119
+ cursorRectIndex = index > -1 ? index : cursorRectIndex;
4120
+ }
4121
+ },
4122
+ onHidden: function onHidden() {
4123
+ cursorRectIndex = -1;
4124
+ }
4125
+ };
4126
+ }
4127
+ };
4128
+ function getInlineBoundingClientRect(currentBasePlacement, boundingRect, clientRects, cursorRectIndex) {
4129
+ // Not an inline element, or placement is not yet known
4130
+ if (clientRects.length < 2 || currentBasePlacement === null) {
4131
+ return boundingRect;
4132
+ } // There are two rects and they are disjoined
4133
+
4134
+
4135
+ if (clientRects.length === 2 && cursorRectIndex >= 0 && clientRects[0].left > clientRects[1].right) {
4136
+ return clientRects[cursorRectIndex] || boundingRect;
4137
+ }
4138
+
4139
+ switch (currentBasePlacement) {
4140
+ case 'top':
4141
+ case 'bottom':
4142
+ {
4143
+ var firstRect = clientRects[0];
4144
+ var lastRect = clientRects[clientRects.length - 1];
4145
+ var isTop = currentBasePlacement === 'top';
4146
+ var top = firstRect.top;
4147
+ var bottom = lastRect.bottom;
4148
+ var left = isTop ? firstRect.left : lastRect.left;
4149
+ var right = isTop ? firstRect.right : lastRect.right;
4150
+ var width = right - left;
4151
+ var height = bottom - top;
4152
+ return {
4153
+ top: top,
4154
+ bottom: bottom,
4155
+ left: left,
4156
+ right: right,
4157
+ width: width,
4158
+ height: height
4159
+ };
4160
+ }
4161
+
4162
+ case 'left':
4163
+ case 'right':
4164
+ {
4165
+ var minLeft = Math.min.apply(Math, clientRects.map(function (rects) {
4166
+ return rects.left;
4167
+ }));
4168
+ var maxRight = Math.max.apply(Math, clientRects.map(function (rects) {
4169
+ return rects.right;
4170
+ }));
4171
+ var measureRects = clientRects.filter(function (rect) {
4172
+ return currentBasePlacement === 'left' ? rect.left === minLeft : rect.right === maxRight;
4173
+ });
4174
+ var _top = measureRects[0].top;
4175
+ var _bottom = measureRects[measureRects.length - 1].bottom;
4176
+ var _left = minLeft;
4177
+ var _right = maxRight;
4178
+
4179
+ var _width = _right - _left;
4180
+
4181
+ var _height = _bottom - _top;
4182
+
4183
+ return {
4184
+ top: _top,
4185
+ bottom: _bottom,
4186
+ left: _left,
4187
+ right: _right,
4188
+ width: _width,
4189
+ height: _height
4190
+ };
4191
+ }
4192
+
4193
+ default:
4194
+ {
4195
+ return boundingRect;
4196
+ }
4197
+ }
4198
+ }
4199
+
4200
+ var sticky = {
4201
+ name: 'sticky',
4202
+ defaultValue: false,
4203
+ fn: function fn(instance) {
4204
+ var reference = instance.reference,
4205
+ popper = instance.popper;
4206
+
4207
+ function getReference() {
4208
+ return instance.popperInstance ? instance.popperInstance.state.elements.reference : reference;
4209
+ }
4210
+
4211
+ function shouldCheck(value) {
4212
+ return instance.props.sticky === true || instance.props.sticky === value;
4213
+ }
4214
+
4215
+ var prevRefRect = null;
4216
+ var prevPopRect = null;
4217
+
4218
+ function updatePosition() {
4219
+ var currentRefRect = shouldCheck('reference') ? getReference().getBoundingClientRect() : null;
4220
+ var currentPopRect = shouldCheck('popper') ? popper.getBoundingClientRect() : null;
4221
+
4222
+ if (currentRefRect && areRectsDifferent(prevRefRect, currentRefRect) || currentPopRect && areRectsDifferent(prevPopRect, currentPopRect)) {
4223
+ if (instance.popperInstance) {
4224
+ instance.popperInstance.update();
4225
+ }
4226
+ }
4227
+
4228
+ prevRefRect = currentRefRect;
4229
+ prevPopRect = currentPopRect;
4230
+
4231
+ if (instance.state.isMounted) {
4232
+ requestAnimationFrame(updatePosition);
4233
+ }
4234
+ }
4235
+
4236
+ return {
4237
+ onMount: function onMount() {
4238
+ if (instance.props.sticky) {
4239
+ updatePosition();
4240
+ }
4241
+ }
4242
+ };
4243
+ }
4244
+ };
4245
+
4246
+ function areRectsDifferent(rectA, rectB) {
4247
+ if (rectA && rectB) {
4248
+ return rectA.top !== rectB.top || rectA.right !== rectB.right || rectA.bottom !== rectB.bottom || rectA.left !== rectB.left;
4249
+ }
4250
+
4251
+ return true;
4252
+ }
4253
+
4254
+ tippy.setDefaultProps({
4255
+ render: render
4256
+ });
4257
+
4258
+ tippy.setDefaultProps({
4259
+ //@ts-ignore
4260
+ onShow: instance => {
4261
+ if (!instance.props.content)
4262
+ return false;
4263
+ },
4264
+ });
4265
+ function useTippy(el, opts = {}, settings = { mount: true }) {
4266
+ const vm = vue.getCurrentInstance();
4267
+ const instance = vue.ref();
4268
+ const state = vue.ref({
4269
+ isEnabled: false,
4270
+ isVisible: false,
4271
+ isDestroyed: false,
4272
+ isMounted: false,
4273
+ isShown: false,
4274
+ });
4275
+ let container = null;
4276
+ const getContainer = () => {
4277
+ if (container)
4278
+ return container;
4279
+ container = document.createDocumentFragment();
4280
+ return container;
4281
+ };
4282
+ const getContent = (content) => {
4283
+ let newContent;
4284
+ let unwrappedContent = vue.isRef(content)
4285
+ ? content.value
4286
+ : content;
4287
+ if (vue.isVNode(unwrappedContent)) {
4288
+ if (vm) {
4289
+ unwrappedContent.appContext = vm.appContext;
4290
+ }
4291
+ vue.render(unwrappedContent, getContainer());
4292
+ newContent = () => getContainer();
4293
+ }
4294
+ else if (typeof unwrappedContent === 'object') {
4295
+ let comp = vue.h(unwrappedContent);
4296
+ if (vm) {
4297
+ comp.appContext = vm.appContext;
4298
+ }
4299
+ vue.render(comp, getContainer());
4300
+ newContent = () => getContainer();
4301
+ }
4302
+ else {
4303
+ newContent = unwrappedContent;
4304
+ }
4305
+ return newContent;
4306
+ };
4307
+ const getProps = (opts) => {
4308
+ let options = {};
4309
+ if (vue.isRef(opts)) {
4310
+ options = opts.value || {};
4311
+ }
4312
+ else if (vue.isReactive(opts)) {
4313
+ options = { ...opts };
4314
+ }
4315
+ else {
4316
+ options = { ...opts };
4317
+ }
4318
+ if (options.content) {
4319
+ options.content = getContent(options.content);
4320
+ }
4321
+ if (options.triggerTarget) {
4322
+ options.triggerTarget = vue.isRef(options.triggerTarget)
4323
+ ? options.triggerTarget.value
4324
+ : options.triggerTarget;
4325
+ }
4326
+ if (!options.plugins || !Array.isArray(options.plugins)) {
4327
+ options.plugins = [];
4328
+ }
4329
+ options.plugins = options.plugins.filter((plugin) => plugin.name !== 'vueTippyReactiveState');
4330
+ options.plugins.push({
4331
+ name: 'vueTippyReactiveState',
4332
+ fn: () => {
4333
+ return {
4334
+ onCreate() {
4335
+ state.value.isEnabled = true;
4336
+ },
4337
+ onMount() {
4338
+ state.value.isMounted = true;
4339
+ },
4340
+ onShow() {
4341
+ state.value.isMounted = true;
4342
+ state.value.isVisible = true;
4343
+ },
4344
+ onShown() {
4345
+ state.value.isShown = true;
4346
+ },
4347
+ onHide() {
4348
+ state.value.isMounted = false;
4349
+ state.value.isVisible = false;
4350
+ },
4351
+ onHidden() {
4352
+ state.value.isShown = false;
4353
+ },
4354
+ onUnmounted() {
4355
+ state.value.isMounted = false;
4356
+ },
4357
+ onDestroy() {
4358
+ state.value.isDestroyed = true;
4359
+ },
4360
+ };
4361
+ }
4362
+ });
4363
+ return options;
4364
+ };
4365
+ const refresh = () => {
4366
+ if (!instance.value)
4367
+ return;
4368
+ instance.value.setProps(getProps(opts));
4369
+ };
4370
+ const refreshContent = () => {
4371
+ if (!instance.value || !opts.content)
4372
+ return;
4373
+ instance.value.setContent(getContent(opts.content));
4374
+ };
4375
+ const setContent = (value) => {
4376
+ var _a;
4377
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.setContent(getContent(value));
4378
+ };
4379
+ const setProps = (value) => {
4380
+ var _a;
4381
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.setProps(getProps(value));
4382
+ };
4383
+ const destroy = () => {
4384
+ if (instance.value) {
4385
+ instance.value.destroy();
4386
+ instance.value = undefined;
4387
+ }
4388
+ container = null;
4389
+ };
4390
+ const show = () => {
4391
+ var _a;
4392
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.show();
4393
+ };
4394
+ const hide = () => {
4395
+ var _a;
4396
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.hide();
4397
+ };
4398
+ const disable = () => {
4399
+ var _a;
4400
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.disable();
4401
+ state.value.isEnabled = false;
4402
+ };
4403
+ const enable = () => {
4404
+ var _a;
4405
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.enable();
4406
+ state.value.isEnabled = true;
4407
+ };
4408
+ const unmount = () => {
4409
+ var _a;
4410
+ (_a = instance.value) === null || _a === void 0 ? void 0 : _a.unmount();
4411
+ };
4412
+ const mount = () => {
4413
+ if (!el)
4414
+ return;
4415
+ let target = vue.isRef(el) ? el.value : el;
4416
+ if (typeof target === 'function')
4417
+ target = target();
4418
+ if (target) {
4419
+ instance.value = tippy(target, getProps(opts));
4420
+ //@ts-ignore
4421
+ target.$tippy = response;
4422
+ }
4423
+ };
4424
+ const response = {
4425
+ tippy: instance,
4426
+ refresh,
4427
+ refreshContent,
4428
+ setContent,
4429
+ setProps,
4430
+ destroy,
4431
+ hide,
4432
+ show,
4433
+ disable,
4434
+ enable,
4435
+ unmount,
4436
+ mount,
4437
+ state,
4438
+ };
4439
+ if (settings.mount) {
4440
+ if (vm) {
4441
+ if (vm.isMounted) {
4442
+ mount();
4443
+ }
4444
+ else {
4445
+ vue.onMounted(mount);
4446
+ }
4447
+ vue.onUnmounted(() => {
4448
+ destroy();
4449
+ });
4450
+ }
4451
+ else {
4452
+ mount();
4453
+ }
4454
+ }
4455
+ if (vue.isRef(opts) || vue.isReactive(opts)) {
4456
+ vue.watch(opts, refresh, { immediate: false });
4457
+ }
4458
+ else if (vue.isRef(opts.content)) {
4459
+ vue.watch(opts.content, refreshContent, { immediate: false });
4460
+ }
4461
+ return response;
4462
+ }
4463
+
4464
+ function useTippyComponent(opts = {}, children) {
4465
+ const instance = vue.ref();
4466
+ return {
4467
+ instance,
4468
+ TippyComponent: vue.h(TippyComponent, {
4469
+ ...opts,
4470
+ onVnodeMounted: (vnode) => {
4471
+ //@ts-ignore
4472
+ instance.value = vnode.component.ctx;
4473
+ },
4474
+ }, children),
4475
+ };
4476
+ }
4477
+
4478
+ function useSingleton(instances, optionalProps) {
4479
+ const singleton = vue.ref();
4480
+ vue.onMounted(() => {
4481
+ const pendingTippyInstances = Array.isArray(instances)
4482
+ ? instances.map(i => i.value)
4483
+ : typeof instances === 'function'
4484
+ ? instances()
4485
+ : instances.value;
4486
+ const tippyInstances = pendingTippyInstances
4487
+ .map((instance) => {
4488
+ if (instance instanceof Element) {
4489
+ //@ts-ignore
4490
+ return instance._tippy;
4491
+ }
4492
+ return instance;
4493
+ })
4494
+ .filter(Boolean);
4495
+ singleton.value = createSingleton(tippyInstances, optionalProps
4496
+ ? { allowHTML: true, ...optionalProps }
4497
+ : { allowHTML: true });
4498
+ });
4499
+ return {
4500
+ singleton,
4501
+ };
4502
+ }
4503
+
4504
+ const TippyComponent = vue.defineComponent({
4505
+ props: {
4506
+ to: {
4507
+ type: [String, Function],
4508
+ },
4509
+ tag: {
4510
+ type: String,
4511
+ default: 'span'
4512
+ },
4513
+ contentTag: {
4514
+ type: String,
4515
+ default: 'span'
4516
+ },
4517
+ contentClass: {
4518
+ type: String,
4519
+ default: null
4520
+ },
4521
+ appendTo: { default: () => tippy.defaultProps['appendTo'] },
4522
+ aria: { default: () => tippy.defaultProps['aria'] },
4523
+ delay: { default: () => tippy.defaultProps['delay'] },
4524
+ duration: { default: () => tippy.defaultProps['duration'] },
4525
+ getReferenceClientRect: { default: () => tippy.defaultProps['getReferenceClientRect'] },
4526
+ hideOnClick: { type: [Boolean, String], default: () => tippy.defaultProps['hideOnClick'] },
4527
+ ignoreAttributes: { type: Boolean, default: () => tippy.defaultProps['ignoreAttributes'] },
4528
+ interactive: { type: Boolean, default: () => tippy.defaultProps['interactive'] },
4529
+ interactiveBorder: { default: () => tippy.defaultProps['interactiveBorder'] },
4530
+ interactiveDebounce: { default: () => tippy.defaultProps['interactiveDebounce'] },
4531
+ moveTransition: { default: () => tippy.defaultProps['moveTransition'] },
4532
+ offset: { default: () => tippy.defaultProps['offset'] },
4533
+ onAfterUpdate: { default: () => tippy.defaultProps['onAfterUpdate'] },
4534
+ onBeforeUpdate: { default: () => tippy.defaultProps['onBeforeUpdate'] },
4535
+ onCreate: { default: () => tippy.defaultProps['onCreate'] },
4536
+ onDestroy: { default: () => tippy.defaultProps['onDestroy'] },
4537
+ onHidden: { default: () => tippy.defaultProps['onHidden'] },
4538
+ onHide: { default: () => tippy.defaultProps['onHide'] },
4539
+ onMount: { default: () => tippy.defaultProps['onMount'] },
4540
+ onShow: { default: () => tippy.defaultProps['onShow'] },
4541
+ onShown: { default: () => tippy.defaultProps['onShown'] },
4542
+ onTrigger: { default: () => tippy.defaultProps['onTrigger'] },
4543
+ onUntrigger: { default: () => tippy.defaultProps['onUntrigger'] },
4544
+ onClickOutside: { default: () => tippy.defaultProps['onClickOutside'] },
4545
+ placement: { default: () => tippy.defaultProps['placement'] },
4546
+ plugins: { default: () => tippy.defaultProps['plugins'] },
4547
+ popperOptions: { default: () => tippy.defaultProps['popperOptions'] },
4548
+ render: { default: () => tippy.defaultProps['render'] },
4549
+ showOnCreate: { type: Boolean, default: () => tippy.defaultProps['showOnCreate'] },
4550
+ touch: { type: [Boolean, String, Array], default: () => tippy.defaultProps['touch'] },
4551
+ trigger: { default: () => tippy.defaultProps['trigger'] },
4552
+ triggerTarget: { default: () => tippy.defaultProps['triggerTarget'] },
4553
+ animateFill: { type: Boolean, default: () => tippy.defaultProps['animateFill'] },
4554
+ followCursor: { type: [Boolean, String], default: () => tippy.defaultProps['followCursor'] },
4555
+ inlinePositioning: { type: Boolean, default: () => tippy.defaultProps['inlinePositioning'] },
4556
+ sticky: { type: [Boolean, String], default: () => tippy.defaultProps['sticky'] },
4557
+ allowHTML: { type: Boolean, default: () => tippy.defaultProps['allowHTML'] },
4558
+ animation: { default: () => tippy.defaultProps['animation'] },
4559
+ arrow: { default: () => tippy.defaultProps['arrow'] },
4560
+ content: { default: () => tippy.defaultProps['content'] },
4561
+ inertia: { default: () => tippy.defaultProps['inertia'] },
4562
+ maxWidth: { default: () => tippy.defaultProps['maxWidth'] },
4563
+ role: { default: () => tippy.defaultProps['role'] },
4564
+ theme: { default: () => tippy.defaultProps['theme'] },
4565
+ zIndex: { default: () => tippy.defaultProps['zIndex'] }
4566
+ },
4567
+ emits: ['state'],
4568
+ setup(props, { slots, emit, expose }) {
4569
+ const elem = vue.ref();
4570
+ const contentElem = vue.ref();
4571
+ const mounted = vue.ref(false);
4572
+ const getOptions = () => {
4573
+ let options = { ...props };
4574
+ for (const prop of ['to', 'tag', 'contentTag', 'contentClass']) {
4575
+ if (options.hasOwnProperty(prop)) {
4576
+ // @ts-ignore
4577
+ delete options[prop];
4578
+ }
4579
+ }
4580
+ return options;
4581
+ };
4582
+ let target = elem;
4583
+ if (props.to) {
4584
+ if (typeof Element !== 'undefined' && props.to instanceof Element) {
4585
+ target = () => props.to;
4586
+ }
4587
+ else if (typeof props.to === 'string' || props.to instanceof String) {
4588
+ target = () => document.querySelector(props.to);
4589
+ }
4590
+ }
4591
+ const tippy = useTippy(target, getOptions());
4592
+ vue.onMounted(() => {
4593
+ mounted.value = true;
4594
+ vue.nextTick(() => {
4595
+ if (slots.content)
4596
+ tippy.setContent(() => contentElem.value);
4597
+ });
4598
+ });
4599
+ vue.watch(tippy.state, () => {
4600
+ emit('state', vue.unref(tippy.state));
4601
+ }, { immediate: true, deep: true });
4602
+ vue.watch(() => props, () => {
4603
+ tippy.setProps(getOptions());
4604
+ if (slots.content)
4605
+ tippy.setContent(() => contentElem.value);
4606
+ });
4607
+ let exposed = vue.reactive({
4608
+ elem,
4609
+ contentElem,
4610
+ mounted,
4611
+ ...tippy
4612
+ });
4613
+ expose(exposed);
4614
+ return () => {
4615
+ const slot = slots.default ? slots.default(exposed) : [];
4616
+ return vue.h(props.tag, { ref: elem, 'data-v-tippy': '' }, slots.content ? [
4617
+ slot,
4618
+ vue.h(props.contentTag, {
4619
+ ref: contentElem,
4620
+ style: { display: mounted.value ? 'inherit' : 'none' },
4621
+ class: props.contentClass
4622
+ }, slots.content(exposed)),
4623
+ ] : slot);
4624
+ };
4625
+ },
4626
+ });
4627
+
4628
+ const booleanProps = [
4629
+ 'a11y',
4630
+ 'allowHTML',
4631
+ 'arrow',
4632
+ 'flip',
4633
+ 'flipOnUpdate',
4634
+ 'hideOnClick',
4635
+ 'ignoreAttributes',
4636
+ 'inertia',
4637
+ 'interactive',
4638
+ 'lazy',
4639
+ 'multiple',
4640
+ 'showOnInit',
4641
+ 'touch',
4642
+ 'touchHold',
4643
+ ];
4644
+ let props = {};
4645
+ Object.keys(tippy.defaultProps).forEach((prop) => {
4646
+ if (booleanProps.includes(prop)) {
4647
+ props[prop] = {
4648
+ type: Boolean,
4649
+ default: function () {
4650
+ return tippy.defaultProps[prop];
4651
+ },
4652
+ };
4653
+ }
4654
+ else {
4655
+ props[prop] = {
4656
+ default: function () {
4657
+ return tippy.defaultProps[prop];
4658
+ },
4659
+ };
4660
+ }
4661
+ });
4662
+ const TippySingleton = vue.defineComponent({
4663
+ props,
4664
+ setup(props) {
4665
+ const instances = vue.ref([]);
4666
+ const { singleton } = useSingleton(instances, props);
4667
+ return { instances, singleton };
4668
+ },
4669
+ mounted() {
4670
+ var _a;
4671
+ const parent = this.$el.parentElement;
4672
+ const elements = parent.querySelectorAll('[data-v-tippy]');
4673
+ this.instances = Array.from(elements)
4674
+ .map((el) => el._tippy)
4675
+ .filter(Boolean);
4676
+ (_a = this.singleton) === null || _a === void 0 ? void 0 : _a.setInstances(this.instances);
4677
+ },
4678
+ render() {
4679
+ let slot = this.$slots.default ? this.$slots.default() : [];
4680
+ return vue.h(() => slot);
4681
+ },
4682
+ });
4683
+
4684
+ const directive = {
4685
+ mounted(el, binding, vnode) {
4686
+ const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
4687
+ const modifiers = Object.keys(binding.modifiers || {});
4688
+ const placement = modifiers.find(modifier => modifier !== 'arrow');
4689
+ const withArrow = modifiers.findIndex(modifier => modifier === 'arrow') !== -1;
4690
+ if (placement) {
4691
+ opts.placement = opts.placement || placement;
4692
+ }
4693
+ if (withArrow) {
4694
+ opts.arrow = opts.arrow !== undefined ? opts.arrow : true;
4695
+ }
4696
+ if (vnode.props && vnode.props.onTippyShow) {
4697
+ opts.onShow = function (...args) {
4698
+ var _a;
4699
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShow(...args);
4700
+ };
4701
+ }
4702
+ if (vnode.props && vnode.props.onTippyShown) {
4703
+ opts.onShown = function (...args) {
4704
+ var _a;
4705
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShown(...args);
4706
+ };
4707
+ }
4708
+ if (vnode.props && vnode.props.onTippyHidden) {
4709
+ opts.onHidden = function (...args) {
4710
+ var _a;
4711
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHidden(...args);
4712
+ };
4713
+ }
4714
+ if (vnode.props && vnode.props.onTippyHide) {
4715
+ opts.onHide = function (...args) {
4716
+ var _a;
4717
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHide(...args);
4718
+ };
4719
+ }
4720
+ if (vnode.props && vnode.props.onTippyMount) {
4721
+ opts.onMount = function (...args) {
4722
+ var _a;
4723
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyMount(...args);
4724
+ };
4725
+ }
4726
+ if (el.getAttribute('title') && !opts.content) {
4727
+ opts.content = el.getAttribute('title');
4728
+ el.removeAttribute('title');
4729
+ }
4730
+ if (el.getAttribute('content') && !opts.content) {
4731
+ opts.content = el.getAttribute('content');
4732
+ }
4733
+ useTippy(el, opts);
4734
+ },
4735
+ unmounted(el) {
4736
+ if (el.$tippy) {
4737
+ el.$tippy.destroy();
4738
+ }
4739
+ else if (el._tippy) {
4740
+ el._tippy.destroy();
4741
+ }
4742
+ },
4743
+ updated(el, binding) {
4744
+ const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
4745
+ if (el.getAttribute('title') && !opts.content) {
4746
+ opts.content = el.getAttribute('title');
4747
+ el.removeAttribute('title');
4748
+ }
4749
+ if (el.getAttribute('content') && !opts.content) {
4750
+ opts.content = el.getAttribute('content');
4751
+ }
4752
+ if (el.$tippy) {
4753
+ el.$tippy.setProps(opts || {});
4754
+ }
4755
+ else if (el._tippy) {
4756
+ el._tippy.setProps(opts || {});
4757
+ }
4758
+ },
4759
+ };
4760
+
4761
+ const plugin = {
4762
+ install(app, options = {}) {
4763
+ tippy.setDefaultProps(options.defaultProps || {});
4764
+ app.directive(options.directive || 'tippy', directive);
4765
+ app.component(options.component || 'tippy', TippyComponent);
4766
+ app.component(options.componentSingleton || 'tippy-singleton', TippySingleton);
4767
+ },
4768
+ };
4769
+
4770
+ const setDefaultProps$1 = tippy.setDefaultProps;
4771
+ setDefaultProps$1({
4772
+ ignoreAttributes: true,
4773
+ plugins: [sticky, inlinePositioning, followCursor, animateFill],
4774
+ });
4775
+
4776
+ exports.Tippy = TippyComponent;
4777
+ exports.TippySingleton = TippySingleton;
4778
+ exports.default = plugin;
4779
+ exports.directive = directive;
4780
+ exports.plugin = plugin;
4781
+ exports.roundArrow = ROUND_ARROW;
4782
+ exports.setDefaultProps = setDefaultProps$1;
4783
+ exports.tippy = tippy;
4784
+ exports.useSingleton = useSingleton;
4785
+ exports.useTippy = useTippy;
4786
+ exports.useTippyComponent = useTippyComponent;
4787
+
4788
+ Object.defineProperty(exports, '__esModule', { value: true });
4789
+
4790
+ return exports;
4791
+
4792
+ }({}, Vue));