mimir-ui-kit 1.13.7 → 1.14.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 (166) hide show
  1. package/README.md +62 -62
  2. package/dist/{NavigationButtons-DuOoqaPo.js → NavigationButtons-B8tMfqrg.js} +20 -20
  3. package/dist/assets/Button.css +1 -1
  4. package/dist/assets/Input.css +1 -1
  5. package/dist/assets/MergedButton.css +1 -1
  6. package/dist/assets/OtpInput.css +1 -1
  7. package/dist/assets/RadioGroup.css +1 -1
  8. package/dist/assets/Slider.css +1 -1
  9. package/dist/assets/index.css +1 -1
  10. package/dist/components/Button/Button.d.ts +1 -0
  11. package/dist/components/Button/Button.js +25 -26
  12. package/dist/components/Button/constants.d.ts +1 -2
  13. package/dist/components/Button/constants.js +0 -1
  14. package/dist/components/Input/Input.d.ts +2 -2
  15. package/dist/components/Input/Input.js +16 -17
  16. package/dist/components/InputPassword/InputPassword.js +2 -2
  17. package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
  18. package/dist/components/MergedButton/MergedButton.d.ts +1 -1
  19. package/dist/components/MergedButton/MergedButton.js +19 -17
  20. package/dist/components/OtpInput/OtpInput.js +6 -6
  21. package/dist/components/RadioGroup/RadioGroup.d.ts +2 -18
  22. package/dist/components/RadioGroup/RadioGroup.js +1061 -130
  23. package/dist/components/RadioGroup/index.d.ts +1 -1
  24. package/dist/components/Slider/NavigationButtons/NavigationButtons.js +1 -1
  25. package/dist/components/Slider/NavigationButtons/index.js +1 -1
  26. package/dist/components/Slider/Slider.js +10 -10
  27. package/dist/components/Tag/Tag.d.ts +57 -19
  28. package/dist/components/Tag/Tag.js +84 -39
  29. package/dist/components/Tag/constants.d.ts +37 -5
  30. package/dist/components/Tag/constants.js +53 -13
  31. package/dist/components/Tag/index.d.ts +3 -2
  32. package/dist/components/Tag/index.js +6 -5
  33. package/dist/components/Tag/types.d.ts +6 -0
  34. package/dist/components/index.d.ts +1 -15
  35. package/dist/components/index.js +0 -29
  36. package/dist/hooks/index.d.ts +0 -3
  37. package/dist/hooks/index.js +1 -7
  38. package/dist/icons/Icon.js +1 -1
  39. package/dist/icons/components/index.d.ts +0 -1
  40. package/dist/icons/components/index.js +559 -560
  41. package/dist/{index-Cxiikb7g.js → index-_ACzPKPw.js} +558 -561
  42. package/dist/index.d.ts +0 -1
  43. package/dist/index.js +1 -38
  44. package/package.json +128 -128
  45. package/dist/DatePickerModal-BM0BgzTb.js +0 -204
  46. package/dist/assets/Accordion.css +0 -1
  47. package/dist/assets/AccordionItem.css +0 -1
  48. package/dist/assets/DatePickerModal.css +0 -1
  49. package/dist/assets/Drawer.css +0 -1
  50. package/dist/assets/ListPhotos.css +0 -1
  51. package/dist/assets/SelectSearch.css +0 -1
  52. package/dist/assets/Switch.css +0 -1
  53. package/dist/assets/TabTrail.css +0 -1
  54. package/dist/assets/Tag.css +0 -1
  55. package/dist/assets/Timer.css +0 -1
  56. package/dist/assets/Uploader.css +0 -1
  57. package/dist/assets/UploaderPhotos.css +0 -1
  58. package/dist/bugs-CSBdWk0R.js +0 -18
  59. package/dist/components/Accordion/Accordion.d.ts +0 -10
  60. package/dist/components/Accordion/Accordion.js +0 -176
  61. package/dist/components/Accordion/AccordionItem/AccordionItem.d.ts +0 -8
  62. package/dist/components/Accordion/AccordionItem/AccordionItem.js +0 -16
  63. package/dist/components/Accordion/AccordionItem/index.d.ts +0 -1
  64. package/dist/components/Accordion/AccordionItem/index.js +0 -4
  65. package/dist/components/Accordion/constants.d.ts +0 -8
  66. package/dist/components/Accordion/constants.js +0 -14
  67. package/dist/components/Accordion/index.d.ts +0 -3
  68. package/dist/components/Accordion/index.js +0 -8
  69. package/dist/components/DatePicker/DatePicker.d.ts +0 -44
  70. package/dist/components/DatePicker/DatePicker.js +0 -69
  71. package/dist/components/DatePicker/DatePickerModal.d.ts +0 -8
  72. package/dist/components/DatePicker/DatePickerModal.js +0 -9
  73. package/dist/components/DatePicker/constants.d.ts +0 -6
  74. package/dist/components/DatePicker/constants.js +0 -11
  75. package/dist/components/DatePicker/index.d.ts +0 -2
  76. package/dist/components/DatePicker/index.js +0 -4
  77. package/dist/components/Drawer/Drawer.d.ts +0 -38
  78. package/dist/components/Drawer/Drawer.js +0 -144
  79. package/dist/components/Drawer/constants.d.ts +0 -5
  80. package/dist/components/Drawer/constants.js +0 -9
  81. package/dist/components/Drawer/index.d.ts +0 -2
  82. package/dist/components/Drawer/index.js +0 -6
  83. package/dist/components/ListPhotos/ListPhotos.d.ts +0 -23
  84. package/dist/components/ListPhotos/ListPhotos.js +0 -33
  85. package/dist/components/ListPhotos/constants.d.ts +0 -3
  86. package/dist/components/ListPhotos/constants.js +0 -21
  87. package/dist/components/ListPhotos/index.d.ts +0 -2
  88. package/dist/components/ListPhotos/index.js +0 -4
  89. package/dist/components/Portal/Portal.d.ts +0 -7
  90. package/dist/components/Portal/Portal.js +0 -10
  91. package/dist/components/Portal/index.d.ts +0 -1
  92. package/dist/components/Portal/index.js +0 -4
  93. package/dist/components/SelectSearch/SelectSearch.d.ts +0 -15
  94. package/dist/components/SelectSearch/SelectSearch.js +0 -3876
  95. package/dist/components/SelectSearch/constants.d.ts +0 -4
  96. package/dist/components/SelectSearch/constants.js +0 -8
  97. package/dist/components/SelectSearch/index.d.ts +0 -2
  98. package/dist/components/SelectSearch/index.js +0 -6
  99. package/dist/components/Switch/Switch.d.ts +0 -294
  100. package/dist/components/Switch/Switch.js +0 -59
  101. package/dist/components/Switch/index.d.ts +0 -2
  102. package/dist/components/Switch/index.js +0 -4
  103. package/dist/components/TabTrail/TabButtons/TabButtons.d.ts +0 -8
  104. package/dist/components/TabTrail/TabButtons/TabButtons.js +0 -29
  105. package/dist/components/TabTrail/TabButtons/constants.d.ts +0 -8
  106. package/dist/components/TabTrail/TabButtons/constants.js +0 -14
  107. package/dist/components/TabTrail/TabButtons/index.d.ts +0 -1
  108. package/dist/components/TabTrail/TabButtons/index.js +0 -4
  109. package/dist/components/TabTrail/TabTrail.d.ts +0 -11
  110. package/dist/components/TabTrail/TabTrail.js +0 -282
  111. package/dist/components/TabTrail/constants.d.ts +0 -4
  112. package/dist/components/TabTrail/constants.js +0 -8
  113. package/dist/components/TabTrail/index.d.ts +0 -2
  114. package/dist/components/TabTrail/index.js +0 -6
  115. package/dist/components/Timer/Timer.d.ts +0 -24
  116. package/dist/components/Timer/Timer.js +0 -29
  117. package/dist/components/Timer/index.d.ts +0 -1
  118. package/dist/components/Timer/index.js +0 -4
  119. package/dist/components/Uploader/Uploader.d.ts +0 -30
  120. package/dist/components/Uploader/Uploader.js +0 -90
  121. package/dist/components/Uploader/constants.d.ts +0 -5
  122. package/dist/components/Uploader/constants.js +0 -16
  123. package/dist/components/Uploader/index.d.ts +0 -2
  124. package/dist/components/Uploader/index.js +0 -4
  125. package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +0 -29
  126. package/dist/components/UploaderPhotos/UploaderPhotos.js +0 -46
  127. package/dist/components/UploaderPhotos/index.d.ts +0 -2
  128. package/dist/components/UploaderPhotos/index.js +0 -4
  129. package/dist/focus-management-1rQPII7Z.js +0 -77
  130. package/dist/hidden-BuVoeHNy.js +0 -13
  131. package/dist/hooks/useClickOutside/index.d.ts +0 -1
  132. package/dist/hooks/useClickOutside/index.js +0 -4
  133. package/dist/hooks/useClickOutside/useClickOutside.d.ts +0 -7
  134. package/dist/hooks/useClickOutside/useClickOutside.js +0 -25
  135. package/dist/hooks/useInterval/index.d.ts +0 -1
  136. package/dist/hooks/useInterval/index.js +0 -4
  137. package/dist/hooks/useInterval/useInterval.d.ts +0 -1
  138. package/dist/hooks/useInterval/useInterval.js +0 -17
  139. package/dist/hooks/useLockBodyScroll/index.d.ts +0 -1
  140. package/dist/hooks/useLockBodyScroll/index.js +0 -4
  141. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +0 -6
  142. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.js +0 -20
  143. package/dist/hooks/useTimer/index.d.ts +0 -18
  144. package/dist/hooks/useTimer/index.js +0 -83
  145. package/dist/hooks/useTimer/useTimer.d.ts +0 -18
  146. package/dist/hooks/useTimer/useTimer.js +0 -87
  147. package/dist/hooks/useTimer/utils.d.ts +0 -24
  148. package/dist/hooks/useTimer/utils.js +0 -88
  149. package/dist/icons/components/12px/Close12px.d.ts +0 -4
  150. package/dist/icons/components/12px/Close12px.js +0 -18
  151. package/dist/keyboard-B256ZoM-.js +0 -745
  152. package/dist/label-C_5Syaoj.js +0 -159
  153. package/dist/open-closed-CbXq00et.js +0 -93
  154. package/dist/use-active-press-B6yeSopF.js +0 -31
  155. package/dist/use-by-comparator-BUO78DGe.js +0 -16
  156. package/dist/use-resolve-button-type-B6LE6gU3.js +0 -19
  157. package/dist/utils/UUID4.d.ts +0 -1
  158. package/dist/utils/UUID4.js +0 -9
  159. package/dist/utils/formating/Date.d.ts +0 -1
  160. package/dist/utils/formating/Date.js +0 -26
  161. package/dist/utils/formating/Month.d.ts +0 -8
  162. package/dist/utils/formating/Month.js +0 -80
  163. package/dist/utils/formating/Numbers.d.ts +0 -6
  164. package/dist/utils/formating/Numbers.js +0 -8
  165. package/dist/utils/index.d.ts +0 -11
  166. package/dist/utils/index.js +0 -13
