react-shepherd 3.3.1 → 3.3.6

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.
package/dist/Shepherd.js CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var React = require('react');
8
- var React__default = _interopDefault(React);
9
6
 
10
- /*! shepherd.js 8.0.2 */
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
10
 
11
+ /*! shepherd.js 8.3.1 */
12
12
  var isMergeableObject = function isMergeableObject(value) {
13
13
  return isNonNullObject(value) && !isSpecial(value);
14
14
  };
@@ -133,12 +133,12 @@ deepmerge.all = function deepmergeAll(array, options) {
133
133
 
134
134
  var deepmerge_1 = deepmerge;
135
135
  var cjs = deepmerge_1;
136
-
137
136
  /**
138
137
  * Checks if `value` is classified as an `Element`.
139
138
  * @param {*} value The param to check if it is an Element
140
139
  */
141
- function isElement(value) {
140
+
141
+ function isElement$1(value) {
142
142
  return value instanceof Element;
143
143
  }
144
144
  /**
@@ -146,7 +146,8 @@ function isElement(value) {
146
146
  * @param {*} value The param to check if it is an HTMLElement
147
147
  */
148
148
 
149
- function isHTMLElement(value) {
149
+
150
+ function isHTMLElement$1(value) {
150
151
  return value instanceof HTMLElement;
151
152
  }
152
153
  /**
@@ -154,6 +155,7 @@ function isHTMLElement(value) {
154
155
  * @param {*} value The param to check if it is a function
155
156
  */
156
157
 
158
+
157
159
  function isFunction(value) {
158
160
  return typeof value === 'function';
159
161
  }
@@ -162,6 +164,7 @@ function isFunction(value) {
162
164
  * @param {*} value The param to check if it is a string
163
165
  */
164
166
 
167
+
165
168
  function isString(value) {
166
169
  return typeof value === 'string';
167
170
  }
@@ -170,6 +173,7 @@ function isString(value) {
170
173
  * @param {*} value The param to check if it is undefined
171
174
  */
172
175
 
176
+
173
177
  function isUndefined(value) {
174
178
  return value === undefined;
175
179
  }
@@ -235,13 +239,14 @@ class Evented {
235
239
  }
236
240
 
237
241
  }
238
-
239
242
  /**
240
243
  * Binds all the methods on a JS Class to the `this` context of the class.
241
244
  * Adapted from https://github.com/sindresorhus/auto-bind
242
245
  * @param {object} self The `this` context of the class
243
246
  * @return {object} The `this` context of the class
244
247
  */
248
+
249
+
245
250
  function autoBind(self) {
246
251
  const keys = Object.getOwnPropertyNames(self.constructor.prototype);
247
252
 
@@ -256,7 +261,6 @@ function autoBind(self) {
256
261
 
257
262
  return self;
258
263
  }
259
-
260
264
  /**
261
265
  * Sets up the handler to determine if we should advance the tour
262
266
  * @param {string} selector
@@ -265,6 +269,7 @@ function autoBind(self) {
265
269
  * @private
266
270
  */
267
271
 
272
+
268
273
  function _setupAdvanceOnHandler(selector, step) {
269
274
  return event => {
270
275
  if (step.isOpen()) {
@@ -319,243 +324,285 @@ function bindAdvance(step) {
319
324
  }
320
325
  }
321
326
 
322
- function getBoundingClientRect(element) {
323
- var rect = element.getBoundingClientRect();
324
- return {
325
- width: rect.width,
326
- height: rect.height,
327
- top: rect.top,
328
- right: rect.right,
329
- bottom: rect.bottom,
330
- left: rect.left,
331
- x: rect.left,
332
- y: rect.top
333
- };
334
- }
327
+ var top = 'top';
328
+ var bottom = 'bottom';
329
+ var right = 'right';
330
+ var left = 'left';
331
+ var auto = 'auto';
332
+ var basePlacements = [top, bottom, right, left];
333
+ var start = 'start';
334
+ var end = 'end';
335
+ var clippingParents = 'clippingParents';
336
+ var viewport = 'viewport';
337
+ var popper = 'popper';
338
+ var reference = 'reference';
339
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
340
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
341
+ }, []);
342
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
343
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
344
+ }, []); // modifiers that need to read the DOM
345
+
346
+ var beforeRead = 'beforeRead';
347
+ var read = 'read';
348
+ var afterRead = 'afterRead'; // pure-logic modifiers
335
349
 
336
- /*:: import type { Window } from '../types'; */
350
+ var beforeMain = 'beforeMain';
351
+ var main = 'main';
352
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
353
+
354
+ var beforeWrite = 'beforeWrite';
355
+ var write = 'write';
356
+ var afterWrite = 'afterWrite';
357
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
358
+
359
+ function getNodeName(element) {
360
+ return element ? (element.nodeName || '').toLowerCase() : null;
361
+ }
337
362
 
338
- /*:: declare function getWindow(node: Node | Window): Window; */
339
363
  function getWindow(node) {
364
+ if (node == null) {
365
+ return window;
366
+ }
367
+
340
368
  if (node.toString() !== '[object Window]') {
341
369
  var ownerDocument = node.ownerDocument;
342
- return ownerDocument ? ownerDocument.defaultView : window;
370
+ return ownerDocument ? ownerDocument.defaultView || window : window;
343
371
  }
344
372
 
345
373
  return node;
346
374
  }
347
375
 
348
- function getWindowScroll(node) {
349
- var win = getWindow(node);
350
- var scrollLeft = win.pageXOffset;
351
- var scrollTop = win.pageYOffset;
352
- return {
353
- scrollLeft: scrollLeft,
354
- scrollTop: scrollTop
355
- };
356
- }
357
-
358
- /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
359
- Element); */
360
-
361
- function isElement$1(node) {
376
+ function isElement(node) {
362
377
  var OwnElement = getWindow(node).Element;
363
378
  return node instanceof OwnElement || node instanceof Element;
364
379
  }
365
- /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
366
- HTMLElement); */
367
380
 
368
-
369
- function isHTMLElement$1(node) {
381
+ function isHTMLElement(node) {
370
382
  var OwnElement = getWindow(node).HTMLElement;
371
383
  return node instanceof OwnElement || node instanceof HTMLElement;
372
384
  }
373
385
 
374
- function getHTMLElementScroll(element) {
375
- return {
376
- scrollLeft: element.scrollLeft,
377
- scrollTop: element.scrollTop
378
- };
379
- }
380
-
381
- function getNodeScroll(node) {
382
- if (node === getWindow(node) || !isHTMLElement$1(node)) {
383
- return getWindowScroll(node);
384
- } else {
385
- return getHTMLElementScroll(node);
386
+ function isShadowRoot(node) {
387
+ // IE 11 has no ShadowRoot
388
+ if (typeof ShadowRoot === 'undefined') {
389
+ return false;
386
390
  }
387
- }
388
391
 
389
- function getNodeName(element) {
390
- return element ? (element.nodeName || '').toLowerCase() : null;
391
- }
392
+ var OwnElement = getWindow(node).ShadowRoot;
393
+ return node instanceof OwnElement || node instanceof ShadowRoot;
394
+ } // and applies them to the HTMLElements such as popper and arrow
392
395
 
393
- function getDocumentElement(element) {
394
- // $FlowFixMe: assume body is always available
395
- return (isElement$1(element) ? element.ownerDocument : element.document).documentElement;
396
- }
397
396
 
398
- function getWindowScrollBarX(element) {
399
- // If <html> has a CSS width greater than the viewport, then this will be
400
- // incorrect for RTL.
401
- // Popper 1 is broken in this case and never had a bug report so let's assume
402
- // it's not an issue. I don't think anyone ever specifies width on <html>
403
- // anyway.
404
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
405
- // this (e.g. Edge 2019, IE11, Safari)
406
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
407
- }
397
+ function applyStyles(_ref) {
398
+ var state = _ref.state;
399
+ Object.keys(state.elements).forEach(function (name) {
400
+ var style = state.styles[name] || {};
401
+ var attributes = state.attributes[name] || {};
402
+ var element = state.elements[name]; // arrow is optional + virtual elements
408
403
 
409
- function getComputedStyle(element) {
410
- return getWindow(element).getComputedStyle(element);
411
- }
404
+ if (!isHTMLElement(element) || !getNodeName(element)) {
405
+ return;
406
+ } // Flow doesn't support to extend this property, but it's the most
407
+ // effective way to apply styles to an HTMLElement
408
+ // $FlowFixMe[cannot-write]
412
409
 
413
- function isScrollParent(element) {
414
- // Firefox wants us to check `-x` and `-y` variations as well
415
- var _getComputedStyle = getComputedStyle(element),
416
- overflow = _getComputedStyle.overflow,
417
- overflowX = _getComputedStyle.overflowX,
418
- overflowY = _getComputedStyle.overflowY;
419
410
 
420
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
411
+ Object.assign(element.style, style);
412
+ Object.keys(attributes).forEach(function (name) {
413
+ var value = attributes[name];
414
+
415
+ if (value === false) {
416
+ element.removeAttribute(name);
417
+ } else {
418
+ element.setAttribute(name, value === true ? '' : value);
419
+ }
420
+ });
421
+ });
421
422
  }
422
423
 
423
- // Composite means it takes into account transforms as well as layout.
424
+ function effect$2(_ref2) {
425
+ var state = _ref2.state;
426
+ var initialStyles = {
427
+ popper: {
428
+ position: state.options.strategy,
429
+ left: '0',
430
+ top: '0',
431
+ margin: '0'
432
+ },
433
+ arrow: {
434
+ position: 'absolute'
435
+ },
436
+ reference: {}
437
+ };
438
+ Object.assign(state.elements.popper.style, initialStyles.popper);
439
+ state.styles = initialStyles;
424
440
 
425
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
426
- if (isFixed === void 0) {
427
- isFixed = false;
441
+ if (state.elements.arrow) {
442
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
428
443
  }
429
444
 
430
- var documentElement = getDocumentElement(offsetParent);
431
- var rect = getBoundingClientRect(elementOrVirtualElement);
432
- var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
433
- var scroll = {
434
- scrollLeft: 0,
435
- scrollTop: 0
436
- };
437
- var offsets = {
438
- x: 0,
439
- y: 0
445
+ return function () {
446
+ Object.keys(state.elements).forEach(function (name) {
447
+ var element = state.elements[name];
448
+ var attributes = state.attributes[name] || {};
449
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
450
+
451
+ var style = styleProperties.reduce(function (style, property) {
452
+ style[property] = '';
453
+ return style;
454
+ }, {}); // arrow is optional + virtual elements
455
+
456
+ if (!isHTMLElement(element) || !getNodeName(element)) {
457
+ return;
458
+ }
459
+
460
+ Object.assign(element.style, style);
461
+ Object.keys(attributes).forEach(function (attribute) {
462
+ element.removeAttribute(attribute);
463
+ });
464
+ });
440
465
  };
466
+ } // eslint-disable-next-line import/no-unused-modules
441
467
 
442
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
443
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
444
- isScrollParent(documentElement)) {
445
- scroll = getNodeScroll(offsetParent);
446
- }
447
468
 
448
- if (isHTMLElement$1(offsetParent)) {
449
- offsets = getBoundingClientRect(offsetParent);
450
- offsets.x += offsetParent.clientLeft;
451
- offsets.y += offsetParent.clientTop;
452
- } else if (documentElement) {
453
- offsets.x = getWindowScrollBarX(documentElement);
454
- }
455
- }
469
+ var applyStyles$1 = {
470
+ name: 'applyStyles',
471
+ enabled: true,
472
+ phase: 'write',
473
+ fn: applyStyles,
474
+ effect: effect$2,
475
+ requires: ['computeStyles']
476
+ };
477
+
478
+ function getBasePlacement(placement) {
479
+ return placement.split('-')[0];
480
+ }
456
481
 
482
+ function getBoundingClientRect(element) {
483
+ var rect = element.getBoundingClientRect();
457
484
  return {
458
- x: rect.left + scroll.scrollLeft - offsets.x,
459
- y: rect.top + scroll.scrollTop - offsets.y,
460
485
  width: rect.width,
461
- height: rect.height
486
+ height: rect.height,
487
+ top: rect.top,
488
+ right: rect.right,
489
+ bottom: rect.bottom,
490
+ left: rect.left,
491
+ x: rect.left,
492
+ y: rect.top
462
493
  };
463
- }
494
+ } // means it doesn't take into account transforms.
495
+
464
496
 
465
- // Returns the layout rect of an element relative to its offsetParent. Layout
466
- // means it doesn't take into account transforms.
467
497
  function getLayoutRect(element) {
498
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
499
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
500
+
501
+ var width = element.offsetWidth;
502
+ var height = element.offsetHeight;
503
+
504
+ if (Math.abs(clientRect.width - width) <= 1) {
505
+ width = clientRect.width;
506
+ }
507
+
508
+ if (Math.abs(clientRect.height - height) <= 1) {
509
+ height = clientRect.height;
510
+ }
511
+
468
512
  return {
469
513
  x: element.offsetLeft,
470
514
  y: element.offsetTop,
471
- width: element.offsetWidth,
472
- height: element.offsetHeight
515
+ width: width,
516
+ height: height
473
517
  };
474
518
  }
475
519
 
520
+ function contains(parent, child) {
521
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
522
+
523
+ if (parent.contains(child)) {
524
+ return true;
525
+ } // then fallback to custom implementation with Shadow DOM support
526
+ else if (rootNode && isShadowRoot(rootNode)) {
527
+ var next = child;
528
+
529
+ do {
530
+ if (next && parent.isSameNode(next)) {
531
+ return true;
532
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
533
+
534
+
535
+ next = next.parentNode || next.host;
536
+ } while (next);
537
+ } // Give up, the result is false
538
+
539
+
540
+ return false;
541
+ }
542
+
543
+ function getComputedStyle(element) {
544
+ return getWindow(element).getComputedStyle(element);
545
+ }
546
+
547
+ function isTableElement(element) {
548
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
549
+ }
550
+
551
+ function getDocumentElement(element) {
552
+ // $FlowFixMe[incompatible-return]: assume body is always available
553
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
554
+ element.document) || window.document).documentElement;
555
+ }
556
+
476
557
  function getParentNode(element) {
477
558
  if (getNodeName(element) === 'html') {
478
559
  return element;
479
560
  }
480
561
 
481
- return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
562
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
563
+ // $FlowFixMe[incompatible-return]
564
+ // $FlowFixMe[prop-missing]
482
565
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
483
- element.parentNode || // DOM Element detected
484
- // $FlowFixMe: need a better way to handle this...
485
- element.host || // ShadowRoot detected
486
- // $FlowFixMe: HTMLElement is a Node
566
+ element.parentNode || ( // DOM Element detected
567
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
568
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
487
569
  getDocumentElement(element) // fallback
488
570
 
489
571
  );
490
572
  }
491
573
 
492
- function getScrollParent(node) {
493
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
494
- // $FlowFixMe: assume body is always available
495
- return node.ownerDocument.body;
496
- }
497
-
498
- if (isHTMLElement$1(node) && isScrollParent(node)) {
499
- return node;
500
- }
501
-
502
- return getScrollParent(getParentNode(node));
503
- }
504
-
505
- /*
506
- given a DOM element, return the list of all scroll parents, up the list of ancesors
507
- until we get to the top window object. This list is what we attach scroll listeners
508
- to, because if any of these parent elements scroll, we'll need to re-calculate the
509
- reference element's position.
510
- */
511
-
512
- function listScrollParents(element, list) {
513
- if (list === void 0) {
514
- list = [];
515
- }
516
-
517
- var scrollParent = getScrollParent(element);
518
- var isBody = getNodeName(scrollParent) === 'body';
519
- var win = getWindow(scrollParent);
520
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
521
- var updatedList = list.concat(target);
522
- return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
523
- updatedList.concat(listScrollParents(getParentNode(target)));
524
- }
525
-
526
- function isTableElement(element) {
527
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
528
- }
529
-
530
574
  function getTrueOffsetParent(element) {
531
- if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
575
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
532
576
  getComputedStyle(element).position === 'fixed') {
533
577
  return null;
534
578
  }
535
579
 
536
- var offsetParent = element.offsetParent;
537
-
538
- if (offsetParent) {
539
- var html = getDocumentElement(offsetParent);
540
-
541
- if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
542
- return html;
543
- }
544
- }
545
-
546
- return offsetParent;
580
+ return element.offsetParent;
547
581
  } // `.offsetParent` reports `null` for fixed elements, while absolute elements
548
582
  // return the containing block
549
583
 
550
584
 
