@tabworthy/components 0.8.6 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/{index-w-Wtojyv.js → index-B1s0tI-Z.js} +21 -0
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/tabworthy-components.cjs.js +2 -2
  4. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +1960 -8
  5. package/dist/cjs/tabworthy-dates.cjs.entry.js +9 -8
  6. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +1 -1
  7. package/dist/cjs/tabworthy-times.cjs.entry.js +6 -5
  8. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +32 -7
  9. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.css +4 -1
  10. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +257 -5
  11. package/dist/collection/components/tabworthy-times/tabworthy-times.js +29 -4
  12. package/dist/components/index.js +1 -1
  13. package/dist/components/{p-DT8TK_a8.js → p-B8sG1vGD.js} +1 -1
  14. package/dist/components/{p-Bnmroodq.js → p-B9YA6avR.js} +1 -1
  15. package/dist/components/p-B9fGfjA-.js +1 -0
  16. package/dist/components/p-BiJ0HZVY.js +1 -0
  17. package/dist/components/tabworthy-dates-calendar.js +1 -1
  18. package/dist/components/tabworthy-dates-modal.js +1 -1
  19. package/dist/components/tabworthy-dates.js +1 -1
  20. package/dist/components/tabworthy-times-picker.js +1 -1
  21. package/dist/components/tabworthy-times.js +1 -1
  22. package/dist/esm/{index-CDFauf_3.js → index-CwtZ_Lud.js} +21 -0
  23. package/dist/esm/loader.js +3 -3
  24. package/dist/esm/tabworthy-components.js +3 -3
  25. package/dist/esm/tabworthy-dates-calendar_2.entry.js +1960 -8
  26. package/dist/esm/tabworthy-dates.entry.js +9 -8
  27. package/dist/esm/tabworthy-times-picker.entry.js +1 -1
  28. package/dist/esm/tabworthy-times.entry.js +6 -5
  29. package/dist/tabworthy-components/{p-8416e0a9.entry.js → p-4eec41e5.entry.js} +1 -1
  30. package/dist/tabworthy-components/{p-dcb3ea8d.entry.js → p-90de04dd.entry.js} +1 -1
  31. package/dist/tabworthy-components/p-CwtZ_Lud.js +2 -0
  32. package/dist/tabworthy-components/{p-224503da.entry.js → p-c0f957f5.entry.js} +1 -1
  33. package/dist/tabworthy-components/p-ee41beed.entry.js +1 -0
  34. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
  35. package/dist/themes/light.css +1 -1
  36. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +6 -1
  37. package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +27 -0
  38. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +6 -1
  39. package/dist/types/components.d.ts +54 -0
  40. package/package.json +2 -1
  41. package/dist/components/p-CGobNAdR.js +0 -1
  42. package/dist/components/p-Kr35QPhi.js +0 -1
  43. package/dist/tabworthy-components/p-CDFauf_3.js +0 -2
  44. package/dist/tabworthy-components/p-e66c010b.entry.js +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-w-Wtojyv.js');
3
+ var index = require('./index-B1s0tI-Z.js');
4
4
  var utils = require('./utils-y5Vtky2t.js');
5
5
 
6
6
  const tabworthyDatesCalendarCss = () => `.visually-hidden.sc-tabworthy-dates-calendar{position:absolute;overflow:hidden;width:1px;height:1px;white-space:nowrap;clip:rect(0 0 0 0);-webkit-clip-path:inset(50%);clip-path:inset(50%)}`;
@@ -530,7 +530,7 @@ const timeouts = new Map();
530
530
  * @param ms
531
531
  * @param id
532
532
  */
