UNPKG

@sanity/ui

Version:

The Sanity UI components.

893 lines (891 loc) 103 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), 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 useArrayProp(val, defaultVal) { const $ = reactCompilerRuntime.c(3); let t0; return $[0] !== defaultVal || $[1] !== val ? (t0 = _visualEditing._getArrayProp(val, defaultVal), $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2], t0; } 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 $ = reactCompilerRuntime.c(180); let customValidity, disabled, filterOptionProp, icon, id, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, optionsProp, prefix, readOnly, relatedElements, renderOptionProp, renderPopover, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, valueProp; $[0] !== props ? ({ border: t0, customValidity, disabled, filterOption: filterOptionProp, fontSize: t1, icon, id, listBox: t2, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, options: optionsProp, padding: t3, popover: t4, prefix, radius: t5, readOnly, relatedElements, renderOption: renderOptionProp, renderPopover, renderValue: t6, suffix, value: valueProp, ...restProps } = props, $[0] = props, $[1] = customValidity, $[2] = disabled, $[3] = filterOptionProp, $[4] = icon, $[5] = id, $[6] = loading, $[7] = onBlur, $[8] = onChange, $[9] = onFocus, $[10] = onQueryChange, $[11] = onSelect, $[12] = openButton, $[13] = openOnFocus, $[14] = optionsProp, $[15] = prefix, $[16] = readOnly, $[17] = relatedElements, $[18] = renderOptionProp, $[19] = renderPopover, $[20] = restProps, $[21] = suffix, $[22] = t0, $[23] = t1, $[24] = t2, $[25] = t3, $[26] = t4, $[27] = t5, $[28] = t6, $[29] = valueProp) : (customValidity = $[1], disabled = $[2], filterOptionProp = $[3], icon = $[4], id = $[5], loading = $[6], onBlur = $[7], onChange = $[8], onFocus = $[9], onQueryChange = $[10], onSelect = $[11], openButton = $[12], openOnFocus = $[13], optionsProp = $[14], prefix = $[15], readOnly = $[16], relatedElements = $[17], renderOptionProp = $[18], renderPopover = $[19], restProps = $[20], suffix = $[21], t0 = $[22], t1 = $[23], t2 = $[24], t3 = $[25], t4 = $[26], t5 = $[27], t6 = $[28], valueProp = $[29]); const border = t0 === void 0 ? !0 : t0, fontSize = t1 === void 0 ? 2 : t1, listBox = t2 === void 0 ? _visualEditing.EMPTY_RECORD : t2, paddingProp = t3 === void 0 ? 3 : t3, popover = t4 === void 0 ? _visualEditing.EMPTY_RECORD : t4, radius = t5 === void 0 ? 2 : t5, renderValue = t6 === void 0 ? DEFAULT_RENDER_VALUE : t6, t7 = valueProp || null, t8 = valueProp || null; let t9; $[30] !== t7 || $[31] !== t8 ? (t9 = { activeValue: t7, focused: !1, listFocused: !1, query: null, value: t8 }, $[30] = t7, $[31] = t8, $[32] = t9) : t9 = $[32]; const [state, dispatch] = react.useReducer(autocompleteReducer, t9), { activeValue, focused, listFocused, query, value } = state; let t10; $[33] !== fontSize || $[34] !== paddingProp ? (t10 = (t112) => { const { value: value_0 } = t112; return /* @__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 }) }); }, $[33] = fontSize, $[34] = paddingProp, $[35] = t10) : t10 = $[35]; const renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), [inputElement, setInputElement] = react.useState(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1); let t11, t12; $[36] !== inputElement ? (t11 = () => inputElement, t12 = [inputElement], $[36] = inputElement, $[37] = t11, $[38] = t12) : (t11 = $[37], t12 = $[38]), react.useImperativeHandle(inputElementRef, t11, t12); let t13, t14; $[39] !== inputElement ? (t13 = () => inputElement, t14 = [inputElement], $[39] = inputElement, $[40] = t13, $[41] = t14) : (t13 = $[40], t14 = $[41]), react.useImperativeHandle(forwardedRef, t13, t14); const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : _visualEditing.EMPTY_ARRAY, padding = _visualEditing._getArrayProp(paddingProp); let t15; $[42] !== options || $[43] !== value ? (t15 = value !== null ? options.find((o) => o.value === value) : void 0, $[42] = options, $[43] = value, $[44] = t15) : t15 = $[44]; const currentOption = t15; let t16; if ($[45] !== filterOption || $[46] !== options || $[47] !== query) { let t172; $[49] !== filterOption || $[50] !== query ? (t172 = (option) => query ? filterOption(query, option) : !0, $[49] = filterOption, $[50] = query, $[51] = t172) : t172 = $[51], t16 = options.filter(t172), $[45] = filterOption, $[46] = options, $[47] = query, $[48] = t16; } else t16 = $[48]; const filteredOptions = t16, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null; let t17; $[52] !== onBlur || $[53] !== onQueryChange || $[54] !== relatedElements ? (t17 = (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); }, $[52] = onBlur, $[53] = onQueryChange, $[54] = relatedElements, $[55] = t17) : t17 = $[55]; const handleRootBlur = t17; let t18; $[56] === Symbol.for("react.memo_cache_sentinel") ? (t18 = (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 })); }, $[56] = t18) : t18 = $[56]; const handleRootFocus = t18; let t19; $[57] !== onChange || $[58] !== onQueryChange || $[59] !== onSelect ? (t19 = (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(); }, $[57] = onChange, $[58] = onQueryChange, $[59] = onSelect, $[60] = t19) : t19 = $[60]; const handleOptionSelect = t19; let t20; $[61] !== activeValue || $[62] !== filteredOptions || $[63] !== filteredOptionsLen || $[64] !== onQueryChange ? (t20 = (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; } }, $[61] = activeValue, $[62] = filteredOptions, $[63] = filteredOptionsLen, $[64] = onQueryChange, $[65] = t20) : t20 = $[65]; const handleRootKeyDown = t20; let t21; $[66] !== onQueryChange ? (t21 = (event_2) => { const nextQuery = event_2.currentTarget.value; dispatch({ type: "input/change", query: nextQuery }), onQueryChange && onQueryChange(nextQuery); }, $[66] = onQueryChange, $[67] = t21) : t21 = $[67]; const handleInputChange = t21; let t22; $[68] !== currentOption || $[69] !== renderValue || $[70] !== value ? (t22 = () => { dispatch({ type: "root/open", query: value ? renderValue(value, currentOption) : "" }); }, $[68] = currentOption, $[69] = renderValue, $[70] = value, $[71] = t22) : t22 = $[71]; const dispatchOpen = t22; let t23; $[72] !== dispatchOpen || $[73] !== focused || $[74] !== onFocus || $[75] !== openOnFocus ? (t23 = (event_3) => { focused || (dispatch({ type: "input/focus" }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen()); }, $[72] = dispatchOpen, $[73] = focused, $[74] = onFocus, $[75] = openOnFocus, $[76] = t23) : t23 = $[76]; const handleInputFocus = t23; let t24; $[77] === Symbol.for("react.memo_cache_sentinel") ? (t24 = () => { popoverMouseWithinRef.current = !0; }, $[77] = t24) : t24 = $[77]; const handlePopoverMouseEnter = t24; let t25; $[78] === Symbol.for("react.memo_cache_sentinel") ? (t25 = () => { popoverMouseWithinRef.current = !1; }, $[78] = t25) : t25 = $[78]; const handlePopoverMouseLeave = t25; let t26; $[79] !== onChange || $[80] !== onQueryChange ? (t26 = () => { dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus(); }, $[79] = onChange, $[80] = onQueryChange, $[81] = t26) : t26 = $[81]; const handleClearButtonClick = t26; let t27; $[82] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => { dispatch({ type: "input/focus" }); }, $[82] = t27) : t27 = $[82]; const handleClearButtonFocus = t27; let t28, t29; $[83] !== valueProp ? (t28 = () => { 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 })); }, t29 = [valueProp], $[83] = valueProp, $[84] = t28, $[85] = t29) : (t28 = $[84], t29 = $[85]), react.useEffect(t28, t29); let t30, t31; $[86] !== focused ? (t30 = () => { !focused && valueRef.current && dispatch({ type: "root/setActiveValue", value: valueRef.current }); }, t31 = [focused], $[86] = focused, $[87] = t30, $[88] = t31) : (t30 = $[87], t31 = $[88]), react.useEffect(t30, t31); let t32, t33; $[89] !== activeValue || $[90] !== filteredOptions ? (t32 = () => { 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); } } }, t33 = [activeValue, filteredOptions], $[89] = activeValue, $[90] = filteredOptions, $[91] = t32, $[92] = t33) : (t32 = $[91], t33 = $[92]), react.useEffect(t32, t33); let t34; bb0: { if (!loading && !disabled && value) { let t352; $[93] === Symbol.for("react.memo_cache_sentinel") ? (t352 = { "aria-label": "Clear", onFocus: handleClearButtonFocus }, $[93] = t352) : t352 = $[93], t34 = t352; break bb0; } t34 = void 0; } const clearButton = t34, openButtonBoxPadding = padding.map(_temp$3), openButtonPadding = padding.map(_temp2$1), openButtonProps = typeof openButton == "object" ? openButton : _visualEditing.EMPTY_RECORD; let t35; $[94] !== dispatchOpen || $[95] !== openButtonProps ? (t35 = (event_4) => { dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus()); }, $[94] = dispatchOpen, $[95] = openButtonProps, $[96] = t35) : t35 = $[96]; const handleOpenClick = t35; let t36; $[97] !== disabled || $[98] !== expanded || $[99] !== fontSize || $[100] !== handleOpenClick || $[101] !== openButton || $[102] !== openButtonBoxPadding || $[103] !== openButtonPadding || $[104] !== openButtonProps || $[105] !== readOnly ? (t36 = !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, $[97] = disabled, $[98] = expanded, $[99] = fontSize, $[100] = handleOpenClick, $[101] = openButton, $[102] = openButtonBoxPadding, $[103] = openButtonPadding, $[104] = openButtonProps, $[105] = readOnly, $[106] = t36) : t36 = $[106]; const openButtonNode = t36; let t37; bb1: { if (query === null) { if (value !== null) { let t382; $[107] !== currentOption || $[108] !== renderValue || $[109] !== value ? (t382 = renderValue(value, currentOption), $[107] = currentOption, $[108] = renderValue, $[109] = value, $[110] = t382) : t382 = $[110], t37 = t382; break bb1; } t37 = ""; break bb1; } t37 = query; } const inputValue = t37; let t38; $[111] !== listFocused ? (t38 = (event_5) => { event_5.key === "Tab" && listFocused && inputElementRef.current?.focus(); }, $[111] = listFocused, $[112] = t38) : t38 = $[112]; const handleListBoxKeyDown = t38; let t39; bb2: { if (filteredOptions.length === 0) { t39 = null; break bb2; } let t402; if ($[113] !== activeValue || $[114] !== currentOption || $[115] !== filteredOptions || $[116] !== handleOptionSelect || $[117] !== id || $[118] !== listFocused || $[119] !== loading || $[120] !== renderOption) { let t413; $[122] !== activeValue || $[123] !== currentOption || $[124] !== handleOptionSelect || $[125] !== id || $[126] !== listFocused || $[127] !== loading || $[128] !== renderOption ? (t413 = (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); }, $[122] = activeValue, $[123] = currentOption, $[124] = handleOptionSelect, $[125] = id, $[126] = listFocused, $[127] = loading, $[128] = renderOption, $[129] = t413) : t413 = $[129], t402 = filteredOptions.map(t413), $[113] = activeValue, $[114] = currentOption, $[115] = filteredOptions, $[116] = handleOptionSelect, $[117] = id, $[118] = listFocused, $[119] = loading, $[120] = renderOption, $[121] = t402; } else t402 = $[121]; let t412; $[130] !== listBoxId || $[131] !== t402 ? (t412 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: t402 }), $[130] = listBoxId, $[131] = t402, $[132] = t412) : t412 = $[132]; let t422; $[133] !== handleListBoxKeyDown || $[134] !== listBox || $[135] !== t412 ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: t412 }), $[133] = handleListBoxKeyDown, $[134] = listBox, $[135] = t412, $[136] = t422) : t422 = $[136], t39 = t422; } const content2 = t39; let t40; bb3: { if (renderPopover) { const t413 = !expanded; let t422; $[137] !== content2 || $[138] !== handlePopoverMouseEnter || $[139] !== handlePopoverMouseLeave || $[140] !== inputElement || $[141] !== renderPopover || $[142] !== t413 ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(RenderPopover, { content: content2, hidden: t413, inputElement, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, resultsPopoverElementRef, renderPopover }), $[137] = content2, $[138] = handlePopoverMouseEnter, $[139] = handlePopoverMouseLeave, $[140] = inputElement, $[141] = renderPopover, $[142] = t413, $[143] = t422) : t422 = $[143], t40 = t422; break bb3; } if (filteredOptionsLen === 0) { t40 = null; break bb3; } let t412; $[144] !== content2 || $[145] !== expanded || $[146] !== handlePopoverMouseEnter || $[147] !== handlePopoverMouseLeave || $[148] !== inputElement || $[149] !== popover || $[150] !== radius ? (t412 = /* @__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: inputElement, ...popover }), $[144] = content2, $[145] = expanded, $[146] = handlePopoverMouseEnter, $[147] = handlePopoverMouseLeave, $[148] = inputElement, $[149] = popover, $[150] = radius, $[151] = t412) : t412 = $[151], t40 = t412; } const results = t40, t41 = loading && AnimatedSpinnerIcon, t42 = suffix || openButtonNode; let t43; $[152] !== activeItemId || $[153] !== border || $[154] !== clearButton || $[155] !== customValidity || $[156] !== disabled || $[157] !== expanded || $[158] !== fontSize || $[159] !== handleClearButtonClick || $[160] !== handleInputChange || $[161] !== handleInputFocus || $[162] !== icon || $[163] !== id || $[164] !== inputValue || $[165] !== listBoxId || $[166] !== padding || $[167] !== prefix || $[168] !== radius || $[169] !== readOnly || $[170] !== restProps || $[171] !== t41 || $[172] !== t42 ? (t43 = /* @__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: t41, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: setInputElement, role: "combobox", spellCheck: !1, suffix: t42, value: inputValue }), $[152] = activeItemId, $[153] = border, $[154] = clearButton, $[155] = customValidity, $[156] = disabled, $[157] = expanded, $[158] = fontSize, $[159] = handleClearButtonClick, $[160] = handleInputChange, $[161] = handleInputFocus, $[162] = icon, $[163] = id, $[164] = inputValue, $[165] = listBoxId, $[166] = padding, $[167] = prefix, $[168] = radius, $[169] = readOnly, $[170] = restProps, $[171] = t41, $[172] = t42, $[173] = t43) : t43 = $[173]; let t44; return $[174] !== handleRootBlur || $[175] !== handleRootFocus || $[176] !== handleRootKeyDown || $[177] !== results || $[178] !== t43 ? (t44 = /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [ t43, results ] }), $[174] = handleRootBlur, $[175] = handleRootFocus, $[176] = handleRootKeyDown, $[177] = results, $[178] = t43, $[179] = t44) : t44 = $[179], t44; }); function RenderPopover({ renderPopover, content: content2, hidden, inputElement, onMouseEnter, onMouseLeave, resultsPopoverElementRef }) { return renderPopover({ content: content2, hidden, inputElement, onMouseEnter, onMouseLeave }, resultsPopoverElementRef); } InnerAutocomplete.displayName = "ForwardRef(Autocomplete)"; const Autocomplete = InnerAutocomplete; function _temp$3(v_0) { return v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2; } function _temp2$1(v_1) { return Math.max(v_1 - 1, 0); } const 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 $ = reactCompilerRuntime.c(29); let children, maxLength, restProps, separator, t0; $[0] !== props ? ({ children, maxLength, separator, space: t0, ...restProps } = props, $[0] = props, $[1] = children, $[2] = maxLength, $[3] = restProps, $[4] = separator, $[5] = t0) : (children = $[1], maxLength = $[2], restProps = $[3], separator = $[4], t0 = $[5]); const spaceRaw = t0 === void 0 ? 2 : t0; let t1; $[6] !== spaceRaw ? (t1 = _visualEditing._getArrayProp(spaceRaw), $[6] = spaceRaw, $[7] = t1) : t1 = $[7]; const space = t1, [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null); let t2; $[8] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(!1), $[8] = t2) : t2 = $[8]; const collapse = t2; let t3; $[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!0), $[9] = t3) : t3 = $[9]; const expand = t3; let t4; $[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => [expandElementRef.current, popoverElementRef.current], $[10] = t4) : t4 = $[10], _visualEditing.useClickOutsideEvent(collapse, t4); let t5; $[11] !== children ? (t5 = react.Children.toArray(children).filter(react.isValidElement), $[11] = children, $[12] = t5) : t5 = $[12]; const rawItems = t5; let t6; $[13] !== maxLength || $[14] !== open || $[15] !== rawItems || $[16] !== space ? (t6 = { collapse, expand, expandElementRef, maxLength, open, popoverElementRef, rawItems, space }, $[13] = maxLength, $[14] = open, $[15] = rawItems, $[16] = space, $[17] = t6) : t6 = $[17]; const items = useItems(t6); let t7; if ($[18] !== items || $[19] !== separator || $[20] !== space) { let t82; $[22] !== separator || $[23] !== space ? (t82 = (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), $[22] = separator, $[23] = space, $[24] = t82) : t82 = $[24], t7 = items.map(t82), $[18] = items, $[19] = separator, $[20] = space, $[21] = t7; } else t7 = $[21]; let t8; return $[25] !== ref || $[26] !== restProps || $[27] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t7 }), $[25] = ref, $[26] = restProps, $[27] = t7, $[28] = t8) : t8 = $[28], t8; }); Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)"; function useItems(t0) { const $ = reactCompilerRuntime.c(28), { collapse, expand, expandElementRef, maxLength, open, popoverElementRef, rawItems, space } = t0, len = rawItems.length; if (maxLength && len > maxLength) { const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2); let t1; if ($[0] !== afterLength || $[1] !== beforeLength || $[2] !== collapse || $[3] !== expand || $[4] !== expandElementRef || $[5] !== len || $[6] !== open || $[7] !== popoverElementRef || $[8] !== rawItems || $[9] !== space) { const t2 = rawItems.slice(0, beforeLength - 1); let t3; $[11] !== afterLength || $[12] !== beforeLength || $[13] !== len || $[14] !== rawItems ? (t3 = rawItems.slice(beforeLength - 1, len - afterLength), $[11] = afterLength, $[12] = beforeLength, $[13] = len, $[14] = rawItems, $[15] = t3) : t3 = $[15]; let t4; $[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18]; const t5 = open ? collapse : expand; let t6; $[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: t5, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }), $[19] = expandElementRef, $[20] = open, $[21] = t5, $[22] = t6) : t6 = $[22]; let t7; $[23] !== open || $[24] !== popoverElementRef || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: t4, open, placement: "top", portal: !0, ref: popoverElementRef, children: t6 }, "button"), $[23] = open, $[24] = popoverElementRef, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t1 = [...t2, t7, ...rawItems.slice(len - afterLength)], $[0] = afterLength, $[1] = beforeLength, $[2] = collapse, $[3] = expand, $[4] = expandElementRef, $[5] = len, $[6] = open, $[7] = popoverElementRef, $[8] = rawItems, $[9] = space, $[10] = t1; } else t1 = $[10]; return t1; } return rawItems; } 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(44), { __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; let t0; $[0] !== radiusProp ? (t0 = _visualEditing._getArrayProp(radiusProp), $[0] = radiusProp, $[1] = t0) : t0 = $[1]; const radius = t0; let t1; $[2] !== shadowProp ? (t1 = _visualEditing._getArrayProp(shadowProp), $[2] = shadowProp, $[3] = t1) : t1 = $[3]; const shadow = t1; let t2; $[4] !== widthProp ? (t2 = _visualEditing._getArrayProp(widthProp), $[4] = widthProp, $[5] = t2) : t2 = $[5]; const width = t2, ref = react.useRef(null), contentRef = react.useRef(null), layer = _visualEditing.useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton; let t3; $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[6] = t3) : t3 = $[6], react.useImperativeHandle(forwardedRef, t3); let t4; $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => contentRef.current, $[7] = t4) : t4 = $[7], react.useImperativeHandle(forwardedContentRef, t4); let t5, t6; $[8] !== autoFocus ? (t5 = () => { autoFocus && ref.current && focusFirstDescendant(ref.current); }, t6 = [autoFocus, ref], $[8] = autoFocus, $[9] = t5, $[10] = t6) : (t5 = $[9], t6 = $[10]), react.useEffect(t5, t6); let t7; $[11] !== boundaryElement || $[12] !== isTopLayer || $[13] !== onClose || $[14] !== portalElement ? (t7 = (event) => { if (!isTopLayer || !onClose) return; const target = document.activeElement; target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose()); }, $[11] = boundaryElement, $[12] = isTopLayer, $[13] = onClose, $[14] = portalElement, $[15] = t7) : t7 = $[15], _visualEditing.useGlobalKeyDown(t7); let t8; $[16] !== boundaryElement || $[17] !== isTopLayer || $[18] !== onClickOutside || $[19] !== portalElement ? (t8 = isTopLayer && onClickOutside && ((event_0) => { const target_0 = event_0.target; target_0 && !isTargetWithinScope(boundaryElement, portalElement, target_0) || onClickOutside(); }), $[16] = boundaryElement, $[17] = isTopLayer, $[18] = onClickOutside, $[19] = portalElement, $[20] = t8) : t8 = $[20]; let t9; $[21] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => [ref.current], $[21] = t9) : t9 = $[21], _visualEditing.useClickOutsideEvent(t8, t9); let t10; $[22] !== header || $[23] !== labelId || $[24] !== onClose || $[25] !== showCloseButton || $[26] !== showHeader ? (t10 = 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 }) }) ] }) }), $[22] = header, $[23] = labelId, $[24] = onClose, $[25] = showCloseButton, $[26] = showHeader, $[27] = t10) : t10 = $[27]; let t11; $[28] !== children ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }), $[28] = children, $[29] = t11) : t11 = $[29]; let t12; $[30] !== footer ? (t12 = footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer }), $[30] = footer, $[31] = t12) : t12 = $[31]; let t13; $[32] !== t10 || $[33] !== t11 || $[34] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [ t10, t11, t12 ] }), $[32] = t10, $[33] = t11, $[34] = t12, $[35] = t13) : t13 = $[35]; let t14; $[36] !== radius || $[37] !== scheme || $[38] !== shadow || $[39] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: t13 }), $[36] = radius, $[37] = scheme, $[38] = shadow, $[39] = t13, $[40] = t14) : t14 = $[40]; let t15; return $[41] !== t14 || $[42] !== width ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: t14 }), $[41] = t14, $[42] = width, $[43] = t15) : t15 = $[43], t15; }); DialogCard.displayName = "ForwardRef(DialogCard)"; const Dialog = react.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(70), 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; let t7; $[22] !== cardRadiusProp ? (t7 = _visualEditing._getArrayProp(cardRadiusProp), $[22] = cardRadiusProp, $[23] = t7) : t7 = $[23]; const cardRadius = t7; let t8; $[24] !== paddingProp ? (t8 = _visualEditing._getArrayProp(paddingProp), $[24] = paddingProp, $[25] = t8) : t8 = $[25]; const padding = t8; let t9; $[26] !== positionProp ? (t9 = _visualEditing._getArrayProp(positionProp), $[26] = positionProp, $[27] = t9) : t9 = $[27]; const position = t9; let t10; $[28] !== widthProp ? (t10 = _visualEditing._getArrayProp(widthProp), $[28] = widthProp, $[29] = t10) : t10 = $[29]; const width = t10; let t11; $[30] !== zOffsetProp ? (t11 = _visualEditing._getArrayProp(zOffsetProp), $[30] = zOffsetProp, $[31] = t11) : t11 = $[31]; const zOffset = t11, preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null); let t12; $[32] !== onFocus ? (t12 = (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); }, $[32] = onFocus, $[33] = t12) : t12 = $[33]; const handleFocus = t12, labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0); let t13; $[34] !== boundaryElement || $[35] !== portalElement ? (t13 = () => { 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); }, $[34] = boundaryElement, $[35] = portalElement, $[36] = t13) : t13 = $[36]; const handleRootClick = t13; let t14; $[37] === Symbol.for("react.memo_cache_sentinel") ? (t14 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: preDivRef, tabIndex: 0 }), $[37] = t14) : t14 = $[37]; let t15; $[38] !== autoFocus || $[39] !== cardRadius || $[40] !== cardShadow || $[41] !== children || $[42] !== contentRef || $[43] !== footer || $[44] !== header || $[45] !== hideCloseButton || $[46] !== id || $[47] !== onClickOutside || $[48] !== onClose || $[49] !== portalProp || $[50] !== scheme || $[51] !== width ? (t15 = /* @__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 }), $[38] = autoFocus, $[39] = cardRadius, $[40] = cardShadow, $[41] = children, $[42] = contentRef, $[43] = footer, $[44] = header, $[45] = hideCloseButton, $[46] = id, $[47] = onClickOutside, $[48] = onClose, $[49] = portalProp, $[50] = scheme, $[51] = width, $[52] = t15) : t15 = $[52]; let t16; $[53] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 }), $[53] = t16) : t16 = $[53]; let t17; $[54] !== animate || $[55] !== handleFocus || $[56] !== handleRootClick || $[57] !== id || $[58] !== labelId || $[59] !== onActivate || $[60] !== padding || $[61] !== position || $[62] !== ref || $[63] !== restProps || $[64] !== t15 || $[65] !== zOffset ? (t17 = /* @__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: [ t14, t15, t16 ] }), $[