cetec-design-system 0.0.44-0 → 0.0.46-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 (60) hide show
  1. package/dist/index.js +3839 -60
  2. package/dist/index.js.map +1 -1
  3. package/dist/preset.js +104 -136
  4. package/dist/preset.js.map +1 -1
  5. package/dist/reset.css +149 -0
  6. package/dist/specs/recipes.json +15 -12
  7. package/dist/specs/tokens.json +9 -4
  8. package/dist/styles/global.css +13 -118
  9. package/dist/styles/recipes/avatar.css +1 -1
  10. package/dist/styles/recipes/badge.css +10 -2
  11. package/dist/styles/recipes/box.css +14 -0
  12. package/dist/styles/recipes/breadcrumbs.css +8 -0
  13. package/dist/styles/recipes/button.css +8 -3
  14. package/dist/styles/recipes/checkbox-input.css +8 -0
  15. package/dist/styles/recipes/chip.css +8 -4
  16. package/dist/styles/recipes/code.css +8 -1
  17. package/dist/styles/recipes/form-field.css +11 -0
  18. package/dist/styles/recipes/heading.css +1 -5
  19. package/dist/styles/recipes/icon-button.css +8 -3
  20. package/dist/styles/recipes/menu.css +16 -0
  21. package/dist/styles/recipes/modal.css +8 -0
  22. package/dist/styles/recipes/pre.css +7 -0
  23. package/dist/styles/recipes/radio-input.css +8 -0
  24. package/dist/styles/recipes/radio.css +10 -1
  25. package/dist/styles/recipes/tag.css +8 -1
  26. package/dist/styles/recipes/text.css +4 -7
  27. package/dist/styles/recipes/textarea.css +9 -2
  28. package/dist/styles/recipes/textinput.css +11 -3
  29. package/dist/styles/recipes/toggle-input.css +8 -0
  30. package/dist/styles/recipes/tooltip.css +8 -3
  31. package/dist/styles/recipes.css +1 -0
  32. package/dist/styles/tokens.css +1 -0
  33. package/dist/styles/utilities.css +2 -2
  34. package/dist/types/index.d.ts +154 -3
  35. package/package.json +3 -2
  36. package/src/recipes/badge.ts +3 -1
  37. package/src/recipes/box.ts +4 -4
  38. package/src/recipes/breadcrumbs.ts +22 -22
  39. package/src/recipes/button.ts +2 -1
  40. package/src/recipes/checkboxInput.ts +11 -11
  41. package/src/recipes/chip.ts +2 -0
  42. package/src/recipes/code.ts +19 -18
  43. package/src/recipes/formField.ts +2 -0
  44. package/src/recipes/menu.ts +3 -0
  45. package/src/recipes/modal.ts +2 -0
  46. package/src/recipes/radio.ts +67 -65
  47. package/src/recipes/radioinput.ts +11 -11
  48. package/src/recipes/tag.ts +4 -2
  49. package/src/recipes/text.ts +10 -6
  50. package/src/recipes/textarea.ts +3 -0
  51. package/src/recipes/textinput.ts +6 -1
  52. package/src/recipes/toggleinput.ts +13 -13
  53. package/src/recipes/tooltip.ts +31 -28
  54. package/src/styles/index.css +1 -1
  55. package/src/styles/primitives/fontSizes.ts +1 -0
  56. package/src/styles/reset.css +149 -0
  57. package/src/styles/utilities/globalStyle.ts +19 -83
  58. package/src/styles/utilities/index.ts +2 -0
  59. package/src/styles/utilities/recipeGlobalStyles.ts +12 -0
  60. package/src/styles/utilities/textStyles.ts +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import React, { forwardRef, useMemo, createElement, createContext, useState, useEffect, useContext, useRef } from "react";
1
+ import * as React from "react";
2
+ import React__default, { forwardRef, useMemo, createElement, createContext, useState, useEffect, useContext, useRef, useLayoutEffect } from "react";
2
3
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
+ import * as ReactDOM from "react-dom";
3
5
  import { cetecPreset } from "./preset.js";
