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

873 lines (862 loc) • 501 kB
import { structureLocaleNamespace, getExtendedProjection, structureUsEnglishLocaleBundle } from "./StructureToolProvider.mjs"; import { Tooltip, TooltipDelayGroupProvider, Button, Dialog, ErrorBoundary, MenuItem, MenuButton, Tab, Popover as Popover$1 } from "./generate-help-url.esm.mjs"; import "../_singletons.mjs"; import { jsx, Fragment, jsxs } from "react/jsx-runtime"; import { c } from "react-compiler-runtime"; import { Box, rem, Flex, Inline, Text, useToast, Stack, Card, Layer, BoundaryElementProvider, MenuDivider, Menu, TextSkeleton, useElementRect, LayerProvider, Button as Button$1, MenuItem as MenuItem$1, Container as Container$1, DialogProvider, PortalProvider, _raf2, TextInput, Code, TabList, TabPanel, Heading, Spinner, focusFirstDescendant, useElementSize, usePortal, Popover, useLayer, useGlobalKeyDown, useClickOutsideEvent, Grid as Grid$2, Dialog as Dialog$1, Badge, AvatarStack, Skeleton, Checkbox, Select } from "@sanity/ui"; import { forwardRef, useContext, useId, useState, useEffect, useRef, useImperativeHandle, useLayoutEffect, memo, useCallback, useMemo, startTransition, useDeferredValue, useReducer, createElement, Fragment as Fragment$1, lazy } from "react"; import { PaneRouterContext, PaneLayoutContext, PaneContext, ConnectorContext, CommentsEnabledContext, ReferenceInputOptionsContext, DocumentPaneContext, StructureToolContext, DocumentSheetListContext, DocumentChangeContext } from "sanity/_singletons"; import { InfoOutlineIcon, DocumentsIcon, ChevronDownIcon, CopyIcon, UnknownIcon, WarningOutlineIcon, CheckmarkIcon, AddIcon, ChevronRightIcon, DocumentIcon, FolderIcon, TransferIcon, CloseIcon, LockIcon, SearchIcon, DocumentRemoveIcon, ReadOnlyIcon, ErrorOutlineIcon, SyncIcon, UnpublishIcon, ArrowLeftIcon, TrashIcon, ResetIcon, RevertIcon, PublishIcon, SplitVerticalIcon, EditIcon, ChevronLeftIcon, RestoreIcon, LinkIcon, EarthAmericasIcon, JsonIcon, SpinnerIcon, EllipsisHorizontalIcon, DoubleChevronLeftIcon, DoubleChevronRightIcon, CheckmarkCircleIcon, MasterDetailIcon } from "@sanity/icons"; import { useSchema, useTranslation, unstable_useValuePreview, useDocumentVersionInfo, usePerspective, getPreviewStateObservable, getPreviewValueWithFallback, SanityDefaultPreview, DocumentPreviewPresence, DocumentStatusIndicator, DocumentStatus, useUnique, getPublishedId, useDocumentPresence, useDocumentPreviewStore, PreviewCard, Translate, createHookFromObservableFactory, getDraftId, useClient, DEFAULT_STUDIO_CLIENT_OPTIONS, useDocumentStore, LoadingBlock, LegacyLayerProvider, IsLastPaneProvider, useGetI18nText, useI18nText, TooltipOfDisabled, ContextMenuButton, StatusButton, useCurrentUser, InsufficientPermissionsMessage, useTemplates, useIsReleaseActive, useTemplatePermissions, isPublishedPerspective, EMPTY_OBJECT, EMPTY_ARRAY as EMPTY_ARRAY$2, useEditState, GetHookCollectionState, useDocumentVersions, useActiveReleases, getVersionFromId, getReleaseIdFromReleaseDocumentId, isPublishedId, isDraftId, getVersionId, ReleaseAvatar, getReleaseTone, formatRelativeLocalePublishDate, isReleaseScheduledOrScheduling, isReleaseDocument, useMiddlewareComponents, ChangeIndicatorsTracker, VirtualizerScrollInstanceProvider, useDocumentForm, FormBuilder, isVersionId, createPatchChannel, isDev, CommentsEnabledProvider, useCommentsEnabled, CommentsProvider, COMMENTS_INSPECTOR_NAME, useArchivedReleases, useDocumentOperationEvent, Resizable, useKeyValueStore, isRecord, isString, isDraftPerspective, useDocumentOperation, isDeprecatedSchemaType, useProjectId, useZIndex, useListFormat, LATEST, useVersionOperations, getVersionInlineBadge, useSanityCreateConfig, getSanityCreateLinkMetadata, useOnlyHasVersions, useSetPerspective, VersionInlineBadge, isGoingToUnpublish, PresenceOverlay, fromMutationPatches, ScrollContainer, isSanityCreateLinked, isSystemBundle, useDocumentPairPermissions, useValidationStatus, useSyncState, useRelativeTime, useSource, Hotkeys, useDateTimeFormat, VersionChip, useFieldActions, UserAvatar, useUser, AvatarSkeleton, CommandList, TextWithTone, useTimelineSelector, useEvents, TIMELINE_ITEM_I18N_KEY_MAPPING as TIMELINE_ITEM_I18N_KEY_MAPPING$1, resizeObserver, ChangeConnectorRoot, useGlobalCopyPasteElementHandler, GetFormValueProvider, FieldActionsResolver, FieldActionsProvider, useInitialValue, useCopyPaste, useEventsStore, EventsProvider, isDeleteDocumentGroupEvent, isDeleteDocumentVersionEvent, PerspectiveProvider, useTimelineStore, SourceProvider, CopyPasteProvider, useDocumentType, ReferenceInputOptionsProvider, ErrorActions, collate, createSWR, getSearchableTypes, createSearch, useWorkspace, useSearchMaxFieldDepth, useSearchState, SearchHeader, Filters, SearchProvider, ChangeFieldWrapper, NoChanges, ChangeList, isUnpublishDocumentEvent, isScheduleDocumentVersionEvent, isUnscheduleDocumentVersionEvent, Event, RELEASES_INTENT, isCreateDocumentVersionEvent, isEditDocumentVersionEvent, getDocumentVariantType, isPublishDocumentVersionEvent, ChangesError, isArray, isValidationError, isValidationWarning, definePlugin } from "sanity"; import { uuid } from "@sanity/uuid"; import { styled, css, keyframes } from "styled-components"; import { motion, AnimatePresence } from "framer-motion"; import { useObservable, useObservableEvent } from "react-rx"; import { StateLink, useIntentLink, IntentLink, useRouter, route, encodeJsonParams, decodeJsonParams } from "sanity/router"; import omit from "lodash/omit.js"; import * as PathUtils from "@sanity/util/paths"; import { toString, fromString, get, resolveKeyedPath } from "@sanity/util/paths"; import { fromEvent, timer, EMPTY, of, Subject, distinctUntilChanged as distinctUntilChanged$1, filter, map as map$1, merge, startWith as startWith$1, catchError as catchError$1, concat, firstValueFrom, BehaviorSubject, from, defer, mergeMap, throwError, share, partition, take, throttleTime, asyncScheduler, tap as tap$1, debounce } from "rxjs"; import fromPairs from "lodash/fromPairs.js"; import toPairs from "lodash/toPairs.js"; import ScrollMirror from "scrollmirror"; import noop from "lodash/noop.js"; import deepEquals from "react-fast-compare"; import { switchMap, startWith, map, distinctUntilChanged, shareReplay, catchError, mapTo, delay, debounceTime, tap, withLatestFrom, filter as filter$1, take as take$1, mergeMap as mergeMap$1, share as share$1, takeUntil, scan } from "rxjs/operators"; import { isHotkey } from "is-hotkey-esm"; import { useTranslation as useTranslation$1 } from "react-i18next"; import { JsonInspector } from "@rexxars/react-json-inspector"; import QuickLRU from "quick-lru"; import { useTelemetry } from "@sanity/telemetry/react"; import { defineEvent } from "@sanity/telemetry"; import { isAfter, addWeeks, isBefore, format } from "date-fns"; import { useEffectEvent } from "use-effect-event"; import { getTheme_v2, rgba } from "@sanity/ui/theme"; import { isSanityDocument as isSanityDocument$1, isValidationErrorMarker, isKeySegment, isIndexSegment, isReferenceSchemaType, isObjectSchemaType, isDocumentSchemaType } from "@sanity/types"; import isEqual from "lodash/isEqual.js"; import shallowEquals from "shallow-equals"; import uniqBy from "lodash/uniqBy.js"; import negate from "lodash/negate.js"; import { MenuGroup } from "./MenuGroup.mjs"; import { parse } from "groq-js"; import { observableCallback } from "observable-callback"; import { exhaustMapWithTrailing } from "rxjs-exhaustmap-with-trailing"; import { flexRender, createColumnHelper, useReactTable, getPaginationRowModel, getFilteredRowModel, getCoreRowModel } from "@tanstack/react-table"; function DocTitle(props) { const $ = c(21), { document: documentValue } = props, schema = useSchema(); let t0; $[0] !== documentValue._type || $[1] !== schema ? (t0 = schema.get(documentValue._type), $[0] = documentValue._type, $[1] = schema, $[2] = t0) : t0 = $[2]; const schemaType = t0, { t } = useTranslation(structureLocaleNamespace); let t1; $[3] !== documentValue || $[4] !== schemaType ? (t1 = { schemaType, value: documentValue }, $[3] = documentValue, $[4] = schemaType, $[5] = t1) : t1 = $[5]; const { error, value } = unstable_useValuePreview(t1); if (!schemaType) { let t22; $[6] !== documentValue._type || $[7] !== t ? (t22 = t("doc-title.unknown-schema-type.text", { schemaType: documentValue._type }), $[6] = documentValue._type, $[7] = t, $[8] = t22) : t22 = $[8]; let t32; return $[9] !== t22 ? (t32 = /* @__PURE__ */ jsx("code", { children: t22 }), $[9] = t22, $[10] = t32) : t32 = $[10], t32; } if (error) { let t22; $[11] !== error.message || $[12] !== t ? (t22 = t("doc-title.error.text", { errorMessage: error.message }), $[11] = error.message, $[12] = t, $[13] = t22) : t22 = $[13]; let t32; return $[14] !== t22 ? (t32 = /* @__PURE__ */ jsx(Fragment, { children: t22 }), $[14] = t22, $[15] = t32) : t32 = $[15], t32; } let t2; $[16] !== t || $[17] !== value?.title ? (t2 = value?.title || /* @__PURE__ */ jsx("span", { style: { color: "var(--card-muted-fg-color)" }, children: t("doc-title.fallback.text") }), $[16] = t, $[17] = value?.title, $[18] = t2) : t2 = $[18]; let t3; return $[19] !== t2 ? (t3 = /* @__PURE__ */ jsx(Fragment, { children: t2 }), $[19] = t2, $[20] = t3) : t3 = $[20], t3; } const ChevronWrapper = styled(Box)` margin-left: auto; `, CrossDatasetReferencesDetails = styled.details` flex: none; &[open] ${ChevronWrapper} { transform: rotate(180deg); } `, CrossDatasetReferencesSummary = styled.summary` list-style: none; &::-webkit-details-marker { display: none; } `, Table$1 = styled.table` width: 100%; text-align: left; padding: 0 ${({ theme }) => rem(theme.sanity.space[2])}; border-collapse: collapse; th { padding: ${({ theme }) => rem(theme.sanity.space[1])}; } td { padding: 0 ${({ theme }) => rem(theme.sanity.space[1])}; } tr > *:last-child { text-align: right; } `, DocumentIdFlex = styled(Flex)` min-height: 33px; `, OtherReferenceCount = (props) => { const $ = c(13), { t } = useTranslation(structureLocaleNamespace), difference = props.totalCount - props.references.length; if (!difference) return null; let t0; $[0] !== difference || $[1] !== t ? (t0 = t("confirm-delete-dialog.other-reference-count.title", { count: difference }), $[0] = difference, $[1] = t, $[2] = t0) : t0 = $[2]; let t1; $[3] !== t0 ? (t1 = /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: t0 }), $[3] = t0, $[4] = t1) : t1 = $[4]; let t2; $[5] !== t ? (t2 = t("confirm-delete-dialog.other-reference-count.tooltip"), $[5] = t, $[6] = t2) : t2 = $[6]; let t3; $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: /* @__PURE__ */ jsx(InfoOutlineIcon, {}) }), $[7] = t3) : t3 = $[7]; let t4; $[8] !== t2 ? (t4 = /* @__PURE__ */ jsx(Tooltip, { portal: !0, placement: "top", content: t2, children: t3 }), $[8] = t2, $[9] = t4) : t4 = $[9]; let t5; return $[10] !== t1 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsxs(Inline, { space: 2, children: [ t1, t4 ] }) }), $[10] = t1, $[11] = t4, $[12] = t5) : t5 = $[12], t5; }; function PaneItemPreview(props) { const $ = c(27), { icon, layout, presence, schemaType, value } = props, versionsInfo = useDocumentVersionInfo(value._id), { perspectiveStack } = usePerspective(); let t0, t1; $[0] !== perspectiveStack || $[1] !== props.documentPreviewStore || $[2] !== schemaType || $[3] !== value._id ? (t1 = getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, perspectiveStack), $[0] = perspectiveStack, $[1] = props.documentPreviewStore, $[2] = schemaType, $[3] = value._id, $[4] = t1) : t1 = $[4], t0 = t1; const previewStateObservable = t0; let t2; $[5] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { snapshot: null, isLoading: !0, original: null }, $[5] = t2) : t2 = $[5]; const { snapshot, original, isLoading: previewIsLoading } = useObservable(previewStateObservable, t2), isLoading = previewIsLoading; let t3; $[6] !== isLoading || $[7] !== presence || $[8] !== versionsInfo.draft || $[9] !== versionsInfo.published || $[10] !== versionsInfo.versions ? (t3 = isLoading ? null : /* @__PURE__ */ jsx(TooltipDelayGroupProvider, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, children: [ presence && presence.length > 0 && /* @__PURE__ */ jsx(DocumentPreviewPresence, { presence }), /* @__PURE__ */ jsx(DocumentStatusIndicator, { draft: versionsInfo.draft, published: versionsInfo.published, versions: versionsInfo.versions }) ] }) }), $[6] = isLoading, $[7] = presence, $[8] = versionsInfo.draft, $[9] = versionsInfo.published, $[10] = versionsInfo.versions, $[11] = t3) : t3 = $[11]; const status = t3; let t4; $[12] !== versionsInfo.draft || $[13] !== versionsInfo.published || $[14] !== versionsInfo.versions ? (t4 = /* @__PURE__ */ jsx(DocumentStatus, { draft: versionsInfo.draft, published: versionsInfo.published, versions: versionsInfo.versions }), $[12] = versionsInfo.draft, $[13] = versionsInfo.published, $[14] = versionsInfo.versions, $[15] = t4) : t4 = $[15]; const tooltip = t4; let t5; $[16] !== original || $[17] !== snapshot || $[18] !== value ? (t5 = getPreviewValueWithFallback({ snapshot, original, fallback: value }), $[16] = original, $[17] = snapshot, $[18] = value, $[19] = t5) : t5 = $[19]; let t6; return $[20] !== icon || $[21] !== isLoading || $[22] !== layout || $[23] !== status || $[24] !== t5 || $[25] !== tooltip ? (t6 = /* @__PURE__ */ jsx(SanityDefaultPreview, { ...t5, isPlaceholder: isLoading, icon, layout, status, tooltip }), $[20] = icon, $[21] = isLoading, $[22] = layout, $[23] = status, $[24] = t5, $[25] = tooltip, $[26] = t6) : t6 = $[26], t6; } const BackLink = forwardRef(function(props, ref) { const $ = c(9), { routerPanesState, groupIndex } = useContext(PaneRouterContext); let t0, t1; $[0] !== groupIndex || $[1] !== routerPanesState ? (t1 = routerPanesState.slice(0, groupIndex), $[0] = groupIndex, $[1] = routerPanesState, $[2] = t1) : t1 = $[2], t0 = t1; const panes = t0; let t2, t3; $[3] !== panes ? (t3 = { panes }, $[3] = panes, $[4] = t3) : t3 = $[4], t2 = t3; const state2 = t2; let t4; return $[5] !== props || $[6] !== ref || $[7] !== state2 ? (t4 = /* @__PURE__ */ jsx(StateLink, { ...props, ref, state: state2 }), $[5] = props, $[6] = ref, $[7] = state2, $[8] = t4) : t4 = $[8], t4; }); function usePaneLayout() { const pane2 = useContext(PaneLayoutContext); if (!pane2) throw new Error("PaneLayout: missing context value"); return pane2; } const ChildLink = forwardRef(function(props, ref) { const $ = c(19); let childId, childParameters, childPayload, rest; $[0] !== props ? ({ childId, childPayload, childParameters, ...rest } = props, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childPayload, $[4] = rest) : (childId = $[1], childParameters = $[2], childPayload = $[3], rest = $[4]); const { routerPanesState, groupIndex } = useContext(PaneRouterContext); let t0; if ($[5] !== childId || $[6] !== childParameters || $[7] !== childPayload || $[8] !== groupIndex || $[9] !== routerPanesState) { let t12; $[11] !== childId || $[12] !== childParameters || $[13] !== childPayload ? (t12 = [{ id: childId, params: childParameters, payload: childPayload }], $[11] = childId, $[12] = childParameters, $[13] = childPayload, $[14] = t12) : t12 = $[14], t0 = { panes: [...routerPanesState.slice(0, groupIndex + 1), t12] }, $[5] = childId, $[6] = childParameters, $[7] = childPayload, $[8] = groupIndex, $[9] = routerPanesState, $[10] = t0; } else t0 = $[10]; let t1; return $[15] !== ref || $[16] !== rest || $[17] !== t0 ? (t1 = /* @__PURE__ */ jsx(StateLink, { ...rest, ref, state: t0 }), $[15] = ref, $[16] = rest, $[17] = t0, $[18] = t1) : t1 = $[18], t1; }), ParameterizedLink = forwardRef(function(props, ref) { const $ = c(22), { routerPanesState: currentPanes, groupIndex, siblingIndex } = useContext(PaneRouterContext); let params, payload, rest; $[0] !== props ? ({ params, payload, ...rest } = props, $[0] = props, $[1] = params, $[2] = payload, $[3] = rest) : (params = $[1], payload = $[2], rest = $[3]); const nextParams = useUnique(params), nextPayload = useUnique(payload); let t0; const currentGroup = currentPanes[groupIndex], currentSibling = currentGroup[siblingIndex], t1 = nextParams ?? currentSibling.params, t2 = nextPayload ?? currentSibling.payload; let t3; $[4] !== currentSibling || $[5] !== t1 || $[6] !== t2 ? (t3 = { ...currentSibling, params: t1, payload: t2 }, $[4] = currentSibling, $[5] = t1, $[6] = t2, $[7] = t3) : t3 = $[7]; const nextSibling = t3; let t4; $[8] !== currentGroup || $[9] !== nextSibling || $[10] !== siblingIndex ? (t4 = [...currentGroup.slice(0, siblingIndex), nextSibling, ...currentGroup.slice(siblingIndex + 1)], $[8] = currentGroup, $[9] = nextSibling, $[10] = siblingIndex, $[11] = t4) : t4 = $[11]; const nextGroup = t4; let t5; $[12] !== currentPanes || $[13] !== groupIndex || $[14] !== nextGroup ? (t5 = [...currentPanes.slice(0, groupIndex), nextGroup, ...currentPanes.slice(groupIndex + 1)], $[12] = currentPanes, $[13] = groupIndex, $[14] = nextGroup, $[15] = t5) : t5 = $[15]; const nextPanes = t5; let t6; $[16] !== nextPanes ? (t6 = { panes: nextPanes }, $[16] = nextPanes, $[17] = t6) : t6 = $[17], t0 = t6; const nextState = t0; let t7; return $[18] !== nextState || $[19] !== ref || $[20] !== rest ? (t7 = /* @__PURE__ */ jsx(StateLink, { ref, ...rest, state: nextState }), $[18] = nextState, $[19] = ref, $[20] = rest, $[21] = t7) : t7 = $[21], t7; }), ReferenceChildLink = forwardRef(function(t0, ref) { const $ = c(22); let children, documentId, documentType, parentRefPath, rest, template; $[0] !== t0 ? ({ documentId, documentType, parentRefPath, children, template, ...rest } = t0, $[0] = t0, $[1] = children, $[2] = documentId, $[3] = documentType, $[4] = parentRefPath, $[5] = rest, $[6] = template) : (children = $[1], documentId = $[2], documentType = $[3], parentRefPath = $[4], rest = $[5], template = $[6]); const t1 = template?.params; let t2; $[7] !== parentRefPath ? (t2 = toString(parentRefPath), $[7] = parentRefPath, $[8] = t2) : t2 = $[8]; let t3; $[9] !== template ? (t3 = template && { template: template?.id }, $[9] = template, $[10] = t3) : t3 = $[10]; let t4; $[11] !== documentType || $[12] !== t2 || $[13] !== t3 ? (t4 = { type: documentType, parentRefPath: t2, ...t3 }, $[11] = documentType, $[12] = t2, $[13] = t3, $[14] = t4) : t4 = $[14]; let t5; return $[15] !== children || $[16] !== documentId || $[17] !== ref || $[18] !== rest || $[19] !== t1 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId: documentId, childPayload: t1, childParameters: t4, children }), $[15] = children, $[16] = documentId, $[17] = ref, $[18] = rest, $[19] = t1, $[20] = t4, $[21] = t5) : t5 = $[21], t5; }); function usePaneRouter() { return useContext(PaneRouterContext); } const EMPTY_ARRAY$1 = []; function ReferencePreviewLink(props) { const $ = c(16), { onClick, type, value } = props, t0 = value?._id; let t1; $[0] !== t0 ? (t1 = getPublishedId(t0), $[0] = t0, $[1] = t1) : t1 = $[1]; const documentPresence = useDocumentPresence(t1), documentPreviewStore = useDocumentPreviewStore(), { ReferenceChildLink: ReferenceChildLink2 } = usePaneRouter(); let t2; $[2] !== ReferenceChildLink2 || $[3] !== type?.name || $[4] !== value?._id ? (t2 = function(linkProps) { return /* @__PURE__ */ jsx(ReferenceChildLink2, { documentId: value?._id, documentType: type?.name, parentRefPath: EMPTY_ARRAY$1, ...linkProps }); }, $[2] = ReferenceChildLink2, $[3] = type?.name, $[4] = value?._id, $[5] = t2) : t2 = $[5]; const t3 = t2, t4 = type?.icon, t5 = documentPresence?.length > 0 ? documentPresence : EMPTY_ARRAY$1; let t6; $[6] !== documentPreviewStore || $[7] !== t4 || $[8] !== t5 || $[9] !== type || $[10] !== value ? (t6 = /* @__PURE__ */ jsx(PaneItemPreview, { documentPreviewStore, icon: t4, layout: "compact", presence: t5, schemaType: type, value }), $[6] = documentPreviewStore, $[7] = t4, $[8] = t5, $[9] = type, $[10] = value, $[11] = t6) : t6 = $[11]; let t7; return $[12] !== onClick || $[13] !== t3 || $[14] !== t6 ? (t7 = /* @__PURE__ */ jsx(PreviewCard, { __unstable_focusRing: !0, as: t3, "data-as": "a", onClick, radius: 2, children: t6 }), $[12] = onClick, $[13] = t3, $[14] = t6, $[15] = t7) : t7 = $[15], t7; } function ConfirmDeleteDialogBody(t0) { const $ = c(78), { crossDatasetReferences, internalReferences, documentTitle, totalCount, action, datasetNames, hasUnknownDatasetNames, onReferenceLinkClick } = t0, schema = useSchema(), toast = useToast(), { t } = useTranslation(structureLocaleNamespace); let t1; $[0] !== onReferenceLinkClick || $[1] !== schema || $[2] !== t ? (t1 = (item) => { const type = schema.get(item._type); return type ? /* @__PURE__ */ jsx(ReferencePreviewLink, { type, value: item, onClick: onReferenceLinkClick }) : /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(SanityDefaultPreview, { icon: UnknownIcon, title: t("confirm-delete-dialog.preview-item.preview-unavailable.title"), subtitle: t("confirm-delete-dialog.preview-item.preview-unavailable.subtitle", { documentId: item._id }), layout: "default" }) }); }, $[0] = onReferenceLinkClick, $[1] = schema, $[2] = t, $[3] = t1) : t1 = $[3]; const renderPreviewItem = t1; if (internalReferences?.totalCount === 0 && crossDatasetReferences?.totalCount === 0) { let t22; $[4] !== documentTitle ? (t22 = { DocumentTitle: () => /* @__PURE__ */ jsx("strong", { children: documentTitle }) }, $[4] = documentTitle, $[5] = t22) : t22 = $[5]; let t32; return $[6] !== action || $[7] !== t || $[8] !== t22 ? (t32 = /* @__PURE__ */ jsx(Text, { as: "p", size: 1, children: /* @__PURE__ */ jsx(Translate, { t, i18nKey: "confirm-delete-dialog.confirmation.text", context: action, components: t22 }) }), $[6] = action, $[7] = t, $[8] = t22, $[9] = t32) : t32 = $[9], t32; } let T0, T1, T2, t10, t11, t12, t2, t3, t4, t5, t6, t7, t8, t9; if ($[10] !== action || $[11] !== crossDatasetReferences || $[12] !== datasetNames || $[13] !== documentTitle || $[14] !== hasUnknownDatasetNames || $[15] !== internalReferences || $[16] !== renderPreviewItem || $[17] !== t || $[18] !== toast || $[19] !== totalCount) { const normalizedDatasetNames = [...datasetNames, ...hasUnknownDatasetNames ? ["unavailable"] : []], datasetSubtitle = t("confirm-delete-dialog.cdr-summary.subtitle", { count: normalizedDatasetNames.length, datasets: normalizedDatasetNames.join(", "), context: hasUnknownDatasetNames && normalizedDatasetNames.length ? "unavailable" : "" }); T2 = Flex, t9 = "column", t10 = 4; let t132; $[34] === Symbol.for("react.memo_cache_sentinel") ? (t132 = /* @__PURE__ */ jsx(Text, { "aria-hidden": "true", size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }), $[34] = t132) : t132 = $[34]; let t142; $[35] !== documentTitle ? (t142 = { DocumentTitle: () => documentTitle }, $[35] = documentTitle, $[36] = t142) : t142 = $[36]; let t152; $[37] !== totalCount ? (t152 = { count: totalCount }, $[37] = totalCount, $[38] = t152) : t152 = $[38], $[39] !== t || $[40] !== t142 || $[41] !== t152 ? (t11 = /* @__PURE__ */ jsx(Card, { padding: 3, radius: 2, tone: "caution", flex: "none", children: /* @__PURE__ */ jsxs(Flex, { children: [ t132, /* @__PURE__ */ jsx(Box, { flex: 1, marginLeft: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Translate, { i18nKey: "confirm-delete-dialog.referring-document-count.text", components: t142, t, values: t152 }) }) }) ] }) }), $[39] = t, $[40] = t142, $[41] = t152, $[42] = t11) : t11 = $[42]; let t162; $[43] !== documentTitle ? (t162 = { DocumentTitle: () => documentTitle }, $[43] = documentTitle, $[44] = t162) : t162 = $[44], $[45] !== action || $[46] !== t || $[47] !== t162 ? (t12 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Translate, { i18nKey: "confirm-delete-dialog.referring-documents-descriptor.text", t, context: action, components: t162 }) }) }), $[45] = action, $[46] = t, $[47] = t162, $[48] = t12) : t12 = $[48], T1 = Card, t5 = 2, t6 = 1, t7 = "auto", t8 = 2, T0 = Flex, t2 = "column", $[49] !== internalReferences || $[50] !== renderPreviewItem ? (t3 = internalReferences.totalCount > 0 && /* @__PURE__ */ jsxs(Stack, { as: "ul", marginBottom: 2, space: 2, "data-testid": "internal-references", children: [ internalReferences?.references.map((item_0) => /* @__PURE__ */ jsx(Box, { as: "li", children: renderPreviewItem(item_0) }, item_0._id)), internalReferences.totalCount > internalReferences.references.length && /* @__PURE__ */ jsx(Box, { as: "li", padding: 3, children: /* @__PURE__ */ jsx(OtherReferenceCount, { ...internalReferences }) }) ] }), $[49] = internalReferences, $[50] = renderPreviewItem, $[51] = t3) : t3 = $[51], t4 = crossDatasetReferences.totalCount > 0 && /* @__PURE__ */ jsxs(CrossDatasetReferencesDetails, { "data-testid": "cross-dataset-references", style: { borderTop: internalReferences.totalCount > 0 ? "1px solid var(--card-shadow-outline-color)" : void 0 }, children: [ /* @__PURE__ */ jsx(CrossDatasetReferencesSummary, { children: /* @__PURE__ */ jsx(Card, { as: "a", marginTop: internalReferences.totalCount > 0 ? 2 : 0, radius: 2, shadow: 1, paddingY: 1, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, paddingX: 3, paddingY: 1, children: [ /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(DocumentsIcon, {}) }), /* @__PURE__ */ jsxs(Stack, { space: 2, children: [ /* @__PURE__ */ jsx(Text, { textOverflow: "ellipsis", size: 1, children: t("confirm-delete-dialog.cdr-summary.title", { count: normalizedDatasetNames.length, documentCount: t("confirm-delete-dialog.cdr-summary.document-count", { count: crossDatasetReferences.totalCount }) }) }), /* @__PURE__ */ jsx(Text, { title: datasetSubtitle, textOverflow: "ellipsis", size: 1, muted: !0, children: datasetSubtitle }) ] }), /* @__PURE__ */ jsx(ChevronWrapper, { children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) }) }) ] }) }) }), /* @__PURE__ */ jsxs(Box, { overflow: "auto", paddingTop: 2, children: [ /* @__PURE__ */ jsxs(Table$1, { children: [ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [ /* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, style: { minWidth: "5rem" }, weight: "medium", children: t("confirm-delete-dialog.cdr-table.project-id.label") }) }), /* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, weight: "medium", children: t("confirm-delete-dialog.cdr-table.dataset.label") }) }), /* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, weight: "medium", children: t("confirm-delete-dialog.cdr-table.document-id.label") }) }) ] }) }), /* @__PURE__ */ jsx("tbody", { children: crossDatasetReferences.references.filter(_temp$p).map((t172, index) => { const { projectId, datasetName, documentId } = t172; return /* @__PURE__ */ jsxs("tr", { children: [ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(Text, { size: 1, children: projectId }) }), /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(Text, { size: 1, children: datasetName || "unavailable" }) }), /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs(DocumentIdFlex, { align: "center", gap: 2, justify: "flex-end", children: [ /* @__PURE__ */ jsx(Text, { textOverflow: "ellipsis", size: 1, children: documentId || "unavailable" }), documentId && /* @__PURE__ */ jsx(Button, { mode: "bleed", icon: CopyIcon, tooltipProps: { content: t("confirm-delete-dialog.cdr-table.copy-id-button.tooltip") }, onClick: () => { navigator.clipboard.writeText(documentId).catch(() => { toast.push({ status: "error", title: t("confirm-delete-dialog.cdr-table.id-copied-toast.title-failed") }); }); } }) ] }) }) ] }, `${documentId}-${index}`); }) }) ] }), /* @__PURE__ */ jsx(OtherReferenceCount, { ...crossDatasetReferences }) ] }) ] }), $[10] = action, $[11] = crossDatasetReferences, $[12] = datasetNames, $[13] = documentTitle, $[14] = hasUnknownDatasetNames, $[15] = internalReferences, $[16] = renderPreviewItem, $[17] = t, $[18] = toast, $[19] = totalCount, $[20] = T0, $[21] = T1, $[22] = T2, $[23] = t10, $[24] = t11, $[25] = t12, $[26] = t2, $[27] = t3, $[28] = t4, $[29] = t5, $[30] = t6, $[31] = t7, $[32] = t8, $[33] = t9; } else T0 = $[20], T1 = $[21], T2 = $[22], t10 = $[23], t11 = $[24], t12 = $[25], t2 = $[26], t3 = $[27], t4 = $[28], t5 = $[29], t6 = $[30], t7 = $[31], t8 = $[32], t9 = $[33]; let t13; $[52] !== T0 || $[53] !== t2 || $[54] !== t3 || $[55] !== t4 ? (t13 = /* @__PURE__ */ jsxs(T0, { direction: t2, children: [ t3, t4 ] }), $[52] = T0, $[53] = t2, $[54] = t3, $[55] = t4, $[56] = t13) : t13 = $[56]; let t14; $[57] !== T1 || $[58] !== t13 || $[59] !== t5 || $[60] !== t6 || $[61] !== t7 || $[62] !== t8 ? (t14 = /* @__PURE__ */ jsx(T1, { radius: t5, shadow: t6, flex: t7, padding: t8, children: t13 }), $[57] = T1, $[58] = t13, $[59] = t5, $[60] = t6, $[61] = t7, $[62] = t8, $[63] = t14) : t14 = $[63]; let t15; $[64] !== documentTitle ? (t15 = { DocumentTitle: () => documentTitle }, $[64] = documentTitle, $[65] = t15) : t15 = $[65]; let t16; $[66] !== action || $[67] !== t || $[68] !== t15 ? (t16 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Translate, { i18nKey: "confirm-delete-dialog.referential-integrity-disclaimer.text", t, context: action, components: t15 }) }) }), $[66] = action, $[67] = t, $[68] = t15, $[69] = t16) : t16 = $[69]; let t17; return $[70] !== T2 || $[71] !== t10 || $[72] !== t11 || $[73] !== t12 || $[74] !== t14 || $[75] !== t16 || $[76] !== t9 ? (t17 = /* @__PURE__ */ jsxs(T2, { direction: t9, gap: t10, children: [ t11, t12, t14, t16 ] }), $[70] = T2, $[71] = t10, $[72] = t11, $[73] = t12, $[74] = t14, $[75] = t16, $[76] = t9, $[77] = t17) : t17 = $[77], t17; } function _temp$p(reference) { return "projectId" in reference; } function isClientError(e) { return typeof e != "object" || !e ? !1 : "statusCode" in e && "response" in e; } const POLL_INTERVAL = 5e3; let visiblePoll$; const getVisiblePoll$ = () => (visiblePoll$ || (visiblePoll$ = fromEvent(document, "visibilitychange").pipe( // add empty emission to have this fire on creation startWith(null), map(() => document.visibilityState === "visible"), distinctUntilChanged(), switchMap((visible) => visible ? ( // using timer instead of interval since timer will emit on creation timer(0, POLL_INTERVAL) ) : EMPTY), shareReplay({ refCount: !0, bufferSize: 1 }) )), visiblePoll$); function getDocumentExistence(documentId, { versionedClient }) { const draftId = getDraftId(documentId), publishedId = getPublishedId(documentId), requestOptions = { uri: versionedClient.getDataUrl("doc", `${draftId},${publishedId}`), json: !0, query: { excludeContent: "true" }, tag: "use-referring-documents.document-existence" }; return versionedClient.observable.request(requestOptions).pipe(map(({ omitted }) => { const nonExistant = omitted.filter((doc) => doc.reason === "existence"); if (nonExistant.length !== 2) return nonExistant.length === 0 || nonExistant.some((doc) => doc.id === draftId) ? publishedId : draftId; })); } function fetchCrossDatasetReferences(documentId, context) { const { versionedClient } = context; return getVisiblePoll$().pipe(switchMap(() => getDocumentExistence(documentId, context)), switchMap((checkDocumentId) => { if (!checkDocumentId) return of({ totalCount: 0, references: [] }); const currentDataset = versionedClient.config().dataset; return versionedClient.observable.request({ url: `/data/references/${currentDataset}/documents/${checkDocumentId}/to?excludeInternalReferences=true&excludePaths=true`, tag: "use-referring-documents.external" }).pipe(catchError((e) => { if (isClientError(e) && e.statusCode === 404) return of({ totalCount: 0, references: [] }); throw e; })); })); } const useInternalReferences = createHookFromObservableFactory(([documentId, documentStore]) => documentStore.listenQuery({ fetch: '{"references":*[references($documentId)][0...100]{_id,_type},"totalCount":count(*[references($documentId)])}', listen: "*[references($documentId)]" }, { documentId }, { tag: "use-referring-documents", transitions: ["appear", "disappear"], throttleTime: 5e3 })), useCrossDatasetReferences = createHookFromObservableFactory(([documentId, versionedClient]) => getVisiblePoll$().pipe(switchMap(() => fetchCrossDatasetReferences(documentId, { versionedClient })))); function useReferringDocuments(documentId) { const $ = c(24), versionedClient = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS), documentStore = useDocumentStore(); let t0; $[0] !== documentId ? (t0 = getPublishedId(documentId), $[0] = documentId, $[1] = t0) : t0 = $[1]; const publishedId = t0; let t1, t2; $[2] !== documentStore || $[3] !== publishedId ? (t2 = [publishedId, documentStore], $[2] = documentStore, $[3] = publishedId, $[4] = t2) : t2 = $[4], t1 = t2; const [internalReferences, isInternalReferencesLoading] = useInternalReferences(t1); let t3, t4; $[5] !== publishedId || $[6] !== versionedClient ? (t4 = [publishedId, versionedClient], $[5] = publishedId, $[6] = versionedClient, $[7] = t4) : t4 = $[7], t3 = t4; const [crossDatasetReferences, isCrossDatasetReferencesLoading] = useCrossDatasetReferences(t3); let t5; $[8] !== crossDatasetReferences?.references ? (t5 = () => Array.from(new Set(crossDatasetReferences?.references.map(_temp$o).filter(Boolean))).sort(), $[8] = crossDatasetReferences?.references, $[9] = t5) : t5 = $[9]; let t6; $[10] !== t5 ? (t6 = t5(), $[10] = t5, $[11] = t6) : t6 = $[11]; const projectIds = t6; let t7, t8; $[12] !== crossDatasetReferences?.references ? (t8 = Array.from(new Set(crossDatasetReferences?.references.map(_temp2$9).filter(_temp3$2))).sort(), $[12] = crossDatasetReferences?.references, $[13] = t8) : t8 = $[13], t7 = t8; const datasetNames = t7; let t9; $[14] !== crossDatasetReferences?.references ? (t9 = () => !!crossDatasetReferences?.references.some(_temp4$2), $[14] = crossDatasetReferences?.references, $[15] = t9) : t9 = $[15]; const hasUnknownDatasetNames = t9(), t10 = (internalReferences?.totalCount || 0) + (crossDatasetReferences?.totalCount || 0), t11 = isInternalReferencesLoading || isCrossDatasetReferencesLoading; let t12; return $[16] !== crossDatasetReferences || $[17] !== datasetNames || $[18] !== hasUnknownDatasetNames || $[19] !== internalReferences || $[20] !== projectIds || $[21] !== t10 || $[22] !== t11 ? (t12 = { totalCount: t10, projectIds, datasetNames, hasUnknownDatasetNames, internalReferences, crossDatasetReferences, isLoading: t11 }, $[16] = crossDatasetReferences, $[17] = datasetNames, $[18] = hasUnknownDatasetNames, $[19] = internalReferences, $[20] = projectIds, $[21] = t10, $[22] = t11, $[23] = t12) : t12 = $[23], t12; } function _temp4$2(crossDatasetReference_1) { return typeof crossDatasetReference_1.datasetName != "string"; } function _temp3$2(datasetName) { return !!datasetName && datasetName !== ""; } function _temp2$9(crossDatasetReference_0) { return crossDatasetReference_0?.datasetName || ""; } function _temp$o(crossDatasetReference) { return crossDatasetReference.projectId; } const DialogBody$1 = styled(Box)` box-sizing: border-box; `, LoadingContainer = styled(Flex).attrs({ align: "center", direction: "column", justify: "center" })` height: 110px; `; function ConfirmDeleteDialog(t0) { const $ = c(40), { id, type, action: t1, onCancel, onConfirm } = t0, action = t1 === void 0 ? "delete" : t1, { t } = useTranslation(structureLocaleNamespace), dialogId = `deletion-confirmation-${useId()}`, { internalReferences, crossDatasetReferences, isLoading, totalCount, projectIds, datasetNames, hasUnknownDatasetNames } = useReferringDocuments(id); let t2, t3; $[0] !== id || $[1] !== type ? (t3 = { _id: id, _type: type }, $[0] = id, $[1] = type, $[2] = t3) : t3 = $[2], t2 = t3; let t4; $[3] !== t2 ? (t4 = /* @__PURE__ */ jsx(DocTitle, { document: t2 }), $[3] = t2, $[4] = t4) : t4 = $[4]; const documentTitle = t4, showConfirmButton = !isLoading; let t5; $[5] !== action || $[6] !== t ? (t5 = t("confirm-delete-dialog.header.text", { context: action }), $[5] = action, $[6] = t, $[7] = t5) : t5 = $[7]; let t6; $[8] !== t ? (t6 = t("confirm-delete-dialog.cancel-button.text"), $[8] = t, $[9] = t6) : t6 = $[9]; let t7; $[10] !== onCancel || $[11] !== t6 ? (t7 = { onClick: onCancel, text: t6 }, $[10] = onCancel, $[11] = t6, $[12] = t7) : t7 = $[12]; let t8; $[13] !== action || $[14] !== onConfirm || $[15] !== showConfirmButton || $[16] !== t || $[17] !== totalCount ? (t8 = showConfirmButton ? { text: totalCount > 0 ? t("confirm-delete-dialog.confirm-anyway-button.text", { context: action }) : t("confirm-delete-dialog.confirm-button.text", { context: action }), onClick: onConfirm } : void 0, $[13] = action, $[14] = onConfirm, $[15] = showConfirmButton, $[16] = t, $[17] = totalCount, $[18] = t8) : t8 = $[18]; let t9; $[19] !== t7 || $[20] !== t8 ? (t9 = { cancelButton: t7, confirmButton: t8 }, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21]; let t10; $[22] !== action || $[23] !== crossDatasetReferences || $[24] !== datasetNames || $[25] !== documentTitle || $[26] !== hasUnknownDatasetNames || $[27] !== internalReferences || $[28] !== isLoading || $[29] !== onCancel || $[30] !== projectIds || $[31] !== t || $[32] !== totalCount ? (t10 = /* @__PURE__ */ jsx(DialogBody$1, { children: crossDatasetReferences && internalReferences && !isLoading ? /* @__PURE__ */ jsx(ConfirmDeleteDialogBody, { crossDatasetReferences, internalReferences, documentTitle, isLoading, totalCount, action, projectIds, datasetNames, hasUnknownDatasetNames, onReferenceLinkClick: onCancel }) : /* @__PURE__ */ jsx(LoadingContainer, { "data-testid": "loading-container", children: /* @__PURE__ */ jsx(LoadingBlock, { showText: !0, title: t("confirm-delete-dialog.loading.text") }) }) }), $[22] = action, $[23] = crossDatasetReferences, $[24] = datasetNames, $[25] = documentTitle, $[26] = hasUnknownDatasetNames, $[27] = internalReferences, $[28] = isLoading, $[29] = onCancel, $[30] = projectIds, $[31] = t, $[32] = totalCount, $[33] = t10) : t10 = $[33]; let t11; return $[34] !== dialogId || $[35] !== onCancel || $[36] !== t10 || $[37] !== t5 || $[38] !== t9 ? (t11 = /* @__PURE__ */ jsx(Dialog, { width: 1, id: dialogId, header: t5, footer: t9, onClose: onCancel, onClickOutside: onCancel, children: t10 }), $[34] = dialogId, $[35] = onCancel, $[36] = t10, $[37] = t5, $[38] = t9, $[39] = t11) : t11 = $[39], t11; } function ConfirmDeleteDialogContainer(props) { const $ = c(6), { t } = useTranslation(structureLocaleNamespace), id = useId(), [error, setError] = useState(null); let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setError(null), $[0] = t0) : t0 = $[0]; const handleRetry = t0; let t1; return $[1] !== error || $[2] !== id || $[3] !== props || $[4] !== t ? (t1 = error ? /* @__PURE__ */ jsx(Dialog, { id: `dialog-error-${id}`, "data-testid": "confirm-delete-error-dialog", header: t("confirm-delete-dialog.error.title.text"), footer: { confirmButton: { text: t("confirm-delete-dialog.error.retry-button.text"), onClick: handleRetry, tone: "default" } }, onClose: props.onCancel, children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Text, { size: 1, children: t("confirm-delete-dialog.error.message.text") }) }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setError, children: /* @__PURE__ */ jsx(ConfirmDeleteDialog, { ...props }) }), $[1] = error, $[2] = id, $[3] = props, $[4] = t, $[5] = t1) : t1 = $[5], t1; } function Delay(t0) { const $ = c(6), { children, ms: t1 } = t0, ms = t1 === void 0 ? 0 : t1, [ready, setReady] = useState(ms <= 0); let t2, t3; if ($[0] !== ms ? (t2 = () => { if (ms <= 0) return; const timeoutId = setTimeout(() => setReady(!0), ms); return () => { clearTimeout(timeoutId); }; }, t3 = [ms], $[0] = ms, $[1] = t2, $[2] = t3) : (t2 = $[1], t3 = $[2]), useEffect(t2, t3), !ready || !children) { let t42; return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t42 = /* @__PURE__ */ jsx(Fragment, {}), $[3] = t42) : t42 = $[3], t42; } let t4; return $[4] !== children ? (t4 = typeof children == "function" ? children() : children, $[4] = children, $[5] = t4) : t4 = $[5], t4; } const PANE_DEBUG = !1, PANE_COLLAPSED_WIDTH = 51, PANE_DEFAULT_MIN_WIDTH = 204, Root$9 = styled(Layer)` position: relative; width: 1px; min-width: 1px; &:before { content: ''; display: block; position: absolute; top: 0; left: 0; bottom: 0; width: 1px; background-color: var(--card-border-color); } &:not([data-disabled]) { cursor: ew-resize; width: 9px; min-width: 9px; margin: 0 -4px; &:before { left: 4px; } &:after { content: ''; display: block; position: absolute; top: 0; left: 0; width: 9px; bottom: 0; background-color: var(--card-border-color); opacity: 0; transition: opacity 150ms; } &[data-dragging]:after, &:hover:after { opacity: 0.2; } } `; function PaneDivider(t0) { const $ = c(7), { disabled, element } = t0, { resize } = usePaneLayout(), [dragging, setDragging] = useState(!1); let t1; $[0] !== element || $[1] !== resize ? (t1 = (event) => { if (!element) return; setDragging(!0), event.preventDefault(); const startX = event.pageX; resize("start", element, 0); const handleMouseMove = (e) => { e.preventDefault(); const deltaX = e.pageX - startX; resize("move", element, deltaX); }, handleMouseUp = (e_0) => { e_0.preventDefault(), setDragging(!1), window.removeEventListener("mousemove", handleMouseMove), window.removeEventListener("mouseup", handleMouseUp), resize("end", element, 0); }; window.addEventListener("mousemove", handleMouseMove), window.addEventListener("mouseup", handleMouseUp); }, $[0] = element, $[1] = resize, $[2] = t1) : t1 = $[2]; const handleMouseDown = t1, t2 = disabled ? "" : void 0, t3 = dragging ? "" : void 0; let t4; return $[3] !== handleMouseDown || $[4] !== t2 || $[5] !== t3 ? (t4 = /* @__PURE__ */ jsx(Root$9, { "data-disabled": t2, "data-dragging": t3, onMouseDown: handleMouseDown }), $[3] = handleMouseDown, $[4] = t2, $[5] = t3, $[6] = t4) : t4 = $[6], t4; } const Root$8 = styled(Card)` outline: none; // NOTE: This will render a border to the right side of each pane // without taking up physical space. box-shadow: 1px 0 0 var(--card-border-color); `, Pane = forwardRef(function(props, forwardedRef) { const $ = c(86); let children, currentMaxWidthProp, currentMinWidthProp, id, maxWidthProp, minWidthProp, restProps, t0, t1; $[0] !== props ? ({ children, currentMinWidth: currentMinWidthProp, currentMaxWidth: currentMaxWidthProp, flex: t0, id, minWidth: minWidthProp, maxWidth: maxWidthProp, selected: t1, ...restProps } = props, $[0] = props, $[1] = children, $[2] = currentMaxWidthProp, $[3] = currentMinWidthProp, $[4] = id, $[5] = maxWidthProp, $[6] = minWidthProp, $[7] = restProps, $[8] = t0, $[9] = t1) : (children = $[1], currentMaxWidthProp = $[2], currentMinWidthProp = $[3], id = $[4], maxWidthProp = $[5], minWidthProp = $[6], restProps = $[7], t0 = $[8], t1 = $[9]); const flexProp = t0 === void 0 ? 1 : t0, selected = t1 === void 0 ? !1 : t1, [rootElement, setRootElement] = useState(null), { collapse, collapsed: layoutCollapsed, expand, expandedElement, mount, panes } = usePaneLayout(); let pane2, t2; if ($[10] !== panes || $[11] !== rootElement) { let t32; $[14] !== rootElement ? (t32 = (p) => p.element === rootElement, $[14] = rootElement, $[15] = t32) : t32 = $[15], pane2 = panes.find(t32), t2 = pane2 && panes.indexOf(pane2), $[10] = panes, $[11] = rootElement, $[12] = pane2, $[13] = t2; } else pane2 = $[12], t2 = $[13]; const paneIndex = t2, nextPane = typeof paneIndex == "number" ? panes[paneIndex + 1] : void 0, isLast = paneIndex === panes.length - 1, expanded = expandedElement === rootElement, collapsed = layoutCollapsed ? !1 : pane2?.collapsed || !1, nextCollapsed = nextPane?.collapsed || !1, ref = useRef(null), flex = pane2?.flex ?? flexProp, currentMinWidth = pane2?.currentMinWidth ?? currentMinWidthProp, currentMaxWidth = pane2?.currentMaxWidth ?? currentMaxWidthProp; let t3; $[16] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[16] = t3) : t3 = $[16], useImperativeHandle(forwardedRef, t3); let t4; $[17] === Symbol.for("react.memo_cache_sentinel") ? (t4 = (refValue) => { setRootElement(refValue), ref.current = refValue; }, $[17] = t4) : t4 = $[17]; const setRef = t4; let t5, t6; $[18] !== currentMaxWidthProp || $[19] !== currentMinWidthProp || $[20] !== flexProp || $[21] !== id || $[22] !== maxWidthProp || $[23] !== minWidthProp || $[24] !== mount || $[25] !== rootElement ? (t5 = () => { if (rootElement) return mount(rootElement, { currentMinWidth: currentMinWidthProp, currentMaxWidth: currentMaxWidthProp, flex: flexProp, id, minWidth: minWidthProp, maxWidth: maxWidthProp }); }, t6 = [currentMinWidthProp, currentMaxWidthProp, flexProp, id, minWidthProp, maxWidthProp, mount, rootElement], $[18] = currentMaxWidthProp, $[19] = currentMinWidthProp, $[20] = flexProp, $[21] = id, $[22] = maxWidthProp, $[23] = minWidthProp, $[24] = mount, $[25] = rootElement, $[26] = t5, $[27] = t6) : (t5 = $[26], t6 = $[27]), useLayoutEffect(t5, t6); let t7; $[28] !== collapse || $[29] !== rootElement ? (t7 = () => { rootElement && collapse(rootElement); }, $[28] = collapse, $[29] = rootElement, $[30] = t7) : t7 = $[30]; const handleCollapse = t7; let t8; $[31] !== expand || $[32] !== rootElement ? (t8 = () => { rootElement && expand(rootElement); }, $[31] = expand, $[32] = rootElement, $[33] = t8) : t8 = $[33]; const handleExpand = t8; let t9; const t10 = layoutCollapsed ? !1 : collapsed; let t11; $[34] !== handleCollapse || $[35] !== handleExpand || $[36] !== isLast || $[37] !== paneIndex || $[38] !== rootElement || $[39] !== t10 ? (t11 = { collapse: handleCollapse, collapsed: t10, expand: handleExpand, index: paneIndex, isLast, rootElement }, $[34] = handleCollapse, $[35] = handleExpand, $[36] = isLast, $[37] = paneIndex, $[38] = rootElement, $[39] = t10, $[40] = t11) : t11 = $[40], t9 = t11; const contextValue = t9; let t12; bb0: { if (layoutCollapsed) { t12 = void 0; break bb0; } if (collapsed) { t12 = PANE_COLLAPSED_WIDTH; break bb0; } if (currentMinWidth === 0) { t12 = minWidthProp || PANE_DEFAULT_MIN_WIDTH; break bb0; } if (isLast) { t12 = minWidthProp || PANE_DEFAULT_MIN_WIDTH; break bb0; } t12 = currentMinWidth || minWidthProp || PANE_DEFAULT_MIN_WIDTH; } const minWidth = t12; let t13; bb1: { if (collapsed) { t13 = PANE_COLLAPSED_WIDTH; break bb1; } if (layoutCollapsed && isLast) { t13 = void 0; break bb1; } if (isLast) { if (maxWidthProp) { t13 = currentMaxWidth ?? maxWidthProp; break bb1; } t13 = void 0; break bb1; } t13 = currentMaxWidth ?? maxWidthProp; } const maxWidth = t13, hidden = layoutCollapsed && !isLast; let t14, t15; $[41] !== collapsed || $[42] !== isLast || $[43] !== layoutCollapsed || $[44] !== nextCollapsed || $[45] !== rootElement ? (t15 = !isLast && !layoutCollapsed && /* @__PURE__ */ jsx(LegacyLayerProvider, { zOffset: "paneResizer", children: /* @__PURE__ */ jsx(PaneDivider, { disabled: collapsed || nextCollapsed, element: rootElement }) }), $[41] = collapsed, $[4