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

956 lines (949 loc) • 632 kB
import { structureLocaleNamespace, getExtendedProjection, structureUsEnglishLocaleBundle } from "./StructureToolProvider.js"; import { MenuButton, Dialog, MenuItem as MenuItem$1, Button as Button$1, Tab, Popover, Tooltip, TooltipDelayGroupProvider, ErrorBoundary } from "./TooltipDelayGroupProvider.js"; import "../_singletons.js"; 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, Dialog as Dialog$1, Popover as Popover$1, useLayer, useGlobalKeyDown, Badge, AvatarStack, Skeleton, Checkbox, Select } from "@sanity/ui"; import { useEffect, forwardRef, useRef, useState, useContext, useImperativeHandle, useLayoutEffect, useId, memo, useEffectEvent, Fragment as Fragment$1, useDeferredValue, lazy, Suspense, startTransition, useCallback, useMemo, useReducer } from "react"; import { ReviewChangesContext, CommentsEnabledContext, ReferenceInputOptionsContext, PaneLayoutContext, PaneContext, DocumentPaneContext, DocumentActionsStateContext, StructureToolContext, PaneRouterContext, ResolvedPanesContext, EventsContext, DocumentSheetListContext, DocumentChangeContext } from "sanity/_singletons"; import { TransferIcon, CloseIcon, LockIcon, CheckmarkIcon, UnknownIcon, SearchIcon, DocumentRemoveIcon, ReadOnlyIcon, ErrorOutlineIcon, SyncIcon, WarningOutlineIcon, InfoOutlineIcon, ComposeSparklesIcon, LaunchIcon, UnpublishIcon, ArrowRightIcon, StarFilledIcon, StarIcon, ArrowLeftIcon, RevertIcon, SplitVerticalIcon, CollapseIcon, ExpandIcon, TrashIcon, ResetIcon, CopyIcon, PublishIcon, EditIcon, AddIcon, ChevronLeftIcon, ChevronDownIcon, RestoreIcon, LinkIcon, EarthAmericasIcon, JsonIcon, DocumentsIcon, ChevronRightIcon, DocumentIcon, FolderIcon, SpinnerIcon, EllipsisHorizontalIcon, DoubleChevronLeftIcon, DoubleChevronRightIcon, CheckmarkCircleIcon, MasterDetailIcon } from "@sanity/icons"; import { isPublishedId, isDraftId, getReleaseIdFromReleaseDocumentId, getVersionFromId, useTranslation, useDocumentVersions, useActiveReleases, getPublishedId, useEditState, useWorkspace, isReleaseDocument, getReleaseTone, isReleaseScheduledOrScheduling, ReleaseAvatar, formatRelativeLocalePublishDate, getDraftId, getVersionId, 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, unstable_useValuePreview, useDocumentOperationEvent, useDocumentLimitsUpsellContext, isDocumentLimitError, Translate, isNewDocument, Resizable, useKeyValueStore, isRecord, isString, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useClient, useZIndex, useCurrentUser, useListFormat, useDocumentPreviewStore, useArchivedReleases, isCardinalityOneRelease, getVersionInlineBadge, useNavigateToCanvasDoc, getDocumentVariantType, isPerspectiveWriteable, ReleasesNav, useSanityCreateConfig, getSanityCreateLinkMetadata, LATEST, useVersionOperations, useConditionalToast, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, useDocumentStore, useDocumentPresence, PresenceOverlay, fromMutationPatches, useDocumentPreviewValues, useManageFavorite, useActiveWorkspace, CapabilityGate, ScrollContainer, isSanityCreateLinked, useFilteredReleases, isSystemBundle, useDateTimeFormat, useSchema, useGetDefaultPerspective, useSingleDocRelease, VersionChip, useFieldActions, 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, useHistoryStore, useTimelineStore, useTemplates, useInitialValue, useCopyPaste, useStudioUrl, selectUpstreamVersion, pathToString, useEventsStore, EventsProvider, isDeleteDocumentGroupEvent, isDeleteDocumentVersionEvent, PerspectiveProvider, SingleDocReleaseProvider, SourceProvider, CopyPasteProvider, useDocumentType, useTemplatePermissions, ReferenceInputOptionsProvider, useDocumentVersionInfo, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, PreviewCard, ReleaseAvatarIcon, createHookFromObservableFactory, DEFAULT_STUDIO_CLIENT_OPTIONS, EMPTY_OBJECT, 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 "motion/react"; import { useObservable, useObservableEvent } from "react-rx"; import { useRouter, useIntentLink, useRouterState, StateLink, IntentLink, route, encodeJsonParams, decodeJsonParams } from "sanity/router"; import { fromPairs, toPairs, noop, negate, omit, isEqual, uniqBy } from "lodash-es"; 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 { MenuGroup, ConfirmPopover } from "./MenuGroup.js"; import { isValidationErrorMarker, isSanityDocument as isSanityDocument$1, isKeySegment, isIndexSegment, isReferenceSchemaType, isObjectSchemaType, isDocumentSchemaType } from "@sanity/types"; import { useTelemetry } from "@sanity/telemetry/react"; import { defineEvent } from "@sanity/telemetry"; import ScrollMirror from "scrollmirror"; 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 { 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; 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$J) }); }, $[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$J(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$I), 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$I(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$H); 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$H(element) { return element !== null; } function findRelease(documentId, releases) { return isPublishedId(documentId) ? "published" : isDraftId(documentId) ? "draft" : releases.find(({ _id }) => getReleaseIdFromReleaseDocumentId(_id) === getVersionFromId(documentId)); } 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 = (t0) => { const $ = c(44), { 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$G), $[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] !== documents || $[10] !== navigateDiffView ? (t4 = (selectedDocumentId) => { typeof documents?.previous < "u" && navigateDiffView({ previousDocument: { ...documents.previous, id: selectedDocumentId } }); }, $[9] = documents, $[10] = navigateDiffView, $[11] = t4) : t4 = $[11]; const onSelectPreviousRelease = t4; let t5; $[12] !== documents || $[13] !== navigateDiffView ? (t5 = (selectedDocumentId_0) => { typeof documents?.next < "u" && navigateDiffView({ nextDocument: { ...documents.next, id: selectedDocumentId_0 } }); }, $[12] = documents, $[13] = navigateDiffView, $[14] = t5) : t5 = $[14]; const onSelectNextRelease = t5; let t6; $[15] !== t ? (t6 = t("compare-versions.title"), $[15] = t, $[16] = t6) : t6 = $[16]; let t7; $[17] !== t6 ? (t7 = /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Text, { as: "h1", size: 1, muted: !0, children: t6 }) }), $[17] = t6, $[18] = t7) : t7 = $[18]; let t8; $[19] !== documentId || $[20] !== documents || $[21] !== onSelectPreviousRelease || $[22] !== releases || $[23] !== state2 ? (t8 = typeof documents?.previous < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, onSelectRelease: onSelectPreviousRelease, role: "previous", documentId, state: state2, document: documents.previous }), $[19] = documentId, $[20] = documents, $[21] = onSelectPreviousRelease, $[22] = releases, $[23] = state2, $[24] = t8) : t8 = $[24]; let t9; $[25] !== t7 || $[26] !== t8 ? (t9 = /* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [ t7, t8 ] }), $[25] = t7, $[26] = t8, $[27] = t9) : t9 = $[27]; let t10; $[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsx(Flex, { align: "center", paddingX: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(TransferIcon, {}) }) }), $[28] = t10) : t10 = $[28]; let t11; $[29] !== documentId || $[30] !== documents || $[31] !== onSelectNextRelease || $[32] !== releases || $[33] !== state2 ? (t11 = typeof documents?.next < "u" && /* @__PURE__ */ jsx(VersionMenu, { releases, onSelectRelease: onSelectNextRelease, role: "next", documentId, state: state2, document: documents.next }), $[29] = documentId, $[30] = documents, $[31] = onSelectNextRelease, $[32] = releases, $[33] = state2, $[34] = t11) : t11 = $[34]; let t12; $[35] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = { justifySelf: "end" }, $[35] = t12) : t12 = $[35]; let t13; $[36] !== exitDiffView ? (t13 = /* @__PURE__ */ jsx(Box, { padding: 3, style: t12, children: /* @__PURE__ */ jsx(Button, { icon: CloseIcon, mode: "bleed", onClick: exitDiffView, padding: 2 }) }), $[36] = exitDiffView, $[37] = t13) : t13 = $[37]; let t14; $[38] !== t11 || $[39] !== t13 ? (t14 = /* @__PURE__ */ jsxs(VersionModeHeaderLayoutSection, { children: [ t11, t13 ] }), $[38] = t11, $[39] = t13, $[40] = t14) : t14 = $[40]; let t15; return $[41] !== t14 || $[42] !== t9 ? (t15 = /* @__PURE__ */ jsxs(VersionModeHeaderLayout, { children: [ t9, t10, t14 ] }), $[41] = t14, $[42] = t9, $[43] = t15) : t15 = $[43], t15; }, VersionMenu = (t0) => { const $ = c(41), { releases: t1, 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; let t7; $[7] !== selected || $[8] !== tCore || $[9] !== tStructure ? (t7 = getMenuButtonProps({ selected, tCore, tStructure }), $[7] = selected, $[8] = tCore, $[9] = tStructure, $[10] = t7) : t7 = $[10]; let t8; $[11] !== t7 ? (t8 = /* @__PURE__ */ jsx(Button, { type: "button", mode: "bleed", padding: 2, paddingRight: 3, radius: "full", selected: !0, ...t7 }), $[11] = t7, $[12] = t8) : t8 = $[12]; let t9; $[13] !== documentId || $[14] !== onSelectRelease || $[15] !== published || $[16] !== selected ? (t9 = published && /* @__PURE__ */ jsx(VersionMenuItem, { type: "published", onSelect: onSelectRelease, isSelected: selected === "published", documentId }), $[13] = documentId, $[14] = onSelectRelease, $[15] = published, $[16] = selected, $[17] = t9) : t9 = $[17]; let t10; $[18] !== documentId || $[19] !== draft || $[20] !== isDraftModelEnabled || $[21] !== onSelectRelease || $[22] !== selected ? (t10 = isDraftModelEnabled && draft && /* @__PURE__ */ jsx(VersionMenuItem, { type: "draft", onSelect: onSelectRelease, isSelected: selected === "draft", documentId }), $[18] = documentId, $[19] = draft, $[20] = isDraftModelEnabled, $[21] = onSelectRelease, $[22] = selected, $[23] = t10) : t10 = $[23]; let t11; if ($[24] !== documentId || $[25] !== onSelectRelease || $[26] !== releases || $[27] !== selected) { let t122; $[29] !== documentId || $[30] !== onSelectRelease || $[31] !== selected ? (t122 = (release) => /* @__PURE__ */ jsx(VersionMenuItem, { release, onSelect: onSelectRelease, isSelected: typeof selected != "string" && selected?._id === release._id, documentId }, release._id), $[29] = documentId, $[30] = onSelectRelease, $[31] = selected, $[32] = t122) : t122 = $[32], t11 = releases.map(t122), $[24] = documentId, $[25] = onSelectRelease, $[26] = releases, $[27] = selected, $[28] = t11; } else t11 = $[28]; let t12; $[33] !== t10 || $[34] !== t11 || $[35] !== t9 ? (t12 = /* @__PURE__ */ jsxs(Menu, { children: [ t9, t10, t11 ] }), $[33] = t10, $[34] = t11, $[35] = t9, $[36] = t12) : t12 = $[36]; let t13; return $[37] !== role || $[38] !== t12 || $[39] !== t8 ? (t13 = /* @__PURE__ */ jsx(MenuButton, { id: role, button: t8, menu: t12 }), $[37] = role, $[38] = t12, $[39] = t8, $[40] = t13) : t13 = $[40], 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 tone = type === "published" ? "positive" : "caution"; let t22; $[5] !== tone ? (t22 = /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, tone }), $[5] = tone, $[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 = release ? getReleaseTone(release) : "neutral", $[21] = release, $[22] = t2) : t2 = $[22]; const tone_0 = t2; let t3; $[23] !== tone_0 ? (t3 = /* @__PURE__ */ jsx(ReleaseAvatar, { padding: 2, tone: tone_0 }), $[23] = tone_0, $[24] = t3) : t3 = $[24]; let t4; $[25] !== release.metadata.title || $[26] !== tCore ? (t4 = release.metadata.title || tCore("release.placeholder-untitled-release"), $[25] = release.metadata.title, $[26] = tCore, $[27] = t4) : t4 = $[27]; let t5; $[28] !== t4 ? (t5 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t4 }), $[28] = t4, $[29] = t5) : t5 = $[29]; let t6; $[30] !== release.metadata.releaseType || $[31] !== tCore ? (t6 = ["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] = t6) : t6 = $[32]; let t7; $[33] !== release ? (t7 = release.metadata.releaseType === "scheduled" && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: formatRelativeLocalePublishDate(release) }), $[33] = release, $[34] = t7) : t7 = $[34]; let t8; $[35] !== t5 || $[36] !== t6 || $[37] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Stack, { flex: 1, paddingY: 2, paddingRight: 2, space: 2, children: [ t5, t6, t7 ] }), $[35] = t5, $[36] = t6, $[37] = t7, $[38] = t8) : t8 = $[38]; let t9; $[39] !== release ? (t9 = isReleaseScheduledOrScheduling(release) && /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(LockIcon, {}) }) }), $[39] = release, $[40] = t9) : t9 = $[40]; let t10; $[41] !== t9 ? (t10 = /* @__PURE__ */ jsx(Flex, { flex: "none", children: t9 }), $[41] = t9, $[42] = t10) : t10 = $[42]; let t11; $[43] !== t10 || $[44] !== t3 || $[45] !== t8 ? (t11 = /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [ t3, t8, t10 ] }), $[43] = t10, $[44] = t3, $[45] = t8, $[46] = t11) : t11 = $[46]; let t12; return $[47] !== isSelected || $[48] !== onClick || $[49] !== t11 ? (t12 = /* @__PURE__ */ jsx(MenuItem, { padding: 1, paddingRight: 3, onClick, pressed: isSelected, children: t11 }), $[47] = isSelected, $[48] = onClick, $[49] = t11, $[50] = t12) : t12 = $[50], t12; }; 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 _temp$G(id) { return getVersionFromId(id) ?? []; } 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; 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$F), filter(t32), map(_temp2$i)), $[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$i(state_0) { return state_0.path; } function _temp$F(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] === /* @__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$E); 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$E() { 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; $[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 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] === /* @__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, 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, t9 = layoutCollapsed ? !1 : collapsed; let t10; $[34] !== handleCollapse || $[35] !== handleExpand || $[36] !== isLast || $[37] !== paneIndex || $[38] !== rootElement || $[39] !== t9 ? (t10 = { collapse: handleCollapse, collapsed: t9, expand: handleExpand, index: paneIndex, isLast, rootElement }, $[34] = handleCollapse, $[35] = handleExpand, $[36] = isLast, $[37] = paneIndex, $[38] = rootElement, $[39] = t9, $[40] = t10) : t10 = $[40]; const contextValue = t10; let t11; bb0: { if (layoutCollapsed) { t11 = void 0; break bb0; } if (collapsed) { t11 = PANE_COLLAPSED_WIDTH; break bb0; } if (currentMinWidth === 0) { t11 = minWidthProp || PANE_DEFAULT_MIN_WIDTH; break bb0; } if (isLast) { t11 = minWidthProp || PANE_DEFAULT_MIN_WIDTH; break bb0; } t11 = currentMinWidth || minWidthProp || PANE_DEFAULT_MIN_WIDTH; } const minWidth = t11; let t12; bb1: { if (collapsed) { t12 = PANE_COLLAPSED_WIDTH; break bb1; } if (layoutCollapsed && isLast) { t12 = void 0; break bb1; } if (isLast) { if (maxWidthProp) { t12 = currentMaxWidth ?? maxWidthProp; break bb1; } t12 = void 0;