4
6
  function isObject(value) {
5
7
  return typeof value === "object" && value != null && !Array.isArray(value);
@@ -53,7 +55,7 @@ var memo = (fn) => {
53
55
  return get;
54
56
  };
55
57
  var MERGE_OMIT = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
56
- function mergeProps(...sources) {
58
+ function mergeProps$1(...sources) {
57
59
  return sources.reduce((prev, obj) => {
58
60
  if (!obj) return prev;
59
61
  Object.keys(obj).forEach((key) => {
@@ -61,7 +63,7 @@ function mergeProps(...sources) {
61
63
  const prevValue = prev[key];
62
64
  const value = obj[key];
63
65
  if (isObject(prevValue) && isObject(value)) {
64
- prev[key] = mergeProps(prevValue, value);
66
+ prev[key] = mergeProps$1(prevValue, value);
65
67
  } else {
66
68
  prev[key] = value;
67
69
  }
@@ -99,8 +101,8 @@ function mapObject(obj, fn) {
99
101
  }
100
102
  function toResponsiveObject(values, breakpoints) {
101
103
  return values.reduce(
102
- (acc, current, index) => {
103
- const key = breakpoints[index];
104
+ (acc, current, index2) => {
105
+ const key = breakpoints[index2];
104
106
  if (current != null) {
105
107
  acc[key] = current;
106
108
  }
@@ -170,7 +172,7 @@ function createMergeCss(context2) {
170
172
  return allStyles.map((style) => normalizeStyleObject(style, context2));
171
173
  }
172
174
  function mergeCss2(...styles) {
173
- return mergeProps(...resolve(styles));
175
+ return mergeProps$1(...resolve(styles));
174
176
  }
175
177
  function assignCss(...styles) {
176
178
  return Object.assign({}, ...resolve(styles));
@@ -331,7 +333,7 @@ function cva(config) {
331
333
  variants: Object.fromEntries(
332
334
  variantKeys2.map((key) => [key, mergeCss(variants[key], override.variants[key])])
333
335
  ),
334
- defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
336
+ defaultVariants: mergeProps$1(defaultVariants, override.defaultVariants),
335
337
  compoundVariants: [...compoundVariants, ...override.compoundVariants]
336
338
  });
337
339
  }
@@ -745,6 +747,7 @@ const labelVariantMap = {
745
747
  "true"
746
748
  ],
747
749
  "size": [
750
+ "10",
748
751
  "12",
749
752
  "14",
750
753
  "16",
@@ -810,6 +813,7 @@ const linkVariantMap = {
810
813
  "true"
811
814
  ],
812
815
  "size": [
816
+ "10",
813
817
  "12",
814
818
  "14",
815
819
  "16",
@@ -1441,6 +1445,7 @@ const textVariantMap = {
1441
1445
  "true"
1442
1446
  ],
1443
1447
  "size": [
1448
+ "10",
1444
1449
  "12",
1445
1450
  "14",
1446
1451
  "16",
@@ -1581,7 +1586,7 @@ const toggleFn = memo((props = {}) => {
1581
1586
  return Object.fromEntries(toggleSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
1582
1587
  });
1583
1588
  const toggleVariantKeys = [];
1584
- const getVariantProps$8 = (variants) => ({ ...toggleDefaultVariants, ...compact(variants) });
1589
+ const getVariantProps$c = (variants) => ({ ...toggleDefaultVariants, ...compact(variants) });
1585
1590
  const toggle = /* @__PURE__ */ Object.assign(toggleFn, {
1586
1591
  __recipe__: false,
1587
1592
  __name__: "toggle",
@@ -1592,7 +1597,7 @@ const toggle = /* @__PURE__ */ Object.assign(toggleFn, {
1592
1597
  splitVariantProps(props) {
1593
1598
  return splitProps$1(props, toggleVariantKeys);
1594
1599
  },
1595
- getVariantProps: getVariantProps$8
1600
+ getVariantProps: getVariantProps$c
1596
1601
  });
1597
1602
  const buttonDefaultVariants = {
1598
1603
  "variant": "standard",
@@ -1692,7 +1697,7 @@ const buttonVariantKeys = [
1692
1697
  "iconBefore",
1693
1698
  "iconAfter"
1694
1699
  ];
1695
- const getVariantProps$7 = (variants) => ({ ...buttonDefaultVariants, ...compact(variants) });
1700
+ const getVariantProps$b = (variants) => ({ ...buttonDefaultVariants, ...compact(variants) });
1696
1701
  const button = /* @__PURE__ */ Object.assign(buttonFn, {
1697
1702
  __recipe__: false,
1698
1703
  __name__: "button",
@@ -1724,7 +1729,7 @@ const button = /* @__PURE__ */ Object.assign(buttonFn, {
1724
1729
  splitVariantProps(props) {
1725
1730
  return splitProps$1(props, buttonVariantKeys);
1726
1731
  },
1727
- getVariantProps: getVariantProps$7
1732
+ getVariantProps: getVariantProps$b
1728
1733
  });
1729
1734
  const iconButtonDefaultVariants = {
1730
1735
  "variant": "standard",
@@ -1749,7 +1754,7 @@ const iconButtonVariantKeys = [
1749
1754
  "variant",
1750
1755
  "size"
1751
1756
  ];
1752
- const getVariantProps$6 = (variants) => ({ ...iconButtonDefaultVariants, ...compact(variants) });
1757
+ const getVariantProps$a = (variants) => ({ ...iconButtonDefaultVariants, ...compact(variants) });
1753
1758
  const iconButton = /* @__PURE__ */ Object.assign(iconButtonFn, {
1754
1759
  __recipe__: false,
1755
1760
  __name__: "iconButton",
@@ -1775,7 +1780,7 @@ const iconButton = /* @__PURE__ */ Object.assign(iconButtonFn, {
1775
1780
  splitVariantProps(props) {
1776
1781
  return splitProps$1(props, iconButtonVariantKeys);
1777
1782
  },
1778
- getVariantProps: getVariantProps$6
1783
+ getVariantProps: getVariantProps$a
1779
1784
  });
1780
1785
  const checkboxDefaultVariants = {};
1781
1786
  const checkboxCompoundVariants = [];
@@ -1798,7 +1803,7 @@ const checkboxFn = memo((props = {}) => {
1798
1803
  return Object.fromEntries(checkboxSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
1799
1804
  });
1800
1805
  const checkboxVariantKeys = [];
1801
- const getVariantProps$5 = (variants) => ({ ...checkboxDefaultVariants, ...compact(variants) });
1806
+ const getVariantProps$9 = (variants) => ({ ...checkboxDefaultVariants, ...compact(variants) });
1802
1807
  const checkbox = /* @__PURE__ */ Object.assign(checkboxFn, {
1803
1808
  __recipe__: false,
1804
1809
  __name__: "checkbox",
@@ -1809,7 +1814,7 @@ const checkbox = /* @__PURE__ */ Object.assign(checkboxFn, {
1809
1814
  splitVariantProps(props) {
1810
1815
  return splitProps$1(props, checkboxVariantKeys);
1811
1816
  },
1812
- getVariantProps: getVariantProps$5
1817
+ getVariantProps: getVariantProps$9
1813
1818
  });
1814
1819
  const radioDefaultVariants = {};
1815
1820
  const radioCompoundVariants = [];
@@ -1832,7 +1837,7 @@ const radioFn = memo((props = {}) => {
1832
1837
  return Object.fromEntries(radioSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
1833
1838
  });
1834
1839
  const radioVariantKeys = [];
1835
- const getVariantProps$4 = (variants) => ({ ...radioDefaultVariants, ...compact(variants) });
1840
+ const getVariantProps$8 = (variants) => ({ ...radioDefaultVariants, ...compact(variants) });
1836
1841
  const radio = /* @__PURE__ */ Object.assign(radioFn, {
1837
1842
  __recipe__: false,
1838
1843
  __name__: "radio",
@@ -1843,7 +1848,7 @@ const radio = /* @__PURE__ */ Object.assign(radioFn, {
1843
1848
  splitVariantProps(props) {
1844
1849
  return splitProps$1(props, radioVariantKeys);
1845
1850
  },
1846
- getVariantProps: getVariantProps$4
1851
+ getVariantProps: getVariantProps$8
1847
1852
  });
1848
1853
  const tooltipDefaultVariants = {
1849
1854
  "position": "bottom"
@@ -1972,7 +1977,7 @@ const tooltipVariantKeys = [
1972
1977
  "position",
1973
1978
  "caret"
1974
1979
  ];
1975
- const getVariantProps$3 = (variants) => ({ ...tooltipDefaultVariants, ...compact(variants) });
1980
+ const getVariantProps$7 = (variants) => ({ ...tooltipDefaultVariants, ...compact(variants) });
1976
1981
  const tooltip = /* @__PURE__ */ Object.assign(tooltipFn, {
1977
1982
  __recipe__: false,
1978
1983
  __name__: "tooltip",
@@ -2002,7 +2007,7 @@ const tooltip = /* @__PURE__ */ Object.assign(tooltipFn, {
2002
2007
  splitVariantProps(props) {
2003
2008
  return splitProps$1(props, tooltipVariantKeys);
2004
2009
  },
2005
- getVariantProps: getVariantProps$3
2010
+ getVariantProps: getVariantProps$7
2006
2011
  });
2007
2012
  const menuDefaultVariants = {
2008
2013
  "iconPlacement": "left",
@@ -2071,7 +2076,7 @@ const menuVariantKeys = [
2071
2076
  "iconPlacement",
2072
2077
  "multiSelectType"
2073
2078
  ];
2074
- const getVariantProps$2 = (variants) => ({ ...menuDefaultVariants, ...compact(variants) });
2079
+ const getVariantProps$6 = (variants) => ({ ...menuDefaultVariants, ...compact(variants) });
2075
2080
  const menu = /* @__PURE__ */ Object.assign(menuFn, {
2076
2081
  __recipe__: false,
2077
2082
  __name__: "menu",
@@ -2091,7 +2096,7 @@ const menu = /* @__PURE__ */ Object.assign(menuFn, {
2091
2096
  splitVariantProps(props) {
2092
2097
  return splitProps$1(props, menuVariantKeys);
2093
2098
  },
2094
- getVariantProps: getVariantProps$2
2099
+ getVariantProps: getVariantProps$6
2095
2100
  });
2096
2101
  const formFieldDefaultVariants = {
2097
2102
  "layout": "default"
@@ -2122,7 +2127,7 @@ const formFieldFn = memo((props = {}) => {
2122
2127
  const formFieldVariantKeys = [
2123
2128
  "layout"
2124
2129
  ];
2125
- const getVariantProps$1 = (variants) => ({ ...formFieldDefaultVariants, ...compact(variants) });
2130
+ const getVariantProps$5 = (variants) => ({ ...formFieldDefaultVariants, ...compact(variants) });
2126
2131
  const formField = /* @__PURE__ */ Object.assign(formFieldFn, {
2127
2132
  __recipe__: false,
2128
2133
  __name__: "formField",
@@ -2138,7 +2143,7 @@ const formField = /* @__PURE__ */ Object.assign(formFieldFn, {
2138
2143
  splitVariantProps(props) {
2139
2144
  return splitProps$1(props, formFieldVariantKeys);
2140
2145
  },
2141
- getVariantProps: getVariantProps$1
2146
+ getVariantProps: getVariantProps$5
2142
2147
  });
2143
2148
  const spinnerDefaultVariants = {
2144
2149
  "size": "md"
@@ -2163,7 +2168,7 @@ const spinnerVariantKeys = [
2163
2168
  "inverse",
2164
2169
  "centered"
2165
2170
  ];
2166
- const getVariantProps = (variants) => ({ ...spinnerDefaultVariants, ...compact(variants) });
2171
+ const getVariantProps$4 = (variants) => ({ ...spinnerDefaultVariants, ...compact(variants) });
2167
2172
  const spinner = /* @__PURE__ */ Object.assign(spinnerFn, {
2168
2173
  __recipe__: false,
2169
2174
  __name__: "spinner",
@@ -2187,6 +2192,327 @@ const spinner = /* @__PURE__ */ Object.assign(spinnerFn, {
2187
2192
  splitVariantProps(props) {
2188
2193
  return splitProps$1(props, spinnerVariantKeys);
2189
2194
  },
2195
+ getVariantProps: getVariantProps$4
2196
+ });
2197
+ const avatarDefaultVariants = {
2198
+ "size": "md",
2199
+ "shape": "circle"
2200
+ };
2201
+ const avatarCompoundVariants = [];
2202
+ const avatarSlotNames = [
2203
+ [
2204
+ "root",
2205
+ "avatar__root"
2206
+ ],
2207
+ [
2208
+ "image",
2209
+ "avatar__image"
2210
+ ],
2211
+ [
2212
+ "fallback",
2213
+ "avatar__fallback"
2214
+ ],
2215
+ [
2216
+ "presence",
2217
+ "avatar__presence"
2218
+ ],
2219
+ [
2220
+ "status",
2221
+ "avatar__status"
2222
+ ]
2223
+ ];
2224
+ const avatarSlotFns = /* @__PURE__ */ avatarSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, avatarDefaultVariants, getSlotCompoundVariant(avatarCompoundVariants, slotName))]);
2225
+ const avatarFn = memo((props = {}) => {
2226
+ return Object.fromEntries(avatarSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
2227
+ });
2228
+ const avatarVariantKeys = [
2229
+ "size",
2230
+ "shape"
2231
+ ];
2232
+ const getVariantProps$3 = (variants) => ({ ...avatarDefaultVariants, ...compact(variants) });
2233
+ const avatar = /* @__PURE__ */ Object.assign(avatarFn, {
2234
+ __recipe__: false,
2235
+ __name__: "avatar",
2236
+ raw: (props) => props,
2237
+ classNameMap: {},
2238
+ variantKeys: avatarVariantKeys,
2239
+ variantMap: {
2240
+ "size": [
2241
+ "xs",
2242
+ "sm",
2243
+ "md",
2244
+ "lg",
2245
+ "xl",
2246
+ "2xl"
2247
+ ],
2248
+ "shape": [
2249
+ "circle",
2250
+ "square",
2251
+ "hexagon"
2252
+ ]
2253
+ },
2254
+ splitVariantProps(props) {
2255
+ return splitProps$1(props, avatarVariantKeys);
2256
+ },
2257
+ getVariantProps: getVariantProps$3
2258
+ });
2259
+ const badgeDefaultVariants = {
2260
+ "size": "md",
2261
+ "variant": "danger"
2262
+ };
2263
+ const badgeCompoundVariants = [
2264
+ {
2265
+ "dot": false,
2266
+ "size": "sm",
2267
+ "css": {
2268
+ "indicator": {
2269
+ "minW": "16",
2270
+ "h": "fit"
2271
+ }
2272
+ }
2273
+ },
2274
+ {
2275
+ "dot": false,
2276
+ "size": "md",
2277
+ "css": {
2278
+ "indicator": {
2279
+ "minW": "20",
2280
+ "h": "fit"
2281
+ }
2282
+ }
2283
+ },
2284
+ {
2285
+ "dot": false,
2286
+ "size": "lg",
2287
+ "css": {
2288
+ "indicator": {
2289
+ "minW": "24",
2290
+ "h": "fit"
2291
+ }
2292
+ }
2293
+ }
2294
+ ];
2295
+ const badgeSlotNames = [
2296
+ [
2297
+ "root",
2298
+ "badge__root"
2299
+ ],
2300
+ [
2301
+ "indicator",
2302
+ "badge__indicator"
2303
+ ]
2304
+ ];
2305
+ const badgeSlotFns = /* @__PURE__ */ badgeSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, badgeDefaultVariants, getSlotCompoundVariant(badgeCompoundVariants, slotName))]);
2306
+ const badgeFn = memo((props = {}) => {
2307
+ return Object.fromEntries(badgeSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
2308
+ });
2309
+ const badgeVariantKeys = [
2310
+ "size",
2311
+ "standalone",
2312
+ "dot",
2313
+ "variant"
2314
+ ];
2315
+ const getVariantProps$2 = (variants) => ({ ...badgeDefaultVariants, ...compact(variants) });
2316
+ const badge = /* @__PURE__ */ Object.assign(badgeFn, {
2317
+ __recipe__: false,
2318
+ __name__: "badge",
2319
+ raw: (props) => props,
2320
+ classNameMap: {},
2321
+ variantKeys: badgeVariantKeys,
2322
+ variantMap: {
2323
+ "size": [
2324
+ "sm",
2325
+ "md",
2326
+ "lg"
2327
+ ],
2328
+ "standalone": [
2329
+ "true",
2330
+ "false"
2331
+ ],
2332
+ "dot": [
2333
+ "true",
2334
+ "false"
2335
+ ],
2336
+ "variant": [
2337
+ "neutral",
2338
+ "subtle",
2339
+ "bold",
2340
+ "inverse",
2341
+ "success",
2342
+ "warning",
2343
+ "danger",
2344
+ "info"
2345
+ ]
2346
+ },
2347
+ splitVariantProps(props) {
2348
+ return splitProps$1(props, badgeVariantKeys);
2349
+ },
2350
+ getVariantProps: getVariantProps$2
2351
+ });
2352
+ const chipDefaultVariants = {
2353
+ "size": "md"
2354
+ };
2355
+ const chipCompoundVariants = [
2356
+ {
2357
+ "size": "md",
2358
+ "before": true,
2359
+ "css": {
2360
+ "container": {
2361
+ "ps": "2"
2362
+ }
2363
+ }
2364
+ },
2365
+ {
2366
+ "size": "md",
2367
+ "after": true,
2368
+ "css": {
2369
+ "container": {
2370
+ "pe": "2"
2371
+ }
2372
+ }
2373
+ },
2374
+ {
2375
+ "size": "sm",
2376
+ "before": true,
2377
+ "css": {
2378
+ "container": {
2379
+ "ps": "2"
2380
+ }
2381
+ }
2382
+ },
2383
+ {
2384
+ "size": "sm",
2385
+ "after": true,
2386
+ "css": {
2387
+ "container": {
2388
+ "pe": "2"
2389
+ }
2390
+ }
2391
+ },
2392
+ {
2393
+ "size": "lg",
2394
+ "before": true,
2395
+ "css": {
2396
+ "container": {
2397
+ "ps": "4"
2398
+ }
2399
+ }
2400
+ },
2401
+ {
2402
+ "size": "lg",
2403
+ "after": true,
2404
+ "css": {
2405
+ "container": {
2406
+ "pe": "4"
2407
+ }
2408
+ }
2409
+ }
2410
+ ];
2411
+ const chipSlotNames = [
2412
+ [
2413
+ "container",
2414
+ "chip__container"
2415
+ ],
2416
+ [
2417
+ "icon",
2418
+ "chip__icon"
2419
+ ]
2420
+ ];
2421
+ const chipSlotFns = /* @__PURE__ */ chipSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, chipDefaultVariants, getSlotCompoundVariant(chipCompoundVariants, slotName))]);
2422
+ const chipFn = memo((props = {}) => {
2423
+ return Object.fromEntries(chipSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
2424
+ });
2425
+ const chipVariantKeys = [
2426
+ "size",
2427
+ "before",
2428
+ "after"
2429
+ ];
2430
+ const getVariantProps$1 = (variants) => ({ ...chipDefaultVariants, ...compact(variants) });
2431
+ const chip = /* @__PURE__ */ Object.assign(chipFn, {
2432
+ __recipe__: false,
2433
+ __name__: "chip",
2434
+ raw: (props) => props,
2435
+ classNameMap: {},
2436
+ variantKeys: chipVariantKeys,
2437
+ variantMap: {
2438
+ "size": [
2439
+ "md",
2440
+ "sm",
2441
+ "lg"
2442
+ ],
2443
+ "before": [
2444
+ "true"
2445
+ ],
2446
+ "after": [
2447
+ "true"
2448
+ ]
2449
+ },
2450
+ splitVariantProps(props) {
2451
+ return splitProps$1(props, chipVariantKeys);
2452
+ },
2453
+ getVariantProps: getVariantProps$1
2454
+ });
2455
+ const modalDefaultVariants = {
2456
+ "size": "md"
2457
+ };
2458
+ const modalCompoundVariants = [];
2459
+ const modalSlotNames = [
2460
+ [
2461
+ "overlay",
2462
+ "modal__overlay"
2463
+ ],
2464
+ [
2465
+ "container",
2466
+ "modal__container"
2467
+ ],
2468
+ [
2469
+ "header",
2470
+ "modal__header"
2471
+ ],
2472
+ [
2473
+ "title",
2474
+ "modal__title"
2475
+ ],
2476
+ [
2477
+ "closeButton",
2478
+ "modal__closeButton"
2479
+ ],
2480
+ [
2481
+ "body",
2482
+ "modal__body"
2483
+ ],
2484
+ [
2485
+ "footer",
2486
+ "modal__footer"
2487
+ ]
2488
+ ];
2489
+ const modalSlotFns = /* @__PURE__ */ modalSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, modalDefaultVariants, getSlotCompoundVariant(modalCompoundVariants, slotName))]);
2490
+ const modalFn = memo((props = {}) => {
2491
+ return Object.fromEntries(modalSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
2492
+ });
2493
+ const modalVariantKeys = [
2494
+ "size"
2495
+ ];
2496
+ const getVariantProps = (variants) => ({ ...modalDefaultVariants, ...compact(variants) });
2497
+ const modal = /* @__PURE__ */ Object.assign(modalFn, {
2498
+ __recipe__: false,
2499
+ __name__: "modal",
2500
+ raw: (props) => props,
2501
+ classNameMap: {},
2502
+ variantKeys: modalVariantKeys,
2503
+ variantMap: {
2504
+ "size": [
2505
+ "sm",
2506
+ "md",
2507
+ "lg",
2508
+ "xl",
2509
+ "full",
2510
+ "mobile"
2511
+ ]
2512
+ },
2513
+ splitVariantProps(props) {
2514
+ return splitProps$1(props, modalVariantKeys);
2515
+ },
2190
2516
  getVariantProps
2191
2517
  });
2192
2518
  var userGeneratedStr = "css,pos,insetX,insetY,insetEnd,end,insetStart,start,flexDir,p,pl,pr,pt,pb,py,paddingY,paddingX,px,pe,paddingEnd,ps,paddingStart,ml,mr,mt,mb,m,my,marginY,mx,marginX,me,marginEnd,ms,marginStart,ringWidth,ringColor,ring,ringOffset,w,minW,maxW,h,minH,maxH,textShadowColor,bgPosition,bgPositionX,bgPositionY,bgAttachment,bgClip,bg,bgColor,bgOrigin,bgImage,bgRepeat,bgBlendMode,bgSize,bgGradient,bgLinear,bgRadial,bgConic,rounded,roundedTopLeft,roundedTopRight,roundedBottomRight,roundedBottomLeft,roundedTop,roundedRight,roundedBottom,roundedLeft,roundedStartStart,roundedStartEnd,roundedStart,roundedEndStart,roundedEndEnd,roundedEnd,borderX,borderXWidth,borderXColor,borderY,borderYWidth,borderYColor,borderStart,borderStartWidth,borderStartColor,borderEnd,borderEndWidth,borderEndColor,shadow,shadowColor,x,y,z,scrollMarginY,scrollMarginX,scrollPaddingY,scrollPaddingX,fontVariant,aspectRatio,boxDecorationBreak,zIndex,boxSizing,objectPosition,objectFit,overscrollBehavior,overscrollBehaviorX,overscrollBehaviorY,position,top,left,inset,insetInline,insetBlock,insetBlockEnd,insetBlockStart,insetInlineEnd,insetInlineStart,right,bottom,float,visibility,display,hideFrom,hideBelow,flexBasis,flex,flexDirection,flexGrow,flexShrink,gridTemplateColumns,gridTemplateRows,gridColumn,gridRow,gridColumnStart,gridColumnEnd,gridAutoFlow,gridAutoColumns,gridAutoRows,gap,gridGap,gridRowGap,gridColumnGap,rowGap,columnGap,justifyContent,alignContent,alignItems,alignSelf,padding,paddingLeft,paddingRight,paddingTop,paddingBottom,paddingBlock,paddingBlockEnd,paddingBlockStart,paddingInline,paddingInlineEnd,paddingInlineStart,marginLeft,marginRight,marginTop,marginBottom,margin,marginBlock,marginBlockEnd,marginBlockStart,marginInline,marginInlineEnd,marginInlineStart,spaceX,spaceY,outlineWidth,outlineColor,outline,outlineOffset,focusRing,focusVisibleRing,focusRingColor,focusRingOffset,focusRingWidth,focusRingStyle,divideX,divideY,divideColor,divideStyle,width,inlineSize,minWidth,minInlineSize,maxWidth,maxInlineSize,height,blockSize,minHeight,minBlockSize,maxHeight,maxBlockSize,boxSize,color,fontFamily,fontSize,fontSizeAdjust,fontPalette,fontKerning,fontFeatureSettings,fontWeight,fontSmoothing,fontVariantAlternates,fontVariantCaps,fontVariationSettings,fontVariantNumeric,letterSpacing,lineHeight,textAlign,textDecoration,textDecorationColor,textEmphasisColor,textDecorationStyle,textDecorationThickness,textUnderlineOffset,textTransform,textIndent,textShadow,WebkitTextFillColor,textOverflow,verticalAlign,wordBreak,textWrap,truncate,lineClamp,listStyleType,listStylePosition,listStyleImage,listStyle,backgroundPosition,backgroundPositionX,backgroundPositionY,backgroundAttachment,backgroundClip,background,backgroundColor,backgroundOrigin,backgroundImage,backgroundRepeat,backgroundBlendMode,backgroundSize,backgroundGradient,backgroundLinear,backgroundRadial,backgroundConic,textGradient,gradientFromPosition,gradientToPosition,gradientFrom,gradientTo,gradientVia,gradientViaPosition,borderRadius,borderTopLeftRadius,borderTopRightRadius,borderBottomRightRadius,borderBottomLeftRadius,borderTopRadius,borderRightRadius,borderBottomRadius,borderLeftRadius,borderStartStartRadius,borderStartEndRadius,borderStartRadius,borderEndStartRadius,borderEndEndRadius,borderEndRadius,border,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,borderBlockStartWidth,borderBlockEndWidth,borderColor,borderInline,borderInlineWidth,borderInlineColor,borderBlock,borderBlockWidth,borderBlockColor,borderLeft,borderLeftColor,borderInlineStart,borderInlineStartWidth,borderInlineStartColor,borderRight,borderRightColor,borderInlineEnd,borderInlineEndWidth,borderInlineEndColor,borderTop,borderTopColor,borderBottom,borderBottomColor,borderBlockEnd,borderBlockEndColor,borderBlockStart,borderBlockStartColor,opacity,boxShadow,boxShadowColor,mixBlendMode,filter,brightness,contrast,grayscale,hueRotate,invert,saturate,sepia,dropShadow,blur,backdropFilter,backdropBlur,backdropBrightness,backdropContrast,backdropGrayscale,backdropHueRotate,backdropInvert,backdropOpacity,backdropSaturate,backdropSepia,borderCollapse,borderSpacing,borderSpacingX,borderSpacingY,tableLayout,transitionTimingFunction,transitionDelay,transitionDuration,transitionProperty,transition,animation,animationName,animationTimingFunction,animationDuration,animationDelay,animationPlayState,animationComposition,animationFillMode,animationDirection,animationIterationCount,animationRange,animationState,animationRangeStart,animationRangeEnd,animationTimeline,transformOrigin,transformBox,transformStyle,transform,rotate,rotateX,rotateY,rotateZ,scale,scaleX,scaleY,translate,translateX,translateY,translateZ,accentColor,caretColor,scrollBehavior,scrollbar,scrollbarColor,scrollbarGutter,scrollbarWidth,scrollMargin,scrollMarginLeft,scrollMarginRight,scrollMarginTop,scrollMarginBottom,scrollMarginBlock,scrollMarginBlockEnd,scrollMarginBlockStart,scrollMarginInline,scrollMarginInlineEnd,scrollMarginInlineStart,scrollPadding,scrollPaddingBlock,scrollPaddingBlockStart,scrollPaddingBlockEnd,scrollPaddingInline,scrollPaddingInlineEnd,scrollPaddingInlineStart,scrollPaddingLeft,scrollPaddingRight,scrollPaddingTop,scrollPaddingBottom,scrollSnapAlign,scrollSnapStop,scrollSnapType,scrollSnapStrictness,scrollSnapMargin,scrollSnapMarginTop,scrollSnapMarginBottom,scrollSnapMarginLeft,scrollSnapMarginRight,scrollSnapCoordinate,scrollSnapDestination,scrollSnapPointsX,scrollSnapPointsY,scrollSnapTypeX,scrollSnapTypeY,scrollTimeline,scrollTimelineAxis,scrollTimelineName,touchAction,userSelect,overflow,overflowWrap,overflowX,overflowY,overflowAnchor,overflowBlock,overflowInline,overflowClipBox,overflowClipMargin,overscrollBehaviorBlock,overscrollBehaviorInline,fill,stroke,strokeWidth,strokeDasharray,strokeDashoffset,strokeLinecap,strokeLinejoin,strokeMiterlimit,strokeOpacity,srOnly,debug,appearance,backfaceVisibility,clipPath,hyphens,mask,maskImage,maskSize,textSizeAdjust,container,containerName,containerType,cursor,fontVariantsProperty,filtersProperty,colorPalette,_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_complete,_incomplete,_dragging,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_grabbed,_underValue,_overValue,_atValue,_default,_optional,_open,_closed,_fullscreen,_loading,_hidden,_current,_currentPage,_currentStep,_today,_unavailable,_rangeStart,_rangeEnd,_now,_topmost,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_icon,_starting,_noscript,_invertedColors,_deleted,_collapsed,_utility,_error,_paused,xs,xsOnly,xsDown,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,xsToSm,xsToMd,xsToLg,xsToXl,xsTo2xl,smToMd,smToLg,smToXl,smTo2xl,mdToLg,mdToXl,mdTo2xl,lgToXl,lgTo2xl,xlTo2xl,@/2xs,@/xs,@/sm,@/md,@/lg,@/xl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,textStyle,layerStyle";
@@ -2206,9 +2532,9 @@ const composeCvaFn = (cvaA, cvaB) => {
2206
2532
  if (cvaA && !cvaB) return cvaA;
2207
2533
  if (!cvaA && cvaB) return cvaB;
2208
2534
  if (cvaA.__cva__ && cvaB.__cva__ || cvaA.__recipe__ && cvaB.__recipe__) return cvaA.merge(cvaB);
2209
- const error = new TypeError("Cannot merge cva with recipe. Please use either cva or recipe.");
2210
- (_a = TypeError.captureStackTrace) == null ? void 0 : _a.call(TypeError, error);
2211
- throw error;
2535
+ const error2 = new TypeError("Cannot merge cva with recipe. Please use either cva or recipe.");
2536
+ (_a = TypeError.captureStackTrace) == null ? void 0 : _a.call(TypeError, error2);
2537
+ throw error2;
2212
2538
  };
2213
2539
  const getDisplayName = (Component) => {
2214
2540
  if (typeof Component === "string") return Component;
@@ -2230,7 +2556,7 @@ function styledFn(Dynamic, configOrCva = {}, options = {}) {
2230
2556
  const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp);
2231
2557
  const __base__ = Dynamic.__base__ || Dynamic;
2232
2558
  const StyledComponent = /* @__PURE__ */ forwardRef(function StyledComponent2(props, ref) {
2233
- const { as: Element = __base__, unstyled, children, ...restProps } = props;
2559
+ const { as: Element2 = __base__, unstyled, children, ...restProps } = props;
2234
2560
  const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps]);
2235
2561
  const [htmlProps2, forwardedProps, variantProps, styleProps, elementProps] = useMemo(() => {
2236
2562
  return splitProps$1(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty);
@@ -2253,7 +2579,7 @@ function styledFn(Dynamic, configOrCva = {}, options = {}) {
2253
2579
  }
2254
2580
  return configOrCva.__recipe__ ? recipeClass() : cvaClass();
2255
2581
  };
2256
- return createElement(Element, {
2582
+ return createElement(Element2, {
2257
2583
  ref,
2258
2584
  ...forwardedProps,
2259
2585
  ...elementProps,
@@ -2966,7 +3292,7 @@ const Label = ({
2966
3292
  };
2967
3293
  const CheckBox = ({
2968
3294
  indeterminate,
2969
- error,
3295
+ error: error2,
2970
3296
  id,
2971
3297
  name,
2972
3298
  checked,
@@ -2977,7 +3303,7 @@ const CheckBox = ({
2977
3303
  Label,
2978
3304
  {
2979
3305
  className: container,
2980
- color: error ? "red.50" : { base: "slate.90", _dark: "slate.0" },
3306
+ color: error2 ? "red.50" : { base: "slate.90", _dark: "slate.0" },
2981
3307
  children: [
2982
3308
  /* @__PURE__ */ jsx(
2983
3309
  Box,
@@ -2990,7 +3316,7 @@ const CheckBox = ({
2990
3316
  "aria-label": name,
2991
3317
  ...props,
2992
3318
  ...indeterminate && { "data-indeterminate": true },
2993
- ...error && { "data-error": true }
3319
+ ...error2 && { "data-error": true }
2994
3320
  }
2995
3321
  ),
2996
3322
  /* @__PURE__ */ jsx(Icon, { className: indicator, name: "checkbox" }),
@@ -3001,13 +3327,13 @@ const CheckBox = ({
3001
3327
  }
3002
3328
  );
3003
3329
  };
3004
- const Radio = ({ id, name, error, ...props }) => {
3330
+ const Radio = ({ id, name, error: error2, ...props }) => {
3005
3331
  const { container, input, indicator } = radio({});
3006
3332
  return /* @__PURE__ */ jsxs(
3007
3333
  Label,
3008
3334
  {
3009
3335
  className: container,
3010
- color: error ? "red.50" : { base: "slate.90", _dark: "slate.0" },
3336
+ color: error2 ? "red.50" : { base: "slate.90", _dark: "slate.0" },
3011
3337
  children: [
3012
3338
  /* @__PURE__ */ jsx(
3013
3339
  Box,
@@ -3019,7 +3345,7 @@ const Radio = ({ id, name, error, ...props }) => {
3019
3345
  "aria-label": name,
3020
3346
  className: input,
3021
3347
  ...props,
3022
- ...error && { "data-error": true }
3348
+ ...error2 && { "data-error": true }
3023
3349
  }
3024
3350
  ),
3025
3351
  /* @__PURE__ */ jsx(Icon, { className: indicator, name: "radio" }),
@@ -3031,7 +3357,7 @@ const Radio = ({ id, name, error, ...props }) => {
3031
3357
  };
3032
3358
  const TextInput = ({
3033
3359
  size,
3034
- error,
3360
+ error: error2,
3035
3361
  autoSize = false,
3036
3362
  id,
3037
3363
  name,
@@ -3046,9 +3372,9 @@ const TextInput = ({
3046
3372
  id,
3047
3373
  name,
3048
3374
  "aria-label": name,
3049
- "aria-invalid": error || void 0,
3375
+ "aria-invalid": error2 || void 0,
3050
3376
  "aria-describedby": ariaDescribedBy,
3051
- ...error && { "data-error": true },
3377
+ ...error2 && { "data-error": true },
3052
3378
  className: cx(textinput({ size, autoSize }), className),
3053
3379
  ...otherProps
3054
3380
  }
@@ -3056,7 +3382,7 @@ const TextInput = ({
3056
3382
  };
3057
3383
  const Textarea = ({
3058
3384
  size,
3059
- error,
3385
+ error: error2,
3060
3386
  autoSize = false,
3061
3387
  id,
3062
3388
  name,
@@ -3070,7 +3396,7 @@ const Textarea = ({
3070
3396
  as: "textarea",
3071
3397
  id,
3072
3398
  name,
3073
- ...error && { "data-error": true },
3399
+ ...error2 && { "data-error": true },
3074
3400
  "aria-disabled": disabled,
3075
3401
  className: cx(
3076
3402
  textarea({ size, autoSize }),
@@ -3119,7 +3445,7 @@ const Card = (props) => {
3119
3445
  const Toggle = ({
3120
3446
  name,
3121
3447
  id,
3122
- error,
3448
+ error: error2,
3123
3449
  disabled,
3124
3450
  checked,
3125
3451
  ...props
@@ -3142,7 +3468,7 @@ const Toggle = ({
3142
3468
  "aria-label": name,
3143
3469
  className: input,
3144
3470
  ...checked ? { "data-checked": true } : {},
3145
- ...error ? { "data-error": true } : {},
3471
+ ...error2 ? { "data-error": true } : {},
3146
3472
  ...props
3147
3473
  }
3148
3474
  ),
@@ -3163,7 +3489,7 @@ const ToggleInput = ({
3163
3489
  name,
3164
3490
  id,
3165
3491
  children,
3166
- error,
3492
+ error: error2,
3167
3493
  ...props
3168
3494
  }) => {
3169
3495
  const [className, otherProps] = splitProps(props);
@@ -3179,7 +3505,7 @@ const ToggleInput = ({
3179
3505
  {
3180
3506
  id,
3181
3507
  name,
3182
- ...error && { "data-error": true },
3508
+ ...error2 && { "data-error": true },
3183
3509
  ...props
3184
3510
  }
3185
3511
  ),
@@ -3193,7 +3519,7 @@ const RadioInput = ({
3193
3519
  name,
3194
3520
  variant,
3195
3521
  children,
3196
- error,
3522
+ error: error2,
3197
3523
  ...props
3198
3524
  }) => {
3199
3525
  const [className, otherProps] = splitProps(props);
@@ -3209,7 +3535,7 @@ const RadioInput = ({
3209
3535
  {
3210
3536
  name,
3211
3537
  id,
3212
- ...error && { "data-error": true },
3538
+ ...error2 && { "data-error": true },
3213
3539
  ...props
3214
3540
  }
3215
3541
  ),
@@ -3223,7 +3549,7 @@ const CheckBoxInput = ({
3223
3549
  name,
3224
3550
  variant,
3225
3551
  children,
3226
- error,
3552
+ error: error2,
3227
3553
  indeterminate,
3228
3554
  ...props
3229
3555
  }) => {
@@ -3239,8 +3565,8 @@ const CheckBoxInput = ({
3239
3565
  {
3240
3566
  id,
3241
3567
  name,
3242
- error,
3243
- ...error && { "data-error": true },
3568
+ error: error2,
3569
+ ...error2 && { "data-error": true },
3244
3570
  ...indeterminate && { "data-indeterminate": true },
3245
3571
  ...props
3246
3572
  }
@@ -3328,9 +3654,9 @@ const Tooltip = ({
3328
3654
  const resolvedPlacement = typeof position === "string" ? position : "bottom";
3329
3655
  const clockWisePlacement = ["bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "top", "top-start", "top-end", "right", "right-start", "right-end"];
3330
3656
  function getClockwise(start) {
3331
- const index = clockWisePlacement.indexOf(start);
3332
- if (index === -1) return clockWisePlacement;
3333
- const reordered = [...clockWisePlacement.slice(index + 1), ...clockWisePlacement.slice(0, index)];
3657
+ const index2 = clockWisePlacement.indexOf(start);
3658
+ if (index2 === -1) return clockWisePlacement;
3659
+ const reordered = [...clockWisePlacement.slice(index2 + 1), ...clockWisePlacement.slice(0, index2)];
3334
3660
  return reordered;
3335
3661
  }
3336
3662
  const checkPosition = () => {
@@ -3512,9 +3838,9 @@ const Breadcrumbs = ({
3512
3838
  ...props
3513
3839
  }) => {
3514
3840
  const [className, otherProps] = splitProps(props);
3515
- return /* @__PURE__ */ jsx(Text, { as: "ul", className: cx(breadcrumbs({}), className), ...otherProps, children: items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ jsxs(Text, { as: "li", children: [
3841
+ return /* @__PURE__ */ jsx(Text, { as: "ul", className: cx(breadcrumbs({}), className), ...otherProps, children: items == null ? void 0 : items.map((item, index2) => /* @__PURE__ */ jsxs(Text, { as: "li", children: [
3516
3842
  item.href ? /* @__PURE__ */ jsx(Link, { family: "mono", size: "14", href: item.href, children: item.label }) : /* @__PURE__ */ jsx(Text, { weight: "bold", family: "mono", size: "14", children: item.label }),
3517
- index < (items == null ? void 0 : items.length) - 1 && /* @__PURE__ */ jsx(Text, { as: "span", family: "mono", size: "14", children: "/" })
3843
+ index2 < (items == null ? void 0 : items.length) - 1 && /* @__PURE__ */ jsx(Text, { as: "span", family: "mono", size: "14", children: "/" })
3518
3844
  ] }, item.id)) });
3519
3845
  };
3520
3846
  const Tag = ({
@@ -3760,7 +4086,7 @@ const FormField = ({
3760
4086
  helpText,
3761
4087
  required,
3762
4088
  infoTooltip,
3763
- error,
4089
+ error: error2,
3764
4090
  errorText,
3765
4091
  disabled,
3766
4092
  tooltip: tooltip2,
@@ -3773,11 +4099,11 @@ const FormField = ({
3773
4099
  const { formFieldContainer, contentWrapper, labelWrapper, headLabel } = formField({
3774
4100
  layout: layout === "inline" ? "inline" : "default"
3775
4101
  });
3776
- const enhancedChildren = React.Children.map(children, (child) => {
3777
- if (React.isValidElement(child)) {
4102
+ const enhancedChildren = React__default.Children.map(children, (child) => {
4103
+ if (React__default.isValidElement(child)) {
3778
4104
  const c = child;
3779
- return React.cloneElement(c, {
3780
- error: error ?? c.props.error
4105
+ return React__default.cloneElement(c, {
4106
+ error: error2 ?? c.props.error
3781
4107
  // disabled: disabled ?? c.props.disabled,
3782
4108
  });
3783
4109
  }
@@ -3806,17 +4132,3469 @@ const FormField = ({
3806
4132
  /* @__PURE__ */ jsxs(Box, { className: contentWrapper, children: [
3807
4133
  enhancedChildren,
3808
4134
  layout === "inline" && /* @__PURE__ */ jsx(Text, { textStyle: "body.sm", children: helpText }),
3809
- error && /* @__PURE__ */ jsx(Text, { as: "span", textStyle: "body.xs", color: "error.default", children: errorText })
4135
+ error2 && /* @__PURE__ */ jsx(Text, { as: "span", textStyle: "body.xs", color: "error.default", children: errorText })
3810
4136
  ] })
3811
4137
  ] });
3812
4138
  };
4139
+ const presenceStyles = {
4140
+ online: css({ bg: "bg.success.bold" }),
4141
+ busy: css({ bg: "bg.danger.bold" }),
4142
+ offline: css({ bg: "bg.accent.neutral" }),
4143
+ focus: css({ bg: "bg.neutral.bold" })
4144
+ };
4145
+ const statusStyles = {
4146
+ approved: css({ bg: "bg.success.bold", fill: "icon.inverse" }),
4147
+ declined: css({ bg: "bg.danger.bold", fill: "icon.inverse" }),
4148
+ locked: css({ bg: "bg.neutral.bold", fill: "icon.inverse" })
4149
+ };
4150
+ const sizeToStatusIconSize = {
4151
+ xs: "8",
4152
+ sm: "10",
4153
+ md: "12",
4154
+ lg: "14",
4155
+ xl: "16",
4156
+ "2xl": "20"
4157
+ };
4158
+ function getInitials(name) {
4159
+ const parts = name.trim().split(/\s+/);
4160
+ if (parts.length === 0 || !parts[0]) {
4161
+ return "";
4162
+ }
4163
+ if (parts.length === 1) {
4164
+ return parts[0].charAt(0);
4165
+ }
4166
+ const lastPart = parts[parts.length - 1];
4167
+ return parts[0].charAt(0) + (lastPart ? lastPart.charAt(0) : "");
4168
+ }
4169
+ const Avatar = (props) => {
4170
+ const {
4171
+ src,
4172
+ alt = "",
4173
+ name,
4174
+ size = "md",
4175
+ shape = "circle",
4176
+ presence,
4177
+ status,
4178
+ fallback,
4179
+ borderColor,
4180
+ ref,
4181
+ ...rest
4182
+ } = props;
4183
+ const [className, otherProps] = splitProps(rest);
4184
+ const [imageError, setImageError] = useState(false);
4185
+ const [imageLoaded, setImageLoaded] = useState(false);
4186
+ useEffect(() => {
4187
+ setImageError(false);
4188
+ setImageLoaded(false);
4189
+ }, [src]);
4190
+ const safeSize = size;
4191
+ const classes = avatar({ size: safeSize, shape });
4192
+ const showImage = src && !imageError;
4193
+ const initials = name ? getInitials(name) : null;
4194
+ const iconSize = sizeToStatusIconSize[safeSize];
4195
+ return /* @__PURE__ */ jsxs(
4196
+ Box,
4197
+ {
4198
+ as: "span",
4199
+ ref,
4200
+ className: cx(classes.root, className),
4201
+ style: borderColor ? { borderColor } : void 0,
4202
+ ...otherProps,
4203
+ children: [
4204
+ showImage && /* @__PURE__ */ jsx(
4205
+ Box,
4206
+ {
4207
+ as: "img",
4208
+ src,
4209
+ alt,
4210
+ className: classes.image,
4211
+ onError: () => setImageError(true),
4212
+ onLoad: () => setImageLoaded(true),
4213
+ style: { opacity: imageLoaded ? 1 : 0 }
4214
+ }
4215
+ ),
4216
+ (!showImage || !imageLoaded) && /* @__PURE__ */ jsx(Box, { as: "span", className: classes.fallback, children: fallback || initials || /* @__PURE__ */ jsx(Icon, { name: "user" }) }),
4217
+ presence && /* @__PURE__ */ jsx(
4218
+ Box,
4219
+ {
4220
+ as: "span",
4221
+ className: cx(
4222
+ classes.presence,
4223
+ presenceStyles[presence]
4224
+ )
4225
+ }
4226
+ ),
4227
+ status && /* @__PURE__ */ jsxs(
4228
+ Box,
4229
+ {
4230
+ as: "span",
4231
+ className: cx(classes.status, statusStyles[status]),
4232
+ children: [
4233
+ status === "approved" && /* @__PURE__ */ jsx(Icon, { name: "check", size: iconSize }),
4234
+ status === "declined" && /* @__PURE__ */ jsx(Icon, { name: "x", size: iconSize }),
4235
+ status === "locked" && /* @__PURE__ */ jsx(Icon, { name: "lock", size: iconSize })
4236
+ ]
4237
+ }
4238
+ )
4239
+ ]
4240
+ }
4241
+ );
4242
+ };
4243
+ Avatar.displayName = "Avatar";
4244
+ function hasWindow() {
4245
+ return typeof window !== "undefined";
4246
+ }
4247
+ function getNodeName(node) {
4248
+ if (isNode(node)) {
4249
+ return (node.nodeName || "").toLowerCase();
4250
+ }
4251
+ return "#document";
4252
+ }
4253
+ function getWindow(node) {
4254
+ var _node$ownerDocument;
4255
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
4256
+ }
4257
+ function getDocumentElement(node) {
4258
+ var _ref;
4259
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
4260
+ }
4261
+ function isNode(value) {
4262
+ if (!hasWindow()) {
4263
+ return false;
4264
+ }
4265
+ return value instanceof Node || value instanceof getWindow(value).Node;
4266
+ }
4267
+ function isElement(value) {
4268
+ if (!hasWindow()) {
4269
+ return false;
4270
+ }
4271
+ return value instanceof Element || value instanceof getWindow(value).Element;
4272
+ }
4273
+ function isHTMLElement(value) {
4274
+ if (!hasWindow()) {
4275
+ return false;
4276
+ }
4277
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
4278
+ }
4279
+ function isShadowRoot(value) {
4280
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
4281
+ return false;
4282
+ }
4283
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
4284
+ }
4285
+ const invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
4286
+ function isOverflowElement(element) {
4287
+ const {
4288
+ overflow,
4289
+ overflowX,
4290
+ overflowY,
4291
+ display
4292
+ } = getComputedStyle$1(element);
4293
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
4294
+ }
4295
+ const tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
4296
+ function isTableElement(element) {
4297
+ return tableElements.has(getNodeName(element));
4298
+ }
4299
+ const topLayerSelectors = [":popover-open", ":modal"];
4300
+ function isTopLayer(element) {
4301
+ return topLayerSelectors.some((selector) => {
4302
+ try {
4303
+ return element.matches(selector);
4304
+ } catch (_e) {
4305
+ return false;
4306
+ }
4307
+ });
4308
+ }
4309
+ const transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
4310
+ const willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
4311
+ const containValues = ["paint", "layout", "strict", "content"];
4312
+ function isContainingBlock(elementOrCss) {
4313
+ const webkit = isWebKit();
4314
+ const css2 = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
4315
+ return transformProperties.some((value) => css2[value] ? css2[value] !== "none" : false) || (css2.containerType ? css2.containerType !== "normal" : false) || !webkit && (css2.backdropFilter ? css2.backdropFilter !== "none" : false) || !webkit && (css2.filter ? css2.filter !== "none" : false) || willChangeValues.some((value) => (css2.willChange || "").includes(value)) || containValues.some((value) => (css2.contain || "").includes(value));
4316
+ }
4317
+ function getContainingBlock(element) {
4318
+ let currentNode = getParentNode(element);
4319
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
4320
+ if (isContainingBlock(currentNode)) {
4321
+ return currentNode;
4322
+ } else if (isTopLayer(currentNode)) {
4323
+ return null;
4324
+ }
4325
+ currentNode = getParentNode(currentNode);
4326
+ }
4327
+ return null;
4328
+ }
4329
+ function isWebKit() {
4330
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
4331
+ return CSS.supports("-webkit-backdrop-filter", "none");
4332
+ }
4333
+ const lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
4334
+ function isLastTraversableNode(node) {
4335
+ return lastTraversableNodeNames.has(getNodeName(node));
4336
+ }
4337
+ function getComputedStyle$1(element) {
4338
+ return getWindow(element).getComputedStyle(element);
4339
+ }
4340
+ function getNodeScroll(element) {
4341
+ if (isElement(element)) {
4342
+ return {
4343
+ scrollLeft: element.scrollLeft,
4344
+ scrollTop: element.scrollTop
4345
+ };
4346
+ }
4347
+ return {
4348
+ scrollLeft: element.scrollX,
4349
+ scrollTop: element.scrollY
4350
+ };
4351
+ }
4352
+ function getParentNode(node) {
4353
+ if (getNodeName(node) === "html") {
4354
+ return node;
4355
+ }
4356
+ const result = (
4357
+ // Step into the shadow DOM of the parent of a slotted node.
4358
+ node.assignedSlot || // DOM Element detected.
4359
+ node.parentNode || // ShadowRoot detected.
4360
+ isShadowRoot(node) && node.host || // Fallback.
4361
+ getDocumentElement(node)
4362
+ );
4363
+ return isShadowRoot(result) ? result.host : result;
4364
+ }
4365
+ function getNearestOverflowAncestor(node) {
4366
+ const parentNode = getParentNode(node);
4367
+ if (isLastTraversableNode(parentNode)) {
4368
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
4369
+ }
4370
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
4371
+ return parentNode;
4372
+ }
4373
+ return getNearestOverflowAncestor(parentNode);
4374
+ }
4375
+ function getOverflowAncestors(node, list, traverseIframes) {
4376
+ var _node$ownerDocument2;
4377
+ if (list === void 0) {
4378
+ list = [];
4379
+ }
4380
+ if (traverseIframes === void 0) {
4381
+ traverseIframes = true;
4382
+ }
4383
+ const scrollableAncestor = getNearestOverflowAncestor(node);
4384
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
4385
+ const win = getWindow(scrollableAncestor);
4386
+ if (isBody) {
4387
+ const frameElement = getFrameElement(win);
4388
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
4389
+ }
4390
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
4391
+ }
4392
+ function getFrameElement(win) {
4393
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
4394
+ }
4395
+ const min = Math.min;
4396
+ const max = Math.max;
4397
+ const round = Math.round;
4398
+ const createCoords = (v) => ({
4399
+ x: v,
4400
+ y: v
4401
+ });
4402
+ function evaluate(value, param) {
4403
+ return typeof value === "function" ? value(param) : value;
4404
+ }
4405
+ function getSide(placement) {
4406
+ return placement.split("-")[0];
4407
+ }
4408
+ function getAlignment(placement) {
4409
+ return placement.split("-")[1];
4410
+ }
4411
+ function getOppositeAxis(axis) {
4412
+ return axis === "x" ? "y" : "x";
4413
+ }
4414
+ function getAxisLength(axis) {
4415
+ return axis === "y" ? "height" : "width";
4416
+ }
4417
+ const yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
4418
+ function getSideAxis(placement) {
4419
+ return yAxisSides.has(getSide(placement)) ? "y" : "x";
4420
+ }
4421
+ function getAlignmentAxis(placement) {
4422
+ return getOppositeAxis(getSideAxis(placement));
4423
+ }
4424
+ function expandPaddingObject(padding) {
4425
+ return {
4426
+ top: 0,
4427
+ right: 0,
4428
+ bottom: 0,
4429
+ left: 0,
4430
+ ...padding
4431
+ };
4432
+ }
4433
+ function getPaddingObject(padding) {
4434
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
4435
+ top: padding,
4436
+ right: padding,
4437
+ bottom: padding,
4438
+ left: padding
4439
+ };
4440
+ }
4441
+ function rectToClientRect(rect) {
4442
+ const {
4443
+ x,
4444
+ y,
4445
+ width,
4446
+ height
4447
+ } = rect;
4448
+ return {
4449
+ width,
4450
+ height,
4451
+ top: y,
4452
+ left: x,
4453
+ right: x + width,
4454
+ bottom: y + height,
4455
+ x,
4456
+ y
4457
+ };
4458
+ }
4459
+ /*!
4460
+ * tabbable 6.4.0
4461
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
4462
+ */
4463
+ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"];
4464
+ var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
4465
+ var NoElement = typeof Element === "undefined";
4466
+ var matches = NoElement ? function() {
4467
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
4468
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
4469
+ var _element$getRootNode;
4470
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
4471
+ } : function(element) {
4472
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
4473
+ };
4474
+ var _isInert = function isInert(node, lookUp) {
4475
+ var _node$getAttribute;
4476
+ if (lookUp === void 0) {
4477
+ lookUp = true;
4478
+ }
4479
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
4480
+ var inert = inertAtt === "" || inertAtt === "true";
4481
+ var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual
4482
+ // lookup upward, in case it is not defined.
4483
+ (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
4484
+ return result;
4485
+ };
4486
+ var isContentEditable = function isContentEditable2(node) {
4487
+ var _node$getAttribute2;
4488
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
4489
+ return attValue === "" || attValue === "true";
4490
+ };
4491
+ var getCandidates = function getCandidates2(el, includeContainer, filter) {
4492
+ if (_isInert(el)) {
4493
+ return [];
4494
+ }
4495
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
4496
+ if (includeContainer && matches.call(el, candidateSelector)) {
4497
+ candidates.unshift(el);
4498
+ }
4499
+ candidates = candidates.filter(filter);
4500
+ return candidates;
4501
+ };
4502
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
4503
+ var candidates = [];
4504
+ var elementsToCheck = Array.from(elements);
4505
+ while (elementsToCheck.length) {
4506
+ var element = elementsToCheck.shift();
4507
+ if (_isInert(element, false)) {
4508
+ continue;
4509
+ }
4510
+ if (element.tagName === "SLOT") {
4511
+ var assigned = element.assignedElements();
4512
+ var content = assigned.length ? assigned : element.children;
4513
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
4514
+ if (options.flatten) {
4515
+ candidates.push.apply(candidates, nestedCandidates);
4516
+ } else {
4517
+ candidates.push({
4518
+ scopeParent: element,
4519
+ candidates: nestedCandidates
4520
+ });
4521
+ }
4522
+ } else {
4523
+ var validCandidate = matches.call(element, candidateSelector);
4524
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
4525
+ candidates.push(element);
4526
+ }
4527
+ var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
4528
+ typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
4529
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
4530
+ if (shadowRoot && validShadowRoot) {
4531
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
4532
+ if (options.flatten) {
4533
+ candidates.push.apply(candidates, _nestedCandidates);
4534
+ } else {
4535
+ candidates.push({
4536
+ scopeParent: element,
4537
+ candidates: _nestedCandidates
4538
+ });
4539
+ }
4540
+ } else {
4541
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
4542
+ }
4543
+ }
4544
+ }
4545
+ return candidates;
4546
+ };
4547
+ var hasTabIndex = function hasTabIndex2(node) {
4548
+ return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
4549
+ };
4550
+ var getTabIndex = function getTabIndex2(node) {
4551
+ if (!node) {
4552
+ throw new Error("No node provided");
4553
+ }
4554
+ if (node.tabIndex < 0) {
4555
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
4556
+ return 0;
4557
+ }
4558
+ }
4559
+ return node.tabIndex;
4560
+ };
4561
+ var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
4562
+ var tabIndex = getTabIndex(node);
4563
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
4564
+ return 0;
4565
+ }
4566
+ return tabIndex;
4567
+ };
4568
+ var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
4569
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
4570
+ };
4571
+ var isInput = function isInput2(node) {
4572
+ return node.tagName === "INPUT";
4573
+ };
4574
+ var isHiddenInput = function isHiddenInput2(node) {
4575
+ return isInput(node) && node.type === "hidden";
4576
+ };
4577
+ var isDetailsWithSummary = function isDetailsWithSummary2(node) {
4578
+ var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
4579
+ return child.tagName === "SUMMARY";
4580
+ });
4581
+ return r;
4582
+ };
4583
+ var getCheckedRadio = function getCheckedRadio2(nodes, form) {
4584
+ for (var i = 0; i < nodes.length; i++) {
4585
+ if (nodes[i].checked && nodes[i].form === form) {
4586
+ return nodes[i];
4587
+ }
4588
+ }
4589
+ };
4590
+ var isTabbableRadio = function isTabbableRadio2(node) {
4591
+ if (!node.name) {
4592
+ return true;
4593
+ }
4594
+ var radioScope = node.form || getRootNode(node);
4595
+ var queryRadios = function queryRadios2(name) {
4596
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
4597
+ };
4598
+ var radioSet;
4599
+ if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
4600
+ radioSet = queryRadios(window.CSS.escape(node.name));
4601
+ } else {
4602
+ try {
4603
+ radioSet = queryRadios(node.name);
4604
+ } catch (err) {
4605
+ console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
4606
+ return false;
4607
+ }
4608
+ }
4609
+ var checked = getCheckedRadio(radioSet, node.form);
4610
+ return !checked || checked === node;
4611
+ };
4612
+ var isRadio = function isRadio2(node) {
4613
+ return isInput(node) && node.type === "radio";
4614
+ };
4615
+ var isNonTabbableRadio = function isNonTabbableRadio2(node) {
4616
+ return isRadio(node) && !isTabbableRadio(node);
4617
+ };
4618
+ var isNodeAttached = function isNodeAttached2(node) {
4619
+ var _nodeRoot;
4620
+ var nodeRoot = node && getRootNode(node);
4621
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
4622
+ var attached = false;
4623
+ if (nodeRoot && nodeRoot !== node) {
4624
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
4625
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
4626
+ while (!attached && nodeRootHost) {
4627
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
4628
+ nodeRoot = getRootNode(nodeRootHost);
4629
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
4630
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
4631
+ }
4632
+ }
4633
+ return attached;
4634
+ };
4635
+ var isZeroArea = function isZeroArea2(node) {
4636
+ var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
4637
+ return width === 0 && height === 0;
4638
+ };
4639
+ var isHidden = function isHidden2(node, _ref) {
4640
+ var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
4641
+ if (displayCheck === "full-native") {
4642
+ if ("checkVisibility" in node) {
4643
+ var visible = node.checkVisibility({
4644
+ // Checking opacity might be desirable for some use cases, but natively,
4645
+ // opacity zero elements _are_ focusable and tabbable.
4646
+ checkOpacity: false,
4647
+ opacityProperty: false,
4648
+ contentVisibilityAuto: true,
4649
+ visibilityProperty: true,
4650
+ // This is an alias for `visibilityProperty`. Contemporary browsers
4651
+ // support both. However, this alias has wider browser support (Chrome
4652
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
4653
+ // we include it anyway.
4654
+ checkVisibilityCSS: true
4655
+ });
4656
+ return !visible;
4657
+ }
4658
+ }
4659
+ if (getComputedStyle(node).visibility === "hidden") {
4660
+ return true;
4661
+ }
4662
+ var isDirectSummary = matches.call(node, "details>summary:first-of-type");
4663
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
4664
+ if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
4665
+ return true;
4666
+ }
4667
+ if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
4668
+ // Element#checkVisibility is unsupported
4669
+ displayCheck === "full-native" || displayCheck === "legacy-full") {
4670
+ if (typeof getShadowRoot === "function") {
4671
+ var originalNode = node;
4672
+ while (node) {
4673
+ var parentElement = node.parentElement;
4674
+ var rootNode = getRootNode(node);
4675
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
4676
+ return isZeroArea(node);
4677
+ } else if (node.assignedSlot) {
4678
+ node = node.assignedSlot;
4679
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
4680
+ node = rootNode.host;
4681
+ } else {
4682
+ node = parentElement;
4683
+ }
4684
+ }
4685
+ node = originalNode;
4686
+ }
4687
+ if (isNodeAttached(node)) {
4688
+ return !node.getClientRects().length;
4689
+ }
4690
+ if (displayCheck !== "legacy-full") {
4691
+ return true;
4692
+ }
4693
+ } else if (displayCheck === "non-zero-area") {
4694
+ return isZeroArea(node);
4695
+ }
4696
+ return false;
4697
+ };
4698
+ var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
4699
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
4700
+ var parentNode = node.parentElement;
4701
+ while (parentNode) {
4702
+ if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
4703
+ for (var i = 0; i < parentNode.children.length; i++) {
4704
+ var child = parentNode.children.item(i);
4705
+ if (child.tagName === "LEGEND") {
4706
+ return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
4707
+ }
4708
+ }
4709
+ return true;
4710
+ }
4711
+ parentNode = parentNode.parentElement;
4712
+ }
4713
+ }
4714
+ return false;
4715
+ };
4716
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
4717
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
4718
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
4719
+ return false;
4720
+ }
4721
+ return true;
4722
+ };
4723
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
4724
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
4725
+ return false;
4726
+ }
4727
+ return true;
4728
+ };
4729
+ var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
4730
+ var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
4731
+ if (isNaN(tabIndex) || tabIndex >= 0) {
4732
+ return true;
4733
+ }
4734
+ return false;
4735
+ };
4736
+ var _sortByOrder = function sortByOrder(candidates) {
4737
+ var regularTabbables = [];
4738
+ var orderedTabbables = [];
4739
+ candidates.forEach(function(item, i) {
4740
+ var isScope = !!item.scopeParent;
4741
+ var element = isScope ? item.scopeParent : item;
4742
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
4743
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
4744
+ if (candidateTabindex === 0) {
4745
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
4746
+ } else {
4747
+ orderedTabbables.push({
4748
+ documentOrder: i,
4749
+ tabIndex: candidateTabindex,
4750
+ item,
4751
+ isScope,
4752
+ content: elements
4753
+ });
4754
+ }
4755
+ });
4756
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
4757
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
4758
+ return acc;
4759
+ }, []).concat(regularTabbables);
4760
+ };
4761
+ var tabbable = function tabbable2(container, options) {
4762
+ options = options || {};
4763
+ var candidates;
4764
+ if (options.getShadowRoot) {
4765
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
4766
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
4767
+ flatten: false,
4768
+ getShadowRoot: options.getShadowRoot,
4769
+ shadowRootFilter: isShadowRootTabbable
4770
+ });
4771
+ } else {
4772
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
4773
+ }
4774
+ return _sortByOrder(candidates);
4775
+ };
4776
+ var focusable = function focusable2(container, options) {
4777
+ options = options || {};
4778
+ var candidates;
4779
+ if (options.getShadowRoot) {
4780
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
4781
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
4782
+ flatten: true,
4783
+ getShadowRoot: options.getShadowRoot
4784
+ });
4785
+ } else {
4786
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
4787
+ }
4788
+ return candidates;
4789
+ };
4790
+ var isTabbable = function isTabbable2(node, options) {
4791
+ options = options || {};
4792
+ if (!node) {
4793
+ throw new Error("No node provided");
4794
+ }
4795
+ if (matches.call(node, candidateSelector) === false) {
4796
+ return false;
4797
+ }
4798
+ return isNodeMatchingSelectorTabbable(options, node);
4799
+ };
4800
+ function getPlatform() {
4801
+ const uaData = navigator.userAgentData;
4802
+ if (uaData != null && uaData.platform) {
4803
+ return uaData.platform;
4804
+ }
4805
+ return navigator.platform;
4806
+ }
4807
+ function getUserAgent() {
4808
+ const uaData = navigator.userAgentData;
4809
+ if (uaData && Array.isArray(uaData.brands)) {
4810
+ return uaData.brands.map((_ref) => {
4811
+ let {
4812
+ brand,
4813
+ version
4814
+ } = _ref;
4815
+ return brand + "/" + version;
4816
+ }).join(" ");
4817
+ }
4818
+ return navigator.userAgent;
4819
+ }
4820
+ function isSafari() {
4821
+ return /apple/i.test(navigator.vendor);
4822
+ }
4823
+ function isAndroid() {
4824
+ const re = /android/i;
4825
+ return re.test(getPlatform()) || re.test(getUserAgent());
4826
+ }
4827
+ function isJSDOM() {
4828
+ return getUserAgent().includes("jsdom/");
4829
+ }
4830
+ const FOCUSABLE_ATTRIBUTE$1 = "data-floating-ui-focusable";
4831
+ const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
4832
+ function activeElement(doc) {
4833
+ let activeElement2 = doc.activeElement;
4834
+ while (((_activeElement = activeElement2) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
4835
+ var _activeElement;
4836
+ activeElement2 = activeElement2.shadowRoot.activeElement;
4837
+ }
4838
+ return activeElement2;
4839
+ }
4840
+ function contains(parent, child) {
4841
+ if (!parent || !child) {
4842
+ return false;
4843
+ }
4844
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
4845
+ if (parent.contains(child)) {
4846
+ return true;
4847
+ }
4848
+ if (rootNode && isShadowRoot(rootNode)) {
4849
+ let next = child;
4850
+ while (next) {
4851
+ if (parent === next) {
4852
+ return true;
4853
+ }
4854
+ next = next.parentNode || next.host;
4855
+ }
4856
+ }
4857
+ return false;
4858
+ }
4859
+ function getTarget(event) {
4860
+ if ("composedPath" in event) {
4861
+ return event.composedPath()[0];
4862
+ }
4863
+ return event.target;
4864
+ }
4865
+ function isEventTargetWithin(event, node) {
4866
+ if (node == null) {
4867
+ return false;
4868
+ }
4869
+ if ("composedPath" in event) {
4870
+ return event.composedPath().includes(node);
4871
+ }
4872
+ const e = event;
4873
+ return e.target != null && node.contains(e.target);
4874
+ }
4875
+ function isRootElement(element) {
4876
+ return element.matches("html,body");
4877
+ }
4878
+ function getDocument$1(node) {
4879
+ return (node == null ? void 0 : node.ownerDocument) || document;
4880
+ }
4881
+ function isTypeableElement(element) {
4882
+ return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
4883
+ }
4884
+ function isTypeableCombobox(element) {
4885
+ if (!element) return false;
4886
+ return element.getAttribute("role") === "combobox" && isTypeableElement(element);
4887
+ }
4888
+ function getFloatingFocusElement(floatingElement) {
4889
+ if (!floatingElement) {
4890
+ return null;
4891
+ }
4892
+ return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE$1) ? floatingElement : floatingElement.querySelector("[" + FOCUSABLE_ATTRIBUTE$1 + "]") || floatingElement;
4893
+ }
4894
+ function getNodeChildren(nodes, id, onlyOpenChildren) {
4895
+ if (onlyOpenChildren === void 0) {
4896
+ onlyOpenChildren = true;
4897
+ }
4898
+ const directChildren = nodes.filter((node) => {
4899
+ var _node$context;
4900
+ return node.parentId === id && (!onlyOpenChildren || ((_node$context = node.context) == null ? void 0 : _node$context.open));
4901
+ });
4902
+ return directChildren.flatMap((child) => [child, ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
4903
+ }
4904
+ function getNodeAncestors(nodes, id) {
4905
+ var _nodes$find;
4906
+ let allAncestors = [];
4907
+ let currentParentId = (_nodes$find = nodes.find((node) => node.id === id)) == null ? void 0 : _nodes$find.parentId;
4908
+ while (currentParentId) {
4909
+ const currentNode = nodes.find((node) => node.id === currentParentId);
4910
+ currentParentId = currentNode == null ? void 0 : currentNode.parentId;
4911
+ if (currentNode) {
4912
+ allAncestors = allAncestors.concat(currentNode);
4913
+ }
4914
+ }
4915
+ return allAncestors;
4916
+ }
4917
+ function stopEvent(event) {
4918
+ event.preventDefault();
4919
+ event.stopPropagation();
4920
+ }
4921
+ function isReactEvent(event) {
4922
+ return "nativeEvent" in event;
4923
+ }
4924
+ function isVirtualClick(event) {
4925
+ if (event.mozInputSource === 0 && event.isTrusted) {
4926
+ return true;
4927
+ }
4928
+ if (isAndroid() && event.pointerType) {
4929
+ return event.type === "click" && event.buttons === 1;
4930
+ }
4931
+ return event.detail === 0 && !event.pointerType;
4932
+ }
4933
+ function isVirtualPointerEvent(event) {
4934
+ if (isJSDOM()) return false;
4935
+ return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
4936
+ event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
4937
+ }
4938
+ var isClient$1 = typeof document !== "undefined";
4939
+ var noop$1 = function noop() {
4940
+ };
4941
+ var index$1 = isClient$1 ? useLayoutEffect : noop$1;
4942
+ const SafeReact$1 = {
4943
+ ...React
4944
+ };
4945
+ function useLatestRef$1(value) {
4946
+ const ref = React.useRef(value);
4947
+ index$1(() => {
4948
+ ref.current = value;
4949
+ });
4950
+ return ref;
4951
+ }
4952
+ const useInsertionEffect = SafeReact$1.useInsertionEffect;
4953
+ const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
4954
+ function useEffectEvent(callback) {
4955
+ const ref = React.useRef(() => {
4956
+ if (process.env.NODE_ENV !== "production") {
4957
+ throw new Error("Cannot call an event handler while rendering.");
4958
+ }
4959
+ });
4960
+ useSafeInsertionEffect(() => {
4961
+ ref.current = callback;
4962
+ });
4963
+ return React.useCallback(function() {
4964
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4965
+ args[_key] = arguments[_key];
4966
+ }
4967
+ return ref.current == null ? void 0 : ref.current(...args);
4968
+ }, []);
4969
+ }
4970
+ const getTabbableOptions = () => ({
4971
+ getShadowRoot: true,
4972
+ displayCheck: (
4973
+ // JSDOM does not support the `tabbable` library. To solve this we can
4974
+ // check if `ResizeObserver` is a real function (not polyfilled), which
4975
+ // determines if the current environment is JSDOM-like.
4976
+ typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
4977
+ )
4978
+ });
4979
+ function getTabbableIn(container, dir) {
4980
+ const list = tabbable(container, getTabbableOptions());
4981
+ const len = list.length;
4982
+ if (len === 0) return;
4983
+ const active = activeElement(getDocument$1(container));
4984
+ const index2 = list.indexOf(active);
4985
+ const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
4986
+ return list[nextIndex];
4987
+ }
4988
+ function getNextTabbable(referenceElement) {
4989
+ return getTabbableIn(getDocument$1(referenceElement).body, 1) || referenceElement;
4990
+ }
4991
+ function getPreviousTabbable(referenceElement) {
4992
+ return getTabbableIn(getDocument$1(referenceElement).body, -1) || referenceElement;
4993
+ }
4994
+ function isOutsideEvent(event, container) {
4995
+ const containerElement = container || event.currentTarget;
4996
+ const relatedTarget = event.relatedTarget;
4997
+ return !relatedTarget || !contains(containerElement, relatedTarget);
4998
+ }
4999
+ function disableFocusInside(container) {
5000
+ const tabbableElements = tabbable(container, getTabbableOptions());
5001
+ tabbableElements.forEach((element) => {
5002
+ element.dataset.tabindex = element.getAttribute("tabindex") || "";
5003
+ element.setAttribute("tabindex", "-1");
5004
+ });
5005
+ }
5006
+ function enableFocusInside(container) {
5007
+ const elements = container.querySelectorAll("[data-tabindex]");
5008
+ elements.forEach((element) => {
5009
+ const tabindex = element.dataset.tabindex;
5010
+ delete element.dataset.tabindex;
5011
+ if (tabindex) {
5012
+ element.setAttribute("tabindex", tabindex);
5013
+ } else {
5014
+ element.removeAttribute("tabindex");
5015
+ }
5016
+ });
5017
+ }
5018
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
5019
+ let {
5020
+ reference,
5021
+ floating
5022
+ } = _ref;
5023
+ const sideAxis = getSideAxis(placement);
5024
+ const alignmentAxis = getAlignmentAxis(placement);
5025
+ const alignLength = getAxisLength(alignmentAxis);
5026
+ const side = getSide(placement);
5027
+ const isVertical = sideAxis === "y";
5028
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
5029
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
5030
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
5031
+ let coords;
5032
+ switch (side) {
5033
+ case "top":
5034
+ coords = {
5035
+ x: commonX,
5036
+ y: reference.y - floating.height
5037
+ };
5038
+ break;
5039
+ case "bottom":
5040
+ coords = {
5041
+ x: commonX,
5042
+ y: reference.y + reference.height
5043
+ };
5044
+ break;
5045
+ case "right":
5046
+ coords = {
5047
+ x: reference.x + reference.width,
5048
+ y: commonY
5049
+ };
5050
+ break;
5051
+ case "left":
5052
+ coords = {
5053
+ x: reference.x - floating.width,
5054
+ y: commonY
5055
+ };
5056
+ break;
5057
+ default:
5058
+ coords = {
5059
+ x: reference.x,
5060
+ y: reference.y
5061
+ };
5062
+ }
5063
+ switch (getAlignment(placement)) {
5064
+ case "start":
5065
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
5066
+ break;
5067
+ case "end":
5068
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
5069
+ break;
5070
+ }
5071
+ return coords;
5072
+ }
5073
+ async function detectOverflow(state, options) {
5074
+ var _await$platform$isEle;
5075
+ if (options === void 0) {
5076
+ options = {};
5077
+ }
5078
+ const {
5079
+ x,
5080
+ y,
5081
+ platform: platform2,
5082
+ rects,
5083
+ elements,
5084
+ strategy
5085
+ } = state;
5086
+ const {
5087
+ boundary = "clippingAncestors",
5088
+ rootBoundary = "viewport",
5089
+ elementContext = "floating",
5090
+ altBoundary = false,
5091
+ padding = 0
5092
+ } = evaluate(options, state);
5093
+ const paddingObject = getPaddingObject(padding);
5094
+ const altContext = elementContext === "floating" ? "reference" : "floating";
5095
+ const element = elements[altBoundary ? altContext : elementContext];
5096
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
5097
+ 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)),
5098
+ boundary,
5099
+ rootBoundary,
5100
+ strategy
5101
+ }));
5102
+ const rect = elementContext === "floating" ? {
5103
+ x,
5104
+ y,
5105
+ width: rects.floating.width,
5106
+ height: rects.floating.height
5107
+ } : rects.reference;
5108
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
5109
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
5110
+ x: 1,
5111
+ y: 1
5112
+ } : {
5113
+ x: 1,
5114
+ y: 1
5115
+ };
5116
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
5117
+ elements,
5118
+ rect,
5119
+ offsetParent,
5120
+ strategy
5121
+ }) : rect);
5122
+ return {
5123
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
5124
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
5125
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
5126
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
5127
+ };
5128
+ }
5129
+ const computePosition$1 = async (reference, floating, config) => {
5130
+ const {
5131
+ placement = "bottom",
5132
+ strategy = "absolute",
5133
+ middleware = [],
5134
+ platform: platform2
5135
+ } = config;
5136
+ const validMiddleware = middleware.filter(Boolean);
5137
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
5138
+ let rects = await platform2.getElementRects({
5139
+ reference,
5140
+ floating,
5141
+ strategy
5142
+ });
5143
+ let {
5144
+ x,
5145
+ y
5146
+ } = computeCoordsFromPlacement(rects, placement, rtl);
5147
+ let statefulPlacement = placement;
5148
+ let middlewareData = {};
5149
+ let resetCount = 0;
5150
+ for (let i = 0; i < validMiddleware.length; i++) {
5151
+ var _platform$detectOverf;
5152
+ const {
5153
+ name,
5154
+ fn
5155
+ } = validMiddleware[i];
5156
+ const {
5157
+ x: nextX,
5158
+ y: nextY,
5159
+ data,
5160
+ reset
5161
+ } = await fn({
5162
+ x,
5163
+ y,
5164
+ initialPlacement: placement,
5165
+ placement: statefulPlacement,
5166
+ strategy,
5167
+ middlewareData,
5168
+ rects,
5169
+ platform: {
5170
+ ...platform2,
5171
+ detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
5172
+ },
5173
+ elements: {
5174
+ reference,
5175
+ floating
5176
+ }
5177
+ });
5178
+ x = nextX != null ? nextX : x;
5179
+ y = nextY != null ? nextY : y;
5180
+ middlewareData = {
5181
+ ...middlewareData,
5182
+ [name]: {
5183
+ ...middlewareData[name],
5184
+ ...data
5185
+ }
5186
+ };
5187
+ if (reset && resetCount <= 50) {
5188
+ resetCount++;
5189
+ if (typeof reset === "object") {
5190
+ if (reset.placement) {
5191
+ statefulPlacement = reset.placement;
5192
+ }
5193
+ if (reset.rects) {
5194
+ rects = reset.rects === true ? await platform2.getElementRects({
5195
+ reference,
5196
+ floating,
5197
+ strategy
5198
+ }) : reset.rects;
5199
+ }
5200
+ ({
5201
+ x,
5202
+ y
5203
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
5204
+ }
5205
+ i = -1;
5206
+ }
5207
+ }
5208
+ return {
5209
+ x,
5210
+ y,
5211
+ placement: statefulPlacement,
5212
+ strategy,
5213
+ middlewareData
5214
+ };
5215
+ };
5216
+ function getCssDimensions(element) {
5217
+ const css2 = getComputedStyle$1(element);
5218
+ let width = parseFloat(css2.width) || 0;
5219
+ let height = parseFloat(css2.height) || 0;
5220
+ const hasOffset = isHTMLElement(element);
5221
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
5222
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
5223
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5224
+ if (shouldFallback) {
5225
+ width = offsetWidth;
5226
+ height = offsetHeight;
5227
+ }
5228
+ return {
5229
+ width,
5230
+ height,
5231
+ $: shouldFallback
5232
+ };
5233
+ }
5234
+ function unwrapElement(element) {
5235
+ return !isElement(element) ? element.contextElement : element;
5236
+ }
5237
+ function getScale(element) {
5238
+ const domElement = unwrapElement(element);
5239
+ if (!isHTMLElement(domElement)) {
5240
+ return createCoords(1);
5241
+ }
5242
+ const rect = domElement.getBoundingClientRect();
5243
+ const {
5244
+ width,
5245
+ height,
5246
+ $
5247
+ } = getCssDimensions(domElement);
5248
+ let x = ($ ? round(rect.width) : rect.width) / width;
5249
+ let y = ($ ? round(rect.height) : rect.height) / height;
5250
+ if (!x || !Number.isFinite(x)) {
5251
+ x = 1;
5252
+ }
5253
+ if (!y || !Number.isFinite(y)) {
5254
+ y = 1;
5255
+ }
5256
+ return {
5257
+ x,
5258
+ y
5259
+ };
5260
+ }
5261
+ const noOffsets = /* @__PURE__ */ createCoords(0);
5262
+ function getVisualOffsets(element) {
5263
+ const win = getWindow(element);
5264
+ if (!isWebKit() || !win.visualViewport) {
5265
+ return noOffsets;
5266
+ }
5267
+ return {
5268
+ x: win.visualViewport.offsetLeft,
5269
+ y: win.visualViewport.offsetTop
5270
+ };
5271
+ }
5272
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5273
+ if (isFixed === void 0) {
5274
+ isFixed = false;
5275
+ }
5276
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5277
+ return false;
5278
+ }
5279
+ return isFixed;
5280
+ }
5281
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5282
+ if (includeScale === void 0) {
5283
+ includeScale = false;
5284
+ }
5285
+ if (isFixedStrategy === void 0) {
5286
+ isFixedStrategy = false;
5287
+ }
5288
+ const clientRect = element.getBoundingClientRect();
5289
+ const domElement = unwrapElement(element);
5290
+ let scale = createCoords(1);
5291
+ if (includeScale) {
5292
+ if (offsetParent) {
5293
+ if (isElement(offsetParent)) {
5294
+ scale = getScale(offsetParent);
5295
+ }
5296
+ } else {
5297
+ scale = getScale(element);
5298
+ }
5299
+ }
5300
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5301
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
5302
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
5303
+ let width = clientRect.width / scale.x;
5304
+ let height = clientRect.height / scale.y;
5305
+ if (domElement) {
5306
+ const win = getWindow(domElement);
5307
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5308
+ let currentWin = win;
5309
+ let currentIFrame = getFrameElement(currentWin);
5310
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5311
+ const iframeScale = getScale(currentIFrame);
5312
+ const iframeRect = currentIFrame.getBoundingClientRect();
5313
+ const css2 = getComputedStyle$1(currentIFrame);
5314
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css2.paddingLeft)) * iframeScale.x;
5315
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css2.paddingTop)) * iframeScale.y;
5316
+ x *= iframeScale.x;
5317
+ y *= iframeScale.y;
5318
+ width *= iframeScale.x;
5319
+ height *= iframeScale.y;
5320
+ x += left;
5321
+ y += top;
5322
+ currentWin = getWindow(currentIFrame);
5323
+ currentIFrame = getFrameElement(currentWin);
5324
+ }
5325
+ }
5326
+ return rectToClientRect({
5327
+ width,
5328
+ height,
5329
+ x,
5330
+ y
5331
+ });
5332
+ }
5333
+ function getWindowScrollBarX(element, rect) {
5334
+ const leftScroll = getNodeScroll(element).scrollLeft;
5335
+ if (!rect) {
5336
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5337
+ }
5338
+ return rect.left + leftScroll;
5339
+ }
5340
+ function getHTMLOffset(documentElement, scroll) {
5341
+ const htmlRect = documentElement.getBoundingClientRect();
5342
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5343
+ const y = htmlRect.top + scroll.scrollTop;
5344
+ return {
5345
+ x,
5346
+ y
5347
+ };
5348
+ }
5349
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5350
+ let {
5351
+ elements,
5352
+ rect,
5353
+ offsetParent,
5354
+ strategy
5355
+ } = _ref;
5356
+ const isFixed = strategy === "fixed";
5357
+ const documentElement = getDocumentElement(offsetParent);
5358
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
5359
+ if (offsetParent === documentElement || topLayer && isFixed) {
5360
+ return rect;
5361
+ }
5362
+ let scroll = {
5363
+ scrollLeft: 0,
5364
+ scrollTop: 0
5365
+ };
5366
+ let scale = createCoords(1);
5367
+ const offsets = createCoords(0);
5368
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5369
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5370
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5371
+ scroll = getNodeScroll(offsetParent);
5372
+ }
5373
+ if (isHTMLElement(offsetParent)) {
5374
+ const offsetRect = getBoundingClientRect(offsetParent);
5375
+ scale = getScale(offsetParent);
5376
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5377
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5378
+ }
5379
+ }
5380
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5381
+ return {
5382
+ width: rect.width * scale.x,
5383
+ height: rect.height * scale.y,
5384
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5385
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5386
+ };
5387
+ }
5388
+ function getClientRects(element) {
5389
+ return Array.from(element.getClientRects());
5390
+ }
5391
+ function getDocumentRect(element) {
5392
+ const html = getDocumentElement(element);
5393
+ const scroll = getNodeScroll(element);
5394
+ const body = element.ownerDocument.body;
5395
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5396
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5397
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
5398
+ const y = -scroll.scrollTop;
5399
+ if (getComputedStyle$1(body).direction === "rtl") {
5400
+ x += max(html.clientWidth, body.clientWidth) - width;
5401
+ }
5402
+ return {
5403
+ width,
5404
+ height,
5405
+ x,
5406
+ y
5407
+ };
5408
+ }
5409
+ const SCROLLBAR_MAX = 25;
5410
+ function getViewportRect(element, strategy) {
5411
+ const win = getWindow(element);
5412
+ const html = getDocumentElement(element);
5413
+ const visualViewport = win.visualViewport;
5414
+ let width = html.clientWidth;
5415
+ let height = html.clientHeight;
5416
+ let x = 0;
5417
+ let y = 0;
5418
+ if (visualViewport) {
5419
+ width = visualViewport.width;
5420
+ height = visualViewport.height;
5421
+ const visualViewportBased = isWebKit();
5422
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5423
+ x = visualViewport.offsetLeft;
5424
+ y = visualViewport.offsetTop;
5425
+ }
5426
+ }
5427
+ const windowScrollbarX = getWindowScrollBarX(html);
5428
+ if (windowScrollbarX <= 0) {
5429
+ const doc = html.ownerDocument;
5430
+ const body = doc.body;
5431
+ const bodyStyles = getComputedStyle(body);
5432
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5433
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5434
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5435
+ width -= clippingStableScrollbarWidth;
5436
+ }
5437
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5438
+ width += windowScrollbarX;
5439
+ }
5440
+ return {
5441
+ width,
5442
+ height,
5443
+ x,
5444
+ y
5445
+ };
5446
+ }
5447
+ const absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
5448
+ function getInnerBoundingClientRect(element, strategy) {
5449
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5450
+ const top = clientRect.top + element.clientTop;
5451
+ const left = clientRect.left + element.clientLeft;
5452
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5453
+ const width = element.clientWidth * scale.x;
5454
+ const height = element.clientHeight * scale.y;
5455
+ const x = left * scale.x;
5456
+ const y = top * scale.y;
5457
+ return {
5458
+ width,
5459
+ height,
5460
+ x,
5461
+ y
5462
+ };
5463
+ }
5464
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5465
+ let rect;
5466
+ if (clippingAncestor === "viewport") {
5467
+ rect = getViewportRect(element, strategy);
5468
+ } else if (clippingAncestor === "document") {
5469
+ rect = getDocumentRect(getDocumentElement(element));
5470
+ } else if (isElement(clippingAncestor)) {
5471
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5472
+ } else {
5473
+ const visualOffsets = getVisualOffsets(element);
5474
+ rect = {
5475
+ x: clippingAncestor.x - visualOffsets.x,
5476
+ y: clippingAncestor.y - visualOffsets.y,
5477
+ width: clippingAncestor.width,
5478
+ height: clippingAncestor.height
5479
+ };
5480
+ }
5481
+ return rectToClientRect(rect);
5482
+ }
5483
+ function hasFixedPositionAncestor(element, stopNode) {
5484
+ const parentNode = getParentNode(element);
5485
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5486
+ return false;
5487
+ }
5488
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5489
+ }
5490
+ function getClippingElementAncestors(element, cache) {
5491
+ const cachedResult = cache.get(element);
5492
+ if (cachedResult) {
5493
+ return cachedResult;
5494
+ }
5495
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5496
+ let currentContainingBlockComputedStyle = null;
5497
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
5498
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
5499
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5500
+ const computedStyle = getComputedStyle$1(currentNode);
5501
+ const currentNodeIsContaining = isContainingBlock(currentNode);
5502
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5503
+ currentContainingBlockComputedStyle = null;
5504
+ }
5505
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5506
+ if (shouldDropCurrentNode) {
5507
+ result = result.filter((ancestor) => ancestor !== currentNode);
5508
+ } else {
5509
+ currentContainingBlockComputedStyle = computedStyle;
5510
+ }
5511
+ currentNode = getParentNode(currentNode);
5512
+ }
5513
+ cache.set(element, result);
5514
+ return result;
5515
+ }
5516
+ function getClippingRect(_ref) {
5517
+ let {
5518
+ element,
5519
+ boundary,
5520
+ rootBoundary,
5521
+ strategy
5522
+ } = _ref;
5523
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5524
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5525
+ const firstClippingAncestor = clippingAncestors[0];
5526
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
5527
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
5528
+ accRect.top = max(rect.top, accRect.top);
5529
+ accRect.right = min(rect.right, accRect.right);
5530
+ accRect.bottom = min(rect.bottom, accRect.bottom);
5531
+ accRect.left = max(rect.left, accRect.left);
5532
+ return accRect;
5533
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
5534
+ return {
5535
+ width: clippingRect.right - clippingRect.left,
5536
+ height: clippingRect.bottom - clippingRect.top,
5537
+ x: clippingRect.left,
5538
+ y: clippingRect.top
5539
+ };
5540
+ }
5541
+ function getDimensions(element) {
5542
+ const {
5543
+ width,
5544
+ height
5545
+ } = getCssDimensions(element);
5546
+ return {
5547
+ width,
5548
+ height
5549
+ };
5550
+ }
5551
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5552
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5553
+ const documentElement = getDocumentElement(offsetParent);
5554
+ const isFixed = strategy === "fixed";
5555
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5556
+ let scroll = {
5557
+ scrollLeft: 0,
5558
+ scrollTop: 0
5559
+ };
5560
+ const offsets = createCoords(0);
5561
+ function setLeftRTLScrollbarOffset() {
5562
+ offsets.x = getWindowScrollBarX(documentElement);
5563
+ }
5564
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5565
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5566
+ scroll = getNodeScroll(offsetParent);
5567
+ }
5568
+ if (isOffsetParentAnElement) {
5569
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5570
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5571
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5572
+ } else if (documentElement) {
5573
+ setLeftRTLScrollbarOffset();
5574
+ }
5575
+ }
5576
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
5577
+ setLeftRTLScrollbarOffset();
5578
+ }
5579
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5580
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5581
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5582
+ return {
5583
+ x,
5584
+ y,
5585
+ width: rect.width,
5586
+ height: rect.height
5587
+ };
5588
+ }
5589
+ function isStaticPositioned(element) {
5590
+ return getComputedStyle$1(element).position === "static";
5591
+ }
5592
+ function getTrueOffsetParent(element, polyfill) {
5593
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
5594
+ return null;
5595
+ }
5596
+ if (polyfill) {
5597
+ return polyfill(element);
5598
+ }
5599
+ let rawOffsetParent = element.offsetParent;
5600
+ if (getDocumentElement(element) === rawOffsetParent) {
5601
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
5602
+ }
5603
+ return rawOffsetParent;
5604
+ }
5605
+ function getOffsetParent(element, polyfill) {
5606
+ const win = getWindow(element);
5607
+ if (isTopLayer(element)) {
5608
+ return win;
5609
+ }
5610
+ if (!isHTMLElement(element)) {
5611
+ let svgOffsetParent = getParentNode(element);
5612
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5613
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5614
+ return svgOffsetParent;
5615
+ }
5616
+ svgOffsetParent = getParentNode(svgOffsetParent);
5617
+ }
5618
+ return win;
5619
+ }
5620
+ let offsetParent = getTrueOffsetParent(element, polyfill);
5621
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5622
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5623
+ }
5624
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5625
+ return win;
5626
+ }
5627
+ return offsetParent || getContainingBlock(element) || win;
5628
+ }
5629
+ const getElementRects = async function(data) {
5630
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5631
+ const getDimensionsFn = this.getDimensions;
5632
+ const floatingDimensions = await getDimensionsFn(data.floating);
5633
+ return {
5634
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5635
+ floating: {
5636
+ x: 0,
5637
+ y: 0,
5638
+ width: floatingDimensions.width,
5639
+ height: floatingDimensions.height
5640
+ }
5641
+ };
5642
+ };
5643
+ function isRTL(element) {
5644
+ return getComputedStyle$1(element).direction === "rtl";
5645
+ }
5646
+ const platform = {
5647
+ convertOffsetParentRelativeRectToViewportRelativeRect,
5648
+ getDocumentElement,
5649
+ getClippingRect,
5650
+ getOffsetParent,
5651
+ getElementRects,
5652
+ getClientRects,
5653
+ getDimensions,
5654
+ getScale,
5655
+ isElement,
5656
+ isRTL
5657
+ };
5658
+ const computePosition = (reference, floating, options) => {
5659
+ const cache = /* @__PURE__ */ new Map();
5660
+ const mergedOptions = {
5661
+ platform,
5662
+ ...options
5663
+ };
5664
+ const platformWithCache = {
5665
+ ...mergedOptions.platform,
5666
+ _c: cache
5667
+ };
5668
+ return computePosition$1(reference, floating, {
5669
+ ...mergedOptions,
5670
+ platform: platformWithCache
5671
+ });
5672
+ };
5673
+ var isClient = typeof document !== "undefined";
5674
+ var noop2 = function noop3() {
5675
+ };
5676
+ var index = isClient ? useLayoutEffect : noop2;
5677
+ function deepEqual(a, b) {
5678
+ if (a === b) {
5679
+ return true;
5680
+ }
5681
+ if (typeof a !== typeof b) {
5682
+ return false;
5683
+ }
5684
+ if (typeof a === "function" && a.toString() === b.toString()) {
5685
+ return true;
5686
+ }
5687
+ let length;
5688
+ let i;
5689
+ let keys;
5690
+ if (a && b && typeof a === "object") {
5691
+ if (Array.isArray(a)) {
5692
+ length = a.length;
5693
+ if (length !== b.length) return false;
5694
+ for (i = length; i-- !== 0; ) {
5695
+ if (!deepEqual(a[i], b[i])) {
5696
+ return false;
5697
+ }
5698
+ }
5699
+ return true;
5700
+ }
5701
+ keys = Object.keys(a);
5702
+ length = keys.length;
5703
+ if (length !== Object.keys(b).length) {
5704
+ return false;
5705
+ }
5706
+ for (i = length; i-- !== 0; ) {
5707
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
5708
+ return false;
5709
+ }
5710
+ }
5711
+ for (i = length; i-- !== 0; ) {
5712
+ const key = keys[i];
5713
+ if (key === "_owner" && a.$$typeof) {
5714
+ continue;
5715
+ }
5716
+ if (!deepEqual(a[key], b[key])) {
5717
+ return false;
5718
+ }
5719
+ }
5720
+ return true;
5721
+ }
5722
+ return a !== a && b !== b;
5723
+ }
5724
+ function getDPR(element) {
5725
+ if (typeof window === "undefined") {
5726
+ return 1;
5727
+ }
5728
+ const win = element.ownerDocument.defaultView || window;
5729
+ return win.devicePixelRatio || 1;
5730
+ }
5731
+ function roundByDPR(element, value) {
5732
+ const dpr = getDPR(element);
5733
+ return Math.round(value * dpr) / dpr;
5734
+ }
5735
+ function useLatestRef(value) {
5736
+ const ref = React.useRef(value);
5737
+ index(() => {
5738
+ ref.current = value;
5739
+ });
5740
+ return ref;
5741
+ }
5742
+ function useFloating$1(options) {
5743
+ if (options === void 0) {
5744
+ options = {};
5745
+ }
5746
+ const {
5747
+ placement = "bottom",
5748
+ strategy = "absolute",
5749
+ middleware = [],
5750
+ platform: platform2,
5751
+ elements: {
5752
+ reference: externalReference,
5753
+ floating: externalFloating
5754
+ } = {},
5755
+ transform = true,
5756
+ whileElementsMounted,
5757
+ open
5758
+ } = options;
5759
+ const [data, setData] = React.useState({
5760
+ x: 0,
5761
+ y: 0,
5762
+ strategy,
5763
+ placement,
5764
+ middlewareData: {},
5765
+ isPositioned: false
5766
+ });
5767
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
5768
+ if (!deepEqual(latestMiddleware, middleware)) {
5769
+ setLatestMiddleware(middleware);
5770
+ }
5771
+ const [_reference, _setReference] = React.useState(null);
5772
+ const [_floating, _setFloating] = React.useState(null);
5773
+ const setReference = React.useCallback((node) => {
5774
+ if (node !== referenceRef.current) {
5775
+ referenceRef.current = node;
5776
+ _setReference(node);
5777
+ }
5778
+ }, []);
5779
+ const setFloating = React.useCallback((node) => {
5780
+ if (node !== floatingRef.current) {
5781
+ floatingRef.current = node;
5782
+ _setFloating(node);
5783
+ }
5784
+ }, []);
5785
+ const referenceEl = externalReference || _reference;
5786
+ const floatingEl = externalFloating || _floating;
5787
+ const referenceRef = React.useRef(null);
5788
+ const floatingRef = React.useRef(null);
5789
+ const dataRef = React.useRef(data);
5790
+ const hasWhileElementsMounted = whileElementsMounted != null;
5791
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5792
+ const platformRef = useLatestRef(platform2);
5793
+ const openRef = useLatestRef(open);
5794
+ const update = React.useCallback(() => {
5795
+ if (!referenceRef.current || !floatingRef.current) {
5796
+ return;
5797
+ }
5798
+ const config = {
5799
+ placement,
5800
+ strategy,
5801
+ middleware: latestMiddleware
5802
+ };
5803
+ if (platformRef.current) {
5804
+ config.platform = platformRef.current;
5805
+ }
5806
+ computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
5807
+ const fullData = {
5808
+ ...data2,
5809
+ // The floating element's position may be recomputed while it's closed
5810
+ // but still mounted (such as when transitioning out). To ensure
5811
+ // `isPositioned` will be `false` initially on the next open, avoid
5812
+ // setting it to `true` when `open === false` (must be specified).
5813
+ isPositioned: openRef.current !== false
5814
+ };
5815
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5816
+ dataRef.current = fullData;
5817
+ ReactDOM.flushSync(() => {
5818
+ setData(fullData);
5819
+ });
5820
+ }
5821
+ });
5822
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5823
+ index(() => {
5824
+ if (open === false && dataRef.current.isPositioned) {
5825
+ dataRef.current.isPositioned = false;
5826
+ setData((data2) => ({
5827
+ ...data2,
5828
+ isPositioned: false
5829
+ }));
5830
+ }
5831
+ }, [open]);
5832
+ const isMountedRef = React.useRef(false);
5833
+ index(() => {
5834
+ isMountedRef.current = true;
5835
+ return () => {
5836
+ isMountedRef.current = false;
5837
+ };
5838
+ }, []);
5839
+ index(() => {
5840
+ if (referenceEl) referenceRef.current = referenceEl;
5841
+ if (floatingEl) floatingRef.current = floatingEl;
5842
+ if (referenceEl && floatingEl) {
5843
+ if (whileElementsMountedRef.current) {
5844
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
5845
+ }
5846
+ update();
5847
+ }
5848
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
5849
+ const refs = React.useMemo(() => ({
5850
+ reference: referenceRef,
5851
+ floating: floatingRef,
5852
+ setReference,
5853
+ setFloating
5854
+ }), [setReference, setFloating]);
5855
+ const elements = React.useMemo(() => ({
5856
+ reference: referenceEl,
5857
+ floating: floatingEl
5858
+ }), [referenceEl, floatingEl]);
5859
+ const floatingStyles = React.useMemo(() => {
5860
+ const initialStyles = {
5861
+ position: strategy,
5862
+ left: 0,
5863
+ top: 0
5864
+ };
5865
+ if (!elements.floating) {
5866
+ return initialStyles;
5867
+ }
5868
+ const x = roundByDPR(elements.floating, data.x);
5869
+ const y = roundByDPR(elements.floating, data.y);
5870
+ if (transform) {
5871
+ return {
5872
+ ...initialStyles,
5873
+ transform: "translate(" + x + "px, " + y + "px)",
5874
+ ...getDPR(elements.floating) >= 1.5 && {
5875
+ willChange: "transform"
5876
+ }
5877
+ };
5878
+ }
5879
+ return {
5880
+ position: strategy,
5881
+ left: x,
5882
+ top: y
5883
+ };
5884
+ }, [strategy, transform, elements.floating, data.x, data.y]);
5885
+ return React.useMemo(() => ({
5886
+ ...data,
5887
+ update,
5888
+ refs,
5889
+ elements,
5890
+ floatingStyles
5891
+ }), [data, update, refs, elements, floatingStyles]);
5892
+ }
5893
+ const FOCUSABLE_ATTRIBUTE = "data-floating-ui-focusable";
5894
+ const ACTIVE_KEY = "active";
5895
+ const SELECTED_KEY = "selected";
5896
+ const SafeReact = {
5897
+ ...React
5898
+ };
5899
+ let serverHandoffComplete = false;
5900
+ let count = 0;
5901
+ const genId = () => (
5902
+ // Ensure the id is unique with multiple independent versions of Floating UI
5903
+ // on <React 18
5904
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
5905
+ );
5906
+ function useFloatingId() {
5907
+ const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
5908
+ index$1(() => {
5909
+ if (id == null) {
5910
+ setId(genId());
5911
+ }
5912
+ }, []);
5913
+ React.useEffect(() => {
5914
+ serverHandoffComplete = true;
5915
+ }, []);
5916
+ return id;
5917
+ }
5918
+ const useReactId = SafeReact.useId;
5919
+ const useId = useReactId || useFloatingId;
5920
+ let devMessageSet;
5921
+ if (process.env.NODE_ENV !== "production") {
5922
+ devMessageSet = /* @__PURE__ */ new Set();
5923
+ }
5924
+ function error() {
5925
+ var _devMessageSet3;
5926
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5927
+ messages[_key2] = arguments[_key2];
5928
+ }
5929
+ const message = "Floating UI: " + messages.join(" ");
5930
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
5931
+ var _devMessageSet4;
5932
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
5933
+ console.error(message);
5934
+ }
5935
+ }
5936
+ function createEventEmitter() {
5937
+ const map = /* @__PURE__ */ new Map();
5938
+ return {
5939
+ emit(event, data) {
5940
+ var _map$get;
5941
+ (_map$get = map.get(event)) == null || _map$get.forEach((listener) => listener(data));
5942
+ },
5943
+ on(event, listener) {
5944
+ if (!map.has(event)) {
5945
+ map.set(event, /* @__PURE__ */ new Set());
5946
+ }
5947
+ map.get(event).add(listener);
5948
+ },
5949
+ off(event, listener) {
5950
+ var _map$get2;
5951
+ (_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
5952
+ }
5953
+ };
5954
+ }
5955
+ const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
5956
+ const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
5957
+ const useFloatingParentNodeId = () => {
5958
+ var _React$useContext;
5959
+ return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
5960
+ };
5961
+ const useFloatingTree = () => React.useContext(FloatingTreeContext);
5962
+ function createAttribute(name) {
5963
+ return "data-floating-ui-" + name;
5964
+ }
5965
+ function clearTimeoutIfSet(timeoutRef) {
5966
+ if (timeoutRef.current !== -1) {
5967
+ clearTimeout(timeoutRef.current);
5968
+ timeoutRef.current = -1;
5969
+ }
5970
+ }
5971
+ let rafId = 0;
5972
+ function enqueueFocus(el, options) {
5973
+ if (options === void 0) {
5974
+ options = {};
5975
+ }
5976
+ const {
5977
+ preventScroll = false,
5978
+ cancelPrevious = true,
5979
+ sync = false
5980
+ } = options;
5981
+ cancelPrevious && cancelAnimationFrame(rafId);
5982
+ const exec = () => el == null ? void 0 : el.focus({
5983
+ preventScroll
5984
+ });
5985
+ if (sync) {
5986
+ exec();
5987
+ } else {
5988
+ rafId = requestAnimationFrame(exec);
5989
+ }
5990
+ }
5991
+ function getDocument(node) {
5992
+ return (node == null ? void 0 : node.ownerDocument) || document;
5993
+ }
5994
+ const counters = {
5995
+ inert: /* @__PURE__ */ new WeakMap(),
5996
+ "aria-hidden": /* @__PURE__ */ new WeakMap(),
5997
+ none: /* @__PURE__ */ new WeakMap()
5998
+ };
5999
+ function getCounterMap(control) {
6000
+ if (control === "inert") return counters.inert;
6001
+ if (control === "aria-hidden") return counters["aria-hidden"];
6002
+ return counters.none;
6003
+ }
6004
+ let uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
6005
+ let markerMap = {};
6006
+ let lockCount$1 = 0;
6007
+ const supportsInert = () => typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype;
6008
+ const unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
6009
+ const correctElements = (parent, targets) => targets.map((target) => {
6010
+ if (parent.contains(target)) {
6011
+ return target;
6012
+ }
6013
+ const correctedTarget = unwrapHost(target);
6014
+ if (parent.contains(correctedTarget)) {
6015
+ return correctedTarget;
6016
+ }
6017
+ return null;
6018
+ }).filter((x) => x != null);
6019
+ function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
6020
+ const markerName = "data-floating-ui-inert";
6021
+ const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
6022
+ const avoidElements = correctElements(body, uncorrectedAvoidElements);
6023
+ const elementsToKeep = /* @__PURE__ */ new Set();
6024
+ const elementsToStop = new Set(avoidElements);
6025
+ const hiddenElements = [];
6026
+ if (!markerMap[markerName]) {
6027
+ markerMap[markerName] = /* @__PURE__ */ new WeakMap();
6028
+ }
6029
+ const markerCounter = markerMap[markerName];
6030
+ avoidElements.forEach(keep);
6031
+ deep(body);
6032
+ elementsToKeep.clear();
6033
+ function keep(el) {
6034
+ if (!el || elementsToKeep.has(el)) {
6035
+ return;
6036
+ }
6037
+ elementsToKeep.add(el);
6038
+ el.parentNode && keep(el.parentNode);
6039
+ }
6040
+ function deep(parent) {
6041
+ if (!parent || elementsToStop.has(parent)) {
6042
+ return;
6043
+ }
6044
+ [].forEach.call(parent.children, (node) => {
6045
+ if (getNodeName(node) === "script") return;
6046
+ if (elementsToKeep.has(node)) {
6047
+ deep(node);
6048
+ } else {
6049
+ const attr2 = controlAttribute ? node.getAttribute(controlAttribute) : null;
6050
+ const alreadyHidden = attr2 !== null && attr2 !== "false";
6051
+ const counterMap = getCounterMap(controlAttribute);
6052
+ const counterValue = (counterMap.get(node) || 0) + 1;
6053
+ const markerValue = (markerCounter.get(node) || 0) + 1;
6054
+ counterMap.set(node, counterValue);
6055
+ markerCounter.set(node, markerValue);
6056
+ hiddenElements.push(node);
6057
+ if (counterValue === 1 && alreadyHidden) {
6058
+ uncontrolledElementsSet.add(node);
6059
+ }
6060
+ if (markerValue === 1) {
6061
+ node.setAttribute(markerName, "");
6062
+ }
6063
+ if (!alreadyHidden && controlAttribute) {
6064
+ node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
6065
+ }
6066
+ }
6067
+ });
6068
+ }
6069
+ lockCount$1++;
6070
+ return () => {
6071
+ hiddenElements.forEach((element) => {
6072
+ const counterMap = getCounterMap(controlAttribute);
6073
+ const currentCounterValue = counterMap.get(element) || 0;
6074
+ const counterValue = currentCounterValue - 1;
6075
+ const markerValue = (markerCounter.get(element) || 0) - 1;
6076
+ counterMap.set(element, counterValue);
6077
+ markerCounter.set(element, markerValue);
6078
+ if (!counterValue) {
6079
+ if (!uncontrolledElementsSet.has(element) && controlAttribute) {
6080
+ element.removeAttribute(controlAttribute);
6081
+ }
6082
+ uncontrolledElementsSet.delete(element);
6083
+ }
6084
+ if (!markerValue) {
6085
+ element.removeAttribute(markerName);
6086
+ }
6087
+ });
6088
+ lockCount$1--;
6089
+ if (!lockCount$1) {
6090
+ counters.inert = /* @__PURE__ */ new WeakMap();
6091
+ counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
6092
+ counters.none = /* @__PURE__ */ new WeakMap();
6093
+ uncontrolledElementsSet = /* @__PURE__ */ new WeakSet();
6094
+ markerMap = {};
6095
+ }
6096
+ };
6097
+ }
6098
+ function markOthers(avoidElements, ariaHidden, inert) {
6099
+ if (ariaHidden === void 0) {
6100
+ ariaHidden = false;
6101
+ }
6102
+ if (inert === void 0) {
6103
+ inert = false;
6104
+ }
6105
+ const body = getDocument(avoidElements[0]).body;
6106
+ return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll('[aria-live],[role="status"],output'))), body, ariaHidden, inert);
6107
+ }
6108
+ const HIDDEN_STYLES = {
6109
+ border: 0,
6110
+ clip: "rect(0 0 0 0)",
6111
+ height: "1px",
6112
+ margin: "-1px",
6113
+ overflow: "hidden",
6114
+ padding: 0,
6115
+ position: "fixed",
6116
+ whiteSpace: "nowrap",
6117
+ width: "1px",
6118
+ top: 0,
6119
+ left: 0
6120
+ };
6121
+ const FocusGuard = /* @__PURE__ */ React.forwardRef(function FocusGuard2(props, ref) {
6122
+ const [role, setRole] = React.useState();
6123
+ index$1(() => {
6124
+ if (isSafari()) {
6125
+ setRole("button");
6126
+ }
6127
+ }, []);
6128
+ const restProps = {
6129
+ ref,
6130
+ tabIndex: 0,
6131
+ // Role is only for VoiceOver
6132
+ role,
6133
+ "aria-hidden": role ? void 0 : true,
6134
+ [createAttribute("focus-guard")]: "",
6135
+ style: HIDDEN_STYLES
6136
+ };
6137
+ return /* @__PURE__ */ jsx("span", {
6138
+ ...props,
6139
+ ...restProps
6140
+ });
6141
+ });
6142
+ const HIDDEN_OWNER_STYLES = {
6143
+ clipPath: "inset(50%)",
6144
+ position: "fixed",
6145
+ top: 0,
6146
+ left: 0
6147
+ };
6148
+ const PortalContext = /* @__PURE__ */ React.createContext(null);
6149
+ const attr = /* @__PURE__ */ createAttribute("portal");
6150
+ function useFloatingPortalNode(props) {
6151
+ if (props === void 0) {
6152
+ props = {};
6153
+ }
6154
+ const {
6155
+ id,
6156
+ root
6157
+ } = props;
6158
+ const uniqueId = useId();
6159
+ const portalContext = usePortalContext();
6160
+ const [portalNode, setPortalNode] = React.useState(null);
6161
+ const portalNodeRef = React.useRef(null);
6162
+ index$1(() => {
6163
+ return () => {
6164
+ portalNode == null || portalNode.remove();
6165
+ queueMicrotask(() => {
6166
+ portalNodeRef.current = null;
6167
+ });
6168
+ };
6169
+ }, [portalNode]);
6170
+ index$1(() => {
6171
+ if (!uniqueId) return;
6172
+ if (portalNodeRef.current) return;
6173
+ const existingIdRoot = id ? document.getElementById(id) : null;
6174
+ if (!existingIdRoot) return;
6175
+ const subRoot = document.createElement("div");
6176
+ subRoot.id = uniqueId;
6177
+ subRoot.setAttribute(attr, "");
6178
+ existingIdRoot.appendChild(subRoot);
6179
+ portalNodeRef.current = subRoot;
6180
+ setPortalNode(subRoot);
6181
+ }, [id, uniqueId]);
6182
+ index$1(() => {
6183
+ if (root === null) return;
6184
+ if (!uniqueId) return;
6185
+ if (portalNodeRef.current) return;
6186
+ let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
6187
+ if (container && !isNode(container)) container = container.current;
6188
+ container = container || document.body;
6189
+ let idWrapper = null;
6190
+ if (id) {
6191
+ idWrapper = document.createElement("div");
6192
+ idWrapper.id = id;
6193
+ container.appendChild(idWrapper);
6194
+ }
6195
+ const subRoot = document.createElement("div");
6196
+ subRoot.id = uniqueId;
6197
+ subRoot.setAttribute(attr, "");
6198
+ container = idWrapper || container;
6199
+ container.appendChild(subRoot);
6200
+ portalNodeRef.current = subRoot;
6201
+ setPortalNode(subRoot);
6202
+ }, [id, root, uniqueId, portalContext]);
6203
+ return portalNode;
6204
+ }
6205
+ function FloatingPortal(props) {
6206
+ const {
6207
+ children,
6208
+ id,
6209
+ root,
6210
+ preserveTabOrder = true
6211
+ } = props;
6212
+ const portalNode = useFloatingPortalNode({
6213
+ id,
6214
+ root
6215
+ });
6216
+ const [focusManagerState, setFocusManagerState] = React.useState(null);
6217
+ const beforeOutsideRef = React.useRef(null);
6218
+ const afterOutsideRef = React.useRef(null);
6219
+ const beforeInsideRef = React.useRef(null);
6220
+ const afterInsideRef = React.useRef(null);
6221
+ const modal2 = focusManagerState == null ? void 0 : focusManagerState.modal;
6222
+ const open = focusManagerState == null ? void 0 : focusManagerState.open;
6223
+ const shouldRenderGuards = (
6224
+ // The FocusManager and therefore floating element are currently open/
6225
+ // rendered.
6226
+ !!focusManagerState && // Guards are only for non-modal focus management.
6227
+ !focusManagerState.modal && // Don't render if unmount is transitioning.
6228
+ focusManagerState.open && preserveTabOrder && !!(root || portalNode)
6229
+ );
6230
+ React.useEffect(() => {
6231
+ if (!portalNode || !preserveTabOrder || modal2) {
6232
+ return;
6233
+ }
6234
+ function onFocus(event) {
6235
+ if (portalNode && isOutsideEvent(event)) {
6236
+ const focusing = event.type === "focusin";
6237
+ const manageFocus = focusing ? enableFocusInside : disableFocusInside;
6238
+ manageFocus(portalNode);
6239
+ }
6240
+ }
6241
+ portalNode.addEventListener("focusin", onFocus, true);
6242
+ portalNode.addEventListener("focusout", onFocus, true);
6243
+ return () => {
6244
+ portalNode.removeEventListener("focusin", onFocus, true);
6245
+ portalNode.removeEventListener("focusout", onFocus, true);
6246
+ };
6247
+ }, [portalNode, preserveTabOrder, modal2]);
6248
+ React.useEffect(() => {
6249
+ if (!portalNode) return;
6250
+ if (open) return;
6251
+ enableFocusInside(portalNode);
6252
+ }, [open, portalNode]);
6253
+ return /* @__PURE__ */ jsxs(PortalContext.Provider, {
6254
+ value: React.useMemo(() => ({
6255
+ preserveTabOrder,
6256
+ beforeOutsideRef,
6257
+ afterOutsideRef,
6258
+ beforeInsideRef,
6259
+ afterInsideRef,
6260
+ portalNode,
6261
+ setFocusManagerState
6262
+ }), [preserveTabOrder, portalNode]),
6263
+ children: [shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
6264
+ "data-type": "outside",
6265
+ ref: beforeOutsideRef,
6266
+ onFocus: (event) => {
6267
+ if (isOutsideEvent(event, portalNode)) {
6268
+ var _beforeInsideRef$curr;
6269
+ (_beforeInsideRef$curr = beforeInsideRef.current) == null || _beforeInsideRef$curr.focus();
6270
+ } else {
6271
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
6272
+ const prevTabbable = getPreviousTabbable(domReference);
6273
+ prevTabbable == null || prevTabbable.focus();
6274
+ }
6275
+ }
6276
+ }), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx("span", {
6277
+ "aria-owns": portalNode.id,
6278
+ style: HIDDEN_OWNER_STYLES
6279
+ }), portalNode && /* @__PURE__ */ ReactDOM.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx(FocusGuard, {
6280
+ "data-type": "outside",
6281
+ ref: afterOutsideRef,
6282
+ onFocus: (event) => {
6283
+ if (isOutsideEvent(event, portalNode)) {
6284
+ var _afterInsideRef$curre;
6285
+ (_afterInsideRef$curre = afterInsideRef.current) == null || _afterInsideRef$curre.focus();
6286
+ } else {
6287
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
6288
+ const nextTabbable = getNextTabbable(domReference);
6289
+ nextTabbable == null || nextTabbable.focus();
6290
+ (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, event.nativeEvent, "focus-out"));
6291
+ }
6292
+ }
6293
+ })]
6294
+ });
6295
+ }
6296
+ const usePortalContext = () => React.useContext(PortalContext);
6297
+ function useLiteMergeRefs(refs) {
6298
+ return React.useMemo(() => {
6299
+ return (value) => {
6300
+ refs.forEach((ref) => {
6301
+ if (ref) {
6302
+ ref.current = value;
6303
+ }
6304
+ });
6305
+ };
6306
+ }, refs);
6307
+ }
6308
+ const LIST_LIMIT = 20;
6309
+ let previouslyFocusedElements = [];
6310
+ function clearDisconnectedPreviouslyFocusedElements() {
6311
+ previouslyFocusedElements = previouslyFocusedElements.filter((el) => el.isConnected);
6312
+ }
6313
+ function addPreviouslyFocusedElement(element) {
6314
+ clearDisconnectedPreviouslyFocusedElements();
6315
+ if (element && getNodeName(element) !== "body") {
6316
+ previouslyFocusedElements.push(element);
6317
+ if (previouslyFocusedElements.length > LIST_LIMIT) {
6318
+ previouslyFocusedElements = previouslyFocusedElements.slice(-20);
6319
+ }
6320
+ }
6321
+ }
6322
+ function getPreviouslyFocusedElement() {
6323
+ clearDisconnectedPreviouslyFocusedElements();
6324
+ return previouslyFocusedElements[previouslyFocusedElements.length - 1];
6325
+ }
6326
+ function getFirstTabbableElement(container) {
6327
+ const tabbableOptions = getTabbableOptions();
6328
+ if (isTabbable(container, tabbableOptions)) {
6329
+ return container;
6330
+ }
6331
+ return tabbable(container, tabbableOptions)[0] || container;
6332
+ }
6333
+ function handleTabIndex(floatingFocusElement, orderRef) {
6334
+ var _floatingFocusElement;
6335
+ if (!orderRef.current.includes("floating") && !((_floatingFocusElement = floatingFocusElement.getAttribute("role")) != null && _floatingFocusElement.includes("dialog"))) {
6336
+ return;
6337
+ }
6338
+ const options = getTabbableOptions();
6339
+ const focusableElements = focusable(floatingFocusElement, options);
6340
+ const tabbableContent = focusableElements.filter((element) => {
6341
+ const dataTabIndex = element.getAttribute("data-tabindex") || "";
6342
+ return isTabbable(element, options) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
6343
+ });
6344
+ const tabIndex = floatingFocusElement.getAttribute("tabindex");
6345
+ if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
6346
+ if (tabIndex !== "0") {
6347
+ floatingFocusElement.setAttribute("tabindex", "0");
6348
+ }
6349
+ } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
6350
+ floatingFocusElement.setAttribute("tabindex", "-1");
6351
+ floatingFocusElement.setAttribute("data-tabindex", "-1");
6352
+ }
6353
+ }
6354
+ const VisuallyHiddenDismiss = /* @__PURE__ */ React.forwardRef(function VisuallyHiddenDismiss2(props, ref) {
6355
+ return /* @__PURE__ */ jsx("button", {
6356
+ ...props,
6357
+ type: "button",
6358
+ ref,
6359
+ tabIndex: -1,
6360
+ style: HIDDEN_STYLES
6361
+ });
6362
+ });
6363
+ function FloatingFocusManager(props) {
6364
+ const {
6365
+ context: context2,
6366
+ children,
6367
+ disabled = false,
6368
+ order = ["content"],
6369
+ guards: _guards = true,
6370
+ initialFocus = 0,
6371
+ returnFocus = true,
6372
+ restoreFocus = false,
6373
+ modal: modal2 = true,
6374
+ visuallyHiddenDismiss = false,
6375
+ closeOnFocusOut = true,
6376
+ outsideElementsInert = false,
6377
+ getInsideElements: _getInsideElements = () => []
6378
+ } = props;
6379
+ const {
6380
+ open,
6381
+ onOpenChange,
6382
+ events,
6383
+ dataRef,
6384
+ elements: {
6385
+ domReference,
6386
+ floating
6387
+ }
6388
+ } = context2;
6389
+ const getNodeId = useEffectEvent(() => {
6390
+ var _dataRef$current$floa;
6391
+ return (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
6392
+ });
6393
+ const getInsideElements = useEffectEvent(_getInsideElements);
6394
+ const ignoreInitialFocus = typeof initialFocus === "number" && initialFocus < 0;
6395
+ const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
6396
+ const inertSupported = supportsInert();
6397
+ const guards = inertSupported ? _guards : true;
6398
+ const useInert = !guards || inertSupported && outsideElementsInert;
6399
+ const orderRef = useLatestRef$1(order);
6400
+ const initialFocusRef = useLatestRef$1(initialFocus);
6401
+ const returnFocusRef = useLatestRef$1(returnFocus);
6402
+ const tree = useFloatingTree();
6403
+ const portalContext = usePortalContext();
6404
+ const startDismissButtonRef = React.useRef(null);
6405
+ const endDismissButtonRef = React.useRef(null);
6406
+ const preventReturnFocusRef = React.useRef(false);
6407
+ const isPointerDownRef = React.useRef(false);
6408
+ const tabbableIndexRef = React.useRef(-1);
6409
+ const blurTimeoutRef = React.useRef(-1);
6410
+ const isInsidePortal = portalContext != null;
6411
+ const floatingFocusElement = getFloatingFocusElement(floating);
6412
+ const getTabbableContent = useEffectEvent(function(container) {
6413
+ if (container === void 0) {
6414
+ container = floatingFocusElement;
6415
+ }
6416
+ return container ? tabbable(container, getTabbableOptions()) : [];
6417
+ });
6418
+ const getTabbableElements = useEffectEvent((container) => {
6419
+ const content = getTabbableContent(container);
6420
+ return orderRef.current.map((type) => {
6421
+ if (domReference && type === "reference") {
6422
+ return domReference;
6423
+ }
6424
+ if (floatingFocusElement && type === "floating") {
6425
+ return floatingFocusElement;
6426
+ }
6427
+ return content;
6428
+ }).filter(Boolean).flat();
6429
+ });
6430
+ React.useEffect(() => {
6431
+ if (disabled) return;
6432
+ if (!modal2) return;
6433
+ function onKeyDown(event) {
6434
+ if (event.key === "Tab") {
6435
+ if (contains(floatingFocusElement, activeElement(getDocument$1(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
6436
+ stopEvent(event);
6437
+ }
6438
+ const els = getTabbableElements();
6439
+ const target = getTarget(event);
6440
+ if (orderRef.current[0] === "reference" && target === domReference) {
6441
+ stopEvent(event);
6442
+ if (event.shiftKey) {
6443
+ enqueueFocus(els[els.length - 1]);
6444
+ } else {
6445
+ enqueueFocus(els[1]);
6446
+ }
6447
+ }
6448
+ if (orderRef.current[1] === "floating" && target === floatingFocusElement && event.shiftKey) {
6449
+ stopEvent(event);
6450
+ enqueueFocus(els[0]);
6451
+ }
6452
+ }
6453
+ }
6454
+ const doc = getDocument$1(floatingFocusElement);
6455
+ doc.addEventListener("keydown", onKeyDown);
6456
+ return () => {
6457
+ doc.removeEventListener("keydown", onKeyDown);
6458
+ };
6459
+ }, [disabled, domReference, floatingFocusElement, modal2, orderRef, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
6460
+ React.useEffect(() => {
6461
+ if (disabled) return;
6462
+ if (!floating) return;
6463
+ function handleFocusIn(event) {
6464
+ const target = getTarget(event);
6465
+ const tabbableContent = getTabbableContent();
6466
+ const tabbableIndex = tabbableContent.indexOf(target);
6467
+ if (tabbableIndex !== -1) {
6468
+ tabbableIndexRef.current = tabbableIndex;
6469
+ }
6470
+ }
6471
+ floating.addEventListener("focusin", handleFocusIn);
6472
+ return () => {
6473
+ floating.removeEventListener("focusin", handleFocusIn);
6474
+ };
6475
+ }, [disabled, floating, getTabbableContent]);
6476
+ React.useEffect(() => {
6477
+ if (disabled) return;
6478
+ if (!closeOnFocusOut) return;
6479
+ function handlePointerDown() {
6480
+ isPointerDownRef.current = true;
6481
+ setTimeout(() => {
6482
+ isPointerDownRef.current = false;
6483
+ });
6484
+ }
6485
+ function handleFocusOutside(event) {
6486
+ const relatedTarget = event.relatedTarget;
6487
+ const currentTarget = event.currentTarget;
6488
+ const target = getTarget(event);
6489
+ queueMicrotask(() => {
6490
+ const nodeId = getNodeId();
6491
+ const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute("focus-guard")) || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => {
6492
+ var _node$context, _node$context2;
6493
+ return contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget);
6494
+ }) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => {
6495
+ var _node$context3, _node$context4, _node$context5;
6496
+ return [(_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating, getFloatingFocusElement((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.floating)].includes(relatedTarget) || ((_node$context5 = node.context) == null ? void 0 : _node$context5.elements.domReference) === relatedTarget;
6497
+ })));
6498
+ if (currentTarget === domReference && floatingFocusElement) {
6499
+ handleTabIndex(floatingFocusElement, orderRef);
6500
+ }
6501
+ if (restoreFocus && currentTarget !== domReference && !(target != null && target.isConnected) && activeElement(getDocument$1(floatingFocusElement)) === getDocument$1(floatingFocusElement).body) {
6502
+ if (isHTMLElement(floatingFocusElement)) {
6503
+ floatingFocusElement.focus();
6504
+ }
6505
+ const prevTabbableIndex = tabbableIndexRef.current;
6506
+ const tabbableContent = getTabbableContent();
6507
+ const nodeToFocus = tabbableContent[prevTabbableIndex] || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
6508
+ if (isHTMLElement(nodeToFocus)) {
6509
+ nodeToFocus.focus();
6510
+ }
6511
+ }
6512
+ if (dataRef.current.insideReactTree) {
6513
+ dataRef.current.insideReactTree = false;
6514
+ return;
6515
+ }
6516
+ if ((isUntrappedTypeableCombobox ? true : !modal2) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
6517
+ relatedTarget !== getPreviouslyFocusedElement()) {
6518
+ preventReturnFocusRef.current = true;
6519
+ onOpenChange(false, event, "focus-out");
6520
+ }
6521
+ });
6522
+ }
6523
+ const shouldHandleBlurCapture = Boolean(!tree && portalContext);
6524
+ function markInsideReactTree() {
6525
+ clearTimeoutIfSet(blurTimeoutRef);
6526
+ dataRef.current.insideReactTree = true;
6527
+ blurTimeoutRef.current = window.setTimeout(() => {
6528
+ dataRef.current.insideReactTree = false;
6529
+ });
6530
+ }
6531
+ if (floating && isHTMLElement(domReference)) {
6532
+ domReference.addEventListener("focusout", handleFocusOutside);
6533
+ domReference.addEventListener("pointerdown", handlePointerDown);
6534
+ floating.addEventListener("focusout", handleFocusOutside);
6535
+ if (shouldHandleBlurCapture) {
6536
+ floating.addEventListener("focusout", markInsideReactTree, true);
6537
+ }
6538
+ return () => {
6539
+ domReference.removeEventListener("focusout", handleFocusOutside);
6540
+ domReference.removeEventListener("pointerdown", handlePointerDown);
6541
+ floating.removeEventListener("focusout", handleFocusOutside);
6542
+ if (shouldHandleBlurCapture) {
6543
+ floating.removeEventListener("focusout", markInsideReactTree, true);
6544
+ }
6545
+ };
6546
+ }
6547
+ }, [disabled, domReference, floating, floatingFocusElement, modal2, tree, portalContext, onOpenChange, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef, dataRef]);
6548
+ const beforeGuardRef = React.useRef(null);
6549
+ const afterGuardRef = React.useRef(null);
6550
+ const mergedBeforeGuardRef = useLiteMergeRefs([beforeGuardRef, portalContext == null ? void 0 : portalContext.beforeInsideRef]);
6551
+ const mergedAfterGuardRef = useLiteMergeRefs([afterGuardRef, portalContext == null ? void 0 : portalContext.afterInsideRef]);
6552
+ React.useEffect(() => {
6553
+ var _portalContext$portal, _ancestors$find;
6554
+ if (disabled) return;
6555
+ if (!floating) return;
6556
+ const portalNodes = Array.from((portalContext == null || (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute("portal") + "]")) || []);
6557
+ const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
6558
+ const rootAncestorComboboxDomReference = (_ancestors$find = ancestors.find((node) => {
6559
+ var _node$context6;
6560
+ return isTypeableCombobox(((_node$context6 = node.context) == null ? void 0 : _node$context6.elements.domReference) || null);
6561
+ })) == null || (_ancestors$find = _ancestors$find.context) == null ? void 0 : _ancestors$find.elements.domReference;
6562
+ const insideElements = [floating, rootAncestorComboboxDomReference, ...portalNodes, ...getInsideElements(), startDismissButtonRef.current, endDismissButtonRef.current, beforeGuardRef.current, afterGuardRef.current, portalContext == null ? void 0 : portalContext.beforeOutsideRef.current, portalContext == null ? void 0 : portalContext.afterOutsideRef.current, orderRef.current.includes("reference") || isUntrappedTypeableCombobox ? domReference : null].filter((x) => x != null);
6563
+ const cleanup2 = modal2 || isUntrappedTypeableCombobox ? markOthers(insideElements, !useInert, useInert) : markOthers(insideElements);
6564
+ return () => {
6565
+ cleanup2();
6566
+ };
6567
+ }, [disabled, domReference, floating, modal2, orderRef, portalContext, isUntrappedTypeableCombobox, guards, useInert, tree, getNodeId, getInsideElements]);
6568
+ index$1(() => {
6569
+ if (disabled || !isHTMLElement(floatingFocusElement)) return;
6570
+ const doc = getDocument$1(floatingFocusElement);
6571
+ const previouslyFocusedElement = activeElement(doc);
6572
+ queueMicrotask(() => {
6573
+ const focusableElements = getTabbableElements(floatingFocusElement);
6574
+ const initialFocusValue = initialFocusRef.current;
6575
+ const elToFocus = (typeof initialFocusValue === "number" ? focusableElements[initialFocusValue] : initialFocusValue.current) || floatingFocusElement;
6576
+ const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
6577
+ if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) {
6578
+ enqueueFocus(elToFocus, {
6579
+ preventScroll: elToFocus === floatingFocusElement
6580
+ });
6581
+ }
6582
+ });
6583
+ }, [disabled, open, floatingFocusElement, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
6584
+ index$1(() => {
6585
+ if (disabled || !floatingFocusElement) return;
6586
+ const doc = getDocument$1(floatingFocusElement);
6587
+ const previouslyFocusedElement = activeElement(doc);
6588
+ addPreviouslyFocusedElement(previouslyFocusedElement);
6589
+ function onOpenChange2(_ref) {
6590
+ let {
6591
+ reason,
6592
+ event,
6593
+ nested
6594
+ } = _ref;
6595
+ if (["hover", "safe-polygon"].includes(reason) && event.type === "mouseleave") {
6596
+ preventReturnFocusRef.current = true;
6597
+ }
6598
+ if (reason !== "outside-press") return;
6599
+ if (nested) {
6600
+ preventReturnFocusRef.current = false;
6601
+ } else if (isVirtualClick(event) || isVirtualPointerEvent(event)) {
6602
+ preventReturnFocusRef.current = false;
6603
+ } else {
6604
+ let isPreventScrollSupported = false;
6605
+ document.createElement("div").focus({
6606
+ get preventScroll() {
6607
+ isPreventScrollSupported = true;
6608
+ return false;
6609
+ }
6610
+ });
6611
+ if (isPreventScrollSupported) {
6612
+ preventReturnFocusRef.current = false;
6613
+ } else {
6614
+ preventReturnFocusRef.current = true;
6615
+ }
6616
+ }
6617
+ }
6618
+ events.on("openchange", onOpenChange2);
6619
+ const fallbackEl = doc.createElement("span");
6620
+ fallbackEl.setAttribute("tabindex", "-1");
6621
+ fallbackEl.setAttribute("aria-hidden", "true");
6622
+ Object.assign(fallbackEl.style, HIDDEN_STYLES);
6623
+ if (isInsidePortal && domReference) {
6624
+ domReference.insertAdjacentElement("afterend", fallbackEl);
6625
+ }
6626
+ function getReturnElement() {
6627
+ if (typeof returnFocusRef.current === "boolean") {
6628
+ const el = domReference || getPreviouslyFocusedElement();
6629
+ return el && el.isConnected ? el : fallbackEl;
6630
+ }
6631
+ return returnFocusRef.current.current || fallbackEl;
6632
+ }
6633
+ return () => {
6634
+ events.off("openchange", onOpenChange2);
6635
+ const activeEl = activeElement(doc);
6636
+ const isFocusInsideFloatingTree = contains(floating, activeEl) || tree && getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => {
6637
+ var _node$context7;
6638
+ return contains((_node$context7 = node.context) == null ? void 0 : _node$context7.elements.floating, activeEl);
6639
+ });
6640
+ const returnElement = getReturnElement();
6641
+ queueMicrotask(() => {
6642
+ const tabbableReturnElement = getFirstTabbableElement(returnElement);
6643
+ if (
6644
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6645
+ returnFocusRef.current && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
6646
+ // since it likely entered a different element which should be
6647
+ // respected: https://github.com/floating-ui/floating-ui/issues/2607
6648
+ (tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)
6649
+ ) {
6650
+ tabbableReturnElement.focus({
6651
+ preventScroll: true
6652
+ });
6653
+ }
6654
+ fallbackEl.remove();
6655
+ });
6656
+ };
6657
+ }, [disabled, floating, floatingFocusElement, returnFocusRef, dataRef, events, tree, isInsidePortal, domReference, getNodeId]);
6658
+ React.useEffect(() => {
6659
+ queueMicrotask(() => {
6660
+ preventReturnFocusRef.current = false;
6661
+ });
6662
+ return () => {
6663
+ queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
6664
+ };
6665
+ }, [disabled]);
6666
+ index$1(() => {
6667
+ if (disabled) return;
6668
+ if (!portalContext) return;
6669
+ portalContext.setFocusManagerState({
6670
+ modal: modal2,
6671
+ closeOnFocusOut,
6672
+ open,
6673
+ onOpenChange,
6674
+ domReference
6675
+ });
6676
+ return () => {
6677
+ portalContext.setFocusManagerState(null);
6678
+ };
6679
+ }, [disabled, portalContext, modal2, open, onOpenChange, closeOnFocusOut, domReference]);
6680
+ index$1(() => {
6681
+ if (disabled) return;
6682
+ if (!floatingFocusElement) return;
6683
+ handleTabIndex(floatingFocusElement, orderRef);
6684
+ }, [disabled, floatingFocusElement, orderRef]);
6685
+ function renderDismissButton(location) {
6686
+ if (disabled || !visuallyHiddenDismiss || !modal2) {
6687
+ return null;
6688
+ }
6689
+ return /* @__PURE__ */ jsx(VisuallyHiddenDismiss, {
6690
+ ref: location === "start" ? startDismissButtonRef : endDismissButtonRef,
6691
+ onClick: (event) => onOpenChange(false, event.nativeEvent),
6692
+ children: typeof visuallyHiddenDismiss === "string" ? visuallyHiddenDismiss : "Dismiss"
6693
+ });
6694
+ }
6695
+ const shouldRenderGuards = !disabled && guards && (modal2 ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal2);
6696
+ return /* @__PURE__ */ jsxs(Fragment, {
6697
+ children: [shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
6698
+ "data-type": "inside",
6699
+ ref: mergedBeforeGuardRef,
6700
+ onFocus: (event) => {
6701
+ if (modal2) {
6702
+ const els = getTabbableElements();
6703
+ enqueueFocus(order[0] === "reference" ? els[0] : els[els.length - 1]);
6704
+ } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
6705
+ preventReturnFocusRef.current = false;
6706
+ if (isOutsideEvent(event, portalContext.portalNode)) {
6707
+ const nextTabbable = getNextTabbable(domReference);
6708
+ nextTabbable == null || nextTabbable.focus();
6709
+ } else {
6710
+ var _portalContext$before;
6711
+ (_portalContext$before = portalContext.beforeOutsideRef.current) == null || _portalContext$before.focus();
6712
+ }
6713
+ }
6714
+ }
6715
+ }), !isUntrappedTypeableCombobox && renderDismissButton("start"), children, renderDismissButton("end"), shouldRenderGuards && /* @__PURE__ */ jsx(FocusGuard, {
6716
+ "data-type": "inside",
6717
+ ref: mergedAfterGuardRef,
6718
+ onFocus: (event) => {
6719
+ if (modal2) {
6720
+ enqueueFocus(getTabbableElements()[0]);
6721
+ } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) {
6722
+ if (closeOnFocusOut) {
6723
+ preventReturnFocusRef.current = true;
6724
+ }
6725
+ if (isOutsideEvent(event, portalContext.portalNode)) {
6726
+ const prevTabbable = getPreviousTabbable(domReference);
6727
+ prevTabbable == null || prevTabbable.focus();
6728
+ } else {
6729
+ var _portalContext$afterO;
6730
+ (_portalContext$afterO = portalContext.afterOutsideRef.current) == null || _portalContext$afterO.focus();
6731
+ }
6732
+ }
6733
+ }
6734
+ })]
6735
+ });
6736
+ }
6737
+ let lockCount = 0;
6738
+ const scrollbarProperty = "--floating-ui-scrollbar-width";
6739
+ function enableScrollLock() {
6740
+ const platform2 = getPlatform();
6741
+ const isIOS = /iP(hone|ad|od)|iOS/.test(platform2) || // iPads can claim to be MacIntel
6742
+ platform2 === "MacIntel" && navigator.maxTouchPoints > 1;
6743
+ const bodyStyle = document.body.style;
6744
+ const scrollbarX = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft;
6745
+ const paddingProp = scrollbarX ? "paddingLeft" : "paddingRight";
6746
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
6747
+ const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.scrollX;
6748
+ const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.scrollY;
6749
+ bodyStyle.overflow = "hidden";
6750
+ bodyStyle.setProperty(scrollbarProperty, scrollbarWidth + "px");
6751
+ if (scrollbarWidth) {
6752
+ bodyStyle[paddingProp] = scrollbarWidth + "px";
6753
+ }
6754
+ if (isIOS) {
6755
+ var _window$visualViewpor, _window$visualViewpor2;
6756
+ const offsetLeft = ((_window$visualViewpor = window.visualViewport) == null ? void 0 : _window$visualViewpor.offsetLeft) || 0;
6757
+ const offsetTop = ((_window$visualViewpor2 = window.visualViewport) == null ? void 0 : _window$visualViewpor2.offsetTop) || 0;
6758
+ Object.assign(bodyStyle, {
6759
+ position: "fixed",
6760
+ top: -(scrollY - Math.floor(offsetTop)) + "px",
6761
+ left: -(scrollX - Math.floor(offsetLeft)) + "px",
6762
+ right: "0"
6763
+ });
6764
+ }
6765
+ return () => {
6766
+ Object.assign(bodyStyle, {
6767
+ overflow: "",
6768
+ [paddingProp]: ""
6769
+ });
6770
+ bodyStyle.removeProperty(scrollbarProperty);
6771
+ if (isIOS) {
6772
+ Object.assign(bodyStyle, {
6773
+ position: "",
6774
+ top: "",
6775
+ left: "",
6776
+ right: ""
6777
+ });
6778
+ window.scrollTo(scrollX, scrollY);
6779
+ }
6780
+ };
6781
+ }
6782
+ let cleanup = () => {
6783
+ };
6784
+ const FloatingOverlay = /* @__PURE__ */ React.forwardRef(function FloatingOverlay2(props, ref) {
6785
+ const {
6786
+ lockScroll = false,
6787
+ ...rest
6788
+ } = props;
6789
+ index$1(() => {
6790
+ if (!lockScroll) return;
6791
+ lockCount++;
6792
+ if (lockCount === 1) {
6793
+ cleanup = enableScrollLock();
6794
+ }
6795
+ return () => {
6796
+ lockCount--;
6797
+ if (lockCount === 0) {
6798
+ cleanup();
6799
+ }
6800
+ };
6801
+ }, [lockScroll]);
6802
+ return /* @__PURE__ */ jsx("div", {
6803
+ ref,
6804
+ ...rest,
6805
+ style: {
6806
+ position: "fixed",
6807
+ overflow: "auto",
6808
+ top: 0,
6809
+ right: 0,
6810
+ bottom: 0,
6811
+ left: 0,
6812
+ ...rest.style
6813
+ }
6814
+ });
6815
+ });
6816
+ const bubbleHandlerKeys = {
6817
+ pointerdown: "onPointerDown",
6818
+ mousedown: "onMouseDown",
6819
+ click: "onClick"
6820
+ };
6821
+ const captureHandlerKeys = {
6822
+ pointerdown: "onPointerDownCapture",
6823
+ mousedown: "onMouseDownCapture",
6824
+ click: "onClickCapture"
6825
+ };
6826
+ const normalizeProp = (normalizable) => {
6827
+ var _normalizable$escapeK, _normalizable$outside;
6828
+ return {
6829
+ escapeKey: typeof normalizable === "boolean" ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
6830
+ outsidePress: typeof normalizable === "boolean" ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
6831
+ };
6832
+ };
6833
+ function useDismiss(context2, props) {
6834
+ if (props === void 0) {
6835
+ props = {};
6836
+ }
6837
+ const {
6838
+ open,
6839
+ onOpenChange,
6840
+ elements,
6841
+ dataRef
6842
+ } = context2;
6843
+ const {
6844
+ enabled = true,
6845
+ escapeKey = true,
6846
+ outsidePress: unstable_outsidePress = true,
6847
+ outsidePressEvent = "pointerdown",
6848
+ referencePress = false,
6849
+ referencePressEvent = "pointerdown",
6850
+ ancestorScroll = false,
6851
+ bubbles,
6852
+ capture
6853
+ } = props;
6854
+ const tree = useFloatingTree();
6855
+ const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === "function" ? unstable_outsidePress : () => false);
6856
+ const outsidePress = typeof unstable_outsidePress === "function" ? outsidePressFn : unstable_outsidePress;
6857
+ const endedOrStartedInsideRef = React.useRef(false);
6858
+ const {
6859
+ escapeKey: escapeKeyBubbles,
6860
+ outsidePress: outsidePressBubbles
6861
+ } = normalizeProp(bubbles);
6862
+ const {
6863
+ escapeKey: escapeKeyCapture,
6864
+ outsidePress: outsidePressCapture
6865
+ } = normalizeProp(capture);
6866
+ const isComposingRef = React.useRef(false);
6867
+ const closeOnEscapeKeyDown = useEffectEvent((event) => {
6868
+ var _dataRef$current$floa;
6869
+ if (!open || !enabled || !escapeKey || event.key !== "Escape") {
6870
+ return;
6871
+ }
6872
+ if (isComposingRef.current) {
6873
+ return;
6874
+ }
6875
+ const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
6876
+ const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
6877
+ if (!escapeKeyBubbles) {
6878
+ event.stopPropagation();
6879
+ if (children.length > 0) {
6880
+ let shouldDismiss = true;
6881
+ children.forEach((child) => {
6882
+ var _child$context;
6883
+ if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
6884
+ shouldDismiss = false;
6885
+ return;
6886
+ }
6887
+ });
6888
+ if (!shouldDismiss) {
6889
+ return;
6890
+ }
6891
+ }
6892
+ }
6893
+ onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, "escape-key");
6894
+ });
6895
+ const closeOnEscapeKeyDownCapture = useEffectEvent((event) => {
6896
+ var _getTarget2;
6897
+ const callback = () => {
6898
+ var _getTarget;
6899
+ closeOnEscapeKeyDown(event);
6900
+ (_getTarget = getTarget(event)) == null || _getTarget.removeEventListener("keydown", callback);
6901
+ };
6902
+ (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener("keydown", callback);
6903
+ });
6904
+ const closeOnPressOutside = useEffectEvent((event) => {
6905
+ var _dataRef$current$floa2;
6906
+ const insideReactTree = dataRef.current.insideReactTree;
6907
+ dataRef.current.insideReactTree = false;
6908
+ const endedOrStartedInside = endedOrStartedInsideRef.current;
6909
+ endedOrStartedInsideRef.current = false;
6910
+ if (outsidePressEvent === "click" && endedOrStartedInside) {
6911
+ return;
6912
+ }
6913
+ if (insideReactTree) {
6914
+ return;
6915
+ }
6916
+ if (typeof outsidePress === "function" && !outsidePress(event)) {
6917
+ return;
6918
+ }
6919
+ const target = getTarget(event);
6920
+ const inertSelector = "[" + createAttribute("inert") + "]";
6921
+ const markers = getDocument$1(elements.floating).querySelectorAll(inertSelector);
6922
+ let targetRootAncestor = isElement(target) ? target : null;
6923
+ while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
6924
+ const nextParent = getParentNode(targetRootAncestor);
6925
+ if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
6926
+ break;
6927
+ }
6928
+ targetRootAncestor = nextParent;
6929
+ }
6930
+ if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
6931
+ !contains(target, elements.floating) && // If the target root element contains none of the markers, then the
6932
+ // element was injected after the floating element rendered.
6933
+ Array.from(markers).every((marker) => !contains(targetRootAncestor, marker))) {
6934
+ return;
6935
+ }
6936
+ if (isHTMLElement(target) && floating) {
6937
+ const lastTraversableNode = isLastTraversableNode(target);
6938
+ const style = getComputedStyle$1(target);
6939
+ const scrollRe = /auto|scroll/;
6940
+ const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
6941
+ const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
6942
+ const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
6943
+ const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
6944
+ const isRTL2 = style.direction === "rtl";
6945
+ const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
6946
+ const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
6947
+ if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
6948
+ return;
6949
+ }
6950
+ }
6951
+ const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
6952
+ const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => {
6953
+ var _node$context;
6954
+ return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
6955
+ });
6956
+ if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
6957
+ return;
6958
+ }
6959
+ const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
6960
+ if (children.length > 0) {
6961
+ let shouldDismiss = true;
6962
+ children.forEach((child) => {
6963
+ var _child$context2;
6964
+ if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
6965
+ shouldDismiss = false;
6966
+ return;
6967
+ }
6968
+ });
6969
+ if (!shouldDismiss) {
6970
+ return;
6971
+ }
6972
+ }
6973
+ onOpenChange(false, event, "outside-press");
6974
+ });
6975
+ const closeOnPressOutsideCapture = useEffectEvent((event) => {
6976
+ var _getTarget4;
6977
+ const callback = () => {
6978
+ var _getTarget3;
6979
+ closeOnPressOutside(event);
6980
+ (_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
6981
+ };
6982
+ (_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
6983
+ });
6984
+ React.useEffect(() => {
6985
+ if (!open || !enabled) {
6986
+ return;
6987
+ }
6988
+ dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
6989
+ dataRef.current.__outsidePressBubbles = outsidePressBubbles;
6990
+ let compositionTimeout = -1;
6991
+ function onScroll(event) {
6992
+ onOpenChange(false, event, "ancestor-scroll");
6993
+ }
6994
+ function handleCompositionStart() {
6995
+ window.clearTimeout(compositionTimeout);
6996
+ isComposingRef.current = true;
6997
+ }
6998
+ function handleCompositionEnd() {
6999
+ compositionTimeout = window.setTimeout(
7000
+ () => {
7001
+ isComposingRef.current = false;
7002
+ },
7003
+ // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
7004
+ // Only apply to WebKit for the test to remain 0ms.
7005
+ isWebKit() ? 5 : 0
7006
+ );
7007
+ }
7008
+ const doc = getDocument$1(elements.floating);
7009
+ if (escapeKey) {
7010
+ doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
7011
+ doc.addEventListener("compositionstart", handleCompositionStart);
7012
+ doc.addEventListener("compositionend", handleCompositionEnd);
7013
+ }
7014
+ outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
7015
+ let ancestors = [];
7016
+ if (ancestorScroll) {
7017
+ if (isElement(elements.domReference)) {
7018
+ ancestors = getOverflowAncestors(elements.domReference);
7019
+ }
7020
+ if (isElement(elements.floating)) {
7021
+ ancestors = ancestors.concat(getOverflowAncestors(elements.floating));
7022
+ }
7023
+ if (!isElement(elements.reference) && elements.reference && elements.reference.contextElement) {
7024
+ ancestors = ancestors.concat(getOverflowAncestors(elements.reference.contextElement));
7025
+ }
7026
+ }
7027
+ ancestors = ancestors.filter((ancestor) => {
7028
+ var _doc$defaultView;
7029
+ return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
7030
+ });
7031
+ ancestors.forEach((ancestor) => {
7032
+ ancestor.addEventListener("scroll", onScroll, {
7033
+ passive: true
7034
+ });
7035
+ });
7036
+ return () => {
7037
+ if (escapeKey) {
7038
+ doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
7039
+ doc.removeEventListener("compositionstart", handleCompositionStart);
7040
+ doc.removeEventListener("compositionend", handleCompositionEnd);
7041
+ }
7042
+ outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
7043
+ ancestors.forEach((ancestor) => {
7044
+ ancestor.removeEventListener("scroll", onScroll);
7045
+ });
7046
+ window.clearTimeout(compositionTimeout);
7047
+ };
7048
+ }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
7049
+ React.useEffect(() => {
7050
+ dataRef.current.insideReactTree = false;
7051
+ }, [dataRef, outsidePress, outsidePressEvent]);
7052
+ const reference = React.useMemo(() => ({
7053
+ onKeyDown: closeOnEscapeKeyDown,
7054
+ ...referencePress && {
7055
+ [bubbleHandlerKeys[referencePressEvent]]: (event) => {
7056
+ onOpenChange(false, event.nativeEvent, "reference-press");
7057
+ },
7058
+ ...referencePressEvent !== "click" && {
7059
+ onClick(event) {
7060
+ onOpenChange(false, event.nativeEvent, "reference-press");
7061
+ }
7062
+ }
7063
+ }
7064
+ }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
7065
+ const floating = React.useMemo(() => ({
7066
+ onKeyDown: closeOnEscapeKeyDown,
7067
+ onMouseDown() {
7068
+ endedOrStartedInsideRef.current = true;
7069
+ },
7070
+ onMouseUp() {
7071
+ endedOrStartedInsideRef.current = true;
7072
+ },
7073
+ [captureHandlerKeys[outsidePressEvent]]: () => {
7074
+ dataRef.current.insideReactTree = true;
7075
+ }
7076
+ }), [closeOnEscapeKeyDown, outsidePressEvent, dataRef]);
7077
+ return React.useMemo(() => enabled ? {
7078
+ reference,
7079
+ floating
7080
+ } : {}, [enabled, reference, floating]);
7081
+ }
7082
+ function useFloatingRootContext(options) {
7083
+ const {
7084
+ open = false,
7085
+ onOpenChange: onOpenChangeProp,
7086
+ elements: elementsProp
7087
+ } = options;
7088
+ const floatingId = useId();
7089
+ const dataRef = React.useRef({});
7090
+ const [events] = React.useState(() => createEventEmitter());
7091
+ const nested = useFloatingParentNodeId() != null;
7092
+ if (process.env.NODE_ENV !== "production") {
7093
+ const optionDomReference = elementsProp.reference;
7094
+ if (optionDomReference && !isElement(optionDomReference)) {
7095
+ error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
7096
+ }
7097
+ }
7098
+ const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
7099
+ const onOpenChange = useEffectEvent((open2, event, reason) => {
7100
+ dataRef.current.openEvent = open2 ? event : void 0;
7101
+ events.emit("openchange", {
7102
+ open: open2,
7103
+ event,
7104
+ reason,
7105
+ nested
7106
+ });
7107
+ onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
7108
+ });
7109
+ const refs = React.useMemo(() => ({
7110
+ setPositionReference
7111
+ }), []);
7112
+ const elements = React.useMemo(() => ({
7113
+ reference: positionReference || elementsProp.reference || null,
7114
+ floating: elementsProp.floating || null,
7115
+ domReference: elementsProp.reference
7116
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
7117
+ return React.useMemo(() => ({
7118
+ dataRef,
7119
+ open,
7120
+ onOpenChange,
7121
+ elements,
7122
+ events,
7123
+ floatingId,
7124
+ refs
7125
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
7126
+ }
7127
+ function useFloating(options) {
7128
+ if (options === void 0) {
7129
+ options = {};
7130
+ }
7131
+ const {
7132
+ nodeId
7133
+ } = options;
7134
+ const internalRootContext = useFloatingRootContext({
7135
+ ...options,
7136
+ elements: {
7137
+ reference: null,
7138
+ floating: null,
7139
+ ...options.elements
7140
+ }
7141
+ });
7142
+ const rootContext = options.rootContext || internalRootContext;
7143
+ const computedElements = rootContext.elements;
7144
+ const [_domReference, setDomReference] = React.useState(null);
7145
+ const [positionReference, _setPositionReference] = React.useState(null);
7146
+ const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
7147
+ const domReference = optionDomReference || _domReference;
7148
+ const domReferenceRef = React.useRef(null);
7149
+ const tree = useFloatingTree();
7150
+ index$1(() => {
7151
+ if (domReference) {
7152
+ domReferenceRef.current = domReference;
7153
+ }
7154
+ }, [domReference]);
7155
+ const position = useFloating$1({
7156
+ ...options,
7157
+ elements: {
7158
+ ...computedElements,
7159
+ ...positionReference && {
7160
+ reference: positionReference
7161
+ }
7162
+ }
7163
+ });
7164
+ const setPositionReference = React.useCallback((node) => {
7165
+ const computedPositionReference = isElement(node) ? {
7166
+ getBoundingClientRect: () => node.getBoundingClientRect(),
7167
+ getClientRects: () => node.getClientRects(),
7168
+ contextElement: node
7169
+ } : node;
7170
+ _setPositionReference(computedPositionReference);
7171
+ position.refs.setReference(computedPositionReference);
7172
+ }, [position.refs]);
7173
+ const setReference = React.useCallback((node) => {
7174
+ if (isElement(node) || node === null) {
7175
+ domReferenceRef.current = node;
7176
+ setDomReference(node);
7177
+ }
7178
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7179
+ // `null` to support `positionReference` + an unstable `reference`
7180
+ // callback ref.
7181
+ node !== null && !isElement(node)) {
7182
+ position.refs.setReference(node);
7183
+ }
7184
+ }, [position.refs]);
7185
+ const refs = React.useMemo(() => ({
7186
+ ...position.refs,
7187
+ setReference,
7188
+ setPositionReference,
7189
+ domReference: domReferenceRef
7190
+ }), [position.refs, setReference, setPositionReference]);
7191
+ const elements = React.useMemo(() => ({
7192
+ ...position.elements,
7193
+ domReference
7194
+ }), [position.elements, domReference]);
7195
+ const context2 = React.useMemo(() => ({
7196
+ ...position,
7197
+ ...rootContext,
7198
+ refs,
7199
+ elements,
7200
+ nodeId
7201
+ }), [position, refs, elements, nodeId, rootContext]);
7202
+ index$1(() => {
7203
+ rootContext.dataRef.current.floatingContext = context2;
7204
+ const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
7205
+ if (node) {
7206
+ node.context = context2;
7207
+ }
7208
+ });
7209
+ return React.useMemo(() => ({
7210
+ ...position,
7211
+ context: context2,
7212
+ refs,
7213
+ elements
7214
+ }), [position, refs, elements, context2]);
7215
+ }
7216
+ function mergeProps(userProps, propsList, elementKey) {
7217
+ const map = /* @__PURE__ */ new Map();
7218
+ const isItem = elementKey === "item";
7219
+ let domUserProps = userProps;
7220
+ if (isItem && userProps) {
7221
+ const {
7222
+ [ACTIVE_KEY]: _,
7223
+ [SELECTED_KEY]: __,
7224
+ ...validProps
7225
+ } = userProps;
7226
+ domUserProps = validProps;
7227
+ }
7228
+ return {
7229
+ ...elementKey === "floating" && {
7230
+ tabIndex: -1,
7231
+ [FOCUSABLE_ATTRIBUTE]: ""
7232
+ },
7233
+ ...domUserProps,
7234
+ ...propsList.map((value) => {
7235
+ const propsOrGetProps = value ? value[elementKey] : null;
7236
+ if (typeof propsOrGetProps === "function") {
7237
+ return userProps ? propsOrGetProps(userProps) : null;
7238
+ }
7239
+ return propsOrGetProps;
7240
+ }).concat(userProps).reduce((acc, props) => {
7241
+ if (!props) {
7242
+ return acc;
7243
+ }
7244
+ Object.entries(props).forEach((_ref) => {
7245
+ let [key, value] = _ref;
7246
+ if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
7247
+ return;
7248
+ }
7249
+ if (key.indexOf("on") === 0) {
7250
+ if (!map.has(key)) {
7251
+ map.set(key, []);
7252
+ }
7253
+ if (typeof value === "function") {
7254
+ var _map$get;
7255
+ (_map$get = map.get(key)) == null || _map$get.push(value);
7256
+ acc[key] = function() {
7257
+ var _map$get2;
7258
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7259
+ args[_key] = arguments[_key];
7260
+ }
7261
+ return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn) => fn(...args)).find((val) => val !== void 0);
7262
+ };
7263
+ }
7264
+ } else {
7265
+ acc[key] = value;
7266
+ }
7267
+ });
7268
+ return acc;
7269
+ }, {})
7270
+ };
7271
+ }
7272
+ function useInteractions(propsList) {
7273
+ if (propsList === void 0) {
7274
+ propsList = [];
7275
+ }
7276
+ const referenceDeps = propsList.map((key) => key == null ? void 0 : key.reference);
7277
+ const floatingDeps = propsList.map((key) => key == null ? void 0 : key.floating);
7278
+ const itemDeps = propsList.map((key) => key == null ? void 0 : key.item);
7279
+ const getReferenceProps = React.useCallback(
7280
+ (userProps) => mergeProps(userProps, propsList, "reference"),
7281
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7282
+ referenceDeps
7283
+ );
7284
+ const getFloatingProps = React.useCallback(
7285
+ (userProps) => mergeProps(userProps, propsList, "floating"),
7286
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7287
+ floatingDeps
7288
+ );
7289
+ const getItemProps = React.useCallback(
7290
+ (userProps) => mergeProps(userProps, propsList, "item"),
7291
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7292
+ itemDeps
7293
+ );
7294
+ return React.useMemo(() => ({
7295
+ getReferenceProps,
7296
+ getFloatingProps,
7297
+ getItemProps
7298
+ }), [getReferenceProps, getFloatingProps, getItemProps]);
7299
+ }
7300
+ const ModalContext = createContext(null);
7301
+ const Modal = (props) => {
7302
+ const {
7303
+ open,
7304
+ onOpenChange,
7305
+ size = "md",
7306
+ preventOverlayClose = false,
7307
+ children,
7308
+ id,
7309
+ ...rest
7310
+ } = props;
7311
+ const [className, otherProps] = splitProps(rest);
7312
+ const classes = modal({ size });
7313
+ const [isClosing, setIsClosing] = useState(false);
7314
+ const [shouldRender, setShouldRender] = useState(open);
7315
+ const timeoutRef = useRef(null);
7316
+ const { refs, context: context2 } = useFloating({
7317
+ open,
7318
+ onOpenChange
7319
+ });
7320
+ const dismiss = useDismiss(context2, {
7321
+ outsidePress: !preventOverlayClose
7322
+ });
7323
+ const { getFloatingProps } = useInteractions([dismiss]);
7324
+ useEffect(() => {
7325
+ if (open) {
7326
+ setShouldRender(true);
7327
+ setIsClosing(false);
7328
+ if (timeoutRef.current) {
7329
+ clearTimeout(timeoutRef.current);
7330
+ timeoutRef.current = null;
7331
+ }
7332
+ } else if (shouldRender) {
7333
+ setIsClosing(true);
7334
+ timeoutRef.current = setTimeout(() => {
7335
+ setShouldRender(false);
7336
+ setIsClosing(false);
7337
+ }, 150);
7338
+ }
7339
+ return () => {
7340
+ if (timeoutRef.current) {
7341
+ clearTimeout(timeoutRef.current);
7342
+ }
7343
+ };
7344
+ }, [open, shouldRender]);
7345
+ const contextValue = {
7346
+ open: shouldRender && !isClosing,
7347
+ onClose: () => onOpenChange(false),
7348
+ preventOverlayClose
7349
+ };
7350
+ if (!shouldRender) {
7351
+ return null;
7352
+ }
7353
+ const dataState = isClosing ? "closing" : "open";
7354
+ return /* @__PURE__ */ jsx(ModalContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(FloatingPortal, { children: [
7355
+ /* @__PURE__ */ jsx(
7356
+ FloatingOverlay,
7357
+ {
7358
+ lockScroll: true,
7359
+ className: cx(classes.overlay),
7360
+ "data-state": dataState,
7361
+ onClick: preventOverlayClose ? void 0 : () => onOpenChange(false),
7362
+ "aria-hidden": "true"
7363
+ }
7364
+ ),
7365
+ /* @__PURE__ */ jsx(FloatingFocusManager, { context: context2, modal: true, children: /* @__PURE__ */ jsx(
7366
+ Box,
7367
+ {
7368
+ ref: refs.setFloating,
7369
+ className: cx(classes.container, className),
7370
+ "data-state": dataState,
7371
+ id,
7372
+ role: "dialog",
7373
+ "aria-modal": "true",
7374
+ ...getFloatingProps(),
7375
+ ...otherProps,
7376
+ children
7377
+ }
7378
+ ) })
7379
+ ] }) });
7380
+ };
7381
+ const ChipGroupContext = createContext(
7382
+ null
7383
+ );
7384
+ const useChipGroup = () => {
7385
+ return useContext(ChipGroupContext);
7386
+ };
7387
+ const chipSizeToIconSize = {
7388
+ sm: "20",
7389
+ md: "20",
7390
+ lg: "24"
7391
+ };
7392
+ const Chip = (props) => {
7393
+ const {
7394
+ size = "md",
7395
+ children,
7396
+ loading,
7397
+ disabled,
7398
+ deleted,
7399
+ before,
7400
+ after,
7401
+ dismissable,
7402
+ onDismiss,
7403
+ value,
7404
+ gap,
7405
+ onClick,
7406
+ ...rest
7407
+ } = props;
7408
+ const [className, otherProps] = splitProps(rest);
7409
+ const groupContext = useChipGroup();
7410
+ const buttonRef = useRef(null);
7411
+ const isSelectable = value !== void 0 && groupContext !== null;
7412
+ useEffect(() => {
7413
+ if (isSelectable && value && groupContext) {
7414
+ groupContext.registerChip(value, buttonRef);
7415
+ return () => groupContext.unregisterChip(value);
7416
+ }
7417
+ }, [isSelectable, value, groupContext]);
7418
+ const isSelected = isSelectable ? groupContext.type === "single" ? groupContext.value === value : Array.isArray(groupContext.value) && groupContext.value.includes(value) : false;
7419
+ const isMultiSelected = isSelectable && groupContext.type === "multi" && isSelected;
7420
+ const hasBefore = Boolean(before) || isMultiSelected;
7421
+ const hasAfter = Boolean(after) || dismissable;
7422
+ const classes = chip({
7423
+ size,
7424
+ before: hasBefore,
7425
+ after: hasAfter
7426
+ });
7427
+ const iconSize = chipSizeToIconSize[size];
7428
+ const handleClick = (e) => {
7429
+ if (dismissable && onDismiss) {
7430
+ onDismiss();
7431
+ } else if (isSelectable && groupContext) {
7432
+ if (groupContext.type === "single") {
7433
+ groupContext.onChange(value);
7434
+ } else {
7435
+ const currentValues = Array.isArray(groupContext.value) ? groupContext.value : [];
7436
+ const newValues = currentValues.includes(value) ? currentValues.filter((v) => v !== value) : [...currentValues, value];
7437
+ groupContext.onChange(newValues);
7438
+ }
7439
+ } else if (onClick) {
7440
+ onClick(e);
7441
+ }
7442
+ };
7443
+ const handleKeyDown = (e) => {
7444
+ if (!isSelectable || !groupContext || !value) return;
7445
+ if (groupContext.type === "single") {
7446
+ if (e.key === "ArrowRight" || e.key === "ArrowDown") {
7447
+ e.preventDefault();
7448
+ groupContext.focusChip("next", value);
7449
+ } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
7450
+ e.preventDefault();
7451
+ groupContext.focusChip("prev", value);
7452
+ }
7453
+ }
7454
+ };
7455
+ const childText = typeof children === "string" ? children : void 0;
7456
+ const ariaLabel = dismissable && childText ? `${childText}, dismiss` : void 0;
7457
+ const role = isSelectable ? groupContext.type === "single" ? "radio" : "checkbox" : void 0;
7458
+ const getTabIndex3 = () => {
7459
+ if (!isSelectable || !groupContext) return void 0;
7460
+ if (groupContext.type === "single") {
7461
+ if (isSelected) return 0;
7462
+ const hasSelection = groupContext.value !== void 0 && groupContext.value !== "";
7463
+ if (!hasSelection && groupContext.chipValues[0] === value) return 0;
7464
+ return -1;
7465
+ }
7466
+ return 0;
7467
+ };
7468
+ return /* @__PURE__ */ jsxs(
7469
+ Box,
7470
+ {
7471
+ as: "button",
7472
+ ref: buttonRef,
7473
+ className: cx(classes.container, className),
7474
+ onClick: handleClick,
7475
+ onKeyDown: handleKeyDown,
7476
+ tabIndex: getTabIndex3(),
7477
+ ...disabled && {
7478
+ disabled: true,
7479
+ "aria-disabled": true
7480
+ },
7481
+ "aria-label": ariaLabel,
7482
+ role,
7483
+ "aria-checked": isSelectable ? isSelected : void 0,
7484
+ "data-selected": isSelected ? true : void 0,
7485
+ "data-loading": loading ? true : void 0,
7486
+ "aria-busy": loading ? true : void 0,
7487
+ type: "button",
7488
+ "data-deleted": deleted ? true : void 0,
7489
+ ...otherProps,
7490
+ children: [
7491
+ /* @__PURE__ */ jsxs(HStack, { gap: gap || "4", opacity: loading ? 0 : 1, children: [
7492
+ isMultiSelected && /* @__PURE__ */ jsx(
7493
+ Icon,
7494
+ {
7495
+ name: "check",
7496
+ size: iconSize,
7497
+ className: classes.icon,
7498
+ "aria-hidden": true
7499
+ }
7500
+ ),
7501
+ before,
7502
+ children,
7503
+ dismissable ? /* @__PURE__ */ jsx(Icon, { name: "x", size: iconSize, className: classes.icon, "aria-hidden": true }) : after
7504
+ ] }),
7505
+ loading && /* @__PURE__ */ jsx(Spinner, { size: "xs", centered: true })
7506
+ ]
7507
+ }
7508
+ );
7509
+ };
7510
+ const animationStyles = {
7511
+ pop: css({
7512
+ animationName: "badgePop",
7513
+ animationDuration: "normal",
7514
+ animationTimingFunction: "default"
7515
+ }),
7516
+ popStandalone: css({
7517
+ animationName: "badgePopStandalone",
7518
+ animationDuration: "normal",
7519
+ animationTimingFunction: "default"
7520
+ })
7521
+ };
7522
+ const Badge = (props) => {
7523
+ const {
7524
+ count: count2,
7525
+ showZero = false,
7526
+ overflowCount = 99,
7527
+ variant = "danger",
7528
+ size = "md",
7529
+ children,
7530
+ ref,
7531
+ ...rest
7532
+ } = props;
7533
+ const [className, otherProps] = splitProps(rest);
7534
+ const prevCountRef = useRef(count2);
7535
+ const [isAnimating, setIsAnimating] = useState(false);
7536
+ useEffect(() => {
7537
+ if (count2 !== void 0 && prevCountRef.current !== count2) {
7538
+ if (prevCountRef.current !== void 0) {
7539
+ setIsAnimating(true);
7540
+ const timer = setTimeout(() => setIsAnimating(false), 200);
7541
+ return () => clearTimeout(timer);
7542
+ }
7543
+ }
7544
+ prevCountRef.current = count2;
7545
+ }, [count2]);
7546
+ const isCountMode = count2 !== void 0;
7547
+ const isDotMode = !isCountMode;
7548
+ const isVisible = isDotMode || count2 !== 0 || showZero;
7549
+ const displayCount = isCountMode && count2 !== void 0 ? count2 > overflowCount ? `${overflowCount}+` : count2 : null;
7550
+ const isStandalone = !children;
7551
+ const classes = badge({
7552
+ size,
7553
+ standalone: isStandalone,
7554
+ dot: isDotMode,
7555
+ variant
7556
+ });
7557
+ const animationClass = isAnimating ? isStandalone ? animationStyles.popStandalone : animationStyles.pop : "";
7558
+ if (!isVisible && !children) {
7559
+ return null;
7560
+ }
7561
+ const indicator = isVisible ? /* @__PURE__ */ jsx(Box, { as: "span", className: cx(classes.indicator, animationClass), children: displayCount }) : null;
7562
+ if (isStandalone) {
7563
+ return /* @__PURE__ */ jsx(
7564
+ Box,
7565
+ {
7566
+ as: "span",
7567
+ ref,
7568
+ className: cx(classes.root, className),
7569
+ ...otherProps,
7570
+ children: indicator
7571
+ }
7572
+ );
7573
+ }
7574
+ return /* @__PURE__ */ jsxs(
7575
+ Box,
7576
+ {
7577
+ as: "span",
7578
+ ref,
7579
+ className: cx(classes.root, className),
7580
+ ...otherProps,
7581
+ children: [
7582
+ children,
7583
+ indicator
7584
+ ]
7585
+ }
7586
+ );
7587
+ };
3813
7588
  export {
7589
+ Avatar,
7590
+ Badge,
3814
7591
  Box,
3815
7592
  Breadcrumbs,
3816
7593
  Button,
3817
7594
  Card,
3818
7595
  CheckBox,
3819
7596
  CheckBoxInput,
7597
+ Chip,
3820
7598
  Divider,
3821
7599
  FormField,
3822
7600
  Heading,
@@ -3825,6 +7603,7 @@ export {
3825
7603
  IconNames,
3826
7604
  Link,
3827
7605
  Menu,
7606
+ Modal,
3828
7607
  Pre,
3829
7608
  Radio,
3830
7609
  RadioInput,