551
585
  function getContainingBlock(element) {
586
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
587
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
588
+
589
+ if (isIE && isHTMLElement(element)) {
590
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
591
+ var elementCss = getComputedStyle(element);
592
+
593
+ if (elementCss.position === 'fixed') {
594
+ return null;
595
+ }
596
+ }
597
+
552
598
  var currentNode = getParentNode(element);
553
599
 
554
- while (isHTMLElement$1(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
600
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
555
601
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
556
602
  // create a containing block.
603
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
557
604
 
558
- if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
605
+ 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') {
559
606
  return currentNode;
560
607
  } else {
561
608
  currentNode = currentNode.parentNode;
@@ -575,630 +622,279 @@ function getOffsetParent(element) {
575
622
  offsetParent = getTrueOffsetParent(offsetParent);
576
623
  }
577
624
 
578
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
625
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
579
626
  return window;
580
627
  }
581
628
 
582
629
  return offsetParent || getContainingBlock(element) || window;
583
630
  }
584
631
 
585
- var top = 'top';
586
- var bottom = 'bottom';
587
- var right = 'right';
588
- var left = 'left';
589
- var auto = 'auto';
590
- var basePlacements = [top, bottom, right, left];
591
- var start = 'start';
592
- var end = 'end';
593
- var clippingParents = 'clippingParents';
594
- var viewport = 'viewport';
595
- var popper = 'popper';
596
- var reference = 'reference';
597
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
598
- return acc.concat([placement + "-" + start, placement + "-" + end]);
599
- }, []);
600
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
601
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
602
- }, []); // modifiers that need to read the DOM
603
-
604
- var beforeRead = 'beforeRead';
605
- var read = 'read';
606
- var afterRead = 'afterRead'; // pure-logic modifiers
607
-
608
- var beforeMain = 'beforeMain';
609
- var main = 'main';
610
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
611
-
612
- var beforeWrite = 'beforeWrite';
613
- var write = 'write';
614
- var afterWrite = 'afterWrite';
615
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
616
-
617
- function order(modifiers) {
618
- var map = new Map();
619
- var visited = new Set();
620
- var result = [];
621
- modifiers.forEach(function (modifier) {
622
- map.set(modifier.name, modifier);
623
- }); // On visiting object, check for its dependencies and visit them recursively
624
-
625
- function sort(modifier) {
626
- visited.add(modifier.name);
627
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
628
- requires.forEach(function (dep) {
629
- if (!visited.has(dep)) {
630
- var depModifier = map.get(dep);
631
-
632
- if (depModifier) {
633
- sort(depModifier);
634
- }
635
- }
636
- });
637
- result.push(modifier);
638
- }
639
-
640
- modifiers.forEach(function (modifier) {
641
- if (!visited.has(modifier.name)) {
642
- // check for visited object
643
- sort(modifier);
644
- }
645
- });
646
- return result;
632
+ function getMainAxisFromPlacement(placement) {
633
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
647
634
  }
648
635
 
649
- function orderModifiers(modifiers) {
650
- // order based on dependencies
651
- var orderedModifiers = order(modifiers); // order based on phase
636
+ var max = Math.max;
637
+ var min = Math.min;
638
+ var round = Math.round;
652
639
 
653
- return modifierPhases.reduce(function (acc, phase) {
654
- return acc.concat(orderedModifiers.filter(function (modifier) {
655
- return modifier.phase === phase;
656
- }));
657
- }, []);
640
+ function within(min$1, value, max$1) {
641
+ return max(min$1, min(value, max$1));
658
642
  }
659
643
 
660
- function debounce(fn) {
661
- var pending;
662
- return function () {
663
- if (!pending) {
664
- pending = new Promise(function (resolve) {
665
- Promise.resolve().then(function () {
666
- pending = undefined;
667
- resolve(fn());
668
- });
669
- });
670
- }
671
-
672
- return pending;
644
+ function getFreshSideObject() {
645
+ return {
646
+ top: 0,
647
+ right: 0,
648
+ bottom: 0,
649
+ left: 0
673
650
  };
674
651
  }
675
652
 
676
- function getBasePlacement(placement) {
677
- return placement.split('-')[0];
653
+ function mergePaddingObject(paddingObject) {
654
+ return Object.assign({}, getFreshSideObject(), paddingObject);
678
655
  }
679
656
 
680
- function mergeByName(modifiers) {
681
- var merged = modifiers.reduce(function (merged, current) {
682
- var existing = merged[current.name];
683
- merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
684
- options: Object.assign(Object.assign({}, existing.options), current.options),
685
- data: Object.assign(Object.assign({}, existing.data), current.data)
686
- }) : current;
687
- return merged;
688
- }, {}); // IE11 does not support Object.values
689
-
690
- return Object.keys(merged).map(function (key) {
691
- return merged[key];
692
- });
657
+ function expandToHashMap(value, keys) {
658
+ return keys.reduce(function (hashMap, key) {
659
+ hashMap[key] = value;
660
+ return hashMap;
661
+ }, {});
693
662
  }
694
663
 
695
- function getViewportRect(element) {
696
- var win = getWindow(element);
697
- var html = getDocumentElement(element);
698
- var visualViewport = win.visualViewport;
699
- var width = html.clientWidth;
700
- var height = html.clientHeight;
701
- var x = 0;
702
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
703
- // can be obscured underneath it.
704
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
705
- // if it isn't open, so if this isn't available, the popper will be detected
706
- // to overflow the bottom of the screen too early.
707
-
708
- if (visualViewport) {
709
- width = visualViewport.width;
710
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
711
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
712
- // errors due to floating point numbers, so we need to check precision.
713
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
714
- // Feature detection fails in mobile emulation mode in Chrome.
715
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
716
- // 0.001
717
- // Fallback here: "Not Safari" userAgent
664
+ var toPaddingObject = function toPaddingObject(padding, state) {
665
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
666
+ placement: state.placement
667
+ })) : padding;
668
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
669
+ };
718
670
 
719
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
720
- x = visualViewport.offsetLeft;
721
- y = visualViewport.offsetTop;
722
- }
723
- }
671
+ function arrow(_ref) {
672
+ var _state$modifiersData$;
724
673
 
725
- return {
726
- width: width,
727
- height: height,
728
- x: x + getWindowScrollBarX(element),
729
- y: y
730
- };
731
- }
674
+ var state = _ref.state,
675
+ name = _ref.name,
676
+ options = _ref.options;
677
+ var arrowElement = state.elements.arrow;
678
+ var popperOffsets = state.modifiersData.popperOffsets;
679
+ var basePlacement = getBasePlacement(state.placement);
680
+ var axis = getMainAxisFromPlacement(basePlacement);
681
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
682
+ var len = isVertical ? 'height' : 'width';
732
683
 
733
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
684
+ if (!arrowElement || !popperOffsets) {
685
+ return;
686
+ }
734
687
 
735
- function getDocumentRect(element) {
736
- var html = getDocumentElement(element);
737
- var winScroll = getWindowScroll(element);
738
- var body = element.ownerDocument.body;
739
- var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
740
- var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
741
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
742
- var y = -winScroll.scrollTop;
688
+ var paddingObject = toPaddingObject(options.padding, state);
689
+ var arrowRect = getLayoutRect(arrowElement);
690
+ var minProp = axis === 'y' ? top : left;
691
+ var maxProp = axis === 'y' ? bottom : right;
692
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
693
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
694
+ var arrowOffsetParent = getOffsetParent(arrowElement);
695
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
696
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
697
+ // outside of the popper bounds
743
698
 
744
- if (getComputedStyle(body || html).direction === 'rtl') {
745
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
746
- }
699
+ var min = paddingObject[minProp];
700
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
701
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
702
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
747
703
 
748
- return {
749
- width: width,
750
- height: height,
751
- x: x,
752
- y: y
753
- };
704
+ var axisProp = axis;
705
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
754
706
  }
755
707
 
756
- function contains(parent, child) {
757
- // $FlowFixMe: hasOwnProperty doesn't seem to work in tests
758
- var isShadow = Boolean(child.getRootNode && child.getRootNode().host); // First, attempt with faster native method
708
+ function effect$1(_ref2) {
709
+ var state = _ref2.state,
710
+ options = _ref2.options;
711
+ var _options$element = options.element,
712
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
759
713
 
760
- if (parent.contains(child)) {
761
- return true;
762
- } // then fallback to custom implementation with Shadow DOM support
763
- else if (isShadow) {
764
- var next = child;
714
+ if (arrowElement == null) {
715
+ return;
716
+ } // CSS selector
765
717
 
766
- do {
767
- if (next && parent.isSameNode(next)) {
768
- return true;
769
- } // $FlowFixMe: need a better way to handle this...
770
718
 
719
+ if (typeof arrowElement === 'string') {
720
+ arrowElement = state.elements.popper.querySelector(arrowElement);
771
721
 
772
- next = next.parentNode || next.host;
773
- } while (next);
774
- } // Give up, the result is false
722
+ if (!arrowElement) {
723
+ return;
724
+ }
725
+ }
775
726
 
727
+ if (!contains(state.elements.popper, arrowElement)) {
728
+ return;
729
+ }
776
730
 
777
- return false;
778
- }
731
+ state.elements.arrow = arrowElement;
732
+ } // eslint-disable-next-line import/no-unused-modules
779
733
 
780
- function rectToClientRect(rect) {
781
- return Object.assign(Object.assign({}, rect), {}, {
782
- left: rect.x,
783
- top: rect.y,
784
- right: rect.x + rect.width,
785
- bottom: rect.y + rect.height
786
- });
787
- }
788
-
789
- function getInnerBoundingClientRect(element) {
790
- var rect = getBoundingClientRect(element);
791
- rect.top = rect.top + element.clientTop;
792
- rect.left = rect.left + element.clientLeft;
793
- rect.bottom = rect.top + element.clientHeight;
794
- rect.right = rect.left + element.clientWidth;
795
- rect.width = element.clientWidth;
796
- rect.height = element.clientHeight;
797
- rect.x = rect.left;
798
- rect.y = rect.top;
799
- return rect;
800
- }
801
-
802
- function getClientRectFromMixedType(element, clippingParent) {
803
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
804
- } // A "clipping parent" is an overflowable container with the characteristic of
805
- // clipping (or hiding) overflowing elements with a position different from
806
- // `initial`
807
734
 
735
+ var arrow$1 = {
736
+ name: 'arrow',
737
+ enabled: true,
738
+ phase: 'main',
739
+ fn: arrow,
740
+ effect: effect$1,
741
+ requires: ['popperOffsets'],
742
+ requiresIfExists: ['preventOverflow']
743
+ };
744
+ var unsetSides = {
745
+ top: 'auto',
746
+ right: 'auto',
747
+ bottom: 'auto',
748
+ left: 'auto'
749
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
750
+ // Zooming can change the DPR, but it seems to report a value that will
751
+ // cleanly divide the values into the appropriate subpixels.
808
752
 
809
- function getClippingParents(element) {
810
- var clippingParents = listScrollParents(getParentNode(element));
811
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
812
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
753
+ function roundOffsetsByDPR(_ref) {
754
+ var x = _ref.x,
755
+ y = _ref.y;
756
+ var win = window;
757
+ var dpr = win.devicePixelRatio || 1;
758
+ return {
759
+ x: round(round(x * dpr) / dpr) || 0,
760
+ y: round(round(y * dpr) / dpr) || 0
761
+ };
762
+ }
813
763
 
814
- if (!isElement$1(clipperElement)) {
815
- return [];
816
- } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
764
+ function mapToStyles(_ref2) {
765
+ var _Object$assign2;
817
766
 
767
+ var popper = _ref2.popper,
768
+ popperRect = _ref2.popperRect,
769
+ placement = _ref2.placement,
770
+ offsets = _ref2.offsets,
771
+ position = _ref2.position,
772
+ gpuAcceleration = _ref2.gpuAcceleration,
773
+ adaptive = _ref2.adaptive,
774
+ roundOffsets = _ref2.roundOffsets;
818
775
 
819
- return clippingParents.filter(function (clippingParent) {
820
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
821
- });
822
- } // Gets the maximum area that the element is visible in due to any number of
823
- // clipping parents
776
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
777
+ _ref3$x = _ref3.x,
778
+ x = _ref3$x === void 0 ? 0 : _ref3$x,
779
+ _ref3$y = _ref3.y,
780
+ y = _ref3$y === void 0 ? 0 : _ref3$y;
824
781
 
782
+ var hasX = offsets.hasOwnProperty('x');
783
+ var hasY = offsets.hasOwnProperty('y');
784
+ var sideX = left;
785
+ var sideY = top;
786
+ var win = window;
825
787
 
826
- function getClippingRect(element, boundary, rootBoundary) {
827
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
828
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
829
- var firstClippingParent = clippingParents[0];
830
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
831
- var rect = getClientRectFromMixedType(element, clippingParent);
832
- accRect.top = Math.max(rect.top, accRect.top);
833
- accRect.right = Math.min(rect.right, accRect.right);
834
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
835
- accRect.left = Math.max(rect.left, accRect.left);
836
- return accRect;
837
- }, getClientRectFromMixedType(element, firstClippingParent));
838
- clippingRect.width = clippingRect.right - clippingRect.left;
839
- clippingRect.height = clippingRect.bottom - clippingRect.top;
840
- clippingRect.x = clippingRect.left;
841
- clippingRect.y = clippingRect.top;
842
- return clippingRect;
843
- }
788
+ if (adaptive) {
789
+ var offsetParent = getOffsetParent(popper);
790
+ var heightProp = 'clientHeight';
791
+ var widthProp = 'clientWidth';
844
792
 
845
- function getVariation(placement) {
846
- return placement.split('-')[1];
847
- }
793
+ if (offsetParent === getWindow(popper)) {
794
+ offsetParent = getDocumentElement(popper);
848
795
 
849
- function getMainAxisFromPlacement(placement) {
850
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
851
- }
796
+ if (getComputedStyle(offsetParent).position !== 'static') {
797
+ heightProp = 'scrollHeight';
798
+ widthProp = 'scrollWidth';
799
+ }
800
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
852
801
 
853
- function computeOffsets(_ref) {
854
- var reference = _ref.reference,
855
- element = _ref.element,
856
- placement = _ref.placement;
857
- var basePlacement = placement ? getBasePlacement(placement) : null;
858
- var variation = placement ? getVariation(placement) : null;
859
- var commonX = reference.x + reference.width / 2 - element.width / 2;
860
- var commonY = reference.y + reference.height / 2 - element.height / 2;
861
- var offsets;
862
802
 
863
- switch (basePlacement) {
864
- case top:
865
- offsets = {
866
- x: commonX,
867
- y: reference.y - element.height
868
- };
869
- break;
803
+ offsetParent = offsetParent;
870
804
 
871
- case bottom:
872
- offsets = {
873
- x: commonX,
874
- y: reference.y + reference.height
875
- };
876
- break;
805
+ if (placement === top) {
806
+ sideY = bottom; // $FlowFixMe[prop-missing]
877
807
 
878
- case right:
879
- offsets = {
880
- x: reference.x + reference.width,
881
- y: commonY
882
- };
883
- break;
808
+ y -= offsetParent[heightProp] - popperRect.height;
809
+ y *= gpuAcceleration ? 1 : -1;
810
+ }
884
811
 
885
- case left:
886
- offsets = {
887
- x: reference.x - element.width,
888
- y: commonY
889
- };
890
- break;
812
+ if (placement === left) {
813
+ sideX = right; // $FlowFixMe[prop-missing]
891
814
 
892
- default:
893
- offsets = {
894
- x: reference.x,
895
- y: reference.y
896
- };
815
+ x -= offsetParent[widthProp] - popperRect.width;
816
+ x *= gpuAcceleration ? 1 : -1;
817
+ }
897
818
  }
898
819
 
899
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
900
-
901
- if (mainAxis != null) {
902
- var len = mainAxis === 'y' ? 'height' : 'width';
820
+ var commonStyles = Object.assign({
821
+ position: position
822
+ }, adaptive && unsetSides);
903
823
 
904
- switch (variation) {
905
- case start:
906
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
907
- break;
824
+ if (gpuAcceleration) {
825
+ var _Object$assign;
908
826
 
909
- case end:
910
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
911
- break;
912
- }
827
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
913
828
  }
914
829
 
915
- return offsets;
830
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
916
831
  }
917
832
 
918
- function getFreshSideObject() {
919
- return {
920
- top: 0,
921
- right: 0,
922
- bottom: 0,
923
- left: 0
833
+ function computeStyles(_ref4) {
834
+ var state = _ref4.state,
835
+ options = _ref4.options;
836
+ var _options$gpuAccelerat = options.gpuAcceleration,
837
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
838
+ _options$adaptive = options.adaptive,
839
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
840
+ _options$roundOffsets = options.roundOffsets,
841
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
842
+ var commonStyles = {
843
+ placement: getBasePlacement(state.placement),
844
+ popper: state.elements.popper,
845
+ popperRect: state.rects.popper,
846
+ gpuAcceleration: gpuAcceleration
924
847
  };
925
- }
926
-
927
- function mergePaddingObject(paddingObject) {
928
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
929
- }
930
848
 
931
- function expandToHashMap(value, keys) {
932
- return keys.reduce(function (hashMap, key) {
933
- hashMap[key] = value;
934
- return hashMap;
935
- }, {});
936
- }
849
+ if (state.modifiersData.popperOffsets != null) {
850
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
851
+ offsets: state.modifiersData.popperOffsets,
852
+ position: state.options.strategy,
853
+ adaptive: adaptive,
854
+ roundOffsets: roundOffsets
855
+ })));
856
+ }
937
857
 
938
- function detectOverflow(state, options) {
939
- if (options === void 0) {
940
- options = {};
858
+ if (state.modifiersData.arrow != null) {
859
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
860
+ offsets: state.modifiersData.arrow,
861
+ position: 'absolute',
862
+ adaptive: false,
863
+ roundOffsets: roundOffsets
864
+ })));
941
865
  }
