@sanity/ui 3.0.0-static.27 → 3.0.0-static.28

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 (217) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks-cjs/_visual-editing.cjs +710 -840
  3. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  4. package/dist/_chunks-cjs/refractor.cjs +2 -2
  5. package/dist/_chunks-cjs/refractor.cjs.map +1 -1
  6. package/dist/_chunks-es/_visual-editing.js +705 -834
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/css/layers.css +4 -0
  10. package/dist/css/primitives/popover/popover.css +4 -0
  11. package/dist/css.cjs +58 -49
  12. package/dist/css.cjs.map +1 -1
  13. package/dist/css.d.cts +13 -5
  14. package/dist/css.d.ts +13 -5
  15. package/dist/css.js +58 -49
  16. package/dist/css.js.map +1 -1
  17. package/dist/index.cjs +2006 -1824
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.css +1 -0
  20. package/dist/index.d.cts +34 -17
  21. package/dist/index.d.ts +34 -17
  22. package/dist/index.js +2002 -1821
  23. package/dist/index.js.map +1 -1
  24. package/dist/theme.cjs +7 -7
  25. package/dist/theme.cjs.map +1 -1
  26. package/dist/theme.js +7 -7
  27. package/dist/theme.js.map +1 -1
  28. package/exports/_visual-editing.ts +1 -1
  29. package/package.json +10 -15
  30. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  31. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  32. package/src/core/components/autocomplete/autocomplete.tsx +13 -17
  33. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
  34. package/src/core/components/autocomplete/constants.ts +3 -1
  35. package/src/core/components/autocomplete/types.ts +1 -1
  36. package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
  37. package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
  38. package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
  39. package/src/core/components/dialog/dialog.tsx +12 -6
  40. package/src/core/components/dialog/dialogCard.tsx +89 -54
  41. package/src/core/components/dialog/dialogContext.ts +1 -1
  42. package/src/core/components/dialog/dialogProvider.tsx +1 -1
  43. package/src/core/components/dialog/index.ts +1 -0
  44. package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
  45. package/src/core/components/hotkeys/hotkeys.tsx +3 -2
  46. package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
  47. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
  48. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
  49. package/src/core/components/menu/helpers.ts +1 -1
  50. package/src/core/components/menu/menu.tsx +6 -3
  51. package/src/core/components/menu/menuButton.tsx +5 -3
  52. package/src/core/components/menu/menuDivider.tsx +1 -1
  53. package/src/core/components/menu/menuGroup.tsx +8 -4
  54. package/src/core/components/menu/menuItem.tsx +4 -2
  55. package/src/core/components/tab/tab.tsx +2 -2
  56. package/src/core/components/tab/tabList.tsx +2 -2
  57. package/src/core/components/tab/tabPanel.tsx +2 -2
  58. package/src/core/components/toast/toast.tsx +7 -2
  59. package/src/core/components/toast/toastLayer.tsx +3 -2
  60. package/src/core/components/toast/toastProvider.tsx +1 -1
  61. package/src/core/components/tree/tree.tsx +2 -2
  62. package/src/core/components/tree/treeGroup.tsx +2 -2
  63. package/src/core/components/tree/treeItem.tsx +13 -6
  64. package/src/core/components/tree/types.ts +0 -1
  65. package/src/core/components/virtualList/virtualList.tsx +10 -5
  66. package/src/core/helpers/focus.ts +0 -8
  67. package/src/core/hooks/useArrayProp.ts +1 -1
  68. package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
  69. package/src/core/hooks/useElementSize.ts +1 -1
  70. package/src/core/hooks/useResponsiveProp.ts +1 -1
  71. package/src/core/index.ts +83 -7
  72. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
  73. package/src/core/primitives/_selectable/index.ts +1 -0
  74. package/src/core/primitives/_selectable/selectable.tsx +13 -3
  75. package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
  76. package/src/core/primitives/arrow/arrow.tsx +1 -1
  77. package/src/core/primitives/avatar/avatar.tsx +4 -3
  78. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  79. package/src/core/primitives/avatar/avatarStack.tsx +4 -4
  80. package/src/core/primitives/avatar/types.ts +17 -0
  81. package/src/core/primitives/badge/badge.tsx +2 -1
  82. package/src/core/primitives/badge/types.ts +11 -2
  83. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
  84. package/src/core/primitives/box/box.tsx +1 -1
  85. package/src/core/primitives/box/index.ts +1 -0
  86. package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
  87. package/src/core/primitives/button/__workshop__/index.ts +5 -0
  88. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  89. package/src/core/primitives/button/button.tsx +15 -14
  90. package/src/core/primitives/button/index.ts +1 -0
  91. package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
  92. package/src/core/primitives/card/card.tsx +1 -1
  93. package/src/core/primitives/card/types.ts +3 -0
  94. package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
  95. package/src/core/primitives/checkbox/checkbox.tsx +3 -4
  96. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
  97. package/src/core/primitives/code/code.tsx +1 -1
  98. package/src/core/primitives/container/container.tsx +1 -1
  99. package/src/core/primitives/flex/flex.tsx +1 -1
  100. package/src/core/primitives/flex/index.ts +1 -0
  101. package/src/core/primitives/grid/grid.tsx +1 -1
  102. package/src/core/primitives/grid/index.ts +1 -0
  103. package/src/core/primitives/heading/heading.tsx +1 -1
  104. package/src/core/primitives/inline/inline.tsx +1 -1
  105. package/src/core/primitives/kbd/kbd.tsx +1 -1
  106. package/src/core/primitives/label/label.tsx +1 -1
  107. package/src/core/primitives/layer/layer.test.tsx +1 -1
  108. package/src/core/primitives/layer/layer.tsx +2 -2
  109. package/src/core/primitives/layer/layerCard.tsx +3 -3
  110. package/src/core/primitives/layer/layerProvider.tsx +2 -1
  111. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -10
  112. package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
  113. package/src/core/primitives/popover/constants.ts +1 -1
  114. package/src/core/primitives/popover/floating-ui/size.ts +1 -1
  115. package/src/core/primitives/popover/popover.tsx +7 -4
  116. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  117. package/src/core/primitives/popover/types.ts +5 -0
  118. package/src/core/primitives/radio/radio.tsx +2 -2
  119. package/src/core/primitives/select/select.tsx +2 -2
  120. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  121. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  122. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  123. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  124. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  125. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  126. package/src/core/primitives/spinner/spinner.tsx +1 -1
  127. package/src/core/primitives/srOnly/srOnly.tsx +1 -1
  128. package/src/core/primitives/stack/stack.tsx +1 -1
  129. package/src/core/primitives/switch/switch.tsx +1 -6
  130. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  131. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  132. package/src/core/primitives/text/text.tsx +3 -1
  133. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  134. package/src/core/primitives/textArea/textArea.tsx +2 -2
  135. package/src/core/primitives/textInput/textInput.tsx +3 -2
  136. package/src/core/primitives/tooltip/constants.ts +1 -1
  137. package/src/core/primitives/tooltip/tooltip.tsx +5 -3
  138. package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
  139. package/src/core/primitives/types.ts +8 -10
  140. package/src/core/types/radius.ts +1 -1
  141. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  142. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  143. package/src/core/utils/portal/portal.tsx +1 -1
  144. package/src/css/components/dialog/dialog.css.ts +26 -1
  145. package/src/css/components/dialog/dialog.ts +27 -7
  146. package/src/css/components/skeleton/skeleton.ts +3 -1
  147. package/src/css/components/skeleton/types.ts +3 -1
  148. package/src/css/index.ts +75 -5
  149. package/src/css/primitives/_input/input.ts +2 -1
  150. package/src/css/primitives/_input/types.ts +2 -1
  151. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  152. package/src/css/primitives/_selectable/selectable.ts +1 -1
  153. package/src/css/primitives/_selectable/types.ts +1 -1
  154. package/src/css/primitives/avatar/avatar.css.ts +8 -4
  155. package/src/css/primitives/avatar/avatar.ts +1 -1
  156. package/src/css/primitives/badge/types.ts +0 -2
  157. package/src/css/primitives/box/box.ts +35 -37
  158. package/src/css/primitives/box/types.ts +34 -36
  159. package/src/css/primitives/button/button.css.ts +4 -0
  160. package/src/css/primitives/button/button.ts +5 -2
  161. package/src/css/primitives/button/types.ts +4 -11
  162. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  163. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  164. package/src/css/primitives/card/card.css.ts +4 -0
  165. package/src/css/primitives/code/code.ts +3 -1
  166. package/src/css/primitives/code/types.ts +2 -1
  167. package/src/css/primitives/container/container.ts +3 -1
  168. package/src/css/primitives/heading/heading.ts +4 -1
  169. package/src/css/primitives/heading/types.ts +3 -1
  170. package/src/css/primitives/kbd/kbd.ts +1 -1
  171. package/src/css/primitives/kbd/types.ts +1 -1
  172. package/src/css/primitives/label/label.ts +4 -1
  173. package/src/css/primitives/label/types.ts +3 -1
  174. package/src/css/primitives/switch/switch.css.ts +1 -1
  175. package/src/css/primitives/text/text.ts +6 -1
  176. package/src/css/primitives/text/types.ts +5 -2
  177. package/src/theme/v3/defaultFonts.ts +6 -6
  178. package/src/theme/v3/defaultTokens.ts +1 -1
  179. package/bin/sanity-ui.cjs +0 -5
  180. package/dist/ui.css +0 -1
  181. package/src/cli/buildCommand.ts +0 -10
  182. package/src/cli/index.ts +0 -26
  183. package/src/core/components/autocomplete/index.ts +0 -2
  184. package/src/core/components/index.ts +0 -10
  185. package/src/core/helpers/index.ts +0 -5
  186. package/src/core/hooks/index.ts +0 -13
  187. package/src/core/observers/index.ts +0 -2
  188. package/src/core/primitives/index.ts +0 -30
  189. package/src/core/types/avatar.ts +0 -16
  190. package/src/core/types/card.ts +0 -4
  191. package/src/core/types/index.ts +0 -15
  192. package/src/core/types/popover.ts +0 -4
  193. package/src/core/utils/index.ts +0 -4
  194. package/src/css/__theme/index.ts +0 -16
  195. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  196. package/src/css/__theme/lib/contract/index.ts +0 -4
  197. package/src/css/__theme/lib/contract/types.ts +0 -17
  198. package/src/css/__theme/resolveTheme.ts +0 -865
  199. package/src/css/components/index.ts +0 -6
  200. package/src/css/primitives/index.ts +0 -24
  201. package/src/css/props/index.ts +0 -37
  202. package/src/css/utils/srOnly/index.ts +0 -1
  203. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  204. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  205. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  206. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  207. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  208. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  209. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  210. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  211. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  212. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  213. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  214. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  215. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  216. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  217. /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1 } from "@sanity/ui/theme";
2
- import { isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, isHTMLElement, _getArrayProp, EMPTY_ARRAY, useElementSize, useResponsiveProp, Box, Text, useCustomValidity, BoundaryElementContext, Code, useDelayedState, TooltipDelayGroupContext, _isEnterToClickElement, Card, EMPTY_RECORD, Button, Stack, Popover, TextInput, AnimatedSpinnerIcon, useClickOutsideEvent, Flex, containsOrEqualsElement, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, createGlobalScopedContext, usePrefersReducedMotion, Portal, Z_OFFSETS, Layer, Grid, LayerProvider, isRecord, Selectable, _ResizeObserver } from "./_chunks-es/_visual-editing.js";
3
- import { Arrow, CardProvider, DEFAULT_ARROW_ELEMENT, DEFAULT_BOX_ELEMENT, DEFAULT_BUTTON_ELEMENT, DEFAULT_CARD_ELEMENT, DEFAULT_CODE_ELEMENT, DEFAULT_ELEMENT_QUERY_ELEMENT, DEFAULT_FLEX_ELEMENT, DEFAULT_GRID_ELEMENT, DEFAULT_HOTKEYS_ELEMENT, DEFAULT_KBD_ELEMENT, DEFAULT_LAYER_ELEMENT, DEFAULT_MENU_DIVIDER_ELEMENT, DEFAULT_MENU_ELEMENT, DEFAULT_MENU_GROUP_ELEMENT, DEFAULT_MENU_ITEM_ELEMENT, DEFAULT_POPOVER_ELEMENT, DEFAULT_SPINNER_ELEMENT, DEFAULT_STACK_ELEMENT, DEFAULT_TAB_ELEMENT, DEFAULT_TAB_LIST_ELEMENT, DEFAULT_TEXT_ELEMENT, DEFAULT_TEXT_INPUT_ELEMENT, DEFAULT_TOOLTIP_ELEMENT, ElementQuery, Hotkeys, KBD, Menu, MenuDivider, MenuGroup, MenuItem, PortalProvider, Spinner, Tab, TabList, ThemeColorProvider, ThemeProvider, Tooltip, _elementSizeObserver, _getResponsiveProp, useCard, useMatchMedia, useMediaIndex, usePrefersDark, useRootTheme, useTheme, useTheme_v2, useTooltipDelayGroup } from "./_chunks-es/_visual-editing.js";
2
+ import { isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, isHTMLElement, BoundaryElementContext, _isEnterToClickElement, Card, Text, useResponsiveProp, EMPTY_ARRAY, EMPTY_RECORD, Box, Button, Stack, Popover, TextInput, AnimatedSpinnerIcon, useClickOutsideEvent, Flex, containsOrEqualsElement, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, createGlobalScopedContext, usePrefersReducedMotion, Portal, Z_OFFSETS, Layer, Grid, LayerProvider, isRecord, Selectable, _getArrayProp, useCustomValidity, useDelayedState, TooltipDelayGroupContext } from "./_chunks-es/_visual-editing.js";
3
+ import { Arrow, CardProvider, DEFAULT_ARROW_ELEMENT, DEFAULT_BOX_ELEMENT, DEFAULT_BUTTON_ELEMENT, DEFAULT_CARD_ELEMENT, DEFAULT_FLEX_ELEMENT, DEFAULT_GRID_ELEMENT, DEFAULT_HOTKEYS_ELEMENT, DEFAULT_KBD_ELEMENT, DEFAULT_LAYER_ELEMENT, DEFAULT_MENU_DIVIDER_ELEMENT, DEFAULT_MENU_ELEMENT, DEFAULT_MENU_GROUP_ELEMENT, DEFAULT_MENU_ITEM_ELEMENT, DEFAULT_POPOVER_ELEMENT, DEFAULT_SELECTABLE_ELEMENT, DEFAULT_SPINNER_ELEMENT, DEFAULT_STACK_ELEMENT, DEFAULT_TAB_ELEMENT, DEFAULT_TAB_LIST_ELEMENT, DEFAULT_TEXT_ELEMENT, DEFAULT_TEXT_INPUT_ELEMENT, DEFAULT_TOOLTIP_ELEMENT, Hotkeys, KBD, Menu, MenuDivider, MenuGroup, MenuItem, PortalProvider, Spinner, Tab, TabList, ThemeColorProvider, ThemeProvider, Tooltip, _getResponsiveProp, useCard, useMatchMedia, useMediaIndex, usePrefersDark, useRootTheme, useTheme, useTheme_v2, useTooltipDelayGroup } from "./_chunks-es/_visual-editing.js";
4
4
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
5
- import { CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ToggleArrowRightIcon } from "@sanity/icons";
6
- import { useState, useRef, useEffect, useImperativeHandle, Children, isValidElement, Fragment, cloneElement, Component, useReducer, useCallback, useMemo, useContext, useSyncExternalStore, startTransition, memo, useId } from "react";
7
- import { c } from "react-compiler-runtime";
8
- import { label, textOverflow, avatar, avatarArrow, avatarInitials, avatarImage, avatarImageOutline, avatarCounter, avatarStack, badge, checkbox, checkboxInput, checkboxPresentation, container as container$1, heading, radio, radioInput, radioPresentation, select, _inputElement, selectPresentation, srOnly, _switch, _switchElement, _switchPresentation, _switchTrack, _switchThumb, textArea, _inputPresentation, breadcrumbs, dialogCard, dialogLayout, dialogHeader, dialogContent, dialogFooter, dialog, dialogContainer, skeleton, codeSkeleton, headingSkeleton, labelSkeleton, textSkeleton, toast, toastLayer, treeItem, vars } from "@sanity/ui/css";
5
+ import { ChevronDownIcon, CloseIcon, ToggleArrowRightIcon, CheckmarkIcon, RemoveIcon } from "@sanity/icons";
6
+ import { useReducer, useCallback, useRef, useImperativeHandle, useMemo, useEffect, cloneElement, useState, Children, isValidElement, Fragment, useContext, useSyncExternalStore, startTransition, memo, useId, lazy, Suspense, Component } from "react";
7
+ import { c } from "react/compiler-runtime";
8
+ import { breadcrumbs, container as container$1, dialogCard, dialogHeader, dialogContent, dialogScrollerShadowTop, dialogScroller, dialogScrollerShadowBottom, dialogFooter, dialog, dialogContainer, toast, toastLayer, treeItem, vars, label, textOverflow, avatar, avatarArrow, avatarInitials, avatarImage, avatarImageOutline, avatarCounter, avatarStack, badge, checkbox, checkboxInput, checkboxPresentation, code, heading, radio, radioInput, radioPresentation, select, _inputElement, selectPresentation, skeleton, codeSkeleton, headingSkeleton, labelSkeleton, textSkeleton, srOnly, _switch, _switchElement, _switchPresentation, _switchTrack, _switchThumb, textArea, _inputPresentation, BREAKPOINTS } from "@sanity/ui/css";
9
9
  import { px, rem } from "@sanity/ui/css";
10
10
  import { motion, AnimatePresence } from "framer-motion";
11
+ import { ResizeObserver } from "@juggle/resize-observer";
11
12
  const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1;
