UNPKG

@sanity/ui

Version:

The Sanity UI components.

929 lines (925 loc) 85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), reactCompilerRuntime = require("react-compiler-runtime"), theme = require("@sanity/ui/theme"), framerMotion = require("framer-motion"); function _raf(fn) { const frameId = requestAnimationFrame(fn); return () => { cancelAnimationFrame(frameId); }; } function _raf2(fn) { let innerDispose = null; const outerDispose = _raf(() => { innerDispose = _raf(fn); }); return () => { innerDispose && innerDispose(), outerDispose(); }; } function _hasFocus(element) { return !!document.activeElement && element.contains(document.activeElement); } function isFocusable(element) { return element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null ? !0 : _visualEditing.isHTMLAnchorElement(element) ? !!element.href && element.rel !== "ignore" : _visualEditing.isHTMLInputElement(element) ? element.type !== "hidden" && element.type !== "file" && !element.disabled : _visualEditing.isHTMLButtonElement(element) || _visualEditing.isHTMLSelectElement(element) || _visualEditing.isHTMLTextAreaElement(element) ? !element.disabled : !1; } function attemptFocus(element) { if (!isFocusable(element)) return !1; try { element.focus(); } catch { } return document.activeElement === element; } function focusFirstDescendant(element) { for (let i = 0; i < element.childNodes.length; i++) { const child = element.childNodes[i]; if (_visualEditing.isHTMLElement(child) && (attemptFocus(child) || focusFirstDescendant(child))) return !0; } return !1; } function focusLastDescendant(element) { for (let i = element.childNodes.length - 1; i >= 0; i--) { const child = element.childNodes[i]; if (_visualEditing.isHTMLElement(child) && (attemptFocus(child) || focusLastDescendant(child))) return !0; } return !1; } function _getElements(element, elementsArg) { const ret = [element]; for (const el of elementsArg) Array.isArray(el) ? ret.push(...el) : ret.push(el); return ret.filter(Boolean); } function useClickOutside(listener, t0, boundaryElement) { const $ = reactCompilerRuntime.c(12), elementsArg = t0 === void 0 ? _visualEditing.EMPTY_ARRAY : t0, [element, setElement] = react.useState(null); let t1; $[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2]; const [elements, setElements] = react.useState(t1), elementsRef = react.useRef(elements); let t2, t3; $[3] !== element || $[4] !== elementsArg ? (t2 = () => { const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg); if (prevElements.length !== nextElements.length) { setElements(nextElements), elementsRef.current = nextElements; return; } for (const el of prevElements) if (!nextElements.includes(el)) { setElements(nextElements), elementsRef.current = nextElements; return; } for (const el_0 of nextElements) if (!prevElements.includes(el_0)) { setElements(nextElements), elementsRef.current = nextElements; return; } }, t3 = [element, elementsArg], $[3] = element, $[4] = elementsArg, $[5] = t2, $[6] = t3) : (t2 = $[5], t3 = $[6]), react.useEffect(t2, t3); let t4, t5; return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => { if (!listener) return; const handleWindowMouseDown = (evt) => { const target = evt.target; if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) { for (const el_1 of elements) if (target === el_1 || el_1.contains(target)) return; listener(evt); } }; return window.addEventListener("mousedown", handleWindowMouseDown), () => { window.removeEventListener("mousedown", handleWindowMouseDown); }; }, t5 = [boundaryElement, listener, elements], $[7] = boundaryElement, $[8] = elements, $[9] = listener, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), react.useEffect(t4, t5), setElement; } function useElementRect(element) { return _visualEditing.useElementSize(element)?._contentRect || null; } function useForwardedRef(ref) { const $ = reactCompilerRuntime.c(1), innerRef = react.useRef(null); let t0; return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => innerRef.current, $[0] = t0) : t0 = $[0], react.useImperativeHandle(ref, t0), innerRef; } class ErrorBoundary extends react.Component { state = { error: null }; static getDerivedStateFromError(error) { return { error }; } componentDidCatch(error, info) { this.props.onCatch({ error, info }); } render() { const { error } = this.state; if (error) { const message = typeof error?.message == "string" ? error.message : "Error"; return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Code, { children: message }); } return this.props.children; } } const StyledAutocomplete = styledComponents.styled.div.withConfig({ displayName: "StyledAutocomplete", componentId: "sc-1igauft-0" })`line-height:0;`, ListBox = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "ListBox", componentId: "sc-1igauft-1" })`& > ul{list-style:none;padding:0;margin:0;}`, rotate = styledComponents.keyframes` from { transform: rotate(0deg); } to { transform: rotate(360deg); } `, AnimatedSpinnerIcon = styledComponents.styled(icons.SpinnerIcon).withConfig({ displayName: "AnimatedSpinnerIcon", componentId: "sc-1igauft-2" })`animation:${rotate} 500ms linear infinite;`; function AutocompleteOption(props) { const $ = reactCompilerRuntime.c(11), { children, id, onSelect, selected, value } = props; let t0; $[0] !== onSelect || $[1] !== value ? (t0 = () => { setTimeout(() => { onSelect(value); }, 0); }, $[0] = onSelect, $[1] = value, $[2] = t0) : t0 = $[2]; const handleClick = t0; let t1; $[3] !== handleClick ? (t1 = (event) => { event.key === "Enter" && !_visualEditing._isEnterToClickElement(event.currentTarget) && handleClick(); }, $[3] = handleClick, $[4] = t1) : t1 = $[4]; const handleKeyDown = t1; let t2; return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsxRuntime.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; } function autocompleteReducer(state, msg) { return msg.type === "input/change" ? { ...state, activeValue: null, focused: !0, query: msg.query } : msg.type === "input/focus" ? { ...state, focused: !0 } : msg.type === "root/blur" ? { ...state, focused: !1, query: null } : msg.type === "root/clear" ? { ...state, activeValue: null, query: null, value: null } : msg.type === "root/escape" ? { ...state, focused: !1, query: null } : msg.type === "root/open" ? { ...state, query: state.query || msg.query } : msg.type === "root/setActiveValue" ? { ...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused } : msg.type === "root/setListFocused" ? { ...state, listFocused: msg.listFocused } : msg.type === "value/change" ? { ...state, activeValue: msg.value, query: null, value: msg.value } : state; } 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_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = react.forwardRef(function(props, forwardedRef) { const { border = !0, customValidity, disabled, filterOption: filterOptionProp, fontSize = 2, icon, id, listBox = _visualEditing.EMPTY_RECORD, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, options: optionsProp, padding: paddingProp = 3, popover = _visualEditing.EMPTY_RECORD, prefix, radius = 2, readOnly, relatedElements, renderOption: renderOptionProp, renderPopover, renderValue = DEFAULT_RENDER_VALUE, suffix, value: valueProp, ...restProps } = props, [state, dispatch] = react.useReducer(autocompleteReducer, { activeValue: valueProp || null, focused: !1, listFocused: !1, query: null, value: valueProp || null }), { activeValue, focused, listFocused, query, value } = state, defaultRenderOption = react.useCallback(({ value: value_0 }) => /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.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 = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1); react.useImperativeHandle(forwardedRef, () => inputElementRef.current); const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : _visualEditing.EMPTY_ARRAY, padding = _visualEditing.useArrayProp(paddingProp), currentOption = react.useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = react.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 = react.useCallback((event) => { setTimeout(() => { if (popoverMouseWithinRef.current) return; const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []); let focusInside = !1; if (document.activeElement) { for (const e of elements) if (e === document.activeElement || e.contains(document.activeElement)) { focusInside = !0; break; } } focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event)); }, 0); }, [onBlur, onQueryChange, relatedElements]), handleRootFocus = react.useCallback((event_0) => { const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1; listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({ type: "root/setListFocused", listFocused: listFocused_0 })); }, []), handleOptionSelect = react.useCallback((v) => { dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); }, [onChange, onSelect, onQueryChange]), handleRootKeyDown = react.useCallback((event_1) => { if (event_1.key === "ArrowDown") { if (event_1.preventDefault(), !filteredOptionsLen) return; const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]; nextActiveOption && dispatch({ type: "root/setActiveValue", value: nextActiveOption.value, listFocused: !0 }); return; } if (event_1.key === "ArrowUp") { if (event_1.preventDefault(), !filteredOptionsLen) return; 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]; nextActiveOption_0 && dispatch({ type: "root/setActiveValue", value: nextActiveOption_0.value, listFocused: !0 }); return; } if (event_1.key === "Escape") { dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); return; } const target = event_1.target, listEl = listBoxElementRef.current; if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) { inputElementRef.current?.focus(); return; } }, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = react.useCallback((event_2) => { const nextQuery = event_2.currentTarget.value; dispatch({ type: "input/change", query: nextQuery }), onQueryChange && onQueryChange(nextQuery); }, [onQueryChange]), dispatchOpen = react.useCallback(() => { dispatch({ type: "root/open", query: value ? renderValue(value, currentOption) : "" }); }, [currentOption, renderValue, value]), handleInputFocus = react.useCallback((event_3) => { focused || (dispatch({ type: "input/focus" }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen()); }, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = react.useCallback(() => { popoverMouseWithinRef.current = !0; }, []), handlePopoverMouseLeave = react.useCallback(() => { popoverMouseWithinRef.current = !1; }, []), handleClearButtonClick = react.useCallback(() => { dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); }, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => { dispatch({ type: "input/focus" }); }, []); react.useEffect(() => { if (valueProp !== valuePropRef.current) { valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({ type: "value/change", value: valueProp }), valueRef.current = valueProp); return; } valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({ type: "value/change", value: valueProp || null })); }, [valueProp]), react.useEffect(() => { !focused && valueRef.current && dispatch({ type: "root/setActiveValue", value: valueRef.current }); }, [focused]), react.useEffect(() => { const listElement = listBoxElementRef.current; if (!listElement) return; const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue); if (activeOption_1) { const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1]; if (activeItemElement) { if (_hasFocus(activeItemElement)) return; focusFirstDescendant(activeItemElement); } } }, [activeValue, filteredOptions]); const clearButton = react.useMemo(() => { if (!loading && !disabled && value) return { "aria-label": "Clear", onFocus: handleClearButtonFocus }; }, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = react.useMemo(() => padding.map((v_0) => v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2), [padding]), openButtonPadding = react.useMemo(() => padding.map((v_1) => Math.max(v_1 - 1, 0)), [padding]), openButtonProps = react.useMemo(() => typeof openButton == "object" ? openButton : _visualEditing.EMPTY_RECORD, [openButton]), handleOpenClick = react.useCallback((event_4) => { dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus()); }, [openButtonProps, dispatchOpen]), openButtonNode = react.useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Open", disabled: expanded, fontSize, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = react.useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", 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 = react.useCallback((event_5) => { event_5.key === "Tab" && listFocused && inputElementRef.current?.focus(); }, [listFocused]), content2 = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => { const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0; return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: react.cloneElement(renderOption(option_0), { disabled: loading, selected: active, tabIndex: listFocused && active ? 0 : -1 }) }, option_0.value); }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = react.useMemo(() => renderPopover ? renderPopover({ content: content2, hidden: !expanded, inputElement: inputElementRef.current, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.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, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]); return /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [ input, results ] }); }); InnerAutocomplete.displayName = "ForwardRef(Autocomplete)"; const Autocomplete = InnerAutocomplete, StyledBreadcrumbs = styledComponents.styled.ol.withConfig({ displayName: "StyledBreadcrumbs", componentId: "sc-1es8h8q-0" })`margin:0;padding:0;display:flex;list-style:none;align-items:center;white-space:nowrap;line-height:0;`, ExpandButton = styledComponents.styled(_visualEditing.Button).withConfig({ displayName: "ExpandButton", componentId: "sc-1es8h8q-1" })`appearance:none;margin:-4px;`, Breadcrumbs = react.forwardRef(function(props, ref) { const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = _visualEditing.useArrayProp(spaceRaw), [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []); _visualEditing.useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]); const rawItems = react.useMemo(() => react.Children.toArray(children).filter(react.isValidElement), [children]), items = react.useMemo(() => { const len = rawItems.length; if (maxLength && len > maxLength) { const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2); return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, space, children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: open ? collapse : expand, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }) }, "button"), ...rawItems.slice(len - afterLength)]; } return rawItems; }, [collapse, expand, maxLength, open, rawItems, space]); return /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [ itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, children: "/" }) }), /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { as: "li", children: item }) ] }, itemIndex)) }); }); Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)"; function dialogStyle({ theme: theme$1 }) { const { color } = theme.getTheme_v2(theme$1); return { "&:not([hidden])": { display: "flex" }, top: 0, left: 0, right: 0, bottom: 0, alignItems: "center", justifyContent: "center", outline: "none", background: color.backdrop }; } function responsiveDialogPositionStyle(props) { const { media } = theme.getTheme_v2(props.theme); return _visualEditing._responsive(media, props.$position, (position) => ({ "&&": { position } })); } function animationDialogStyle(props) { return props.$animate ? styledComponents.css` @keyframes zoomIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } animation: fadeIn 200ms ease-out; // Animates the dialog card. & > [data-ui='DialogCard'] { animation: zoomIn 200ms ease-out; } ` : styledComponents.css``; } const DialogContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/dialog", { version: 0 }); function useDialog() { return react.useContext(DialogContext); } function isTargetWithinScope(boundaryElement, portalElement, target) { return !boundaryElement || !portalElement ? !0 : _visualEditing.containsOrEqualsElement(boundaryElement, target) || _visualEditing.containsOrEqualsElement(portalElement, target); } const StyledDialog = /* @__PURE__ */ styledComponents.styled(_visualEditing.Layer).withConfig({ displayName: "StyledDialog", componentId: "sc-4n4xb3-0" })(_visualEditing.responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle, animationDialogStyle), DialogContainer = styledComponents.styled(_visualEditing.Container).withConfig({ displayName: "DialogContainer", componentId: "sc-4n4xb3-1" })`&:not([hidden]){display:flex;}width:100%;height:100%;flex-direction:column;align-items:center;justify-content:center;`, DialogCardRoot = styledComponents.styled(_visualEditing.Card).withConfig({ displayName: "DialogCardRoot", componentId: "sc-4n4xb3-2" })`&:not([hidden]){display:flex;}width:100%;min-height:0;max-height:100%;overflow:hidden;overflow:clip;`, DialogLayout = styledComponents.styled(_visualEditing.Flex).withConfig({ displayName: "DialogLayout", componentId: "sc-4n4xb3-3" })`flex:1;min-height:0;width:100%;`, DialogHeader = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogHeader", componentId: "sc-4n4xb3-4" })`position:relative;z-index:2;`, DialogContent = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogContent", componentId: "sc-4n4xb3-5" })`position:relative;z-index:1;overflow:auto;outline:none;`, DialogFooter = styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "DialogFooter", componentId: "sc-4n4xb3-6" })`position:relative;z-index:3;`, DialogCard = react.forwardRef(function(props, forwardedRef) { const $ = reactCompilerRuntime.c(38), { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, children, contentRef: forwardedContentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: radiusProp, scheme, shadow: shadowProp, width: widthProp } = props, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element, radius = _visualEditing.useArrayProp(radiusProp), shadow = _visualEditing.useArrayProp(shadowProp), width = _visualEditing.useArrayProp(widthProp), ref = react.useRef(null), contentRef = react.useRef(null), layer = _visualEditing.useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton; let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => ref.current, $[0] = t0) : t0 = $[0], react.useImperativeHandle(forwardedRef, t0); let t1; $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => contentRef.current, $[1] = t1) : t1 = $[1], react.useImperativeHandle(forwardedContentRef, t1); let t2, t3; $[2] !== autoFocus ? (t2 = () => { autoFocus && ref.current && focusFirstDescendant(ref.current); }, t3 = [autoFocus, ref], $[2] = autoFocus, $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), react.useEffect(t2, t3); let t4; $[5] !== boundaryElement || $[6] !== isTopLayer || $[7] !== onClose || $[8] !== portalElement ? (t4 = (event) => { if (!isTopLayer || !onClose) return; const target = document.activeElement; target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose()); }, $[5] = boundaryElement, $[6] = isTopLayer, $[7] = onClose, $[8] = portalElement, $[9] = t4) : t4 = $[9], _visualEditing.useGlobalKeyDown(t4); let t5; $[10] !== boundaryElement || $[11] !== isTopLayer || $[12] !== onClickOutside || $[13] !== portalElement ? (t5 = isTopLayer && onClickOutside && ((event_0) => { const target_0 = event_0.target; target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside(); }), $[10] = boundaryElement, $[11] = isTopLayer, $[12] = onClickOutside, $[13] = portalElement, $[14] = t5) : t5 = $[14]; let t6; $[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => [ref.current], $[15] = t6) : t6 = $[15], _visualEditing.useClickOutsideEvent(t5, t6); let t7; $[16] !== header || $[17] !== labelId || $[18] !== onClose || $[19] !== showCloseButton || $[20] !== showHeader ? (t7 = showHeader && /* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { align: "flex-start", padding: 3, children: [ /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { id: labelId, size: 1, weight: "semibold", children: header }) }), showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Close dialog", disabled: !onClose, icon: icons.CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) }) ] }) }), $[16] = header, $[17] = labelId, $[18] = onClose, $[19] = showCloseButton, $[20] = showHeader, $[21] = t7) : t7 = $[21]; let t8; $[22] !== children ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }), $[22] = children, $[23] = t8) : t8 = $[23]; let t9; $[24] !== footer ? (t9 = footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer }), $[24] = footer, $[25] = t9) : t9 = $[25]; let t10; $[26] !== t7 || $[27] !== t8 || $[28] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [ t7, t8, t9 ] }), $[26] = t7, $[27] = t8, $[28] = t9, $[29] = t10) : t10 = $[29]; let t11; $[30] !== radius || $[31] !== scheme || $[32] !== shadow || $[33] !== t10 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: t10 }), $[30] = radius, $[31] = scheme, $[32] = shadow, $[33] = t10, $[34] = t11) : t11 = $[34]; let t12; return $[35] !== t11 || $[36] !== width ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: t11 }), $[35] = t11, $[36] = width, $[37] = t12) : t12 = $[37], t12; }); DialogCard.displayName = "ForwardRef(DialogCard)"; const Dialog = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(60), dialog = useDialog(), { layer } = _visualEditing.useTheme_v2(); let _positionProp, _zOffsetProp, children, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, portalProp, restProps, scheme, t0, t1, t2, t3, t4, t5, t6; $[0] !== props ? ({ __unstable_autoFocus: t0, __unstable_hideCloseButton: t1, cardRadius: t2, cardShadow: t3, children, contentRef, footer, header, id, onActivate, onClickOutside, onClose, onFocus, padding: t4, portal: portalProp, position: _positionProp, scheme, width: t5, zOffset: _zOffsetProp, animate: t6, ...restProps } = props, $[0] = props, $[1] = _positionProp, $[2] = _zOffsetProp, $[3] = children, $[4] = contentRef, $[5] = footer, $[6] = header, $[7] = id, $[8] = onActivate, $[9] = onClickOutside, $[10] = onClose, $[11] = onFocus, $[12] = portalProp, $[13] = restProps, $[14] = scheme, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6) : (_positionProp = $[1], _zOffsetProp = $[2], children = $[3], contentRef = $[4], footer = $[5], header = $[6], id = $[7], onActivate = $[8], onClickOutside = $[9], onClose = $[10], onFocus = $[11], portalProp = $[12], restProps = $[13], scheme = $[14], t0 = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21]); const autoFocus = t0 === void 0 ? !0 : t0, hideCloseButton = t1 === void 0 ? !1 : t1, cardRadiusProp = t2 === void 0 ? 4 : t2, cardShadow = t3 === void 0 ? 3 : t3, paddingProp = t4 === void 0 ? 3 : t4, widthProp = t5 === void 0 ? 0 : t5, _animate = t6 === void 0 ? !1 : t6, positionProp = _positionProp ?? (dialog.position || "fixed"), zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset), animate = _visualEditing.usePrefersReducedMotion() ? !1 : _animate, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element, cardRadius = _visualEditing.useArrayProp(cardRadiusProp), padding = _visualEditing.useArrayProp(paddingProp), position = _visualEditing.useArrayProp(positionProp), width = _visualEditing.useArrayProp(widthProp), zOffset = _visualEditing.useArrayProp(zOffsetProp), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null); let t7; $[22] !== onFocus ? (t7 = (event) => { onFocus?.(event); const target = event.target, cardElement = cardRef.current; if (cardElement && target === preDivRef.current) { focusLastDescendant(cardElement); return; } if (cardElement && target === postDivRef.current) { focusFirstDescendant(cardElement); return; } _visualEditing.isHTMLElement(event.target) && (focusedElementRef.current = event.target); }, $[22] = onFocus, $[23] = t7) : t7 = $[23]; const handleFocus = t7, labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0); let t8; $[24] !== boundaryElement || $[25] !== portalElement ? (t8 = () => { rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => { const activeElement = document.activeElement; if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) { const target_0 = focusedElementRef.current; if (!target_0 || !document.body.contains(target_0)) { const cardElement_0 = cardRef.current; cardElement_0 && focusFirstDescendant(cardElement_0); return; } target_0.focus(); } }, 0); }, $[24] = boundaryElement, $[25] = portalElement, $[26] = t8) : t8 = $[26]; const handleRootClick = t8; let t9; $[27] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: preDivRef, tabIndex: 0 }), $[27] = t9) : t9 = $[27]; let t10; $[28] !== autoFocus || $[29] !== cardRadius || $[30] !== cardShadow || $[31] !== children || $[32] !== contentRef || $[33] !== footer || $[34] !== header || $[35] !== hideCloseButton || $[36] !== id || $[37] !== onClickOutside || $[38] !== onClose || $[39] !== portalProp || $[40] !== scheme || $[41] !== width ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, width, children }), $[28] = autoFocus, $[29] = cardRadius, $[30] = cardShadow, $[31] = children, $[32] = contentRef, $[33] = footer, $[34] = header, $[35] = hideCloseButton, $[36] = id, $[37] = onClickOutside, $[38] = onClose, $[39] = portalProp, $[40] = scheme, $[41] = width, $[42] = t10) : t10 = $[42]; let t11; $[43] === Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 }), $[43] = t11) : t11 = $[43]; let t12; $[44] !== animate || $[45] !== handleFocus || $[46] !== handleRootClick || $[47] !== id || $[48] !== labelId || $[49] !== onActivate || $[50] !== padding || $[51] !== position || $[52] !== ref || $[53] !== restProps || $[54] !== t10 || $[55] !== zOffset ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs(StyledDialog, { ...restProps, $animate: animate, $padding: padding, $position: position, "aria-labelledby": labelId, "aria-modal": !0, "data-ui": "Dialog", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, ref, role: "dialog", zOffset, children: [ t9, t10, t11 ] }), $[44] = animate, $[45] = handleFocus, $[46] = handleRootClick, $[47] = id, $[48] = labelId, $[49] = onActivate, $[50] = padding, $[51] = position, $[52] = ref, $[53] = restProps, $[54] = t10, $[55] = zOffset, $[56] = t12) : t12 = $[56]; let t13; return $[57] !== portalProp || $[58] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Portal, { __unstable_name: portalProp, children: t12 }), $[57] = portalProp, $[58] = t12, $[59] = t13) : t13 = $[59], t13; }); Dialog.displayName = "ForwardRef(Dialog)"; function DialogProvider(props) { const $ = reactCompilerRuntime.c(6), { children, position, zOffset } = props; let t0, t1; $[0] !== position || $[1] !== zOffset ? (t1 = { version: 0, position, zOffset }, $[0] = position, $[1] = zOffset, $[2] = t1) : t1 = $[2], t0 = t1; const contextValue = t0; let t2; return $[3] !== children || $[4] !== contextValue ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t2) : t2 = $[5], t2; } DialogProvider.displayName = "DialogProvider"; const MenuButton = react.forwardRef(function(props, forwardedRef) { const $ = reactCompilerRuntime.c(62), { __unstable_disableRestoreFocusOnClose: t0, boundaryElement: deprecated_boundaryElement, button: buttonProp, id, menu: menuProp, onClose, onOpen, placement: deprecated_placement, popoverScheme: deprecated_popoverScheme, portal: t1, popover, popoverRadius: deprecated_popoverRadius, preventOverflow: deprecated_preventOverflow } = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), [buttonElement, setButtonElement] = react.useState(null); let t2; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0]; const [menuElements, setChildMenuElements] = react.useState(t2), openRef = react.useRef(open); let t3, t4; $[1] !== onOpen || $[2] !== open ? (t3 = () => { onOpen && open && !openRef.current && onOpen(); }, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), react.useEffect(t3, t4); let t5, t6; $[5] !== onClose || $[6] !== open ? (t5 = () => { onClose && !open && openRef.current && onClose(); }, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), react.useEffect(t5, t6); let t7, t8; $[9] !== open ? (t7 = () => { openRef.current = open; }, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), react.useEffect(t7, t8); let t9; $[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => { setOpen(_temp$2), setShouldFocus(null); }, $[12] = t9) : t9 = $[12]; const handleButtonClick = t9; let t10; $[13] !== open ? (t10 = (event) => { open && event.preventDefault(); }, $[13] = open, $[14] = t10) : t10 = $[14]; const handleMouseDown = t10; let t11; $[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => { if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") { event_0.preventDefault(), setOpen(!0), setShouldFocus("first"); return; } if (event_0.key === "ArrowUp") { event_0.preventDefault(), setOpen(!0), setShouldFocus("last"); return; } }, $[15] = t11) : t11 = $[15]; const handleButtonKeyDown = t11; let t12; $[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => { const target = event_1.target; if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) { for (const el of menuElements) if (target === el || el.contains(target)) return; setOpen(!1); } }, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18]; const handleMenuClickOutside = t12; let t13; $[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => { setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus(); }, $[19] = buttonElement, $[20] = disableRestoreFocusOnClose, $[21] = t13) : t13 = $[21]; const handleMenuEscape = t13; let t14; $[22] !== menuElements ? (t14 = (event_2) => { const target_0 = event_2.relatedTarget; if (target_0 instanceof Node) { for (const el_0 of menuElements) if (el_0 === target_0 || el_0.contains(target_0)) return; setOpen(!1); } }, $[22] = menuElements, $[23] = t14) : t14 = $[23]; const handleBlur = t14; let t15; $[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => { setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus(); }, $[24] = buttonElement, $[25] = disableRestoreFocusOnClose, $[26] = t15) : t15 = $[26]; const handleItemClick = t15; let t16; $[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]; const registerElement = t16; let t17; $[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && react.cloneElement(menuProp, { "aria-labelledby": id, onBlurCapture: handleBlur, onClickOutside: handleMenuClickOutside, onEscape: handleMenuEscape, onItemClick: handleItemClick, originElement: buttonElement, registerElement, shouldFocus }), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t17) : t17 = $[36]; const menu = t17; let t18, t19; $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t19 = buttonProp && react.cloneElement(buttonProp, { "data-ui": "MenuButton", id, onClick: handleButtonClick, onKeyDown: handleButtonKeyDown, onMouseDown: handleMouseDown, "aria-haspopup": !0, "aria-expanded": open, ref: setButtonElement, selected: buttonProp.props.selected ?? open }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t19) : t19 = $[41], t18 = t19; const button = t18; let t20, t21; $[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), react.useImperativeHandle(forwardedRef, t20, t21); let t22, t23; $[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46]; let t24; $[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t23 ? (t24 = { boundaryElement: deprecated_boundaryElement, overflow: "auto", placement: deprecated_placement, portal: deprecated_portal, preventOverflow: deprecated_preventOverflow, radius: deprecated_popoverRadius, scheme: deprecated_popoverScheme, ...t23 }, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_popoverRadius, $[50] = deprecated_popoverScheme, $[51] = deprecated_portal, $[52] = deprecated_preventOverflow, $[53] = t23, $[54] = t24) : t24 = $[54], t22 = t24; const popoverProps = t22; let t25; $[55] !== button ? (t25 = button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}), $[55] = button, $[56] = t25) : t25 = $[56]; let t26; return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26; }); MenuButton.displayName = "ForwardRef(MenuButton)"; function _temp$2(v) { return !v; } const keyframe = styledComponents.keyframes` 0% { background-position: 100%; } 100% { background-position: -100%; } `, animation = styledComponents.css` background-image: linear-gradient( to right, var(--card-skeleton-color-from), var(--card-skeleton-color-to), var(--card-skeleton-color-from), var(--card-skeleton-color-from), var(--card-skeleton-color-from) ); background-position: 100%; background-size: 200% 100%; background-attachment: fixed; animation-name: ${keyframe}; animation-timing-function: ease-in-out; animation-iteration-count: infinite; animation-duration: 2000ms; `, skeletonStyle = styledComponents.css` opacity: ${({ $visible }) => $visible ? 1 : 0}; transition: opacity 200ms ease-in; @media screen and (prefers-reduced-motion: no-preference) { ${({ $animated }) => $animated ? animation : styledComponents.css` background-color: var(--card-skeleton-color-from); `} } @media screen and (prefers-reduced-motion: reduce) { background-color: var(--card-skeleton-color-from); } `, StyledSkeleton$1 = /* @__PURE__ */ styledComponents.styled(_visualEditing.Box).withConfig({ displayName: "StyledSkeleton", componentId: "sc-ebtpni-0" })(_visualEditing.responsiveRadiusStyle, skeletonStyle), Skeleton = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(14); let delay, radius, restProps, t0; $[0] !== props ? ({ animated: t0, delay, radius, ...restProps } = props, $[0] = props, $[1] = delay, $[2] = radius, $[3] = restProps, $[4] = t0) : (delay = $[1], radius = $[2], restProps = $[3], t0 = $[4]); const animated = t0 === void 0 ? !1 : t0, [visible, setVisible] = react.useState(!delay); let t1, t2; $[5] !== delay ? (t1 = () => { if (!delay) return setVisible(!0); const timeout = setTimeout(() => { setVisible(!0); }, delay); return () => { clearTimeout(timeout); }; }, t2 = [delay], $[5] = delay, $[6] = t1, $[7] = t2) : (t1 = $[6], t2 = $[7]), react.useEffect(t1, t2); const t3 = _visualEditing.useArrayProp(radius); let t4; return $[8] !== animated || $[9] !== ref || $[10] !== restProps || $[11] !== t3 || $[12] !== visible ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton$1, { ...restProps, $animated: animated, $radius: t3, $visible: visible, ref }), $[8] = animated, $[9] = ref, $[10] = restProps, $[11] = t3, $[12] = visible, $[13] = t4) : t4 = $[13], t4; }); Skeleton.displayName = "ForwardRef(Skeleton)"; const StyledSkeleton = /* @__PURE__ */ styledComponents.styled(Skeleton).withConfig({ displayName: "StyledSkeleton", componentId: "sc-2p7a1v-0" })((props) => { const { $size, $style } = props, { font, media } = theme.getTheme_v2(props.theme), fontStyle = font[$style]; return _visualEditing._responsive(media, $size, (sizeIndex) => { const fontSize = fontStyle.sizes[sizeIndex]; return { height: fontSize.lineHeight - fontSize.ascenderHeight - fontSize.descenderHeight }; }); }), TextSkeleton = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(7); let restProps, t0; $[0] !== props ? ({ size: t0, ...restProps } = props, $[0] = props, $[1] = restProps, $[2] = t0) : (restProps = $[1], t0 = $[2]); const $size = _visualEditing.useArrayProp(t0 === void 0 ? 2 : t0); let t1; return $[3] !== $size || $[4] !== ref || $[5] !== restProps ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "text" }), $[3] = $size, $[4] = ref, $[5] = restProps, $[6] = t1) : t1 = $[6], t1; }); TextSkeleton.displayName = "ForwardRef(TextSkeleton)"; const LabelSkeleton = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(7); let restProps, t0; $[0] !== props ? ({ size: t0, ...restProps } = props, $[0] = props, $[1] = restProps, $[2] = t0) : (restProps = $[1], t0 = $[2]); const $size = _visualEditing.useArrayProp(t0 === void 0 ? 2 : t0); let t1; return $[3] !== $size || $[4] !== ref || $[5] !== restProps ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "label" }), $[3] = $size, $[4] = ref, $[5] = restProps, $[6] = t1) : t1 = $[6], t1; }); LabelSkeleton.displayName = "ForwardRef(LabelSkeleton)"; const HeadingSkeleton = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(7); let restProps, t0; $[0] !== pr