942
866
 
943
- var _options = options,
944
- _options$placement = _options.placement,
945
- placement = _options$placement === void 0 ? state.placement : _options$placement,
946
- _options$boundary = _options.boundary,
947
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
948
- _options$rootBoundary = _options.rootBoundary,
949
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
950
- _options$elementConte = _options.elementContext,
951
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
952
- _options$altBoundary = _options.altBoundary,
953
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
954
- _options$padding = _options.padding,
955
- padding = _options$padding === void 0 ? 0 : _options$padding;
956
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
957
- var altContext = elementContext === popper ? reference : popper;
958
- var referenceElement = state.elements.reference;
959
- var popperRect = state.rects.popper;
960
- var element = state.elements[altBoundary ? altContext : elementContext];
961
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
962
- var referenceClientRect = getBoundingClientRect(referenceElement);
963
- var popperOffsets = computeOffsets({
964
- reference: referenceClientRect,
965
- element: popperRect,
966
- strategy: 'absolute',
967
- placement: placement
867
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
868
+ 'data-popper-placement': state.placement
968
869
  });
969
- var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
970
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
971
- // 0 or negative = within the clipping rect
870
+ } // eslint-disable-next-line import/no-unused-modules
972
871
 
973
- var overflowOffsets = {
974
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
975
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
976
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
977
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
978
- };
979
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
980
872
 
981
- if (elementContext === popper && offsetData) {
982
- var offset = offsetData[placement];
983
- Object.keys(overflowOffsets).forEach(function (key) {
984
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
985
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
986
- overflowOffsets[key] += offset[axis] * multiply;
987
- });
988
- }
989
-
990
- return overflowOffsets;
991
- }
992
-
993
- var DEFAULT_OPTIONS = {
994
- placement: 'bottom',
995
- modifiers: [],
996
- strategy: 'absolute'
997
- };
998
-
999
- function areValidElements() {
1000
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1001
- args[_key] = arguments[_key];
1002
- }
1003
-
1004
- return !args.some(function (element) {
1005
- return !(element && typeof element.getBoundingClientRect === 'function');
1006
- });
1007
- }
1008
-
1009
- function popperGenerator(generatorOptions) {
1010
- if (generatorOptions === void 0) {
1011
- generatorOptions = {};
1012
- }
1013
-
1014
- var _generatorOptions = generatorOptions,
1015
- _generatorOptions$def = _generatorOptions.defaultModifiers,
1016
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1017
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
1018
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1019
- return function createPopper(reference, popper, options) {
1020
- if (options === void 0) {
1021
- options = defaultOptions;
1022
- }
1023
-
1024
- var state = {
1025
- placement: 'bottom',
1026
- orderedModifiers: [],
1027
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
1028
- modifiersData: {},
1029
- elements: {
1030
- reference: reference,
1031
- popper: popper
1032
- },
1033
- attributes: {},
1034
- styles: {}
1035
- };
1036
- var effectCleanupFns = [];
1037
- var isDestroyed = false;
1038
- var instance = {
1039
- state: state,
1040
- setOptions: function setOptions(options) {
1041
- cleanupModifierEffects();
1042
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
1043
- state.scrollParents = {
1044
- reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1045
- popper: listScrollParents(popper)
1046
- }; // Orders the modifiers based on their dependencies and `phase`
1047
- // properties
1048
-
1049
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1050
-
1051
- state.orderedModifiers = orderedModifiers.filter(function (m) {
1052
- return m.enabled;
1053
- }); // Validate the provided modifiers so that the consumer will get warned
1054
-
1055
- runModifierEffects();
1056
- return instance.update();
1057
- },
1058
- // Sync update – it will always be executed, even if not necessary. This
1059
- // is useful for low frequency updates where sync behavior simplifies the
1060
- // logic.
1061
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1062
- // prefer the async Popper#update method
1063
- forceUpdate: function forceUpdate() {
1064
- if (isDestroyed) {
1065
- return;
1066
- }
1067
-
1068
- var _state$elements = state.elements,
1069
- reference = _state$elements.reference,
1070
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1071
- // anymore
1072
-
1073
- if (!areValidElements(reference, popper)) {
1074
-
1075
- return;
1076
- } // Store the reference and popper rects to be read by modifiers
1077
-
1078
-
1079
- state.rects = {
1080
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1081
- popper: getLayoutRect(popper)
1082
- }; // Modifiers have the ability to reset the current update cycle. The
1083
- // most common use case for this is the `flip` modifier changing the
1084
- // placement, which then needs to re-run all the modifiers, because the
1085
- // logic was previously ran for the previous placement and is therefore
1086
- // stale/incorrect
1087
-
1088
- state.reset = false;
1089
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1090
- // is filled with the initial data specified by the modifier. This means
1091
- // it doesn't persist and is fresh on each update.
1092
- // To ensure persistent data, use `${name}#persistent`
1093
-
1094
- state.orderedModifiers.forEach(function (modifier) {
1095
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1096
- });
1097
-
1098
- for (var index = 0; index < state.orderedModifiers.length; index++) {
1099
-
1100
- if (state.reset === true) {
1101
- state.reset = false;
1102
- index = -1;
1103
- continue;
1104
- }
1105
-
1106
- var _state$orderedModifie = state.orderedModifiers[index],
1107
- fn = _state$orderedModifie.fn,
1108
- _state$orderedModifie2 = _state$orderedModifie.options,
1109
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1110
- name = _state$orderedModifie.name;
1111
-
1112
- if (typeof fn === 'function') {
1113
- state = fn({
1114
- state: state,
1115
- options: _options,
1116
- name: name,
1117
- instance: instance
1118
- }) || state;
1119
- }
1120
- }
1121
- },
1122
- // Async and optimistically optimized update – it will not be executed if
1123
- // not necessary (debounced to run at most once-per-tick)
1124
- update: debounce(function () {
1125
- return new Promise(function (resolve) {
1126
- instance.forceUpdate();
1127
- resolve(state);
1128
- });
1129
- }),
1130
- destroy: function destroy() {
1131
- cleanupModifierEffects();
1132
- isDestroyed = true;
1133
- }
1134
- };
1135
-
1136
- if (!areValidElements(reference, popper)) {
1137
-
1138
- return instance;
1139
- }
1140
-
1141
- instance.setOptions(options).then(function (state) {
1142
- if (!isDestroyed && options.onFirstUpdate) {
1143
- options.onFirstUpdate(state);
1144
- }
1145
- }); // Modifiers have the ability to execute arbitrary code before the first
1146
- // update cycle runs. They will be executed in the same order as the update
1147
- // cycle. This is useful when a modifier adds some persistent data that
1148
- // other modifiers need to use, but the modifier is run after the dependent
1149
- // one.
1150
-
1151
- function runModifierEffects() {
1152
- state.orderedModifiers.forEach(function (_ref3) {
1153
- var name = _ref3.name,
1154
- _ref3$options = _ref3.options,
1155
- options = _ref3$options === void 0 ? {} : _ref3$options,
1156
- effect = _ref3.effect;
1157
-
1158
- if (typeof effect === 'function') {
1159
- var cleanupFn = effect({
1160
- state: state,
1161
- name: name,
1162
- instance: instance,
1163
- options: options
1164
- });
1165
-
1166
- var noopFn = function noopFn() {};
1167
-
1168
- effectCleanupFns.push(cleanupFn || noopFn);
1169
- }
1170
- });
1171
- }
1172
-
1173
- function cleanupModifierEffects() {
1174
- effectCleanupFns.forEach(function (fn) {
1175
- return fn();
1176
- });
1177
- effectCleanupFns = [];
1178
- }
1179
-
1180
- return instance;
1181
- };
1182
- }
1183
-
1184
- var passive = {
1185
- passive: true
1186
- };
1187
-
1188
- function effect(_ref) {
1189
- var state = _ref.state,
1190
- instance = _ref.instance,
1191
- options = _ref.options;
1192
- var _options$scroll = options.scroll,
1193
- scroll = _options$scroll === void 0 ? true : _options$scroll,
1194
- _options$resize = options.resize,
1195
- resize = _options$resize === void 0 ? true : _options$resize;
1196
- var window = getWindow(state.elements.popper);
1197
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1198
-
1199
- if (scroll) {
1200
- scrollParents.forEach(function (scrollParent) {
1201
- scrollParent.addEventListener('scroll', instance.update, passive);
873
+ var computeStyles$1 = {
874
+ name: 'computeStyles',
875
+ enabled: true,
876
+ phase: 'beforeWrite',
877
+ fn: computeStyles,
878
+ data: {}
879
+ };
880
+ var passive = {
881
+ passive: true
882
+ };
883
+
884
+ function effect(_ref) {
885
+ var state = _ref.state,
886
+ instance = _ref.instance,
887
+ options = _ref.options;
888
+ var _options$scroll = options.scroll,
889
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
890
+ _options$resize = options.resize,
891
+ resize = _options$resize === void 0 ? true : _options$resize;
892
+ var window = getWindow(state.elements.popper);
893
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
894
+
895
+ if (scroll) {
896
+ scrollParents.forEach(function (scrollParent) {
897
+ scrollParent.addEventListener('scroll', instance.update, passive);
1202
898
  });
1203
899
  }
1204
900
 
@@ -1228,315 +924,347 @@ var eventListeners = {
1228
924
  effect: effect,
1229
925
  data: {}
1230
926
  };
927
+ var hash$1 = {
928
+ left: 'right',
929
+ right: 'left',
930
+ bottom: 'top',
931
+ top: 'bottom'
932
+ };
1231
933
 
1232
- function popperOffsets(_ref) {
1233
- var state = _ref.state,
1234
- name = _ref.name; // Offsets are the actual position the popper needs to have to be
1235
- // properly positioned near its reference element
1236
- // This is the most basic placement, and will be adjusted by
1237
- // the modifiers in the next step
1238
-
1239
- state.modifiersData[name] = computeOffsets({
1240
- reference: state.rects.reference,
1241
- element: state.rects.popper,
1242
- strategy: 'absolute',
1243
- placement: state.placement
934
+ function getOppositePlacement(placement) {
935
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
936
+ return hash$1[matched];
1244
937
  });
1245
- } // eslint-disable-next-line import/no-unused-modules
1246
-
938
+ }
1247
939
 
1248
- var popperOffsets$1 = {
1249
- name: 'popperOffsets',
1250
- enabled: true,
1251
- phase: 'read',
1252
- fn: popperOffsets,
1253
- data: {}
940
+ var hash = {
941
+ start: 'end',
942
+ end: 'start'
1254
943
  };
1255
944
 
1256
- var unsetSides = {
1257
- top: 'auto',
1258
- right: 'auto',
1259
- bottom: 'auto',
1260
- left: 'auto'
1261
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1262
- // Zooming can change the DPR, but it seems to report a value that will
1263
- // cleanly divide the values into the appropriate subpixels.
945
+ function getOppositeVariationPlacement(placement) {
946
+ return placement.replace(/start|end/g, function (matched) {
947
+ return hash[matched];
948
+ });
949
+ }
1264
950
 
1265
- function roundOffsets(_ref) {
1266
- var x = _ref.x,
1267
- y = _ref.y;
1268
- var win = window;
1269
- var dpr = win.devicePixelRatio || 1;
951
+ function getWindowScroll(node) {
952
+ var win = getWindow(node);
953
+ var scrollLeft = win.pageXOffset;
954
+ var scrollTop = win.pageYOffset;
1270
955
  return {
1271
- x: Math.round(x * dpr) / dpr || 0,
1272
- y: Math.round(y * dpr) / dpr || 0
956
+ scrollLeft: scrollLeft,
957
+ scrollTop: scrollTop
1273
958
  };
1274
959
  }
1275
960
 
1276
- function mapToStyles(_ref2) {
1277
- var _Object$assign2;
1278
-
1279
- var popper = _ref2.popper,
1280
- popperRect = _ref2.popperRect,
1281
- placement = _ref2.placement,
1282
- offsets = _ref2.offsets,
1283
- position = _ref2.position,
1284
- gpuAcceleration = _ref2.gpuAcceleration,
1285
- adaptive = _ref2.adaptive;
961
+ function getWindowScrollBarX(element) {
962
+ // If <html> has a CSS width greater than the viewport, then this will be
963
+ // incorrect for RTL.
964
+ // Popper 1 is broken in this case and never had a bug report so let's assume
965
+ // it's not an issue. I don't think anyone ever specifies width on <html>
966
+ // anyway.
967
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
968
+ // this (e.g. Edge 2019, IE11, Safari)
969
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
970
+ }
1286
971
 
1287
- var _roundOffsets = roundOffsets(offsets),
1288
- x = _roundOffsets.x,
1289
- y = _roundOffsets.y;
972
+ function getViewportRect(element) {
973
+ var win = getWindow(element);
974
+ var html = getDocumentElement(element);
975
+ var visualViewport = win.visualViewport;
976
+ var width = html.clientWidth;
977
+ var height = html.clientHeight;
978
+ var x = 0;
979
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
980
+ // can be obscured underneath it.
981
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
982
+ // if it isn't open, so if this isn't available, the popper will be detected
983
+ // to overflow the bottom of the screen too early.
1290
984
 
1291
- var hasX = offsets.hasOwnProperty('x');
1292
- var hasY = offsets.hasOwnProperty('y');
1293
- var sideX = left;
1294
- var sideY = top;
1295
- var win = window;
985
+ if (visualViewport) {
986
+ width = visualViewport.width;
987
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
988
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
989
+ // errors due to floating point numbers, so we need to check precision.
990
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
991
+ // Feature detection fails in mobile emulation mode in Chrome.
992
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
993
+ // 0.001
994
+ // Fallback here: "Not Safari" userAgent
1296
995
 
1297
- if (adaptive) {
1298
- var offsetParent = getOffsetParent(popper);
996
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
997
+ x = visualViewport.offsetLeft;
998
+ y = visualViewport.offsetTop;
999
+ }
1000
+ }
1299
1001
 
1300
- if (offsetParent === getWindow(popper)) {
1301
- offsetParent = getDocumentElement(popper);
1302
- } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1002
+ return {
1003
+ width: width,
1004
+ height: height,
1005
+ x: x + getWindowScrollBarX(element),
1006
+ y: y
1007
+ };
1008
+ } // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1303
1009
 
1304
- /*:: offsetParent = (offsetParent: Element); */
1305
1010
 
1011
+ function getDocumentRect(element) {
1012
+ var _element$ownerDocumen;
1306
1013
 
1307
- if (placement === top) {
1308
- sideY = bottom;
1309
- y -= offsetParent.clientHeight - popperRect.height;
1310
- y *= gpuAcceleration ? 1 : -1;
1311
- }
1014
+ var html = getDocumentElement(element);
1015
+ var winScroll = getWindowScroll(element);
1016
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1017
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1018
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1019
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1020
+ var y = -winScroll.scrollTop;
1312
1021
 
1313
- if (placement === left) {
1314
- sideX = right;
1315
- x -= offsetParent.clientWidth - popperRect.width;
1316
- x *= gpuAcceleration ? 1 : -1;
1317
- }
1022
+ if (getComputedStyle(body || html).direction === 'rtl') {
1023
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1318
1024
  }
1319
1025
 
1320
- var commonStyles = Object.assign({
1321
- position: position
1322
- }, adaptive && unsetSides);
1026
+ return {
1027
+ width: width,
1028
+ height: height,
1029
+ x: x,
1030
+ y: y
1031
+ };
1032
+ }
1323
1033
 
1324
- if (gpuAcceleration) {
1325
- var _Object$assign;
1034
+ function isScrollParent(element) {
1035
+ // Firefox wants us to check `-x` and `-y` variations as well
1036
+ var _getComputedStyle = getComputedStyle(element),
1037
+ overflow = _getComputedStyle.overflow,
1038
+ overflowX = _getComputedStyle.overflowX,
1039
+ overflowY = _getComputedStyle.overflowY;
1040
+
1041
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1042
+ }
1043
+
1044
+ function getScrollParent(node) {
1045
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
1046
+ // $FlowFixMe[incompatible-return]: assume body is always available
1047
+ return node.ownerDocument.body;
1048
+ }
1326
1049
 
1327
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1050
+ if (isHTMLElement(node) && isScrollParent(node)) {
1051
+ return node;
1328
1052
  }
1329
1053
 
1330
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1054
+ return getScrollParent(getParentNode(node));
1331
1055
  }
1056
+ /*
1057
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
1058
+ until we get to the top window object. This list is what we attach scroll listeners
1059
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
1060
+ reference element's position.
1061
+ */
1332
1062
 
1333
- function computeStyles(_ref3) {
1334
- var state = _ref3.state,
1335
- options = _ref3.options;
1336
- var _options$gpuAccelerat = options.gpuAcceleration,
1337
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1338
- _options$adaptive = options.adaptive,
1339
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
1340
1063
 
1341
- var commonStyles = {
1342
- placement: getBasePlacement(state.placement),
1343
- popper: state.elements.popper,
1344
- popperRect: state.rects.popper,
1345
- gpuAcceleration: gpuAcceleration
1346
- };
1064
+ function listScrollParents(element, list) {
1065
+ var _element$ownerDocumen;
1347
1066
 
1348
- if (state.modifiersData.popperOffsets != null) {
1349
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
1350
- offsets: state.modifiersData.popperOffsets,
1351
- position: state.options.strategy,
1352
- adaptive: adaptive
1353
- })));
1067
+ if (list === void 0) {
1068
+ list = [];
1354
1069
  }
1355
1070
 
1356
- if (state.modifiersData.arrow != null) {
1357
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
1358
- offsets: state.modifiersData.arrow,
1359
- position: 'absolute',
1360
- adaptive: false
1361
- })));
1362
- }
1071
+ var scrollParent = getScrollParent(element);
1072
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1073
+ var win = getWindow(scrollParent);
1074
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1075
+ var updatedList = list.concat(target);
1076
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1077
+ updatedList.concat(listScrollParents(getParentNode(target)));
1078
+ }
1363
1079
 
1364
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1365
- 'data-popper-placement': state.placement
1080
+ function rectToClientRect(rect) {
1081
+ return Object.assign({}, rect, {
1082
+ left: rect.x,
1083
+ top: rect.y,
1084
+ right: rect.x + rect.width,
1085
+ bottom: rect.y + rect.height
1366
1086
  });
1367
- } // eslint-disable-next-line import/no-unused-modules
1368
-
1087
+ }
1369
1088
 
1370
- var computeStyles$1 = {
1371
- name: 'computeStyles',
1372
- enabled: true,
1373
- phase: 'beforeWrite',
1374
- fn: computeStyles,
1375
- data: {}
1376
- };
1089
+ function getInnerBoundingClientRect(element) {
1090
+ var rect = getBoundingClientRect(element);
1091
+ rect.top = rect.top + element.clientTop;
1092
+ rect.left = rect.left + element.clientLeft;
1093
+ rect.bottom = rect.top + element.clientHeight;
1094
+ rect.right = rect.left + element.clientWidth;
1095
+ rect.width = element.clientWidth;
1096
+ rect.height = element.clientHeight;
1097
+ rect.x = rect.left;
1098
+ rect.y = rect.top;
1099
+ return rect;
1100
+ }
1377
1101
 
1378
- // and applies them to the HTMLElements such as popper and arrow
1102
+ function getClientRectFromMixedType(element, clippingParent) {
1103
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1104
+ } // A "clipping parent" is an overflowable container with the characteristic of
1105
+ // clipping (or hiding) overflowing elements with a position different from
1106
+ // `initial`
1379
1107
 
1380
- function applyStyles(_ref) {
1381
- var state = _ref.state;
1382
- Object.keys(state.elements).forEach(function (name) {
1383
- var style = state.styles[name] || {};
1384
- var attributes = state.attributes[name] || {};
1385
- var element = state.elements[name]; // arrow is optional + virtual elements
1386
1108
 
1387
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
1388
- return;
1389
- } // Flow doesn't support to extend this property, but it's the most
1390
- // effective way to apply styles to an HTMLElement
1391
- // $FlowFixMe
1109
+ function getClippingParents(element) {
1110
+ var clippingParents = listScrollParents(getParentNode(element));
1111
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
1112
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1392
1113
 
1114
+ if (!isElement(clipperElement)) {
1115
+ return [];
1116
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
1393
1117
 
1394
- Object.assign(element.style, style);
1395
- Object.keys(attributes).forEach(function (name) {
1396
- var value = attributes[name];
1397
1118
 
1398
- if (value === false) {
1399
- element.removeAttribute(name);
1400
- } else {
1401
- element.setAttribute(name, value === true ? '' : value);
1402
- }
1403
- });
1119
+ return clippingParents.filter(function (clippingParent) {
1120
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
1404
1121
  });
1405
- }
1406
-
1407
- function effect$1(_ref2) {
1408
- var state = _ref2.state;
1409
- var initialStyles = {
1410
- popper: {
1411
- position: state.options.strategy,
1412
- left: '0',
1413
- top: '0',
1414
- margin: '0'
1415
- },
1416
- arrow: {
1417
- position: 'absolute'
1418
- },
1419
- reference: {}
1420
- };
1421
- Object.assign(state.elements.popper.style, initialStyles.popper);
1422
-
1423
- if (state.elements.arrow) {
1424
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
1425
- }
1122
+ } // Gets the maximum area that the element is visible in due to any number of
1123
+ // clipping parents
1426
1124
 
1427
- return function () {
1428
- Object.keys(state.elements).forEach(function (name) {
1429
- var element = state.elements[name];
1430
- var attributes = state.attributes[name] || {};
1431
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
1432
1125
 
1433
- var style = styleProperties.reduce(function (style, property) {
1434
- style[property] = '';
1435
- return style;
1436
- }, {}); // arrow is optional + virtual elements
1126
+ function getClippingRect(element, boundary, rootBoundary) {
1127
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
1128
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
1129
+ var firstClippingParent = clippingParents[0];
1130
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
1131
+ var rect = getClientRectFromMixedType(element, clippingParent);
1132
+ accRect.top = max(rect.top, accRect.top);
1133
+ accRect.right = min(rect.right, accRect.right);
1134
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1135
+ accRect.left = max(rect.left, accRect.left);
1136
+ return accRect;
1137
+ }, getClientRectFromMixedType(element, firstClippingParent));
1138
+ clippingRect.width = clippingRect.right - clippingRect.left;
1139
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1140
+ clippingRect.x = clippingRect.left;
1141
+ clippingRect.y = clippingRect.top;
1142
+ return clippingRect;
1143
+ }
1437
1144
 
1438
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
1439
- return;
1440
- } // Flow doesn't support to extend this property, but it's the most
1441
- // effective way to apply styles to an HTMLElement
1442
- // $FlowFixMe
1145
+ function getVariation(placement) {
1146
+ return placement.split('-')[1];
1147
+ }
1443
1148
 
1149
+ function computeOffsets(_ref) {
1150
+ var reference = _ref.reference,
1151
+ element = _ref.element,
1152
+ placement = _ref.placement;
1153
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1154
+ var variation = placement ? getVariation(placement) : null;
1155
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1156
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1157
+ var offsets;
1444
1158
 
1445
- Object.assign(element.style, style);
1446
- Object.keys(attributes).forEach(function (attribute) {
1447
- element.removeAttribute(attribute);
1448
- });
1449
- });
1450
- };
1451
- } // eslint-disable-next-line import/no-unused-modules
1159
+ switch (basePlacement) {
1160
+ case top:
1161
+ offsets = {
1162
+ x: commonX,
1163
+ y: reference.y - element.height
1164
+ };
1165
+ break;
1452
1166
 
1167
+ case bottom:
1168
+ offsets = {
1169
+ x: commonX,
1170
+ y: reference.y + reference.height
1171
+ };
1172
+ break;
1453
1173
 
1454
- var applyStyles$1 = {
1455
- name: 'applyStyles',
1456
- enabled: true,
1457
- phase: 'write',
1458
- fn: applyStyles,
1459
- effect: effect$1,
1460
- requires: ['computeStyles']
1461
- };
1174
+ case right:
1175
+ offsets = {
1176
+ x: reference.x + reference.width,
1177
+ y: commonY
1178
+ };
1179
+ break;
1462
1180
 
1463
- function distanceAndSkiddingToXY(placement, rects, offset) {
1464
- var basePlacement = getBasePlacement(placement);
1465
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1181
+ case left:
1182
+ offsets = {
1183
+ x: reference.x - element.width,
1184
+ y: commonY
1185
+ };
1186
+ break;
1466
1187
 
1467
- var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
1468
- placement: placement
1469
- })) : offset,
1470
- skidding = _ref[0],
1471
- distance = _ref[1];
1188
+ default:
1189
+ offsets = {
1190
+ x: reference.x,
1191
+ y: reference.y
1192
+ };
1193
+ }
1472
1194
 