12
13
  function _responsive(media, values, callback) {
13
14
  return (values?.map(callback) || []).map((statement, mediaIndex) => mediaIndex === 0 ? statement : {
@@ -60,303 +61,314 @@ function focusLastDescendant(element) {
60
61
  }
61
62
  return !1;
62
63
  }
63
- function _isScrollable(el) {
64
- if (!(el instanceof Element)) return !1;
65
- const style = window.getComputedStyle(el);
66
- return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
64
+ function BoundaryElementProvider(props) {
65
+ const $ = c(5), {
66
+ children,
67
+ element
68
+ } = props;
69
+ let t0, t1;
70
+ $[0] !== element ? (t1 = {
71
+ version: 0,
72
+ element
73
+ }, $[0] = element, $[1] = t1) : t1 = $[1], t0 = t1;
74
+ const value = t0;
75
+ let t2;
76
+ return $[2] !== children || $[3] !== value ? (t2 = /* @__PURE__ */ jsx(BoundaryElementContext.Provider, { value, children }), $[2] = children, $[3] = value, $[4] = t2) : t2 = $[4], t2;
67
77
  }
68
- function useArrayProp(val, defaultVal) {
69
- const $ = c(3);
78
+ function AutocompleteOption(props) {
79
+ const $ = c(11), {
80
+ children,
81
+ id,
82
+ onSelect,
83
+ selected,
84
+ value
85
+ } = props;
70
86
  let t0;
71
- $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getArrayProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
72
- const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
73
- return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
87
+ $[0] !== onSelect || $[1] !== value ? (t0 = () => {
88
+ setTimeout(() => {
89
+ onSelect(value);
90
+ }, 0);
91
+ }, $[0] = onSelect, $[1] = value, $[2] = t0) : t0 = $[2];
92
+ const handleClick = t0;
93
+ let t1;
94
+ $[3] !== handleClick ? (t1 = (event) => {
95
+ event.key === "Enter" && !_isEnterToClickElement(event.currentTarget) && handleClick();
96
+ }, $[3] = handleClick, $[4] = t1) : t1 = $[4];
97
+ const handleKeyDown = t1;
98
+ let t2;
99
+ return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children }), $[5] = children, $[6] = handleClick, $[7] = handleKeyDown, $[8] = id, $[9] = selected, $[10] = t2) : t2 = $[10], t2;
74
100
  }
75
- function _getElements(element, elementsArg) {
76
- const ret = [element];
77
- for (const el of elementsArg)
78
- Array.isArray(el) ? ret.push(...el) : ret.push(el);
79
- return ret.filter(Boolean);
101
+ function autocompleteReducer(state, msg) {
102
+ return msg.type === "input/change" ? {
103
+ ...state,
104
+ activeValue: null,
105
+ focused: !0,
106
+ query: msg.query
107
+ } : msg.type === "input/focus" ? {
108
+ ...state,
109
+ focused: !0
110
+ } : msg.type === "root/blur" ? {
111
+ ...state,
112
+ focused: !1,
113
+ query: null
114
+ } : msg.type === "root/clear" ? {
115
+ ...state,
116
+ activeValue: null,
117
+ query: null,
118
+ value: null
119
+ } : msg.type === "root/escape" ? {
120
+ ...state,
121
+ focused: !1,
122
+ query: null
123
+ } : msg.type === "root/open" ? {
124
+ ...state,
125
+ query: state.query || msg.query
126
+ } : msg.type === "root/setActiveValue" ? {
127
+ ...state,
128
+ activeValue: msg.value,
129
+ listFocused: msg.listFocused || state.listFocused
130
+ } : msg.type === "root/setListFocused" ? {
131
+ ...state,
132
+ listFocused: msg.listFocused
133
+ } : msg.type === "value/change" ? {
134
+ ...state,
135
+ activeValue: msg.value,
136
+ query: null,
137
+ value: msg.value
138
+ } : state;
80
139
  }
81
- function useClickOutside(listener, t0, boundaryElement) {
82
- const $ = c(12), elementsArg = t0 === void 0 ? EMPTY_ARRAY : t0, [element, setElement] = useState(null);
83
- let t1;
84
- $[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2];
85
- const [elements, setElements] = useState(t1), elementsRef = useRef(elements);
86
- let t2, t3;
87
- $[3] !== element || $[4] !== elementsArg ? (t2 = () => {
88
- const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
89
- if (prevElements.length !== nextElements.length) {
90
- setElements(nextElements), elementsRef.current = nextElements;
91
- return;
92
- }
93
- for (const el of prevElements)
94
- if (!nextElements.includes(el)) {
95
- setElements(nextElements), elementsRef.current = nextElements;
96
- return;
97
- }
98
- for (const el_0 of nextElements)
99
- if (!prevElements.includes(el_0)) {
100
- setElements(nextElements), elementsRef.current = nextElements;
140
+ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "Home", "End", "PageUp", "PageDown", "Meta", "Tab", "CapsLock"], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_AUTOCOMPLETE_ELEMENT = "input", DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
141
+ function Autocomplete(props) {
142
+ const {
143
+ as = DEFAULT_AUTOCOMPLETE_ELEMENT,
144
+ border = !0,
145
+ customValidity,
146
+ disabled,
147
+ filterOption: filterOptionProp,
148
+ fontSize = 2,
149
+ icon,
150
+ id,
151
+ listBox = EMPTY_RECORD,
152
+ loading,
153
+ onBlur,
154
+ onChange,
155
+ onFocus,
156
+ onQueryChange,
157
+ onSelect,
158
+ openButton,
159
+ openOnFocus,
160
+ options: optionsProp,
161
+ padding: paddingProp = 3,
162
+ popover = EMPTY_RECORD,
163
+ prefix,
164
+ radius = 2,
165
+ readOnly,
166
+ ref: forwardedRef,
167
+ relatedElements,
168
+ renderOption: renderOptionProp,
169
+ renderPopover,
170
+ renderValue = DEFAULT_RENDER_VALUE,
171
+ suffix,
172
+ value: valueProp,
173
+ ...rest
174
+ } = props, [state, dispatch] = useReducer(autocompleteReducer, {
175
+ activeValue: valueProp || null,
176
+ focused: !1,
177
+ listFocused: !1,
178
+ query: null,
179
+ value: valueProp || null
180
+ }), {
181
+ activeValue,
182
+ focused,
183
+ listFocused,
184
+ query,
185
+ value
186
+ } = state, defaultRenderOption = useCallback(({
187
+ value: value_0
188
+ }) => /* @__PURE__ */ jsx(Card, { as: "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", children: value_0 }) }), [fontSize, paddingProp]), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1);
189
+ useImperativeHandle(forwardedRef, () => inputElementRef.current);
190
+ const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useResponsiveProp(paddingProp), currentOption = useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = useMemo(() => options.filter((option) => query ? filterOption(query, option) : !0), [filterOption, options, query]), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = useCallback((event) => {
191
+ setTimeout(() => {
192
+ if (popoverMouseWithinRef.current)
101
193
  return;
194
+ const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []);
195
+ let focusInside = !1;
196
+ if (document.activeElement) {
197
+ for (const e of elements)
198
+ if (e === document.activeElement || e.contains(document.activeElement)) {
199
+ focusInside = !0;
200
+ break;
201
+ }
102
202
  }
103
- }, t3 = [element, elementsArg], $[3] = element, $[4] = elementsArg, $[5] = t2, $[6] = t3) : (t2 = $[5], t3 = $[6]), useEffect(t2, t3);
104
- let t4, t5;
105
- return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => {
106
- if (!listener)
203
+ focusInside === !1 && (dispatch({
204
+ type: "root/blur"
205
+ }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
206
+ }, 0);
207
+ }, [onBlur, onQueryChange, relatedElements]), handleRootFocus = useCallback((event_0) => {
208
+ const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
209
+ listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
210
+ type: "root/setListFocused",
211
+ listFocused: listFocused_0
212
+ }));
213
+ }, []), handleOptionSelect = useCallback((v) => {
214
+ dispatch({
215
+ type: "value/change",
216
+ value: v
217
+ }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
218
+ }, [onChange, onSelect, onQueryChange]), handleRootKeyDown = useCallback((event_1) => {
219
+ if (event_1.key === "ArrowDown") {
220
+ if (event_1.preventDefault(), !filteredOptionsLen) return;
221
+ const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
222
+ nextActiveOption && dispatch({
223
+ type: "root/setActiveValue",
224
+ value: nextActiveOption.value,
225
+ listFocused: !0
226
+ });
107
227
  return;
108
- const handleWindowMouseDown = (evt) => {
109
- const target = evt.target;
110
- if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
111
- for (const el_1 of elements)
112
- if (target === el_1 || el_1.contains(target))
113
- return;
114
- listener(evt);
115
- }
116
- };
117
- return window.addEventListener("mousedown", handleWindowMouseDown), () => {
118
- window.removeEventListener("mousedown", handleWindowMouseDown);
119
- };
120
- }, t5 = [boundaryElement, listener, elements], $[7] = boundaryElement, $[8] = elements, $[9] = listener, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), useEffect(t4, t5), setElement;
121
- }
122
- function useElementRect(element) {
123
- return useElementSize(element)?._contentRect || null;
124
- }
125
- function useForwardedRef(ref) {
126
- const $ = c(1), innerRef = useRef(null);
127
- let t0;
128
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => innerRef.current, $[0] = t0) : t0 = $[0], useImperativeHandle(ref, t0), innerRef;
129
- }
130
- const DEFAULT_LABEL_ELEMENT = "div";
131
- function Label(props) {
132
- const $ = c(28);
133
- let accent, align, children, className, rest, t0, t1, t2, t3, textOverflowProp;
134
- $[0] !== props ? ({
135
- accent,
136
- align,
137
- as: t0,
138
- children,
139
- className,
140
- muted: t1,
141
- size: t2,
142
- textOverflow: textOverflowProp,
143
- weight: t3,
144
- ...rest
145
- } = props, $[0] = props, $[1] = accent, $[2] = align, $[3] = children, $[4] = className, $[5] = rest, $[6] = t0, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = textOverflowProp) : (accent = $[1], align = $[2], children = $[3], className = $[4], rest = $[5], t0 = $[6], t1 = $[7], t2 = $[8], t3 = $[9], textOverflowProp = $[10]);
146
- const Element2 = t0 === void 0 ? DEFAULT_LABEL_ELEMENT : t0, muted = t1 === void 0 ? !1 : t1, size = t2 === void 0 ? 1 : t2, weight = t3 === void 0 ? "regular" : t3;
147
- let t4;
148
- $[11] !== accent || $[12] !== align || $[13] !== className || $[14] !== muted || $[15] !== size || $[16] !== weight ? (t4 = label({
149
- className,
150
- accent,
151
- align,
152
- muted,
153
- size,
154
- weight
155
- }), $[11] = accent, $[12] = align, $[13] = className, $[14] = muted, $[15] = size, $[16] = weight, $[17] = t4) : t4 = $[17];
156
- let t5;
157
- $[18] !== textOverflowProp ? (t5 = textOverflow({
158
- textOverflow: textOverflowProp
159
- }), $[18] = textOverflowProp, $[19] = t5) : t5 = $[19];
160
- let t6;
161
- $[20] !== children || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx("span", { className: t5, children }), $[20] = children, $[21] = t5, $[22] = t6) : t6 = $[22];
162
- let t7;
163
- return $[23] !== Element2 || $[24] !== rest || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsx(Element2, { "data-ui": "Label", ...rest, className: t4, children: t6 }), $[23] = Element2, $[24] = rest, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t7;
164
- }
165
- const DEFAULT_AVATAR_ELEMENT = "span";
166
- function Avatar(props) {
167
- const $ = c(51), t0 = props;
168
- let __unstable_hideInnerStroke, animateArrowFrom, arrowPositionProp, className, initials, onImageLoadError, rest, src, t1, t2, t3, t4, title;
169
- $[0] !== t0 ? ({
170
- __unstable_hideInnerStroke,
171
- as: t1,
172
- className,
173
- color: t2,
174
- src,
175
- title,
176
- initials,
177
- onImageLoadError,
178
- arrowPosition: arrowPositionProp,
179
- animateArrowFrom,
180
- status: t3,
181
- size: t4,
182
- ...rest
183
- } = t0, $[0] = t0, $[1] = __unstable_hideInnerStroke, $[2] = animateArrowFrom, $[3] = arrowPositionProp, $[4] = className, $[5] = initials, $[6] = onImageLoadError, $[7] = rest, $[8] = src, $[9] = t1, $[10] = t2, $[11] = t3, $[12] = t4, $[13] = title) : (__unstable_hideInnerStroke = $[1], animateArrowFrom = $[2], arrowPositionProp = $[3], className = $[4], initials = $[5], onImageLoadError = $[6], rest = $[7], src = $[8], t1 = $[9], t2 = $[10], t3 = $[11], t4 = $[12], title = $[13]);
184
- const Element2 = t1 === void 0 ? DEFAULT_AVATAR_ELEMENT : t1, color = t2 === void 0 ? "magenta" : t2, sizeProp = t4 === void 0 ? 1 : t4, size = useResponsiveProp(sizeProp), [arrowPosition, setArrowPosition] = useState(animateArrowFrom || arrowPositionProp || "inside"), [imageError, setImageError] = useState(!1);
185
- let t5, t6;
186
- $[14] !== arrowPosition || $[15] !== arrowPositionProp ? (t5 = () => {
187
- if (arrowPosition === arrowPositionProp)
228
+ }
229
+ if (event_1.key === "ArrowUp") {
230
+ if (event_1.preventDefault(), !filteredOptionsLen) return;
231
+ const activeOption_0 = filteredOptions.find((o_1) => o_1.value === activeValue), activeIndex_0 = activeOption_0 ? filteredOptions.indexOf(activeOption_0) : -1, nextActiveOption_0 = filteredOptions[activeIndex_0 === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex_0 - 1) % filteredOptionsLen];
232
+ nextActiveOption_0 && dispatch({
233
+ type: "root/setActiveValue",
234
+ value: nextActiveOption_0.value,
235
+ listFocused: !0
236
+ });
188
237
  return;
189
- const raf = requestAnimationFrame(() => setArrowPosition(arrowPositionProp));
190
- return () => cancelAnimationFrame(raf);
191
- }, t6 = [arrowPosition, arrowPositionProp], $[14] = arrowPosition, $[15] = arrowPositionProp, $[16] = t5, $[17] = t6) : (t5 = $[16], t6 = $[17]), useEffect(t5, t6);
192
- let t7, t8;
193
- $[18] !== src ? (t7 = () => {
194
- src && setImageError(!1);
195
- }, t8 = [src], $[18] = src, $[19] = t7, $[20] = t8) : (t7 = $[19], t8 = $[20]), useEffect(t7, t8);
196
- let t9;
197
- $[21] !== onImageLoadError ? (t9 = () => {
198
- setImageError(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
199
- }, $[21] = onImageLoadError, $[22] = t9) : t9 = $[22];
200
- const handleImageError = t9;
201
- let t10, t11;
202
- $[23] !== size ? (t11 = Object.values(size).map(_temp$4), $[23] = size, $[24] = t11) : t11 = $[24], t10 = t11;
203
- const initialsSize = t10, t12 = __unstable_hideInnerStroke ? "" : void 0;
204
- let t13;
205
- $[25] !== className || $[26] !== color || $[27] !== sizeProp ? (t13 = avatar({
206
- className,
207
- color,
208
- size: sizeProp
209
- }), $[25] = className, $[26] = color, $[27] = sizeProp, $[28] = t13) : t13 = $[28];
210
- const t14 = imageError ? "" : void 0;
211
- let t15;
212
- $[29] === Symbol.for("react.memo_cache_sentinel") ? (t15 = avatarArrow(), $[29] = t15) : t15 = $[29];
213
- let t16;
214
- $[30] !== color ? (t16 = /* @__PURE__ */ jsx("span", { className: t15, children: /* @__PURE__ */ jsx("svg", { width: "11", height: "7", viewBox: "0 0 11 7", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M6.67948 1.50115L11 7L0 7L4.32052 1.50115C4.92109 0.736796 6.07891 0.736795 6.67948 1.50115Z", fill: color }) }) }), $[30] = color, $[31] = t16) : t16 = $[31];
215
- let t17;
216
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t17 = avatarInitials(), $[32] = t17) : t17 = $[32];
217
- let t18;
218
- $[33] !== initials || $[34] !== initialsSize ? (t18 = /* @__PURE__ */ jsx(Box, { alignItems: "center", as: "span", className: t17, display: "flex", justifyContent: "center", position: "absolute", inset: 0, children: /* @__PURE__ */ jsx(Label, { align: "center", as: "span", size: initialsSize, weight: "medium", children: initials }) }), $[33] = initials, $[34] = initialsSize, $[35] = t18) : t18 = $[35];
219
- let t19;
220
- $[36] !== handleImageError || $[37] !== initials || $[38] !== src ? (t19 = src && /* @__PURE__ */ jsxs(Box, { className: avatarImage(), inset: 0, position: "absolute", children: [
221
- /* @__PURE__ */ jsx("img", { alt: initials, onError: handleImageError, src }),
222
- /* @__PURE__ */ jsx("span", { className: avatarImageOutline() })
223
- ] }), $[36] = handleImageError, $[37] = initials, $[38] = src, $[39] = t19) : t19 = $[39];
224
- let t20;
225
- return $[40] !== Element2 || $[41] !== arrowPosition || $[42] !== rest || $[43] !== t12 || $[44] !== t13 || $[45] !== t14 || $[46] !== t16 || $[47] !== t18 || $[48] !== t19 || $[49] !== title ? (t20 = /* @__PURE__ */ jsxs(Element2, { "data-hide-inner-stroke": t12, "data-ui": "Avatar", ...rest, "aria-label": title, className: t13, "data-arrow-position": arrowPosition, "data-image-error": t14, title, children: [
226
- t16,
227
- t18,
228
- t19
229
- ] }), $[40] = Element2, $[41] = arrowPosition, $[42] = rest, $[43] = t12, $[44] = t13, $[45] = t14, $[46] = t16, $[47] = t18, $[48] = t19, $[49] = title, $[50] = t20) : t20 = $[50], t20;
230
- }
231
- function _temp$4(s) {
232
- return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
233
- }
234
- const DEFAULT_AVATAR_COUNTER_ELEMENT = "div";
235
- function AvatarCounter(props) {
236
- const $ = c(19), t0 = props;
237
- let className, count, rest, t1, t2;
238
- $[0] !== t0 ? ({
239
- as: t1,
240
- className,
241
- count,
242
- size: t2,
243
- ...rest
244
- } = t0, $[0] = t0, $[1] = className, $[2] = count, $[3] = rest, $[4] = t1, $[5] = t2) : (className = $[1], count = $[2], rest = $[3], t1 = $[4], t2 = $[5]);
245
- const as = t1 === void 0 ? DEFAULT_AVATAR_COUNTER_ELEMENT : t1, size = useResponsiveProp(t2 === void 0 ? 1 : t2);
246
- let t3, t4;
247
- $[6] !== size ? (t4 = Object.values(size).map(_temp$3), $[6] = size, $[7] = t4) : t4 = $[7], t3 = t4;
248
- const labelSize = t3;
249
- let t5;
250
- $[8] !== className || $[9] !== size ? (t5 = avatarCounter({
251
- className,
252
- size
253
- }), $[8] = className, $[9] = size, $[10] = t5) : t5 = $[10];
254
- let t6;
255
- $[11] !== count || $[12] !== labelSize ? (t6 = /* @__PURE__ */ jsx(Label, { align: "center", as: "span", size: labelSize, weight: "medium", children: count }), $[11] = count, $[12] = labelSize, $[13] = t6) : t6 = $[13];
256
- let t7;
257
- return $[14] !== as || $[15] !== rest || $[16] !== t5 || $[17] !== t6 ? (t7 = /* @__PURE__ */ jsx(Box, { "data-ui": "AvatarCounter", ...rest, alignItems: "center", as, className: t5, display: "flex", flex: "none", justifyContent: "center", paddingX: 2, sizing: "border", children: t6 }), $[14] = as, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
258
- }
259
- function _temp$3(s) {
260
- return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
261
- }
262
- const DEFAULT_AVATAR_STACK_ELEMENT = "div";
263
- function AvatarStack(props) {
264
- const $ = c(20), t0 = props;
265
- let childrenProp, className, rest, t1, t2, t3;
266
- $[0] !== t0 ? ({
267
- as: t1,
268
- children: childrenProp,
269
- className,
270
- maxLength: t2,
271
- size: t3,
272
- ...rest
273
- } = t0, $[0] = t0, $[1] = childrenProp, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3) : (childrenProp = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6]);
274
- const as = t1 === void 0 ? DEFAULT_AVATAR_STACK_ELEMENT : t1, maxLengthProp = t2 === void 0 ? 4 : t2, sizeProp = t3 === void 0 ? 1 : t3, children = Children.toArray(childrenProp).filter(isValidElement), maxLength = Math.max(maxLengthProp, 0), size = useResponsiveProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children, T0 = Box, t4 = "AvatarStack", t5 = "center";
275
- let t6;
276
- $[7] !== className || $[8] !== size ? (t6 = avatarStack({
277
- className,
278
- size
279
- }), $[7] = className, $[8] = size, $[9] = t6) : t6 = $[9];
280
- const t7 = "flex", t8 = "flex-start", t9 = len === 0 && /* @__PURE__ */ jsx(AvatarCounter, { count: len, size }), t10 = len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size });
281
- let t11;
282
- $[10] !== size ? (t11 = (child, childIndex) => /* @__PURE__ */ jsx(Fragment, { children: cloneElement(child, {
283
- size
284
- }) }, String(childIndex)), $[10] = size, $[11] = t11) : t11 = $[11];
285
- const t12 = visibleChildren.map(t11);
286
- let t13;
287
- return $[12] !== T0 || $[13] !== as || $[14] !== rest || $[15] !== t10 || $[16] !== t12 || $[17] !== t6 || $[18] !== t9 ? (t13 = /* @__PURE__ */ jsxs(T0, { "data-ui": t4, ...rest, alignItems: t5, as, className: t6, display: t7, justifyContent: t8, children: [
288
- t9,
289
- t10,
290
- t12
291
- ] }), $[12] = T0, $[13] = as, $[14] = rest, $[15] = t10, $[16] = t12, $[17] = t6, $[18] = t9, $[19] = t13) : t13 = $[19], t13;
238
+ }
239
+ if (event_1.key === "Escape") {
240
+ dispatch({
241
+ type: "root/escape"
242
+ }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
243
+ return;
244
+ }
245
+ const target = event_1.target, listEl = listBoxElementRef.current;
246
+ if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
247
+ inputElementRef.current?.focus();
248
+ return;
249
+ }
250
+ }, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = useCallback((event_2) => {
251
+ const nextQuery = event_2.currentTarget.value;
252
+ dispatch({
253
+ type: "input/change",
254
+ query: nextQuery
255
+ }), onQueryChange && onQueryChange(nextQuery);
256
+ }, [onQueryChange]), dispatchOpen = useCallback(() => {
257
+ dispatch({
258
+ type: "root/open",
259
+ query: value ? renderValue(value, currentOption) : ""
260
+ });
261
+ }, [currentOption, renderValue, value]), handleInputFocus = useCallback((event_3) => {
262
+ focused || (dispatch({
263
+ type: "input/focus"
264
+ }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen());
265
+ }, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = useCallback(() => {
266
+ popoverMouseWithinRef.current = !0;
267
+ }, []), handlePopoverMouseLeave = useCallback(() => {
268
+ popoverMouseWithinRef.current = !1;
269
+ }, []), handleClearButtonClick = useCallback(() => {
270
+ dispatch({
271
+ type: "root/clear"
272
+ }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
273
+ }, [onChange, onQueryChange]), handleClearButtonFocus = useCallback(() => {
274
+ dispatch({
275
+ type: "input/focus"
276
+ });
277
+ }, []);
278
+ useEffect(() => {
279
+ if (valueProp !== valuePropRef.current) {
280
+ valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
281
+ type: "value/change",
282
+ value: valueProp
283
+ }), valueRef.current = valueProp);
284
+ return;
285
+ }
286
+ valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({
287
+ type: "value/change",
288
+ value: valueProp || null
289
+ }));
290
+ }, [valueProp]), useEffect(() => {
291
+ !focused && valueRef.current && dispatch({
292
+ type: "root/setActiveValue",
293
+ value: valueRef.current
294
+ });
295
+ }, [focused]), useEffect(() => {
296
+ const listElement = listBoxElementRef.current;
297
+ if (!listElement) return;
298
+ const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
299
+ if (activeOption_1) {
300
+ const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
301
+ if (activeItemElement) {
302
+ if (_hasFocus(activeItemElement))
303
+ return;
304
+ focusFirstDescendant(activeItemElement);
305
+ }
306
+ }
307
+ }, [activeValue, filteredOptions]);
308
+ const clearButton = useMemo(() => {
309
+ if (!loading && !disabled && value)
310
+ return {
311
+ "aria-label": "Clear",
312
+ onFocus: handleClearButtonFocus
313
+ };
314
+ }, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = useMemo(() => Object.fromEntries(Object.entries(padding).map(([key, value_1]) => value_1 === 0 ? [key, 0] : value_1 === 1 ? [key, 1] : value_1 === 2 ? [key, 1] : [key, value_1 - 2])), [padding]), openButtonPadding = useMemo(() => Object.values(padding).map((v_0) => Math.max(v_0 - 1, 0)), [padding]), openButtonProps = useMemo(() => typeof openButton == "object" ? openButton : EMPTY_RECORD, [openButton]), handleOpenClick = useCallback((event_4) => {
315
+ dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
316
+ }, [openButtonProps, dispatchOpen]), openButtonNode = useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Open", disabled: expanded, display: "block", fontSize, icon: ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsx(TextInput, { ...rest, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", as, border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = useCallback((event_5) => {
317
+ event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
318
+ }, [listFocused]), content2 = useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsx(Box, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", gap: 1, id: listBoxId, ref: listBoxElementRef, role: "listbox", children: filteredOptions.map((option_0) => {
319
+ const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
320
+ return /* @__PURE__ */ jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: cloneElement(renderOption(option_0), {
321
+ disabled: loading,
322
+ selected: active,
323
+ tabIndex: listFocused && active ? 0 : -1
324
+ }) }, option_0.value);
325
+ }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover({
326
+ content: content2,
327
+ hidden: !expanded,
328
+ inputElement: inputElementRef.current,
329
+ onMouseEnter: handlePopoverMouseEnter,
330
+ onMouseLeave: handlePopoverMouseLeave
331
+ }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius: 3, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, renderPopover]);
332
+ return (
333
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
334
+ /* @__PURE__ */ jsxs("div", { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
335
+ input,
336
+ results
337
+ ] })
338
+ );
292
339
  }
293
- const DEFAULT_BADGE_ELEMENT = "span";
294
- function Badge(props) {
295
- const $ = c(22), t0 = props;
296
- let children, className, rest, t1, t2, t3, t4, t5;
297
- $[0] !== t0 ? ({
298
- as: t1,
340
+ const DEFAULT_BREADCRUMBS_ELEMENT = "nav";
341
+ function Breadcrumbs(props) {
342
+ const {
343
+ as = DEFAULT_BREADCRUMBS_ELEMENT,
299
344
  children,
300
345
  className,
301
- fontSize: t2,
302
- padding: t3,
303
- radius: t4,
304
- tone: t5,
305
- ...rest
306
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
307
- const as = t1 === void 0 ? DEFAULT_BADGE_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 1 : t3, radius = t4 === void 0 ? 2 : t4, tone = t5 === void 0 ? "default" : t5;
308
- let t6;
309
- $[9] !== className || $[10] !== tone ? (t6 = badge({
310
- className,
311
- tone
312
- }), $[9] = className, $[10] = tone, $[11] = t6) : t6 = $[11];
313
- let t7;
314
- $[12] !== children || $[13] !== fontSize ? (t7 = /* @__PURE__ */ jsx(Text, { size: fontSize, children }), $[12] = children, $[13] = fontSize, $[14] = t7) : t7 = $[14];
315
- let t8;
316
- return $[15] !== as || $[16] !== padding || $[17] !== radius || $[18] !== rest || $[19] !== t6 || $[20] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { "data-ui": "Badge", ...rest, as, className: t6, display: "flex", maxWidth: "fill", padding, radius, width: "min", children: t7 }), $[15] = as, $[16] = padding, $[17] = radius, $[18] = rest, $[19] = t6, $[20] = t7, $[21] = t8) : t8 = $[21], t8;
317
- }
318
- const DEFAULT_CHECKBOX_ELEMENT = "input";
319
- function Checkbox(props) {
320
- const $ = c(30), t0 = props;
321
- let checked, className, customValidity, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
322
- $[0] !== t0 ? ({
323
- as: t1,
324
- checked,
325
- className,
326
- disabled,
327
- indeterminate,
328
- customValidity,
329
- readOnly,
330
- ref: forwardedRef,
331
- style,
346
+ expandButton: expandButtonProps,
347
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
348
+ gap: _gapProp,
349
+ gapX = props.gap ?? props.space ?? 2,
350
+ gapY = props.gap ?? props.space ?? 2,
351
+ maxLength,
352
+ separator,
353
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
354
+ space: _spaceProp,
332
355
  ...rest
333
- } = t0, $[0] = t0, $[1] = checked, $[2] = className, $[3] = customValidity, $[4] = disabled, $[5] = forwardedRef, $[6] = indeterminate, $[7] = readOnly, $[8] = rest, $[9] = style, $[10] = t1) : (checked = $[1], className = $[2], customValidity = $[3], disabled = $[4], forwardedRef = $[5], indeterminate = $[6], readOnly = $[7], rest = $[8], style = $[9], t1 = $[10]);
334
- const Element2 = t1 === void 0 ? DEFAULT_CHECKBOX_ELEMENT : t1, ref = useRef(null);
335
- let t2;
336
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[11] = t2) : t2 = $[11], useImperativeHandle(forwardedRef, t2);
337
- let t3, t4;
338
- $[12] !== indeterminate ? (t3 = () => {
339
- ref.current && (ref.current.indeterminate = indeterminate || !1);
340
- }, t4 = [indeterminate], $[12] = indeterminate, $[13] = t3, $[14] = t4) : (t3 = $[13], t4 = $[14]), useEffect(t3, t4), useCustomValidity(ref, customValidity);
341
- let t5;
342
- $[15] !== className ? (t5 = checkbox({
356
+ } = props, [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null), collapse = useCallback(() => setOpen(!1), []), expand = useCallback(() => setOpen(!0), []);
357
+ useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
358
+ const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children]), items = useMemo(() => {
359
+ const len = rawItems.length;
360
+ if (maxLength && len > maxLength) {
361
+ const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
362
+ return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsx(Popover, { constrainSize: !0, content: /* @__PURE__ */ jsx(Stack, { as: "ol", gap: gapY, overflow: "auto", children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, padding: 2, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", padding: 0, text: "\u2026", ...expandButtonProps, onClick: open ? collapse : expand, ref: expandElementRef, selected: open }) }, "button"), ...rawItems.slice(len - afterLength)];
363
+ }
364
+ return rawItems;
365
+ }, [collapse, expand, expandButtonProps, gapY, maxLength, open, rawItems]);
366
+ return /* @__PURE__ */ jsx(Flex, { as, "data-ui": "Breadcrumbs", ...rest, className: breadcrumbs({
343
367
  className
344
- }), $[15] = className, $[16] = t5) : t5 = $[16];
345
- let t6;
346
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t6 = checkboxInput(), $[17] = t6) : t6 = $[17];
347
- const t7 = customValidity ? "" : void 0, t8 = disabled || readOnly;
348
- let t9;
349
- $[18] !== Element2 || $[19] !== checked || $[20] !== readOnly || $[21] !== rest || $[22] !== t7 || $[23] !== t8 ? (t9 = /* @__PURE__ */ jsx(Element2, { ...rest, checked, className: t6, "data-invalid": t7, disabled: t8, type: "checkbox", readOnly, ref }), $[18] = Element2, $[19] = checked, $[20] = readOnly, $[21] = rest, $[22] = t7, $[23] = t8, $[24] = t9) : t9 = $[24];
350
- let t10;
351
- $[25] === Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsxs("span", { className: checkboxPresentation(), children: [
352
- /* @__PURE__ */ jsx(CheckmarkIcon, {}),
353
- /* @__PURE__ */ jsx(RemoveIcon, {})
354
- ] }), $[25] = t10) : t10 = $[25];
355
- let t11;
356
- return $[26] !== style || $[27] !== t5 || $[28] !== t9 ? (t11 = /* @__PURE__ */ jsxs("span", { className: t5, "data-ui": "Checkbox", style, children: [
357
- t9,
358
- t10
359
- ] }), $[26] = style, $[27] = t5, $[28] = t9, $[29] = t11) : t11 = $[29], t11;
368
+ }), gapX, gapY, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
369
+ itemIndex > 0 && /* @__PURE__ */ jsx(Box, { "aria-hidden": !0, as: "li", children: separator || /* @__PURE__ */ jsx(Text, { muted: !0, children: "/" }) }),
370
+ /* @__PURE__ */ jsx(Box, { as: "li", children: item })
371
+ ] }, itemIndex)) });
360
372
  }
361
373
  const DEFAULT_CONTAINER_ELEMENT = "div";
362
374
  function Container(props) {
@@ -372,1679 +384,1846 @@ function Container(props) {
372
384
  let t3;
373
385
  $[5] !== className || $[6] !== width ? (t3 = container$1({
374
386
  className,
375
- width
376
- }), $[5] = className, $[6] = width, $[7] = t3) : t3 = $[7];
377
- let t4;
378
- return $[8] !== as || $[9] !== rest || $[10] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { "data-ui": "Container", ...rest, as, className: t3 }), $[8] = as, $[9] = rest, $[10] = t3, $[11] = t4) : t4 = $[11], t4;
379
- }
380
- const DEFAULT_HEADING_ELEMENT = "div";
381
- function Heading(props) {
382
- const $ = c(30), t0 = props;
383
- let align, children, className, flex, rest, t1, t2, t3, t4, t5, textOverflowProp;
384
- $[0] !== t0 ? ({
385
- accent: t1,
386
- align,
387
- as: t2,
388
- children,
389
- className,
390
- flex,
391
- muted: t3,
392
- size: t4,
393
- textOverflow: textOverflowProp,
394
- weight: t5,
395
- ...rest
396
- } = t0, $[0] = t0, $[1] = align, $[2] = children, $[3] = className, $[4] = flex, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = t4, $[10] = t5, $[11] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], flex = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8], t4 = $[9], t5 = $[10], textOverflowProp = $[11]);
397
- const accent = t1 === void 0 ? !1 : t1, Element2 = t2 === void 0 ? DEFAULT_HEADING_ELEMENT : t2, muted = t3 === void 0 ? !1 : t3, size = t4 === void 0 ? 2 : t4, weight = t5 === void 0 ? "regular" : t5;
398
- let t6;
399
- $[12] !== accent || $[13] !== align || $[14] !== className || $[15] !== flex || $[16] !== muted || $[17] !== size || $[18] !== weight ? (t6 = heading({
400
- className,
401
- accent,
402
- align,
403
- flex,
404
- muted,
405
- size,
406
- weight
407
- }), $[12] = accent, $[13] = align, $[14] = className, $[15] = flex, $[16] = muted, $[17] = size, $[18] = weight, $[19] = t6) : t6 = $[19];
408
- let t7;
409
- $[20] !== textOverflowProp ? (t7 = textOverflow({
410
- textOverflow: textOverflowProp
411
- }), $[20] = textOverflowProp, $[21] = t7) : t7 = $[21];
412
- let t8;
413
- $[22] !== children || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx("span", { className: t7, children }), $[22] = children, $[23] = t7, $[24] = t8) : t8 = $[24];
414
- let t9;
415
- return $[25] !== Element2 || $[26] !== rest || $[27] !== t6 || $[28] !== t8 ? (t9 = /* @__PURE__ */ jsx(Element2, { "data-ui": "Heading", ...rest, className: t6, children: t8 }), $[25] = Element2, $[26] = rest, $[27] = t6, $[28] = t8, $[29] = t9) : t9 = $[29], t9;
416
- }
417
- const DEFAULT_INLINE_ELEMENT = "div";
418
- function Inline(props) {
419
- const $ = c(11), t0 = props;
420
- let children, gap, rest, space, t1;
421
- $[0] !== t0 ? ({
422
- as: t1,
423
- children,
424
- gap,
425
- space,
426
- ...rest
427
- } = t0, $[0] = t0, $[1] = children, $[2] = gap, $[3] = rest, $[4] = space, $[5] = t1) : (children = $[1], gap = $[2], rest = $[3], space = $[4], t1 = $[5]);
428
- const as = t1 === void 0 ? DEFAULT_INLINE_ELEMENT : t1, t2 = gap ?? space;
429
- let t3;
430
- return $[6] !== as || $[7] !== children || $[8] !== rest || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Inline", ...rest, alignItems: "center", as, display: "flex", gap: t2, flexWrap: "wrap", children }), $[6] = as, $[7] = children, $[8] = rest, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
431
- }
432
- function BoundaryElementProvider(props) {
433
- const $ = c(5), {
434
- children,
435
- element
436
- } = props;
437
- let t0, t1;
438
- $[0] !== element ? (t1 = {
439
- version: 0,
440
- element
441
- }, $[0] = element, $[1] = t1) : t1 = $[1], t0 = t1;
442
- const value = t0;
443
- let t2;
444
- return $[2] !== children || $[3] !== value ? (t2 = /* @__PURE__ */ jsx(BoundaryElementContext.Provider, { value, children }), $[2] = children, $[3] = value, $[4] = t2) : t2 = $[4], t2;
445
- }
446
- class ErrorBoundary extends Component {
447
- state = {
448
- error: null
449
- };
450
- static displayName = "ErrorBoundary";
451
- static getDerivedStateFromError(error) {
452
- return {
453
- error
454
- };
455
- }
456
- componentDidCatch(error, info) {
457
- this.props.onCatch({
458
- error,
459
- info
460
- });
461
- }
462
- render() {
463
- const {
464
- error
465
- } = this.state;
466
- if (error) {
467
- const message = typeof error?.message == "string" ? error.message : "Error";
468
- return /* @__PURE__ */ jsx(Code, { children: message });
469
- }
470
- return this.props.children;
471
- }
387
+ width
388
+ }), $[5] = className, $[6] = width, $[7] = t3) : t3 = $[7];
389
+ let t4;
390
+ return $[8] !== as || $[9] !== rest || $[10] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { "data-ui": "Container", ...rest, as, className: t3 }), $[8] = as, $[9] = rest, $[10] = t3, $[11] = t4) : t4 = $[11], t4;
472
391
  }
473
- const DEFAULT_RADIO_ELEMENT = "input";
474
- function Radio(props) {
475
- const $ = c(25), t0 = props;
476
- let className, customValidity, disabled, forwardedRef, readOnly, rest, style, t1;
392
+ function isTargetWithinScope(boundaryElement, portalElement, target) {
393
+ return !boundaryElement || !portalElement ? !0 : containsOrEqualsElement(boundaryElement, target) || containsOrEqualsElement(portalElement, target);
394
+ }
395
+ const DEFAULT_DIALOG_CARD_ELEMENT = "div";
396
+ function DialogCard(props) {
397
+ const $ = c(60), t0 = props;
398
+ let autoFocus, children, footer, forwardedContentRef, forwardedRef, header, hideCloseButton, id, onClickOutside, onClose, portalProp, rest, t1;
477
399
  $[0] !== t0 ? ({
400
+ __unstable_autoFocus: autoFocus,
401
+ __unstable_hideCloseButton: hideCloseButton,
478
402
  as: t1,
479
- className,
480
- disabled,
481
- style,
482
- customValidity,
483
- readOnly,
403
+ children,
404
+ contentRef: forwardedContentRef,
405
+ footer,
406
+ header,
407
+ id,
408
+ onClickOutside,
409
+ onClose,
410
+ portal: portalProp,
484
411
  ref: forwardedRef,
485
412
  ...rest
486
- } = t0, $[0] = t0, $[1] = className, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = readOnly, $[6] = rest, $[7] = style, $[8] = t1) : (className = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], readOnly = $[5], rest = $[6], style = $[7], t1 = $[8]);
487
- const Element2 = t1 === void 0 ? DEFAULT_RADIO_ELEMENT : t1, ref = useRef(null);
413
+ } = t0, $[0] = t0, $[1] = autoFocus, $[2] = children, $[3] = footer, $[4] = forwardedContentRef, $[5] = forwardedRef, $[6] = header, $[7] = hideCloseButton, $[8] = id, $[9] = onClickOutside, $[10] = onClose, $[11] = portalProp, $[12] = rest, $[13] = t1) : (autoFocus = $[1], children = $[2], footer = $[3], forwardedContentRef = $[4], forwardedRef = $[5], header = $[6], hideCloseButton = $[7], id = $[8], onClickOutside = $[9], onClose = $[10], portalProp = $[11], rest = $[12], t1 = $[13]);
414
+ const as = t1 === void 0 ? DEFAULT_DIALOG_CARD_ELEMENT : t1, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, ref = useRef(null), contentRef = useRef(null), layer = useLayer(), {
415
+ isTopLayer
416
+ } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton, [scrollTop, setScrollTop] = useState(0);
488
417
  let t2;
489
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[9] = t2) : t2 = $[9], useImperativeHandle(forwardedRef, t2), useCustomValidity(ref, customValidity);
418
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[14] = t2) : t2 = $[14], useImperativeHandle(forwardedRef, t2);
490
419
  let t3;
491
- $[10] !== className ? (t3 = radio({
492
- className
493
- }), $[10] = className, $[11] = t3) : t3 = $[11];
494
- let t4;
495
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = radioInput(), $[12] = t4) : t4 = $[12];
496
- const t5 = customValidity ? "" : void 0, t6 = !disabled && readOnly ? "" : void 0, t7 = disabled || readOnly;
420
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => contentRef.current, $[15] = t3) : t3 = $[15], useImperativeHandle(forwardedContentRef, t3);
421
+ let t4, t5;
422
+ $[16] !== autoFocus ? (t4 = () => {
423
+ autoFocus && ref.current && focusFirstDescendant(ref.current);
424
+ }, t5 = [autoFocus, ref], $[16] = autoFocus, $[17] = t4, $[18] = t5) : (t4 = $[17], t5 = $[18]), useEffect(t4, t5);
425
+ let t6;
426
+ $[19] !== boundaryElement || $[20] !== isTopLayer || $[21] !== onClose || $[22] !== portalElement ? (t6 = (event) => {
427
+ if (!isTopLayer || !onClose)
428
+ return;
429
+ const target = document.activeElement;
430
+ target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose());
431
+ }, $[19] = boundaryElement, $[20] = isTopLayer, $[21] = onClose, $[22] = portalElement, $[23] = t6) : t6 = $[23], useGlobalKeyDown(t6);
432
+ let t7;
433
+ $[24] !== boundaryElement || $[25] !== isTopLayer || $[26] !== onClickOutside || $[27] !== portalElement ? (t7 = isTopLayer && onClickOutside && ((event_0) => {
434
+ const target_0 = event_0.target;
435
+ target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside();
436
+ }), $[24] = boundaryElement, $[25] = isTopLayer, $[26] = onClickOutside, $[27] = portalElement, $[28] = t7) : t7 = $[28];
497
437
  let t8;
