@vonage/vivid 4.23.0 → 4.25.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 (396) hide show
  1. package/custom-elements.json +21830 -14295
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +112 -150
  5. package/index.js +37 -35
  6. package/lib/accordion-item/accordion-item.d.ts +6 -0
  7. package/lib/action-group/action-group.d.ts +6 -0
  8. package/lib/alert/alert.d.ts +20 -0
  9. package/lib/audio-player/audio-player.d.ts +6 -0
  10. package/lib/badge/badge.d.ts +9 -1
  11. package/lib/banner/banner.d.ts +25 -0
  12. package/lib/breadcrumb/breadcrumb.d.ts +6 -0
  13. package/lib/breadcrumb-item/breadcrumb-item.d.ts +63 -7
  14. package/lib/button/button.d.ts +732 -7
  15. package/lib/button/locale.d.ts +3 -0
  16. package/lib/calendar-event/calendar-event.d.ts +6 -0
  17. package/lib/card/card.d.ts +394 -2
  18. package/lib/card/card.template.d.ts +2 -1
  19. package/lib/checkbox/checkbox.d.ts +1822 -5
  20. package/lib/combobox/combobox.d.ts +1827 -20
  21. package/lib/data-grid/data-grid-cell.d.ts +339 -1
  22. package/lib/data-grid/locale.d.ts +5 -0
  23. package/lib/date-picker/date-picker.d.ts +1676 -207
  24. package/lib/date-range-picker/date-range-picker.d.ts +840 -107
  25. package/lib/date-time-picker/date-time-picker.d.ts +1678 -209
  26. package/lib/dial-pad/dial-pad.d.ts +8 -0
  27. package/lib/dialog/dialog.d.ts +12 -0
  28. package/lib/divider/divider.d.ts +6 -0
  29. package/lib/fab/fab.d.ts +6 -0
  30. package/lib/file-picker/file-picker.d.ts +1510 -32
  31. package/lib/file-picker/locale.d.ts +1 -0
  32. package/lib/header/header.d.ts +6 -0
  33. package/lib/icon/icon.d.ts +1 -0
  34. package/lib/icon/icon.template.d.ts +2 -1
  35. package/lib/menu/menu.d.ts +16 -7
  36. package/lib/menu/name.d.ts +1 -0
  37. package/lib/menu-item/menu-item.d.ts +14 -2
  38. package/lib/nav/nav.d.ts +6 -0
  39. package/lib/nav-disclosure/nav-disclosure.d.ts +13 -0
  40. package/lib/nav-item/nav-item.d.ts +405 -3
  41. package/lib/note/note.d.ts +6 -0
  42. package/lib/number-field/number-field.d.ts +1857 -36
  43. package/lib/option/option.d.ts +12 -0
  44. package/lib/progress/progress.d.ts +6 -0
  45. package/lib/progress-ring/progress-ring.d.ts +6 -0
  46. package/lib/radio/radio.d.ts +1137 -4
  47. package/lib/radio-group/radio-group.d.ts +20 -2
  48. package/lib/range-slider/range-slider.d.ts +752 -5
  49. package/lib/rich-text-editor/definition.d.ts +2 -2
  50. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +3 -1
  51. package/lib/rich-text-editor/locale.d.ts +10 -0
  52. package/lib/rich-text-editor/menubar/menubar.d.ts +340 -1
  53. package/lib/rich-text-editor/rich-text-editor.d.ts +352 -2
  54. package/lib/searchable-select/locale.d.ts +1 -0
  55. package/lib/searchable-select/option-tag.d.ts +6 -0
  56. package/lib/searchable-select/searchable-select.d.ts +1857 -35
  57. package/lib/select/select.d.ts +1843 -28
  58. package/lib/selectable-box/selectable-box.d.ts +6 -0
  59. package/lib/slider/slider.d.ts +384 -2
  60. package/lib/split-button/split-button.d.ts +18 -0
  61. package/lib/switch/switch.d.ts +386 -3
  62. package/lib/tab/tab.d.ts +18 -1
  63. package/lib/tab-panel/tab-panel.d.ts +6 -0
  64. package/lib/tabs/tabs.d.ts +5 -21
  65. package/lib/tag/tag.d.ts +12 -0
  66. package/lib/tag-group/tag-group.d.ts +6 -0
  67. package/lib/text-area/text-area.d.ts +2174 -19
  68. package/lib/text-field/text-field.d.ts +2195 -31
  69. package/lib/time-picker/time-picker.d.ts +839 -106
  70. package/lib/toggletip/toggletip.d.ts +10 -4
  71. package/lib/tooltip/tooltip.d.ts +10 -4
  72. package/lib/tree-item/tree-item.d.ts +12 -0
  73. package/lib/tree-view/tree-view.d.ts +6 -0
  74. package/lib/video-player/video-player.d.ts +6 -0
  75. package/lib/visually-hidden/definition.d.ts +4 -0
  76. package/lib/visually-hidden/visually-hidden.d.ts +3 -0
  77. package/lib/visually-hidden/visually-hidden.template.d.ts +3 -0
  78. package/locales/de-DE.cjs +47 -1
  79. package/locales/de-DE.js +47 -1
  80. package/locales/en-GB.cjs +47 -1
  81. package/locales/en-GB.js +47 -1
  82. package/locales/en-US.cjs +47 -1
  83. package/locales/en-US.js +47 -1
  84. package/locales/ja-JP.cjs +47 -1
  85. package/locales/ja-JP.js +47 -1
  86. package/locales/zh-CN.cjs +47 -1
  87. package/locales/zh-CN.js +47 -1
  88. package/menu/index.cjs +1 -1
  89. package/menu/index.js +1 -1
  90. package/nav/index.cjs +1 -1
  91. package/nav/index.js +1 -1
  92. package/nav-disclosure/index.cjs +1 -1
  93. package/nav-disclosure/index.js +1 -1
  94. package/nav-item/index.cjs +1 -1
  95. package/nav-item/index.js +1 -1
  96. package/note/index.cjs +1 -1
  97. package/note/index.js +1 -1
  98. package/number-field/index.cjs +1 -1
  99. package/number-field/index.js +1 -1
  100. package/option/index.cjs +1 -1
  101. package/option/index.js +1 -1
  102. package/package.json +1 -1
  103. package/pagination/index.cjs +1 -1
  104. package/pagination/index.js +1 -1
  105. package/popup/index.cjs +1 -1
  106. package/popup/index.js +1 -1
  107. package/progress/index.cjs +1 -1
  108. package/progress/index.js +1 -1
  109. package/progress-ring/index.cjs +1 -1
  110. package/progress-ring/index.js +1 -1
  111. package/radio/index.cjs +1 -1
  112. package/radio/index.js +1 -1
  113. package/radio-group/index.cjs +1 -1
  114. package/radio-group/index.js +1 -1
  115. package/range-slider/index.cjs +1 -1
  116. package/range-slider/index.js +1 -1
  117. package/rich-text-editor/index.cjs +1 -1
  118. package/rich-text-editor/index.js +1 -1
  119. package/searchable-select/index.cjs +1 -1
  120. package/searchable-select/index.js +1 -1
  121. package/select/index.cjs +1 -1
  122. package/select/index.js +1 -1
  123. package/selectable-box/index.cjs +1 -1
  124. package/selectable-box/index.js +1 -1
  125. package/shared/affix.cjs +13 -7
  126. package/shared/affix.js +13 -8
  127. package/shared/aria/delegates-aria.d.ts +6 -0
  128. package/shared/aria/host-semantics.d.ts +6 -0
  129. package/shared/breadcrumb-item.cjs +2 -5
  130. package/shared/breadcrumb-item.js +2 -5
  131. package/shared/button.cjs +19 -14
  132. package/shared/button.js +19 -14
  133. package/shared/calendar-picker.template.cjs +3 -3
  134. package/shared/calendar-picker.template.js +1 -1
  135. package/shared/char-count.cjs +92 -0
  136. package/shared/char-count.js +90 -0
  137. package/shared/definition.js +1 -1
  138. package/shared/definition10.js +1 -1
  139. package/shared/definition11.cjs +27 -44
  140. package/shared/definition11.js +28 -45
  141. package/shared/definition12.cjs +1 -1
  142. package/shared/definition12.js +2 -2
  143. package/shared/definition13.js +1 -1
  144. package/shared/definition14.cjs +53 -22
  145. package/shared/definition14.js +54 -23
  146. package/shared/definition15.cjs +31 -36
  147. package/shared/definition15.js +30 -36
  148. package/shared/definition16.cjs +43 -63
  149. package/shared/definition16.js +42 -63
  150. package/shared/definition17.cjs +12 -5
  151. package/shared/definition17.js +12 -5
  152. package/shared/definition18.cjs +10 -14
  153. package/shared/definition18.js +9 -14
  154. package/shared/definition19.cjs +85 -100
  155. package/shared/definition19.js +75 -91
  156. package/shared/definition2.js +1 -1
  157. package/shared/definition20.cjs +15 -20
  158. package/shared/definition20.js +14 -20
  159. package/shared/definition21.cjs +22 -3
  160. package/shared/definition21.js +23 -4
  161. package/shared/definition22.cjs +12 -6
  162. package/shared/definition22.js +13 -7
  163. package/shared/definition23.cjs +5 -38
  164. package/shared/definition23.js +5 -37
  165. package/shared/definition24.cjs +2 -7
  166. package/shared/definition24.js +3 -8
  167. package/shared/definition25.js +1 -1
  168. package/shared/definition26.cjs +160 -163
  169. package/shared/definition26.js +159 -163
  170. package/shared/definition27.cjs +1 -1
  171. package/shared/definition27.js +2 -2
  172. package/shared/definition28.cjs +32 -17
  173. package/shared/definition28.js +33 -18
  174. package/shared/definition29.js +1 -1
  175. package/shared/definition3.js +1 -1
  176. package/shared/definition30.cjs +96 -482
  177. package/shared/definition30.js +99 -482
  178. package/shared/definition31.cjs +334 -57
  179. package/shared/definition31.js +333 -56
  180. package/shared/definition32.cjs +104 -19
  181. package/shared/definition32.js +105 -20
  182. package/shared/definition33.cjs +67 -15
  183. package/shared/definition33.js +66 -14
  184. package/shared/definition34.cjs +15 -50
  185. package/shared/definition34.js +14 -49
  186. package/shared/definition35.cjs +28 -397
  187. package/shared/definition35.js +27 -397
  188. package/shared/definition36.cjs +404 -54
  189. package/shared/definition36.js +404 -55
  190. package/shared/definition37.cjs +57 -234
  191. package/shared/definition37.js +57 -233
  192. package/shared/definition38.cjs +221 -66
  193. package/shared/definition38.js +220 -65
  194. package/shared/definition39.cjs +52 -44
  195. package/shared/definition39.js +51 -43
  196. package/shared/definition4.cjs +31 -24
  197. package/shared/definition4.js +33 -26
  198. package/shared/definition40.cjs +56 -266
  199. package/shared/definition40.js +55 -265
  200. package/shared/definition41.cjs +285 -142
  201. package/shared/definition41.js +285 -142
  202. package/shared/definition42.cjs +156 -564
  203. package/shared/definition42.js +156 -565
  204. package/shared/definition43.cjs +557 -14317
  205. package/shared/definition43.js +556 -14316
  206. package/shared/definition44.cjs +14418 -1085
  207. package/shared/definition44.js +14416 -1085
  208. package/shared/definition45.cjs +1049 -671
  209. package/shared/definition45.js +1050 -672
  210. package/shared/definition46.cjs +848 -113
  211. package/shared/definition46.js +847 -112
  212. package/shared/definition47.cjs +125 -90
  213. package/shared/definition47.js +124 -89
  214. package/shared/definition48.cjs +88 -455
  215. package/shared/definition48.js +87 -454
  216. package/shared/definition49.cjs +466 -109
  217. package/shared/definition49.js +466 -109
  218. package/shared/definition5.cjs +8 -7
  219. package/shared/definition5.js +6 -5
  220. package/shared/definition50.cjs +106 -106
  221. package/shared/definition50.js +105 -105
  222. package/shared/definition51.cjs +136 -15
  223. package/shared/definition51.js +135 -14
  224. package/shared/definition52.cjs +16 -115
  225. package/shared/definition52.js +15 -114
  226. package/shared/definition53.cjs +78 -490
  227. package/shared/definition53.js +77 -488
  228. package/shared/definition54.cjs +445 -23
  229. package/shared/definition54.js +443 -22
  230. package/shared/definition55.cjs +22 -136
  231. package/shared/definition55.js +21 -135
  232. package/shared/definition56.cjs +95 -291
  233. package/shared/definition56.js +95 -292
  234. package/shared/definition57.cjs +192 -480
  235. package/shared/definition57.js +190 -479
  236. package/shared/definition58.cjs +411 -24
  237. package/shared/definition58.js +410 -24
  238. package/shared/definition59.cjs +27 -144
  239. package/shared/definition59.js +27 -143
  240. package/shared/definition6.js +1 -1
  241. package/shared/definition60.cjs +83 -54
  242. package/shared/definition60.js +82 -53
  243. package/shared/definition61.cjs +78 -166
  244. package/shared/definition61.js +77 -164
  245. package/shared/definition62.cjs +143 -232
  246. package/shared/definition62.js +141 -231
  247. package/shared/definition63.cjs +234 -69417
  248. package/shared/definition63.js +233 -69416
  249. package/shared/definition64.cjs +69454 -28
  250. package/shared/definition64.js +69453 -27
  251. package/shared/definition65.cjs +28 -2168
  252. package/shared/definition65.js +27 -2166
  253. package/shared/definition66.cjs +27 -0
  254. package/shared/definition66.js +23 -0
  255. package/shared/definition67.cjs +2195 -0
  256. package/shared/definition67.js +2190 -0
  257. package/shared/definition7.cjs +11 -2
  258. package/shared/definition7.js +12 -3
  259. package/shared/definition8.cjs +24 -11
  260. package/shared/definition8.js +26 -13
  261. package/shared/definition9.cjs +1 -2
  262. package/shared/definition9.js +2 -3
  263. package/shared/delegates-aria.js +1 -1
  264. package/shared/deprecation/replaced-props.d.ts +20 -0
  265. package/shared/divider.cjs +41 -0
  266. package/shared/divider.js +38 -0
  267. package/shared/feedback/feedback-message.d.ts +345 -0
  268. package/shared/feedback/locale.d.ts +4 -0
  269. package/{lib/text-anchor/text-anchor.d.ts → shared/feedback/mixins.d.ts} +62 -39
  270. package/shared/form-associated.cjs +124 -100
  271. package/shared/form-associated.js +125 -101
  272. package/shared/form-element.cjs +84 -0
  273. package/shared/form-element.js +82 -0
  274. package/shared/foundation/button/button.d.ts +378 -2
  275. package/shared/foundation/form-associated/form-associated.d.ts +753 -49
  276. package/shared/foundation/listbox/listbox.d.ts +1 -1
  277. package/shared/foundation/vivid-element/vivid-element.d.ts +14 -0
  278. package/shared/host-semantics.js +1 -1
  279. package/shared/key-codes.js +1 -1
  280. package/shared/linkable.cjs +70 -0
  281. package/shared/linkable.js +68 -0
  282. package/shared/localization/Locale.d.ts +16 -0
  283. package/shared/mixins.cjs +306 -0
  284. package/shared/mixins.js +300 -0
  285. package/shared/patterns/affix.d.ts +16 -1
  286. package/shared/patterns/anchored.d.ts +20 -8
  287. package/shared/patterns/char-count/char-count.d.ts +351 -0
  288. package/shared/patterns/char-count/index.d.ts +1 -0
  289. package/shared/patterns/char-count/locale.d.ts +4 -0
  290. package/shared/patterns/form-elements/form-element.d.ts +744 -0
  291. package/shared/patterns/form-elements/index.d.ts +3 -1
  292. package/shared/patterns/form-elements/with-error-text.d.ts +1122 -0
  293. package/shared/patterns/form-elements/with-success-text.d.ts +341 -0
  294. package/shared/patterns/index.d.ts +2 -0
  295. package/shared/patterns/linkable.d.ts +394 -0
  296. package/shared/patterns/localized.d.ts +6 -0
  297. package/shared/patterns/trapped-focus.d.ts +6 -0
  298. package/shared/picker-field/mixins/calendar-picker.d.ts +420 -52
  299. package/shared/picker-field/mixins/calendar-picker.template.d.ts +420 -52
  300. package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +6 -0
  301. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +843 -107
  302. package/shared/picker-field/mixins/single-date-picker.d.ts +1259 -155
  303. package/shared/picker-field/mixins/single-value-picker.d.ts +417 -49
  304. package/shared/picker-field/mixins/time-selection-picker.d.ts +842 -106
  305. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +839 -103
  306. package/shared/picker-field/picker-field.d.ts +1491 -15
  307. package/shared/picker-field.template.cjs +13 -22
  308. package/shared/picker-field.template.js +14 -23
  309. package/shared/repeat.js +1 -1
  310. package/shared/slider.template.cjs +1 -1
  311. package/shared/slider.template.js +1 -1
  312. package/shared/time-selection-picker.template.cjs +10 -15
  313. package/shared/time-selection-picker.template.js +10 -16
  314. package/shared/vivid-element.cjs +53 -4
  315. package/shared/vivid-element.js +53 -3
  316. package/shared/with-error-text.cjs +56 -0
  317. package/shared/with-error-text.js +54 -0
  318. package/shared/with-success-text.cjs +23 -0
  319. package/shared/with-success-text.js +21 -0
  320. package/side-drawer/index.cjs +1 -1
  321. package/side-drawer/index.js +1 -1
  322. package/slider/index.cjs +1 -1
  323. package/slider/index.js +1 -1
  324. package/split-button/index.cjs +1 -1
  325. package/split-button/index.js +1 -1
  326. package/styles/core/all.css +1 -1
  327. package/styles/core/theme.css +1 -1
  328. package/styles/core/typography.css +1 -1
  329. package/styles/tokens/theme-dark.css +4 -4
  330. package/styles/tokens/theme-light.css +4 -4
  331. package/styles/tokens/vivid-2-compat.css +1 -1
  332. package/switch/index.cjs +1 -1
  333. package/switch/index.js +1 -1
  334. package/tab/index.cjs +1 -1
  335. package/tab/index.js +1 -1
  336. package/tab-panel/index.cjs +1 -1
  337. package/tab-panel/index.js +1 -1
  338. package/tabs/index.cjs +1 -1
  339. package/tabs/index.js +1 -1
  340. package/tag/index.cjs +1 -1
  341. package/tag/index.js +1 -1
  342. package/tag-group/index.cjs +1 -1
  343. package/tag-group/index.js +1 -1
  344. package/text-area/index.cjs +1 -1
  345. package/text-area/index.js +1 -1
  346. package/text-field/index.cjs +1 -1
  347. package/text-field/index.js +1 -1
  348. package/time-picker/index.cjs +1 -1
  349. package/time-picker/index.js +1 -1
  350. package/toggletip/index.cjs +1 -1
  351. package/toggletip/index.js +1 -1
  352. package/tooltip/index.cjs +1 -1
  353. package/tooltip/index.js +1 -1
  354. package/tree-item/index.cjs +1 -1
  355. package/tree-item/index.js +1 -1
  356. package/tree-view/index.cjs +1 -1
  357. package/tree-view/index.js +1 -1
  358. package/video-player/index.cjs +1 -1
  359. package/video-player/index.js +1 -1
  360. package/visually-hidden/index.cjs +5 -0
  361. package/visually-hidden/index.js +3 -0
  362. package/vivid.api.json +762 -1478
  363. package/lib/checkbox/checkbox.form-associated.d.ts +0 -11
  364. package/lib/file-picker/file-picker.form-associated.d.ts +0 -11
  365. package/lib/number-field/number-field.form-associated.d.ts +0 -11
  366. package/lib/radio/radio.form-associated.d.ts +0 -13
  367. package/lib/range-slider/range-slider.form-associated.d.ts +0 -11
  368. package/lib/searchable-select/searchable-select.form-associated.d.ts +0 -11
  369. package/lib/select/select.form-associated.d.ts +0 -11
  370. package/lib/slider/slider.form-associated.d.ts +0 -11
  371. package/lib/switch/switch.form-associated.d.ts +0 -11
  372. package/lib/text-anchor/definition.d.ts +0 -2
  373. package/lib/text-anchor/text-anchor.template.d.ts +0 -3
  374. package/lib/text-area/text-area.form-associated.d.ts +0 -11
  375. package/lib/text-field/text-field.form-associated.d.ts +0 -11
  376. package/shared/anchor.cjs +0 -49
  377. package/shared/anchor.js +0 -47
  378. package/shared/apply-mixins.cjs +0 -23
  379. package/shared/apply-mixins.js +0 -21
  380. package/shared/applyMixinsWithObservables.cjs +0 -15
  381. package/shared/applyMixinsWithObservables.js +0 -13
  382. package/shared/direction.cjs +0 -17
  383. package/shared/direction.js +0 -15
  384. package/shared/form-elements.cjs +0 -209
  385. package/shared/form-elements.js +0 -202
  386. package/shared/foundation/anchor/anchor.d.ts +0 -11
  387. package/shared/foundation/utilities/apply-mixins.d.ts +0 -1
  388. package/shared/patterns/form-elements/form-elements.d.ts +0 -58
  389. package/shared/picker-field/picker-field.form-associated.d.ts +0 -11
  390. package/shared/text-anchor.cjs +0 -38
  391. package/shared/text-anchor.js +0 -36
  392. package/shared/text-anchor.template.cjs +0 -35
  393. package/shared/text-anchor.template.js +0 -33
  394. package/shared/utils/applyMixinsWithObservables.d.ts +0 -1
  395. package/text-anchor/index.cjs +0 -17
  396. package/text-anchor/index.js +0 -15