1473
- skidding = skidding || 0;
1474
- distance = (distance || 0) * invertDistance;
1475
- return [left, right].indexOf(basePlacement) >= 0 ? {
1476
- x: distance,
1477
- y: skidding
1478
- } : {
1479
- x: skidding,
1480
- y: distance
1481
- };
1482
- }
1195
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1483
1196
 
1484
- function offset(_ref2) {
1485
- var state = _ref2.state,
1486
- options = _ref2.options,
1487
- name = _ref2.name;
1488
- var _options$offset = options.offset,
1489
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1490
- var data = placements.reduce(function (acc, placement) {
1491
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1492
- return acc;
1493
- }, {});
1494
- var _data$state$placement = data[state.placement],
1495
- x = _data$state$placement.x,
1496
- y = _data$state$placement.y;
1197
+ if (mainAxis != null) {
1198
+ var len = mainAxis === 'y' ? 'height' : 'width';
1497
1199
 
1498
- if (state.modifiersData.popperOffsets != null) {
1499
- state.modifiersData.popperOffsets.x += x;
1500
- state.modifiersData.popperOffsets.y += y;
1501
- }
1200
+ switch (variation) {
1201
+ case start:
1202
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1203
+ break;
1502
1204
 
1503
- state.modifiersData[name] = data;
1504
- } // eslint-disable-next-line import/no-unused-modules
1205
+ case end:
1206
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1207
+ break;
1208
+ }
1209
+ }
1505
1210
 
1211
+ return offsets;
1212
+ }
1506
1213
 
1507
- var offset$1 = {
1508
- name: 'offset',
1509
- enabled: true,
1510
- phase: 'main',
1511
- requires: ['popperOffsets'],
1512
- fn: offset
1513
- };
1214
+ function detectOverflow(state, options) {
1215
+ if (options === void 0) {
1216
+ options = {};
1217
+ }
1514
1218
 
1515
- var hash = {
1516
- left: 'right',
1517
- right: 'left',
1518
- bottom: 'top',
1519
- top: 'bottom'
1520
- };
1521
- function getOppositePlacement(placement) {
1522
- return placement.replace(/left|right|bottom|top/g, function (matched) {
1523
- return hash[matched];
1219
+ var _options = options,
1220
+ _options$placement = _options.placement,
1221
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
1222
+ _options$boundary = _options.boundary,
1223
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1224
+ _options$rootBoundary = _options.rootBoundary,
1225
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1226
+ _options$elementConte = _options.elementContext,
1227
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1228
+ _options$altBoundary = _options.altBoundary,
1229
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1230
+ _options$padding = _options.padding,
1231
+ padding = _options$padding === void 0 ? 0 : _options$padding;
1232
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1233
+ var altContext = elementContext === popper ? reference : popper;
1234
+ var referenceElement = state.elements.reference;
1235
+ var popperRect = state.rects.popper;
1236
+ var element = state.elements[altBoundary ? altContext : elementContext];
1237
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1238
+ var referenceClientRect = getBoundingClientRect(referenceElement);
1239
+ var popperOffsets = computeOffsets({
1240
+ reference: referenceClientRect,
1241
+ element: popperRect,
1242
+ strategy: 'absolute',
1243
+ placement: placement
1524
1244
  });
1525
- }
1245
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1246
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1247
+ // 0 or negative = within the clipping rect
1526
1248
 
1527
- var hash$1 = {
1528
- start: 'end',
1529
- end: 'start'
1530
- };
1531
- function getOppositeVariationPlacement(placement) {
1532
- return placement.replace(/start|end/g, function (matched) {
1533
- return hash$1[matched];
1534
- });
1535
- }
1249
+ var overflowOffsets = {
1250
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1251
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1252
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1253
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1254
+ };
1255
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1536
1256
 
1537
- /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
1257
+ if (elementContext === popper && offsetData) {
1258
+ var offset = offsetData[placement];
1259
+ Object.keys(overflowOffsets).forEach(function (key) {
1260
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1261
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1262
+ overflowOffsets[key] += offset[axis] * multiply;
1263
+ });
1264
+ }
1538
1265
 
1539
- /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
1266
+ return overflowOffsets;
1267
+ }
1540
1268
 
1541
1269
  function computeAutoPlacement(state, options) {
1542
1270
  if (options === void 0) {
@@ -1554,15 +1282,14 @@ function computeAutoPlacement(state, options) {
1554
1282
  var variation = getVariation(placement);
1555
1283
  var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1556
1284
  return getVariation(placement) === variation;
1557
- }) : basePlacements; // $FlowFixMe
1558
-
1285
+ }) : basePlacements;
1559
1286
  var allowedPlacements = placements$1.filter(function (placement) {
1560
1287
  return allowedAutoPlacements.indexOf(placement) >= 0;
1561
1288
  });
1562
1289
 
1563
1290
  if (allowedPlacements.length === 0) {
1564
1291
  allowedPlacements = placements$1;
1565
- } // $FlowFixMe: Flow seems to have problems with two array unions...
1292
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1566
1293
 
1567
1294
 
1568
1295
  var overflows = allowedPlacements.reduce(function (acc, placement) {
@@ -1719,72 +1446,203 @@ var flip$1 = {
1719
1446
  }
1720
1447
  };
1721
1448
 
1722
- function getAltAxis(axis) {
1723
- return axis === 'x' ? 'y' : 'x';
1449
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1450
+ if (preventedOffsets === void 0) {
1451
+ preventedOffsets = {
1452
+ x: 0,
1453
+ y: 0
1454
+ };
1455
+ }
1456
+
1457
+ return {
1458
+ top: overflow.top - rect.height - preventedOffsets.y,
1459
+ right: overflow.right - rect.width + preventedOffsets.x,
1460
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1461
+ left: overflow.left - rect.width - preventedOffsets.x
1462
+ };
1724
1463
  }
1725
1464
 
1726
- function within(min, value, max) {
1727
- return Math.max(min, Math.min(value, max));
1465
+ function isAnySideFullyClipped(overflow) {
1466
+ return [top, right, bottom, left].some(function (side) {
1467
+ return overflow[side] >= 0;
1468
+ });
1728
1469
  }
1729
1470
 
1730
- function preventOverflow(_ref) {
1471
+ function hide(_ref) {
1731
1472
  var state = _ref.state,
1732
- options = _ref.options,
1733
1473
  name = _ref.name;
1734
- var _options$mainAxis = options.mainAxis,
1735
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1736
- _options$altAxis = options.altAxis,
1737
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1738
- boundary = options.boundary,
1739
- rootBoundary = options.rootBoundary,
1740
- altBoundary = options.altBoundary,
1741
- padding = options.padding,
1742
- _options$tether = options.tether,
1743
- tether = _options$tether === void 0 ? true : _options$tether,
1744
- _options$tetherOffset = options.tetherOffset,
1745
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1746
- var overflow = detectOverflow(state, {
1747
- boundary: boundary,
1748
- rootBoundary: rootBoundary,
1749
- padding: padding,
1750
- altBoundary: altBoundary
1751
- });
1752
- var basePlacement = getBasePlacement(state.placement);
1753
- var variation = getVariation(state.placement);
1754
- var isBasePlacement = !variation;
1755
- var mainAxis = getMainAxisFromPlacement(basePlacement);
1756
- var altAxis = getAltAxis(mainAxis);
1757
- var popperOffsets = state.modifiersData.popperOffsets;
1758
1474
  var referenceRect = state.rects.reference;
1759
1475
  var popperRect = state.rects.popper;
1760
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
1761
- placement: state.placement
1762
- })) : tetherOffset;
1763
- var data = {
1764
- x: 0,
1765
- y: 0
1476
+ var preventedOffsets = state.modifiersData.preventOverflow;
1477
+ var referenceOverflow = detectOverflow(state, {
1478
+ elementContext: 'reference'
1479
+ });
1480
+ var popperAltOverflow = detectOverflow(state, {
1481
+ altBoundary: true
1482
+ });
1483
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1484
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1485
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1486
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1487
+ state.modifiersData[name] = {
1488
+ referenceClippingOffsets: referenceClippingOffsets,
1489
+ popperEscapeOffsets: popperEscapeOffsets,
1490
+ isReferenceHidden: isReferenceHidden,
1491
+ hasPopperEscaped: hasPopperEscaped
1766
1492
  };
1493
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1494
+ 'data-popper-reference-hidden': isReferenceHidden,
1495
+ 'data-popper-escaped': hasPopperEscaped
1496
+ });
1497
+ } // eslint-disable-next-line import/no-unused-modules
1767
1498
 
