@esri/solutions-components 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. package/dist/cjs/deduct-calculator.cjs.entry.js +1 -1
  2. package/dist/cjs/pci-calculator.cjs.entry.js +1 -1
  3. package/dist/cjs/{pciUtils-6a806ba4.js → pciUtils-423cfc68.js} +25 -7
  4. package/dist/collection/demos/deduct-calculator.html +2 -5
  5. package/dist/collection/demos/new-public-notification.html +6 -4
  6. package/dist/collection/utils/pciUtils.js +25 -7
  7. package/dist/collection/utils/pciUtils.ts +30 -7
  8. package/dist/components/ExpandToggle.js +110 -0
  9. package/dist/components/Heading.js +22 -0
  10. package/dist/components/_commonjsHelpers.js +22 -0
  11. package/dist/components/action-bar.js +276 -0
  12. package/dist/components/action-group.js +149 -0
  13. package/dist/components/action-menu.js +356 -0
  14. package/dist/components/action.js +214 -0
  15. package/dist/components/add-record-modal.d.ts +11 -0
  16. package/dist/components/add-record-modal.js +171 -0
  17. package/dist/components/array.js +15 -0
  18. package/dist/components/block.js +272 -0
  19. package/dist/components/buffer-tools.d.ts +11 -0
  20. package/dist/components/buffer-tools.js +11 -0
  21. package/dist/components/buffer-tools2.js +262 -0
  22. package/dist/components/button.js +263 -0
  23. package/dist/components/calcite-accordion-item.js +244 -0
  24. package/dist/components/calcite-accordion.js +180 -0
  25. package/dist/components/calcite-action-bar.js +11 -0
  26. package/dist/components/calcite-action-group.js +11 -0
  27. package/dist/components/calcite-action-menu.js +11 -0
  28. package/dist/components/calcite-action-pad.js +197 -0
  29. package/dist/components/calcite-action.js +11 -0
  30. package/dist/components/calcite-alert.js +297 -0
  31. package/dist/components/calcite-avatar.js +182 -0
  32. package/dist/components/calcite-block-section.js +155 -0
  33. package/dist/components/calcite-block.js +11 -0
  34. package/dist/components/calcite-button.js +11 -0
  35. package/dist/components/calcite-card.js +187 -0
  36. package/dist/components/calcite-checkbox.js +11 -0
  37. package/dist/components/calcite-chip.js +11 -0
  38. package/dist/components/calcite-color-picker-hex-input.js +11 -0
  39. package/dist/components/calcite-color-picker-swatch.js +11 -0
  40. package/dist/components/calcite-color-picker.js +1036 -0
  41. package/dist/components/calcite-combobox-item-group.js +75 -0
  42. package/dist/components/calcite-combobox-item.js +11 -0
  43. package/dist/components/calcite-combobox.js +11 -0
  44. package/dist/components/calcite-date-picker-day.js +11 -0
  45. package/dist/components/calcite-date-picker-month-header.js +11 -0
  46. package/dist/components/calcite-date-picker-month.js +11 -0
  47. package/dist/components/calcite-date-picker.js +11 -0
  48. package/dist/components/calcite-dropdown-group.js +11 -0
  49. package/dist/components/calcite-dropdown-item.js +11 -0
  50. package/dist/components/calcite-dropdown.js +11 -0
  51. package/dist/components/calcite-fab.js +144 -0
  52. package/dist/components/calcite-filter.js +195 -0
  53. package/dist/components/calcite-flow-item.js +243 -0
  54. package/dist/components/calcite-flow.js +147 -0
  55. package/dist/components/calcite-graph.js +11 -0
  56. package/dist/components/calcite-handle.js +11 -0
  57. package/dist/components/calcite-icon.js +11 -0
  58. package/dist/components/calcite-inline-editable.js +294 -0
  59. package/dist/components/calcite-input-date-picker.js +713 -0
  60. package/dist/components/calcite-input-message.js +11 -0
  61. package/dist/components/calcite-input-number.js +637 -0
  62. package/dist/components/calcite-input-text.js +400 -0
  63. package/dist/components/calcite-input-time-picker.js +434 -0
  64. package/dist/components/calcite-input.js +11 -0
  65. package/dist/components/calcite-label.js +11 -0
  66. package/dist/components/calcite-link.js +11 -0
  67. package/dist/components/calcite-list-item-group.js +65 -0
  68. package/dist/components/calcite-list-item.js +11 -0
  69. package/dist/components/calcite-list.js +11 -0
  70. package/dist/components/calcite-loader.js +11 -0
  71. package/dist/components/calcite-modal.js +11 -0
  72. package/dist/components/calcite-notice.js +11 -0
  73. package/dist/components/calcite-option-group.js +64 -0
  74. package/dist/components/calcite-option.js +11 -0
  75. package/dist/components/calcite-pagination.js +258 -0
  76. package/dist/components/calcite-panel.js +11 -0
  77. package/dist/components/calcite-pick-list-group.js +74 -0
  78. package/dist/components/calcite-pick-list-item.js +11 -0
  79. package/dist/components/calcite-pick-list.js +11 -0
  80. package/dist/components/calcite-popover-manager.js +94 -0
  81. package/dist/components/calcite-popover.js +11 -0
  82. package/dist/components/calcite-progress.js +11 -0
  83. package/dist/components/calcite-radio-button-group.js +132 -0
  84. package/dist/components/calcite-radio-button.js +310 -0
  85. package/dist/components/calcite-radio-group-item.js +11 -0
  86. package/dist/components/calcite-radio-group.js +11 -0
  87. package/dist/components/calcite-rating.js +201 -0
  88. package/dist/components/calcite-scrim.js +11 -0
  89. package/dist/components/calcite-select.js +11 -0
  90. package/dist/components/calcite-shell-center-row.js +100 -0
  91. package/dist/components/calcite-shell-panel.js +11 -0
  92. package/dist/components/calcite-shell.js +11 -0
  93. package/dist/components/calcite-slider.js +11 -0
  94. package/dist/components/calcite-sortable-list.js +202 -0
  95. package/dist/components/calcite-split-button.js +11 -0
  96. package/dist/components/calcite-stepper-item.js +271 -0
  97. package/dist/components/calcite-stepper.js +256 -0
  98. package/dist/components/calcite-switch.js +11 -0
  99. package/dist/components/calcite-tab-nav.js +11 -0
  100. package/dist/components/calcite-tab-title.js +11 -0
  101. package/dist/components/calcite-tab.js +11 -0
  102. package/dist/components/calcite-tabs.js +11 -0
  103. package/dist/components/calcite-tile-select-group.js +65 -0
  104. package/dist/components/calcite-tile-select.js +266 -0
  105. package/dist/components/calcite-tile.js +11 -0
  106. package/dist/components/calcite-time-picker.js +11 -0
  107. package/dist/components/calcite-tip-group.js +41 -0
  108. package/dist/components/calcite-tip-manager.js +223 -0
  109. package/dist/components/calcite-tip.js +162 -0
  110. package/dist/components/calcite-tooltip-manager.js +57 -0
  111. package/dist/components/calcite-tooltip.js +11 -0
  112. package/dist/components/calcite-tree-item.js +11 -0
  113. package/dist/components/calcite-tree.js +11 -0
  114. package/dist/components/calcite-value-list-item.js +11 -0
  115. package/dist/components/calcite-value-list.js +11 -0
  116. package/dist/components/card-manager.d.ts +11 -0
  117. package/dist/components/card-manager.js +143 -0
  118. package/dist/components/check-list.d.ts +11 -0
  119. package/dist/components/check-list.js +11 -0
  120. package/dist/components/check-list2.js +131 -0
  121. package/dist/components/checkbox.js +165 -0
  122. package/dist/components/chip.js +170 -0
  123. package/dist/components/color-picker-hex-input.js +363 -0
  124. package/dist/components/color-picker-swatch.js +2034 -0
  125. package/dist/components/combobox-item.js +182 -0
  126. package/dist/components/combobox.js +912 -0
  127. package/dist/components/comment-card.d.ts +11 -0
  128. package/dist/components/comment-card.js +90 -0
  129. package/dist/components/conditionalSlot.js +50 -0
  130. package/dist/components/config-buffer-tools.d.ts +11 -0
  131. package/dist/components/config-buffer-tools.js +187 -0
  132. package/dist/components/config-draw-tools.d.ts +11 -0
  133. package/dist/components/config-draw-tools.js +121 -0
  134. package/dist/components/config-layer-picker.d.ts +11 -0
  135. package/dist/components/config-layer-picker.js +163 -0
  136. package/dist/components/config-pdf-download.d.ts +11 -0
  137. package/dist/components/config-pdf-download.js +154 -0
  138. package/dist/components/crowdsource-manager.d.ts +11 -0
  139. package/dist/components/crowdsource-manager.js +90 -0
  140. package/dist/components/crowdsource-reporter.d.ts +11 -0
  141. package/dist/components/crowdsource-reporter.js +90 -0
  142. package/dist/components/csvUtils.js +74 -0
  143. package/dist/components/date-picker-day.js +111 -0
  144. package/dist/components/date-picker-month-header.js +224 -0
  145. package/dist/components/date-picker-month.js +344 -0
  146. package/dist/components/date-picker.js +575 -0
  147. package/dist/components/date.js +180 -0
  148. package/dist/components/debounce.js +487 -0
  149. package/dist/components/deduct-calculator.d.ts +11 -0
  150. package/dist/components/deduct-calculator.js +11 -0
  151. package/dist/components/deduct-calculator2.js +1002 -0
  152. package/dist/components/dom.js +231 -0
  153. package/dist/components/dropdown-group.js +96 -0
  154. package/dist/components/dropdown-item.js +232 -0
  155. package/dist/components/dropdown.js +505 -0
  156. package/dist/components/edit-record-modal.d.ts +11 -0
  157. package/dist/components/edit-record-modal.js +11 -0
  158. package/dist/components/edit-record-modal2.js +161 -0
  159. package/dist/components/filter.js +763 -0
  160. package/dist/components/floating-ui.js +1768 -0
  161. package/dist/components/form.js +228 -0
  162. package/dist/components/graph.js +254 -0
  163. package/dist/components/guid.js +24 -0
  164. package/dist/components/handle.js +119 -0
  165. package/dist/components/icon.js +202 -0
  166. package/dist/components/index.d.ts +61 -0
  167. package/dist/components/index.js +196 -0
  168. package/dist/components/index2.js +199 -0
  169. package/dist/components/info-card.d.ts +11 -0
  170. package/dist/components/info-card.js +11 -0
  171. package/dist/components/info-card2.js +97 -0
  172. package/dist/components/input-message.js +101 -0
  173. package/dist/components/input.js +740 -0
  174. package/dist/components/interactive.js +51 -0
  175. package/dist/components/interfaces.js +19 -0
  176. package/dist/components/interfaces2.js +21 -0
  177. package/dist/components/interfaces3.js +80 -0
  178. package/dist/components/json-editor.d.ts +11 -0
  179. package/dist/components/json-editor.js +11 -0
  180. package/dist/components/json-editor2.js +441 -0
  181. package/dist/components/key.js +16 -0
  182. package/dist/components/label.js +106 -0
  183. package/dist/components/label2.js +131 -0
  184. package/dist/components/labelFormats.js +210 -0
  185. package/dist/components/layer-table.d.ts +11 -0
  186. package/dist/components/layer-table.js +453 -0
  187. package/dist/components/link.js +123 -0
  188. package/dist/components/list-item.d.ts +11 -0
  189. package/dist/components/list-item.js +90 -0
  190. package/dist/components/list-item2.js +149 -0
  191. package/dist/components/list.js +83 -0
  192. package/dist/components/loadModules.js +28 -0
  193. package/dist/components/loader.js +116 -0
  194. package/dist/components/locale.js +412 -0
  195. package/dist/components/locale2.js +413 -0
  196. package/dist/components/map-card.d.ts +11 -0
  197. package/dist/components/map-card.js +354 -0
  198. package/dist/components/map-draw-tools.d.ts +11 -0
  199. package/dist/components/map-draw-tools.js +11 -0
  200. package/dist/components/map-draw-tools2.js +228 -0
  201. package/dist/components/map-layer-picker.d.ts +11 -0
  202. package/dist/components/map-layer-picker.js +11 -0
  203. package/dist/components/map-layer-picker2.js +188 -0
  204. package/dist/components/map-search.d.ts +11 -0
  205. package/dist/components/map-search.js +155 -0
  206. package/dist/components/map-select-tools.d.ts +11 -0
  207. package/dist/components/map-select-tools.js +11 -0
  208. package/dist/components/map-select-tools2.js +588 -0
  209. package/dist/components/mapViewUtils.js +129 -0
  210. package/dist/components/math.js +24 -0
  211. package/dist/components/media-card.d.ts +11 -0
  212. package/dist/components/media-card.js +11 -0
  213. package/dist/components/media-card2.js +177 -0
  214. package/dist/components/modal.js +495 -0
  215. package/dist/components/nonChromiumPlatformUtils.js +503 -0
  216. package/dist/components/notice.js +192 -0
  217. package/dist/components/observers.js +56 -0
  218. package/dist/components/openCloseComponent.js +56 -0
  219. package/dist/components/option.js +109 -0
  220. package/dist/components/panel.js +459 -0
  221. package/dist/components/pci-calculator.d.ts +11 -0
  222. package/dist/components/pci-calculator.js +193 -0
  223. package/dist/components/pdf-download.d.ts +11 -0
  224. package/dist/components/pdf-download.js +11 -0
  225. package/dist/components/pdf-download2.js +189 -0
  226. package/dist/components/pick-list-item.js +255 -0
  227. package/dist/components/pick-list.js +170 -0
  228. package/dist/components/popover.js +500 -0
  229. package/dist/components/progress.js +60 -0
  230. package/dist/components/public-notification.d.ts +11 -0
  231. package/dist/components/public-notification.js +825 -0
  232. package/dist/components/publicNotificationStore.js +38 -0
  233. package/dist/components/queryUtils.js +187 -0
  234. package/dist/components/radio-group-item.js +101 -0
  235. package/dist/components/radio-group.js +235 -0
  236. package/dist/components/refine-selection-tools.d.ts +11 -0
  237. package/dist/components/refine-selection-tools.js +11 -0
  238. package/dist/components/refine-selection-tools2.js +492 -0
  239. package/dist/components/refine-selection.d.ts +11 -0
  240. package/dist/components/refine-selection.js +11 -0
  241. package/dist/components/refine-selection2.js +376 -0
  242. package/dist/components/resources.js +24 -0
  243. package/dist/components/resources2.js +21 -0
  244. package/dist/components/resources3.js +38 -0
  245. package/dist/components/scrim.js +83 -0
  246. package/dist/components/select.js +259 -0
  247. package/dist/components/shared-list-render.js +319 -0
  248. package/dist/components/shell-panel.js +281 -0
  249. package/dist/components/shell.js +121 -0
  250. package/dist/components/slider.js +896 -0
  251. package/dist/components/solution-configuration.d.ts +11 -0
  252. package/dist/components/solution-configuration.js +2233 -0
  253. package/dist/components/solution-contents.d.ts +11 -0
  254. package/dist/components/solution-contents.js +11 -0
  255. package/dist/components/solution-contents2.js +128 -0
  256. package/dist/components/solution-item-details.d.ts +11 -0
  257. package/dist/components/solution-item-details.js +11 -0
  258. package/dist/components/solution-item-details2.js +234 -0
  259. package/dist/components/solution-item-icon.d.ts +11 -0
  260. package/dist/components/solution-item-icon.js +11 -0
  261. package/dist/components/solution-item-icon2.js +342 -0
  262. package/dist/components/solution-item-sharing.d.ts +11 -0
  263. package/dist/components/solution-item-sharing.js +11 -0
  264. package/dist/components/solution-item-sharing2.js +167 -0
  265. package/dist/components/solution-item.d.ts +11 -0
  266. package/dist/components/solution-item.js +11 -0
  267. package/dist/components/solution-item2.js +315 -0
  268. package/dist/components/solution-organization-variables.d.ts +11 -0
  269. package/dist/components/solution-organization-variables.js +11 -0
  270. package/dist/components/solution-organization-variables2.js +132 -0
  271. package/dist/components/solution-resource-item.d.ts +11 -0
  272. package/dist/components/solution-resource-item.js +11 -0
  273. package/dist/components/solution-resource-item2.js +356 -0
  274. package/dist/components/solution-spatial-ref.d.ts +11 -0
  275. package/dist/components/solution-spatial-ref.js +11 -0
  276. package/dist/components/solution-spatial-ref2.js +21446 -0
  277. package/dist/components/solution-store.js +4092 -0
  278. package/dist/components/solution-template-data.d.ts +11 -0
  279. package/dist/components/solution-template-data.js +11 -0
  280. package/dist/components/solution-template-data2.js +233 -0
  281. package/dist/components/solution-variables.d.ts +11 -0
  282. package/dist/components/solution-variables.js +11 -0
  283. package/dist/components/solution-variables2.js +150 -0
  284. package/dist/components/sortable.esm.js +3026 -0
  285. package/dist/components/split-button.js +165 -0
  286. package/dist/components/store-manager.d.ts +11 -0
  287. package/dist/components/store-manager.js +83 -0
  288. package/dist/components/switch.js +139 -0
  289. package/dist/components/tab-nav.js +241 -0
  290. package/dist/components/tab-title.js +276 -0
  291. package/dist/components/tab.js +154 -0
  292. package/dist/components/tabs.js +188 -0
  293. package/dist/components/tile.js +129 -0
  294. package/dist/components/time-picker.js +943 -0
  295. package/dist/components/tooltip.js +399 -0
  296. package/dist/components/tree-item.js +294 -0
  297. package/dist/components/tree.js +327 -0
  298. package/dist/components/utils.js +119 -0
  299. package/dist/components/utils2.js +51 -0
  300. package/dist/components/value-list-item.js +204 -0
  301. package/dist/components/value-list.js +333 -0
  302. package/dist/esm/deduct-calculator.entry.js +1 -1
  303. package/dist/esm/pci-calculator.entry.js +1 -1
  304. package/dist/esm/{pciUtils-e3007a1c.js → pciUtils-ecda46e5.js} +25 -7
  305. package/dist/solutions-components/demos/deduct-calculator.html +2 -5
  306. package/dist/solutions-components/demos/new-public-notification.html +6 -4
  307. package/dist/solutions-components/{p-ff80ffbb.entry.js → p-0512635b.entry.js} +1 -1
  308. package/dist/solutions-components/{p-5ec407c2.entry.js → p-0c088725.entry.js} +1 -1
  309. package/dist/solutions-components/p-cc815aca.js +21 -0
  310. package/dist/solutions-components/solutions-components.esm.js +1 -1
  311. package/dist/solutions-components/utils/pciUtils.ts +30 -7
  312. package/dist/types/utils/pciUtils.d.ts +2 -1
  313. package/package.json +4 -3
  314. package/dist/solutions-components/p-647bbd18.js +0 -21