498
- $[13] !== Element2 || $[14] !== readOnly || $[15] !== rest || $[16] !== t5 || $[17] !== t6 || $[18] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t4, "data-invalid": t5, "data-read-only": t6, disabled: t7, readOnly, ref, type: "radio" }), $[13] = Element2, $[14] = readOnly, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7, $[19] = t8) : t8 = $[19];
499
- let t9;
500
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx("span", { className: radioPresentation() }), $[20] = t9) : t9 = $[20];
501
- let t10;
502
- return $[21] !== style || $[22] !== t3 || $[23] !== t8 ? (t10 = /* @__PURE__ */ jsxs("div", { className: t3, "data-ui": "Radio", style, children: [
503
- t8,
504
- t9
505
- ] }), $[21] = style, $[22] = t3, $[23] = t8, $[24] = t10) : t10 = $[24], t10;
438
+ $[29] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => [ref.current], $[29] = t8) : t8 = $[29], useClickOutsideEvent(t7, t8);
439
+ let t10, t9;
440
+ $[30] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
441
+ const el = contentRef.current;
442
+ if (!el)
443
+ return;
444
+ const handleScroll = () => {
445
+ setScrollTop(el.scrollTop);
446
+ };
447
+ return el.addEventListener("scroll", handleScroll, {
448
+ passive: !0
449
+ }), () => {
450
+ el.removeEventListener("scroll", handleScroll);
451
+ };
452
+ }, t10 = [], $[30] = t10, $[31] = t9) : (t10 = $[30], t9 = $[31]), useEffect(t9, t10);
453
+ let t11;
454
+ $[32] === Symbol.for("react.memo_cache_sentinel") ? (t11 = dialogCard(), $[32] = t11) : t11 = $[32];
455
+ let t12;
456
+ $[33] !== header || $[34] !== labelId || $[35] !== onClose || $[36] !== showCloseButton || $[37] !== showHeader ? (t12 = showHeader && /* @__PURE__ */ jsxs(Flex, { align: "flex-start", className: dialogHeader(), padding: 3, position: "relative", children: [
457
+ /* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
458
+ showCloseButton && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Button, { "aria-label": "Close dialog", disabled: !onClose, icon: CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) })
459
+ ] }), $[33] = header, $[34] = labelId, $[35] = onClose, $[36] = showCloseButton, $[37] = showHeader, $[38] = t12) : t12 = $[38];
460
+ let t13;
461
+ $[39] === Symbol.for("react.memo_cache_sentinel") ? (t13 = dialogContent(), $[39] = t13) : t13 = $[39];
462
+ let t14;
463
+ $[40] !== scrollTop || $[41] !== showHeader ? (t14 = showHeader && /* @__PURE__ */ jsx("div", { className: dialogScrollerShadowTop(), style: {
464
+ opacity: Math.min(scrollTop, 32) / 32
465
+ } }), $[40] = scrollTop, $[41] = showHeader, $[42] = t14) : t14 = $[42];
466
+ let t15;
467
+ $[43] === Symbol.for("react.memo_cache_sentinel") ? (t15 = dialogScroller(), $[43] = t15) : t15 = $[43];
468
+ let t16;
469
+ $[44] !== children ? (t16 = /* @__PURE__ */ jsx(Box, { className: t15, overflow: "auto", ref: contentRef, children }), $[44] = children, $[45] = t16) : t16 = $[45];
470
+ let t17;
471
+ $[46] !== footer ? (t17 = footer && /* @__PURE__ */ jsx("div", { className: dialogScrollerShadowBottom() }), $[46] = footer, $[47] = t17) : t17 = $[47];
472
+ let t18;
473
+ $[48] !== t14 || $[49] !== t16 || $[50] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Box, { className: t13, flex: 1, position: "relative", tabIndex: -1, children: [
474
+ t14,
475
+ t16,
476
+ t17
477
+ ] }), $[48] = t14, $[49] = t16, $[50] = t17, $[51] = t18) : t18 = $[51];
478
+ let t19;
479
+ $[52] !== footer ? (t19 = footer && /* @__PURE__ */ jsx(Box, { className: dialogFooter(), position: "relative", children: footer }), $[52] = footer, $[53] = t19) : t19 = $[53];
480
+ let t20;
481
+ return $[54] !== as || $[55] !== rest || $[56] !== t12 || $[57] !== t18 || $[58] !== t19 ? (t20 = /* @__PURE__ */ jsxs(Card, { ...rest, as, className: t11, display: "flex", flexDirection: "column", ref, children: [
482
+ t12,
483
+ t18,
484
+ t19
485
+ ] }), $[54] = as, $[55] = rest, $[56] = t12, $[57] = t18, $[58] = t19, $[59] = t20) : t20 = $[59], t20;
506
486
  }
507
- const DEFAULT_SELECT_ELEMENT = "select";
508
- function Select(props) {
509
- const $ = c(38), t0 = props;
510
- let children, customValidity, disabled, forwardedRef, gap, readOnly, rest, t1, t2, t3, t4, t5, t6;
487
+ const DialogContext = createGlobalScopedContext("@sanity/ui/context/dialog", {
488
+ version: 0
489
+ });
490
+ function useDialog() {
491
+ return useContext(DialogContext);
492
+ }
493
+ const DEFAULT_DIALOG_ELEMENT = "div";
494
+ function Dialog(props) {
495
+ const $ = c(69), context = useDialog(), t0 = props;
496
+ let _positionProp, _zOffsetProp, children, className, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, portalProp, rest, scheme, t1, t2, t3, t4, t5, t6, t7, tone;
511
497
  $[0] !== t0 ? ({
512
- as: t1,
513
- border: t2,
498
+ __unstable_autoFocus: t1,
499
+ __unstable_hideCloseButton: t2,
500
+ animate: t3,
501
+ cardRadius: t4,
514
502
  children,
515
- customValidity,
516
- disabled,
517
- fontSize: t3,
518
- gap,
519
- padding: t4,
520
- radius: t5,
521
- readOnly,
522
- ref: forwardedRef,
523
- space: t6,
503
+ className,
504
+ contentRef,
505
+ footer,
506
+ header,
507
+ id,
508
+ onActivate,
509
+ onClickOutside,
510
+ onClose,
511
+ onFocus,
512
+ padding: t5,
513
+ portal: portalProp,
514
+ position: _positionProp,
515
+ scheme,
516
+ shadow: t6,
517
+ width: t7,
518
+ zOffset: _zOffsetProp,
519
+ tone,
524
520
  ...rest
525
- } = t0, $[0] = t0, $[1] = children, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = gap, $[6] = readOnly, $[7] = rest, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5, $[13] = t6) : (children = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], gap = $[5], readOnly = $[6], rest = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12], t6 = $[13]);
526
- const Element2 = t1 === void 0 ? DEFAULT_SELECT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, fontSize = t3 === void 0 ? 2 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 1 : t5, space = t6 === void 0 ? 2 : t6, ref = useRef(null);
527
- let t7;
528
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[14] = t7) : t7 = $[14], useImperativeHandle(forwardedRef, t7), useCustomValidity(ref, customValidity);
529
- const t8 = gap ?? space;
521
+ } = t0, $[0] = t0, $[1] = _positionProp, $[2] = _zOffsetProp, $[3] = children, $[4] = className, $[5] = contentRef, $[6] = footer, $[7] = header, $[8] = id, $[9] = onActivate, $[10] = onClickOutside, $[11] = onClose, $[12] = onFocus, $[13] = portalProp, $[14] = rest, $[15] = scheme, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = tone) : (_positionProp = $[1], _zOffsetProp = $[2], children = $[3], className = $[4], contentRef = $[5], footer = $[6], header = $[7], id = $[8], onActivate = $[9], onClickOutside = $[10], onClose = $[11], onFocus = $[12], portalProp = $[13], rest = $[14], scheme = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21], t7 = $[22], tone = $[23]);
522
+ const autoFocus = t1 === void 0 ? !0 : t1, hideCloseButton = t2 === void 0 ? !1 : t2, _animate = t3 === void 0 ? !1 : t3, cardRadiusProp = t4 === void 0 ? 4 : t4, padding = t5 === void 0 ? 3 : t5, cardShadow = t6 === void 0 ? 4 : t6, width = t7 === void 0 ? 0 : t7, positionProp = _positionProp ?? context.position ?? "fixed", zOffsetProp = _zOffsetProp ?? context.zOffset ?? Z_OFFSETS.dialog, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useResponsiveProp(cardRadiusProp), position = useResponsiveProp(positionProp), zOffset = useResponsiveProp(zOffsetProp), preDivRef = useRef(null), postDivRef = useRef(null), cardRef = useRef(null), focusedElementRef = useRef(null);
523
+ let t8;
524
+ $[24] !== onFocus ? (t8 = (event) => {
525
+ onFocus?.(event);
526
+ const target = event.target, cardElement = cardRef.current;
527
+ if (cardElement && target === preDivRef.current) {
528
+ focusLastDescendant(cardElement);
529
+ return;
530
+ }
531
+ if (cardElement && target === postDivRef.current) {
532
+ focusFirstDescendant(cardElement);
533
+ return;
534
+ }
535
+ isHTMLElement(event.target) && (focusedElementRef.current = event.target);
536
+ }, $[24] = onFocus, $[25] = t8) : t8 = $[25];
537
+ const handleFocus = t8, labelId = `${id}_label`, rootClickTimeoutRef = useRef(void 0);
530
538
  let t9;
531
- $[15] !== border || $[16] !== fontSize || $[17] !== padding || $[18] !== radius || $[19] !== t8 ? (t9 = select({
532
- border,
533
- fontSize,
534
- padding,
535
- radius,
536
- gap: t8
537
- }), $[15] = border, $[16] = fontSize, $[17] = padding, $[18] = radius, $[19] = t8, $[20] = t9) : t9 = $[20];
539
+ $[26] !== boundaryElement || $[27] !== portalElement ? (t9 = () => {
540
+ rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => {
541
+ const activeElement = document.activeElement;
542
+ if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) {
543
+ const target_0 = focusedElementRef.current;
544
+ if (!target_0 || !document.body.contains(target_0)) {
545
+ const cardElement_0 = cardRef.current;
546
+ cardElement_0 && focusFirstDescendant(cardElement_0);
547
+ return;
548
+ }
549
+ target_0.focus();
550
+ }
551
+ }, 0);
552
+ }, $[26] = boundaryElement, $[27] = portalElement, $[28] = t9) : t9 = $[28];
553
+ const handleRootClick = t9;
538
554
  let t10;
539
- $[21] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _inputElement(), $[21] = t10) : t10 = $[21];
540
- const t11 = disabled || readOnly;
555
+ $[29] !== className ? (t10 = dialog({
556
+ className
557
+ }), $[29] = className, $[30] = t10) : t10 = $[30];
558
+ const t11 = animate ? "" : void 0;
559
+ let t12;
560
+ $[31] === Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx("div", { ref: preDivRef, tabIndex: 0 }), $[31] = t12) : t12 = $[31];
561
+ let t13;
562
+ $[32] === Symbol.for("react.memo_cache_sentinel") ? (t13 = dialogContainer(), $[32] = t13) : t13 = $[32];
563
+ let t14;
564
+ $[33] !== autoFocus || $[34] !== cardRadius || $[35] !== cardShadow || $[36] !== children || $[37] !== contentRef || $[38] !== footer || $[39] !== header || $[40] !== hideCloseButton || $[41] !== id || $[42] !== onClickOutside || $[43] !== onClose || $[44] !== portalProp || $[45] !== scheme || $[46] !== tone || $[47] !== width ? (t14 = /* @__PURE__ */ jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, tone, width, children }), $[33] = autoFocus, $[34] = cardRadius, $[35] = cardShadow, $[36] = children, $[37] = contentRef, $[38] = footer, $[39] = header, $[40] = hideCloseButton, $[41] = id, $[42] = onClickOutside, $[43] = onClose, $[44] = portalProp, $[45] = scheme, $[46] = tone, $[47] = width, $[48] = t14) : t14 = $[48];
565
+ let t15;
566
+ $[49] !== t14 || $[50] !== width ? (t15 = /* @__PURE__ */ jsx(Container, { alignItems: "center", className: t13, "data-ui": "DialogCard", flexDirection: "column", display: "flex", justifyContent: "center", width, children: t14 }), $[49] = t14, $[50] = width, $[51] = t15) : t15 = $[51];
567
+ let t16;
568
+ $[52] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsx("div", { ref: postDivRef, tabIndex: 0 }), $[52] = t16) : t16 = $[52];
569
+ let t17;
570
+ $[53] !== handleFocus || $[54] !== handleRootClick || $[55] !== id || $[56] !== labelId || $[57] !== onActivate || $[58] !== padding || $[59] !== position || $[60] !== rest || $[61] !== t10 || $[62] !== t11 || $[63] !== t15 || $[64] !== zOffset ? (t17 = /* @__PURE__ */ jsxs(Layer, { ...rest, "aria-labelledby": labelId, "aria-modal": !0, className: t10, "data-animate": t11, "data-ui": "Dialog", display: "flex", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, padding, position, role: "dialog", zOffset, children: [
571
+ t12,
572
+ t15,
573
+ t16
574
+ ] }), $[53] = handleFocus, $[54] = handleRootClick, $[55] = id, $[56] = labelId, $[57] = onActivate, $[58] = padding, $[59] = position, $[60] = rest, $[61] = t10, $[62] = t11, $[63] = t15, $[64] = zOffset, $[65] = t17) : t17 = $[65];
575
+ let t18;
576
+ return $[66] !== portalProp || $[67] !== t17 ? (t18 = /* @__PURE__ */ jsx(Portal, { __unstable_name: portalProp, children: t17 }), $[66] = portalProp, $[67] = t17, $[68] = t18) : t18 = $[68], t18;
577
+ }
578
+ function DialogProvider(props) {
579
+ const $ = c(6), {
580
+ children,
581
+ position,
582
+ zOffset
583
+ } = props;
584
+ let t0, t1;
585
+ $[0] !== position || $[1] !== zOffset ? (t1 = {
586
+ version: 0,
587
+ position,
588
+ zOffset
589
+ }, $[0] = position, $[1] = zOffset, $[2] = t1) : t1 = $[2], t0 = t1;
590
+ const contextValue = t0;
591
+ let t2;
592
+ return $[3] !== children || $[4] !== contextValue ? (t2 = /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t2) : t2 = $[5], t2;
593
+ }
594
+ function MenuButton(props) {
595
+ const $ = c(63), {
596
+ __unstable_disableRestoreFocusOnClose: t0,
597
+ boundaryElement: deprecated_boundaryElement,
598
+ button: buttonProp,
599
+ id,
600
+ menu: menuProp,
601
+ onClose,
602
+ onOpen,
603
+ placement: deprecated_placement,
604
+ popoverScheme: deprecated_popoverScheme,
605
+ portal: t1,
606
+ popover,
607
+ popoverRadius: deprecated_popoverRadius,
608
+ preventOverflow: deprecated_preventOverflow,
609
+ ref: forwardedRef
610
+ } = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null);
611
+ let t2;
612
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
613
+ const [menuElements, setChildMenuElements] = useState(t2), openRef = useRef(open);
614
+ let t3, t4;
615
+ $[1] !== onOpen || $[2] !== open ? (t3 = () => {
616
+ onOpen && open && !openRef.current && onOpen();
617
+ }, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), useEffect(t3, t4);
618
+ let t5, t6;
619
+ $[5] !== onClose || $[6] !== open ? (t5 = () => {
620
+ onClose && !open && openRef.current && onClose();
621
+ }, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), useEffect(t5, t6);
622
+ let t7, t8;
623
+ $[9] !== open ? (t7 = () => {
624
+ openRef.current = open;
625
+ }, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), useEffect(t7, t8);
626
+ let t9;
627
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
628
+ setOpen(_temp$4), setShouldFocus(null);
629
+ }, $[12] = t9) : t9 = $[12];
630
+ const handleButtonClick = t9;
631
+ let t10;
632
+ $[13] !== open ? (t10 = (event) => {
633
+ open && event.preventDefault();
634
+ }, $[13] = open, $[14] = t10) : t10 = $[14];
635
+ const handleMouseDown = t10;
636
+ let t11;
637
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
638
+ if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
639
+ event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
640
+ return;
641
+ }
642
+ if (event_0.key === "ArrowUp") {
643
+ event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
644
+ return;
645
+ }
646
+ }, $[15] = t11) : t11 = $[15];
647
+ const handleButtonKeyDown = t11;
541
648
  let t12;
542
- $[22] !== Element2 || $[23] !== children || $[24] !== rest || $[25] !== t11 ? (t12 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t10, disabled: t11, ref, children }), $[22] = Element2, $[23] = children, $[24] = rest, $[25] = t11, $[26] = t12) : t12 = $[26];
649
+ $[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
650
+ const target = event_1.target;
651
+ if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
652
+ for (const el of menuElements)
653
+ if (target === el || el.contains(target))
654
+ return;
655
+ setOpen(!1);
656
+ }
657
+ }, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18];
658
+ const handleMenuClickOutside = t12;
543
659
  let t13;
544
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t13 = selectPresentation(), $[27] = t13) : t13 = $[27];
660
+ $[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => {
661
+ setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
662
+ }, $[19] = buttonElement, $[20] = disableRestoreFocusOnClose, $[21] = t13) : t13 = $[21];
663
+ const handleMenuEscape = t13;
545
664
  let t14;
546
- $[28] === Symbol.for("react.memo_cache_sentinel") ? (t14 = /* @__PURE__ */ jsx(ChevronDownIcon, {}), $[28] = t14) : t14 = $[28];
665
+ $[22] !== menuElements ? (t14 = (event_2) => {
666
+ const target_0 = event_2.relatedTarget;
667
+ if (target_0 instanceof Node) {
668
+ for (const el_0 of menuElements)
669
+ if (el_0 === target_0 || el_0.contains(target_0))
670
+ return;
671
+ setOpen(!1);
672
+ }
673
+ }, $[22] = menuElements, $[23] = t14) : t14 = $[23];
674
+ const handleBlur = t14;
547
675
  let t15;
548
- $[29] !== fontSize ? (t15 = /* @__PURE__ */ jsx(Text, { size: fontSize, children: t14 }), $[29] = fontSize, $[30] = t15) : t15 = $[30];
676
+ $[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => {
677
+ setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
678
+ }, $[24] = buttonElement, $[25] = disableRestoreFocusOnClose, $[26] = t15) : t15 = $[26];
679
+ const handleItemClick = t15;
549
680
  let t16;
550
- $[31] !== padding || $[32] !== t15 ? (t16 = /* @__PURE__ */ jsx("span", { className: t13, children: /* @__PURE__ */ jsx(Box, { as: "span", display: "inline-block", padding, children: t15 }) }), $[31] = padding, $[32] = t15, $[33] = t16) : t16 = $[33];
681
+ $[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
682
+ const registerElement = t16;
551
683
  let t17;
552
- return $[34] !== t12 || $[35] !== t16 || $[36] !== t9 ? (t17 = /* @__PURE__ */ jsxs("div", { "data-ui": "Select", className: t9, "data-icon-right": "", children: [
553
- t12,
554
- t16
555
- ] }), $[34] = t12, $[35] = t16, $[36] = t9, $[37] = t17) : t17 = $[37], t17;
684
+ $[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && cloneElement(menuProp, {
685
+ "aria-labelledby": id,
686
+ onBlurCapture: handleBlur,
687
+ onClickOutside: handleMenuClickOutside,
688
+ onEscape: handleMenuEscape,
689
+ onItemClick: handleItemClick,
690
+ originElement: buttonElement,
691
+ registerElement,
692
+ shouldFocus
693
+ }), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t17) : t17 = $[36];
694
+ const menu = t17;
695
+ let t18;
696
+ bb0: {
697
+ if (!buttonProp) {
698
+ t18 = null;
699
+ break bb0;
700
+ }
701
+ const t192 = buttonProp.props.selected ?? open;
702
+ let t202;
703
+ $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open || $[41] !== t192 ? (t202 = cloneElement(buttonProp, {
704
+ "data-ui": "MenuButton",
705
+ id,
706
+ onClick: handleButtonClick,
707
+ onKeyDown: handleButtonKeyDown,
708
+ onMouseDown: handleMouseDown,
709
+ "aria-haspopup": !0,
710
+ "aria-expanded": open,
711
+ ref: setButtonElement,
712
+ selected: t192
713
+ }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t192, $[42] = t202) : t202 = $[42], t18 = t202;
714
+ }
715
+ const button = t18;
716
+ let t19, t20;
717
+ $[43] !== buttonElement ? (t19 = () => buttonElement, t20 = [buttonElement], $[43] = buttonElement, $[44] = t19, $[45] = t20) : (t19 = $[44], t20 = $[45]), useImperativeHandle(forwardedRef, t19, t20);
718
+ let t21, t22;
719
+ $[46] !== popover ? (t22 = popover || {}, $[46] = popover, $[47] = t22) : t22 = $[47];
720
+ let t23;
721
+ $[48] !== deprecated_boundaryElement || $[49] !== deprecated_placement || $[50] !== deprecated_popoverRadius || $[51] !== deprecated_popoverScheme || $[52] !== deprecated_portal || $[53] !== deprecated_preventOverflow || $[54] !== t22 ? (t23 = {
722
+ boundaryElement: deprecated_boundaryElement,
723
+ overflow: "auto",
724
+ placement: deprecated_placement,
725
+ portal: deprecated_portal,
726
+ preventOverflow: deprecated_preventOverflow,
727
+ radius: deprecated_popoverRadius,
728
+ scheme: deprecated_popoverScheme,
729
+ ...t22
730
+ }, $[48] = deprecated_boundaryElement, $[49] = deprecated_placement, $[50] = deprecated_popoverRadius, $[51] = deprecated_popoverScheme, $[52] = deprecated_portal, $[53] = deprecated_preventOverflow, $[54] = t22, $[55] = t23) : t23 = $[55], t21 = t23;
731
+ const popoverProps = t21;
732
+ let t24;
733
+ $[56] !== button ? (t24 = button || /* @__PURE__ */ jsx(Fragment$1, {}), $[56] = button, $[57] = t24) : t24 = $[57];
734
+ let t25;
735
+ return $[58] !== menu || $[59] !== open || $[60] !== popoverProps || $[61] !== t24 ? (t25 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t24 }), $[58] = menu, $[59] = open, $[60] = popoverProps, $[61] = t24, $[62] = t25) : t25 = $[62], t25;
556
736
  }
557
- const DEFAULT_SR_ONLY_ELEMENT = "span";
558
- function SrOnly(props) {
559
- const $ = c(12), t0 = props;
560
- let children, className, rest, t1;
737
+ function _temp$4(v) {
738
+ return !v;
739
+ }
740
+ const DEFAULT_TAB_PANEL_ELEMENT = "div";
741
+ function TabPanel(props) {
742
+ const $ = c(10), t0 = props;
743
+ let children, rest, t1, tabIndex;
561
744
  $[0] !== t0 ? ({
562
745
  as: t1,
563
746
  children,
564
- className,
747
+ tabIndex,
565
748
  ...rest
566
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1) : (children = $[1], className = $[2], rest = $[3], t1 = $[4]);
567
- const Element2 = t1 === void 0 ? DEFAULT_SR_ONLY_ELEMENT : t1;
568
- let t2;
569
- $[5] !== className ? (t2 = srOnly({
570
- className
571
- }), $[5] = className, $[6] = t2) : t2 = $[6];
749
+ } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1, $[4] = tabIndex) : (children = $[1], rest = $[2], t1 = $[3], tabIndex = $[4]);
750
+ const as = t1 === void 0 ? DEFAULT_TAB_PANEL_ELEMENT : t1, t2 = tabIndex === void 0 ? 0 : tabIndex;
572
751
  let t3;
573
- return $[7] !== Element2 || $[8] !== children || $[9] !== rest || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsx(Element2, { "data-ui": "SrOnly", ...rest, "aria-hidden": !0, className: t2, children }), $[7] = Element2, $[8] = children, $[9] = rest, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
752
+ return $[5] !== as || $[6] !== children || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "TabPanel", ...rest, as, role: "tabpanel", tabIndex: t2, children }), $[5] = as, $[6] = children, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
574
753
  }
575
- const DEFAULT_SWITCH_ELEMENT = "input";
576
- function Switch(props) {
577
- const $ = c(31), t0 = props;
578
- let checked, className, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
579
- $[0] !== t0 ? ({
580
- as: t1,
581
- checked,
582
- className,
583
- disabled,
584
- indeterminate,
585
- readOnly,
586
- ref: forwardedRef,
587
- style,
588
- ...rest
589
- } = t0, $[0] = t0, $[1] = checked, $[2] = className, $[3] = disabled, $[4] = forwardedRef, $[5] = indeterminate, $[6] = readOnly, $[7] = rest, $[8] = style, $[9] = t1) : (checked = $[1], className = $[2], disabled = $[3], forwardedRef = $[4], indeterminate = $[5], readOnly = $[6], rest = $[7], style = $[8], t1 = $[9]);
590
- const Element2 = t1 === void 0 ? DEFAULT_SWITCH_ELEMENT : t1, ref = useRef(null);
591
- let t2;
592
- $[10] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[10] = t2) : t2 = $[10], useImperativeHandle(forwardedRef, t2);
593
- let t3, t4;
594
- $[11] !== indeterminate ? (t3 = () => {
595
- ref.current && (ref.current.indeterminate = indeterminate || !1);
596
- }, t4 = [indeterminate], $[11] = indeterminate, $[12] = t3, $[13] = t4) : (t3 = $[12], t4 = $[13]), useEffect(t3, t4);
754
+ const DEFAULT_TOAST_ELEMENT = "li", ROLES = {
755
+ error: "alert",
756
+ warning: "alert",
757
+ success: "alert",
758
+ info: "alert"
759
+ }, STATUS_CARD_TONE = {
760
+ error: "critical",
761
+ warning: "caution",
762
+ success: "positive",
763
+ info: "neutral"
764
+ }, BUTTON_TONE = {
765
+ error: "critical",
766
+ warning: "caution",
767
+ success: "positive",
768
+ info: "neutral"
769
+ };
770
+ function Toast(props) {
771
+ const $ = c(40), t0 = props;
772
+ let closable, description, onClose, rest, status, t1, t2, title;
773
+ if ($[0] !== t0) {
774
+ const {
775
+ as: t32,
776
+ closable: t42,
777
+ description: t52,
778
+ duration,
779
+ onClose: t62,
780
+ radius: t72,
781
+ title: t82,
782
+ status: t92,
783
+ updatedAt,
784
+ ...t102
785
+ } = t0;
786
+ t1 = t32, closable = t42, description = t52, onClose = t62, t2 = t72, title = t82, status = t92, rest = t102, $[0] = t0, $[1] = closable, $[2] = description, $[3] = onClose, $[4] = rest, $[5] = status, $[6] = t1, $[7] = t2, $[8] = title;
787
+ } else
788
+ closable = $[1], description = $[2], onClose = $[3], rest = $[4], status = $[5], t1 = $[6], t2 = $[7], title = $[8];
789
+ const as = t1 === void 0 ? DEFAULT_TOAST_ELEMENT : t1, radius = t2 === void 0 ? 3 : t2, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = usePrefersReducedMotion() ? 0 : 0.26;
790
+ let t3;
791
+ $[9] !== visualDuration ? (t3 = visualDuration ? {
792
+ type: "spring",
793
+ visualDuration,
794
+ bounce: 0.25
795
+ } : {
796
+ duration: 0
797
+ }, $[9] = visualDuration, $[10] = t3) : t3 = $[10];
798
+ const transition = t3;
799
+ let t4;
800
+ $[11] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["hidden", "initial"], $[11] = t4) : t4 = $[11];
801
+ const initial = t4;
597
802
  let t5;
598
- $[14] !== className ? (t5 = _switch({
599
- className
600
- }), $[14] = className, $[15] = t5) : t5 = $[15];
601
- const t6 = checked ? "" : void 0, t7 = indeterminate ? "" : void 0, t8 = indeterminate !== !0 && checked;
602
- let t9;
603
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t9 = _switchElement(), $[16] = t9) : t9 = $[16];
604
- const t10 = disabled ? "" : void 0, t11 = !disabled && readOnly ? "" : void 0, t12 = disabled || readOnly;
605
- let t13;
606
- $[17] !== Element2 || $[18] !== rest || $[19] !== t10 || $[20] !== t11 || $[21] !== t12 || $[22] !== t8 ? (t13 = /* @__PURE__ */ jsx(Element2, { ...rest, checked: t8, className: t9, "data-disabled": t10, "data-read-only": t11, disabled: t12, type: "checkbox", ref }), $[17] = Element2, $[18] = rest, $[19] = t10, $[20] = t11, $[21] = t12, $[22] = t8, $[23] = t13) : t13 = $[23];
607
- let t14;
608
- $[24] === Symbol.for("react.memo_cache_sentinel") ? (t14 = /* @__PURE__ */ jsxs("span", { "aria-hidden": !0, className: _switchPresentation(), children: [
609
- /* @__PURE__ */ jsx("span", { className: _switchTrack() }),
610
- /* @__PURE__ */ jsx("span", { className: _switchThumb() })
611
- ] }), $[24] = t14) : t14 = $[24];
612
- let t15;
613
- return $[25] !== style || $[26] !== t13 || $[27] !== t5 || $[28] !== t6 || $[29] !== t7 ? (t15 = /* @__PURE__ */ jsxs(Box, { className: t5, "data-checked": t6, "data-indeterminate": t7, "data-ui": "Switch", display: "block", position: "relative", style, children: [
614
- t13,
615
- t14
616
- ] }), $[25] = style, $[26] = t13, $[27] = t5, $[28] = t6, $[29] = t7, $[30] = t15) : t15 = $[30], t15;
617
- }
618
- const DEFAULT_TEXT_AREA_ELEMENT = "textarea";
619
- function TextArea(props) {
620
- const $ = c(34), t0 = props;
621
- let __unstable_disableFocusRing, customValidity, forwardedRef, gap, readOnly, rest, t1, t2, t3, t4, t5, t6, t7;
622
- $[0] !== t0 ? ({
623
- __unstable_disableFocusRing,
624
- as: t1,
625
- border: t2,
626
- customValidity,
627
- disabled: t3,
628
- fontSize: t4,
629
- gap,
630
- padding: t5,
631
- radius: t6,
632
- readOnly,
633
- ref: forwardedRef,
634
- space: t7,
635
- ...rest
636
- } = t0, $[0] = t0, $[1] = __unstable_disableFocusRing, $[2] = customValidity, $[3] = forwardedRef, $[4] = gap, $[5] = readOnly, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = t6, $[13] = t7) : (__unstable_disableFocusRing = $[1], customValidity = $[2], forwardedRef = $[3], gap = $[4], readOnly = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], t6 = $[12], t7 = $[13]);
637
- const Element2 = t1 === void 0 ? DEFAULT_TEXT_AREA_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, padding = t5 === void 0 ? 3 : t5, radius = t6 === void 0 ? 2 : t6, space = t7 === void 0 ? 3 : t7, ref = useRef(null);
803
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t5 = ["visible", "slideIn"], $[12] = t5) : t5 = $[12];
804
+ const animate = t5;
805
+ let t6;
806
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t6 = ["hidden", "slideOut"], $[13] = t6) : t6 = $[13];
807
+ const exit = t6;
808
+ let t7;
809
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = toast(), $[14] = t7) : t7 = $[14];
638
810
  let t8;
