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