1768
- if (!popperOffsets) {
1769
- return;
1770
- }
1771
-
1772
- if (checkMainAxis) {
1773
- var mainSide = mainAxis === 'y' ? top : left;
1774
- var altSide = mainAxis === 'y' ? bottom : right;
1775
- var len = mainAxis === 'y' ? 'height' : 'width';
1776
- var offset = popperOffsets[mainAxis];
1777
- var min = popperOffsets[mainAxis] + overflow[mainSide];
1778
- var max = popperOffsets[mainAxis] - overflow[altSide];
1779
- var additive = tether ? -popperRect[len] / 2 : 0;
1780
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1781
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1782
- // outside the reference bounds
1783
1499
 
1784
- var arrowElement = state.elements.arrow;
1785
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1786
- width: 0,
1787
- height: 0
1500
+ var hide$1 = {
1501
+ name: 'hide',
1502
+ enabled: true,
1503
+ phase: 'main',
1504
+ requiresIfExists: ['preventOverflow'],
1505
+ fn: hide
1506
+ };
1507
+
1508
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1509
+ var basePlacement = getBasePlacement(placement);
1510
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1511
+
1512
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1513
+ placement: placement
1514
+ })) : offset,
1515
+ skidding = _ref[0],
1516
+ distance = _ref[1];
1517
+
1518
+ skidding = skidding || 0;
1519
+ distance = (distance || 0) * invertDistance;
1520
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1521
+ x: distance,
1522
+ y: skidding
1523
+ } : {
1524
+ x: skidding,
1525
+ y: distance
1526
+ };
1527
+ }
1528
+
1529
+ function offset(_ref2) {
1530
+ var state = _ref2.state,
1531
+ options = _ref2.options,
1532
+ name = _ref2.name;
1533
+ var _options$offset = options.offset,
1534
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1535
+ var data = placements.reduce(function (acc, placement) {
1536
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1537
+ return acc;
1538
+ }, {});
1539
+ var _data$state$placement = data[state.placement],
1540
+ x = _data$state$placement.x,
1541
+ y = _data$state$placement.y;
1542
+
1543
+ if (state.modifiersData.popperOffsets != null) {
1544
+ state.modifiersData.popperOffsets.x += x;
1545
+ state.modifiersData.popperOffsets.y += y;
1546
+ }
1547
+
1548
+ state.modifiersData[name] = data;
1549
+ } // eslint-disable-next-line import/no-unused-modules
1550
+
1551
+
1552
+ var offset$1 = {
1553
+ name: 'offset',
1554
+ enabled: true,
1555
+ phase: 'main',
1556
+ requires: ['popperOffsets'],
1557
+ fn: offset
1558
+ };
1559
+
1560
+ function popperOffsets(_ref) {
1561
+ var state = _ref.state,
1562
+ name = _ref.name; // Offsets are the actual position the popper needs to have to be
1563
+ // properly positioned near its reference element
1564
+ // This is the most basic placement, and will be adjusted by
1565
+ // the modifiers in the next step
1566
+
1567
+ state.modifiersData[name] = computeOffsets({
1568
+ reference: state.rects.reference,
1569
+ element: state.rects.popper,
1570
+ strategy: 'absolute',
1571
+ placement: state.placement
1572
+ });
1573
+ } // eslint-disable-next-line import/no-unused-modules
1574
+
1575
+
1576
+ var popperOffsets$1 = {
1577
+ name: 'popperOffsets',
1578
+ enabled: true,
1579
+ phase: 'read',
1580
+ fn: popperOffsets,
1581
+ data: {}
1582
+ };
1583
+
1584
+ function getAltAxis(axis) {
1585
+ return axis === 'x' ? 'y' : 'x';
1586
+ }
1587
+
1588
+ function preventOverflow(_ref) {
1589
+ var state = _ref.state,
1590
+ options = _ref.options,
1591
+ name = _ref.name;
1592
+ var _options$mainAxis = options.mainAxis,
1593
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1594
+ _options$altAxis = options.altAxis,
1595
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1596
+ boundary = options.boundary,
1597
+ rootBoundary = options.rootBoundary,
1598
+ altBoundary = options.altBoundary,
1599
+ padding = options.padding,
1600
+ _options$tether = options.tether,
1601
+ tether = _options$tether === void 0 ? true : _options$tether,
1602
+ _options$tetherOffset = options.tetherOffset,
1603
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1604
+ var overflow = detectOverflow(state, {
1605
+ boundary: boundary,
1606
+ rootBoundary: rootBoundary,
1607
+ padding: padding,
1608
+ altBoundary: altBoundary
1609
+ });
1610
+ var basePlacement = getBasePlacement(state.placement);
1611
+ var variation = getVariation(state.placement);
1612
+ var isBasePlacement = !variation;
1613
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1614
+ var altAxis = getAltAxis(mainAxis);
1615
+ var popperOffsets = state.modifiersData.popperOffsets;
1616
+ var referenceRect = state.rects.reference;
1617
+ var popperRect = state.rects.popper;
1618
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1619
+ placement: state.placement
1620
+ })) : tetherOffset;
1621
+ var data = {
1622
+ x: 0,
1623
+ y: 0
1624
+ };
1625
+
1626
+ if (!popperOffsets) {
1627
+ return;
1628
+ }
1629
+
1630
+ if (checkMainAxis || checkAltAxis) {
1631
+ var mainSide = mainAxis === 'y' ? top : left;
1632
+ var altSide = mainAxis === 'y' ? bottom : right;
1633
+ var len = mainAxis === 'y' ? 'height' : 'width';
1634
+ var offset = popperOffsets[mainAxis];
1635
+ var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1636
+ var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1637
+ var additive = tether ? -popperRect[len] / 2 : 0;
1638
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1639
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1640
+ // outside the reference bounds
1641
+
1642
+ var arrowElement = state.elements.arrow;
1643
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1644
+ width: 0,
1645
+ height: 0
1788
1646
  };
1789
1647
  var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1790
1648
  var arrowPaddingMin = arrowPaddingObject[mainSide];
@@ -1802,26 +1660,29 @@ function preventOverflow(_ref) {
1802
1660
  var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1803
1661
  var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1804
1662
  var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1805
- var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
1806
- popperOffsets[mainAxis] = preventedOffset;
1807
- data[mainAxis] = preventedOffset - offset;
1808
- }
1809
1663
 
1810
- if (checkAltAxis) {
1811
- var _mainSide = mainAxis === 'x' ? top : left;
1664
+ if (checkMainAxis) {
1665
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1666
+ popperOffsets[mainAxis] = preventedOffset;
1667
+ data[mainAxis] = preventedOffset - offset;
1668
+ }
1669
+
1670
+ if (checkAltAxis) {
1671
+ var _mainSide = mainAxis === 'x' ? top : left;
1812
1672
 
1813
- var _altSide = mainAxis === 'x' ? bottom : right;
1673
+ var _altSide = mainAxis === 'x' ? bottom : right;
1814
1674
 
1815
- var _offset = popperOffsets[altAxis];
1675
+ var _offset = popperOffsets[altAxis];
1816
1676
 
1817
- var _min = _offset + overflow[_mainSide];
1677
+ var _min = _offset + overflow[_mainSide];
1818
1678
 
1819
- var _max = _offset - overflow[_altSide];
1679
+ var _max = _offset - overflow[_altSide];
1820
1680
 
1821
- var _preventedOffset = within(_min, _offset, _max);
1681
+ var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
1822
1682
 
1823
- popperOffsets[altAxis] = _preventedOffset;
1824
- data[altAxis] = _preventedOffset - _offset;
1683
+ popperOffsets[altAxis] = _preventedOffset;
1684
+ data[altAxis] = _preventedOffset - _offset;
1685
+ }
1825
1686
  }
1826
1687
 
1827
1688
  state.modifiersData[name] = data;
@@ -1836,145 +1697,324 @@ var preventOverflow$1 = {
1836
1697
  requiresIfExists: ['offset']
1837
1698
  };
1838
1699
 
1839
- function arrow(_ref) {
1840
- var _state$modifiersData$;
1700
+ function getHTMLElementScroll(element) {
1701
+ return {
1702
+ scrollLeft: element.scrollLeft,
1703
+ scrollTop: element.scrollTop
1704
+ };
1705
+ }
1841
1706
 
1842
- var state = _ref.state,
1843
- name = _ref.name;
1844
- var arrowElement = state.elements.arrow;
1845
- var popperOffsets = state.modifiersData.popperOffsets;
1846
- var basePlacement = getBasePlacement(state.placement);
1847
- var axis = getMainAxisFromPlacement(basePlacement);
1848
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
1849
- var len = isVertical ? 'height' : 'width';
1707
+ function getNodeScroll(node) {
1708
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1709
+ return getWindowScroll(node);
1710
+ } else {
1711
+ return getHTMLElementScroll(node);
1712
+ }
1713
+ } // Composite means it takes into account transforms as well as layout.
1850
1714
 
1851
- if (!arrowElement || !popperOffsets) {
1852
- return;
1715
+
1716
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1717
+ if (isFixed === void 0) {
1718
+ isFixed = false;
1853
1719
  }
1854
1720
 
1855
- var paddingObject = state.modifiersData[name + "#persistent"].padding;
1856
- var arrowRect = getLayoutRect(arrowElement);
1857
- var minProp = axis === 'y' ? top : left;
1858
- var maxProp = axis === 'y' ? bottom : right;
1859
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1860
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1861
- var arrowOffsetParent = getOffsetParent(arrowElement);
1862
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1863
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1864
- // outside of the popper bounds
1721
+ var documentElement = getDocumentElement(offsetParent);
1722
+ var rect = getBoundingClientRect(elementOrVirtualElement);
1723
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1724
+ var scroll = {
1725
+ scrollLeft: 0,
1726
+ scrollTop: 0
1727
+ };
1728
+ var offsets = {
1729
+ x: 0,
1730
+ y: 0
1731
+ };
1865
1732
 
1866
- var min = paddingObject[minProp];
1867
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1868
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1869
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1733
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1734
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1735
+ isScrollParent(documentElement)) {
1736
+ scroll = getNodeScroll(offsetParent);
1737
+ }
1870
1738
 
1871
- var axisProp = axis;
1872
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1739
+ if (isHTMLElement(offsetParent)) {
1740
+ offsets = getBoundingClientRect(offsetParent);
1741
+ offsets.x += offsetParent.clientLeft;
1742
+ offsets.y += offsetParent.clientTop;
1743
+ } else if (documentElement) {
1744
+ offsets.x = getWindowScrollBarX(documentElement);
1745
+ }
1746
+ }
1747
+
1748
+ return {
1749
+ x: rect.left + scroll.scrollLeft - offsets.x,
1750
+ y: rect.top + scroll.scrollTop - offsets.y,
1751
+ width: rect.width,
1752
+ height: rect.height
1753
+ };
1873
1754
  }
1874
1755
 
1875
- function effect$2(_ref2) {
1876
- var state = _ref2.state,
1877
- options = _ref2.options,
1878
- name = _ref2.name;
1879
- var _options$element = options.element,
1880
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
1881
- _options$padding = options.padding,
1882
- padding = _options$padding === void 0 ? 0 : _options$padding;
1756
+ function order(modifiers) {
1757
+ var map = new Map();
1758
+ var visited = new Set();
1759
+ var result = [];
1760
+ modifiers.forEach(function (modifier) {
1761
+ map.set(modifier.name, modifier);
1762
+ }); // On visiting object, check for its dependencies and visit them recursively
1883
1763
 
1884
- if (arrowElement == null) {
1885
- return;
1886
- } // CSS selector
1764
+ function sort(modifier) {
1765
+ visited.add(modifier.name);
1766
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1767
+ requires.forEach(function (dep) {
1768
+ if (!visited.has(dep)) {
1769
+ var depModifier = map.get(dep);
1770
+
1771
+ if (depModifier) {
1772
+ sort(depModifier);
1773
+ }
1774
+ }
1775
+ });
1776
+ result.push(modifier);
1777
+ }
1778
+
1779
+ modifiers.forEach(function (modifier) {
1780
+ if (!visited.has(modifier.name)) {
1781
+ // check for visited object
1782
+ sort(modifier);
1783
+ }
1784
+ });
1785
+ return result;
1786
+ }
1787
+
1788
+ function orderModifiers(modifiers) {
1789
+ // order based on dependencies
1790
+ var orderedModifiers = order(modifiers); // order based on phase
1791
+
1792
+ return modifierPhases.reduce(function (acc, phase) {
1793
+ return acc.concat(orderedModifiers.filter(function (modifier) {
1794
+ return modifier.phase === phase;
1795
+ }));
1796
+ }, []);
1797
+ }
1798
+
1799
+ function debounce(fn) {
1800
+ var pending;
1801
+ return function () {
1802
+ if (!pending) {
1803
+ pending = new Promise(function (resolve) {
1804
+ Promise.resolve().then(function () {
1805
+ pending = undefined;
1806
+ resolve(fn());
1807
+ });
1808
+ });
1809
+ }
1810
+
1811
+ return pending;
1812
+ };
1813
+ }
1814
+
1815
+ function mergeByName(modifiers) {
1816
+ var merged = modifiers.reduce(function (merged, current) {
1817
+ var existing = merged[current.name];
1818
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1819
+ options: Object.assign({}, existing.options, current.options),
1820
+ data: Object.assign({}, existing.data, current.data)
1821
+ }) : current;
1822
+ return merged;
1823
+ }, {}); // IE11 does not support Object.values
1824
+
1825
+ return Object.keys(merged).map(function (key) {
1826
+ return merged[key];
1827
+ });
1828
+ }
1829
+
1830
+ var DEFAULT_OPTIONS = {
1831
+ placement: 'bottom',
1832
+ modifiers: [],
1833
+ strategy: 'absolute'
1834
+ };
1835
+
1836
+ function areValidElements() {
1837
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1838
+ args[_key] = arguments[_key];
1839
+ }
1840
+
1841
+ return !args.some(function (element) {
1842
+ return !(element && typeof element.getBoundingClientRect === 'function');
1843
+ });
1844
+ }
1845
+
1846
+ function popperGenerator(generatorOptions) {
1847
+ if (generatorOptions === void 0) {
1848
+ generatorOptions = {};
1849
+ }
1850
+
1851
+ var _generatorOptions = generatorOptions,
1852
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
1853
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1854
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
1855
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1856
+ return function createPopper(reference, popper, options) {
1857
+ if (options === void 0) {
1858
+ options = defaultOptions;
1859
+ }
1860
+
1861
+ var state = {
1862
+ placement: 'bottom',
1863
+ orderedModifiers: [],
1864
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1865
+ modifiersData: {},
1866
+ elements: {
1867
+ reference: reference,
1868
+ popper: popper
1869
+ },
1870
+ attributes: {},
1871
+ styles: {}
1872
+ };
1873
+ var effectCleanupFns = [];
1874
+ var isDestroyed = false;
1875
+ var instance = {
1876
+ state: state,
1877
+ setOptions: function setOptions(options) {
1878
+ cleanupModifierEffects();
1879
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1880
+ state.scrollParents = {
1881
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1882
+ popper: listScrollParents(popper)
1883
+ }; // Orders the modifiers based on their dependencies and `phase`
1884
+ // properties
1885
+
1886
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1887
+
1888
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
1889
+ return m.enabled;
1890
+ }); // Validate the provided modifiers so that the consumer will get warned
1891
+
1892
+ runModifierEffects();
1893
+ return instance.update();
1894
+ },
1895
+ // Sync update – it will always be executed, even if not necessary. This
1896
+ // is useful for low frequency updates where sync behavior simplifies the
1897
+ // logic.
1898
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
1899
+ // prefer the async Popper#update method
1900
+ forceUpdate: function forceUpdate() {
1901
+ if (isDestroyed) {
1902
+ return;
1903
+ }
1904
+
1905
+ var _state$elements = state.elements,
1906
+ reference = _state$elements.reference,
1907
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1908
+ // anymore
1909
+
1910
+ if (!areValidElements(reference, popper)) {
1911
+ return;
1912
+ } // Store the reference and popper rects to be read by modifiers
1913
+
1914
+
1915
+ state.rects = {
1916
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1917
+ popper: getLayoutRect(popper)
1918
+ }; // Modifiers have the ability to reset the current update cycle. The
1919
+ // most common use case for this is the `flip` modifier changing the
1920
+ // placement, which then needs to re-run all the modifiers, because the
1921
+ // logic was previously ran for the previous placement and is therefore
1922
+ // stale/incorrect
1923
+
1924
+ state.reset = false;
1925
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1926
+ // is filled with the initial data specified by the modifier. This means
1927
+ // it doesn't persist and is fresh on each update.
1928
+ // To ensure persistent data, use `${name}#persistent`
1929
+
1930
+ state.orderedModifiers.forEach(function (modifier) {
1931
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1932
+ });
1933
+
1934
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
1935
+ if (state.reset === true) {
1936
+ state.reset = false;
1937
+ index = -1;
1938
+ continue;
1939
+ }
1887
1940
 
1941
+ var _state$orderedModifie = state.orderedModifiers[index],
1942
+ fn = _state$orderedModifie.fn,
1943
+ _state$orderedModifie2 = _state$orderedModifie.options,
1944
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1945
+ name = _state$orderedModifie.name;
1888
1946
 
1889
- if (typeof arrowElement === 'string') {
1890
- arrowElement = state.elements.popper.querySelector(arrowElement);
1947
+ if (typeof fn === 'function') {
1948
+ state = fn({
1949
+ state: state,
1950
+ options: _options,
1951
+ name: name,
1952
+ instance: instance
1953
+ }) || state;
1954
+ }
1955
+ }
1956
+ },
1957
+ // Async and optimistically optimized update – it will not be executed if
1958
+ // not necessary (debounced to run at most once-per-tick)
1959
+ update: debounce(function () {
1960
+ return new Promise(function (resolve) {
1961
+ instance.forceUpdate();
1962
+ resolve(state);
1963
+ });
1964
+ }),
1965
+ destroy: function destroy() {
1966
+ cleanupModifierEffects();
1967
+ isDestroyed = true;
1968
+ }
1969
+ };
1891
1970
 
