UNPKG

sanity

Version:

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

879 lines (878 loc) • 655 kB
import { jsxs, jsx, Fragment } from "react/jsx-runtime"; import { c } from "react/compiler-runtime"; import { Box, Text, Flex, Button, Badge, 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, Dialog as Dialog$1, Popover as Popover$1, useLayer, useGlobalKeyDown, AvatarStack, Skeleton } from "@sanity/ui"; import { useEffect, forwardRef, useRef, useState, useContext, useImperativeHandle, useLayoutEffect, useId, memo, useEffectEvent, Fragment as Fragment$1, useDeferredValue, lazy, Suspense, startTransition } from "react"; import { ReviewChangesContext, CommentsEnabledContext, ReferenceInputOptionsContext, PaneLayoutContext, PaneContext, DocumentPaneContext, DocumentActionsStateContext, StructureToolContext, DocumentPaneInfoContext, PaneRouterContext, ResolvedPanesContext, EventsContext, DocumentChangeContext } from "sanity/_singletons"; import { motion, AnimatePresence } from "motion/react"; import { isPublishedId, isDraftId, getReleaseIdFromReleaseDocumentId, getVersionFromId, useTranslation, useDocumentVersions, useActiveReleases, getPublishedId, useEditState, useWorkspace, isReleaseDocument, getReleaseTone, isReleaseScheduledOrScheduling, ReleaseAvatar, isSystemBundleName, PUBLISHED, LATEST, formatRelativeLocalePublishDate, getDraftId, getVersionId, ReleaseTitle, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, LoadingBlock, FormBuilder, isVersionId, createPatchChannel, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, isDev, CommentsEnabledProvider, useCommentsEnabled, usePerspective, CommentsProvider, COMMENTS_INSPECTOR_NAME, GetHookCollectionState, EMPTY_ARRAY as EMPTY_ARRAY$2, getDocumentIdForCanvasLink, useCanvasCompanionDoc, useUnique, isPublishedPerspective, prepareForPreview, useValuePreview, useDocumentOperationEvent, useDocumentLimitsUpsellContext, isDocumentLimitError, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, isSystemBundle, useScheduledDraftDocument, useArchivedReleases, isCardinalityOneRelease, getVersionInlineBadge, useNavigateToCanvasDoc, getDocumentVariantType, isPerspectiveWriteable, ReleasesNav, useVersionOperations, useConditionalToast, isAgentBundleName, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, FormRow, FormContainer, PresenceOverlay, fromMutationPatches, useDocumentPreviewValues, useManageFavorite, useActiveWorkspace, CapabilityGate, useFilteredReleases, usePausedScheduledDraft, isPausedCardinalityOneRelease, ScrollContainer, useStudioUrl, VersionChip, Chip, useDateTimeFormat, useSchema, useGetDefaultPerspective, useSingleDocRelease, useAgentVersionDisplay, useFieldActions, useDocumentVersionTypeSortedList, useDocumentPairPermissions, InsufficientPermissionsMessage, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, isSanityDefinedAction, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, resizeObserver, ChangeConnectorRoot, useGlobalCopyPasteElementHandler, useDocumentIdStack, GetFormValueProvider, FieldActionsResolver, FieldActionsProvider, useTemplates, useInitialValue, useCopyPaste, selectUpstreamVersion, pathToString, DivergencesProvider, useDocumentDivergences, useEventsStore, EventsProvider, PerspectiveProvider, useTimelineStore, SingleDocReleaseProvider, SourceProvider, CopyPasteProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, useDocumentVersionInfo, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, PreviewCard, ReleaseAvatarIcon, createHookFromObservableFactory, DEFAULT_STUDIO_CLIENT_OPTIONS, EMPTY_OBJECT, CrossDatasetReferencePreview, getPreviewPaths, isNonNullable as isNonNullable$1, getReferencePaths, ErrorActions, collate, createSWR, getSearchableTypes, createSearch, useSearchMaxFieldDepth, measureFirstMatch, catchWithCount, useReconnectingToast, ChangeFieldWrapper, NoChanges, ChangeList, isDeleteDocumentVersionEvent, isDeleteDocumentGroupEvent, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, isPublishDocumentVersionEvent, ChangesError, isArray, isValidationError, isValidationWarning, definePlugin } from "sanity"; import { useRouter, useIntentLink, useRouterState, StateLink, IntentLink, route, encodeJsonParams, decodeJsonParams } from "sanity/router"; import { structureLocaleNamespace, getExtendedProjection, structureUsEnglishLocaleBundle } from "./StructureToolProvider.js"; import * as PathUtils from "@sanity/util/paths"; import { fromString, get, resolveKeyedPath, toString } from "@sanity/util/paths"; import omit from "lodash-es/omit.js"; import { MenuButton, Dialog, MenuItem as MenuItem$1, Button as Button$1, Tab, Popover, Tooltip, TooltipDelayGroupProvider, ErrorBoundary } from "./index.js"; import isEqual from "lodash-es/isEqual.js"; import shallowEquals from "shallow-equals"; import "react-i18next"; import { TransferIcon, CloseIcon, LockIcon, CheckmarkIcon, UnknownIcon, SearchIcon, DocumentRemoveIcon, ReadOnlyIcon, ErrorOutlineIcon, SyncIcon, WarningOutlineIcon, InfoOutlineIcon, ComposeSparklesIcon, LaunchIcon, PauseIcon, UnpublishIcon, ArrowRightIcon, StarFilledIcon, StarIcon, ArrowLeftIcon, RevertIcon, ShareIcon, LinkIcon, TargetIcon, ChevronUpIcon, ChevronDownIcon, SplitVerticalIcon, CollapseIcon, ExpandIcon, TrashIcon, ResetIcon, CopyIcon, PublishIcon, EditIcon, AddIcon, ChevronLeftIcon, RestoreIcon, EarthAmericasIcon, JsonIcon, DocumentsIcon, ChevronRightIcon, DocumentIcon, FolderIcon, SpinnerIcon, CheckmarkCircleIcon, MasterDetailIcon } from "@sanity/icons"; import { nanoid } from "nanoid"; import { useObservable, useObservableEvent } from "react-rx"; import { Subject, distinctUntilChanged, filter, map, of, merge, startWith, catchError, concat, firstValueFrom, BehaviorSubject, from, fromEvent, EMPTY, timer, switchMap as switchMap$1, defer, mergeMap, throwError, share, partition, throttleTime, asyncScheduler, NEVER, tap as tap$1, debounce } from "rxjs"; import { styled, css, keyframes } from "styled-components"; import { isValidationErrorMarker, isSanityDocument as isSanityDocument$1, isKeySegment, isIndexSegment, isReferenceSchemaType } from "@sanity/types"; import { parse } from "groq-js"; import { ChannelError, ServerError, ClientError } from "@sanity/client"; import { useTelemetry } from "@sanity/telemetry/react"; import { observableCallback } from "observable-callback"; 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 { defineEvent } from "@sanity/telemetry"; import { exhaustMapWithTrailing } from "rxjs-exhaustmap-with-trailing"; import uniqBy from "lodash-es/uniqBy.js"; import negate from "lodash-es/negate.js"; import { MenuGroup, ConfirmPopover } from "./MenuGroup.js"; import fromPairs from "lodash-es/fromPairs.js"; import toPairs from "lodash-es/toPairs.js"; import ScrollMirror from "scrollmirror"; import noop from "lodash-es/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 { addWeeks } from "date-fns/addWeeks"; import { isAfter } from "date-fns/isAfter"; import { isBefore } from "date-fns/isBefore"; import { getTheme_v2, rgba } from "@sanity/ui/theme"; import { uuid } from "@sanity/uuid"; import { format } from "date-fns/format"; import { diffInput, wrap } from "@sanity/diff"; import { mergeMapArray } from "rxjs-mergemap-array"; function useCreatePathSyncChannel() { const $ = c(1); let t0; return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = new Subject(), $[0] = t0) : t0 = $[0], 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$M) }); }, $[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$M(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(t0) { const $ = c(22); let t1; $[0] !== t0 ? (t1 = t0 === void 0 ? {} : t0, $[0] = t0, $[1] = t1) : t1 = $[1]; const { onParamsError } = t1, { state: routerState } = useRouter(); let nextDocument, previousDocument, t2; if ($[2] !== routerState._searchParams) { const searchParams = new URLSearchParams(routerState._searchParams); previousDocument = searchParams.get(DIFF_VIEW_PREVIOUS_DOCUMENT_SEARCH_PARAMETER), nextDocument = searchParams.get(DIFF_VIEW_NEXT_DOCUMENT_SEARCH_PARAMETER), t2 = searchParams.get(DIFF_VIEW_SEARCH_PARAMETER), $[2] = routerState._searchParams, $[3] = nextDocument, $[4] = previousDocument, $[5] = t2; } else nextDocument = $[3], previousDocument = $[4], t2 = $[5]; const mode = t2, anyParamSet = [previousDocument, nextDocument, mode].some(_temp$L), t3 = previousDocument ?? "", t4 = nextDocument ?? "", t5 = mode ?? ""; let t6; $[6] !== t3 || $[7] !== t4 || $[8] !== t5 ? (t6 = parseParams({ previousDocument: t3, nextDocument: t4, mode: t5 }), $[6] = t3, $[7] = t4, $[8] = t5, $[9] = t6) : t6 = $[9]; const params = t6; let t7; $[10] !== anyParamSet || $[11] !== onParamsError || $[12] !== params.errors || $[13] !== params.result ? (t7 = () => { params.result === "error" && anyParamSet && onParamsError?.(params.errors); }, $[10] = anyParamSet, $[11] = onParamsError, $[12] = params.errors, $[13] = params.result, $[14] = t7) : t7 = $[14]; let t8; if ($[15] !== anyParamSet || $[16] !== onParamsError || $[17] !== params ? (t8 = [anyParamSet, onParamsError, params], $[15] = anyParamSet, $[16] = onParamsError, $[17] = params, $[18] = t8) : t8 = $[18], useEffect(t7, t8), params.result === "error") { let t92; return $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t92 = { isActive: !1 }, $[19] = t92) : t92 = $[19], t92; } let t9; return $[20] !== params.params ? (t9 = { state: "ready", isActive: !0, ...params.params }, $[20] = params.params, $[21] = t9) : t9 = $[21], t9; } function _temp$L(param) { return param !== null; } 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$K); 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$K(element) { return element !== null; } function findRelease(documentId, releases) { return isPublishedId(documentId) ? "published" : isDraftId(documentId) ? "draft" : releases.find(({ _id }) => getReleaseIdFromReleaseDocumentId(_id) === getVersionFromId(documentId)) ?? getVersionFromId(documentId); } const VersionModeHeaderLayout = styled.header.withConfig({ displayName: "VersionModeHeaderLayout", componentId: "sc-w17umd-0" })`display:grid;grid-area:header;grid-template-columns:1fr min-content 1fr;border-block-end:1px solid var(--card-border-color);`, VersionModeHeaderLayoutSection = styled.div.withConfig({ displayName: "VersionModeHeaderLayoutSection", componentId: "sc-w17umd-1" })`display:flex;justify-content:space-between;align-items:center;`, VersionModeHeader = (t0) => { const $ = c(48), { documentId, state: state2 } = t0, { t } = useTranslation(structureLocaleNamespace); let t1; $[0] !== documentId ? (t1 = { documentId }, $[0] = documentId, $[1] = t1) : t1 = $[1]; const { data: documentVersions } = useDocumentVersions(t1), { exitDiffView, navigateDiffView } = useDiffViewRouter(), { documents } = useDiffViewState(), activeReleases = useActiveReleases(); let t2; $[2] !== documentVersions ? (t2 = documentVersions.flatMap(_temp$J), $[2] = documentVersions, $[3] = t2) : t2 = $[3]; const releasesIds = t2; let t3; if ($[4] !== activeReleases.data || $[5] !== releasesIds) { let t42; $[7] !== releasesIds ? (t42 = (release) => { const releaseId = getReleaseIdFromReleaseDocumentId(release._id); return typeof releaseId < "u" && releasesIds.includes(releaseId); }, $[7] = releasesIds, $[8] = t42) : t42 = $[8], t3 = activeReleases.data.filter(t42), $[4] = activeReleases.data, $[5] = releasesIds, $[6] = t3; } else t3 = $[6]; const releases = t3; let t4; $[9] !== activeReleases ? (t4 = fetchingState(activeReleases), $[9] = activeReleases, $[10] = t4) : t4 = $[10]; const releasesState = t4; let t5; $[11] !== documents || $[12] !== navigateDiffView ? (t5 = (selectedDocumentId) => { typeof documents?.previous < "u" && navigateDiffView({ previousDocument: { ...documents.previous, id: selectedDocumentId } }); }, $[11] = documents, $[12] = navigateDiffView, $[13] = t5) : t5 = $[13]; const onSelectPreviousRelease = t5; let t6; $[14] !== documents || $[15] !== navigateDiffView ? (t6 = (selectedDocumentId_0) => { typeof documents?.next < "u" && navigateDiffView({ nextDocument: { ...documents.next, id: selectedDocumentId_0 } }); }, $[14] = documents, $[15] = navigateDiffView, $[16] = t6) : t6 = $[16]; const onSelectNextRelease = t6; let t7; $[17] !== t ? (t7 = t("compare-versions.title"), $[17] = t, $[18] = t7) : t7 = $[18]; let t8; $[19] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Text, { as: "h1", size: 1, muted: !0, children: t7 }) }), $[19] = t7, $[20] = t8) : t8 = $[20]; let t9; $[21] !== documentId || $[22] !== documents || $[23] !== onSelectPreviousRelease || $[24] !== releases || $[25] !== releasesState || $[26] !== state2 ? (t9 = typeof documents?.previous < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, releasesState, onSelectRelease: onSelectPreviousRelease, role: "previous", documentId, state: state2, document: documents.previous }), $[21] = documentId, $[22] = documents, $[23] = onSelectPreviousRelease, $[24] = releases, $[25] = releasesState, $[26] = state2, $[27] = t9) : t9 = $[27]; let t10; $[28] !== t8 || $[29] !== t9 ? (t10 = /* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [ t8, t9 ] }), $[28] = t8, $[29] = t9, $[30] = t10) : t10 = $[30]; let t11; $[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsx(Flex, { align: "center", paddingX: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(TransferIcon, {}) }) }), $[31] = t11) : t11 = $[31]; let t12; $[32] !== documentId || $[33] !== documents || $[34] !== onSelectNextRelease || $[35] !== releases || $[36] !== releasesState || $[37] !== state2 ? (t12 = typeof documents?.next < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, releasesState, onSelectRelease: onSelectNextRelease, role: "next", documentId, state: state2, document: documents.next }), $[32] = documentId, $[33] = documents, $[34] = onSelectNextRelease, $[35] = releases, $[36] = releasesState, $[37] = state2, $[38] = t12) : t12 = $[38]; let t13; $[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = { justifySelf: "end" }, $[39] = t13) : t13 = $[39]; let t14; $[40] !== exitDiffView ? (t14 = /* @__PURE__ */ jsx(Box, { padding: 3, style: t13, children: /* @__PURE__ */ jsx(Button, { icon: CloseIcon, mode: "bleed", onClick: exitDiffView, padding: 2 }) }), $[40] = exitDiffView, $[41] = t14) : t14 = $[41]; let t15; $[42] !== t12 || $[43] !== t14 ? (t15 = /* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [ t12, t14 ] }), $[42] = t12, $[43] = t14, $[44] = t15) : t15 = $[44]; let t16; return $[45] !== t10 || $[46] !== t15 ? (t16 = /* @__PURE__ */ jsxs(VersionModeHeaderLayout, { children: [ t10, t11, t15 ] }), $[45] = t10, $[46] = t15, $[47] = t16) : t16 = $[47], t16; }, VersionMenu = (t0) => { const $ = c(46), { releases: t1, releasesState, onSelectRelease, role, documentId, document: document2 } = t0; let t2; $[0] !== t1 ? (t2 = t1 === void 0 ? [] : t1, $[0] = t1, $[1] = t2) : t2 = $[1]; const releases = t2; let t3; $[2] !== document2.id ? (t3 = getPublishedId(document2.id), $[2] = document2.id, $[3] = t3) : t3 = $[3]; const { published, draft } = useEditState(t3, document2.type); let t4; $[4] !== document2.id || $[5] !== releases ? (t4 = findRelease(document2.id, releases), $[4] = document2.id, $[5] = releases, $[6] = t4) : t4 = $[6]; const selected = t4, { t: tStructure } = useTranslation(structureLocaleNamespace), { t: tCore } = useTranslation(), { document: t5 } = useWorkspace(), { drafts: t6 } = t5, { enabled: isDraftModelEnabled } = t6; if (releasesState === "error") { let t72; $[7] !== tStructure ? (t72 = tStructure("compare-version.error.loadReleases.title"), $[7] = tStructure, $[8] = t72) : t72 = $[8]; let t82; return $[9] !== t72 ? (t82 = /* @__PURE__ */ jsx(Badge, { tone: "critical", radius: 3, children: t72 }), $[9] = t72, $[10] = t82) : t82 = $[10], t82; } let t7; $[11] !== releasesState || $[12] !== selected || $[13] !== tCore || $[14] !== tStructure ? (t7 = getMenuButtonProps({ selected, tCore, tStructure, releasesState }), $[11] = releasesState, $[12] = selected, $[13] = tCore, $[14] = tStructure, $[15] = t7) : t7 = $[15]; let t8; $[16] !== t7 ? (t8 = /* @__PURE__ */ jsx(Button, { type: "button", mode: "bleed", padding: 2, paddingRight: 3, radius: "full", selected: !0, ...t7 }), $[16] = t7, $[17] = t8) : t8 = $[17]; let t9; $[18] !== documentId || $[19] !== onSelectRelease || $[20] !== published || $[21] !== selected ? (t9 = published && /* @__PURE__ */ jsx(VersionMenuItem, { type: "published", onSelect: onSelectRelease, isSelected: selected === "published", documentId }), $[18] = documentId, $[19] = onSelectRelease, $[20] = published, $[21] = selected, $[22] = t9) : t9 = $[22]; let t10; $[23] !== documentId || $[24] !== draft || $[25] !== isDraftModelEnabled || $[26] !== onSelectRelease || $[27] !== selected ? (t10 = isDraftModelEnabled && draft && /* @__PURE__ */ jsx(VersionMenuItem, { type: "draft", onSelect: onSelectRelease, isSelected: selected === "draft", documentId }), $[23] = documentId, $[24] = draft, $[25] = isDraftModelEnabled, $[26] = onSelectRelease, $[27] = selected, $[28] = t10) : t10 = $[28]; let t11; if ($[29] !== documentId || $[30] !== onSelectRelease || $[31] !== releases || $[32] !== selected) { let t122; $[34] !== documentId || $[35] !== onSelectRelease || $[36] !== selected ? (t122 = (release) => /* @__PURE__ */ jsx(VersionMenuItem, { release, onSelect: onSelectRelease, isSelected: typeof selected != "string" && selected?._id === release._id, documentId }, release._id), $[34] = documentId, $[35] = onSelectRelease, $[36] = selected, $[37] = t122) : t122 = $[37], t11 = releases.map(t122), $[29] = documentId, $[30] = onSelectRelease, $[31] = releases, $[32] = selected, $[33] = t11; } else t11 = $[33]; let t12; $[38] !== t10 || $[39] !== t11 || $[40] !== t9 ? (t12 = /* @__PURE__ */ jsxs(Menu, { children: [ t9, t10, t11 ] }), $[38] = t10, $[39] = t11, $[40] = t9, $[41] = t12) : t12 = $[41]; let t13; return $[42] !== role || $[43] !== t12 || $[44] !== t8 ? (t13 = /* @__PURE__ */ jsx(MenuButton, { id: role, button: t8, menu: t12 }), $[42] = role, $[43] = t12, $[44] = t8, $[45] = t13) : t13 = $[45], t13; }, VersionMenuItem = (t0) => { const $ = c(51), { type, release, onSelect, isSelected, documentId } = t0, { t: tCore } = useTranslation(), { t: tStructure } = useTranslation(structureLocaleNamespace); let t1; $[0] !== documentId || $[1] !== onSelect || $[2] !== release || $[3] !== type ? (t1 = () => { if (type === "draft") { onSelect(getDraftId(documentId)); return; } if (type === "published") { onSelect(getPublishedId(documentId)); return; } typeof release?._id < "u" && onSelect(getVersionId(documentId, getReleaseIdFromReleaseDocumentId(release._id))); }, $[0] = documentId, $[1] = onSelect, $[2] = release, $[3] = type, $[4] = t1) : t1 = $[4]; const onClick = t1; if (type) { const releasePerspective = type === "published" ? PUBLISHED : LATEST; let t22; $[5] !== releasePerspective ? (t22 = /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, release: releasePerspective }), $[5] = releasePerspective, $[6] = t22) : t22 = $[6]; let t32; $[7] !== type ? (t32 = ["compare-versions.status", type], $[7] = type, $[8] = t32) : t32 = $[8]; const t42 = t32.join("."); let t52; $[9] !== t42 || $[10] !== tStructure ? (t52 = tStructure(t42), $[9] = t42, $[10] = tStructure, $[11] = t52) : t52 = $[11]; let t62; $[12] !== t52 ? (t62 = /* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t52 }) }), $[12] = t52, $[13] = t62) : t62 = $[13]; let t72; $[14] !== t22 || $[15] !== t62 ? (t72 = /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [ t22, t62 ] }), $[14] = t22, $[15] = t62, $[16] = t72) : t72 = $[16]; let t82; return $[17] !== isSelected || $[18] !== onClick || $[19] !== t72 ? (t82 = /* @__PURE__ */ jsx(MenuItem, { padding: 1, paddingRight: 3, onClick, pressed: isSelected, children: t72 }), $[17] = isSelected, $[18] = onClick, $[19] = t72, $[20] = t82) : t82 = $[20], t82; } let t2; $[21] !== release ? (t2 = /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, release }), $[21] = release, $[22] = t2) : t2 = $[22]; let t3; $[23] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = { minWidth: 0 }, $[23] = t3) : t3 = $[23]; const t4 = release.metadata.title; let t5; $[24] !== tCore ? (t5 = tCore("release.placeholder-untitled-release"), $[24] = tCore, $[25] = t5) : t5 = $[25]; let t6; $[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = { size: 1, weight: "medium" }, $[26] = t6) : t6 = $[26]; let t7; $[27] !== release.metadata.title || $[28] !== t5 ? (t7 = /* @__PURE__ */ jsx(ReleaseTitle, { title: t4, fallback: t5, textProps: t6 }), $[27] = release.metadata.title, $[28] = t5, $[29] = t7) : t7 = $[29]; let t8; $[30] !== release.metadata.releaseType || $[31] !== tCore ? (t8 = ["asap", "undecided"].includes(release.metadata.releaseType) && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: tCore(`release.type.${release.metadata.releaseType}`) }), $[30] = release.metadata.releaseType, $[31] = tCore, $[32] = t8) : t8 = $[32]; let t9; $[33] !== release ? (t9 = release.metadata.releaseType === "scheduled" && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: formatRelativeLocalePublishDate(release) }), $[33] = release, $[34] = t9) : t9 = $[34]; let t10; $[35] !== t7 || $[36] !== t8 || $[37] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Stack, { flex: 1, paddingY: 2, paddingRight: 2, space: 2, style: t3, children: [ t7, t8, t9 ] }), $[35] = t7, $[36] = t8, $[37] = t9, $[38] = t10) : t10 = $[38]; let t11; $[39] !== release ? (t11 = isReleaseScheduledOrScheduling(release) && /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(LockIcon, {}) }) }), $[39] = release, $[40] = t11) : t11 = $[40]; let t12; $[41] !== t11 ? (t12 = /* @__PURE__ */ jsx(Flex, { flex: "none", children: t11 }), $[41] = t11, $[42] = t12) : t12 = $[42]; let t13; $[43] !== t10 || $[44] !== t12 || $[45] !== t2 ? (t13 = /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [ t2, t10, t12 ] }), $[43] = t10, $[44] = t12, $[45] = t2, $[46] = t13) : t13 = $[46]; let t14; return $[47] !== isSelected || $[48] !== onClick || $[49] !== t13 ? (t14 = /* @__PURE__ */ jsx(MenuItem, { padding: 1, paddingRight: 3, onClick, pressed: isSelected, children: t13 }), $[47] = isSelected, $[48] = onClick, $[49] = t13, $[50] = t14) : t14 = $[50], t14; }; function getMenuButtonProps({ selected, tCore, tStructure, releasesState }) { if (releasesState === "pending") return { text: tCore("common.loading"), tone: "neutral", disabled: !0 }; if (isReleaseDocument(selected)) { const tone = selected ? getReleaseTone(selected) : "neutral"; return { text: selected?.metadata.title || tCore("release.placeholder-untitled-release"), icon: /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 1, release: selected }), iconRight: selected && isReleaseScheduledOrScheduling(selected) ? /* @__PURE__ */ jsx(LockIcon, {}) : void 0, tone }; } if (isSystemBundleName(selected)) { const tone = selected === "published" ? "positive" : "caution", releasePerspective = selected === "published" ? PUBLISHED : LATEST; return { text: tStructure(["compare-versions.status", selected].join(".")), icon: /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 1, release: releasePerspective }), tone }; } return { text: selected, // eslint-disable-next-line @sanity/i18n/no-attribute-string-literals icon: /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 1, releaseType: "undecided" }), tone: "neutral" }; } function fetchingState({ loading, error }) { return loading ? "pending" : typeof error < "u" ? "error" : "ready"; } function _temp$J(id) { return getVersionFromId(id) ?? []; } const DialogLayout = styled.div.withConfig({ displayName: "DialogLayout", componentId: "sc-x0jh85-0" })`--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; if ($[3] !== id || $[4] !== syncChannel) { let t32; $[6] !== id ? (t32 = (t4) => { const { source } = t4; return source !== id; }, $[6] = id, $[7] = t32) : t32 = $[7], t2 = syncChannel.pipe(distinctUntilChanged(_temp$I), filter(t32), map(_temp2$j)), $[3] = id, $[4] = syncChannel, $[5] = t2; } else t2 = $[5]; const path = t2; let t3; return $[8] !== path || $[9] !== push ? (t3 = { path, push }, $[8] = path, $[9] = push, $[10] = t3) : t3 = $[10], t3; } function _temp2$j(state_0) { return state_0.path; } function _temp$I(previous, next) { return deepEquals(previous.path, next.path); } const Scroller$5 = styled.div.withConfig({ displayName: "Scroller", componentId: "sc-16z7cpf-0" })`position:relative;height:100%;overflow:auto;scroll-behavior:smooth;scrollbar-width:var(--scrollbar-width);overscroll-behavior:contain;will-change:scroll-position;`, DiffViewPaneLayout = styled(Card).withConfig({ displayName: "DiffViewPaneLayout", componentId: "sc-1856b20-0" })`position:relative;grid-area:var(--grid-area);`, Container = styled(Container$1).withConfig({ displayName: "Container", componentId: "sc-1856b20-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] === /* @__PURE__ */ 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] === /* @__PURE__ */ 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(52), { role, documentType, documentId, syncChannel, compareDocument } = t0; let t1; $[0] !== compareDocument ? (t1 = { compareDocument }, $[0] = compareDocument, $[1] = t1) : t1 = $[1]; const compareValue = useCompareValue(t1), { data: releases } = useActiveReleases(), [patchChannel] = useState(_temp$H); let t2; $[2] !== documentId || $[3] !== releases ? (t2 = findRelease(documentId, releases), $[2] = documentId, $[3] = releases, $[4] = t2) : t2 = $[4]; const perspective = t2; let t3; $[5] !== documentId ? (t3 = getPublishedId(documentId), $[5] = documentId, $[6] = t3) : t3 = $[6]; let t4; $[7] !== documentId ? (t4 = perspectiveName(documentId), $[7] = documentId, $[8] = t4) : t4 = $[8]; let t5; $[9] !== documentId ? (t5 = getVersionFromId(documentId), $[9] = documentId, $[10] = t5) : t5 = $[10]; let t6; $[11] !== compareValue || $[12] !== documentType || $[13] !== t3 || $[14] !== t4 || $[15] !== t5 ? (t6 = { documentId: t3, documentType, selectedPerspectiveName: t4, releaseId: t5, comparisonValue: compareValue, displayInlineChanges: !0 }, $[11] = compareValue, $[12] = documentType, $[13] = t3, $[14] = t4, $[15] = t5, $[16] = t6) : t6 = $[16]; const { formState, onChange, onFocus, onBlur, onSetActiveFieldGroup, onSetCollapsedFieldSet, onSetCollapsedPath, collapsedFieldSets, ready, collapsedPaths, schemaType, value, onProgrammaticFocus, openPath, onPathOpen: onPathOpenFromForm } = useDocumentForm(t6), isLoading = formState === null || !ready; let t7; $[17] !== role || $[18] !== syncChannel ? (t7 = { id: role, syncChannel }, $[17] = role, $[18] = syncChannel, $[19] = t7) : t7 = $[19]; const pathSyncChannel = usePathSyncChannel(t7); let t8; $[20] !== onPathOpenFromForm || $[21] !== pathSyncChannel || $[22] !== role ? (t8 = (path) => { onPathOpenFromForm(path), pathSyncChannel.push({ source: role, path }); }, $[20] = onPathOpenFromForm, $[21] = pathSyncChannel, $[22] = role, $[23] = t8) : t8 = $[23]; const onPathOpen = t8; let t9; $[24] !== onPathOpenFromForm || $[25] !== onProgrammaticFocus || $[26] !== pathSyncChannel.path ? (t9 = () => { const subscription = pathSyncChannel.path.subscribe((path_0) => { onPathOpenFromForm(path_0), onProgrammaticFocus(path_0); }); return () => subscription.unsubscribe(); }, $[24] = onPathOpenFromForm, $[25] = onProgrammaticFocus, $[26] = pathSyncChannel.path, $[27] = t9) : t9 = $[27]; let t10; $[28] !== onPathOpenFromForm || $[29] !== onProgrammaticFocus || $[30] !== pathSyncChannel.path || $[31] !== role ? (t10 = [onPathOpenFromForm, onProgrammaticFocus, pathSyncChannel.path, role], $[28] = onPathOpenFromForm, $[29] = onProgrammaticFocus, $[30] = pathSyncChannel.path, $[31] = role, $[32] = t10) : t10 = $[32], useEffect(t9, t10); let t11; return $[33] !== collapsedFieldSets || $[34] !== collapsedPaths || $[35] !== compareValue || $[36] !== formState || $[37] !== isLoading || $[38] !== onBlur || $[39] !== onChange || $[40] !== onFocus || $[41] !== onPathOpen || $[42] !== onSetActiveFieldGroup || $[43] !== onSetCollapsedFieldSet || $[44] !== onSetCollapsedPath || $[45] !== openPath || $[46] !== patchChannel || $[47] !== perspective || $[48] !== role || $[49] !== schemaType || $[50] !== 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, openPath, changed: formState.changed, focused: formState.focused, groups: formState.groups, validation: formState.validation, members: formState.members, perspective: sanitizeBundleName(perspective), hasUpstreamVersion: formState.hasUpstreamVersion, presence: formState.presence, schemaType, value, compareValue }) }), $[33] = collapsedFieldSets, $[34] = collapsedPaths, $[35] = compareValue, $[36] = formState, $[37] = isLoading, $[38] = onBlur, $[39] = onChange, $[40] = onFocus, $[41] = onPathOpen, $[42] = onSetActiveFieldGroup, $[43] = onSetCollapsedFieldSet, $[44] = onSetCollapsedPath, $[45] = openPath, $[46] = patchChannel, $[47] = perspective, $[48] = role, $[49] = schemaType, $[50] = value, $[51] = t11) : t11 = $[51], 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 sanitizeBundleName(bundle) { return bundle === "draft" ? "drafts" : bundle; } function _temp$H() { return createPatchChannel(); } const Link = styled.a.withConfig({ displayName: "Link", componentId: "sc-ihhvnj-0" })`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; $[0] !== referenceInputOptionsContext ? (t1 = { ...referenceInputOptionsContext, disableNew: !0, EditReferenceLinkComponent }, $[0] = referenceInputOptionsContext, $[1] = t1) : t1 = $[1]; const diffViewReferenceInputOptionsContext = t1; let t2; $[2] !== nextPaneElement || $[3] !== previousPaneElement ? (t2 = [previousPaneElement, nextPaneElement], $[2] = nextPaneElement, $[3] = previousPaneElement, $[4] = t2) : t2 = $[4], useScrollMirror(t2); let t3; $[5] !== documentId || $[6] !== mode || $[7] !== state2 ? (t3 = mode === "version" && /* @__PURE__ */ jsx(VersionModeHeader, { documentId, state: state2 }), $[5] = documentId, $[6] = mode, $[7] = state2, $[8] = t3) : t3 = $[8]; let t4; $[9] !== documents || $[10] !== nextPaneElement || $[11] !== previousPaneElement || $[12] !== state2 || $[13] !== syncChannel ? (t4 = 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] = t4) : t4 = $[14]; let t5; $[15] !== t3 || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsxs(DialogLayout, { children: [ t3, t4 ] }), $[15] = t3, $[16] = t4, $[17] = t5) : t5 = $[17]; let t6; $[18] !== exitDiffView || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsx(Dialog, { id: "diffView", width: "auto", onClose: exitDiffView, padding: !1, __unstable_hideCloseButton: !0, children: t5 }), $[18] = exitDiffView, $[19] = t5, $[20] = t6) : t6 = $[20]; let t7; return $[21] !== diffViewReferenceInputOptionsContext || $[22] !== t6 ? (t7 = /* @__PURE__ */ jsx(ReferenceInputOptionsContext.Provider, { value: diffViewReferenceInputOptionsContext, children: t6 }), $[21] = diffViewReferenceInputOptionsContext, $[22] = t6, $[23] = t7) : t7 = $[23], t7; }, 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 pane = useContext(PaneLayoutContext); if (!pane) throw new Error("PaneLayout: missing context value"); return pane; } const Root$a = styled(Layer).withConfig({ displayName: "Root", componentId: "sc-k0eo57-0" })`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$a, { "data-disabled": t2, "data-dragging": t3, onMouseDown: handleMouseDown }), $[3] = handleMouseDown, $[4] = t2, $[5] = t3, $[6] = t4) : t4 = $[6], t4; } const Root$9 = styled(Card).withConfig({ displayName: "Root", componentId: "sc-o2std4-0" })`outline:none;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 pane, t2; if ($[10] !== panes || $[11] !== rootElement) { let t32; $[14] !== rootElement ? (t32 = (p) => p.element === rootElement, $[14] = rootElement, $[15] = t32) : t32 = $[15], pane = panes.find(t32), t2 = pane && panes.indexOf(pane), $[10] = panes, $[11] = rootElement, $[12] = pane, $[13] = t2; } else pane = $[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 : pane?.collapsed || !1, nextCollapsed = nextPane?.collapsed || !1, ref = useRef(null), flex = pane?.flex ?? flexProp, currentMinWidth = pane?.currentMinWidth ?? currentMinWidthProp, currentMaxWidth = pane?.currentMaxWidth ?? currentMaxWidthProp; let t3; $[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[16] = t3) : t3 = $[16], useImperativeHandle(forwardedRef, t3); let t4; $[17] === /* @__PURE__ */ 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,