639
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => ref.current, $[14] = t8) : t8 = $[14], useImperativeHandle(forwardedRef, t8), useCustomValidity(ref, customValidity);
640
- const t9 = gap ?? space;
811
+ $[15] !== title ? (t8 = title && /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: title }), $[15] = title, $[16] = t8) : t8 = $[16];
812
+ let t9;
813
+ $[17] !== description || $[18] !== transition ? (t9 = description && /* @__PURE__ */ jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description }), $[17] = description, $[18] = transition, $[19] = t9) : t9 = $[19];
641
814
  let t10;
642
- $[15] !== border || $[16] !== fontSize || $[17] !== padding || $[18] !== radius || $[19] !== t9 ? (t10 = textArea({
643
- border,
644
- fontSize,
645
- padding,
646
- radius,
647
- gap: t9
648
- }), $[15] = border, $[16] = fontSize, $[17] = padding, $[18] = radius, $[19] = t9, $[20] = t10) : t10 = $[20];
649
- const t11 = customValidity ? "" : void 0, t12 = !disabled && readOnly ? "" : void 0;
815
+ $[20] !== t8 || $[21] !== t9 ? (t10 = /* @__PURE__ */ jsx(Flex, { flex: 1, overflowX: "auto", padding: 3, children: /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
816
+ t8,
817
+ t9
818
+ ] }) }), $[20] = t8, $[21] = t9, $[22] = t10) : t10 = $[22];
819
+ let t11;
820
+ $[23] !== buttonTone || $[24] !== closable || $[25] !== onClose ? (t11 = closable && /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Button, { as: "button", icon: CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
821
+ verticalAlign: "top"
822
+ } }) }), $[23] = buttonTone, $[24] = closable, $[25] = onClose, $[26] = t11) : t11 = $[26];
823
+ let t12;
824
+ $[27] !== t10 || $[28] !== t11 || $[29] !== transition ? (t12 = /* @__PURE__ */ jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
825
+ t10,
826
+ t11
827
+ ] }), $[27] = t10, $[28] = t11, $[29] = transition, $[30] = t12) : t12 = $[30];
650
828
  let t13;
651
- $[21] === Symbol.for("react.memo_cache_sentinel") ? (t13 = _inputElement(), $[21] = t13) : t13 = $[21];
652
- const t14 = __unstable_disableFocusRing ? "" : void 0;
653
- let t15;
654
- $[22] !== Element2 || $[23] !== disabled || $[24] !== readOnly || $[25] !== rest || $[26] !== t14 ? (t15 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t13, "data-no-focus-ring": t14, disabled, readOnly, ref }), $[22] = Element2, $[23] = disabled, $[24] = readOnly, $[25] = rest, $[26] = t14, $[27] = t15) : t15 = $[27];
655
- let t16;
656
- $[28] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsx("span", { className: _inputPresentation() }), $[28] = t16) : t16 = $[28];
657
- let t17;
658
- return $[29] !== t10 || $[30] !== t11 || $[31] !== t12 || $[32] !== t15 ? (t17 = /* @__PURE__ */ jsxs("span", { className: t10, "data-invalid": t11, "data-read-only": t12, "data-ui": "TextArea", children: [
659
- t15,
660
- t16
661
- ] }), $[29] = t10, $[30] = t11, $[31] = t12, $[32] = t15, $[33] = t17) : t17 = $[33], t17;
829
+ return $[31] !== as || $[32] !== cardTone || $[33] !== radius || $[34] !== rest || $[35] !== role || $[36] !== t12 || $[37] !== transition || $[38] !== visualDuration ? (t13 = /* @__PURE__ */ jsx(MotionCard, { as, className: t7, "data-ui": "Toast", role, ...rest, custom: visualDuration, radius, shadow: 2, tone: cardTone, layout: "position", variants: container, initial, animate, exit, transition, position: "relative", children: t12 }), $[31] = as, $[32] = cardTone, $[33] = radius, $[34] = rest, $[35] = role, $[36] = t12, $[37] = transition, $[38] = visualDuration, $[39] = t13) : t13 = $[39], t13;
662
830
  }
663
- function TooltipDelayGroupProvider(props) {
664
- const $ = c(9), {
831
+ const container = {
832
+ initial: {
833
+ y: 32,
834
+ scale: 0.5,
835
+ zIndex: 1
836
+ },
837
+ hidden: {
838
+ opacity: 0
839
+ },
840
+ visible: (visualDuration) => visualDuration ? {
841
+ opacity: 1,
842
+ transition: {
843
+ when: "beforeChildren",
844
+ staggerChildren: visualDuration / 3,
845
+ duration: visualDuration / 3
846
+ }
847
+ } : {
848
+ opacity: 1
849
+ },
850
+ slideIn: {
851
+ y: 0,
852
+ scale: 1
853
+ },
854
+ slideOut: {
855
+ zIndex: 0,
856
+ scale: 0.75
857
+ }
858
+ }, content = {
859
+ initial: {
860
+ willChange: "transform"
861
+ },
862
+ hidden: {
863
+ opacity: 0
864
+ },
865
+ visible: {
866
+ opacity: 1
867
+ }
868
+ }, MotionCard = motion.create(Card), MotionFlex = motion.create(Flex), MotionText = motion.create(Text);
869
+ function useMounted() {
870
+ return useSyncExternalStore(subscribe, _temp$3, _temp2);
871
+ }
872
+ function _temp2() {
873
+ return !1;
874
+ }
875
+ function _temp$3() {
876
+ return !0;
877
+ }
878
+ const subscribe = () => () => {
879
+ }, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null), DEFAULT_TOAST_LAYER_ELEMENT = "ul";
880
+ function ToastLayer(props) {
881
+ const $ = c(11), {
882
+ as: t0,
665
883
  children,
666
- delay
667
- } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay : delay?.open || 0, closeDelay = typeof delay == "number" ? delay : delay?.close || 0;
668
- let t0;
669
- const t1 = isGroupActive ? 1 : openDelay;
670
- let t2;
671
- $[0] !== closeDelay || $[1] !== openTooltipId || $[2] !== setIsGroupActive || $[3] !== setOpenTooltipId || $[4] !== t1 ? (t2 = {
672
- setIsGroupActive,
673
- openTooltipId,
674
- setOpenTooltipId,
675
- openDelay: t1,
676
- closeDelay
677
- }, $[0] = closeDelay, $[1] = openTooltipId, $[2] = setIsGroupActive, $[3] = setOpenTooltipId, $[4] = t1, $[5] = t2) : t2 = $[5], t0 = t2;
678
- const value = t0;
884
+ padding: t1,
885
+ paddingX,
886
+ paddingY,
887
+ gap: t2
888
+ } = props, as = t0 === void 0 ? DEFAULT_TOAST_LAYER_ELEMENT : t0, padding = t1 === void 0 ? 4 : t1, gap = t2 === void 0 ? 3 : t2, {
889
+ zIndex
890
+ } = useLayer();
679
891
  let t3;
680
- return $[6] !== children || $[7] !== value ? (t3 = /* @__PURE__ */ jsx(TooltipDelayGroupContext.Provider, { value, children }), $[6] = children, $[7] = value, $[8] = t3) : t3 = $[8], t3;
892
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t3 = toastLayer(), $[0] = t3) : t3 = $[0];
893
+ let t4;
894
+ $[1] !== zIndex ? (t4 = {
895
+ zIndex
896
+ }, $[1] = zIndex, $[2] = t4) : t4 = $[2];
897
+ let t5;
898
+ return $[3] !== as || $[4] !== children || $[5] !== gap || $[6] !== padding || $[7] !== paddingX || $[8] !== paddingY || $[9] !== t4 ? (t5 = /* @__PURE__ */ jsx(Grid, { as, className: t3, "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: t4, children }), $[3] = as, $[4] = children, $[5] = gap, $[6] = padding, $[7] = paddingX, $[8] = paddingY, $[9] = t4, $[10] = t5) : t5 = $[10], t5;
681
899
  }
682
- function AutocompleteOption(props) {
683
- const $ = c(11), {
900
+ let toastId = 0;
901
+ function generateToastId() {
902
+ return String(toastId++);
903
+ }
904
+ function ToastProvider(props) {
905
+ const $ = c(13), {
684
906
  children,
685
- id,
686
- onSelect,
687
- selected,
688
- value
689
- } = props;
690
- let t0;
691
- $[0] !== onSelect || $[1] !== value ? (t0 = () => {
692
- setTimeout(() => {
693
- onSelect(value);
694
- }, 0);
695
- }, $[0] = onSelect, $[1] = value, $[2] = t0) : t0 = $[2];
696
- const handleClick = t0;
907
+ padding,
908
+ paddingX,
909
+ paddingY,
910
+ gap,
911
+ zOffset: t0
912
+ } = props, zOffset = t0 === void 0 ? 1 : t0;
697
913
  let t1;
698
- $[3] !== handleClick ? (t1 = (event) => {
699
- event.key === "Enter" && !_isEnterToClickElement(event.currentTarget) && handleClick();
700
- }, $[3] = handleClick, $[4] = t1) : t1 = $[4];
701
- const handleKeyDown = t1;
702
- let t2;
703
- return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children }), $[5] = children, $[6] = handleClick, $[7] = handleKeyDown, $[8] = id, $[9] = selected, $[10] = t2) : t2 = $[10], t2;
914
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
915
+ const [state, setState] = useState(t1), mounted = useMounted();
916
+ let t2, t3;
917
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
918
+ version: 0,
919
+ push: (params) => {
920
+ const id = params.id || generateToastId(), duration = params.duration || 5e3;
921
+ return startTransition(() => {
922
+ setState((prevState) => {
923
+ if (duration === 0.01)
924
+ return prevState.filter((toast2) => toast2.id !== id);
925
+ const dismiss = () => startTransition(() => setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id)));
926
+ return [...prevState.filter((toast_1) => toast_1.id !== id), {
927
+ dismiss,
928
+ id,
929
+ updatedAt: Date.now(),
930
+ params: {
931
+ ...params,
932
+ duration
933
+ }
934
+ }];
935
+ });
936
+ }), id;
937
+ }
938
+ }, $[1] = t3) : t3 = $[1], t2 = t3;
939
+ const value = t2;
940
+ let t4;
941
+ $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp$2) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
942
+ let t5;
943
+ return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
944
+ children,
945
+ t4
946
+ ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
704
947
  }
705
- function autocompleteReducer(state, msg) {
706
- return msg.type === "input/change" ? {
707
- ...state,
708
- activeValue: null,
709
- focused: !0,
710
- query: msg.query
711
- } : msg.type === "input/focus" ? {
712
- ...state,
713
- focused: !0
714
- } : msg.type === "root/blur" ? {
715
- ...state,
716
- focused: !1,
717
- query: null
718
- } : msg.type === "root/clear" ? {
719
- ...state,
720
- activeValue: null,
721
- query: null,
722
- value: null
723
- } : msg.type === "root/escape" ? {
724
- ...state,
725
- focused: !1,
726
- query: null
727
- } : msg.type === "root/open" ? {
728
- ...state,
729
- query: state.query || msg.query
730
- } : msg.type === "root/setActiveValue" ? {
731
- ...state,
732
- activeValue: msg.value,
733
- listFocused: msg.listFocused || state.listFocused
734
- } : msg.type === "root/setListFocused" ? {
735
- ...state,
736
- listFocused: msg.listFocused
737
- } : msg.type === "value/change" ? {
738
- ...state,
739
- activeValue: msg.value,
740
- query: null,
741
- value: msg.value
742
- } : state;
948
+ function _temp$2(t0) {
949
+ const {
950
+ dismiss: dismiss_0,
951
+ id: id_0,
952
+ params: params_0,
953
+ updatedAt
954
+ } = t0;
955
+ return /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration, updatedAt }, id_0);
956
+ }
957
+ function useToast() {
958
+ const value = useContext(ToastContext);
959
+ if (!value)
960
+ throw new Error("useToast(): missing context value");
961
+ if (!isRecord(value) || value.version !== 0)
962
+ throw new Error("useToast(): the context value is not compatible");
963
+ return value;
964
+ }
965
+ function _findPrevItemElement(state, itemElements, focusedElement) {
966
+ const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(0, idx), len = els.length;
967
+ for (let i = len - 1; i >= 0; i -= 1) {
968
+ const itemKey = els[i].getAttribute("data-tree-key");
969
+ if (!itemKey)
970
+ continue;
971
+ const segments = itemKey.split("/");
972
+ segments.pop();
973
+ const p = [];
974
+ let expanded = !0;
975
+ for (let j = 0; j < segments.length; j += 1) {
976
+ p.push(segments[j]);
977
+ const k = p.join("/");
978
+ if (!state[k]?.expanded) {
979
+ expanded = !1;
980
+ break;
981
+ }
982
+ }
983
+ if (expanded)
984
+ return els[i];
985
+ }
986
+ return null;
987
+ }
988
+ function _findNextItemElement(state, itemElements, focusedElement) {
989
+ const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(idx), len = itemElements.length;
990
+ for (let i = 1; i < len; i += 1) {
991
+ if (!els[i])
992
+ continue;
993
+ const itemKey = els[i].getAttribute("data-tree-key");
994
+ if (!itemKey)
995
+ continue;
996
+ const segments = itemKey.split("/");
997
+ segments.pop();
998
+ const p = [];
999
+ let expanded = !0;
1000
+ for (let j = 0; j < segments.length; j += 1) {
1001
+ p.push(segments[j]);
1002
+ const k = p.join("/");
1003
+ if (!state[k]?.expanded) {
1004
+ expanded = !1;
1005
+ break;
1006
+ }
1007
+ }
1008
+ if (expanded)
1009
+ return els[i];
1010
+ }
1011
+ return null;
743
1012
  }
744
- const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "Home", "End", "PageUp", "PageDown", "Meta", "Tab", "CapsLock"], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_AUTOCOMPLETE_ELEMENT = "input", DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
745
- function Autocomplete(props) {
746
- const {
747
- as = DEFAULT_AUTOCOMPLETE_ELEMENT,
748
- border = !0,
749
- customValidity,
750
- disabled,
751
- filterOption: filterOptionProp,
752
- fontSize = 2,
753
- icon,
754
- id,
755
- listBox = EMPTY_RECORD,
756
- loading,
757
- onBlur,
758
- onChange,
1013
+ function _focusItemElement(el) {
1014
+ if (el.getAttribute("role") === "treeitem" && el.focus(), el.getAttribute("role") === "none") {
1015
+ const firstChild = el.firstChild;
1016
+ firstChild && firstChild instanceof HTMLElement && firstChild.focus();
1017
+ }
1018
+ }
1019
+ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null), DEFAULT_TREE_ELEMENT = "div";
1020
+ function Tree(props) {
1021
+ const $ = c(39), t0 = props;
1022
+ let children, forwardedRef, gap, onFocus, rest, t1;
1023
+ $[0] !== t0 ? ({
1024
+ children,
1025
+ gap,
1026
+ space: t1,
759
1027
  onFocus,
760
- onQueryChange,
761
- onSelect,
762
- openButton,
763
- openOnFocus,
764
- options: optionsProp,
765
- padding: paddingProp = 3,
766
- popover = EMPTY_RECORD,
767
- prefix,
768
- radius = 2,
769
- readOnly,
770
1028
  ref: forwardedRef,
771
- relatedElements,
772
- renderOption: renderOptionProp,
773
- renderPopover,
774
- renderValue = DEFAULT_RENDER_VALUE,
775
- suffix,
776
- value: valueProp,
777
1029
  ...rest
778
- } = props, [state, dispatch] = useReducer(autocompleteReducer, {
779
- activeValue: valueProp || null,
780
- focused: !1,
781
- listFocused: !1,
782
- query: null,
783
- value: valueProp || null
784
- }), {
785
- activeValue,
786
- focused,
787
- listFocused,
788
- query,
789
- value
790
- } = state, defaultRenderOption = useCallback(({
791
- value: value_0
792
- }) => /* @__PURE__ */ jsx(Card, { as: "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", children: value_0 }) }), [fontSize, paddingProp]), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1);
793
- useImperativeHandle(forwardedRef, () => inputElementRef.current);
794
- const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useResponsiveProp(paddingProp), currentOption = useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = useMemo(() => options.filter((option) => query ? filterOption(query, option) : !0), [filterOption, options, query]), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = useCallback((event) => {
795
- setTimeout(() => {
796
- if (popoverMouseWithinRef.current)
797
- return;
798
- const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []);
799
- let focusInside = !1;
800
- if (document.activeElement) {
801
- for (const e of elements)
802
- if (e === document.activeElement || e.contains(document.activeElement)) {
803
- focusInside = !0;
804
- break;
805
- }
806
- }
807
- focusInside === !1 && (dispatch({
808
- type: "root/blur"
809
- }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
810
- }, 0);
811
- }, [onBlur, onQueryChange, relatedElements]), handleRootFocus = useCallback((event_0) => {
812
- const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
813
- listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
814
- type: "root/setListFocused",
815
- listFocused: listFocused_0
816
- }));
817
- }, []), handleOptionSelect = useCallback((v) => {
818
- dispatch({
819
- type: "value/change",
820
- value: v
821
- }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
822
- }, [onChange, onSelect, onQueryChange]), handleRootKeyDown = useCallback((event_1) => {
823
- if (event_1.key === "ArrowDown") {
824
- if (event_1.preventDefault(), !filteredOptionsLen) return;
825
- const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
826
- nextActiveOption && dispatch({
827
- type: "root/setActiveValue",
828
- value: nextActiveOption.value,
829
- listFocused: !0
830
- });
831
- return;
832
- }
833
- if (event_1.key === "ArrowUp") {
834
- if (event_1.preventDefault(), !filteredOptionsLen) return;
835
- const activeOption_0 = filteredOptions.find((o_1) => o_1.value === activeValue), activeIndex_0 = activeOption_0 ? filteredOptions.indexOf(activeOption_0) : -1, nextActiveOption_0 = filteredOptions[activeIndex_0 === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex_0 - 1) % filteredOptionsLen];
836
- nextActiveOption_0 && dispatch({
837
- type: "root/setActiveValue",
838
- value: nextActiveOption_0.value,
839
- listFocused: !0
840
- });
841
- return;
842
- }
843
- if (event_1.key === "Escape") {
844
- dispatch({
845
- type: "root/escape"
846
- }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
847
- return;
848
- }
849
- const target = event_1.target, listEl = listBoxElementRef.current;
850
- if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
851
- inputElementRef.current?.focus();
852
- return;
1030
+ } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = gap, $[4] = onFocus, $[5] = rest, $[6] = t1) : (children = $[1], forwardedRef = $[2], gap = $[3], onFocus = $[4], rest = $[5], t1 = $[6]);
1031
+ const space = t1 === void 0 ? 1 : t1, ref = useRef(null), [focusedElement, setFocusedElement] = useState(null), focusedElementRef = useRef(focusedElement);
1032
+ let t2, t3;
1033
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[7] = t3) : t3 = $[7], t2 = t3;
1034
+ const path = t2;
1035
+ let t4;
1036
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[8] = t4) : t4 = $[8];
1037
+ const [itemElements, setItemElements] = useState(t4);
1038
+ let t5;
1039
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t5 = {}, $[9] = t5) : t5 = $[9];
1040
+ const [state, setState] = useState(t5), stateRef = useRef(state);
1041
+ let t6;
1042
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[10] = t6) : t6 = $[10], useImperativeHandle(forwardedRef, t6);
1043
+ let t7, t8;
1044
+ $[11] !== focusedElement ? (t7 = () => {
1045
+ focusedElementRef.current = focusedElement;
1046
+ }, t8 = [focusedElement], $[11] = focusedElement, $[12] = t7, $[13] = t8) : (t7 = $[12], t8 = $[13]), useEffect(t7, t8);
1047
+ let t10, t9;
1048
+ $[14] !== state ? (t9 = () => {
1049
+ stateRef.current = state;
1050
+ }, t10 = [state], $[14] = state, $[15] = t10, $[16] = t9) : (t10 = $[15], t9 = $[16]), useEffect(t9, t10);
1051
+ let t11;
1052
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (element, path_0, expanded, selected) => (setState((s) => ({
1053
+ ...s,
1054
+ [path_0]: {
1055
+ element,
1056
+ expanded
853
1057
  }
854
- }, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = useCallback((event_2) => {
855
- const nextQuery = event_2.currentTarget.value;
856
- dispatch({
857
- type: "input/change",
858
- query: nextQuery
859
- }), onQueryChange && onQueryChange(nextQuery);
860
- }, [onQueryChange]), dispatchOpen = useCallback(() => {
861
- dispatch({
862
- type: "root/open",
863
- query: value ? renderValue(value, currentOption) : ""
864
- });
865
- }, [currentOption, renderValue, value]), handleInputFocus = useCallback((event_3) => {
866
- focused || (dispatch({
867
- type: "input/focus"
868
- }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen());
869
- }, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = useCallback(() => {
870
- popoverMouseWithinRef.current = !0;
871
- }, []), handlePopoverMouseLeave = useCallback(() => {
872
- popoverMouseWithinRef.current = !1;
873
- }, []), handleClearButtonClick = useCallback(() => {
874
- dispatch({
875
- type: "root/clear"
876
- }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
877
- }, [onChange, onQueryChange]), handleClearButtonFocus = useCallback(() => {
878
- dispatch({
879
- type: "input/focus"
1058
+ })), selected && setFocusedElement(element), () => {
1059
+ setState((s_0) => {
1060
+ const newState = {
1061
+ ...s_0
1062
+ };
1063
+ return delete newState[path_0], newState;
880
1064
  });
881
- }, []);
882
- useEffect(() => {
883
- if (valueProp !== valuePropRef.current) {
884
- valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
885
- type: "value/change",
886
- value: valueProp
887
- }), valueRef.current = valueProp);
888
- return;
889
- }
890
- valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({
891
- type: "value/change",
892
- value: valueProp || null
893
- }));
894
- }, [valueProp]), useEffect(() => {
895
- !focused && valueRef.current && dispatch({
896
- type: "root/setActiveValue",
897
- value: valueRef.current
1065
+ }), $[17] = t11) : t11 = $[17];
1066
+ const registerItem = t11;
1067
+ let t12;
1068
+ $[18] === Symbol.for("react.memo_cache_sentinel") ? (t12 = (path_1, expanded_0) => {
1069
+ setState((s_1) => {
1070
+ const itemState = s_1[path_1];
1071
+ return itemState ? {
1072
+ ...s_1,
1073
+ [path_1]: {
1074
+ ...itemState,
1075
+ expanded: expanded_0
1076
+ }
1077
+ } : s_1;
898
1078
  });
899
- }, [focused]), useEffect(() => {
900
- const listElement = listBoxElementRef.current;
901
- if (!listElement) return;
902
- const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
903
- if (activeOption_1) {
904
- const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
905
- if (activeItemElement) {
906
- if (_hasFocus(activeItemElement))
1079
+ }, $[18] = t12) : t12 = $[18];
1080
+ const setExpanded = t12;
1081
+ let t13;
1082
+ const t14 = focusedElement || itemElements[0] || null;
1083
+ let t15;
1084
+ $[19] !== space || $[20] !== state || $[21] !== t14 ? (t15 = {
1085
+ version: 0,
1086
+ focusedElement: t14,
1087
+ level: 0,
1088
+ path,
1089
+ registerItem,
1090
+ setExpanded,
1091
+ setFocusedElement,
1092
+ space,
1093
+ state
1094
+ }, $[19] = space, $[20] = state, $[21] = t14, $[22] = t15) : t15 = $[22], t13 = t15;
1095
+ const contextValue = t13;
1096
+ let t16;
1097
+ $[23] !== itemElements ? (t16 = (event) => {
1098
+ if (focusedElementRef.current) {
1099
+ if (event.key === "ArrowDown") {
1100
+ event.preventDefault();
1101
+ const nextEl = _findNextItemElement(stateRef.current, itemElements, focusedElementRef.current);
1102
+ nextEl && (_focusItemElement(nextEl), setFocusedElement(nextEl));
1103
+ return;
1104
+ }
1105
+ if (event.key === "ArrowUp") {
1106
+ event.preventDefault();
1107
+ const prevEl = _findPrevItemElement(stateRef.current, itemElements, focusedElementRef.current);
1108
+ prevEl && (_focusItemElement(prevEl), setFocusedElement(prevEl));
1109
+ return;
1110
+ }
1111
+ if (event.key === "ArrowLeft") {
1112
+ event.preventDefault();
1113
+ const itemKey = focusedElementRef.current.getAttribute("data-tree-key");
1114
+ if (!itemKey)
1115
+ return;
1116
+ const itemState_0 = stateRef.current[itemKey];
1117
+ if (!itemState_0)
907
1118
  return;
908
- focusFirstDescendant(activeItemElement);
1119
+ if (itemState_0.expanded)
1120
+ setState((s_2) => {
1121
+ const itemState_1 = s_2[itemKey];
1122
+ return itemState_1 ? {
1123
+ ...s_2,
1124
+ [itemKey]: {
1125
+ ...itemState_1,
1126
+ expanded: !1
1127
+ }
1128
+ } : s_2;
1129
+ });
1130
+ else {
1131
+ const itemPath = itemKey.split("/");
1132
+ itemPath.pop();
1133
+ const parentKey = itemPath.join("/"), parentState = parentKey && stateRef.current[parentKey];
1134
+ parentState && (parentState.element.focus(), setFocusedElement(parentState.element));
1135
+ }
1136
+ return;
1137
+ }
1138
+ if (event.key === "ArrowRight") {
1139
+ event.preventDefault();
1140
+ const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
1141
+ if (!focusedKey)
1142
+ return;
1143
+ stateRef.current[focusedKey]?.expanded || setState((s_3) => {
1144
+ const itemState_2 = s_3[focusedKey];
1145
+ return itemState_2 ? {
1146
+ ...s_3,
1147
+ [focusedKey]: {
1148
+ ...itemState_2,
1149
+ expanded: !0
1150
+ }
1151
+ } : s_3;
1152
+ });
1153
+ return;
909
1154
  }
910
1155
  }
911
- }, [activeValue, filteredOptions]);
912
- const clearButton = useMemo(() => {
913
- if (!loading && !disabled && value)
914
- return {
915
- "aria-label": "Clear",
916
- onFocus: handleClearButtonFocus
917
- };
918
- }, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = useMemo(() => Object.fromEntries(Object.entries(padding).map(([key, value_1]) => value_1 === 0 ? [key, 0] : value_1 === 1 ? [key, 1] : value_1 === 2 ? [key, 1] : [key, value_1 - 2])), [padding]), openButtonPadding = useMemo(() => Object.values(padding).map((v_0) => Math.max(v_0 - 1, 0)), [padding]), openButtonProps = useMemo(() => typeof openButton == "object" ? openButton : EMPTY_RECORD, [openButton]), handleOpenClick = useCallback((event_4) => {
919
- dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
920
- }, [openButtonProps, dispatchOpen]), openButtonNode = useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Open", disabled: expanded, display: "block", fontSize, icon: ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsx(TextInput, { ...rest, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", as, border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = useCallback((event_5) => {
921
- event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
922
- }, [listFocused]), content2 = useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsx(Box, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", gap: 1, id: listBoxId, ref: listBoxElementRef, role: "listbox", children: filteredOptions.map((option_0) => {
923
- const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
924
- return /* @__PURE__ */ jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: cloneElement(renderOption(option_0), {
925
- disabled: loading,
926
- selected: active,
927
- tabIndex: listFocused && active ? 0 : -1
928
- }) }, option_0.value);
929
- }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover({
930
- content: content2,
931
- hidden: !expanded,
932
- inputElement: inputElementRef.current,
933
- onMouseEnter: handlePopoverMouseEnter,
934
- onMouseLeave: handlePopoverMouseLeave
935
- }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius: 3, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, renderPopover]);
936
- return (
937
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
938
- /* @__PURE__ */ jsxs("div", { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
939
- input,
940
- results
941
- ] })
942
- );
943
- }
944
- const DEFAULT_BREADCRUMBS_ELEMENT = "nav";
945
- function Breadcrumbs(props) {
946
- const {
947
- as = DEFAULT_BREADCRUMBS_ELEMENT,
948
- children,
949
- className,
950
- expandButton: expandButtonProps,
951
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
952
- gap: _gapProp,
953
- gapX = props.gap ?? props.space ?? 2,
954
- gapY = props.gap ?? props.space ?? 2,
955
- maxLength,
956
- separator,
957
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
958
- space: _spaceProp,
959
- ...rest
960
- } = props, [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null), collapse = useCallback(() => setOpen(!1), []), expand = useCallback(() => setOpen(!0), []);
961
- useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
962
- const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children]), items = useMemo(() => {
963
- const len = rawItems.length;
964
- if (maxLength && len > maxLength) {
965
- const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
966
- return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsx(Popover, { constrainSize: !0, content: /* @__PURE__ */ jsx(Stack, { as: "ol", gap: gapY, overflow: "auto", children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, padding: 2, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", padding: 0, text: "\u2026", ...expandButtonProps, onClick: open ? collapse : expand, ref: expandElementRef, selected: open }) }, "button"), ...rawItems.slice(len - afterLength)];
967
- }
968
- return rawItems;
969
- }, [collapse, expand, expandButtonProps, gapY, maxLength, open, rawItems]);
970
- return /* @__PURE__ */ jsx(Flex, { as, "data-ui": "Breadcrumbs", ...rest, className: breadcrumbs({
971
- className
972
- }), gapX, gapY, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
973
- itemIndex > 0 && /* @__PURE__ */ jsx(Box, { "aria-hidden": !0, as: "li", children: separator || /* @__PURE__ */ jsx(Text, { muted: !0, children: "/" }) }),
974
- /* @__PURE__ */ jsx(Box, { as: "li", children: item })
975
- ] }, itemIndex)) });
1156
+ }, $[23] = itemElements, $[24] = t16) : t16 = $[24];
1157
+ const handleKeyDown = t16;
1158
+ let t17;
1159
+ $[25] !== onFocus ? (t17 = (event_0) => {
1160
+ setFocusedElement(event_0.target), onFocus?.(event_0);
1161
+ }, $[25] = onFocus, $[26] = t17) : t17 = $[26];
1162
+ const handleFocus = t17;
1163
+ let t18;
1164
+ $[27] === Symbol.for("react.memo_cache_sentinel") ? (t18 = () => {
1165
+ if (!ref.current)
1166
+ return;
1167
+ const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
1168
+ setItemElements(_itemElements);
1169
+ }, $[27] = t18) : t18 = $[27];
1170
+ let t19;
1171
+ $[28] !== children ? (t19 = [children], $[28] = children, $[29] = t19) : t19 = $[29], useEffect(t18, t19);
1172
+ const t20 = gap ?? space;
1173
+ let t21;
1174
+ $[30] !== children || $[31] !== handleFocus || $[32] !== handleKeyDown || $[33] !== rest || $[34] !== t20 ? (t21 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "Tree", ...rest, gap: t20, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", children }), $[30] = children, $[31] = handleFocus, $[32] = handleKeyDown, $[33] = rest, $[34] = t20, $[35] = t21) : t21 = $[35];
1175
+ let t22;
1176
+ return $[36] !== contextValue || $[37] !== t21 ? (t22 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t21 }), $[36] = contextValue, $[37] = t21, $[38] = t22) : t22 = $[38], t22;
976
1177
  }