@@ -1,3876 +0,0 @@
1
- import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
- import { c as classNames } from "../../index-CweZ_OcN.js";
3
- import * as React from "react";
4
- import React__default, { useReducer, useMemo, useSyncExternalStore, useId as useId$1, useEffect, useCallback, useRef, useLayoutEffect, createContext, useContext, useState, Fragment, createRef, forwardRef } from "react";
5
- import { ESelectSearchSize } from "./constants.js";
6
- import { useMediaQuery } from "../../hooks/useMediaQuery/useMediaQuery.js";
7
- import { EMediaQuery } from "../../hooks/useMediaQuery/constants.js";
8
- import { Icon } from "../../icons/Icon.js";
9
- import { n as n$2, u as u$3, d as o$1, s as s$3, o as o$2, p as p$1, t as t$3, e as s$4, W as W$1, y as y$3, T, H, M as M$1, a as u$5, $ as $f7dceffc5ad7768b$export$4e328f61c538687f, b as $6179b936705e76d3$export$ae780daf29e6d456, D as D$2, c as o$3 } from "../../keyboard-B256ZoM-.js";
10
- import * as ReactDOM from "react-dom";
11
- import { flushSync, createPortal } from "react-dom";
12
- import { w } from "../../use-active-press-B6yeSopF.js";
13
- import { u as u$4 } from "../../use-by-comparator-BUO78DGe.js";
14
- import { K, a as a$5, l as l$3, T as T$1, z, j as j$1, u as u$6, I as I$1, G } from "../../label-C_5Syaoj.js";
15
- import { A, h as h$1, f as f$6, _ } from "../../focus-management-1rQPII7Z.js";
16
- import { T as T$2 } from "../../use-resolve-button-type-B6LE6gU3.js";
17
- import { c as c$2, i as i$2, u as u$7, V, A as A$1 } from "../../open-closed-CbXq00et.js";
18
- import { r as r$2 } from "../../bugs-CSBdWk0R.js";
19
- import '../../assets/SelectSearch.css';function memo(getDeps, fn, opts) {
20
- let deps = opts.initialDeps ?? [];
21
- let result;
22
- return () => {
23
- var _a, _b, _c, _d;
24
- let depTime;
25
- if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
26
- const newDeps = getDeps();
27
- const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index2) => deps[index2] !== dep);
28
- if (!depsChanged) {
29
- return result;
30
- }
31
- deps = newDeps;
32
- let resultTime;
33
- if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
34
- result = fn(...newDeps);
35
- if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
36
- const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
37
- const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
38
- const resultFpsPercentage = resultEndTime / 16;
39
- const pad = (str, num) => {
40
- str = String(str);
41
- while (str.length < num) {
42
- str = " " + str;
43
- }
44
- return str;
45
- };
46
- console.info(
47
- `%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
48
- `
49
- font-size: .6rem;
50
- font-weight: bold;
51
- color: hsl(${Math.max(
52
- 0,
53
- Math.min(120 - 120 * resultFpsPercentage, 120)
54
- )}deg 100% 31%);`,
55
- opts == null ? void 0 : opts.key
56
- );
57
- }
58
- (_d = opts == null ? void 0 : opts.onChange) == null ? void 0 : _d.call(opts, result);
59
- return result;
60
- };
61
- }
62
- function notUndefined(value, msg) {
63
- if (value === void 0) {
64
- throw new Error(`Unexpected undefined${""}`);
65
- } else {
66
- return value;
67
- }
68
- }
69
- const approxEqual = (a3, b) => Math.abs(a3 - b) < 1;
70
- const debounce = (targetWindow, fn, ms) => {
71
- let timeoutId;
72
- return function(...args) {
73
- targetWindow.clearTimeout(timeoutId);
74
- timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
75
- };
76
- };
77
- const defaultKeyExtractor = (index2) => index2;
78
- const defaultRangeExtractor = (range) => {
79
- const start = Math.max(range.startIndex - range.overscan, 0);
80
- const end = Math.min(range.endIndex + range.overscan, range.count - 1);
81
- const arr = [];
82
- for (let i2 = start; i2 <= end; i2++) {
83
- arr.push(i2);
84
- }
85
- return arr;
86
- };
87
- const observeElementRect = (instance, cb) => {
88
- const element = instance.scrollElement;
89
- if (!element) {
90
- return;
91
- }
92
- const targetWindow = instance.targetWindow;
93
- if (!targetWindow) {
94
- return;
95
- }
96
- const handler = (rect) => {
97
- const { width, height } = rect;
98
- cb({ width: Math.round(width), height: Math.round(height) });
99
- };
100
- handler(element.getBoundingClientRect());
101
- if (!targetWindow.ResizeObserver) {
102
- return () => {
103
- };
104
- }
105
- const observer = new targetWindow.ResizeObserver((entries) => {
106
- const entry = entries[0];
107
- if (entry == null ? void 0 : entry.borderBoxSize) {
108
- const box = entry.borderBoxSize[0];
109
- if (box) {
110
- handler({ width: box.inlineSize, height: box.blockSize });
111
- return;
112
- }
113
- }
114
- handler(element.getBoundingClientRect());
115
- });
116
- observer.observe(element, { box: "border-box" });
117
- return () => {
118
- observer.unobserve(element);
119
- };
120
- };
121
- const addEventListenerOptions = {
122
- passive: true
123
- };
124
- const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
125
- const observeElementOffset = (instance, cb) => {
126
- const element = instance.scrollElement;
127
- if (!element) {
128
- return;
129
- }
130
- const targetWindow = instance.targetWindow;
131
- if (!targetWindow) {
132
- return;
133
- }
134
- let offset2 = 0;
135
- const fallback = supportsScrollend ? () => void 0 : debounce(
136
- targetWindow,
137
- () => {
138
- cb(offset2, false);
139
- },
140
- instance.options.isScrollingResetDelay
141
- );
142
- const createHandler = (isScrolling) => () => {
143
- offset2 = element[instance.options.horizontal ? "scrollLeft" : "scrollTop"];
144
- fallback();
145
- cb(offset2, isScrolling);
146
- };
147
- const handler = createHandler(true);
148
- const endHandler = createHandler(false);
149
- endHandler();
150
- element.addEventListener("scroll", handler, addEventListenerOptions);
151
- element.addEventListener("scrollend", endHandler, addEventListenerOptions);
152
- return () => {
153
- element.removeEventListener("scroll", handler);
154
- element.removeEventListener("scrollend", endHandler);
155
- };
156
- };
157
- const measureElement = (element, entry, instance) => {
158
- if (entry == null ? void 0 : entry.borderBoxSize) {
159
- const box = entry.borderBoxSize[0];
160
- if (box) {
161
- const size2 = Math.round(
162
- box[instance.options.horizontal ? "inlineSize" : "blockSize"]
163
- );
164
- return size2;
165
- }
166
- }
167
- return Math.round(
168
- element.getBoundingClientRect()[instance.options.horizontal ? "width" : "height"]
169
- );
170
- };
171
- const elementScroll = (offset2, {
172
- adjustments = 0,
173
- behavior
174
- }, instance) => {
175
- var _a, _b;
176
- const toOffset = offset2 + adjustments;
177
- (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
178
- [instance.options.horizontal ? "left" : "top"]: toOffset,
179
- behavior
180
- });
181
- };
182
- class Virtualizer {
183
- constructor(opts) {
184
- this.unsubs = [];
185
- this.scrollElement = null;
186
- this.targetWindow = null;
187
- this.isScrolling = false;
188
- this.scrollToIndexTimeoutId = null;
189
- this.measurementsCache = [];
190
- this.itemSizeCache = /* @__PURE__ */ new Map();
191
- this.pendingMeasuredCacheIndexes = [];
192
- this.scrollRect = null;
193
- this.scrollOffset = null;
194
- this.scrollDirection = null;
195
- this.scrollAdjustments = 0;
196
- this.elementsCache = /* @__PURE__ */ new Map();
197
- this.observer = /* @__PURE__ */ (() => {
198
- let _ro = null;
199
- const get = () => {
200
- if (_ro) {
201
- return _ro;
202
- }
203
- if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
204
- return null;
205
- }
206
- return _ro = new this.targetWindow.ResizeObserver((entries) => {
207
- entries.forEach((entry) => {
208
- this._measureElement(entry.target, entry);
209
- });
210
- });
211
- };
212
- return {
213
- disconnect: () => {
214
- var _a;
215
- return (_a = get()) == null ? void 0 : _a.disconnect();
216
- },
217
- observe: (target) => {
218
- var _a;
219
- return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
220
- },
221
- unobserve: (target) => {
222
- var _a;
223
- return (_a = get()) == null ? void 0 : _a.unobserve(target);
224
- }
225
- };
226
- })();
227
- this.range = null;
228
- this.setOptions = (opts2) => {
229
- Object.entries(opts2).forEach(([key, value]) => {
230
- if (typeof value === "undefined") delete opts2[key];
231
- });
232
- this.options = {
233
- debug: false,
234
- initialOffset: 0,
235
- overscan: 1,
236
- paddingStart: 0,
237
- paddingEnd: 0,
238
- scrollPaddingStart: 0,
239
- scrollPaddingEnd: 0,
240
- horizontal: false,
241
- getItemKey: defaultKeyExtractor,
242
- rangeExtractor: defaultRangeExtractor,
243
- onChange: () => {
244
- },
245
- measureElement,
246
- initialRect: { width: 0, height: 0 },
247
- scrollMargin: 0,
248
- gap: 0,
249
- indexAttribute: "data-index",
250
- initialMeasurementsCache: [],
251
- lanes: 1,
252
- isScrollingResetDelay: 150,
253
- enabled: true,
254
- ...opts2
255
- };
256
- };
257
- this.notify = (force, sync) => {
258
- var _a, _b;
259
- const { startIndex, endIndex } = this.range ?? {
260
- startIndex: void 0,
261
- endIndex: void 0
262
- };
263
- const range = this.calculateRange();
264
- if (force || startIndex !== (range == null ? void 0 : range.startIndex) || endIndex !== (range == null ? void 0 : range.endIndex)) {
265
- (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
266
- }
267
- };
268
- this.cleanup = () => {
269
- this.unsubs.filter(Boolean).forEach((d2) => d2());
270
- this.unsubs = [];
271
- this.scrollElement = null;
272
- this.targetWindow = null;
273
- this.observer.disconnect();
274
- this.elementsCache.clear();
275
- };
276
- this._didMount = () => {
277
- return () => {
278
- this.cleanup();
279
- };
280
- };
281
- this._willUpdate = () => {
282
- var _a;
283
- const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
284
- if (this.scrollElement !== scrollElement) {
285
- this.cleanup();
286
- if (!scrollElement) {
287
- this.notify(false, false);
288
- return;
289
- }
290
- this.scrollElement = scrollElement;
291
- if (this.scrollElement && "ownerDocument" in this.scrollElement) {
292
- this.targetWindow = this.scrollElement.ownerDocument.defaultView;
293
- } else {
294
- this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
295
- }
296
- this._scrollToOffset(this.getScrollOffset(), {
297
- adjustments: void 0,
298
- behavior: void 0
299
- });
300
- this.unsubs.push(
301
- this.options.observeElementRect(this, (rect) => {
302
- this.scrollRect = rect;
303
- this.notify(false, false);
304
- })
305
- );
306
- this.unsubs.push(
307
- this.options.observeElementOffset(this, (offset2, isScrolling) => {
308
- this.scrollAdjustments = 0;
309
- this.scrollDirection = isScrolling ? this.getScrollOffset() < offset2 ? "forward" : "backward" : null;
310
- this.scrollOffset = offset2;
311
- const prevIsScrolling = this.isScrolling;
312
- this.isScrolling = isScrolling;
313
- this.notify(prevIsScrolling !== isScrolling, isScrolling);
314
- })
315
- );
316
- }
317
- };
318
- this.getSize = () => {
319
- if (!this.options.enabled) {
320
- this.scrollRect = null;
321
- return 0;
322
- }
323
- this.scrollRect = this.scrollRect ?? this.options.initialRect;
324
- return this.scrollRect[this.options.horizontal ? "width" : "height"];
325
- };
326
- this.getScrollOffset = () => {
327
- if (!this.options.enabled) {
328
- this.scrollOffset = null;
329
- return 0;
330
- }
331
- this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
332
- return this.scrollOffset;
333
- };
334
- this.getFurthestMeasurement = (measurements, index2) => {
335
- const furthestMeasurementsFound = /* @__PURE__ */ new Map();
336
- const furthestMeasurements = /* @__PURE__ */ new Map();
337
- for (let m2 = index2 - 1; m2 >= 0; m2--) {
338
- const measurement = measurements[m2];
339
- if (furthestMeasurementsFound.has(measurement.lane)) {
340
- continue;
341
- }
342
- const previousFurthestMeasurement = furthestMeasurements.get(
343
- measurement.lane
344
- );
345
- if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
346
- furthestMeasurements.set(measurement.lane, measurement);
347
- } else if (measurement.end < previousFurthestMeasurement.end) {
348
- furthestMeasurementsFound.set(measurement.lane, true);
349
- }
350
- if (furthestMeasurementsFound.size === this.options.lanes) {
351
- break;
352
- }
353
- }
354
- return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a3, b) => {
355
- if (a3.end === b.end) {
356
- return a3.index - b.index;
357
- }
358
- return a3.end - b.end;
359
- })[0] : void 0;
360
- };
361
- this.getMeasurementOptions = memo(
362
- () => [
363
- this.options.count,
364
- this.options.paddingStart,
365
- this.options.scrollMargin,
366
- this.options.getItemKey,
367
- this.options.enabled
368
- ],
369
- (count2, paddingStart, scrollMargin, getItemKey, enabled) => {
370
- this.pendingMeasuredCacheIndexes = [];
371
- return {
372
- count: count2,
373
- paddingStart,
374
- scrollMargin,
375
- getItemKey,
376
- enabled
377
- };
378
- },
379
- {
380
- key: false
381
- }
382
- );
383
- this.getMeasurements = memo(
384
- () => [this.getMeasurementOptions(), this.itemSizeCache],
385
- ({ count: count2, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
386
- var _a;
387
- if (!enabled) {
388
- this.measurementsCache = [];
389
- this.itemSizeCache.clear();
390
- return [];
391
- }
392
- if (this.measurementsCache.length === 0) {
393
- this.measurementsCache = this.options.initialMeasurementsCache;
394
- this.measurementsCache.forEach((item) => {
395
- this.itemSizeCache.set(item.key, item.size);
396
- });
397
- }
398
- const min2 = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
399
- this.pendingMeasuredCacheIndexes = [];
400
- const measurements = this.measurementsCache.slice(0, min2);
401
- for (let i2 = min2; i2 < count2; i2++) {
402
- let measureElement2 = (_a = this.measurementsCache[i2]) == null ? void 0 : _a.measureElement;
403
- if (!measureElement2) {
404
- measureElement2 = (node) => {
405
- const key2 = getItemKey(i2);
406
- const prevNode = this.elementsCache.get(key2);
407
- if (!node) {
408
- if (prevNode) {
409
- this.observer.unobserve(prevNode);
410
- this.elementsCache.delete(key2);
411
- }
412
- return;
413
- }
414
- if (prevNode !== node) {
415
- if (prevNode) {
416
- this.observer.unobserve(prevNode);
417
- }
418
- this.observer.observe(node);
419
- this.elementsCache.set(key2, node);
420
- }
421
- if (node.isConnected) {
422
- this.resizeItem(
423
- i2,
424
- this.options.measureElement(node, void 0, this)
425
- );
426
- }
427
- };
428
- }
429
- const key = getItemKey(i2);
430
- const furthestMeasurement = this.options.lanes === 1 ? measurements[i2 - 1] : this.getFurthestMeasurement(measurements, i2);
431
- const start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
432
- const measuredSize = itemSizeCache.get(key);
433
- const size2 = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i2);
434
- const end = start + size2;
435
- const lane = furthestMeasurement ? furthestMeasurement.lane : i2 % this.options.lanes;
436
- measurements[i2] = {
437
- index: i2,
438
- start,
439
- size: size2,
440
- end,
441
- key,
442
- lane,
443
- measureElement: measureElement2
444
- };
445
- }
446
- this.measurementsCache = measurements;
447
- return measurements;
448
- },
449
- {
450
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
451
- debug: () => this.options.debug
452
- }
453
- );
454
- this.calculateRange = memo(
455
- () => [this.getMeasurements(), this.getSize(), this.getScrollOffset()],
456
- (measurements, outerSize, scrollOffset) => {
457
- return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
458
- measurements,
459
- outerSize,
460
- scrollOffset
461
- }) : null;
462
- },
463
- {
464
- key: process.env.NODE_ENV !== "production" && "calculateRange",
465
- debug: () => this.options.debug
466
- }
467
- );
468
- this.getIndexes = memo(
469
- () => [
470
- this.options.rangeExtractor,
471
- this.calculateRange(),
472
- this.options.overscan,
473
- this.options.count
474
- ],
475
- (rangeExtractor, range, overscan, count2) => {
476
- return range === null ? [] : rangeExtractor({
477
- startIndex: range.startIndex,
478
- endIndex: range.endIndex,
479
- overscan,
480
- count: count2
481
- });
482
- },
483
- {
484
- key: process.env.NODE_ENV !== "production" && "getIndexes",
485
- debug: () => this.options.debug
486
- }
487
- );
488
- this.indexFromElement = (node) => {
489
- const attributeName = this.options.indexAttribute;
490
- const indexStr = node.getAttribute(attributeName);
491
- if (!indexStr) {
492
- console.warn(
493
- `Missing attribute name '${attributeName}={index}' on measured element.`
494
- );
495
- return -1;
496
- }
497
- return parseInt(indexStr, 10);
498
- };
499
- this._measureElement = (node, entry) => {
500
- const i2 = this.indexFromElement(node);
501
- const item = this.getMeasurements()[i2];
502
- if (!item || !node.isConnected) {
503
- this.elementsCache.forEach((cached, key) => {
504
- if (cached === node) {
505
- this.observer.unobserve(node);
506
- this.elementsCache.delete(key);
507
- }
508
- });
509
- return;
510
- }
511
- const prevNode = this.elementsCache.get(item.key);
512
- if (prevNode !== node) {
513
- if (prevNode) {
514
- this.observer.unobserve(prevNode);
515
- }
516
- this.observer.observe(node);
517
- this.elementsCache.set(item.key, node);
518
- }
519
- this.resizeItem(i2, this.options.measureElement(node, entry, this));
520
- };
521
- this.resizeItem = (index2, size2) => {
522
- const item = this.getMeasurements()[index2];
523
- if (!item) {
524
- return;
525
- }
526
- const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
527
- const delta = size2 - itemSize;
528
- if (delta !== 0) {
529
- if (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) {
530
- if (process.env.NODE_ENV !== "production" && this.options.debug) {
531
- console.info("correction", delta);
532
- }
533
- this._scrollToOffset(this.getScrollOffset(), {
534
- adjustments: this.scrollAdjustments += delta,
535
- behavior: void 0
536
- });
537
- }
538
- this.pendingMeasuredCacheIndexes.push(item.index);
539
- this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size2));
540
- this.notify(true, false);
541
- }
542
- };
543
- this.measureElement = (node) => {
544
- if (!node) {
545
- return;
546
- }
547
- this._measureElement(node, void 0);
548
- };
549
- this.getVirtualItems = memo(
550
- () => [this.getIndexes(), this.getMeasurements()],
551
- (indexes, measurements) => {
552
- const virtualItems = [];
553
- for (let k = 0, len = indexes.length; k < len; k++) {
554
- const i2 = indexes[k];
555
- const measurement = measurements[i2];
556
- virtualItems.push(measurement);
557
- }
558
- return virtualItems;
559
- },
560
- {
561
- key: process.env.NODE_ENV !== "production" && "getIndexes",
562
- debug: () => this.options.debug
563
- }
564
- );
565
- this.getVirtualItemForOffset = (offset2) => {
566
- const measurements = this.getMeasurements();
567
- if (measurements.length === 0) {
568
- return void 0;
569
- }
570
- return notUndefined(
571
- measurements[findNearestBinarySearch(
572
- 0,
573
- measurements.length - 1,
574
- (index2) => notUndefined(measurements[index2]).start,
575
- offset2
576
- )]
577
- );
578
- };
579
- this.getOffsetForAlignment = (toOffset, align) => {
580
- const size2 = this.getSize();
581
- const scrollOffset = this.getScrollOffset();
582
- if (align === "auto") {
583
- if (toOffset <= scrollOffset) {
584
- align = "start";
585
- } else if (toOffset >= scrollOffset + size2) {
586
- align = "end";
587
- } else {
588
- align = "start";
589
- }
590
- }
591
- if (align === "start") {
592
- toOffset = toOffset;
593
- } else if (align === "end") {
594
- toOffset = toOffset - size2;
595
- } else if (align === "center") {
596
- toOffset = toOffset - size2 / 2;
597
- }
598
- const scrollSizeProp = this.options.horizontal ? "scrollWidth" : "scrollHeight";
599
- const scrollSize = this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[scrollSizeProp] : this.scrollElement[scrollSizeProp] : 0;
600
- const maxOffset = scrollSize - size2;
601
- return Math.max(Math.min(maxOffset, toOffset), 0);
602
- };
603
- this.getOffsetForIndex = (index2, align = "auto") => {
604
- index2 = Math.max(0, Math.min(index2, this.options.count - 1));
605
- const item = this.getMeasurements()[index2];
606
- if (!item) {
607
- return void 0;
608
- }
609
- const size2 = this.getSize();
610
- const scrollOffset = this.getScrollOffset();
611
- if (align === "auto") {
612
- if (item.end >= scrollOffset + size2 - this.options.scrollPaddingEnd) {
613
- align = "end";
614
- } else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
615
- align = "start";
616
- } else {
617
- return [scrollOffset, align];
618
- }
619
- }
620
- const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
621
- return [this.getOffsetForAlignment(toOffset, align), align];
622
- };
623
- this.isDynamicMode = () => this.elementsCache.size > 0;
624
- this.cancelScrollToIndex = () => {
625
- if (this.scrollToIndexTimeoutId !== null && this.targetWindow) {
626
- this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId);
627
- this.scrollToIndexTimeoutId = null;
628
- }
629
- };
630
- this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
631
- this.cancelScrollToIndex();
632
- if (behavior === "smooth" && this.isDynamicMode()) {
633
- console.warn(
634
- "The `smooth` scroll behavior is not fully supported with dynamic size."
635
- );
636
- }
637
- this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
638
- adjustments: void 0,
639
- behavior
640
- });
641
- };
642
- this.scrollToIndex = (index2, { align: initialAlign = "auto", behavior } = {}) => {
643
- index2 = Math.max(0, Math.min(index2, this.options.count - 1));
644
- this.cancelScrollToIndex();
645
- if (behavior === "smooth" && this.isDynamicMode()) {
646
- console.warn(
647
- "The `smooth` scroll behavior is not fully supported with dynamic size."
648
- );
649
- }
650
- const offsetAndAlign = this.getOffsetForIndex(index2, initialAlign);
651
- if (!offsetAndAlign) return;
652
- const [offset2, align] = offsetAndAlign;
653
- this._scrollToOffset(offset2, { adjustments: void 0, behavior });
654
- if (behavior !== "smooth" && this.isDynamicMode() && this.targetWindow) {
655
- this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
656
- this.scrollToIndexTimeoutId = null;
657
- const elementInDOM = this.elementsCache.has(
658
- this.options.getItemKey(index2)
659
- );
660
- if (elementInDOM) {
661
- const [latestOffset] = notUndefined(
662
- this.getOffsetForIndex(index2, align)
663
- );
664
- if (!approxEqual(latestOffset, this.getScrollOffset())) {
665
- this.scrollToIndex(index2, { align, behavior });
666
- }
667
- } else {
668
- this.scrollToIndex(index2, { align, behavior });
669
- }
670
- });
671
- }
672
- };
673
- this.scrollBy = (delta, { behavior } = {}) => {
674
- this.cancelScrollToIndex();
675
- if (behavior === "smooth" && this.isDynamicMode()) {
676
- console.warn(
677
- "The `smooth` scroll behavior is not fully supported with dynamic size."
678
- );
679
- }
680
- this._scrollToOffset(this.getScrollOffset() + delta, {
681
- adjustments: void 0,
682
- behavior
683
- });
684
- };
685
- this.getTotalSize = () => {
686
- var _a;
687
- const measurements = this.getMeasurements();
688
- let end;
689
- if (measurements.length === 0) {
690
- end = this.options.paddingStart;
691
- } else {
692
- end = this.options.lanes === 1 ? ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0 : Math.max(
693
- ...measurements.slice(-this.options.lanes).map((m2) => m2.end)
694
- );
695
- }
696
- return end - this.options.scrollMargin + this.options.paddingEnd;
697
- };
698
- this._scrollToOffset = (offset2, {
699
- adjustments,
700
- behavior
701
- }) => {
702
- this.options.scrollToFn(offset2, { behavior, adjustments }, this);
703
- };
704
- this.measure = () => {
705
- var _a, _b;
706
- this.itemSizeCache = /* @__PURE__ */ new Map();
707
- (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, false);
708
- };
709
- this.setOptions(opts);
710
- }
711
- }
712
- const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
713
- while (low <= high) {
714
- const middle = (low + high) / 2 | 0;
715
- const currentValue = getCurrentValue(middle);
716
- if (currentValue < value) {
717
- low = middle + 1;
718
- } else if (currentValue > value) {
719
- high = middle - 1;
720
- } else {
721
- return middle;
722
- }
723
- }
724
- if (low > 0) {
725
- return low - 1;
726
- } else {
727
- return 0;
728
- }
729
- };
730
- function calculateRange({
731
- measurements,
732
- outerSize,
733
- scrollOffset
734
- }) {
735
- const count2 = measurements.length - 1;
736
- const getOffset = (index2) => measurements[index2].start;
737
- const startIndex = findNearestBinarySearch(0, count2, getOffset, scrollOffset);
738
- let endIndex = startIndex;
739
- while (endIndex < count2 && measurements[endIndex].end < scrollOffset + outerSize) {
740
- endIndex++;
741
- }
742
- return { startIndex, endIndex };
743
- }
744
- const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
745
- function useVirtualizerBase(options2) {
746
- const rerender = React.useReducer(() => ({}), {})[1];
747
- const resolvedOptions = {
748
- ...options2,
749
- onChange: (instance2, sync) => {
750
- var _a;
751
- if (sync) {
752
- flushSync(rerender);
753
- } else {
754
- rerender();
755
- }
756
- (_a = options2.onChange) == null ? void 0 : _a.call(options2, instance2, sync);
757
- }
758
- };
759
- const [instance] = React.useState(
760
- () => new Virtualizer(resolvedOptions)
761
- );
762
- instance.setOptions(resolvedOptions);
763
- React.useEffect(() => {
764
- return instance._didMount();
765
- }, []);
766
- useIsomorphicLayoutEffect(() => {
767
- return instance._willUpdate();
768
- });
769
- return instance;
770
- }
771
- function useVirtualizer(options2) {
772
- return useVirtualizerBase({
773
- observeElementRect,
774
- observeElementOffset,
775
- scrollToFn: elementScroll,
776
- ...options2
777
- });
778
- }
779
- function s$2(e2) {
780
- if (e2 === null) return { width: 0, height: 0 };
781
- let { width: n2, height: t2 } = e2.getBoundingClientRect();
782
- return { width: n2, height: t2 };
783
- }
784
- function f$5(e2, n2 = false) {
785
- let t2 = e2 === null ? null : "current" in e2 ? e2.current : e2, [l2, u2] = useReducer(() => ({}), {}), r2 = useMemo(() => s$2(t2), [t2, l2]);
786
- return n$2(() => {
787
- if (!t2) return;
788
- let i2 = new ResizeObserver(u2);
789
- return i2.observe(t2), () => {
790
- i2.disconnect();
791
- };
792
- }, [t2]), n2 ? { width: `${r2.width}px`, height: `${r2.height}px` } : r2;
793
- }
794
- let a$4 = class a extends Map {
795
- constructor(t2) {
796
- super();
797
- this.factory = t2;
798
- }
799
- get(t2) {
800
- let e2 = super.get(t2);
801
- return e2 === void 0 && (e2 = this.factory(t2), this.set(t2, e2)), e2;
802
- }
803
- };
804
- function a$3(o2, r2) {
805
- let t2 = o2(), n2 = /* @__PURE__ */ new Set();
806
- return { getSnapshot() {
807
- return t2;
808
- }, subscribe(e2) {
809
- return n2.add(e2), () => n2.delete(e2);
810
- }, dispatch(e2, ...s2) {
811
- let i2 = r2[e2].call(t2, ...s2);
812
- i2 && (t2 = i2, n2.forEach((c2) => c2()));
813
- } };
814
- }
815
- function o(t2) {
816
- return useSyncExternalStore(t2.subscribe, t2.getSnapshot, t2.getSnapshot);
817
- }
818
- let p = new a$4(() => a$3(() => [], { ADD(r2) {
819
- return this.includes(r2) ? this : [...this, r2];
820
- }, REMOVE(r2) {
821
- let e2 = this.indexOf(r2);
822
- if (e2 === -1) return this;
823
- let t2 = this.slice();
824
- return t2.splice(e2, 1), t2;
825
- } }));
826
- function x(r2, e2) {
827
- let t2 = p.get(e2), i2 = useId$1(), h2 = o(t2);
828
- if (n$2(() => {
829
- if (r2) return t2.dispatch("ADD", i2), () => t2.dispatch("REMOVE", i2);
830
- }, [t2, r2]), !r2) return false;
831
- let s2 = h2.indexOf(i2), o$12 = h2.length;
832
- return s2 === -1 && (s2 = o$12, o$12 += 1), s2 === o$12 - 1;
833
- }
834
- let f$4 = /* @__PURE__ */ new Map(), u$2 = /* @__PURE__ */ new Map();
835
- function h(t2) {
836
- var e2;
837
- let r2 = (e2 = u$2.get(t2)) != null ? e2 : 0;
838
- return u$2.set(t2, r2 + 1), r2 !== 0 ? () => m$3(t2) : (f$4.set(t2, { "aria-hidden": t2.getAttribute("aria-hidden"), inert: t2.inert }), t2.setAttribute("aria-hidden", "true"), t2.inert = true, () => m$3(t2));
839
- }
840
- function m$3(t2) {
841
- var i2;
842
- let r2 = (i2 = u$2.get(t2)) != null ? i2 : 1;
843
- if (r2 === 1 ? u$2.delete(t2) : u$2.set(t2, r2 - 1), r2 !== 1) return;
844
- let e2 = f$4.get(t2);
845
- e2 && (e2["aria-hidden"] === null ? t2.removeAttribute("aria-hidden") : t2.setAttribute("aria-hidden", e2["aria-hidden"]), t2.inert = e2.inert, f$4.delete(t2));
846
- }
847
- function y$2(t2, { allowed: r2, disallowed: e2 } = {}) {
848
- let i2 = x(t2, "inert-others");
849
- n$2(() => {
850
- var d2, c2;
851
- if (!i2) return;
852
- let a3 = o$1();
853
- for (let n2 of (d2 = e2 == null ? void 0 : e2()) != null ? d2 : []) n2 && a3.add(h(n2));
854
- let s2 = (c2 = r2 == null ? void 0 : r2()) != null ? c2 : [];
855
- for (let n2 of s2) {
856
- if (!n2) continue;
857
- let l2 = u$3(n2);
858
- if (!l2) continue;
859
- let o2 = n2.parentElement;
860
- for (; o2 && o2 !== l2.body; ) {
861
- for (let p2 of o2.children) s2.some((E2) => p2.contains(E2)) || a3.add(h(p2));
862
- o2 = o2.parentElement;
863
- }
864
- }
865
- return a3.dispose;
866
- }, [i2, r2, e2]);
867
- }
868
- function m$2(s2, n2, l2) {
869
- let i2 = s$3((t2) => {
870
- let e2 = t2.getBoundingClientRect();
871
- e2.x === 0 && e2.y === 0 && e2.width === 0 && e2.height === 0 && l2();
872
- });
873
- useEffect(() => {
874
- if (!s2) return;
875
- let t2 = n2 === null ? null : n2 instanceof HTMLElement ? n2 : n2.current;
876
- if (!t2) return;
877
- let e2 = o$1();
878
- if (typeof ResizeObserver != "undefined") {
879
- let r2 = new ResizeObserver(() => i2.current(t2));
880
- r2.observe(t2), e2.add(() => r2.disconnect());
881
- }
882
- if (typeof IntersectionObserver != "undefined") {
883
- let r2 = new IntersectionObserver(() => i2.current(t2));
884
- r2.observe(t2), e2.add(() => r2.disconnect());
885
- }
886
- return () => e2.dispose();
887
- }, [n2, i2, s2]);
888
- }
889
- function t$2() {
890
- return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
891
- }
892
- function i$1() {
893
- return /Android/gi.test(window.navigator.userAgent);
894
- }
895
- function n$1() {
896
- return t$2() || i$1();
897
- }
898
- function i(t2, e2, o2, n2) {
899
- let u2 = s$3(o2);
900
- useEffect(() => {
901
- if (!t2) return;
902
- function r2(m2) {
903
- u2.current(m2);
904
- }
905
- return document.addEventListener(e2, r2, n2), () => document.removeEventListener(e2, r2, n2);
906
- }, [t2, e2, n2]);
907
- }
908
- function s$1(t2, e2, o2, n2) {
909
- let i2 = s$3(o2);
910
- useEffect(() => {
911
- if (!t2) return;
912
- function r2(d2) {
913
- i2.current(d2);
914
- }
915
- return window.addEventListener(e2, r2, n2), () => window.removeEventListener(e2, r2, n2);
916
- }, [t2, e2, n2]);
917
- }
918
- const d$2 = 30;
919
- function F$1(E2, p2, C) {
920
- let u2 = x(E2, "outside-click"), f2 = s$3(C), s2 = useCallback(function(e2, o2) {
921
- if (e2.defaultPrevented) return;
922
- let r2 = o2(e2);
923
- if (r2 === null || !r2.getRootNode().contains(r2) || !r2.isConnected) return;
924
- let T2 = function i2(n2) {
925
- return typeof n2 == "function" ? i2(n2()) : Array.isArray(n2) || n2 instanceof Set ? n2 : [n2];
926
- }(p2);
927
- for (let i2 of T2) {
928
- if (i2 === null) continue;
929
- let n2 = i2 instanceof HTMLElement ? i2 : i2.current;
930
- if (n2 != null && n2.contains(r2) || e2.composed && e2.composedPath().includes(n2)) return;
931
- }
932
- return !A(r2, h$1.Loose) && r2.tabIndex !== -1 && e2.preventDefault(), f2.current(e2, r2);
933
- }, [f2]), l2 = useRef(null);
934
- i(u2, "pointerdown", (t2) => {
935
- var e2, o2;
936
- l2.current = ((o2 = (e2 = t2.composedPath) == null ? void 0 : e2.call(t2)) == null ? void 0 : o2[0]) || t2.target;
937
- }, true), i(u2, "mousedown", (t2) => {
938
- var e2, o2;
939
- l2.current = ((o2 = (e2 = t2.composedPath) == null ? void 0 : e2.call(t2)) == null ? void 0 : o2[0]) || t2.target;
940
- }, true), i(u2, "click", (t2) => {
941
- n$1() || l2.current && (s2(t2, () => l2.current), l2.current = null);
942
- }, true);
943
- let a3 = useRef({ x: 0, y: 0 });
944
- i(u2, "touchstart", (t2) => {
945
- a3.current.x = t2.touches[0].clientX, a3.current.y = t2.touches[0].clientY;
946
- }, true), i(u2, "touchend", (t2) => {
947
- let e2 = { x: t2.changedTouches[0].clientX, y: t2.changedTouches[0].clientY };
948
- if (!(Math.abs(e2.x - a3.current.x) >= d$2 || Math.abs(e2.y - a3.current.y) >= d$2)) return s2(t2, () => t2.target instanceof HTMLElement ? t2.target : null);
949
- }, true), s$1(u2, "blur", (t2) => s2(t2, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), true);
950
- }
951
- function n(...e2) {
952
- return useMemo(() => u$3(...e2), [...e2]);
953
- }
954
- function E(n2, e2, a3, t2) {
955
- let i2 = s$3(a3);
956
- useEffect(() => {
957
- n2 = n2 != null ? n2 : window;
958
- function r2(o2) {
959
- i2.current(o2);
960
- }
961
- return n2.addEventListener(e2, r2, t2), () => n2.removeEventListener(e2, r2, t2);
962
- }, [n2, e2, t2]);
963
- }
964
- function f$3(l2) {
965
- let n2 = useRef({ value: "", selectionStart: null, selectionEnd: null });
966
- return E(l2.current, "blur", (e2) => {
967
- let t2 = e2.target;
968
- t2 instanceof HTMLInputElement && (n2.current = { value: t2.value, selectionStart: t2.selectionStart, selectionEnd: t2.selectionEnd });
969
- }), o$2(() => {
970
- let e2 = l2.current;
971
- if (document.activeElement !== e2 && e2 instanceof HTMLInputElement && e2.isConnected) {
972
- if (e2.focus({ preventScroll: true }), e2.value !== n2.current.value) e2.setSelectionRange(e2.value.length, e2.value.length);
973
- else {
974
- let { selectionStart: t2, selectionEnd: u2 } = n2.current;
975
- t2 !== null && u2 !== null && e2.setSelectionRange(t2, u2);
976
- }
977
- n2.current = { value: "", selectionStart: null, selectionEnd: null };
978
- }
979
- });
980
- }
981
- function d$1() {
982
- let r2;
983
- return { before({ doc: e2 }) {
984
- var l2;
985
- let o2 = e2.documentElement, t2 = (l2 = e2.defaultView) != null ? l2 : window;
986
- r2 = Math.max(0, t2.innerWidth - o2.clientWidth);
987
- }, after({ doc: e2, d: o2 }) {
988
- let t2 = e2.documentElement, l2 = Math.max(0, t2.clientWidth - t2.offsetWidth), n2 = Math.max(0, r2 - l2);
989
- o2.style(t2, "paddingRight", `${n2}px`);
990
- } };
991
- }
992
- function d() {
993
- return t$2() ? { before({ doc: r2, d: n2, meta: c2 }) {
994
- function o2(a3) {
995
- return c2.containers.flatMap((l2) => l2()).some((l2) => l2.contains(a3));
996
- }
997
- n2.microTask(() => {
998
- var s2;
999
- if (window.getComputedStyle(r2.documentElement).scrollBehavior !== "auto") {
1000
- let t2 = o$1();
1001
- t2.style(r2.documentElement, "scrollBehavior", "auto"), n2.add(() => n2.microTask(() => t2.dispose()));
1002
- }
1003
- let a3 = (s2 = window.scrollY) != null ? s2 : window.pageYOffset, l2 = null;
1004
- n2.addEventListener(r2, "click", (t2) => {
1005
- if (t2.target instanceof HTMLElement) try {
1006
- let e2 = t2.target.closest("a");
1007
- if (!e2) return;
1008
- let { hash: f2 } = new URL(e2.href), i2 = r2.querySelector(f2);
1009
- i2 && !o2(i2) && (l2 = i2);
1010
- } catch {
1011
- }
1012
- }, true), n2.addEventListener(r2, "touchstart", (t2) => {
1013
- if (t2.target instanceof HTMLElement) if (o2(t2.target)) {
1014
- let e2 = t2.target;
1015
- for (; e2.parentElement && o2(e2.parentElement); ) e2 = e2.parentElement;
1016
- n2.style(e2, "overscrollBehavior", "contain");
1017
- } else n2.style(t2.target, "touchAction", "none");
1018
- }), n2.addEventListener(r2, "touchmove", (t2) => {
1019
- if (t2.target instanceof HTMLElement) {
1020
- if (t2.target.tagName === "INPUT") return;
1021
- if (o2(t2.target)) {
1022
- let e2 = t2.target;
1023
- for (; e2.parentElement && e2.dataset.headlessuiPortal !== "" && !(e2.scrollHeight > e2.clientHeight || e2.scrollWidth > e2.clientWidth); ) e2 = e2.parentElement;
1024
- e2.dataset.headlessuiPortal === "" && t2.preventDefault();
1025
- } else t2.preventDefault();
1026
- }
1027
- }, { passive: false }), n2.add(() => {
1028
- var e2;
1029
- let t2 = (e2 = window.scrollY) != null ? e2 : window.pageYOffset;
1030
- a3 !== t2 && window.scrollTo(0, a3), l2 && l2.isConnected && (l2.scrollIntoView({ block: "nearest" }), l2 = null);
1031
- });
1032
- });
1033
- } } : {};
1034
- }
1035
- function r$1() {
1036
- return { before({ doc: e2, d: o2 }) {
1037
- o2.style(e2.documentElement, "overflow", "hidden");
1038
- } };
1039
- }
1040
- function m$1(e2) {
1041
- let n2 = {};
1042
- for (let t2 of e2) Object.assign(n2, t2(n2));
1043
- return n2;
1044
- }
1045
- let a$2 = a$3(() => /* @__PURE__ */ new Map(), { PUSH(e2, n2) {
1046
- var o2;
1047
- let t2 = (o2 = this.get(e2)) != null ? o2 : { doc: e2, count: 0, d: o$1(), meta: /* @__PURE__ */ new Set() };
1048
- return t2.count++, t2.meta.add(n2), this.set(e2, t2), this;
1049
- }, POP(e2, n2) {
1050
- let t2 = this.get(e2);
1051
- return t2 && (t2.count--, t2.meta.delete(n2)), this;
1052
- }, SCROLL_PREVENT({ doc: e2, d: n2, meta: t2 }) {
1053
- let o2 = { doc: e2, d: n2, meta: m$1(t2) }, c2 = [d(), d$1(), r$1()];
1054
- c2.forEach(({ before: r2 }) => r2 == null ? void 0 : r2(o2)), c2.forEach(({ after: r2 }) => r2 == null ? void 0 : r2(o2));
1055
- }, SCROLL_ALLOW({ d: e2 }) {
1056
- e2.dispose();
1057
- }, TEARDOWN({ doc: e2 }) {
1058
- this.delete(e2);
1059
- } });
1060
- a$2.subscribe(() => {
1061
- let e2 = a$2.getSnapshot(), n2 = /* @__PURE__ */ new Map();
1062
- for (let [t2] of e2) n2.set(t2, t2.documentElement.style.overflow);
1063
- for (let t2 of e2.values()) {
1064
- let o2 = n2.get(t2.doc) === "hidden", c2 = t2.count !== 0;
1065
- (c2 && !o2 || !c2 && o2) && a$2.dispatch(t2.count > 0 ? "SCROLL_PREVENT" : "SCROLL_ALLOW", t2), t2.count === 0 && a$2.dispatch("TEARDOWN", t2);
1066
- }
1067
- });
1068
- function a$1(r2, e2, n2 = () => ({ containers: [] })) {
1069
- let f2 = o(a$2), o$12 = e2 ? f2.get(e2) : void 0, i2 = o$12 ? o$12.count > 0 : false;
1070
- return n$2(() => {
1071
- if (!(!e2 || !r2)) return a$2.dispatch("PUSH", e2, n2), () => a$2.dispatch("POP", e2, n2);
1072
- }, [r2, e2]), i2;
1073
- }
1074
- function f$2(e2, c2, n2 = () => [document.body]) {
1075
- let r2 = x(e2, "scroll-lock");
1076
- a$1(r2, c2, (t2) => {
1077
- var o2;
1078
- return { containers: [...(o2 = t2.containers) != null ? o2 : [], n2] };
1079
- });
1080
- }
1081
- function t$1(e2) {
1082
- return [e2.screenX, e2.screenY];
1083
- }
1084
- function u$1() {
1085
- let e2 = useRef([-1, -1]);
1086
- return { wasMoved(r2) {
1087
- let n2 = t$1(r2);
1088
- return e2.current[0] === n2[0] && e2.current[1] === n2[1] ? false : (e2.current = n2, true);
1089
- }, update(r2) {
1090
- e2.current = t$1(r2);
1091
- } };
1092
- }
1093
- function F(c2, { container: e2, accept: t2, walk: r2 }) {
1094
- let o2 = useRef(t2), l2 = useRef(r2);
1095
- useEffect(() => {
1096
- o2.current = t2, l2.current = r2;
1097
- }, [t2, r2]), n$2(() => {
1098
- if (!e2 || !c2) return;
1099
- let n2 = u$3(e2);
1100
- if (!n2) return;
1101
- let f2 = o2.current, p2 = l2.current, i2 = Object.assign((m2) => f2(m2), { acceptNode: f2 }), u2 = n2.createTreeWalker(e2, NodeFilter.SHOW_ELEMENT, i2, false);
1102
- for (; u2.nextNode(); ) p2(u2.currentNode);
1103
- }, [e2, c2, o2, l2]);
1104
- }
1105
- function m(u2, t2) {
1106
- let e2 = useRef([]), r2 = o$2(u2);
1107
- useEffect(() => {
1108
- let o2 = [...e2.current];
1109
- for (let [a3, l2] of t2.entries()) if (e2.current[a3] !== l2) {
1110
- let n2 = r2(t2, o2);
1111
- return e2.current = t2, n2;
1112
- }
1113
- }, [r2, ...t2]);
1114
- }
1115
- function getNodeName(node) {
1116
- if (isNode(node)) {
1117
- return (node.nodeName || "").toLowerCase();
1118
- }
1119
- return "#document";
1120
- }
1121
- function getWindow(node) {
1122
- var _node$ownerDocument;
1123
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1124
- }
1125
- function getDocumentElement(node) {
1126
- var _ref;
1127
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1128
- }
1129
- function isNode(value) {
1130
- return value instanceof Node || value instanceof getWindow(value).Node;
1131
- }
1132
- function isElement(value) {
1133
- return value instanceof Element || value instanceof getWindow(value).Element;
1134
- }
1135
- function isHTMLElement(value) {
1136
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1137
- }
1138
- function isShadowRoot(value) {
1139
- if (typeof ShadowRoot === "undefined") {
1140
- return false;
1141
- }
1142
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1143
- }
1144
- function isOverflowElement(element) {
1145
- const {
1146
- overflow,
1147
- overflowX,
1148
- overflowY,
1149
- display
1150
- } = getComputedStyle$1(element);
1151
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
1152
- }
1153
- function isTableElement(element) {
1154
- return ["table", "td", "th"].includes(getNodeName(element));
1155
- }
1156
- function isTopLayer(element) {
1157
- return [":popover-open", ":modal"].some((selector) => {
1158
- try {
1159
- return element.matches(selector);
1160
- } catch (e2) {
1161
- return false;
1162
- }
1163
- });
1164
- }
1165
- function isContainingBlock(element) {
1166
- const webkit = isWebKit();
1167
- const css = getComputedStyle$1(element);
1168
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
1169
- }
1170
- function getContainingBlock(element) {
1171
- let currentNode = getParentNode(element);
1172
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1173
- if (isTopLayer(currentNode)) {
1174
- return null;
1175
- }
1176
- if (isContainingBlock(currentNode)) {
1177
- return currentNode;
1178
- }
1179
- currentNode = getParentNode(currentNode);
1180
- }
1181
- return null;
1182
- }
1183
- function isWebKit() {
1184
- if (typeof CSS === "undefined" || !CSS.supports) return false;
1185
- return CSS.supports("-webkit-backdrop-filter", "none");
1186
- }
1187
- function isLastTraversableNode(node) {
1188
- return ["html", "body", "#document"].includes(getNodeName(node));
1189
- }
1190
- function getComputedStyle$1(element) {
1191
- return getWindow(element).getComputedStyle(element);
1192
- }
1193
- function getNodeScroll(element) {
1194
- if (isElement(element)) {
1195
- return {
1196
- scrollLeft: element.scrollLeft,
1197
- scrollTop: element.scrollTop
1198
- };
1199
- }
1200
- return {
1201
- scrollLeft: element.scrollX,
1202
- scrollTop: element.scrollY
1203
- };
1204
- }
1205
- function getParentNode(node) {
1206
- if (getNodeName(node) === "html") {
1207
- return node;
1208
- }
1209
- const result = (
1210
- // Step into the shadow DOM of the parent of a slotted node.
1211
- node.assignedSlot || // DOM Element detected.
1212
- node.parentNode || // ShadowRoot detected.
1213
- isShadowRoot(node) && node.host || // Fallback.
1214
- getDocumentElement(node)
1215
- );
1216
- return isShadowRoot(result) ? result.host : result;
1217
- }
1218
- function getNearestOverflowAncestor(node) {
1219
- const parentNode = getParentNode(node);
1220
- if (isLastTraversableNode(parentNode)) {
1221
- return node.ownerDocument ? node.ownerDocument.body : node.body;
1222
- }
1223
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1224
- return parentNode;
1225
- }
1226
- return getNearestOverflowAncestor(parentNode);
1227
- }
1228
- function getOverflowAncestors(node, list, traverseIframes) {
1229
- var _node$ownerDocument2;
1230
- if (list === void 0) {
1231
- list = [];
1232
- }
1233
- if (traverseIframes === void 0) {
1234
- traverseIframes = true;
1235
- }
1236
- const scrollableAncestor = getNearestOverflowAncestor(node);
1237
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1238
- const win = getWindow(scrollableAncestor);
1239
- if (isBody) {
1240
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
1241
- }
1242
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1243
- }
1244
- function getUserAgent() {
1245
- const uaData = navigator.userAgentData;
1246
- if (uaData && Array.isArray(uaData.brands)) {
1247
- return uaData.brands.map((_ref) => {
1248
- let {
1249
- brand,
1250
- version
1251
- } = _ref;
1252
- return brand + "/" + version;
1253
- }).join(" ");
1254
- }
1255
- return navigator.userAgent;
1256
- }
1257
- const min = Math.min;
1258
- const max = Math.max;
1259
- const round = Math.round;
1260
- const floor = Math.floor;
1261
- const createCoords = (v2) => ({
1262
- x: v2,
1263
- y: v2
1264
- });
1265
- const oppositeSideMap = {
1266
- left: "right",
1267
- right: "left",
1268
- bottom: "top",
1269
- top: "bottom"
1270
- };
1271
- const oppositeAlignmentMap = {
1272
- start: "end",
1273
- end: "start"
1274
- };
1275
- function clamp(start, value, end) {
1276
- return max(start, min(value, end));
1277
- }
1278
- function evaluate(value, param) {
1279
- return typeof value === "function" ? value(param) : value;
1280
- }
1281
- function getSide(placement) {
1282
- return placement.split("-")[0];
1283
- }
1284
- function getAlignment(placement) {
1285
- return placement.split("-")[1];
1286
- }
1287
- function getOppositeAxis(axis) {
1288
- return axis === "x" ? "y" : "x";
1289
- }
1290
- function getAxisLength(axis) {
1291
- return axis === "y" ? "height" : "width";
1292
- }
1293
- function getSideAxis(placement) {
1294
- return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
1295
- }
1296
- function getAlignmentAxis(placement) {
1297
- return getOppositeAxis(getSideAxis(placement));
1298
- }
1299
- function getAlignmentSides(placement, rects, rtl) {
1300
- if (rtl === void 0) {
1301
- rtl = false;
1302
- }
1303
- const alignment = getAlignment(placement);
1304
- const alignmentAxis = getAlignmentAxis(placement);
1305
- const length = getAxisLength(alignmentAxis);
1306
- let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1307
- if (rects.reference[length] > rects.floating[length]) {
1308
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1309
- }
1310
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1311
- }
1312
- function getExpandedPlacements(placement) {
1313
- const oppositePlacement = getOppositePlacement(placement);
1314
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1315
- }
1316
- function getOppositeAlignmentPlacement(placement) {
1317
- return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
1318
- }
1319
- function getSideList(side, isStart, rtl) {
1320
- const lr = ["left", "right"];
1321
- const rl = ["right", "left"];
1322
- const tb = ["top", "bottom"];
1323
- const bt = ["bottom", "top"];
1324
- switch (side) {
1325
- case "top":
1326
- case "bottom":
1327
- if (rtl) return isStart ? rl : lr;
1328
- return isStart ? lr : rl;
1329
- case "left":
1330
- case "right":
1331
- return isStart ? tb : bt;
1332
- default:
1333
- return [];
1334
- }
1335
- }
1336
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1337
- const alignment = getAlignment(placement);
1338
- let list = getSideList(getSide(placement), direction === "start", rtl);
1339
- if (alignment) {
1340
- list = list.map((side) => side + "-" + alignment);
1341
- if (flipAlignment) {
1342
- list = list.concat(list.map(getOppositeAlignmentPlacement));
1343
- }
1344
- }
1345
- return list;
1346
- }
1347
- function getOppositePlacement(placement) {
1348
- return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
1349
- }
1350
- function expandPaddingObject(padding) {
1351
- return {
1352
- top: 0,
1353
- right: 0,
1354
- bottom: 0,
1355
- left: 0,
1356
- ...padding
1357
- };
1358
- }
1359
- function getPaddingObject(padding) {
1360
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
1361
- top: padding,
1362
- right: padding,
1363
- bottom: padding,
1364
- left: padding
1365
- };
1366
- }
1367
- function rectToClientRect(rect) {
1368
- const {
1369
- x: x2,
1370
- y: y2,
1371
- width,
1372
- height
1373
- } = rect;
1374
- return {
1375
- width,
1376
- height,
1377
- top: y2,
1378
- left: x2,
1379
- right: x2 + width,
1380
- bottom: y2 + height,
1381
- x: x2,
1382
- y: y2
1383
- };
1384
- }
1385
- function computeCoordsFromPlacement(_ref, placement, rtl) {
1386
- let {
1387
- reference,
1388
- floating
1389
- } = _ref;
1390
- const sideAxis = getSideAxis(placement);
1391
- const alignmentAxis = getAlignmentAxis(placement);
1392
- const alignLength = getAxisLength(alignmentAxis);
1393
- const side = getSide(placement);
1394
- const isVertical = sideAxis === "y";
1395
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
1396
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
1397
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1398
- let coords;
1399
- switch (side) {
1400
- case "top":
1401
- coords = {
1402
- x: commonX,
1403
- y: reference.y - floating.height
1404
- };
1405
- break;
1406
- case "bottom":
1407
- coords = {
1408
- x: commonX,
1409
- y: reference.y + reference.height
1410
- };
1411
- break;
1412
- case "right":
1413
- coords = {
1414
- x: reference.x + reference.width,
1415
- y: commonY
1416
- };
1417
- break;
1418
- case "left":
1419
- coords = {
1420
- x: reference.x - floating.width,
1421
- y: commonY
1422
- };
1423
- break;
1424
- default:
1425
- coords = {
1426
- x: reference.x,
1427
- y: reference.y
1428
- };
1429
- }
1430
- switch (getAlignment(placement)) {
1431
- case "start":
1432
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1433
- break;
1434
- case "end":
1435
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1436
- break;
1437
- }
1438
- return coords;
1439
- }
1440
- const computePosition$1 = async (reference, floating, config) => {
1441
- const {
1442
- placement = "bottom",
1443
- strategy = "absolute",
1444
- middleware = [],
1445
- platform: platform2
1446
- } = config;
1447
- const validMiddleware = middleware.filter(Boolean);
1448
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1449
- let rects = await platform2.getElementRects({
1450
- reference,
1451
- floating,
1452
- strategy
1453
- });
1454
- let {
1455
- x: x2,
1456
- y: y2
1457
- } = computeCoordsFromPlacement(rects, placement, rtl);
1458
- let statefulPlacement = placement;
1459
- let middlewareData = {};
1460
- let resetCount = 0;
1461
- for (let i2 = 0; i2 < validMiddleware.length; i2++) {
1462
- const {
1463
- name,
1464
- fn
1465
- } = validMiddleware[i2];
1466
- const {
1467
- x: nextX,
1468
- y: nextY,
1469
- data,
1470
- reset
1471
- } = await fn({
1472
- x: x2,
1473
- y: y2,
1474
- initialPlacement: placement,
1475
- placement: statefulPlacement,
1476
- strategy,
1477
- middlewareData,
1478
- rects,
1479
- platform: platform2,
1480
- elements: {
1481
- reference,
1482
- floating
1483
- }
1484
- });
1485
- x2 = nextX != null ? nextX : x2;
1486
- y2 = nextY != null ? nextY : y2;
1487
- middlewareData = {
1488
- ...middlewareData,
1489
- [name]: {
1490
- ...middlewareData[name],
1491
- ...data
1492
- }
1493
- };
1494
- if (reset && resetCount <= 50) {
1495
- resetCount++;
1496
- if (typeof reset === "object") {
1497
- if (reset.placement) {
1498
- statefulPlacement = reset.placement;
1499
- }
1500
- if (reset.rects) {
1501
- rects = reset.rects === true ? await platform2.getElementRects({
1502
- reference,
1503
- floating,
1504
- strategy
1505
- }) : reset.rects;
1506
- }
1507
- ({
1508
- x: x2,
1509
- y: y2
1510
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1511
- }
1512
- i2 = -1;
1513
- }
1514
- }
1515
- return {
1516
- x: x2,
1517
- y: y2,
1518
- placement: statefulPlacement,
1519
- strategy,
1520
- middlewareData
1521
- };
1522
- };
1523
- async function detectOverflow$1(state, options2) {
1524
- var _await$platform$isEle;
1525
- if (options2 === void 0) {
1526
- options2 = {};
1527
- }
1528
- const {
1529
- x: x2,
1530
- y: y2,
1531
- platform: platform2,
1532
- rects,
1533
- elements,
1534
- strategy
1535
- } = state;
1536
- const {
1537
- boundary = "clippingAncestors",
1538
- rootBoundary = "viewport",
1539
- elementContext = "floating",
1540
- altBoundary = false,
1541
- padding = 0
1542
- } = evaluate(options2, state);
1543
- const paddingObject = getPaddingObject(padding);
1544
- const altContext = elementContext === "floating" ? "reference" : "floating";
1545
- const element = elements[altBoundary ? altContext : elementContext];
1546
- const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1547
- element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
1548
- boundary,
1549
- rootBoundary,
1550
- strategy
1551
- }));
1552
- const rect = elementContext === "floating" ? {
1553
- x: x2,
1554
- y: y2,
1555
- width: rects.floating.width,
1556
- height: rects.floating.height
1557
- } : rects.reference;
1558
- const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1559
- const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1560
- x: 1,
1561
- y: 1
1562
- } : {
1563
- x: 1,
1564
- y: 1
1565
- };
1566
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1567
- elements,
1568
- rect,
1569
- offsetParent,
1570
- strategy
1571
- }) : rect);
1572
- return {
1573
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1574
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1575
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1576
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1577
- };
1578
- }
1579
- const flip$2 = function(options2) {
1580
- if (options2 === void 0) {
1581
- options2 = {};
1582
- }
1583
- return {
1584
- name: "flip",
1585
- options: options2,
1586
- async fn(state) {
1587
- var _middlewareData$arrow, _middlewareData$flip;
1588
- const {
1589
- placement,
1590
- middlewareData,
1591
- rects,
1592
- initialPlacement,
1593
- platform: platform2,
1594
- elements
1595
- } = state;
1596
- const {
1597
- mainAxis: checkMainAxis = true,
1598
- crossAxis: checkCrossAxis = true,
1599
- fallbackPlacements: specifiedFallbackPlacements,
1600
- fallbackStrategy = "bestFit",
1601
- fallbackAxisSideDirection = "none",
1602
- flipAlignment = true,
1603
- ...detectOverflowOptions
1604
- } = evaluate(options2, state);
1605
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1606
- return {};
1607
- }
1608
- const side = getSide(placement);
1609
- const initialSideAxis = getSideAxis(initialPlacement);
1610
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1611
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1612
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1613
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1614
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1615
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1616
- }
1617
- const placements = [initialPlacement, ...fallbackPlacements];
1618
- const overflow = await detectOverflow$1(state, detectOverflowOptions);
1619
- const overflows = [];
1620
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1621
- if (checkMainAxis) {
1622
- overflows.push(overflow[side]);
1623
- }
1624
- if (checkCrossAxis) {
1625
- const sides = getAlignmentSides(placement, rects, rtl);
1626
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
1627
- }
1628
- overflowsData = [...overflowsData, {
1629
- placement,
1630
- overflows
1631
- }];
1632
- if (!overflows.every((side2) => side2 <= 0)) {
1633
- var _middlewareData$flip2, _overflowsData$filter;
1634
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1635
- const nextPlacement = placements[nextIndex];
1636
- if (nextPlacement) {
1637
- return {
1638
- data: {
1639
- index: nextIndex,
1640
- overflows: overflowsData
1641
- },
1642
- reset: {
1643
- placement: nextPlacement
1644
- }
1645
- };
1646
- }
1647
- let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a3, b) => a3.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1648
- if (!resetPlacement) {
1649
- switch (fallbackStrategy) {
1650
- case "bestFit": {
1651
- var _overflowsData$filter2;
1652
- const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
1653
- if (hasFallbackAxisSideDirection) {
1654
- const currentSideAxis = getSideAxis(d2.placement);
1655
- return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
1656
- // reading directions favoring greater width.
1657
- currentSideAxis === "y";
1658
- }
1659
- return true;
1660
- }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a3, b) => a3[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1661
- if (placement2) {
1662
- resetPlacement = placement2;
1663
- }
1664
- break;
1665
- }
1666
- case "initialPlacement":
1667
- resetPlacement = initialPlacement;
1668
- break;
1669
- }
1670
- }
1671
- if (placement !== resetPlacement) {
1672
- return {
1673
- reset: {
1674
- placement: resetPlacement
1675
- }
1676
- };
1677
- }
1678
- }
1679
- return {};
1680
- }
1681
- };
1682
- };
1683
- async function convertValueToCoords(state, options2) {
1684
- const {
1685
- placement,
1686
- platform: platform2,
1687
- elements
1688
- } = state;
1689
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1690
- const side = getSide(placement);
1691
- const alignment = getAlignment(placement);
1692
- const isVertical = getSideAxis(placement) === "y";
1693
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
1694
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1695
- const rawValue = evaluate(options2, state);
1696
- let {
1697
- mainAxis,
1698
- crossAxis,
1699
- alignmentAxis
1700
- } = typeof rawValue === "number" ? {
1701
- mainAxis: rawValue,
1702
- crossAxis: 0,
1703
- alignmentAxis: null
1704
- } : {
1705
- mainAxis: 0,
1706
- crossAxis: 0,
1707
- alignmentAxis: null,
1708
- ...rawValue
1709
- };
1710
- if (alignment && typeof alignmentAxis === "number") {
1711
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1712
- }
1713
- return isVertical ? {
1714
- x: crossAxis * crossAxisMulti,
1715
- y: mainAxis * mainAxisMulti
1716
- } : {
1717
- x: mainAxis * mainAxisMulti,
1718
- y: crossAxis * crossAxisMulti
1719
- };
1720
- }
1721
- const offset$2 = function(options2) {
1722
- if (options2 === void 0) {
1723
- options2 = 0;
1724
- }
1725
- return {
1726
- name: "offset",
1727
- options: options2,
1728
- async fn(state) {
1729
- var _middlewareData$offse, _middlewareData$arrow;
1730
- const {
1731
- x: x2,
1732
- y: y2,
1733
- placement,
1734
- middlewareData
1735
- } = state;
1736
- const diffCoords = await convertValueToCoords(state, options2);
1737
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1738
- return {};
1739
- }
1740
- return {
1741
- x: x2 + diffCoords.x,
1742
- y: y2 + diffCoords.y,
1743
- data: {
1744
- ...diffCoords,
1745
- placement
1746
- }
1747
- };
1748
- }
1749
- };
1750
- };
1751
- const shift$2 = function(options2) {
1752
- if (options2 === void 0) {
1753
- options2 = {};
1754
- }
1755
- return {
1756
- name: "shift",
1757
- options: options2,
1758
- async fn(state) {
1759
- const {
1760
- x: x2,
1761
- y: y2,
1762
- placement
1763
- } = state;
1764
- const {
1765
- mainAxis: checkMainAxis = true,
1766
- crossAxis: checkCrossAxis = false,
1767
- limiter = {
1768
- fn: (_ref) => {
1769
- let {
1770
- x: x3,
1771
- y: y3
1772
- } = _ref;
1773
- return {
1774
- x: x3,
1775
- y: y3
1776
- };
1777
- }
1778
- },
1779
- ...detectOverflowOptions
1780
- } = evaluate(options2, state);
1781
- const coords = {
1782
- x: x2,
1783
- y: y2
1784
- };
1785
- const overflow = await detectOverflow$1(state, detectOverflowOptions);
1786
- const crossAxis = getSideAxis(getSide(placement));
1787
- const mainAxis = getOppositeAxis(crossAxis);
1788
- let mainAxisCoord = coords[mainAxis];
1789
- let crossAxisCoord = coords[crossAxis];
1790
- if (checkMainAxis) {
1791
- const minSide = mainAxis === "y" ? "top" : "left";
1792
- const maxSide = mainAxis === "y" ? "bottom" : "right";
1793
- const min2 = mainAxisCoord + overflow[minSide];
1794
- const max2 = mainAxisCoord - overflow[maxSide];
1795
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
1796
- }
1797
- if (checkCrossAxis) {
1798
- const minSide = crossAxis === "y" ? "top" : "left";
1799
- const maxSide = crossAxis === "y" ? "bottom" : "right";
1800
- const min2 = crossAxisCoord + overflow[minSide];
1801
- const max2 = crossAxisCoord - overflow[maxSide];
1802
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
1803
- }
1804
- const limitedCoords = limiter.fn({
1805
- ...state,
1806
- [mainAxis]: mainAxisCoord,
1807
- [crossAxis]: crossAxisCoord
1808
- });
1809
- return {
1810
- ...limitedCoords,
1811
- data: {
1812
- x: limitedCoords.x - x2,
1813
- y: limitedCoords.y - y2
1814
- }
1815
- };
1816
- }
1817
- };
1818
- };
1819
- const size$2 = function(options2) {
1820
- if (options2 === void 0) {
1821
- options2 = {};
1822
- }
1823
- return {
1824
- name: "size",
1825
- options: options2,
1826
- async fn(state) {
1827
- const {
1828
- placement,
1829
- rects,
1830
- platform: platform2,
1831
- elements
1832
- } = state;
1833
- const {
1834
- apply = () => {
1835
- },
1836
- ...detectOverflowOptions
1837
- } = evaluate(options2, state);
1838
- const overflow = await detectOverflow$1(state, detectOverflowOptions);
1839
- const side = getSide(placement);
1840
- const alignment = getAlignment(placement);
1841
- const isYAxis = getSideAxis(placement) === "y";
1842
- const {
1843
- width,
1844
- height
1845
- } = rects.floating;
1846
- let heightSide;
1847
- let widthSide;
1848
- if (side === "top" || side === "bottom") {
1849
- heightSide = side;
1850
- widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
1851
- } else {
1852
- widthSide = side;
1853
- heightSide = alignment === "end" ? "top" : "bottom";
1854
- }
1855
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
1856
- const maximumClippingWidth = width - overflow.left - overflow.right;
1857
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1858
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1859
- const noShift = !state.middlewareData.shift;
1860
- let availableHeight = overflowAvailableHeight;
1861
- let availableWidth = overflowAvailableWidth;
1862
- if (isYAxis) {
1863
- availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1864
- } else {
1865
- availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1866
- }
1867
- if (noShift && !alignment) {
1868
- const xMin = max(overflow.left, 0);
1869
- const xMax = max(overflow.right, 0);
1870
- const yMin = max(overflow.top, 0);
1871
- const yMax = max(overflow.bottom, 0);
1872
- if (isYAxis) {
1873
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1874
- } else {
1875
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1876
- }
1877
- }
1878
- await apply({
1879
- ...state,
1880
- availableWidth,
1881
- availableHeight
1882
- });
1883
- const nextDimensions = await platform2.getDimensions(elements.floating);
1884
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
1885
- return {
1886
- reset: {
1887
- rects: true
1888
- }
1889
- };
1890
- }
1891
- return {};
1892
- }
1893
- };
1894
- };
1895
- function getCssDimensions(element) {
1896
- const css = getComputedStyle$1(element);
1897
- let width = parseFloat(css.width) || 0;
1898
- let height = parseFloat(css.height) || 0;
1899
- const hasOffset = isHTMLElement(element);
1900
- const offsetWidth = hasOffset ? element.offsetWidth : width;
1901
- const offsetHeight = hasOffset ? element.offsetHeight : height;
1902
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1903
- if (shouldFallback) {
1904
- width = offsetWidth;
1905
- height = offsetHeight;
1906
- }
1907
- return {
1908
- width,
1909
- height,
1910
- $: shouldFallback
1911
- };
1912
- }
1913
- function unwrapElement(element) {
1914
- return !isElement(element) ? element.contextElement : element;
1915
- }
1916
- function getScale(element) {
1917
- const domElement = unwrapElement(element);
1918
- if (!isHTMLElement(domElement)) {
1919
- return createCoords(1);
1920
- }
1921
- const rect = domElement.getBoundingClientRect();
1922
- const {
1923
- width,
1924
- height,
1925
- $
1926
- } = getCssDimensions(domElement);
1927
- let x2 = ($ ? round(rect.width) : rect.width) / width;
1928
- let y2 = ($ ? round(rect.height) : rect.height) / height;
1929
- if (!x2 || !Number.isFinite(x2)) {
1930
- x2 = 1;
1931
- }
1932
- if (!y2 || !Number.isFinite(y2)) {
1933
- y2 = 1;
1934
- }
1935
- return {
1936
- x: x2,
1937
- y: y2
1938
- };
1939
- }
1940
- const noOffsets = /* @__PURE__ */ createCoords(0);
1941
- function getVisualOffsets(element) {
1942
- const win = getWindow(element);
1943
- if (!isWebKit() || !win.visualViewport) {
1944
- return noOffsets;
1945
- }
1946
- return {
1947
- x: win.visualViewport.offsetLeft,
1948
- y: win.visualViewport.offsetTop
1949
- };
1950
- }
1951
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1952
- if (isFixed === void 0) {
1953
- isFixed = false;
1954
- }
1955
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1956
- return false;
1957
- }
1958
- return isFixed;
1959
- }
1960
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1961
- if (includeScale === void 0) {
1962
- includeScale = false;
1963
- }
1964
- if (isFixedStrategy === void 0) {
1965
- isFixedStrategy = false;
1966
- }
1967
- const clientRect = element.getBoundingClientRect();
1968
- const domElement = unwrapElement(element);
1969
- let scale = createCoords(1);
1970
- if (includeScale) {
1971
- if (offsetParent) {
1972
- if (isElement(offsetParent)) {
1973
- scale = getScale(offsetParent);
1974
- }
1975
- } else {
1976
- scale = getScale(element);
1977
- }
1978
- }
1979
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1980
- let x2 = (clientRect.left + visualOffsets.x) / scale.x;
1981
- let y2 = (clientRect.top + visualOffsets.y) / scale.y;
1982
- let width = clientRect.width / scale.x;
1983
- let height = clientRect.height / scale.y;
1984
- if (domElement) {
1985
- const win = getWindow(domElement);
1986
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1987
- let currentWin = win;
1988
- let currentIFrame = currentWin.frameElement;
1989
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1990
- const iframeScale = getScale(currentIFrame);
1991
- const iframeRect = currentIFrame.getBoundingClientRect();
1992
- const css = getComputedStyle$1(currentIFrame);
1993
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1994
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1995
- x2 *= iframeScale.x;
1996
- y2 *= iframeScale.y;
1997
- width *= iframeScale.x;
1998
- height *= iframeScale.y;
1999
- x2 += left;
2000
- y2 += top;
2001
- currentWin = getWindow(currentIFrame);
2002
- currentIFrame = currentWin.frameElement;
2003
- }
2004
- }
2005
- return rectToClientRect({
2006
- width,
2007
- height,
2008
- x: x2,
2009
- y: y2
2010
- });
2011
- }
2012
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2013
- let {
2014
- elements,
2015
- rect,
2016
- offsetParent,
2017
- strategy
2018
- } = _ref;
2019
- const isFixed = strategy === "fixed";
2020
- const documentElement = getDocumentElement(offsetParent);
2021
- const topLayer = elements ? isTopLayer(elements.floating) : false;
2022
- if (offsetParent === documentElement || topLayer && isFixed) {
2023
- return rect;
2024
- }
2025
- let scroll = {
2026
- scrollLeft: 0,
2027
- scrollTop: 0
2028
- };
2029
- let scale = createCoords(1);
2030
- const offsets = createCoords(0);
2031
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2032
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2033
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2034
- scroll = getNodeScroll(offsetParent);
2035
- }
2036
- if (isHTMLElement(offsetParent)) {
2037
- const offsetRect = getBoundingClientRect(offsetParent);
2038
- scale = getScale(offsetParent);
2039
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2040
- offsets.y = offsetRect.y + offsetParent.clientTop;
2041
- }
2042
- }
2043
- return {
2044
- width: rect.width * scale.x,
2045
- height: rect.height * scale.y,
2046
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2047
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2048
- };
2049
- }
2050
- function getClientRects(element) {
2051
- return Array.from(element.getClientRects());
2052
- }
2053
- function getWindowScrollBarX(element) {
2054
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2055
- }
2056
- function getDocumentRect(element) {
2057
- const html = getDocumentElement(element);
2058
- const scroll = getNodeScroll(element);
2059
- const body = element.ownerDocument.body;
2060
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2061
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2062
- let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
2063
- const y2 = -scroll.scrollTop;
2064
- if (getComputedStyle$1(body).direction === "rtl") {
2065
- x2 += max(html.clientWidth, body.clientWidth) - width;
2066
- }
2067
- return {
2068
- width,
2069
- height,
2070
- x: x2,
2071
- y: y2
2072
- };
2073
- }
2074
- function getViewportRect(element, strategy) {
2075
- const win = getWindow(element);
2076
- const html = getDocumentElement(element);
2077
- const visualViewport = win.visualViewport;
2078
- let width = html.clientWidth;
2079
- let height = html.clientHeight;
2080
- let x2 = 0;
2081
- let y2 = 0;
2082
- if (visualViewport) {
2083
- width = visualViewport.width;
2084
- height = visualViewport.height;
2085
- const visualViewportBased = isWebKit();
2086
- if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2087
- x2 = visualViewport.offsetLeft;
2088
- y2 = visualViewport.offsetTop;
2089
- }
2090
- }
2091
- return {
2092
- width,
2093
- height,
2094
- x: x2,
2095
- y: y2
2096
- };
2097
- }
2098
- function getInnerBoundingClientRect(element, strategy) {
2099
- const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2100
- const top = clientRect.top + element.clientTop;
2101
- const left = clientRect.left + element.clientLeft;
2102
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2103
- const width = element.clientWidth * scale.x;
2104
- const height = element.clientHeight * scale.y;
2105
- const x2 = left * scale.x;
2106
- const y2 = top * scale.y;
2107
- return {
2108
- width,
2109
- height,
2110
- x: x2,
2111
- y: y2
2112
- };
2113
- }
2114
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2115
- let rect;
2116
- if (clippingAncestor === "viewport") {
2117
- rect = getViewportRect(element, strategy);
2118
- } else if (clippingAncestor === "document") {
2119
- rect = getDocumentRect(getDocumentElement(element));
2120
- } else if (isElement(clippingAncestor)) {
2121
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2122
- } else {
2123
- const visualOffsets = getVisualOffsets(element);
2124
- rect = {
2125
- ...clippingAncestor,
2126
- x: clippingAncestor.x - visualOffsets.x,
2127
- y: clippingAncestor.y - visualOffsets.y
2128
- };
2129
- }
2130
- return rectToClientRect(rect);
2131
- }
2132
- function hasFixedPositionAncestor(element, stopNode) {
2133
- const parentNode = getParentNode(element);
2134
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2135
- return false;
2136
- }
2137
- return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2138
- }
2139
- function getClippingElementAncestors(element, cache) {
2140
- const cachedResult = cache.get(element);
2141
- if (cachedResult) {
2142
- return cachedResult;
2143
- }
2144
- let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2145
- let currentContainingBlockComputedStyle = null;
2146
- const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2147
- let currentNode = elementIsFixed ? getParentNode(element) : element;
2148
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2149
- const computedStyle = getComputedStyle$1(currentNode);
2150
- const currentNodeIsContaining = isContainingBlock(currentNode);
2151
- if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2152
- currentContainingBlockComputedStyle = null;
2153
- }
2154
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2155
- if (shouldDropCurrentNode) {
2156
- result = result.filter((ancestor) => ancestor !== currentNode);
2157
- } else {
2158
- currentContainingBlockComputedStyle = computedStyle;
2159
- }
2160
- currentNode = getParentNode(currentNode);
2161
- }
2162
- cache.set(element, result);
2163
- return result;
2164
- }
2165
- function getClippingRect(_ref) {
2166
- let {
2167
- element,
2168
- boundary,
2169
- rootBoundary,
2170
- strategy
2171
- } = _ref;
2172
- const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2173
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2174
- const firstClippingAncestor = clippingAncestors[0];
2175
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2176
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2177
- accRect.top = max(rect.top, accRect.top);
2178
- accRect.right = min(rect.right, accRect.right);
2179
- accRect.bottom = min(rect.bottom, accRect.bottom);
2180
- accRect.left = max(rect.left, accRect.left);
2181
- return accRect;
2182
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2183
- return {
2184
- width: clippingRect.right - clippingRect.left,
2185
- height: clippingRect.bottom - clippingRect.top,
2186
- x: clippingRect.left,
2187
- y: clippingRect.top
2188
- };
2189
- }
2190
- function getDimensions(element) {
2191
- const {
2192
- width,
2193
- height
2194
- } = getCssDimensions(element);
2195
- return {
2196
- width,
2197
- height
2198
- };
2199
- }
2200
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2201
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2202
- const documentElement = getDocumentElement(offsetParent);
2203
- const isFixed = strategy === "fixed";
2204
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2205
- let scroll = {
2206
- scrollLeft: 0,
2207
- scrollTop: 0
2208
- };
2209
- const offsets = createCoords(0);
2210
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2211
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2212
- scroll = getNodeScroll(offsetParent);
2213
- }
2214
- if (isOffsetParentAnElement) {
2215
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2216
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2217
- offsets.y = offsetRect.y + offsetParent.clientTop;
2218
- } else if (documentElement) {
2219
- offsets.x = getWindowScrollBarX(documentElement);
2220
- }
2221
- }
2222
- const x2 = rect.left + scroll.scrollLeft - offsets.x;
2223
- const y2 = rect.top + scroll.scrollTop - offsets.y;
2224
- return {
2225
- x: x2,
2226
- y: y2,
2227
- width: rect.width,
2228
- height: rect.height
2229
- };
2230
- }
2231
- function isStaticPositioned(element) {
2232
- return getComputedStyle$1(element).position === "static";
2233
- }
2234
- function getTrueOffsetParent(element, polyfill) {
2235
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2236
- return null;
2237
- }
2238
- if (polyfill) {
2239
- return polyfill(element);
2240
- }
2241
- return element.offsetParent;
2242
- }
2243
- function getOffsetParent(element, polyfill) {
2244
- const win = getWindow(element);
2245
- if (isTopLayer(element)) {
2246
- return win;
2247
- }
2248
- if (!isHTMLElement(element)) {
2249
- let svgOffsetParent = getParentNode(element);
2250
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2251
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2252
- return svgOffsetParent;
2253
- }
2254
- svgOffsetParent = getParentNode(svgOffsetParent);
2255
- }
2256
- return win;
2257
- }
2258
- let offsetParent = getTrueOffsetParent(element, polyfill);
2259
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2260
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2261
- }
2262
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2263
- return win;
2264
- }
2265
- return offsetParent || getContainingBlock(element) || win;
2266
- }
2267
- const getElementRects = async function(data) {
2268
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2269
- const getDimensionsFn = this.getDimensions;
2270
- const floatingDimensions = await getDimensionsFn(data.floating);
2271
- return {
2272
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2273
- floating: {
2274
- x: 0,
2275
- y: 0,
2276
- width: floatingDimensions.width,
2277
- height: floatingDimensions.height
2278
- }
2279
- };
2280
- };
2281
- function isRTL(element) {
2282
- return getComputedStyle$1(element).direction === "rtl";
2283
- }
2284
- const platform = {
2285
- convertOffsetParentRelativeRectToViewportRelativeRect,
2286
- getDocumentElement,
2287
- getClippingRect,
2288
- getOffsetParent,
2289
- getElementRects,
2290
- getClientRects,
2291
- getDimensions,
2292
- getScale,
2293
- isElement,
2294
- isRTL
2295
- };
2296
- function observeMove(element, onMove) {
2297
- let io = null;
2298
- let timeoutId;
2299
- const root = getDocumentElement(element);
2300
- function cleanup() {
2301
- var _io;
2302
- clearTimeout(timeoutId);
2303
- (_io = io) == null || _io.disconnect();
2304
- io = null;
2305
- }
2306
- function refresh(skip, threshold) {
2307
- if (skip === void 0) {
2308
- skip = false;
2309
- }
2310
- if (threshold === void 0) {
2311
- threshold = 1;
2312
- }
2313
- cleanup();
2314
- const {
2315
- left,
2316
- top,
2317
- width,
2318
- height
2319
- } = element.getBoundingClientRect();
2320
- if (!skip) {
2321
- onMove();
2322
- }
2323
- if (!width || !height) {
2324
- return;
2325
- }
2326
- const insetTop = floor(top);
2327
- const insetRight = floor(root.clientWidth - (left + width));
2328
- const insetBottom = floor(root.clientHeight - (top + height));
2329
- const insetLeft = floor(left);
2330
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2331
- const options2 = {
2332
- rootMargin,
2333
- threshold: max(0, min(1, threshold)) || 1
2334
- };
2335
- let isFirstUpdate = true;
2336
- function handleObserve(entries) {
2337
- const ratio = entries[0].intersectionRatio;
2338
- if (ratio !== threshold) {
2339
- if (!isFirstUpdate) {
2340
- return refresh();
2341
- }
2342
- if (!ratio) {
2343
- timeoutId = setTimeout(() => {
2344
- refresh(false, 1e-7);
2345
- }, 1e3);
2346
- } else {
2347
- refresh(false, ratio);
2348
- }
2349
- }
2350
- isFirstUpdate = false;
2351
- }
2352
- try {
2353
- io = new IntersectionObserver(handleObserve, {
2354
- ...options2,
2355
- // Handle <iframe>s
2356
- root: root.ownerDocument
2357
- });
2358
- } catch (e2) {
2359
- io = new IntersectionObserver(handleObserve, options2);
2360
- }
2361
- io.observe(element);
2362
- }
2363
- refresh(true);
2364
- return cleanup;
2365
- }
2366
- function autoUpdate(reference, floating, update, options2) {
2367
- if (options2 === void 0) {
2368
- options2 = {};
2369
- }
2370
- const {
2371
- ancestorScroll = true,
2372
- ancestorResize = true,
2373
- elementResize = typeof ResizeObserver === "function",
2374
- layoutShift = typeof IntersectionObserver === "function",
2375
- animationFrame = false
2376
- } = options2;
2377
- const referenceEl = unwrapElement(reference);
2378
- const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2379
- ancestors.forEach((ancestor) => {
2380
- ancestorScroll && ancestor.addEventListener("scroll", update, {
2381
- passive: true
2382
- });
2383
- ancestorResize && ancestor.addEventListener("resize", update);
2384
- });
2385
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2386
- let reobserveFrame = -1;
2387
- let resizeObserver = null;
2388
- if (elementResize) {
2389
- resizeObserver = new ResizeObserver((_ref) => {
2390
- let [firstEntry] = _ref;
2391
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2392
- resizeObserver.unobserve(floating);
2393
- cancelAnimationFrame(reobserveFrame);
2394
- reobserveFrame = requestAnimationFrame(() => {
2395
- var _resizeObserver;
2396
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2397
- });
2398
- }
2399
- update();
2400
- });
2401
- if (referenceEl && !animationFrame) {
2402
- resizeObserver.observe(referenceEl);
2403
- }
2404
- resizeObserver.observe(floating);
2405
- }
2406
- let frameId;
2407
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2408
- if (animationFrame) {
2409
- frameLoop();
2410
- }
2411
- function frameLoop() {
2412
- const nextRefRect = getBoundingClientRect(reference);
2413
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2414
- update();
2415
- }
2416
- prevRefRect = nextRefRect;
2417
- frameId = requestAnimationFrame(frameLoop);
2418
- }
2419
- update();
2420
- return () => {
2421
- var _resizeObserver2;
2422
- ancestors.forEach((ancestor) => {
2423
- ancestorScroll && ancestor.removeEventListener("scroll", update);
2424
- ancestorResize && ancestor.removeEventListener("resize", update);
2425
- });
2426
- cleanupIo == null || cleanupIo();
2427
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2428
- resizeObserver = null;
2429
- if (animationFrame) {
2430
- cancelAnimationFrame(frameId);
2431
- }
2432
- };
2433
- }
2434
- const detectOverflow = detectOverflow$1;
2435
- const offset$1 = offset$2;
2436
- const shift$1 = shift$2;
2437
- const flip$1 = flip$2;
2438
- const size$1 = size$2;
2439
- const computePosition = (reference, floating, options2) => {
2440
- const cache = /* @__PURE__ */ new Map();
2441
- const mergedOptions = {
2442
- platform,
2443
- ...options2
2444
- };
2445
- const platformWithCache = {
2446
- ...mergedOptions.platform,
2447
- _c: cache
2448
- };
2449
- return computePosition$1(reference, floating, {
2450
- ...mergedOptions,
2451
- platform: platformWithCache
2452
- });
2453
- };
2454
- var index$1 = typeof document !== "undefined" ? useLayoutEffect : useEffect;
2455
- function deepEqual(a3, b) {
2456
- if (a3 === b) {
2457
- return true;
2458
- }
2459
- if (typeof a3 !== typeof b) {
2460
- return false;
2461
- }
2462
- if (typeof a3 === "function" && a3.toString() === b.toString()) {
2463
- return true;
2464
- }
2465
- let length;
2466
- let i2;
2467
- let keys;
2468
- if (a3 && b && typeof a3 === "object") {
2469
- if (Array.isArray(a3)) {
2470
- length = a3.length;
2471
- if (length !== b.length) return false;
2472
- for (i2 = length; i2-- !== 0; ) {
2473
- if (!deepEqual(a3[i2], b[i2])) {
2474
- return false;
2475
- }
2476
- }
2477
- return true;
2478
- }
2479
- keys = Object.keys(a3);
2480
- length = keys.length;
2481
- if (length !== Object.keys(b).length) {
2482
- return false;
2483
- }
2484
- for (i2 = length; i2-- !== 0; ) {
2485
- if (!{}.hasOwnProperty.call(b, keys[i2])) {
2486
- return false;
2487
- }
2488
- }
2489
- for (i2 = length; i2-- !== 0; ) {
2490
- const key = keys[i2];
2491
- if (key === "_owner" && a3.$$typeof) {
2492
- continue;
2493
- }
2494
- if (!deepEqual(a3[key], b[key])) {
2495
- return false;
2496
- }
2497
- }
2498
- return true;
2499
- }
2500
- return a3 !== a3 && b !== b;
2501
- }
2502
- function getDPR(element) {
2503
- if (typeof window === "undefined") {
2504
- return 1;
2505
- }
2506
- const win = element.ownerDocument.defaultView || window;
2507
- return win.devicePixelRatio || 1;
2508
- }
2509
- function roundByDPR(element, value) {
2510
- const dpr = getDPR(element);
2511
- return Math.round(value * dpr) / dpr;
2512
- }
2513
- function useLatestRef(value) {
2514
- const ref = React.useRef(value);
2515
- index$1(() => {
2516
- ref.current = value;
2517
- });
2518
- return ref;
2519
- }
2520
- function useFloating$1(options2) {
2521
- if (options2 === void 0) {
2522
- options2 = {};
2523
- }
2524
- const {
2525
- placement = "bottom",
2526
- strategy = "absolute",
2527
- middleware = [],
2528
- platform: platform2,
2529
- elements: {
2530
- reference: externalReference,
2531
- floating: externalFloating
2532
- } = {},
2533
- transform = true,
2534
- whileElementsMounted,
2535
- open
2536
- } = options2;
2537
- const [data, setData] = React.useState({
2538
- x: 0,
2539
- y: 0,
2540
- strategy,
2541
- placement,
2542
- middlewareData: {},
2543
- isPositioned: false
2544
- });
2545
- const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2546
- if (!deepEqual(latestMiddleware, middleware)) {
2547
- setLatestMiddleware(middleware);
2548
- }
2549
- const [_reference, _setReference] = React.useState(null);
2550
- const [_floating, _setFloating] = React.useState(null);
2551
- const setReference = React.useCallback((node) => {
2552
- if (node !== referenceRef.current) {
2553
- referenceRef.current = node;
2554
- _setReference(node);
2555
- }
2556
- }, []);
2557
- const setFloating = React.useCallback((node) => {
2558
- if (node !== floatingRef.current) {
2559
- floatingRef.current = node;
2560
- _setFloating(node);
2561
- }
2562
- }, []);
2563
- const referenceEl = externalReference || _reference;
2564
- const floatingEl = externalFloating || _floating;
2565
- const referenceRef = React.useRef(null);
2566
- const floatingRef = React.useRef(null);
2567
- const dataRef = React.useRef(data);
2568
- const hasWhileElementsMounted = whileElementsMounted != null;
2569
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2570
- const platformRef = useLatestRef(platform2);
2571
- const update = React.useCallback(() => {
2572
- if (!referenceRef.current || !floatingRef.current) {
2573
- return;
2574
- }
2575
- const config = {
2576
- placement,
2577
- strategy,
2578
- middleware: latestMiddleware
2579
- };
2580
- if (platformRef.current) {
2581
- config.platform = platformRef.current;
2582
- }
2583
- computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
2584
- const fullData = {
2585
- ...data2,
2586
- isPositioned: true
2587
- };
2588
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2589
- dataRef.current = fullData;
2590
- ReactDOM.flushSync(() => {
2591
- setData(fullData);
2592
- });
2593
- }
2594
- });
2595
- }, [latestMiddleware, placement, strategy, platformRef]);
2596
- index$1(() => {
2597
- if (open === false && dataRef.current.isPositioned) {
2598
- dataRef.current.isPositioned = false;
2599
- setData((data2) => ({
2600
- ...data2,
2601
- isPositioned: false
2602
- }));
2603
- }
2604
- }, [open]);
2605
- const isMountedRef = React.useRef(false);
2606
- index$1(() => {
2607
- isMountedRef.current = true;
2608
- return () => {
2609
- isMountedRef.current = false;
2610
- };
2611
- }, []);
2612
- index$1(() => {
2613
- if (referenceEl) referenceRef.current = referenceEl;
2614
- if (floatingEl) floatingRef.current = floatingEl;
2615
- if (referenceEl && floatingEl) {
2616
- if (whileElementsMountedRef.current) {
2617
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2618
- }
2619
- update();
2620
- }
2621
- }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2622
- const refs = React.useMemo(() => ({
2623
- reference: referenceRef,
2624
- floating: floatingRef,
2625
- setReference,
2626
- setFloating
2627
- }), [setReference, setFloating]);
2628
- const elements = React.useMemo(() => ({
2629
- reference: referenceEl,
2630
- floating: floatingEl
2631
- }), [referenceEl, floatingEl]);
2632
- const floatingStyles = React.useMemo(() => {
2633
- const initialStyles = {
2634
- position: strategy,
2635
- left: 0,
2636
- top: 0
2637
- };
2638
- if (!elements.floating) {
2639
- return initialStyles;
2640
- }
2641
- const x2 = roundByDPR(elements.floating, data.x);
2642
- const y2 = roundByDPR(elements.floating, data.y);
2643
- if (transform) {
2644
- return {
2645
- ...initialStyles,
2646
- transform: "translate(" + x2 + "px, " + y2 + "px)",
2647
- ...getDPR(elements.floating) >= 1.5 && {
2648
- willChange: "transform"
2649
- }
2650
- };
2651
- }
2652
- return {
2653
- position: strategy,
2654
- left: x2,
2655
- top: y2
2656
- };
2657
- }, [strategy, transform, elements.floating, data.x, data.y]);
2658
- return React.useMemo(() => ({
2659
- ...data,
2660
- update,
2661
- refs,
2662
- elements,
2663
- floatingStyles
2664
- }), [data, update, refs, elements, floatingStyles]);
2665
- }
2666
- const offset = (options2, deps) => ({
2667
- ...offset$1(options2),
2668
- options: [options2, deps]
2669
- });
2670
- const shift = (options2, deps) => ({
2671
- ...shift$1(options2),
2672
- options: [options2, deps]
2673
- });
2674
- const flip = (options2, deps) => ({
2675
- ...flip$1(options2),
2676
- options: [options2, deps]
2677
- });
2678
- const size = (options2, deps) => ({
2679
- ...size$1(options2),
2680
- options: [options2, deps]
2681
- });
2682
- const SafeReact = {
2683
- ...React
2684
- };
2685
- const useInsertionEffect = SafeReact.useInsertionEffect;
2686
- const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
2687
- function useEffectEvent(callback) {
2688
- const ref = React.useRef(() => {
2689
- if (process.env.NODE_ENV !== "production") {
2690
- throw new Error("Cannot call an event handler while rendering.");
2691
- }
2692
- });
2693
- useSafeInsertionEffect(() => {
2694
- ref.current = callback;
2695
- });
2696
- return React.useCallback(function() {
2697
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2698
- args[_key] = arguments[_key];
2699
- }
2700
- return ref.current == null ? void 0 : ref.current(...args);
2701
- }, []);
2702
- }
2703
- var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
2704
- let serverHandoffComplete = false;
2705
- let count = 0;
2706
- const genId = () => (
2707
- // Ensure the id is unique with multiple independent versions of Floating UI
2708
- // on <React 18
2709
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
2710
- );
2711
- function useFloatingId() {
2712
- const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
2713
- index(() => {
2714
- if (id == null) {
2715
- setId(genId());
2716
- }
2717
- }, []);
2718
- React.useEffect(() => {
2719
- serverHandoffComplete = true;
2720
- }, []);
2721
- return id;
2722
- }
2723
- const useReactId = SafeReact.useId;
2724
- const useId = useReactId || useFloatingId;
2725
- let devMessageSet;
2726
- if (process.env.NODE_ENV !== "production") {
2727
- devMessageSet = /* @__PURE__ */ new Set();
2728
- }
2729
- function warn() {
2730
- var _devMessageSet;
2731
- for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
2732
- messages[_key] = arguments[_key];
2733
- }
2734
- const message = "Floating UI: " + messages.join(" ");
2735
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
2736
- var _devMessageSet2;
2737
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
2738
- console.warn(message);
2739
- }
2740
- }
2741
- function error() {
2742
- var _devMessageSet3;
2743
- for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2744
- messages[_key2] = arguments[_key2];
2745
- }
2746
- const message = "Floating UI: " + messages.join(" ");
2747
- if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
2748
- var _devMessageSet4;
2749
- (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
2750
- console.error(message);
2751
- }
2752
- }
2753
- function createPubSub() {
2754
- const map = /* @__PURE__ */ new Map();
2755
- return {
2756
- emit(event, data) {
2757
- var _map$get;
2758
- (_map$get = map.get(event)) == null || _map$get.forEach((handler) => handler(data));
2759
- },
2760
- on(event, listener) {
2761
- map.set(event, [...map.get(event) || [], listener]);
2762
- },
2763
- off(event, listener) {
2764
- var _map$get2;
2765
- map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter((l2) => l2 !== listener)) || []);
2766
- }
2767
- };
2768
- }
2769
- const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
2770
- const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
2771
- const useFloatingParentNodeId = () => {
2772
- var _React$useContext;
2773
- return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
2774
- };
2775
- const useFloatingTree = () => React.useContext(FloatingTreeContext);
2776
- function useFloatingRootContext(options2) {
2777
- const {
2778
- open = false,
2779
- onOpenChange: onOpenChangeProp,
2780
- elements: elementsProp
2781
- } = options2;
2782
- const floatingId = useId();
2783
- const dataRef = React.useRef({});
2784
- const [events] = React.useState(() => createPubSub());
2785
- const nested = useFloatingParentNodeId() != null;
2786
- if (process.env.NODE_ENV !== "production") {
2787
- const optionDomReference = elementsProp.reference;
2788
- if (optionDomReference && !isElement(optionDomReference)) {
2789
- error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
2790
- }
2791
- }
2792
- const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
2793
- const onOpenChange = useEffectEvent((open2, event, reason) => {
2794
- dataRef.current.openEvent = open2 ? event : void 0;
2795
- events.emit("openchange", {
2796
- open: open2,
2797
- event,
2798
- reason,
2799
- nested
2800
- });
2801
- onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
2802
- });
2803
- const refs = React.useMemo(() => ({
2804
- setPositionReference
2805
- }), []);
2806
- const elements = React.useMemo(() => ({
2807
- reference: positionReference || elementsProp.reference || null,
2808
- floating: elementsProp.floating || null,
2809
- domReference: elementsProp.reference
2810
- }), [positionReference, elementsProp.reference, elementsProp.floating]);
2811
- return React.useMemo(() => ({
2812
- dataRef,
2813
- open,
2814
- onOpenChange,
2815
- elements,
2816
- events,
2817
- floatingId,
2818
- refs
2819
- }), [open, onOpenChange, elements, events, floatingId, refs]);
2820
- }
2821
- function useFloating(options2) {
2822
- if (options2 === void 0) {
2823
- options2 = {};
2824
- }
2825
- const {
2826
- nodeId
2827
- } = options2;
2828
- const internalRootContext = useFloatingRootContext({
2829
- ...options2,
2830
- elements: {
2831
- reference: null,
2832
- floating: null,
2833
- ...options2.elements
2834
- }
2835
- });
2836
- const rootContext = options2.rootContext || internalRootContext;
2837
- const computedElements = rootContext.elements;
2838
- const [_domReference, setDomReference] = React.useState(null);
2839
- const [positionReference, _setPositionReference] = React.useState(null);
2840
- const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
2841
- const domReference = optionDomReference || _domReference;
2842
- const domReferenceRef = React.useRef(null);
2843
- const tree = useFloatingTree();
2844
- index(() => {
2845
- if (domReference) {
2846
- domReferenceRef.current = domReference;
2847
- }
2848
- }, [domReference]);
2849
- const position = useFloating$1({
2850
- ...options2,
2851
- elements: {
2852
- ...computedElements,
2853
- ...positionReference && {
2854
- reference: positionReference
2855
- }
2856
- }
2857
- });
2858
- const setPositionReference = React.useCallback((node) => {
2859
- const computedPositionReference = isElement(node) ? {
2860
- getBoundingClientRect: () => node.getBoundingClientRect(),
2861
- contextElement: node
2862
- } : node;
2863
- _setPositionReference(computedPositionReference);
2864
- position.refs.setReference(computedPositionReference);
2865
- }, [position.refs]);
2866
- const setReference = React.useCallback((node) => {
2867
- if (isElement(node) || node === null) {
2868
- domReferenceRef.current = node;
2869
- setDomReference(node);
2870
- }
2871
- if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
2872
- // `null` to support `positionReference` + an unstable `reference`
2873
- // callback ref.
2874
- node !== null && !isElement(node)) {
2875
- position.refs.setReference(node);
2876
- }
2877
- }, [position.refs]);
2878
- const refs = React.useMemo(() => ({
2879
- ...position.refs,
2880
- setReference,
2881
- setPositionReference,
2882
- domReference: domReferenceRef
2883
- }), [position.refs, setReference, setPositionReference]);
2884
- const elements = React.useMemo(() => ({
2885
- ...position.elements,
2886
- domReference
2887
- }), [position.elements, domReference]);
2888
- const context = React.useMemo(() => ({
2889
- ...position,
2890
- ...rootContext,
2891
- refs,
2892
- elements,
2893
- nodeId
2894
- }), [position, refs, elements, nodeId, rootContext]);
2895
- index(() => {
2896
- rootContext.dataRef.current.floatingContext = context;
2897
- const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
2898
- if (node) {
2899
- node.context = context;
2900
- }
2901
- });
2902
- return React.useMemo(() => ({
2903
- ...position,
2904
- context,
2905
- refs,
2906
- elements
2907
- }), [position, refs, elements, context]);
2908
- }
2909
- const ACTIVE_KEY = "active";
2910
- const SELECTED_KEY = "selected";
2911
- function mergeProps(userProps, propsList, elementKey) {
2912
- const map = /* @__PURE__ */ new Map();
2913
- const isItem = elementKey === "item";
2914
- let domUserProps = userProps;
2915
- if (isItem && userProps) {
2916
- const {
2917
- [ACTIVE_KEY]: _2,
2918
- [SELECTED_KEY]: __,
2919
- ...validProps
2920
- } = userProps;
2921
- domUserProps = validProps;
2922
- }
2923
- return {
2924
- ...elementKey === "floating" && {
2925
- tabIndex: -1
2926
- },
2927
- ...domUserProps,
2928
- ...propsList.map((value) => {
2929
- const propsOrGetProps = value ? value[elementKey] : null;
2930
- if (typeof propsOrGetProps === "function") {
2931
- return userProps ? propsOrGetProps(userProps) : null;
2932
- }
2933
- return propsOrGetProps;
2934
- }).concat(userProps).reduce((acc, props) => {
2935
- if (!props) {
2936
- return acc;
2937
- }
2938
- Object.entries(props).forEach((_ref) => {
2939
- let [key, value] = _ref;
2940
- if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
2941
- return;
2942
- }
2943
- if (key.indexOf("on") === 0) {
2944
- if (!map.has(key)) {
2945
- map.set(key, []);
2946
- }
2947
- if (typeof value === "function") {
2948
- var _map$get;
2949
- (_map$get = map.get(key)) == null || _map$get.push(value);
2950
- acc[key] = function() {
2951
- var _map$get2;
2952
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2953
- args[_key] = arguments[_key];
2954
- }
2955
- return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
2956
- };
2957
- }
2958
- } else {
2959
- acc[key] = value;
2960
- }
2961
- });
2962
- return acc;
2963
- }, {})
2964
- };
2965
- }
2966
- function useInteractions(propsList) {
2967
- if (propsList === void 0) {
2968
- propsList = [];
2969
- }
2970
- const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
2971
- const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
2972
- const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
2973
- const getReferenceProps = React.useCallback(
2974
- (userProps) => mergeProps(userProps, propsList, "reference"),
2975
- // eslint-disable-next-line react-hooks/exhaustive-deps
2976
- referenceDeps
2977
- );
2978
- const getFloatingProps = React.useCallback(
2979
- (userProps) => mergeProps(userProps, propsList, "floating"),
2980
- // eslint-disable-next-line react-hooks/exhaustive-deps
2981
- floatingDeps
2982
- );
2983
- const getItemProps = React.useCallback(
2984
- (userProps) => mergeProps(userProps, propsList, "item"),
2985
- // eslint-disable-next-line react-hooks/exhaustive-deps
2986
- itemDeps
2987
- );
2988
- return React.useMemo(() => ({
2989
- getReferenceProps,
2990
- getFloatingProps,
2991
- getItemProps
2992
- }), [getReferenceProps, getFloatingProps, getItemProps]);
2993
- }
2994
- function getArgsWithCustomFloatingHeight(state, height) {
2995
- return {
2996
- ...state,
2997
- rects: {
2998
- ...state.rects,
2999
- floating: {
3000
- ...state.rects.floating,
3001
- height
3002
- }
3003
- }
3004
- };
3005
- }
3006
- const inner = (props) => ({
3007
- name: "inner",
3008
- options: props,
3009
- async fn(state) {
3010
- const {
3011
- listRef,
3012
- overflowRef,
3013
- onFallbackChange,
3014
- offset: innerOffset = 0,
3015
- index: index2 = 0,
3016
- minItemsVisible = 4,
3017
- referenceOverflowThreshold = 0,
3018
- scrollRef,
3019
- ...detectOverflowOptions
3020
- } = evaluate(props, state);
3021
- const {
3022
- rects,
3023
- elements: {
3024
- floating
3025
- }
3026
- } = state;
3027
- const item = listRef.current[index2];
3028
- if (process.env.NODE_ENV !== "production") {
3029
- if (!state.placement.startsWith("bottom")) {
3030
- warn('`placement` side must be "bottom" when using the `inner`', "middleware.");
3031
- }
3032
- }
3033
- if (!item) {
3034
- return {};
3035
- }
3036
- const nextArgs = {
3037
- ...state,
3038
- ...await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state)
3039
- };
3040
- const el = (scrollRef == null ? void 0 : scrollRef.current) || floating;
3041
- const overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, el.scrollHeight), detectOverflowOptions);
3042
- const refOverflow = await detectOverflow(nextArgs, {
3043
- ...detectOverflowOptions,
3044
- elementContext: "reference"
3045
- });
3046
- const diffY = Math.max(0, overflow.top);
3047
- const nextY = nextArgs.y + diffY;
3048
- const maxHeight = Math.max(0, el.scrollHeight - diffY - Math.max(0, overflow.bottom));
3049
- el.style.maxHeight = maxHeight + "px";
3050
- el.scrollTop = diffY;
3051
- if (onFallbackChange) {
3052
- if (el.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current.length - 1) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold) {
3053
- ReactDOM.flushSync(() => onFallbackChange(true));
3054
- } else {
3055
- ReactDOM.flushSync(() => onFallbackChange(false));
3056
- }
3057
- }
3058
- if (overflowRef) {
3059
- overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({
3060
- ...nextArgs,
3061
- y: nextY
3062
- }, el.offsetHeight), detectOverflowOptions);
3063
- }
3064
- return {
3065
- y: nextY
3066
- };
3067
- }
3068
- });
3069
- function useInnerOffset(context, props) {
3070
- const {
3071
- open,
3072
- elements
3073
- } = context;
3074
- const {
3075
- enabled = true,
3076
- overflowRef,
3077
- scrollRef,
3078
- onChange: unstable_onChange
3079
- } = props;
3080
- const onChange = useEffectEvent(unstable_onChange);
3081
- const controlledScrollingRef = React.useRef(false);
3082
- const prevScrollTopRef = React.useRef(null);
3083
- const initialOverflowRef = React.useRef(null);
3084
- React.useEffect(() => {
3085
- if (!enabled) return;
3086
- function onWheel(e2) {
3087
- if (e2.ctrlKey || !el || overflowRef.current == null) {
3088
- return;
3089
- }
3090
- const dY = e2.deltaY;
3091
- const isAtTop = overflowRef.current.top >= -0.5;
3092
- const isAtBottom = overflowRef.current.bottom >= -0.5;
3093
- const remainingScroll = el.scrollHeight - el.clientHeight;
3094
- const sign = dY < 0 ? -1 : 1;
3095
- const method = dY < 0 ? "max" : "min";
3096
- if (el.scrollHeight <= el.clientHeight) {
3097
- return;
3098
- }
3099
- if (!isAtTop && dY > 0 || !isAtBottom && dY < 0) {
3100
- e2.preventDefault();
3101
- ReactDOM.flushSync(() => {
3102
- onChange((d2) => d2 + Math[method](dY, remainingScroll * sign));
3103
- });
3104
- } else if (/firefox/i.test(getUserAgent())) {
3105
- el.scrollTop += dY;
3106
- }
3107
- }
3108
- const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3109
- if (open && el) {
3110
- el.addEventListener("wheel", onWheel);
3111
- requestAnimationFrame(() => {
3112
- prevScrollTopRef.current = el.scrollTop;
3113
- if (overflowRef.current != null) {
3114
- initialOverflowRef.current = {
3115
- ...overflowRef.current
3116
- };
3117
- }
3118
- });
3119
- return () => {
3120
- prevScrollTopRef.current = null;
3121
- initialOverflowRef.current = null;
3122
- el.removeEventListener("wheel", onWheel);
3123
- };
3124
- }
3125
- }, [enabled, open, elements.floating, overflowRef, scrollRef, onChange]);
3126
- const floating = React.useMemo(() => ({
3127
- onKeyDown() {
3128
- controlledScrollingRef.current = true;
3129
- },
3130
- onWheel() {
3131
- controlledScrollingRef.current = false;
3132
- },
3133
- onPointerMove() {
3134
- controlledScrollingRef.current = false;
3135
- },
3136
- onScroll() {
3137
- const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;
3138
- if (!overflowRef.current || !el || !controlledScrollingRef.current) {
3139
- return;
3140
- }
3141
- if (prevScrollTopRef.current !== null) {
3142
- const scrollDiff = el.scrollTop - prevScrollTopRef.current;
3143
- if (overflowRef.current.bottom < -0.5 && scrollDiff < -1 || overflowRef.current.top < -0.5 && scrollDiff > 1) {
3144
- ReactDOM.flushSync(() => onChange((d2) => d2 + scrollDiff));
3145
- }
3146
- }
3147
- requestAnimationFrame(() => {
3148
- prevScrollTopRef.current = el.scrollTop;
3149
- });
3150
- }
3151
- }), [elements.floating, onChange, overflowRef, scrollRef]);
3152
- return React.useMemo(() => enabled ? {
3153
- floating
3154
- } : {}, [enabled, floating]);
3155
- }
3156
- let y$1 = createContext({ styles: void 0, setReference: () => {
3157
- }, setFloating: () => {
3158
- }, getReferenceProps: () => ({}), getFloatingProps: () => ({}), slot: {} });
3159
- y$1.displayName = "FloatingContext";
3160
- let S$1 = createContext(null);
3161
- S$1.displayName = "PlacementContext";
3162
- function xe$1(e2) {
3163
- return useMemo(() => e2 ? typeof e2 == "string" ? { to: e2 } : e2 : null, [e2]);
3164
- }
3165
- function ye() {
3166
- return useContext(y$1).setReference;
3167
- }
3168
- function be() {
3169
- let { getFloatingProps: e2, slot: t2 } = useContext(y$1);
3170
- return useCallback((...n2) => Object.assign({}, e2(...n2), { "data-anchor": t2.anchor }), [e2, t2]);
3171
- }
3172
- function Re(e2 = null) {
3173
- e2 === false && (e2 = null), typeof e2 == "string" && (e2 = { to: e2 });
3174
- let t2 = useContext(S$1), n2 = useMemo(() => e2, [JSON.stringify(e2, typeof HTMLElement != "undefined" ? (r2, o2) => o2 instanceof HTMLElement ? o2.outerHTML : o2 : void 0)]);
3175
- n$2(() => {
3176
- t2 == null || t2(n2 != null ? n2 : null);
3177
- }, [t2, n2]);
3178
- let l2 = useContext(y$1);
3179
- return useMemo(() => [l2.setFloating, e2 ? l2.styles : {}], [l2.setFloating, e2, l2.styles]);
3180
- }
3181
- let q = 4;
3182
- function ve({ children: e2, enabled: t2 = true }) {
3183
- let [n2, l2] = useState(null), [r2, o2] = useState(0), c2 = useRef(null), [u2, s2] = useState(null);
3184
- pe(u2);
3185
- let i2 = t2 && n2 !== null && u2 !== null, { to: F2 = "bottom", gap: C = 0, offset: M2 = 0, padding: p2 = 0, inner: P } = ce(n2, u2), [a3, f2 = "center"] = F2.split(" ");
3186
- n$2(() => {
3187
- i2 && o2(0);
3188
- }, [i2]);
3189
- let { refs: b, floatingStyles: w2, context: g2 } = useFloating({ open: i2, placement: a3 === "selection" ? f2 === "center" ? "bottom" : `bottom-${f2}` : f2 === "center" ? `${a3}` : `${a3}-${f2}`, strategy: "absolute", transform: false, middleware: [offset({ mainAxis: a3 === "selection" ? 0 : C, crossAxis: M2 }), shift({ padding: p2 }), a3 !== "selection" && flip({ padding: p2 }), a3 === "selection" && P ? inner({ ...P, padding: p2, overflowRef: c2, offset: r2, minItemsVisible: q, referenceOverflowThreshold: p2, onFallbackChange(h2) {
3190
- var O, W2;
3191
- if (!h2) return;
3192
- let d2 = g2.elements.floating;
3193
- if (!d2) return;
3194
- let T2 = parseFloat(getComputedStyle(d2).scrollPaddingBottom) || 0, $ = Math.min(q, d2.childElementCount), B = 0, N2 = 0;
3195
- for (let m2 of (W2 = (O = g2.elements.floating) == null ? void 0 : O.childNodes) != null ? W2 : []) if (m2 instanceof HTMLElement) {
3196
- let x2 = m2.offsetTop, k = x2 + m2.clientHeight + T2, H2 = d2.scrollTop, U = H2 + d2.clientHeight;
3197
- if (x2 >= H2 && k <= U) $--;
3198
- else {
3199
- N2 = Math.max(0, Math.min(k, U) - Math.max(x2, H2)), B = m2.clientHeight;
3200
- break;
3201
- }
3202
- }
3203
- $ >= 1 && o2((m2) => {
3204
- let x2 = B * $ - N2 + T2;
3205
- return m2 >= x2 ? m2 : x2;
3206
- });
3207
- } }) : null, size({ padding: p2, apply({ availableWidth: h2, availableHeight: d2, elements: T2 }) {
3208
- Object.assign(T2.floating.style, { overflow: "auto", maxWidth: `${h2}px`, maxHeight: `min(var(--anchor-max-height, 100vh), ${d2}px)` });
3209
- } })].filter(Boolean), whileElementsMounted: autoUpdate }), [I2 = a3, V2 = f2] = g2.placement.split("-");
3210
- a3 === "selection" && (I2 = "selection");
3211
- let G2 = useMemo(() => ({ anchor: [I2, V2].filter(Boolean).join(" ") }), [I2, V2]), K2 = useInnerOffset(g2, { overflowRef: c2, onChange: o2 }), { getReferenceProps: Q, getFloatingProps: X } = useInteractions([K2]), Y = o$2((h2) => {
3212
- s2(h2), b.setFloating(h2);
3213
- });
3214
- return React.createElement(S$1.Provider, { value: l2 }, React.createElement(y$1.Provider, { value: { setFloating: Y, setReference: b.setReference, styles: w2, getReferenceProps: Q, getFloatingProps: X, slot: G2 } }, e2));
3215
- }
3216
- function pe(e2) {
3217
- n$2(() => {
3218
- if (!e2) return;
3219
- let t2 = new MutationObserver(() => {
3220
- let n2 = window.getComputedStyle(e2).maxHeight, l2 = parseFloat(n2);
3221
- if (isNaN(l2)) return;
3222
- let r2 = parseInt(n2);
3223
- isNaN(r2) || l2 !== r2 && (e2.style.maxHeight = `${Math.ceil(l2)}px`);
3224
- });
3225
- return t2.observe(e2, { attributes: true, attributeFilter: ["style"] }), () => {
3226
- t2.disconnect();
3227
- };
3228
- }, [e2]);
3229
- }
3230
- function ce(e2, t2) {
3231
- var o2, c2, u2;
3232
- let n2 = L((o2 = e2 == null ? void 0 : e2.gap) != null ? o2 : "var(--anchor-gap, 0)", t2), l2 = L((c2 = e2 == null ? void 0 : e2.offset) != null ? c2 : "var(--anchor-offset, 0)", t2), r2 = L((u2 = e2 == null ? void 0 : e2.padding) != null ? u2 : "var(--anchor-padding, 0)", t2);
3233
- return { ...e2, gap: n2, offset: l2, padding: r2 };
3234
- }
3235
- function L(e2, t2, n2 = void 0) {
3236
- let l2 = p$1(), r2 = o$2((s2, i2) => {
3237
- if (s2 == null) return [n2, null];
3238
- if (typeof s2 == "number") return [s2, null];
3239
- if (typeof s2 == "string") {
3240
- if (!i2) return [n2, null];
3241
- let F2 = J$1(s2, i2);
3242
- return [F2, (C) => {
3243
- let M2 = D$1(s2);
3244
- {
3245
- let p2 = M2.map((P) => window.getComputedStyle(i2).getPropertyValue(P));
3246
- l2.requestAnimationFrame(function P() {
3247
- l2.nextFrame(P);
3248
- let a3 = false;
3249
- for (let [b, w2] of M2.entries()) {
3250
- let g2 = window.getComputedStyle(i2).getPropertyValue(w2);
3251
- if (p2[b] !== g2) {
3252
- p2[b] = g2, a3 = true;
3253
- break;
3254
- }
3255
- }
3256
- if (!a3) return;
3257
- let f2 = J$1(s2, i2);
3258
- F2 !== f2 && (C(f2), F2 = f2);
3259
- });
3260
- }
3261
- return l2.dispose;
3262
- }];
3263
- }
3264
- return [n2, null];
3265
- }), o2 = useMemo(() => r2(e2, t2)[0], [e2, t2]), [c2 = o2, u2] = useState();
3266
- return n$2(() => {
3267
- let [s2, i2] = r2(e2, t2);
3268
- if (u2(s2), !!i2) return i2(u2);
3269
- }, [e2, t2]), c2;
3270
- }
3271
- function D$1(e2) {
3272
- let t2 = /var\((.*)\)/.exec(e2);
3273
- if (t2) {
3274
- let n2 = t2[1].indexOf(",");
3275
- if (n2 === -1) return [t2[1]];
3276
- let l2 = t2[1].slice(0, n2).trim(), r2 = t2[1].slice(n2 + 1).trim();
3277
- return r2 ? [l2, ...D$1(r2)] : [l2];
3278
- }
3279
- return [];
3280
- }
3281
- function J$1(e2, t2) {
3282
- let n2 = document.createElement("div");
3283
- t2.appendChild(n2), n2.style.setProperty("margin-top", "0px", "important"), n2.style.setProperty("margin-top", e2, "important");
3284
- let l2 = parseFloat(window.getComputedStyle(n2).marginTop) || 0;
3285
- return t2.removeChild(n2), l2;
3286
- }
3287
- function f$1({ children: o2, freeze: e2 }) {
3288
- let n2 = l$2(e2, o2);
3289
- return React__default.createElement(React__default.Fragment, null, n2);
3290
- }
3291
- function l$2(o2, e2) {
3292
- let [n2, t2] = useState(e2);
3293
- return !o2 && n2 !== e2 && t2(e2), o2 ? n2 : e2;
3294
- }
3295
- function t(n2) {
3296
- function e2() {
3297
- document.readyState !== "loading" && (n2(), document.removeEventListener("DOMContentLoaded", e2));
3298
- }
3299
- typeof window != "undefined" && typeof document != "undefined" && (document.addEventListener("DOMContentLoaded", e2), e2());
3300
- }
3301
- let r = [];
3302
- t(() => {
3303
- function e2(t2) {
3304
- if (!(t2.target instanceof HTMLElement) || t2.target === document.body || r[0] === t2.target) return;
3305
- let n2 = t2.target;
3306
- n2 = n2.closest(f$6), r.unshift(n2 != null ? n2 : t2.target), r = r.filter((o2) => o2 != null && o2.isConnected), r.splice(10);
3307
- }
3308
- window.addEventListener("click", e2, { capture: true }), window.addEventListener("mousedown", e2, { capture: true }), window.addEventListener("focus", e2, { capture: true }), document.body.addEventListener("click", e2, { capture: true }), document.body.addEventListener("mousedown", e2, { capture: true }), document.body.addEventListener("focus", e2, { capture: true });
3309
- });
3310
- function u(l2) {
3311
- throw new Error("Unexpected object: " + l2);
3312
- }
3313
- var c$1 = ((i2) => (i2[i2.First = 0] = "First", i2[i2.Previous = 1] = "Previous", i2[i2.Next = 2] = "Next", i2[i2.Last = 3] = "Last", i2[i2.Specific = 4] = "Specific", i2[i2.Nothing = 5] = "Nothing", i2))(c$1 || {});
3314
- function f(l2, n2) {
3315
- let t2 = n2.resolveItems();
3316
- if (t2.length <= 0) return null;
3317
- let r2 = n2.resolveActiveIndex(), s2 = r2 != null ? r2 : -1;
3318
- switch (l2.focus) {
3319
- case 0: {
3320
- for (let e2 = 0; e2 < t2.length; ++e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3321
- return r2;
3322
- }
3323
- case 1: {
3324
- s2 === -1 && (s2 = t2.length);
3325
- for (let e2 = s2 - 1; e2 >= 0; --e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3326
- return r2;
3327
- }
3328
- case 2: {
3329
- for (let e2 = s2 + 1; e2 < t2.length; ++e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3330
- return r2;
3331
- }
3332
- case 3: {
3333
- for (let e2 = t2.length - 1; e2 >= 0; --e2) if (!n2.resolveDisabled(t2[e2], e2, t2)) return e2;
3334
- return r2;
3335
- }
3336
- case 4: {
3337
- for (let e2 = 0; e2 < t2.length; ++e2) if (n2.resolveId(t2[e2], e2, t2) === l2.id) return e2;
3338
- return r2;
3339
- }
3340
- case 5:
3341
- return null;
3342
- default:
3343
- u(l2);
3344
- }
3345
- }
3346
- var g = ((f2) => (f2[f2.Left = 0] = "Left", f2[f2.Right = 2] = "Right", f2))(g || {});
3347
- function c(t2) {
3348
- let r2 = o$2(t2), e2 = useRef(false);
3349
- useEffect(() => (e2.current = false, () => {
3350
- e2.current = true, t$3(() => {
3351
- e2.current && r2();
3352
- });
3353
- }), [r2]);
3354
- }
3355
- function s() {
3356
- let r2 = typeof document == "undefined";
3357
- return "useSyncExternalStore" in React ? ((o2) => o2.useSyncExternalStore)(React)(() => () => {
3358
- }, () => false, () => !r2) : false;
3359
- }
3360
- function l$1() {
3361
- let r2 = s(), [e2, n2] = React.useState(s$4.isHandoffComplete);
3362
- return e2 && s$4.isHandoffComplete === false && n2(false), React.useEffect(() => {
3363
- e2 !== true && n2(true);
3364
- }, [e2]), React.useEffect(() => s$4.handoff(), []), r2 ? false : e2;
3365
- }
3366
- let e = createContext(false);
3367
- function a2() {
3368
- return useContext(e);
3369
- }
3370
- function D(p2) {
3371
- let r2 = a2(), l2 = useContext(v), e2 = n(p2), [o2, n$12] = useState(() => {
3372
- var t2;
3373
- if (!r2 && l2 !== null) return (t2 = l2.current) != null ? t2 : null;
3374
- if (s$4.isServer) return null;
3375
- let u2 = e2 == null ? void 0 : e2.getElementById("headlessui-portal-root");
3376
- if (u2) return u2;
3377
- if (e2 === null) return null;
3378
- let a3 = e2.createElement("div");
3379
- return a3.setAttribute("id", "headlessui-portal-root"), e2.body.appendChild(a3);
3380
- });
3381
- return useEffect(() => {
3382
- o2 !== null && (e2 != null && e2.body.contains(o2) || e2 == null || e2.body.appendChild(o2));
3383
- }, [o2, e2]), useEffect(() => {
3384
- r2 || l2 !== null && n$12(l2.current);
3385
- }, [l2, n$12, r2]), o2;
3386
- }
3387
- let M = Fragment, N = W$1(function(r2, l2) {
3388
- let e2 = r2, o2 = useRef(null), n$12 = y$3(T((i2) => {
3389
- o2.current = i2;
3390
- }), l2), u2 = n(o2), a3 = D(o2), [t2] = useState(() => {
3391
- var i2;
3392
- return s$4.isServer ? null : (i2 = u2 == null ? void 0 : u2.createElement("div")) != null ? i2 : null;
3393
- }), s2 = useContext(y), b = l$1();
3394
- return n$2(() => {
3395
- !a3 || !t2 || a3.contains(t2) || (t2.setAttribute("data-headlessui-portal", ""), a3.appendChild(t2));
3396
- }, [a3, t2]), n$2(() => {
3397
- if (t2 && s2) return s2.register(t2);
3398
- }, [s2, t2]), c(() => {
3399
- var i2;
3400
- !a3 || !t2 || (t2 instanceof Node && a3.contains(t2) && a3.removeChild(t2), a3.childNodes.length <= 0 && ((i2 = a3.parentElement) == null || i2.removeChild(a3)));
3401
- }), b ? !a3 || !t2 ? null : createPortal(H({ ourProps: { ref: n$12 }, theirProps: e2, slot: {}, defaultTag: M, name: "Portal" }), t2) : null;
3402
- });
3403
- function S(p2, r2) {
3404
- let l2 = y$3(r2), { enabled: e2 = true, ...o2 } = p2;
3405
- return e2 ? React__default.createElement(N, { ...o2, ref: l2 }) : H({ ourProps: { ref: l2 }, theirProps: o2, slot: {}, defaultTag: M, name: "Portal" });
3406
- }
3407
- let j = Fragment, v = createContext(null);
3408
- function W(p2, r2) {
3409
- let { target: l2, ...e2 } = p2, n2 = { ref: y$3(r2) };
3410
- return React__default.createElement(v.Provider, { value: l2 }, H({ ourProps: n2, theirProps: e2, defaultTag: j, name: "Popover.Group" }));
3411
- }
3412
- let y = createContext(null);
3413
- let I = W$1(S), J = W$1(W), te = Object.assign(I, { Group: J });
3414
- var Co = ((e2) => (e2[e2.Open = 0] = "Open", e2[e2.Closed = 1] = "Closed", e2))(Co || {}), Ro = ((e2) => (e2[e2.Single = 0] = "Single", e2[e2.Multi = 1] = "Multi", e2))(Ro || {}), So = ((t2) => (t2[t2.Pointer = 0] = "Pointer", t2[t2.Focus = 1] = "Focus", t2[t2.Other = 2] = "Other", t2))(So || {}), Po = ((u2) => (u2[u2.OpenCombobox = 0] = "OpenCombobox", u2[u2.CloseCombobox = 1] = "CloseCombobox", u2[u2.GoToOption = 2] = "GoToOption", u2[u2.SetTyping = 3] = "SetTyping", u2[u2.RegisterOption = 4] = "RegisterOption", u2[u2.UnregisterOption = 5] = "UnregisterOption", u2[u2.SetActivationTrigger = 6] = "SetActivationTrigger", u2[u2.UpdateVirtualConfiguration = 7] = "UpdateVirtualConfiguration", u2))(Po || {});
3415
- function Te(o2, r2 = (e2) => e2) {
3416
- let e2 = o2.activeOptionIndex !== null ? o2.options[o2.activeOptionIndex] : null, t2 = r2(o2.options.slice()), c2 = t2.length > 0 && t2[0].dataRef.current.order !== null ? t2.sort((f2, s2) => f2.dataRef.current.order - s2.dataRef.current.order) : _(t2, (f2) => f2.dataRef.current.domRef.current), d2 = e2 ? c2.indexOf(e2) : null;
3417
- return d2 === -1 && (d2 = null), { options: c2, activeOptionIndex: d2 };
3418
- }
3419
- let Ao = { [1](o2) {
3420
- var r2;
3421
- return (r2 = o2.dataRef.current) != null && r2.disabled || o2.comboboxState === 1 ? o2 : { ...o2, activeOptionIndex: null, comboboxState: 1, isTyping: false, activationTrigger: 2, __demoMode: false };
3422
- }, [0](o2) {
3423
- var r2, e2;
3424
- if ((r2 = o2.dataRef.current) != null && r2.disabled || o2.comboboxState === 0) return o2;
3425
- if ((e2 = o2.dataRef.current) != null && e2.value) {
3426
- let t2 = o2.dataRef.current.calculateIndex(o2.dataRef.current.value);
3427
- if (t2 !== -1) return { ...o2, activeOptionIndex: t2, comboboxState: 0, __demoMode: false };
3428
- }
3429
- return { ...o2, comboboxState: 0, __demoMode: false };
3430
- }, [3](o2, r2) {
3431
- return o2.isTyping === r2.isTyping ? o2 : { ...o2, isTyping: r2.isTyping };
3432
- }, [2](o2, r2) {
3433
- var d2, f$12, s2, u2, a3;
3434
- if ((d2 = o2.dataRef.current) != null && d2.disabled || (f$12 = o2.dataRef.current) != null && f$12.optionsRef.current && !((s2 = o2.dataRef.current) != null && s2.optionsPropsRef.current.static) && o2.comboboxState === 1) return o2;
3435
- if (o2.virtual) {
3436
- let { options: n2, disabled: T2 } = o2.virtual, C = r2.focus === c$1.Specific ? r2.idx : f(r2, { resolveItems: () => n2, resolveActiveIndex: () => {
3437
- var p2, L2;
3438
- return (L2 = (p2 = o2.activeOptionIndex) != null ? p2 : n2.findIndex((M2) => !T2(M2))) != null ? L2 : null;
3439
- }, resolveDisabled: T2, resolveId() {
3440
- throw new Error("Function not implemented.");
3441
- } }), _2 = (u2 = r2.trigger) != null ? u2 : 2;
3442
- return o2.activeOptionIndex === C && o2.activationTrigger === _2 ? o2 : { ...o2, activeOptionIndex: C, activationTrigger: _2, isTyping: false, __demoMode: false };
3443
- }
3444
- let e2 = Te(o2);
3445
- if (e2.activeOptionIndex === null) {
3446
- let n2 = e2.options.findIndex((T2) => !T2.dataRef.current.disabled);
3447
- n2 !== -1 && (e2.activeOptionIndex = n2);
3448
- }
3449
- let t2 = r2.focus === c$1.Specific ? r2.idx : f(r2, { resolveItems: () => e2.options, resolveActiveIndex: () => e2.activeOptionIndex, resolveId: (n2) => n2.id, resolveDisabled: (n2) => n2.dataRef.current.disabled }), c2 = (a3 = r2.trigger) != null ? a3 : 2;
3450
- return o2.activeOptionIndex === t2 && o2.activationTrigger === c2 ? o2 : { ...o2, ...e2, isTyping: false, activeOptionIndex: t2, activationTrigger: c2, __demoMode: false };
3451
- }, [4]: (o2, r2) => {
3452
- var d2, f2, s2;
3453
- if ((d2 = o2.dataRef.current) != null && d2.virtual) return { ...o2, options: [...o2.options, r2.payload] };
3454
- let e2 = r2.payload, t2 = Te(o2, (u2) => (u2.push(e2), u2));
3455
- o2.activeOptionIndex === null && (f2 = o2.dataRef.current) != null && f2.isSelected(r2.payload.dataRef.current.value) && (t2.activeOptionIndex = t2.options.indexOf(e2));
3456
- let c2 = { ...o2, ...t2, activationTrigger: 2 };
3457
- return (s2 = o2.dataRef.current) != null && s2.__demoMode && o2.dataRef.current.value === void 0 && (c2.activeOptionIndex = 0), c2;
3458
- }, [5]: (o2, r2) => {
3459
- var t2;
3460
- if ((t2 = o2.dataRef.current) != null && t2.virtual) return { ...o2, options: o2.options.filter((c2) => c2.id !== r2.id) };
3461
- let e2 = Te(o2, (c2) => {
3462
- let d2 = c2.findIndex((f2) => f2.id === r2.id);
3463
- return d2 !== -1 && c2.splice(d2, 1), c2;
3464
- });
3465
- return { ...o2, ...e2, activationTrigger: 2 };
3466
- }, [6]: (o2, r2) => o2.activationTrigger === r2.trigger ? o2 : { ...o2, activationTrigger: r2.trigger }, [7]: (o2, r2) => {
3467
- var t2, c2;
3468
- if (o2.virtual === null) return { ...o2, virtual: { options: r2.options, disabled: (t2 = r2.disabled) != null ? t2 : () => false } };
3469
- if (o2.virtual.options === r2.options && o2.virtual.disabled === r2.disabled) return o2;
3470
- let e2 = o2.activeOptionIndex;
3471
- if (o2.activeOptionIndex !== null) {
3472
- let d2 = r2.options.indexOf(o2.virtual.options[o2.activeOptionIndex]);
3473
- d2 !== -1 ? e2 = d2 : e2 = null;
3474
- }
3475
- return { ...o2, activeOptionIndex: e2, virtual: { options: r2.options, disabled: (c2 = r2.disabled) != null ? c2 : () => false } };
3476
- } }, xe = createContext(null);
3477
- xe.displayName = "ComboboxActionsContext";
3478
- function re(o2) {
3479
- let r2 = useContext(xe);
3480
- if (r2 === null) {
3481
- let e2 = new Error(`<${o2} /> is missing a parent <Combobox /> component.`);
3482
- throw Error.captureStackTrace && Error.captureStackTrace(e2, re), e2;
3483
- }
3484
- return r2;
3485
- }
3486
- let Le = createContext(null);
3487
- function Io(o2) {
3488
- let r2 = oe("VirtualProvider"), { options: e2 } = r2.virtual, [t2, c2] = useMemo(() => {
3489
- let a3 = r2.optionsRef.current;
3490
- if (!a3) return [0, 0];
3491
- let n2 = window.getComputedStyle(a3);
3492
- return [parseFloat(n2.paddingBlockStart || n2.paddingTop), parseFloat(n2.paddingBlockEnd || n2.paddingBottom)];
3493
- }, [r2.optionsRef.current]), d2 = useVirtualizer({ enabled: e2.length !== 0, scrollPaddingStart: t2, scrollPaddingEnd: c2, count: e2.length, estimateSize() {
3494
- return 40;
3495
- }, getScrollElement() {
3496
- var a3;
3497
- return (a3 = r2.optionsRef.current) != null ? a3 : null;
3498
- }, overscan: 12 }), [f2, s2] = useState(0);
3499
- n$2(() => {
3500
- s2((a3) => a3 + 1);
3501
- }, [e2]);
3502
- let u2 = d2.getVirtualItems();
3503
- return u2.length === 0 ? null : React__default.createElement(Le.Provider, { value: d2 }, React__default.createElement("div", { style: { position: "relative", width: "100%", height: `${d2.getTotalSize()}px` }, ref: (a3) => {
3504
- if (a3) {
3505
- if (typeof process != "undefined" && process.env.JEST_WORKER_ID !== void 0 || r2.activationTrigger === 0) return;
3506
- r2.activeOptionIndex !== null && e2.length > r2.activeOptionIndex && d2.scrollToIndex(r2.activeOptionIndex);
3507
- }
3508
- } }, u2.map((a3) => {
3509
- var n2;
3510
- return React__default.createElement(Fragment, { key: a3.key }, React__default.cloneElement((n2 = o2.children) == null ? void 0 : n2.call(o2, { ...o2.slot, option: e2[a3.index] }), { key: `${f2}-${a3.key}`, "data-index": a3.index, "aria-setsize": e2.length, "aria-posinset": a3.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${a3.start}px)`, overflowAnchor: "none" } }));
3511
- })));
3512
- }
3513
- let ie = createContext(null);
3514
- ie.displayName = "ComboboxDataContext";
3515
- function oe(o2) {
3516
- let r2 = useContext(ie);
3517
- if (r2 === null) {
3518
- let e2 = new Error(`<${o2} /> is missing a parent <Combobox /> component.`);
3519
- throw Error.captureStackTrace && Error.captureStackTrace(e2, oe), e2;
3520
- }
3521
- return r2;
3522
- }
3523
- function Eo(o2, r2) {
3524
- return u$5(r2.type, Ao, o2, r2);
3525
- }
3526
- let _o = Fragment;
3527
- function ho(o2, r2) {
3528
- var ge, ve$1;
3529
- let e2 = a$5(), { value: t2, defaultValue: c2, onChange: d2, form: f2, name: s2, by: u2, disabled: a3 = e2 || false, onClose: n2, __demoMode: T2 = false, multiple: C = false, immediate: _2 = false, virtual: p2 = null, nullable: L2, ...M2 } = o2, F2 = l$3(c2), [v2 = C ? [] : void 0, y2] = T$1(t2, d2, F2), [A2, R] = useReducer(Eo, { dataRef: createRef(), comboboxState: T2 ? 0 : 1, isTyping: false, options: [], virtual: p2 ? { options: p2.options, disabled: (ge = p2.disabled) != null ? ge : () => false } : null, activeOptionIndex: null, activationTrigger: 2, __demoMode: T2 }), h2 = useRef(false), O = useRef({ static: false, hold: false }), G2 = useRef(null), J2 = useRef(null), Q = useRef(null), I2 = u$4(u2), B = o$2((b) => p2 ? u2 === null ? p2.options.indexOf(b) : p2.options.findIndex((g2) => I2(g2, b)) : A2.options.findIndex((g2) => I2(g2.dataRef.current.value, b))), k = useCallback((b) => u$5(i2.mode, { [1]: () => v2.some((g2) => I2(g2, b)), [0]: () => I2(v2, b) }), [v2]), K2 = o$2((b) => A2.activeOptionIndex === B(b)), i2 = useMemo(() => ({ ...A2, immediate: _2, optionsPropsRef: O, inputRef: G2, buttonRef: J2, optionsRef: Q, value: v2, defaultValue: F2, disabled: a3, mode: C ? 1 : 0, virtual: p2 ? A2.virtual : null, get activeOptionIndex() {
3530
- if (h2.current && A2.activeOptionIndex === null && (p2 ? p2.options.length > 0 : A2.options.length > 0)) {
3531
- if (p2) {
3532
- let g2 = p2.options.findIndex((j2) => {
3533
- var ue, Oe;
3534
- return !((Oe = (ue = p2.disabled) == null ? void 0 : ue.call(p2, j2)) != null && Oe);
3535
- });
3536
- if (g2 !== -1) return g2;
3537
- }
3538
- let b = A2.options.findIndex((g2) => !g2.dataRef.current.disabled);
3539
- if (b !== -1) return b;
3540
- }
3541
- return A2.activeOptionIndex;
3542
- }, calculateIndex: B, compare: I2, isSelected: k, isActive: K2 }), [v2, F2, a3, C, T2, A2, p2]);
3543
- n$2(() => {
3544
- var b;
3545
- p2 && R({ type: 7, options: p2.options, disabled: (b = p2.disabled) != null ? b : null });
3546
- }, [p2, p2 == null ? void 0 : p2.options, p2 == null ? void 0 : p2.disabled]), n$2(() => {
3547
- A2.dataRef.current = i2;
3548
- }, [i2]);
3549
- let N2 = i2.comboboxState === 0;
3550
- F$1(N2, [i2.buttonRef, i2.inputRef, i2.optionsRef], () => x2.closeCombobox());
3551
- let q2 = useMemo(() => {
3552
- var b, g2, j2;
3553
- return { open: i2.comboboxState === 0, disabled: a3, activeIndex: i2.activeOptionIndex, activeOption: i2.activeOptionIndex === null ? null : i2.virtual ? i2.virtual.options[(b = i2.activeOptionIndex) != null ? b : 0] : (j2 = (g2 = i2.options[i2.activeOptionIndex]) == null ? void 0 : g2.dataRef.current.value) != null ? j2 : null, value: v2 };
3554
- }, [i2, a3, v2]), Y = o$2(() => {
3555
- if (i2.activeOptionIndex !== null) {
3556
- if (x2.setIsTyping(false), i2.virtual) S2(i2.virtual.options[i2.activeOptionIndex]);
3557
- else {
3558
- let { dataRef: b } = i2.options[i2.activeOptionIndex];
3559
- S2(b.current.value);
3560
- }
3561
- x2.goToOption(c$1.Specific, i2.activeOptionIndex);
3562
- }
3563
- }), E2 = o$2(() => {
3564
- R({ type: 0 }), h2.current = true;
3565
- }), ae = o$2(() => {
3566
- R({ type: 1 }), h2.current = false, n2 == null || n2();
3567
- }), le = o$2((b) => {
3568
- R({ type: 3, isTyping: b });
3569
- }), l2 = o$2((b, g2, j2) => (h2.current = false, b === c$1.Specific ? R({ type: 2, focus: c$1.Specific, idx: g2, trigger: j2 }) : R({ type: 2, focus: b, trigger: j2 }))), U = o$2((b, g2) => (R({ type: 4, payload: { id: b, dataRef: g2 } }), () => {
3570
- i2.isActive(g2.current.value) && (h2.current = true), R({ type: 5, id: b });
3571
- })), S2 = o$2((b) => u$5(i2.mode, { [0]() {
3572
- return y2 == null ? void 0 : y2(b);
3573
- }, [1]() {
3574
- let g2 = i2.value.slice(), j2 = g2.findIndex((ue) => I2(ue, b));
3575
- return j2 === -1 ? g2.push(b) : g2.splice(j2, 1), y2 == null ? void 0 : y2(g2);
3576
- } })), H$1 = o$2((b) => {
3577
- R({ type: 6, trigger: b });
3578
- }), x2 = useMemo(() => ({ onChange: S2, registerOption: U, goToOption: l2, setIsTyping: le, closeCombobox: ae, openCombobox: E2, setActivationTrigger: H$1, selectActiveOption: Y }), []), [w2, W2] = z(), we = r2 === null ? {} : { ref: r2 }, Be = useCallback(() => {
3579
- if (F2 !== void 0) return y2 == null ? void 0 : y2(F2);
3580
- }, [y2, F2]);
3581
- return React__default.createElement(W2, { value: w2, props: { htmlFor: (ve$1 = i2.inputRef.current) == null ? void 0 : ve$1.id }, slot: { open: i2.comboboxState === 0, disabled: a3 } }, React__default.createElement(ve, null, React__default.createElement(xe.Provider, { value: x2 }, React__default.createElement(ie.Provider, { value: i2 }, React__default.createElement(c$2, { value: u$5(i2.comboboxState, { [0]: i$2.Open, [1]: i$2.Closed }) }, s2 != null && React__default.createElement(j$1, { disabled: a3, data: v2 != null ? { [s2]: v2 } : {}, form: f2, onReset: Be }), H({ ourProps: we, theirProps: M2, slot: q2, defaultTag: _o, name: "Combobox" }))))));
3582
- }
3583
- let Do = "input";
3584
- function Mo(o2, r$12) {
3585
- var q2, Y, E2, ae, le;
3586
- let e2 = oe("Combobox.Input"), t2 = re("Combobox.Input"), c2 = useId$1(), d2 = u$6(), { id: f2 = d2 || `headlessui-combobox-input-${c2}`, onChange: s2, displayValue: u2, disabled: a3 = e2.disabled || false, autoFocus: n$12 = false, type: T2 = "text", ...C } = o2, _2 = y$3(e2.inputRef, r$12, ye()), p2 = n(e2.inputRef), L2 = p$1(), M2 = o$2(() => {
3587
- t2.onChange(null), e2.optionsRef.current && (e2.optionsRef.current.scrollTop = 0), t2.goToOption(c$1.Nothing);
3588
- }), F2 = useMemo(() => {
3589
- var l2;
3590
- return typeof u2 == "function" && e2.value !== void 0 ? (l2 = u2(e2.value)) != null ? l2 : "" : typeof e2.value == "string" ? e2.value : "";
3591
- }, [e2.value, u2]);
3592
- m(([l2, U], [S2, H2]) => {
3593
- if (e2.isTyping) return;
3594
- let x2 = e2.inputRef.current;
3595
- x2 && ((H2 === 0 && U === 1 || l2 !== S2) && (x2.value = l2), requestAnimationFrame(() => {
3596
- if (e2.isTyping || !x2 || (p2 == null ? void 0 : p2.activeElement) !== x2) return;
3597
- let { selectionStart: w2, selectionEnd: W2 } = x2;
3598
- Math.abs((W2 != null ? W2 : 0) - (w2 != null ? w2 : 0)) === 0 && w2 === 0 && x2.setSelectionRange(x2.value.length, x2.value.length);
3599
- }));
3600
- }, [F2, e2.comboboxState, p2, e2.isTyping]), m(([l2], [U]) => {
3601
- if (l2 === 0 && U === 1) {
3602
- if (e2.isTyping) return;
3603
- let S2 = e2.inputRef.current;
3604
- if (!S2) return;
3605
- let H2 = S2.value, { selectionStart: x2, selectionEnd: w2, selectionDirection: W2 } = S2;
3606
- S2.value = "", S2.value = H2, W2 !== null ? S2.setSelectionRange(x2, w2, W2) : S2.setSelectionRange(x2, w2);
3607
- }
3608
- }, [e2.comboboxState]);
3609
- let v2 = useRef(false), y2 = o$2(() => {
3610
- v2.current = true;
3611
- }), A2 = o$2(() => {
3612
- L2.nextFrame(() => {
3613
- v2.current = false;
3614
- });
3615
- }), R = o$2((l2) => {
3616
- switch (t2.setIsTyping(true), l2.key) {
3617
- case o$3.Enter:
3618
- if (e2.comboboxState !== 0 || v2.current) return;
3619
- if (l2.preventDefault(), l2.stopPropagation(), e2.activeOptionIndex === null) {
3620
- t2.closeCombobox();
3621
- return;
3622
- }
3623
- t2.selectActiveOption(), e2.mode === 0 && t2.closeCombobox();
3624
- break;
3625
- case o$3.ArrowDown:
3626
- return l2.preventDefault(), l2.stopPropagation(), u$5(e2.comboboxState, { [0]: () => t2.goToOption(c$1.Next), [1]: () => t2.openCombobox() });
3627
- case o$3.ArrowUp:
3628
- return l2.preventDefault(), l2.stopPropagation(), u$5(e2.comboboxState, { [0]: () => t2.goToOption(c$1.Previous), [1]: () => {
3629
- flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.Last);
3630
- } });
3631
- case o$3.Home:
3632
- if (l2.shiftKey) break;
3633
- return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.First);
3634
- case o$3.PageUp:
3635
- return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.First);
3636
- case o$3.End:
3637
- if (l2.shiftKey) break;
3638
- return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.Last);
3639
- case o$3.PageDown:
3640
- return l2.preventDefault(), l2.stopPropagation(), t2.goToOption(c$1.Last);
3641
- case o$3.Escape:
3642
- return e2.comboboxState !== 0 ? void 0 : (l2.preventDefault(), e2.optionsRef.current && !e2.optionsPropsRef.current.static && l2.stopPropagation(), e2.mode === 0 && e2.value === null && M2(), t2.closeCombobox());
3643
- case o$3.Tab:
3644
- if (e2.comboboxState !== 0) return;
3645
- e2.mode === 0 && e2.activationTrigger !== 1 && t2.selectActiveOption(), t2.closeCombobox();
3646
- break;
3647
- }
3648
- }), h2 = o$2((l2) => {
3649
- s2 == null || s2(l2), e2.mode === 0 && l2.target.value === "" && M2(), t2.openCombobox();
3650
- }), O = o$2((l2) => {
3651
- var S2, H2, x2;
3652
- let U = (S2 = l2.relatedTarget) != null ? S2 : r.find((w2) => w2 !== l2.currentTarget);
3653
- if (!((H2 = e2.optionsRef.current) != null && H2.contains(U)) && !((x2 = e2.buttonRef.current) != null && x2.contains(U)) && e2.comboboxState === 0) return l2.preventDefault(), e2.mode === 0 && e2.value === null && M2(), t2.closeCombobox();
3654
- }), G$1 = o$2((l2) => {
3655
- var S2, H2, x2;
3656
- let U = (S2 = l2.relatedTarget) != null ? S2 : r.find((w2) => w2 !== l2.currentTarget);
3657
- (H2 = e2.buttonRef.current) != null && H2.contains(U) || (x2 = e2.optionsRef.current) != null && x2.contains(U) || e2.disabled || e2.immediate && e2.comboboxState !== 0 && L2.microTask(() => {
3658
- flushSync(() => t2.openCombobox()), t2.setActivationTrigger(1);
3659
- });
3660
- }), J2 = I$1(), Q = G(), { isFocused: I2, focusProps: B } = $f7dceffc5ad7768b$export$4e328f61c538687f({ autoFocus: n$12 }), { isHovered: k, hoverProps: K2 } = $6179b936705e76d3$export$ae780daf29e6d456({ isDisabled: a3 }), i2 = useMemo(() => ({ open: e2.comboboxState === 0, disabled: a3, hover: k, focus: I2, autofocus: n$12 }), [e2, k, I2, n$12, a3]), N2 = D$2({ ref: _2, id: f2, role: "combobox", type: T2, "aria-controls": (q2 = e2.optionsRef.current) == null ? void 0 : q2.id, "aria-expanded": e2.comboboxState === 0, "aria-activedescendant": e2.activeOptionIndex === null ? void 0 : e2.virtual ? (Y = e2.options.find((l2) => !l2.dataRef.current.disabled && e2.compare(l2.dataRef.current.value, e2.virtual.options[e2.activeOptionIndex]))) == null ? void 0 : Y.id : (E2 = e2.options[e2.activeOptionIndex]) == null ? void 0 : E2.id, "aria-labelledby": J2, "aria-describedby": Q, "aria-autocomplete": "list", defaultValue: (le = (ae = o2.defaultValue) != null ? ae : e2.defaultValue !== void 0 ? u2 == null ? void 0 : u2(e2.defaultValue) : null) != null ? le : e2.defaultValue, disabled: a3 || void 0, autoFocus: n$12, onCompositionStart: y2, onCompositionEnd: A2, onKeyDown: R, onChange: h2, onFocus: G$1, onBlur: O }, B, K2);
3661
- return H({ ourProps: N2, theirProps: C, slot: i2, defaultTag: Do, name: "Combobox.Input" });
3662
- }
3663
- let Fo = "button";
3664
- function Vo(o2, r2) {
3665
- var h2;
3666
- let e2 = oe("Combobox.Button"), t2 = re("Combobox.Button"), c2 = y$3(e2.buttonRef, r2), d2 = useId$1(), { id: f2 = `headlessui-combobox-button-${d2}`, disabled: s2 = e2.disabled || false, autoFocus: u2 = false, ...a3 } = o2, n2 = f$3(e2.inputRef), T2 = o$2((O) => {
3667
- switch (O.key) {
3668
- case o$3.Space:
3669
- case o$3.Enter:
3670
- O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && flushSync(() => t2.openCombobox()), n2();
3671
- return;
3672
- case o$3.ArrowDown:
3673
- O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && (flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.First)), n2();
3674
- return;
3675
- case o$3.ArrowUp:
3676
- O.preventDefault(), O.stopPropagation(), e2.comboboxState === 1 && (flushSync(() => t2.openCombobox()), e2.value || t2.goToOption(c$1.Last)), n2();
3677
- return;
3678
- case o$3.Escape:
3679
- if (e2.comboboxState !== 0) return;
3680
- O.preventDefault(), e2.optionsRef.current && !e2.optionsPropsRef.current.static && O.stopPropagation(), flushSync(() => t2.closeCombobox()), n2();
3681
- return;
3682
- default:
3683
- return;
3684
- }
3685
- }), C = o$2((O) => {
3686
- O.preventDefault(), !r$2(O.currentTarget) && (O.button === g.Left && (e2.comboboxState === 0 ? t2.closeCombobox() : t2.openCombobox()), n2());
3687
- }), _2 = I$1([f2]), { isFocusVisible: p2, focusProps: L2 } = $f7dceffc5ad7768b$export$4e328f61c538687f({ autoFocus: u2 }), { isHovered: M2, hoverProps: F2 } = $6179b936705e76d3$export$ae780daf29e6d456({ isDisabled: s2 }), { pressed: v2, pressProps: y2 } = w({ disabled: s2 }), A2 = useMemo(() => ({ open: e2.comboboxState === 0, active: v2 || e2.comboboxState === 0, disabled: s2, value: e2.value, hover: M2, focus: p2 }), [e2, M2, p2, v2, s2]), R = D$2({ ref: c2, id: f2, type: T$2(o2, e2.buttonRef), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (h2 = e2.optionsRef.current) == null ? void 0 : h2.id, "aria-expanded": e2.comboboxState === 0, "aria-labelledby": _2, disabled: s2 || void 0, autoFocus: u2, onMouseDown: C, onKeyDown: T2 }, L2, F2, y2);
3688
- return H({ ourProps: R, theirProps: a3, slot: A2, defaultTag: Fo, name: "Combobox.Button" });
3689
- }
3690
- let Lo = "div", wo = M$1.RenderStrategy | M$1.Static;
3691
- function Bo(o2, r2) {
3692
- var N2, q2, Y;
3693
- let e2 = useId$1(), { id: t2 = `headlessui-combobox-options-${e2}`, hold: c2 = false, anchor: d2, portal: f2 = false, modal: s2 = true, transition: u2 = false, ...a3 } = o2, n$12 = oe("Combobox.Options"), T2 = re("Combobox.Options"), C = xe$1(d2);
3694
- C && (f2 = true);
3695
- let [_2, p2] = Re(C), L2 = be(), M2 = y$3(n$12.optionsRef, r2, C ? _2 : null), F$12 = n(n$12.optionsRef), v2 = u$7(), [y2, A2] = V(u2, n$12.optionsRef, v2 !== null ? (v2 & i$2.Open) === i$2.Open : n$12.comboboxState === 0);
3696
- m$2(y2, n$12.inputRef, T2.closeCombobox);
3697
- let R = n$12.__demoMode ? false : s2 && n$12.comboboxState === 0;
3698
- f$2(R, F$12);
3699
- let h2 = n$12.__demoMode ? false : s2 && n$12.comboboxState === 0;
3700
- y$2(h2, { allowed: o$2(() => [n$12.inputRef.current, n$12.buttonRef.current, n$12.optionsRef.current]) }), n$2(() => {
3701
- var E2;
3702
- n$12.optionsPropsRef.current.static = (E2 = o2.static) != null ? E2 : false;
3703
- }, [n$12.optionsPropsRef, o2.static]), n$2(() => {
3704
- n$12.optionsPropsRef.current.hold = c2;
3705
- }, [n$12.optionsPropsRef, c2]), F(n$12.comboboxState === 0, { container: n$12.optionsRef.current, accept(E2) {
3706
- return E2.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : E2.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
3707
- }, walk(E2) {
3708
- E2.setAttribute("role", "none");
3709
- } });
3710
- let O = I$1([(N2 = n$12.buttonRef.current) == null ? void 0 : N2.id]), G2 = useMemo(() => ({ open: n$12.comboboxState === 0, option: void 0 }), [n$12.comboboxState]), J2 = o$2(() => {
3711
- T2.setActivationTrigger(0);
3712
- }), Q = o$2((E2) => {
3713
- E2.preventDefault(), T2.setActivationTrigger(0);
3714
- }), I2 = D$2(C ? L2() : {}, { "aria-labelledby": O, role: "listbox", "aria-multiselectable": n$12.mode === 1 ? true : void 0, id: t2, ref: M2, style: { ...a3.style, ...p2, "--input-width": f$5(n$12.inputRef, true).width, "--button-width": f$5(n$12.buttonRef, true).width }, onWheel: n$12.activationTrigger === 0 ? void 0 : J2, onMouseDown: Q, ...A$1(A2) }), B = y2 && n$12.comboboxState === 1, k = l$2(B, (q2 = n$12.virtual) == null ? void 0 : q2.options), K2 = l$2(B, n$12.value), i2 = o$2((E2) => n$12.compare(K2, E2));
3715
- if (n$12.virtual) {
3716
- if (k === void 0) throw new Error("Missing `options` in virtual mode");
3717
- Object.assign(a3, { children: React__default.createElement(ie.Provider, { value: k !== n$12.virtual.options ? { ...n$12, virtual: { ...n$12.virtual, options: k } } : n$12 }, React__default.createElement(Io, { slot: G2 }, a3.children)) });
3718
- }
3719
- return React__default.createElement(te, { enabled: f2 ? o2.static || y2 : false }, React__default.createElement(ie.Provider, { value: n$12.mode === 1 ? n$12 : { ...n$12, isSelected: i2 } }, H({ ourProps: I2, theirProps: { ...a3, children: React__default.createElement(f$1, { freeze: B }, typeof a3.children == "function" ? (Y = a3.children) == null ? void 0 : Y.call(a3, G2) : a3.children) }, slot: G2, defaultTag: Lo, features: wo, visible: y2, name: "Combobox.Options" })));
3720
- }
3721
- let ko = "div";
3722
- function No(o2, r2) {
3723
- var I2, B, k, K2;
3724
- let e2 = oe("Combobox.Option"), t2 = re("Combobox.Option"), c2 = useId$1(), { id: d2 = `headlessui-combobox-option-${c2}`, value: f2, disabled: s2 = (k = (B = (I2 = e2.virtual) == null ? void 0 : I2.disabled) == null ? void 0 : B.call(I2, f2)) != null ? k : false, order: u2 = null, ...a3 } = o2, n2 = f$3(e2.inputRef), T2 = e2.virtual ? e2.activeOptionIndex === e2.calculateIndex(f2) : e2.activeOptionIndex === null ? false : ((K2 = e2.options[e2.activeOptionIndex]) == null ? void 0 : K2.id) === d2, C = e2.isSelected(f2), _2 = useRef(null), p2 = s$3({ disabled: s2, value: f2, domRef: _2, order: u2 }), L2 = useContext(Le), M2 = y$3(r2, _2, L2 ? L2.measureElement : null), F2 = o$2(() => {
3725
- t2.setIsTyping(false), t2.onChange(f2);
3726
- });
3727
- n$2(() => t2.registerOption(d2, p2), [p2, d2]);
3728
- let v2 = useRef(!(e2.virtual || e2.__demoMode));
3729
- n$2(() => {
3730
- if (!e2.virtual && !e2.__demoMode) return o$1().requestAnimationFrame(() => {
3731
- v2.current = true;
3732
- });
3733
- }, [e2.virtual, e2.__demoMode]), n$2(() => {
3734
- if (v2.current && e2.comboboxState === 0 && T2 && e2.activationTrigger !== 0) return o$1().requestAnimationFrame(() => {
3735
- var i2, N2;
3736
- (N2 = (i2 = _2.current) == null ? void 0 : i2.scrollIntoView) == null || N2.call(i2, { block: "nearest" });
3737
- });
3738
- }, [_2, T2, e2.comboboxState, e2.activationTrigger, e2.activeOptionIndex]);
3739
- let y2 = o$2((i2) => {
3740
- i2.preventDefault(), i2.button === g.Left && (s2 || (F2(), n$1() || requestAnimationFrame(() => n2()), e2.mode === 0 && t2.closeCombobox()));
3741
- }), A2 = o$2(() => {
3742
- if (s2) return t2.goToOption(c$1.Nothing);
3743
- let i2 = e2.calculateIndex(f2);
3744
- t2.goToOption(c$1.Specific, i2);
3745
- }), R = u$1(), h2 = o$2((i2) => R.update(i2)), O = o$2((i2) => {
3746
- if (!R.wasMoved(i2) || s2 || T2) return;
3747
- let N2 = e2.calculateIndex(f2);
3748
- t2.goToOption(c$1.Specific, N2, 0);
3749
- }), G2 = o$2((i2) => {
3750
- R.wasMoved(i2) && (s2 || T2 && (e2.optionsPropsRef.current.hold || t2.goToOption(c$1.Nothing)));
3751
- }), J2 = useMemo(() => ({ active: T2, focus: T2, selected: C, disabled: s2 }), [T2, C, s2]);
3752
- return H({ ourProps: { id: d2, ref: M2, role: "option", tabIndex: s2 === true ? void 0 : -1, "aria-disabled": s2 === true ? true : void 0, "aria-selected": C, disabled: void 0, onMouseDown: y2, onFocus: A2, onPointerEnter: h2, onMouseEnter: h2, onPointerMove: O, onMouseMove: O, onPointerLeave: G2, onMouseLeave: G2 }, theirProps: a3, slot: J2, defaultTag: ko, name: "Combobox.Option" });
3753
- }
3754
- let Uo = W$1(ho), Ho = W$1(Vo), Go = W$1(Mo), jo = K, zo = W$1(Bo), Ko = W$1(No), Nt = Object.assign(Uo, { Input: Go, Button: Ho, Label: jo, Options: zo, Option: Ko });
3755
- const container = "_container_1eksg_6";
3756
- const full = "_full_1eksg_20";
3757
- const placeholder = "_placeholder_1eksg_28";
3758
- const input = "_input_1eksg_49";
3759
- const button = "_button_1eksg_67";
3760
- const options = "_options_1eksg_75";
3761
- const option = "_option_1eksg_75";
3762
- const l = "_l_1eksg_124";
3763
- const xxl = "_xxl_1eksg_134";
3764
- const cls = {
3765
- "select-search": "_select-search_1eksg_2",
3766
- container,
3767
- "container-open": "_container-open_1eksg_16",
3768
- full,
3769
- "selectorIcon-open": "_selectorIcon-open_1eksg_24",
3770
- placeholder,
3771
- "placeholder-top": "_placeholder-top_1eksg_37",
3772
- "active-placeholder": "_active-placeholder_1eksg_43",
3773
- input,
3774
- "input-container": "_input-container_1eksg_61",
3775
- button,
3776
- options,
3777
- option,
3778
- "option-active": "_option-active_1eksg_109",
3779
- "option-inner": "_option-inner_1eksg_112",
3780
- "no-options": "_no-options_1eksg_119",
3781
- l,
3782
- xxl,
3783
- "selected-icon": "_selected-icon_1eksg_144"
3784
- };
3785
- const SelectSearch = forwardRef(
3786
- ({ items, placeholder: placeholder2, size: size2 = ESelectSearchSize.L, onChange, value, full: full2 }, ref) => {
3787
- const [searchValue, setSearchValue] = useState("");
3788
- const [isItemSelected, setIsItemSelected] = useState(false);
3789
- const isMobile = useMediaQuery(EMediaQuery.XSS);
3790
- const filteredItems = useMemo(() => {
3791
- return searchValue.trim().toLowerCase() ? items.filter(
3792
- (item) => item.name.toLowerCase().includes(searchValue.toLowerCase())
3793
- ) : items;
3794
- }, [searchValue, items]);
3795
- const handleOneChange = (newValue) => {
3796
- onChange == null ? void 0 : onChange(newValue);
3797
- setIsItemSelected(!!newValue);
3798
- };
3799
- return /* @__PURE__ */ jsx(
3800
- Nt,
3801
- {
3802
- as: "div",
3803
- onChange: handleOneChange,
3804
- value,
3805
- className: classNames(cls["select-search"], { [cls.full]: full2 }),
3806
- ref,
3807
- children: ({ open }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
3808
- /* @__PURE__ */ jsxs(
3809
- "div",
3810
- {
3811
- className: classNames(cls.container, cls[size2], {
3812
- [cls["container-open"]]: open
3813
- }),
3814
- children: [
3815
- /* @__PURE__ */ jsxs("div", { className: cls["input-container"], children: [
3816
- /* @__PURE__ */ jsx(
3817
- Go,
3818
- {
3819
- className: classNames(
3820
- cls.input,
3821
- value && cls["active-placeholder"]
3822
- ),
3823
- onChange: (event) => setSearchValue(event.target.value),
3824
- displayValue: (item) => item == null ? void 0 : item.name
3825
- }
3826
- ),
3827
- /* @__PURE__ */ jsx(
3828
- "span",
3829
- {
3830
- className: classNames(cls.placeholder, {
3831
- [cls["placeholder-top"]]: isItemSelected || open || searchValue
3832
- }),
3833
- children: placeholder2
3834
- }
3835
- )
3836
- ] }),
3837
- /* @__PURE__ */ jsx(Ho, { className: cls.button, children: /* @__PURE__ */ jsx(
3838
- Icon,
3839
- {
3840
- iconName: isMobile ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
3841
- className: classNames(cls["selector-icon"], {
3842
- [cls["selector-icon-open"]]: open
3843
- })
3844
- }
3845
- ) })
3846
- ]
3847
- }
3848
- ),
3849
- /* @__PURE__ */ jsx(zo, { className: classNames(cls.options, cls[size2]), children: !items.length ? /* @__PURE__ */ jsx("div", { className: cls["no-options"], children: "Нет данных" }) : !filteredItems.length && searchValue.trim() ? /* @__PURE__ */ jsx("div", { className: cls["no-options"], children: "Ничего не найдено" }) : filteredItems.map((item) => /* @__PURE__ */ jsx(
3850
- Ko,
3851
- {
3852
- value: item,
3853
- className: ({ focus }) => classNames(cls.option, {
3854
- [cls["option-active"]]: focus
3855
- }),
3856
- children: ({ selected }) => /* @__PURE__ */ jsxs("div", { className: cls["option-inner"], children: [
3857
- /* @__PURE__ */ jsx("span", { className: cls["option-text"], children: item.name }),
3858
- selected && /* @__PURE__ */ jsx(
3859
- Icon,
3860
- {
3861
- iconName: "Done16px",
3862
- className: cls["selected-icon"]
3863
- }
3864
- )
3865
- ] })
3866
- },
3867
- item.id
3868
- )) })
3869
- ] })
3870
- }
3871
- );
3872
- }
3873
- );
3874
- export {
3875
- SelectSearch
3876
- };