@szum-tech/design-system 2.7.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/chunk-2Y2ZCPNV.cjs +61 -0
  2. package/dist/chunk-3376ZTRC.cjs +2 -0
  3. package/dist/{chunk-S5BN23O7.cjs → chunk-3KMXFN6M.cjs} +14 -20
  4. package/dist/chunk-5AA4IE2T.cjs +27 -0
  5. package/dist/chunk-5F2Y65JH.js +32 -0
  6. package/dist/chunk-6BSR3O2J.js +53 -0
  7. package/dist/chunk-BYXBJQAS.js +1 -0
  8. package/dist/{chunk-XIPREW2R.js → chunk-DP7UEOTA.js} +173 -176
  9. package/dist/chunk-HCHVDUI6.cjs +34 -0
  10. package/dist/chunk-HD7ZDQWW.js +173 -0
  11. package/dist/chunk-I3RSTJP6.js +20 -0
  12. package/dist/chunk-I7AV5IQO.cjs +33 -0
  13. package/dist/chunk-N4O2GO6V.cjs +204 -0
  14. package/dist/chunk-NGVFYKAT.js +29 -0
  15. package/dist/chunk-NU5UQPBX.cjs +25 -0
  16. package/dist/chunk-OQCNPNPS.js +23 -0
  17. package/dist/chunk-S3ANEJJ7.cjs +22 -0
  18. package/dist/chunk-U4AWAABZ.js +4901 -0
  19. package/dist/chunk-UGSNASZM.js +25 -0
  20. package/dist/{chunk-EIXSMEDP.cjs → chunk-UIOBJSKZ.cjs} +1 -3
  21. package/dist/{chunk-I5P2HH5Z.js → chunk-WJSS32MY.js} +13 -19
  22. package/dist/{chunk-GEACYHTU.js → chunk-XJIUGEPN.js} +1 -3
  23. package/dist/chunk-Y6EVJSAH.cjs +4928 -0
  24. package/dist/{chunk-D3MOZUNH.cjs → chunk-ZV4467OW.cjs} +176 -185
  25. package/dist/components/alert-dialog/index.cjs +1 -0
  26. package/dist/components/alert-dialog/index.js +1 -0
  27. package/dist/components/avatar/index.cjs +5 -4
  28. package/dist/components/avatar/index.d.cts +5 -19
  29. package/dist/components/avatar/index.d.ts +5 -19
  30. package/dist/components/avatar/index.js +2 -1
  31. package/dist/components/badge/index.cjs +1 -0
  32. package/dist/components/badge/index.js +1 -0
  33. package/dist/components/button/index.cjs +23 -3
  34. package/dist/components/button/index.d.cts +8 -15
  35. package/dist/components/button/index.d.ts +8 -15
  36. package/dist/components/button/index.js +22 -2
  37. package/dist/components/card/index.cjs +12 -7
  38. package/dist/components/card/index.d.cts +8 -5
  39. package/dist/components/card/index.d.ts +8 -5
  40. package/dist/components/card/index.js +2 -1
  41. package/dist/components/checkbox/index.cjs +12 -0
  42. package/dist/components/checkbox/index.d.cts +8 -0
  43. package/dist/components/checkbox/index.d.ts +8 -0
  44. package/dist/components/checkbox/index.js +3 -0
  45. package/dist/components/dialog/index.cjs +1 -0
  46. package/dist/components/dialog/index.d.cts +1 -1
  47. package/dist/components/dialog/index.d.ts +1 -1
  48. package/dist/components/dialog/index.js +1 -0
  49. package/dist/components/field/index.cjs +50 -0
  50. package/dist/components/field/index.d.cts +50 -0
  51. package/dist/components/field/index.d.ts +50 -0
  52. package/dist/components/field/index.js +5 -0
  53. package/dist/components/header/index.cjs +1 -0
  54. package/dist/components/header/index.js +1 -0
  55. package/dist/components/index.cjs +158 -126
  56. package/dist/components/index.d.cts +7 -8
  57. package/dist/components/index.d.ts +7 -8
  58. package/dist/components/index.js +14 -14
  59. package/dist/components/input/index.cjs +3 -2
  60. package/dist/components/input/index.d.cts +2 -4
  61. package/dist/components/input/index.d.ts +2 -4
  62. package/dist/components/input/index.js +2 -1
  63. package/dist/components/item/index.cjs +13 -12
  64. package/dist/components/item/index.d.cts +7 -7
  65. package/dist/components/item/index.d.ts +7 -7
  66. package/dist/components/item/index.js +3 -2
  67. package/dist/components/label/index.cjs +3 -2
  68. package/dist/components/label/index.js +2 -1
  69. package/dist/components/select/index.cjs +20 -3
  70. package/dist/components/select/index.d.cts +20 -6
  71. package/dist/components/select/index.d.ts +20 -6
  72. package/dist/components/select/index.js +2 -1
  73. package/dist/components/separator/index.cjs +3 -2
  74. package/dist/components/separator/index.js +2 -1
  75. package/dist/components/sheet/index.cjs +1 -0
  76. package/dist/components/sheet/index.d.cts +1 -1
  77. package/dist/components/sheet/index.d.ts +1 -1
  78. package/dist/components/sheet/index.js +1 -0
  79. package/dist/components/spinner/index.cjs +1 -0
  80. package/dist/components/spinner/index.js +1 -0
  81. package/dist/components/stepper/index.cjs +33 -33
  82. package/dist/components/stepper/index.js +14 -14
  83. package/dist/components/textarea/index.cjs +4 -2
  84. package/dist/components/textarea/index.d.cts +2 -2
  85. package/dist/components/textarea/index.d.ts +2 -2
  86. package/dist/components/textarea/index.js +3 -1
  87. package/dist/components/tooltip/index.cjs +1 -0
  88. package/dist/components/tooltip/index.js +1 -0
  89. package/dist/contexts/index.cjs +1 -0
  90. package/dist/contexts/index.js +1 -0
  91. package/dist/hooks/index.cjs +1 -0
  92. package/dist/hooks/index.js +1 -0
  93. package/dist/icons/index.cjs +89 -18
  94. package/dist/icons/index.js +88 -1
  95. package/dist/utils/index.cjs +1 -0
  96. package/dist/utils/index.js +1 -0
  97. package/package.json +8 -9
  98. package/tailwind/global.css +5 -9
  99. package/tailwind/palette.css +149 -204
  100. package/tailwind/typography.css +33 -57
  101. package/dist/chunk-36YD6ICC.js +0 -70
  102. package/dist/chunk-4NO6IM75.cjs +0 -40
  103. package/dist/chunk-5BTQ6BQA.js +0 -24
  104. package/dist/chunk-5PBHBOXI.js +0 -30
  105. package/dist/chunk-EU7G37IS.js +0 -36
  106. package/dist/chunk-FPFRA5Q6.cjs +0 -31
  107. package/dist/chunk-FVSO3RHT.cjs +0 -17
  108. package/dist/chunk-G6VXQ7DJ.cjs +0 -63
  109. package/dist/chunk-IAI7BIAG.js +0 -31
  110. package/dist/chunk-K4TRAPRN.cjs +0 -341
  111. package/dist/chunk-MI3CQBHC.js +0 -60
  112. package/dist/chunk-OIWEXHFE.cjs +0 -33
  113. package/dist/chunk-P4J2TTH7.cjs +0 -32
  114. package/dist/chunk-UKWZ5BHD.cjs +0 -93
  115. package/dist/chunk-VZKTT6CG.js +0 -15
  116. package/dist/chunk-XTO7CMIM.js +0 -88
  117. package/dist/chunk-YJFJLF7Y.js +0 -319
  118. package/dist/chunk-ZZ3EBGSD.cjs +0 -72
  119. package/dist/components/form/index.cjs +0 -55
  120. package/dist/components/form/index.d.cts +0 -32
  121. package/dist/components/form/index.d.ts +0 -32
  122. package/dist/components/form/index.js +0 -22
  123. package/dist/components/helper-text/index.cjs +0 -10
  124. package/dist/components/helper-text/index.d.cts +0 -18
  125. package/dist/components/helper-text/index.d.ts +0 -18
  126. package/dist/components/helper-text/index.js +0 -1