977
- function isTargetWithinScope(boundaryElement, portalElement, target) {
978
- return !boundaryElement || !portalElement ? !0 : containsOrEqualsElement(boundaryElement, target) || containsOrEqualsElement(portalElement, target);
1178
+ function useTree() {
1179
+ const tree = useContext(TreeContext);
1180
+ if (!tree)
1181
+ throw new Error("Tree: missing context value");
1182
+ return tree;
979
1183
  }
980
- const DEFAULT_DIALOG_CARD_ELEMENT = "div";
981
- function DialogCard(props) {
982
- const $ = c(51), t0 = props;
983
- let autoFocus, children, footer, forwardedContentRef, forwardedRef, header, hideCloseButton, id, onClickOutside, onClose, portalProp, rest, t1;
1184
+ const TreeGroup = memo(function(props) {
1185
+ const $ = c(9), t0 = props;
1186
+ let children, rest, t1;
984
1187
  $[0] !== t0 ? ({
985
- __unstable_autoFocus: autoFocus,
986
- __unstable_hideCloseButton: hideCloseButton,
987
- as: t1,
988
1188
  children,
989
- contentRef: forwardedContentRef,
990
- footer,
991
- header,
992
- id,
993
- onClickOutside,
994
- onClose,
995
- portal: portalProp,
996
- ref: forwardedRef,
1189
+ expanded: t1,
997
1190
  ...rest
998
- } = t0, $[0] = t0, $[1] = autoFocus, $[2] = children, $[3] = footer, $[4] = forwardedContentRef, $[5] = forwardedRef, $[6] = header, $[7] = hideCloseButton, $[8] = id, $[9] = onClickOutside, $[10] = onClose, $[11] = portalProp, $[12] = rest, $[13] = t1) : (autoFocus = $[1], children = $[2], footer = $[3], forwardedContentRef = $[4], forwardedRef = $[5], header = $[6], hideCloseButton = $[7], id = $[8], onClickOutside = $[9], onClose = $[10], portalProp = $[11], rest = $[12], t1 = $[13]);
999
- const as = t1 === void 0 ? DEFAULT_DIALOG_CARD_ELEMENT : t1, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, ref = useRef(null), contentRef = useRef(null), layer = useLayer(), {
1000
- isTopLayer
1001
- } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
1002
- let t2;
1003
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[14] = t2) : t2 = $[14], useImperativeHandle(forwardedRef, t2);
1191
+ } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
1192
+ const expanded = t1 === void 0 ? !1 : t1, tree = useTree(), t2 = !expanded;
1004
1193
  let t3;
1005
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => contentRef.current, $[15] = t3) : t3 = $[15], useImperativeHandle(forwardedContentRef, t3);
1006
- let t4, t5;
1007
- $[16] !== autoFocus ? (t4 = () => {
1008
- autoFocus && ref.current && focusFirstDescendant(ref.current);
1009
- }, t5 = [autoFocus, ref], $[16] = autoFocus, $[17] = t4, $[18] = t5) : (t4 = $[17], t5 = $[18]), useEffect(t4, t5);
1010
- let t6;
1011
- $[19] !== boundaryElement || $[20] !== isTopLayer || $[21] !== onClose || $[22] !== portalElement ? (t6 = (event) => {
1012
- if (!isTopLayer || !onClose)
1013
- return;
1014
- const target = document.activeElement;
1015
- target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose());
1016
- }, $[19] = boundaryElement, $[20] = isTopLayer, $[21] = onClose, $[22] = portalElement, $[23] = t6) : t6 = $[23], useGlobalKeyDown(t6);
1017
- let t7;
1018
- $[24] !== boundaryElement || $[25] !== isTopLayer || $[26] !== onClickOutside || $[27] !== portalElement ? (t7 = isTopLayer && onClickOutside && ((event_0) => {
1019
- const target_0 = event_0.target;
1020
- target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside();
1021
- }), $[24] = boundaryElement, $[25] = isTopLayer, $[26] = onClickOutside, $[27] = portalElement, $[28] = t7) : t7 = $[28];
1022
- let t8;
1023
- $[29] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => [ref.current], $[29] = t8) : t8 = $[29], useClickOutsideEvent(t7, t8);
1024
- let t9;
1025
- $[30] === Symbol.for("react.memo_cache_sentinel") ? (t9 = dialogCard(), $[30] = t9) : t9 = $[30];
1026
- let t10;
1027
- $[31] === Symbol.for("react.memo_cache_sentinel") ? (t10 = dialogLayout(), $[31] = t10) : t10 = $[31];
1028
- let t11;
1029
- $[32] !== header || $[33] !== labelId || $[34] !== onClose || $[35] !== showCloseButton || $[36] !== showHeader ? (t11 = showHeader && /* @__PURE__ */ jsx(Box, { className: dialogHeader(), position: "relative", children: /* @__PURE__ */ jsxs(Flex, { align: "flex-start", padding: 3, children: [
1030
- /* @__PURE__ */ jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
1031
- showCloseButton && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Button, { "aria-label": "Close dialog", disabled: !onClose, icon: CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) })
1032
- ] }) }), $[32] = header, $[33] = labelId, $[34] = onClose, $[35] = showCloseButton, $[36] = showHeader, $[37] = t11) : t11 = $[37];
1033
- let t12;
1034
- $[38] === Symbol.for("react.memo_cache_sentinel") ? (t12 = dialogContent(), $[38] = t12) : t12 = $[38];
1035
- let t13;
1036
- $[39] !== children ? (t13 = /* @__PURE__ */ jsx(Box, { className: t12, flex: 1, overflow: "auto", position: "relative", ref: contentRef, tabIndex: -1, children }), $[39] = children, $[40] = t13) : t13 = $[40];
1037
- let t14;
1038
- $[41] !== footer ? (t14 = footer && /* @__PURE__ */ jsx(Box, { className: dialogFooter(), position: "relative", children: footer }), $[41] = footer, $[42] = t14) : t14 = $[42];
1039
- let t15;
1040
- $[43] !== t11 || $[44] !== t13 || $[45] !== t14 ? (t15 = /* @__PURE__ */ jsxs(Flex, { className: t10, direction: "column", flex: 1, children: [
1041
- t11,
1042
- t13,
1043
- t14
1044
- ] }), $[43] = t11, $[44] = t13, $[45] = t14, $[46] = t15) : t15 = $[46];
1045
- let t16;
1046
- return $[47] !== as || $[48] !== rest || $[49] !== t15 ? (t16 = /* @__PURE__ */ jsx(Card, { ...rest, as, className: t9, display: "flex", ref, children: t15 }), $[47] = as, $[48] = rest, $[49] = t15, $[50] = t16) : t16 = $[50], t16;
1194
+ return $[4] !== children || $[5] !== rest || $[6] !== t2 || $[7] !== tree.space ? (t3 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "TreeGroup", ...rest, hidden: t2, marginTop: tree.space, role: "group", gap: tree.space, children }), $[4] = children, $[5] = rest, $[6] = t2, $[7] = tree.space, $[8] = t3) : t3 = $[8], t3;
1195
+ }), DEFAULT_TREE_ITEM_ELEMENT = "a";
1196
+ function TreeItem(props) {
1197
+ const {
1198
+ children,
1199
+ className,
1200
+ expanded: expandedProp = !1,
1201
+ fontSize = 1,
1202
+ href,
1203
+ icon: IconComponent,
1204
+ id: idProp,
1205
+ linkAs = "a",
1206
+ muted,
1207
+ onClick,
1208
+ padding = 2,
1209
+ radius = 2,
1210
+ selected = !1,
1211
+ space = 2,
1212
+ text,
1213
+ weight,
1214
+ ...rest
1215
+ } = props, rootRef = useRef(null), treeitemRef = useRef(null), tree = useTree(), {
1216
+ path,
1217
+ registerItem,
1218
+ setExpanded,
1219
+ setFocusedElement
1220
+ } = tree, _id = useId(), id = idProp || _id, itemPath = useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, focused = tree.focusedElement && tree.focusedElement === rootRef.current, tabIndex = focused ? 0 : -1, contextValue = useMemo(() => ({
1221
+ ...tree,
1222
+ level: tree.level + 1,
1223
+ path: itemPath
1224
+ }), [itemPath, tree]), handleClick = useCallback((event) => {
1225
+ onClick && onClick(event);
1226
+ const target = event.target;
1227
+ target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
1228
+ }, [expanded, itemKey, onClick, setExpanded, setFocusedElement]), handleKeyDown = useCallback((event_0) => {
1229
+ focused && event_0.key === "Enter" && (treeitemRef.current || rootRef.current)?.click();
1230
+ }, [focused]);
1231
+ useEffect(() => {
1232
+ if (rootRef.current)
1233
+ return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
1234
+ }, [expanded, itemPath, registerItem, selected]);
1235
+ const content2 = /* @__PURE__ */ jsxs(Flex, { gap: space, padding, children: [
1236
+ /* @__PURE__ */ jsxs(Box, { style: {
1237
+ visibility: IconComponent || children ? "visible" : "hidden",
1238
+ pointerEvents: "none"
1239
+ }, children: [
1240
+ IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }),
1241
+ !IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: {
1242
+ transform: expanded ? "rotate(90deg)" : void 0
1243
+ } }) })
1244
+ ] }),
1245
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
1246
+ ] });
1247
+ return href ? /* @__PURE__ */ jsxs(Box, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...rest, as: "li", className: treeItem({
1248
+ className
1249
+ }), onClick: handleClick, ref: rootRef, role: "none", children: [
1250
+ /* @__PURE__ */ jsx(
1251
+ Selectable,
1252
+ {
1253
+ "aria-expanded": expanded,
1254
+ as: linkAs,
1255
+ "data-ui": "TreeItem__box",
1256
+ href,
1257
+ radius,
1258
+ ref: treeitemRef,
1259
+ role: "treeitem",
1260
+ selected,
1261
+ tabIndex,
1262
+ style: {
1263
+ paddingLeft: `calc(${vars.space[2]} * ${tree.level})`
1264
+ },
1265
+ children: content2
1266
+ }
1267
+ ),
1268
+ /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { hidden: !expanded, children }) })
1269
+ ] }) : /* @__PURE__ */ jsxs(Box, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...rest, "aria-expanded": expanded, className: treeItem({
1270
+ className
1271
+ }), onClick: handleClick, onKeyDown: handleKeyDown, ref: rootRef, role: "treeitem", tabIndex, children: [
1272
+ /* @__PURE__ */ jsx(
1273
+ Selectable,
1274
+ {
1275
+ as: "button",
1276
+ "data-focused": focused ? "" : void 0,
1277
+ "data-ui": "TreeItem__box",
1278
+ radius,
1279
+ selected,
1280
+ style: {
1281
+ paddingLeft: `calc(${vars.space[2]} * ${tree.level})`
1282
+ },
1283
+ children: content2
1284
+ }
1285
+ ),
1286
+ /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { expanded, children }) })
1287
+ ] });
1047
1288
  }
1048
- const DialogContext = createGlobalScopedContext("@sanity/ui/context/dialog", {
1049
- version: 0
1050
- });
1051
- function useDialog() {
1052
- return useContext(DialogContext);
1289
+ function _isScrollable(el) {
1290
+ if (!(el instanceof Element)) return !1;
1291
+ const style = window.getComputedStyle(el);
1292
+ return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
1053
1293
  }
1054
- const DEFAULT_DIALOG_ELEMENT = "div";
1055
- function Dialog(props) {
1056
- const $ = c(69), context = useDialog(), t0 = props;
1057
- let _positionProp, _zOffsetProp, children, className, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, portalProp, rest, scheme, t1, t2, t3, t4, t5, t6, t7, tone;
1294
+ const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : ResizeObserver, DEFAULT_VIRTUAL_LIST_ELEMENT = "div";
1295
+ function VirtualList(props) {
1296
+ const $ = c(61), t0 = props;
1297
+ let forwardedRef, getItemKey, onChange, renderItem, rest, t1, t2, t3;
1058
1298
  $[0] !== t0 ? ({
1059
- __unstable_autoFocus: t1,
1060
- __unstable_hideCloseButton: t2,
1061
- animate: t3,
1062
- cardRadius: t4,
1063
- children,
1064
- className,
1065
- contentRef,
1066
- footer,
1067
- header,
1068
- id,
1069
- onActivate,
1070
- onClickOutside,
1071
- onClose,
1072
- onFocus,
1073
- padding: t5,
1074
- portal: portalProp,
1075
- position: _positionProp,
1076
- scheme,
1077
- shadow: t6,
1078
- width: t7,
1079
- zOffset: _zOffsetProp,
1080
- tone,
1299
+ as: t1,
1300
+ gap: t2,
1301
+ getItemKey,
1302
+ items: t3,
1303
+ onChange,
1304
+ renderItem,
1305
+ ref: forwardedRef,
1081
1306
  ...rest
1082
- } = t0, $[0] = t0, $[1] = _positionProp, $[2] = _zOffsetProp, $[3] = children, $[4] = className, $[5] = contentRef, $[6] = footer, $[7] = header, $[8] = id, $[9] = onActivate, $[10] = onClickOutside, $[11] = onClose, $[12] = onFocus, $[13] = portalProp, $[14] = rest, $[15] = scheme, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = tone) : (_positionProp = $[1], _zOffsetProp = $[2], children = $[3], className = $[4], contentRef = $[5], footer = $[6], header = $[7], id = $[8], onActivate = $[9], onClickOutside = $[10], onClose = $[11], onFocus = $[12], portalProp = $[13], rest = $[14], scheme = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21], t7 = $[22], tone = $[23]);
1083
- const autoFocus = t1 === void 0 ? !0 : t1, hideCloseButton = t2 === void 0 ? !1 : t2, _animate = t3 === void 0 ? !1 : t3, cardRadiusProp = t4 === void 0 ? 4 : t4, padding = t5 === void 0 ? 3 : t5, cardShadow = t6 === void 0 ? 4 : t6, width = t7 === void 0 ? 0 : t7, positionProp = _positionProp ?? context.position ?? "fixed", zOffsetProp = _zOffsetProp ?? context.zOffset ?? Z_OFFSETS.dialog, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useResponsiveProp(cardRadiusProp), position = useResponsiveProp(positionProp), zOffset = useResponsiveProp(zOffsetProp), preDivRef = useRef(null), postDivRef = useRef(null), cardRef = useRef(null), focusedElementRef = useRef(null);
1084
- let t8;
1085
- $[24] !== onFocus ? (t8 = (event) => {
1086
- onFocus?.(event);
1087
- const target = event.target, cardElement = cardRef.current;
1088
- if (cardElement && target === preDivRef.current) {
1089
- focusLastDescendant(cardElement);
1090
- return;
1091
- }
1092
- if (cardElement && target === postDivRef.current) {
1093
- focusFirstDescendant(cardElement);
1307
+ } = t0, $[0] = t0, $[1] = forwardedRef, $[2] = getItemKey, $[3] = onChange, $[4] = renderItem, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3) : (forwardedRef = $[1], getItemKey = $[2], onChange = $[3], renderItem = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8]);
1308
+ const as = t1 === void 0 ? DEFAULT_VIRTUAL_LIST_ELEMENT : t1, gap = t2 === void 0 ? 0 : t2;
1309
+ let t4;
1310
+ $[9] !== t3 ? (t4 = t3 === void 0 ? [] : t3, $[9] = t3, $[10] = t4) : t4 = $[10];
1311
+ const items = t4, ref = useRef(null), wrapperRef = useRef(null), [scrollTop, setScrollTop] = useState(0), [scrollHeight, setScrollHeight] = useState(0), [itemHeight, setItemHeight] = useState(-1), [gapValue, setGapValue] = useState(0);
1312
+ let t5;
1313
+ $[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => ref.current, $[11] = t5) : t5 = $[11], useImperativeHandle(forwardedRef, t5);
1314
+ let t6, t7;
1315
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
1316
+ if (!ref.current)
1094
1317
  return;
1318
+ const scrollEl = findScrollable(ref.current.parentNode);
1319
+ if (scrollEl) {
1320
+ if (!(scrollEl instanceof HTMLElement))
1321
+ return;
1322
+ const handleScroll = () => {
1323
+ setScrollTop(scrollEl.scrollTop);
1324
+ };
1325
+ scrollEl.addEventListener("scroll", handleScroll, {
1326
+ passive: !0
1327
+ });
1328
+ const ro = new _ResizeObserver((entries) => {
1329
+ setScrollHeight(entries[0].contentRect.height);
1330
+ });
1331
+ return ro.observe(scrollEl), handleScroll(), () => {
1332
+ scrollEl.removeEventListener("scroll", handleScroll), ro.unobserve(scrollEl), ro.disconnect();
1333
+ };
1095
1334
  }
1096
- isHTMLElement(event.target) && (focusedElementRef.current = event.target);
1097
- }, $[24] = onFocus, $[25] = t8) : t8 = $[25];
1098
- const handleFocus = t8, labelId = `${id}_label`, rootClickTimeoutRef = useRef(void 0);
1099
- let t9;
1100
- $[26] !== boundaryElement || $[27] !== portalElement ? (t9 = () => {
1101
- rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => {
1102
- const activeElement = document.activeElement;
1103
- if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) {
1104
- const target_0 = focusedElementRef.current;
1105
- if (!target_0 || !document.body.contains(target_0)) {
1106
- const cardElement_0 = cardRef.current;
1107
- cardElement_0 && focusFirstDescendant(cardElement_0);
1108
- return;
1109
- }
1110
- target_0.focus();
1111
- }
1112
- }, 0);
1113
- }, $[26] = boundaryElement, $[27] = portalElement, $[28] = t9) : t9 = $[28];
1114
- const handleRootClick = t9;
1335
+ const handleScroll_0 = () => {
1336
+ setScrollTop(window.scrollY);
1337
+ }, handleResize = () => {
1338
+ setScrollHeight(window.innerHeight);
1339
+ };
1340
+ return window.addEventListener("scroll", handleScroll_0, {
1341
+ passive: !0
1342
+ }), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll_0(), () => {
1343
+ window.removeEventListener("scroll", handleScroll_0), window.removeEventListener("resize", handleResize);
1344
+ };
1345
+ }, t7 = [], $[12] = t6, $[13] = t7) : (t6 = $[12], t7 = $[13]), useEffect(t6, t7);
1346
+ const len = items.length, height = itemHeight ? len * (itemHeight + gapValue) - gapValue : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
1347
+ let t8, t9;
1348
+ $[14] !== fromIndex || $[15] !== gapValue || $[16] !== itemHeight || $[17] !== onChange || $[18] !== scrollHeight || $[19] !== scrollTop || $[20] !== toIndex ? (t8 = () => {
1349
+ onChange?.({
1350
+ fromIndex,
1351
+ gap: gapValue,
1352
+ itemHeight,
1353
+ scrollHeight,
1354
+ scrollTop,
1355
+ toIndex
1356
+ });
1357
+ }, t9 = [fromIndex, gapValue, itemHeight, onChange, scrollHeight, scrollTop, toIndex], $[14] = fromIndex, $[15] = gapValue, $[16] = itemHeight, $[17] = onChange, $[18] = scrollHeight, $[19] = scrollTop, $[20] = toIndex, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), useEffect(t8, t9);
1115
1358
  let t10;
1116
- $[29] !== className ? (t10 = dialog({
1117
- className
1118
- }), $[29] = className, $[30] = t10) : t10 = $[30];
1119
- const t11 = animate ? "" : void 0;
1359
+ $[23] === Symbol.for("react.memo_cache_sentinel") ? (t10 = () => {
1360
+ setItemHeight(-1);
1361
+ }, $[23] = t10) : t10 = $[23];
1362
+ let t11;
1363
+ $[24] !== renderItem ? (t11 = [renderItem], $[24] = renderItem, $[25] = t11) : t11 = $[25], useEffect(t10, t11);
1120
1364
  let t12;
1121
- $[31] === Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx("div", { ref: preDivRef, tabIndex: 0 }), $[31] = t12) : t12 = $[31];
1122
- let t13;
1123
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t13 = dialogContainer(), $[32] = t13) : t13 = $[32];
1124
- let t14;
1125
- $[33] !== autoFocus || $[34] !== cardRadius || $[35] !== cardShadow || $[36] !== children || $[37] !== contentRef || $[38] !== footer || $[39] !== header || $[40] !== hideCloseButton || $[41] !== id || $[42] !== onClickOutside || $[43] !== onClose || $[44] !== portalProp || $[45] !== scheme || $[46] !== tone || $[47] !== width ? (t14 = /* @__PURE__ */ jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, tone, width, children }), $[33] = autoFocus, $[34] = cardRadius, $[35] = cardShadow, $[36] = children, $[37] = contentRef, $[38] = footer, $[39] = header, $[40] = hideCloseButton, $[41] = id, $[42] = onClickOutside, $[43] = onClose, $[44] = portalProp, $[45] = scheme, $[46] = tone, $[47] = width, $[48] = t14) : t14 = $[48];
1365
+ bb0: {
1366
+ if (!renderItem || items.length === 0) {
1367
+ t12 = null;
1368
+ break bb0;
1369
+ }
1370
+ if (itemHeight === -1) {
1371
+ let t133;
1372
+ $[26] === Symbol.for("react.memo_cache_sentinel") ? (t133 = (el) => el ? setItemHeight(el.offsetHeight) : void 0, $[26] = t133) : t133 = $[26];
1373
+ let t142;
1374
+ $[27] !== items[0] || $[28] !== renderItem ? (t142 = renderItem(items[0]), $[27] = items[0], $[28] = renderItem, $[29] = t142) : t142 = $[29];
1375
+ let t152;
1376
+ $[30] !== t142 ? (t152 = /* @__PURE__ */ jsx(Box, { ref: t133, insetTop: 0, insetLeft: 0, insetRight: 0, position: "absolute", children: t142 }, 0), $[30] = t142, $[31] = t152) : t152 = $[31];
1377
+ let t162;
1378
+ $[32] === Symbol.for("react.memo_cache_sentinel") ? (t162 = (el_0) => el_0 ? setGapValue(el_0.offsetHeight) : void 0, $[32] = t162) : t162 = $[32];
1379
+ const t17 = vars.space[gap];
1380
+ let t18;
1381
+ $[33] !== t17 ? (t18 = /* @__PURE__ */ jsx("div", { ref: t162, style: {
1382
+ height: t17
1383
+ } }), $[33] = t17, $[34] = t18) : t18 = $[34];
1384
+ let t19;
1385
+ $[35] !== t152 || $[36] !== t18 ? (t19 = [/* @__PURE__ */ jsxs(Fragment$1, { children: [
1386
+ t152,
1387
+ t18
1388
+ ] })], $[35] = t152, $[36] = t18, $[37] = t19) : t19 = $[37], t12 = t19;
1389
+ break bb0;
1390
+ }
1391
+ let t132;
1392
+ if ($[38] !== fromIndex || $[39] !== gapValue || $[40] !== getItemKey || $[41] !== itemHeight || $[42] !== items || $[43] !== renderItem || $[44] !== toIndex) {
1393
+ let t142;
1394
+ $[46] !== fromIndex || $[47] !== gapValue || $[48] !== getItemKey || $[49] !== itemHeight || $[50] !== renderItem ? (t142 = (item, _itemIndex) => {
1395
+ const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
1396
+ return /* @__PURE__ */ jsx(Box, { insetLeft: 0, insetRight: 0, position: "absolute", style: {
1397
+ top: itemIndex * (itemHeight + gapValue)
1398
+ }, children: node }, key);
1399
+ }, $[46] = fromIndex, $[47] = gapValue, $[48] = getItemKey, $[49] = itemHeight, $[50] = renderItem, $[51] = t142) : t142 = $[51], t132 = items.slice(fromIndex, toIndex).map(t142), $[38] = fromIndex, $[39] = gapValue, $[40] = getItemKey, $[41] = itemHeight, $[42] = items, $[43] = renderItem, $[44] = toIndex, $[45] = t132;
1400
+ } else
1401
+ t132 = $[45];
1402
+ t12 = t132;
1403
+ }
1404
+ const children = t12;
1405
+ let t13, t14;
1406
+ $[52] !== height ? (t14 = {
1407
+ height
1408
+ }, $[52] = height, $[53] = t14) : t14 = $[53], t13 = t14;
1409
+ const wrapperStyle = t13;
1126
1410
  let t15;
1127
- $[49] !== t14 || $[50] !== width ? (t15 = /* @__PURE__ */ jsx(Container, { alignItems: "center", className: t13, "data-ui": "DialogCard", flexDirection: "column", display: "flex", justifyContent: "center", width, children: t14 }), $[49] = t14, $[50] = width, $[51] = t15) : t15 = $[51];
1411
+ $[54] !== children || $[55] !== wrapperStyle ? (t15 = /* @__PURE__ */ jsx("div", { ref: wrapperRef, style: wrapperStyle, children }), $[54] = children, $[55] = wrapperStyle, $[56] = t15) : t15 = $[56];
1128
1412
  let t16;
1129
- $[52] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsx("div", { ref: postDivRef, tabIndex: 0 }), $[52] = t16) : t16 = $[52];
1130
- let t17;
1131
- $[53] !== handleFocus || $[54] !== handleRootClick || $[55] !== id || $[56] !== labelId || $[57] !== onActivate || $[58] !== padding || $[59] !== position || $[60] !== rest || $[61] !== t10 || $[62] !== t11 || $[63] !== t15 || $[64] !== zOffset ? (t17 = /* @__PURE__ */ jsxs(Layer, { ...rest, "aria-labelledby": labelId, "aria-modal": !0, className: t10, "data-animate": t11, "data-ui": "Dialog", display: "flex", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, padding, position, role: "dialog", zOffset, children: [
1132
- t12,
1133
- t15,
1134
- t16
1135
- ] }), $[53] = handleFocus, $[54] = handleRootClick, $[55] = id, $[56] = labelId, $[57] = onActivate, $[58] = padding, $[59] = position, $[60] = rest, $[61] = t10, $[62] = t11, $[63] = t15, $[64] = zOffset, $[65] = t17) : t17 = $[65];
1136
- let t18;
1137
- return $[66] !== portalProp || $[67] !== t17 ? (t18 = /* @__PURE__ */ jsx(Portal, { __unstable_name: portalProp, children: t17 }), $[66] = portalProp, $[67] = t17, $[68] = t18) : t18 = $[68], t18;
1413
+ return $[57] !== as || $[58] !== rest || $[59] !== t15 ? (t16 = /* @__PURE__ */ jsx(Box, { "data-ui": "VirtualList", ...rest, as, position: "relative", ref, children: t15 }), $[57] = as, $[58] = rest, $[59] = t15, $[60] = t16) : t16 = $[60], t16;
1138
1414
  }
