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,047 lines (1,044 loc) • 172 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )); var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), react = require("@xstate/react"), presentation = require("./presentation.js"), comlink = require("@sanity/comlink"), presentationComlink = require("@sanity/presentation-comlink"), constants = require("@sanity/preview-url-secret/constants"), ui = require("@sanity/ui"), React = require("react"), sanity = require("sanity"), router = require("sanity/router"), styledComponents = require("styled-components"), useEffectEvent = require("use-effect-event"), xstate = require("xstate"), _singletons = require("sanity/_singletons"), icons = require("@sanity/icons"), structure = require("sanity/structure"), TooltipDelayGroupProvider = require("./TooltipDelayGroupProvider.js"); require("../_singletons.js"); var PathUtils = require("@sanity/util/paths"), StructureToolProvider = require("./StructureToolProvider.js"), csm = require("@sanity/client/csm"), 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"), createSecret = require("@sanity/preview-url-secret/create-secret"), uuid$1 = require("@sanity/uuid"), rxjs = require("rxjs"), 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$f), 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$f() { return { features: { optimistic: !0 } }; } const presentationMachine = xstate.setup({ types: {}, actions: { // }, actors: { // }, guards: { // } }).createMachine({ // eslint-disable-next-line tsdoc/syntax /** @xstate-layout N4IgpgJg5mDOIC5QAUBOcwDsAuBDbAlgPaYAEAKkUQDYDEBAZqrgLZinrVG4QDaADAF1EoAA5FYBQiREgAHogAsAJgA0IAJ6IAHAEYAdIoCcJowFY9R-vzPLlAX3vq0GHPmJlKNfVx4FMUPRMrOy+EJACwkgg4pLSmLIKCLoAbIr6Zoop2tqKAMxpJnnF6loIZkbK+uZ5umapKXmK-Cm6js7osFh48RRU1D7c4RC02ERQUNTsAG4EsACuuNSkkFL+UKRE02Co1LgasJGysWsy0UnaZinVyrpGAOx1Rim2efeliPe3hma1Zvy6XT8W4OJwgFxdNy9LwDMKQILMNgcMBMOAACyO0RO8USiAK930LWU-3uiiB9yaKXemkQjW01V+txS-GKqUe7XBnW67hIfW8cJGjER7E4Q0xYgkpwS5zxVMJKWJ-FJ5Mp1LKFn4Pz+DSaLTaYIh3Oh-UGPEg+nQqNgaPWCJCpAF4pikpxMoQKWZ+gp+TSZLy1hSH3deXpNSZLNqVP1HVcPQ8fNhQ3Nor8ATtSMdQmOLo8uPdnu9BUUfoDQY1WrqOuarUcYMwRHC8Gihqh8Zh2biubdAFpAzSEL2OS247yYfodqgiKgO1K8yog7ptATFL9dFljMDrHkh1zW6OTWF1jPXaAkmY1YgKnktfxtC9dPd+Io9DvYzzPAekxBj13T3i7vKirKkqqpBsYVQ1HUFjFs0t6KK+kIjh+-JfvoBAQFMP5nH+CDaMo16KjYyjMvUNh5GWOT6MoLL8A8ygrk0dQIUabafmaEAWiinQ2gEWHSjhjJUYuj73Pcd63noQaNEYFb-Dk2S0cxe7IYm7GcYevFYjm2HyJeeQQb8tFkikVjGNoFGajUt73o+z61vYQA */ id: "Presentation Tool", context: { url: null, error: null, visualEditingOverlaysEnabled: !1 }, on: { "iframe reload": { actions: xstate.assign({ url: null }), target: ".loading" } }, states: { error: { description: "Failed to load, either because of a misconfiguration, a network error, or an unexpected error", tags: ["error"] }, loading: { on: { "iframe loaded": { target: "loaded" } }, tags: ["busy"] }, loaded: { on: { "toggle visual editing overlays": { actions: xstate.assign({ visualEditingOverlaysEnabled: ({ event }) => event.enabled }) }, "iframe refresh": { target: ".refreshing" }, "iframe reload": { target: ".reloading" } }, states: { idle: {}, refreshing: { on: { "iframe loaded": { target: "idle" } }, tags: ["busy"] }, reloading: { on: { "iframe loaded": { target: "idle" } }, tags: ["busy"] } }, initial: "idle" } }, initial: "loading" }), 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; }; function debounce(fn, timeout) { let timer; return (...args) => { clearTimeout(timer), timer = setTimeout(() => { fn.apply(fn, args); }, timeout); }; } const 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$8, set = _temp3$4; 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$4(panels_0, widths) { const stored_0 = getStoredItem(), key_0 = getKeyForPanels(panels_0), data = { ...stored_0, [key_0]: widths }; setStoredItem(data); } function _temp2$8(panels) { const stored = getStoredItem(), key = getKeyForPanels(panels); return Array.isArray(stored[key]) && stored[key].some(_temp$e) ? void 0 : stored[key]; } function _temp$e(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; } const ChildLink = React.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(17); let childId, childParameters, childType, rest, searchParams; if ($[0] !== props) { const { childId: t02, childType: t12, childPayload, childParameters: t22, searchParams: t3, ...t4 } = props; childId = t02, childType = t12, childParameters = t22, searchParams = t3, rest = t4, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childType, $[4] = rest, $[5] = searchParams; } else childId = $[1], childParameters = $[2], childType = $[3], rest = $[4], searchParams = $[5]; let t0; $[6] !== childParameters || $[7] !== searchParams ? (t0 = Object.entries({ ...searchParams, ...childParameters }), $[6] = childParameters, $[7] = searchParams, $[8] = t0) : t0 = $[8]; let t1; $[9] !== childId || $[10] !== childType || $[11] !== t0 ? (t1 = { id: childId, type: childType, _searchParams: t0 }, $[9] = childId, $[10] = childType, $[11] = t0, $[12] = t1) : t1 = $[12]; let t2; return $[13] !== ref || $[14] !== rest || $[15] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(router.StateLink, { ...rest, ref, state: t1 }), $[13] = ref, $[14] = rest, $[15] = t1, $[16] = t2) : t2 = $[16], t2; }), ReferenceChildLink = React.forwardRef(function(props, ref) { const $ = reactCompilerRuntime.c(22); let documentId, documentType, parentRefPath, rest, searchParams, template; $[0] !== props ? ({ documentId, documentType, parentRefPath, template, searchParams, ...rest } = props, $[0] = props, $[1] = documentId, $[2] = documentType, $[3] = parentRefPath, $[4] = rest, $[5] = searchParams, $[6] = template) : (documentId = $[1], documentType = $[2], parentRefPath = $[3], rest = $[4], searchParams = $[5], template = $[6]); const t0 = template?.params; let t1; $[7] !== parentRefPath ? (t1 = sanity.pathToString(parentRefPath), $[7] = parentRefPath, $[8] = t1) : t1 = $[8]; let t2; $[9] !== template ? (t2 = template && { template: template?.id }, $[9] = template, $[10] = t2) : t2 = $[10]; let t3; $[11] !== t1 || $[12] !== t2 ? (t3 = { parentRefPath: t1, ...t2 }, $[11] = t1, $[12] = t2, $[13] = t3) : t3 = $[13]; let t4; return $[14] !== documentId || $[15] !== documentType || $[16] !== ref || $[17] !== rest || $[18] !== searchParams || $[19] !== t0 || $[20] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(ChildLink, { ...rest, ref, childId: documentId, childType: documentType, childPayload: t0, childParameters: t3, searchParams }), $[14] = documentId, $[15] = documentType, $[16] = ref, $[17] = rest, $[18] = searchParams, $[19] = t0, $[20] = t3, $[21] = t4) : t4 = $[21], t4; }); 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; }); function PresentationPaneRouterProvider(props) { const $ = reactCompilerRuntime.c(28), { children, onEditReference, 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 = React.forwardRef(function(childLinkProps, ref) { const { childId, ...rest } = childLinkProps, doc = refs?.find((r) => r._id === childId || sanity.getPublishedId(r._id) === childId); return doc ? /* @__PURE__ */ jsxRuntime.jsx(ChildLink, { ...rest, ref, childId, childType: doc._type, searchParams }) : (console.warn(`ChildLink: No document found for childId "${childId}"`), null); }), $[8] = refs, $[9] = searchParams, $[10] = t6) : t6 = $[10]; let t7; $[11] !== searchParams ? (t7 = React.forwardRef(function(backLinkProps, ref_0) { return /* @__PURE__ */ jsxRuntime.jsx(BackLink, { ...backLinkProps, ref: ref_0, searchParams }); }), $[11] = searchParams, $[12] = t7) : t7 = $[12]; let t8; $[13] !== searchParams ? (t8 = React.forwardRef(function(childLinkProps_0, ref_1) { return /* @__PURE__ */ jsxRuntime.jsx(ReferenceChildLink, { ...childLinkProps_0, ref: ref_1, searchParams }); }), $[13] = searchParams, $[14] = t8) : t8 = $[14]; let t9; $[15] !== onEditReference ? (t9 = (options) => { const { id, template, type, parentRefPath, version } = options; onEditReference({ state: { id, type }, params: { template: template.id, parentRefPath: PathUtils.toString(parentRefPath), version } }); }, $[15] = onEditReference, $[16] = t9) : t9 = $[16]; let t10; $[17] !== createPathWithParams || $[18] !== onStructureParams || $[19] !== t4 || $[20] !== t6 || $[21] !== t7 || $[22] !== t8 || $[23] !== 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$d, closeCurrentAndAfter: _temp2$7, handleEditReference: t9, replaceCurrent: _temp3$3, closeCurrent: _temp4$2, duplicateCurrent: _temp5$2, setView: _temp6$1, setParams: onStructureParams, setPayload: _temp7$1, navigateIntent: _temp8, createPathWithParams }, $[17] = createPathWithParams, $[18] = onStructureParams, $[19] = t4, $[20] = t6, $[21] = t7, $[22] = t8, $[23] = t9, $[24] = t10) : t10 = $[24], t2 = t10; const context = t2; let t11; return $[25] !== children || $[26] !== context ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(structure.PaneRouterContext.Provider, { value: context, children }), $[25] = children, $[26] = context, $[27] = t11) : t11 = $[27], t11; } function _temp8(intentName, intentParams, options_0) { console.warn("navigateIntent", intentName, intentParams, options_0); } function _temp7$1(payload) { console.warn("setPayload", payload); } function _temp6$1(viewId) { console.warn("setView", viewId); } function _temp5$2(pane_0) { console.warn("duplicateCurrent", pane_0); } function _temp4$2() { console.warn("closeCurrent"); } function _temp3$3(pane) { console.warn("replaceCurrent", pane); } function _temp2$7() { console.warn("closeCurrentAndAfter"); } function _temp$d() { 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(34), { mainDocumentState, onEditReference, 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$c), $[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$6); 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] !== onEditReference || $[28] !== onStructureParams || $[29] !== refs || $[30] !== searchParams || $[31] !== structureParams || $[32] !== 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, { onEditReference, onStructureParams, structureParams, searchParams, refs, children: t9 }) }) }) }), $[27] = onEditReference, $[28] = onStructureParams, $[29] = refs, $[30] = searchParams, $[31] = structureParams, $[32] = t9, $[33] = t10) : t10 = $[33], t10; } function _temp2$6() { return {}; } function _temp$c(r_0) { return sanity.getPublishedId(r_0._id); } const WrappedCode = styledComponents.styled(ui.Code)` white-space: pre-wrap; `; function DocumentPane(props) { const $ = reactCompilerRuntime.c(40), { documentId, documentType, onFocusPath, onEditReference, 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; let t4; $[10] !== documentId || $[11] !== documentType || $[12] !== onFocusPath ? (t4 = (path) => onFocusPath({ id: documentId, type: documentType, path: csm.studioPath.toString(path) }), $[10] = documentId, $[11] = documentType, $[12] = onFocusPath, $[13] = t4) : t4 = $[13]; const handleFocusPath = t4, [errorParams, setErrorParams] = React.useState(null); let t5; $[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => setErrorParams(null), $[14] = t5) : t5 = $[14]; const handleRetry = t5; let t6; $[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => { setErrorParams(null); }, $[15] = t6) : t6 = $[15]; let t7; if ($[16] !== documentId || $[17] !== documentType || $[18] !== structureParams ? (t7 = [documentId, documentType, structureParams], $[16] = documentId, $[17] = documentType, $[18] = structureParams, $[19] = t7) : t7 = $[19], React.useEffect(t6, t7), errorParams) { let t82; $[20] !== t ? (t82 = t("document-pane.error.text"), $[20] = t, $[21] = t82) : t82 = $[21]; let t92; $[22] !== devMode || $[23] !== errorParams || $[24] !== t ? (t92 = 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 }) ] }) }), $[22] = devMode, $[23] = errorParams, $[24] = t, $[25] = t92) : t92 = $[25]; let t102; return $[26] !== t82 || $[27] !== t92 ? (t102 = /* @__PURE__ */ jsxRuntime.jsx(ErrorCard, { flex: 1, message: t82, onRetry: handleRetry, children: t92 }), $[26] = t82, $[27] = t92, $[28] = t102) : t102 = $[28], t102; } let t8; $[29] === Symbol.for("react.memo_cache_sentinel") ? (t8 = { height: "100%" }, $[29] = t8) : t8 = $[29]; let t9; $[30] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(presentation.PresentationSpinner, {}), $[30] = t9) : t9 = $[30]; let t10; $[31] !== handleFocusPath || $[32] !== paneDocumentNode ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: t9, children: /* @__PURE__ */ jsxRuntime.jsx(structure.DocumentPane, { paneKey: "document", index: 1, itemId: "document", pane: paneDocumentNode, onFocusPath: handleFocusPath }) }), $[31] = handleFocusPath, $[32] = paneDocumentNode, $[33] = t10) : t10 = $[33]; let t11; return $[34] !== onEditReference || $[35] !== onStructureParams || $[36] !== searchParams || $[37] !== structureParams || $[38] !== t10 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsxRuntime.jsx(structure.PaneLayout, { style: t8, children: /* @__PURE__ */ jsxRuntime.jsx(PresentationPaneRouterProvider, { searchParams, onEditReference, onStructureParams, structureParams, children: t10 }) }) }), $[34] = onEditReference, $[35] = onStructureParams, $[36] = searchParams, $[37] = structureParams, $[38] = t10, $[39] = t11) : t11 = $[39], t11; } function DocumentPanel(props) { const $ = reactCompilerRuntime.c(8), { documentId, documentType, onFocusPath, onEditReference, onStructureParams, searchParams, structureParams } = props; let t0; return $[0] !== documentId || $[1] !== documentType || $[2] !== onEditReference || $[3] !== onFocusPath || $[4] !== onStructureParams || $[5] !== searchParams || $[6] !== structureParams ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(StructureToolProvider.StructureToolProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentPane, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }) }), $[0] = documentId, $[1] = documentType, $[2] = onEditReference, $[3] = onFocusPath, $[4] = onStructureParams, $[5] = searchParams, $[6] = structureParams, $[7] = t0) : t0 = $[7], 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(40), { documentId, documentType, mainDocumentState, onEditReference, 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] !== onEditReference || $[21] !== onFocusPath || $[22] !== onStructureParams || $[23] !== searchParams || $[24] !== structureParams ? (t42 = /* @__PURE__ */ jsxRuntime.jsx(DocumentPanel, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }), $[18] = documentId, $[19] = documentType, $[20] = onEditReference, $[21] = onFocusPath, $[22] = onStructureParams, $[23] = searchParams, $[24] = structureParams, $[25] = t42) : t42 = $[25], t42; } let t4; $[26] !== MainDocumentLink || $[27] !== mainDocumentState || $[28] !== preview || $[29] !== 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 } }) }) }) ] }) }) }), $[26] = MainDocumentLink, $[27] = mainDocumentState, $[28] = preview, $[29] = t, $[30] = t4) : t4 = $[30]; let t5; $[31] !== mainDocumentState || $[32] !== onEditReference || $[33] !== onStructureParams || $[34] !== refs || $[35] !== searchParams ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(DocumentListPane, { mainDocumentState, onEditReference, onStructureParams, searchParams, refs }), $[31] = mainDocumentState, $[32] = onEditReference, $[33] = onStructureParams, $[34] = refs, $[35] = searchParams, $[36] = t5) : t5 = $[36]; let t6; return $[37] !== t4 || $[38] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", flex: 1, height: "fill", children: [ t4, t5 ] }), $[37] = t4, $[38] = t5, $[39] = t6) : t6 = $[39], 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"); cons