1892
- if (!arrowElement) {
1893
- return;
1971
+ if (!areValidElements(reference, popper)) {
1972
+ return instance;
1894
1973
  }
1895
- }
1896
1974
 
1897
- if (!contains(state.elements.popper, arrowElement)) {
1975
+ instance.setOptions(options).then(function (state) {
1976
+ if (!isDestroyed && options.onFirstUpdate) {
1977
+ options.onFirstUpdate(state);
1978
+ }
1979
+ }); // Modifiers have the ability to execute arbitrary code before the first
1980
+ // update cycle runs. They will be executed in the same order as the update
1981
+ // cycle. This is useful when a modifier adds some persistent data that
1982
+ // other modifiers need to use, but the modifier is run after the dependent
1983
+ // one.
1898
1984
 
1899
- return;
1900
- }
1985
+ function runModifierEffects() {
1986
+ state.orderedModifiers.forEach(function (_ref3) {
1987
+ var name = _ref3.name,
1988
+ _ref3$options = _ref3.options,
1989
+ options = _ref3$options === void 0 ? {} : _ref3$options,
1990
+ effect = _ref3.effect;
1901
1991
 
1902
- state.elements.arrow = arrowElement;
1903
- state.modifiersData[name + "#persistent"] = {
1904
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
1905
- };
1906
- } // eslint-disable-next-line import/no-unused-modules
1992
+ if (typeof effect === 'function') {
1993
+ var cleanupFn = effect({
1994
+ state: state,
1995
+ name: name,
1996
+ instance: instance,
1997
+ options: options
1998
+ });
1907
1999
 
2000
+ var noopFn = function noopFn() {};
1908
2001
 
1909
- var arrow$1 = {
1910
- name: 'arrow',
1911
- enabled: true,
1912
- phase: 'main',
1913
- fn: arrow,
1914
- effect: effect$2,
1915
- requires: ['popperOffsets'],
1916
- requiresIfExists: ['preventOverflow']
1917
- };
2002
+ effectCleanupFns.push(cleanupFn || noopFn);
2003
+ }
2004
+ });
2005
+ }
1918
2006
 
1919
- function getSideOffsets(overflow, rect, preventedOffsets) {
1920
- if (preventedOffsets === void 0) {
1921
- preventedOffsets = {
1922
- x: 0,
1923
- y: 0
1924
- };
1925
- }
2007
+ function cleanupModifierEffects() {
2008
+ effectCleanupFns.forEach(function (fn) {
2009
+ return fn();
2010
+ });
2011
+ effectCleanupFns = [];
2012
+ }
1926
2013
 
1927
- return {
1928
- top: overflow.top - rect.height - preventedOffsets.y,
1929
- right: overflow.right - rect.width + preventedOffsets.x,
1930
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1931
- left: overflow.left - rect.width - preventedOffsets.x
2014
+ return instance;
1932
2015
  };
1933
2016
  }
1934
2017
 
1935
- function isAnySideFullyClipped(overflow) {
1936
- return [top, right, bottom, left].some(function (side) {
1937
- return overflow[side] >= 0;
1938
- });
1939
- }
1940
-
1941
- function hide(_ref) {
1942
- var state = _ref.state,
1943
- name = _ref.name;
1944
- var referenceRect = state.rects.reference;
1945
- var popperRect = state.rects.popper;
1946
- var preventedOffsets = state.modifiersData.preventOverflow;
1947
- var referenceOverflow = detectOverflow(state, {
1948
- elementContext: 'reference'
1949
- });
1950
- var popperAltOverflow = detectOverflow(state, {
1951
- altBoundary: true
1952
- });
1953
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1954
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1955
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1956
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1957
- state.modifiersData[name] = {
1958
- referenceClippingOffsets: referenceClippingOffsets,
1959
- popperEscapeOffsets: popperEscapeOffsets,
1960
- isReferenceHidden: isReferenceHidden,
1961
- hasPopperEscaped: hasPopperEscaped
1962
- };
1963
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1964
- 'data-popper-reference-hidden': isReferenceHidden,
1965
- 'data-popper-escaped': hasPopperEscaped
1966
- });
1967
- } // eslint-disable-next-line import/no-unused-modules
1968
-
1969
-
1970
- var hide$1 = {
1971
- name: 'hide',
1972
- enabled: true,
1973
- phase: 'main',
1974
- requiresIfExists: ['preventOverflow'],
1975
- fn: hide
1976
- };
1977
-
1978
2018
  var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1979
2019
  var createPopper = /*#__PURE__*/popperGenerator({
1980
2020
  defaultModifiers: defaultModifiers
@@ -2074,13 +2114,13 @@ function makeCenteredPopper(step) {
2074
2114
  });
2075
2115
  return popperOptions;
2076
2116
  }
2077
-
2078
2117
  /**
2079
2118
  * Ensure class prefix ends in `-`
2080
2119
  * @param {string} prefix The prefix to prepend to the class names generated by nano-css
2081
2120
  * @return {string} The prefix ending in `-`
2082
2121
  */
2083
2122
 