1139
- function DialogProvider(props) {
1140
- const $ = c(6), {
1141
- children,
1142
- position,
1143
- zOffset
1144
- } = props;
1145
- let t0, t1;
1146
- $[0] !== position || $[1] !== zOffset ? (t1 = {
1147
- version: 0,
1148
- position,
1149
- zOffset
1150
- }, $[0] = position, $[1] = zOffset, $[2] = t1) : t1 = $[2], t0 = t1;
1151
- const contextValue = t0;
1152
- let t2;
1153
- return $[3] !== children || $[4] !== contextValue ? (t2 = /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t2) : t2 = $[5], t2;
1415
+ function findScrollable(parentNode) {
1416
+ let _scrollEl = parentNode;
1417
+ for (; _scrollEl && !_isScrollable(_scrollEl); )
1418
+ _scrollEl = _scrollEl.parentNode;
1419
+ return _scrollEl;
1154
1420
  }
1155
- function MenuButton(props) {
1156
- const $ = c(63), {
1157
- __unstable_disableRestoreFocusOnClose: t0,
1158
- boundaryElement: deprecated_boundaryElement,
1159
- button: buttonProp,
1160
- id,
1161
- menu: menuProp,
1162
- onClose,
1163
- onOpen,
1164
- placement: deprecated_placement,
1165
- popoverScheme: deprecated_popoverScheme,
1166
- portal: t1,
1167
- popover,
1168
- popoverRadius: deprecated_popoverRadius,
1169
- preventOverflow: deprecated_preventOverflow,
1170
- ref: forwardedRef
1171
- } = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null);
1172
- let t2;
1173
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
1174
- const [menuElements, setChildMenuElements] = useState(t2), openRef = useRef(open);
1175
- let t3, t4;
1176
- $[1] !== onOpen || $[2] !== open ? (t3 = () => {
1177
- onOpen && open && !openRef.current && onOpen();
1178
- }, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), useEffect(t3, t4);
1179
- let t5, t6;
1180
- $[5] !== onClose || $[6] !== open ? (t5 = () => {
1181
- onClose && !open && openRef.current && onClose();
1182
- }, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), useEffect(t5, t6);
1183
- let t7, t8;
1184
- $[9] !== open ? (t7 = () => {
1185
- openRef.current = open;
1186
- }, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), useEffect(t7, t8);
1187
- let t9;
1188
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
1189
- setOpen(_temp$2), setShouldFocus(null);
1190
- }, $[12] = t9) : t9 = $[12];
1191
- const handleButtonClick = t9;
1192
- let t10;
1193
- $[13] !== open ? (t10 = (event) => {
1194
- open && event.preventDefault();
1195
- }, $[13] = open, $[14] = t10) : t10 = $[14];
1196
- const handleMouseDown = t10;
1197
- let t11;
1198
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
1199
- if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
1200
- event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
1421
+ function useArrayProp(val, defaultVal) {
1422
+ const $ = c(3);
1423
+ let t0;
1424
+ $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getArrayProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
1425
+ const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
1426
+ return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
1427
+ }
1428
+ function _getElements(element, elementsArg) {
1429
+ const ret = [element];
1430
+ for (const el of elementsArg)
1431
+ Array.isArray(el) ? ret.push(...el) : ret.push(el);
1432
+ return ret.filter(Boolean);
1433
+ }
1434
+ function useClickOutside(listener, t0, boundaryElement) {
1435
+ const $ = c(12), elementsArg = t0 === void 0 ? EMPTY_ARRAY : t0, [element, setElement] = useState(null);
1436
+ let t1;
1437
+ $[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2];
1438
+ const [elements, setElements] = useState(t1), elementsRef = useRef(elements);
1439
+ let t2, t3;
1440
+ $[3] !== element || $[4] !== elementsArg ? (t2 = () => {
1441
+ const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
1442
+ if (prevElements.length !== nextElements.length) {
1443
+ setElements(nextElements), elementsRef.current = nextElements;
1201
1444
  return;
1202
1445
  }
1203
- if (event_0.key === "ArrowUp") {
1204
- event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
1446
+ for (const el of prevElements)
1447
+ if (!nextElements.includes(el)) {
1448
+ setElements(nextElements), elementsRef.current = nextElements;
1449
+ return;
1450
+ }
1451
+ for (const el_0 of nextElements)
1452
+ if (!prevElements.includes(el_0)) {
1453
+ setElements(nextElements), elementsRef.current = nextElements;
1454
+ return;
1455
+ }
1456
+ }, t3 = [element, elementsArg], $[3] = element, $[4] = elementsArg, $[5] = t2, $[6] = t3) : (t2 = $[5], t3 = $[6]), useEffect(t2, t3);
1457
+ let t4, t5;
1458
+ return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => {
1459
+ if (!listener)
1205
1460
  return;
1461
+ const handleWindowMouseDown = (evt) => {
1462
+ const target = evt.target;
1463
+ if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
1464
+ for (const el_1 of elements)
1465
+ if (target === el_1 || el_1.contains(target))
1466
+ return;
1467
+ listener(evt);
1468
+ }
1469
+ };
1470
+ return window.addEventListener("mousedown", handleWindowMouseDown), () => {
1471
+ window.removeEventListener("mousedown", handleWindowMouseDown);
1472
+ };
1473
+ }, t5 = [boundaryElement, listener, elements], $[7] = boundaryElement, $[8] = elements, $[9] = listener, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), useEffect(t4, t5), setElement;
1474
+ }
1475
+ const _elementSizeObserver = _createElementSizeObserver();
1476
+ function _createElementRectValueListener() {
1477
+ return {
1478
+ subscribe(element, subscriber) {
1479
+ const resizeObserver = new _ResizeObserver(([entry]) => {
1480
+ subscriber({
1481
+ _contentRect: entry.contentRect,
1482
+ border: {
1483
+ width: entry.borderBoxSize[0].inlineSize,
1484
+ height: entry.borderBoxSize[0].blockSize
1485
+ },
1486
+ content: {
1487
+ width: entry.contentRect.width,
1488
+ height: entry.contentRect.height
1489
+ }
1490
+ });
1491
+ });
1492
+ return resizeObserver.observe(element), () => {
1493
+ resizeObserver.unobserve(element), resizeObserver.disconnect();
1494
+ };
1206
1495
  }
1207
- }, $[15] = t11) : t11 = $[15];
1208
- const handleButtonKeyDown = t11;
1209
- let t12;
1210
- $[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
1211
- const target = event_1.target;
1212
- if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
1213
- for (const el of menuElements)
1214
- if (target === el || el.contains(target))
1215
- return;
1216
- setOpen(!1);
1217
- }
1218
- }, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18];
1219
- const handleMenuClickOutside = t12;
1220
- let t13;
1221
- $[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => {
1222
- setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
1223
- }, $[19] = buttonElement, $[20] = disableRestoreFocusOnClose, $[21] = t13) : t13 = $[21];
1224
- const handleMenuEscape = t13;
1225
- let t14;
1226
- $[22] !== menuElements ? (t14 = (event_2) => {
1227
- const target_0 = event_2.relatedTarget;
1228
- if (target_0 instanceof Node) {
1229
- for (const el_0 of menuElements)
1230
- if (el_0 === target_0 || el_0.contains(target_0))
1231
- return;
1232
- setOpen(!1);
1233
- }
1234
- }, $[22] = menuElements, $[23] = t14) : t14 = $[23];
1235
- const handleBlur = t14;
1236
- let t15;
1237
- $[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => {
1238
- setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
1239
- }, $[24] = buttonElement, $[25] = disableRestoreFocusOnClose, $[26] = t15) : t15 = $[26];
1240
- const handleItemClick = t15;
1241
- let t16;
1242
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
1243
- const registerElement = t16;
1244
- let t17;
1245
- $[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && cloneElement(menuProp, {
1246
- "aria-labelledby": id,
1247
- onBlurCapture: handleBlur,
1248
- onClickOutside: handleMenuClickOutside,
1249
- onEscape: handleMenuEscape,
1250
- onItemClick: handleItemClick,
1251
- originElement: buttonElement,
1252
- registerElement,
1253
- shouldFocus
1254
- }), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t17) : t17 = $[36];
1255
- const menu = t17;
1256
- let t18;
1257
- bb0: {
1258
- if (!buttonProp) {
1259
- t18 = null;
1260
- break bb0;
1496
+ };
1497
+ }
1498
+ function _createElementSizeObserver() {
1499
+ const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
1500
+ return {
1501
+ subscribe(element, subscriber) {
1502
+ const subscribers = subscribersCache.get(element) || [];
1503
+ let dispose = disposeCache.get(element);
1504
+ return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
1505
+ for (const sub of subscribers)
1506
+ sub(elementRect);
1507
+ })), subscribers.push(subscriber), () => {
1508
+ const idx = subscribers.indexOf(subscriber);
1509
+ idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
1510
+ };
1261
1511
  }
1262
- const t192 = buttonProp.props.selected ?? open;
1263
- let t202;
1264
- $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open || $[41] !== t192 ? (t202 = cloneElement(buttonProp, {
1265
- "data-ui": "MenuButton",
1266
- id,
1267
- onClick: handleButtonClick,
1268
- onKeyDown: handleButtonKeyDown,
1269
- onMouseDown: handleMouseDown,
1270
- "aria-haspopup": !0,
1271
- "aria-expanded": open,
1272
- ref: setButtonElement,
1273
- selected: t192
1274
- }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t192, $[42] = t202) : t202 = $[42], t18 = t202;
1275
- }
1276
- const button = t18;
1277
- let t19, t20;
1278
- $[43] !== buttonElement ? (t19 = () => buttonElement, t20 = [buttonElement], $[43] = buttonElement, $[44] = t19, $[45] = t20) : (t19 = $[44], t20 = $[45]), useImperativeHandle(forwardedRef, t19, t20);
1279
- let t21, t22;
1280
- $[46] !== popover ? (t22 = popover || {}, $[46] = popover, $[47] = t22) : t22 = $[47];
1281
- let t23;
1282
- $[48] !== deprecated_boundaryElement || $[49] !== deprecated_placement || $[50] !== deprecated_popoverRadius || $[51] !== deprecated_popoverScheme || $[52] !== deprecated_portal || $[53] !== deprecated_preventOverflow || $[54] !== t22 ? (t23 = {
1283
- boundaryElement: deprecated_boundaryElement,
1284
- overflow: "auto",
1285
- placement: deprecated_placement,
1286
- portal: deprecated_portal,
1287
- preventOverflow: deprecated_preventOverflow,
1288
- radius: deprecated_popoverRadius,
1289
- scheme: deprecated_popoverScheme,
1290
- ...t22
1291
- }, $[48] = deprecated_boundaryElement, $[49] = deprecated_placement, $[50] = deprecated_popoverRadius, $[51] = deprecated_popoverScheme, $[52] = deprecated_portal, $[53] = deprecated_preventOverflow, $[54] = t22, $[55] = t23) : t23 = $[55], t21 = t23;
1292
- const popoverProps = t21;
1293
- let t24;
1294
- $[56] !== button ? (t24 = button || /* @__PURE__ */ jsx(Fragment$1, {}), $[56] = button, $[57] = t24) : t24 = $[57];
1295
- let t25;
1296
- return $[58] !== menu || $[59] !== open || $[60] !== popoverProps || $[61] !== t24 ? (t25 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t24 }), $[58] = menu, $[59] = open, $[60] = popoverProps, $[61] = t24, $[62] = t25) : t25 = $[62], t25;
1512
+ };
1297
1513
  }
1298
- function _temp$2(v) {
1299
- return !v;
1514
+ function useElementSize(element) {
1515
+ const $ = c(3), [size, setSize] = useState(null);
1516
+ let t0, t1;
1517
+ return $[0] !== element ? (t0 = () => {
1518
+ if (element)
1519
+ return _elementSizeObserver.subscribe(element, setSize);
1520
+ }, t1 = [element], $[0] = element, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), size;
1300
1521
  }
1301
- const DEFAULT_SKELETON_ELEMENT = "div";
1302
- function Skeleton(props) {
1303
- const $ = c(17), t0 = props;
1304
- let className, delay, radius, rest, t1;
1305
- $[0] !== t0 ? ({
1306
- animated: t1,
1522
+ function useElementRect(element) {
1523
+ return useElementSize(element)?._contentRect || null;
1524
+ }
1525
+ function useForwardedRef(ref) {
1526
+ const $ = c(1), innerRef = useRef(null);
1527
+ let t0;
1528
+ return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => innerRef.current, $[0] = t0) : t0 = $[0], useImperativeHandle(ref, t0), innerRef;
1529
+ }
1530
+ const DEFAULT_LABEL_ELEMENT = "div";
1531
+ function Label(props) {
1532
+ const $ = c(28);
1533
+ let accent, align, children, className, rest, t0, t1, t2, t3, textOverflowProp;
1534
+ $[0] !== props ? ({
1535
+ accent,
1536
+ align,
1537
+ as: t0,
1538
+ children,
1307
1539
  className,
1308
- delay,
1309
- radius,
1540
+ muted: t1,
1541
+ size: t2,
1542
+ textOverflow: textOverflowProp,
1543
+ weight: t3,
1310
1544
  ...rest
1311
- } = t0, $[0] = t0, $[1] = className, $[2] = delay, $[3] = radius, $[4] = rest, $[5] = t1) : (className = $[1], delay = $[2], radius = $[3], rest = $[4], t1 = $[5]);
1312
- const animated = t1 === void 0 ? !1 : t1, [visible, setVisible] = useState(!delay);
1313
- let t2, t3;
1314
- $[6] !== delay ? (t2 = () => {
1315
- if (!delay)
1316
- return setVisible(!0);
1317
- const timeout = setTimeout(() => {
1318
- setVisible(!0);
1319
- }, delay);
1320
- return () => {
1321
- clearTimeout(timeout);
1322
- };
1323
- }, t3 = [delay], $[6] = delay, $[7] = t2, $[8] = t3) : (t2 = $[7], t3 = $[8]), useEffect(t2, t3);
1545
+ } = props, $[0] = props, $[1] = accent, $[2] = align, $[3] = children, $[4] = className, $[5] = rest, $[6] = t0, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = textOverflowProp) : (accent = $[1], align = $[2], children = $[3], className = $[4], rest = $[5], t0 = $[6], t1 = $[7], t2 = $[8], t3 = $[9], textOverflowProp = $[10]);
1546
+ const Element2 = t0 === void 0 ? DEFAULT_LABEL_ELEMENT : t0, muted = t1 === void 0 ? !1 : t1, size = t2 === void 0 ? 1 : t2, weight = t3 === void 0 ? "regular" : t3;
1324
1547
  let t4;
1325
- $[9] !== className || $[10] !== radius ? (t4 = skeleton({
1548
+ $[11] !== accent || $[12] !== align || $[13] !== className || $[14] !== muted || $[15] !== size || $[16] !== weight ? (t4 = label({
1326
1549
  className,
1327
- radius
1328
- }), $[9] = className, $[10] = radius, $[11] = t4) : t4 = $[11];
1329
- const t5 = animated ? "" : void 0, t6 = visible ? "" : void 0;
1550
+ accent,
1551
+ align,
1552
+ muted,
1553
+ size,
1554
+ weight
1555
+ }), $[11] = accent, $[12] = align, $[13] = className, $[14] = muted, $[15] = size, $[16] = weight, $[17] = t4) : t4 = $[17];
1556
+ let t5;
1557
+ $[18] !== textOverflowProp ? (t5 = textOverflow({
1558
+ textOverflow: textOverflowProp
1559
+ }), $[18] = textOverflowProp, $[19] = t5) : t5 = $[19];
1560
+ let t6;
1561
+ $[20] !== children || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx("span", { className: t5, children }), $[20] = children, $[21] = t5, $[22] = t6) : t6 = $[22];
1330
1562
  let t7;
1331
- return $[12] !== rest || $[13] !== t4 || $[14] !== t5 || $[15] !== t6 ? (t7 = /* @__PURE__ */ jsx(Box, { "data-ui": "Skeleton", ...rest, className: t4, "data-animated": t5, "data-visible": t6 }), $[12] = rest, $[13] = t4, $[14] = t5, $[15] = t6, $[16] = t7) : t7 = $[16], t7;
1563
+ return $[23] !== Element2 || $[24] !== rest || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsx(Element2, { "data-ui": "Label", ...rest, className: t4, children: t6 }), $[23] = Element2, $[24] = rest, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t7;
1332
1564
  }
1333
- const DEFAULT_CODE_SKELETON_ELEMENT = "div";
1334
- function CodeSkeleton(props) {
1335
- const $ = c(10), t0 = props;
1336
- let className, rest, t1;
1565
+ const DEFAULT_AVATAR_ELEMENT = "span";
1566
+ function Avatar(props) {
1567
+ const $ = c(51), t0 = props;
1568
+ let __unstable_hideInnerStroke, animateArrowFrom, arrowPositionProp, className, initials, onImageLoadError, rest, src, t1, t2, t3, t4, title;
1337
1569
  $[0] !== t0 ? ({
1570
+ __unstable_hideInnerStroke,
1571
+ as: t1,
1338
1572
  className,
1339
- size: t1,
1573
+ color: t2,
1574
+ src,
1575
+ title,
1576
+ initials,
1577
+ onImageLoadError,
1578
+ arrowPosition: arrowPositionProp,
1579
+ animateArrowFrom,
1580
+ status: t3,
1581
+ size: t4,
1340
1582
  ...rest
1341
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1342
- const size = t1 === void 0 ? 2 : t1;
1343
- let t2;
1344
- $[4] !== className || $[5] !== size ? (t2 = codeSkeleton({
1583
+ } = t0, $[0] = t0, $[1] = __unstable_hideInnerStroke, $[2] = animateArrowFrom, $[3] = arrowPositionProp, $[4] = className, $[5] = initials, $[6] = onImageLoadError, $[7] = rest, $[8] = src, $[9] = t1, $[10] = t2, $[11] = t3, $[12] = t4, $[13] = title) : (__unstable_hideInnerStroke = $[1], animateArrowFrom = $[2], arrowPositionProp = $[3], className = $[4], initials = $[5], onImageLoadError = $[6], rest = $[7], src = $[8], t1 = $[9], t2 = $[10], t3 = $[11], t4 = $[12], title = $[13]);
1584
+ const Element2 = t1 === void 0 ? DEFAULT_AVATAR_ELEMENT : t1, color = t2 === void 0 ? "magenta" : t2, sizeProp = t4 === void 0 ? 1 : t4, size = useResponsiveProp(sizeProp), [arrowPosition, setArrowPosition] = useState(animateArrowFrom || arrowPositionProp || "inside"), [imageError, setImageError] = useState(!1);
1585
+ let t5, t6;
1586
+ $[14] !== arrowPosition || $[15] !== arrowPositionProp ? (t5 = () => {
1587
+ if (arrowPosition === arrowPositionProp)
1588
+ return;
1589
+ const raf = requestAnimationFrame(() => setArrowPosition(arrowPositionProp));
1590
+ return () => cancelAnimationFrame(raf);
1591
+ }, t6 = [arrowPosition, arrowPositionProp], $[14] = arrowPosition, $[15] = arrowPositionProp, $[16] = t5, $[17] = t6) : (t5 = $[16], t6 = $[17]), useEffect(t5, t6);
1592
+ let t7, t8;
1593
+ $[18] !== src ? (t7 = () => {
1594
+ src && setImageError(!1);
1595
+ }, t8 = [src], $[18] = src, $[19] = t7, $[20] = t8) : (t7 = $[19], t8 = $[20]), useEffect(t7, t8);
1596
+ let t9;
1597
+ $[21] !== onImageLoadError ? (t9 = () => {
1598
+ setImageError(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
1599
+ }, $[21] = onImageLoadError, $[22] = t9) : t9 = $[22];
1600
+ const handleImageError = t9;
1601
+ let t10, t11;
1602
+ $[23] !== size ? (t11 = Object.values(size).map(_temp$1), $[23] = size, $[24] = t11) : t11 = $[24], t10 = t11;
1603
+ const initialsSize = t10, t12 = __unstable_hideInnerStroke ? "" : void 0;
1604
+ let t13;
1605
+ $[25] !== className || $[26] !== color || $[27] !== sizeProp ? (t13 = avatar({
1345
1606
  className,
1346
- size
1347
- }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1348
- let t3;
1349
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1607
+ color,
1608
+ size: sizeProp
1609
+ }), $[25] = className, $[26] = color, $[27] = sizeProp, $[28] = t13) : t13 = $[28];
1610
+ const t14 = imageError ? "" : void 0;
1611
+ let t15;
1612
+ $[29] === Symbol.for("react.memo_cache_sentinel") ? (t15 = avatarArrow(), $[29] = t15) : t15 = $[29];
1613
+ let t16;
1614
+ $[30] !== color ? (t16 = /* @__PURE__ */ jsx("span", { className: t15, children: /* @__PURE__ */ jsx("svg", { width: "11", height: "7", viewBox: "0 0 11 7", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M6.67948 1.50115L11 7L0 7L4.32052 1.50115C4.92109 0.736796 6.07891 0.736795 6.67948 1.50115Z", fill: color }) }) }), $[30] = color, $[31] = t16) : t16 = $[31];
1615
+ let t17;
1616
+ $[32] === Symbol.for("react.memo_cache_sentinel") ? (t17 = avatarInitials(), $[32] = t17) : t17 = $[32];
1617
+ let t18;
1618
+ $[33] !== initials || $[34] !== initialsSize ? (t18 = /* @__PURE__ */ jsx(Box, { alignItems: "center", as: "span", className: t17, display: "flex", justifyContent: "center", position: "absolute", inset: 0, children: /* @__PURE__ */ jsx(Label, { align: "center", as: "span", size: initialsSize, weight: "medium", children: initials }) }), $[33] = initials, $[34] = initialsSize, $[35] = t18) : t18 = $[35];
1619
+ let t19;
1620
+ $[36] !== handleImageError || $[37] !== initials || $[38] !== src ? (t19 = src && /* @__PURE__ */ jsxs(Box, { className: avatarImage(), inset: 0, position: "absolute", children: [
1621
+ /* @__PURE__ */ jsx("img", { alt: initials, onError: handleImageError, src }),
1622
+ /* @__PURE__ */ jsx("span", { className: avatarImageOutline() })
1623
+ ] }), $[36] = handleImageError, $[37] = initials, $[38] = src, $[39] = t19) : t19 = $[39];
1624
+ let t20;
1625
+ return $[40] !== Element2 || $[41] !== arrowPosition || $[42] !== rest || $[43] !== t12 || $[44] !== t13 || $[45] !== t14 || $[46] !== t16 || $[47] !== t18 || $[48] !== t19 || $[49] !== title ? (t20 = /* @__PURE__ */ jsxs(Element2, { "data-hide-inner-stroke": t12, "data-ui": "Avatar", ...rest, "aria-label": title, className: t13, "data-arrow-position": arrowPosition, "data-image-error": t14, title, children: [
1626
+ t16,
1627
+ t18,
1628
+ t19
1629
+ ] }), $[40] = Element2, $[41] = arrowPosition, $[42] = rest, $[43] = t12, $[44] = t13, $[45] = t14, $[46] = t16, $[47] = t18, $[48] = t19, $[49] = title, $[50] = t20) : t20 = $[50], t20;
1350
1630
  }
1351
- const DEFAULT_HEADING_SKELETON_ELEMENT = "div";
1352
- function HeadingSkeleton(props) {
1353
- const $ = c(10), t0 = props;
1354
- let className, rest, t1;
1355
- $[0] !== t0 ? ({
1356
- className,
1357
- size: t1,
1358
- ...rest
1359
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1360
- const size = t1 === void 0 ? 2 : t1;
1361
- let t2;
1362
- $[4] !== className || $[5] !== size ? (t2 = headingSkeleton({
1363
- className,
1364
- size
1365
- }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1366
- let t3;
1367
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1631
+ function _temp$1(s) {
1632
+ return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
1368
1633
  }
1369
- const DEFAULT_LABEL_SKELETON_ELEMENT = "div";
1370
- function LabelSkeleton(props) {
1371
- const $ = c(10), t0 = props;
1372
- let className, rest, t1;
1634
+ const DEFAULT_AVATAR_COUNTER_ELEMENT = "span";
1635
+ function AvatarCounter(props) {
1636
+ const $ = c(19), t0 = props;
1637
+ let className, count, rest, t1, t2;
1373
1638
  $[0] !== t0 ? ({
1639
+ as: t1,
1374
1640
  className,
1375
- size: t1,
1641
+ count,
1642
+ size: t2,
1376
1643
  ...rest
1377
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1378
- const size = t1 === void 0 ? 2 : t1;
1379
- let t2;
1380
- $[4] !== className || $[5] !== size ? (t2 = labelSkeleton({
1644
+ } = t0, $[0] = t0, $[1] = className, $[2] = count, $[3] = rest, $[4] = t1, $[5] = t2) : (className = $[1], count = $[2], rest = $[3], t1 = $[4], t2 = $[5]);
1645
+ const as = t1 === void 0 ? DEFAULT_AVATAR_COUNTER_ELEMENT : t1, size = useResponsiveProp(t2 === void 0 ? 1 : t2);
1646
+ let t3, t4;
1647
+ $[6] !== size ? (t4 = Object.values(size).map(_temp), $[6] = size, $[7] = t4) : t4 = $[7], t3 = t4;
1648
+ const labelSize = t3;
1649
+ let t5;
1650
+ $[8] !== className || $[9] !== size ? (t5 = avatarCounter({
1381
1651
  className,
1382
1652
  size
1383
- }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1384
- let t3;
1385
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1653
+ }), $[8] = className, $[9] = size, $[10] = t5) : t5 = $[10];
1654
+ let t6;
1655
+ $[11] !== count || $[12] !== labelSize ? (t6 = /* @__PURE__ */ jsx(Label, { align: "center", as: "span", size: labelSize, weight: "medium", children: count }), $[11] = count, $[12] = labelSize, $[13] = t6) : t6 = $[13];
1656
+ let t7;
1657
+ return $[14] !== as || $[15] !== rest || $[16] !== t5 || $[17] !== t6 ? (t7 = /* @__PURE__ */ jsx(Box, { "data-ui": "AvatarCounter", ...rest, alignItems: "center", as, className: t5, display: "flex", flex: "none", justifyContent: "center", paddingX: 2, sizing: "border", children: t6 }), $[14] = as, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
1386
1658
  }
1387
- const DEFAULT_TEXT_SKELETON_ELEMENT = "div";
1388
- function TextSkeleton(props) {
1389
- const $ = c(10), t0 = props;
1390
- let className, rest, t1;
1659
+ function _temp(s) {
1660
+ return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
1661
+ }
1662
+ const DEFAULT_AVATAR_STACK_ELEMENT = "span";
1663
+ function AvatarStack(props) {
1664
+ const $ = c(20), t0 = props;
1665
+ let childrenProp, className, rest, t1, t2, t3;
1391
1666
  $[0] !== t0 ? ({
1667
+ as: t1,
1668
+ children: childrenProp,
1392
1669
  className,
1393
- size: t1,
1670
+ maxLength: t2,
1671
+ size: t3,
1394
1672
  ...rest
1395
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1396
- const size = t1 === void 0 ? 2 : t1;
1397
- let t2;
1398
- $[4] !== className || $[5] !== size ? (t2 = textSkeleton({
1673
+ } = t0, $[0] = t0, $[1] = childrenProp, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3) : (childrenProp = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6]);
1674
+ const as = t1 === void 0 ? DEFAULT_AVATAR_STACK_ELEMENT : t1, maxLengthProp = t2 === void 0 ? 4 : t2, sizeProp = t3 === void 0 ? 1 : t3, children = Children.toArray(childrenProp).filter(isValidElement), maxLength = Math.max(maxLengthProp, 0), size = useResponsiveProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children, T0 = Box, t4 = "AvatarStack", t5 = "center";
1675
+ let t6;
1676
+ $[7] !== className || $[8] !== size ? (t6 = avatarStack({
1399
1677
  className,
1400
1678
  size
1401
- }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1402
- let t3;
1403
- return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1679
+ }), $[7] = className, $[8] = size, $[9] = t6) : t6 = $[9];
1680
+ const t7 = "flex", t8 = "flex-start", t9 = len === 0 && /* @__PURE__ */ jsx(AvatarCounter, { count: len, size }), t10 = len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size });
1681
+ let t11;
1682
+ $[10] !== size ? (t11 = (child, childIndex) => /* @__PURE__ */ jsx(Fragment, { children: cloneElement(child, {
1683
+ size
1684
+ }) }, String(childIndex)), $[10] = size, $[11] = t11) : t11 = $[11];
1685
+ const t12 = visibleChildren.map(t11);
1686
+ let t13;
1687
+ return $[12] !== T0 || $[13] !== as || $[14] !== rest || $[15] !== t10 || $[16] !== t12 || $[17] !== t6 || $[18] !== t9 ? (t13 = /* @__PURE__ */ jsxs(T0, { "data-ui": t4, ...rest, alignItems: t5, as, className: t6, display: t7, justifyContent: t8, children: [
1688
+ t9,
1689
+ t10,
1690
+ t12
1691
+ ] }), $[12] = T0, $[13] = as, $[14] = rest, $[15] = t10, $[16] = t12, $[17] = t6, $[18] = t9, $[19] = t13) : t13 = $[19], t13;
1404
1692
  }
1405
- const DEFAULT_TAB_PANEL_ELEMENT = "div";
1406
- function TabPanel(props) {
1407
- const $ = c(10), t0 = props;
1408
- let children, rest, t1, tabIndex;
1693
+ const DEFAULT_BADGE_ELEMENT = "span";
1694
+ function Badge(props) {
1695
+ const $ = c(22), t0 = props;
1696
+ let children, className, rest, t1, t2, t3, t4, t5;
1409
1697
  $[0] !== t0 ? ({
1410
1698
  as: t1,
1411
1699
  children,
1412
- tabIndex,
1700
+ className,
1701
+ fontSize: t2,
1702
+ padding: t3,
1703
+ radius: t4,
1704
+ tone: t5,
1413
1705
  ...rest
1414
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1, $[4] = tabIndex) : (children = $[1], rest = $[2], t1 = $[3], tabIndex = $[4]);
1415
- const as = t1 === void 0 ? DEFAULT_TAB_PANEL_ELEMENT : t1, t2 = tabIndex === void 0 ? 0 : tabIndex;
1416
- let t3;
1417
- return $[5] !== as || $[6] !== children || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "TabPanel", ...rest, as, role: "tabpanel", tabIndex: t2, children }), $[5] = as, $[6] = children, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1418
- }
1419
- const DEFAULT_TOAST_ELEMENT = "li", ROLES = {
1420
- error: "alert",
1421
- warning: "alert",
1422
- success: "alert",
1423
- info: "alert"
1424
- }, STATUS_CARD_TONE = {
1425
- error: "critical",
1426
- warning: "caution",
1427
- success: "positive",
1428
- info: "neutral"
1429
- }, BUTTON_TONE = {
1430
- error: "critical",
1431
- warning: "caution",
1432
- success: "positive",
1433
- info: "neutral"
1434
- };
1435
- function Toast(props) {
1436
- const $ = c(40), t0 = props;
1437
- let closable, description, onClose, rest, status, t1, t2, title;
1438
- if ($[0] !== t0) {
1439
- const {
1440
- as: t32,
1441
- closable: t42,
1442
- description: t52,
1443
- duration,
1444
- onClose: t62,
1445
- radius: t72,
1446
- title: t82,
1447
- status: t92,
1448
- updatedAt,
1449
- ...t102
1450
- } = t0;
1451
- t1 = t32, closable = t42, description = t52, onClose = t62, t2 = t72, title = t82, status = t92, rest = t102, $[0] = t0, $[1] = closable, $[2] = description, $[3] = onClose, $[4] = rest, $[5] = status, $[6] = t1, $[7] = t2, $[8] = title;
1452
- } else
1453
- closable = $[1], description = $[2], onClose = $[3], rest = $[4], status = $[5], t1 = $[6], t2 = $[7], title = $[8];
1454
- const as = t1 === void 0 ? DEFAULT_TOAST_ELEMENT : t1, radius = t2 === void 0 ? 3 : t2, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = usePrefersReducedMotion() ? 0 : 0.26;
1455
- let t3;
1456
- $[9] !== visualDuration ? (t3 = visualDuration ? {
1457
- type: "spring",
1458
- visualDuration,
1459
- bounce: 0.25
1460
- } : {
1461
- duration: 0
1462
- }, $[9] = visualDuration, $[10] = t3) : t3 = $[10];
1463
- const transition = t3;
1464
- let t4;
1465
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t4 = ["hidden", "initial"], $[11] = t4) : t4 = $[11];
1466
- const initial = t4;
1467
- let t5;
1468
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t5 = ["visible", "slideIn"], $[12] = t5) : t5 = $[12];
1469
- const animate = t5;
1706
+ } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
1707
+ const as = t1 === void 0 ? DEFAULT_BADGE_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 1 : t3, radius = t4 === void 0 ? 2 : t4, tone = t5 === void 0 ? "default" : t5;
1470
1708
  let t6;
1471
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t6 = ["hidden", "slideOut"], $[13] = t6) : t6 = $[13];
1472
- const exit = t6;
1709
+ $[9] !== className || $[10] !== tone ? (t6 = badge({
1710
+ className,
1711
+ tone
1712
+ }), $[9] = className, $[10] = tone, $[11] = t6) : t6 = $[11];
1473
1713
  let t7;
1474
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = toast(), $[14] = t7) : t7 = $[14];
1714
+ $[12] !== children || $[13] !== fontSize ? (t7 = /* @__PURE__ */ jsx(Text, { size: fontSize, children }), $[12] = children, $[13] = fontSize, $[14] = t7) : t7 = $[14];
1475
1715
  let t8;
1476
- $[15] !== title ? (t8 = title && /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: title }), $[15] = title, $[16] = t8) : t8 = $[16];
1477
- let t9;
1478
- $[17] !== description || $[18] !== transition ? (t9 = description && /* @__PURE__ */ jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description }), $[17] = description, $[18] = transition, $[19] = t9) : t9 = $[19];
1479
- let t10;
1480
- $[20] !== t8 || $[21] !== t9 ? (t10 = /* @__PURE__ */ jsx(Flex, { flex: 1, overflowX: "auto", padding: 3, children: /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
1481
- t8,
1482
- t9
1483
- ] }) }), $[20] = t8, $[21] = t9, $[22] = t10) : t10 = $[22];
1484
- let t11;
1485
- $[23] !== buttonTone || $[24] !== closable || $[25] !== onClose ? (t11 = closable && /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Button, { as: "button", icon: CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
1486
- verticalAlign: "top"
1487
- } }) }), $[23] = buttonTone, $[24] = closable, $[25] = onClose, $[26] = t11) : t11 = $[26];
1488
- let t12;
1489
- $[27] !== t10 || $[28] !== t11 || $[29] !== transition ? (t12 = /* @__PURE__ */ jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
1490
- t10,
1491
- t11
1492
- ] }), $[27] = t10, $[28] = t11, $[29] = transition, $[30] = t12) : t12 = $[30];
1493
- let t13;
1494
- return $[31] !== as || $[32] !== cardTone || $[33] !== radius || $[34] !== rest || $[35] !== role || $[36] !== t12 || $[37] !== transition || $[38] !== visualDuration ? (t13 = /* @__PURE__ */ jsx(MotionCard, { as, className: t7, "data-ui": "Toast", role, ...rest, custom: visualDuration, radius, shadow: 2, tone: cardTone, layout: "position", variants: container, initial, animate, exit, transition, position: "relative", children: t12 }), $[31] = as, $[32] = cardTone, $[33] = radius, $[34] = rest, $[35] = role, $[36] = t12, $[37] = transition, $[38] = visualDuration, $[39] = t13) : t13 = $[39], t13;
1495
- }
1496
- const container = {
1497
- initial: {
1498
- y: 32,
1499
- scale: 0.5,
1500
- zIndex: 1
1501
- },
1502
- hidden: {
1503
- opacity: 0
1504
- },
1505
- visible: (visualDuration) => visualDuration ? {
1506
- opacity: 1,
1507
- transition: {
1508
- when: "beforeChildren",
1509
- staggerChildren: visualDuration / 3,
1510
- duration: visualDuration / 3
1511
- }
1512
- } : {
1513
- opacity: 1
1514
- },
1515
- slideIn: {
1516
- y: 0,
1517
- scale: 1
1518
- },
1519
- slideOut: {
1520
- zIndex: 0,
1521
- scale: 0.75
1522
- }
1523
- }, content = {
1524
- initial: {
1525
- willChange: "transform"
1526
- },
1527
- hidden: {
1528
- opacity: 0
1529
- },
1530
- visible: {
1531
- opacity: 1
1532
- }
1533
- }, MotionCard = motion.create(Card), MotionFlex = motion.create(Flex), MotionText = motion.create(Text);
1534
- function useMounted() {
1535
- return useSyncExternalStore(subscribe, _temp$1, _temp2);
1536
- }
1537
- function _temp2() {
1538
- return !1;
1539
- }
1540
- function _temp$1() {
1541
- return !0;
1716
+ return $[15] !== as || $[16] !== padding || $[17] !== radius || $[18] !== rest || $[19] !== t6 || $[20] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { "data-ui": "Badge", ...rest, as, className: t6, display: "flex", maxWidth: "fill", padding, radius, width: "min", children: t7 }), $[15] = as, $[16] = padding, $[17] = radius, $[18] = rest, $[19] = t6, $[20] = t7, $[21] = t8) : t8 = $[21], t8;
1542
1717
  }