@@ -0,0 +1,4901 @@
1
+ import { cn } from './chunk-ZD2QRAOX.js';
2
+ import { ChevronDownIcon, ChevronUpIcon, CheckIcon } from 'lucide-react';
3
+ import { Select as Select$1 } from 'radix-ui';
4
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
+ import * as React30 from 'react';
6
+ import React30__default, { useLayoutEffect, useState } from 'react';
7
+ import * as ReactDOM4 from 'react-dom';
8
+ import ReactDOM4__default from 'react-dom';
9
+ import { createSlot } from '@radix-ui/react-slot';
10
+
11
+ function Select({
12
+ children,
13
+ disabled,
14
+ defaultOpen,
15
+ defaultValue,
16
+ value,
17
+ dir,
18
+ open,
19
+ form,
20
+ name,
21
+ onOpenChange,
22
+ onValueChange,
23
+ required,
24
+ autoComplete,
25
+ // value props
26
+ placeholder,
27
+ // trigger props
28
+ className,
29
+ size: size4 = "default",
30
+ invalid = false,
31
+ ...triggerProps
32
+ }) {
33
+ const rootProps = {
34
+ children,
35
+ disabled,
36
+ defaultOpen,
37
+ defaultValue,
38
+ value,
39
+ dir,
40
+ open,
41
+ form,
42
+ name,
43
+ onOpenChange,
44
+ onValueChange,
45
+ required,
46
+ autoComplete
47
+ };
48
+ return /* @__PURE__ */ jsxs(Select$1.Root, { "data-slot": "select", ...rootProps, children: [
49
+ /* @__PURE__ */ jsxs(
50
+ Select$1.Trigger,
51
+ {
52
+ "data-slot": "select-trigger",
53
+ "aria-invalid": triggerProps["aria-invalid"] || invalid ? true : void 0,
54
+ "data-size": size4,
55
+ className: cn(
56
+ "border-input dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none",
57
+ "*:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2",
58
+ "disabled:cursor-not-allowed disabled:opacity-50",
59
+ "aria-invalid:ring-error/20 dark:aria-invalid:ring-error/40 aria-invalid:border-error",
60
+ "data-[size=default]:h-9 data-[size=sm]:h-8",
61
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
62
+ "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
63
+ "data-[placeholder]:text-muted-foreground",
64
+ className
65
+ ),
66
+ ...triggerProps,
67
+ children: [
68
+ /* @__PURE__ */ jsx(Select$1.Value, { "data-slot": "select-value", placeholder }),
69
+ /* @__PURE__ */ jsx(Select$1.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
70
+ ]
71
+ }
72
+ ),
73
+ children
74
+ ] });
75
+ }
76
+ function SelectContent({
77
+ className,
78
+ children,
79
+ position = "popper",
80
+ align = "center",
81
+ ...props
82
+ }) {
83
+ return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsxs(
84
+ Select$1.Content,
85
+ {
86
+ "data-slot": "select-content",
87
+ className: cn(
88
+ "bg-popover text-popover-foreground border-border relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded border shadow-sm",
89
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
90
+ position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
91
+ className
92
+ ),
93
+ position,
94
+ align,
95
+ ...props,
96
+ children: [
97
+ /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
98
+ /* @__PURE__ */ jsx(
99
+ Select$1.Viewport,
100
+ {
101
+ className: cn(
102
+ "p-1",
103
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
104
+ ),
105
+ children
106
+ }
107
+ ),
108
+ /* @__PURE__ */ jsx(SelectScrollDownButton, {})
109
+ ]
110
+ }
111
+ ) });
112
+ }
113
+ function SelectScrollUpButton({ className, ...props }) {
114
+ return /* @__PURE__ */ jsx(
115
+ Select$1.ScrollUpButton,
116
+ {
117
+ "data-slot": "select-scroll-up-button",
118
+ className: cn("flex cursor-default items-center justify-center py-1", className),
119
+ ...props,
120
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
121
+ }
122
+ );
123
+ }
124
+ function SelectScrollDownButton({
125
+ className,
126
+ ...props
127
+ }) {
128
+ return /* @__PURE__ */ jsx(
129
+ Select$1.ScrollDownButton,
130
+ {
131
+ "data-slot": "select-scroll-down-button",
132
+ className: cn("flex cursor-default items-center justify-center py-1", className),
133
+ ...props,
134
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
135
+ }
136
+ );
137
+ }
138
+
139
+ // node_modules/@radix-ui/number/dist/index.mjs
140
+ function clamp(value, [min2, max2]) {
141
+ return Math.min(max2, Math.max(min2, value));
142
+ }
143
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
144
+ return function handleEvent(event) {
145
+ originalEventHandler?.(event);
146
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
147
+ return ourEventHandler?.(event);
148
+ }
149
+ };
150
+ }
151
+ function createContextScope(scopeName, createContextScopeDeps = []) {
152
+ let defaultContexts = [];
153
+ function createContext32(rootComponentName, defaultContext) {
154
+ const BaseContext = React30.createContext(defaultContext);
155
+ const index2 = defaultContexts.length;
156
+ defaultContexts = [...defaultContexts, defaultContext];
157
+ const Provider = (props) => {
158
+ const { scope, children, ...context } = props;
159
+ const Context = scope?.[scopeName]?.[index2] || BaseContext;
160
+ const value = React30.useMemo(() => context, Object.values(context));
161
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
162
+ };
163
+ Provider.displayName = rootComponentName + "Provider";
164
+ function useContext22(consumerName, scope) {
165
+ const Context = scope?.[scopeName]?.[index2] || BaseContext;
166
+ const context = React30.useContext(Context);
167
+ if (context) return context;
168
+ if (defaultContext !== void 0) return defaultContext;
169
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
170
+ }
171
+ return [Provider, useContext22];
172
+ }
173
+ const createScope = () => {
174
+ const scopeContexts = defaultContexts.map((defaultContext) => {
175
+ return React30.createContext(defaultContext);
176
+ });
177
+ return function useScope(scope) {
178
+ const contexts = scope?.[scopeName] || scopeContexts;
179
+ return React30.useMemo(
180
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
181
+ [scope, contexts]
182
+ );
183
+ };
184
+ };
185
+ createScope.scopeName = scopeName;
186
+ return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
187
+ }
188
+ function composeContextScopes(...scopes) {
189
+ const baseScope = scopes[0];
190
+ if (scopes.length === 1) return baseScope;
191
+ const createScope = () => {
192
+ const scopeHooks = scopes.map((createScope2) => ({
193
+ useScope: createScope2(),
194
+ scopeName: createScope2.scopeName
195
+ }));
196
+ return function useComposedScopes(overrideScopes) {
197
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
198
+ const scopeProps = useScope(overrideScopes);
199
+ const currentScope = scopeProps[`__scope${scopeName}`];
200
+ return { ...nextScopes2, ...currentScope };
201
+ }, {});
202
+ return React30.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
203
+ };
204
+ };
205
+ createScope.scopeName = baseScope.scopeName;
206
+ return createScope;
207
+ }
208
+ function setRef(ref, value) {
209
+ if (typeof ref === "function") {
210
+ return ref(value);
211
+ } else if (ref !== null && ref !== void 0) {
212
+ ref.current = value;
213
+ }
214
+ }
215
+ function composeRefs(...refs) {
216
+ return (node) => {
217
+ let hasCleanup = false;
218
+ const cleanups = refs.map((ref) => {
219
+ const cleanup = setRef(ref, node);
220
+ if (!hasCleanup && typeof cleanup == "function") {
221
+ hasCleanup = true;
222
+ }
223
+ return cleanup;
224
+ });
225
+ if (hasCleanup) {
226
+ return () => {
227
+ for (let i = 0; i < cleanups.length; i++) {
228
+ const cleanup = cleanups[i];
229
+ if (typeof cleanup == "function") {
230
+ cleanup();
231
+ } else {
232
+ setRef(refs[i], null);
233
+ }
234
+ }
235
+ };
236
+ }
237
+ };
238
+ }
239
+ function useComposedRefs(...refs) {
240
+ return React30.useCallback(composeRefs(...refs), refs);
241
+ }
242
+ function createCollection(name) {
243
+ const PROVIDER_NAME = name + "CollectionProvider";
244
+ const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
245
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
246
+ PROVIDER_NAME,
247
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
248
+ );
249
+ const CollectionProvider = (props) => {
250
+ const { scope, children } = props;
251
+ const ref = React30__default.useRef(null);
252
+ const itemMap = React30__default.useRef(/* @__PURE__ */ new Map()).current;
253
+ return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
254
+ };
255
+ CollectionProvider.displayName = PROVIDER_NAME;
256
+ const COLLECTION_SLOT_NAME = name + "CollectionSlot";
257
+ const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
258
+ const CollectionSlot = React30__default.forwardRef(
259
+ (props, forwardedRef) => {
260
+ const { scope, children } = props;
261
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
262
+ const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
263
+ return /* @__PURE__ */ jsx(CollectionSlotImpl, { ref: composedRefs, children });
264
+ }
265
+ );
266
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
267
+ const ITEM_SLOT_NAME = name + "CollectionItemSlot";
268
+ const ITEM_DATA_ATTR = "data-radix-collection-item";
269
+ const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
270
+ const CollectionItemSlot = React30__default.forwardRef(
271
+ (props, forwardedRef) => {
272
+ const { scope, children, ...itemData } = props;
273
+ const ref = React30__default.useRef(null);
274
+ const composedRefs = useComposedRefs(forwardedRef, ref);
275
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
276
+ React30__default.useEffect(() => {
277
+ context.itemMap.set(ref, { ref, ...itemData });
278
+ return () => void context.itemMap.delete(ref);
279
+ });
280
+ return /* @__PURE__ */ jsx(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
281
+ }
282
+ );
283
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
284
+ function useCollection2(scope) {
285
+ const context = useCollectionContext(name + "CollectionConsumer", scope);
286
+ const getItems = React30__default.useCallback(() => {
287
+ const collectionNode = context.collectionRef.current;
288
+ if (!collectionNode) return [];
289
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
290
+ const items = Array.from(context.itemMap.values());
291
+ const orderedItems = items.sort(
292
+ (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
293
+ );
294
+ return orderedItems;
295
+ }, [context.collectionRef, context.itemMap]);
296
+ return getItems;
297
+ }
298
+ return [
299
+ { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
300
+ useCollection2,
301
+ createCollectionScope2
302
+ ];
303
+ }
304
+ React30.createContext(void 0);
305
+ var NODES = [
306
+ "a",
307
+ "button",
308
+ "div",
309
+ "form",
310
+ "h2",
311
+ "h3",
312
+ "img",
313
+ "input",
314
+ "label",
315
+ "li",
316
+ "nav",
317
+ "ol",
318
+ "p",
319
+ "select",
320
+ "span",
321
+ "svg",
322
+ "ul"
323
+ ];
324
+ var Primitive = NODES.reduce((primitive, node) => {
325
+ const Slot2 = createSlot(`Primitive.${node}`);
326
+ const Node2 = React30.forwardRef((props, forwardedRef) => {
327
+ const { asChild, ...primitiveProps } = props;
328
+ const Comp = asChild ? Slot2 : node;
329
+ if (typeof window !== "undefined") {
330
+ window[Symbol.for("radix-ui")] = true;
331
+ }
332
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
333
+ });
334
+ Node2.displayName = `Primitive.${node}`;
335
+ return { ...primitive, [node]: Node2 };
336
+ }, {});
337
+ function dispatchDiscreteCustomEvent(target, event) {
338
+ if (target) ReactDOM4.flushSync(() => target.dispatchEvent(event));
339
+ }
340
+ function useCallbackRef(callback) {
341
+ const callbackRef = React30.useRef(callback);
342
+ React30.useEffect(() => {
343
+ callbackRef.current = callback;
344
+ });
345
+ return React30.useMemo(() => (...args) => callbackRef.current?.(...args), []);
346
+ }
347
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
348
+ const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
349
+ React30.useEffect(() => {
350
+ const handleKeyDown = (event) => {
351
+ if (event.key === "Escape") {
352
+ onEscapeKeyDown(event);
353
+ }
354
+ };
355
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
356
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
357
+ }, [onEscapeKeyDown, ownerDocument]);
358
+ }
359
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
360
+ var CONTEXT_UPDATE = "dismissableLayer.update";
361
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
362
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
363
+ var originalBodyPointerEvents;
364
+ var DismissableLayerContext = React30.createContext({
365
+ layers: /* @__PURE__ */ new Set(),
366
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
367
+ branches: /* @__PURE__ */ new Set()
368
+ });
369
+ var DismissableLayer = React30.forwardRef(
370
+ (props, forwardedRef) => {
371
+ const {
372
+ disableOutsidePointerEvents = false,
373
+ onEscapeKeyDown,
374
+ onPointerDownOutside,
375
+ onFocusOutside,
376
+ onInteractOutside,
377
+ onDismiss,
378
+ ...layerProps
379
+ } = props;
380
+ const context = React30.useContext(DismissableLayerContext);
381
+ const [node, setNode] = React30.useState(null);
382
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
383
+ const [, force] = React30.useState({});
384
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
385
+ const layers = Array.from(context.layers);
386
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
387
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
388
+ const index2 = node ? layers.indexOf(node) : -1;
389
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
390
+ const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
391
+ const pointerDownOutside = usePointerDownOutside((event) => {
392
+ const target = event.target;
393
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
394
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
395
+ onPointerDownOutside?.(event);
396
+ onInteractOutside?.(event);
397
+ if (!event.defaultPrevented) onDismiss?.();
398
+ }, ownerDocument);
399
+ const focusOutside = useFocusOutside((event) => {
400
+ const target = event.target;
401
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
402
+ if (isFocusInBranch) return;
403
+ onFocusOutside?.(event);
404
+ onInteractOutside?.(event);
405
+ if (!event.defaultPrevented) onDismiss?.();
406
+ }, ownerDocument);
407
+ useEscapeKeydown((event) => {
408
+ const isHighestLayer = index2 === context.layers.size - 1;
409
+ if (!isHighestLayer) return;
410
+ onEscapeKeyDown?.(event);
411
+ if (!event.defaultPrevented && onDismiss) {
412
+ event.preventDefault();
413
+ onDismiss();
414
+ }
415
+ }, ownerDocument);
416
+ React30.useEffect(() => {
417
+ if (!node) return;
418
+ if (disableOutsidePointerEvents) {
419
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
420
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
421
+ ownerDocument.body.style.pointerEvents = "none";
422
+ }
423
+ context.layersWithOutsidePointerEventsDisabled.add(node);
424
+ }
425
+ context.layers.add(node);
426
+ dispatchUpdate();
427
+ return () => {
428
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
429
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
430
+ }
431
+ };
432
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
433
+ React30.useEffect(() => {
434
+ return () => {
435
+ if (!node) return;
436
+ context.layers.delete(node);
437
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
438
+ dispatchUpdate();
439
+ };
440
+ }, [node, context]);
441
+ React30.useEffect(() => {
442
+ const handleUpdate = () => force({});
443
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
444
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
445
+ }, []);
446
+ return /* @__PURE__ */ jsx(
447
+ Primitive.div,
448
+ {
449
+ ...layerProps,
450
+ ref: composedRefs,
451
+ style: {
452
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
453
+ ...props.style
454
+ },
455
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
456
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
457
+ onPointerDownCapture: composeEventHandlers(
458
+ props.onPointerDownCapture,
459
+ pointerDownOutside.onPointerDownCapture
460
+ )
461
+ }
462
+ );
463
+ }
464
+ );
465
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
466
+ var BRANCH_NAME = "DismissableLayerBranch";
467
+ var DismissableLayerBranch = React30.forwardRef((props, forwardedRef) => {
468
+ const context = React30.useContext(DismissableLayerContext);
469
+ const ref = React30.useRef(null);
470
+ const composedRefs = useComposedRefs(forwardedRef, ref);
471
+ React30.useEffect(() => {
472
+ const node = ref.current;
473
+ if (node) {
474
+ context.branches.add(node);
475
+ return () => {
476
+ context.branches.delete(node);
477
+ };
478
+ }
479
+ }, [context.branches]);
480
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
481
+ });
482
+ DismissableLayerBranch.displayName = BRANCH_NAME;
483
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
484
+ const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
485
+ const isPointerInsideReactTreeRef = React30.useRef(false);
486
+ const handleClickRef = React30.useRef(() => {
487
+ });
488
+ React30.useEffect(() => {
489
+ const handlePointerDown = (event) => {
490
+ if (event.target && !isPointerInsideReactTreeRef.current) {
491
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
492
+ handleAndDispatchCustomEvent(
493
+ POINTER_DOWN_OUTSIDE,
494
+ handlePointerDownOutside,
495
+ eventDetail,
496
+ { discrete: true }
497
+ );
498
+ };
499
+ const eventDetail = { originalEvent: event };
500
+ if (event.pointerType === "touch") {
501
+ ownerDocument.removeEventListener("click", handleClickRef.current);
502
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
503
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
504
+ } else {
505
+ handleAndDispatchPointerDownOutsideEvent2();
506
+ }
507
+ } else {
508
+ ownerDocument.removeEventListener("click", handleClickRef.current);
509
+ }
510
+ isPointerInsideReactTreeRef.current = false;
511
+ };
512
+ const timerId = window.setTimeout(() => {
513
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
514
+ }, 0);
515
+ return () => {
516
+ window.clearTimeout(timerId);
517
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
518
+ ownerDocument.removeEventListener("click", handleClickRef.current);
519
+ };
520
+ }, [ownerDocument, handlePointerDownOutside]);
521
+ return {
522
+ // ensures we check React component tree (not just DOM tree)
523
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
524
+ };
525
+ }
526
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
527
+ const handleFocusOutside = useCallbackRef(onFocusOutside);
528
+ const isFocusInsideReactTreeRef = React30.useRef(false);
529
+ React30.useEffect(() => {
530
+ const handleFocus = (event) => {
531
+ if (event.target && !isFocusInsideReactTreeRef.current) {
532
+ const eventDetail = { originalEvent: event };
533
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
534
+ discrete: false
535
+ });
536
+ }
537
+ };
538
+ ownerDocument.addEventListener("focusin", handleFocus);
539
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
540
+ }, [ownerDocument, handleFocusOutside]);
541
+ return {
542
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
543
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
544
+ };
545
+ }
546
+ function dispatchUpdate() {
547
+ const event = new CustomEvent(CONTEXT_UPDATE);
548
+ document.dispatchEvent(event);
549
+ }
550
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
551
+ const target = detail.originalEvent.target;
552
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
553
+ if (handler) target.addEventListener(name, handler, { once: true });
554
+ if (discrete) {
555
+ dispatchDiscreteCustomEvent(target, event);
556
+ } else {
557
+ target.dispatchEvent(event);
558
+ }
559
+ }
560
+ var count = 0;
561
+ function useFocusGuards() {
562
+ React30.useEffect(() => {
563
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
564
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
565
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
566
+ count++;
567
+ return () => {
568
+ if (count === 1) {
569
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
570
+ }
571
+ count--;
572
+ };
573
+ }, []);
574
+ }
575
+ function createFocusGuard() {
576
+ const element = document.createElement("span");
577
+ element.setAttribute("data-radix-focus-guard", "");
578
+ element.tabIndex = 0;
579
+ element.style.outline = "none";
580
+ element.style.opacity = "0";
581
+ element.style.position = "fixed";
582
+ element.style.pointerEvents = "none";
583
+ return element;
584
+ }
585
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
586
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
587
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
588
+ var FOCUS_SCOPE_NAME = "FocusScope";
589
+ var FocusScope = React30.forwardRef((props, forwardedRef) => {
590
+ const {
591
+ loop = false,
592
+ trapped = false,
593
+ onMountAutoFocus: onMountAutoFocusProp,
594
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
595
+ ...scopeProps
596
+ } = props;
597
+ const [container, setContainer] = React30.useState(null);
598
+ const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
599
+ const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
600
+ const lastFocusedElementRef = React30.useRef(null);
601
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
602
+ const focusScope = React30.useRef({
603
+ paused: false,
604
+ pause() {
605
+ this.paused = true;
606
+ },
607
+ resume() {
608
+ this.paused = false;
609
+ }
610
+ }).current;
611
+ React30.useEffect(() => {
612
+ if (trapped) {
613
+ let handleFocusIn2 = function(event) {
614
+ if (focusScope.paused || !container) return;
615
+ const target = event.target;
616
+ if (container.contains(target)) {
617
+ lastFocusedElementRef.current = target;
618
+ } else {
619
+ focus(lastFocusedElementRef.current, { select: true });
620
+ }
621
+ }, handleFocusOut2 = function(event) {
622
+ if (focusScope.paused || !container) return;
623
+ const relatedTarget = event.relatedTarget;
624
+ if (relatedTarget === null) return;
625
+ if (!container.contains(relatedTarget)) {
626
+ focus(lastFocusedElementRef.current, { select: true });
627
+ }
628
+ }, handleMutations2 = function(mutations) {
629
+ const focusedElement = document.activeElement;
630
+ if (focusedElement !== document.body) return;
631
+ for (const mutation of mutations) {
632
+ if (mutation.removedNodes.length > 0) focus(container);
633
+ }
634
+ };
635
+ document.addEventListener("focusin", handleFocusIn2);
636
+ document.addEventListener("focusout", handleFocusOut2);
637
+ const mutationObserver = new MutationObserver(handleMutations2);
638
+ if (container) mutationObserver.observe(container, { childList: true, subtree: true });
639
+ return () => {
640
+ document.removeEventListener("focusin", handleFocusIn2);
641
+ document.removeEventListener("focusout", handleFocusOut2);
642
+ mutationObserver.disconnect();
643
+ };
644
+ }
645
+ }, [trapped, container, focusScope.paused]);
646
+ React30.useEffect(() => {
647
+ if (container) {
648
+ focusScopesStack.add(focusScope);
649
+ const previouslyFocusedElement = document.activeElement;
650
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
651
+ if (!hasFocusedCandidate) {
652
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
653
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
654
+ container.dispatchEvent(mountEvent);
655
+ if (!mountEvent.defaultPrevented) {
656
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
657
+ if (document.activeElement === previouslyFocusedElement) {
658
+ focus(container);
659
+ }
660
+ }
661
+ }
662
+ return () => {
663
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
664
+ setTimeout(() => {
665
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
666
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
667
+ container.dispatchEvent(unmountEvent);
668
+ if (!unmountEvent.defaultPrevented) {
669
+ focus(previouslyFocusedElement ?? document.body, { select: true });
670
+ }
671
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
672
+ focusScopesStack.remove(focusScope);
673
+ }, 0);
674
+ };
675
+ }
676
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
677
+ const handleKeyDown = React30.useCallback(
678
+ (event) => {
679
+ if (!loop && !trapped) return;
680
+ if (focusScope.paused) return;
681
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
682
+ const focusedElement = document.activeElement;
683
+ if (isTabKey && focusedElement) {
684
+ const container2 = event.currentTarget;
685
+ const [first, last] = getTabbableEdges(container2);
686
+ const hasTabbableElementsInside = first && last;
687
+ if (!hasTabbableElementsInside) {
688
+ if (focusedElement === container2) event.preventDefault();
689
+ } else {
690
+ if (!event.shiftKey && focusedElement === last) {
691
+ event.preventDefault();
692
+ if (loop) focus(first, { select: true });
693
+ } else if (event.shiftKey && focusedElement === first) {
694
+ event.preventDefault();
695
+ if (loop) focus(last, { select: true });
696
+ }
697
+ }
698
+ }
699
+ },
700
+ [loop, trapped, focusScope.paused]
701
+ );
702
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
703
+ });
704
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
705
+ function focusFirst(candidates, { select = false } = {}) {
706
+ const previouslyFocusedElement = document.activeElement;
707
+ for (const candidate of candidates) {
708
+ focus(candidate, { select });
709
+ if (document.activeElement !== previouslyFocusedElement) return;
710
+ }
711
+ }
712
+ function getTabbableEdges(container) {
713
+ const candidates = getTabbableCandidates(container);
714
+ const first = findVisible(candidates, container);
715
+ const last = findVisible(candidates.reverse(), container);
716
+ return [first, last];
717
+ }
718
+ function getTabbableCandidates(container) {
719
+ const nodes = [];
720
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
721
+ acceptNode: (node) => {
722
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
723
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
724
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
725
+ }
726
+ });
727
+ while (walker.nextNode()) nodes.push(walker.currentNode);
728
+ return nodes;
729
+ }
730
+ function findVisible(elements, container) {
731
+ for (const element of elements) {
732
+ if (!isHidden(element, { upTo: container })) return element;
733
+ }
734
+ }
735
+ function isHidden(node, { upTo }) {
736
+ if (getComputedStyle(node).visibility === "hidden") return true;
737
+ while (node) {
738
+ if (upTo !== void 0 && node === upTo) return false;
739
+ if (getComputedStyle(node).display === "none") return true;
740
+ node = node.parentElement;
741
+ }
742
+ return false;
743
+ }
744
+ function isSelectableInput(element) {
745
+ return element instanceof HTMLInputElement && "select" in element;
746
+ }
747
+ function focus(element, { select = false } = {}) {
748
+ if (element && element.focus) {
749
+ const previouslyFocusedElement = document.activeElement;
750
+ element.focus({ preventScroll: true });
751
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
752
+ element.select();
753
+ }
754
+ }
755
+ var focusScopesStack = createFocusScopesStack();
756
+ function createFocusScopesStack() {
757
+ let stack = [];
758
+ return {
759
+ add(focusScope) {
760
+ const activeFocusScope = stack[0];
761
+ if (focusScope !== activeFocusScope) {
762
+ activeFocusScope?.pause();
763
+ }
764
+ stack = arrayRemove(stack, focusScope);
765
+ stack.unshift(focusScope);
766
+ },
767
+ remove(focusScope) {
768
+ stack = arrayRemove(stack, focusScope);
769
+ stack[0]?.resume();
770
+ }
771
+ };
772
+ }
773
+ function arrayRemove(array, item) {
774
+ const updatedArray = [...array];
775
+ const index2 = updatedArray.indexOf(item);
776
+ if (index2 !== -1) {
777
+ updatedArray.splice(index2, 1);
778
+ }
779
+ return updatedArray;
780
+ }
781
+ function removeLinks(items) {
782
+ return items.filter((item) => item.tagName !== "A");
783
+ }
784
+ var useLayoutEffect2 = globalThis?.document ? React30.useLayoutEffect : () => {
785
+ };
786
+
787
+ // node_modules/@radix-ui/react-id/dist/index.mjs
788
+ var useReactId = React30[" useId ".trim().toString()] || (() => void 0);
789
+ var count2 = 0;
790
+ function useId(deterministicId) {
791
+ const [id, setId] = React30.useState(useReactId());
792
+ useLayoutEffect2(() => {
793
+ setId((reactId) => reactId ?? String(count2++));
794
+ }, [deterministicId]);
795
+ return (id ? `radix-${id}` : "");
796
+ }
797
+
798
+ // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
799
+ var sides = ["top", "right", "bottom", "left"];
800
+ var min = Math.min;
801
+ var max = Math.max;
802
+ var round = Math.round;
803
+ var floor = Math.floor;
804
+ var createCoords = (v) => ({
805
+ x: v,
806
+ y: v
807
+ });
808
+ var oppositeSideMap = {
809
+ left: "right",
810
+ right: "left",
811
+ bottom: "top",
812
+ top: "bottom"
813
+ };
814
+ var oppositeAlignmentMap = {
815
+ start: "end",
816
+ end: "start"
817
+ };
818
+ function clamp2(start, value, end) {
819
+ return max(start, min(value, end));
820
+ }
821
+ function evaluate(value, param) {
822
+ return typeof value === "function" ? value(param) : value;
823
+ }
824
+ function getSide(placement) {
825
+ return placement.split("-")[0];
826
+ }
827
+ function getAlignment(placement) {
828
+ return placement.split("-")[1];
829
+ }
830
+ function getOppositeAxis(axis) {
831
+ return axis === "x" ? "y" : "x";
832
+ }
833
+ function getAxisLength(axis) {
834
+ return axis === "y" ? "height" : "width";
835
+ }
836
+ var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
837
+ function getSideAxis(placement) {
838
+ return yAxisSides.has(getSide(placement)) ? "y" : "x";
839
+ }
840
+ function getAlignmentAxis(placement) {
841
+ return getOppositeAxis(getSideAxis(placement));
842
+ }
843
+ function getAlignmentSides(placement, rects, rtl) {
844
+ if (rtl === void 0) {
845
+ rtl = false;
846
+ }
847
+ const alignment = getAlignment(placement);
848
+ const alignmentAxis = getAlignmentAxis(placement);
849
+ const length = getAxisLength(alignmentAxis);
850
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
851
+ if (rects.reference[length] > rects.floating[length]) {
852
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
853
+ }
854
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
855
+ }
856
+ function getExpandedPlacements(placement) {
857
+ const oppositePlacement = getOppositePlacement(placement);
858
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
859
+ }
860
+ function getOppositeAlignmentPlacement(placement) {
861
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
862
+ }
863
+ var lrPlacement = ["left", "right"];
864
+ var rlPlacement = ["right", "left"];
865
+ var tbPlacement = ["top", "bottom"];
866
+ var btPlacement = ["bottom", "top"];
867
+ function getSideList(side, isStart, rtl) {
868
+ switch (side) {
869
+ case "top":
870
+ case "bottom":
871
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
872
+ return isStart ? lrPlacement : rlPlacement;
873
+ case "left":
874
+ case "right":
875
+ return isStart ? tbPlacement : btPlacement;
876
+ default:
877
+ return [];
878
+ }
879
+ }
880
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
881
+ const alignment = getAlignment(placement);
882
+ let list = getSideList(getSide(placement), direction === "start", rtl);
883
+ if (alignment) {
884
+ list = list.map((side) => side + "-" + alignment);
885
+ if (flipAlignment) {
886
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
887
+ }
888
+ }
889
+ return list;
890
+ }
891
+ function getOppositePlacement(placement) {
892
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
893
+ }
894
+ function expandPaddingObject(padding) {
895
+ return {
896
+ top: 0,
897
+ right: 0,
898
+ bottom: 0,
899
+ left: 0,
900
+ ...padding
901
+ };
902
+ }
903
+ function getPaddingObject(padding) {
904
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
905
+ top: padding,
906
+ right: padding,
907
+ bottom: padding,
908
+ left: padding
909
+ };
910
+ }
911
+ function rectToClientRect(rect) {
912
+ const {
913
+ x,
914
+ y,
915
+ width,
916
+ height
917
+ } = rect;
918
+ return {
919
+ width,
920
+ height,
921
+ top: y,
922
+ left: x,
923
+ right: x + width,
924
+ bottom: y + height,
925
+ x,
926
+ y
927
+ };
928
+ }
929
+
930
+ // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
931
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
932
+ let {
933
+ reference,
934
+ floating
935
+ } = _ref;
936
+ const sideAxis = getSideAxis(placement);
937
+ const alignmentAxis = getAlignmentAxis(placement);
938
+ const alignLength = getAxisLength(alignmentAxis);
939
+ const side = getSide(placement);
940
+ const isVertical = sideAxis === "y";
941
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
942
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
943
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
944
+ let coords;
945
+ switch (side) {
946
+ case "top":
947
+ coords = {
948
+ x: commonX,
949
+ y: reference.y - floating.height
950
+ };
951
+ break;
952
+ case "bottom":
953
+ coords = {
954
+ x: commonX,
955
+ y: reference.y + reference.height
956
+ };
957
+ break;
958
+ case "right":
959
+ coords = {
960
+ x: reference.x + reference.width,
961
+ y: commonY
962
+ };
963
+ break;
964
+ case "left":
965
+ coords = {
966
+ x: reference.x - floating.width,
967
+ y: commonY
968
+ };
969
+ break;
970
+ default:
971
+ coords = {
972
+ x: reference.x,
973
+ y: reference.y
974
+ };
975
+ }
976
+ switch (getAlignment(placement)) {
977
+ case "start":
978
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
979
+ break;
980
+ case "end":
981
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
982
+ break;
983
+ }
984
+ return coords;
985
+ }
986
+ var computePosition = async (reference, floating, config) => {
987
+ const {
988
+ placement = "bottom",
989
+ strategy = "absolute",
990
+ middleware = [],
991
+ platform: platform2
992
+ } = config;
993
+ const validMiddleware = middleware.filter(Boolean);
994
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
995
+ let rects = await platform2.getElementRects({
996
+ reference,
997
+ floating,
998
+ strategy
999
+ });
1000
+ let {
1001
+ x,
1002
+ y
1003
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1004
+ let statefulPlacement = placement;
1005
+ let middlewareData = {};
1006
+ let resetCount = 0;
1007
+ for (let i = 0; i < validMiddleware.length; i++) {
1008
+ const {
1009
+ name,
1010
+ fn
1011
+ } = validMiddleware[i];
1012
+ const {
1013
+ x: nextX,
1014
+ y: nextY,
1015
+ data,
1016
+ reset
1017
+ } = await fn({
1018
+ x,
1019
+ y,
1020
+ initialPlacement: placement,
1021
+ placement: statefulPlacement,
1022
+ strategy,
1023
+ middlewareData,
1024
+ rects,
1025
+ platform: platform2,
1026
+ elements: {
1027
+ reference,
1028
+ floating
1029
+ }
1030
+ });
1031
+ x = nextX != null ? nextX : x;
1032
+ y = nextY != null ? nextY : y;
1033
+ middlewareData = {
1034
+ ...middlewareData,
1035
+ [name]: {
1036
+ ...middlewareData[name],
1037
+ ...data
1038
+ }
1039
+ };
1040
+ if (reset && resetCount <= 50) {
1041
+ resetCount++;
1042
+ if (typeof reset === "object") {
1043
+ if (reset.placement) {
1044
+ statefulPlacement = reset.placement;
1045
+ }
1046
+ if (reset.rects) {
1047
+ rects = reset.rects === true ? await platform2.getElementRects({
1048
+ reference,
1049
+ floating,
1050
+ strategy
1051
+ }) : reset.rects;
1052
+ }
1053
+ ({
1054
+ x,
1055
+ y
1056
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1057
+ }
1058
+ i = -1;
1059
+ }
1060
+ }
1061
+ return {
1062
+ x,
1063
+ y,
1064
+ placement: statefulPlacement,
1065
+ strategy,
1066
+ middlewareData
1067
+ };
1068
+ };
1069
+ async function detectOverflow(state, options) {
1070
+ var _await$platform$isEle;
1071
+ if (options === void 0) {
1072
+ options = {};
1073
+ }
1074
+ const {
1075
+ x,
1076
+ y,
1077
+ platform: platform2,
1078
+ rects,
1079
+ elements,
1080
+ strategy
1081
+ } = state;
1082
+ const {
1083
+ boundary = "clippingAncestors",
1084
+ rootBoundary = "viewport",
1085
+ elementContext = "floating",
1086
+ altBoundary = false,
1087
+ padding = 0
1088
+ } = evaluate(options, state);
1089
+ const paddingObject = getPaddingObject(padding);
1090
+ const altContext = elementContext === "floating" ? "reference" : "floating";
1091
+ const element = elements[altBoundary ? altContext : elementContext];
1092
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1093
+ 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)),
1094
+ boundary,
1095
+ rootBoundary,
1096
+ strategy
1097
+ }));
1098
+ const rect = elementContext === "floating" ? {
1099
+ x,
1100
+ y,
1101
+ width: rects.floating.width,
1102
+ height: rects.floating.height
1103
+ } : rects.reference;
1104
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1105
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1106
+ x: 1,
1107
+ y: 1
1108
+ } : {
1109
+ x: 1,
1110
+ y: 1
1111
+ };
1112
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1113
+ elements,
1114
+ rect,
1115
+ offsetParent,
1116
+ strategy
1117
+ }) : rect);
1118
+ return {
1119
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1120
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1121
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1122
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1123
+ };
1124
+ }
1125
+ var arrow = (options) => ({
1126
+ name: "arrow",
1127
+ options,
1128
+ async fn(state) {
1129
+ const {
1130
+ x,
1131
+ y,
1132
+ placement,
1133
+ rects,
1134
+ platform: platform2,
1135
+ elements,
1136
+ middlewareData
1137
+ } = state;
1138
+ const {
1139
+ element,
1140
+ padding = 0
1141
+ } = evaluate(options, state) || {};
1142
+ if (element == null) {
1143
+ return {};
1144
+ }
1145
+ const paddingObject = getPaddingObject(padding);
1146
+ const coords = {
1147
+ x,
1148
+ y
1149
+ };
1150
+ const axis = getAlignmentAxis(placement);
1151
+ const length = getAxisLength(axis);
1152
+ const arrowDimensions = await platform2.getDimensions(element);
1153
+ const isYAxis = axis === "y";
1154
+ const minProp = isYAxis ? "top" : "left";
1155
+ const maxProp = isYAxis ? "bottom" : "right";
1156
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
1157
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1158
+ const startDiff = coords[axis] - rects.reference[axis];
1159
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
1160
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1161
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
1162
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1163
+ }
1164
+ const centerToReference = endDiff / 2 - startDiff / 2;
1165
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1166
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1167
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1168
+ const min$1 = minPadding;
1169
+ const max2 = clientSize - arrowDimensions[length] - maxPadding;
1170
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1171
+ const offset4 = clamp2(min$1, center, max2);
1172
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1173
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
1174
+ return {
1175
+ [axis]: coords[axis] + alignmentOffset,
1176
+ data: {
1177
+ [axis]: offset4,
1178
+ centerOffset: center - offset4 - alignmentOffset,
1179
+ ...shouldAddOffset && {
1180
+ alignmentOffset
1181
+ }
1182
+ },
1183
+ reset: shouldAddOffset
1184
+ };
1185
+ }
1186
+ });
1187
+ var flip = function(options) {
1188
+ if (options === void 0) {
1189
+ options = {};
1190
+ }
1191
+ return {
1192
+ name: "flip",
1193
+ options,
1194
+ async fn(state) {
1195
+ var _middlewareData$arrow, _middlewareData$flip;
1196
+ const {
1197
+ placement,
1198
+ middlewareData,
1199
+ rects,
1200
+ initialPlacement,
1201
+ platform: platform2,
1202
+ elements
1203
+ } = state;
1204
+ const {
1205
+ mainAxis: checkMainAxis = true,
1206
+ crossAxis: checkCrossAxis = true,
1207
+ fallbackPlacements: specifiedFallbackPlacements,
1208
+ fallbackStrategy = "bestFit",
1209
+ fallbackAxisSideDirection = "none",
1210
+ flipAlignment = true,
1211
+ ...detectOverflowOptions
1212
+ } = evaluate(options, state);
1213
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1214
+ return {};
1215
+ }
1216
+ const side = getSide(placement);
1217
+ const initialSideAxis = getSideAxis(initialPlacement);
1218
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1219
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1220
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1221
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1222
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1223
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1224
+ }
1225
+ const placements2 = [initialPlacement, ...fallbackPlacements];
1226
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1227
+ const overflows = [];
1228
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1229
+ if (checkMainAxis) {
1230
+ overflows.push(overflow[side]);
1231
+ }
1232
+ if (checkCrossAxis) {
1233
+ const sides2 = getAlignmentSides(placement, rects, rtl);
1234
+ overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
1235
+ }
1236
+ overflowsData = [...overflowsData, {
1237
+ placement,
1238
+ overflows
1239
+ }];
1240
+ if (!overflows.every((side2) => side2 <= 0)) {
1241
+ var _middlewareData$flip2, _overflowsData$filter;
1242
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1243
+ const nextPlacement = placements2[nextIndex];
1244
+ if (nextPlacement) {
1245
+ const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
1246
+ if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
1247
+ // overflows the main axis.
1248
+ overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
1249
+ return {
1250
+ data: {
1251
+ index: nextIndex,
1252
+ overflows: overflowsData
1253
+ },
1254
+ reset: {
1255
+ placement: nextPlacement
1256
+ }
1257
+ };
1258
+ }
1259
+ }
1260
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1261
+ if (!resetPlacement) {
1262
+ switch (fallbackStrategy) {
1263
+ case "bestFit": {
1264
+ var _overflowsData$filter2;
1265
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
1266
+ if (hasFallbackAxisSideDirection) {
1267
+ const currentSideAxis = getSideAxis(d.placement);
1268
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
1269
+ // reading directions favoring greater width.
1270
+ currentSideAxis === "y";
1271
+ }
1272
+ return true;
1273
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1274
+ if (placement2) {
1275
+ resetPlacement = placement2;
1276
+ }
1277
+ break;
1278
+ }
1279
+ case "initialPlacement":
1280
+ resetPlacement = initialPlacement;
1281
+ break;
1282
+ }
1283
+ }
1284
+ if (placement !== resetPlacement) {
1285
+ return {
1286
+ reset: {
1287
+ placement: resetPlacement
1288
+ }
1289
+ };
1290
+ }
1291
+ }
1292
+ return {};
1293
+ }
1294
+ };
1295
+ };
1296
+ function getSideOffsets(overflow, rect) {
1297
+ return {
1298
+ top: overflow.top - rect.height,
1299
+ right: overflow.right - rect.width,
1300
+ bottom: overflow.bottom - rect.height,
1301
+ left: overflow.left - rect.width
1302
+ };
1303
+ }
1304
+ function isAnySideFullyClipped(overflow) {
1305
+ return sides.some((side) => overflow[side] >= 0);
1306
+ }
1307
+ var hide = function(options) {
1308
+ if (options === void 0) {
1309
+ options = {};
1310
+ }
1311
+ return {
1312
+ name: "hide",
1313
+ options,
1314
+ async fn(state) {
1315
+ const {
1316
+ rects
1317
+ } = state;
1318
+ const {
1319
+ strategy = "referenceHidden",
1320
+ ...detectOverflowOptions
1321
+ } = evaluate(options, state);
1322
+ switch (strategy) {
1323
+ case "referenceHidden": {
1324
+ const overflow = await detectOverflow(state, {
1325
+ ...detectOverflowOptions,
1326
+ elementContext: "reference"
1327
+ });
1328
+ const offsets = getSideOffsets(overflow, rects.reference);
1329
+ return {
1330
+ data: {
1331
+ referenceHiddenOffsets: offsets,
1332
+ referenceHidden: isAnySideFullyClipped(offsets)
1333
+ }
1334
+ };
1335
+ }
1336
+ case "escaped": {
1337
+ const overflow = await detectOverflow(state, {
1338
+ ...detectOverflowOptions,
1339
+ altBoundary: true
1340
+ });
1341
+ const offsets = getSideOffsets(overflow, rects.floating);
1342
+ return {
1343
+ data: {
1344
+ escapedOffsets: offsets,
1345
+ escaped: isAnySideFullyClipped(offsets)
1346
+ }
1347
+ };
1348
+ }
1349
+ default: {
1350
+ return {};
1351
+ }
1352
+ }
1353
+ }
1354
+ };
1355
+ };
1356
+ var originSides = /* @__PURE__ */ new Set(["left", "top"]);
1357
+ async function convertValueToCoords(state, options) {
1358
+ const {
1359
+ placement,
1360
+ platform: platform2,
1361
+ elements
1362
+ } = state;
1363
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1364
+ const side = getSide(placement);
1365
+ const alignment = getAlignment(placement);
1366
+ const isVertical = getSideAxis(placement) === "y";
1367
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
1368
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1369
+ const rawValue = evaluate(options, state);
1370
+ let {
1371
+ mainAxis,
1372
+ crossAxis,
1373
+ alignmentAxis
1374
+ } = typeof rawValue === "number" ? {
1375
+ mainAxis: rawValue,
1376
+ crossAxis: 0,
1377
+ alignmentAxis: null
1378
+ } : {
1379
+ mainAxis: rawValue.mainAxis || 0,
1380
+ crossAxis: rawValue.crossAxis || 0,
1381
+ alignmentAxis: rawValue.alignmentAxis
1382
+ };
1383
+ if (alignment && typeof alignmentAxis === "number") {
1384
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1385
+ }
1386
+ return isVertical ? {
1387
+ x: crossAxis * crossAxisMulti,
1388
+ y: mainAxis * mainAxisMulti
1389
+ } : {
1390
+ x: mainAxis * mainAxisMulti,
1391
+ y: crossAxis * crossAxisMulti
1392
+ };
1393
+ }
1394
+ var offset = function(options) {
1395
+ if (options === void 0) {
1396
+ options = 0;
1397
+ }
1398
+ return {
1399
+ name: "offset",
1400
+ options,
1401
+ async fn(state) {
1402
+ var _middlewareData$offse, _middlewareData$arrow;
1403
+ const {
1404
+ x,
1405
+ y,
1406
+ placement,
1407
+ middlewareData
1408
+ } = state;
1409
+ const diffCoords = await convertValueToCoords(state, options);
1410
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1411
+ return {};
1412
+ }
1413
+ return {
1414
+ x: x + diffCoords.x,
1415
+ y: y + diffCoords.y,
1416
+ data: {
1417
+ ...diffCoords,
1418
+ placement
1419
+ }
1420
+ };
1421
+ }
1422
+ };
1423
+ };
1424
+ var shift = function(options) {
1425
+ if (options === void 0) {
1426
+ options = {};
1427
+ }
1428
+ return {
1429
+ name: "shift",
1430
+ options,
1431
+ async fn(state) {
1432
+ const {
1433
+ x,
1434
+ y,
1435
+ placement
1436
+ } = state;
1437
+ const {
1438
+ mainAxis: checkMainAxis = true,
1439
+ crossAxis: checkCrossAxis = false,
1440
+ limiter = {
1441
+ fn: (_ref) => {
1442
+ let {
1443
+ x: x2,
1444
+ y: y2
1445
+ } = _ref;
1446
+ return {
1447
+ x: x2,
1448
+ y: y2
1449
+ };
1450
+ }
1451
+ },
1452
+ ...detectOverflowOptions
1453
+ } = evaluate(options, state);
1454
+ const coords = {
1455
+ x,
1456
+ y
1457
+ };
1458
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1459
+ const crossAxis = getSideAxis(getSide(placement));
1460
+ const mainAxis = getOppositeAxis(crossAxis);
1461
+ let mainAxisCoord = coords[mainAxis];
1462
+ let crossAxisCoord = coords[crossAxis];
1463
+ if (checkMainAxis) {
1464
+ const minSide = mainAxis === "y" ? "top" : "left";
1465
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
1466
+ const min2 = mainAxisCoord + overflow[minSide];
1467
+ const max2 = mainAxisCoord - overflow[maxSide];
1468
+ mainAxisCoord = clamp2(min2, mainAxisCoord, max2);
1469
+ }
1470
+ if (checkCrossAxis) {
1471
+ const minSide = crossAxis === "y" ? "top" : "left";
1472
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
1473
+ const min2 = crossAxisCoord + overflow[minSide];
1474
+ const max2 = crossAxisCoord - overflow[maxSide];
1475
+ crossAxisCoord = clamp2(min2, crossAxisCoord, max2);
1476
+ }
1477
+ const limitedCoords = limiter.fn({
1478
+ ...state,
1479
+ [mainAxis]: mainAxisCoord,
1480
+ [crossAxis]: crossAxisCoord
1481
+ });
1482
+ return {
1483
+ ...limitedCoords,
1484
+ data: {
1485
+ x: limitedCoords.x - x,
1486
+ y: limitedCoords.y - y,
1487
+ enabled: {
1488
+ [mainAxis]: checkMainAxis,
1489
+ [crossAxis]: checkCrossAxis
1490
+ }
1491
+ }
1492
+ };
1493
+ }
1494
+ };
1495
+ };
1496
+ var limitShift = function(options) {
1497
+ if (options === void 0) {
1498
+ options = {};
1499
+ }
1500
+ return {
1501
+ options,
1502
+ fn(state) {
1503
+ const {
1504
+ x,
1505
+ y,
1506
+ placement,
1507
+ rects,
1508
+ middlewareData
1509
+ } = state;
1510
+ const {
1511
+ offset: offset4 = 0,
1512
+ mainAxis: checkMainAxis = true,
1513
+ crossAxis: checkCrossAxis = true
1514
+ } = evaluate(options, state);
1515
+ const coords = {
1516
+ x,
1517
+ y
1518
+ };
1519
+ const crossAxis = getSideAxis(placement);
1520
+ const mainAxis = getOppositeAxis(crossAxis);
1521
+ let mainAxisCoord = coords[mainAxis];
1522
+ let crossAxisCoord = coords[crossAxis];
1523
+ const rawOffset = evaluate(offset4, state);
1524
+ const computedOffset = typeof rawOffset === "number" ? {
1525
+ mainAxis: rawOffset,
1526
+ crossAxis: 0
1527
+ } : {
1528
+ mainAxis: 0,
1529
+ crossAxis: 0,
1530
+ ...rawOffset
1531
+ };
1532
+ if (checkMainAxis) {
1533
+ const len = mainAxis === "y" ? "height" : "width";
1534
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1535
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1536
+ if (mainAxisCoord < limitMin) {
1537
+ mainAxisCoord = limitMin;
1538
+ } else if (mainAxisCoord > limitMax) {
1539
+ mainAxisCoord = limitMax;
1540
+ }
1541
+ }
1542
+ if (checkCrossAxis) {
1543
+ var _middlewareData$offse, _middlewareData$offse2;
1544
+ const len = mainAxis === "y" ? "width" : "height";
1545
+ const isOriginSide = originSides.has(getSide(placement));
1546
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1547
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1548
+ if (crossAxisCoord < limitMin) {
1549
+ crossAxisCoord = limitMin;
1550
+ } else if (crossAxisCoord > limitMax) {
1551
+ crossAxisCoord = limitMax;
1552
+ }
1553
+ }
1554
+ return {
1555
+ [mainAxis]: mainAxisCoord,
1556
+ [crossAxis]: crossAxisCoord
1557
+ };
1558
+ }
1559
+ };
1560
+ };
1561
+ var size = function(options) {
1562
+ if (options === void 0) {
1563
+ options = {};
1564
+ }
1565
+ return {
1566
+ name: "size",
1567
+ options,
1568
+ async fn(state) {
1569
+ var _state$middlewareData, _state$middlewareData2;
1570
+ const {
1571
+ placement,
1572
+ rects,
1573
+ platform: platform2,
1574
+ elements
1575
+ } = state;
1576
+ const {
1577
+ apply = () => {
1578
+ },
1579
+ ...detectOverflowOptions
1580
+ } = evaluate(options, state);
1581
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1582
+ const side = getSide(placement);
1583
+ const alignment = getAlignment(placement);
1584
+ const isYAxis = getSideAxis(placement) === "y";
1585
+ const {
1586
+ width,
1587
+ height
1588
+ } = rects.floating;
1589
+ let heightSide;
1590
+ let widthSide;
1591
+ if (side === "top" || side === "bottom") {
1592
+ heightSide = side;
1593
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
1594
+ } else {
1595
+ widthSide = side;
1596
+ heightSide = alignment === "end" ? "top" : "bottom";
1597
+ }
1598
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1599
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1600
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1601
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1602
+ const noShift = !state.middlewareData.shift;
1603
+ let availableHeight = overflowAvailableHeight;
1604
+ let availableWidth = overflowAvailableWidth;
1605
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1606
+ availableWidth = maximumClippingWidth;
1607
+ }
1608
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1609
+ availableHeight = maximumClippingHeight;
1610
+ }
1611
+ if (noShift && !alignment) {
1612
+ const xMin = max(overflow.left, 0);
1613
+ const xMax = max(overflow.right, 0);
1614
+ const yMin = max(overflow.top, 0);
1615
+ const yMax = max(overflow.bottom, 0);
1616
+ if (isYAxis) {
1617
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1618
+ } else {
1619
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1620
+ }
1621
+ }
1622
+ await apply({
1623
+ ...state,
1624
+ availableWidth,
1625
+ availableHeight
1626
+ });
1627
+ const nextDimensions = await platform2.getDimensions(elements.floating);
1628
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1629
+ return {
1630
+ reset: {
1631
+ rects: true
1632
+ }
1633
+ };
1634
+ }
1635
+ return {};
1636
+ }
1637
+ };
1638
+ };
1639
+
1640
+ // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1641
+ function hasWindow() {
1642
+ return typeof window !== "undefined";
1643
+ }
1644
+ function getNodeName(node) {
1645
+ if (isNode(node)) {
1646
+ return (node.nodeName || "").toLowerCase();
1647
+ }
1648
+ return "#document";
1649
+ }
1650
+ function getWindow(node) {
1651
+ var _node$ownerDocument;
1652
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1653
+ }
1654
+ function getDocumentElement(node) {
1655
+ var _ref;
1656
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1657
+ }
1658
+ function isNode(value) {
1659
+ if (!hasWindow()) {
1660
+ return false;
1661
+ }
1662
+ return value instanceof Node || value instanceof getWindow(value).Node;
1663
+ }
1664
+ function isElement(value) {
1665
+ if (!hasWindow()) {
1666
+ return false;
1667
+ }
1668
+ return value instanceof Element || value instanceof getWindow(value).Element;
1669
+ }
1670
+ function isHTMLElement(value) {
1671
+ if (!hasWindow()) {
1672
+ return false;
1673
+ }
1674
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1675
+ }
1676
+ function isShadowRoot(value) {
1677
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
1678
+ return false;
1679
+ }
1680
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1681
+ }
1682
+ var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
1683
+ function isOverflowElement(element) {
1684
+ const {
1685
+ overflow,
1686
+ overflowX,
1687
+ overflowY,
1688
+ display
1689
+ } = getComputedStyle2(element);
1690
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
1691
+ }
1692
+ var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
1693
+ function isTableElement(element) {
1694
+ return tableElements.has(getNodeName(element));
1695
+ }
1696
+ var topLayerSelectors = [":popover-open", ":modal"];
1697
+ function isTopLayer(element) {
1698
+ return topLayerSelectors.some((selector) => {
1699
+ try {
1700
+ return element.matches(selector);
1701
+ } catch (_e) {
1702
+ return false;
1703
+ }
1704
+ });
1705
+ }
1706
+ var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
1707
+ var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
1708
+ var containValues = ["paint", "layout", "strict", "content"];
1709
+ function isContainingBlock(elementOrCss) {
1710
+ const webkit = isWebKit();
1711
+ const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1712
+ return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
1713
+ }
1714
+ function getContainingBlock(element) {
1715
+ let currentNode = getParentNode(element);
1716
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1717
+ if (isContainingBlock(currentNode)) {
1718
+ return currentNode;
1719
+ } else if (isTopLayer(currentNode)) {
1720
+ return null;
1721
+ }
1722
+ currentNode = getParentNode(currentNode);
1723
+ }
1724
+ return null;
1725
+ }
1726
+ function isWebKit() {
1727
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
1728
+ return CSS.supports("-webkit-backdrop-filter", "none");
1729
+ }
1730
+ var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
1731
+ function isLastTraversableNode(node) {
1732
+ return lastTraversableNodeNames.has(getNodeName(node));
1733
+ }
1734
+ function getComputedStyle2(element) {
1735
+ return getWindow(element).getComputedStyle(element);
1736
+ }
1737
+ function getNodeScroll(element) {
1738
+ if (isElement(element)) {
1739
+ return {
1740
+ scrollLeft: element.scrollLeft,
1741
+ scrollTop: element.scrollTop
1742
+ };
1743
+ }
1744
+ return {
1745
+ scrollLeft: element.scrollX,
1746
+ scrollTop: element.scrollY
1747
+ };
1748
+ }
1749
+ function getParentNode(node) {
1750
+ if (getNodeName(node) === "html") {
1751
+ return node;
1752
+ }
1753
+ const result = (
1754
+ // Step into the shadow DOM of the parent of a slotted node.
1755
+ node.assignedSlot || // DOM Element detected.
1756
+ node.parentNode || // ShadowRoot detected.
1757
+ isShadowRoot(node) && node.host || // Fallback.
1758
+ getDocumentElement(node)
1759
+ );
1760
+ return isShadowRoot(result) ? result.host : result;
1761
+ }
1762
+ function getNearestOverflowAncestor(node) {
1763
+ const parentNode = getParentNode(node);
1764
+ if (isLastTraversableNode(parentNode)) {
1765
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1766
+ }
1767
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1768
+ return parentNode;
1769
+ }
1770
+ return getNearestOverflowAncestor(parentNode);
1771
+ }
1772
+ function getOverflowAncestors(node, list, traverseIframes) {
1773
+ var _node$ownerDocument2;
1774
+ if (list === void 0) {
1775
+ list = [];
1776
+ }
1777
+ if (traverseIframes === void 0) {
1778
+ traverseIframes = true;
1779
+ }
1780
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1781
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1782
+ const win = getWindow(scrollableAncestor);
1783
+ if (isBody) {
1784
+ const frameElement = getFrameElement(win);
1785
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1786
+ }
1787
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1788
+ }
1789
+ function getFrameElement(win) {
1790
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1791
+ }
1792
+
1793
+ // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
1794
+ function getCssDimensions(element) {
1795
+ const css = getComputedStyle2(element);
1796
+ let width = parseFloat(css.width) || 0;
1797
+ let height = parseFloat(css.height) || 0;
1798
+ const hasOffset = isHTMLElement(element);
1799
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1800
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1801
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1802
+ if (shouldFallback) {
1803
+ width = offsetWidth;
1804
+ height = offsetHeight;
1805
+ }
1806
+ return {
1807
+ width,
1808
+ height,
1809
+ $: shouldFallback
1810
+ };
1811
+ }
1812
+ function unwrapElement(element) {
1813
+ return !isElement(element) ? element.contextElement : element;
1814
+ }
1815
+ function getScale(element) {
1816
+ const domElement = unwrapElement(element);
1817
+ if (!isHTMLElement(domElement)) {
1818
+ return createCoords(1);
1819
+ }
1820
+ const rect = domElement.getBoundingClientRect();
1821
+ const {
1822
+ width,
1823
+ height,
1824
+ $
1825
+ } = getCssDimensions(domElement);
1826
+ let x = ($ ? round(rect.width) : rect.width) / width;
1827
+ let y = ($ ? round(rect.height) : rect.height) / height;
1828
+ if (!x || !Number.isFinite(x)) {
1829
+ x = 1;
1830
+ }
1831
+ if (!y || !Number.isFinite(y)) {
1832
+ y = 1;
1833
+ }
1834
+ return {
1835
+ x,
1836
+ y
1837
+ };
1838
+ }
1839
+ var noOffsets = /* @__PURE__ */ createCoords(0);
1840
+ function getVisualOffsets(element) {
1841
+ const win = getWindow(element);
1842
+ if (!isWebKit() || !win.visualViewport) {
1843
+ return noOffsets;
1844
+ }
1845
+ return {
1846
+ x: win.visualViewport.offsetLeft,
1847
+ y: win.visualViewport.offsetTop
1848
+ };
1849
+ }
1850
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1851
+ if (isFixed === void 0) {
1852
+ isFixed = false;
1853
+ }
1854
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1855
+ return false;
1856
+ }
1857
+ return isFixed;
1858
+ }
1859
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1860
+ if (includeScale === void 0) {
1861
+ includeScale = false;
1862
+ }
1863
+ if (isFixedStrategy === void 0) {
1864
+ isFixedStrategy = false;
1865
+ }
1866
+ const clientRect = element.getBoundingClientRect();
1867
+ const domElement = unwrapElement(element);
1868
+ let scale = createCoords(1);
1869
+ if (includeScale) {
1870
+ if (offsetParent) {
1871
+ if (isElement(offsetParent)) {
1872
+ scale = getScale(offsetParent);
1873
+ }
1874
+ } else {
1875
+ scale = getScale(element);
1876
+ }
1877
+ }
1878
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1879
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1880
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1881
+ let width = clientRect.width / scale.x;
1882
+ let height = clientRect.height / scale.y;
1883
+ if (domElement) {
1884
+ const win = getWindow(domElement);
1885
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1886
+ let currentWin = win;
1887
+ let currentIFrame = getFrameElement(currentWin);
1888
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1889
+ const iframeScale = getScale(currentIFrame);
1890
+ const iframeRect = currentIFrame.getBoundingClientRect();
1891
+ const css = getComputedStyle2(currentIFrame);
1892
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1893
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1894
+ x *= iframeScale.x;
1895
+ y *= iframeScale.y;
1896
+ width *= iframeScale.x;
1897
+ height *= iframeScale.y;
1898
+ x += left;
1899
+ y += top;
1900
+ currentWin = getWindow(currentIFrame);
1901
+ currentIFrame = getFrameElement(currentWin);
1902
+ }
1903
+ }
1904
+ return rectToClientRect({
1905
+ width,
1906
+ height,
1907
+ x,
1908
+ y
1909
+ });
1910
+ }
1911
+ function getWindowScrollBarX(element, rect) {
1912
+ const leftScroll = getNodeScroll(element).scrollLeft;
1913
+ if (!rect) {
1914
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1915
+ }
1916
+ return rect.left + leftScroll;
1917
+ }
1918
+ function getHTMLOffset(documentElement, scroll) {
1919
+ const htmlRect = documentElement.getBoundingClientRect();
1920
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1921
+ const y = htmlRect.top + scroll.scrollTop;
1922
+ return {
1923
+ x,
1924
+ y
1925
+ };
1926
+ }
1927
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1928
+ let {
1929
+ elements,
1930
+ rect,
1931
+ offsetParent,
1932
+ strategy
1933
+ } = _ref;
1934
+ const isFixed = strategy === "fixed";
1935
+ const documentElement = getDocumentElement(offsetParent);
1936
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1937
+ if (offsetParent === documentElement || topLayer && isFixed) {
1938
+ return rect;
1939
+ }
1940
+ let scroll = {
1941
+ scrollLeft: 0,
1942
+ scrollTop: 0
1943
+ };
1944
+ let scale = createCoords(1);
1945
+ const offsets = createCoords(0);
1946
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1947
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1948
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1949
+ scroll = getNodeScroll(offsetParent);
1950
+ }
1951
+ if (isHTMLElement(offsetParent)) {
1952
+ const offsetRect = getBoundingClientRect(offsetParent);
1953
+ scale = getScale(offsetParent);
1954
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1955
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1956
+ }
1957
+ }
1958
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1959
+ return {
1960
+ width: rect.width * scale.x,
1961
+ height: rect.height * scale.y,
1962
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1963
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1964
+ };
1965
+ }
1966
+ function getClientRects(element) {
1967
+ return Array.from(element.getClientRects());
1968
+ }
1969
+ function getDocumentRect(element) {
1970
+ const html = getDocumentElement(element);
1971
+ const scroll = getNodeScroll(element);
1972
+ const body = element.ownerDocument.body;
1973
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1974
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1975
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1976
+ const y = -scroll.scrollTop;
1977
+ if (getComputedStyle2(body).direction === "rtl") {
1978
+ x += max(html.clientWidth, body.clientWidth) - width;
1979
+ }
1980
+ return {
1981
+ width,
1982
+ height,
1983
+ x,
1984
+ y
1985
+ };
1986
+ }
1987
+ var SCROLLBAR_MAX = 25;
1988
+ function getViewportRect(element, strategy) {
1989
+ const win = getWindow(element);
1990
+ const html = getDocumentElement(element);
1991
+ const visualViewport = win.visualViewport;
1992
+ let width = html.clientWidth;
1993
+ let height = html.clientHeight;
1994
+ let x = 0;
1995
+ let y = 0;
1996
+ if (visualViewport) {
1997
+ width = visualViewport.width;
1998
+ height = visualViewport.height;
1999
+ const visualViewportBased = isWebKit();
2000
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2001
+ x = visualViewport.offsetLeft;
2002
+ y = visualViewport.offsetTop;
2003
+ }
2004
+ }
2005
+ const windowScrollbarX = getWindowScrollBarX(html);
2006
+ if (windowScrollbarX <= 0) {
2007
+ const doc = html.ownerDocument;
2008
+ const body = doc.body;
2009
+ const bodyStyles = getComputedStyle(body);
2010
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
2011
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
2012
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
2013
+ width -= clippingStableScrollbarWidth;
2014
+ }
2015
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
2016
+ width += windowScrollbarX;
2017
+ }
2018
+ return {
2019
+ width,
2020
+ height,
2021
+ x,
2022
+ y
2023
+ };
2024
+ }
2025
+ var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
2026
+ function getInnerBoundingClientRect(element, strategy) {
2027
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2028
+ const top = clientRect.top + element.clientTop;
2029
+ const left = clientRect.left + element.clientLeft;
2030
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2031
+ const width = element.clientWidth * scale.x;
2032
+ const height = element.clientHeight * scale.y;
2033
+ const x = left * scale.x;
2034
+ const y = top * scale.y;
2035
+ return {
2036
+ width,
2037
+ height,
2038
+ x,
2039
+ y
2040
+ };
2041
+ }
2042
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2043
+ let rect;
2044
+ if (clippingAncestor === "viewport") {
2045
+ rect = getViewportRect(element, strategy);
2046
+ } else if (clippingAncestor === "document") {
2047
+ rect = getDocumentRect(getDocumentElement(element));
2048
+ } else if (isElement(clippingAncestor)) {
2049
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2050
+ } else {
2051
+ const visualOffsets = getVisualOffsets(element);
2052
+ rect = {
2053
+ x: clippingAncestor.x - visualOffsets.x,
2054
+ y: clippingAncestor.y - visualOffsets.y,
2055
+ width: clippingAncestor.width,
2056
+ height: clippingAncestor.height
2057
+ };
2058
+ }
2059
+ return rectToClientRect(rect);
2060
+ }
2061
+ function hasFixedPositionAncestor(element, stopNode) {
2062
+ const parentNode = getParentNode(element);
2063
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2064
+ return false;
2065
+ }
2066
+ return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2067
+ }
2068
+ function getClippingElementAncestors(element, cache) {
2069
+ const cachedResult = cache.get(element);
2070
+ if (cachedResult) {
2071
+ return cachedResult;
2072
+ }
2073
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2074
+ let currentContainingBlockComputedStyle = null;
2075
+ const elementIsFixed = getComputedStyle2(element).position === "fixed";
2076
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2077
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2078
+ const computedStyle = getComputedStyle2(currentNode);
2079
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2080
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2081
+ currentContainingBlockComputedStyle = null;
2082
+ }
2083
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2084
+ if (shouldDropCurrentNode) {
2085
+ result = result.filter((ancestor) => ancestor !== currentNode);
2086
+ } else {
2087
+ currentContainingBlockComputedStyle = computedStyle;
2088
+ }
2089
+ currentNode = getParentNode(currentNode);
2090
+ }
2091
+ cache.set(element, result);
2092
+ return result;
2093
+ }
2094
+ function getClippingRect(_ref) {
2095
+ let {
2096
+ element,
2097
+ boundary,
2098
+ rootBoundary,
2099
+ strategy
2100
+ } = _ref;
2101
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2102
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2103
+ const firstClippingAncestor = clippingAncestors[0];
2104
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2105
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2106
+ accRect.top = max(rect.top, accRect.top);
2107
+ accRect.right = min(rect.right, accRect.right);
2108
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2109
+ accRect.left = max(rect.left, accRect.left);
2110
+ return accRect;
2111
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2112
+ return {
2113
+ width: clippingRect.right - clippingRect.left,
2114
+ height: clippingRect.bottom - clippingRect.top,
2115
+ x: clippingRect.left,
2116
+ y: clippingRect.top
2117
+ };
2118
+ }
2119
+ function getDimensions(element) {
2120
+ const {
2121
+ width,
2122
+ height
2123
+ } = getCssDimensions(element);
2124
+ return {
2125
+ width,
2126
+ height
2127
+ };
2128
+ }
2129
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2130
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2131
+ const documentElement = getDocumentElement(offsetParent);
2132
+ const isFixed = strategy === "fixed";
2133
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2134
+ let scroll = {
2135
+ scrollLeft: 0,
2136
+ scrollTop: 0
2137
+ };
2138
+ const offsets = createCoords(0);
2139
+ function setLeftRTLScrollbarOffset() {
2140
+ offsets.x = getWindowScrollBarX(documentElement);
2141
+ }
2142
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2143
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2144
+ scroll = getNodeScroll(offsetParent);
2145
+ }
2146
+ if (isOffsetParentAnElement) {
2147
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2148
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2149
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2150
+ } else if (documentElement) {
2151
+ setLeftRTLScrollbarOffset();
2152
+ }
2153
+ }
2154
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
2155
+ setLeftRTLScrollbarOffset();
2156
+ }
2157
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2158
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2159
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2160
+ return {
2161
+ x,
2162
+ y,
2163
+ width: rect.width,
2164
+ height: rect.height
2165
+ };
2166
+ }
2167
+ function isStaticPositioned(element) {
2168
+ return getComputedStyle2(element).position === "static";
2169
+ }
2170
+ function getTrueOffsetParent(element, polyfill) {
2171
+ if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
2172
+ return null;
2173
+ }
2174
+ if (polyfill) {
2175
+ return polyfill(element);
2176
+ }
2177
+ let rawOffsetParent = element.offsetParent;
2178
+ if (getDocumentElement(element) === rawOffsetParent) {
2179
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
2180
+ }
2181
+ return rawOffsetParent;
2182
+ }
2183
+ function getOffsetParent(element, polyfill) {
2184
+ const win = getWindow(element);
2185
+ if (isTopLayer(element)) {
2186
+ return win;
2187
+ }
2188
+ if (!isHTMLElement(element)) {
2189
+ let svgOffsetParent = getParentNode(element);
2190
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2191
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2192
+ return svgOffsetParent;
2193
+ }
2194
+ svgOffsetParent = getParentNode(svgOffsetParent);
2195
+ }
2196
+ return win;
2197
+ }
2198
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2199
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2200
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2201
+ }
2202
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2203
+ return win;
2204
+ }
2205
+ return offsetParent || getContainingBlock(element) || win;
2206
+ }
2207
+ var getElementRects = async function(data) {
2208
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2209
+ const getDimensionsFn = this.getDimensions;
2210
+ const floatingDimensions = await getDimensionsFn(data.floating);
2211
+ return {
2212
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2213
+ floating: {
2214
+ x: 0,
2215
+ y: 0,
2216
+ width: floatingDimensions.width,
2217
+ height: floatingDimensions.height
2218
+ }
2219
+ };
2220
+ };
2221
+ function isRTL(element) {
2222
+ return getComputedStyle2(element).direction === "rtl";
2223
+ }
2224
+ var platform = {
2225
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2226
+ getDocumentElement,
2227
+ getClippingRect,
2228
+ getOffsetParent,
2229
+ getElementRects,
2230
+ getClientRects,
2231
+ getDimensions,
2232
+ getScale,
2233
+ isElement,
2234
+ isRTL
2235
+ };
2236
+ function rectsAreEqual(a, b) {
2237
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
2238
+ }
2239
+ function observeMove(element, onMove) {
2240
+ let io = null;
2241
+ let timeoutId;
2242
+ const root = getDocumentElement(element);
2243
+ function cleanup() {
2244
+ var _io;
2245
+ clearTimeout(timeoutId);
2246
+ (_io = io) == null || _io.disconnect();
2247
+ io = null;
2248
+ }
2249
+ function refresh(skip, threshold) {
2250
+ if (skip === void 0) {
2251
+ skip = false;
2252
+ }
2253
+ if (threshold === void 0) {
2254
+ threshold = 1;
2255
+ }
2256
+ cleanup();
2257
+ const elementRectForRootMargin = element.getBoundingClientRect();
2258
+ const {
2259
+ left,
2260
+ top,
2261
+ width,
2262
+ height
2263
+ } = elementRectForRootMargin;
2264
+ if (!skip) {
2265
+ onMove();
2266
+ }
2267
+ if (!width || !height) {
2268
+ return;
2269
+ }
2270
+ const insetTop = floor(top);
2271
+ const insetRight = floor(root.clientWidth - (left + width));
2272
+ const insetBottom = floor(root.clientHeight - (top + height));
2273
+ const insetLeft = floor(left);
2274
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2275
+ const options = {
2276
+ rootMargin,
2277
+ threshold: max(0, min(1, threshold)) || 1
2278
+ };
2279
+ let isFirstUpdate = true;
2280
+ function handleObserve(entries) {
2281
+ const ratio = entries[0].intersectionRatio;
2282
+ if (ratio !== threshold) {
2283
+ if (!isFirstUpdate) {
2284
+ return refresh();
2285
+ }
2286
+ if (!ratio) {
2287
+ timeoutId = setTimeout(() => {
2288
+ refresh(false, 1e-7);
2289
+ }, 1e3);
2290
+ } else {
2291
+ refresh(false, ratio);
2292
+ }
2293
+ }
2294
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
2295
+ refresh();
2296
+ }
2297
+ isFirstUpdate = false;
2298
+ }
2299
+ try {
2300
+ io = new IntersectionObserver(handleObserve, {
2301
+ ...options,
2302
+ // Handle <iframe>s
2303
+ root: root.ownerDocument
2304
+ });
2305
+ } catch (_e) {
2306
+ io = new IntersectionObserver(handleObserve, options);
2307
+ }
2308
+ io.observe(element);
2309
+ }
2310
+ refresh(true);
2311
+ return cleanup;
2312
+ }
2313
+ function autoUpdate(reference, floating, update, options) {
2314
+ if (options === void 0) {
2315
+ options = {};
2316
+ }
2317
+ const {
2318
+ ancestorScroll = true,
2319
+ ancestorResize = true,
2320
+ elementResize = typeof ResizeObserver === "function",
2321
+ layoutShift = typeof IntersectionObserver === "function",
2322
+ animationFrame = false
2323
+ } = options;
2324
+ const referenceEl = unwrapElement(reference);
2325
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2326
+ ancestors.forEach((ancestor) => {
2327
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
2328
+ passive: true
2329
+ });
2330
+ ancestorResize && ancestor.addEventListener("resize", update);
2331
+ });
2332
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2333
+ let reobserveFrame = -1;
2334
+ let resizeObserver = null;
2335
+ if (elementResize) {
2336
+ resizeObserver = new ResizeObserver((_ref) => {
2337
+ let [firstEntry] = _ref;
2338
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2339
+ resizeObserver.unobserve(floating);
2340
+ cancelAnimationFrame(reobserveFrame);
2341
+ reobserveFrame = requestAnimationFrame(() => {
2342
+ var _resizeObserver;
2343
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2344
+ });
2345
+ }
2346
+ update();
2347
+ });
2348
+ if (referenceEl && !animationFrame) {
2349
+ resizeObserver.observe(referenceEl);
2350
+ }
2351
+ resizeObserver.observe(floating);
2352
+ }
2353
+ let frameId;
2354
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2355
+ if (animationFrame) {
2356
+ frameLoop();
2357
+ }
2358
+ function frameLoop() {
2359
+ const nextRefRect = getBoundingClientRect(reference);
2360
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2361
+ update();
2362
+ }
2363
+ prevRefRect = nextRefRect;
2364
+ frameId = requestAnimationFrame(frameLoop);
2365
+ }
2366
+ update();
2367
+ return () => {
2368
+ var _resizeObserver2;
2369
+ ancestors.forEach((ancestor) => {
2370
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
2371
+ ancestorResize && ancestor.removeEventListener("resize", update);
2372
+ });
2373
+ cleanupIo == null || cleanupIo();
2374
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2375
+ resizeObserver = null;
2376
+ if (animationFrame) {
2377
+ cancelAnimationFrame(frameId);
2378
+ }
2379
+ };
2380
+ }
2381
+ var offset2 = offset;
2382
+ var shift2 = shift;
2383
+ var flip2 = flip;
2384
+ var size2 = size;
2385
+ var hide2 = hide;
2386
+ var arrow2 = arrow;
2387
+ var limitShift2 = limitShift;
2388
+ var computePosition2 = (reference, floating, options) => {
2389
+ const cache = /* @__PURE__ */ new Map();
2390
+ const mergedOptions = {
2391
+ platform,
2392
+ ...options
2393
+ };
2394
+ const platformWithCache = {
2395
+ ...mergedOptions.platform,
2396
+ _c: cache
2397
+ };
2398
+ return computePosition(reference, floating, {
2399
+ ...mergedOptions,
2400
+ platform: platformWithCache
2401
+ });
2402
+ };
2403
+ var isClient = typeof document !== "undefined";
2404
+ var noop = function noop2() {
2405
+ };
2406
+ var index = isClient ? useLayoutEffect : noop;
2407
+ function deepEqual(a, b) {
2408
+ if (a === b) {
2409
+ return true;
2410
+ }
2411
+ if (typeof a !== typeof b) {
2412
+ return false;
2413
+ }
2414
+ if (typeof a === "function" && a.toString() === b.toString()) {
2415
+ return true;
2416
+ }
2417
+ let length;
2418
+ let i;
2419
+ let keys;
2420
+ if (a && b && typeof a === "object") {
2421
+ if (Array.isArray(a)) {
2422
+ length = a.length;
2423
+ if (length !== b.length) return false;
2424
+ for (i = length; i-- !== 0; ) {
2425
+ if (!deepEqual(a[i], b[i])) {
2426
+ return false;
2427
+ }
2428
+ }
2429
+ return true;
2430
+ }
2431
+ keys = Object.keys(a);
2432
+ length = keys.length;
2433
+ if (length !== Object.keys(b).length) {
2434
+ return false;
2435
+ }
2436
+ for (i = length; i-- !== 0; ) {
2437
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2438
+ return false;
2439
+ }
2440
+ }
2441
+ for (i = length; i-- !== 0; ) {
2442
+ const key = keys[i];
2443
+ if (key === "_owner" && a.$$typeof) {
2444
+ continue;
2445
+ }
2446
+ if (!deepEqual(a[key], b[key])) {
2447
+ return false;
2448
+ }
2449
+ }
2450
+ return true;
2451
+ }
2452
+ return a !== a && b !== b;
2453
+ }
2454
+ function getDPR(element) {
2455
+ if (typeof window === "undefined") {
2456
+ return 1;
2457
+ }
2458
+ const win = element.ownerDocument.defaultView || window;
2459
+ return win.devicePixelRatio || 1;
2460
+ }
2461
+ function roundByDPR(element, value) {
2462
+ const dpr = getDPR(element);
2463
+ return Math.round(value * dpr) / dpr;
2464
+ }
2465
+ function useLatestRef(value) {
2466
+ const ref = React30.useRef(value);
2467
+ index(() => {
2468
+ ref.current = value;
2469
+ });
2470
+ return ref;
2471
+ }
2472
+ function useFloating(options) {
2473
+ if (options === void 0) {
2474
+ options = {};
2475
+ }
2476
+ const {
2477
+ placement = "bottom",
2478
+ strategy = "absolute",
2479
+ middleware = [],
2480
+ platform: platform2,
2481
+ elements: {
2482
+ reference: externalReference,
2483
+ floating: externalFloating
2484
+ } = {},
2485
+ transform = true,
2486
+ whileElementsMounted,
2487
+ open
2488
+ } = options;
2489
+ const [data, setData] = React30.useState({
2490
+ x: 0,
2491
+ y: 0,
2492
+ strategy,
2493
+ placement,
2494
+ middlewareData: {},
2495
+ isPositioned: false
2496
+ });
2497
+ const [latestMiddleware, setLatestMiddleware] = React30.useState(middleware);
2498
+ if (!deepEqual(latestMiddleware, middleware)) {
2499
+ setLatestMiddleware(middleware);
2500
+ }
2501
+ const [_reference, _setReference] = React30.useState(null);
2502
+ const [_floating, _setFloating] = React30.useState(null);
2503
+ const setReference = React30.useCallback((node) => {
2504
+ if (node !== referenceRef.current) {
2505
+ referenceRef.current = node;
2506
+ _setReference(node);
2507
+ }
2508
+ }, []);
2509
+ const setFloating = React30.useCallback((node) => {
2510
+ if (node !== floatingRef.current) {
2511
+ floatingRef.current = node;
2512
+ _setFloating(node);
2513
+ }
2514
+ }, []);
2515
+ const referenceEl = externalReference || _reference;
2516
+ const floatingEl = externalFloating || _floating;
2517
+ const referenceRef = React30.useRef(null);
2518
+ const floatingRef = React30.useRef(null);
2519
+ const dataRef = React30.useRef(data);
2520
+ const hasWhileElementsMounted = whileElementsMounted != null;
2521
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2522
+ const platformRef = useLatestRef(platform2);
2523
+ const openRef = useLatestRef(open);
2524
+ const update = React30.useCallback(() => {
2525
+ if (!referenceRef.current || !floatingRef.current) {
2526
+ return;
2527
+ }
2528
+ const config = {
2529
+ placement,
2530
+ strategy,
2531
+ middleware: latestMiddleware
2532
+ };
2533
+ if (platformRef.current) {
2534
+ config.platform = platformRef.current;
2535
+ }
2536
+ computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
2537
+ const fullData = {
2538
+ ...data2,
2539
+ // The floating element's position may be recomputed while it's closed
2540
+ // but still mounted (such as when transitioning out). To ensure
2541
+ // `isPositioned` will be `false` initially on the next open, avoid
2542
+ // setting it to `true` when `open === false` (must be specified).
2543
+ isPositioned: openRef.current !== false
2544
+ };
2545
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2546
+ dataRef.current = fullData;
2547
+ ReactDOM4.flushSync(() => {
2548
+ setData(fullData);
2549
+ });
2550
+ }
2551
+ });
2552
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2553
+ index(() => {
2554
+ if (open === false && dataRef.current.isPositioned) {
2555
+ dataRef.current.isPositioned = false;
2556
+ setData((data2) => ({
2557
+ ...data2,
2558
+ isPositioned: false
2559
+ }));
2560
+ }
2561
+ }, [open]);
2562
+ const isMountedRef = React30.useRef(false);
2563
+ index(() => {
2564
+ isMountedRef.current = true;
2565
+ return () => {
2566
+ isMountedRef.current = false;
2567
+ };
2568
+ }, []);
2569
+ index(() => {
2570
+ if (referenceEl) referenceRef.current = referenceEl;
2571
+ if (floatingEl) floatingRef.current = floatingEl;
2572
+ if (referenceEl && floatingEl) {
2573
+ if (whileElementsMountedRef.current) {
2574
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2575
+ }
2576
+ update();
2577
+ }
2578
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2579
+ const refs = React30.useMemo(() => ({
2580
+ reference: referenceRef,
2581
+ floating: floatingRef,
2582
+ setReference,
2583
+ setFloating
2584
+ }), [setReference, setFloating]);
2585
+ const elements = React30.useMemo(() => ({
2586
+ reference: referenceEl,
2587
+ floating: floatingEl
2588
+ }), [referenceEl, floatingEl]);
2589
+ const floatingStyles = React30.useMemo(() => {
2590
+ const initialStyles = {
2591
+ position: strategy,
2592
+ left: 0,
2593
+ top: 0
2594
+ };
2595
+ if (!elements.floating) {
2596
+ return initialStyles;
2597
+ }
2598
+ const x = roundByDPR(elements.floating, data.x);
2599
+ const y = roundByDPR(elements.floating, data.y);
2600
+ if (transform) {
2601
+ return {
2602
+ ...initialStyles,
2603
+ transform: "translate(" + x + "px, " + y + "px)",
2604
+ ...getDPR(elements.floating) >= 1.5 && {
2605
+ willChange: "transform"
2606
+ }
2607
+ };
2608
+ }
2609
+ return {
2610
+ position: strategy,
2611
+ left: x,
2612
+ top: y
2613
+ };
2614
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2615
+ return React30.useMemo(() => ({
2616
+ ...data,
2617
+ update,
2618
+ refs,
2619
+ elements,
2620
+ floatingStyles
2621
+ }), [data, update, refs, elements, floatingStyles]);
2622
+ }
2623
+ var arrow$1 = (options) => {
2624
+ function isRef(value) {
2625
+ return {}.hasOwnProperty.call(value, "current");
2626
+ }
2627
+ return {
2628
+ name: "arrow",
2629
+ options,
2630
+ fn(state) {
2631
+ const {
2632
+ element,
2633
+ padding
2634
+ } = typeof options === "function" ? options(state) : options;
2635
+ if (element && isRef(element)) {
2636
+ if (element.current != null) {
2637
+ return arrow2({
2638
+ element: element.current,
2639
+ padding
2640
+ }).fn(state);
2641
+ }
2642
+ return {};
2643
+ }
2644
+ if (element) {
2645
+ return arrow2({
2646
+ element,
2647
+ padding
2648
+ }).fn(state);
2649
+ }
2650
+ return {};
2651
+ }
2652
+ };
2653
+ };
2654
+ var offset3 = (options, deps) => ({
2655
+ ...offset2(options),
2656
+ options: [options, deps]
2657
+ });
2658
+ var shift3 = (options, deps) => ({
2659
+ ...shift2(options),
2660
+ options: [options, deps]
2661
+ });
2662
+ var limitShift3 = (options, deps) => ({
2663
+ ...limitShift2(options),
2664
+ options: [options, deps]
2665
+ });
2666
+ var flip3 = (options, deps) => ({
2667
+ ...flip2(options),
2668
+ options: [options, deps]
2669
+ });
2670
+ var size3 = (options, deps) => ({
2671
+ ...size2(options),
2672
+ options: [options, deps]
2673
+ });
2674
+ var hide3 = (options, deps) => ({
2675
+ ...hide2(options),
2676
+ options: [options, deps]
2677
+ });
2678
+ var arrow3 = (options, deps) => ({
2679
+ ...arrow$1(options),
2680
+ options: [options, deps]
2681
+ });
2682
+ var NAME = "Arrow";
2683
+ var Arrow = React30.forwardRef((props, forwardedRef) => {
2684
+ const { children, width = 10, height = 5, ...arrowProps } = props;
2685
+ return /* @__PURE__ */ jsx(
2686
+ Primitive.svg,
2687
+ {
2688
+ ...arrowProps,
2689
+ ref: forwardedRef,
2690
+ width,
2691
+ height,
2692
+ viewBox: "0 0 30 10",
2693
+ preserveAspectRatio: "none",
2694
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
2695
+ }
2696
+ );
2697
+ });
2698
+ Arrow.displayName = NAME;
2699
+ var Root = Arrow;
2700
+ function useSize(element) {
2701
+ const [size4, setSize] = React30.useState(void 0);
2702
+ useLayoutEffect2(() => {
2703
+ if (element) {
2704
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
2705
+ const resizeObserver = new ResizeObserver((entries) => {
2706
+ if (!Array.isArray(entries)) {
2707
+ return;
2708
+ }
2709
+ if (!entries.length) {
2710
+ return;
2711
+ }
2712
+ const entry = entries[0];
2713
+ let width;
2714
+ let height;
2715
+ if ("borderBoxSize" in entry) {
2716
+ const borderSizeEntry = entry["borderBoxSize"];
2717
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2718
+ width = borderSize["inlineSize"];
2719
+ height = borderSize["blockSize"];
2720
+ } else {
2721
+ width = element.offsetWidth;
2722
+ height = element.offsetHeight;
2723
+ }
2724
+ setSize({ width, height });
2725
+ });
2726
+ resizeObserver.observe(element, { box: "border-box" });
2727
+ return () => resizeObserver.unobserve(element);
2728
+ } else {
2729
+ setSize(void 0);
2730
+ }
2731
+ }, [element]);
2732
+ return size4;
2733
+ }
2734
+ var POPPER_NAME = "Popper";
2735
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
2736
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
2737
+ var ANCHOR_NAME = "PopperAnchor";
2738
+ var PopperAnchor = React30.forwardRef(
2739
+ (props, forwardedRef) => {
2740
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
2741
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
2742
+ const ref = React30.useRef(null);
2743
+ const composedRefs = useComposedRefs(forwardedRef, ref);
2744
+ const anchorRef = React30.useRef(null);
2745
+ React30.useEffect(() => {
2746
+ const previousAnchor = anchorRef.current;
2747
+ anchorRef.current = virtualRef?.current || ref.current;
2748
+ if (previousAnchor !== anchorRef.current) {
2749
+ context.onAnchorChange(anchorRef.current);
2750
+ }
2751
+ });
2752
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
2753
+ }
2754
+ );
2755
+ PopperAnchor.displayName = ANCHOR_NAME;
2756
+ var CONTENT_NAME = "PopperContent";
2757
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
2758
+ var PopperContent = React30.forwardRef(
2759
+ (props, forwardedRef) => {
2760
+ const {
2761
+ __scopePopper,
2762
+ side = "bottom",
2763
+ sideOffset = 0,
2764
+ align = "center",
2765
+ alignOffset = 0,
2766
+ arrowPadding = 0,
2767
+ avoidCollisions = true,
2768
+ collisionBoundary = [],
2769
+ collisionPadding: collisionPaddingProp = 0,
2770
+ sticky = "partial",
2771
+ hideWhenDetached = false,
2772
+ updatePositionStrategy = "optimized",
2773
+ onPlaced,
2774
+ ...contentProps
2775
+ } = props;
2776
+ const context = usePopperContext(CONTENT_NAME, __scopePopper);
2777
+ const [content, setContent] = React30.useState(null);
2778
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
2779
+ const [arrow4, setArrow] = React30.useState(null);
2780
+ const arrowSize = useSize(arrow4);
2781
+ const arrowWidth = arrowSize?.width ?? 0;
2782
+ const arrowHeight = arrowSize?.height ?? 0;
2783
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
2784
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
2785
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
2786
+ const hasExplicitBoundaries = boundary.length > 0;
2787
+ const detectOverflowOptions = {
2788
+ padding: collisionPadding,
2789
+ boundary: boundary.filter(isNotNull),
2790
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2791
+ altBoundary: hasExplicitBoundaries
2792
+ };
2793
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
2794
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2795
+ strategy: "fixed",
2796
+ placement: desiredPlacement,
2797
+ whileElementsMounted: (...args) => {
2798
+ const cleanup = autoUpdate(...args, {
2799
+ animationFrame: updatePositionStrategy === "always"
2800
+ });
2801
+ return cleanup;
2802
+ },
2803
+ elements: {
2804
+ reference: context.anchor
2805
+ },
2806
+ middleware: [
2807
+ offset3({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
2808
+ avoidCollisions && shift3({
2809
+ mainAxis: true,
2810
+ crossAxis: false,
2811
+ limiter: sticky === "partial" ? limitShift3() : void 0,
2812
+ ...detectOverflowOptions
2813
+ }),
2814
+ avoidCollisions && flip3({ ...detectOverflowOptions }),
2815
+ size3({
2816
+ ...detectOverflowOptions,
2817
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
2818
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
2819
+ const contentStyle = elements.floating.style;
2820
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
2821
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
2822
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
2823
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
2824
+ }
2825
+ }),
2826
+ arrow4 && arrow3({ element: arrow4, padding: arrowPadding }),
2827
+ transformOrigin({ arrowWidth, arrowHeight }),
2828
+ hideWhenDetached && hide3({ strategy: "referenceHidden", ...detectOverflowOptions })
2829
+ ]
2830
+ });
2831
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2832
+ const handlePlaced = useCallbackRef(onPlaced);
2833
+ useLayoutEffect2(() => {
2834
+ if (isPositioned) {
2835
+ handlePlaced?.();
2836
+ }
2837
+ }, [isPositioned, handlePlaced]);
2838
+ const arrowX = middlewareData.arrow?.x;
2839
+ const arrowY = middlewareData.arrow?.y;
2840
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2841
+ const [contentZIndex, setContentZIndex] = React30.useState();
2842
+ useLayoutEffect2(() => {
2843
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2844
+ }, [content]);
2845
+ return /* @__PURE__ */ jsx(
2846
+ "div",
2847
+ {
2848
+ ref: refs.setFloating,
2849
+ "data-radix-popper-content-wrapper": "",
2850
+ style: {
2851
+ ...floatingStyles,
2852
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
2853
+ // keep off the page when measuring
2854
+ minWidth: "max-content",
2855
+ zIndex: contentZIndex,
2856
+ ["--radix-popper-transform-origin"]: [
2857
+ middlewareData.transformOrigin?.x,
2858
+ middlewareData.transformOrigin?.y
2859
+ ].join(" "),
2860
+ // hide the content if using the hide middleware and should be hidden
2861
+ // set visibility to hidden and disable pointer events so the UI behaves
2862
+ // as if the PopperContent isn't there at all
2863
+ ...middlewareData.hide?.referenceHidden && {
2864
+ visibility: "hidden",
2865
+ pointerEvents: "none"
2866
+ }
2867
+ },
2868
+ dir: props.dir,
2869
+ children: /* @__PURE__ */ jsx(
2870
+ PopperContentProvider,
2871
+ {
2872
+ scope: __scopePopper,
2873
+ placedSide,
2874
+ onArrowChange: setArrow,
2875
+ arrowX,
2876
+ arrowY,
2877
+ shouldHideArrow: cannotCenterArrow,
2878
+ children: /* @__PURE__ */ jsx(
2879
+ Primitive.div,
2880
+ {
2881
+ "data-side": placedSide,
2882
+ "data-align": placedAlign,
2883
+ ...contentProps,
2884
+ ref: composedRefs,
2885
+ style: {
2886
+ ...contentProps.style,
2887
+ // if the PopperContent hasn't been placed yet (not all measurements done)
2888
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
2889
+ animation: !isPositioned ? "none" : void 0
2890
+ }
2891
+ }
2892
+ )
2893
+ }
2894
+ )
2895
+ }
2896
+ );
2897
+ }
2898
+ );
2899
+ PopperContent.displayName = CONTENT_NAME;
2900
+ var ARROW_NAME = "PopperArrow";
2901
+ var OPPOSITE_SIDE = {
2902
+ top: "bottom",
2903
+ right: "left",
2904
+ bottom: "top",
2905
+ left: "right"
2906
+ };
2907
+ var PopperArrow = React30.forwardRef(function PopperArrow2(props, forwardedRef) {
2908
+ const { __scopePopper, ...arrowProps } = props;
2909
+ const contentContext = useContentContext(ARROW_NAME, __scopePopper);
2910
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
2911
+ return (
2912
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
2913
+ // doesn't report size as we'd expect on SVG elements.
2914
+ // it reports their bounding box which is effectively the largest path inside the SVG.
2915
+ /* @__PURE__ */ jsx(
2916
+ "span",
2917
+ {
2918
+ ref: contentContext.onArrowChange,
2919
+ style: {
2920
+ position: "absolute",
2921
+ left: contentContext.arrowX,
2922
+ top: contentContext.arrowY,
2923
+ [baseSide]: 0,
2924
+ transformOrigin: {
2925
+ top: "",
2926
+ right: "0 0",
2927
+ bottom: "center 0",
2928
+ left: "100% 0"
2929
+ }[contentContext.placedSide],
2930
+ transform: {
2931
+ top: "translateY(100%)",
2932
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
2933
+ bottom: `rotate(180deg)`,
2934
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
2935
+ }[contentContext.placedSide],
2936
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
2937
+ },
2938
+ children: /* @__PURE__ */ jsx(
2939
+ Root,
2940
+ {
2941
+ ...arrowProps,
2942
+ ref: forwardedRef,
2943
+ style: {
2944
+ ...arrowProps.style,
2945
+ // ensures the element can be measured correctly (mostly for if SVG)
2946
+ display: "block"
2947
+ }
2948
+ }
2949
+ )
2950
+ }
2951
+ )
2952
+ );
2953
+ });
2954
+ PopperArrow.displayName = ARROW_NAME;
2955
+ function isNotNull(value) {
2956
+ return value !== null;
2957
+ }
2958
+ var transformOrigin = (options) => ({
2959
+ name: "transformOrigin",
2960
+ options,
2961
+ fn(data) {
2962
+ const { placement, rects, middlewareData } = data;
2963
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2964
+ const isArrowHidden = cannotCenterArrow;
2965
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2966
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2967
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2968
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
2969
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
2970
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
2971
+ let x = "";
2972
+ let y = "";
2973
+ if (placedSide === "bottom") {
2974
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2975
+ y = `${-arrowHeight}px`;
2976
+ } else if (placedSide === "top") {
2977
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2978
+ y = `${rects.floating.height + arrowHeight}px`;
2979
+ } else if (placedSide === "right") {
2980
+ x = `${-arrowHeight}px`;
2981
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2982
+ } else if (placedSide === "left") {
2983
+ x = `${rects.floating.width + arrowHeight}px`;
2984
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2985
+ }
2986
+ return { data: { x, y } };
2987
+ }
2988
+ });
2989
+ function getSideAndAlignFromPlacement(placement) {
2990
+ const [side, align = "center"] = placement.split("-");
2991
+ return [side, align];
2992
+ }
2993
+ var Anchor = PopperAnchor;
2994
+ var Content = PopperContent;
2995
+ var Arrow2 = PopperArrow;
2996
+ var PORTAL_NAME = "Portal";
2997
+ var Portal = React30.forwardRef((props, forwardedRef) => {
2998
+ const { container: containerProp, ...portalProps } = props;
2999
+ const [mounted, setMounted] = React30.useState(false);
3000
+ useLayoutEffect2(() => setMounted(true), []);
3001
+ const container = containerProp || mounted && globalThis?.document?.body;
3002
+ return container ? ReactDOM4__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
3003
+ });
3004
+ Portal.displayName = PORTAL_NAME;
3005
+ function usePrevious(value) {
3006
+ const ref = React30.useRef({ value, previous: value });
3007
+ return React30.useMemo(() => {
3008
+ if (ref.current.value !== value) {
3009
+ ref.current.previous = ref.current.value;
3010
+ ref.current.value = value;
3011
+ }
3012
+ return ref.current.previous;
3013
+ }, [value]);
3014
+ }
3015
+ var VISUALLY_HIDDEN_STYLES = Object.freeze({
3016
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
3017
+ position: "absolute",
3018
+ border: 0,
3019
+ width: 1,
3020
+ height: 1,
3021
+ padding: 0,
3022
+ margin: -1,
3023
+ overflow: "hidden",
3024
+ clip: "rect(0, 0, 0, 0)",
3025
+ whiteSpace: "nowrap",
3026
+ wordWrap: "normal"
3027
+ });
3028
+ var NAME2 = "VisuallyHidden";
3029
+ var VisuallyHidden = React30.forwardRef(
3030
+ (props, forwardedRef) => {
3031
+ return /* @__PURE__ */ jsx(
3032
+ Primitive.span,
3033
+ {
3034
+ ...props,
3035
+ ref: forwardedRef,
3036
+ style: { ...VISUALLY_HIDDEN_STYLES, ...props.style }
3037
+ }
3038
+ );
3039
+ }
3040
+ );
3041
+ VisuallyHidden.displayName = NAME2;
3042
+
3043
+ // node_modules/aria-hidden/dist/es2015/index.js
3044
+ var getDefaultParent = function(originalTarget) {
3045
+ if (typeof document === "undefined") {
3046
+ return null;
3047
+ }
3048
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
3049
+ return sampleTarget.ownerDocument.body;
3050
+ };
3051
+ var counterMap = /* @__PURE__ */ new WeakMap();
3052
+ var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
3053
+ var markerMap = {};
3054
+ var lockCount = 0;
3055
+ var unwrapHost = function(node) {
3056
+ return node && (node.host || unwrapHost(node.parentNode));
3057
+ };
3058
+ var correctTargets = function(parent, targets) {
3059
+ return targets.map(function(target) {
3060
+ if (parent.contains(target)) {
3061
+ return target;
3062
+ }
3063
+ var correctedTarget = unwrapHost(target);
3064
+ if (correctedTarget && parent.contains(correctedTarget)) {
3065
+ return correctedTarget;
3066
+ }
3067
+ console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
3068
+ return null;
3069
+ }).filter(function(x) {
3070
+ return Boolean(x);
3071
+ });
3072
+ };
3073
+ var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
3074
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3075
+ if (!markerMap[markerName]) {
3076
+ markerMap[markerName] = /* @__PURE__ */ new WeakMap();
3077
+ }
3078
+ var markerCounter = markerMap[markerName];
3079
+ var hiddenNodes = [];
3080
+ var elementsToKeep = /* @__PURE__ */ new Set();
3081
+ var elementsToStop = new Set(targets);
3082
+ var keep = function(el) {
3083
+ if (!el || elementsToKeep.has(el)) {
3084
+ return;
3085
+ }
3086
+ elementsToKeep.add(el);
3087
+ keep(el.parentNode);
3088
+ };
3089
+ targets.forEach(keep);
3090
+ var deep = function(parent) {
3091
+ if (!parent || elementsToStop.has(parent)) {
3092
+ return;
3093
+ }
3094
+ Array.prototype.forEach.call(parent.children, function(node) {
3095
+ if (elementsToKeep.has(node)) {
3096
+ deep(node);
3097
+ } else {
3098
+ try {
3099
+ var attr = node.getAttribute(controlAttribute);
3100
+ var alreadyHidden = attr !== null && attr !== "false";
3101
+ var counterValue = (counterMap.get(node) || 0) + 1;
3102
+ var markerValue = (markerCounter.get(node) || 0) + 1;
3103
+ counterMap.set(node, counterValue);
3104
+ markerCounter.set(node, markerValue);
3105
+ hiddenNodes.push(node);
3106
+ if (counterValue === 1 && alreadyHidden) {
3107
+ uncontrolledNodes.set(node, true);
3108
+ }
3109
+ if (markerValue === 1) {
3110
+ node.setAttribute(markerName, "true");
3111
+ }
3112
+ if (!alreadyHidden) {
3113
+ node.setAttribute(controlAttribute, "true");
3114
+ }
3115
+ } catch (e) {
3116
+ console.error("aria-hidden: cannot operate on ", node, e);
3117
+ }
3118
+ }
3119
+ });
3120
+ };
3121
+ deep(parentNode);
3122
+ elementsToKeep.clear();
3123
+ lockCount++;
3124
+ return function() {
3125
+ hiddenNodes.forEach(function(node) {
3126
+ var counterValue = counterMap.get(node) - 1;
3127
+ var markerValue = markerCounter.get(node) - 1;
3128
+ counterMap.set(node, counterValue);
3129
+ markerCounter.set(node, markerValue);
3130
+ if (!counterValue) {
3131
+ if (!uncontrolledNodes.has(node)) {
3132
+ node.removeAttribute(controlAttribute);
3133
+ }
3134
+ uncontrolledNodes.delete(node);
3135
+ }
3136
+ if (!markerValue) {
3137
+ node.removeAttribute(markerName);
3138
+ }
3139
+ });
3140
+ lockCount--;
3141
+ if (!lockCount) {
3142
+ counterMap = /* @__PURE__ */ new WeakMap();
3143
+ counterMap = /* @__PURE__ */ new WeakMap();
3144
+ uncontrolledNodes = /* @__PURE__ */ new WeakMap();
3145
+ markerMap = {};
3146
+ }
3147
+ };
3148
+ };
3149
+ var hideOthers = function(originalTarget, parentNode, markerName) {
3150
+ if (markerName === void 0) {
3151
+ markerName = "data-aria-hidden";
3152
+ }
3153
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3154
+ var activeParentNode = getDefaultParent(originalTarget);
3155
+ if (!activeParentNode) {
3156
+ return function() {
3157
+ return null;
3158
+ };
3159
+ }
3160
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
3161
+ return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
3162
+ };
3163
+
3164
+ // node_modules/tslib/tslib.es6.mjs
3165
+ var __assign = function() {
3166
+ __assign = Object.assign || function __assign2(t) {
3167
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3168
+ s = arguments[i];
3169
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3170
+ }
3171
+ return t;
3172
+ };
3173
+ return __assign.apply(this, arguments);
3174
+ };
3175
+ function __rest(s, e) {
3176
+ var t = {};
3177
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3178
+ t[p] = s[p];
3179
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3180
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3181
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3182
+ t[p[i]] = s[p[i]];
3183
+ }
3184
+ return t;
3185
+ }
3186
+ function __spreadArray(to, from, pack) {
3187
+ for (var i = 0, l = from.length, ar; i < l; i++) {
3188
+ if (ar || !(i in from)) {
3189
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3190
+ ar[i] = from[i];
3191
+ }
3192
+ }
3193
+ return to.concat(ar || Array.prototype.slice.call(from));
3194
+ }
3195
+
3196
+ // node_modules/react-remove-scroll-bar/dist/es2015/constants.js
3197
+ var zeroRightClassName = "right-scroll-bar-position";
3198
+ var fullWidthClassName = "width-before-scroll-bar";
3199
+ var noScrollbarsClassName = "with-scroll-bars-hidden";
3200
+ var removedBarSizeVariable = "--removed-body-scroll-bar-size";
3201
+
3202
+ // node_modules/use-callback-ref/dist/es2015/assignRef.js
3203
+ function assignRef(ref, value) {
3204
+ if (typeof ref === "function") {
3205
+ ref(value);
3206
+ } else if (ref) {
3207
+ ref.current = value;
3208
+ }
3209
+ return ref;
3210
+ }
3211
+ function useCallbackRef2(initialValue, callback) {
3212
+ var ref = useState(function() {
3213
+ return {
3214
+ // value
3215
+ value: initialValue,
3216
+ // last callback
3217
+ callback,
3218
+ // "memoized" public interface
3219
+ facade: {
3220
+ get current() {
3221
+ return ref.value;
3222
+ },
3223
+ set current(value) {
3224
+ var last = ref.value;
3225
+ if (last !== value) {
3226
+ ref.value = value;
3227
+ ref.callback(value, last);
3228
+ }
3229
+ }
3230
+ }
3231
+ };
3232
+ })[0];
3233
+ ref.callback = callback;
3234
+ return ref.facade;
3235
+ }
3236
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React30.useLayoutEffect : React30.useEffect;
3237
+ var currentValues = /* @__PURE__ */ new WeakMap();
3238
+ function useMergeRefs(refs, defaultValue) {
3239
+ var callbackRef = useCallbackRef2(null, function(newValue) {
3240
+ return refs.forEach(function(ref) {
3241
+ return assignRef(ref, newValue);
3242
+ });
3243
+ });
3244
+ useIsomorphicLayoutEffect(function() {
3245
+ var oldValue = currentValues.get(callbackRef);
3246
+ if (oldValue) {
3247
+ var prevRefs_1 = new Set(oldValue);
3248
+ var nextRefs_1 = new Set(refs);
3249
+ var current_1 = callbackRef.current;
3250
+ prevRefs_1.forEach(function(ref) {
3251
+ if (!nextRefs_1.has(ref)) {
3252
+ assignRef(ref, null);
3253
+ }
3254
+ });
3255
+ nextRefs_1.forEach(function(ref) {
3256
+ if (!prevRefs_1.has(ref)) {
3257
+ assignRef(ref, current_1);
3258
+ }
3259
+ });
3260
+ }
3261
+ currentValues.set(callbackRef, refs);
3262
+ }, [refs]);
3263
+ return callbackRef;
3264
+ }
3265
+
3266
+ // node_modules/use-sidecar/dist/es2015/medium.js
3267
+ function ItoI(a) {
3268
+ return a;
3269
+ }
3270
+ function innerCreateMedium(defaults, middleware) {
3271
+ if (middleware === void 0) {
3272
+ middleware = ItoI;
3273
+ }
3274
+ var buffer = [];
3275
+ var assigned = false;
3276
+ var medium = {
3277
+ read: function() {
3278
+ if (assigned) {
3279
+ throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
3280
+ }
3281
+ if (buffer.length) {
3282
+ return buffer[buffer.length - 1];
3283
+ }
3284
+ return defaults;
3285
+ },
3286
+ useMedium: function(data) {
3287
+ var item = middleware(data, assigned);
3288
+ buffer.push(item);
3289
+ return function() {
3290
+ buffer = buffer.filter(function(x) {
3291
+ return x !== item;
3292
+ });
3293
+ };
3294
+ },
3295
+ assignSyncMedium: function(cb) {
3296
+ assigned = true;
3297
+ while (buffer.length) {
3298
+ var cbs = buffer;
3299
+ buffer = [];
3300
+ cbs.forEach(cb);
3301
+ }
3302
+ buffer = {
3303
+ push: function(x) {
3304
+ return cb(x);
3305
+ },
3306
+ filter: function() {
3307
+ return buffer;
3308
+ }
3309
+ };
3310
+ },
3311
+ assignMedium: function(cb) {
3312
+ assigned = true;
3313
+ var pendingQueue = [];
3314
+ if (buffer.length) {
3315
+ var cbs = buffer;
3316
+ buffer = [];
3317
+ cbs.forEach(cb);
3318
+ pendingQueue = buffer;
3319
+ }
3320
+ var executeQueue = function() {
3321
+ var cbs2 = pendingQueue;
3322
+ pendingQueue = [];
3323
+ cbs2.forEach(cb);
3324
+ };
3325
+ var cycle = function() {
3326
+ return Promise.resolve().then(executeQueue);
3327
+ };
3328
+ cycle();
3329
+ buffer = {
3330
+ push: function(x) {
3331
+ pendingQueue.push(x);
3332
+ cycle();
3333
+ },
3334
+ filter: function(filter) {
3335
+ pendingQueue = pendingQueue.filter(filter);
3336
+ return buffer;
3337
+ }
3338
+ };
3339
+ }
3340
+ };
3341
+ return medium;
3342
+ }
3343
+ function createSidecarMedium(options) {
3344
+ if (options === void 0) {
3345
+ options = {};
3346
+ }
3347
+ var medium = innerCreateMedium(null);
3348
+ medium.options = __assign({ async: true, ssr: false }, options);
3349
+ return medium;
3350
+ }
3351
+ var SideCar = function(_a) {
3352
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
3353
+ if (!sideCar) {
3354
+ throw new Error("Sidecar: please provide `sideCar` property to import the right car");
3355
+ }
3356
+ var Target = sideCar.read();
3357
+ if (!Target) {
3358
+ throw new Error("Sidecar medium not found");
3359
+ }
3360
+ return React30.createElement(Target, __assign({}, rest));
3361
+ };
3362
+ SideCar.isSideCarExport = true;
3363
+ function exportSidecar(medium, exported) {
3364
+ medium.useMedium(exported);
3365
+ return SideCar;
3366
+ }
3367
+
3368
+ // node_modules/react-remove-scroll/dist/es2015/medium.js
3369
+ var effectCar = createSidecarMedium();
3370
+
3371
+ // node_modules/react-remove-scroll/dist/es2015/UI.js
3372
+ var nothing = function() {
3373
+ return;
3374
+ };
3375
+ var RemoveScroll = React30.forwardRef(function(props, parentRef) {
3376
+ var ref = React30.useRef(null);
3377
+ var _a = React30.useState({
3378
+ onScrollCapture: nothing,
3379
+ onWheelCapture: nothing,
3380
+ onTouchMoveCapture: nothing
3381
+ }), callbacks = _a[0], setCallbacks = _a[1];
3382
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
3383
+ var SideCar2 = sideCar;
3384
+ var containerRef = useMergeRefs([ref, parentRef]);
3385
+ var containerProps = __assign(__assign({}, rest), callbacks);
3386
+ return React30.createElement(
3387
+ React30.Fragment,
3388
+ null,
3389
+ enabled && React30.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
3390
+ forwardProps ? React30.cloneElement(React30.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React30.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
3391
+ );
3392
+ });
3393
+ RemoveScroll.defaultProps = {
3394
+ enabled: true,
3395
+ removeScrollBar: true,
3396
+ inert: false
3397
+ };
3398
+ RemoveScroll.classNames = {
3399
+ fullWidth: fullWidthClassName,
3400
+ zeroRight: zeroRightClassName
3401
+ };
3402
+ var getNonce = function() {
3403
+ if (typeof __webpack_nonce__ !== "undefined") {
3404
+ return __webpack_nonce__;
3405
+ }
3406
+ return void 0;
3407
+ };
3408
+
3409
+ // node_modules/react-style-singleton/dist/es2015/singleton.js
3410
+ function makeStyleTag() {
3411
+ if (!document)
3412
+ return null;
3413
+ var tag = document.createElement("style");
3414
+ tag.type = "text/css";
3415
+ var nonce = getNonce();
3416
+ if (nonce) {
3417
+ tag.setAttribute("nonce", nonce);
3418
+ }
3419
+ return tag;
3420
+ }
3421
+ function injectStyles(tag, css) {
3422
+ if (tag.styleSheet) {
3423
+ tag.styleSheet.cssText = css;
3424
+ } else {
3425
+ tag.appendChild(document.createTextNode(css));
3426
+ }
3427
+ }
3428
+ function insertStyleTag(tag) {
3429
+ var head = document.head || document.getElementsByTagName("head")[0];
3430
+ head.appendChild(tag);
3431
+ }
3432
+ var stylesheetSingleton = function() {
3433
+ var counter = 0;
3434
+ var stylesheet = null;
3435
+ return {
3436
+ add: function(style) {
3437
+ if (counter == 0) {
3438
+ if (stylesheet = makeStyleTag()) {
3439
+ injectStyles(stylesheet, style);
3440
+ insertStyleTag(stylesheet);
3441
+ }
3442
+ }
3443
+ counter++;
3444
+ },
3445
+ remove: function() {
3446
+ counter--;
3447
+ if (!counter && stylesheet) {
3448
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
3449
+ stylesheet = null;
3450
+ }
3451
+ }
3452
+ };
3453
+ };
3454
+
3455
+ // node_modules/react-style-singleton/dist/es2015/hook.js
3456
+ var styleHookSingleton = function() {
3457
+ var sheet = stylesheetSingleton();
3458
+ return function(styles, isDynamic) {
3459
+ React30.useEffect(function() {
3460
+ sheet.add(styles);
3461
+ return function() {
3462
+ sheet.remove();
3463
+ };
3464
+ }, [styles && isDynamic]);
3465
+ };
3466
+ };
3467
+
3468
+ // node_modules/react-style-singleton/dist/es2015/component.js
3469
+ var styleSingleton = function() {
3470
+ var useStyle = styleHookSingleton();
3471
+ var Sheet = function(_a) {
3472
+ var styles = _a.styles, dynamic = _a.dynamic;
3473
+ useStyle(styles, dynamic);
3474
+ return null;
3475
+ };
3476
+ return Sheet;
3477
+ };
3478
+
3479
+ // node_modules/react-remove-scroll-bar/dist/es2015/utils.js
3480
+ var zeroGap = {
3481
+ left: 0,
3482
+ top: 0,
3483
+ right: 0,
3484
+ gap: 0
3485
+ };
3486
+ var parse = function(x) {
3487
+ return parseInt(x || "", 10) || 0;
3488
+ };
3489
+ var getOffset = function(gapMode) {
3490
+ var cs = window.getComputedStyle(document.body);
3491
+ var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
3492
+ var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
3493
+ var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
3494
+ return [parse(left), parse(top), parse(right)];
3495
+ };
3496
+ var getGapWidth = function(gapMode) {
3497
+ if (gapMode === void 0) {
3498
+ gapMode = "margin";
3499
+ }
3500
+ if (typeof window === "undefined") {
3501
+ return zeroGap;
3502
+ }
3503
+ var offsets = getOffset(gapMode);
3504
+ var documentWidth = document.documentElement.clientWidth;
3505
+ var windowWidth = window.innerWidth;
3506
+ return {
3507
+ left: offsets[0],
3508
+ top: offsets[1],
3509
+ right: offsets[2],
3510
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
3511
+ };
3512
+ };
3513
+
3514
+ // node_modules/react-remove-scroll-bar/dist/es2015/component.js
3515
+ var Style = styleSingleton();
3516
+ var lockAttribute = "data-scroll-locked";
3517
+ var getStyles = function(_a, allowRelative, gapMode, important) {
3518
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
3519
+ if (gapMode === void 0) {
3520
+ gapMode = "margin";
3521
+ }
3522
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
3523
+ allowRelative && "position: relative ".concat(important, ";"),
3524
+ gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
3525
+ gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
3526
+ ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
3527
+ };
3528
+ var getCurrentUseCounter = function() {
3529
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
3530
+ return isFinite(counter) ? counter : 0;
3531
+ };
3532
+ var useLockAttribute = function() {
3533
+ React30.useEffect(function() {
3534
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
3535
+ return function() {
3536
+ var newCounter = getCurrentUseCounter() - 1;
3537
+ if (newCounter <= 0) {
3538
+ document.body.removeAttribute(lockAttribute);
3539
+ } else {
3540
+ document.body.setAttribute(lockAttribute, newCounter.toString());
3541
+ }
3542
+ };
3543
+ }, []);
3544
+ };
3545
+ var RemoveScrollBar = function(_a) {
3546
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
3547
+ useLockAttribute();
3548
+ var gap = React30.useMemo(function() {
3549
+ return getGapWidth(gapMode);
3550
+ }, [gapMode]);
3551
+ return React30.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
3552
+ };
3553
+
3554
+ // node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
3555
+ var passiveSupported = false;
3556
+ if (typeof window !== "undefined") {
3557
+ try {
3558
+ options = Object.defineProperty({}, "passive", {
3559
+ get: function() {
3560
+ passiveSupported = true;
3561
+ return true;
3562
+ }
3563
+ });
3564
+ window.addEventListener("test", options, options);
3565
+ window.removeEventListener("test", options, options);
3566
+ } catch (err) {
3567
+ passiveSupported = false;
3568
+ }
3569
+ }
3570
+ var options;
3571
+ var nonPassive = passiveSupported ? { passive: false } : false;
3572
+
3573
+ // node_modules/react-remove-scroll/dist/es2015/handleScroll.js
3574
+ var alwaysContainsScroll = function(node) {
3575
+ return node.tagName === "TEXTAREA";
3576
+ };
3577
+ var elementCanBeScrolled = function(node, overflow) {
3578
+ if (!(node instanceof Element)) {
3579
+ return false;
3580
+ }
3581
+ var styles = window.getComputedStyle(node);
3582
+ return (
3583
+ // not-not-scrollable
3584
+ styles[overflow] !== "hidden" && // contains scroll inside self
3585
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
3586
+ );
3587
+ };
3588
+ var elementCouldBeVScrolled = function(node) {
3589
+ return elementCanBeScrolled(node, "overflowY");
3590
+ };
3591
+ var elementCouldBeHScrolled = function(node) {
3592
+ return elementCanBeScrolled(node, "overflowX");
3593
+ };
3594
+ var locationCouldBeScrolled = function(axis, node) {
3595
+ var ownerDocument = node.ownerDocument;
3596
+ var current = node;
3597
+ do {
3598
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
3599
+ current = current.host;
3600
+ }
3601
+ var isScrollable = elementCouldBeScrolled(axis, current);
3602
+ if (isScrollable) {
3603
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
3604
+ if (scrollHeight > clientHeight) {
3605
+ return true;
3606
+ }
3607
+ }
3608
+ current = current.parentNode;
3609
+ } while (current && current !== ownerDocument.body);
3610
+ return false;
3611
+ };
3612
+ var getVScrollVariables = function(_a) {
3613
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
3614
+ return [
3615
+ scrollTop,
3616
+ scrollHeight,
3617
+ clientHeight
3618
+ ];
3619
+ };
3620
+ var getHScrollVariables = function(_a) {
3621
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
3622
+ return [
3623
+ scrollLeft,
3624
+ scrollWidth,
3625
+ clientWidth
3626
+ ];
3627
+ };
3628
+ var elementCouldBeScrolled = function(axis, node) {
3629
+ return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
3630
+ };
3631
+ var getScrollVariables = function(axis, node) {
3632
+ return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
3633
+ };
3634
+ var getDirectionFactor = function(axis, direction) {
3635
+ return axis === "h" && direction === "rtl" ? -1 : 1;
3636
+ };
3637
+ var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
3638
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
3639
+ var delta = directionFactor * sourceDelta;
3640
+ var target = event.target;
3641
+ var targetInLock = endTarget.contains(target);
3642
+ var shouldCancelScroll = false;
3643
+ var isDeltaPositive = delta > 0;
3644
+ var availableScroll = 0;
3645
+ var availableScrollTop = 0;
3646
+ do {
3647
+ if (!target) {
3648
+ break;
3649
+ }
3650
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
3651
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
3652
+ if (position || elementScroll) {
3653
+ if (elementCouldBeScrolled(axis, target)) {
3654
+ availableScroll += elementScroll;
3655
+ availableScrollTop += position;
3656
+ }
3657
+ }
3658
+ var parent_1 = target.parentNode;
3659
+ target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
3660
+ } while (
3661
+ // portaled content
3662
+ !targetInLock && target !== document.body || // self content
3663
+ targetInLock && (endTarget.contains(target) || endTarget === target)
3664
+ );
3665
+ if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
3666
+ shouldCancelScroll = true;
3667
+ } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
3668
+ shouldCancelScroll = true;
3669
+ }
3670
+ return shouldCancelScroll;
3671
+ };
3672
+
3673
+ // node_modules/react-remove-scroll/dist/es2015/SideEffect.js
3674
+ var getTouchXY = function(event) {
3675
+ return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
3676
+ };
3677
+ var getDeltaXY = function(event) {
3678
+ return [event.deltaX, event.deltaY];
3679
+ };
3680
+ var extractRef = function(ref) {
3681
+ return ref && "current" in ref ? ref.current : ref;
3682
+ };
3683
+ var deltaCompare = function(x, y) {
3684
+ return x[0] === y[0] && x[1] === y[1];
3685
+ };
3686
+ var generateStyle = function(id) {
3687
+ return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
3688
+ };
3689
+ var idCounter = 0;
3690
+ var lockStack = [];
3691
+ function RemoveScrollSideCar(props) {
3692
+ var shouldPreventQueue = React30.useRef([]);
3693
+ var touchStartRef = React30.useRef([0, 0]);
3694
+ var activeAxis = React30.useRef();
3695
+ var id = React30.useState(idCounter++)[0];
3696
+ var Style2 = React30.useState(styleSingleton)[0];
3697
+ var lastProps = React30.useRef(props);
3698
+ React30.useEffect(function() {
3699
+ lastProps.current = props;
3700
+ }, [props]);
3701
+ React30.useEffect(function() {
3702
+ if (props.inert) {
3703
+ document.body.classList.add("block-interactivity-".concat(id));
3704
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef)).filter(Boolean);
3705
+ allow_1.forEach(function(el) {
3706
+ return el.classList.add("allow-interactivity-".concat(id));
3707
+ });
3708
+ return function() {
3709
+ document.body.classList.remove("block-interactivity-".concat(id));
3710
+ allow_1.forEach(function(el) {
3711
+ return el.classList.remove("allow-interactivity-".concat(id));
3712
+ });
3713
+ };
3714
+ }
3715
+ return;
3716
+ }, [props.inert, props.lockRef.current, props.shards]);
3717
+ var shouldCancelEvent = React30.useCallback(function(event, parent) {
3718
+ if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
3719
+ return !lastProps.current.allowPinchZoom;
3720
+ }
3721
+ var touch = getTouchXY(event);
3722
+ var touchStart = touchStartRef.current;
3723
+ var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
3724
+ var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
3725
+ var currentAxis;
3726
+ var target = event.target;
3727
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
3728
+ if ("touches" in event && moveDirection === "h" && target.type === "range") {
3729
+ return false;
3730
+ }
3731
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
3732
+ if (!canBeScrolledInMainDirection) {
3733
+ return true;
3734
+ }
3735
+ if (canBeScrolledInMainDirection) {
3736
+ currentAxis = moveDirection;
3737
+ } else {
3738
+ currentAxis = moveDirection === "v" ? "h" : "v";
3739
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
3740
+ }
3741
+ if (!canBeScrolledInMainDirection) {
3742
+ return false;
3743
+ }
3744
+ if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
3745
+ activeAxis.current = currentAxis;
3746
+ }
3747
+ if (!currentAxis) {
3748
+ return true;
3749
+ }
3750
+ var cancelingAxis = activeAxis.current || currentAxis;
3751
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
3752
+ }, []);
3753
+ var shouldPrevent = React30.useCallback(function(_event) {
3754
+ var event = _event;
3755
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
3756
+ return;
3757
+ }
3758
+ var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
3759
+ var sourceEvent = shouldPreventQueue.current.filter(function(e) {
3760
+ return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
3761
+ })[0];
3762
+ if (sourceEvent && sourceEvent.should) {
3763
+ if (event.cancelable) {
3764
+ event.preventDefault();
3765
+ }
3766
+ return;
3767
+ }
3768
+ if (!sourceEvent) {
3769
+ var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
3770
+ return node.contains(event.target);
3771
+ });
3772
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
3773
+ if (shouldStop) {
3774
+ if (event.cancelable) {
3775
+ event.preventDefault();
3776
+ }
3777
+ }
3778
+ }
3779
+ }, []);
3780
+ var shouldCancel = React30.useCallback(function(name, delta, target, should) {
3781
+ var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
3782
+ shouldPreventQueue.current.push(event);
3783
+ setTimeout(function() {
3784
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
3785
+ return e !== event;
3786
+ });
3787
+ }, 1);
3788
+ }, []);
3789
+ var scrollTouchStart = React30.useCallback(function(event) {
3790
+ touchStartRef.current = getTouchXY(event);
3791
+ activeAxis.current = void 0;
3792
+ }, []);
3793
+ var scrollWheel = React30.useCallback(function(event) {
3794
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
3795
+ }, []);
3796
+ var scrollTouchMove = React30.useCallback(function(event) {
3797
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
3798
+ }, []);
3799
+ React30.useEffect(function() {
3800
+ lockStack.push(Style2);
3801
+ props.setCallbacks({
3802
+ onScrollCapture: scrollWheel,
3803
+ onWheelCapture: scrollWheel,
3804
+ onTouchMoveCapture: scrollTouchMove
3805
+ });
3806
+ document.addEventListener("wheel", shouldPrevent, nonPassive);
3807
+ document.addEventListener("touchmove", shouldPrevent, nonPassive);
3808
+ document.addEventListener("touchstart", scrollTouchStart, nonPassive);
3809
+ return function() {
3810
+ lockStack = lockStack.filter(function(inst) {
3811
+ return inst !== Style2;
3812
+ });
3813
+ document.removeEventListener("wheel", shouldPrevent, nonPassive);
3814
+ document.removeEventListener("touchmove", shouldPrevent, nonPassive);
3815
+ document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
3816
+ };
3817
+ }, []);
3818
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
3819
+ return React30.createElement(
3820
+ React30.Fragment,
3821
+ null,
3822
+ inert ? React30.createElement(Style2, { styles: generateStyle(id) }) : null,
3823
+ removeScrollBar ? React30.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
3824
+ );
3825
+ }
3826
+ function getOutermostShadowParent(node) {
3827
+ var shadowParent = null;
3828
+ while (node !== null) {
3829
+ if (node instanceof ShadowRoot) {
3830
+ shadowParent = node.host;
3831
+ node = node.host;
3832
+ }
3833
+ node = node.parentNode;
3834
+ }
3835
+ return shadowParent;
3836
+ }
3837
+
3838
+ // node_modules/react-remove-scroll/dist/es2015/sidecar.js
3839
+ var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
3840
+
3841
+ // node_modules/react-remove-scroll/dist/es2015/Combination.js
3842
+ var ReactRemoveScroll = React30.forwardRef(function(props, ref) {
3843
+ return React30.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default }));
3844
+ });
3845
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
3846
+ var Combination_default = ReactRemoveScroll;
3847
+ var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
3848
+ var SELECTION_KEYS = [" ", "Enter"];
3849
+ var SELECT_NAME = "Select";
3850
+ var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
3851
+ var [createSelectContext] = createContextScope(SELECT_NAME, [
3852
+ createCollectionScope,
3853
+ createPopperScope
3854
+ ]);
3855
+ var usePopperScope = createPopperScope();
3856
+ var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
3857
+ var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
3858
+ var TRIGGER_NAME = "SelectTrigger";
3859
+ var SelectTrigger = React30.forwardRef(
3860
+ (props, forwardedRef) => {
3861
+ const { __scopeSelect, disabled = false, ...triggerProps } = props;
3862
+ const popperScope = usePopperScope(__scopeSelect);
3863
+ const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
3864
+ const isDisabled = context.disabled || disabled;
3865
+ const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
3866
+ const getItems = useCollection(__scopeSelect);
3867
+ const pointerTypeRef = React30.useRef("touch");
3868
+ const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
3869
+ const enabledItems = getItems().filter((item) => !item.disabled);
3870
+ const currentItem = enabledItems.find((item) => item.value === context.value);
3871
+ const nextItem = findNextItem(enabledItems, search, currentItem);
3872
+ if (nextItem !== void 0) {
3873
+ context.onValueChange(nextItem.value);
3874
+ }
3875
+ });
3876
+ const handleOpen = (pointerEvent) => {
3877
+ if (!isDisabled) {
3878
+ context.onOpenChange(true);
3879
+ resetTypeahead();
3880
+ }
3881
+ if (pointerEvent) {
3882
+ context.triggerPointerDownPosRef.current = {
3883
+ x: Math.round(pointerEvent.pageX),
3884
+ y: Math.round(pointerEvent.pageY)
3885
+ };
3886
+ }
3887
+ };
3888
+ return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
3889
+ Primitive.button,
3890
+ {
3891
+ type: "button",
3892
+ role: "combobox",
3893
+ "aria-controls": context.contentId,
3894
+ "aria-expanded": context.open,
3895
+ "aria-required": context.required,
3896
+ "aria-autocomplete": "none",
3897
+ dir: context.dir,
3898
+ "data-state": context.open ? "open" : "closed",
3899
+ disabled: isDisabled,
3900
+ "data-disabled": isDisabled ? "" : void 0,
3901
+ "data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
3902
+ ...triggerProps,
3903
+ ref: composedRefs,
3904
+ onClick: composeEventHandlers(triggerProps.onClick, (event) => {
3905
+ event.currentTarget.focus();
3906
+ if (pointerTypeRef.current !== "mouse") {
3907
+ handleOpen(event);
3908
+ }
3909
+ }),
3910
+ onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
3911
+ pointerTypeRef.current = event.pointerType;
3912
+ const target = event.target;
3913
+ if (target.hasPointerCapture(event.pointerId)) {
3914
+ target.releasePointerCapture(event.pointerId);
3915
+ }
3916
+ if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
3917
+ handleOpen(event);
3918
+ event.preventDefault();
3919
+ }
3920
+ }),
3921
+ onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
3922
+ const isTypingAhead = searchRef.current !== "";
3923
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
3924
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
3925
+ if (isTypingAhead && event.key === " ") return;
3926
+ if (OPEN_KEYS.includes(event.key)) {
3927
+ handleOpen();
3928
+ event.preventDefault();
3929
+ }
3930
+ })
3931
+ }
3932
+ ) });
3933
+ }
3934
+ );
3935
+ SelectTrigger.displayName = TRIGGER_NAME;
3936
+ var VALUE_NAME = "SelectValue";
3937
+ var SelectValue = React30.forwardRef(
3938
+ (props, forwardedRef) => {
3939
+ const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
3940
+ const context = useSelectContext(VALUE_NAME, __scopeSelect);
3941
+ const { onValueNodeHasChildrenChange } = context;
3942
+ const hasChildren = children !== void 0;
3943
+ const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
3944
+ useLayoutEffect2(() => {
3945
+ onValueNodeHasChildrenChange(hasChildren);
3946
+ }, [onValueNodeHasChildrenChange, hasChildren]);
3947
+ return /* @__PURE__ */ jsx(
3948
+ Primitive.span,
3949
+ {
3950
+ ...valueProps,
3951
+ ref: composedRefs,
3952
+ style: { pointerEvents: "none" },
3953
+ children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsx(Fragment, { children: placeholder }) : children
3954
+ }
3955
+ );
3956
+ }
3957
+ );
3958
+ SelectValue.displayName = VALUE_NAME;
3959
+ var ICON_NAME = "SelectIcon";
3960
+ var SelectIcon = React30.forwardRef(
3961
+ (props, forwardedRef) => {
3962
+ const { __scopeSelect, children, ...iconProps } = props;
3963
+ return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
3964
+ }
3965
+ );
3966
+ SelectIcon.displayName = ICON_NAME;
3967
+ var CONTENT_NAME2 = "SelectContent";
3968
+ var SelectContent2 = React30.forwardRef(
3969
+ (props, forwardedRef) => {
3970
+ const context = useSelectContext(CONTENT_NAME2, props.__scopeSelect);
3971
+ const [fragment, setFragment] = React30.useState();
3972
+ useLayoutEffect2(() => {
3973
+ setFragment(new DocumentFragment());
3974
+ }, []);
3975
+ if (!context.open) {
3976
+ const frag = fragment;
3977
+ return frag ? ReactDOM4.createPortal(
3978
+ /* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
3979
+ frag
3980
+ ) : null;
3981
+ }
3982
+ return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
3983
+ }
3984
+ );
3985
+ SelectContent2.displayName = CONTENT_NAME2;
3986
+ var CONTENT_MARGIN = 10;
3987
+ var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME2);
3988
+ var CONTENT_IMPL_NAME = "SelectContentImpl";
3989
+ var Slot = createSlot("SelectContent.RemoveScroll");
3990
+ var SelectContentImpl = React30.forwardRef(
3991
+ (props, forwardedRef) => {
3992
+ const {
3993
+ __scopeSelect,
3994
+ position = "item-aligned",
3995
+ onCloseAutoFocus,
3996
+ onEscapeKeyDown,
3997
+ onPointerDownOutside,
3998
+ //
3999
+ // PopperContent props
4000
+ side,
4001
+ sideOffset,
4002
+ align,
4003
+ alignOffset,
4004
+ arrowPadding,
4005
+ collisionBoundary,
4006
+ collisionPadding,
4007
+ sticky,
4008
+ hideWhenDetached,
4009
+ avoidCollisions,
4010
+ //
4011
+ ...contentProps
4012
+ } = props;
4013
+ const context = useSelectContext(CONTENT_NAME2, __scopeSelect);
4014
+ const [content, setContent] = React30.useState(null);
4015
+ const [viewport, setViewport] = React30.useState(null);
4016
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
4017
+ const [selectedItem, setSelectedItem] = React30.useState(null);
4018
+ const [selectedItemText, setSelectedItemText] = React30.useState(
4019
+ null
4020
+ );
4021
+ const getItems = useCollection(__scopeSelect);
4022
+ const [isPositioned, setIsPositioned] = React30.useState(false);
4023
+ const firstValidItemFoundRef = React30.useRef(false);
4024
+ React30.useEffect(() => {
4025
+ if (content) return hideOthers(content);
4026
+ }, [content]);
4027
+ useFocusGuards();
4028
+ const focusFirst2 = React30.useCallback(
4029
+ (candidates) => {
4030
+ const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
4031
+ const [lastItem] = restItems.slice(-1);
4032
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
4033
+ for (const candidate of candidates) {
4034
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
4035
+ candidate?.scrollIntoView({ block: "nearest" });
4036
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
4037
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
4038
+ candidate?.focus();
4039
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
4040
+ }
4041
+ },
4042
+ [getItems, viewport]
4043
+ );
4044
+ const focusSelectedItem = React30.useCallback(
4045
+ () => focusFirst2([selectedItem, content]),
4046
+ [focusFirst2, selectedItem, content]
4047
+ );
4048
+ React30.useEffect(() => {
4049
+ if (isPositioned) {
4050
+ focusSelectedItem();
4051
+ }
4052
+ }, [isPositioned, focusSelectedItem]);
4053
+ const { onOpenChange, triggerPointerDownPosRef } = context;
4054
+ React30.useEffect(() => {
4055
+ if (content) {
4056
+ let pointerMoveDelta = { x: 0, y: 0 };
4057
+ const handlePointerMove = (event) => {
4058
+ pointerMoveDelta = {
4059
+ x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
4060
+ y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
4061
+ };
4062
+ };
4063
+ const handlePointerUp = (event) => {
4064
+ if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
4065
+ event.preventDefault();
4066
+ } else {
4067
+ if (!content.contains(event.target)) {
4068
+ onOpenChange(false);
4069
+ }
4070
+ }
4071
+ document.removeEventListener("pointermove", handlePointerMove);
4072
+ triggerPointerDownPosRef.current = null;
4073
+ };
4074
+ if (triggerPointerDownPosRef.current !== null) {
4075
+ document.addEventListener("pointermove", handlePointerMove);
4076
+ document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
4077
+ }
4078
+ return () => {
4079
+ document.removeEventListener("pointermove", handlePointerMove);
4080
+ document.removeEventListener("pointerup", handlePointerUp, { capture: true });
4081
+ };
4082
+ }
4083
+ }, [content, onOpenChange, triggerPointerDownPosRef]);
4084
+ React30.useEffect(() => {
4085
+ const close = () => onOpenChange(false);
4086
+ window.addEventListener("blur", close);
4087
+ window.addEventListener("resize", close);
4088
+ return () => {
4089
+ window.removeEventListener("blur", close);
4090
+ window.removeEventListener("resize", close);
4091
+ };
4092
+ }, [onOpenChange]);
4093
+ const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
4094
+ const enabledItems = getItems().filter((item) => !item.disabled);
4095
+ const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
4096
+ const nextItem = findNextItem(enabledItems, search, currentItem);
4097
+ if (nextItem) {
4098
+ setTimeout(() => nextItem.ref.current.focus());
4099
+ }
4100
+ });
4101
+ const itemRefCallback = React30.useCallback(
4102
+ (node, value, disabled) => {
4103
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
4104
+ const isSelectedItem = context.value !== void 0 && context.value === value;
4105
+ if (isSelectedItem || isFirstValidItem) {
4106
+ setSelectedItem(node);
4107
+ if (isFirstValidItem) firstValidItemFoundRef.current = true;
4108
+ }
4109
+ },
4110
+ [context.value]
4111
+ );
4112
+ const handleItemLeave = React30.useCallback(() => content?.focus(), [content]);
4113
+ const itemTextRefCallback = React30.useCallback(
4114
+ (node, value, disabled) => {
4115
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
4116
+ const isSelectedItem = context.value !== void 0 && context.value === value;
4117
+ if (isSelectedItem || isFirstValidItem) {
4118
+ setSelectedItemText(node);
4119
+ }
4120
+ },
4121
+ [context.value]
4122
+ );
4123
+ const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
4124
+ const popperContentProps = SelectPosition === SelectPopperPosition ? {
4125
+ side,
4126
+ sideOffset,
4127
+ align,
4128
+ alignOffset,
4129
+ arrowPadding,
4130
+ collisionBoundary,
4131
+ collisionPadding,
4132
+ sticky,
4133
+ hideWhenDetached,
4134
+ avoidCollisions
4135
+ } : {};
4136
+ return /* @__PURE__ */ jsx(
4137
+ SelectContentProvider,
4138
+ {
4139
+ scope: __scopeSelect,
4140
+ content,
4141
+ viewport,
4142
+ onViewportChange: setViewport,
4143
+ itemRefCallback,
4144
+ selectedItem,
4145
+ onItemLeave: handleItemLeave,
4146
+ itemTextRefCallback,
4147
+ focusSelectedItem,
4148
+ selectedItemText,
4149
+ position,
4150
+ isPositioned,
4151
+ searchRef,
4152
+ children: /* @__PURE__ */ jsx(Combination_default, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
4153
+ FocusScope,
4154
+ {
4155
+ asChild: true,
4156
+ trapped: context.open,
4157
+ onMountAutoFocus: (event) => {
4158
+ event.preventDefault();
4159
+ },
4160
+ onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
4161
+ context.trigger?.focus({ preventScroll: true });
4162
+ event.preventDefault();
4163
+ }),
4164
+ children: /* @__PURE__ */ jsx(
4165
+ DismissableLayer,
4166
+ {
4167
+ asChild: true,
4168
+ disableOutsidePointerEvents: true,
4169
+ onEscapeKeyDown,
4170
+ onPointerDownOutside,
4171
+ onFocusOutside: (event) => event.preventDefault(),
4172
+ onDismiss: () => context.onOpenChange(false),
4173
+ children: /* @__PURE__ */ jsx(
4174
+ SelectPosition,
4175
+ {
4176
+ role: "listbox",
4177
+ id: context.contentId,
4178
+ "data-state": context.open ? "open" : "closed",
4179
+ dir: context.dir,
4180
+ onContextMenu: (event) => event.preventDefault(),
4181
+ ...contentProps,
4182
+ ...popperContentProps,
4183
+ onPlaced: () => setIsPositioned(true),
4184
+ ref: composedRefs,
4185
+ style: {
4186
+ // flex layout so we can place the scroll buttons properly
4187
+ display: "flex",
4188
+ flexDirection: "column",
4189
+ // reset the outline by default as the content MAY get focused
4190
+ outline: "none",
4191
+ ...contentProps.style
4192
+ },
4193
+ onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
4194
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
4195
+ if (event.key === "Tab") event.preventDefault();
4196
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
4197
+ if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
4198
+ const items = getItems().filter((item) => !item.disabled);
4199
+ let candidateNodes = items.map((item) => item.ref.current);
4200
+ if (["ArrowUp", "End"].includes(event.key)) {
4201
+ candidateNodes = candidateNodes.slice().reverse();
4202
+ }
4203
+ if (["ArrowUp", "ArrowDown"].includes(event.key)) {
4204
+ const currentElement = event.target;
4205
+ const currentIndex = candidateNodes.indexOf(currentElement);
4206
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
4207
+ }
4208
+ setTimeout(() => focusFirst2(candidateNodes));
4209
+ event.preventDefault();
4210
+ }
4211
+ })
4212
+ }
4213
+ )
4214
+ }
4215
+ )
4216
+ }
4217
+ ) })
4218
+ }
4219
+ );
4220
+ }
4221
+ );
4222
+ SelectContentImpl.displayName = CONTENT_IMPL_NAME;
4223
+ var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
4224
+ var SelectItemAlignedPosition = React30.forwardRef((props, forwardedRef) => {
4225
+ const { __scopeSelect, onPlaced, ...popperProps } = props;
4226
+ const context = useSelectContext(CONTENT_NAME2, __scopeSelect);
4227
+ const contentContext = useSelectContentContext(CONTENT_NAME2, __scopeSelect);
4228
+ const [contentWrapper, setContentWrapper] = React30.useState(null);
4229
+ const [content, setContent] = React30.useState(null);
4230
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
4231
+ const getItems = useCollection(__scopeSelect);
4232
+ const shouldExpandOnScrollRef = React30.useRef(false);
4233
+ const shouldRepositionRef = React30.useRef(true);
4234
+ const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
4235
+ const position = React30.useCallback(() => {
4236
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
4237
+ const triggerRect = context.trigger.getBoundingClientRect();
4238
+ const contentRect = content.getBoundingClientRect();
4239
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
4240
+ const itemTextRect = selectedItemText.getBoundingClientRect();
4241
+ if (context.dir !== "rtl") {
4242
+ const itemTextOffset = itemTextRect.left - contentRect.left;
4243
+ const left = valueNodeRect.left - itemTextOffset;
4244
+ const leftDelta = triggerRect.left - left;
4245
+ const minContentWidth = triggerRect.width + leftDelta;
4246
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
4247
+ const rightEdge = window.innerWidth - CONTENT_MARGIN;
4248
+ const clampedLeft = clamp(left, [
4249
+ CONTENT_MARGIN,
4250
+ // Prevents the content from going off the starting edge of the
4251
+ // viewport. It may still go off the ending edge, but this can be
4252
+ // controlled by the user since they may want to manage overflow in a
4253
+ // specific way.
4254
+ // https://github.com/radix-ui/primitives/issues/2049
4255
+ Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
4256
+ ]);
4257
+ contentWrapper.style.minWidth = minContentWidth + "px";
4258
+ contentWrapper.style.left = clampedLeft + "px";
4259
+ } else {
4260
+ const itemTextOffset = contentRect.right - itemTextRect.right;
4261
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
4262
+ const rightDelta = window.innerWidth - triggerRect.right - right;
4263
+ const minContentWidth = triggerRect.width + rightDelta;
4264
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
4265
+ const leftEdge = window.innerWidth - CONTENT_MARGIN;
4266
+ const clampedRight = clamp(right, [
4267
+ CONTENT_MARGIN,
4268
+ Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
4269
+ ]);
4270
+ contentWrapper.style.minWidth = minContentWidth + "px";
4271
+ contentWrapper.style.right = clampedRight + "px";
4272
+ }
4273
+ const items = getItems();
4274
+ const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
4275
+ const itemsHeight = viewport.scrollHeight;
4276
+ const contentStyles = window.getComputedStyle(content);
4277
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
4278
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
4279
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
4280
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
4281
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
4282
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
4283
+ const viewportStyles = window.getComputedStyle(viewport);
4284
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
4285
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
4286
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
4287
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
4288
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
4289
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
4290
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
4291
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
4292
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
4293
+ if (willAlignWithoutTopOverflow) {
4294
+ const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
4295
+ contentWrapper.style.bottom = "0px";
4296
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
4297
+ const clampedTriggerMiddleToBottomEdge = Math.max(
4298
+ triggerMiddleToBottomEdge,
4299
+ selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
4300
+ (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
4301
+ );
4302
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
4303
+ contentWrapper.style.height = height + "px";
4304
+ } else {
4305
+ const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
4306
+ contentWrapper.style.top = "0px";
4307
+ const clampedTopEdgeToTriggerMiddle = Math.max(
4308
+ topEdgeToTriggerMiddle,
4309
+ contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
4310
+ (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
4311
+ );
4312
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
4313
+ contentWrapper.style.height = height + "px";
4314
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
4315
+ }
4316
+ contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
4317
+ contentWrapper.style.minHeight = minContentHeight + "px";
4318
+ contentWrapper.style.maxHeight = availableHeight + "px";
4319
+ onPlaced?.();
4320
+ requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
4321
+ }
4322
+ }, [
4323
+ getItems,
4324
+ context.trigger,
4325
+ context.valueNode,
4326
+ contentWrapper,
4327
+ content,
4328
+ viewport,
4329
+ selectedItem,
4330
+ selectedItemText,
4331
+ context.dir,
4332
+ onPlaced
4333
+ ]);
4334
+ useLayoutEffect2(() => position(), [position]);
4335
+ const [contentZIndex, setContentZIndex] = React30.useState();
4336
+ useLayoutEffect2(() => {
4337
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
4338
+ }, [content]);
4339
+ const handleScrollButtonChange = React30.useCallback(
4340
+ (node) => {
4341
+ if (node && shouldRepositionRef.current === true) {
4342
+ position();
4343
+ focusSelectedItem?.();
4344
+ shouldRepositionRef.current = false;
4345
+ }
4346
+ },
4347
+ [position, focusSelectedItem]
4348
+ );
4349
+ return /* @__PURE__ */ jsx(
4350
+ SelectViewportProvider,
4351
+ {
4352
+ scope: __scopeSelect,
4353
+ contentWrapper,
4354
+ shouldExpandOnScrollRef,
4355
+ onScrollButtonChange: handleScrollButtonChange,
4356
+ children: /* @__PURE__ */ jsx(
4357
+ "div",
4358
+ {
4359
+ ref: setContentWrapper,
4360
+ style: {
4361
+ display: "flex",
4362
+ flexDirection: "column",
4363
+ position: "fixed",
4364
+ zIndex: contentZIndex
4365
+ },
4366
+ children: /* @__PURE__ */ jsx(
4367
+ Primitive.div,
4368
+ {
4369
+ ...popperProps,
4370
+ ref: composedRefs,
4371
+ style: {
4372
+ // When we get the height of the content, it includes borders. If we were to set
4373
+ // the height without having `boxSizing: 'border-box'` it would be too big.
4374
+ boxSizing: "border-box",
4375
+ // We need to ensure the content doesn't get taller than the wrapper
4376
+ maxHeight: "100%",
4377
+ ...popperProps.style
4378
+ }
4379
+ }
4380
+ )
4381
+ }
4382
+ )
4383
+ }
4384
+ );
4385
+ });
4386
+ SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
4387
+ var POPPER_POSITION_NAME = "SelectPopperPosition";
4388
+ var SelectPopperPosition = React30.forwardRef((props, forwardedRef) => {
4389
+ const {
4390
+ __scopeSelect,
4391
+ align = "start",
4392
+ collisionPadding = CONTENT_MARGIN,
4393
+ ...popperProps
4394
+ } = props;
4395
+ const popperScope = usePopperScope(__scopeSelect);
4396
+ return /* @__PURE__ */ jsx(
4397
+ Content,
4398
+ {
4399
+ ...popperScope,
4400
+ ...popperProps,
4401
+ ref: forwardedRef,
4402
+ align,
4403
+ collisionPadding,
4404
+ style: {
4405
+ // Ensure border-box for floating-ui calculations
4406
+ boxSizing: "border-box",
4407
+ ...popperProps.style,
4408
+ // re-namespace exposed content custom properties
4409
+ ...{
4410
+ "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
4411
+ "--radix-select-content-available-width": "var(--radix-popper-available-width)",
4412
+ "--radix-select-content-available-height": "var(--radix-popper-available-height)",
4413
+ "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
4414
+ "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
4415
+ }
4416
+ }
4417
+ }
4418
+ );
4419
+ });
4420
+ SelectPopperPosition.displayName = POPPER_POSITION_NAME;
4421
+ var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME2, {});
4422
+ var VIEWPORT_NAME = "SelectViewport";
4423
+ var SelectViewport = React30.forwardRef(
4424
+ (props, forwardedRef) => {
4425
+ const { __scopeSelect, nonce, ...viewportProps } = props;
4426
+ const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
4427
+ const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
4428
+ const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
4429
+ const prevScrollTopRef = React30.useRef(0);
4430
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4431
+ /* @__PURE__ */ jsx(
4432
+ "style",
4433
+ {
4434
+ dangerouslySetInnerHTML: {
4435
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
4436
+ },
4437
+ nonce
4438
+ }
4439
+ ),
4440
+ /* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
4441
+ Primitive.div,
4442
+ {
4443
+ "data-radix-select-viewport": "",
4444
+ role: "presentation",
4445
+ ...viewportProps,
4446
+ ref: composedRefs,
4447
+ style: {
4448
+ // we use position: 'relative' here on the `viewport` so that when we call
4449
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
4450
+ // (independent of the scrollUpButton).
4451
+ position: "relative",
4452
+ flex: 1,
4453
+ // Viewport should only be scrollable in the vertical direction.
4454
+ // This won't work in vertical writing modes, so we'll need to
4455
+ // revisit this if/when that is supported
4456
+ // https://developer.chrome.com/blog/vertical-form-controls
4457
+ overflow: "hidden auto",
4458
+ ...viewportProps.style
4459
+ },
4460
+ onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
4461
+ const viewport = event.currentTarget;
4462
+ const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
4463
+ if (shouldExpandOnScrollRef?.current && contentWrapper) {
4464
+ const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
4465
+ if (scrolledBy > 0) {
4466
+ const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
4467
+ const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
4468
+ const cssHeight = parseFloat(contentWrapper.style.height);
4469
+ const prevHeight = Math.max(cssMinHeight, cssHeight);
4470
+ if (prevHeight < availableHeight) {
4471
+ const nextHeight = prevHeight + scrolledBy;
4472
+ const clampedNextHeight = Math.min(availableHeight, nextHeight);
4473
+ const heightDiff = nextHeight - clampedNextHeight;
4474
+ contentWrapper.style.height = clampedNextHeight + "px";
4475
+ if (contentWrapper.style.bottom === "0px") {
4476
+ viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
4477
+ contentWrapper.style.justifyContent = "flex-end";
4478
+ }
4479
+ }
4480
+ }
4481
+ }
4482
+ prevScrollTopRef.current = viewport.scrollTop;
4483
+ })
4484
+ }
4485
+ ) })
4486
+ ] });
4487
+ }
4488
+ );
4489
+ SelectViewport.displayName = VIEWPORT_NAME;
4490
+ var GROUP_NAME = "SelectGroup";
4491
+ var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
4492
+ var SelectGroup = React30.forwardRef(
4493
+ (props, forwardedRef) => {
4494
+ const { __scopeSelect, ...groupProps } = props;
4495
+ const groupId = useId();
4496
+ return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
4497
+ }
4498
+ );
4499
+ SelectGroup.displayName = GROUP_NAME;
4500
+ var LABEL_NAME = "SelectLabel";
4501
+ var SelectLabel = React30.forwardRef(
4502
+ (props, forwardedRef) => {
4503
+ const { __scopeSelect, ...labelProps } = props;
4504
+ const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
4505
+ return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
4506
+ }
4507
+ );
4508
+ SelectLabel.displayName = LABEL_NAME;
4509
+ var ITEM_NAME = "SelectItem";
4510
+ var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
4511
+ var SelectItem = React30.forwardRef(
4512
+ (props, forwardedRef) => {
4513
+ const {
4514
+ __scopeSelect,
4515
+ value,
4516
+ disabled = false,
4517
+ textValue: textValueProp,
4518
+ ...itemProps
4519
+ } = props;
4520
+ const context = useSelectContext(ITEM_NAME, __scopeSelect);
4521
+ const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
4522
+ const isSelected = context.value === value;
4523
+ const [textValue, setTextValue] = React30.useState(textValueProp ?? "");
4524
+ const [isFocused, setIsFocused] = React30.useState(false);
4525
+ const composedRefs = useComposedRefs(
4526
+ forwardedRef,
4527
+ (node) => contentContext.itemRefCallback?.(node, value, disabled)
4528
+ );
4529
+ const textId = useId();
4530
+ const pointerTypeRef = React30.useRef("touch");
4531
+ const handleSelect = () => {
4532
+ if (!disabled) {
4533
+ context.onValueChange(value);
4534
+ context.onOpenChange(false);
4535
+ }
4536
+ };
4537
+ if (value === "") {
4538
+ throw new Error(
4539
+ "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
4540
+ );
4541
+ }
4542
+ return /* @__PURE__ */ jsx(
4543
+ SelectItemContextProvider,
4544
+ {
4545
+ scope: __scopeSelect,
4546
+ value,
4547
+ disabled,
4548
+ textId,
4549
+ isSelected,
4550
+ onItemTextChange: React30.useCallback((node) => {
4551
+ setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
4552
+ }, []),
4553
+ children: /* @__PURE__ */ jsx(
4554
+ Collection.ItemSlot,
4555
+ {
4556
+ scope: __scopeSelect,
4557
+ value,
4558
+ disabled,
4559
+ textValue,
4560
+ children: /* @__PURE__ */ jsx(
4561
+ Primitive.div,
4562
+ {
4563
+ role: "option",
4564
+ "aria-labelledby": textId,
4565
+ "data-highlighted": isFocused ? "" : void 0,
4566
+ "aria-selected": isSelected && isFocused,
4567
+ "data-state": isSelected ? "checked" : "unchecked",
4568
+ "aria-disabled": disabled || void 0,
4569
+ "data-disabled": disabled ? "" : void 0,
4570
+ tabIndex: disabled ? void 0 : -1,
4571
+ ...itemProps,
4572
+ ref: composedRefs,
4573
+ onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
4574
+ onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
4575
+ onClick: composeEventHandlers(itemProps.onClick, () => {
4576
+ if (pointerTypeRef.current !== "mouse") handleSelect();
4577
+ }),
4578
+ onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
4579
+ if (pointerTypeRef.current === "mouse") handleSelect();
4580
+ }),
4581
+ onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
4582
+ pointerTypeRef.current = event.pointerType;
4583
+ }),
4584
+ onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
4585
+ pointerTypeRef.current = event.pointerType;
4586
+ if (disabled) {
4587
+ contentContext.onItemLeave?.();
4588
+ } else if (pointerTypeRef.current === "mouse") {
4589
+ event.currentTarget.focus({ preventScroll: true });
4590
+ }
4591
+ }),
4592
+ onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
4593
+ if (event.currentTarget === document.activeElement) {
4594
+ contentContext.onItemLeave?.();
4595
+ }
4596
+ }),
4597
+ onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
4598
+ const isTypingAhead = contentContext.searchRef?.current !== "";
4599
+ if (isTypingAhead && event.key === " ") return;
4600
+ if (SELECTION_KEYS.includes(event.key)) handleSelect();
4601
+ if (event.key === " ") event.preventDefault();
4602
+ })
4603
+ }
4604
+ )
4605
+ }
4606
+ )
4607
+ }
4608
+ );
4609
+ }
4610
+ );
4611
+ SelectItem.displayName = ITEM_NAME;
4612
+ var ITEM_TEXT_NAME = "SelectItemText";
4613
+ var SelectItemText = React30.forwardRef(
4614
+ (props, forwardedRef) => {
4615
+ const { __scopeSelect, className, style, ...itemTextProps } = props;
4616
+ const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
4617
+ const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
4618
+ const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
4619
+ const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
4620
+ const [itemTextNode, setItemTextNode] = React30.useState(null);
4621
+ const composedRefs = useComposedRefs(
4622
+ forwardedRef,
4623
+ (node) => setItemTextNode(node),
4624
+ itemContext.onItemTextChange,
4625
+ (node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
4626
+ );
4627
+ const textContent = itemTextNode?.textContent;
4628
+ const nativeOption = React30.useMemo(
4629
+ () => /* @__PURE__ */ jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
4630
+ [itemContext.disabled, itemContext.value, textContent]
4631
+ );
4632
+ const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
4633
+ useLayoutEffect2(() => {
4634
+ onNativeOptionAdd(nativeOption);
4635
+ return () => onNativeOptionRemove(nativeOption);
4636
+ }, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
4637
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4638
+ /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
4639
+ itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM4.createPortal(itemTextProps.children, context.valueNode) : null
4640
+ ] });
4641
+ }
4642
+ );
4643
+ SelectItemText.displayName = ITEM_TEXT_NAME;
4644
+ var ITEM_INDICATOR_NAME = "SelectItemIndicator";
4645
+ var SelectItemIndicator = React30.forwardRef(
4646
+ (props, forwardedRef) => {
4647
+ const { __scopeSelect, ...itemIndicatorProps } = props;
4648
+ const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
4649
+ return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
4650
+ }
4651
+ );
4652
+ SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
4653
+ var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
4654
+ var SelectScrollUpButton2 = React30.forwardRef((props, forwardedRef) => {
4655
+ const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
4656
+ const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
4657
+ const [canScrollUp, setCanScrollUp] = React30.useState(false);
4658
+ const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
4659
+ useLayoutEffect2(() => {
4660
+ if (contentContext.viewport && contentContext.isPositioned) {
4661
+ let handleScroll22 = function() {
4662
+ const canScrollUp2 = viewport.scrollTop > 0;
4663
+ setCanScrollUp(canScrollUp2);
4664
+ };
4665
+ const viewport = contentContext.viewport;
4666
+ handleScroll22();
4667
+ viewport.addEventListener("scroll", handleScroll22);
4668
+ return () => viewport.removeEventListener("scroll", handleScroll22);
4669
+ }
4670
+ }, [contentContext.viewport, contentContext.isPositioned]);
4671
+ return canScrollUp ? /* @__PURE__ */ jsx(
4672
+ SelectScrollButtonImpl,
4673
+ {
4674
+ ...props,
4675
+ ref: composedRefs,
4676
+ onAutoScroll: () => {
4677
+ const { viewport, selectedItem } = contentContext;
4678
+ if (viewport && selectedItem) {
4679
+ viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
4680
+ }
4681
+ }
4682
+ }
4683
+ ) : null;
4684
+ });
4685
+ SelectScrollUpButton2.displayName = SCROLL_UP_BUTTON_NAME;
4686
+ var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
4687
+ var SelectScrollDownButton2 = React30.forwardRef((props, forwardedRef) => {
4688
+ const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
4689
+ const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
4690
+ const [canScrollDown, setCanScrollDown] = React30.useState(false);
4691
+ const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
4692
+ useLayoutEffect2(() => {
4693
+ if (contentContext.viewport && contentContext.isPositioned) {
4694
+ let handleScroll22 = function() {
4695
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight;
4696
+ const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
4697
+ setCanScrollDown(canScrollDown2);
4698
+ };
4699
+ const viewport = contentContext.viewport;
4700
+ handleScroll22();
4701
+ viewport.addEventListener("scroll", handleScroll22);
4702
+ return () => viewport.removeEventListener("scroll", handleScroll22);
4703
+ }
4704
+ }, [contentContext.viewport, contentContext.isPositioned]);
4705
+ return canScrollDown ? /* @__PURE__ */ jsx(
4706
+ SelectScrollButtonImpl,
4707
+ {
4708
+ ...props,
4709
+ ref: composedRefs,
4710
+ onAutoScroll: () => {
4711
+ const { viewport, selectedItem } = contentContext;
4712
+ if (viewport && selectedItem) {
4713
+ viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
4714
+ }
4715
+ }
4716
+ }
4717
+ ) : null;
4718
+ });
4719
+ SelectScrollDownButton2.displayName = SCROLL_DOWN_BUTTON_NAME;
4720
+ var SelectScrollButtonImpl = React30.forwardRef((props, forwardedRef) => {
4721
+ const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
4722
+ const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
4723
+ const autoScrollTimerRef = React30.useRef(null);
4724
+ const getItems = useCollection(__scopeSelect);
4725
+ const clearAutoScrollTimer = React30.useCallback(() => {
4726
+ if (autoScrollTimerRef.current !== null) {
4727
+ window.clearInterval(autoScrollTimerRef.current);
4728
+ autoScrollTimerRef.current = null;
4729
+ }
4730
+ }, []);
4731
+ React30.useEffect(() => {
4732
+ return () => clearAutoScrollTimer();
4733
+ }, [clearAutoScrollTimer]);
4734
+ useLayoutEffect2(() => {
4735
+ const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
4736
+ activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
4737
+ }, [getItems]);
4738
+ return /* @__PURE__ */ jsx(
4739
+ Primitive.div,
4740
+ {
4741
+ "aria-hidden": true,
4742
+ ...scrollIndicatorProps,
4743
+ ref: forwardedRef,
4744
+ style: { flexShrink: 0, ...scrollIndicatorProps.style },
4745
+ onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
4746
+ if (autoScrollTimerRef.current === null) {
4747
+ autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
4748
+ }
4749
+ }),
4750
+ onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
4751
+ contentContext.onItemLeave?.();
4752
+ if (autoScrollTimerRef.current === null) {
4753
+ autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
4754
+ }
4755
+ }),
4756
+ onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
4757
+ clearAutoScrollTimer();
4758
+ })
4759
+ }
4760
+ );
4761
+ });
4762
+ var SEPARATOR_NAME = "SelectSeparator";
4763
+ var SelectSeparator = React30.forwardRef(
4764
+ (props, forwardedRef) => {
4765
+ const { __scopeSelect, ...separatorProps } = props;
4766
+ return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
4767
+ }
4768
+ );
4769
+ SelectSeparator.displayName = SEPARATOR_NAME;
4770
+ var ARROW_NAME2 = "SelectArrow";
4771
+ var SelectArrow = React30.forwardRef(
4772
+ (props, forwardedRef) => {
4773
+ const { __scopeSelect, ...arrowProps } = props;
4774
+ const popperScope = usePopperScope(__scopeSelect);
4775
+ const context = useSelectContext(ARROW_NAME2, __scopeSelect);
4776
+ const contentContext = useSelectContentContext(ARROW_NAME2, __scopeSelect);
4777
+ return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(Arrow2, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
4778
+ }
4779
+ );
4780
+ SelectArrow.displayName = ARROW_NAME2;
4781
+ var BUBBLE_INPUT_NAME = "SelectBubbleInput";
4782
+ var SelectBubbleInput = React30.forwardRef(
4783
+ ({ __scopeSelect, value, ...props }, forwardedRef) => {
4784
+ const ref = React30.useRef(null);
4785
+ const composedRefs = useComposedRefs(forwardedRef, ref);
4786
+ const prevValue = usePrevious(value);
4787
+ React30.useEffect(() => {
4788
+ const select = ref.current;
4789
+ if (!select) return;
4790
+ const selectProto = window.HTMLSelectElement.prototype;
4791
+ const descriptor = Object.getOwnPropertyDescriptor(
4792
+ selectProto,
4793
+ "value"
4794
+ );
4795
+ const setValue = descriptor.set;
4796
+ if (prevValue !== value && setValue) {
4797
+ const event = new Event("change", { bubbles: true });
4798
+ setValue.call(select, value);
4799
+ select.dispatchEvent(event);
4800
+ }
4801
+ }, [prevValue, value]);
4802
+ return /* @__PURE__ */ jsx(
4803
+ Primitive.select,
4804
+ {
4805
+ ...props,
4806
+ style: { ...VISUALLY_HIDDEN_STYLES, ...props.style },
4807
+ ref: composedRefs,
4808
+ defaultValue: value
4809
+ }
4810
+ );
4811
+ }
4812
+ );
4813
+ SelectBubbleInput.displayName = BUBBLE_INPUT_NAME;
4814
+ function shouldShowPlaceholder(value) {
4815
+ return value === "" || value === void 0;
4816
+ }
4817
+ function useTypeaheadSearch(onSearchChange) {
4818
+ const handleSearchChange = useCallbackRef(onSearchChange);
4819
+ const searchRef = React30.useRef("");
4820
+ const timerRef = React30.useRef(0);
4821
+ const handleTypeaheadSearch = React30.useCallback(
4822
+ (key) => {
4823
+ const search = searchRef.current + key;
4824
+ handleSearchChange(search);
4825
+ (function updateSearch(value) {
4826
+ searchRef.current = value;
4827
+ window.clearTimeout(timerRef.current);
4828
+ if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
4829
+ })(search);
4830
+ },
4831
+ [handleSearchChange]
4832
+ );
4833
+ const resetTypeahead = React30.useCallback(() => {
4834
+ searchRef.current = "";
4835
+ window.clearTimeout(timerRef.current);
4836
+ }, []);
4837
+ React30.useEffect(() => {
4838
+ return () => window.clearTimeout(timerRef.current);
4839
+ }, []);
4840
+ return [searchRef, handleTypeaheadSearch, resetTypeahead];
4841
+ }
4842
+ function findNextItem(items, search, currentItem) {
4843
+ const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
4844
+ const normalizedSearch = isRepeated ? search[0] : search;
4845
+ const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
4846
+ let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
4847
+ const excludeCurrentItem = normalizedSearch.length === 1;
4848
+ if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
4849
+ const nextItem = wrappedItems.find(
4850
+ (item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
4851
+ );
4852
+ return nextItem !== currentItem ? nextItem : void 0;
4853
+ }
4854
+ function wrapArray(array, startIndex) {
4855
+ return array.map((_, index2) => array[(startIndex + index2) % array.length]);
4856
+ }
4857
+ var Group = SelectGroup;
4858
+ function SelectGroup2(props) {
4859
+ return /* @__PURE__ */ jsx(Group, { "data-slot": "select-group", ...props });
4860
+ }
4861
+ function SelectItem2({ className, children, ...props }) {
4862
+ return /* @__PURE__ */ jsxs(
4863
+ Select$1.Item,
4864
+ {
4865
+ "data-slot": "select-item",
4866
+ className: cn(
4867
+ "focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
4868
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
4869
+ "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
4870
+ className
4871
+ ),
4872
+ ...props,
4873
+ children: [
4874
+ /* @__PURE__ */ jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(Select$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) }) }),
4875
+ /* @__PURE__ */ jsx(Select$1.ItemText, { children })
4876
+ ]
4877
+ }
4878
+ );
4879
+ }
4880
+ function SelectLabel2({ className, ...props }) {
4881
+ return /* @__PURE__ */ jsx(
4882
+ Select$1.Label,
4883
+ {
4884
+ "data-slot": "select-label",
4885
+ className: cn("text-muted-foreground px-2 py-1.5 text-xs", className),
4886
+ ...props
4887
+ }
4888
+ );
4889
+ }
4890
+ function SelectSeparator2({ className, ...props }) {
4891
+ return /* @__PURE__ */ jsx(
4892
+ Select$1.Separator,
4893
+ {
4894
+ "data-slot": "select-separator",
4895
+ className: cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
4896
+ ...props
4897
+ }
4898
+ );
4899
+ }
4900
+
4901
+ export { Select, SelectContent, SelectGroup2 as SelectGroup, SelectItem2 as SelectItem, SelectLabel2 as SelectLabel, SelectSeparator2 as SelectSeparator, useComposedRefs };