@@ -0,0 +1,1768 @@
1
+ /*!
2
+ * Copyright 2022 Esri
3
+ * Licensed under the Apache License, Version 2.0
4
+ * http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { c as getElementDir, h as closestElementCrossShadowBoundary } from './dom.js';
7
+ import { Build } from '@stencil/core/internal/client';
8
+ import { d as debounce } from './debounce.js';
9
+
10
+ function getAlignment(placement) {
11
+ return placement.split('-')[1];
12
+ }
13
+
14
+ function getLengthFromAxis(axis) {
15
+ return axis === 'y' ? 'height' : 'width';
16
+ }
17
+
18
+ function getSide(placement) {
19
+ return placement.split('-')[0];
20
+ }
21
+
22
+ function getMainAxisFromPlacement(placement) {
23
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
24
+ }
25
+
26
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
27
+ let {
28
+ reference,
29
+ floating
30
+ } = _ref;
31
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
32
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
33
+ const mainAxis = getMainAxisFromPlacement(placement);
34
+ const length = getLengthFromAxis(mainAxis);
35
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
36
+ const side = getSide(placement);
37
+ const isVertical = mainAxis === 'x';
38
+ let coords;
39
+ switch (side) {
40
+ case 'top':
41
+ coords = {
42
+ x: commonX,
43
+ y: reference.y - floating.height
44
+ };
45
+ break;
46
+ case 'bottom':
47
+ coords = {
48
+ x: commonX,
49
+ y: reference.y + reference.height
50
+ };
51
+ break;
52
+ case 'right':
53
+ coords = {
54
+ x: reference.x + reference.width,
55
+ y: commonY
56
+ };
57
+ break;
58
+ case 'left':
59
+ coords = {
60
+ x: reference.x - floating.width,
61
+ y: commonY
62
+ };
63
+ break;
64
+ default:
65
+ coords = {
66
+ x: reference.x,
67
+ y: reference.y
68
+ };
69
+ }
70
+ switch (getAlignment(placement)) {
71
+ case 'start':
72
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
73
+ break;
74
+ case 'end':
75
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
76
+ break;
77
+ }
78
+ return coords;
79
+ }
80
+
81
+ /**
82
+ * Computes the `x` and `y` coordinates that will place the floating element
83
+ * next to a reference element when it is given a certain positioning strategy.
84
+ *
85
+ * This export does not have any `platform` interface logic. You will need to
86
+ * write one for the platform you are using Floating UI with.
87
+ */
88
+ const computePosition$1 = async (reference, floating, config) => {
89
+ const {
90
+ placement = 'bottom',
91
+ strategy = 'absolute',
92
+ middleware = [],
93
+ platform
94
+ } = config;
95
+ const validMiddleware = middleware.filter(Boolean);
96
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
97
+ let rects = await platform.getElementRects({
98
+ reference,
99
+ floating,
100
+ strategy
101
+ });
102
+ let {
103
+ x,
104
+ y
105
+ } = computeCoordsFromPlacement(rects, placement, rtl);
106
+ let statefulPlacement = placement;
107
+ let middlewareData = {};
108
+ let resetCount = 0;
109
+ for (let i = 0; i < validMiddleware.length; i++) {
110
+ const {
111
+ name,
112
+ fn
113
+ } = validMiddleware[i];
114
+ const {
115
+ x: nextX,
116
+ y: nextY,
117
+ data,
118
+ reset
119
+ } = await fn({
120
+ x,
121
+ y,
122
+ initialPlacement: placement,
123
+ placement: statefulPlacement,
124
+ strategy,
125
+ middlewareData,
126
+ rects,
127
+ platform,
128
+ elements: {
129
+ reference,
130
+ floating
131
+ }
132
+ });
133
+ x = nextX != null ? nextX : x;
134
+ y = nextY != null ? nextY : y;
135
+ middlewareData = {
136
+ ...middlewareData,
137
+ [name]: {
138
+ ...middlewareData[name],
139
+ ...data
140
+ }
141
+ };
142
+ if (reset && resetCount <= 50) {
143
+ resetCount++;
144
+ if (typeof reset === 'object') {
145
+ if (reset.placement) {
146
+ statefulPlacement = reset.placement;
147
+ }
148
+ if (reset.rects) {
149
+ rects = reset.rects === true ? await platform.getElementRects({
150
+ reference,
151
+ floating,
152
+ strategy
153
+ }) : reset.rects;
154
+ }
155
+ ({
156
+ x,
157
+ y
158
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
159
+ }
160
+ i = -1;
161
+ continue;
162
+ }
163
+ }
164
+ return {
165
+ x,
166
+ y,
167
+ placement: statefulPlacement,
168
+ strategy,
169
+ middlewareData
170
+ };
171
+ };
172
+
173
+ function expandPaddingObject(padding) {
174
+ return {
175
+ top: 0,
176
+ right: 0,
177
+ bottom: 0,
178
+ left: 0,
179
+ ...padding
180
+ };
181
+ }
182
+
183
+ function getSideObjectFromPadding(padding) {
184
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
185
+ top: padding,
186
+ right: padding,
187
+ bottom: padding,
188
+ left: padding
189
+ };
190
+ }
191
+
192
+ function rectToClientRect(rect) {
193
+ return {
194
+ ...rect,
195
+ top: rect.y,
196
+ left: rect.x,
197
+ right: rect.x + rect.width,
198
+ bottom: rect.y + rect.height
199
+ };
200
+ }
201
+
202
+ /**
203
+ * Resolves with an object of overflow side offsets that determine how much the
204
+ * element is overflowing a given clipping boundary.
205
+ * - positive = overflowing the boundary by that number of pixels
206
+ * - negative = how many pixels left before it will overflow
207
+ * - 0 = lies flush with the boundary
208
+ * @see https://floating-ui.com/docs/detectOverflow
209
+ */
210
+ async function detectOverflow(middlewareArguments, options) {
211
+ var _await$platform$isEle;
212
+ if (options === void 0) {
213
+ options = {};
214
+ }
215
+ const {
216
+ x,
217
+ y,
218
+ platform,
219
+ rects,
220
+ elements,
221
+ strategy
222
+ } = middlewareArguments;
223
+ const {
224
+ boundary = 'clippingAncestors',
225
+ rootBoundary = 'viewport',
226
+ elementContext = 'floating',
227
+ altBoundary = false,
228
+ padding = 0
229
+ } = options;
230
+ const paddingObject = getSideObjectFromPadding(padding);
231
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
232
+ const element = elements[altBoundary ? altContext : elementContext];
233
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
234
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
235
+ boundary,
236
+ rootBoundary,
237
+ strategy
238
+ }));
239
+ const rect = elementContext === 'floating' ? {
240
+ ...rects.floating,
241
+ x,
242
+ y
243
+ } : rects.reference;
244
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
245
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
246
+ x: 1,
247
+ y: 1
248
+ } : {
249
+ x: 1,
250
+ y: 1
251
+ };
252
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
253
+ rect,
254
+ offsetParent,
255
+ strategy
256
+ }) : rect);
257
+ return {
258
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
259
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
260
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
261
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
262
+ };
263
+ }
264
+
265
+ const min$1 = Math.min;
266
+ const max$1 = Math.max;
267
+
268
+ function within(min$1$1, value, max$1$1) {
269
+ return max$1(min$1$1, min$1(value, max$1$1));
270
+ }
271
+
272
+ /**
273
+ * Positions an inner element of the floating element such that it is centered
274
+ * to the reference element.
275
+ * @see https://floating-ui.com/docs/arrow
276
+ */
277
+ const arrow = options => ({
278
+ name: 'arrow',
279
+ options,
280
+ async fn(middlewareArguments) {
281
+ // Since `element` is required, we don't Partial<> the type.
282
+ const {
283
+ element,
284
+ padding = 0
285
+ } = options || {};
286
+ const {
287
+ x,
288
+ y,
289
+ placement,
290
+ rects,
291
+ platform
292
+ } = middlewareArguments;
293
+ if (element == null) {
294
+ return {};
295
+ }
296
+ const paddingObject = getSideObjectFromPadding(padding);
297
+ const coords = {
298
+ x,
299
+ y
300
+ };
301
+ const axis = getMainAxisFromPlacement(placement);
302
+ const length = getLengthFromAxis(axis);
303
+ const arrowDimensions = await platform.getDimensions(element);
304
+ const minProp = axis === 'y' ? 'top' : 'left';
305
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
306
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
307
+ const startDiff = coords[axis] - rects.reference[axis];
308
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
309
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
310
+ if (clientSize === 0) {
311
+ clientSize = rects.floating[length];
312
+ }
313
+ const centerToReference = endDiff / 2 - startDiff / 2;
314
+
315
+ // Make sure the arrow doesn't overflow the floating element if the center
316
+ // point is outside the floating element's bounds.
317
+ const min = paddingObject[minProp];
318
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
319
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
320
+ const offset = within(min, center, max);
321
+
322
+ // If the reference is small enough that the arrow's padding causes it to
323
+ // to point to nothing for an aligned placement, adjust the offset of the
324
+ // floating element itself. This stops `shift()` from taking action, but can
325
+ // be worked around by calling it again after the `arrow()` if desired.
326
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
327
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
328
+ return {
329
+ [axis]: coords[axis] - alignmentOffset,
330
+ data: {
331
+ [axis]: offset,
332
+ centerOffset: center - offset
333
+ }
334
+ };
335
+ }
336
+ });
337
+
338
+ const sides = ['top', 'right', 'bottom', 'left'];
339
+ const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
340
+
341
+ const oppositeSideMap = {
342
+ left: 'right',
343
+ right: 'left',
344
+ bottom: 'top',
345
+ top: 'bottom'
346
+ };
347
+ function getOppositePlacement(placement) {
348
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
349
+ }
350
+
351
+ function getAlignmentSides(placement, rects, rtl) {
352
+ if (rtl === void 0) {
353
+ rtl = false;
354
+ }
355
+ const alignment = getAlignment(placement);
356
+ const mainAxis = getMainAxisFromPlacement(placement);
357
+ const length = getLengthFromAxis(mainAxis);
358
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
359
+ if (rects.reference[length] > rects.floating[length]) {
360
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
361
+ }
362
+ return {
363
+ main: mainAlignmentSide,
364
+ cross: getOppositePlacement(mainAlignmentSide)
365
+ };
366
+ }
367
+
368
+ const oppositeAlignmentMap = {
369
+ start: 'end',
370
+ end: 'start'
371
+ };
372
+ function getOppositeAlignmentPlacement(placement) {
373
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
374
+ }
375
+
376
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
377
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
378
+ return allowedPlacementsSortedByAlignment.filter(placement => {
379
+ if (alignment) {
380
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
381
+ }
382
+ return true;
383
+ });
384
+ }
385
+ /**
386
+ * Automatically chooses the `placement` which has the most space available.
387
+ * @see https://floating-ui.com/docs/autoPlacement
388
+ */
389
+ const autoPlacement = function (options) {
390
+ if (options === void 0) {
391
+ options = {};
392
+ }
393
+ return {
394
+ name: 'autoPlacement',
395
+ options,
396
+ async fn(middlewareArguments) {
397
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsSortedByLe;
398
+ const {
399
+ rects,
400
+ middlewareData,
401
+ placement,
402
+ platform,
403
+ elements
404
+ } = middlewareArguments;
405
+ const {
406
+ alignment,
407
+ allowedPlacements = allPlacements,
408
+ autoAlignment = true,
409
+ ...detectOverflowOptions
410
+ } = options;
411
+ const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
412
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
413
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
414
+ const currentPlacement = placements[currentIndex];
415
+ if (currentPlacement == null) {
416
+ return {};
417
+ }
418
+ const {
419
+ main,
420
+ cross
421
+ } = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
422
+
423
+ // Make `computeCoords` start from the right place.
424
+ if (placement !== currentPlacement) {
425
+ return {
426
+ reset: {
427
+ placement: placements[0]
428
+ }
429
+ };
430
+ }
431
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
432
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
433
+ placement: currentPlacement,
434
+ overflows: currentOverflows
435
+ }];
436
+ const nextPlacement = placements[currentIndex + 1];
437
+
438
+ // There are more placements to check.
439
+ if (nextPlacement) {
440
+ return {
441
+ data: {
442
+ index: currentIndex + 1,
443
+ overflows: allOverflows
444
+ },
445
+ reset: {
446
+ placement: nextPlacement
447
+ }
448
+ };
449
+ }
450
+ const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
451
+ const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
452
+ let {
453
+ overflows
454
+ } = _ref;
455
+ return overflows.every(overflow => overflow <= 0);
456
+ })) == null ? void 0 : _placementsSortedByLe.placement;
457
+ const resetPlacement = placementThatFitsOnAllSides || placementsSortedByLeastOverflow[0].placement;
458
+ if (resetPlacement !== placement) {
459
+ return {
460
+ data: {
461
+ index: currentIndex + 1,
462
+ overflows: allOverflows
463
+ },
464
+ reset: {
465
+ placement: resetPlacement
466
+ }
467
+ };
468
+ }
469
+ return {};
470
+ }
471
+ };
472
+ };
473
+
474
+ function getExpandedPlacements(placement) {
475
+ const oppositePlacement = getOppositePlacement(placement);
476
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
477
+ }
478
+
479
+ function getSideList(side, isStart, rtl) {
480
+ const lr = ['left', 'right'];
481
+ const rl = ['right', 'left'];
482
+ const tb = ['top', 'bottom'];
483
+ const bt = ['bottom', 'top'];
484
+ switch (side) {
485
+ case 'top':
486
+ case 'bottom':
487
+ if (rtl) return isStart ? rl : lr;
488
+ return isStart ? lr : rl;
489
+ case 'left':
490
+ case 'right':
491
+ return isStart ? tb : bt;
492
+ default:
493
+ return [];
494
+ }
495
+ }
496
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
497
+ const alignment = getAlignment(placement);
498
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
499
+ if (alignment) {
500
+ list = list.map(side => side + "-" + alignment);
501
+ if (flipAlignment) {
502
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
503
+ }
504
+ }
505
+ return list;
506
+ }
507
+
508
+ /**
509
+ * Changes the placement of the floating element to one that will fit if the
510
+ * initially specified `placement` does not.
511
+ * @see https://floating-ui.com/docs/flip
512
+ */
513
+ const flip = function (options) {
514
+ if (options === void 0) {
515
+ options = {};
516
+ }
517
+ return {
518
+ name: 'flip',
519
+ options,
520
+ async fn(middlewareArguments) {
521
+ var _middlewareData$flip;
522
+ const {
523
+ placement,
524
+ middlewareData,
525
+ rects,
526
+ initialPlacement,
527
+ platform,
528
+ elements
529
+ } = middlewareArguments;
530
+ const {
531
+ mainAxis: checkMainAxis = true,
532
+ crossAxis: checkCrossAxis = true,
533
+ fallbackPlacements: specifiedFallbackPlacements,
534
+ fallbackStrategy = 'bestFit',
535
+ fallbackAxisSideDirection = 'none',
536
+ flipAlignment = true,
537
+ ...detectOverflowOptions
538
+ } = options;
539
+ const side = getSide(placement);
540
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
541
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
542
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
543
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
544
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
545
+ }
546
+ const placements = [initialPlacement, ...fallbackPlacements];
547
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
548
+ const overflows = [];
549
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
550
+ if (checkMainAxis) {
551
+ overflows.push(overflow[side]);
552
+ }
553
+ if (checkCrossAxis) {
554
+ const {
555
+ main,
556
+ cross
557
+ } = getAlignmentSides(placement, rects, rtl);
558
+ overflows.push(overflow[main], overflow[cross]);
559
+ }
560
+ overflowsData = [...overflowsData, {
561
+ placement,
562
+ overflows
563
+ }];
564
+
565
+ // One or more sides is overflowing.
566
+ if (!overflows.every(side => side <= 0)) {
567
+ var _middlewareData$flip2;
568
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
569
+ const nextPlacement = placements[nextIndex];
570
+ if (nextPlacement) {
571
+ // Try next placement and re-run the lifecycle.
572
+ return {
573
+ data: {
574
+ index: nextIndex,
575
+ overflows: overflowsData
576
+ },
577
+ reset: {
578
+ placement: nextPlacement
579
+ }
580
+ };
581
+ }
582
+ let resetPlacement = 'bottom';
583
+ switch (fallbackStrategy) {
584
+ case 'bestFit':
585
+ {
586
+ var _overflowsData$map$so;
587
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
588
+ if (placement) {
589
+ resetPlacement = placement;
590
+ }
591
+ break;
592
+ }
593
+ case 'initialPlacement':
594
+ resetPlacement = initialPlacement;
595
+ break;
596
+ }
597
+ if (placement !== resetPlacement) {
598
+ return {
599
+ reset: {
600
+ placement: resetPlacement
601
+ }
602
+ };
603
+ }
604
+ }
605
+ return {};
606
+ }
607
+ };
608
+ };
609
+
610
+ function getSideOffsets(overflow, rect) {
611
+ return {
612
+ top: overflow.top - rect.height,
613
+ right: overflow.right - rect.width,
614
+ bottom: overflow.bottom - rect.height,
615
+ left: overflow.left - rect.width
616
+ };
617
+ }
618
+ function isAnySideFullyClipped(overflow) {
619
+ return sides.some(side => overflow[side] >= 0);
620
+ }
621
+ /**
622
+ * Provides data to hide the floating element in applicable situations, such as
623
+ * when it is not in the same clipping context as the reference element.
624
+ * @see https://floating-ui.com/docs/hide
625
+ */
626
+ const hide = function (options) {
627
+ if (options === void 0) {
628
+ options = {};
629
+ }
630
+ return {
631
+ name: 'hide',
632
+ options,
633
+ async fn(middlewareArguments) {
634
+ const {
635
+ strategy = 'referenceHidden',
636
+ ...detectOverflowOptions
637
+ } = options;
638
+ const {
639
+ rects
640
+ } = middlewareArguments;
641
+ switch (strategy) {
642
+ case 'referenceHidden':
643
+ {
644
+ const overflow = await detectOverflow(middlewareArguments, {
645
+ ...detectOverflowOptions,
646
+ elementContext: 'reference'
647
+ });
648
+ const offsets = getSideOffsets(overflow, rects.reference);
649
+ return {
650
+ data: {
651
+ referenceHiddenOffsets: offsets,
652
+ referenceHidden: isAnySideFullyClipped(offsets)
653
+ }
654
+ };
655
+ }
656
+ case 'escaped':
657
+ {
658
+ const overflow = await detectOverflow(middlewareArguments, {
659
+ ...detectOverflowOptions,
660
+ altBoundary: true
661
+ });
662
+ const offsets = getSideOffsets(overflow, rects.floating);
663
+ return {
664
+ data: {
665
+ escapedOffsets: offsets,
666
+ escaped: isAnySideFullyClipped(offsets)
667
+ }
668
+ };
669
+ }
670
+ default:
671
+ {
672
+ return {};
673
+ }
674
+ }
675
+ }
676
+ };
677
+ };
678
+
679
+ async function convertValueToCoords(middlewareArguments, value) {
680
+ const {
681
+ placement,
682
+ platform,
683
+ elements
684
+ } = middlewareArguments;
685
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
686
+ const side = getSide(placement);
687
+ const alignment = getAlignment(placement);
688
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
689
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
690
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
691
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
692
+
693
+ // eslint-disable-next-line prefer-const
694
+ let {
695
+ mainAxis,
696
+ crossAxis,
697
+ alignmentAxis
698
+ } = typeof rawValue === 'number' ? {
699
+ mainAxis: rawValue,
700
+ crossAxis: 0,
701
+ alignmentAxis: null
702
+ } : {
703
+ mainAxis: 0,
704
+ crossAxis: 0,
705
+ alignmentAxis: null,
706
+ ...rawValue
707
+ };
708
+ if (alignment && typeof alignmentAxis === 'number') {
709
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
710
+ }
711
+ return isVertical ? {
712
+ x: crossAxis * crossAxisMulti,
713
+ y: mainAxis * mainAxisMulti
714
+ } : {
715
+ x: mainAxis * mainAxisMulti,
716
+ y: crossAxis * crossAxisMulti
717
+ };
718
+ }
719
+
720
+ /**
721
+ * Displaces the floating element from its reference element.
722
+ * @see https://floating-ui.com/docs/offset
723
+ */
724
+ const offset = function (value) {
725
+ if (value === void 0) {
726
+ value = 0;
727
+ }
728
+ return {
729
+ name: 'offset',
730
+ options: value,
731
+ async fn(middlewareArguments) {
732
+ const {
733
+ x,
734
+ y
735
+ } = middlewareArguments;
736
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
737
+ return {
738
+ x: x + diffCoords.x,
739
+ y: y + diffCoords.y,
740
+ data: diffCoords
741
+ };
742
+ }
743
+ };
744
+ };
745
+
746
+ function getCrossAxis(axis) {
747
+ return axis === 'x' ? 'y' : 'x';
748
+ }
749
+
750
+ /**
751
+ * Shifts the floating element in order to keep it in view when it will overflow
752
+ * a clipping boundary.
753
+ * @see https://floating-ui.com/docs/shift
754
+ */
755
+ const shift = function (options) {
756
+ if (options === void 0) {
757
+ options = {};
758
+ }
759
+ return {
760
+ name: 'shift',
761
+ options,
762
+ async fn(middlewareArguments) {
763
+ const {
764
+ x,
765
+ y,
766
+ placement
767
+ } = middlewareArguments;
768
+ const {
769
+ mainAxis: checkMainAxis = true,
770
+ crossAxis: checkCrossAxis = false,
771
+ limiter = {
772
+ fn: _ref => {
773
+ let {
774
+ x,
775
+ y
776
+ } = _ref;
777
+ return {
778
+ x,
779
+ y
780
+ };
781
+ }
782
+ },
783
+ ...detectOverflowOptions
784
+ } = options;
785
+ const coords = {
786
+ x,
787
+ y
788
+ };
789
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
790
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
791
+ const crossAxis = getCrossAxis(mainAxis);
792
+ let mainAxisCoord = coords[mainAxis];
793
+ let crossAxisCoord = coords[crossAxis];
794
+ if (checkMainAxis) {
795
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
796
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
797
+ const min = mainAxisCoord + overflow[minSide];
798
+ const max = mainAxisCoord - overflow[maxSide];
799
+ mainAxisCoord = within(min, mainAxisCoord, max);
800
+ }
801
+ if (checkCrossAxis) {
802
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
803
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
804
+ const min = crossAxisCoord + overflow[minSide];
805
+ const max = crossAxisCoord - overflow[maxSide];
806
+ crossAxisCoord = within(min, crossAxisCoord, max);
807
+ }
808
+ const limitedCoords = limiter.fn({
809
+ ...middlewareArguments,
810
+ [mainAxis]: mainAxisCoord,
811
+ [crossAxis]: crossAxisCoord
812
+ });
813
+ return {
814
+ ...limitedCoords,
815
+ data: {
816
+ x: limitedCoords.x - x,
817
+ y: limitedCoords.y - y
818
+ }
819
+ };
820
+ }
821
+ };
822
+ };
823
+
824
+ function isWindow(value) {
825
+ return value && value.document && value.location && value.alert && value.setInterval;
826
+ }
827
+ function getWindow(node) {
828
+ if (node == null) {
829
+ return window;
830
+ }
831
+
832
+ if (!isWindow(node)) {
833
+ const ownerDocument = node.ownerDocument;
834
+ return ownerDocument ? ownerDocument.defaultView || window : window;
835
+ }
836
+
837
+ return node;
838
+ }
839
+
840
+ function getComputedStyle(element) {
841
+ return getWindow(element).getComputedStyle(element);
842
+ }
843
+
844
+ function getNodeName(node) {
845
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
846
+ }
847
+
848
+ function getUAString() {
849
+ const uaData = navigator.userAgentData;
850
+
851
+ if (uaData != null && uaData.brands) {
852
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
853
+ }
854
+
855
+ return navigator.userAgent;
856
+ }
857
+
858
+ function isHTMLElement(value) {
859
+ return value instanceof getWindow(value).HTMLElement;
860
+ }
861
+ function isElement(value) {
862
+ return value instanceof getWindow(value).Element;
863
+ }
864
+ function isNode(value) {
865
+ return value instanceof getWindow(value).Node;
866
+ }
867
+ function isShadowRoot(node) {
868
+ // Browsers without `ShadowRoot` support
869
+ if (typeof ShadowRoot === 'undefined') {
870
+ return false;
871
+ }
872
+
873
+ const OwnElement = getWindow(node).ShadowRoot;
874
+ return node instanceof OwnElement || node instanceof ShadowRoot;
875
+ }
876
+ function isOverflowElement(element) {
877
+ // Firefox wants us to check `-x` and `-y` variations as well
878
+ const {
879
+ overflow,
880
+ overflowX,
881
+ overflowY,
882
+ display
883
+ } = getComputedStyle(element);
884
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
885
+ }
886
+ function isTableElement(element) {
887
+ return ['table', 'td', 'th'].includes(getNodeName(element));
888
+ }
889
+ function isContainingBlock(element) {
890
+ // TODO: Try and use feature detection here instead
891
+ const isFirefox = /firefox/i.test(getUAString());
892
+ const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that
893
+ // create a containing block.
894
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
895
+
896
+ return css.transform !== 'none' || css.perspective !== 'none' || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( // TS 4.1 compat
897
+ value => {
898
+ const contain = css.contain;
899
+ return contain != null ? contain.includes(value) : false;
900
+ });
901
+ }
902
+ function isLayoutViewport() {
903
+ // Not Safari
904
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
905
+ // • Always-visible scrollbar or not
906
+ // • Width of <html>, etc.
907
+ // const vV = win.visualViewport;
908
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
909
+ }
910
+ function isLastTraversableNode(node) {
911
+ return ['html', 'body', '#document'].includes(getNodeName(node));
912
+ }
913
+
914
+ const min = Math.min;
915
+ const max = Math.max;
916
+ const round = Math.round;
917
+
918
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
919
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
920
+
921
+ if (includeScale === void 0) {
922
+ includeScale = false;
923
+ }
924
+
925
+ if (isFixedStrategy === void 0) {
926
+ isFixedStrategy = false;
927
+ }
928
+
929
+ const clientRect = element.getBoundingClientRect();
930
+ let scaleX = 1;
931
+ let scaleY = 1;
932
+
933
+ if (includeScale && isHTMLElement(element)) {
934
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
935
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
936
+ }
937
+
938
+ const win = isElement(element) ? getWindow(element) : window;
939
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
940
+ const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
941
+ const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
942
+ const width = clientRect.width / scaleX;
943
+ const height = clientRect.height / scaleY;
944
+ return {
945
+ width,
946
+ height,
947
+ top: y,
948
+ right: x + width,
949
+ bottom: y + height,
950
+ left: x,
951
+ x,
952
+ y
953
+ };
954
+ }
955
+
956
+ function getDocumentElement(node) {
957
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
958
+ }
959
+
960
+ function getNodeScroll(element) {
961
+ if (isElement(element)) {
962
+ return {
963
+ scrollLeft: element.scrollLeft,
964
+ scrollTop: element.scrollTop
965
+ };
966
+ }
967
+
968
+ return {
969
+ scrollLeft: element.pageXOffset,
970
+ scrollTop: element.pageYOffset
971
+ };
972
+ }
973
+
974
+ function getWindowScrollBarX(element) {
975
+ // If <html> has a CSS width greater than the viewport, then this will be
976
+ // incorrect for RTL.
977
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
978
+ }
979
+
980
+ function isScaled(element) {
981
+ const rect = getBoundingClientRect(element);
982
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
983
+ }
984
+
985
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
986
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
987
+ const documentElement = getDocumentElement(offsetParent);
988
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
989
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
990
+ let scroll = {
991
+ scrollLeft: 0,
992
+ scrollTop: 0
993
+ };
994
+ const offsets = {
995
+ x: 0,
996
+ y: 0
997
+ };
998
+
999
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1000
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1001
+ scroll = getNodeScroll(offsetParent);
1002
+ }
1003
+
1004
+ if (isHTMLElement(offsetParent)) {
1005
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1006
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1007
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1008
+ } else if (documentElement) {
1009
+ offsets.x = getWindowScrollBarX(documentElement);
1010
+ }
1011
+ }
1012
+
1013
+ return {
1014
+ x: rect.left + scroll.scrollLeft - offsets.x,
1015
+ y: rect.top + scroll.scrollTop - offsets.y,
1016
+ width: rect.width,
1017
+ height: rect.height
1018
+ };
1019
+ }
1020
+
1021
+ function getParentNode(node) {
1022
+ if (getNodeName(node) === 'html') {
1023
+ return node;
1024
+ }
1025
+
1026
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1027
+ // @ts-ignore
1028
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1029
+ node.parentNode || ( // DOM Element detected
1030
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1031
+ getDocumentElement(node) // fallback
1032
+
1033
+ );
1034
+ }
1035
+
1036
+ function getTrueOffsetParent(element) {
1037
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1038
+ return null;
1039
+ }
1040
+
1041
+ return element.offsetParent;
1042
+ }
1043
+
1044
+ function getContainingBlock(element) {
1045
+ let currentNode = getParentNode(element);
1046
+
1047
+ if (isShadowRoot(currentNode)) {
1048
+ currentNode = currentNode.host;
1049
+ }
1050
+
1051
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1052
+ if (isContainingBlock(currentNode)) {
1053
+ return currentNode;
1054
+ } else {
1055
+ const parent = currentNode.parentNode;
1056
+ currentNode = isShadowRoot(parent) ? parent.host : parent;
1057
+ }
1058
+ }
1059
+
1060
+ return null;
1061
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1062
+ // such as table ancestors and cross browser bugs.
1063
+
1064
+
1065
+ function getOffsetParent(element) {
1066
+ const window = getWindow(element);
1067
+ let offsetParent = getTrueOffsetParent(element);
1068
+
1069
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1070
+ offsetParent = getTrueOffsetParent(offsetParent);
1071
+ }
1072
+
1073
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1074
+ return window;
1075
+ }
1076
+
1077
+ return offsetParent || getContainingBlock(element) || window;
1078
+ }
1079
+
1080
+ function getDimensions(element) {
1081
+ if (isHTMLElement(element)) {
1082
+ return {
1083
+ width: element.offsetWidth,
1084
+ height: element.offsetHeight
1085
+ };
1086
+ }
1087
+
1088
+ const rect = getBoundingClientRect(element);
1089
+ return {
1090
+ width: rect.width,
1091
+ height: rect.height
1092
+ };
1093
+ }
1094
+
1095
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1096
+ let {
1097
+ rect,
1098
+ offsetParent,
1099
+ strategy
1100
+ } = _ref;
1101
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1102
+ const documentElement = getDocumentElement(offsetParent);
1103
+
1104
+ if (offsetParent === documentElement) {
1105
+ return rect;
1106
+ }
1107
+
1108
+ let scroll = {
1109
+ scrollLeft: 0,
1110
+ scrollTop: 0
1111
+ };
1112
+ const offsets = {
1113
+ x: 0,
1114
+ y: 0
1115
+ };
1116
+
1117
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1118
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1119
+ scroll = getNodeScroll(offsetParent);
1120
+ }
1121
+
1122
+ if (isHTMLElement(offsetParent)) {
1123
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1124
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1125
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1126
+ } // This doesn't appear to be need to be negated.
1127
+ // else if (documentElement) {
1128
+ // offsets.x = getWindowScrollBarX(documentElement);
1129
+ // }
1130
+
1131
+ }
1132
+
1133
+ return { ...rect,
1134
+ x: rect.x - scroll.scrollLeft + offsets.x,
1135
+ y: rect.y - scroll.scrollTop + offsets.y
1136
+ };
1137
+ }
1138
+
1139
+ function getViewportRect(element, strategy) {
1140
+ const win = getWindow(element);
1141
+ const html = getDocumentElement(element);
1142
+ const visualViewport = win.visualViewport;
1143
+ let width = html.clientWidth;
1144
+ let height = html.clientHeight;
1145
+ let x = 0;
1146
+ let y = 0;
1147
+
1148
+ if (visualViewport) {
1149
+ width = visualViewport.width;
1150
+ height = visualViewport.height;
1151
+ const layoutViewport = isLayoutViewport();
1152
+
1153
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1154
+ x = visualViewport.offsetLeft;
1155
+ y = visualViewport.offsetTop;
1156
+ }
1157
+ }
1158
+
1159
+ return {
1160
+ width,
1161
+ height,
1162
+ x,
1163
+ y
1164
+ };
1165
+ }
1166
+
1167
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1168
+
1169
+ function getDocumentRect(element) {
1170
+ var _element$ownerDocumen;
1171
+
1172
+ const html = getDocumentElement(element);
1173
+ const scroll = getNodeScroll(element);
1174
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1175
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1176
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1177
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1178
+ const y = -scroll.scrollTop;
1179
+
1180
+ if (getComputedStyle(body || html).direction === 'rtl') {
1181
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1182
+ }
1183
+
1184
+ return {
1185
+ width,
1186
+ height,
1187
+ x,
1188
+ y
1189
+ };
1190
+ }
1191
+
1192
+ function getNearestOverflowAncestor(node) {
1193
+ const parentNode = getParentNode(node);
1194
+
1195
+ if (isLastTraversableNode(parentNode)) {
1196
+ // @ts-ignore assume body is always available
1197
+ return node.ownerDocument.body;
1198
+ }
1199
+
1200
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1201
+ return parentNode;
1202
+ }
1203
+
1204
+ return getNearestOverflowAncestor(parentNode);
1205
+ }
1206
+
1207
+ function getOverflowAncestors(node, list) {
1208
+ var _node$ownerDocument;
1209
+
1210
+ if (list === void 0) {
1211
+ list = [];
1212
+ }
1213
+
1214
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1215
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1216
+ const win = getWindow(scrollableAncestor);
1217
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1218
+ const updatedList = list.concat(target);
1219
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1220
+ updatedList.concat(getOverflowAncestors(target));
1221
+ }
1222
+
1223
+ function contains(parent, child) {
1224
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1225
+
1226
+ if (parent.contains(child)) {
1227
+ return true;
1228
+ } // then fallback to custom implementation with Shadow DOM support
1229
+ else if (rootNode && isShadowRoot(rootNode)) {
1230
+ let next = child;
1231
+
1232
+ do {
1233
+ // use `===` replace node.isSameNode()
1234
+ if (next && parent === next) {
1235
+ return true;
1236
+ } // @ts-ignore: need a better way to handle this...
1237
+
1238
+
1239
+ next = next.parentNode || next.host;
1240
+ } while (next);
1241
+ }
1242
+
1243
+ return false;
1244
+ }
1245
+
1246
+ function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
1247
+ let currentNode = element;
1248
+
1249
+ while (currentNode && !isLastTraversableNode(currentNode) && // @ts-expect-error
1250
+ !clippingAncestors.includes(currentNode)) {
1251
+ if (isElement(currentNode) && ['absolute', 'fixed'].includes(getComputedStyle(currentNode).position)) {
1252
+ break;
1253
+ }
1254
+
1255
+ const parentNode = getParentNode(currentNode);
1256
+ currentNode = isShadowRoot(parentNode) ? parentNode.host : parentNode;
1257
+ }
1258
+
1259
+ return currentNode;
1260
+ }
1261
+
1262
+ function getInnerBoundingClientRect(element, strategy) {
1263
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1264
+ const top = clientRect.top + element.clientTop;
1265
+ const left = clientRect.left + element.clientLeft;
1266
+ return {
1267
+ top,
1268
+ left,
1269
+ x: left,
1270
+ y: top,
1271
+ right: left + element.clientWidth,
1272
+ bottom: top + element.clientHeight,
1273
+ width: element.clientWidth,
1274
+ height: element.clientHeight
1275
+ };
1276
+ }
1277
+
1278
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1279
+ if (clippingParent === 'viewport') {
1280
+ return rectToClientRect(getViewportRect(element, strategy));
1281
+ }
1282
+
1283
+ if (isElement(clippingParent)) {
1284
+ return getInnerBoundingClientRect(clippingParent, strategy);
1285
+ }
1286
+
1287
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1288
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1289
+ // clipping (or hiding) overflowing elements with a position different from
1290
+ // `initial`
1291
+
1292
+
1293
+ function getClippingAncestors(element) {
1294
+ const clippingAncestors = getOverflowAncestors(element);
1295
+ const nearestEscapableParent = getNearestParentCapableOfEscapingClipping(element, clippingAncestors);
1296
+ let clipperElement = null;
1297
+
1298
+ if (nearestEscapableParent && isHTMLElement(nearestEscapableParent)) {
1299
+ const offsetParent = getOffsetParent(nearestEscapableParent);
1300
+
1301
+ if (isOverflowElement(nearestEscapableParent)) {
1302
+ clipperElement = nearestEscapableParent;
1303
+ } else if (isHTMLElement(offsetParent)) {
1304
+ clipperElement = offsetParent;
1305
+ }
1306
+ }
1307
+
1308
+ if (!isElement(clipperElement)) {
1309
+ return [];
1310
+ } // @ts-ignore isElement check ensures we return Array<Element>
1311
+
1312
+
1313
+ return clippingAncestors.filter(clippingAncestors => clipperElement && isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1314
+ } // Gets the maximum area that the element is visible in due to any number of
1315
+ // clipping ancestors
1316
+
1317
+
1318
+ function getClippingRect(_ref) {
1319
+ let {
1320
+ element,
1321
+ boundary,
1322
+ rootBoundary,
1323
+ strategy
1324
+ } = _ref;
1325
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1326
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1327
+ const firstClippingAncestor = clippingAncestors[0];
1328
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1329
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1330
+ accRect.top = max(rect.top, accRect.top);
1331
+ accRect.right = min(rect.right, accRect.right);
1332
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1333
+ accRect.left = max(rect.left, accRect.left);
1334
+ return accRect;
1335
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1336
+ return {
1337
+ width: clippingRect.right - clippingRect.left,
1338
+ height: clippingRect.bottom - clippingRect.top,
1339
+ x: clippingRect.left,
1340
+ y: clippingRect.top
1341
+ };
1342
+ }
1343
+
1344
+ const platform = {
1345
+ getClippingRect,
1346
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1347
+ isElement,
1348
+ getDimensions,
1349
+ getOffsetParent,
1350
+ getDocumentElement,
1351
+ getElementRects: _ref => {
1352
+ let {
1353
+ reference,
1354
+ floating,
1355
+ strategy
1356
+ } = _ref;
1357
+ return {
1358
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1359
+ floating: { ...getDimensions(floating),
1360
+ x: 0,
1361
+ y: 0
1362
+ }
1363
+ };
1364
+ },
1365
+ getClientRects: element => Array.from(element.getClientRects()),
1366
+ isRTL: element => getComputedStyle(element).direction === 'rtl'
1367
+ };
1368
+
1369
+ /**
1370
+ * Automatically updates the position of the floating element when necessary.
1371
+ * @see https://floating-ui.com/docs/autoUpdate
1372
+ */
1373
+ function autoUpdate(reference, floating, update, options) {
1374
+ if (options === void 0) {
1375
+ options = {};
1376
+ }
1377
+
1378
+ const {
1379
+ ancestorScroll: _ancestorScroll = true,
1380
+ ancestorResize = true,
1381
+ elementResize = true,
1382
+ animationFrame = false
1383
+ } = options;
1384
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1385
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1386
+ ancestors.forEach(ancestor => {
1387
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1388
+ passive: true
1389
+ });
1390
+ ancestorResize && ancestor.addEventListener('resize', update);
1391
+ });
1392
+ let observer = null;
1393
+
1394
+ if (elementResize) {
1395
+ let initialUpdate = true;
1396
+ observer = new ResizeObserver(() => {
1397
+ if (!initialUpdate) {
1398
+ update();
1399
+ }
1400
+
1401
+ initialUpdate = false;
1402
+ });
1403
+ isElement(reference) && !animationFrame && observer.observe(reference);
1404
+ observer.observe(floating);
1405
+ }
1406
+
1407
+ let frameId;
1408
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1409
+
1410
+ if (animationFrame) {
1411
+ frameLoop();
1412
+ }
1413
+
1414
+ function frameLoop() {
1415
+ const nextRefRect = getBoundingClientRect(reference);
1416
+
1417
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1418
+ update();
1419
+ }
1420
+
1421
+ prevRefRect = nextRefRect;
1422
+ frameId = requestAnimationFrame(frameLoop);
1423
+ }
1424
+
1425
+ update();
1426
+ return () => {
1427
+ var _observer;
1428
+
1429
+ ancestors.forEach(ancestor => {
1430
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1431
+ ancestorResize && ancestor.removeEventListener('resize', update);
1432
+ });
1433
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1434
+ observer = null;
1435
+
1436
+ if (animationFrame) {
1437
+ cancelAnimationFrame(frameId);
1438
+ }
1439
+ };
1440
+ }
1441
+
1442
+ /**
1443
+ * Computes the `x` and `y` coordinates that will place the floating element
1444
+ * next to a reference element when it is given a certain CSS positioning
1445
+ * strategy.
1446
+ */
1447
+
1448
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1449
+ platform,
1450
+ ...options
1451
+ });
1452
+
1453
+ /*!
1454
+ * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
1455
+ * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
1456
+ * v1.0.0-beta.97
1457
+ */
1458
+ /**
1459
+ * This module helps users provide custom configuration for component internals.
1460
+ *
1461
+ * @internal
1462
+ */
1463
+ const configOverrides = globalThis["calciteComponentsConfig"];
1464
+ const config = {
1465
+ /**
1466
+ * We apply a custom fix to improve positioning for non-Chromium browsers.
1467
+ * The fix comes at a performance cost, so provides users a way to opt-out if necessary.
1468
+ *
1469
+ * @internal
1470
+ */
1471
+ floatingUINonChromiumPositioningFix: true,
1472
+ ...configOverrides
1473
+ };
1474
+
1475
+ /*!
1476
+ * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
1477
+ * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
1478
+ * v1.0.0-beta.97
1479
+ */
1480
+ const floatingUIBrowserCheck = patchFloatingUiForNonChromiumBrowsers();
1481
+ async function patchFloatingUiForNonChromiumBrowsers() {
1482
+ function getUAString() {
1483
+ const uaData = navigator.userAgentData;
1484
+ if (uaData === null || uaData === void 0 ? void 0 : uaData.brands) {
1485
+ return uaData.brands.map((item) => `${item.brand}/${item.version}`).join(" ");
1486
+ }
1487
+ return navigator.userAgent;
1488
+ }
1489
+ if (Build.isBrowser &&
1490
+ config.floatingUINonChromiumPositioningFix &&
1491
+ // ⚠️ browser-sniffing is not a best practice and should be avoided ⚠️
1492
+ /firefox|safari/i.test(getUAString())) {
1493
+ const { getClippingRect, getElementRects, getOffsetParent } = await import('./nonChromiumPlatformUtils.js');
1494
+ platform.getClippingRect = getClippingRect;
1495
+ platform.getOffsetParent = getOffsetParent;
1496
+ platform.getElementRects = getElementRects;
1497
+ }
1498
+ }
1499
+ const placementDataAttribute = "data-placement";
1500
+ /**
1501
+ * Exported for testing purposes only
1502
+ */
1503
+ const repositionDebounceTimeout = 100;
1504
+ const effectivePlacements = [
1505
+ "top",
1506
+ "bottom",
1507
+ "right",
1508
+ "left",
1509
+ "top-start",
1510
+ "top-end",
1511
+ "bottom-start",
1512
+ "bottom-end",
1513
+ "right-start",
1514
+ "right-end",
1515
+ "left-start",
1516
+ "left-end"
1517
+ ];
1518
+ const defaultMenuPlacement = "bottom-start";
1519
+ const FloatingCSS = {
1520
+ animation: "calcite-floating-ui-anim",
1521
+ animationActive: "calcite-floating-ui-anim--active"
1522
+ };
1523
+ function getMiddleware({ placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, arrowEl, type }) {
1524
+ const defaultMiddleware = [shift(), hide()];
1525
+ if (type === "menu") {
1526
+ return [
1527
+ ...defaultMiddleware,
1528
+ flip({
1529
+ fallbackPlacements: flipPlacements || ["top-start", "top", "top-end", "bottom-start", "bottom", "bottom-end"]
1530
+ })
1531
+ ];
1532
+ }
1533
+ if (type === "popover" || type === "tooltip") {
1534
+ const middleware = [
1535
+ ...defaultMiddleware,
1536
+ offset({
1537
+ mainAxis: typeof offsetDistance === "number" ? offsetDistance : 0,
1538
+ crossAxis: typeof offsetSkidding === "number" ? offsetSkidding : 0
1539
+ })
1540
+ ];
1541
+ if (placement === "auto" || placement === "auto-start" || placement === "auto-end") {
1542
+ middleware.push(autoPlacement({ alignment: placement === "auto-start" ? "start" : placement === "auto-end" ? "end" : null }));
1543
+ }
1544
+ else if (!disableFlip) {
1545
+ middleware.push(flip(flipPlacements ? { fallbackPlacements: flipPlacements } : {}));
1546
+ }
1547
+ if (arrowEl) {
1548
+ middleware.push(arrow({
1549
+ element: arrowEl
1550
+ }));
1551
+ }
1552
+ return middleware;
1553
+ }
1554
+ return [];
1555
+ }
1556
+ function filterComputedPlacements(placements, el) {
1557
+ const filteredPlacements = placements.filter((placement) => effectivePlacements.includes(placement));
1558
+ if (filteredPlacements.length !== placements.length) {
1559
+ console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${effectivePlacements
1560
+ .map((placement) => `"${placement}"`)
1561
+ .join(", ")
1562
+ .trim()}`, { el });
1563
+ }
1564
+ return filteredPlacements;
1565
+ }
1566
+ /*
1567
+ In floating-ui, "*-start" and "*-end" are already flipped in RTL.
1568
+ There is no need for our "*-leading" and "*-trailing" values anymore.
1569
+ https://github.com/floating-ui/floating-ui/issues/1530
1570
+ https://github.com/floating-ui/floating-ui/issues/1563
1571
+ */
1572
+ function getEffectivePlacement(floatingEl, placement) {
1573
+ const placements = ["left", "right"];
1574
+ if (getElementDir(floatingEl) === "rtl") {
1575
+ placements.reverse();
1576
+ }
1577
+ return placement
1578
+ .replace(/-leading/gi, "-start")
1579
+ .replace(/-trailing/gi, "-end")
1580
+ .replace(/leading/gi, placements[0])
1581
+ .replace(/trailing/gi, placements[1]);
1582
+ }
1583
+ /**
1584
+ * Convenience function to manage `reposition` calls for FloatingUIComponents that use `positionFloatingUI.
1585
+ *
1586
+ * Note: this is not needed for components that use `calcite-popover`.
1587
+ *
1588
+ * @param component
1589
+ * @param options
1590
+ * @param options.referenceEl
1591
+ * @param options.floatingEl
1592
+ * @param options.overlayPositioning
1593
+ * @param options.placement
1594
+ * @param options.disableFlip
1595
+ * @param options.flipPlacements
1596
+ * @param options.offsetDistance
1597
+ * @param options.offsetSkidding
1598
+ * @param options.arrowEl
1599
+ * @param options.type
1600
+ * @param delayed
1601
+ */
1602
+ async function reposition(component, options, delayed = false) {
1603
+ if (!component.open) {
1604
+ return;
1605
+ }
1606
+ return delayed ? debouncedReposition(options) : positionFloatingUI(options);
1607
+ }
1608
+ const debouncedReposition = debounce(positionFloatingUI, repositionDebounceTimeout, {
1609
+ leading: true,
1610
+ maxWait: repositionDebounceTimeout
1611
+ });
1612
+ /**
1613
+ * Positions the floating element relative to the reference element.
1614
+ *
1615
+ * **Note:** exported for testing purposes only
1616
+ *
1617
+ * @param root0
1618
+ * @param root0.referenceEl
1619
+ * @param root0.floatingEl
1620
+ * @param root0.overlayPositioning
1621
+ * @param root0.placement
1622
+ * @param root0.disableFlip
1623
+ * @param root0.flipPlacements
1624
+ * @param root0.offsetDistance
1625
+ * @param root0.offsetSkidding
1626
+ * @param root0.arrowEl
1627
+ * @param root0.type
1628
+ * @param root0.includeArrow
1629
+ */
1630
+ async function positionFloatingUI({ referenceEl, floatingEl, overlayPositioning = "absolute", placement, disableFlip, flipPlacements, offsetDistance, offsetSkidding, includeArrow = false, arrowEl, type }) {
1631
+ var _a;
1632
+ if (!referenceEl || !floatingEl || (includeArrow && !arrowEl)) {
1633
+ return null;
1634
+ }
1635
+ await floatingUIBrowserCheck;
1636
+ const { x, y, placement: effectivePlacement, strategy: position, middlewareData } = await computePosition(referenceEl, floatingEl, {
1637
+ strategy: overlayPositioning,
1638
+ placement: placement === "auto" || placement === "auto-start" || placement === "auto-end"
1639
+ ? undefined
1640
+ : getEffectivePlacement(floatingEl, placement),
1641
+ middleware: getMiddleware({
1642
+ placement,
1643
+ disableFlip,
1644
+ flipPlacements,
1645
+ offsetDistance,
1646
+ offsetSkidding,
1647
+ arrowEl,
1648
+ type
1649
+ })
1650
+ });
1651
+ if (middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.arrow) {
1652
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
1653
+ Object.assign(arrowEl.style, {
1654
+ left: arrowX != null ? `${arrowX}px` : "",
1655
+ top: arrowY != null ? `${arrowY}px` : ""
1656
+ });
1657
+ }
1658
+ const referenceHidden = (_a = middlewareData === null || middlewareData === void 0 ? void 0 : middlewareData.hide) === null || _a === void 0 ? void 0 : _a.referenceHidden;
1659
+ const visibility = referenceHidden ? "hidden" : null;
1660
+ const pointerEvents = visibility ? "none" : null;
1661
+ floatingEl.setAttribute(placementDataAttribute, effectivePlacement);
1662
+ const transform = `translate(${Math.round(x)}px,${Math.round(y)}px)`;
1663
+ Object.assign(floatingEl.style, {
1664
+ visibility,
1665
+ pointerEvents,
1666
+ position,
1667
+ top: "0",
1668
+ left: "0",
1669
+ transform
1670
+ });
1671
+ }
1672
+ /**
1673
+ * Exported for testing purposes only
1674
+ *
1675
+ * @internal
1676
+ */
1677
+ const cleanupMap = new WeakMap();
1678
+ /**
1679
+ * Helper to set up floating element interactions on connectedCallback.
1680
+ *
1681
+ * @param component
1682
+ * @param referenceEl
1683
+ * @param floatingEl
1684
+ */
1685
+ function connectFloatingUI(component, referenceEl, floatingEl) {
1686
+ if (!floatingEl || !referenceEl) {
1687
+ return;
1688
+ }
1689
+ disconnectFloatingUI(component, referenceEl, floatingEl);
1690
+ const position = component.overlayPositioning;
1691
+ // ensure position matches for initial positioning
1692
+ floatingEl.style.position = position;
1693
+ if (position === "absolute") {
1694
+ moveOffScreen(floatingEl);
1695
+ }
1696
+ const runAutoUpdate = Build.isBrowser
1697
+ ? autoUpdate
1698
+ : (_refEl, _floatingEl, updateCallback) => {
1699
+ updateCallback();
1700
+ return () => {
1701
+ /* noop */
1702
+ };
1703
+ };
1704
+ cleanupMap.set(component, runAutoUpdate(referenceEl, floatingEl, () => component.reposition()));
1705
+ }
1706
+ /**
1707
+ * Helper to tear down floating element interactions on disconnectedCallback.
1708
+ *
1709
+ * @param component
1710
+ * @param referenceEl
1711
+ * @param floatingEl
1712
+ */
1713
+ function disconnectFloatingUI(component, referenceEl, floatingEl) {
1714
+ if (!floatingEl || !referenceEl) {
1715
+ return;
1716
+ }
1717
+ getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
1718
+ const cleanup = cleanupMap.get(component);
1719
+ if (cleanup) {
1720
+ cleanup();
1721
+ }
1722
+ cleanupMap.delete(component);
1723
+ }
1724
+ const visiblePointerSize = 4;
1725
+ /**
1726
+ * Default offset the position of the floating element away from the reference element.
1727
+ *
1728
+ * @default 6
1729
+ */
1730
+ const defaultOffsetDistance = Math.ceil(Math.hypot(visiblePointerSize, visiblePointerSize));
1731
+ /**
1732
+ * This utils applies floating element styles to avoid affecting layout when closed.
1733
+ *
1734
+ * This should be called when the closing transition will start.
1735
+ *
1736
+ * @param floatingEl
1737
+ */
1738
+ function updateAfterClose(floatingEl) {
1739
+ if (!floatingEl || floatingEl.style.position !== "absolute") {
1740
+ return;
1741
+ }
1742
+ getTransitionTarget(floatingEl).addEventListener("transitionend", handleTransitionElTransitionEnd);
1743
+ }
1744
+ function getTransitionTarget(floatingEl) {
1745
+ // assumes floatingEl w/ shadowRoot is a FloatingUIComponent
1746
+ return floatingEl.shadowRoot || floatingEl;
1747
+ }
1748
+ function handleTransitionElTransitionEnd(event) {
1749
+ const floatingTransitionEl = event.target;
1750
+ if (
1751
+ // using any prop from floating-ui transition
1752
+ event.propertyName === "opacity" &&
1753
+ floatingTransitionEl.classList.contains(FloatingCSS.animation)) {
1754
+ const floatingEl = getFloatingElFromTransitionTarget(floatingTransitionEl);
1755
+ moveOffScreen(floatingEl);
1756
+ getTransitionTarget(floatingEl).removeEventListener("transitionend", handleTransitionElTransitionEnd);
1757
+ }
1758
+ }
1759
+ function moveOffScreen(floatingEl) {
1760
+ floatingEl.style.transform = "";
1761
+ floatingEl.style.top = "-99999px";
1762
+ floatingEl.style.left = "-99999px";
1763
+ }
1764
+ function getFloatingElFromTransitionTarget(floatingTransitionEl) {
1765
+ return closestElementCrossShadowBoundary(floatingTransitionEl, `[${placementDataAttribute}]`);
1766
+ }
1767
+
1768
+ export { FloatingCSS as F, disconnectFloatingUI as a, defaultOffsetDistance as b, connectFloatingUI as c, defaultMenuPlacement as d, rectToClientRect as e, filterComputedPlacements as f, reposition as r, updateAfterClose as u };