1543
- const subscribe = () => () => {
1544
- }, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null), DEFAULT_TOAST_LAYER_ELEMENT = "ul";
1545
- function ToastLayer(props) {
1546
- const $ = c(11), {
1547
- as: t0,
1548
- children,
1549
- padding: t1,
1550
- paddingX,
1551
- paddingY,
1552
- gap: t2
1553
- } = props, as = t0 === void 0 ? DEFAULT_TOAST_LAYER_ELEMENT : t0, padding = t1 === void 0 ? 4 : t1, gap = t2 === void 0 ? 3 : t2, {
1554
- zIndex
1555
- } = useLayer();
1556
- let t3;
1557
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t3 = toastLayer(), $[0] = t3) : t3 = $[0];
1558
- let t4;
1559
- $[1] !== zIndex ? (t4 = {
1560
- zIndex
1561
- }, $[1] = zIndex, $[2] = t4) : t4 = $[2];
1718
+ const DEFAULT_CHECKBOX_ELEMENT = "input";
1719
+ function Checkbox(props) {
1720
+ const $ = c(29), t0 = props;
1721
+ let className, customValidity, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
1722
+ $[0] !== t0 ? ({
1723
+ as: t1,
1724
+ className,
1725
+ disabled,
1726
+ indeterminate,
1727
+ customValidity,
1728
+ readOnly,
1729
+ ref: forwardedRef,
1730
+ style,
1731
+ ...rest
1732
+ } = t0, $[0] = t0, $[1] = className, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = indeterminate, $[6] = readOnly, $[7] = rest, $[8] = style, $[9] = t1) : (className = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], indeterminate = $[5], readOnly = $[6], rest = $[7], style = $[8], t1 = $[9]);
1733
+ const Element2 = t1 === void 0 ? DEFAULT_CHECKBOX_ELEMENT : t1, ref = useRef(null);
1734
+ let t2;
1735
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[10] = t2) : t2 = $[10], useImperativeHandle(forwardedRef, t2);
1736
+ let t3, t4;
1737
+ $[11] !== indeterminate ? (t3 = () => {
1738
+ ref.current && (ref.current.indeterminate = indeterminate || !1);
1739
+ }, t4 = [indeterminate], $[11] = indeterminate, $[12] = t3, $[13] = t4) : (t3 = $[12], t4 = $[13]), useEffect(t3, t4), useCustomValidity(ref, customValidity);
1562
1740
  let t5;
1563
- return $[3] !== as || $[4] !== children || $[5] !== gap || $[6] !== padding || $[7] !== paddingX || $[8] !== paddingY || $[9] !== t4 ? (t5 = /* @__PURE__ */ jsx(Grid, { as, className: t3, "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: t4, children }), $[3] = as, $[4] = children, $[5] = gap, $[6] = padding, $[7] = paddingX, $[8] = paddingY, $[9] = t4, $[10] = t5) : t5 = $[10], t5;
1564
- }
1565
- let toastId = 0;
1566
- function generateToastId() {
1567
- return String(toastId++);
1741
+ $[14] !== className ? (t5 = checkbox({
1742
+ className
1743
+ }), $[14] = className, $[15] = t5) : t5 = $[15];
1744
+ let t6;
1745
+ $[16] === Symbol.for("react.memo_cache_sentinel") ? (t6 = checkboxInput(), $[16] = t6) : t6 = $[16];
1746
+ const t7 = customValidity ? "" : void 0, t8 = !disabled && readOnly ? "" : void 0, t9 = disabled || readOnly;
1747
+ let t10;
1748
+ $[17] !== Element2 || $[18] !== readOnly || $[19] !== rest || $[20] !== t7 || $[21] !== t8 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t6, "data-invalid": t7, "data-read-only": t8, disabled: t9, type: "checkbox", readOnly, ref }), $[17] = Element2, $[18] = readOnly, $[19] = rest, $[20] = t7, $[21] = t8, $[22] = t9, $[23] = t10) : t10 = $[23];
1749
+ let t11;
1750
+ $[24] === Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsxs("span", { className: checkboxPresentation(), children: [
1751
+ /* @__PURE__ */ jsx(CheckmarkIcon, {}),
1752
+ /* @__PURE__ */ jsx(RemoveIcon, {})
1753
+ ] }), $[24] = t11) : t11 = $[24];
1754
+ let t12;
1755
+ return $[25] !== style || $[26] !== t10 || $[27] !== t5 ? (t12 = /* @__PURE__ */ jsxs("span", { className: t5, "data-ui": "Checkbox", style, children: [
1756
+ t10,
1757
+ t11
1758
+ ] }), $[25] = style, $[26] = t10, $[27] = t5, $[28] = t12) : t12 = $[28], t12;
1568
1759
  }
1569
- function ToastProvider(props) {
1570
- const $ = c(13), {
1760
+ const LazyRefractor = lazy(() => import("./_chunks-es/refractor.js")), DEFAULT_CODE_ELEMENT = "pre";
1761
+ function Code(props) {
1762
+ const $ = c(25), t0 = props;
1763
+ let children, className, languageProp, rest, t1, t2, t3;
1764
+ $[0] !== t0 ? ({
1765
+ as: t1,
1571
1766
  children,
1572
- padding,
1573
- paddingX,
1574
- paddingY,
1575
- gap,
1576
- zOffset: t0
1577
- } = props, zOffset = t0 === void 0 ? 1 : t0;
1578
- let t1;
1579
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
1580
- const [state, setState] = useState(t1), mounted = useMounted();
1581
- let t2, t3;
1582
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
1583
- version: 0,
1584
- push: (params) => {
1585
- const id = params.id || generateToastId(), duration = params.duration || 5e3;
1586
- return startTransition(() => {
1587
- setState((prevState) => {
1588
- if (duration === 0.01)
1589
- return prevState.filter((toast2) => toast2.id !== id);
1590
- const dismiss = () => startTransition(() => setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id)));
1591
- return [...prevState.filter((toast_1) => toast_1.id !== id), {
1592
- dismiss,
1593
- id,
1594
- updatedAt: Date.now(),
1595
- params: {
1596
- ...params,
1597
- duration
1598
- }
1599
- }];
1600
- });
1601
- }), id;
1602
- }
1603
- }, $[1] = t3) : t3 = $[1], t2 = t3;
1604
- const value = t2;
1767
+ className,
1768
+ language: languageProp,
1769
+ size: t2,
1770
+ weight: t3,
1771
+ ...rest
1772
+ } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = languageProp, $[4] = rest, $[5] = t1, $[6] = t2, $[7] = t3) : (children = $[1], className = $[2], languageProp = $[3], rest = $[4], t1 = $[5], t2 = $[6], t3 = $[7]);
1773
+ const Element2 = t1 === void 0 ? DEFAULT_CODE_ELEMENT : t1, size = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3, language = typeof languageProp == "string" ? languageProp : void 0;
1605
1774
  let t4;
1606
- $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
1775
+ $[8] !== className || $[9] !== size || $[10] !== weight ? (t4 = code({
1776
+ className,
1777
+ size,
1778
+ weight
1779
+ }), $[8] = className, $[9] = size, $[10] = weight, $[11] = t4) : t4 = $[11];
1607
1780
  let t5;
1608
- return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
1609
- children,
1610
- t4
1611
- ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
1612
- }
1613
- function _temp(t0) {
1614
- const {
1615
- dismiss: dismiss_0,
1616
- id: id_0,
1617
- params: params_0,
1618
- updatedAt
1619
- } = t0;
1620
- return /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration, updatedAt }, id_0);
1621
- }
1622
- function useToast() {
1623
- const value = useContext(ToastContext);
1624
- if (!value)
1625
- throw new Error("useToast(): missing context value");
1626
- if (!isRecord(value) || value.version !== 0)
1627
- throw new Error("useToast(): the context value is not compatible");
1628
- return value;
1629
- }
1630
- function _findPrevItemElement(state, itemElements, focusedElement) {
1631
- const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(0, idx), len = els.length;
1632
- for (let i = len - 1; i >= 0; i -= 1) {
1633
- const itemKey = els[i].getAttribute("data-tree-key");
1634
- if (!itemKey)
1635
- continue;
1636
- const segments = itemKey.split("/");
1637
- segments.pop();
1638
- const p = [];
1639
- let expanded = !0;
1640
- for (let j = 0; j < segments.length; j += 1) {
1641
- p.push(segments[j]);
1642
- const k = p.join("/");
1643
- if (!state[k]?.expanded) {
1644
- expanded = !1;
1645
- break;
1646
- }
1647
- }
1648
- if (expanded)
1649
- return els[i];
1650
- }
1651
- return null;
1652
- }
1653
- function _findNextItemElement(state, itemElements, focusedElement) {
1654
- const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(idx), len = itemElements.length;
1655
- for (let i = 1; i < len; i += 1) {
1656
- if (!els[i])
1657
- continue;
1658
- const itemKey = els[i].getAttribute("data-tree-key");
1659
- if (!itemKey)
1660
- continue;
1661
- const segments = itemKey.split("/");
1662
- segments.pop();
1663
- const p = [];
1664
- let expanded = !0;
1665
- for (let j = 0; j < segments.length; j += 1) {
1666
- p.push(segments[j]);
1667
- const k = p.join("/");
1668
- if (!state[k]?.expanded) {
1669
- expanded = !1;
1670
- break;
1671
- }
1672
- }
1673
- if (expanded)
1674
- return els[i];
1675
- }
1676
- return null;
1781
+ $[12] !== children ? (t5 = /* @__PURE__ */ jsx("code", { children }), $[12] = children, $[13] = t5) : t5 = $[13];
1782
+ let t6;
1783
+ $[14] !== children || $[15] !== language ? (t6 = /* @__PURE__ */ jsx(LazyRefractor, { language, value: children }), $[14] = children, $[15] = language, $[16] = t6) : t6 = $[16];
1784
+ let t7;
1785
+ $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsx(Suspense, { fallback: t5, children: t6 }), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
1786
+ let t8;
1787
+ return $[20] !== Element2 || $[21] !== rest || $[22] !== t4 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element2, { "data-ui": "Code", ...rest, className: t4, children: t7 }), $[20] = Element2, $[21] = rest, $[22] = t4, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
1677
1788
  }
1678
- function _focusItemElement(el) {
1679
- if (el.getAttribute("role") === "treeitem" && el.focus(), el.getAttribute("role") === "none") {
1680
- const firstChild = el.firstChild;
1681
- firstChild && firstChild instanceof HTMLElement && firstChild.focus();
1682
- }
1789
+ const DEFAULT_HEADING_ELEMENT = "div";
1790
+ function Heading(props) {
1791
+ const $ = c(30), t0 = props;
1792
+ let align, children, className, flex, rest, t1, t2, t3, t4, t5, textOverflowProp;
1793
+ $[0] !== t0 ? ({
1794
+ accent: t1,
1795
+ align,
1796
+ as: t2,
1797
+ children,
1798
+ className,
1799
+ flex,
1800
+ muted: t3,
1801
+ size: t4,
1802
+ textOverflow: textOverflowProp,
1803
+ weight: t5,
1804
+ ...rest
1805
+ } = t0, $[0] = t0, $[1] = align, $[2] = children, $[3] = className, $[4] = flex, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3, $[9] = t4, $[10] = t5, $[11] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], flex = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8], t4 = $[9], t5 = $[10], textOverflowProp = $[11]);
1806
+ const accent = t1 === void 0 ? !1 : t1, Element2 = t2 === void 0 ? DEFAULT_HEADING_ELEMENT : t2, muted = t3 === void 0 ? !1 : t3, size = t4 === void 0 ? 2 : t4, weight = t5 === void 0 ? "regular" : t5;
1807
+ let t6;
1808
+ $[12] !== accent || $[13] !== align || $[14] !== className || $[15] !== flex || $[16] !== muted || $[17] !== size || $[18] !== weight ? (t6 = heading({
1809
+ className,
1810
+ accent,
1811
+ align,
1812
+ flex,
1813
+ muted,
1814
+ size,
1815
+ weight
1816
+ }), $[12] = accent, $[13] = align, $[14] = className, $[15] = flex, $[16] = muted, $[17] = size, $[18] = weight, $[19] = t6) : t6 = $[19];
1817
+ let t7;
1818
+ $[20] !== textOverflowProp ? (t7 = textOverflow({
1819
+ textOverflow: textOverflowProp
1820
+ }), $[20] = textOverflowProp, $[21] = t7) : t7 = $[21];
1821
+ let t8;
1822
+ $[22] !== children || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx("span", { className: t7, children }), $[22] = children, $[23] = t7, $[24] = t8) : t8 = $[24];
1823
+ let t9;
1824
+ return $[25] !== Element2 || $[26] !== rest || $[27] !== t6 || $[28] !== t8 ? (t9 = /* @__PURE__ */ jsx(Element2, { "data-ui": "Heading", ...rest, className: t6, children: t8 }), $[25] = Element2, $[26] = rest, $[27] = t6, $[28] = t8, $[29] = t9) : t9 = $[29], t9;
1683
1825
  }
1684
- const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null), DEFAULT_TREE_ELEMENT = "div";
1685
- function Tree(props) {
1686
- const $ = c(39), t0 = props;
1687
- let children, forwardedRef, gap, onFocus, rest, t1;
1826
+ const DEFAULT_INLINE_ELEMENT = "div";
1827
+ function Inline(props) {
1828
+ const $ = c(11), t0 = props;
1829
+ let children, gap, rest, space, t1;
1688
1830
  $[0] !== t0 ? ({
1831
+ as: t1,
1689
1832
  children,
1690
1833
  gap,
1691
- space: t1,
1692
- onFocus,
1834
+ space,
1835
+ ...rest
1836
+ } = t0, $[0] = t0, $[1] = children, $[2] = gap, $[3] = rest, $[4] = space, $[5] = t1) : (children = $[1], gap = $[2], rest = $[3], space = $[4], t1 = $[5]);
1837
+ const as = t1 === void 0 ? DEFAULT_INLINE_ELEMENT : t1, t2 = gap ?? space;
1838
+ let t3;
1839
+ return $[6] !== as || $[7] !== children || $[8] !== rest || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Inline", ...rest, alignItems: "center", as, display: "flex", gap: t2, flexWrap: "wrap", children }), $[6] = as, $[7] = children, $[8] = rest, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
1840
+ }
1841
+ const DEFAULT_RADIO_ELEMENT = "input";
1842
+ function Radio(props) {
1843
+ const $ = c(25), t0 = props;
1844
+ let className, customValidity, disabled, forwardedRef, readOnly, rest, style, t1;
1845
+ $[0] !== t0 ? ({
1846
+ as: t1,
1847
+ className,
1848
+ disabled,
1849
+ style,
1850
+ customValidity,
1851
+ readOnly,
1693
1852
  ref: forwardedRef,
1694
1853
  ...rest
1695
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = gap, $[4] = onFocus, $[5] = rest, $[6] = t1) : (children = $[1], forwardedRef = $[2], gap = $[3], onFocus = $[4], rest = $[5], t1 = $[6]);
1696
- const space = t1 === void 0 ? 1 : t1, ref = useRef(null), [focusedElement, setFocusedElement] = useState(null), focusedElementRef = useRef(focusedElement);
1697
- let t2, t3;
1698
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[7] = t3) : t3 = $[7], t2 = t3;
1699
- const path = t2;
1854
+ } = t0, $[0] = t0, $[1] = className, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = readOnly, $[6] = rest, $[7] = style, $[8] = t1) : (className = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], readOnly = $[5], rest = $[6], style = $[7], t1 = $[8]);
1855
+ const Element2 = t1 === void 0 ? DEFAULT_RADIO_ELEMENT : t1, ref = useRef(null);
1856
+ let t2;
1857
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[9] = t2) : t2 = $[9], useImperativeHandle(forwardedRef, t2), useCustomValidity(ref, customValidity);
1858
+ let t3;
1859
+ $[10] !== className ? (t3 = radio({
1860
+ className
1861
+ }), $[10] = className, $[11] = t3) : t3 = $[11];
1700
1862
  let t4;
1701
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[8] = t4) : t4 = $[8];
1702
- const [itemElements, setItemElements] = useState(t4);
1703
- let t5;
1704
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t5 = {}, $[9] = t5) : t5 = $[9];
1705
- const [state, setState] = useState(t5), stateRef = useRef(state);
1706
- let t6;
1707
- $[10] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[10] = t6) : t6 = $[10], useImperativeHandle(forwardedRef, t6);
1708
- let t7, t8;
1709
- $[11] !== focusedElement ? (t7 = () => {
1710
- focusedElementRef.current = focusedElement;
1711
- }, t8 = [focusedElement], $[11] = focusedElement, $[12] = t7, $[13] = t8) : (t7 = $[12], t8 = $[13]), useEffect(t7, t8);
1712
- let t10, t9;
1713
- $[14] !== state ? (t9 = () => {
1714
- stateRef.current = state;
1715
- }, t10 = [state], $[14] = state, $[15] = t10, $[16] = t9) : (t10 = $[15], t9 = $[16]), useEffect(t9, t10);
1716
- let t11;
1717
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (element, path_0, expanded, selected) => (setState((s) => ({
1718
- ...s,
1719
- [path_0]: {
1720
- element,
1721
- expanded
1722
- }
1723
- })), selected && setFocusedElement(element), () => {
1724
- setState((s_0) => {
1725
- const newState = {
1726
- ...s_0
1727
- };
1728
- return delete newState[path_0], newState;
1729
- });
1730
- }), $[17] = t11) : t11 = $[17];
1731
- const registerItem = t11;
1863
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t4 = radioInput(), $[12] = t4) : t4 = $[12];
1864
+ const t5 = customValidity ? "" : void 0, t6 = !disabled && readOnly ? "" : void 0, t7 = disabled || readOnly;
1865
+ let t8;
1866
+ $[13] !== Element2 || $[14] !== readOnly || $[15] !== rest || $[16] !== t5 || $[17] !== t6 || $[18] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t4, "data-invalid": t5, "data-read-only": t6, disabled: t7, readOnly, ref, type: "radio" }), $[13] = Element2, $[14] = readOnly, $[15] = rest, $[16] = t5, $[17] = t6, $[18] = t7, $[19] = t8) : t8 = $[19];
1867
+ let t9;
1868
+ $[20] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx("span", { className: radioPresentation() }), $[20] = t9) : t9 = $[20];
1869
+ let t10;
1870
+ return $[21] !== style || $[22] !== t3 || $[23] !== t8 ? (t10 = /* @__PURE__ */ jsxs("div", { className: t3, "data-ui": "Radio", style, children: [
1871
+ t8,
1872
+ t9
1873
+ ] }), $[21] = style, $[22] = t3, $[23] = t8, $[24] = t10) : t10 = $[24], t10;
1874
+ }
1875
+ const DEFAULT_SELECT_ELEMENT = "select";
1876
+ function Select(props) {
1877
+ const $ = c(38), t0 = props;
1878
+ let children, customValidity, disabled, forwardedRef, gap, readOnly, rest, t1, t2, t3, t4, t5, t6;
1879
+ $[0] !== t0 ? ({
1880
+ as: t1,
1881
+ border: t2,
1882
+ children,
1883
+ customValidity,
1884
+ disabled,
1885
+ fontSize: t3,
1886
+ gap,
1887
+ padding: t4,
1888
+ radius: t5,
1889
+ readOnly,
1890
+ ref: forwardedRef,
1891
+ space: t6,
1892
+ ...rest
1893
+ } = t0, $[0] = t0, $[1] = children, $[2] = customValidity, $[3] = disabled, $[4] = forwardedRef, $[5] = gap, $[6] = readOnly, $[7] = rest, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5, $[13] = t6) : (children = $[1], customValidity = $[2], disabled = $[3], forwardedRef = $[4], gap = $[5], readOnly = $[6], rest = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12], t6 = $[13]);
1894
+ const Element2 = t1 === void 0 ? DEFAULT_SELECT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, fontSize = t3 === void 0 ? 2 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 1 : t5, space = t6 === void 0 ? 2 : t6, ref = useRef(null);
1895
+ let t7;
1896
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[14] = t7) : t7 = $[14], useImperativeHandle(forwardedRef, t7), useCustomValidity(ref, customValidity);
1897
+ const t8 = gap ?? space;
1898
+ let t9;
1899
+ $[15] !== border || $[16] !== fontSize || $[17] !== padding || $[18] !== radius || $[19] !== t8 ? (t9 = select({
1900
+ border,
1901
+ fontSize,
1902
+ padding,
1903
+ radius,
1904
+ gap: t8
1905
+ }), $[15] = border, $[16] = fontSize, $[17] = padding, $[18] = radius, $[19] = t8, $[20] = t9) : t9 = $[20];
1906
+ let t10;
1907
+ $[21] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _inputElement(), $[21] = t10) : t10 = $[21];
1908
+ const t11 = disabled || readOnly;
1732
1909
  let t12;
1733
- $[18] === Symbol.for("react.memo_cache_sentinel") ? (t12 = (path_1, expanded_0) => {
1734
- setState((s_1) => {
1735
- const itemState = s_1[path_1];
1736
- return itemState ? {
1737
- ...s_1,
1738
- [path_1]: {
1739
- ...itemState,
1740
- expanded: expanded_0
1741
- }
1742
- } : s_1;
1743
- });
1744
- }, $[18] = t12) : t12 = $[18];
1745
- const setExpanded = t12;
1910
+ $[22] !== Element2 || $[23] !== children || $[24] !== rest || $[25] !== t11 ? (t12 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t10, disabled: t11, ref, children }), $[22] = Element2, $[23] = children, $[24] = rest, $[25] = t11, $[26] = t12) : t12 = $[26];
1746
1911
  let t13;
1747
- const t14 = focusedElement || itemElements[0] || null;
1912
+ $[27] === Symbol.for("react.memo_cache_sentinel") ? (t13 = selectPresentation(), $[27] = t13) : t13 = $[27];
1913
+ let t14;
1914
+ $[28] === Symbol.for("react.memo_cache_sentinel") ? (t14 = /* @__PURE__ */ jsx(ChevronDownIcon, {}), $[28] = t14) : t14 = $[28];
1748
1915
  let t15;
1749
- $[19] !== space || $[20] !== state || $[21] !== t14 ? (t15 = {
1750
- version: 0,
1751
- focusedElement: t14,
1752
- level: 0,
1753
- path,
1754
- registerItem,
1755
- setExpanded,
1756
- setFocusedElement,
1757
- space,
1758
- state
1759
- }, $[19] = space, $[20] = state, $[21] = t14, $[22] = t15) : t15 = $[22], t13 = t15;
1760
- const contextValue = t13;
1916
+ $[29] !== fontSize ? (t15 = /* @__PURE__ */ jsx(Text, { size: fontSize, children: t14 }), $[29] = fontSize, $[30] = t15) : t15 = $[30];
1761
1917
  let t16;
1762
- $[23] !== itemElements ? (t16 = (event) => {
1763
- if (focusedElementRef.current) {
1764
- if (event.key === "ArrowDown") {
1765
- event.preventDefault();
1766
- const nextEl = _findNextItemElement(stateRef.current, itemElements, focusedElementRef.current);
1767
- nextEl && (_focusItemElement(nextEl), setFocusedElement(nextEl));
1768
- return;
1769
- }
1770
- if (event.key === "ArrowUp") {
1771
- event.preventDefault();
1772
- const prevEl = _findPrevItemElement(stateRef.current, itemElements, focusedElementRef.current);
1773
- prevEl && (_focusItemElement(prevEl), setFocusedElement(prevEl));
1774
- return;
1775
- }
1776
- if (event.key === "ArrowLeft") {
1777
- event.preventDefault();
1778
- const itemKey = focusedElementRef.current.getAttribute("data-tree-key");
1779
- if (!itemKey)
1780
- return;
1781
- const itemState_0 = stateRef.current[itemKey];
1782
- if (!itemState_0)
1783
- return;
1784
- if (itemState_0.expanded)
1785
- setState((s_2) => {
1786
- const itemState_1 = s_2[itemKey];
1787
- return itemState_1 ? {
1788
- ...s_2,
1789
- [itemKey]: {
1790
- ...itemState_1,
1791
- expanded: !1
1792
- }
1793
- } : s_2;
1794
- });
1795
- else {
1796
- const itemPath = itemKey.split("/");
1797
- itemPath.pop();
1798
- const parentKey = itemPath.join("/"), parentState = parentKey && stateRef.current[parentKey];
1799
- parentState && (parentState.element.focus(), setFocusedElement(parentState.element));
1800
- }
1801
- return;
1802
- }
1803
- if (event.key === "ArrowRight") {
1804
- event.preventDefault();
1805
- const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
1806
- if (!focusedKey)
1807
- return;
1808
- stateRef.current[focusedKey]?.expanded || setState((s_3) => {
1809
- const itemState_2 = s_3[focusedKey];
1810
- return itemState_2 ? {
1811
- ...s_3,
1812
- [focusedKey]: {
1813
- ...itemState_2,
1814
- expanded: !0
1815
- }
1816
- } : s_3;
1817
- });
1818
- return;
1819
- }
1820
- }
1821
- }, $[23] = itemElements, $[24] = t16) : t16 = $[24];
1822
- const handleKeyDown = t16;
1918
+ $[31] !== padding || $[32] !== t15 ? (t16 = /* @__PURE__ */ jsx("span", { className: t13, children: /* @__PURE__ */ jsx(Box, { as: "span", display: "inline-block", padding, children: t15 }) }), $[31] = padding, $[32] = t15, $[33] = t16) : t16 = $[33];
1823
1919
  let t17;