533
- function debounce(cb, ms, id) {
533
+ function debounce$1(cb, ms, id) {
534
534
  // Clear current timeout for id
535
535
  const timeout = timeouts.get(id);
536
536
  if (timeout != null) {
@@ -690,7 +690,7 @@ class FocusTrap extends HTMLElement {
690
690
  * @param value
691
691
  */
692
692
  updateFocused(value) {
693
- debounce(() => {
693
+ debounce$1(() => {
694
694
  if (this.focused !== value) {
695
695
  this._focused = value;
696
696
  this.render();
@@ -836,7 +836,1796 @@ var hideOthers = function (originalTarget, parentNode, markerName) {
836
836
  return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
837
837
  };
838
838
 
839
- const tabworthyDatesModalCss = () => `:host::part(body){position:absolute;width:-moz-fit-content;width:fit-content;z-index:1200;margin-top:0.5rem}:host::part(backdrop){}:host::part(content){}`;
839
+ var top = 'top';
840
+ var bottom = 'bottom';
841
+ var right = 'right';
842
+ var left = 'left';
843
+ var auto = 'auto';
844
+ var basePlacements = [top, bottom, right, left];
845
+ var start = 'start';
846
+ var end = 'end';
847
+ var clippingParents = 'clippingParents';
848
+ var viewport = 'viewport';
849
+ var popper = 'popper';
850
+ var reference = 'reference';
851
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
852
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
853
+ }, []);
854
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
855
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
856
+ }, []); // modifiers that need to read the DOM
857
+
858
+ var beforeRead = 'beforeRead';
859
+ var read = 'read';
860
+ var afterRead = 'afterRead'; // pure-logic modifiers
861
+
862
+ var beforeMain = 'beforeMain';
863
+ var main = 'main';
864
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
865
+
866
+ var beforeWrite = 'beforeWrite';
867
+ var write = 'write';
868
+ var afterWrite = 'afterWrite';
869
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
870
+
871
+ function getNodeName(element) {
872
+ return element ? (element.nodeName || '').toLowerCase() : null;
873
+ }
874
+
875
+ function getWindow(node) {
876
+ if (node == null) {
877
+ return window;
878
+ }
879
+
880
+ if (node.toString() !== '[object Window]') {
881
+ var ownerDocument = node.ownerDocument;
882
+ return ownerDocument ? ownerDocument.defaultView || window : window;
883
+ }
884
+
885
+ return node;
886
+ }
887
+
888
+ function isElement(node) {
889
+ var OwnElement = getWindow(node).Element;
890
+ return node instanceof OwnElement || node instanceof Element;
891
+ }
892
+
893
+ function isHTMLElement(node) {
894
+ var OwnElement = getWindow(node).HTMLElement;
895
+ return node instanceof OwnElement || node instanceof HTMLElement;
896
+ }
897
+
898
+ function isShadowRoot(node) {
899
+ // IE 11 has no ShadowRoot
900
+ if (typeof ShadowRoot === 'undefined') {
901
+ return false;
902
+ }
903
+
904
+ var OwnElement = getWindow(node).ShadowRoot;
905
+ return node instanceof OwnElement || node instanceof ShadowRoot;
906
+ }
907
+
908
+ // and applies them to the HTMLElements such as popper and arrow
909
+
910
+ function applyStyles(_ref) {
911
+ var state = _ref.state;
912
+ Object.keys(state.elements).forEach(function (name) {
913
+ var style = state.styles[name] || {};
914
+ var attributes = state.attributes[name] || {};
915
+ var element = state.elements[name]; // arrow is optional + virtual elements
916
+
917
+ if (!isHTMLElement(element) || !getNodeName(element)) {
918
+ return;
919
+ } // Flow doesn't support to extend this property, but it's the most
920
+ // effective way to apply styles to an HTMLElement
921
+ // $FlowFixMe[cannot-write]
922
+
923
+
924
+ Object.assign(element.style, style);
925
+ Object.keys(attributes).forEach(function (name) {
926
+ var value = attributes[name];
927
+
928
+ if (value === false) {
929
+ element.removeAttribute(name);
930
+ } else {
931
+ element.setAttribute(name, value === true ? '' : value);
932
+ }
933
+ });
934
+ });
935
+ }
936
+
937
+ function effect$2(_ref2) {
938
+ var state = _ref2.state;
939
+ var initialStyles = {
940
+ popper: {
941
+ position: state.options.strategy,
942
+ left: '0',
943
+ top: '0',
944
+ margin: '0'
945
+ },
946
+ arrow: {
947
+ position: 'absolute'
948
+ },
949
+ reference: {}
950
+ };
951
+ Object.assign(state.elements.popper.style, initialStyles.popper);
952
+ state.styles = initialStyles;
953
+
954
+ if (state.elements.arrow) {
955
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
956
+ }
957
+
958
+ return function () {
959
+ Object.keys(state.elements).forEach(function (name) {
960
+ var element = state.elements[name];
961
+ var attributes = state.attributes[name] || {};
962
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
963
+
964
+ var style = styleProperties.reduce(function (style, property) {
965
+ style[property] = '';
966
+ return style;
967
+ }, {}); // arrow is optional + virtual elements
968
+
969
+ if (!isHTMLElement(element) || !getNodeName(element)) {
970
+ return;
971
+ }
972
+
973
+ Object.assign(element.style, style);
974
+ Object.keys(attributes).forEach(function (attribute) {
975
+ element.removeAttribute(attribute);
976
+ });
977
+ });
978
+ };
979
+ } // eslint-disable-next-line import/no-unused-modules
980
+
981
+
982
+ var applyStyles$1 = {
983
+ name: 'applyStyles',
984
+ enabled: true,
985
+ phase: 'write',
986
+ fn: applyStyles,
987
+ effect: effect$2,
988
+ requires: ['computeStyles']
989
+ };
990
+
991
+ function getBasePlacement(placement) {
992
+ return placement.split('-')[0];
993
+ }
994
+
995
+ var max = Math.max;
996
+ var min = Math.min;
997
+ var round = Math.round;
998
+
999
+ function getUAString() {
1000
+ var uaData = navigator.userAgentData;
1001
+
1002
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
1003
+ return uaData.brands.map(function (item) {
1004
+ return item.brand + "/" + item.version;
1005
+ }).join(' ');
1006
+ }
1007
+
1008
+ return navigator.userAgent;
1009
+ }
1010
+
1011
+ function isLayoutViewport() {
1012
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
1013
+ }
1014
+
1015
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1016
+ if (includeScale === void 0) {
1017
+ includeScale = false;
1018
+ }
1019
+
1020
+ if (isFixedStrategy === void 0) {
1021
+ isFixedStrategy = false;
1022
+ }
1023
+
1024
+ var clientRect = element.getBoundingClientRect();
1025
+ var scaleX = 1;
1026
+ var scaleY = 1;
1027
+
1028
+ if (includeScale && isHTMLElement(element)) {
1029
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1030
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1031
+ }
1032
+
1033
+ var _ref = isElement(element) ? getWindow(element) : window,
1034
+ visualViewport = _ref.visualViewport;
1035
+
1036
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1037
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
1038
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
1039
+ var width = clientRect.width / scaleX;
1040
+ var height = clientRect.height / scaleY;
1041
+ return {
1042
+ width: width,
1043
+ height: height,
1044
+ top: y,
1045
+ right: x + width,
1046
+ bottom: y + height,
1047
+ left: x,
1048
+ x: x,
1049
+ y: y
1050
+ };
1051
+ }
1052
+
1053
+ // means it doesn't take into account transforms.
1054
+
1055
+ function getLayoutRect(element) {
1056
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
1057
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
1058
+
1059
+ var width = element.offsetWidth;
1060
+ var height = element.offsetHeight;
1061
+
1062
+ if (Math.abs(clientRect.width - width) <= 1) {
1063
+ width = clientRect.width;
1064
+ }
1065
+
1066
+ if (Math.abs(clientRect.height - height) <= 1) {
1067
+ height = clientRect.height;
1068
+ }
1069
+
1070
+ return {
1071
+ x: element.offsetLeft,
1072
+ y: element.offsetTop,
1073
+ width: width,
1074
+ height: height
1075
+ };
1076
+ }
1077
+
1078
+ function contains(parent, child) {
1079
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
1080
+
1081
+ if (parent.contains(child)) {
1082
+ return true;
1083
+ } // then fallback to custom implementation with Shadow DOM support
1084
+ else if (rootNode && isShadowRoot(rootNode)) {
1085
+ var next = child;
1086
+
1087
+ do {
1088
+ if (next && parent.isSameNode(next)) {
1089
+ return true;
1090
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
1091
+
1092
+
1093
+ next = next.parentNode || next.host;
1094
+ } while (next);
1095
+ } // Give up, the result is false
1096
+
1097
+
1098
+ return false;
1099
+ }
1100
+
1101
+ function getComputedStyle(element) {
1102
+ return getWindow(element).getComputedStyle(element);
1103
+ }
1104
+
1105
+ function isTableElement(element) {
1106
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
1107
+ }
1108
+
1109
+ function getDocumentElement(element) {
1110
+ // $FlowFixMe[incompatible-return]: assume body is always available
1111
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
1112
+ element.document) || window.document).documentElement;
1113
+ }
1114
+
1115
+ function getParentNode(element) {
1116
+ if (getNodeName(element) === 'html') {
1117
+ return element;
1118
+ }
1119
+
1120
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1121
+ // $FlowFixMe[incompatible-return]
1122
+ // $FlowFixMe[prop-missing]
1123
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1124
+ element.parentNode || ( // DOM Element detected
1125
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
1126
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1127
+ getDocumentElement(element) // fallback
1128
+
1129
+ );
1130
+ }
1131
+
1132
+ function getTrueOffsetParent(element) {
1133
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
1134
+ getComputedStyle(element).position === 'fixed') {
1135
+ return null;
1136
+ }
1137
+
1138
+ return element.offsetParent;
1139
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
1140
+ // return the containing block
1141
+
1142
+
1143
+ function getContainingBlock(element) {
1144
+ var isFirefox = /firefox/i.test(getUAString());
1145
+ var isIE = /Trident/i.test(getUAString());
1146
+
1147
+ if (isIE && isHTMLElement(element)) {
1148
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
1149
+ var elementCss = getComputedStyle(element);
1150
+
1151
+ if (elementCss.position === 'fixed') {
1152
+ return null;
1153
+ }
1154
+ }
1155
+
1156
+ var currentNode = getParentNode(element);
1157
+
1158
+ if (isShadowRoot(currentNode)) {
1159
+ currentNode = currentNode.host;
1160
+ }
1161
+
1162
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
1163
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
1164
+ // create a containing block.
1165
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1166
+
1167
+ 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') {
1168
+ return currentNode;
1169
+ } else {
1170
+ currentNode = currentNode.parentNode;
1171
+ }
1172
+ }
1173
+
1174
+ return null;
1175
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1176
+ // such as table ancestors and cross browser bugs.
1177
+
1178
+
1179
+ function getOffsetParent(element) {
1180
+ var window = getWindow(element);
1181
+ var offsetParent = getTrueOffsetParent(element);
1182
+
1183
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1184
+ offsetParent = getTrueOffsetParent(offsetParent);
1185
+ }
1186
+
1187
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
1188
+ return window;
1189
+ }
1190
+
1191
+ return offsetParent || getContainingBlock(element) || window;
1192
+ }
1193
+
1194
+ function getMainAxisFromPlacement(placement) {
1195
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1196
+ }
1197
+
1198
+ function within(min$1, value, max$1) {
1199
+ return max(min$1, min(value, max$1));
1200
+ }
1201
+ function withinMaxClamp(min, value, max) {
1202
+ var v = within(min, value, max);
1203
+ return v > max ? max : v;
1204
+ }
1205
+
1206
+ function getFreshSideObject() {
1207
+ return {
1208
+ top: 0,
1209
+ right: 0,
1210
+ bottom: 0,
1211
+ left: 0
1212
+ };
1213
+ }
1214
+
1215
+ function mergePaddingObject(paddingObject) {
1216
+ return Object.assign({}, getFreshSideObject(), paddingObject);
1217
+ }
1218
+
1219
+ function expandToHashMap(value, keys) {
1220
+ return keys.reduce(function (hashMap, key) {
1221
+ hashMap[key] = value;
1222
+ return hashMap;
1223
+ }, {});
1224
+ }
1225
+
1226
+ var toPaddingObject = function toPaddingObject(padding, state) {
1227
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
1228
+ placement: state.placement
1229
+ })) : padding;
1230
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1231
+ };
1232
+
1233
+ function arrow(_ref) {
1234
+ var _state$modifiersData$;
1235
+
1236
+ var state = _ref.state,
1237
+ name = _ref.name,
1238
+ options = _ref.options;
1239
+ var arrowElement = state.elements.arrow;
1240
+ var popperOffsets = state.modifiersData.popperOffsets;
1241
+ var basePlacement = getBasePlacement(state.placement);
1242
+ var axis = getMainAxisFromPlacement(basePlacement);
1243
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
1244
+ var len = isVertical ? 'height' : 'width';
1245
+
1246
+ if (!arrowElement || !popperOffsets) {
1247
+ return;
1248
+ }
1249
+
1250
+ var paddingObject = toPaddingObject(options.padding, state);
1251
+ var arrowRect = getLayoutRect(arrowElement);
1252
+ var minProp = axis === 'y' ? top : left;
1253
+ var maxProp = axis === 'y' ? bottom : right;
1254
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1255
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1256
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1257
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1258
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1259
+ // outside of the popper bounds
1260
+
1261
+ var min = paddingObject[minProp];
1262
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1263
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1264
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1265
+
1266
+ var axisProp = axis;
1267
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1268
+ }
1269
+
1270
+ function effect$1(_ref2) {
1271
+ var state = _ref2.state,
1272
+ options = _ref2.options;
1273
+ var _options$element = options.element,
1274
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
1275
+
1276
+ if (arrowElement == null) {
1277
+ return;
1278
+ } // CSS selector
1279
+
1280
+
1281
+ if (typeof arrowElement === 'string') {
1282
+ arrowElement = state.elements.popper.querySelector(arrowElement);
1283
+
1284
+ if (!arrowElement) {
1285
+ return;
1286
+ }
1287
+ }
1288
+
1289
+ if (!contains(state.elements.popper, arrowElement)) {
1290
+ return;
1291
+ }
1292
+
1293
+ state.elements.arrow = arrowElement;
1294
+ } // eslint-disable-next-line import/no-unused-modules
1295
+
1296
+
1297
+ var arrow$1 = {
1298
+ name: 'arrow',
1299
+ enabled: true,
1300
+ phase: 'main',
1301
+ fn: arrow,
1302
+ effect: effect$1,
1303
+ requires: ['popperOffsets'],
1304
+ requiresIfExists: ['preventOverflow']
1305
+ };
1306
+
1307
+ function getVariation(placement) {
1308
+ return placement.split('-')[1];
1309
+ }
1310
+
1311
+ var unsetSides = {
1312
+ top: 'auto',
1313
+ right: 'auto',
1314
+ bottom: 'auto',
1315
+ left: 'auto'
1316
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1317
+ // Zooming can change the DPR, but it seems to report a value that will
1318
+ // cleanly divide the values into the appropriate subpixels.
1319
+
1320
+ function roundOffsetsByDPR(_ref, win) {
1321
+ var x = _ref.x,
1322
+ y = _ref.y;
1323
+ var dpr = win.devicePixelRatio || 1;
1324
+ return {
1325
+ x: round(x * dpr) / dpr || 0,
1326
+ y: round(y * dpr) / dpr || 0
1327
+ };
1328
+ }
1329
+
1330
+ function mapToStyles(_ref2) {
1331
+ var _Object$assign2;
1332
+
1333
+ var popper = _ref2.popper,
1334
+ popperRect = _ref2.popperRect,
1335
+ placement = _ref2.placement,
1336
+ variation = _ref2.variation,
1337
+ offsets = _ref2.offsets,
1338
+ position = _ref2.position,
1339
+ gpuAcceleration = _ref2.gpuAcceleration,
1340
+ adaptive = _ref2.adaptive,
1341
+ roundOffsets = _ref2.roundOffsets,
1342
+ isFixed = _ref2.isFixed;
1343
+ var _offsets$x = offsets.x,
1344
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1345
+ _offsets$y = offsets.y,
1346
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1347
+
1348
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1349
+ x: x,
1350
+ y: y
1351
+ }) : {
1352
+ x: x,
1353
+ y: y
1354
+ };
1355
+
1356
+ x = _ref3.x;
1357
+ y = _ref3.y;
1358
+ var hasX = offsets.hasOwnProperty('x');
1359
+ var hasY = offsets.hasOwnProperty('y');
1360
+ var sideX = left;
1361
+ var sideY = top;
1362
+ var win = window;
1363
+
1364
+ if (adaptive) {
1365
+ var offsetParent = getOffsetParent(popper);
1366
+ var heightProp = 'clientHeight';
1367
+ var widthProp = 'clientWidth';
1368
+
1369
+ if (offsetParent === getWindow(popper)) {
1370
+ offsetParent = getDocumentElement(popper);
1371
+
1372
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1373
+ heightProp = 'scrollHeight';
1374
+ widthProp = 'scrollWidth';
1375
+ }
1376
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1377
+
1378
+
1379
+ offsetParent = offsetParent;
1380
+
1381
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1382
+ sideY = bottom;
1383
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1384
+ offsetParent[heightProp];
1385
+ y -= offsetY - popperRect.height;
1386
+ y *= gpuAcceleration ? 1 : -1;
1387
+ }
1388
+
1389
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1390
+ sideX = right;
1391
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1392
+ offsetParent[widthProp];
1393
+ x -= offsetX - popperRect.width;
1394
+ x *= gpuAcceleration ? 1 : -1;
1395
+ }
1396
+ }
1397
+
1398
+ var commonStyles = Object.assign({
1399
+ position: position
1400
+ }, adaptive && unsetSides);
1401
+
1402
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1403
+ x: x,
1404
+ y: y
1405
+ }, getWindow(popper)) : {
1406
+ x: x,
1407
+ y: y
1408
+ };
1409
+
1410
+ x = _ref4.x;
1411
+ y = _ref4.y;
1412
+
1413
+ if (gpuAcceleration) {
1414
+ var _Object$assign;
1415
+
1416
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1417
+ }
1418
+
1419
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1420
+ }
1421
+
1422
+ function computeStyles(_ref5) {
1423
+ var state = _ref5.state,
1424
+ options = _ref5.options;
1425
+ var _options$gpuAccelerat = options.gpuAcceleration,
1426
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1427
+ _options$adaptive = options.adaptive,
1428
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1429
+ _options$roundOffsets = options.roundOffsets,
1430
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1431
+ var commonStyles = {
1432
+ placement: getBasePlacement(state.placement),
1433
+ variation: getVariation(state.placement),
1434
+ popper: state.elements.popper,
1435
+ popperRect: state.rects.popper,
1436
+ gpuAcceleration: gpuAcceleration,
1437
+ isFixed: state.options.strategy === 'fixed'
1438
+ };
1439
+
1440
+ if (state.modifiersData.popperOffsets != null) {
1441
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1442
+ offsets: state.modifiersData.popperOffsets,
1443
+ position: state.options.strategy,
1444
+ adaptive: adaptive,
1445
+ roundOffsets: roundOffsets
1446
+ })));
1447
+ }
1448
+
1449
+ if (state.modifiersData.arrow != null) {
1450
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1451
+ offsets: state.modifiersData.arrow,
1452
+ position: 'absolute',
1453
+ adaptive: false,
1454
+ roundOffsets: roundOffsets
1455
+ })));
1456
+ }
1457
+
1458
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1459
+ 'data-popper-placement': state.placement
1460
+ });
1461
+ } // eslint-disable-next-line import/no-unused-modules
1462
+
1463
+
1464
+ var computeStyles$1 = {
1465
+ name: 'computeStyles',
1466
+ enabled: true,
1467
+ phase: 'beforeWrite',
1468
+ fn: computeStyles,
1469
+ data: {}
1470
+ };
1471
+
1472
+ var passive = {
1473
+ passive: true
1474
+ };
1475
+
1476
+ function effect(_ref) {
1477
+ var state = _ref.state,
1478
+ instance = _ref.instance,
1479
+ options = _ref.options;
1480
+ var _options$scroll = options.scroll,
1481
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
1482
+ _options$resize = options.resize,
1483
+ resize = _options$resize === void 0 ? true : _options$resize;
1484
+ var window = getWindow(state.elements.popper);
1485
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1486
+
1487
+ if (scroll) {
1488
+ scrollParents.forEach(function (scrollParent) {
1489
+ scrollParent.addEventListener('scroll', instance.update, passive);
1490
+ });
1491
+ }
1492
+
1493
+ if (resize) {
1494
+ window.addEventListener('resize', instance.update, passive);
1495
+ }
1496
+
1497
+ return function () {
1498
+ if (scroll) {
1499
+ scrollParents.forEach(function (scrollParent) {
1500
+ scrollParent.removeEventListener('scroll', instance.update, passive);
1501
+ });
1502
+ }
1503
+
1504
+ if (resize) {
1505
+ window.removeEventListener('resize', instance.update, passive);
1506
+ }
1507
+ };
1508
+ } // eslint-disable-next-line import/no-unused-modules
1509
+
1510
+
1511
+ var eventListeners = {
1512
+ name: 'eventListeners',
1513
+ enabled: true,
1514
+ phase: 'write',
1515
+ fn: function fn() {},
1516
+ effect: effect,
1517
+ data: {}
1518
+ };
1519
+
1520
+ var hash$1 = {
1521
+ left: 'right',
1522
+ right: 'left',
1523
+ bottom: 'top',
1524
+ top: 'bottom'
1525
+ };
1526
+ function getOppositePlacement(placement) {
1527
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
1528
+ return hash$1[matched];
1529
+ });
1530
+ }
1531
+
1532
+ var hash = {
1533
+ start: 'end',
1534
+ end: 'start'
1535
+ };
1536
+ function getOppositeVariationPlacement(placement) {
1537
+ return placement.replace(/start|end/g, function (matched) {
1538
+ return hash[matched];
1539
+ });
1540
+ }
1541
+
1542
+ function getWindowScroll(node) {
1543
+ var win = getWindow(node);
1544
+ var scrollLeft = win.pageXOffset;
1545
+ var scrollTop = win.pageYOffset;
1546
+ return {
1547
+ scrollLeft: scrollLeft,
1548
+ scrollTop: scrollTop
1549
+ };
1550
+ }
1551
+
1552
+ function getWindowScrollBarX(element) {
1553
+ // If <html> has a CSS width greater than the viewport, then this will be
1554
+ // incorrect for RTL.
1555
+ // Popper 1 is broken in this case and never had a bug report so let's assume
1556
+ // it's not an issue. I don't think anyone ever specifies width on <html>
1557
+ // anyway.
1558
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
1559
+ // this (e.g. Edge 2019, IE11, Safari)
1560
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
1561
+ }
1562
+
1563
+ function getViewportRect(element, strategy) {
1564
+ var win = getWindow(element);
1565
+ var html = getDocumentElement(element);
1566
+ var visualViewport = win.visualViewport;
1567
+ var width = html.clientWidth;
1568
+ var height = html.clientHeight;
1569
+ var x = 0;
1570
+ var y = 0;
1571
+
1572
+ if (visualViewport) {
1573
+ width = visualViewport.width;
1574
+ height = visualViewport.height;
1575
+ var layoutViewport = isLayoutViewport();
1576
+
1577
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1578
+ x = visualViewport.offsetLeft;
1579
+ y = visualViewport.offsetTop;
1580
+ }
1581
+ }
1582
+
1583
+ return {
1584
+ width: width,
1585
+ height: height,
1586
+ x: x + getWindowScrollBarX(element),
1587
+ y: y
1588
+ };
1589
+ }
1590
+
1591
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1592
+
1593
+ function getDocumentRect(element) {
1594
+ var _element$ownerDocumen;
1595
+
1596
+ var html = getDocumentElement(element);
1597
+ var winScroll = getWindowScroll(element);
1598
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1599
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1600
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1601
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1602
+ var y = -winScroll.scrollTop;
1603
+
1604
+ if (getComputedStyle(body || html).direction === 'rtl') {
1605
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1606
+ }
1607
+
1608
+ return {
1609
+ width: width,
1610
+ height: height,
1611
+ x: x,
1612
+ y: y
1613
+ };
1614
+ }
1615
+
1616
+ function isScrollParent(element) {
1617
+ // Firefox wants us to check `-x` and `-y` variations as well
1618
+ var _getComputedStyle = getComputedStyle(element),
1619
+ overflow = _getComputedStyle.overflow,
1620
+ overflowX = _getComputedStyle.overflowX,
1621
+ overflowY = _getComputedStyle.overflowY;
1622
+
1623
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1624
+ }
1625
+
1626
+ function getScrollParent(node) {
1627
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
1628
+ // $FlowFixMe[incompatible-return]: assume body is always available
1629
+ return node.ownerDocument.body;
1630
+ }
1631
+
1632
+ if (isHTMLElement(node) && isScrollParent(node)) {
1633
+ return node;
1634
+ }
1635
+
1636
+ return getScrollParent(getParentNode(node));
1637
+ }
1638
+
1639
+ /*
1640
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
1641
+ until we get to the top window object. This list is what we attach scroll listeners
1642
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
1643
+ reference element's position.
1644
+ */
1645
+
1646
+ function listScrollParents(element, list) {
1647
+ var _element$ownerDocumen;
1648
+
1649
+ if (list === void 0) {
1650
+ list = [];
1651
+ }
1652
+
1653
+ var scrollParent = getScrollParent(element);
1654
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1655
+ var win = getWindow(scrollParent);
1656
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1657
+ var updatedList = list.concat(target);
1658
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1659
+ updatedList.concat(listScrollParents(getParentNode(target)));
1660
+ }
1661
+
1662
+ function rectToClientRect(rect) {
1663
+ return Object.assign({}, rect, {
1664
+ left: rect.x,
1665
+ top: rect.y,
1666
+ right: rect.x + rect.width,
1667
+ bottom: rect.y + rect.height
1668
+ });
1669
+ }
1670
+
1671
+ function getInnerBoundingClientRect(element, strategy) {
1672
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
1673
+ rect.top = rect.top + element.clientTop;
1674
+ rect.left = rect.left + element.clientLeft;
1675
+ rect.bottom = rect.top + element.clientHeight;
1676
+ rect.right = rect.left + element.clientWidth;
1677
+ rect.width = element.clientWidth;
1678
+ rect.height = element.clientHeight;
1679
+ rect.x = rect.left;
1680
+ rect.y = rect.top;
1681
+ return rect;
1682
+ }
1683
+
1684
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
1685
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1686
+ } // A "clipping parent" is an overflowable container with the characteristic of
1687
+ // clipping (or hiding) overflowing elements with a position different from
1688
+ // `initial`
1689
+
1690
+
1691
+ function getClippingParents(element) {
1692
+ var clippingParents = listScrollParents(getParentNode(element));
1693
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
1694
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1695
+
1696
+ if (!isElement(clipperElement)) {
1697
+ return [];
1698
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
1699
+
1700
+
1701
+ return clippingParents.filter(function (clippingParent) {
1702
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
1703
+ });
1704
+ } // Gets the maximum area that the element is visible in due to any number of
1705
+ // clipping parents
1706
+
1707
+
1708
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
1709
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
1710
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
1711
+ var firstClippingParent = clippingParents[0];
1712
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
1713
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
1714
+ accRect.top = max(rect.top, accRect.top);
1715
+ accRect.right = min(rect.right, accRect.right);
1716
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1717
+ accRect.left = max(rect.left, accRect.left);
1718
+ return accRect;
1719
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
1720
+ clippingRect.width = clippingRect.right - clippingRect.left;
1721
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1722
+ clippingRect.x = clippingRect.left;
1723
+ clippingRect.y = clippingRect.top;
1724
+ return clippingRect;
1725
+ }
1726
+
1727
+ function computeOffsets(_ref) {
1728
+ var reference = _ref.reference,
1729
+ element = _ref.element,
1730
+ placement = _ref.placement;
1731
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1732
+ var variation = placement ? getVariation(placement) : null;
1733
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1734
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1735
+ var offsets;
1736
+
1737
+ switch (basePlacement) {
1738
+ case top:
1739
+ offsets = {
1740
+ x: commonX,
1741
+ y: reference.y - element.height
1742
+ };
1743
+ break;
1744
+
1745
+ case bottom:
1746
+ offsets = {
1747
+ x: commonX,
1748
+ y: reference.y + reference.height
1749
+ };
1750
+ break;
1751
+
1752
+ case right:
1753
+ offsets = {
1754
+ x: reference.x + reference.width,
1755
+ y: commonY
1756
+ };
1757
+ break;
1758
+
1759
+ case left:
1760
+ offsets = {
1761
+ x: reference.x - element.width,
1762
+ y: commonY
1763
+ };
1764
+ break;
1765
+
1766
+ default:
1767
+ offsets = {
1768
+ x: reference.x,
1769
+ y: reference.y
1770
+ };
1771
+ }
1772
+
1773
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1774
+
1775
+ if (mainAxis != null) {
1776
+ var len = mainAxis === 'y' ? 'height' : 'width';
1777
+
1778
+ switch (variation) {
1779
+ case start:
1780
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1781
+ break;
1782
+
1783
+ case end:
1784
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1785
+ break;
1786
+ }
1787
+ }
1788
+
1789
+ return offsets;
1790
+ }
1791
+
1792
+ function detectOverflow(state, options) {
1793
+ if (options === void 0) {
1794
+ options = {};
1795
+ }
1796
+
1797
+ var _options = options,
1798
+ _options$placement = _options.placement,
1799
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
1800
+ _options$strategy = _options.strategy,
1801
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
1802
+ _options$boundary = _options.boundary,
1803
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1804
+ _options$rootBoundary = _options.rootBoundary,
1805
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1806
+ _options$elementConte = _options.elementContext,
1807
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1808
+ _options$altBoundary = _options.altBoundary,
1809
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1810
+ _options$padding = _options.padding,
1811
+ padding = _options$padding === void 0 ? 0 : _options$padding;
1812
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1813
+ var altContext = elementContext === popper ? reference : popper;
1814
+ var popperRect = state.rects.popper;
1815
+ var element = state.elements[altBoundary ? altContext : elementContext];
1816
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
1817
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1818
+ var popperOffsets = computeOffsets({
1819
+ reference: referenceClientRect,
1820
+ element: popperRect,
1821
+ placement: placement
1822
+ });
1823
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1824
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1825
+ // 0 or negative = within the clipping rect
1826
+
1827
+ var overflowOffsets = {
1828
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1829
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1830
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1831
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1832
+ };
1833
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1834
+
1835
+ if (elementContext === popper && offsetData) {
1836
+ var offset = offsetData[placement];
1837
+ Object.keys(overflowOffsets).forEach(function (key) {
1838
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1839
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1840
+ overflowOffsets[key] += offset[axis] * multiply;
1841
+ });
1842
+ }
1843
+
1844
+ return overflowOffsets;
1845
+ }
1846
+
1847
+ function computeAutoPlacement(state, options) {
1848
+ if (options === void 0) {
1849
+ options = {};
1850
+ }
1851
+
1852
+ var _options = options,
1853
+ placement = _options.placement,
1854
+ boundary = _options.boundary,
1855
+ rootBoundary = _options.rootBoundary,
1856
+ padding = _options.padding,
1857
+ flipVariations = _options.flipVariations,
1858
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1859
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1860
+ var variation = getVariation(placement);
1861
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1862
+ return getVariation(placement) === variation;
1863
+ }) : basePlacements;
1864
+ var allowedPlacements = placements$1.filter(function (placement) {
1865
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1866
+ });
1867
+
1868
+ if (allowedPlacements.length === 0) {
1869
+ allowedPlacements = placements$1;
1870
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1871
+
1872
+
1873
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1874
+ acc[placement] = detectOverflow(state, {
1875
+ placement: placement,
1876
+ boundary: boundary,
1877
+ rootBoundary: rootBoundary,
1878
+ padding: padding
1879
+ })[getBasePlacement(placement)];
1880
+ return acc;
1881
+ }, {});
1882
+ return Object.keys(overflows).sort(function (a, b) {
1883
+ return overflows[a] - overflows[b];
1884
+ });
1885
+ }
1886
+
1887
+ function getExpandedFallbackPlacements(placement) {
1888
+ if (getBasePlacement(placement) === auto) {
1889
+ return [];
1890
+ }
1891
+
1892
+ var oppositePlacement = getOppositePlacement(placement);
1893
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1894
+ }
1895
+
1896
+ function flip(_ref) {
1897
+ var state = _ref.state,
1898
+ options = _ref.options,
1899
+ name = _ref.name;
1900
+
1901
+ if (state.modifiersData[name]._skip) {
1902
+ return;
1903
+ }
1904
+
1905
+ var _options$mainAxis = options.mainAxis,
1906
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1907
+ _options$altAxis = options.altAxis,
1908
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1909
+ specifiedFallbackPlacements = options.fallbackPlacements,
1910
+ padding = options.padding,
1911
+ boundary = options.boundary,
1912
+ rootBoundary = options.rootBoundary,
1913
+ altBoundary = options.altBoundary,
1914
+ _options$flipVariatio = options.flipVariations,
1915
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1916
+ allowedAutoPlacements = options.allowedAutoPlacements;
1917
+ var preferredPlacement = state.options.placement;
1918
+ var basePlacement = getBasePlacement(preferredPlacement);
1919
+ var isBasePlacement = basePlacement === preferredPlacement;
1920
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1921
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1922
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1923
+ placement: placement,
1924
+ boundary: boundary,
1925
+ rootBoundary: rootBoundary,
1926
+ padding: padding,
1927
+ flipVariations: flipVariations,
1928
+ allowedAutoPlacements: allowedAutoPlacements
1929
+ }) : placement);
1930
+ }, []);
1931
+ var referenceRect = state.rects.reference;
1932
+ var popperRect = state.rects.popper;
1933
+ var checksMap = new Map();
1934
+ var makeFallbackChecks = true;
1935
+ var firstFittingPlacement = placements[0];
1936
+
1937
+ for (var i = 0; i < placements.length; i++) {
1938
+ var placement = placements[i];
1939
+
1940
+ var _basePlacement = getBasePlacement(placement);
1941
+
1942
+ var isStartVariation = getVariation(placement) === start;
1943
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1944
+ var len = isVertical ? 'width' : 'height';
1945
+ var overflow = detectOverflow(state, {
1946
+ placement: placement,
1947
+ boundary: boundary,
1948
+ rootBoundary: rootBoundary,
1949
+ altBoundary: altBoundary,
1950
+ padding: padding
1951
+ });
1952
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1953
+
1954
+ if (referenceRect[len] > popperRect[len]) {
1955
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1956
+ }
1957
+
1958
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1959
+ var checks = [];
1960
+
1961
+ if (checkMainAxis) {
1962
+ checks.push(overflow[_basePlacement] <= 0);
1963
+ }
1964
+
1965
+ if (checkAltAxis) {
1966
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1967
+ }
1968
+
1969
+ if (checks.every(function (check) {
1970
+ return check;
1971
+ })) {
1972
+ firstFittingPlacement = placement;
1973
+ makeFallbackChecks = false;
1974
+ break;
1975
+ }
1976
+
1977
+ checksMap.set(placement, checks);
1978
+ }
1979
+
1980
+ if (makeFallbackChecks) {
1981
+ // `2` may be desired in some cases – research later
1982
+ var numberOfChecks = flipVariations ? 3 : 1;
1983
+
1984
+ var _loop = function _loop(_i) {
1985
+ var fittingPlacement = placements.find(function (placement) {
1986
+ var checks = checksMap.get(placement);
1987
+
1988
+ if (checks) {
1989
+ return checks.slice(0, _i).every(function (check) {
1990
+ return check;
1991
+ });
1992
+ }
1993
+ });
1994
+
1995
+ if (fittingPlacement) {
1996
+ firstFittingPlacement = fittingPlacement;
1997
+ return "break";
1998
+ }
1999
+ };
2000
+
2001
+ for (var _i = numberOfChecks; _i > 0; _i--) {
2002
+ var _ret = _loop(_i);
2003
+
2004
+ if (_ret === "break") break;
2005
+ }
2006
+ }
2007
+
2008
+ if (state.placement !== firstFittingPlacement) {
2009
+ state.modifiersData[name]._skip = true;
2010
+ state.placement = firstFittingPlacement;
2011
+ state.reset = true;
2012
+ }
2013
+ } // eslint-disable-next-line import/no-unused-modules
2014
+
2015
+
2016
+ var flip$1 = {
2017
+ name: 'flip',
2018
+ enabled: true,
2019
+ phase: 'main',
2020
+ fn: flip,
2021
+ requiresIfExists: ['offset'],
2022
+ data: {
2023
+ _skip: false
2024
+ }
2025
+ };
2026
+
2027
+ function getSideOffsets(overflow, rect, preventedOffsets) {
2028
+ if (preventedOffsets === void 0) {
2029
+ preventedOffsets = {
2030
+ x: 0,
2031
+ y: 0
2032
+ };
2033
+ }
2034
+
2035
+ return {
2036
+ top: overflow.top - rect.height - preventedOffsets.y,
2037
+ right: overflow.right - rect.width + preventedOffsets.x,
2038
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
2039
+ left: overflow.left - rect.width - preventedOffsets.x
2040
+ };
2041
+ }
2042
+
2043
+ function isAnySideFullyClipped(overflow) {
2044
+ return [top, right, bottom, left].some(function (side) {
2045
+ return overflow[side] >= 0;
2046
+ });
2047
+ }
2048
+
2049
+ function hide(_ref) {
2050
+ var state = _ref.state,
2051
+ name = _ref.name;
2052
+ var referenceRect = state.rects.reference;
2053
+ var popperRect = state.rects.popper;
2054
+ var preventedOffsets = state.modifiersData.preventOverflow;
2055
+ var referenceOverflow = detectOverflow(state, {
2056
+ elementContext: 'reference'
2057
+ });
2058
+ var popperAltOverflow = detectOverflow(state, {
2059
+ altBoundary: true
2060
+ });
2061
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
2062
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
2063
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
2064
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
2065
+ state.modifiersData[name] = {
2066
+ referenceClippingOffsets: referenceClippingOffsets,
2067
+ popperEscapeOffsets: popperEscapeOffsets,
2068
+ isReferenceHidden: isReferenceHidden,
2069
+ hasPopperEscaped: hasPopperEscaped
2070
+ };
2071
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
2072
+ 'data-popper-reference-hidden': isReferenceHidden,
2073
+ 'data-popper-escaped': hasPopperEscaped
2074
+ });
2075
+ } // eslint-disable-next-line import/no-unused-modules
2076
+
2077
+
2078
+ var hide$1 = {
2079
+ name: 'hide',
2080
+ enabled: true,
2081
+ phase: 'main',
2082
+ requiresIfExists: ['preventOverflow'],
2083
+ fn: hide
2084
+ };
2085
+
2086
+ function distanceAndSkiddingToXY(placement, rects, offset) {
2087
+ var basePlacement = getBasePlacement(placement);
2088
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
2089
+
2090
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
2091
+ placement: placement
2092
+ })) : offset,
2093
+ skidding = _ref[0],
2094
+ distance = _ref[1];
2095
+
2096
+ skidding = skidding || 0;
2097
+ distance = (distance || 0) * invertDistance;
2098
+ return [left, right].indexOf(basePlacement) >= 0 ? {
2099
+ x: distance,
2100
+ y: skidding
2101
+ } : {
2102
+ x: skidding,
2103
+ y: distance
2104
+ };
2105
+ }
2106
+
2107
+ function offset(_ref2) {
2108
+ var state = _ref2.state,
2109
+ options = _ref2.options,
2110
+ name = _ref2.name;
2111
+ var _options$offset = options.offset,
2112
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
2113
+ var data = placements.reduce(function (acc, placement) {
2114
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
2115
+ return acc;
2116
+ }, {});
2117
+ var _data$state$placement = data[state.placement],
2118
+ x = _data$state$placement.x,
2119
+ y = _data$state$placement.y;
2120
+
2121
+ if (state.modifiersData.popperOffsets != null) {
2122
+ state.modifiersData.popperOffsets.x += x;
2123
+ state.modifiersData.popperOffsets.y += y;
2124
+ }
2125
+
2126
+ state.modifiersData[name] = data;
2127
+ } // eslint-disable-next-line import/no-unused-modules
2128
+
2129
+
2130
+ var offset$1 = {
2131
+ name: 'offset',
2132
+ enabled: true,
2133
+ phase: 'main',
2134
+ requires: ['popperOffsets'],
2135
+ fn: offset
2136
+ };
2137
+
2138
+ function popperOffsets(_ref) {
2139
+ var state = _ref.state,
2140
+ name = _ref.name;
2141
+ // Offsets are the actual position the popper needs to have to be
2142
+ // properly positioned near its reference element
2143
+ // This is the most basic placement, and will be adjusted by
2144
+ // the modifiers in the next step
2145
+ state.modifiersData[name] = computeOffsets({
2146
+ reference: state.rects.reference,
2147
+ element: state.rects.popper,
2148
+ placement: state.placement
2149
+ });
2150
+ } // eslint-disable-next-line import/no-unused-modules
2151
+
2152
+
2153
+ var popperOffsets$1 = {
2154
+ name: 'popperOffsets',
2155
+ enabled: true,
2156
+ phase: 'read',
2157
+ fn: popperOffsets,
2158
+ data: {}
2159
+ };
2160
+
2161
+ function getAltAxis(axis) {
2162
+ return axis === 'x' ? 'y' : 'x';
2163
+ }
2164
+
2165
+ function preventOverflow(_ref) {
2166
+ var state = _ref.state,
2167
+ options = _ref.options,
2168
+ name = _ref.name;
2169
+ var _options$mainAxis = options.mainAxis,
2170
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
2171
+ _options$altAxis = options.altAxis,
2172
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
2173
+ boundary = options.boundary,
2174
+ rootBoundary = options.rootBoundary,
2175
+ altBoundary = options.altBoundary,
2176
+ padding = options.padding,
2177
+ _options$tether = options.tether,
2178
+ tether = _options$tether === void 0 ? true : _options$tether,
2179
+ _options$tetherOffset = options.tetherOffset,
2180
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
2181
+ var overflow = detectOverflow(state, {
2182
+ boundary: boundary,
2183
+ rootBoundary: rootBoundary,
2184
+ padding: padding,
2185
+ altBoundary: altBoundary
2186
+ });
2187
+ var basePlacement = getBasePlacement(state.placement);
2188
+ var variation = getVariation(state.placement);
2189
+ var isBasePlacement = !variation;
2190
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
2191
+ var altAxis = getAltAxis(mainAxis);
2192
+ var popperOffsets = state.modifiersData.popperOffsets;
2193
+ var referenceRect = state.rects.reference;
2194
+ var popperRect = state.rects.popper;
2195
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2196
+ placement: state.placement
2197
+ })) : tetherOffset;
2198
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2199
+ mainAxis: tetherOffsetValue,
2200
+ altAxis: tetherOffsetValue
2201
+ } : Object.assign({
2202
+ mainAxis: 0,
2203
+ altAxis: 0
2204
+ }, tetherOffsetValue);
2205
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2206
+ var data = {
2207
+ x: 0,
2208
+ y: 0
2209
+ };
2210
+
2211
+ if (!popperOffsets) {
2212
+ return;
2213
+ }
2214
+
2215
+ if (checkMainAxis) {
2216
+ var _offsetModifierState$;
2217
+
2218
+ var mainSide = mainAxis === 'y' ? top : left;
2219
+ var altSide = mainAxis === 'y' ? bottom : right;
2220
+ var len = mainAxis === 'y' ? 'height' : 'width';
2221
+ var offset = popperOffsets[mainAxis];
2222
+ var min$1 = offset + overflow[mainSide];
2223
+ var max$1 = offset - overflow[altSide];
2224
+ var additive = tether ? -popperRect[len] / 2 : 0;
2225
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
2226
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
2227
+ // outside the reference bounds
2228
+
2229
+ var arrowElement = state.elements.arrow;
2230
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
2231
+ width: 0,
2232
+ height: 0
2233
+ };
2234
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
2235
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
2236
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
2237
+ // to include its full size in the calculation. If the reference is small
2238
+ // and near the edge of a boundary, the popper can overflow even if the
2239
+ // reference is not overflowing as well (e.g. virtual elements with no
2240
+ // width or height)
2241
+
2242
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2243
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2244
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2245
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2246
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2247
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2248
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2249
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2250
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2251
+ popperOffsets[mainAxis] = preventedOffset;
2252
+ data[mainAxis] = preventedOffset - offset;
2253
+ }
2254
+
2255
+ if (checkAltAxis) {
2256
+ var _offsetModifierState$2;
2257
+
2258
+ var _mainSide = mainAxis === 'x' ? top : left;
2259
+
2260
+ var _altSide = mainAxis === 'x' ? bottom : right;
2261
+
2262
+ var _offset = popperOffsets[altAxis];
2263
+
2264
+ var _len = altAxis === 'y' ? 'height' : 'width';
2265
+
2266
+ var _min = _offset + overflow[_mainSide];
2267
+
2268
+ var _max = _offset - overflow[_altSide];
2269
+
2270
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2271
+
2272
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2273
+
2274
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2275
+
2276
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2277
+
2278
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2279
+
2280
+ popperOffsets[altAxis] = _preventedOffset;
2281
+ data[altAxis] = _preventedOffset - _offset;
2282
+ }
2283
+
2284
+ state.modifiersData[name] = data;
2285
+ } // eslint-disable-next-line import/no-unused-modules
2286
+
2287
+
2288
+ var preventOverflow$1 = {
2289
+ name: 'preventOverflow',
2290
+ enabled: true,
2291
+ phase: 'main',
2292
+ fn: preventOverflow,
2293
+ requiresIfExists: ['offset']
2294
+ };
2295
+
2296
+ function getHTMLElementScroll(element) {
2297
+ return {
2298
+ scrollLeft: element.scrollLeft,
2299
+ scrollTop: element.scrollTop
2300
+ };
2301
+ }
2302
+
2303
+ function getNodeScroll(node) {
2304
+ if (node === getWindow(node) || !isHTMLElement(node)) {
2305
+ return getWindowScroll(node);
2306
+ } else {
2307
+ return getHTMLElementScroll(node);
2308
+ }
2309
+ }
2310
+
2311
+ function isElementScaled(element) {
2312
+ var rect = element.getBoundingClientRect();
2313
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2314
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2315
+ return scaleX !== 1 || scaleY !== 1;
2316
+ } // Returns the composite rect of an element relative to its offsetParent.
2317
+ // Composite means it takes into account transforms as well as layout.
2318
+
2319
+
2320
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2321
+ if (isFixed === void 0) {
2322
+ isFixed = false;
2323
+ }
2324
+
2325
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2326
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2327
+ var documentElement = getDocumentElement(offsetParent);
2328
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
2329
+ var scroll = {
2330
+ scrollLeft: 0,
2331
+ scrollTop: 0
2332
+ };
2333
+ var offsets = {
2334
+ x: 0,
2335
+ y: 0
2336
+ };
2337
+
2338
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2339
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
2340
+ isScrollParent(documentElement)) {
2341
+ scroll = getNodeScroll(offsetParent);
2342
+ }
2343
+
2344
+ if (isHTMLElement(offsetParent)) {
2345
+ offsets = getBoundingClientRect(offsetParent, true);
2346
+ offsets.x += offsetParent.clientLeft;
2347
+ offsets.y += offsetParent.clientTop;
2348
+ } else if (documentElement) {
2349
+ offsets.x = getWindowScrollBarX(documentElement);
2350
+ }
2351
+ }
2352
+
2353
+ return {
2354
+ x: rect.left + scroll.scrollLeft - offsets.x,
2355
+ y: rect.top + scroll.scrollTop - offsets.y,
2356
+ width: rect.width,
2357
+ height: rect.height
2358
+ };
2359
+ }
2360
+
2361
+ function order(modifiers) {
2362
+ var map = new Map();
2363
+ var visited = new Set();
2364
+ var result = [];
2365
+ modifiers.forEach(function (modifier) {
2366
+ map.set(modifier.name, modifier);
2367
+ }); // On visiting object, check for its dependencies and visit them recursively
2368
+
2369
+ function sort(modifier) {
2370
+ visited.add(modifier.name);
2371
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2372
+ requires.forEach(function (dep) {
2373
+ if (!visited.has(dep)) {
2374
+ var depModifier = map.get(dep);
2375
+
2376
+ if (depModifier) {
2377
+ sort(depModifier);
2378
+ }
2379
+ }
2380
+ });
2381
+ result.push(modifier);
2382
+ }
2383
+
2384
+ modifiers.forEach(function (modifier) {
2385
+ if (!visited.has(modifier.name)) {
2386
+ // check for visited object
2387
+ sort(modifier);
2388
+ }
2389
+ });
2390
+ return result;
2391
+ }
2392
+
2393
+ function orderModifiers(modifiers) {
2394
+ // order based on dependencies
2395
+ var orderedModifiers = order(modifiers); // order based on phase
2396
+
2397
+ return modifierPhases.reduce(function (acc, phase) {
2398
+ return acc.concat(orderedModifiers.filter(function (modifier) {
2399
+ return modifier.phase === phase;
2400
+ }));
2401
+ }, []);
2402
+ }
2403
+
2404
+ function debounce(fn) {
2405
+ var pending;
2406
+ return function () {
2407
+ if (!pending) {
2408
+ pending = new Promise(function (resolve) {
2409
+ Promise.resolve().then(function () {
2410
+ pending = undefined;
2411
+ resolve(fn());
2412
+ });
2413
+ });
2414
+ }
2415
+
2416
+ return pending;
2417
+ };
2418
+ }
2419
+
2420
+ function mergeByName(modifiers) {
2421
+ var merged = modifiers.reduce(function (merged, current) {
2422
+ var existing = merged[current.name];
2423
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
2424
+ options: Object.assign({}, existing.options, current.options),
2425
+ data: Object.assign({}, existing.data, current.data)
2426
+ }) : current;
2427
+ return merged;
2428
+ }, {}); // IE11 does not support Object.values
2429
+
2430
+ return Object.keys(merged).map(function (key) {
2431
+ return merged[key];
2432
+ });
2433
+ }
2434
+
2435
+ var DEFAULT_OPTIONS = {
2436
+ placement: 'bottom',
2437
+ modifiers: [],
2438
+ strategy: 'absolute'
2439
+ };
2440
+
2441
+ function areValidElements() {
2442
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2443
+ args[_key] = arguments[_key];
2444
+ }
2445
+
2446
+ return !args.some(function (element) {
2447
+ return !(element && typeof element.getBoundingClientRect === 'function');
2448
+ });
2449
+ }
2450
+
2451
+ function popperGenerator(generatorOptions) {
2452
+ if (generatorOptions === void 0) {
2453
+ generatorOptions = {};
2454
+ }
2455
+
2456
+ var _generatorOptions = generatorOptions,
2457
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
2458
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
2459
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
2460
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
2461
+ return function createPopper(reference, popper, options) {
2462
+ if (options === void 0) {
2463
+ options = defaultOptions;
2464
+ }
2465
+
2466
+ var state = {
2467
+ placement: 'bottom',
2468
+ orderedModifiers: [],
2469
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2470
+ modifiersData: {},
2471
+ elements: {
2472
+ reference: reference,
2473
+ popper: popper
2474
+ },
2475
+ attributes: {},
2476
+ styles: {}
2477
+ };
2478
+ var effectCleanupFns = [];
2479
+ var isDestroyed = false;
2480
+ var instance = {
2481
+ state: state,
2482
+ setOptions: function setOptions(setOptionsAction) {
2483
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2484
+ cleanupModifierEffects();
2485
+ state.options = Object.assign({}, defaultOptions, state.options, options);
2486
+ state.scrollParents = {
2487
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
2488
+ popper: listScrollParents(popper)
2489
+ }; // Orders the modifiers based on their dependencies and `phase`
2490
+ // properties
2491
+
2492
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
2493
+
2494
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
2495
+ return m.enabled;
2496
+ });
2497
+ runModifierEffects();
2498
+ return instance.update();
2499
+ },
2500
+ // Sync update – it will always be executed, even if not necessary. This
2501
+ // is useful for low frequency updates where sync behavior simplifies the
2502
+ // logic.
2503
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
2504
+ // prefer the async Popper#update method
2505
+ forceUpdate: function forceUpdate() {
2506
+ if (isDestroyed) {
2507
+ return;
2508
+ }
2509
+
2510
+ var _state$elements = state.elements,
2511
+ reference = _state$elements.reference,
2512
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
2513
+ // anymore
2514
+
2515
+ if (!areValidElements(reference, popper)) {
2516
+ return;
2517
+ } // Store the reference and popper rects to be read by modifiers
2518
+
2519
+
2520
+ state.rects = {
2521
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
2522
+ popper: getLayoutRect(popper)
2523
+ }; // Modifiers have the ability to reset the current update cycle. The
2524
+ // most common use case for this is the `flip` modifier changing the
2525
+ // placement, which then needs to re-run all the modifiers, because the
2526
+ // logic was previously ran for the previous placement and is therefore
2527
+ // stale/incorrect
2528
+
2529
+ state.reset = false;
2530
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
2531
+ // is filled with the initial data specified by the modifier. This means
2532
+ // it doesn't persist and is fresh on each update.
2533
+ // To ensure persistent data, use `${name}#persistent`
2534
+
2535
+ state.orderedModifiers.forEach(function (modifier) {
2536
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2537
+ });
2538
+
2539
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
2540
+ if (state.reset === true) {
2541
+ state.reset = false;
2542
+ index = -1;
2543
+ continue;
2544
+ }
2545
+
2546
+ var _state$orderedModifie = state.orderedModifiers[index],
2547
+ fn = _state$orderedModifie.fn,
2548
+ _state$orderedModifie2 = _state$orderedModifie.options,
2549
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
2550
+ name = _state$orderedModifie.name;
2551
+
2552
+ if (typeof fn === 'function') {
2553
+ state = fn({
2554
+ state: state,
2555
+ options: _options,
2556
+ name: name,
2557
+ instance: instance
2558
+ }) || state;
2559
+ }
2560
+ }
2561
+ },
2562
+ // Async and optimistically optimized update – it will not be executed if
2563
+ // not necessary (debounced to run at most once-per-tick)
2564
+ update: debounce(function () {
2565
+ return new Promise(function (resolve) {
2566
+ instance.forceUpdate();
2567
+ resolve(state);
2568
+ });
2569
+ }),
2570
+ destroy: function destroy() {
2571
+ cleanupModifierEffects();
2572
+ isDestroyed = true;
2573
+ }
2574
+ };
2575
+
2576
+ if (!areValidElements(reference, popper)) {
2577
+ return instance;
2578
+ }
2579
+
2580
+ instance.setOptions(options).then(function (state) {
2581
+ if (!isDestroyed && options.onFirstUpdate) {
2582
+ options.onFirstUpdate(state);
2583
+ }
2584
+ }); // Modifiers have the ability to execute arbitrary code before the first
2585
+ // update cycle runs. They will be executed in the same order as the update
2586
+ // cycle. This is useful when a modifier adds some persistent data that
2587
+ // other modifiers need to use, but the modifier is run after the dependent
2588
+ // one.
2589
+
2590
+ function runModifierEffects() {
2591
+ state.orderedModifiers.forEach(function (_ref) {
2592
+ var name = _ref.name,
2593
+ _ref$options = _ref.options,
2594
+ options = _ref$options === void 0 ? {} : _ref$options,
2595
+ effect = _ref.effect;
2596
+
2597
+ if (typeof effect === 'function') {
2598
+ var cleanupFn = effect({
2599
+ state: state,
2600
+ name: name,
2601
+ instance: instance,
2602
+ options: options
2603
+ });
2604
+
2605
+ var noopFn = function noopFn() {};
2606
+
2607
+ effectCleanupFns.push(cleanupFn || noopFn);
2608
+ }
2609
+ });
2610
+ }
2611
+
2612
+ function cleanupModifierEffects() {
2613
+ effectCleanupFns.forEach(function (fn) {
2614
+ return fn();
2615
+ });
2616
+ effectCleanupFns = [];
2617
+ }
2618
+
2619
+ return instance;
2620
+ };
2621
+ }
2622
+
2623
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
2624
+ var createPopper = /*#__PURE__*/popperGenerator({
2625
+ defaultModifiers: defaultModifiers
2626
+ }); // eslint-disable-next-line import/no-unused-modules
2627
+
2628
+ const tabworthyDatesModalCss = () => `:host::part(body){position:absolute;top:0;left:0;width:-moz-fit-content;width:fit-content;z-index:1200}:host::part(backdrop){}:host::part(content){}`;
840
2629
 