2123
+
2084
2124
  function normalizePrefix(prefix) {
2085
2125
  if (!isString(prefix) || prefix === '') {
2086
2126
  return '';
@@ -2096,6 +2136,7 @@ function normalizePrefix(prefix) {
2096
2136
  * `on` is a string position value
2097
2137
  */
2098
2138
 
2139
+
2099
2140
  function parseAttachTo(step) {
2100
2141
  const options = step.options.attachTo || {};
2101
2142
  const returnOpts = Object.assign({}, options);
@@ -2121,6 +2162,7 @@ function parseAttachTo(step) {
2121
2162
  * @param {Step} step The step instance
2122
2163
  */
2123
2164
 
2165
+
2124
2166
  function setupTooltip(step) {
2125
2167
  if (step.tooltip) {
2126
2168
  step.tooltip.destroy();
@@ -2145,6 +2187,7 @@ function setupTooltip(step) {
2145
2187
  * @return {string}
2146
2188
  */
2147
2189
 
2190
+
2148
2191
  function uuid() {
2149
2192
  let d = Date.now();
2150
2193
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
@@ -2161,12 +2204,14 @@ function uuid() {
2161
2204
  * @private
2162
2205
  */
2163
2206
 
2207
+
2164
2208
  function getPopperOptions(attachToOptions, step) {
2165
2209
  let popperOptions = {
2166
2210
  modifiers: [{
2167
2211
  name: 'preventOverflow',
2168
2212
  options: {
2169
- altAxis: true
2213
+ altAxis: true,
2214
+ tether: false
2170
2215
  }
2171
2216
  }, {
2172
2217
  name: 'focusAfterRender',
@@ -2246,6 +2291,10 @@ function safe_not_equal(a, b) {
2246
2291
  return a != a ? b == b : a !== b || a && typeof a === 'object' || typeof a === 'function';
2247
2292
  }
2248
2293
 
2294
+ function is_empty(obj) {
2295
+ return Object.keys(obj).length === 0;
2296
+ }
2297
+
2249
2298
  function append(target, node) {
2250
2299
  target.appendChild(node);
2251
2300
  }
@@ -2327,7 +2376,7 @@ function set_current_component(component) {
2327
2376
  }
2328
2377
 
2329
2378
  function get_current_component() {
2330
- if (!current_component) throw new Error(`Function called outside component initialization`);
2379
+ if (!current_component) throw new Error('Function called outside component initialization');
2331
2380
  return current_component;
2332
2381
  }
2333
2382
 
@@ -2373,6 +2422,7 @@ function flush() {
2373
2422
  update(component.$$);
2374
2423
  }
2375
2424
 
2425
+ set_current_component(null);
2376
2426
  dirty_components.length = 0;
2377
2427
 
2378
2428
  while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call
@@ -2499,28 +2549,32 @@ function create_component(block) {
2499
2549
  block && block.c();
2500
2550
  }
2501
2551
 
2502
- function mount_component(component, target, anchor) {
2552
+ function mount_component(component, target, anchor, customElement) {
2503
2553
  const {
2504
2554
  fragment,
2505
2555
  on_mount,
2506
2556
  on_destroy,
2507
2557
  after_update
2508
2558
  } = component.$$;
2509
- fragment && fragment.m(target, anchor); // onMount happens before the initial afterUpdate
2559
+ fragment && fragment.m(target, anchor);
2510
2560
 
2511
- add_render_callback(() => {
2512
- const new_on_destroy = on_mount.map(run).filter(is_function);
2561
+ if (!customElement) {
2562
+ // onMount happens before the initial afterUpdate
2563
+ add_render_callback(() => {
2564
+ const new_on_destroy = on_mount.map(run).filter(is_function);
2513
2565
 
2514
- if (on_destroy) {
2515
- on_destroy.push(...new_on_destroy);
2516
- } else {
2517
- // Edge case - component was destroyed immediately,
2518
- // most likely as a result of a binding initialising
2519
- run_all(new_on_destroy);
2520
- }
2566
+ if (on_destroy) {
2567
+ on_destroy.push(...new_on_destroy);
2568
+ } else {
2569
+ // Edge case - component was destroyed immediately,
2570
+ // most likely as a result of a binding initialising
2571
+ run_all(new_on_destroy);
2572
+ }
2573
+
2574
+ component.$$.on_mount = [];
2575
+ });
2576
+ }
2521
2577
 
2522
- component.$$.on_mount = [];
2523
- });
2524
2578
  after_update.forEach(add_render_callback);
2525
2579
  }
2526
2580
 
@@ -2550,7 +2604,6 @@ function make_dirty(component, i) {
2550
2604
  function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
2551
2605
  const parent_component = current_component;
2552
2606
  set_current_component(component);
2553
- const prop_values = options.props || {};
2554
2607
  const $$ = component.$$ = {
2555
2608
  fragment: null,
2556
2609
  ctx: null,
@@ -2562,19 +2615,21 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2562
2615
  // lifecycle
2563
2616
  on_mount: [],
2564
2617
  on_destroy: [],
2618
+ on_disconnect: [],
2565
2619
  before_update: [],
2566
2620
  after_update: [],
2567
- context: new Map(parent_component ? parent_component.$$.context : []),
2621
+ context: new Map(parent_component ? parent_component.$$.context : options.context || []),
2568
2622
  // everything else
2569
2623
  callbacks: blank_object(),
2570
- dirty
2624
+ dirty,
2625
+ skip_bound: false
2571
2626
  };
2572
2627
  let ready = false;
2573
- $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => {
2628
+ $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
2574
2629
  const value = rest.length ? rest[0] : ret;
2575
2630
 
2576
2631
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
2577
- if ($$.bound[i]) $$.bound[i](value);
2632
+ if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
2578
2633
  if (ready) make_dirty(component, i);
2579
2634
  }
2580
2635
 
@@ -2598,12 +2653,16 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2598
2653
  }
2599
2654
 
2600
2655
  if (options.intro) transition_in(component.$$.fragment);
2601
- mount_component(component, options.target, options.anchor);
2656
+ mount_component(component, options.target, options.anchor, options.customElement);
2602
2657
  flush();
2603
2658
  }
2604
2659
 
2605
2660
  set_current_component(parent_component);
2606
2661
  }
2662
+ /**
2663
+ * Base class for Svelte components. Used when dev=false.
2664
+ */
2665
+
2607
2666
 
2608
2667
  class SvelteComponent {
2609
2668
  $destroy() {
@@ -2620,14 +2679,19 @@ class SvelteComponent {
2620
2679
  };
2621
2680
  }
2622
2681
 
2623
- $set() {// overridden by instance, if it has props
2682
+ $set($$props) {
2683
+ if (this.$$set && !is_empty($$props)) {
2684
+ this.$$.skip_bound = true;
2685
+ this.$$set($$props);
2686
+ this.$$.skip_bound = false;
2687
+ }
2624
2688
  }
2625
2689
 
2626
2690
  }
2691
+ /* src/js/components/shepherd-button.svelte generated by Svelte v3.37.0 */
2627
2692
 
2628
- /* src/js/components/shepherd-button.svelte generated by Svelte v3.23.2 */
2629
2693
 
2630
- function create_fragment(ctx) {
2694
+ function create_fragment$8(ctx) {
2631
2695
  let button;
2632
2696
  let button_aria_label_value;
2633
2697
  let button_class_value;
@@ -2719,7 +2783,7 @@ function create_fragment(ctx) {
2719
2783
  };
2720
2784
  }
2721
2785
 
2722
- function instance($$self, $$props, $$invalidate) {
2786
+ function instance$8($$self, $$props, $$invalidate) {
2723
2787
  let {
2724
2788
  config
2725
2789
  } = $$props,
@@ -2736,7 +2800,7 @@ function instance($$self, $$props, $$invalidate) {
2736
2800
  return disabled;
2737
2801
  }
2738
2802
 
2739
- $$self.$set = $$props => {
2803
+ $$self.$$set = $$props => {
2740
2804
  if ("config" in $$props) $$invalidate(6, config = $$props.config);
2741
2805
  if ("step" in $$props) $$invalidate(7, step = $$props.step);
2742
2806
  };
@@ -2745,7 +2809,7 @@ function instance($$self, $$props, $$invalidate) {
2745
2809
  if ($$self.$$.dirty &
2746
2810
  /*config, step*/
2747
2811
  192) {
2748
- {
2812
+ {
2749
2813
  $$invalidate(0, action = config.action ? config.action.bind(step.tour) : null);
2750
2814
  $$invalidate(1, classes = config.classes);
2751
2815
  $$invalidate(2, disabled = config.disabled ? getDisabled(config.disabled) : false);
@@ -2762,15 +2826,15 @@ function instance($$self, $$props, $$invalidate) {
2762
2826
  class Shepherd_button extends SvelteComponent {
2763
2827
  constructor(options) {
2764
2828
  super();
2765
- init(this, options, instance, create_fragment, safe_not_equal, {
2829
+ init(this, options, instance$8, create_fragment$8, safe_not_equal, {
2766
2830
  config: 6,
2767
2831
  step: 7
2768
2832
  });
2769
2833
  }
2770
2834
 
2771
2835
  }
2836
+ /* src/js/components/shepherd-footer.svelte generated by Svelte v3.37.0 */
2772
2837
 
2773
- /* src/js/components/shepherd-footer.svelte generated by Svelte v3.23.2 */
2774
2838
 
2775
2839
  function get_each_context(ctx, list, i) {
2776
2840
  const child_ctx = ctx.slice();
@@ -2779,7 +2843,7 @@ function get_each_context(ctx, list, i) {
2779
2843
  } // (24:4) {#if buttons}
2780
2844
 
2781
2845
 
2782
- function create_if_block(ctx) {
2846
+ function create_if_block$3(ctx) {
2783
2847
  let each_1_anchor;
2784
2848
  let current;
2785
2849
  let each_value =
@@ -2931,12 +2995,12 @@ function create_each_block(ctx) {
2931
2995
  };
2932
2996
  }
2933
2997
 
2934
- function create_fragment$1(ctx) {
2998
+ function create_fragment$7(ctx) {
2935
2999
  let footer;
2936
3000
  let current;
2937
3001
  let if_block =
2938
3002
  /*buttons*/
2939
- ctx[1] && create_if_block(ctx);
3003
+ ctx[1] && create_if_block$3(ctx);
2940
3004
  return {
2941
3005
  c() {
2942
3006
  footer = element("footer");
@@ -2963,7 +3027,7 @@ function create_fragment$1(ctx) {
2963
3027
  transition_in(if_block, 1);
2964
3028
  }
2965
3029
  } else {
2966
- if_block = create_if_block(ctx);
3030
+ if_block = create_if_block$3(ctx);
2967
3031
  if_block.c();
2968
3032
  transition_in(if_block, 1);
2969
3033
  if_block.m(footer, null);
@@ -2996,22 +3060,21 @@ function create_fragment$1(ctx) {
2996
3060
  };
2997
3061
  }
2998
3062
 
2999
- function instance$1($$self, $$props, $$invalidate) {
3063
+ function instance$7($$self, $$props, $$invalidate) {
3064
+ let buttons;
3000
3065
  let {
3001
3066
  step
3002
3067
  } = $$props;
3003
3068
 
3004
- $$self.$set = $$props => {
3069
+ $$self.$$set = $$props => {
3005
3070
  if ("step" in $$props) $$invalidate(0, step = $$props.step);
3006
3071
  };
3007
3072
 
3008
- let buttons;
3009
-
3010
3073
  $$self.$$.update = () => {
3011
3074
  if ($$self.$$.dirty &
3012
3075
  /*step*/
3013
3076
  1) {
3014
- $$invalidate(1, buttons = step.options.buttons);
3077
+ $$invalidate(1, buttons = step.options.buttons);
3015
3078
  }
3016
3079
  };
3017
3080
 
@@ -3021,16 +3084,16 @@ function instance$1($$self, $$props, $$invalidate) {
3021
3084
  class Shepherd_footer extends SvelteComponent {
3022
3085
  constructor(options) {
3023
3086
  super();
3024
- init(this, options, instance$1, create_fragment$1, safe_not_equal, {
3087
+ init(this, options, instance$7, create_fragment$7, safe_not_equal, {
3025
3088
  step: 0
3026
3089
  });
3027
3090
  }
3028
3091
 
3029
3092
  }
3093
+ /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.37.0 */
3030
3094
 
3031
- /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.23.2 */
3032
3095
 
3033
- function create_fragment$2(ctx) {
3096
+ function create_fragment$6(ctx) {
3034
3097
  let button;
3035
3098
  let span;
3036
3099
  let button_aria_label_value;
@@ -3087,7 +3150,7 @@ function create_fragment$2(ctx) {
3087
3150
  };
3088
3151
  }
3089
3152
 
3090
- function instance$2($$self, $$props, $$invalidate) {
3153
+ function instance$6($$self, $$props, $$invalidate) {
3091
3154
  let {
3092
3155
  cancelIcon
3093
3156
  } = $$props,
@@ -3103,7 +3166,7 @@ function instance$2($$self, $$props, $$invalidate) {
3103
3166
  step.cancel();
3104
3167
  };
3105
3168
 
3106
- $$self.$set = $$props => {
3169
+ $$self.$$set = $$props => {
3107
3170
  if ("cancelIcon" in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3108
3171
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
3109
3172
  };
@@ -3114,17 +3177,17 @@ function instance$2($$self, $$props, $$invalidate) {
3114
3177
  class Shepherd_cancel_icon extends SvelteComponent {
3115
3178
  constructor(options) {
3116
3179
  super();
3117
- init(this, options, instance$2, create_fragment$2, safe_not_equal, {
3180
+ init(this, options, instance$6, create_fragment$6, safe_not_equal, {
3118
3181
  cancelIcon: 0,
3119
3182
  step: 2
3120
3183
  });
3121
3184
  }
3122
3185
 
3123
3186
  }
3187
+ /* src/js/components/shepherd-title.svelte generated by Svelte v3.37.0 */
3124
3188
 
3125
- /* src/js/components/shepherd-title.svelte generated by Svelte v3.23.2 */
3126
3189
 
3127
- function create_fragment$3(ctx) {
3190
+ function create_fragment$5(ctx) {
3128
3191
  let h3;
3129
3192
  return {
3130
3193
  c() {
@@ -3165,7 +3228,7 @@ function create_fragment$3(ctx) {
3165
3228
  };
3166
3229
  }
3167
3230
 
3168
- function instance$3($$self, $$props, $$invalidate) {
3231
+ function instance$5($$self, $$props, $$invalidate) {
3169
3232
  let {
3170
3233
  labelId
3171
3234
  } = $$props,
@@ -3190,7 +3253,7 @@ function instance$3($$self, $$props, $$invalidate) {
3190
3253
  });
3191
3254
  }
3192
3255
 
3193
- $$self.$set = $$props => {
3256
+ $$self.$$set = $$props => {
3194
3257
  if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3195
3258
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
3196
3259
  if ("title" in $$props) $$invalidate(2, title = $$props.title);
@@ -3202,7 +3265,7 @@ function instance$3($$self, $$props, $$invalidate) {
3202
3265
  class Shepherd_title extends SvelteComponent {
3203
3266
  constructor(options) {
3204
3267
  super();
3205
- init(this, options, instance$3, create_fragment$3, safe_not_equal, {
3268
+ init(this, options, instance$5, create_fragment$5, safe_not_equal, {
3206
3269
  labelId: 1,
3207
3270
  element: 0,
3208
3271
  title: 2
@@ -3210,10 +3273,10 @@ class Shepherd_title extends SvelteComponent {
3210
3273
  }
3211
3274
 
3212
3275
  }
3276
+ /* src/js/components/shepherd-header.svelte generated by Svelte v3.37.0 */
3213
3277
 
3214
- /* src/js/components/shepherd-header.svelte generated by Svelte v3.23.2 */
3215
3278
 
3216
- function create_if_block_1(ctx) {
3279
+ function create_if_block_1$1(ctx) {
3217
3280
  let shepherdtitle;
3218
3281
  let current;
3219
3282
  shepherdtitle = new Shepherd_title({
@@ -3270,7 +3333,7 @@ function create_if_block_1(ctx) {
3270
3333
  } // (39:4) {#if cancelIcon && cancelIcon.enabled}
3271
3334
 
3272
3335
 
3273
- function create_if_block$1(ctx) {
3336
+ function create_if_block$2(ctx) {
3274
3337
  let shepherdcancelicon;
3275
3338
  let current;
3276
3339
  shepherdcancelicon = new Shepherd_cancel_icon({
@@ -3332,12 +3395,12 @@ function create_fragment$4(ctx) {
3332
3395
  let current;
3333
3396
  let if_block0 =
3334
3397
  /*title*/
3335
- ctx[2] && create_if_block_1(ctx);
3398
+ ctx[2] && create_if_block_1$1(ctx);
3336
3399
  let if_block1 =
3337
3400
  /*cancelIcon*/
3338
3401
  ctx[3] &&
3339
3402
  /*cancelIcon*/
3340
- ctx[3].enabled && create_if_block$1(ctx);
3403
+ ctx[3].enabled && create_if_block$2(ctx);
3341
3404
  return {
3342
3405
  c() {
3343
3406
  header = element("header");
@@ -3368,7 +3431,7 @@ function create_fragment$4(ctx) {
3368
3431
  transition_in(if_block0, 1);
3369
3432
  }
3370
3433
  } else {
3371
- if_block0 = create_if_block_1(ctx);
3434
+ if_block0 = create_if_block_1$1(ctx);
3372
3435
  if_block0.c();
3373
3436
  transition_in(if_block0, 1);
3374
3437
  if_block0.m(header, t);
@@ -3395,7 +3458,7 @@ function create_fragment$4(ctx) {
3395
3458
  transition_in(if_block1, 1);
3396
3459
  }
3397
3460
  } else {
3398
- if_block1 = create_if_block$1(ctx);
3461
+ if_block1 = create_if_block$2(ctx);
3399
3462
  if_block1.c();
3400
3463
  transition_in(if_block1, 1);
3401
3464
  if_block1.m(header, null);
@@ -3440,7 +3503,7 @@ function instance$4($$self, $$props, $$invalidate) {
3440
3503
  } = $$props;
3441
3504
  let title, cancelIcon;
3442
3505
 
3443
- $$self.$set = $$props => {
3506
+ $$self.$$set = $$props => {
3444
3507
  if ("labelId" in $$props) $$invalidate(0, labelId = $$props.labelId);
3445
3508
  if ("step" in $$props) $$invalidate(1, step = $$props.step);
3446
3509
  };
@@ -3449,7 +3512,7 @@ function instance$4($$self, $$props, $$invalidate) {
3449
3512
  if ($$self.$$.dirty &
3450
3513
  /*step*/
3451
3514
  2) {
3452
- {
3515
+ {
3453
3516
  $$invalidate(2, title = step.options.title);
3454
3517
  $$invalidate(3, cancelIcon = step.options.cancelIcon);
3455
3518
  }
@@ -3469,10 +3532,10 @@ class Shepherd_header extends SvelteComponent {
3469
3532
  }
3470
3533
 
3471
3534
  }
3535
+ /* src/js/components/shepherd-text.svelte generated by Svelte v3.37.0 */
3472
3536
 
3473
- /* src/js/components/shepherd-text.svelte generated by Svelte v3.23.2 */
3474
3537
 
3475
- function create_fragment$5(ctx) {
3538
+ function create_fragment$3(ctx) {
3476
3539
  let div;
3477
3540
  return {
3478
3541
  c() {
@@ -3513,7 +3576,7 @@ function create_fragment$5(ctx) {
3513
3576
  };
3514
3577
  }
3515
3578
 
3516
- function instance$5($$self, $$props, $$invalidate) {
3579
+ function instance$3($$self, $$props, $$invalidate) {
3517
3580
  let {
3518
3581
  descriptionId
3519
3582
  } = $$props,
@@ -3532,7 +3595,7 @@ function instance$5($$self, $$props, $$invalidate) {
3532
3595
  text = text.call(step);
3533
3596
  }
3534
3597
 
3535
- if (isHTMLElement(text)) {
3598
+ if (isHTMLElement$1(text)) {
3536
3599
  element.appendChild(text);
3537
3600
  } else {
3538
3601
  $$invalidate(0, element.innerHTML = text, element);
@@ -3546,7 +3609,7 @@ function instance$5($$self, $$props, $$invalidate) {
3546
3609
  });
3547
3610
  }
3548
3611
 
3549
- $$self.$set = $$props => {
3612
+ $$self.$$set = $$props => {
3550
3613
  if ("descriptionId" in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3551
3614
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
3552
3615
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
@@ -3558,7 +3621,7 @@ function instance$5($$self, $$props, $$invalidate) {
3558
3621
  class Shepherd_text extends SvelteComponent {
3559
3622
  constructor(options) {
3560
3623
  super();
3561
- init(this, options, instance$5, create_fragment$5, safe_not_equal, {
3624
+ init(this, options, instance$3, create_fragment$3, safe_not_equal, {
3562
3625
  descriptionId: 1,
3563
3626
  element: 0,
3564
3627
  step: 2
@@ -3566,8 +3629,8 @@ class Shepherd_text extends SvelteComponent {
3566
3629
  }
3567
3630
 
3568
3631
  }
3632
+ /* src/js/components/shepherd-content.svelte generated by Svelte v3.37.0 */
3569
3633
 
3570
- /* src/js/components/shepherd-content.svelte generated by Svelte v3.23.2 */
3571
3634
 
3572
3635
  function create_if_block_2(ctx) {
3573
3636
  let shepherdheader;
@@ -3626,7 +3689,7 @@ function create_if_block_2(ctx) {
3626
3689
  } // (28:2) {#if !isUndefined(step.options.text)}
3627
3690
 
3628
3691
 
3629
- function create_if_block_1$1(ctx) {
3692
+ function create_if_block_1(ctx) {
3630
3693
  let shepherdtext;
3631
3694
  let current;
3632
3695
  shepherdtext = new Shepherd_text({
@@ -3683,7 +3746,7 @@ function create_if_block_1$1(ctx) {
3683
3746
  } // (35:2) {#if Array.isArray(step.options.buttons) && step.options.buttons.length}
3684
3747
 
3685
3748
 
3686
- function create_if_block$2(ctx) {
3749
+ function create_if_block$1(ctx) {
3687
3750
  let shepherdfooter;
3688
3751
  let current;
3689
3752
  shepherdfooter = new Shepherd_footer({
@@ -3731,7 +3794,7 @@ function create_if_block$2(ctx) {
3731
3794
  };
3732
3795
  }
3733
3796
 
3734
- function create_fragment$6(ctx) {
3797
+ function create_fragment$2(ctx) {
3735
3798
  let div;
3736
3799
  let show_if_2 = !isUndefined(
3737
3800
  /*step*/
@@ -3752,8 +3815,8 @@ function create_fragment$6(ctx) {
3752
3815
  ctx[2].options.buttons.length;
3753
3816
  let current;
3754
3817
  let if_block0 = show_if_2 && create_if_block_2(ctx);
3755
- let if_block1 = show_if_1 && create_if_block_1$1(ctx);
3756
- let if_block2 = show_if && create_if_block$2(ctx);
3818
+ let if_block1 = show_if_1 && create_if_block_1(ctx);
3819
+ let if_block2 = show_if && create_if_block$1(ctx);
3757
3820
  return {
3758
3821
  c() {
3759
3822
  div = element("div");
@@ -3825,7 +3888,7 @@ function create_fragment$6(ctx) {
3825
3888
  transition_in(if_block1, 1);
3826
3889
  }
3827
3890
  } else {
3828
- if_block1 = create_if_block_1$1(ctx);
3891
+ if_block1 = create_if_block_1(ctx);
3829
3892
  if_block1.c();
3830
3893
  transition_in(if_block1, 1);
3831
3894
  if_block1.m(div, t1);
@@ -3856,7 +3919,7 @@ function create_fragment$6(ctx) {
3856
3919
  transition_in(if_block2, 1);
3857
3920
  }
3858
3921
  } else {
3859
- if_block2 = create_if_block$2(ctx);
3922
+ if_block2 = create_if_block$1(ctx);
3860
3923
  if_block2.c();
3861
3924
  transition_in(if_block2, 1);
3862
3925
  if_block2.m(div, null);
@@ -3895,7 +3958,7 @@ function create_fragment$6(ctx) {
3895
3958
  };
3896
3959
  }
3897
3960
 
3898
- function instance$6($$self, $$props, $$invalidate) {
3961
+ function instance$2($$self, $$props, $$invalidate) {
3899
3962
  let {
3900
3963
  descriptionId
3901
3964
  } = $$props,
@@ -3906,7 +3969,7 @@ function instance$6($$self, $$props, $$invalidate) {
3906
3969
  step
3907
3970
  } = $$props;
3908
3971
 
3909
- $$self.$set = $$props => {
3972
+ $$self.$$set = $$props => {
3910
3973
  if ("descriptionId" in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
3911
3974
  if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3912
3975
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
@@ -3918,7 +3981,7 @@ function instance$6($$self, $$props, $$invalidate) {
3918
3981
  class Shepherd_content extends SvelteComponent {
3919
3982
  constructor(options) {
3920
3983
  super();
3921
- init(this, options, instance$6, create_fragment$6, safe_not_equal, {
3984
+ init(this, options, instance$2, create_fragment$2, safe_not_equal, {
3922
3985
  descriptionId: 0,
3923
3986
  labelId: 1,
3924
3987
  step: 2
@@ -3926,10 +3989,10 @@ class Shepherd_content extends SvelteComponent {
3926
3989
  }
3927
3990
 
3928
3991
  }
3992
+ /* src/js/components/shepherd-element.svelte generated by Svelte v3.37.0 */
3929
3993
 
3930
- /* src/js/components/shepherd-element.svelte generated by Svelte v3.23.2 */
3931
3994
 
3932
- function create_if_block$3(ctx) {
3995
+ function create_if_block(ctx) {
3933
3996
  let div;
3934
3997
  return {
3935
3998
  c() {
@@ -3949,10 +4012,12 @@ function create_if_block$3(ctx) {
3949
4012
  };
3950
4013
  }
3951
4014
 
3952
- function create_fragment$7(ctx) {
4015
+ function create_fragment$1(ctx) {
3953
4016
  let div;
3954
4017
  let t;
3955
4018
  let shepherdcontent;
4019
+ let div_aria_describedby_value;
4020
+ let div_aria_labelledby_value;
3956
4021
  let current;
3957
4022
  let mounted;
3958
4023
  let dispose;
@@ -3964,7 +4029,7 @@ function create_fragment$7(ctx) {
3964
4029
  /*step*/
3965
4030
  ctx[4].options.attachTo.element &&
3966
4031
  /*step*/
3967
- ctx[4].options.attachTo.on && create_if_block$3();
4032
+ ctx[4].options.attachTo.on && create_if_block();
3968
4033
  shepherdcontent = new Shepherd_content({
3969
4034
  props: {
3970
4035
  descriptionId:
@@ -3979,13 +4044,13 @@ function create_fragment$7(ctx) {
3979
4044
  }
3980
4045
  });
3981
4046
  let div_levels = [{
3982
- "aria-describedby": !isUndefined(
4047
+ "aria-describedby": div_aria_describedby_value = !isUndefined(
3983
4048
  /*step*/
3984
4049
  ctx[4].options.text) ?
3985
4050
  /*descriptionId*/
3986
4051
  ctx[2] : null
3987
4052
  }, {
3988
- "aria-labelledby":
4053
+ "aria-labelledby": div_aria_labelledby_value =
3989
4054
  /*step*/
3990
4055
  ctx[4].options.title ?
3991
4056
  /*labelId*/
@@ -4047,8 +4112,8 @@ function create_fragment$7(ctx) {
4047
4112
  ctx[4].options.attachTo.element &&
4048
4113
  /*step*/
4049
4114
  ctx[4].options.attachTo.on) {
4050
- if (if_block) ; else {
4051
- if_block = create_if_block$3();
4115
+ if (if_block) ;else {
4116
+ if_block = create_if_block();
4052
4117
  if_block.c();
4053
4118
  if_block.m(div, t);
4054
4119
  }
@@ -4074,22 +4139,22 @@ function create_fragment$7(ctx) {
4074
4139
  /*step*/
4075
4140
  ctx[4];
4076
4141
  shepherdcontent.$set(shepherdcontent_changes);
4077
- set_attributes(div, div_data = get_spread_update(div_levels, [dirty &
4078
- /*isUndefined, step, descriptionId*/
4079
- 20 && {
4080
- "aria-describedby": !isUndefined(
4081
- /*step*/
4082
- ctx[4].options.text) ?
4083
- /*descriptionId*/
4084
- ctx[2] : null
4085
- }, dirty &
4142
+ set_attributes(div, div_data = get_spread_update(div_levels, [(!current || dirty &
4143
+ /*step, descriptionId*/
4144
+ 20 && div_aria_describedby_value !== (div_aria_describedby_value = !isUndefined(
4145
+ /*step*/
4146
+ ctx[4].options.text) ?
4147
+ /*descriptionId*/
4148
+ ctx[2] : null)) && {
4149
+ "aria-describedby": div_aria_describedby_value
4150
+ }, (!current || dirty &
4086
4151
  /*step, labelId*/
4087
- 24 && {
4088
- "aria-labelledby":
4089
- /*step*/
4090
- ctx[4].options.title ?
4091
- /*labelId*/
4092
- ctx[3] : null
4152
+ 24 && div_aria_labelledby_value !== (div_aria_labelledby_value =
4153
+ /*step*/
4154
+ ctx[4].options.title ?
4155
+ /*labelId*/
4156
+ ctx[3] : null)) && {
4157
+ "aria-labelledby": div_aria_labelledby_value
4093
4158
  }, dirty &
4094
4159
  /*dataStepId*/
4095
4160
  2 &&
@@ -4142,7 +4207,7 @@ function getClassesArray(classes) {
4142
4207
  return classes.split(" ").filter(className => !!className.length);
4143
4208
  }
4144
4209
 
4145
- function instance$7($$self, $$props, $$invalidate) {
4210
+ function instance$1($$self, $$props, $$invalidate) {
4146
4211
  let {
4147
4212
  classPrefix
4148
4213
  } = $$props,
@@ -4237,7 +4302,7 @@ function instance$7($$self, $$props, $$invalidate) {
4237
4302
 
4238
4303
 
4239
4304
  if (e.shiftKey) {
4240
- if (document.activeElement === firstFocusableElement) {
4305
+ if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains("shepherd-element")) {
4241
4306
  e.preventDefault();
4242
4307
  lastFocusableElement.focus();
4243
4308
  }
@@ -4280,7 +4345,7 @@ function instance$7($$self, $$props, $$invalidate) {
4280
4345
  });
4281
4346
  }
4282
4347
 
4283
- $$self.$set = $$props => {
4348
+ $$self.$$set = $$props => {
4284
4349
  if ("classPrefix" in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4285
4350
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
4286
4351
  if ("descriptionId" in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
@@ -4296,7 +4361,7 @@ function instance$7($$self, $$props, $$invalidate) {
4296
4361
  if ($$self.$$.dirty &
4297
4362
  /*step*/
4298
4363
  16) {
4299
- {
4364
+ {
4300
4365
  $$invalidate(5, hasCancelIcon = step.options && step.options.cancelIcon && step.options.cancelIcon.enabled);
4301
4366
  $$invalidate(6, hasTitle = step.options && step.options.title);
4302
4367
  }
@@ -4309,7 +4374,7 @@ function instance$7($$self, $$props, $$invalidate) {
4309
4374
  class Shepherd_element extends SvelteComponent {
4310
4375
  constructor(options) {
4311
4376
  super();
4312
- init(this, options, instance$7, create_fragment$7, safe_not_equal, {
4377
+ init(this, options, instance$1, create_fragment$1, safe_not_equal, {
4313
4378
  classPrefix: 11,
4314
4379
  element: 0,
4315
4380
  descriptionId: 2,
@@ -4330,13 +4395,14 @@ class Shepherd_element extends SvelteComponent {
4330
4395
  }
4331
4396
 
4332
4397
  function createCommonjsModule(fn, module) {
4333
- return module = { exports: {} }, fn(module, module.exports), module.exports;
4398
+ return module = {
4399
+ exports: {}
4400
+ }, fn(module, module.exports), module.exports;
4334
4401
  }
4335
4402
 
4336
4403
  var smoothscroll = createCommonjsModule(function (module, exports) {
4337
4404
  /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
4338
4405
  (function () {
4339
-
4340
4406
  function polyfill() {
4341
4407
  // aliases
4342
4408
  var w = window;
@@ -4675,8 +4741,7 @@ var smoothscroll = createCommonjsModule(function (module, exports) {
4675
4741
  }
4676
4742
  })();
4677
4743
  });
4678
- var smoothscroll_1 = smoothscroll.polyfill;
4679
-
4744
+ smoothscroll.polyfill;
4680
4745
  smoothscroll.polyfill();
4681
4746
  /**
4682
4747
  * A class representing steps to be added to a tour.
@@ -4814,14 +4879,12 @@ class Step extends Evented {
4814
4879
  this.tooltip = null;
4815
4880
  }
4816
4881
 
4817
- if (isHTMLElement(this.el) && this.el.parentNode) {
4882
+ if (isHTMLElement$1(this.el) && this.el.parentNode) {
4818
4883
  this.el.parentNode.removeChild(this.el);
4819
4884
  this.el = null;
4820
4885
  }
4821
4886
 
4822
- if (this.target) {
4823
- this._updateStepTargetOnHide();
4824
- }
4887
+ this._updateStepTargetOnHide();
4825
4888
 
4826
4889
  this.trigger('destroy');
4827
4890
  }
@@ -4847,9 +4910,7 @@ class Step extends Evented {
4847
4910
  this.el.hidden = true;
4848
4911
  }
4849
4912
 
4850
- if (this.target) {
4851
- this._updateStepTargetOnHide();
4852
- }
4913
+ this._updateStepTargetOnHide();
4853
4914
 
4854
4915
  this.trigger('hide');
4855
4916
  }
@@ -4935,7 +4996,7 @@ class Step extends Evented {
4935
4996
  const descriptionId = `${this.id}-description`;
4936
4997
  const labelId = `${this.id}-label`;
4937
4998
  this.shepherdElementComponent = new Shepherd_element({
4938
- target: document.body,
4999
+ target: this.tour.options.stepsContainer || document.body,
4939
5000
  props: {
4940
5001
  classPrefix: this.classPrefix,
4941
5002
  descriptionId,
@@ -4963,7 +5024,7 @@ class Step extends Evented {
4963
5024
 
4964
5025
  if (isFunction(this.options.scrollToHandler)) {
4965
5026
  this.options.scrollToHandler(element);
4966
- } else if (isElement(element) && typeof element.scrollIntoView === 'function') {
5027
+ } else if (isElement$1(element) && typeof element.scrollIntoView === 'function') {
4967
5028
  element.scrollIntoView(scrollToOptions);
4968
5029
  }
4969
5030
  }
@@ -5096,19 +5157,22 @@ class Step extends Evented {
5096
5157
 
5097
5158
 
5098
5159
  _updateStepTargetOnHide() {
5160
+ const target = this.target || document.body;
5161
+
5099
5162
  if (this.options.highlightClass) {
5100
- this.target.classList.remove(this.options.highlightClass);
5163
+ target.classList.remove(this.options.highlightClass);
5101
5164
  }
5102
5165
 
5103
- this.target.classList.remove(`${this.classPrefix}shepherd-enabled`, `${this.classPrefix}shepherd-target`);
5166
+ target.classList.remove('shepherd-target-click-disabled', `${this.classPrefix}shepherd-enabled`, `${this.classPrefix}shepherd-target`);
5104
5167
  }
5105
5168
 
5106
5169
  }
5107
-
5108
5170
  /**
5109
5171
  * Cleanup the steps and set pointerEvents back to 'auto'
5110
5172
  * @param tour The tour object
5111
5173
  */
5174
+
5175
+
5112
5176
  function cleanupSteps(tour) {
5113
5177
  if (tour) {
5114
5178
  const {
@@ -5123,7 +5187,6 @@ function cleanupSteps(tour) {
5123
5187
  });
5124
5188
  }
5125
5189
  }
5126
-
5127
5190
  /**
5128
5191
  * Generates the svg path data for a rounded rectangle overlay
5129
5192
  * @param {Object} dimension - Dimensions of rectangle.
@@ -5134,6 +5197,8 @@ function cleanupSteps(tour) {
5134
5197
  * @param {number} [r=0] - Corner Radius. Keep this smaller than half of width or height.
5135
5198
  * @returns {string} - Rounded rectangle overlay path data.
5136
5199
  */
5200
+
5201
+
5137
5202
  function makeOverlayPath({
5138
5203
  width,
5139
5204
  height,
@@ -5161,10 +5226,10 @@ V${y + r}\
5161
5226
  a${r},${r},0,0,0-${r}-${r}\
5162
5227
  Z`;
5163
5228
  }
5229
+ /* src/js/components/shepherd-modal.svelte generated by Svelte v3.37.0 */
5164
5230
 
5165
- /* src/js/components/shepherd-modal.svelte generated by Svelte v3.23.2 */
5166
5231
 
5167
- function create_fragment$8(ctx) {
5232
+ function create_fragment(ctx) {
5168
5233
  let svg;
5169
5234
  let path;
5170
5235
  let svg_class_value;
@@ -5246,14 +5311,14 @@ function _getScrollParent(element) {
5246
5311
  return _getScrollParent(element.parentElement);
5247
5312
  }
5248
5313
  /**
5249
- * Get the visible height of the target element relative to its scrollParent.
5250
- * If there is no scroll parent, the height of the element is returned.
5251
- *
5252
- * @param {HTMLElement} element The target element
5253
- * @param {HTMLElement} [scrollParent] The scrollable parent element
5254
- * @returns {{y: number, height: number}}
5255
- * @private
5256
- */
5314
+ * Get the visible height of the target element relative to its scrollParent.
5315
+ * If there is no scroll parent, the height of the element is returned.
5316
+ *
5317
+ * @param {HTMLElement} element The target element
5318
+ * @param {HTMLElement} [scrollParent] The scrollable parent element
5319
+ * @returns {{y: number, height: number}}
5320
+ * @private
5321
+ */
5257
5322
 
5258
5323
 
5259
5324
  function _getVisibleHeight(element, scrollParent) {
@@ -5277,14 +5342,14 @@ function _getVisibleHeight(element, scrollParent) {
5277
5342
  };
5278
5343
  }
5279
5344
 
5280
- function instance$8($$self, $$props, $$invalidate) {
5345
+ function instance($$self, $$props, $$invalidate) {
5281
5346
  let {
5282
5347
  element
5283
5348
  } = $$props,
5284
5349
  {
5285
5350
  openingProperties
5286
5351
  } = $$props;
5287
- const guid = uuid();
5352
+ uuid();
5288
5353
  let modalIsVisible = false;
5289
5354
  let rafId = undefined;
5290
5355
  let pathDefinition;
@@ -5308,8 +5373,8 @@ function instance$8($$self, $$props, $$invalidate) {
5308
5373
  _cleanupStepEventListeners();
5309
5374
  }
5310
5375
 
5311
- function positionModalOpening(targetElement, scrollParent, modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0) {
5312
- if (targetElement.getBoundingClientRect) {
5376
+ function positionModal(modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0, scrollParent, targetElement) {
5377
+ if (targetElement) {
5313
5378
  const {
5314
5379
  y,
5315
5380
  height
@@ -5328,6 +5393,8 @@ function instance$8($$self, $$props, $$invalidate) {
5328
5393
  y: y - modalOverlayOpeningPadding,
5329
5394
  r: modalOverlayOpeningRadius
5330
5395
  });
5396
+ } else {
5397
+ closeModalOpening();
5331
5398
  }
5332
5399
  }
5333
5400
 
@@ -5396,22 +5463,18 @@ function instance$8($$self, $$props, $$invalidate) {
5396
5463
  modalOverlayOpeningRadius
5397
5464
  } = step.options;
5398
5465
 
5399
- if (step.target) {
5400
- const scrollParent = _getScrollParent(step.target); // Setup recursive function to call requestAnimationFrame to update the modal opening position
5466
+ const scrollParent = _getScrollParent(step.target); // Setup recursive function to call requestAnimationFrame to update the modal opening position
5401
5467
 
5402
5468
 
5403
- const rafLoop = () => {
5404
- rafId = undefined;
5405
- positionModalOpening(step.target, scrollParent, modalOverlayOpeningPadding, modalOverlayOpeningRadius);
5406
- rafId = requestAnimationFrame(rafLoop);
5407
- };
5469
+ const rafLoop = () => {
5470
+ rafId = undefined;
5471
+ positionModal(modalOverlayOpeningPadding, modalOverlayOpeningRadius, scrollParent, step.target);
5472
+ rafId = requestAnimationFrame(rafLoop);
5473
+ };
5408
5474
 
5409
- rafLoop();
5475
+ rafLoop();
5410
5476
 
5411
- _addStepEventListeners();
5412
- } else {
5413
- closeModalOpening();
5414
- }
5477
+ _addStepEventListeners();
5415
5478
  }
5416
5479
 
5417
5480
  function svg_binding($$value) {
@@ -5421,7 +5484,7 @@ function instance$8($$self, $$props, $$invalidate) {
5421
5484
  });
5422
5485
  }
5423
5486
 
5424
- $$self.$set = $$props => {
5487
+ $$self.$$set = $$props => {
5425
5488
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
5426
5489
  if ("openingProperties" in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5427
5490
  };
@@ -5430,23 +5493,23 @@ function instance$8($$self, $$props, $$invalidate) {
5430
5493
  if ($$self.$$.dirty &
5431
5494
  /*openingProperties*/
5432
5495
  16) {
5433
- $$invalidate(2, pathDefinition = makeOverlayPath(openingProperties));
5496
+ $$invalidate(2, pathDefinition = makeOverlayPath(openingProperties));
5434
5497
  }
5435
5498
  };
5436
5499
 
5437
- return [element, modalIsVisible, pathDefinition, _preventModalOverlayTouch, openingProperties, getElement, closeModalOpening, hide, positionModalOpening, setupForStep, show, svg_binding];
5500
+ return [element, modalIsVisible, pathDefinition, _preventModalOverlayTouch, openingProperties, getElement, closeModalOpening, hide, positionModal, setupForStep, show, svg_binding];
5438
5501
  }
5439
5502
 
5440
5503
  class Shepherd_modal extends SvelteComponent {
5441
5504
  constructor(options) {
5442
5505
  super();
5443
- init(this, options, instance$8, create_fragment$8, safe_not_equal, {
5506
+ init(this, options, instance, create_fragment, safe_not_equal, {
5444
5507
  element: 0,
5445
5508
  openingProperties: 4,
5446
5509
  getElement: 5,
5447
5510
  closeModalOpening: 6,
5448
5511
  hide: 7,
5449
- positionModalOpening: 8,
5512
+ positionModal: 8,
5450
5513
  setupForStep: 9,
5451
5514
  show: 10
5452
5515
  });
@@ -5464,7 +5527,7 @@ class Shepherd_modal extends SvelteComponent {
5464
5527
  return this.$$.ctx[7];
5465
5528
  }
5466
5529
 
5467
- get positionModalOpening() {
5530
+ get positionModal() {
5468
5531
  return this.$$.ctx[8];
5469
5532
  }
5470
5533
 
@@ -5495,6 +5558,8 @@ class Tour extends Evented {
5495
5558
  * set to false.
5496
5559
  * @param {boolean} options.keyboardNavigation Navigating the tour via left and right arrow keys will be enabled
5497
5560
  * unless this is explicitly set to false.
5561
+ * @param {HTMLElement} options.stepsContainer An optional container element for the steps.
5562
+ * If not set, the steps will be appended to `document.body`.
5498
5563
  * @param {HTMLElement} options.modalContainer An optional container element for the modal.
5499
5564
  * If not set, the modal will be appended to `document.body`.
5500
5565
  * @param {object[] | Step[]} options.steps An array of step options objects or Step instances to initialize the tour with
@@ -5775,7 +5840,7 @@ class Tour extends Evented {
5775
5840
  } // Focus the element that was focused before the tour started
5776
5841
 
5777
5842
 
5778
- if (isHTMLElement(this.focusedElBeforeOpen)) {
5843
+ if (isHTMLElement$1(this.focusedElBeforeOpen)) {
5779
5844
  this.focusedElBeforeOpen.focus();
5780
5845
  }
5781
5846
  }
@@ -5853,7 +5918,7 @@ Object.assign(Shepherd, {
5853
5918
  Step
5854
5919
  });
5855
5920
 
5856
- var ShepherdTourContext = React__default.createContext(null);
5921
+ var ShepherdTourContext = React__default["default"].createContext(null);
5857
5922
  var ShepherdTourContextConsumer = ShepherdTourContext.Consumer;
5858
5923
  /**
5859
5924
  * Take a set of steps and formats to use actions on the buttons in the current context
@@ -5866,7 +5931,6 @@ var addSteps = function (steps, tour) {
5866
5931
  if (!steps.length) {
5867
5932
  return [];
5868
5933
  }
5869
- console.log('🍻');
5870
5934
  var parsedStepsforAction = steps.map(function (step) {
5871
5935
  var buttons = step.buttons;
5872
5936
  if (buttons) {
@@ -5875,7 +5939,7 @@ var addSteps = function (steps, tour) {
5875
5939
  return {
5876
5940
  // TypeScript doesn't have great support for dynamic method calls with
5877
5941
  // bracket notation, so we use the `any` escape hatch
5878
- action: action || tour[type],
5942
+ action: tour[type] || action,
5879
5943
  classes: classes,
5880
5944
  disabled: disabled,
5881
5945
  label: label,
@@ -5896,7 +5960,7 @@ var ShepherdTour = function (props) {
5896
5960
  addSteps(steps, tourObject);
5897
5961
  return tourObject;
5898
5962
  }, [tourOptions, steps]);
5899
- return (React__default.createElement(ShepherdTourContext.Provider, { value: tourObject }, props.children));
5963
+ return (React__default["default"].createElement(ShepherdTourContext.Provider, { value: tourObject }, props.children));
5900
5964
  };
5901
5965
 
5902
5966
  exports.ShepherdTour = ShepherdTour;