1824
- $[25] !== onFocus ? (t17 = (event_0) => {
1825
- setFocusedElement(event_0.target), onFocus?.(event_0);
1826
- }, $[25] = onFocus, $[26] = t17) : t17 = $[26];
1827
- const handleFocus = t17;
1828
- let t18;
1829
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t18 = () => {
1830
- if (!ref.current)
1831
- return;
1832
- const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
1833
- setItemElements(_itemElements);
1834
- }, $[27] = t18) : t18 = $[27];
1835
- let t19;
1836
- $[28] !== children ? (t19 = [children], $[28] = children, $[29] = t19) : t19 = $[29], useEffect(t18, t19);
1837
- const t20 = gap ?? space;
1838
- let t21;
1839
- $[30] !== children || $[31] !== handleFocus || $[32] !== handleKeyDown || $[33] !== rest || $[34] !== t20 ? (t21 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "Tree", ...rest, gap: t20, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", children }), $[30] = children, $[31] = handleFocus, $[32] = handleKeyDown, $[33] = rest, $[34] = t20, $[35] = t21) : t21 = $[35];
1840
- let t22;
1841
- return $[36] !== contextValue || $[37] !== t21 ? (t22 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t21 }), $[36] = contextValue, $[37] = t21, $[38] = t22) : t22 = $[38], t22;
1920
+ return $[34] !== t12 || $[35] !== t16 || $[36] !== t9 ? (t17 = /* @__PURE__ */ jsxs("div", { "data-ui": "Select", className: t9, "data-icon-right": "", children: [
1921
+ t12,
1922
+ t16
1923
+ ] }), $[34] = t12, $[35] = t16, $[36] = t9, $[37] = t17) : t17 = $[37], t17;
1842
1924
  }
1843
- function useTree() {
1844
- const tree = useContext(TreeContext);
1845
- if (!tree)
1846
- throw new Error("Tree: missing context value");
1847
- return tree;
1925
+ const DEFAULT_SKELETON_ELEMENT = "div";
1926
+ function Skeleton(props) {
1927
+ const $ = c(19), t0 = props;
1928
+ let className, delay, radius, rest, t1, t2;
1929
+ $[0] !== t0 ? ({
1930
+ as: t1,
1931
+ animated: t2,
1932
+ className,
1933
+ delay,
1934
+ radius,
1935
+ ...rest
1936
+ } = t0, $[0] = t0, $[1] = className, $[2] = delay, $[3] = radius, $[4] = rest, $[5] = t1, $[6] = t2) : (className = $[1], delay = $[2], radius = $[3], rest = $[4], t1 = $[5], t2 = $[6]);
1937
+ const As = t1 === void 0 ? DEFAULT_SKELETON_ELEMENT : t1, animated = t2 === void 0 ? !1 : t2, [visible, setVisible] = useState(!delay);
1938
+ let t3, t4;
1939
+ $[7] !== delay ? (t3 = () => {
1940
+ if (!delay)
1941
+ return setVisible(!0);
1942
+ const timeout = setTimeout(() => {
1943
+ setVisible(!0);
1944
+ }, delay);
1945
+ return () => {
1946
+ clearTimeout(timeout);
1947
+ };
1948
+ }, t4 = [delay], $[7] = delay, $[8] = t3, $[9] = t4) : (t3 = $[8], t4 = $[9]), useEffect(t3, t4);
1949
+ let t5;
1950
+ $[10] !== className || $[11] !== radius ? (t5 = skeleton({
1951
+ className,
1952
+ radius
1953
+ }), $[10] = className, $[11] = radius, $[12] = t5) : t5 = $[12];
1954
+ const t6 = animated ? "" : void 0, t7 = visible ? "" : void 0;
1955
+ let t8;
1956
+ return $[13] !== As || $[14] !== rest || $[15] !== t5 || $[16] !== t6 || $[17] !== t7 ? (t8 = /* @__PURE__ */ jsx(As, { "data-ui": "Skeleton", ...rest, className: t5, "data-animated": t6, "data-visible": t7 }), $[13] = As, $[14] = rest, $[15] = t5, $[16] = t6, $[17] = t7, $[18] = t8) : t8 = $[18], t8;
1848
1957
  }
1849
- const TreeGroup = memo(function(props) {
1850
- const $ = c(9), t0 = props;
1851
- let children, rest, t1;
1958
+ const DEFAULT_CODE_SKELETON_ELEMENT = "div";
1959
+ function CodeSkeleton(props) {
1960
+ const $ = c(10), t0 = props;
1961
+ let className, rest, t1;
1852
1962
  $[0] !== t0 ? ({
1853
- children,
1854
- expanded: t1,
1963
+ className,
1964
+ size: t1,
1855
1965
  ...rest
1856
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
1857
- const expanded = t1 === void 0 ? !1 : t1, tree = useTree(), t2 = !expanded;
1966
+ } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1967
+ const size = t1 === void 0 ? 2 : t1;
1968
+ let t2;
1969
+ $[4] !== className || $[5] !== size ? (t2 = codeSkeleton({
1970
+ className,
1971
+ size
1972
+ }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1858
1973
  let t3;
1859
- return $[4] !== children || $[5] !== rest || $[6] !== t2 || $[7] !== tree.space ? (t3 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "TreeGroup", ...rest, hidden: t2, marginTop: tree.space, role: "group", gap: tree.space, children }), $[4] = children, $[5] = rest, $[6] = t2, $[7] = tree.space, $[8] = t3) : t3 = $[8], t3;
1860
- }), DEFAULT_TREE_ITEM_ELEMENT = "a";
1861
- function TreeItem(props) {
1862
- const {
1974
+ return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1975
+ }
1976
+ const DEFAULT_HEADING_SKELETON_ELEMENT = "div";
1977
+ function HeadingSkeleton(props) {
1978
+ const $ = c(10), t0 = props;
1979
+ let className, rest, t1;
1980
+ $[0] !== t0 ? ({
1981
+ className,
1982
+ size: t1,
1983
+ ...rest
1984
+ } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1985
+ const size = t1 === void 0 ? 2 : t1;
1986
+ let t2;
1987
+ $[4] !== className || $[5] !== size ? (t2 = headingSkeleton({
1988
+ className,
1989
+ size
1990
+ }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
1991
+ let t3;
1992
+ return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1993
+ }
1994
+ const DEFAULT_LABEL_SKELETON_ELEMENT = "div";
1995
+ function LabelSkeleton(props) {
1996
+ const $ = c(10), t0 = props;
1997
+ let className, rest, t1;
1998
+ $[0] !== t0 ? ({
1999
+ className,
2000
+ size: t1,
2001
+ ...rest
2002
+ } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
2003
+ const size = t1 === void 0 ? 2 : t1;
2004
+ let t2;
2005
+ $[4] !== className || $[5] !== size ? (t2 = labelSkeleton({
2006
+ className,
2007
+ size
2008
+ }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
2009
+ let t3;
2010
+ return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2011
+ }
2012
+ const DEFAULT_TEXT_SKELETON_ELEMENT = "div";
2013
+ function TextSkeleton(props) {
2014
+ const $ = c(10), t0 = props;
2015
+ let className, rest, t1;
2016
+ $[0] !== t0 ? ({
2017
+ className,
2018
+ size: t1,
2019
+ ...rest
2020
+ } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
2021
+ const size = t1 === void 0 ? 2 : t1;
2022
+ let t2;
2023
+ $[4] !== className || $[5] !== size ? (t2 = textSkeleton({
2024
+ className,
2025
+ size
2026
+ }), $[4] = className, $[5] = size, $[6] = t2) : t2 = $[6];
2027
+ let t3;
2028
+ return $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Skeleton, { ...rest, className: t2 }), $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2029
+ }
2030
+ const DEFAULT_SR_ONLY_ELEMENT = "span";
2031
+ function SrOnly(props) {
2032
+ const $ = c(12), t0 = props;
2033
+ let children, className, rest, t1;
2034
+ $[0] !== t0 ? ({
2035
+ as: t1,
1863
2036
  children,
1864
2037
  className,
1865
- expanded: expandedProp = !1,
1866
- fontSize = 1,
1867
- href,
1868
- icon: IconComponent,
1869
- id: idProp,
1870
- linkAs = "a",
1871
- muted,
1872
- onClick,
1873
- padding = 2,
1874
- radius = 2,
1875
- selected = !1,
1876
- space = 2,
1877
- text,
1878
- weight,
1879
2038
  ...rest
1880
- } = props, rootRef = useRef(null), treeitemRef = useRef(null), tree = useTree(), {
1881
- path,
1882
- registerItem,
1883
- setExpanded,
1884
- setFocusedElement
1885
- } = tree, _id = useId(), id = idProp || _id, itemPath = useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = useMemo(() => ({
1886
- ...tree,
1887
- level: tree.level + 1,
1888
- path: itemPath
1889
- }), [itemPath, tree]), handleClick = useCallback((event) => {
1890
- onClick && onClick(event);
1891
- const target = event.target;
1892
- target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
1893
- }, [expanded, itemKey, onClick, setExpanded, setFocusedElement]), handleKeyDown = useCallback((event_0) => {
1894
- focused && event_0.key === "Enter" && (treeitemRef.current || rootRef.current)?.click();
1895
- }, [focused]);
1896
- useEffect(() => {
1897
- if (rootRef.current)
1898
- return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
1899
- }, [expanded, itemPath, registerItem, selected]);
1900
- const content2 = /* @__PURE__ */ jsxs(Flex, { gap: space, padding, children: [
1901
- /* @__PURE__ */ jsxs(Box, { style: {
1902
- visibility: IconComponent || children ? "visible" : "hidden",
1903
- pointerEvents: "none"
1904
- }, children: [
1905
- IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }),
1906
- !IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: {
1907
- transform: expanded ? "rotate(90deg)" : void 0
1908
- } }) })
1909
- ] }),
1910
- /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
1911
- ] });
1912
- return href ? /* @__PURE__ */ jsxs(Box, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...rest, as: "li", className: treeItem({
1913
- className
1914
- }), onClick: handleClick, ref: rootRef, role: "none", children: [
1915
- /* @__PURE__ */ jsx(Selectable, { "aria-expanded": expanded, as: linkAs, "data-pressed": selected ? "" : void 0, "data-ui": "TreeItem__box", href, radius, ref: treeitemRef, role: "treeitem", tabIndex, style: {
1916
- paddingLeft: `calc(${vars.space[2]} * ${tree.level})`
1917
- }, children: content2 }),
1918
- /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { hidden: !expanded, children }) })
1919
- ] }) : /* @__PURE__ */ jsxs(Box, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...rest, "aria-expanded": expanded, className: treeItem({
2039
+ } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1) : (children = $[1], className = $[2], rest = $[3], t1 = $[4]);
2040
+ const Element2 = t1 === void 0 ? DEFAULT_SR_ONLY_ELEMENT : t1;
2041
+ let t2;
2042
+ $[5] !== className ? (t2 = srOnly({
1920
2043
  className
1921
- }), onClick: handleClick, onKeyDown: handleKeyDown, ref: rootRef, role: "treeitem", tabIndex, children: [
1922
- /* @__PURE__ */ jsx(Selectable, { as: "button", "data-pressed": selected ? "" : void 0, "data-ui": "TreeItem__box", radius, style: {
1923
- paddingLeft: `calc(${vars.space[2]} * ${tree.level})`
1924
- }, children: content2 }),
1925
- /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsx(TreeGroup, { expanded, children }) })
1926
- ] });
2044
+ }), $[5] = className, $[6] = t2) : t2 = $[6];
2045
+ let t3;
2046
+ return $[7] !== Element2 || $[8] !== children || $[9] !== rest || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsx(Element2, { "data-ui": "SrOnly", ...rest, "aria-hidden": !0, className: t2, children }), $[7] = Element2, $[8] = children, $[9] = rest, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
1927
2047
  }
1928
- const DEFAULT_VIRTUAL_LIST_ELEMENT = "div";
1929
- function VirtualList(props) {
1930
- const $ = c(58), t0 = props;
1931
- let forwardedRef, getItemKey, onChange, renderItem, rest, t1, t2, t3;
2048
+ const DEFAULT_SWITCH_ELEMENT = "input";
2049
+ function Switch(props) {
2050
+ const $ = c(26), t0 = props;
2051
+ let className, disabled, forwardedRef, indeterminate, readOnly, rest, style, t1;
1932
2052
  $[0] !== t0 ? ({
1933
2053
  as: t1,
1934
- gap: t2,
1935
- getItemKey,
1936
- items: t3,
1937
- onChange,
1938
- renderItem,
2054
+ className,
2055
+ disabled,
2056
+ indeterminate,
2057
+ readOnly,
1939
2058
  ref: forwardedRef,
2059
+ style,
1940
2060
  ...rest
1941
- } = t0, $[0] = t0, $[1] = forwardedRef, $[2] = getItemKey, $[3] = onChange, $[4] = renderItem, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3) : (forwardedRef = $[1], getItemKey = $[2], onChange = $[3], renderItem = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8]);
1942
- const as = t1 === void 0 ? DEFAULT_VIRTUAL_LIST_ELEMENT : t1, gap = t2 === void 0 ? 0 : t2;
1943
- let t4;
1944
- $[9] !== t3 ? (t4 = t3 === void 0 ? [] : t3, $[9] = t3, $[10] = t4) : t4 = $[10];
1945
- const items = t4, ref = useRef(null), wrapperRef = useRef(null), [scrollTop, setScrollTop] = useState(0), [scrollHeight, setScrollHeight] = useState(0), [itemHeight, setItemHeight] = useState(-1), [gapValue, setGapValue] = useState(0);
2061
+ } = t0, $[0] = t0, $[1] = className, $[2] = disabled, $[3] = forwardedRef, $[4] = indeterminate, $[5] = readOnly, $[6] = rest, $[7] = style, $[8] = t1) : (className = $[1], disabled = $[2], forwardedRef = $[3], indeterminate = $[4], readOnly = $[5], rest = $[6], style = $[7], t1 = $[8]);
2062
+ const Element2 = t1 === void 0 ? DEFAULT_SWITCH_ELEMENT : t1, ref = useRef(null);
2063
+ let t2;
2064
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[9] = t2) : t2 = $[9], useImperativeHandle(forwardedRef, t2);
2065
+ let t3, t4;
2066
+ $[10] !== indeterminate ? (t3 = () => {
2067
+ ref.current && (ref.current.indeterminate = indeterminate || !1);
2068
+ }, t4 = [indeterminate], $[10] = indeterminate, $[11] = t3, $[12] = t4) : (t3 = $[11], t4 = $[12]), useEffect(t3, t4);
1946
2069
  let t5;
1947
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => ref.current, $[11] = t5) : t5 = $[11], useImperativeHandle(forwardedRef, t5);
1948
- let t6, t7;
1949
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
1950
- if (!ref.current)
1951
- return;
1952
- const scrollEl = findScrollable(ref.current.parentNode);
1953
- if (scrollEl) {
1954
- if (!(scrollEl instanceof HTMLElement))
1955
- return;
1956
- const handleScroll = () => {
1957
- setScrollTop(scrollEl.scrollTop);
1958
- };
1959
- scrollEl.addEventListener("scroll", handleScroll, {
1960
- passive: !0
1961
- });
1962
- const ro = new _ResizeObserver((entries) => {
1963
- setScrollHeight(entries[0].contentRect.height);
1964
- });
1965
- return ro.observe(scrollEl), handleScroll(), () => {
1966
- scrollEl.removeEventListener("scroll", handleScroll), ro.unobserve(scrollEl), ro.disconnect();
1967
- };
1968
- }
1969
- const handleScroll_0 = () => {
1970
- setScrollTop(window.scrollY);
1971
- }, handleResize = () => {
1972
- setScrollHeight(window.innerHeight);
1973
- };
1974
- return window.addEventListener("scroll", handleScroll_0, {
1975
- passive: !0
1976
- }), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll_0(), () => {
1977
- window.removeEventListener("scroll", handleScroll_0), window.removeEventListener("resize", handleResize);
2070
+ $[13] !== className ? (t5 = _switch({
2071
+ className
2072
+ }), $[13] = className, $[14] = t5) : t5 = $[14];
2073
+ let t6;
2074
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = _switchElement(), $[15] = t6) : t6 = $[15];
2075
+ const t7 = !disabled && readOnly ? "" : void 0, t8 = disabled || readOnly;
2076
+ let t9;
2077
+ $[16] !== Element2 || $[17] !== rest || $[18] !== t7 || $[19] !== t8 ? (t9 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t6, "data-read-only": t7, disabled: t8, type: "checkbox", ref }), $[16] = Element2, $[17] = rest, $[18] = t7, $[19] = t8, $[20] = t9) : t9 = $[20];
2078
+ let t10;
2079
+ $[21] === Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsxs("span", { "aria-hidden": !0, className: _switchPresentation(), children: [
2080
+ /* @__PURE__ */ jsx("span", { className: _switchTrack() }),
2081
+ /* @__PURE__ */ jsx("span", { className: _switchThumb() })
2082
+ ] }), $[21] = t10) : t10 = $[21];
2083
+ let t11;
2084
+ return $[22] !== style || $[23] !== t5 || $[24] !== t9 ? (t11 = /* @__PURE__ */ jsxs(Box, { className: t5, "data-ui": "Switch", display: "block", position: "relative", style, children: [
2085
+ t9,
2086
+ t10
2087
+ ] }), $[22] = style, $[23] = t5, $[24] = t9, $[25] = t11) : t11 = $[25], t11;
2088
+ }
2089
+ const DEFAULT_TEXT_AREA_ELEMENT = "textarea";
2090
+ function TextArea(props) {
2091
+ const $ = c(34), t0 = props;
2092
+ let __unstable_disableFocusRing, customValidity, forwardedRef, gap, readOnly, rest, t1, t2, t3, t4, t5, t6, t7;
2093
+ $[0] !== t0 ? ({
2094
+ __unstable_disableFocusRing,
2095
+ as: t1,
2096
+ border: t2,
2097
+ customValidity,
2098
+ disabled: t3,
2099
+ fontSize: t4,
2100
+ gap,
2101
+ padding: t5,
2102
+ radius: t6,
2103
+ readOnly,
2104
+ ref: forwardedRef,
2105
+ space: t7,
2106
+ ...rest
2107
+ } = t0, $[0] = t0, $[1] = __unstable_disableFocusRing, $[2] = customValidity, $[3] = forwardedRef, $[4] = gap, $[5] = readOnly, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = t6, $[13] = t7) : (__unstable_disableFocusRing = $[1], customValidity = $[2], forwardedRef = $[3], gap = $[4], readOnly = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], t6 = $[12], t7 = $[13]);
2108
+ const Element2 = t1 === void 0 ? DEFAULT_TEXT_AREA_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, padding = t5 === void 0 ? 3 : t5, radius = t6 === void 0 ? 2 : t6, space = t7 === void 0 ? 3 : t7, ref = useRef(null);
2109
+ let t8;
2110
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t8 = () => ref.current, $[14] = t8) : t8 = $[14], useImperativeHandle(forwardedRef, t8), useCustomValidity(ref, customValidity);
2111
+ const t9 = gap ?? space;
2112
+ let t10;
2113
+ $[15] !== border || $[16] !== fontSize || $[17] !== padding || $[18] !== radius || $[19] !== t9 ? (t10 = textArea({
2114
+ border,
2115
+ fontSize,
2116
+ padding,
2117
+ radius,
2118
+ gap: t9
2119
+ }), $[15] = border, $[16] = fontSize, $[17] = padding, $[18] = radius, $[19] = t9, $[20] = t10) : t10 = $[20];
2120
+ const t11 = customValidity ? "" : void 0, t12 = !disabled && readOnly ? "" : void 0;
2121
+ let t13;
2122
+ $[21] === Symbol.for("react.memo_cache_sentinel") ? (t13 = _inputElement(), $[21] = t13) : t13 = $[21];
2123
+ const t14 = __unstable_disableFocusRing ? "" : void 0;
2124
+ let t15;
2125
+ $[22] !== Element2 || $[23] !== disabled || $[24] !== readOnly || $[25] !== rest || $[26] !== t14 ? (t15 = /* @__PURE__ */ jsx(Element2, { ...rest, className: t13, "data-no-focus-ring": t14, disabled, readOnly, ref }), $[22] = Element2, $[23] = disabled, $[24] = readOnly, $[25] = rest, $[26] = t14, $[27] = t15) : t15 = $[27];
2126
+ let t16;
2127
+ $[28] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsx("span", { className: _inputPresentation() }), $[28] = t16) : t16 = $[28];
2128
+ let t17;
2129
+ return $[29] !== t10 || $[30] !== t11 || $[31] !== t12 || $[32] !== t15 ? (t17 = /* @__PURE__ */ jsxs("span", { className: t10, "data-invalid": t11, "data-read-only": t12, "data-ui": "TextArea", children: [
2130
+ t15,
2131
+ t16
2132
+ ] }), $[29] = t10, $[30] = t11, $[31] = t12, $[32] = t15, $[33] = t17) : t17 = $[33], t17;
2133
+ }
2134
+ function TooltipDelayGroupProvider(props) {
2135
+ const $ = c(9), {
2136
+ children,
2137
+ delay
2138
+ } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay : delay?.open || 0, closeDelay = typeof delay == "number" ? delay : delay?.close || 0;
2139
+ let t0;
2140
+ const t1 = isGroupActive ? 1 : openDelay;
2141
+ let t2;
2142
+ $[0] !== closeDelay || $[1] !== openTooltipId || $[2] !== setIsGroupActive || $[3] !== setOpenTooltipId || $[4] !== t1 ? (t2 = {
2143
+ setIsGroupActive,
2144
+ openTooltipId,
2145
+ setOpenTooltipId,
2146
+ openDelay: t1,
2147
+ closeDelay
2148
+ }, $[0] = closeDelay, $[1] = openTooltipId, $[2] = setIsGroupActive, $[3] = setOpenTooltipId, $[4] = t1, $[5] = t2) : t2 = $[5], t0 = t2;
2149
+ const value = t0;
2150
+ let t3;
2151
+ return $[6] !== children || $[7] !== value ? (t3 = /* @__PURE__ */ jsx(TooltipDelayGroupContext.Provider, { value, children }), $[6] = children, $[7] = value, $[8] = t3) : t3 = $[8], t3;
2152
+ }
2153
+ function findMaxBreakpoints(media, width) {
2154
+ const ret = [];
2155
+ for (let i = 0; i < media.length; i += 1)
2156
+ media[i] > width && ret.push(i);
2157
+ return ret;
2158
+ }
2159
+ function findMinBreakpoints(media, width) {
2160
+ const ret = [];
2161
+ for (let i = 0; i < media.length; i += 1)
2162
+ media[i] <= width && ret.push(i);
2163
+ return ret;
2164
+ }
2165
+ const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(BREAKPOINTS);
2166
+ function ElementQuery(props) {
2167
+ const $ = c(21), t0 = props;
2168
+ let children, forwardedRef, mediaProp, rest, t1;
2169
+ $[0] !== t0 ? ({
2170
+ as: t1,
2171
+ children,
2172
+ media: mediaProp,
2173
+ ref: forwardedRef,
2174
+ ...rest
2175
+ } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
2176
+ const Element2 = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = useState(null), elementSize = useElementSize(element);
2177
+ let t2;
2178
+ t2 = elementSize?.border.width ?? window.innerWidth;
2179
+ const width = t2;
2180
+ let t3, t4;
2181
+ if ($[6] !== breakpoints || $[7] !== width) {
2182
+ const eq = findMaxBreakpoints(breakpoints, width);
2183
+ t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
2184
+ } else
2185
+ t4 = $[8];
2186
+ t3 = t4;
2187
+ const max = t3;
2188
+ let t5, t6;
2189
+ if ($[9] !== breakpoints || $[10] !== width) {
2190
+ const eq_0 = findMinBreakpoints(breakpoints, width);
2191
+ t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
2192
+ } else
2193
+ t6 = $[11];
2194
+ t5 = t6;
2195
+ const min = t5;
2196
+ let t7, t8;
2197
+ $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useImperativeHandle(forwardedRef, t7, t8);
2198
+ let t9;
2199
+ return $[15] !== Element2 || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsx(Element2, { "data-ui": "ElementQuery", ...rest, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[15] = Element2, $[16] = children, $[17] = max, $[18] = min, $[19] = rest, $[20] = t9) : t9 = $[20], t9;
2200
+ }
2201
+ class ErrorBoundary extends Component {
2202
+ state = {
2203
+ error: null
2204
+ };
2205
+ static displayName = "ErrorBoundary";
2206
+ static getDerivedStateFromError(error) {
2207
+ return {
2208
+ error
1978
2209
  };
1979
- }, t7 = [], $[12] = t6, $[13] = t7) : (t6 = $[12], t7 = $[13]), useEffect(t6, t7);
1980
- const len = items.length, height = itemHeight ? len * (itemHeight + gapValue) - gapValue : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
1981
- let t8, t9;
1982
- $[14] !== fromIndex || $[15] !== gapValue || $[16] !== itemHeight || $[17] !== onChange || $[18] !== scrollHeight || $[19] !== scrollTop || $[20] !== toIndex ? (t8 = () => {
1983
- onChange?.({
1984
- fromIndex,
1985
- gap: gapValue,
1986
- itemHeight,
1987
- scrollHeight,
1988
- scrollTop,
1989
- toIndex
2210
+ }
2211
+ componentDidCatch(error, info) {
2212
+ this.props.onCatch({
2213
+ error,
2214
+ info
1990
2215
  });
1991
- }, t9 = [fromIndex, gapValue, itemHeight, onChange, scrollHeight, scrollTop, toIndex], $[14] = fromIndex, $[15] = gapValue, $[16] = itemHeight, $[17] = onChange, $[18] = scrollHeight, $[19] = scrollTop, $[20] = toIndex, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), useEffect(t8, t9);
1992
- let t10;
1993
- bb0: {
1994
- if (!renderItem || items.length === 0) {
1995
- t10 = null;
1996
- break bb0;
1997
- }
1998
- if (itemHeight === -1) {
1999
- let t113;
2000
- $[23] === Symbol.for("react.memo_cache_sentinel") ? (t113 = (el) => el ? setItemHeight(el.offsetHeight) : void 0, $[23] = t113) : t113 = $[23];
2001
- let t122;
2002
- $[24] !== items[0] || $[25] !== renderItem ? (t122 = renderItem(items[0]), $[24] = items[0], $[25] = renderItem, $[26] = t122) : t122 = $[26];
2003
- let t132;
2004
- $[27] !== t122 ? (t132 = /* @__PURE__ */ jsx(Box, { ref: t113, insetTop: 0, insetLeft: 0, insetRight: 0, position: "absolute", children: t122 }, 0), $[27] = t122, $[28] = t132) : t132 = $[28];
2005
- let t142;
2006
- $[29] === Symbol.for("react.memo_cache_sentinel") ? (t142 = (el_0) => el_0 ? setGapValue(el_0.offsetHeight) : void 0, $[29] = t142) : t142 = $[29];
2007
- const t15 = vars.space[gap];
2008
- let t16;
2009
- $[30] !== t15 ? (t16 = /* @__PURE__ */ jsx("div", { ref: t142, style: {
2010
- height: t15
2011
- } }), $[30] = t15, $[31] = t16) : t16 = $[31];
2012
- let t17;
2013
- $[32] !== t132 || $[33] !== t16 ? (t17 = [/* @__PURE__ */ jsxs(Fragment$1, { children: [
2014
- t132,
2015
- t16
2016
- ] })], $[32] = t132, $[33] = t16, $[34] = t17) : t17 = $[34], t10 = t17;
2017
- break bb0;
2216
+ }
2217
+ render() {
2218
+ const {
2219
+ error
2220
+ } = this.state;
2221
+ if (error) {
2222
+ const message = typeof error?.message == "string" ? error.message : "Error";
2223
+ return /* @__PURE__ */ jsx(Code, { children: message });
2018
2224
  }
2019
- let t112;
2020
- if ($[35] !== fromIndex || $[36] !== gapValue || $[37] !== getItemKey || $[38] !== itemHeight || $[39] !== items || $[40] !== renderItem || $[41] !== toIndex) {
2021
- let t122;
2022
- $[43] !== fromIndex || $[44] !== gapValue || $[45] !== getItemKey || $[46] !== itemHeight || $[47] !== renderItem ? (t122 = (item, _itemIndex) => {
2023
- const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
2024
- return /* @__PURE__ */ jsx(Box, { insetLeft: 0, insetRight: 0, position: "absolute", style: {
2025
- top: itemIndex * (itemHeight + gapValue) - gapValue
2026
- }, children: node }, key);
2027
- }, $[43] = fromIndex, $[44] = gapValue, $[45] = getItemKey, $[46] = itemHeight, $[47] = renderItem, $[48] = t122) : t122 = $[48], t112 = items.slice(fromIndex, toIndex).map(t122), $[35] = fromIndex, $[36] = gapValue, $[37] = getItemKey, $[38] = itemHeight, $[39] = items, $[40] = renderItem, $[41] = toIndex, $[42] = t112;
2028
- } else
2029
- t112 = $[42];
2030
- t10 = t112;
2225
+ return this.props.children;
2031
2226
  }
2032
- const children = t10;
2033
- let t11, t12;
2034
- $[49] !== height ? (t12 = {
2035
- height
2036
- }, $[49] = height, $[50] = t12) : t12 = $[50], t11 = t12;
2037
- const wrapperStyle = t11;
2038
- let t13;
2039
- $[51] !== children || $[52] !== wrapperStyle ? (t13 = /* @__PURE__ */ jsx("div", { ref: wrapperRef, style: wrapperStyle, children }), $[51] = children, $[52] = wrapperStyle, $[53] = t13) : t13 = $[53];
2040
- let t14;
2041
- return $[54] !== as || $[55] !== rest || $[56] !== t13 ? (t14 = /* @__PURE__ */ jsx(Box, { "data-ui": "VirtualList", ...rest, as, position: "relative", ref, children: t13 }), $[54] = as, $[55] = rest, $[56] = t13, $[57] = t14) : t14 = $[57], t14;
2042
- }
2043
- function findScrollable(parentNode) {
2044
- let _scrollEl = parentNode;
2045
- for (; _scrollEl && !_isScrollable(_scrollEl); )
2046
- _scrollEl = _scrollEl.parentNode;
2047
- return _scrollEl;
2048
2227
  }
2049
2228
  export {
2050
2229
  Arrow,
@@ -2095,6 +2274,7 @@ export {
2095
2274
  DEFAULT_MENU_ITEM_ELEMENT,
2096
2275
  DEFAULT_POPOVER_ELEMENT,
2097
2276
  DEFAULT_RADIO_ELEMENT,
2277
+ DEFAULT_SELECTABLE_ELEMENT,
2098
2278
  DEFAULT_SELECT_ELEMENT,
2099
2279
  DEFAULT_SKELETON_ELEMENT,
2100
2280
  DEFAULT_SPINNER_ELEMENT,
@@ -2139,6 +2319,7 @@ export {
2139
2319
  PortalProvider,
2140
2320
  Radio,
2141
2321
  Select,
2322
+ Selectable,
2142
2323
  Skeleton,
2143
2324
  Spinner,
2144
2325
  SrOnly,