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
870 lines (859 loc) • 527 kB
JavaScript
"use strict";
var StructureToolProvider = require("./StructureToolProvider.js"), TooltipDelayGroupProvider = require("./TooltipDelayGroupProvider.js");
require("../_singletons.js");
var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), ui = require("@sanity/ui"), React = require("react"), _singletons = require("sanity/_singletons"), icons = require("@sanity/icons"), sanity = require("sanity"), uuid = require("@sanity/uuid"), styledComponents = require("styled-components"), framerMotion = require("framer-motion"), reactRx = require("react-rx"), router$1 = require("sanity/router"), omit = require("lodash/omit.js"), PathUtils = require("@sanity/util/paths"), rxjs = require("rxjs"), fromPairs = require("lodash/fromPairs.js"), toPairs = require("lodash/toPairs.js"), ScrollMirror = require("scrollmirror"), noop = require("lodash/noop.js"), deepEquals = require("react-fast-compare"), operators = require("rxjs/operators"), isHotkeyEsm = require("is-hotkey-esm"), reactI18next = require("react-i18next"), reactJsonInspector = require("@rexxars/react-json-inspector"), QuickLRU = require("quick-lru"), react = require("@sanity/telemetry/react"), telemetry = require("@sanity/telemetry"), dateFns = require("date-fns"), useEffectEvent = require("use-effect-event"), theme = require("@sanity/ui/theme"), types = require("@sanity/types"), isEqual = require("lodash/isEqual.js"), shallowEquals = require("shallow-equals"), uniqBy = require("lodash/uniqBy.js"), negate = require("lodash/negate.js"), MenuGroup = require("./MenuGroup.js"), groqJs = require("groq-js"), observableCallback = require("observable-callback"), rxjsExhaustmapWithTrailing = require("rxjs-exhaustmap-with-trailing"), reactTable = require("@tanstack/react-table");
function _interopDefaultCompat(e) {
return e && typeof e == "object" && "default" in e ? e : { default: e };
}
function _interopNamespaceCompat(e) {
if (e && typeof e == "object" && "default" in e) return e;
var n = /* @__PURE__ */ Object.create(null);
return e && Object.keys(e).forEach(function(k) {
if (k !== "default") {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: !0,
get: function() {
return e[k];
}
});
}
}), n.default = e, Object.freeze(n);
}
var omit__default = /* @__PURE__ */ _interopDefaultCompat(omit), PathUtils__namespace = /* @__PURE__ */ _interopNamespaceCompat(PathUtils), fromPairs__default = /* @__PURE__ */ _interopDefaultCompat(fromPairs), toPairs__default = /* @__PURE__ */ _interopDefaultCompat(toPairs), ScrollMirror__default = /* @__PURE__ */ _interopDefaultCompat(ScrollMirror), noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), deepEquals__default = /* @__PURE__ */ _interopDefaultCompat(deepEquals), QuickLRU__default = /* @__PURE__ */ _interopDefaultCompat(QuickLRU), isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), shallowEquals__default = /* @__PURE__ */ _interopDefaultCompat(shallowEquals), uniqBy__default = /* @__PURE__ */ _interopDefaultCompat(uniqBy), negate__default = /* @__PURE__ */ _interopDefaultCompat(negate);
function DocTitle(props) {
const $ = reactCompilerRuntime.c(21), {
document: documentValue
} = props, schema = sanity.useSchema();
let t0;
$[0] !== documentValue._type || $[1] !== schema ? (t0 = schema.get(documentValue._type), $[0] = documentValue._type, $[1] = schema, $[2] = t0) : t0 = $[2];
const schemaType = t0, {
t
} = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace);
let t1;
$[3] !== documentValue || $[4] !== schemaType ? (t1 = {
schemaType,
value: documentValue
}, $[3] = documentValue, $[4] = schemaType, $[5] = t1) : t1 = $[5];
const {
error,
value
} = sanity.unstable_useValuePreview(t1);
if (!schemaType) {
let t22;
$[6] !== documentValue._type || $[7] !== t ? (t22 = t("doc-title.unknown-schema-type.text", {
schemaType: documentValue._type
}), $[6] = documentValue._type, $[7] = t, $[8] = t22) : t22 = $[8];
let t32;
return $[9] !== t22 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx("code", { children: t22 }), $[9] = t22, $[10] = t32) : t32 = $[10], t32;
}
if (error) {
let t22;
$[11] !== error.message || $[12] !== t ? (t22 = t("doc-title.error.text", {
errorMessage: error.message
}), $[11] = error.message, $[12] = t, $[13] = t22) : t22 = $[13];
let t32;
return $[14] !== t22 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: t22 }), $[14] = t22, $[15] = t32) : t32 = $[15], t32;
}
let t2;
$[16] !== t || $[17] !== value?.title ? (t2 = value?.title || /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
color: "var(--card-muted-fg-color)"
}, children: t("doc-title.fallback.text") }), $[16] = t, $[17] = value?.title, $[18] = t2) : t2 = $[18];
let t3;
return $[19] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: t2 }), $[19] = t2, $[20] = t3) : t3 = $[20], t3;
}
const ChevronWrapper = styledComponents.styled(ui.Box)`
margin-left: auto;
`, CrossDatasetReferencesDetails = styledComponents.styled.details`
flex: none;
&[open] ${ChevronWrapper} {
transform: rotate(180deg);
}
`, CrossDatasetReferencesSummary = styledComponents.styled.summary`
list-style: none;
&::-webkit-details-marker {
display: none;
}
`, Table$1 = styledComponents.styled.table`
width: 100%;
text-align: left;
padding: 0 ${({
theme: theme2
}) => ui.rem(theme2.sanity.space[2])};
border-collapse: collapse;
th {
padding: ${({
theme: theme2
}) => ui.rem(theme2.sanity.space[1])};
}
td {
padding: 0 ${({
theme: theme2
}) => ui.rem(theme2.sanity.space[1])};
}
tr > *:last-child {
text-align: right;
}
`, DocumentIdFlex = styledComponents.styled(ui.Flex)`
min-height: 33px;
`, OtherReferenceCount = (props) => {
const $ = reactCompilerRuntime.c(13), {
t
} = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace), difference = props.totalCount - props.references.length;
if (!difference)
return null;
let t0;
$[0] !== difference || $[1] !== t ? (t0 = t("confirm-delete-dialog.other-reference-count.title", {
count: difference
}), $[0] = difference, $[1] = t, $[2] = t0) : t0 = $[2];
let t1;
$[3] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: t0 }), $[3] = t0, $[4] = t1) : t1 = $[4];
let t2;
$[5] !== t ? (t2 = t("confirm-delete-dialog.other-reference-count.tooltip"), $[5] = t, $[6] = t2) : t2 = $[6];
let t3;
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: /* @__PURE__ */ jsxRuntime.jsx(icons.InfoOutlineIcon, {}) }), $[7] = t3) : t3 = $[7];
let t4;
$[8] !== t2 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { portal: !0, placement: "top", content: t2, children: t3 }), $[8] = t2, $[9] = t4) : t4 = $[9];
let t5;
return $[10] !== t1 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Inline, { space: 2, children: [
t1,
t4
] }) }), $[10] = t1, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
};
function PaneItemPreview(props) {
const $ = reactCompilerRuntime.c(27), {
icon,
layout,
presence,
schemaType,
value
} = props, versionsInfo = sanity.useDocumentVersionInfo(value._id), {
perspectiveStack
} = sanity.usePerspective();
let t0, t1;
$[0] !== perspectiveStack || $[1] !== props.documentPreviewStore || $[2] !== schemaType || $[3] !== value._id ? (t1 = sanity.getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, perspectiveStack), $[0] = perspectiveStack, $[1] = props.documentPreviewStore, $[2] = schemaType, $[3] = value._id, $[4] = t1) : t1 = $[4], t0 = t1;
const previewStateObservable = t0;
let t2;
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
snapshot: null,
isLoading: !0,
original: null
}, $[5] = t2) : t2 = $[5];
const {
snapshot,
original,
isLoading: previewIsLoading
} = reactRx.useObservable(previewStateObservable, t2), isLoading = previewIsLoading;
let t3;
$[6] !== isLoading || $[7] !== presence || $[8] !== versionsInfo.draft || $[9] !== versionsInfo.published || $[10] !== versionsInfo.versions ? (t3 = isLoading ? null : /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.TooltipDelayGroupProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, children: [
presence && presence.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(sanity.DocumentPreviewPresence, { presence }),
/* @__PURE__ */ jsxRuntime.jsx(sanity.DocumentStatusIndicator, { draft: versionsInfo.draft, published: versionsInfo.published, versions: versionsInfo.versions })
] }) }), $[6] = isLoading, $[7] = presence, $[8] = versionsInfo.draft, $[9] = versionsInfo.published, $[10] = versionsInfo.versions, $[11] = t3) : t3 = $[11];
const status = t3;
let t4;
$[12] !== versionsInfo.draft || $[13] !== versionsInfo.published || $[14] !== versionsInfo.versions ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(sanity.DocumentStatus, { draft: versionsInfo.draft, published: versionsInfo.published, versions: versionsInfo.versions }), $[12] = versionsInfo.draft, $[13] = versionsInfo.published, $[14] = versionsInfo.versions, $[15] = t4) : t4 = $[15];
const tooltip = t4;
let t5;
$[16] !== original || $[17] !== snapshot || $[18] !== value ? (t5 = sanity.getPreviewValueWithFallback({
snapshot,
original,
fallback: value
}), $[16] = original, $[17] = snapshot, $[18] = value, $[19] = t5) : t5 = $[19];
let t6;
return $[20] !== icon || $[21] !== isLoading || $[22] !== layout || $[23] !== status || $[24] !== t5 || $[25] !== tooltip ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(sanity.SanityDefaultPreview, { ...t5, isPlaceholder: isLoading, icon, layout, status, tooltip }), $[20] = icon, $[21] = isLoading, $[22] = layout, $[23] = status, $[24] = t5, $[25] = tooltip, $[26] = t6) : t6 = $[26], t6;
}
const BackLink = React.forwardRef(function(props, ref) {
const $ = reactCompilerRuntime.c(9), {
routerPanesState,
groupIndex
} = React.useContext(_singletons.PaneRouterContext);
let t0, t1;
$[0] !== groupIndex || $[1] !== routerPanesState ? (t1 = routerPanesState.slice(0, groupIndex), $[0] = groupIndex, $[1] = routerPanesState, $[2] = t1) : t1 = $[2], t0 = t1;
const panes = t0;
let t2, t3;
$[3] !== panes ? (t3 = {
panes
}, $[3] = panes, $[4] = t3) : t3 = $[4], t2 = t3;
const state2 = t2;
let t4;
return $[5] !== props || $[6] !== ref || $[7] !== state2 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(router$1.StateLink, { ...props, ref, state: state2 }), $[5] = props, $[6] = ref, $[7] = state2, $[8] = t4) : t4 = $[8], t4;
});
function usePaneLayout() {
const pane2 = React.useContext(_singletons.PaneLayoutContext);
if (!pane2)
throw new Error("PaneLayout: missing context value");
return pane2;
}
const ChildLink = React.forwardRef(function(props, ref) {
const $ = reactCompilerRuntime.c(19);
let childId, childParameters, childPayload, rest;
$[0] !== props ? ({
childId,
childPayload,
childParameters,
...rest
} = props, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childPayload, $[4] = rest) : (childId = $[1], childParameters = $[2], childPayload = $[3], rest = $[4]);
const {
routerPanesState,
groupIndex
} = React.useContext(_singletons.PaneRouterContext);
let t0;
if ($[5] !== childId || $[6] !== childParameters || $[7] !== childPayload || $[8] !== groupIndex || $[9] !== routerPanesState) {
let t12;
$[11] !== childId || $[12] !== childParameters || $[13] !== childPayload ? (t12 = [{
id: childId,
params: childParameters,
payload: childPayload
}], $[11] = childId, $[12] = childParameters, $[13] = childPayload, $[14] = t12) : t12 = $[14], t0 = {
panes: [...routerPanesState.slice(0, groupIndex + 1), t12]
}, $[5] = childId, $[6] = childParameters, $[7] = childPayload, $[8] = groupIndex, $[9] = routerPanesState, $[10] = t0;
} else
t0 = $[10];
let t1;
return $[15] !== ref || $[16] !== rest || $[17] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(router$1.StateLink, { ...rest, ref, state: t0 }), $[15] = ref, $[16] = rest, $[17] = t0, $[18] = t1) : t1 = $[18], t1;
}), ParameterizedLink = React.forwardRef(function(props, ref) {
const $ = reactCompilerRuntime.c(22), {
routerPanesState: currentPanes,
groupIndex,
siblingIndex
} = React.useContext(_singletons.PaneRouterContext);
let params, payload, rest;
$[0] !== props ? ({
params,
payload,
...rest
} = props, $[0] = props, $[1] = params, $[2] = payload, $[3] = rest) : (params = $[1], payload = $[2], rest = $[3]);
const nextParams = sanity.useUnique(params), nextPayload = sanity.useUnique(payload);
let t0;
const currentGroup = currentPanes[groupIndex], currentSibling = currentGroup[siblingIndex], t1 = nextParams ?? currentSibling.params, t2 = nextPayload ?? currentSibling.payload;
let t3;
$[4] !== currentSibling || $[5] !== t1 || $[6] !== t2 ? (t3 = {
...currentSibling,
params: t1,
payload: t2
}, $[4] = currentSibling, $[5] = t1, $[6] = t2, $[7] = t3) : t3 = $[7];
const nextSibling = t3;
let t4;
$[8] !== currentGroup || $[9] !== nextSibling || $[10] !== siblingIndex ? (t4 = [...currentGroup.slice(0, siblingIndex), nextSibling, ...currentGroup.slice(siblingIndex + 1)], $[8] = currentGroup, $[9] = nextSibling, $[10] = siblingIndex, $[11] = t4) : t4 = $[11];
const nextGroup = t4;
let t5;
$[12] !== currentPanes || $[13] !== groupIndex || $[14] !== nextGroup ? (t5 = [...currentPanes.slice(0, groupIndex), nextGroup, ...currentPanes.slice(groupIndex + 1)], $[12] = currentPanes, $[13] = groupIndex, $[14] = nextGroup, $[15] = t5) : t5 = $[15];
const nextPanes = t5;
let t6;
$[16] !== nextPanes ? (t6 = {
panes: nextPanes
}, $[16] = nextPanes, $[17] = t6) : t6 = $[17], t0 = t6;
const nextState = t0;
let t7;
return $[18] !== nextState || $[19] !== ref || $[20] !== rest ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(router$1.StateLink, { ref, ...rest, state: nextState }), $[18] = nextState, $[19] = ref, $[20] = rest, $[21] = t7) : t7 = $[21], t7;
}), ReferenceChildLink = React.forwardRef(function(t0, ref) {
const $ = reactCompilerRuntime.c(22);
let children, documentId, documentType, parentRefPath, rest, template;
$[0] !== t0 ? ({
documentId,
documentType,
parentRefPath,
children,
template,
...rest
} = t0, $[0] = t0, $[1] = children, $[2] = documentId, $[3] = documentType, $[4] = parentRefPath, $[5] = rest, $[6] = template) : (children = $[1], documentId = $[2], documentType = $[3], parentRefPath = $[4], rest = $[5], template = $[6]);
const t1 = template?.params;
let t2;
$[7] !== parentRefPath ? (t2 = PathUtils.toString(parentRefPath), $[7] = parentRefPath, $[8] = t2) : t2 = $[8];
let t3;
$[9] !== template ? (t3 = template && {
template: template?.id
}, $[9] = template, $[10] = t3) : t3 = $[10];
let t4;
$[11] !== documentType || $[12] !== t2 || $[13] !== t3 ? (t4 = {
type: documentType,
parentRefPath: t2,
...t3
}, $[11] = documentType, $[12] = t2, $[13] = t3, $[14] = t4) : t4 = $[14];
let t5;
return $[15] !== children || $[16] !== documentId || $[17] !== ref || $[18] !== rest || $[19] !== t1 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(ChildLink, { ...rest, ref, childId: documentId, childPayload: t1, childParameters: t4, children }), $[15] = children, $[16] = documentId, $[17] = ref, $[18] = rest, $[19] = t1, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
});
function usePaneRouter() {
return React.useContext(_singletons.PaneRouterContext);
}
const EMPTY_ARRAY$1 = [];
function ReferencePreviewLink(props) {
const $ = reactCompilerRuntime.c(16), {
onClick,
type,
value
} = props, t0 = value?._id;
let t1;
$[0] !== t0 ? (t1 = sanity.getPublishedId(t0), $[0] = t0, $[1] = t1) : t1 = $[1];
const documentPresence = sanity.useDocumentPresence(t1), documentPreviewStore = sanity.useDocumentPreviewStore(), {
ReferenceChildLink: ReferenceChildLink2
} = usePaneRouter();
let t2;
$[2] !== ReferenceChildLink2 || $[3] !== type?.name || $[4] !== value?._id ? (t2 = function(linkProps) {
return /* @__PURE__ */ jsxRuntime.jsx(ReferenceChildLink2, { documentId: value?._id, documentType: type?.name, parentRefPath: EMPTY_ARRAY$1, ...linkProps });
}, $[2] = ReferenceChildLink2, $[3] = type?.name, $[4] = value?._id, $[5] = t2) : t2 = $[5];
const t3 = t2, t4 = type?.icon, t5 = documentPresence?.length > 0 ? documentPresence : EMPTY_ARRAY$1;
let t6;
$[6] !== documentPreviewStore || $[7] !== t4 || $[8] !== t5 || $[9] !== type || $[10] !== value ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(PaneItemPreview, { documentPreviewStore, icon: t4, layout: "compact", presence: t5, schemaType: type, value }), $[6] = documentPreviewStore, $[7] = t4, $[8] = t5, $[9] = type, $[10] = value, $[11] = t6) : t6 = $[11];
let t7;
return $[12] !== onClick || $[13] !== t3 || $[14] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(sanity.PreviewCard, { __unstable_focusRing: !0, as: t3, "data-as": "a", onClick, radius: 2, children: t6 }), $[12] = onClick, $[13] = t3, $[14] = t6, $[15] = t7) : t7 = $[15], t7;
}
function ConfirmDeleteDialogBody(t0) {
const $ = reactCompilerRuntime.c(78), {
crossDatasetReferences,
internalReferences,
documentTitle,
totalCount,
action,
datasetNames,
hasUnknownDatasetNames,
onReferenceLinkClick
} = t0, schema = sanity.useSchema(), toast = ui.useToast(), {
t
} = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace);
let t1;
$[0] !== onReferenceLinkClick || $[1] !== schema || $[2] !== t ? (t1 = (item) => {
const type = schema.get(item._type);
return type ? /* @__PURE__ */ jsxRuntime.jsx(ReferencePreviewLink, { type, value: item, onClick: onReferenceLinkClick }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.SanityDefaultPreview, { icon: icons.UnknownIcon, title: t("confirm-delete-dialog.preview-item.preview-unavailable.title"), subtitle: t("confirm-delete-dialog.preview-item.preview-unavailable.subtitle", {
documentId: item._id
}), layout: "default" }) });
}, $[0] = onReferenceLinkClick, $[1] = schema, $[2] = t, $[3] = t1) : t1 = $[3];
const renderPreviewItem = t1;
if (internalReferences?.totalCount === 0 && crossDatasetReferences?.totalCount === 0) {
let t22;
$[4] !== documentTitle ? (t22 = {
DocumentTitle: () => /* @__PURE__ */ jsxRuntime.jsx("strong", { children: documentTitle })
}, $[4] = documentTitle, $[5] = t22) : t22 = $[5];
let t32;
return $[6] !== action || $[7] !== t || $[8] !== t22 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "p", size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { t, i18nKey: "confirm-delete-dialog.confirmation.text", context: action, components: t22 }) }), $[6] = action, $[7] = t, $[8] = t22, $[9] = t32) : t32 = $[9], t32;
}
let T0, T1, T2, t10, t11, t12, t2, t3, t4, t5, t6, t7, t8, t9;
if ($[10] !== action || $[11] !== crossDatasetReferences || $[12] !== datasetNames || $[13] !== documentTitle || $[14] !== hasUnknownDatasetNames || $[15] !== internalReferences || $[16] !== renderPreviewItem || $[17] !== t || $[18] !== toast || $[19] !== totalCount) {
const normalizedDatasetNames = [...datasetNames, ...hasUnknownDatasetNames ? ["unavailable"] : []], datasetSubtitle = t("confirm-delete-dialog.cdr-summary.subtitle", {
count: normalizedDatasetNames.length,
datasets: normalizedDatasetNames.join(", "),
context: hasUnknownDatasetNames && normalizedDatasetNames.length ? "unavailable" : ""
});
T2 = ui.Flex, t9 = "column", t10 = 4;
let t132;
$[34] === Symbol.for("react.memo_cache_sentinel") ? (t132 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { "aria-hidden": "true", size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningOutlineIcon, {}) }), $[34] = t132) : t132 = $[34];
let t142;
$[35] !== documentTitle ? (t142 = {
DocumentTitle: () => documentTitle
}, $[35] = documentTitle, $[36] = t142) : t142 = $[36];
let t152;
$[37] !== totalCount ? (t152 = {
count: totalCount
}, $[37] = totalCount, $[38] = t152) : t152 = $[38], $[39] !== t || $[40] !== t142 || $[41] !== t152 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 3, radius: 2, tone: "caution", flex: "none", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [
t132,
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, marginLeft: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { i18nKey: "confirm-delete-dialog.referring-document-count.text", components: t142, t, values: t152 }) }) })
] }) }), $[39] = t, $[40] = t142, $[41] = t152, $[42] = t11) : t11 = $[42];
let t162;
$[43] !== documentTitle ? (t162 = {
DocumentTitle: () => documentTitle
}, $[43] = documentTitle, $[44] = t162) : t162 = $[44], $[45] !== action || $[46] !== t || $[47] !== t162 ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { i18nKey: "confirm-delete-dialog.referring-documents-descriptor.text", t, context: action, components: t162 }) }) }), $[45] = action, $[46] = t, $[47] = t162, $[48] = t12) : t12 = $[48], T1 = ui.Card, t5 = 2, t6 = 1, t7 = "auto", t8 = 2, T0 = ui.Flex, t2 = "column", $[49] !== internalReferences || $[50] !== renderPreviewItem ? (t3 = internalReferences.totalCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { as: "ul", marginBottom: 2, space: 2, "data-testid": "internal-references", children: [
internalReferences?.references.map((item_0) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "li", children: renderPreviewItem(item_0) }, item_0._id)),
internalReferences.totalCount > internalReferences.references.length && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "li", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(OtherReferenceCount, { ...internalReferences }) })
] }), $[49] = internalReferences, $[50] = renderPreviewItem, $[51] = t3) : t3 = $[51], t4 = crossDatasetReferences.totalCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(CrossDatasetReferencesDetails, { "data-testid": "cross-dataset-references", style: {
borderTop: internalReferences.totalCount > 0 ? "1px solid var(--card-shadow-outline-color)" : void 0
}, children: [
/* @__PURE__ */ jsxRuntime.jsx(CrossDatasetReferencesSummary, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "a", marginTop: internalReferences.totalCount > 0 ? 2 : 0, radius: 2, shadow: 1, paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 3, paddingX: 3, paddingY: 1, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.DocumentsIcon, {}) }),
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { textOverflow: "ellipsis", size: 1, children: t("confirm-delete-dialog.cdr-summary.title", {
count: normalizedDatasetNames.length,
documentCount: t("confirm-delete-dialog.cdr-summary.document-count", {
count: crossDatasetReferences.totalCount
})
}) }),
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: datasetSubtitle, textOverflow: "ellipsis", size: 1, muted: !0, children: datasetSubtitle })
] }),
/* @__PURE__ */ jsxRuntime.jsx(ChevronWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDownIcon, {}) }) })
] }) }) }),
/* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { overflow: "auto", paddingTop: 2, children: [
/* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
/* @__PURE__ */ jsxRuntime.jsx("th", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, style: {
minWidth: "5rem"
}, weight: "medium", children: t("confirm-delete-dialog.cdr-table.project-id.label") }) }),
/* @__PURE__ */ jsxRuntime.jsx("th", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, weight: "medium", children: t("confirm-delete-dialog.cdr-table.dataset.label") }) }),
/* @__PURE__ */ jsxRuntime.jsx("th", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, weight: "medium", children: t("confirm-delete-dialog.cdr-table.document-id.label") }) })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: crossDatasetReferences.references.filter(_temp$p).map((t172, index) => {
const {
projectId,
datasetName,
documentId
} = t172;
return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
/* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: projectId }) }),
/* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: datasetName || "unavailable" }) }),
/* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsxs(DocumentIdFlex, { align: "center", gap: 2, justify: "flex-end", children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { textOverflow: "ellipsis", size: 1, children: documentId || "unavailable" }),
documentId && /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Button, { mode: "bleed", icon: icons.CopyIcon, tooltipProps: {
content: t("confirm-delete-dialog.cdr-table.copy-id-button.tooltip")
}, onClick: () => {
navigator.clipboard.writeText(documentId).catch(() => {
toast.push({
status: "error",
title: t("confirm-delete-dialog.cdr-table.id-copied-toast.title-failed")
});
});
} })
] }) })
] }, `${documentId}-${index}`);
}) })
] }),
/* @__PURE__ */ jsxRuntime.jsx(OtherReferenceCount, { ...crossDatasetReferences })
] })
] }), $[10] = action, $[11] = crossDatasetReferences, $[12] = datasetNames, $[13] = documentTitle, $[14] = hasUnknownDatasetNames, $[15] = internalReferences, $[16] = renderPreviewItem, $[17] = t, $[18] = toast, $[19] = totalCount, $[20] = T0, $[21] = T1, $[22] = T2, $[23] = t10, $[24] = t11, $[25] = t12, $[26] = t2, $[27] = t3, $[28] = t4, $[29] = t5, $[30] = t6, $[31] = t7, $[32] = t8, $[33] = t9;
} else
T0 = $[20], T1 = $[21], T2 = $[22], t10 = $[23], t11 = $[24], t12 = $[25], t2 = $[26], t3 = $[27], t4 = $[28], t5 = $[29], t6 = $[30], t7 = $[31], t8 = $[32], t9 = $[33];
let t13;
$[52] !== T0 || $[53] !== t2 || $[54] !== t3 || $[55] !== t4 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(T0, { direction: t2, children: [
t3,
t4
] }), $[52] = T0, $[53] = t2, $[54] = t3, $[55] = t4, $[56] = t13) : t13 = $[56];
let t14;
$[57] !== T1 || $[58] !== t13 || $[59] !== t5 || $[60] !== t6 || $[61] !== t7 || $[62] !== t8 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(T1, { radius: t5, shadow: t6, flex: t7, padding: t8, children: t13 }), $[57] = T1, $[58] = t13, $[59] = t5, $[60] = t6, $[61] = t7, $[62] = t8, $[63] = t14) : t14 = $[63];
let t15;
$[64] !== documentTitle ? (t15 = {
DocumentTitle: () => documentTitle
}, $[64] = documentTitle, $[65] = t15) : t15 = $[65];
let t16;
$[66] !== action || $[67] !== t || $[68] !== t15 ? (t16 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { i18nKey: "confirm-delete-dialog.referential-integrity-disclaimer.text", t, context: action, components: t15 }) }) }), $[66] = action, $[67] = t, $[68] = t15, $[69] = t16) : t16 = $[69];
let t17;
return $[70] !== T2 || $[71] !== t10 || $[72] !== t11 || $[73] !== t12 || $[74] !== t14 || $[75] !== t16 || $[76] !== t9 ? (t17 = /* @__PURE__ */ jsxRuntime.jsxs(T2, { direction: t9, gap: t10, children: [
t11,
t12,
t14,
t16
] }), $[70] = T2, $[71] = t10, $[72] = t11, $[73] = t12, $[74] = t14, $[75] = t16, $[76] = t9, $[77] = t17) : t17 = $[77], t17;
}
function _temp$p(reference) {
return "projectId" in reference;
}
function isClientError(e) {
return typeof e != "object" || !e ? !1 : "statusCode" in e && "response" in e;
}
const POLL_INTERVAL = 5e3;
let visiblePoll$;
const getVisiblePoll$ = () => (visiblePoll$ || (visiblePoll$ = rxjs.fromEvent(document, "visibilitychange").pipe(
// add empty emission to have this fire on creation
operators.startWith(null),
operators.map(() => document.visibilityState === "visible"),
operators.distinctUntilChanged(),
operators.switchMap((visible) => visible ? (
// using timer instead of interval since timer will emit on creation
rxjs.timer(0, POLL_INTERVAL)
) : rxjs.EMPTY),
operators.shareReplay({
refCount: !0,
bufferSize: 1
})
)), visiblePoll$);
function getDocumentExistence(documentId, {
versionedClient
}) {
const draftId = sanity.getDraftId(documentId), publishedId = sanity.getPublishedId(documentId), requestOptions = {
uri: versionedClient.getDataUrl("doc", `${draftId},${publishedId}`),
json: !0,
query: {
excludeContent: "true"
},
tag: "use-referring-documents.document-existence"
};
return versionedClient.observable.request(requestOptions).pipe(operators.map(({
omitted
}) => {
const nonExistant = omitted.filter((doc) => doc.reason === "existence");
if (nonExistant.length !== 2)
return nonExistant.length === 0 || nonExistant.some((doc) => doc.id === draftId) ? publishedId : draftId;
}));
}
function fetchCrossDatasetReferences(documentId, context) {
const {
versionedClient
} = context;
return getVisiblePoll$().pipe(operators.switchMap(() => getDocumentExistence(documentId, context)), operators.switchMap((checkDocumentId) => {
if (!checkDocumentId)
return rxjs.of({
totalCount: 0,
references: []
});
const currentDataset = versionedClient.config().dataset;
return versionedClient.observable.request({
url: `/data/references/${currentDataset}/documents/${checkDocumentId}/to?excludeInternalReferences=true&excludePaths=true`,
tag: "use-referring-documents.external"
}).pipe(operators.catchError((e) => {
if (isClientError(e) && e.statusCode === 404)
return rxjs.of({
totalCount: 0,
references: []
});
throw e;
}));
}));
}
const useInternalReferences = sanity.createHookFromObservableFactory(([documentId, documentStore]) => documentStore.listenQuery({
fetch: '{"references":*[references($documentId)][0...100]{_id,_type},"totalCount":count(*[references($documentId)])}',
listen: "*[references($documentId)]"
}, {
documentId
}, {
tag: "use-referring-documents",
transitions: ["appear", "disappear"],
throttleTime: 5e3
})), useCrossDatasetReferences = sanity.createHookFromObservableFactory(([documentId, versionedClient]) => getVisiblePoll$().pipe(operators.switchMap(() => fetchCrossDatasetReferences(documentId, {
versionedClient
}))));
function useReferringDocuments(documentId) {
const $ = reactCompilerRuntime.c(24), versionedClient = sanity.useClient(sanity.DEFAULT_STUDIO_CLIENT_OPTIONS), documentStore = sanity.useDocumentStore();
let t0;
$[0] !== documentId ? (t0 = sanity.getPublishedId(documentId), $[0] = documentId, $[1] = t0) : t0 = $[1];
const publishedId = t0;
let t1, t2;
$[2] !== documentStore || $[3] !== publishedId ? (t2 = [publishedId, documentStore], $[2] = documentStore, $[3] = publishedId, $[4] = t2) : t2 = $[4], t1 = t2;
const [internalReferences, isInternalReferencesLoading] = useInternalReferences(t1);
let t3, t4;
$[5] !== publishedId || $[6] !== versionedClient ? (t4 = [publishedId, versionedClient], $[5] = publishedId, $[6] = versionedClient, $[7] = t4) : t4 = $[7], t3 = t4;
const [crossDatasetReferences, isCrossDatasetReferencesLoading] = useCrossDatasetReferences(t3);
let t5;
$[8] !== crossDatasetReferences?.references ? (t5 = () => Array.from(new Set(crossDatasetReferences?.references.map(_temp$o).filter(Boolean))).sort(), $[8] = crossDatasetReferences?.references, $[9] = t5) : t5 = $[9];
let t6;
$[10] !== t5 ? (t6 = t5(), $[10] = t5, $[11] = t6) : t6 = $[11];
const projectIds = t6;
let t7, t8;
$[12] !== crossDatasetReferences?.references ? (t8 = Array.from(new Set(crossDatasetReferences?.references.map(_temp2$9).filter(_temp3$2))).sort(), $[12] = crossDatasetReferences?.references, $[13] = t8) : t8 = $[13], t7 = t8;
const datasetNames = t7;
let t9;
$[14] !== crossDatasetReferences?.references ? (t9 = () => !!crossDatasetReferences?.references.some(_temp4$2), $[14] = crossDatasetReferences?.references, $[15] = t9) : t9 = $[15];
const hasUnknownDatasetNames = t9(), t10 = (internalReferences?.totalCount || 0) + (crossDatasetReferences?.totalCount || 0), t11 = isInternalReferencesLoading || isCrossDatasetReferencesLoading;
let t12;
return $[16] !== crossDatasetReferences || $[17] !== datasetNames || $[18] !== hasUnknownDatasetNames || $[19] !== internalReferences || $[20] !== projectIds || $[21] !== t10 || $[22] !== t11 ? (t12 = {
totalCount: t10,
projectIds,
datasetNames,
hasUnknownDatasetNames,
internalReferences,
crossDatasetReferences,
isLoading: t11
}, $[16] = crossDatasetReferences, $[17] = datasetNames, $[18] = hasUnknownDatasetNames, $[19] = internalReferences, $[20] = projectIds, $[21] = t10, $[22] = t11, $[23] = t12) : t12 = $[23], t12;
}
function _temp4$2(crossDatasetReference_1) {
return typeof crossDatasetReference_1.datasetName != "string";
}
function _temp3$2(datasetName) {
return !!datasetName && datasetName !== "";
}
function _temp2$9(crossDatasetReference_0) {
return crossDatasetReference_0?.datasetName || "";
}
function _temp$o(crossDatasetReference) {
return crossDatasetReference.projectId;
}
const DialogBody$1 = styledComponents.styled(ui.Box)`
box-sizing: border-box;
`, LoadingContainer = styledComponents.styled(ui.Flex).attrs({
align: "center",
direction: "column",
justify: "center"
})`
height: 110px;
`;
function ConfirmDeleteDialog(t0) {
const $ = reactCompilerRuntime.c(40), {
id,
type,
action: t1,
onCancel,
onConfirm
} = t0, action = t1 === void 0 ? "delete" : t1, {
t
} = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace), dialogId = `deletion-confirmation-${React.useId()}`, {
internalReferences,
crossDatasetReferences,
isLoading,
totalCount,
projectIds,
datasetNames,
hasUnknownDatasetNames
} = useReferringDocuments(id);
let t2, t3;
$[0] !== id || $[1] !== type ? (t3 = {
_id: id,
_type: type
}, $[0] = id, $[1] = type, $[2] = t3) : t3 = $[2], t2 = t3;
let t4;
$[3] !== t2 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(DocTitle, { document: t2 }), $[3] = t2, $[4] = t4) : t4 = $[4];
const documentTitle = t4, showConfirmButton = !isLoading;
let t5;
$[5] !== action || $[6] !== t ? (t5 = t("confirm-delete-dialog.header.text", {
context: action
}), $[5] = action, $[6] = t, $[7] = t5) : t5 = $[7];
let t6;
$[8] !== t ? (t6 = t("confirm-delete-dialog.cancel-button.text"), $[8] = t, $[9] = t6) : t6 = $[9];
let t7;
$[10] !== onCancel || $[11] !== t6 ? (t7 = {
onClick: onCancel,
text: t6
}, $[10] = onCancel, $[11] = t6, $[12] = t7) : t7 = $[12];
let t8;
$[13] !== action || $[14] !== onConfirm || $[15] !== showConfirmButton || $[16] !== t || $[17] !== totalCount ? (t8 = showConfirmButton ? {
text: totalCount > 0 ? t("confirm-delete-dialog.confirm-anyway-button.text", {
context: action
}) : t("confirm-delete-dialog.confirm-button.text", {
context: action
}),
onClick: onConfirm
} : void 0, $[13] = action, $[14] = onConfirm, $[15] = showConfirmButton, $[16] = t, $[17] = totalCount, $[18] = t8) : t8 = $[18];
let t9;
$[19] !== t7 || $[20] !== t8 ? (t9 = {
cancelButton: t7,
confirmButton: t8
}, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21];
let t10;
$[22] !== action || $[23] !== crossDatasetReferences || $[24] !== datasetNames || $[25] !== documentTitle || $[26] !== hasUnknownDatasetNames || $[27] !== internalReferences || $[28] !== isLoading || $[29] !== onCancel || $[30] !== projectIds || $[31] !== t || $[32] !== totalCount ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(DialogBody$1, { children: crossDatasetReferences && internalReferences && !isLoading ? /* @__PURE__ */ jsxRuntime.jsx(ConfirmDeleteDialogBody, { crossDatasetReferences, internalReferences, documentTitle, isLoading, totalCount, action, projectIds, datasetNames, hasUnknownDatasetNames, onReferenceLinkClick: onCancel }) : /* @__PURE__ */ jsxRuntime.jsx(LoadingContainer, { "data-testid": "loading-container", children: /* @__PURE__ */ jsxRuntime.jsx(sanity.LoadingBlock, { showText: !0, title: t("confirm-delete-dialog.loading.text") }) }) }), $[22] = action, $[23] = crossDatasetReferences, $[24] = datasetNames, $[25] = documentTitle, $[26] = hasUnknownDatasetNames, $[27] = internalReferences, $[28] = isLoading, $[29] = onCancel, $[30] = projectIds, $[31] = t, $[32] = totalCount, $[33] = t10) : t10 = $[33];
let t11;
return $[34] !== dialogId || $[35] !== onCancel || $[36] !== t10 || $[37] !== t5 || $[38] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Dialog, { width: 1, id: dialogId, header: t5, footer: t9, onClose: onCancel, onClickOutside: onCancel, children: t10 }), $[34] = dialogId, $[35] = onCancel, $[36] = t10, $[37] = t5, $[38] = t9, $[39] = t11) : t11 = $[39], t11;
}
function ConfirmDeleteDialogContainer(props) {
const $ = reactCompilerRuntime.c(6), {
t
} = sanity.useTranslation(StructureToolProvider.structureLocaleNamespace), id = React.useId(), [error, setError] = React.useState(null);
let t0;
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setError(null), $[0] = t0) : t0 = $[0];
const handleRetry = t0;
let t1;
return $[1] !== error || $[2] !== id || $[3] !== props || $[4] !== t ? (t1 = error ? /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Dialog, { id: `dialog-error-${id}`, "data-testid": "confirm-delete-error-dialog", header: t("confirm-delete-dialog.error.title.text"), footer: {
confirmButton: {
text: t("confirm-delete-dialog.error.retry-button.text"),
onClick: handleRetry,
tone: "default"
}
}, onClose: props.onCancel, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: t("confirm-delete-dialog.error.message.text") }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.ErrorBoundary, { onCatch: setError, children: /* @__PURE__ */ jsxRuntime.jsx(ConfirmDeleteDialog, { ...props }) }), $[1] = error, $[2] = id, $[3] = props, $[4] = t, $[5] = t1) : t1 = $[5], t1;
}
function Delay(t0) {
const $ = reactCompilerRuntime.c(6), {
children,
ms: t1
} = t0, ms = t1 === void 0 ? 0 : t1, [ready, setReady] = React.useState(ms <= 0);
let t2, t3;
if ($[0] !== ms ? (t2 = () => {
if (ms <= 0)
return;
const timeoutId = setTimeout(() => setReady(!0), ms);
return () => {
clearTimeout(timeoutId);
};
}, t3 = [ms], $[0] = ms, $[1] = t2, $[2] = t3) : (t2 = $[1], t3 = $[2]), React.useEffect(t2, t3), !ready || !children) {
let t42;
return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t42 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}), $[3] = t42) : t42 = $[3], t42;
}
let t4;
return $[4] !== children ? (t4 = typeof children == "function" ? children() : children, $[4] = children, $[5] = t4) : t4 = $[5], t4;
}
const PANE_DEBUG = !1, PANE_COLLAPSED_WIDTH = 51, PANE_DEFAULT_MIN_WIDTH = 204, Root$9 = styledComponents.styled(ui.Layer)`
position: relative;
width: 1px;
min-width: 1px;
&:before {
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 1px;
background-color: var(--card-border-color);
}
&:not([data-disabled]) {
cursor: ew-resize;
width: 9px;
min-width: 9px;
margin: 0 -4px;
&:before {
left: 4px;
}
&:after {
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: 9px;
bottom: 0;
background-color: var(--card-border-color);
opacity: 0;
transition: opacity 150ms;
}
&[data-dragging]:after,
&:hover:after {
opacity: 0.2;
}
}
`;
function PaneDivider(t0) {
const $ = reactCompilerRuntime.c(7), {
disabled,
element
} = t0, {
resize
} = usePaneLayout(), [dragging, setDragging] = React.useState(!1);
let t1;
$[0] !== element || $[1] !== resize ? (t1 = (event) => {
if (!element)
return;
setDragging(!0), event.preventDefault();
const startX = event.pageX;
resize("start", element, 0);
const handleMouseMove = (e) => {
e.preventDefault();
const deltaX = e.pageX - startX;
resize("move", element, deltaX);
}, handleMouseUp = (e_0) => {
e_0.preventDefault(), setDragging(!1), window.removeEventListener("mousemove", handleMouseMove), window.removeEventListener("mouseup", handleMouseUp), resize("end", element, 0);
};
window.addEventListener("mousemove", handleMouseMove), window.addEventListener("mouseup", handleMouseUp);
}, $[0] = element, $[1] = resize, $[2] = t1) : t1 = $[2];
const handleMouseDown = t1, t2 = disabled ? "" : void 0, t3 = dragging ? "" : void 0;
let t4;
return $[3] !== handleMouseDown || $[4] !== t2 || $[5] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Root$9, { "data-disabled": t2, "data-dragging": t3, onMouseDown: handleMouseDown }), $[3] = handleMouseDown, $[4] = t2, $[5] = t3, $[6] = t4) : t4 = $[6], t4;
}
const Root$8 = styledComponents.styled(ui.Card)`
outline: none;
// NOTE: This will render a border to the right side of each pane
// without taking up physical space.
box-shadow: 1px 0 0 var(--card-border-color);
`, Pane = React.forwardRef(function(props, forwardedRef) {
const $ = reactCompilerRuntime.c(86);
let children, currentMaxWidthProp, currentMinWidthProp, id, maxWidthProp, minWidthProp, restProps, t0, t1;
$[0] !== props ? ({
children,
currentMinWidth: currentMinWidthProp,
currentMaxWidth: currentMaxWidthProp,
flex: t0,
id,
minWidth: minWidthProp,
maxWidth: maxWidthProp,
selected: t1,
...restProps
} = props, $[0] = props, $[1] = children, $[2] = currentMaxWidthProp, $[3] = currentMinWidthProp, $[4] = id, $[5] = maxWidthProp, $[6] = minWidthProp, $[7] = restProps, $[8] = t0, $[9] = t1) : (children = $[1], currentMaxWidthProp = $[2], currentMinWidthProp = $[3], id = $[4], maxWidthProp = $[5], minWidthProp = $[6], restProps = $[7], t0 = $[8], t1 = $[9]);
const flexProp = t0 === void 0 ? 1 : t0, selected = t1 === void 0 ? !1 : t1, [rootElement, setRootElement] = React.useState(null), {
collapse,
collapsed: layoutCollapsed,
expand,
expandedElement,
mount,
panes
} = usePaneLayout();
let pane2, t2;
if ($[10] !== panes || $[11] !== rootElement) {
let t32;
$[14] !== rootElement ? (t32 = (p) => p.element === rootElement, $[14] = rootElement, $[15] = t32) : t32 = $[15], pane2 = panes.find(t32), t2 = pane2 && panes.indexOf(pane2), $[10] = panes, $[11] = rootElement, $[12] = pane2, $[13] = t2;
} else
pane2 = $[12], t2 = $[13];
const paneIndex = t2, nextPane = typeof paneIndex == "number" ? panes[paneIndex + 1] : void 0, isLast = paneIndex === panes.length - 1, expanded = expandedElement === rootElement, collapsed = layoutCollapsed ? !1 : pane2?.collapsed || !1, nextCollapsed = nextPane?.collapsed || !1, ref = React.useRef(null), flex = pane2?.flex ?? flexProp, currentMinWidth = pane2?.currentMinWidth ?? currentMinWidthProp, currentMaxWidth = pane2?.currentMaxWidth ?? currentMaxWidthProp;
let t3;
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[16] = t3) : t3 = $[16], React.useImperativeHandle(forwardedRef, t3);
let t4;
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t4 = (refValue) => {
setRootElement(refValue), ref.current = refValue;
}, $[17] = t4) : t4 = $[17];
const setRef = t4;
let t5, t6;
$[18] !== currentMaxWidthProp || $[19] !== currentMinWidthProp || $[20] !== flexProp || $[21] !== id || $[22] !== maxWidthProp || $[23] !== minWidthProp || $[24] !== mount || $[25] !== rootElement ? (t5 = () => {
if (rootElement)
return mount(rootElement, {
currentMinWidth: currentMinWidthProp,
currentMaxWidth: currentMaxWidthProp,
flex: flexProp,
id,
minWidth: minWidthProp,
maxWidth: maxWidthProp
});
}, t6 = [currentMinWidthProp, currentMaxWidthProp, flexProp, id, minWidthProp, maxWidthProp, mount, rootElement], $[18] = currentMaxWidthProp, $[19] = currentMinWidthProp, $[20] = flexProp, $[21] = id, $[22] = maxWidthProp, $[23] = minWidthProp, $[24] = mount, $[25] = rootElement, $[26] = t5, $[27] = t6) : (t5 = $[26], t6 = $[27]), React.useLayoutEffect(t5, t6);
let t7;
$[28] !== collapse || $[29] !== rootElement ? (t7 = () => {
rootElement && collapse(rootElement);
}, $[28] = collapse, $[29] = rootElement, $[30] = t7) : t7 = $[30];
const handleCollapse = t7;
let t8;
$[31] !== expand || $[32] !== rootElement ? (t8 = () => {
rootElement && expand(rootElement);
}, $[31] = expand, $[32] = rootElement, $[33] = t8) : t8 = $[33];
const handleExpand = t8;
let t9;
const t10 = layoutCollapsed ? !1 : collapsed;
let t11;
$[34] !== handleCollapse || $[35] !== handleExpand || $[36] !== isLast || $[37] !== paneIndex || $[38] !== rootElement || $[39] !== t10 ? (t11 = {
collapse: handleCollapse,
collapsed: t10,
expand: handleExpand,
index: paneIndex,
isLast,
rootElement
}, $[34] = handleCollapse, $[35] = handleExpand, $[36] = isLast, $[37] = paneIndex, $[38] = rootElement, $[39] = t10, $[40] = t11) : t11 = $[40], t9 = t11;
const contextValue = t9;
let t12;
bb0: {
if (layoutCollapsed) {
t12 = void 0;
break bb0;
}
if (collapsed) {
t12 = PANE_COLLAPSED_WIDTH;
break bb0;
}
if (currentMinWidth === 0) {
t12 = minWidthProp || PANE_DEFAULT_MIN_WIDTH;
break bb0;
}
if (isLast) {
t12 = minWidthProp || PANE_DEFAULT_MIN_WIDTH;
break bb0;
}
t12 = currentMinWidth || minWidthProp || PANE_DEFAULT_MIN_WIDTH;
}
const minWidth = t12;
let t13;
bb1: {
if (collapsed) {
t13 = PANE_COLLAPSED_WIDTH;
break bb1;
}
if (layoutCollapsed && isLast) {
t13 = void 0;
break bb1;
}
if (isLast) {
if (maxWidthProp) {
t13 = currentMaxWidth ?? maxWidthProp;
break bb1;
}
t13 = void 0;
break bb1;
}
t13 = currentMaxWidth ?? maxWidthProp;
}
const maxWidth = t13, hidden = layoutCollapsed && !isLast;
let t14, t15;
$[41] !== collapsed || $[42] !== isLast || $[43] !== layoutCollapsed || $[44] !== nextCollapsed || $[45] !== rootElement ? (t15 = !isLast && !layoutCollapsed && /* @__PURE__ */ jsxRuntime.jsx(sanity.LegacyLayerProvider, { zOffset: "paneResizer", children: /* @__PURE__ */ jsxRuntime.jsx(PaneDivider, { disabled: collapsed || nextCollapsed, element: rootElement }) }), $[41] = collapsed, $[42] = isLast, $[43] = layoutCollapsed, $[44] = nextCollapsed, $[45] = rootElement, $[46] = t15) : t15 = $[46], t14 = t15;
const divider = t14;
let t16;
const t17 = maxWidth === 1 / 0 ? void 0 : maxWidth;
let t18;
$[47] !== flex || $[48] !== minWidth || $[49] !== t17 ? (t18 = {
flex,
minWidth,
maxWidth: t17
}, $[47] = flex, $[48] = minWidth, $[49] = t17, $[50] = t18) : t18 = $[50], t16 = t18;
const style = t16, t19 = layoutCollapsed ? void 0 : "hidden", t20 = collapsed ? "" : void 0, t21 = selected ? "" : void 0;
let t22;
$[51] !== collapsed || $[52] !== currentMaxWidth || $[53] !== currentMinWidth || $[54] !== expanded || $[55] !== flex || $[56] !== maxWidth || $[57] !== minWidth || $[58] !== paneIndex ? (t22 = PANE_DEBUG, $[51] = collapsed, $[52] = currentMaxWidth, $[53] = currentMinWidth, $[54] = expanded, $[55] = flex, $[56] = maxWidth, $[57] = minWidth, $[58] = paneIndex, $[59] = t22) : t22 = $[59];
let t23;
$[60] !== children || $[61] !== hidden ? (t23 = !hidden && /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "column", height: "fill", children }), $[60] = children, $[61] = hidden, $[62] = t23) : t23 = $[62];
let t24;
$[63] !== rootElement || $[64] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(ui.BoundaryElementProvider, { element: rootElement, children: t23 }), $[63] = rootElement, $[64] = t23, $[65] = t24) : t24 = $[65];
let t25;
$[66] !== hidden || $[67] !== id || $[68] !== paneIndex || $[69] !== restProps || $[70] !== style || $[71] !== t19 || $[72] !== t20 || $[73] !== t21 || $[74] !== t22 || $[75] !== t24 ? (t25 = /* @__PURE__ */ jsxRuntime.jsxs(Root$8, { "data-testid": "pane", "data-ui": "Pane