UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

1,004 lines (1,001 loc) • 136 kB
"use strict"; var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), constants = require("@sanity/preview-url-secret/constants"), ui = require("@sanity/ui"), uuid$1 = require("@sanity/uuid"), React = require("react"), sanity = require("sanity"), presentation = require("./presentation.js"), csm = require("@sanity/client/csm"), comlink = require("@sanity/comlink"), presentationComlink = require("@sanity/presentation-comlink"), router = require("sanity/router"), styledComponents = require("styled-components"), useEffectEvent = require("use-effect-event"), _singletons = require("sanity/_singletons"), icons = require("@sanity/icons"), structure = require("sanity/structure"), TooltipDelayGroupProvider = require("./TooltipDelayGroupProvider.js"); require("../_singletons.js"); var StructureToolProvider = require("./StructureToolProvider.js"), DisplayedDocumentBroadcaster = require("./DisplayedDocumentBroadcaster.js"), uuid = require("uuid"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), withoutSecretSearchParams = require("@sanity/preview-url-secret/without-secret-search-params"), logos = require("@sanity/logos"), togglePreviewAccessSharing = require("@sanity/preview-url-secret/toggle-preview-access-sharing"), client = require("@sanity/client"), isEqual = require("fast-deep-equal"), pathToRegexp = require("path-to-regexp"), valibot = require("valibot"), createSecret = require("@sanity/preview-url-secret/create-secret"), definePreviewUrl = require("@sanity/preview-url-secret/define-preview-url"), suspendReact = require("suspend-react"), toggleVercelProtectionBypass = require("@sanity/preview-url-secret/toggle-vercel-protection-bypass"); function _interopDefaultCompat(e) { return e && typeof e == "object" && "default" in e ? e : { default: e }; } var isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual); const PostMessageFeatures = (props) => { const $ = reactCompilerRuntime.c(3), { comlink: comlink2 } = props; let t0, t1; return $[0] !== comlink2 ? (t0 = () => comlink2.on("visual-editing/features", _temp$a), t1 = [comlink2], $[0] = comlink2, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), React.useEffect(t0, t1), null; }; var PostMessageFeatures$1 = React.memo(PostMessageFeatures); function _temp$a() { return { features: { optimistic: !0 } }; } function debounce(fn, timeout) { let timer; return (...args) => { clearTimeout(timer), timer = setTimeout(() => { fn.apply(fn, args); }, timeout); }; } const SharedStateProvider = function(props) { const $ = reactCompilerRuntime.c(14), { comlink: comlink2, children } = props; let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0]; const sharedState = React.useRef(t0); let t1, t2; $[1] !== comlink2 ? (t1 = () => comlink2?.on("visual-editing/shared-state", () => ({ state: sharedState.current })), t2 = [comlink2], $[1] = comlink2, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), React.useEffect(t1, t2); let t3; $[4] !== comlink2 ? (t3 = (key, value) => { sharedState.current[key] = value, comlink2?.post("presentation/shared-state", { key, value }); }, $[4] = comlink2, $[5] = t3) : t3 = $[5]; const setValue = t3; let t4; $[6] !== comlink2 ? (t4 = (key_0) => { comlink2?.post("presentation/shared-state", { key: key_0 }), delete sharedState.current[key_0]; }, $[6] = comlink2, $[7] = t4) : t4 = $[7]; const removeValue = t4; let t5, t6; $[8] !== removeValue || $[9] !== setValue ? (t6 = { removeValue, setValue }, $[8] = removeValue, $[9] = setValue, $[10] = t6) : t6 = $[10], t5 = t6; const context = t5; let t7; return $[11] !== children || $[12] !== context ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.PresentationSharedStateContext.Provider, { value: context, children }), $[11] = children, $[12] = context, $[13] = t7) : t7 = $[13], t7; }, Root$1 = styledComponents.styled.div` overflow: hidden; flex-basis: 0; flex-shrink: 1; `, Panel = function(t0) { const $ = reactCompilerRuntime.c(15), { children, defaultSize: t1, id, minWidth, maxWidth, order: t2 } = t0, defaultSize = t1 === void 0 ? null : t1, order = t2 === void 0 ? 0 : t2, context = React.useContext(_singletons.PresentationPanelsContext); if (context === null) throw Error("Panel components must be rendered within a PanelGroup container"); const { getPanelStyle, registerElement, unregisterElement } = context; let t3; $[0] !== getPanelStyle || $[1] !== id ? (t3 = getPanelStyle(id), $[0] = getPanelStyle, $[1] = id, $[2] = t3) : t3 = $[2]; const style = t3; let t4, t5; $[3] !== defaultSize || $[4] !== id || $[5] !== maxWidth || $[6] !== minWidth || $[7] !== order || $[8] !== registerElement || $[9] !== unregisterElement ? (t4 = () => (registerElement(id, { id, type: "panel", defaultSize, maxWidth: maxWidth ?? null, minWidth: minWidth ?? 0, order }), () => { unregisterElement(id); }), t5 = [id, defaultSize, order, maxWidth, minWidth, registerElement, unregisterElement], $[3] = defaultSize, $[4] = id, $[5] = maxWidth, $[6] = minWidth, $[7] = order, $[8] = registerElement, $[9] = unregisterElement, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), React.useLayoutEffect(t4, t5); let t6; return $[12] !== children || $[13] !== style ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(Root$1, { style, children }), $[12] = children, $[13] = style, $[14] = t6) : t6 = $[14], t6; }, itemKey = "presentation/panels", getStoredItem = () => JSON.parse(localStorage.getItem(itemKey) || "{}"), setStoredItem = (data) => { localStorage.setItem(itemKey, JSON.stringify(data)); }, getKeyForPanels = (panels) => panels.map((panel) => [panel.id, panel.order].join(":")).join(","); function usePanelsStorage() { const $ = reactCompilerRuntime.c(1); let t0; const get = _temp2$5, set = _temp3$2; let t1; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const setDebounced = debounce(set, 100); t1 = { get, set, setDebounced }, $[0] = t1; } else t1 = $[0]; return t0 = t1, t0; } function _temp3$2(panels_0, widths) { const stored_0 = getStoredItem(), key_0 = getKeyForPanels(panels_0), data = { ...stored_0, [key_0]: widths }; setStoredItem(data); } function _temp2$5(panels) { const stored = getStoredItem(), key = getKeyForPanels(panels); return Array.isArray(stored[key]) && stored[key].some(_temp$9) ? void 0 : stored[key]; } function _temp$9(val) { return val === null; } function getNextWidth(panel, nextWidth, containerWidth) { const { maxWidth: maxWidthPx, minWidth: minWidthPx } = panel, maxWidth = maxWidthPx == null ? 100 : maxWidthPx / containerWidth * 100, minWidth = minWidthPx / containerWidth * 100; return Math.min(maxWidth, Math.max(minWidth, nextWidth)); } function getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsState, initialDragState) { const { panels, widths: prevWidths } = panelsState, { widths: initialWidths } = initialDragState, widths = initialWidths || prevWidths, nextWidths = [...widths]; { const pivotPanel2 = delta < 0 ? panelAfter : panelBefore, index2 = panels.findIndex((panel) => panel.id === pivotPanel2.id), width = widths[index2], nextWidth = getNextWidth(pivotPanel2, width + Math.abs(delta), containerWidth); if (width === nextWidth) return widths; delta = delta < 0 ? width - nextWidth : nextWidth - width; } let deltaApplied = 0, pivotPanel = delta < 0 ? panelBefore : panelAfter, index = panels.findIndex((panel) => panel.id === pivotPanel.id); for (; ; ) { const panel = panels[index], width = widths[index], deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied), nextWidth = getNextWidth(panel, width - deltaRemaining, containerWidth); if (width !== nextWidth && (deltaApplied += width - nextWidth, nextWidths[index] = nextWidth, deltaApplied.toPrecision(10).localeCompare(Math.abs(delta).toPrecision(10), void 0, { numeric: !0 }) >= 0)) break; if (delta < 0) { if (--index < 0) break; } else if (++index >= panels.length) break; } return deltaApplied === 0 ? widths : (pivotPanel = delta < 0 ? panelAfter : panelBefore, index = panels.findIndex((panel) => panel.id === pivotPanel.id), nextWidths[index] = widths[index] + deltaApplied, nextWidths); } function getPanelWidth(panels, id, widths) { if (panels.length === 1) return "100"; const index = panels.findIndex((panel) => panel.id === id), width = widths[index]; return width == null ? "0" : width.toPrecision(10); } function getOffset(event, handleElement, initialOffset = 0, initialHandleElementRect = null) { const pointerOffset = event.clientX, elementOffset = (initialHandleElementRect || handleElement.getBoundingClientRect()).left; return pointerOffset - elementOffset - initialOffset; } function isPanel(element) { return element.type === "panel"; } function isResizer(element) { return element.type === "resizer"; } function getSortedElements(elements) { return Array.from(elements.values()).sort(({ order: a }, { order: b }) => a == null && b == null ? 0 : a == null ? -1 : b == null ? 1 : a - b); } function validateWidths(panels, widthsToValidate, containerWidth) { const total = widthsToValidate.reduce((total2, width) => total2 + width, 0), widths = [...widthsToValidate].map((width) => width / total * 100); let remainingWidth = 0; for (let index = 0; index < panels.length; index++) { const panel = panels[index], width = widths[index], nextWidth = getNextWidth(panel, width, containerWidth); width != nextWidth && (remainingWidth += width - nextWidth, widths[index] = nextWidth); } if (remainingWidth.toFixed(3) !== "0.000") for (let index = 0; index < panels.length; index++) { const panel = panels[index]; let { maxWidth, minWidth } = panel; minWidth = minWidth / containerWidth * 100, maxWidth != null && (maxWidth = maxWidth / containerWidth * 100); const width = Math.min( // eslint-disable-next-line no-negated-condition maxWidth ?? 100, Math.max(minWidth, widths[index] + remainingWidth) ); if (width !== widths[index] && (remainingWidth -= width - widths[index], widths[index] = width, Math.abs(remainingWidth).toFixed(3) === "0.000")) break; } return widths; } function getDefaultWidths(panels) { let panelsWithoutWidth = panels.length, remainingWidthTotal = 100; const widthsWithNulls = panels.map((panel) => panel.defaultSize ? (remainingWidthTotal -= panel.defaultSize, panelsWithoutWidth -= 1, panel.defaultSize) : null), defaultWidth = remainingWidthTotal / panelsWithoutWidth; return widthsWithNulls.map((width) => width === null ? defaultWidth : width); } const PanelsWrapper = styledComponents.styled.div` display: flex; flex-direction: row; height: 100%; overflow: hidden; width: 100%; `, Panels = function(t0) { const $ = reactCompilerRuntime.c(46), { children } = t0, panelsEl = React.useRef(null); let t1; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ new Map(), $[0] = t1) : t1 = $[0]; const [elements, setElements] = React.useState(t1); let t2, t3; $[1] !== elements ? (t3 = getSortedElements(elements).filter(isPanel), $[1] = elements, $[2] = t3) : t3 = $[2], t2 = t3; const panels = t2; let t4; $[3] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[3] = t4) : t4 = $[3]; const [widths, setWidths] = React.useState(t4), [activeResizer, setActiveResizer] = React.useState(null); let t5; $[4] !== elements || $[5] !== panels || $[6] !== widths ? (t5 = { elements, panels, widths }, $[4] = elements, $[5] = panels, $[6] = widths, $[7] = t5) : t5 = $[7]; const panelsRef = React.useRef(t5); let t6; $[8] !== activeResizer || $[9] !== panels || $[10] !== widths ? (t6 = (id) => ({ flexGrow: getPanelWidth(panels, id, widths), pointerEvents: activeResizer === null ? void 0 : "none" }), $[8] = activeResizer, $[9] = panels, $[10] = widths, $[11] = t6) : t6 = $[11]; const getPanelStyle = t6; let t7; $[12] === Symbol.for("react.memo_cache_sentinel") ? (t7 = (id_0, data) => { setElements((prev) => { if (prev.has(id_0)) return prev; const next = new Map(prev); return next.set(id_0, data), next; }); }, $[12] = t7) : t7 = $[12]; const registerElement = t7; let t8; $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = (id_1) => { setElements((prev_0) => { if (!prev_0.has(id_1)) return prev_0; const next_0 = new Map(prev_0); return next_0.delete(id_1), next_0; }); }, $[13] = t8) : t8 = $[13]; const unregisterElement = t8; let t9; $[14] === Symbol.for("react.memo_cache_sentinel") ? (t9 = { containerWidth: window.innerWidth, dragOffset: 0, panelAfter: null, panelBefore: null, resizerIndex: -1, resizerRect: null, startX: 0, widths: [] }, $[14] = t9) : t9 = $[14]; const dragRef = React.useRef(t9); let t10; $[15] !== elements ? (t10 = (id_2, event) => { const elementsArr = getSortedElements(elements), index = elementsArr.findIndex((el) => el.id === id_2), resizer = elements.get(id_2); if (!resizer || !isResizer(resizer)) return; const resizeElement = resizer.el.current; resizeElement && (dragRef.current = { resizerIndex: index, panelBefore: elementsArr.reduce((acc, el_0, i) => isPanel(el_0) && i < index ? el_0 : acc, null), panelAfter: elementsArr.reduce((acc_0, el_1, i_0) => acc_0 === null && isPanel(el_1) && i_0 > index ? el_1 : acc_0, null), containerWidth: window.innerWidth, startX: event.pageX, dragOffset: getOffset(event, resizeElement), resizerRect: resizeElement.getBoundingClientRect(), widths: panelsRef.current.widths }, setActiveResizer(id_2)); }, $[15] = elements, $[16] = t10) : t10 = $[16]; const startDragging = t10; let t11; $[17] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => { setActiveResizer(null); }, $[17] = t11) : t11 = $[17]; const stopDragging = t11; let t12; $[18] !== elements ? (t12 = (id_3, event_0) => { event_0.preventDefault(), event_0.stopPropagation(); const { containerWidth, dragOffset, panelBefore, panelAfter, resizerRect } = dragRef.current; if (panelBefore == null || panelAfter == null) return; const resizer_0 = elements.get(id_3); if (!resizer_0 || !isResizer(resizer_0)) return; const resizeElement_0 = resizer_0.el.current; if (!resizeElement_0) return; const offset = getOffset(event_0, resizeElement_0, dragOffset, resizerRect); if (offset === 0) return; const { widths: prevWidths } = panelsRef.current, rect = panelsEl.current.getBoundingClientRect(), delta = offset / rect.width * 100, nextWidths = getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsRef.current, dragRef.current); prevWidths.some((prevWidth, i_1) => prevWidth !== nextWidths[i_1]) && setWidths(nextWidths); }, $[18] = elements, $[19] = t12) : t12 = $[19]; const drag = t12; let t13, t14; $[20] !== elements || $[21] !== panels || $[22] !== widths ? (t13 = () => { panelsRef.current.elements = elements, panelsRef.current.panels = panels, panelsRef.current.widths = widths; }, t14 = [elements, panels, widths], $[20] = elements, $[21] = panels, $[22] = widths, $[23] = t13, $[24] = t14) : (t13 = $[23], t14 = $[24]), React.useLayoutEffect(t13, t14); const storage = usePanelsStorage(); let t15, t16; $[25] !== panels || $[26] !== storage ? (t15 = () => { const { widths: widths_0 } = panelsRef.current; if (widths_0.length === panels.length) return; const storedWidths = storage.get(panels); if (storedWidths) { const validatedStoredWidths = validateWidths(panels, storedWidths, window.innerWidth); setWidths(validatedStoredWidths); return; } const defaultWidths = getDefaultWidths(panels); setWidths(defaultWidths); }, t16 = [storage, panels], $[25] = panels, $[26] = storage, $[27] = t15, $[28] = t16) : (t15 = $[27], t16 = $[28]), React.useLayoutEffect(t15, t16); let t17, t18; $[29] !== panels || $[30] !== storage || $[31] !== widths ? (t17 = () => { widths.length && storage.setDebounced(panels, widths); }, t18 = [storage, panels, widths], $[29] = panels, $[30] = storage, $[31] = widths, $[32] = t17, $[33] = t18) : (t17 = $[32], t18 = $[33]), React.useEffect(t17, t18); let t19, t20; $[34] === Symbol.for("react.memo_cache_sentinel") ? (t19 = () => { const resizeObserver = new ResizeObserver(() => { const { panels: panels_0, widths: prevWidths_0 } = panelsRef.current, nextWidths_0 = validateWidths(panels_0, prevWidths_0, window.innerWidth); prevWidths_0.some((prevWidth_0, i_2) => prevWidth_0 !== nextWidths_0[i_2]) && setWidths(nextWidths_0); }); return resizeObserver.observe(panelsEl.current), () => { resizeObserver.disconnect(); }; }, t20 = [], $[34] = t19, $[35] = t20) : (t19 = $[34], t20 = $[35]), React.useLayoutEffect(t19, t20); let t21, t22; $[36] !== activeResizer || $[37] !== drag || $[38] !== getPanelStyle || $[39] !== startDragging ? (t22 = { activeResizer, drag, getPanelStyle, registerElement, startDragging, stopDragging, unregisterElement }, $[36] = activeResizer, $[37] = drag, $[38] = getPanelStyle, $[39] = startDragging, $[40] = t22) : t22 = $[40], t21 = t22; const context = t21; let t23; $[41] !== children ? (t23 = /* @__PURE__ */ jsxRuntime.jsx(PanelsWrapper, { ref: panelsEl, children }), $[41] = children, $[42] = t23) : t23 = $[42]; let t24; return $[43] !== context || $[44] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.PresentationPanelsContext.Provider, { value: context, children: t23 }), $[43] = context, $[44] = t23, $[45] = t24) : t24 = $[45], t24; }; function ErrorCard(props) { const $ = reactCompilerRuntime.c(37); let children, message, onContinueAnyway, onRetry, restProps; $[0] !== props ? ({ children, message, onRetry, onContinueAnyway, ...restProps } = props, $[0] = props, $[1] = children, $[2] = message, $[3] = onContinueAnyway, $[4] = onRetry, $[5] = restProps) : (children = $[1], message = $[2], onContinueAnyway = $[3], onRetry = $[4], restProps = $[5]); const { t } = sanity.useTranslation(presentation.presentationLocaleNamespace); let t0; $[6] !== t ? (t0 = t("error-card.retry-button.text"), $[6] = t, $[7] = t0) : t0 = $[7]; let t1; $[8] !== onRetry || $[9] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { mode: "ghost", onClick: onRetry, text: t0 }), $[8] = onRetry, $[9] = t0, $[10] = t1) : t1 = $[10]; const retryButton = t1; let t2; $[11] !== t ? (t2 = t("error-card.continue-button.text"), $[11] = t, $[12] = t2) : t2 = $[12]; let t3; $[13] !== onContinueAnyway || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { mode: "ghost", tone: "critical", onClick: onContinueAnyway, text: t2 }), $[13] = onContinueAnyway, $[14] = t2, $[15] = t3) : t3 = $[15]; const continueAnywayButton = t3; let t4; $[16] !== t ? (t4 = t("error-card.title"), $[16] = t, $[17] = t4) : t4 = $[17]; let t5; $[18] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: t4 }), $[18] = t4, $[19] = t5) : t5 = $[19]; let t6; $[20] !== message ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: message }), $[20] = message, $[21] = t6) : t6 = $[21]; let t7; $[22] !== t5 || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [ t5, t6 ] }), $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24]; let t8; $[25] !== continueAnywayButton || $[26] !== onContinueAnyway || $[27] !== onRetry || $[28] !== retryButton ? (t8 = onRetry && onContinueAnyway ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Inline, { space: 2, children: [ retryButton, continueAnywayButton ] }) : onRetry ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: retryButton }) : onContinueAnyway ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: continueAnywayButton }) : null, $[25] = continueAnywayButton, $[26] = onContinueAnyway, $[27] = onRetry, $[28] = retryButton, $[29] = t8) : t8 = $[29]; let t9; $[30] !== children || $[31] !== t7 || $[32] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", height: "fill", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { padding: 4, sizing: "border", width: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [ t7, children, t8 ] }) }) }), $[30] = children, $[31] = t7, $[32] = t8, $[33] = t9) : t9 = $[33]; let t10; return $[34] !== restProps || $[35] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { height: "fill", ...restProps, children: t9 }), $[34] = restProps, $[35] = t9, $[36] = t10) : t10 = $[36], t10; } function encodeQueryString(params = {}) { const parts = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&"); return parts.length ? `?${parts}` : ""; } function resolveQueryStringFromParams(nextParams) { const allowed = ["comment", "inspect", "instruction", "pathKey", "rev", "since", "template", "view"], safeNextParams = Object.entries(nextParams).filter(([key]) => allowed.includes(key)).reduce((obj, [key, value]) => value == null ? obj : { ...obj, [key]: value }, {}); return encodeQueryString(safeNextParams); } const BackLink = React.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(11); let restProps, searchParams; $[0] !== props ? ({ searchParams, ...restProps } = props, $[0] = props, $[1] = restProps, $[2] = searchParams) : (restProps = $[1], searchParams = $[2]); let t0; $[3] !== searchParams ? (t0 = Object.entries(searchParams), $[3] = searchParams, $[4] = t0) : t0 = $[4]; let t1; $[5] !== t0 ? (t1 = { type: void 0, _searchParams: t0 }, $[5] = t0, $[6] = t1) : t1 = $[6]; let t2; return $[7] !== ref || $[8] !== restProps || $[9] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(router.StateLink, { ...restProps, ref, state: t1, title: void 0 }), $[7] = ref, $[8] = restProps, $[9] = t1, $[10] = t2) : t2 = $[10], t2; }), ReferenceChildLink = React.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(15); let documentId, documentType, restProps, searchParams; if ($[0] !== props) { const { documentId: t02, documentType: t12, parentRefPath, template, searchParams: t22, ...t3 } = props; documentId = t02, documentType = t12, searchParams = t22, restProps = t3, $[0] = props, $[1] = documentId, $[2] = documentType, $[3] = restProps, $[4] = searchParams; } else documentId = $[1], documentType = $[2], restProps = $[3], searchParams = $[4]; let t0; $[5] !== searchParams ? (t0 = Object.entries(searchParams), $[5] = searchParams, $[6] = t0) : t0 = $[6]; let t1; $[7] !== documentId || $[8] !== documentType || $[9] !== t0 ? (t1 = { id: documentId, type: documentType, _searchParams: t0 }, $[7] = documentId, $[8] = documentType, $[9] = t0, $[10] = t1) : t1 = $[10]; let t2; return $[11] !== ref || $[12] !== restProps || $[13] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(router.StateLink, { ...restProps, ref, state: t1, title: void 0 }), $[11] = ref, $[12] = restProps, $[13] = t1, $[14] = t2) : t2 = $[14], t2; }); function PresentationPaneRouterProvider(props) { const $ = reactCompilerRuntime.c(26), { children, onStructureParams, structureParams, searchParams, refs } = props, { state: routerState, resolvePathFromState } = router.useRouter(); let t0; $[0] !== routerState._searchParams ? (t0 = Object.fromEntries(routerState._searchParams || []), $[0] = routerState._searchParams, $[1] = t0) : t0 = $[1]; const routerSearchParams = sanity.useUnique(t0); let t1; $[2] !== resolvePathFromState || $[3] !== routerSearchParams || $[4] !== routerState ? (t1 = (nextParams) => { const path = resolvePathFromState(routerState), qs = resolveQueryStringFromParams({ ...routerSearchParams, ...nextParams }); return `${path}${qs}`; }, $[2] = resolvePathFromState, $[3] = routerSearchParams, $[4] = routerState, $[5] = t1) : t1 = $[5]; const createPathWithParams = t1; let t2, t3; $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[6] = t3) : t3 = $[6]; const t4 = structureParams; let t5; $[7] === Symbol.for("react.memo_cache_sentinel") ? (t5 = [], $[7] = t5) : t5 = $[7]; let t6; $[8] !== refs || $[9] !== searchParams ? (t6 = (childLinkProps) => { const { childId, ...restProps } = childLinkProps, ref = refs?.find((r) => r._id === childId || sanity.getPublishedId(r._id) === childId); return ref ? /* @__PURE__ */ jsxRuntime.jsx(router.StateLink, { ...restProps, state: { id: childId, type: ref._type, _searchParams: Object.entries(searchParams) } }) : /* @__PURE__ */ jsxRuntime.jsx("div", { ...restProps }); }, $[8] = refs, $[9] = searchParams, $[10] = t6) : t6 = $[10]; let t7, t8; $[11] !== searchParams ? (t7 = (backLinkProps) => /* @__PURE__ */ jsxRuntime.jsx(BackLink, { ...backLinkProps, searchParams }), t8 = (childLinkProps_0) => /* @__PURE__ */ jsxRuntime.jsx(ReferenceChildLink, { ...childLinkProps_0, searchParams }), $[11] = searchParams, $[12] = t7, $[13] = t8) : (t7 = $[12], t8 = $[13]); let t9; $[14] !== onStructureParams ? (t9 = (nextParams_0) => { onStructureParams({ ...nextParams_0, inspect: nextParams_0.inspect ?? void 0 }); }, $[14] = onStructureParams, $[15] = t9) : t9 = $[15]; let t10; $[16] !== createPathWithParams || $[17] !== t4 || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 || $[21] !== t9 ? (t10 = { index: 0, groupIndex: 0, siblingIndex: 0, payload: t3, params: t4, hasGroupSiblings: !1, groupLength: 1, routerPanesState: t5, ChildLink: t6, BackLink: t7, ReferenceChildLink: t8, ParameterizedLink: _temp$8, closeCurrentAndAfter: _temp2$4, handleEditReference: _temp3$1, replaceCurrent: _temp4, closeCurrent: _temp5, duplicateCurrent: _temp6, setView: _temp7, setParams: t9, setPayload: _temp8, navigateIntent: _temp9, createPathWithParams }, $[16] = createPathWithParams, $[17] = t4, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9, $[22] = t10) : t10 = $[22], t2 = t10; const context = t2; let t11; return $[23] !== children || $[24] !== context ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(structure.PaneRouterContext.Provider, { value: context, children }), $[23] = children, $[24] = context, $[25] = t11) : t11 = $[25], t11; } function _temp9(intentName, intentParams, options_0) { console.warn("navigateIntent", intentName, intentParams, options_0); } function _temp8(payload) { console.warn("setPayload", payload); } function _temp7(viewId) { console.warn("setView", viewId); } function _temp6(pane_0) { console.warn("duplicateCurrent", pane_0); } function _temp5() { console.warn("closeCurrent"); } function _temp4(pane) { console.warn("replaceCurrent", pane); } function _temp3$1(options) { console.warn("handleEditReference", options); } function _temp2$4() { console.warn("closeCurrentAndAfter"); } function _temp$8() { throw new Error("ParameterizedLink not implemented"); } const RootLayout = styledComponents.styled(structure.PaneLayout)` height: 100%; `, Root = styledComponents.styled(ui.Flex)` & > div { min-width: none !important; max-width: none !important; } `, WrappedCode$1 = styledComponents.styled(ui.Code)` white-space: pre-wrap; `; function DocumentListPane(props) { const $ = reactCompilerRuntime.c(33), { mainDocumentState, onStructureParams, searchParams, refs } = props, { t } = sanity.useTranslation(presentation.presentationLocaleNamespace), { devMode } = presentation.usePresentationTool(); let t0, t1; if ($[0] !== mainDocumentState?.document?._id || $[1] !== refs) { let t22; $[3] !== mainDocumentState?.document?._id ? (t22 = (r) => sanity.getPublishedId(r._id) !== mainDocumentState?.document?._id, $[3] = mainDocumentState?.document?._id, $[4] = t22) : t22 = $[4], t1 = refs.filter(t22).map(_temp$7), $[0] = mainDocumentState?.document?._id, $[1] = refs, $[2] = t1; } else t1 = $[2]; t0 = t1; const ids = t0; let t2, t3; $[5] !== ids ? (t3 = { filter: "_id in $ids", params: { ids } }, $[5] = ids, $[6] = t3) : t3 = $[6]; let t4; $[7] !== t ? (t4 = t("document-list-pane.document-list.title"), $[7] = t, $[8] = t4) : t4 = $[8]; let t5; $[9] !== t3 || $[10] !== t4 ? (t5 = { id: "$root", options: t3, schemaTypeName: "", title: t4, type: "documentList" }, $[9] = t3, $[10] = t4, $[11] = t5) : t5 = $[11], t2 = t5; const pane = t2, [errorParams, setErrorParams] = React.useState(null); let t6; $[12] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => setErrorParams(null), $[12] = t6) : t6 = $[12]; const handleRetry = t6, [structureParams] = React.useState(_temp2$3); let t7; $[13] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => setErrorParams(null), $[13] = t7) : t7 = $[13]; let t8; if ($[14] !== refs ? (t8 = [refs], $[14] = refs, $[15] = t8) : t8 = $[15], React.useEffect(t7, t8), errorParams) { let t92; $[16] !== t ? (t92 = t("document-list-pane.error.text"), $[16] = t, $[17] = t92) : t92 = $[17]; let t102; $[18] !== devMode || $[19] !== errorParams || $[20] !== t ? (t102 = devMode && /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, size: 0, children: t("presentation-error.label") }), /* @__PURE__ */ jsxRuntime.jsx(WrappedCode$1, { size: 1, children: errorParams.error.message }) ] }) }), $[18] = devMode, $[19] = errorParams, $[20] = t, $[21] = t102) : t102 = $[21]; let t11; return $[22] !== t102 || $[23] !== t92 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(ErrorCard, { flex: 1, message: t92, onRetry: handleRetry, children: t102 }), $[22] = t102, $[23] = t92, $[24] = t11) : t11 = $[24], t11; } let t9; $[25] !== pane ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(Root, { direction: "column", flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(structure.DocumentListPane, { index: 0, itemId: "$root", pane, paneKey: "$root" }) }), $[25] = pane, $[26] = t9) : t9 = $[26]; let t10; return $[27] !== onStructureParams || $[28] !== refs || $[29] !== searchParams || $[30] !== structureParams || $[31] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsxRuntime.jsx(RootLayout, { children: /* @__PURE__ */ jsxRuntime.jsx(structure.StructureToolProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(PresentationPaneRouterProvider, { onStructureParams, structureParams, searchParams, refs, children: t9 }) }) }) }), $[27] = onStructureParams, $[28] = refs, $[29] = searchParams, $[30] = structureParams, $[31] = t9, $[32] = t10) : t10 = $[32], t10; } function _temp2$3() { return {}; } function _temp$7(r_0) { return sanity.getPublishedId(r_0._id); } const WrappedCode = styledComponents.styled(ui.Code)` white-space: pre-wrap; `; function DocumentPane(props) { const $ = reactCompilerRuntime.c(35), { documentId, documentType, onFocusPath, onStructureParams, searchParams, structureParams } = props, { template, templateParams } = structureParams, { t } = sanity.useTranslation(presentation.presentationLocaleNamespace), { devMode } = presentation.usePresentationTool(); let t0, t1; $[0] !== templateParams ? (t1 = router.decodeJsonParams(templateParams), $[0] = templateParams, $[1] = t1) : t1 = $[1]; let t2; $[2] !== documentId || $[3] !== documentType || $[4] !== t1 || $[5] !== template ? (t2 = { id: documentId, type: documentType, template, templateParameters: t1 }, $[2] = documentId, $[3] = documentType, $[4] = t1, $[5] = template, $[6] = t2) : t2 = $[6]; let t3; $[7] !== documentId || $[8] !== t2 ? (t3 = { id: documentId, options: t2, title: "", type: "document" }, $[7] = documentId, $[8] = t2, $[9] = t3) : t3 = $[9], t0 = t3; const paneDocumentNode = t0, [errorParams, setErrorParams] = React.useState(null); let t4; $[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setErrorParams(null), $[10] = t4) : t4 = $[10]; const handleRetry = t4; let t5; $[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => { setErrorParams(null); }, $[11] = t5) : t5 = $[11]; let t6; if ($[12] !== documentId || $[13] !== documentType || $[14] !== structureParams ? (t6 = [documentId, documentType, structureParams], $[12] = documentId, $[13] = documentType, $[14] = structureParams, $[15] = t6) : t6 = $[15], React.useEffect(t5, t6), errorParams) { let t72; $[16] !== t ? (t72 = t("document-pane.error.text"), $[16] = t, $[17] = t72) : t72 = $[17]; let t82; $[18] !== devMode || $[19] !== errorParams || $[20] !== t ? (t82 = devMode && /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { muted: !0, size: 0, children: t("presentation-error.label") }), /* @__PURE__ */ jsxRuntime.jsx(WrappedCode, { size: 1, children: errorParams.error.message }) ] }) }), $[18] = devMode, $[19] = errorParams, $[20] = t, $[21] = t82) : t82 = $[21]; let t92; return $[22] !== t72 || $[23] !== t82 ? (t92 = /* @__PURE__ */ jsxRuntime.jsx(ErrorCard, { flex: 1, message: t72, onRetry: handleRetry, children: t82 }), $[22] = t72, $[23] = t82, $[24] = t92) : t92 = $[24], t92; } let t7; $[25] === Symbol.for("react.memo_cache_sentinel") ? (t7 = { height: "100%" }, $[25] = t7) : t7 = $[25]; let t8; $[26] === Symbol.for("react.memo_cache_sentinel") ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(presentation.PresentationSpinner, {}), $[26] = t8) : t8 = $[26]; let t9; $[27] !== onFocusPath || $[28] !== paneDocumentNode ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: t8, children: /* @__PURE__ */ jsxRuntime.jsx(structure.DocumentPane, { paneKey: "document", index: 1, itemId: "document", pane: paneDocumentNode, onFocusPath }) }), $[27] = onFocusPath, $[28] = paneDocumentNode, $[29] = t9) : t9 = $[29]; let t10; return $[30] !== onStructureParams || $[31] !== searchParams || $[32] !== structureParams || $[33] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsxRuntime.jsx(structure.PaneLayout, { style: t7, children: /* @__PURE__ */ jsxRuntime.jsx(PresentationPaneRouterProvider, { searchParams, onStructureParams, structureParams, children: t9 }) }) }), $[30] = onStructureParams, $[31] = searchParams, $[32] = structureParams, $[33] = t9, $[34] = t10) : t10 = $[34], t10; } function DocumentPanel(props) { const $ = reactCompilerRuntime.c(7), { documentId, documentType, onFocusPath, onStructureParams, searchParams, structureParams } = props; let t0; return $[0] !== documentId || $[1] !== documentType || $[2] !== onFocusPath || $[3] !== onStructureParams || $[4] !== searchParams || $[5] !== structureParams ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(StructureToolProvider.StructureToolProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentPane, { documentId, documentType, onFocusPath, onStructureParams, searchParams, structureParams }) }), $[0] = documentId, $[1] = documentType, $[2] = onFocusPath, $[3] = onStructureParams, $[4] = searchParams, $[5] = structureParams, $[6] = t0) : t0 = $[6], t0; } function usePreviewState(documentId, schemaType) { const $ = reactCompilerRuntime.c(7), documentPreviewStore = sanity.useDocumentPreviewStore(); let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0]; const [preview, setPreview] = React.useState(t0), { perspectiveStack } = sanity.usePerspective(); let t1, t2; return $[1] !== documentId || $[2] !== documentPreviewStore || $[3] !== perspectiveStack || $[4] !== schemaType ? (t1 = () => { if (!schemaType) return; const subscription = sanity.getPreviewStateObservable(documentPreviewStore, schemaType, documentId, perspectiveStack).subscribe((state) => { setPreview(state); }); return () => { subscription?.unsubscribe(); }; }, t2 = [documentPreviewStore, schemaType, documentId, perspectiveStack], $[1] = documentId, $[2] = documentPreviewStore, $[3] = perspectiveStack, $[4] = schemaType, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), React.useEffect(t1, t2), preview; } function ContentEditor(props) { const $ = reactCompilerRuntime.c(38), { documentId, documentType, mainDocumentState, onFocusPath, onStructureParams, refs, searchParams, structureParams } = props, { t } = sanity.useTranslation(presentation.presentationLocaleNamespace), schema = sanity.useSchema(); let t0; $[0] !== mainDocumentState?.document?._id || $[1] !== mainDocumentState?.document?._type || $[2] !== searchParams ? (t0 = (props_0) => /* @__PURE__ */ jsxRuntime.jsx(router.StateLink, { ...props_0, state: { id: mainDocumentState?.document?._id, type: mainDocumentState?.document?._type, _searchParams: Object.entries(searchParams) } }), $[0] = mainDocumentState?.document?._id, $[1] = mainDocumentState?.document?._type, $[2] = searchParams, $[3] = t0) : t0 = $[3]; const MainDocumentLink = t0; let t1, t2; $[4] !== mainDocumentState?.document?._type || $[5] !== schema ? (t2 = schema.get(mainDocumentState?.document?._type || "shoe"), $[4] = mainDocumentState?.document?._type, $[5] = schema, $[6] = t2) : t2 = $[6], t1 = t2; const schemaType = t1, previewState = usePreviewState(mainDocumentState?.document?._id || "", schemaType); let t3; bb0: { if (!mainDocumentState?.document) { t3 = null; break bb0; } let t42; $[7] !== mainDocumentState.document || $[8] !== previewState.snapshot ? (t42 = sanity.getPreviewValueWithFallback({ snapshot: previewState.snapshot, fallback: mainDocumentState.document }), $[7] = mainDocumentState.document, $[8] = previewState.snapshot, $[9] = t42) : t42 = $[9]; let t52; $[10] !== t ? (t52 = t("main-document.label"), $[10] = t, $[11] = t52) : t52 = $[11]; let t62; $[12] !== t52 ? (t62 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 1, radius: 2, shadow: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 0, weight: "medium", children: t52 }) }), $[12] = t52, $[13] = t62) : t62 = $[13]; let t7; $[14] !== schemaType || $[15] !== t42 || $[16] !== t62 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(sanity.SanityDefaultPreview, { ...t42, schemaType, status: t62 }), $[14] = schemaType, $[15] = t42, $[16] = t62, $[17] = t7) : t7 = $[17], t3 = t7; } const preview = t3; if (documentId && documentType) { let t42; return $[18] !== documentId || $[19] !== documentType || $[20] !== onFocusPath || $[21] !== onStructureParams || $[22] !== searchParams || $[23] !== structureParams ? (t42 = /* @__PURE__ */ jsxRuntime.jsx(DocumentPanel, { documentId, documentType, onFocusPath, onStructureParams, searchParams, structureParams }), $[18] = documentId, $[19] = documentType, $[20] = onFocusPath, $[21] = onStructureParams, $[22] = searchParams, $[23] = structureParams, $[24] = t42) : t42 = $[24], t42; } let t4; $[25] !== MainDocumentLink || $[26] !== mainDocumentState || $[27] !== preview || $[28] !== t ? (t4 = mainDocumentState && /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 3, tone: mainDocumentState.document ? "inherit" : "caution", children: mainDocumentState.document ? /* @__PURE__ */ jsxRuntime.jsx(sanity.PreviewCard, { __unstable_focusRing: !0, as: MainDocumentLink, "data-as": "a", radius: 2, sizing: "border", tone: "inherit", children: preview }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 2, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, children: [ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningOutlineIcon, {}) }) }), /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { t, i18nKey: "main-document.missing.text", components: { Code: "code" }, values: { path: mainDocumentState.path } }) }) }) ] }) }) }), $[25] = MainDocumentLink, $[26] = mainDocumentState, $[27] = preview, $[28] = t, $[29] = t4) : t4 = $[29]; let t5; $[30] !== mainDocumentState || $[31] !== onStructureParams || $[32] !== refs || $[33] !== searchParams ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(DocumentListPane, { mainDocumentState, onStructureParams, searchParams, refs }), $[30] = mainDocumentState, $[31] = onStructureParams, $[32] = refs, $[33] = searchParams, $[34] = t5) : t5 = $[34]; let t6; return $[35] !== t4 || $[36] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", flex: 1, height: "fill", children: [ t4, t5 ] }), $[35] = t4, $[36] = t5, $[37] = t6) : t6 = $[37], t6; } function usePanelId(id) { const $ = reactCompilerRuntime.c(2); let t0; $[0] !== id ? (t0 = () => id || uuid.v4(), $[0] = id, $[1] = t0) : t0 = $[1]; const [panelId] = React.useState(t0); return panelId; } const Resizer = styledComponents.styled.div` position: relative; `, ResizerInner = styledComponents.styled.div` position: absolute; top: 0; bottom: 0; left: -5px; width: 9px; z-index: 10; cursor: ${({ $disabled }) => $disabled ? "auto" : "ew-resize"}; /* Border */ & > span:nth-child(1) { display: block; border-left: 1px solid var(--card-border-color); position: absolute; top: 0; left: 4px; bottom: 0; transition: opacity 200ms; } ${({ $disabled }) => !$disabled && ` /* Hover effect */ & > span:nth-child(2) { display: block; position: absolute; top: 0; left: 0; width: 9px; bottom: 0; background-color: var(--card-border-color); opacity: 0; transition: opacity 150ms; } @media (hover: hover) { &:hover > span:nth-child(2) { opacity: 0.2; } } `} `, PanelResizer = function(t0) { const $ = reactCompilerRuntime.c(27), { id: propId, order, disabled: t1 } = t0, disabled = t1 === void 0 ? !1 : t1, el = React.useRef(null), context = React.useContext(_singletons.PresentationPanelsContext); if (context === null) throw Error("Panel components must be rendered within a PanelGroup container"); const id = usePanelId(propId), { activeResizer, drag, startDragging, stopDragging, registerElement, unregisterElement } = context, isDragging = activeResizer === id; if (context === null) throw Error("Panel components must be rendered within a PanelGroup container"); let t2; $[0] !== id || $[1] !== startDragging ? (t2 = (event) => { startDragging(id, event.nativeEvent); }, $[0] = id, $[1] = startDragging, $[2] = t2) : t2 = $[2]; const onMouseDown = t2; let t3; $[3] !== drag || $[4] !== id ? (t3 = (e) => { drag(id, e); }, $[3] = drag, $[4] = id, $[5] = t3) : t3 = $[5]; const onDrag = t3; let t4; $[6] !== stopDragging ? (t4 = () => { el.current.blur(), stopDragging(); }, $[6] = stopDragging, $[7] = t4) : t4 = $[7]; const onDragStop = t4; let t5, t6; $[8] !== disabled || $[9] !== isDragging || $[10] !== onDrag || $[11] !== onDragStop ? (t5 = () => { if (!isDragging || disabled) return; const resetDocumentStyles = function() { const bodyStyle = document.body.style, documentStyle = document.documentElement.style, { cursor } = documentStyle, { userSelect } = bodyStyle; return documentStyle.cursor = "ew-resize", bodyStyle.userSelect = "none", () => { cursor ? documentStyle.cursor = cursor : documentStyle.removeProperty("cursor"), userSelect ? bodyStyle.userSelect = userSelect : bodyStyle.removeProperty("user-select"); }; }(); return window.addEventListener("mousemove", onDrag), window.addEventListener("mouseup", onDragStop), window.addEventListener("contextmenu", onDragStop), () => { resetDocumentStyles(), window.removeEventListener("mousemove", onDrag), window.removeEventListener("mouseup", onDragStop), window.removeEventListener("contextmenu", onDragStop); }; }, t6 = [disabled, isDragging, onDrag, onDragStop], $[8] = disabled, $[9] = isDragging, $[10] = onDrag, $[11] = onDragStop, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), React.useEffect(t5, t6); let t7, t8; $[14] !== id || $[15] !== order || $[16] !== registerElement || $[17] !== unregisterElement ? (t7 = () => (registerElement(id, { id, order, type: "resizer", el }), () => { unregisterElement(id); }), t8 = [id, order, registerElement, unregisterElement], $[14] = id, $[15] = order, $[16] = registerElement, $[17] = unregisterElement, $[18] = t7, $[19] = t8) : (t7 = $[18], t8 = $[19]), React.useLayoutEffect(t7, t8); let t10, t9; $[20] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsxRuntime.jsx("span", {}), t10 = /* @__PURE__ */ jsxRuntime.jsx("span", {}), $[20] = t10, $[21] = t9) : (t10 = $[20], t9 = $[21]); let t11; $[22] !== disabled ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs(ResizerInner, { $disabled: disabled, children: [ t9, t10 ] }), $[22] = disabled, $[23] = t11) : t11 = $[23]; let t12; return $[24] !== onMouseDown || $[25] !== t11 ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(Resizer, { onMouseDown, ref: el, children: t11 }), $[24] = onMouseDown, $[25] = t11, $[26] = t12) : t12 = $[26], t12; }, PresentationContentWrapper = (props) => { const $ = reactCompilerRuntime.c(8), { documentId, setDisplayedDocument, getCommentIntent } = props; let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(PanelResizer, { order: 4 }), $[0] = t0) : t0 = $[0]; let t1; $[1] !== getCommentIntent || $[2] !== props.children ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(sanity.CommentsIntentProvider, { getIntent: getCommentIntent, children: props.children }), $[1] = getCommentIntent, $[2] = props.children, $[3] = t1) : t1 = $[3]; let t2; return $[4] !== documentId || $[5] !== setDisplayedDocument || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ t0, /* @__PURE__ */ jsxRuntime.jsx(Panel, { id: "content", minWidth: 325, order: 5, children: /* @__PURE__ */ jsxRuntime.jsx(DisplayedDocumentBroadcaster.DisplayedDocumentBroadcasterProvider, { documentId, setDisplayedDocument, children: t1 }) }) ] }), $[4] = documentId, $[5] = setDisplayedDocument, $[6] = t1, $[7] = t2) : t2 = $[7], t2; }, PresentationContent = (props) => { const $ = reactCompilerRuntime.c(14), { documentId, documentsOnPage, documentType, getCommentIntent, mainDocumentState, onFocusPath, onStructureParams, searchParams, setDisplayedDocument, structureParams } = props; let t0; $[0] !== documentId || $[1] !== documentType || $[2] !== documentsOnPage || $[3] !== mainDocumentState || $[4] !== onFocusPath || $[5] !== onStructureParams || $[6] !== searchParams || $[7] !== structureParams ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(ContentEditor, { documentId, documentType, mainDocumentState, onFocusPath, onStructureParams, refs: documentsOnPage, searchParams, structureParams }), $[0] = documentId, $[1] = documentType, $[2] = documentsOnPage, $[3] = mainDocumentState, $[4] = onFocusPath, $[5] = onStructureParams, $[6] = searchParams, $[7] = structureParams, $[8] = t0) : t0 = $[8]; let t1; return $[9] !== documentId || $[10] !== getCommentIntent || $[11] !== setDisplayedDocument || $[12] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(PresentationContentWrapper, { documentId, getCommentIntent, setDisplayedDocument, children: t0 }), $[9] = documentId, $[10] = getCommentIntent, $[11] = setDisplayedDocument, $[12] = t0, $[13] = t1) : t1 = $[13], t1; }, PresentationNavigateProvider = function(props) { const $ = reactCompilerRuntime.c(5), { children, navigate: _navigate } = props; let t0; $[0] !== _navigate ? (t0 = (preview, t12) => { _navigate((t12 === void 0 ? void 0 : t12) || {}, preview ? { preview } : {}); }, $[0] = _navigate, $[1] = t0) : t0 = $[1]; const navigate = t0; let t1; return $[2] !== children || $[3] !== navigate ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.PresentationNavigateContext.Provider, { value: navigate, children }), $[2] = children, $[3] = navigate, $[4] = t1) : t1 = $[4], t1; }; function useLocalState(key, defaultValue) { const $ = reactCompilerRuntime.c(9); let t0; $[0] !== defaultValue || $[1] !== key ? (t0 = () => JSON.p