@@ -0,0 +1,2195 @@
1
+ 'use strict';
2
+
3
+ const definition$1 = require('./definition11.cjs');
4
+ const definition = require('./definition65.cjs');
5
+ const vividElement = require('./vivid-element.cjs');
6
+ const ref = require('./ref.cjs');
7
+ const classNames = require('./class-names.cjs');
8
+ const when = require('./when.cjs');
9
+
10
+ /**
11
+ * Custom positioning reference element.
12
+ * @see https://floating-ui.com/docs/virtual-elements
13
+ */
14
+
15
+ const sides = ['top', 'right', 'bottom', 'left'];
16
+ const alignments = ['start', 'end'];
17
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
18
+ const min = Math.min;
19
+ const max = Math.max;
20
+ const round = Math.round;
21
+ const floor = Math.floor;
22
+ const createCoords = v => ({
23
+ x: v,
24
+ y: v
25
+ });
26
+ const oppositeSideMap = {
27
+ left: 'right',
28
+ right: 'left',
29
+ bottom: 'top',
30
+ top: 'bottom'
31
+ };
32
+ const oppositeAlignmentMap = {
33
+ start: 'end',
34
+ end: 'start'
35
+ };
36
+ function clamp(start, value, end) {
37
+ return max(start, min(value, end));
38
+ }
39
+ function evaluate(value, param) {
40
+ return typeof value === 'function' ? value(param) : value;
41
+ }
42
+ function getSide(placement) {
43
+ return placement.split('-')[0];
44
+ }
45
+ function getAlignment(placement) {
46
+ return placement.split('-')[1];
47
+ }
48
+ function getOppositeAxis(axis) {
49
+ return axis === 'x' ? 'y' : 'x';
50
+ }
51
+ function getAxisLength(axis) {
52
+ return axis === 'y' ? 'height' : 'width';
53
+ }
54
+ function getSideAxis(placement) {
55
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
56
+ }
57
+ function getAlignmentAxis(placement) {
58
+ return getOppositeAxis(getSideAxis(placement));
59
+ }
60
+ function getAlignmentSides(placement, rects, rtl) {
61
+ if (rtl === void 0) {
62
+ rtl = false;
63
+ }
64
+ const alignment = getAlignment(placement);
65
+ const alignmentAxis = getAlignmentAxis(placement);
66
+ const length = getAxisLength(alignmentAxis);
67
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
68
+ if (rects.reference[length] > rects.floating[length]) {
69
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
70
+ }
71
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
72
+ }
73
+ function getExpandedPlacements(placement) {
74
+ const oppositePlacement = getOppositePlacement(placement);
75
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
76
+ }
77
+ function getOppositeAlignmentPlacement(placement) {
78
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
79
+ }
80
+ function getSideList(side, isStart, rtl) {
81
+ const lr = ['left', 'right'];
82
+ const rl = ['right', 'left'];
83
+ const tb = ['top', 'bottom'];
84
+ const bt = ['bottom', 'top'];
85
+ switch (side) {
86
+ case 'top':
87
+ case 'bottom':
88
+ if (rtl) return isStart ? rl : lr;
89
+ return isStart ? lr : rl;
90
+ case 'left':
91
+ case 'right':
92
+ return isStart ? tb : bt;
93
+ default:
94
+ return [];
95
+ }
96
+ }
97
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
98
+ const alignment = getAlignment(placement);
99
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
100
+ if (alignment) {
101
+ list = list.map(side => side + "-" + alignment);
102
+ if (flipAlignment) {
103
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
104
+ }
105
+ }
106
+ return list;
107
+ }
108
+ function getOppositePlacement(placement) {
109
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
110
+ }
111
+ function expandPaddingObject(padding) {
112
+ return {
113
+ top: 0,
114
+ right: 0,
115
+ bottom: 0,
116
+ left: 0,
117
+ ...padding
118
+ };
119
+ }
120
+ function getPaddingObject(padding) {
121
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
122
+ top: padding,
123
+ right: padding,
124
+ bottom: padding,
125
+ left: padding
126
+ };
127
+ }
128
+ function rectToClientRect(rect) {
129
+ const {
130
+ x,
131
+ y,
132
+ width,
133
+ height
134
+ } = rect;
135
+ return {
136
+ width,
137
+ height,
138
+ top: y,
139
+ left: x,
140
+ right: x + width,
141
+ bottom: y + height,
142
+ x,
143
+ y
144
+ };
145
+ }
146
+
147
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
148
+ let {
149
+ reference,
150
+ floating
151
+ } = _ref;
152
+ const sideAxis = getSideAxis(placement);
153
+ const alignmentAxis = getAlignmentAxis(placement);
154
+ const alignLength = getAxisLength(alignmentAxis);
155
+ const side = getSide(placement);
156
+ const isVertical = sideAxis === 'y';
157
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
158
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
159
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
160
+ let coords;
161
+ switch (side) {
162
+ case 'top':
163
+ coords = {
164
+ x: commonX,
165
+ y: reference.y - floating.height
166
+ };
167
+ break;
168
+ case 'bottom':
169
+ coords = {
170
+ x: commonX,
171
+ y: reference.y + reference.height
172
+ };
173
+ break;
174
+ case 'right':
175
+ coords = {
176
+ x: reference.x + reference.width,
177
+ y: commonY
178
+ };
179
+ break;
180
+ case 'left':
181
+ coords = {
182
+ x: reference.x - floating.width,
183
+ y: commonY
184
+ };
185
+ break;
186
+ default:
187
+ coords = {
188
+ x: reference.x,
189
+ y: reference.y
190
+ };
191
+ }
192
+ switch (getAlignment(placement)) {
193
+ case 'start':
194
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
195
+ break;
196
+ case 'end':
197
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
198
+ break;
199
+ }
200
+ return coords;
201
+ }
202
+
203
+ /**
204
+ * Computes the `x` and `y` coordinates that will place the floating element
205
+ * next to a given reference element.
206
+ *
207
+ * This export does not have any `platform` interface logic. You will need to
208
+ * write one for the platform you are using Floating UI with.
209
+ */
210
+ const computePosition$1 = async (reference, floating, config) => {
211
+ const {
212
+ placement = 'bottom',
213
+ strategy = 'absolute',
214
+ middleware = [],
215
+ platform
216
+ } = config;
217
+ const validMiddleware = middleware.filter(Boolean);
218
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
219
+ let rects = await platform.getElementRects({
220
+ reference,
221
+ floating,
222
+ strategy
223
+ });
224
+ let {
225
+ x,
226
+ y
227
+ } = computeCoordsFromPlacement(rects, placement, rtl);
228
+ let statefulPlacement = placement;
229
+ let middlewareData = {};
230
+ let resetCount = 0;
231
+ for (let i = 0; i < validMiddleware.length; i++) {
232
+ const {
233
+ name,
234
+ fn
235
+ } = validMiddleware[i];
236
+ const {
237
+ x: nextX,
238
+ y: nextY,
239
+ data,
240
+ reset
241
+ } = await fn({
242
+ x,
243
+ y,
244
+ initialPlacement: placement,
245
+ placement: statefulPlacement,
246
+ strategy,
247
+ middlewareData,
248
+ rects,
249
+ platform,
250
+ elements: {
251
+ reference,
252
+ floating
253
+ }
254
+ });
255
+ x = nextX != null ? nextX : x;
256
+ y = nextY != null ? nextY : y;
257
+ middlewareData = {
258
+ ...middlewareData,
259
+ [name]: {
260
+ ...middlewareData[name],
261
+ ...data
262
+ }
263
+ };
264
+ if (reset && resetCount <= 50) {
265
+ resetCount++;
266
+ if (typeof reset === 'object') {
267
+ if (reset.placement) {
268
+ statefulPlacement = reset.placement;
269
+ }
270
+ if (reset.rects) {
271
+ rects = reset.rects === true ? await platform.getElementRects({
272
+ reference,
273
+ floating,
274
+ strategy
275
+ }) : reset.rects;
276
+ }
277
+ ({
278
+ x,
279
+ y
280
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
281
+ }
282
+ i = -1;
283
+ }
284
+ }
285
+ return {
286
+ x,
287
+ y,
288
+ placement: statefulPlacement,
289
+ strategy,
290
+ middlewareData
291
+ };
292
+ };
293
+
294
+ /**
295
+ * Resolves with an object of overflow side offsets that determine how much the
296
+ * element is overflowing a given clipping boundary on each side.
297
+ * - positive = overflowing the boundary by that number of pixels
298
+ * - negative = how many pixels left before it will overflow
299
+ * - 0 = lies flush with the boundary
300
+ * @see https://floating-ui.com/docs/detectOverflow
301
+ */
302
+ async function detectOverflow(state, options) {
303
+ var _await$platform$isEle;
304
+ if (options === void 0) {
305
+ options = {};
306
+ }
307
+ const {
308
+ x,
309
+ y,
310
+ platform,
311
+ rects,
312
+ elements,
313
+ strategy
314
+ } = state;
315
+ const {
316
+ boundary = 'clippingAncestors',
317
+ rootBoundary = 'viewport',
318
+ elementContext = 'floating',
319
+ altBoundary = false,
320
+ padding = 0
321
+ } = evaluate(options, state);
322
+ const paddingObject = getPaddingObject(padding);
323
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
324
+ const element = elements[altBoundary ? altContext : elementContext];
325
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
326
+ 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))),
327
+ boundary,
328
+ rootBoundary,
329
+ strategy
330
+ }));
331
+ const rect = elementContext === 'floating' ? {
332
+ x,
333
+ y,
334
+ width: rects.floating.width,
335
+ height: rects.floating.height
336
+ } : rects.reference;
337
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
338
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
339
+ x: 1,
340
+ y: 1
341
+ } : {
342
+ x: 1,
343
+ y: 1
344
+ };
345
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
346
+ elements,
347
+ rect,
348
+ offsetParent,
349
+ strategy
350
+ }) : rect);
351
+ return {
352
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
353
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
354
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
355
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
356
+ };
357
+ }
358
+
359
+ /**
360
+ * Provides data to position an inner element of the floating element so that it
361
+ * appears centered to the reference element.
362
+ * @see https://floating-ui.com/docs/arrow
363
+ */
364
+ const arrow$1 = options => ({
365
+ name: 'arrow',
366
+ options,
367
+ async fn(state) {
368
+ const {
369
+ x,
370
+ y,
371
+ placement,
372
+ rects,
373
+ platform,
374
+ elements,
375
+ middlewareData
376
+ } = state;
377
+ // Since `element` is required, we don't Partial<> the type.
378
+ const {
379
+ element,
380
+ padding = 0
381
+ } = evaluate(options, state) || {};
382
+ if (element == null) {
383
+ return {};
384
+ }
385
+ const paddingObject = getPaddingObject(padding);
386
+ const coords = {
387
+ x,
388
+ y
389
+ };
390
+ const axis = getAlignmentAxis(placement);
391
+ const length = getAxisLength(axis);
392
+ const arrowDimensions = await platform.getDimensions(element);
393
+ const isYAxis = axis === 'y';
394
+ const minProp = isYAxis ? 'top' : 'left';
395
+ const maxProp = isYAxis ? 'bottom' : 'right';
396
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
397
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
398
+ const startDiff = coords[axis] - rects.reference[axis];
399
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
400
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
401
+
402
+ // DOM platform can return `window` as the `offsetParent`.
403
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
404
+ clientSize = elements.floating[clientProp] || rects.floating[length];
405
+ }
406
+ const centerToReference = endDiff / 2 - startDiff / 2;
407
+
408
+ // If the padding is large enough that it causes the arrow to no longer be
409
+ // centered, modify the padding so that it is centered.
410
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
411
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
412
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
413
+
414
+ // Make sure the arrow doesn't overflow the floating element if the center
415
+ // point is outside the floating element's bounds.
416
+ const min$1 = minPadding;
417
+ const max = clientSize - arrowDimensions[length] - maxPadding;
418
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
419
+ const offset = clamp(min$1, center, max);
420
+
421
+ // If the reference is small enough that the arrow's padding causes it to
422
+ // to point to nothing for an aligned placement, adjust the offset of the
423
+ // floating element itself. To ensure `shift()` continues to take action,
424
+ // a single reset is performed when this is true.
425
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
426
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
427
+ return {
428
+ [axis]: coords[axis] + alignmentOffset,
429
+ data: {
430
+ [axis]: offset,
431
+ centerOffset: center - offset - alignmentOffset,
432
+ ...(shouldAddOffset && {
433
+ alignmentOffset
434
+ })
435
+ },
436
+ reset: shouldAddOffset
437
+ };
438
+ }
439
+ });
440
+
441
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
442
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
443
+ return allowedPlacementsSortedByAlignment.filter(placement => {
444
+ if (alignment) {
445
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
446
+ }
447
+ return true;
448
+ });
449
+ }
450
+ /**
451
+ * Optimizes the visibility of the floating element by choosing the placement
452
+ * that has the most space available automatically, without needing to specify a
453
+ * preferred placement. Alternative to `flip`.
454
+ * @see https://floating-ui.com/docs/autoPlacement
455
+ */
456
+ const autoPlacement$1 = function (options) {
457
+ if (options === void 0) {
458
+ options = {};
459
+ }
460
+ return {
461
+ name: 'autoPlacement',
462
+ options,
463
+ async fn(state) {
464
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
465
+ const {
466
+ rects,
467
+ middlewareData,
468
+ placement,
469
+ platform,
470
+ elements
471
+ } = state;
472
+ const {
473
+ crossAxis = false,
474
+ alignment,
475
+ allowedPlacements = placements,
476
+ autoAlignment = true,
477
+ ...detectOverflowOptions
478
+ } = evaluate(options, state);
479
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
480
+ const overflow = await detectOverflow(state, detectOverflowOptions);
481
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
482
+ const currentPlacement = placements$1[currentIndex];
483
+ if (currentPlacement == null) {
484
+ return {};
485
+ }
486
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
487
+
488
+ // Make `computeCoords` start from the right place.
489
+ if (placement !== currentPlacement) {
490
+ return {
491
+ reset: {
492
+ placement: placements$1[0]
493
+ }
494
+ };
495
+ }
496
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
497
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
498
+ placement: currentPlacement,
499
+ overflows: currentOverflows
500
+ }];
501
+ const nextPlacement = placements$1[currentIndex + 1];
502
+
503
+ // There are more placements to check.
504
+ if (nextPlacement) {
505
+ return {
506
+ data: {
507
+ index: currentIndex + 1,
508
+ overflows: allOverflows
509
+ },
510
+ reset: {
511
+ placement: nextPlacement
512
+ }
513
+ };
514
+ }
515
+ const placementsSortedByMostSpace = allOverflows.map(d => {
516
+ const alignment = getAlignment(d.placement);
517
+ return [d.placement, alignment && crossAxis ?
518
+ // Check along the mainAxis and main crossAxis side.
519
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
520
+ // Check only the mainAxis.
521
+ d.overflows[0], d.overflows];
522
+ }).sort((a, b) => a[1] - b[1]);
523
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
524
+ // Aligned placements should not check their opposite crossAxis
525
+ // side.
526
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
527
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
528
+ if (resetPlacement !== placement) {
529
+ return {
530
+ data: {
531
+ index: currentIndex + 1,
532
+ overflows: allOverflows
533
+ },
534
+ reset: {
535
+ placement: resetPlacement
536
+ }
537
+ };
538
+ }
539
+ return {};
540
+ }
541
+ };
542
+ };
543
+
544
+ /**
545
+ * Optimizes the visibility of the floating element by flipping the `placement`
546
+ * in order to keep it in view when the preferred placement(s) will overflow the
547
+ * clipping boundary. Alternative to `autoPlacement`.
548
+ * @see https://floating-ui.com/docs/flip
549
+ */
550
+ const flip$1 = function (options) {
551
+ if (options === void 0) {
552
+ options = {};
553
+ }
554
+ return {
555
+ name: 'flip',
556
+ options,
557
+ async fn(state) {
558
+ var _middlewareData$arrow, _middlewareData$flip;
559
+ const {
560
+ placement,
561
+ middlewareData,
562
+ rects,
563
+ initialPlacement,
564
+ platform,
565
+ elements
566
+ } = state;
567
+ const {
568
+ mainAxis: checkMainAxis = true,
569
+ crossAxis: checkCrossAxis = true,
570
+ fallbackPlacements: specifiedFallbackPlacements,
571
+ fallbackStrategy = 'bestFit',
572
+ fallbackAxisSideDirection = 'none',
573
+ flipAlignment = true,
574
+ ...detectOverflowOptions
575
+ } = evaluate(options, state);
576
+
577
+ // If a reset by the arrow was caused due to an alignment offset being
578
+ // added, we should skip any logic now since `flip()` has already done its
579
+ // work.
580
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
581
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
582
+ return {};
583
+ }
584
+ const side = getSide(placement);
585
+ const initialSideAxis = getSideAxis(initialPlacement);
586
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
587
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
588
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
589
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
590
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
591
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
592
+ }
593
+ const placements = [initialPlacement, ...fallbackPlacements];
594
+ const overflow = await detectOverflow(state, detectOverflowOptions);
595
+ const overflows = [];
596
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
597
+ if (checkMainAxis) {
598
+ overflows.push(overflow[side]);
599
+ }
600
+ if (checkCrossAxis) {
601
+ const sides = getAlignmentSides(placement, rects, rtl);
602
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
603
+ }
604
+ overflowsData = [...overflowsData, {
605
+ placement,
606
+ overflows
607
+ }];
608
+
609
+ // One or more sides is overflowing.
610
+ if (!overflows.every(side => side <= 0)) {
611
+ var _middlewareData$flip2, _overflowsData$filter;
612
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
613
+ const nextPlacement = placements[nextIndex];
614
+ if (nextPlacement) {
615
+ // Try next placement and re-run the lifecycle.
616
+ return {
617
+ data: {
618
+ index: nextIndex,
619
+ overflows: overflowsData
620
+ },
621
+ reset: {
622
+ placement: nextPlacement
623
+ }
624
+ };
625
+ }
626
+
627
+ // First, find the candidates that fit on the mainAxis side of overflow,
628
+ // then find the placement that fits the best on the main crossAxis side.
629
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
630
+
631
+ // Otherwise fallback.
632
+ if (!resetPlacement) {
633
+ switch (fallbackStrategy) {
634
+ case 'bestFit':
635
+ {
636
+ var _overflowsData$filter2;
637
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
638
+ if (hasFallbackAxisSideDirection) {
639
+ const currentSideAxis = getSideAxis(d.placement);
640
+ return currentSideAxis === initialSideAxis ||
641
+ // Create a bias to the `y` side axis due to horizontal
642
+ // reading directions favoring greater width.
643
+ currentSideAxis === 'y';
644
+ }
645
+ return true;
646
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
647
+ if (placement) {
648
+ resetPlacement = placement;
649
+ }
650
+ break;
651
+ }
652
+ case 'initialPlacement':
653
+ resetPlacement = initialPlacement;
654
+ break;
655
+ }
656
+ }
657
+ if (placement !== resetPlacement) {
658
+ return {
659
+ reset: {
660
+ placement: resetPlacement
661
+ }
662
+ };
663
+ }
664
+ }
665
+ return {};
666
+ }
667
+ };
668
+ };
669
+
670
+ function getSideOffsets(overflow, rect) {
671
+ return {
672
+ top: overflow.top - rect.height,
673
+ right: overflow.right - rect.width,
674
+ bottom: overflow.bottom - rect.height,
675
+ left: overflow.left - rect.width
676
+ };
677
+ }
678
+ function isAnySideFullyClipped(overflow) {
679
+ return sides.some(side => overflow[side] >= 0);
680
+ }
681
+ /**
682
+ * Provides data to hide the floating element in applicable situations, such as
683
+ * when it is not in the same clipping context as the reference element.
684
+ * @see https://floating-ui.com/docs/hide
685
+ */
686
+ const hide$1 = function (options) {
687
+ if (options === void 0) {
688
+ options = {};
689
+ }
690
+ return {
691
+ name: 'hide',
692
+ options,
693
+ async fn(state) {
694
+ const {
695
+ rects
696
+ } = state;
697
+ const {
698
+ strategy = 'referenceHidden',
699
+ ...detectOverflowOptions
700
+ } = evaluate(options, state);
701
+ switch (strategy) {
702
+ case 'referenceHidden':
703
+ {
704
+ const overflow = await detectOverflow(state, {
705
+ ...detectOverflowOptions,
706
+ elementContext: 'reference'
707
+ });
708
+ const offsets = getSideOffsets(overflow, rects.reference);
709
+ return {
710
+ data: {
711
+ referenceHiddenOffsets: offsets,
712
+ referenceHidden: isAnySideFullyClipped(offsets)
713
+ }
714
+ };
715
+ }
716
+ case 'escaped':
717
+ {
718
+ const overflow = await detectOverflow(state, {
719
+ ...detectOverflowOptions,
720
+ altBoundary: true
721
+ });
722
+ const offsets = getSideOffsets(overflow, rects.floating);
723
+ return {
724
+ data: {
725
+ escapedOffsets: offsets,
726
+ escaped: isAnySideFullyClipped(offsets)
727
+ }
728
+ };
729
+ }
730
+ default:
731
+ {
732
+ return {};
733
+ }
734
+ }
735
+ }
736
+ };
737
+ };
738
+
739
+ function getBoundingRect(rects) {
740
+ const minX = min(...rects.map(rect => rect.left));
741
+ const minY = min(...rects.map(rect => rect.top));
742
+ const maxX = max(...rects.map(rect => rect.right));
743
+ const maxY = max(...rects.map(rect => rect.bottom));
744
+ return {
745
+ x: minX,
746
+ y: minY,
747
+ width: maxX - minX,
748
+ height: maxY - minY
749
+ };
750
+ }
751
+ function getRectsByLine(rects) {
752
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
753
+ const groups = [];
754
+ let prevRect = null;
755
+ for (let i = 0; i < sortedRects.length; i++) {
756
+ const rect = sortedRects[i];
757
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
758
+ groups.push([rect]);
759
+ } else {
760
+ groups[groups.length - 1].push(rect);
761
+ }
762
+ prevRect = rect;
763
+ }
764
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
765
+ }
766
+ /**
767
+ * Provides improved positioning for inline reference elements that can span
768
+ * over multiple lines, such as hyperlinks or range selections.
769
+ * @see https://floating-ui.com/docs/inline
770
+ */
771
+ const inline$1 = function (options) {
772
+ if (options === void 0) {
773
+ options = {};
774
+ }
775
+ return {
776
+ name: 'inline',
777
+ options,
778
+ async fn(state) {
779
+ const {
780
+ placement,
781
+ elements,
782
+ rects,
783
+ platform,
784
+ strategy
785
+ } = state;
786
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
787
+ // ClientRect's bounds, despite the event listener being triggered. A
788
+ // padding of 2 seems to handle this issue.
789
+ const {
790
+ padding = 2,
791
+ x,
792
+ y
793
+ } = evaluate(options, state);
794
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
795
+ const clientRects = getRectsByLine(nativeClientRects);
796
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
797
+ const paddingObject = getPaddingObject(padding);
798
+ function getBoundingClientRect() {
799
+ // There are two rects and they are disjoined.
800
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
801
+ // Find the first rect in which the point is fully inside.
802
+ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
803
+ }
804
+
805
+ // There are 2 or more connected rects.
806
+ if (clientRects.length >= 2) {
807
+ if (getSideAxis(placement) === 'y') {
808
+ const firstRect = clientRects[0];
809
+ const lastRect = clientRects[clientRects.length - 1];
810
+ const isTop = getSide(placement) === 'top';
811
+ const top = firstRect.top;
812
+ const bottom = lastRect.bottom;
813
+ const left = isTop ? firstRect.left : lastRect.left;
814
+ const right = isTop ? firstRect.right : lastRect.right;
815
+ const width = right - left;
816
+ const height = bottom - top;
817
+ return {
818
+ top,
819
+ bottom,
820
+ left,
821
+ right,
822
+ width,
823
+ height,
824
+ x: left,
825
+ y: top
826
+ };
827
+ }
828
+ const isLeftSide = getSide(placement) === 'left';
829
+ const maxRight = max(...clientRects.map(rect => rect.right));
830
+ const minLeft = min(...clientRects.map(rect => rect.left));
831
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
832
+ const top = measureRects[0].top;
833
+ const bottom = measureRects[measureRects.length - 1].bottom;
834
+ const left = minLeft;
835
+ const right = maxRight;
836
+ const width = right - left;
837
+ const height = bottom - top;
838
+ return {
839
+ top,
840
+ bottom,
841
+ left,
842
+ right,
843
+ width,
844
+ height,
845
+ x: left,
846
+ y: top
847
+ };
848
+ }
849
+ return fallback;
850
+ }
851
+ const resetRects = await platform.getElementRects({
852
+ reference: {
853
+ getBoundingClientRect
854
+ },
855
+ floating: elements.floating,
856
+ strategy
857
+ });
858
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
859
+ return {
860
+ reset: {
861
+ rects: resetRects
862
+ }
863
+ };
864
+ }
865
+ return {};
866
+ }
867
+ };
868
+ };
869
+
870
+ // For type backwards-compatibility, the `OffsetOptions` type was also
871
+ // Derivable.
872
+
873
+ async function convertValueToCoords(state, options) {
874
+ const {
875
+ placement,
876
+ platform,
877
+ elements
878
+ } = state;
879
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
880
+ const side = getSide(placement);
881
+ const alignment = getAlignment(placement);
882
+ const isVertical = getSideAxis(placement) === 'y';
883
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
884
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
885
+ const rawValue = evaluate(options, state);
886
+
887
+ // eslint-disable-next-line prefer-const
888
+ let {
889
+ mainAxis,
890
+ crossAxis,
891
+ alignmentAxis
892
+ } = typeof rawValue === 'number' ? {
893
+ mainAxis: rawValue,
894
+ crossAxis: 0,
895
+ alignmentAxis: null
896
+ } : {
897
+ mainAxis: rawValue.mainAxis || 0,
898
+ crossAxis: rawValue.crossAxis || 0,
899
+ alignmentAxis: rawValue.alignmentAxis
900
+ };
901
+ if (alignment && typeof alignmentAxis === 'number') {
902
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
903
+ }
904
+ return isVertical ? {
905
+ x: crossAxis * crossAxisMulti,
906
+ y: mainAxis * mainAxisMulti
907
+ } : {
908
+ x: mainAxis * mainAxisMulti,
909
+ y: crossAxis * crossAxisMulti
910
+ };
911
+ }
912
+
913
+ /**
914
+ * Modifies the placement by translating the floating element along the
915
+ * specified axes.
916
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
917
+ * object may be passed.
918
+ * @see https://floating-ui.com/docs/offset
919
+ */
920
+ const offset$1 = function (options) {
921
+ if (options === void 0) {
922
+ options = 0;
923
+ }
924
+ return {
925
+ name: 'offset',
926
+ options,
927
+ async fn(state) {
928
+ var _middlewareData$offse, _middlewareData$arrow;
929
+ const {
930
+ x,
931
+ y,
932
+ placement,
933
+ middlewareData
934
+ } = state;
935
+ const diffCoords = await convertValueToCoords(state, options);
936
+
937
+ // If the placement is the same and the arrow caused an alignment offset
938
+ // then we don't need to change the positioning coordinates.
939
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
940
+ return {};
941
+ }
942
+ return {
943
+ x: x + diffCoords.x,
944
+ y: y + diffCoords.y,
945
+ data: {
946
+ ...diffCoords,
947
+ placement
948
+ }
949
+ };
950
+ }
951
+ };
952
+ };
953
+
954
+ /**
955
+ * Provides data that allows you to change the size of the floating element —
956
+ * for instance, prevent it from overflowing the clipping boundary or match the
957
+ * width of the reference element.
958
+ * @see https://floating-ui.com/docs/size
959
+ */
960
+ const size$1 = function (options) {
961
+ if (options === void 0) {
962
+ options = {};
963
+ }
964
+ return {
965
+ name: 'size',
966
+ options,
967
+ async fn(state) {
968
+ var _state$middlewareData, _state$middlewareData2;
969
+ const {
970
+ placement,
971
+ rects,
972
+ platform,
973
+ elements
974
+ } = state;
975
+ const {
976
+ apply = () => {},
977
+ ...detectOverflowOptions
978
+ } = evaluate(options, state);
979
+ const overflow = await detectOverflow(state, detectOverflowOptions);
980
+ const side = getSide(placement);
981
+ const alignment = getAlignment(placement);
982
+ const isYAxis = getSideAxis(placement) === 'y';
983
+ const {
984
+ width,
985
+ height
986
+ } = rects.floating;
987
+ let heightSide;
988
+ let widthSide;
989
+ if (side === 'top' || side === 'bottom') {
990
+ heightSide = side;
991
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
992
+ } else {
993
+ widthSide = side;
994
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
995
+ }
996
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
997
+ const maximumClippingWidth = width - overflow.left - overflow.right;
998
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
999
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1000
+ const noShift = !state.middlewareData.shift;
1001
+ let availableHeight = overflowAvailableHeight;
1002
+ let availableWidth = overflowAvailableWidth;
1003
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1004
+ availableWidth = maximumClippingWidth;
1005
+ }
1006
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1007
+ availableHeight = maximumClippingHeight;
1008
+ }
1009
+ if (noShift && !alignment) {
1010
+ const xMin = max(overflow.left, 0);
1011
+ const xMax = max(overflow.right, 0);
1012
+ const yMin = max(overflow.top, 0);
1013
+ const yMax = max(overflow.bottom, 0);
1014
+ if (isYAxis) {
1015
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1016
+ } else {
1017
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1018
+ }
1019
+ }
1020
+ await apply({
1021
+ ...state,
1022
+ availableWidth,
1023
+ availableHeight
1024
+ });
1025
+ const nextDimensions = await platform.getDimensions(elements.floating);
1026
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1027
+ return {
1028
+ reset: {
1029
+ rects: true
1030
+ }
1031
+ };
1032
+ }
1033
+ return {};
1034
+ }
1035
+ };
1036
+ };
1037
+
1038
+ function hasWindow() {
1039
+ return typeof window !== 'undefined';
1040
+ }
1041
+ function getNodeName(node) {
1042
+ if (isNode(node)) {
1043
+ return (node.nodeName || '').toLowerCase();
1044
+ }
1045
+ // Mocked nodes in testing environments may not be instances of Node. By
1046
+ // returning `#document` an infinite loop won't occur.
1047
+ // https://github.com/floating-ui/floating-ui/issues/2317
1048
+ return '#document';
1049
+ }
1050
+ function getWindow(node) {
1051
+ var _node$ownerDocument;
1052
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1053
+ }
1054
+ function getDocumentElement(node) {
1055
+ var _ref;
1056
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1057
+ }
1058
+ function isNode(value) {
1059
+ if (!hasWindow()) {
1060
+ return false;
1061
+ }
1062
+ return value instanceof Node || value instanceof getWindow(value).Node;
1063
+ }
1064
+ function isElement(value) {
1065
+ if (!hasWindow()) {
1066
+ return false;
1067
+ }
1068
+ return value instanceof Element || value instanceof getWindow(value).Element;
1069
+ }
1070
+ function isHTMLElement(value) {
1071
+ if (!hasWindow()) {
1072
+ return false;
1073
+ }
1074
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1075
+ }
1076
+ function isShadowRoot(value) {
1077
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1078
+ return false;
1079
+ }
1080
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1081
+ }
1082
+ function isOverflowElement(element) {
1083
+ const {
1084
+ overflow,
1085
+ overflowX,
1086
+ overflowY,
1087
+ display
1088
+ } = getComputedStyle(element);
1089
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1090
+ }
1091
+ function isTableElement(element) {
1092
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1093
+ }
1094
+ function isTopLayer(element) {
1095
+ return [':popover-open', ':modal'].some(selector => {
1096
+ try {
1097
+ return element.matches(selector);
1098
+ } catch (e) {
1099
+ return false;
1100
+ }
1101
+ });
1102
+ }
1103
+ function isContainingBlock(elementOrCss) {
1104
+ const webkit = isWebKit();
1105
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1106
+
1107
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1108
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1109
+ return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1110
+ }
1111
+ function getContainingBlock(element) {
1112
+ let currentNode = getParentNode(element);
1113
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1114
+ if (isContainingBlock(currentNode)) {
1115
+ return currentNode;
1116
+ } else if (isTopLayer(currentNode)) {
1117
+ return null;
1118
+ }
1119
+ currentNode = getParentNode(currentNode);
1120
+ }
1121
+ return null;
1122
+ }
1123
+ function isWebKit() {
1124
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1125
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1126
+ }
1127
+ function isLastTraversableNode(node) {
1128
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1129
+ }
1130
+ function getComputedStyle(element) {
1131
+ return getWindow(element).getComputedStyle(element);
1132
+ }
1133
+ function getNodeScroll(element) {
1134
+ if (isElement(element)) {
1135
+ return {
1136
+ scrollLeft: element.scrollLeft,
1137
+ scrollTop: element.scrollTop
1138
+ };
1139
+ }
1140
+ return {
1141
+ scrollLeft: element.scrollX,
1142
+ scrollTop: element.scrollY
1143
+ };
1144
+ }
1145
+ function getParentNode(node) {
1146
+ if (getNodeName(node) === 'html') {
1147
+ return node;
1148
+ }
1149
+ const result =
1150
+ // Step into the shadow DOM of the parent of a slotted node.
1151
+ node.assignedSlot ||
1152
+ // DOM Element detected.
1153
+ node.parentNode ||
1154
+ // ShadowRoot detected.
1155
+ isShadowRoot(node) && node.host ||
1156
+ // Fallback.
1157
+ getDocumentElement(node);
1158
+ return isShadowRoot(result) ? result.host : result;
1159
+ }
1160
+ function getNearestOverflowAncestor(node) {
1161
+ const parentNode = getParentNode(node);
1162
+ if (isLastTraversableNode(parentNode)) {
1163
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1164
+ }
1165
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1166
+ return parentNode;
1167
+ }
1168
+ return getNearestOverflowAncestor(parentNode);
1169
+ }
1170
+ function getOverflowAncestors(node, list, traverseIframes) {
1171
+ var _node$ownerDocument2;
1172
+ if (list === void 0) {
1173
+ list = [];
1174
+ }
1175
+ if (traverseIframes === void 0) {
1176
+ traverseIframes = true;
1177
+ }
1178
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1179
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1180
+ const win = getWindow(scrollableAncestor);
1181
+ if (isBody) {
1182
+ const frameElement = getFrameElement(win);
1183
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1184
+ }
1185
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1186
+ }
1187
+ function getFrameElement(win) {
1188
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1189
+ }
1190
+
1191
+ function getCssDimensions(element) {
1192
+ const css = getComputedStyle(element);
1193
+ // In testing environments, the `width` and `height` properties are empty
1194
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1195
+ let width = parseFloat(css.width) || 0;
1196
+ let height = parseFloat(css.height) || 0;
1197
+ const hasOffset = isHTMLElement(element);
1198
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1199
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1200
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1201
+ if (shouldFallback) {
1202
+ width = offsetWidth;
1203
+ height = offsetHeight;
1204
+ }
1205
+ return {
1206
+ width,
1207
+ height,
1208
+ $: shouldFallback
1209
+ };
1210
+ }
1211
+
1212
+ function unwrapElement(element) {
1213
+ return !isElement(element) ? element.contextElement : element;
1214
+ }
1215
+
1216
+ function getScale(element) {
1217
+ const domElement = unwrapElement(element);
1218
+ if (!isHTMLElement(domElement)) {
1219
+ return createCoords(1);
1220
+ }
1221
+ const rect = domElement.getBoundingClientRect();
1222
+ const {
1223
+ width,
1224
+ height,
1225
+ $
1226
+ } = getCssDimensions(domElement);
1227
+ let x = ($ ? round(rect.width) : rect.width) / width;
1228
+ let y = ($ ? round(rect.height) : rect.height) / height;
1229
+
1230
+ // 0, NaN, or Infinity should always fallback to 1.
1231
+
1232
+ if (!x || !Number.isFinite(x)) {
1233
+ x = 1;
1234
+ }
1235
+ if (!y || !Number.isFinite(y)) {
1236
+ y = 1;
1237
+ }
1238
+ return {
1239
+ x,
1240
+ y
1241
+ };
1242
+ }
1243
+
1244
+ const noOffsets = /*#__PURE__*/createCoords(0);
1245
+ function getVisualOffsets(element) {
1246
+ const win = getWindow(element);
1247
+ if (!isWebKit() || !win.visualViewport) {
1248
+ return noOffsets;
1249
+ }
1250
+ return {
1251
+ x: win.visualViewport.offsetLeft,
1252
+ y: win.visualViewport.offsetTop
1253
+ };
1254
+ }
1255
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1256
+ if (isFixed === void 0) {
1257
+ isFixed = false;
1258
+ }
1259
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1260
+ return false;
1261
+ }
1262
+ return isFixed;
1263
+ }
1264
+
1265
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1266
+ if (includeScale === void 0) {
1267
+ includeScale = false;
1268
+ }
1269
+ if (isFixedStrategy === void 0) {
1270
+ isFixedStrategy = false;
1271
+ }
1272
+ const clientRect = element.getBoundingClientRect();
1273
+ const domElement = unwrapElement(element);
1274
+ let scale = createCoords(1);
1275
+ if (includeScale) {
1276
+ if (offsetParent) {
1277
+ if (isElement(offsetParent)) {
1278
+ scale = getScale(offsetParent);
1279
+ }
1280
+ } else {
1281
+ scale = getScale(element);
1282
+ }
1283
+ }
1284
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1285
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1286
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1287
+ let width = clientRect.width / scale.x;
1288
+ let height = clientRect.height / scale.y;
1289
+ if (domElement) {
1290
+ const win = getWindow(domElement);
1291
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1292
+ let currentWin = win;
1293
+ let currentIFrame = getFrameElement(currentWin);
1294
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1295
+ const iframeScale = getScale(currentIFrame);
1296
+ const iframeRect = currentIFrame.getBoundingClientRect();
1297
+ const css = getComputedStyle(currentIFrame);
1298
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1299
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1300
+ x *= iframeScale.x;
1301
+ y *= iframeScale.y;
1302
+ width *= iframeScale.x;
1303
+ height *= iframeScale.y;
1304
+ x += left;
1305
+ y += top;
1306
+ currentWin = getWindow(currentIFrame);
1307
+ currentIFrame = getFrameElement(currentWin);
1308
+ }
1309
+ }
1310
+ return rectToClientRect({
1311
+ width,
1312
+ height,
1313
+ x,
1314
+ y
1315
+ });
1316
+ }
1317
+
1318
+ // If <html> has a CSS width greater than the viewport, then this will be
1319
+ // incorrect for RTL.
1320
+ function getWindowScrollBarX(element, rect) {
1321
+ const leftScroll = getNodeScroll(element).scrollLeft;
1322
+ if (!rect) {
1323
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1324
+ }
1325
+ return rect.left + leftScroll;
1326
+ }
1327
+
1328
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1329
+ if (ignoreScrollbarX === void 0) {
1330
+ ignoreScrollbarX = false;
1331
+ }
1332
+ const htmlRect = documentElement.getBoundingClientRect();
1333
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1334
+ // RTL <body> scrollbar.
1335
+ getWindowScrollBarX(documentElement, htmlRect));
1336
+ const y = htmlRect.top + scroll.scrollTop;
1337
+ return {
1338
+ x,
1339
+ y
1340
+ };
1341
+ }
1342
+
1343
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1344
+ let {
1345
+ elements,
1346
+ rect,
1347
+ offsetParent,
1348
+ strategy
1349
+ } = _ref;
1350
+ const isFixed = strategy === 'fixed';
1351
+ const documentElement = getDocumentElement(offsetParent);
1352
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1353
+ if (offsetParent === documentElement || topLayer && isFixed) {
1354
+ return rect;
1355
+ }
1356
+ let scroll = {
1357
+ scrollLeft: 0,
1358
+ scrollTop: 0
1359
+ };
1360
+ let scale = createCoords(1);
1361
+ const offsets = createCoords(0);
1362
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1363
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1364
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1365
+ scroll = getNodeScroll(offsetParent);
1366
+ }
1367
+ if (isHTMLElement(offsetParent)) {
1368
+ const offsetRect = getBoundingClientRect(offsetParent);
1369
+ scale = getScale(offsetParent);
1370
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1371
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1372
+ }
1373
+ }
1374
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1375
+ return {
1376
+ width: rect.width * scale.x,
1377
+ height: rect.height * scale.y,
1378
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1379
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1380
+ };
1381
+ }
1382
+
1383
+ function getClientRects(element) {
1384
+ return Array.from(element.getClientRects());
1385
+ }
1386
+
1387
+ // Gets the entire size of the scrollable document area, even extending outside
1388
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1389
+ function getDocumentRect(element) {
1390
+ const html = getDocumentElement(element);
1391
+ const scroll = getNodeScroll(element);
1392
+ const body = element.ownerDocument.body;
1393
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1394
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1395
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1396
+ const y = -scroll.scrollTop;
1397
+ if (getComputedStyle(body).direction === 'rtl') {
1398
+ x += max(html.clientWidth, body.clientWidth) - width;
1399
+ }
1400
+ return {
1401
+ width,
1402
+ height,
1403
+ x,
1404
+ y
1405
+ };
1406
+ }
1407
+
1408
+ function getViewportRect(element, strategy) {
1409
+ const win = getWindow(element);
1410
+ const html = getDocumentElement(element);
1411
+ const visualViewport = win.visualViewport;
1412
+ let width = html.clientWidth;
1413
+ let height = html.clientHeight;
1414
+ let x = 0;
1415
+ let y = 0;
1416
+ if (visualViewport) {
1417
+ width = visualViewport.width;
1418
+ height = visualViewport.height;
1419
+ const visualViewportBased = isWebKit();
1420
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1421
+ x = visualViewport.offsetLeft;
1422
+ y = visualViewport.offsetTop;
1423
+ }
1424
+ }
1425
+ return {
1426
+ width,
1427
+ height,
1428
+ x,
1429
+ y
1430
+ };
1431
+ }
1432
+
1433
+ // Returns the inner client rect, subtracting scrollbars if present.
1434
+ function getInnerBoundingClientRect(element, strategy) {
1435
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1436
+ const top = clientRect.top + element.clientTop;
1437
+ const left = clientRect.left + element.clientLeft;
1438
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1439
+ const width = element.clientWidth * scale.x;
1440
+ const height = element.clientHeight * scale.y;
1441
+ const x = left * scale.x;
1442
+ const y = top * scale.y;
1443
+ return {
1444
+ width,
1445
+ height,
1446
+ x,
1447
+ y
1448
+ };
1449
+ }
1450
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1451
+ let rect;
1452
+ if (clippingAncestor === 'viewport') {
1453
+ rect = getViewportRect(element, strategy);
1454
+ } else if (clippingAncestor === 'document') {
1455
+ rect = getDocumentRect(getDocumentElement(element));
1456
+ } else if (isElement(clippingAncestor)) {
1457
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1458
+ } else {
1459
+ const visualOffsets = getVisualOffsets(element);
1460
+ rect = {
1461
+ x: clippingAncestor.x - visualOffsets.x,
1462
+ y: clippingAncestor.y - visualOffsets.y,
1463
+ width: clippingAncestor.width,
1464
+ height: clippingAncestor.height
1465
+ };
1466
+ }
1467
+ return rectToClientRect(rect);
1468
+ }
1469
+ function hasFixedPositionAncestor(element, stopNode) {
1470
+ const parentNode = getParentNode(element);
1471
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1472
+ return false;
1473
+ }
1474
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1475
+ }
1476
+
1477
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1478
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1479
+ // of the given element up the tree.
1480
+ function getClippingElementAncestors(element, cache) {
1481
+ const cachedResult = cache.get(element);
1482
+ if (cachedResult) {
1483
+ return cachedResult;
1484
+ }
1485
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1486
+ let currentContainingBlockComputedStyle = null;
1487
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1488
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1489
+
1490
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1491
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1492
+ const computedStyle = getComputedStyle(currentNode);
1493
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1494
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1495
+ currentContainingBlockComputedStyle = null;
1496
+ }
1497
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1498
+ if (shouldDropCurrentNode) {
1499
+ // Drop non-containing blocks.
1500
+ result = result.filter(ancestor => ancestor !== currentNode);
1501
+ } else {
1502
+ // Record last containing block for next iteration.
1503
+ currentContainingBlockComputedStyle = computedStyle;
1504
+ }
1505
+ currentNode = getParentNode(currentNode);
1506
+ }
1507
+ cache.set(element, result);
1508
+ return result;
1509
+ }
1510
+
1511
+ // Gets the maximum area that the element is visible in due to any number of
1512
+ // clipping ancestors.
1513
+ function getClippingRect(_ref) {
1514
+ let {
1515
+ element,
1516
+ boundary,
1517
+ rootBoundary,
1518
+ strategy
1519
+ } = _ref;
1520
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1521
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1522
+ const firstClippingAncestor = clippingAncestors[0];
1523
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1524
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1525
+ accRect.top = max(rect.top, accRect.top);
1526
+ accRect.right = min(rect.right, accRect.right);
1527
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1528
+ accRect.left = max(rect.left, accRect.left);
1529
+ return accRect;
1530
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1531
+ return {
1532
+ width: clippingRect.right - clippingRect.left,
1533
+ height: clippingRect.bottom - clippingRect.top,
1534
+ x: clippingRect.left,
1535
+ y: clippingRect.top
1536
+ };
1537
+ }
1538
+
1539
+ function getDimensions(element) {
1540
+ const {
1541
+ width,
1542
+ height
1543
+ } = getCssDimensions(element);
1544
+ return {
1545
+ width,
1546
+ height
1547
+ };
1548
+ }
1549
+
1550
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1551
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1552
+ const documentElement = getDocumentElement(offsetParent);
1553
+ const isFixed = strategy === 'fixed';
1554
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1555
+ let scroll = {
1556
+ scrollLeft: 0,
1557
+ scrollTop: 0
1558
+ };
1559
+ const offsets = createCoords(0);
1560
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1561
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1562
+ scroll = getNodeScroll(offsetParent);
1563
+ }
1564
+ if (isOffsetParentAnElement) {
1565
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1566
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1567
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1568
+ } else if (documentElement) {
1569
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1570
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1571
+ offsets.x = getWindowScrollBarX(documentElement);
1572
+ }
1573
+ }
1574
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1575
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1576
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1577
+ return {
1578
+ x,
1579
+ y,
1580
+ width: rect.width,
1581
+ height: rect.height
1582
+ };
1583
+ }
1584
+
1585
+ function isStaticPositioned(element) {
1586
+ return getComputedStyle(element).position === 'static';
1587
+ }
1588
+
1589
+ function getTrueOffsetParent(element, polyfill) {
1590
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1591
+ return null;
1592
+ }
1593
+ if (polyfill) {
1594
+ return polyfill(element);
1595
+ }
1596
+ let rawOffsetParent = element.offsetParent;
1597
+
1598
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1599
+ // while Chrome and Safari return the <body> element. The <body> element must
1600
+ // be used to perform the correct calculations even if the <html> element is
1601
+ // non-static.
1602
+ if (getDocumentElement(element) === rawOffsetParent) {
1603
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1604
+ }
1605
+ return rawOffsetParent;
1606
+ }
1607
+
1608
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1609
+ // such as table ancestors and cross browser bugs.
1610
+ function getOffsetParent(element, polyfill) {
1611
+ const win = getWindow(element);
1612
+ if (isTopLayer(element)) {
1613
+ return win;
1614
+ }
1615
+ if (!isHTMLElement(element)) {
1616
+ let svgOffsetParent = getParentNode(element);
1617
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1618
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1619
+ return svgOffsetParent;
1620
+ }
1621
+ svgOffsetParent = getParentNode(svgOffsetParent);
1622
+ }
1623
+ return win;
1624
+ }
1625
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1626
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1627
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1628
+ }
1629
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1630
+ return win;
1631
+ }
1632
+ return offsetParent || getContainingBlock(element) || win;
1633
+ }
1634
+
1635
+ const getElementRects = async function (data) {
1636
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1637
+ const getDimensionsFn = this.getDimensions;
1638
+ const floatingDimensions = await getDimensionsFn(data.floating);
1639
+ return {
1640
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1641
+ floating: {
1642
+ x: 0,
1643
+ y: 0,
1644
+ width: floatingDimensions.width,
1645
+ height: floatingDimensions.height
1646
+ }
1647
+ };
1648
+ };
1649
+
1650
+ function isRTL(element) {
1651
+ return getComputedStyle(element).direction === 'rtl';
1652
+ }
1653
+
1654
+ const platform = {
1655
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1656
+ getDocumentElement,
1657
+ getClippingRect,
1658
+ getOffsetParent,
1659
+ getElementRects,
1660
+ getClientRects,
1661
+ getDimensions,
1662
+ getScale,
1663
+ isElement,
1664
+ isRTL
1665
+ };
1666
+
1667
+ function rectsAreEqual(a, b) {
1668
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1669
+ }
1670
+
1671
+ // https://samthor.au/2021/observing-dom/
1672
+ function observeMove(element, onMove) {
1673
+ let io = null;
1674
+ let timeoutId;
1675
+ const root = getDocumentElement(element);
1676
+ function cleanup() {
1677
+ var _io;
1678
+ clearTimeout(timeoutId);
1679
+ (_io = io) == null || _io.disconnect();
1680
+ io = null;
1681
+ }
1682
+ function refresh(skip, threshold) {
1683
+ if (skip === void 0) {
1684
+ skip = false;
1685
+ }
1686
+ if (threshold === void 0) {
1687
+ threshold = 1;
1688
+ }
1689
+ cleanup();
1690
+ const elementRectForRootMargin = element.getBoundingClientRect();
1691
+ const {
1692
+ left,
1693
+ top,
1694
+ width,
1695
+ height
1696
+ } = elementRectForRootMargin;
1697
+ if (!skip) {
1698
+ onMove();
1699
+ }
1700
+ if (!width || !height) {
1701
+ return;
1702
+ }
1703
+ const insetTop = floor(top);
1704
+ const insetRight = floor(root.clientWidth - (left + width));
1705
+ const insetBottom = floor(root.clientHeight - (top + height));
1706
+ const insetLeft = floor(left);
1707
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1708
+ const options = {
1709
+ rootMargin,
1710
+ threshold: max(0, min(1, threshold)) || 1
1711
+ };
1712
+ let isFirstUpdate = true;
1713
+ function handleObserve(entries) {
1714
+ const ratio = entries[0].intersectionRatio;
1715
+ if (ratio !== threshold) {
1716
+ if (!isFirstUpdate) {
1717
+ return refresh();
1718
+ }
1719
+ if (!ratio) {
1720
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1721
+ // to prevent an infinite loop of updates.
1722
+ timeoutId = setTimeout(() => {
1723
+ refresh(false, 1e-7);
1724
+ }, 1000);
1725
+ } else {
1726
+ refresh(false, ratio);
1727
+ }
1728
+ }
1729
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1730
+ // It's possible that even though the ratio is reported as 1, the
1731
+ // element is not actually fully within the IntersectionObserver's root
1732
+ // area anymore. This can happen under performance constraints. This may
1733
+ // be a bug in the browser's IntersectionObserver implementation. To
1734
+ // work around this, we compare the element's bounding rect now with
1735
+ // what it was at the time we created the IntersectionObserver. If they
1736
+ // are not equal then the element moved, so we refresh.
1737
+ refresh();
1738
+ }
1739
+ isFirstUpdate = false;
1740
+ }
1741
+
1742
+ // Older browsers don't support a `document` as the root and will throw an
1743
+ // error.
1744
+ try {
1745
+ io = new IntersectionObserver(handleObserve, {
1746
+ ...options,
1747
+ // Handle <iframe>s
1748
+ root: root.ownerDocument
1749
+ });
1750
+ } catch (e) {
1751
+ io = new IntersectionObserver(handleObserve, options);
1752
+ }
1753
+ io.observe(element);
1754
+ }
1755
+ refresh(true);
1756
+ return cleanup;
1757
+ }
1758
+
1759
+ /**
1760
+ * Automatically updates the position of the floating element when necessary.
1761
+ * Should only be called when the floating element is mounted on the DOM or
1762
+ * visible on the screen.
1763
+ * @returns cleanup function that should be invoked when the floating element is
1764
+ * removed from the DOM or hidden from the screen.
1765
+ * @see https://floating-ui.com/docs/autoUpdate
1766
+ */
1767
+ function autoUpdate(reference, floating, update, options) {
1768
+ if (options === void 0) {
1769
+ options = {};
1770
+ }
1771
+ const {
1772
+ ancestorScroll = true,
1773
+ ancestorResize = true,
1774
+ elementResize = typeof ResizeObserver === 'function',
1775
+ layoutShift = typeof IntersectionObserver === 'function',
1776
+ animationFrame = false
1777
+ } = options;
1778
+ const referenceEl = unwrapElement(reference);
1779
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1780
+ ancestors.forEach(ancestor => {
1781
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1782
+ passive: true
1783
+ });
1784
+ ancestorResize && ancestor.addEventListener('resize', update);
1785
+ });
1786
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1787
+ let reobserveFrame = -1;
1788
+ let resizeObserver = null;
1789
+ if (elementResize) {
1790
+ resizeObserver = new ResizeObserver(_ref => {
1791
+ let [firstEntry] = _ref;
1792
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1793
+ // Prevent update loops when using the `size` middleware.
1794
+ // https://github.com/floating-ui/floating-ui/issues/1740
1795
+ resizeObserver.unobserve(floating);
1796
+ cancelAnimationFrame(reobserveFrame);
1797
+ reobserveFrame = requestAnimationFrame(() => {
1798
+ var _resizeObserver;
1799
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1800
+ });
1801
+ }
1802
+ update();
1803
+ });
1804
+ if (referenceEl && !animationFrame) {
1805
+ resizeObserver.observe(referenceEl);
1806
+ }
1807
+ resizeObserver.observe(floating);
1808
+ }
1809
+ let frameId;
1810
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1811
+ if (animationFrame) {
1812
+ frameLoop();
1813
+ }
1814
+ function frameLoop() {
1815
+ const nextRefRect = getBoundingClientRect(reference);
1816
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1817
+ update();
1818
+ }
1819
+ prevRefRect = nextRefRect;
1820
+ frameId = requestAnimationFrame(frameLoop);
1821
+ }
1822
+ update();
1823
+ return () => {
1824
+ var _resizeObserver2;
1825
+ ancestors.forEach(ancestor => {
1826
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1827
+ ancestorResize && ancestor.removeEventListener('resize', update);
1828
+ });
1829
+ cleanupIo == null || cleanupIo();
1830
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1831
+ resizeObserver = null;
1832
+ if (animationFrame) {
1833
+ cancelAnimationFrame(frameId);
1834
+ }
1835
+ };
1836
+ }
1837
+
1838
+ /**
1839
+ * Modifies the placement by translating the floating element along the
1840
+ * specified axes.
1841
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1842
+ * object may be passed.
1843
+ * @see https://floating-ui.com/docs/offset
1844
+ */
1845
+ const offset = offset$1;
1846
+
1847
+ /**
1848
+ * Optimizes the visibility of the floating element by choosing the placement
1849
+ * that has the most space available automatically, without needing to specify a
1850
+ * preferred placement. Alternative to `flip`.
1851
+ * @see https://floating-ui.com/docs/autoPlacement
1852
+ */
1853
+ const autoPlacement = autoPlacement$1;
1854
+
1855
+ /**
1856
+ * Optimizes the visibility of the floating element by flipping the `placement`
1857
+ * in order to keep it in view when the preferred placement(s) will overflow the
1858
+ * clipping boundary. Alternative to `autoPlacement`.
1859
+ * @see https://floating-ui.com/docs/flip
1860
+ */
1861
+ const flip = flip$1;
1862
+
1863
+ /**
1864
+ * Provides data that allows you to change the size of the floating element —
1865
+ * for instance, prevent it from overflowing the clipping boundary or match the
1866
+ * width of the reference element.
1867
+ * @see https://floating-ui.com/docs/size
1868
+ */
1869
+ const size = size$1;
1870
+
1871
+ /**
1872
+ * Provides data to hide the floating element in applicable situations, such as
1873
+ * when it is not in the same clipping context as the reference element.
1874
+ * @see https://floating-ui.com/docs/hide
1875
+ */
1876
+ const hide = hide$1;
1877
+
1878
+ /**
1879
+ * Provides data to position an inner element of the floating element so that it
1880
+ * appears centered to the reference element.
1881
+ * @see https://floating-ui.com/docs/arrow
1882
+ */
1883
+ const arrow = arrow$1;
1884
+
1885
+ /**
1886
+ * Provides improved positioning for inline reference elements that can span
1887
+ * over multiple lines, such as hyperlinks or range selections.
1888
+ * @see https://floating-ui.com/docs/inline
1889
+ */
1890
+ const inline = inline$1;
1891
+
1892
+ /**
1893
+ * Computes the `x` and `y` coordinates that will place the floating element
1894
+ * next to a given reference element.
1895
+ */
1896
+ const computePosition = (reference, floating, options) => {
1897
+ // This caches the expensive `getClippingElementAncestors` function so that
1898
+ // multiple lifecycle resets re-use the same result. It only lives for a
1899
+ // single call. If other functions become expensive, we can add them as well.
1900
+ const cache = new Map();
1901
+ const mergedOptions = {
1902
+ platform,
1903
+ ...options
1904
+ };
1905
+ const platformWithCache = {
1906
+ ...mergedOptions.platform,
1907
+ _c: cache
1908
+ };
1909
+ return computePosition$1(reference, floating, {
1910
+ ...mergedOptions,
1911
+ platform: platformWithCache
1912
+ });
1913
+ };
1914
+
1915
+ var __defProp = Object.defineProperty;
1916
+ var __decorateClass = (decorators, target, key, kind) => {
1917
+ var result = void 0 ;
1918
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1919
+ if (decorator = decorators[i])
1920
+ result = (decorator(target, key, result) ) || result;
1921
+ if (result) __defProp(target, key, result);
1922
+ return result;
1923
+ };
1924
+ const PlacementStrategy = {
1925
+ Flip: "flip",
1926
+ AutoPlacementHorizontal: "auto-placement-horizontal",
1927
+ AutoPlacementVertical: "auto-placement-vertical"
1928
+ };
1929
+ const placementStrategyMiddlewares = {
1930
+ [PlacementStrategy.Flip]: flip(),
1931
+ [PlacementStrategy.AutoPlacementHorizontal]: autoPlacement({
1932
+ allowedPlacements: [
1933
+ "bottom",
1934
+ "top",
1935
+ "bottom-start",
1936
+ "bottom-end",
1937
+ "top-start",
1938
+ "top-end"
1939
+ ]
1940
+ }),
1941
+ [PlacementStrategy.AutoPlacementVertical]: autoPlacement({
1942
+ allowedPlacements: [
1943
+ "left",
1944
+ "right",
1945
+ "left-start",
1946
+ "left-end",
1947
+ "right-start",
1948
+ "right-end"
1949
+ ]
1950
+ })
1951
+ };
1952
+ class Popup extends vividElement.VividElement {
1953
+ constructor() {
1954
+ super(...arguments);
1955
+ this.open = false;
1956
+ this.dismissible = false;
1957
+ this.arrow = false;
1958
+ this.alternate = false;
1959
+ /**
1960
+ * The placement strategy of the popup.
1961
+ *
1962
+ * @public
1963
+ */
1964
+ this.placementStrategy = PlacementStrategy.Flip;
1965
+ this.animationFrame = false;
1966
+ this.strategy = "fixed";
1967
+ this.#autoUpdateCallback = () => {
1968
+ this.#lastPositionUpdate = this.updatePosition();
1969
+ return this.#lastPositionUpdate;
1970
+ };
1971
+ }
1972
+ get #middleware() {
1973
+ let middleware = [
1974
+ inline(),
1975
+ placementStrategyMiddlewares[this.placementStrategy],
1976
+ hide(),
1977
+ size({
1978
+ apply({ availableWidth, availableHeight, elements }) {
1979
+ Object.assign(elements.floating.style, {
1980
+ maxWidth: `${availableWidth}px`,
1981
+ maxHeight: `${availableHeight}px`
1982
+ });
1983
+ }
1984
+ })
1985
+ ];
1986
+ if (this.arrow) {
1987
+ middleware = [
1988
+ offset(12),
1989
+ ...middleware,
1990
+ arrow({ element: this.arrowEl, padding: 10 })
1991
+ ];
1992
+ }
1993
+ return middleware;
1994
+ }
1995
+ #cleanup;
1996
+ openChanged(_, newValue) {
1997
+ this.#togglePopover();
1998
+ this.#updateAutoUpdate();
1999
+ this.$emit(newValue ? "vwc-popup:open" : "vwc-popup:close");
2000
+ }
2001
+ /**
2002
+ * @internal
2003
+ */
2004
+ animationFrameChanged() {
2005
+ this.#updateAutoUpdate();
2006
+ }
2007
+ /**
2008
+ * @internal
2009
+ */
2010
+ anchorChanged() {
2011
+ this.#updateAutoUpdate();
2012
+ }
2013
+ /**
2014
+ * @internal
2015
+ */
2016
+ strategyChanged() {
2017
+ this.#togglePopover();
2018
+ }
2019
+ connectedCallback() {
2020
+ super.connectedCallback();
2021
+ this.#togglePopover();
2022
+ this.#updateAutoUpdate();
2023
+ }
2024
+ disconnectedCallback() {
2025
+ super.disconnectedCallback();
2026
+ this.#updateAutoUpdate();
2027
+ }
2028
+ #updateAutoUpdate() {
2029
+ this.#cleanup?.();
2030
+ if (this.open && this.controlEl) {
2031
+ this.controlEl.classList.add("open");
2032
+ }
2033
+ if (this.anchorEl && this.open && this.popupEl) {
2034
+ this.#cleanup = autoUpdate(
2035
+ this.anchorEl,
2036
+ this.popupEl,
2037
+ this.#autoUpdateCallback,
2038
+ {
2039
+ animationFrame: this.animationFrame
2040
+ }
2041
+ );
2042
+ }
2043
+ }
2044
+ #togglePopover() {
2045
+ if (this.popupEl && this.strategy === "fixed") {
2046
+ if (this.open) {
2047
+ this.popupEl.showPopover();
2048
+ } else {
2049
+ this.popupEl.hidePopover();
2050
+ }
2051
+ }
2052
+ }
2053
+ #lastPositionUpdate;
2054
+ #autoUpdateCallback;
2055
+ /**
2056
+ * Updates popup's position
2057
+ *
2058
+ * @public
2059
+ */
2060
+ async updatePosition() {
2061
+ if (!this.open || !this.anchorEl) {
2062
+ return;
2063
+ }
2064
+ const positionData = await computePosition(this.anchorEl, this.popupEl, {
2065
+ placement: this.placement,
2066
+ strategy: this.strategy,
2067
+ middleware: this.#middleware
2068
+ });
2069
+ this.#assignPopupPosition(positionData);
2070
+ if (this.arrow) {
2071
+ this.#assignArrowPosition(positionData);
2072
+ }
2073
+ }
2074
+ #assignPopupPosition(data) {
2075
+ const { x: popupX, y: popupY } = data;
2076
+ const { referenceHidden } = data.middlewareData.hide;
2077
+ Object.assign(this.popupEl.style, {
2078
+ left: `${popupX}px`,
2079
+ top: `${popupY}px`,
2080
+ visibility: referenceHidden ? "hidden" : "visible"
2081
+ });
2082
+ }
2083
+ #assignArrowPosition(data) {
2084
+ const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
2085
+ const styles = {
2086
+ left: "calc(100% - 4px)",
2087
+ right: "-4px",
2088
+ top: "calc(100% - 4px)",
2089
+ bottom: "-4px"
2090
+ };
2091
+ const staticAxis = data.placement.split("-")[0];
2092
+ Object.assign(this.arrowEl.style, {
2093
+ left: arrowX ? `${arrowX}px` : styles[staticAxis],
2094
+ top: arrowY ? `${arrowY}px` : styles[staticAxis]
2095
+ });
2096
+ }
2097
+ get anchorEl() {
2098
+ return this.anchor ?? null;
2099
+ }
2100
+ /**
2101
+ * Shows the popup.
2102
+ * Unlike toggling the `open` attribute, show() will wait for the popup to become visible and positioned correctly.
2103
+ */
2104
+ show() {
2105
+ this.open = true;
2106
+ return this.#lastPositionUpdate ?? Promise.resolve();
2107
+ }
2108
+ hide() {
2109
+ this.open = false;
2110
+ }
2111
+ }
2112
+ __decorateClass([
2113
+ vividElement.attr({
2114
+ mode: "boolean"
2115
+ })
2116
+ ], Popup.prototype, "open");
2117
+ __decorateClass([
2118
+ vividElement.attr({
2119
+ mode: "boolean"
2120
+ })
2121
+ ], Popup.prototype, "dismissible");
2122
+ __decorateClass([
2123
+ vividElement.attr({
2124
+ mode: "boolean"
2125
+ })
2126
+ ], Popup.prototype, "arrow");
2127
+ __decorateClass([
2128
+ vividElement.attr({
2129
+ mode: "boolean"
2130
+ })
2131
+ ], Popup.prototype, "alternate");
2132
+ __decorateClass([
2133
+ vividElement.attr({ mode: "fromView" })
2134
+ ], Popup.prototype, "placement");
2135
+ __decorateClass([
2136
+ vividElement.attr({ mode: "boolean", attribute: "animation-frame" })
2137
+ ], Popup.prototype, "animationFrame");
2138
+ __decorateClass([
2139
+ vividElement.attr({ mode: "fromView" })
2140
+ ], Popup.prototype, "strategy");
2141
+ __decorateClass([
2142
+ vividElement.observable
2143
+ ], Popup.prototype, "anchor");
2144
+
2145
+ const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.popup-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.popup-wrapper ::-webkit-scrollbar{width:4px}.popup-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.popup-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.popup-wrapper{z-index:var(--_popup-z-index, 10);overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
2146
+
2147
+ const getClasses = ({ open, dismissible, alternate }) => classNames.classNames(
2148
+ "control",
2149
+ ["open", Boolean(open)],
2150
+ ["dismissible", Boolean(dismissible)],
2151
+ ["alternate", Boolean(alternate)]
2152
+ );
2153
+ function handlePopover(x) {
2154
+ return x.strategy && x.strategy === "fixed" ? "manual" : null;
2155
+ }
2156
+ const popupTemplate = (context) => {
2157
+ const elevationTag = context.tagFor(definition.Elevation);
2158
+ const buttonTag = context.tagFor(definition$1.Button);
2159
+ return vividElement.html`
2160
+ <${elevationTag}>
2161
+ <div popover="${handlePopover}" class="popup-wrapper ${(x) => x.strategy}" ${ref.ref("popupEl")} part="popup-base">
2162
+ <div ${ref.ref("controlEl")} class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
2163
+ part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
2164
+ <div class="popup-content">
2165
+ <slot></slot>
2166
+ ${when.when(
2167
+ (x) => x.dismissible,
2168
+ vividElement.html`<${buttonTag} size="condensed" @click="${(x) => x.open = false}"
2169
+ class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`
2170
+ )}
2171
+ </div>
2172
+ ${when.when(
2173
+ (x) => x.arrow,
2174
+ vividElement.html`<div class="arrow" ${ref.ref("arrowEl")}></div>`
2175
+ )}
2176
+ </div>
2177
+ </div>
2178
+ </${elevationTag}>`;
2179
+ };
2180
+
2181
+ const popupDefinition = vividElement.defineVividComponent(
2182
+ "popup",
2183
+ Popup,
2184
+ popupTemplate,
2185
+ [definition.elevationDefinition, definition$1.buttonDefinition],
2186
+ {
2187
+ styles
2188
+ }
2189
+ );
2190
+ const registerPopup = vividElement.createRegisterFunction(popupDefinition);
2191
+
2192
+ exports.PlacementStrategy = PlacementStrategy;
2193
+ exports.Popup = Popup;
2194
+ exports.popupDefinition = popupDefinition;
2195
+ exports.registerPopup = registerPopup;