mimir-ui-kit 1.4.0 → 1.5.0

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