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
945 lines (939 loc) • 542 kB
JavaScript
import { structureLocaleNamespace, getExtendedProjection, structureUsEnglishLocaleBundle } from "./StructureToolProvider.mjs";
import { MenuButton, Dialog, MenuItem as MenuItem$1, Button as Button$1, Tab, Popover, Tooltip, TooltipDelayGroupProvider, ErrorBoundary } from "./generate-help-url.esm.mjs";
import "../_singletons.mjs";
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
import { c } from "react-compiler-runtime";
import { Box, Text, Flex, Button, Menu, MenuItem, Stack, Card, Container as Container$1, DialogProvider, PortalProvider, BoundaryElementProvider, useToast, Layer, MenuDivider, TextSkeleton, useElementRect, LayerProvider, _raf2, rem, TextInput, Code, TabList, TabPanel, useClickOutsideEvent, Heading, Inline, Spinner, focusFirstDescendant, usePortal, Popover as Popover$1, useLayer, useGlobalKeyDown, Grid as Grid$2, Dialog as Dialog$1, Badge, AvatarStack, Skeleton, Checkbox, Select } from "@sanity/ui";
import { useMemo, useEffect, useCallback, forwardRef, useRef, useState, useContext, useImperativeHandle, useLayoutEffect, useId, memo, useDeferredValue, lazy, Suspense, startTransition, useReducer, Fragment as Fragment$1 } from "react";
import { ReviewChangesContext, CommentsEnabledContext, ReferenceInputOptionsContext, PaneLayoutContext, PaneContext, DocumentPaneContext, PaneRouterContext, StructureToolContext, DocumentSheetListContext, DocumentChangeContext } from "sanity/_singletons";
import { TransferIcon, CloseIcon, LockIcon, CheckmarkIcon, UnknownIcon, SearchIcon, DocumentRemoveIcon, ReadOnlyIcon, ErrorOutlineIcon, WarningOutlineIcon, SyncIcon, InfoOutlineIcon, ComposeSparklesIcon, LaunchIcon, UnpublishIcon, StarFilledIcon, StarIcon, ArrowLeftIcon, TrashIcon, ResetIcon, CopyIcon, RevertIcon, PublishIcon, SplitVerticalIcon, EditIcon, AddIcon, ChevronLeftIcon, ChevronDownIcon, RestoreIcon, LinkIcon, EarthAmericasIcon, JsonIcon, DocumentsIcon, ChevronRightIcon, DocumentIcon, FolderIcon, SpinnerIcon, EllipsisHorizontalIcon, DoubleChevronLeftIcon, DoubleChevronRightIcon, CheckmarkCircleIcon, MasterDetailIcon } from "@sanity/icons";
import { useTranslation, useDocumentVersions, useActiveReleases, getVersionFromId, getReleaseIdFromReleaseDocumentId, useEditState, getPublishedId, useWorkspace, isPublishedId, isDraftId, getDraftId, getVersionId, ReleaseAvatar, getReleaseTone, formatRelativeLocalePublishDate, isReleaseScheduledOrScheduling, isReleaseDocument, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, useStudioUrl, CommentsProvider, COMMENTS_INSPECTOR_NAME, useArchivedReleases, useUnique, prepareForPreview, unstable_useValuePreview, useDocumentOperationEvent, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isPublishedPerspective, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, getVersionInlineBadge, useCanvasCompanionDoc, useNavigateToCanvasDoc, getDocumentVariantType, isPerspectiveWriteable, ReleasesNav, useSanityCreateConfig, getSanityCreateLinkMetadata, LATEST, useVersionOperations, useConditionalToast, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, PresenceOverlay, fromMutationPatches, useManageFavorite, useActiveWorkspace, CapabilityGate, ScrollContainer, isSanityCreateLinked, isSystemBundle, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, useDateTimeFormat, useSchema, VersionChip, useFieldActions, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, resizeObserver, ChangeConnectorRoot, useGlobalCopyPasteElementHandler, GetFormValueProvider, FieldActionsResolver, FieldActionsProvider, useHistoryStore, useTimelineStore, useTemplates, useInitialValue, useCopyPaste, EMPTY_ARRAY as EMPTY_ARRAY$2, useEventsStore, EventsProvider, isDeleteDocumentGroupEvent, isDeleteDocumentVersionEvent, PerspectiveProvider, SourceProvider, CopyPasteProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, useDocumentVersionInfo, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, PreviewCard, createHookFromObservableFactory, DEFAULT_STUDIO_CLIENT_OPTIONS, EMPTY_OBJECT, GetHookCollectionState, ErrorActions, collate, createSWR, getSearchableTypes, createSearch, useSearchMaxFieldDepth, catchWithCount, useReconnectingToast, useSearchState, SearchHeader, Filters, SearchProvider, ChangeFieldWrapper, NoChanges, ChangeList, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, isValidationError, isValidationWarning, definePlugin } from "sanity";
import { uuid } from "@sanity/uuid";
import { styled, css, keyframes } from "styled-components";
import { diffInput, wrap } from "@sanity/diff";
import { motion, AnimatePresence } from "framer-motion";
import { useObservable, useObservableEvent } from "react-rx";
import { useRouter, useIntentLink, StateLink, useRouterState, IntentLink, route, encodeJsonParams, decodeJsonParams } from "sanity/router";
import omit from "lodash/omit.js";
import isEqual from "lodash/isEqual.js";
import shallowEquals from "shallow-equals";
import { mapTo, delay, map as map$1, catchError as catchError$1, startWith as startWith$1, debounceTime, tap, distinctUntilChanged as distinctUntilChanged$1, switchMap, shareReplay, scan, withLatestFrom, filter as filter$1, take, mergeMap as mergeMap$1, share as share$1, takeUntil } from "rxjs/operators";
import { Subject, distinctUntilChanged, filter, map, of, merge, startWith, catchError, concat, firstValueFrom, BehaviorSubject, from, fromEvent, timer, EMPTY, defer, mergeMap, throwError, share, partition, throttleTime, asyncScheduler, NEVER, tap as tap$1, debounce } from "rxjs";
import * as PathUtils from "@sanity/util/paths";
import { fromString, get, resolveKeyedPath, toString } from "@sanity/util/paths";
import uniqBy from "lodash/uniqBy.js";
import negate from "lodash/negate.js";
import { MenuGroup } from "./MenuGroup.mjs";
import { isValidationErrorMarker, isSanityDocument as isSanityDocument$1, isKeySegment, isIndexSegment, isReferenceSchemaType, isObjectSchemaType, isDocumentSchemaType } from "@sanity/types";
import { useTelemetry } from "@sanity/telemetry/react";
import fromPairs from "lodash/fromPairs.js";
import toPairs from "lodash/toPairs.js";
import { defineEvent } from "@sanity/telemetry";
import ScrollMirror from "scrollmirror";
import noop from "lodash/noop.js";
import deepEquals from "react-fast-compare";
import { isHotkey } from "is-hotkey-esm";
import { JsonInspector } from "@rexxars/react-json-inspector";
import QuickLRU from "quick-lru";
import { isAfter, addWeeks, isBefore, format } from "date-fns";
import { useEffectEvent } from "use-effect-event";
import { getTheme_v2, rgba } from "@sanity/ui/theme";
import { parse } from "groq-js";
import { ChannelError, ServerError, ClientError } from "@sanity/client";
import { observableCallback } from "observable-callback";
import { exhaustMapWithTrailing } from "rxjs-exhaustmap-with-trailing";
import { flexRender, createColumnHelper, useReactTable, getPaginationRowModel, getFilteredRowModel, getCoreRowModel } from "@tanstack/react-table";
function useCreatePathSyncChannel() {
const $ = c(1);
let t0, t1;
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = new Subject(), $[0] = t1) : t1 = $[0], t0 = t1, t0;
}
const DIFF_VIEW_SEARCH_PARAMETER = "diffView", DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER = "previousDocument", DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER = "nextDocument", DIFF_SEARCH_PARAM_DELIMITER = ",";
function useDiffViewRouter() {
const $ = c(9), {
navigate,
state: routerState
} = useRouter();
let t0;
$[0] !== navigate || $[1] !== routerState ? (t0 = (t12) => {
const {
mode,
previousDocument,
nextDocument
} = t12, next = {
...fromPairs(routerState._searchParams),
...mode ? {
[DIFF_VIEW_SEARCH_PARAMETER]: mode
} : {},
...previousDocument ? {
[DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER]: [previousDocument.type, previousDocument.id].join(DIFF_SEARCH_PARAM_DELIMITER)
} : {},
...nextDocument ? {
[DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER]: [nextDocument.type, nextDocument.id].join(DIFF_SEARCH_PARAM_DELIMITER)
} : {}
};
navigate({
...routerState,
_searchParams: toPairs(next)
});
}, $[0] = navigate, $[1] = routerState, $[2] = t0) : t0 = $[2];
const navigateDiffView = t0;
let t1;
$[3] !== navigate || $[4] !== routerState ? (t1 = () => {
navigate({
...routerState,
_searchParams: (routerState._searchParams ?? []).filter(_temp$s)
});
}, $[3] = navigate, $[4] = routerState, $[5] = t1) : t1 = $[5];
const exitDiffView = t1;
let t2;
return $[6] !== exitDiffView || $[7] !== navigateDiffView ? (t2 = {
navigateDiffView,
exitDiffView
}, $[6] = exitDiffView, $[7] = navigateDiffView, $[8] = t2) : t2 = $[8], t2;
}
function _temp$s(t0) {
const [key] = t0;
return ![DIFF_VIEW_SEARCH_PARAMETER, DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER, DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER].includes(key);
}
const diffViewModes = ["version"];
function isDiffViewMode(maybeDiffViewMode) {
return diffViewModes.includes(maybeDiffViewMode);
}
function useDiffViewState({
onParamsError
} = {}) {
const {
state: routerState
} = useRouter(), searchParams = new URLSearchParams(routerState._searchParams), previousDocument = searchParams.get(DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER), nextDocument = searchParams.get(DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER), mode = searchParams.get(DIFF_VIEW_SEARCH_PARAMETER), anyParamSet = [previousDocument, nextDocument, mode].some((param) => param !== null), params = useMemo(() => parseParams({
previousDocument: previousDocument ?? "",
nextDocument: nextDocument ?? "",
mode: mode ?? ""
}), [mode, nextDocument, previousDocument]);
return useEffect(() => {
params.result === "error" && anyParamSet && onParamsError?.(params.errors);
}, [anyParamSet, onParamsError, params]), params.result === "error" ? {
isActive: !1
} : {
state: "ready",
isActive: !0,
...params.params
};
}
function parseParams({
previousDocument,
nextDocument,
mode
}) {
const errors = [], [previousDocumentType, previousDocumentId] = previousDocument.split(DIFF_SEARCH_PARAM_DELIMITER).filter(Boolean), [nextDocumentType, nextDocumentId] = nextDocument.split(DIFF_SEARCH_PARAM_DELIMITER).filter(Boolean);
return isDiffViewMode(mode) || errors.push(["invalidModeParam", mode]), (typeof previousDocumentType > "u" || typeof previousDocumentId > "u") && errors.push(["invalidPreviousDocumentParam", previousDocument]), (typeof nextDocumentType > "u" || typeof nextDocumentId > "u") && errors.push(["invalidNextDocumentParam", nextDocument]), errors.length !== 0 ? {
result: "error",
errors
} : {
result: "success",
params: {
mode,
documents: {
previous: {
type: previousDocumentType,
id: previousDocumentId
},
next: {
type: nextDocumentType,
id: nextDocumentId
}
}
}
};
}
function useScrollMirror(elements) {
const $ = c(3);
let t0, t1;
$[0] !== elements ? (t0 = () => {
const existentElements = elements.filter(_temp$r);
if (existentElements.length === 0)
return;
const scrollMirror = new ScrollMirror(existentElements);
return () => scrollMirror.destroy();
}, t1 = [elements], $[0] = elements, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1);
}
function _temp$r(element) {
return element !== null;
}
const VersionModeHeaderLayout = styled.header`
display: grid;
grid-area: header;
grid-template-columns: 1fr min-content 1fr;
border-block-end: 1px solid var(--card-border-color);
`, VersionModeHeaderLayoutSection = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`, VersionModeHeader = ({
documentId,
state: state2
}) => {
const {
t
} = useTranslation(structureLocaleNamespace), {
data: documentVersions
} = useDocumentVersions({
documentId
}), {
exitDiffView,
navigateDiffView
} = useDiffViewRouter(), {
documents
} = useDiffViewState(), activeReleases = useActiveReleases(), releasesIds = documentVersions.flatMap((id) => getVersionFromId(id) ?? []), releases = useMemo(() => activeReleases.data.filter((release) => {
const releaseId = getReleaseIdFromReleaseDocumentId(release._id);
return typeof releaseId < "u" && releasesIds.includes(releaseId);
}), [activeReleases.data, releasesIds]), onSelectPreviousRelease = useCallback((selectedDocumentId) => {
typeof documents?.previous < "u" && navigateDiffView({
previousDocument: {
...documents.previous,
id: selectedDocumentId
}
});
}, [documents?.previous, navigateDiffView]), onSelectNextRelease = useCallback((selectedDocumentId_0) => {
typeof documents?.next < "u" && navigateDiffView({
nextDocument: {
...documents.next,
id: selectedDocumentId_0
}
});
}, [documents?.next, navigateDiffView]);
return /* @__PURE__ */ jsxs(VersionModeHeaderLayout, { children: [
/* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [
/* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Text, { as: "h1", size: 1, muted: !0, children: t("compare-versions.title") }) }),
typeof documents?.previous < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, onSelectRelease: onSelectPreviousRelease, role: "previous", documentId, state: state2, document: documents.previous })
] }),
/* @__PURE__ */ jsx(Flex, { align: "center", paddingX: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(TransferIcon, {}) }) }),
/* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [
typeof documents?.next < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, onSelectRelease: onSelectNextRelease, role: "next", documentId, state: state2, document: documents.next }),
/* @__PURE__ */ jsx(Box, { padding: 3, style: {
justifySelf: "end"
}, children: /* @__PURE__ */ jsx(Button, { icon: CloseIcon, mode: "bleed", onClick: exitDiffView, padding: 2 }) })
] })
] });
}, VersionMenu = ({
releases = [],
onSelectRelease,
role,
documentId,
document: document2
}) => {
const {
published,
draft
} = useEditState(getPublishedId(document2.id), document2.type), selected = useMemo(() => findRelease(document2.id, releases), [document2.id, releases]), {
t: tStructure
} = useTranslation(structureLocaleNamespace), {
t: tCore
} = useTranslation(), {
document: {
drafts: {
enabled: isDraftModelEnabled
}
}
} = useWorkspace();
return /* @__PURE__ */ jsx(MenuButton, { id: role, button: /* @__PURE__ */ jsx(Button, { type: "button", mode: "bleed", padding: 2, paddingRight: 3, radius: "full", selected: !0, ...getMenuButtonProps({
selected,
tCore,
tStructure
}) }), menu: /* @__PURE__ */ jsxs(Menu, { children: [
published && /* @__PURE__ */ jsx(VersionMenuItem, { type: "published", onSelect: onSelectRelease, isSelected: selected === "published", documentId }),
isDraftModelEnabled && draft && /* @__PURE__ */ jsx(VersionMenuItem, { type: "draft", onSelect: onSelectRelease, isSelected: selected === "draft", documentId }),
releases.map((release) => /* @__PURE__ */ jsx(VersionMenuItem, { release, onSelect: onSelectRelease, isSelected: typeof selected != "string" && selected?._id === release._id, documentId }, release._id))
] }) });
}, VersionMenuItem = ({
type,
release,
onSelect,
isSelected,
documentId
}) => {
const {
t: tCore
} = useTranslation(), {
t: tStructure
} = useTranslation(structureLocaleNamespace), onClick = useCallback(() => {
if (type === "draft") {
onSelect(getDraftId(documentId));
return;
}
if (type === "published") {
onSelect(getPublishedId(documentId));
return;
}
typeof release?._id < "u" && onSelect(getVersionId(documentId, getReleaseIdFromReleaseDocumentId(release._id)));
}, [type, onSelect, documentId, release?._id]);
if (type)
return /* @__PURE__ */ jsx(MenuItem, { padding: 1, paddingRight: 3, onClick, pressed: isSelected, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
/* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, tone: type === "published" ? "positive" : "caution" }),
/* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: tStructure(["compare-versions.status", type].join(".")) }) })
] }) });
const tone_0 = release ? getReleaseTone(release) : "neutral";
return /* @__PURE__ */ jsx(MenuItem, { padding: 1, paddingRight: 3, onClick, pressed: isSelected, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
/* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, tone: tone_0 }),
/* @__PURE__ */ jsxs(Stack, { flex: 1, paddingY: 2, paddingRight: 2, space: 2, children: [
/* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: release.metadata.title || tCore("release.placeholder-untitled-release") }),
["asap", "undecided"].includes(release.metadata.releaseType) && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: tCore(`release.type.${release.metadata.releaseType}`) }),
release.metadata.releaseType === "scheduled" && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: formatRelativeLocalePublishDate(release) })
] }),
/* @__PURE__ */ jsx(Flex, { flex: "none", children: isReleaseScheduledOrScheduling(release) && /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(LockIcon, {}) }) }) })
] }) });
};
function getMenuButtonProps({
selected,
tCore,
tStructure
}) {
if (typeof selected > "u")
return {
text: tCore("common.loading"),
tone: "neutral",
disabled: !0
};
if (isReleaseDocument(selected)) {
const tone2 = selected ? getReleaseTone(selected) : "neutral";
return {
text: selected?.metadata.title || tCore("release.placeholder-untitled-release"),
icon: /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 1, tone: tone2 }),
iconRight: selected && isReleaseScheduledOrScheduling(selected) ? /* @__PURE__ */ jsx(LockIcon, {}) : void 0,
tone: tone2
};
}
const tone = selected === "published" ? "positive" : "caution";
return {
text: tStructure(["compare-versions.status", selected].join(".")),
icon: /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 1, tone }),
tone
};
}
function findRelease(documentId, releases) {
return isPublishedId(documentId) ? "published" : isDraftId(documentId) ? "draft" : releases.find(({
_id
}) => getReleaseIdFromReleaseDocumentId(_id) === getVersionFromId(documentId));
}
const DialogLayout = styled.div`
--offset-block: 40px;
display: grid;
height: calc(100vh - var(--offset-block));
min-height: 0;
overflow: hidden;
grid-template-areas:
'header header'
'previous-document next-document';
grid-template-columns: 1fr 1fr;
grid-template-rows: min-content minmax(0, 1fr);
`;
function pickDocumentLayoutComponent(plugin) {
return plugin.document?.components?.unstable_layout;
}
function usePathSyncChannel(t0) {
const $ = c(11), {
syncChannel,
id
} = t0;
let t1;
$[0] !== id || $[1] !== syncChannel ? (t1 = (state2) => syncChannel.next({
...state2,
source: id
}), $[0] = id, $[1] = syncChannel, $[2] = t1) : t1 = $[2];
const push = t1;
let t2, t3;
if ($[3] !== id || $[4] !== syncChannel) {
let t42;
$[6] !== id ? (t42 = (t5) => {
const {
source
} = t5;
return source !== id;
}, $[6] = id, $[7] = t42) : t42 = $[7], t3 = syncChannel.pipe(distinctUntilChanged(_temp$q), filter(t42), map(_temp2$9)), $[3] = id, $[4] = syncChannel, $[5] = t3;
} else
t3 = $[5];
t2 = t3;
const path = t2;
let t4;
return $[8] !== path || $[9] !== push ? (t4 = {
path,
push
}, $[8] = path, $[9] = push, $[10] = t4) : t4 = $[10], t4;
}
function _temp2$9(state_0) {
return state_0.path;
}
function _temp$q(previous, next) {
return deepEquals(previous.path, next.path);
}
const Scroller$5 = styled.div`
position: relative;
height: 100%;
overflow: auto;
scroll-behavior: smooth;
scrollbar-width: var(--scrollbar-width);
overscroll-behavior: contain;
will-change: scroll-position;
`, DiffViewPaneLayout = styled(Card)`
position: relative;
grid-area: var(--grid-area);
`, Container = styled(Container$1)`
width: auto;
`, DiffViewPane = forwardRef(function(t0, ref) {
const $ = c(36), {
role,
documentType,
documentId,
scrollElement,
syncChannel,
compareDocument
} = t0, containerElement = useRef(null), [portalElement, setPortalElement] = useState(null), [boundaryElement, setBoundaryElement] = useState(null);
let t1;
$[0] !== compareDocument || $[1] !== documentId || $[2] !== documentType || $[3] !== role || $[4] !== scrollElement || $[5] !== syncChannel ? (t1 = () => /* @__PURE__ */ jsx(DiffViewDocument, { compareDocument, documentId, documentType, role, scrollElement, syncChannel }), $[0] = compareDocument, $[1] = documentId, $[2] = documentType, $[3] = role, $[4] = scrollElement, $[5] = syncChannel, $[6] = t1) : t1 = $[6];
const t2 = t1;
let t3;
$[7] !== t2 ? (t3 = {
pick: pickDocumentLayoutComponent,
defaultComponent: t2
}, $[7] = t2, $[8] = t3) : t3 = $[8];
const DocumentLayout2 = useMiddlewareComponents(t3);
let t4;
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
isInteractive: !1,
onOpenReviewChanges: noop,
onSetFocus: noop,
isReviewChangesOpen: !1
}, $[9] = t4) : t4 = $[9];
const t5 = `${role}-document`;
let t6;
$[10] !== t5 ? (t6 = {
"--grid-area": t5
}, $[10] = t5, $[11] = t6) : t6 = $[11];
const t7 = t6, t8 = role === "next", t9 = role !== "next" && "none";
let t10;
$[12] !== t9 ? (t10 = {
"--scrollbar-width": t9
}, $[12] = t9, $[13] = t10) : t10 = $[13];
const t11 = t10;
let t12;
$[14] !== DocumentLayout2 || $[15] !== documentId || $[16] !== documentType ? (t12 = /* @__PURE__ */ jsx(DialogProvider, { position: "absolute", children: /* @__PURE__ */ jsx(Container, { ref: containerElement, padding: 4, width: 1, children: /* @__PURE__ */ jsx(DocumentLayout2, { documentId, documentType }) }) }), $[14] = DocumentLayout2, $[15] = documentId, $[16] = documentType, $[17] = t12) : t12 = $[17];
let t13;
$[18] !== portalElement || $[19] !== t12 ? (t13 = /* @__PURE__ */ jsx(PortalProvider, { element: portalElement, children: t12 }), $[18] = portalElement, $[19] = t12, $[20] = t13) : t13 = $[20];
let t14;
$[21] !== ref || $[22] !== t11 || $[23] !== t13 ? (t14 = /* @__PURE__ */ jsx(Scroller$5, { ref, style: t11, children: t13 }), $[21] = ref, $[22] = t11, $[23] = t13, $[24] = t14) : t14 = $[24];
let t15;
$[25] === Symbol.for("react.memo_cache_sentinel") ? (t15 = /* @__PURE__ */ jsx("div", { "data-testid": "diffView-document-panel-portal", ref: setPortalElement }), $[25] = t15) : t15 = $[25];
let t16;
$[26] !== t14 || $[27] !== t7 || $[28] !== t8 ? (t16 = /* @__PURE__ */ jsxs(DiffViewPaneLayout, { ref: setBoundaryElement, style: t7, borderLeft: t8, children: [
t14,
t15
] }), $[26] = t14, $[27] = t7, $[28] = t8, $[29] = t16) : t16 = $[29];
let t17;
$[30] !== boundaryElement || $[31] !== t16 ? (t17 = /* @__PURE__ */ jsx(BoundaryElementProvider, { element: boundaryElement, children: t16 }), $[30] = boundaryElement, $[31] = t16, $[32] = t17) : t17 = $[32];
let t18;
return $[33] !== scrollElement || $[34] !== t17 ? (t18 = /* @__PURE__ */ jsx(ReviewChangesContext.Provider, { value: t4, children: /* @__PURE__ */ jsx(ChangeIndicatorsTracker, { children: /* @__PURE__ */ jsx(VirtualizerScrollInstanceProvider, { scrollElement, containerElement, children: t17 }) }) }), $[33] = scrollElement, $[34] = t17, $[35] = t18) : t18 = $[35], t18;
}), DiffViewDocument = (t0) => {
const $ = c(56), {
role,
documentType,
documentId,
syncChannel,
compareDocument
} = t0;
let t1;
$[0] !== compareDocument ? (t1 = {
compareDocument
}, $[0] = compareDocument, $[1] = t1) : t1 = $[1];
const compareValue = useCompareValue(t1), [patchChannel] = useState(_temp$p);
let t2;
$[2] !== documentId ? (t2 = getPublishedId(documentId), $[2] = documentId, $[3] = t2) : t2 = $[3];
let t3;
$[4] !== documentId ? (t3 = perspectiveName(documentId), $[4] = documentId, $[5] = t3) : t3 = $[5];
let t4;
$[6] !== documentId ? (t4 = getVersionFromId(documentId), $[6] = documentId, $[7] = t4) : t4 = $[7];
let t5;
$[8] !== compareValue || $[9] !== documentType || $[10] !== t2 || $[11] !== t3 || $[12] !== t4 ? (t5 = {
documentId: t2,
documentType,
selectedPerspectiveName: t3,
releaseId: t4,
comparisonValue: compareValue
}, $[8] = compareValue, $[9] = documentType, $[10] = t2, $[11] = t3, $[12] = t4, $[13] = t5) : t5 = $[13];
const t6 = useDocumentForm(t5);
let collapsedFieldSets, collapsedPaths, documentForm, formState, onBlur, onChange, onFocus, onProgrammaticFocus, onSetActiveFieldGroup, onSetCollapsedFieldSet, onSetCollapsedPath, ready, schemaType, value;
$[14] !== t6 ? ({
formState,
onChange,
onFocus,
onBlur,
onSetActiveFieldGroup,
onSetCollapsedFieldSet,
onSetCollapsedPath,
collapsedFieldSets,
ready,
collapsedPaths,
schemaType,
value,
onProgrammaticFocus,
...documentForm
} = t6, $[14] = t6, $[15] = collapsedFieldSets, $[16] = collapsedPaths, $[17] = documentForm, $[18] = formState, $[19] = onBlur, $[20] = onChange, $[21] = onFocus, $[22] = onProgrammaticFocus, $[23] = onSetActiveFieldGroup, $[24] = onSetCollapsedFieldSet, $[25] = onSetCollapsedPath, $[26] = ready, $[27] = schemaType, $[28] = value) : (collapsedFieldSets = $[15], collapsedPaths = $[16], documentForm = $[17], formState = $[18], onBlur = $[19], onChange = $[20], onFocus = $[21], onProgrammaticFocus = $[22], onSetActiveFieldGroup = $[23], onSetCollapsedFieldSet = $[24], onSetCollapsedPath = $[25], ready = $[26], schemaType = $[27], value = $[28]);
const isLoading = formState === null || !ready;
let t7;
$[29] !== role || $[30] !== syncChannel ? (t7 = {
id: role,
syncChannel
}, $[29] = role, $[30] = syncChannel, $[31] = t7) : t7 = $[31];
const pathSyncChannel = usePathSyncChannel(t7);
let t8;
$[32] !== documentForm || $[33] !== pathSyncChannel || $[34] !== role ? (t8 = (path) => {
documentForm.onPathOpen(path), pathSyncChannel.push({
source: role,
path
});
}, $[32] = documentForm, $[33] = pathSyncChannel, $[34] = role, $[35] = t8) : t8 = $[35];
const onPathOpen = t8;
let t10, t9;
$[36] !== onProgrammaticFocus || $[37] !== pathSyncChannel.path ? (t9 = () => {
const subscription = pathSyncChannel.path.subscribe(onProgrammaticFocus);
return () => subscription.unsubscribe();
}, t10 = [onProgrammaticFocus, pathSyncChannel.path], $[36] = onProgrammaticFocus, $[37] = pathSyncChannel.path, $[38] = t10, $[39] = t9) : (t10 = $[38], t9 = $[39]), useEffect(t9, t10);
let t11;
return $[40] !== collapsedFieldSets || $[41] !== collapsedPaths || $[42] !== formState || $[43] !== isLoading || $[44] !== onBlur || $[45] !== onChange || $[46] !== onFocus || $[47] !== onPathOpen || $[48] !== onSetActiveFieldGroup || $[49] !== onSetCollapsedFieldSet || $[50] !== onSetCollapsedPath || $[51] !== patchChannel || $[52] !== role || $[53] !== schemaType || $[54] !== value ? (t11 = isLoading ? /* @__PURE__ */ jsx(LoadingBlock, { showText: !0 }) : /* @__PURE__ */ jsx(CommentsEnabledContext.Provider, { value: {
enabled: !1,
mode: null
}, children: /* @__PURE__ */ jsx(FormBuilder, { __internal_patchChannel: patchChannel, id: `diffView-pane-${role}`, onChange, onPathFocus: onFocus, onPathOpen, onPathBlur: onBlur, onFieldGroupSelect: onSetActiveFieldGroup, onSetFieldSetCollapsed: onSetCollapsedFieldSet, onSetPathCollapsed: onSetCollapsedPath, collapsedPaths, collapsedFieldSets, focusPath: formState.focusPath, changed: formState.changed, focused: formState.focused, groups: formState.groups, validation: formState.validation, members: formState.members, presence: formState.presence, schemaType, value }) }), $[40] = collapsedFieldSets, $[41] = collapsedPaths, $[42] = formState, $[43] = isLoading, $[44] = onBlur, $[45] = onChange, $[46] = onFocus, $[47] = onPathOpen, $[48] = onSetActiveFieldGroup, $[49] = onSetCollapsedFieldSet, $[50] = onSetCollapsedPath, $[51] = patchChannel, $[52] = role, $[53] = schemaType, $[54] = value, $[55] = t11) : t11 = $[55], t11;
};
function perspectiveName(documentId) {
if (isVersionId(documentId))
return getVersionFromId(documentId);
if (isPublishedId(documentId))
return "published";
}
function useCompareValue(t0) {
const $ = c(4), {
compareDocument
} = t0;
let t1;
$[0] !== compareDocument.id ? (t1 = getPublishedId(compareDocument.id), $[0] = compareDocument.id, $[1] = t1) : t1 = $[1];
const t2 = compareDocument.type;
let t3;
$[2] !== compareDocument.id ? (t3 = getVersionFromId(compareDocument.id), $[2] = compareDocument.id, $[3] = t3) : t3 = $[3];
const compareDocumentEditState = useEditState(t1, t2, "low", t3);
let t4;
bb0: {
if (isVersionId(compareDocument.id)) {
t4 = compareDocumentEditState.version ?? void 0;
break bb0;
}
if (isDraftId(compareDocument.id)) {
t4 = compareDocumentEditState.draft ?? void 0;
break bb0;
}
if (isPublishedId(compareDocument.id)) {
t4 = compareDocumentEditState.published ?? void 0;
break bb0;
}
t4 = void 0;
}
return t4;
}
function _temp$p() {
return createPatchChannel();
}
const Link = styled.a`
flex: 1;
text-decoration: none;
color: inherit;
`, EditReferenceLinkComponent = (t0) => {
const $ = c(6), {
children,
documentId: _documentId,
documentType
} = t0;
let t1;
$[0] !== _documentId || $[1] !== documentType ? (t1 = {
intent: "edit",
params: {
id: _documentId,
type: documentType
}
}, $[0] = _documentId, $[1] = documentType, $[2] = t1) : t1 = $[2];
const {
href
} = useIntentLink(t1);
let t2;
return $[3] !== children || $[4] !== href ? (t2 = /* @__PURE__ */ jsx(Link, { href, target: "_blank", rel: "noopener noreferrer", children }), $[3] = children, $[4] = href, $[5] = t2) : t2 = $[5], t2;
}, DiffView = (t0) => {
const $ = c(24), {
documentId
} = t0, {
documents,
state: state2,
mode
} = useDiffViewState(), {
exitDiffView
} = useDiffViewRouter(), syncChannel = useCreatePathSyncChannel(), [previousPaneElement, setPreviousPaneElement] = useState(null), [nextPaneElement, setNextPaneElement] = useState(null), referenceInputOptionsContext = useContext(ReferenceInputOptionsContext);
let t1, t2;
$[0] !== referenceInputOptionsContext ? (t2 = {
...referenceInputOptionsContext,
disableNew: !0,
EditReferenceLinkComponent
}, $[0] = referenceInputOptionsContext, $[1] = t2) : t2 = $[1], t1 = t2;
const diffViewReferenceInputOptionsContext = t1;
let t3;
$[2] !== nextPaneElement || $[3] !== previousPaneElement ? (t3 = [previousPaneElement, nextPaneElement], $[2] = nextPaneElement, $[3] = previousPaneElement, $[4] = t3) : t3 = $[4], useScrollMirror(t3);
let t4;
$[5] !== documentId || $[6] !== mode || $[7] !== state2 ? (t4 = mode === "version" && /* @__PURE__ */ jsx(VersionModeHeader, { documentId, state: state2 }), $[5] = documentId, $[6] = mode, $[7] = state2, $[8] = t4) : t4 = $[8];
let t5;
$[9] !== documents || $[10] !== nextPaneElement || $[11] !== previousPaneElement || $[12] !== state2 || $[13] !== syncChannel ? (t5 = state2 === "ready" && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(DiffViewPane, { documentType: documents.previous.type, documentId: documents.previous.id, role: "previous", ref: setPreviousPaneElement, scrollElement: previousPaneElement, syncChannel, compareDocument: documents.previous }),
/* @__PURE__ */ jsx(DiffViewPane, { documentType: documents.next.type, documentId: documents.next.id, role: "next", ref: setNextPaneElement, scrollElement: nextPaneElement, syncChannel, compareDocument: documents.previous })
] }), $[9] = documents, $[10] = nextPaneElement, $[11] = previousPaneElement, $[12] = state2, $[13] = syncChannel, $[14] = t5) : t5 = $[14];
let t6;
$[15] !== t4 || $[16] !== t5 ? (t6 = /* @__PURE__ */ jsxs(DialogLayout, { children: [
t4,
t5
] }), $[15] = t4, $[16] = t5, $[17] = t6) : t6 = $[17];
let t7;
$[18] !== exitDiffView || $[19] !== t6 ? (t7 = /* @__PURE__ */ jsx(Dialog, { id: "diffView", width: "auto", onClose: exitDiffView, padding: !1, __unstable_hideCloseButton: !0, children: t6 }), $[18] = exitDiffView, $[19] = t6, $[20] = t7) : t7 = $[20];
let t8;
return $[21] !== diffViewReferenceInputOptionsContext || $[22] !== t7 ? (t8 = /* @__PURE__ */ jsx(ReferenceInputOptionsContext.Provider, { value: diffViewReferenceInputOptionsContext, children: t7 }), $[21] = diffViewReferenceInputOptionsContext, $[22] = t7, $[23] = t8) : t8 = $[23], t8;
}, DiffViewDocumentLayout = (t0) => {
const $ = c(9), {
children,
documentId
} = t0, toast = useToast(), {
t
} = useTranslation(structureLocaleNamespace);
let t1;
$[0] !== t || $[1] !== toast ? (t1 = {
onParamsError: (errors) => {
toast.push({
id: "diffViewParamsParsingError",
status: "error",
title: t("compare-version.error.invalidParams.title"),
description: /* @__PURE__ */ jsx("ul", { children: errors.map((t22) => {
const [error, input] = t22;
return /* @__PURE__ */ jsx("li", { children: t(`compare-version.error.${error}`, {
input
}) }, error);
}) })
});
}
}, $[0] = t, $[1] = toast, $[2] = t1) : t1 = $[2];
const {
isActive
} = useDiffViewState(t1);
let t2;
$[3] !== documentId || $[4] !== isActive ? (t2 = isActive && /* @__PURE__ */ jsx(DiffView, { documentId }), $[3] = documentId, $[4] = isActive, $[5] = t2) : t2 = $[5];
let t3;
return $[6] !== children || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Fragment, { children: [
children,
t2
] }), $[6] = children, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
}, PANE_DEBUG = !1, PANE_COLLAPSED_WIDTH = 51, PANE_DEFAULT_MIN_WIDTH = 204;
function usePaneLayout() {
const pane2 = useContext(PaneLayoutContext);
if (!pane2)
throw new Error("PaneLayout: missing context value");
return pane2;
}
const Root$9 = styled(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 $ = c(7), {
disabled,
element
} = t0, {
resize
} = usePaneLayout(), [dragging, setDragging] = 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__ */ 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 = styled(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 = forwardRef(function(props, forwardedRef) {
const $ = 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] = 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 = 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], 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]), 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__ */ jsx(LegacyLayerProvider, { zOffset: "paneResizer", children: /* @__PURE__ */ 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__ */ jsx(Flex, { direction: "column", height: "fill", children }), $[60] = children, $[61] = hidden, $[62] = t23) : t23 = $[62];
let t24;
$[63] !== rootElement || $[64] !== t23 ? (t24 = /* @__PURE__ */ jsx(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__ */ jsxs(Root$8, { "data-testid": "pane", "data-ui": "Pane", tone: "inherit", hidden, id, overflow: t19, ...restProps, "data-pane-collapsed": t20, "data-pane-index": paneIndex, "data-pane-selected": t21, ref: setRef, style, children: [
t22,
t24
] }), $[66] = hidden, $[67] = id, $[68] = paneIndex, $[69] = restProps, $[70] = style, $[71] = t19, $[72] = t20, $[73] = t21, $[74] = t22, $[75] = t24, $[76] = t25) : t25 = $[76];
let t26;
$[77] !== isLast || $[78] !== t25 ? (t26 = /* @__PURE__ */ jsx(IsLastPaneProvider, { isLastPane: isLast, children: t25 }), $[77] = isLast, $[78] = t25, $[79] = t26) : t26 = $[79];
let t27;
$[80] !== contextValue || $[81] !== t26 ? (t27 = /* @__PURE__ */ jsx(LegacyLayerProvider, { zOffset: "pane", children: /* @__PURE__ */ jsx(PaneContext.Provider, { value: contextValue, children: t26 }) }), $[80] = contextValue, $[81] = t26, $[82] = t27) : t27 = $[82];
let t28;
return $[83] !== divider || $[84] !== t27 ? (t28 = /* @__PURE__ */ jsxs(Fragment, { children: [
t27,
divider
] }), $[83] = divider, $[84] = t27, $[85] = t28) : t28 = $[85], t28;
}), Root$7 = styled(Card)`
position: relative;
outline: none;
`;
Root$7.displayName = "PaneContent__root";
function usePane() {
const pane2 = useContext(PaneContext);
if (!pane2)
throw new Error("Pane: missing context value");
return pane2;
}
const PaneContent = forwardRef(function(props, ref) {
const $ = c(14);
let as, children, overflow, padding, restProps;
$[0] !== props ? ({
as,
children,
overflow,
padding,
...restProps
} = props, $[0] = props, $[1] = as, $[2] = children, $[3] = overflow, $[4] = padding, $[5] = restProps) : (as = $[1], children = $[2], overflow = $[3], padding = $[4], restProps = $[5]);
const {
collapsed
} = usePane(), {
collapsed: layoutCollapsed
} = usePaneLayout(), t0 = layoutCollapsed ? void 0 : overflow;
let t1;
return $[6] !== as || $[7] !== children || $[8] !== collapsed || $[9] !== padding || $[10] !== ref || $[11] !== restProps || $[12] !== t0 ? (t1 = /* @__PURE__ */ jsx(Root$7, { "data-testid": "pane-content", forwardedAs: as, ...restProps, flex: 1, hidden: collapsed, overflow: t0, padding, ref, tone: "inherit", children }), $[6] = as, $[7] = children, $[8] = collapsed, $[9] = padding, $[10] = ref, $[11] = restProps, $[12] = t0, $[13] = t1) : t1 = $[13], t1;
});
function toLowerCaseNoSpaces(str) {
return str ? str.toLocaleLowerCase().replaceAll(" ", "") : "";
}
const MENU_GROUP_POPOVER_PROPS = {
constrainSize: !0,
placement: "left-start",
portal: !0
};
function PaneMenuButtonItem(props) {
const $ = c(35), {
disabled,
isAfterGroup,
node
} = props, getI18nText = useGetI18nText("i18n" in node ? node : void 0);
if (node.type === "divider") {
let t02;
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(MenuDivider, {}), $[0] = t02) : t02 = $[0], t02;
}
let t0;
$[1] !== getI18nText || $[2] !== node ? (t0 = getI18nText(node), $[1] = getI18nText, $[2] = node, $[3] = t0) : t0 = $[3];
const {
title
} = t0;
if (node.type === "group") {
if (node.children.length === 0)
return null;
if (node.expanded) {
let t13;
$[4] !== isAfterGroup ? (t13 = isAfterGroup && /* @__PURE__ */ jsx(MenuDivider, {}), $[4] = isAfterGroup, $[5] = t13) : t13 = $[5];
let t23;
$[6] !== disabled || $[7] !== node.children || $[8] !== node.disabled ? (t23 = node.children.map((child, childIndex) => /* @__PURE__ */ jsx(PaneMenuButtonItem, { disabled: disabled || !!node.disabled, isAfterGroup: node.children[childIndex - 1]?.type === "group", node: child }, child.key)), $[6] = disabled, $[7] = node.children, $[8] = node.disabled, $[9] = t23) : t23 = $[9];
let t33;
return $[10] !== t13 || $[11] !== t23 ? (t33 = /* @__PURE__ */ jsxs(Fragment, { children: [
t13,
t23
] }), $[10] = t13, $[11] = t23, $[12] = t33) : t33 = $[12], t33;
}
let t12;
$[13] !== isAfterGroup ? (t12 = isAfterGroup && /* @__PURE__ */ jsx(MenuDivider, {}), $[13] = isAfterGroup, $[14] = t12) : t12 = $[14];
const t22 = node.icon;
let t32;
$[15] !== disabled || $[16] !== node.children || $[17] !== node.disabled ? (t32 = node.children.map((child_0, childIndex_0) => /* @__PURE__ */ jsx(PaneMenuButtonItem, { disabled: disabled || !!node.disabled, isAfterGroup: node.children[childIndex_0 - 1]?.type === "group", node: child_0 }, child_0.key)), $[15] = disabled, $[16] = node.children, $[17] = node.disabled, $[18] = t32) : t32 = $[18];
let t4;
$[19] !== disabled || $[20] !== node.icon || $[21] !== t32 || $[22] !== title ? (t4 = /* @__PURE__ */ jsx(MenuGroup, { disabled, icon: t22, popover: MENU_GROUP_POPOVER_PROPS, text: title, children: t32 }), $[19] = disabled, $[20] = node.icon, $[21] = t32, $[22] = title, $[23] = t4) : t4 = $[23];
let t5;
return $[24] !== t12 || $[25] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
t12,
t4
] }), $[24] = t12, $[25] = t4, $[26] = t5) : t5 = $[26], t5;
}
let t1;
$[27] !== isAfterGroup ? (t1 = isAfterGroup && /* @__PURE__ */ jsx(MenuDivider, {}), $[27] = isAfterGroup, $[28] = t1) : t1 = $[28];
let t2;
$[29] !== disabled || $[30] !== node ? (t2 = /* @__PURE__ */ jsx(PaneContextMenuItemResolver, { disabled, node }), $[29] = disabled, $[30] = n