841
2630
  const InclusiveDatesModal = class {
842
2631
  constructor(hostRef) {
@@ -844,14 +2633,132 @@ const InclusiveDatesModal = class {
844
2633
  this.opened = index.createEvent(this, "opened", 7);
845
2634
  this.closed = index.createEvent(this, "closed", 7);
846
2635
  this.inline = false;
2636
+ /** Preferred placement of the dropdown (Popper.js placement) */
2637
+ this.placement = "bottom-start";
2638
+ /** Offset from the trigger element [skidding, distance] */
2639
+ this.offset = [0, 8];
847
2640
  this.closing = false;
848
2641
  this.showing = this.inline || false;
2642
+ this.positioned = false;
2643
+ this.originalParent = null;
2644
+ this.originalNextSibling = null;
2645
+ this.isMovingPortal = false;
2646
+ this.popperInstance = null;
849
2647
  this.onKeyDown = (event) => {
850
2648
  if (event.code === "Escape") {
851
2649
  this.close();
852
2650
  }
853
2651
  };
854
2652
  }
2653
+ watchShowing(newValue) {
2654
+ if (newValue) {
2655
+ // Reset positioned state - portal setup happens in render ref callback
2656
+ this.positioned = false;
2657
+ }
2658
+ else {
2659
+ this.destroyPopperInstance();
2660
+ this.cleanupPortal();
2661
+ this.positioned = false;
2662
+ }
2663
+ }
2664
+ getAppendToElement() {
2665
+ if (!this.appendTo)
2666
+ return null;
2667
+ if (this.appendTo === "body") {
2668
+ return document.body;
2669
+ }
2670
+ if (typeof this.appendTo === "string") {
2671
+ return document.querySelector(this.appendTo);
2672
+ }
2673
+ return this.appendTo;
2674
+ }
2675
+ setupPortal() {
2676
+ const appendToEl = this.getAppendToElement();
2677
+ if (!appendToEl)
2678
+ return;
2679
+ // Store original position so we can restore later
2680
+ this.originalParent = this.hostElement.parentElement;
2681
+ this.originalNextSibling = this.hostElement.nextSibling;
2682
+ // Guard against triggering disconnectedCallback during move
2683
+ this.isMovingPortal = true;
2684
+ appendToEl.appendChild(this.hostElement);
2685
+ this.isMovingPortal = false;
2686
+ }
2687
+ cleanupPortal() {
2688
+ // Guard against recursion - moving element triggers disconnectedCallback
2689
+ if (this.isMovingPortal)
2690
+ return;
2691
+ // Move host back to original position
2692
+ if (this.originalParent) {
2693
+ this.isMovingPortal = true;
2694
+ if (this.originalNextSibling) {
2695
+ this.originalParent.insertBefore(this.hostElement, this.originalNextSibling);
2696
+ }
2697
+ else {
2698
+ this.originalParent.appendChild(this.hostElement);
2699
+ }
2700
+ this.originalParent = null;
2701
+ this.originalNextSibling = null;
2702
+ this.isMovingPortal = false;
2703
+ }
2704
+ }
2705
+ createPopperInstance() {
2706
+ if (!this.triggerElement || !this.bodyRef)
2707
+ return;
2708
+ // Use fixed strategy when portaling to escape scroll containers
2709
+ const useFixed = !!this.appendTo;
2710
+ // When portaled, use viewport boundary; otherwise use clipping parents
2711
+ const boundary = useFixed ? "viewport" : "clippingParents";
2712
+ this.popperInstance = createPopper(this.triggerElement, this.bodyRef, {
2713
+ placement: this.placement,
2714
+ strategy: useFixed ? "fixed" : "absolute",
2715
+ modifiers: [
2716
+ {
2717
+ name: "offset",
2718
+ options: {
2719
+ offset: this.offset
2720
+ }
2721
+ },
2722
+ {
2723
+ name: "flip",
2724
+ options: {
2725
+ fallbackPlacements: ["top-start", "top-end", "bottom-end"],
2726
+ boundary
2727
+ }
2728
+ },
2729
+ {
2730
+ name: "preventOverflow",
2731
+ options: {
2732
+ boundary,
2733
+ altAxis: true,
2734
+ padding: 8
2735
+ }
2736
+ },
2737
+ {
2738
+ name: "computeStyles",
2739
+ options: {
2740
+ // Use GPU acceleration for smooth animations
2741
+ gpuAcceleration: true
2742
+ }
2743
+ },
2744
+ {
2745
+ // Custom modifier to ensure initial position is applied immediately
2746
+ name: "applyStyles",
2747
+ enabled: true
2748
+ }
2749
+ ]
2750
+ });
2751
+ // Force immediate position update
2752
+ this.popperInstance.forceUpdate();
2753
+ // Mark as positioned to show the element
2754
+ this.positioned = true;
2755
+ }
2756
+ destroyPopperInstance() {
2757
+ if (this.popperInstance) {
2758
+ this.popperInstance.destroy();
2759
+ this.popperInstance = null;
2760
+ }
2761
+ }
855
2762
  /**
856
2763
  * Open the dialog.
857
2764
  */
@@ -866,28 +2773,73 @@ const InclusiveDatesModal = class {
866
2773
  * Close the dialog.
867
2774
  */
868
2775
  async close() {
2776
+ var _a;
869
2777
  if (this.inline)
870
2778
  return;
871
2779
  this.showing = false;
872
2780
  this.closed.emit(undefined);
873
- this.undo();
2781
+ (_a = this.undo) === null || _a === void 0 ? void 0 : _a.call(this);
874
2782
  if (this.triggerElement)
875
2783
  this.triggerElement.focus();
876
2784
  }
2785
+ disconnectedCallback() {
2786
+ // Skip cleanup if we're in the middle of portal operations
2787
+ if (this.isMovingPortal)
2788
+ return;
2789
+ this.destroyPopperInstance();
2790
+ this.cleanupPortal();
2791
+ }
877
2792
  async getState() {
878
2793
  return this.showing;
879
2794
  }
880
2795
  async setTriggerElement(element) {
881
2796
  this.triggerElement = element;
882
2797
  }
2798
+ /** Force update the popper position */
2799
+ async updatePosition() {
2800
+ var _a;
2801
+ await ((_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.update());
2802
+ }
883
2803
  handleClick(event) {
884
- if (this.showing && !this.el.contains(event.target)) {
885
- this.close();
2804
+ var _a;
2805
+ if (this.showing) {
2806
+ const target = event.target;
2807
+ // Check if click is inside the host element, trigger element, or original parent (when portaled)
2808
+ const clickedInside = this.hostElement.contains(target) ||
2809
+ ((_a = this.triggerElement) === null || _a === void 0 ? void 0 : _a.contains(target)) ||
2810
+ // When portaled, also check the original parent to avoid closing on container clicks
2811
+ (this.originalParent && this.originalParent.contains(target));
2812
+ if (!clickedInside) {
2813
+ this.close();
2814
+ }
886
2815
  }
887
2816
  }
888
2817
  render() {
889
- return (index.h(index.Host, { key: 'e5e440df97f5b2f51f742892ca591aff3a3e51a9', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (index.h("div", { key: 'f3b5f92b0f3b8eb54f665a14fcaa1616d59b182b', part: "body", onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, index.h("focus-trap", { key: 'f94c02a8db391d671adc08ac1742dc6fabca72d3' }, index.h("div", { key: '888259505b6a2416674523d6a6924272b676daad', part: "content" }, index.h("slot", { key: 'e4e141ecae238f68fdde53baca66f478ebb93f88' }))))), this.inline && (index.h("div", { key: 'f2e7fb2614274d5dc7d03f10a0ee760363438435', part: "content" }, index.h("slot", { key: 'f845ef9c46b146ac916c90bb2fcec1f357aee5ee' })))));
2818
+ return (index.h(index.Host, { key: '35e8ed14b0108e9cb75782516d070dfb8474b0b2', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (index.h("div", { key: 'fdb64ed8717e2a1620ef2d4ffb21a44d1de03a46', part: "body", ref: (r) => {
2819
+ if (r) {
2820
+ this.bodyRef = r;
2821
+ // Setup portal and create popper when ref is set
2822
+ if (this.showing &&
2823
+ this.triggerElement &&
2824
+ !this.popperInstance) {
2825
+ // Setup portal first (move element to body), then create popper
2826
+ this.setupPortal();
2827
+ // Use double RAF to ensure DOM is fully settled after portal move
2828
+ requestAnimationFrame(() => {
2829
+ requestAnimationFrame(() => {
2830
+ this.createPopperInstance();
2831
+ });
2832
+ });
2833
+ }
2834
+ }
2835
+ }, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, index.h("focus-trap", { key: 'af4734b1a18dd62a600ca49313b1ba07f2d19039' }, index.h("div", { key: 'fb41d5ce07b5aac179e4bed63c18a8d254503a50', part: "content" }, index.h("slot", { key: 'fc480cf1a29a42b1a19737a72d410c139dc32f07' }))))), this.inline && (index.h("div", { key: '7aef10d50f790a1e72e05b26dc108c40500fa7c3', part: "content" }, index.h("slot", { key: '06395cd19052d1b81ab448c0a9a618da876fa86d' })))));
890
2836
  }
2837
+ get hostElement() { return index.getElement(this); }
2838
+ static get watchers() { return {
2839
+ "showing": [{
2840
+ "watchShowing": 0
2841
+ }]
2842
+ }; }
891
2843
  };
892
2844
  InclusiveDatesModal.style = tabworthyDatesModalCss();
893
2845