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

842 lines (828 loc) • 4.22 MB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }); var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), PathUtils = require("@sanity/util/paths"), React = require("react"), deepEquals = require("react-fast-compare"), _singletons = require("sanity/_singletons"), debounce = require("lodash/debounce.js"), ui = require("@sanity/ui"), resizeObserver$1 = require("@juggle/resize-observer"), createPubSub = require("nano-pubsub"), TooltipDelayGroupProvider = require("./_chunks-cjs/TooltipDelayGroupProvider.js"); require("./_singletons.js"); var reactI18next = require("react-i18next"), theme = require("@sanity/ui/theme"), styledComponents = require("styled-components"), sortBy = require("lodash/sortBy.js"), types = require("@sanity/types"), reactVirtual = require("@tanstack/react-virtual"), throttle = require("lodash/throttle.js"), icons = require("@sanity/icons"), color = require("@sanity/color"), color2k = require("color2k"), rxjs = require("rxjs"), operators = require("rxjs/operators"), client = require("@sanity/client"), isEqual$2 = require("lodash/isEqual.js"), memoize$1 = require("lodash/memoize.js"), reactRx = require("react-rx"), observableCallback = require("observable-callback"), uniqueId = require("lodash/uniqueId.js"), i18next = require("i18next"), telemetry = require("@sanity/telemetry"), QuickLRU = require("quick-lru"), react = require("@sanity/telemetry/react"), DataLoader = require("dataloader"), nanoid = require("nanoid"), debug$8 = require("debug"), cloneObject = require("date-fns/_lib/cloneObject/index.js"), dateFnsFormat = require("date-fns/format/index.js"), toInteger = require("date-fns/_lib/toInteger/index.js"), getTimezoneOffsetInMilliseconds = require("date-fns/_lib/getTimezoneOffsetInMilliseconds/index.js"), dateFns = require("date-fns"), FocusLock = require("react-focus-lock"), semver = require("semver"), version = require("./_chunks-cjs/version.js"), omit = require("lodash/omit.js"), mutator = require("@sanity/mutator"), groupBy = require("lodash/groupBy.js"), partition = require("lodash/partition.js"), legacyDateFormat = require("@sanity/util/legacyDateFormat"), useDevicePixelRatio = require("use-device-pixel-ratio"), classNames = require("classnames"), reactIs = require("react-is"), assetUtils = require("@sanity/asset-utils"), imageUrlBuilder = require("@sanity/image-url"), router = require("sanity/router"), isString$1 = require("lodash/isString.js"), framerMotion = require("framer-motion"), isHotkeyEsm = require("is-hotkey-esm"), useEffectEvent = require("use-effect-event"), flatten$1 = require("lodash/flatten.js"), last = require("lodash/last.js"), uniqBy = require("lodash/uniqBy.js"), orderBy = require("lodash/orderBy.js"), _internal = require("@sanity/schema/_internal"), compact = require("lodash/compact.js"), flow = require("lodash/flow.js"), toLower = require("lodash/toLower.js"), trim = require("lodash/trim.js"), union = require("lodash/union.js"), uniq = require("lodash/uniq.js"), words = require("lodash/words.js"), content = require("@sanity/util/content"), get = require("lodash/get.js"), isPlainObject$1 = require("lodash/isPlainObject.js"), capitalize = require("lodash/capitalize.js"), core = require("@dnd-kit/core"), modifiers = require("@dnd-kit/modifiers"), sortable = require("@dnd-kit/sortable"), utilities = require("@dnd-kit/utilities"), shallowEquals = require("shallow-equals"), react$1 = require("@portabletext/react"), editor$1 = require("@portabletext/editor"), schema$1 = require("@sanity/schema"), plugins = require("@portabletext/editor/plugins"), startCase = require("lodash/startCase.js"), template = require("lodash/template.js"), diffMatchPatch$1 = require("@sanity/diff-match-patch"), scrollIntoView$1 = require("scroll-into-view-if-needed"), difference = require("lodash/difference.js"), range = require("lodash/range.js"), index_js = require("use-sync-external-store/shim/index.js"), uuid = require("@sanity/uuid"), deburr = require("lodash/deburr.js"), blockTools = require("@portabletext/block-tools"), keyBy = require("lodash/keyBy.js"), pick = require("lodash/pick.js"), sample = require("lodash/sample.js"), intersection = require("lodash/intersection.js"), isEmpty$1 = require("lodash/isEmpty.js"), server = require("react-dom/server"), isFinite = require("lodash/isFinite.js"), Refractor = require("react-refractor"), bash = require("refractor/lang/bash.js"), javascript = require("refractor/lang/javascript.js"), json = require("refractor/lang/json.js"), jsx2 = require("refractor/lang/jsx.js"), typescript = require("refractor/lang/typescript.js"), isObject = require("lodash/isObject.js"), react$2 = require("@sentry/react"), history$1 = require("history"), withSelector_js = require("use-sync-external-store/with-selector.js"), escapeRegExp$1 = require("lodash/escapeRegExp.js"), bifurClient = require("@sanity/bifur-client"), cloneDeep = require("lodash/cloneDeep.js"), logos = require("@sanity/logos"), generateHelpUrl_esm = require("./_chunks-cjs/generate-help-url.esm.js"), useHotModuleReload = require("use-hot-module-reload"), arrify = require("arrify"), csm = require("@sanity/client/csm"), castArray = require("lodash/castArray.js"), groqJs = require("groq-js"), insertMenu = require("@sanity/insert-menu"), mendoza = require("mendoza"), findIndex$1 = require("lodash/findIndex.js"), upperFirst = require("lodash/upperFirst.js"), find = require("lodash/find.js"), MenuGroup = require("./_chunks-cjs/MenuGroup.js"), getRandomValues = require("get-random-values-esm"), exif = require("exif-component"), clone = require("lodash/clone.js"), rxjsExhaustmapWithTrailing = require("rxjs-exhaustmap-with-trailing"), rxjsMergemapArray = require("rxjs-mergemap-array"), jsonReduce = require("json-reduce"), client$1 = require("@sanity/util/client"), concurrencyLimiter = require("@sanity/util/concurrency-limiter"), speakingurl = require("speakingurl"), xor = require("lodash/xor.js"), diffPatch = require("@sanity/diff-patch"), sortedIndex = require("lodash/sortedIndex.js"), identity$2 = require("lodash/identity.js"), values = require("lodash/values.js"), diff = require("@sanity/diff"), raf = require("raf"), client$2 = require("react-dom/client"), polished = require("polished"); function _interopDefaultCompat(e) { return e && typeof e == "object" && "default" in e ? e : { default: e }; } function _interopNamespaceCompat(e) { if (e && typeof e == "object" && "default" in e) return e; var n = /* @__PURE__ */ Object.create(null); return e && Object.keys(e).forEach(function(k) { if (k !== "default") { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: !0, get: function() { return e[k]; } }); } }), n.default = e, Object.freeze(n); } var PathUtils__namespace = /* @__PURE__ */ _interopNamespaceCompat(PathUtils), React__default = /* @__PURE__ */ _interopDefaultCompat(React), deepEquals__default = /* @__PURE__ */ _interopDefaultCompat(deepEquals), debounce__default = /* @__PURE__ */ _interopDefaultCompat(debounce), createPubSub__default = /* @__PURE__ */ _interopDefaultCompat(createPubSub), sortBy__default = /* @__PURE__ */ _interopDefaultCompat(sortBy), throttle__default = /* @__PURE__ */ _interopDefaultCompat(throttle), isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual$2), memoize__default = /* @__PURE__ */ _interopDefaultCompat(memoize$1), uniqueId__default = /* @__PURE__ */ _interopDefaultCompat(uniqueId), QuickLRU__default = /* @__PURE__ */ _interopDefaultCompat(QuickLRU), DataLoader__default = /* @__PURE__ */ _interopDefaultCompat(DataLoader), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$8), cloneObject__default = /* @__PURE__ */ _interopDefaultCompat(cloneObject), dateFnsFormat__default = /* @__PURE__ */ _interopDefaultCompat(dateFnsFormat), toInteger__default = /* @__PURE__ */ _interopDefaultCompat(toInteger), getTimezoneOffsetInMilliseconds__default = /* @__PURE__ */ _interopDefaultCompat(getTimezoneOffsetInMilliseconds), FocusLock__default = /* @__PURE__ */ _interopDefaultCompat(FocusLock), semver__default = /* @__PURE__ */ _interopDefaultCompat(semver), omit__default = /* @__PURE__ */ _interopDefaultCompat(omit), groupBy__default = /* @__PURE__ */ _interopDefaultCompat(groupBy), partition__default = /* @__PURE__ */ _interopDefaultCompat(partition), legacyDateFormat__namespace = /* @__PURE__ */ _interopNamespaceCompat(legacyDateFormat), classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames), imageUrlBuilder__default = /* @__PURE__ */ _interopDefaultCompat(imageUrlBuilder), isString__default = /* @__PURE__ */ _interopDefaultCompat(isString$1), flatten__default = /* @__PURE__ */ _interopDefaultCompat(flatten$1), last__default = /* @__PURE__ */ _interopDefaultCompat(last), uniqBy__default = /* @__PURE__ */ _interopDefaultCompat(uniqBy), orderBy__default = /* @__PURE__ */ _interopDefaultCompat(orderBy), compact__default = /* @__PURE__ */ _interopDefaultCompat(compact), flow__default = /* @__PURE__ */ _interopDefaultCompat(flow), toLower__default = /* @__PURE__ */ _interopDefaultCompat(toLower), trim__default = /* @__PURE__ */ _interopDefaultCompat(trim), union__default = /* @__PURE__ */ _interopDefaultCompat(union), uniq__default = /* @__PURE__ */ _interopDefaultCompat(uniq), words__default = /* @__PURE__ */ _interopDefaultCompat(words), get__default = /* @__PURE__ */ _interopDefaultCompat(get), isPlainObject__default = /* @__PURE__ */ _interopDefaultCompat(isPlainObject$1), capitalize__default = /* @__PURE__ */ _interopDefaultCompat(capitalize), shallowEquals__default = /* @__PURE__ */ _interopDefaultCompat(shallowEquals), startCase__default = /* @__PURE__ */ _interopDefaultCompat(startCase), template__default = /* @__PURE__ */ _interopDefaultCompat(template), scrollIntoView__default = /* @__PURE__ */ _interopDefaultCompat(scrollIntoView$1), difference__default = /* @__PURE__ */ _interopDefaultCompat(difference), range__default = /* @__PURE__ */ _interopDefaultCompat(range), deburr__default = /* @__PURE__ */ _interopDefaultCompat(deburr), keyBy__default = /* @__PURE__ */ _interopDefaultCompat(keyBy), pick__default = /* @__PURE__ */ _interopDefaultCompat(pick), sample__default = /* @__PURE__ */ _interopDefaultCompat(sample), intersection__default = /* @__PURE__ */ _interopDefaultCompat(intersection), isEmpty__default = /* @__PURE__ */ _interopDefaultCompat(isEmpty$1), isFinite__default = /* @__PURE__ */ _interopDefaultCompat(isFinite), Refractor__default = /* @__PURE__ */ _interopDefaultCompat(Refractor), bash__default = /* @__PURE__ */ _interopDefaultCompat(bash), javascript__default = /* @__PURE__ */ _interopDefaultCompat(javascript), json__default = /* @__PURE__ */ _interopDefaultCompat(json), jsx2__default = /* @__PURE__ */ _interopDefaultCompat(jsx2), typescript__default = /* @__PURE__ */ _interopDefaultCompat(typescript), isObject__default = /* @__PURE__ */ _interopDefaultCompat(isObject), escapeRegExp__default = /* @__PURE__ */ _interopDefaultCompat(escapeRegExp$1), cloneDeep__default = /* @__PURE__ */ _interopDefaultCompat(cloneDeep), arrify__default = /* @__PURE__ */ _interopDefaultCompat(arrify), castArray__default = /* @__PURE__ */ _interopDefaultCompat(castArray), findIndex__default = /* @__PURE__ */ _interopDefaultCompat(findIndex$1), upperFirst__default = /* @__PURE__ */ _interopDefaultCompat(upperFirst), find__default = /* @__PURE__ */ _interopDefaultCompat(find), getRandomValues__default = /* @__PURE__ */ _interopDefaultCompat(getRandomValues), exif__default = /* @__PURE__ */ _interopDefaultCompat(exif), clone__default = /* @__PURE__ */ _interopDefaultCompat(clone), speakingurl__default = /* @__PURE__ */ _interopDefaultCompat(speakingurl), xor__default = /* @__PURE__ */ _interopDefaultCompat(xor), sortedIndex__default = /* @__PURE__ */ _interopDefaultCompat(sortedIndex), identity__default = /* @__PURE__ */ _interopDefaultCompat(identity$2), values__default = /* @__PURE__ */ _interopDefaultCompat(values), raf__default = /* @__PURE__ */ _interopDefaultCompat(raf); function createStore(reportedValues, publish2) { function add(id2, value) { reportedValues.has(id2), reportedValues.set(id2, value), publish2(); } function update(id2, value) { reportedValues.has(id2), reportedValues.set(id2, value), publish2(); } function remove2(id2) { reportedValues.has(id2), reportedValues.delete(id2), publish2(); } return { add, remove: remove2, update }; } function useTrackerStore() { const [reportedValues] = React.useState(() => /* @__PURE__ */ new Map()), [snapshot2, updateSnapshot] = React.useReducer(() => Array.from(reportedValues.entries()), []), debouncedUpdateSnapshot = React.useMemo(() => debounce__default.default(updateSnapshot, 10, { trailing: !0 }), []); return { store: React.useMemo(() => createStore(reportedValues, debouncedUpdateSnapshot), [debouncedUpdateSnapshot, reportedValues]), snapshot: snapshot2 }; } function useTrackerStoreReporter(store, id2, value, t0) { const $ = reactCompilerRuntime.c(10), isEqual2 = t0 === void 0 ? Object.is : t0, idRef = React.useRef(null), previousRef = React.useRef(null); let t1, t2; $[0] !== id2 || $[1] !== store || $[2] !== value ? (t1 = () => { if (id2 === null || store === null) return; const nextValue = value(); return store.add(id2, nextValue), idRef.current = id2, previousRef.current = nextValue, () => { store.remove(id2), idRef.current = null, previousRef.current = null; }; }, t2 = [id2, store, value], $[0] = id2, $[1] = store, $[2] = value, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), React.useLayoutEffect(t1, t2); let t3; $[5] !== id2 || $[6] !== isEqual2 || $[7] !== store || $[8] !== value ? (t3 = () => { if (id2 === null || idRef.current === null || store === null || id2 !== idRef.current) return; const nextValue_0 = value(); isEqual2(previousRef.current, nextValue_0) || (store.update(id2, nextValue_0), previousRef.current = nextValue_0); }, $[5] = id2, $[6] = isEqual2, $[7] = store, $[8] = value, $[9] = t3) : t3 = $[9], React.useLayoutEffect(t3); } function ChangeIndicatorsTrackerComponent(props2) { const $ = reactCompilerRuntime.c(6), { children } = props2, { store, snapshot: snapshot2 } = useTrackerStore(); let t0; $[0] !== children || $[1] !== snapshot2 ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.ChangeIndicatorTrackerContextGetSnapshot.Provider, { value: snapshot2, children }), $[0] = children, $[1] = snapshot2, $[2] = t0) : t0 = $[2]; let t1; return $[3] !== store || $[4] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.ChangeIndicatorTrackerContextStore.Provider, { value: store, children: t0 }), $[3] = store, $[4] = t0, $[5] = t1) : t1 = $[5], t1; } const ChangeIndicatorsTracker = React.memo(ChangeIndicatorsTrackerComponent), EMPTY_ARRAY$C = []; function useChangeIndicatorsReportedValues() { const snapshot2 = React.useContext(_singletons.ChangeIndicatorTrackerContextGetSnapshot); return snapshot2 === null ? (console.warn(new Error('No context provided for reporter. Make sure that the component calling "useChangeIndicatorsReportedValues()", is wrapped inside a <ChangeIndicatorsTracker> element')), EMPTY_ARRAY$C) : snapshot2; } const useChangeIndicatorsReporter = (id2, value, isEqual2) => { const store = React.useContext(_singletons.ChangeIndicatorTrackerContextStore); store === null && console.warn(new Error('No context provided for reporter. Make sure that the component calling "useChangeIndicatorsReporter()", is wrapped inside a <ChangeIndicatorsTracker> element')), useTrackerStoreReporter(store, id2, value, isEqual2); }, ChangeFieldWrapper = (props2) => { const $ = reactCompilerRuntime.c(13), { path, hasHover } = props2, { onSetFocus } = React.useContext(_singletons.ConnectorContext), [isHover, setHover] = React.useState(!1); let t0; $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => { setHover(!0); }, $[0] = t0) : t0 = $[0]; const onMouseEnter = t0; let t1; $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => { setHover(!1); }, $[1] = t1) : t1 = $[1]; const onMouseLeave = t1, [element, setElement] = React.useState(null); let t2; t2 = element ? `change-${PathUtils__namespace.toString(path)}` : null; const reporterId = t2; let t3; $[2] !== element || $[3] !== hasHover || $[4] !== isHover || $[5] !== path ? (t3 = () => ({ element, path, isChanged: !0, hasFocus: !1, hasHover: isHover, hasRevertHover: hasHover }), $[2] = element, $[3] = hasHover, $[4] = isHover, $[5] = path, $[6] = t3) : t3 = $[6], useChangeIndicatorsReporter(reporterId, t3, deepEquals__default.default); let t4; $[7] !== onSetFocus || $[8] !== path ? (t4 = (event) => { setFocusWithStopPropagation(event, onSetFocus, path); }, $[7] = onSetFocus, $[8] = path, $[9] = t4) : t4 = $[9]; const handleClick = t4; let t5; return $[10] !== handleClick || $[11] !== props2.children ? (t5 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setElement, onClick: handleClick, onMouseLeave, onMouseEnter, children: props2.children }), $[10] = handleClick, $[11] = props2.children, $[12] = t5) : t5 = $[12], t5; }; function setFocusWithStopPropagation(event, onSetFocus, path) { event.stopPropagation(), onSetFocus(path); } function createHookFromObservableFactory(observableFactory, initialValue) { const initialLoadingTuple = [initialValue, !0], initialResult = { type: "tuple", tuple: initialLoadingTuple }; return function(arg) { const observable = React.useMemo(() => rxjs.of(arg).pipe(operators.switchMap((_arg) => rxjs.concat(rxjs.of({ type: "loading" }), observableFactory(_arg).pipe(operators.map((value) => ({ type: "value", value }))))), operators.scan(([prevValue], next) => next.type === "loading" ? [prevValue, !0] : [next.value, !1], initialLoadingTuple), operators.distinctUntilChanged(([prevValue, prevIsLoading], [nextValue, nextIsLoading]) => !(prevValue !== nextValue || prevIsLoading !== nextIsLoading)), operators.map((tuple) => ({ type: "tuple", tuple })), operators.catchError((error) => rxjs.of({ type: "error", error }))), [arg]), result = reactRx.useObservable(observable, initialResult); if (result.type === "error") throw result.error; return result.tuple; }; } function isNonNullable$3(value) { return value != null; } const DRAFTS_FOLDER = "drafts", VERSION_FOLDER = "versions", PATH_SEPARATOR = ".", DRAFTS_PREFIX = `${DRAFTS_FOLDER}${PATH_SEPARATOR}`, VERSION_PREFIX = `${VERSION_FOLDER}${PATH_SEPARATOR}`; function documentIdEquals(documentId, equalsDocumentId) { return getPublishedId(documentId) === getPublishedId(equalsDocumentId); } function isDraft(document2) { return isDraftId(document2._id); } function isDraftId(id2) { return id2.startsWith(DRAFTS_PREFIX); } function isVersionId(id2) { return id2.startsWith(VERSION_PREFIX); } function getIdPair(id2, { version: version2 } = {}) { if (version2 === "drafts" || version2 === "published") throw new Error('Version can not be "published" or "drafts"'); return { publishedId: getPublishedId(id2), draftId: getDraftId(id2), ...version2 ? { versionId: getVersionId(id2, version2) } : {} }; } function isPublishedId(id2) { return !isDraftId(id2) && !isVersionId(id2); } function getDraftId(id2) { if (isVersionId(id2)) { const publishedId = getPublishedId(id2); return DRAFTS_PREFIX + publishedId; } return isDraftId(id2) ? id2 : DRAFTS_PREFIX + id2; } const systemBundles = ["drafts", "published"]; function isSystemBundle(maybeSystemBundle) { return systemBundles.includes(maybeSystemBundle); } const systemBundleNames = ["draft", "published"]; function isSystemBundleName(maybeSystemBundleName) { return systemBundleNames.includes(maybeSystemBundleName); } function getVersionId(id2, version2) { if (isSystemBundle(version2)) throw new Error('Version can not be "published" or "drafts"'); return `${VERSION_PREFIX}${version2}${PATH_SEPARATOR}${getPublishedId(id2)}`; } function idMatchesPerspective(perspectiveStack, documentId) { return isPublishedId(documentId) ? !0 : perspectiveStack.some((perspective) => perspective === "drafts" ? isDraftId(documentId) : getVersionFromId(documentId) === perspective); } function getVersionFromId(id2) { if (!isVersionId(id2)) return; const [_versionPrefix, versionId, ..._publishedId] = id2.split(PATH_SEPARATOR); return versionId; } function getPublishedId(id2) { return isVersionId(id2) ? id2.split(PATH_SEPARATOR).slice(2).join(PATH_SEPARATOR) : isDraftId(id2) ? id2.slice(DRAFTS_PREFIX.length) : id2; } function createDraftFrom(document2) { return { ...document2, _id: getDraftId(document2._id) }; } function newDraftFrom(document2) { return { ...document2, _id: DRAFTS_PREFIX }; } function createPublishedFrom(document2) { return { ...document2, _id: getPublishedId(document2._id) }; } function collate(documents) { const byId = documents.reduce((res, doc) => { const publishedId = getPublishedId(doc._id); let entry = res.get(publishedId); return entry || (entry = { id: publishedId, type: doc._type, published: void 0, draft: void 0, versions: [] }, res.set(publishedId, entry)), isPublishedId(doc._id) && (entry.published = doc), isDraftId(doc._id) && (entry.draft = doc), isVersionId(doc._id) && entry.versions.push(doc), res; }, /* @__PURE__ */ new Map()); return Array.from(byId.values()); } function removeDupes$3(documents) { return collate(documents).map((entry) => entry.draft || entry.published || entry.versions[0]).filter(isNonNullable$3); } const EMPTY_OBJECT = Object.freeze({}), EMPTY_ARRAY$B = Object.freeze([]), formatRelativeLocale = (...args) => { const dateFnsRelative = dateFns.formatRelative(...args); if (dateFns.isValid(dateFns.parse(dateFnsRelative, "MM/dd/yyyy", /* @__PURE__ */ new Date()))) { const [dateTime] = args; return new Date(dateTime).toLocaleDateString(); } return dateFnsRelative; }; function getDocumentVariantType(documentId) { return isDraftId(documentId) ? "draft" : isVersionId(documentId) ? "version" : "published"; } function getGlobalScope() { if (typeof globalThis < "u") return globalThis; if (typeof window < "u") return window; if (typeof self < "u") return self; if (typeof global < "u") return global; throw new Error("@sanity/ui: could not locate global scope"); } const globalScope = getGlobalScope(); function isArray(value) { return Array.isArray(value); } function isRecord$4(value) { return !!value && typeof value == "object" && !Array.isArray(value); } function isString(value) { return typeof value == "string"; } function isTruthy(value) { return !!value; } const ResizeObserver = typeof document == "object" && typeof window == "object" && window.ResizeObserver ? window.ResizeObserver : resizeObserver$1.ResizeObserver, createSharedResizeObserver = () => { const event = createPubSub__default.default(), resizeObserver2 = new ResizeObserver((entries) => event.publish(entries)); return { observe: (element, observer, options) => { const unsubscribe = event.subscribe((entries) => { const entry = entries.find((e) => e.target === element); entry && observer(entry); }); return resizeObserver2.observe(element, options), () => { unsubscribe(), resizeObserver2.unobserve(element); }; }, unobserve: (element) => resizeObserver2.unobserve(element) }; }, resizeObserver = createSharedResizeObserver(), createSWRCache = createLRUCache; function createSWR(options) { const cache2 = createSWRCache(options); return function(key) { return (input$) => rxjs.concat(rxjs.defer(() => cache2.has(key) ? rxjs.of({ fromCache: !0, value: cache2.get(key) }) : rxjs.EMPTY), input$.pipe(operators.tap((result) => cache2.set(key, result)), rxjs.map((value) => ({ fromCache: !1, value })))); }; } function createLRUCache(options) { const lru = new QuickLRU__default.default(options); return { get(key) { const entry = lru.get(key); if (!entry) throw new Error(`Key not found in LRU cache: ${key}`); return entry.value; }, set(key, value) { lru.set(key, { value }); }, delete(key) { lru.delete(key); }, has(key) { return lru.has(key); } }; } const BUNDLED_DOC_TYPES = ["sanity.imageAsset", "sanity.fileAsset"]; function _isSanityDocumentTypeDefinition(def) { return def.type === "document" && BUNDLED_DOC_TYPES.includes(def.name); } function _isCustomDocumentTypeDefinition(def) { return def.type === "document" && !_isSanityDocumentTypeDefinition(def); } const GROQ_KEYWORDS = ["match", "in", "asc", "desc", "true", "false", "null"], VALID_FIELD = /^[a-zA-Z_][a-zA-Z0-9_]*$/, fieldNeedsEscape = (fieldName) => !VALID_FIELD.test(fieldName) || GROQ_KEYWORDS.includes(fieldName), escapeField = (fieldName) => `["${fieldName}"]`, escapeFirst = (fieldName) => `@${escapeField(fieldName)}`, isEmptyArray = (value) => Array.isArray(value) && value.length === 0, joinPath = (pathArray) => { let path = ""; for (let i = 0; i < pathArray.length; i++) { const pathSegment = pathArray[i]; if (isEmptyArray(pathSegment)) { path += "[]"; continue; } if (typeof pathSegment == "number") { path += `[${pathSegment}]`; continue; } const isFirst = i === 0; fieldNeedsEscape(pathSegment) ? path = isFirst ? escapeFirst(pathSegment) : `${path}${escapeField(pathSegment)}` : path = isFirst ? pathSegment : `${path}.${pathSegment}`; } return path; }, supportsTouch = isTouchDevice$1(); function isTouchDevice$1() { return typeof window > "u" ? !1 : "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; } const FONT_SANS_SERIF = "-apple-system, BlinkMacSystemFont, \\'Segoe UI\\', Roboto, \\'Helvetica Neue\\', Helvetica, Arial, system-ui, sans-serif", FONT_MONOSPACE = "-apple-system-ui-monospace, \\'SF Mono\\', Menlo, Monaco, Consolas, monospace", uncaughtErrorHandler = () => ( // prettier-ignore ["window.onerror = function(m,u,l,c,e) {", "var p=window.location.port;", "var h=window.location.protocol+'//'+window.location.hostname+(p?':'+p:'');", "var r=document.getElementById('sanity');", "while(r.firstChild){r.removeChild(r.firstChild);}", "var s=document.createElement('style');", "s.appendChild(document.createTextNode('", "html,body,#sanityBody,#sanity,#sanityError{height:100%;}", "body{-webkit-font-smoothing:antialiased;margin:0;}", `#sanityError{position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;background-color:#fff;color:#121923;font-family:${FONT_SANS_SERIF};font-size:16px;line-height:21px;min-height:100%;}`, "#sanityError>div{background-color:#fff;max-width:960px;margin:0 auto;padding:47px 32px 52px;}", "@media(min-width:512px){", "#sanityError>div{", "padding:47px 84px;", "}", "}", "#sanityError button{-webkit-font-smoothing:inherit;font:inherit;font-weight:500;background-color:#2276FC;color:#fff;padding:7px 12px;border-radius:3px;border:0;}", "#sanityError button:hover{background-color:#1E63D0;}", "#sanityError button:active{background-color:#1B50A5;}", "'));", "document.head.appendChild(s);", "var f=document.createElement('div');", "f.id='sanityError';", "f.innerHTML='", "<div>", '<h1 style="font-size:21px;line-height:27px;margin: 0 0 10px;">Unhandled error</h1>', '<p style="color:#66758D;margin:10px 0 14px;">Encountered an unhandled error in this Studio.</p>', '<button class="sanity-error-handler__reload-btn" type="button">Reload page</button>', '<pre style="background-color:#FDEBEA;color:#C3362C;font-size:13px;line-height:17px;padding:8px 12px;border-radius:3px;margin:32px 0 0;overflow:auto;">', `<code style="font-family:${FONT_MONOSPACE};">`, "'+e.stack.replaceAll(h,'')+'", "</code>", "</pre>", "</div>", "';", "var b=f.querySelector('.sanity-error-handler__reload-btn');", "if(b){", "b.onclick=function() {", "window.location.reload();", "}", "};", "r.appendChild(f);", "};"].join("") ), segmenter = typeof Intl == "object" && "Segmenter" in Intl ? new Intl.Segmenter() : void 0; function sliceString(str, start, end) { if (end < start) throw new Error("End must be greater than start, use `String.prototype.slice()` for negative values"); if (!segmenter) return str.slice(start, end); let i = 0, sliced = ""; for (const value of segmenter.segment(str)) { if (i === end) return sliced; sliced += value.segment, i++; } return sliced; } function truncateString(str, maxLength) { const truncated = sliceString(str, 0, maxLength); return truncated === str ? truncated : `${truncated}\u2026`; } const LOADING_STATE$1 = { isLoading: !0, value: void 0, error: null }; function useLoadable(value$, initialValue) { const $ = reactCompilerRuntime.c(4); let t0; $[0] !== initialValue ? (t0 = typeof initialValue > "u" ? LOADING_STATE$1 : { isLoading: !1, value: initialValue, error: null }, $[0] = initialValue, $[1] = t0) : t0 = $[1]; const initial2 = t0; let t1, t2; return $[2] !== value$ ? (t2 = value$.pipe(asLoadable()), $[2] = value$, $[3] = t2) : t2 = $[3], t1 = t2, reactRx.useObservable(t1, initial2); } function asLoadable() { return (value$) => value$.pipe(operators.map((value) => ({ isLoading: !1, value, error: null })), operators.catchError((error) => rxjs.of({ isLoading: !1, value: void 0, error }))); } function userHasRole(user, roleId) { return user !== null && user.roles.some((role) => role.name === roleId); } function useThrottledCallback(callback, wait, options) { const $ = reactCompilerRuntime.c(4); let t0, t1; return $[0] !== callback || $[1] !== options || $[2] !== wait ? (t1 = throttle__default.default(callback, wait, options), $[0] = callback, $[1] = options, $[2] = wait, $[3] = t1) : t1 = $[3], t0 = t1, t0; } function useUnique(value) { const [previous, setPrevious] = React.useState(value); return isEqual__default.default(previous, value) ? previous : (setPrevious(value), value); } const DEBUG_MODE$2 = typeof process > "u" ? !1 : process?.env?.SANITY_STUDIO_DEBUG_I18N, DEBUG_I18N = !!DEBUG_MODE$2, debugWrappers = { reverse: (str) => `\u202E${str}`, triangles: (str) => `\u25E4 ${str} \u25E2` }; function maybeWrapT(t) { const wrapper = DEBUG_MODE$2 === "reverse" || DEBUG_MODE$2 === "triangles" ? debugWrappers[DEBUG_MODE$2] : null; return wrapper ? (...args) => wrapper(t(...args)) : t; } const translationOptionOverrides = { // We're manually forcing a re-render with the locale key in the LocaleProvider, // so we don't need to bind to the i18n instance for language change events. bindI18n: !1 }; function useTranslation(ns, options) { const $ = reactCompilerRuntime.c(6); let t0; $[0] !== options ? (t0 = options ? { keyPrefix: options.keyPrefix, lng: options.lng, ...translationOptionOverrides } : translationOptionOverrides, $[0] = options, $[1] = t0) : t0 = $[1]; const { t } = reactI18next.useTranslation(ns, t0); let t1; $[2] !== t ? (t1 = maybeWrapT(t), $[2] = t, $[3] = t1) : t1 = $[3]; let t2; return $[4] !== t1 ? (t2 = { t: t1 }, $[4] = t1, $[5] = t2) : t2 = $[5], t2; } const animationSpeed = 250, ChangeBarWrapper$1 = styledComponents.styled.div(({ $changed, $disabled, $hasFocus, $isReviewChangeOpen }) => $disabled ? styledComponents.css` ${ChangeBarMarker}:after { display: none; } ` : styledComponents.css` --change-bar-offset: 4px; display: flex; position: relative; ${ChangeBarMarker}:after { opacity: 0.5; } @media (hover: hover) { &:hover { z-index: 10; ${ChangeBarMarker}:after { opacity: 1; } } } /* hide when field is not changed */ ${$hasFocus && styledComponents.css` ${ChangeBarMarker}:after { opacity: 1; } `} /* hide when field is not changed */ ${!$changed && styledComponents.css` ${ChangeBarMarker}:after { opacity: 0; pointer-events: none; } `} /* hide hover effect when review changes is open */ ${$isReviewChangeOpen && styledComponents.css` ${ChangeBarButton} { opacity: 0; } `} `), FieldWrapper$1 = styledComponents.styled.div` flex-grow: 1; min-width: 0; `, ChangeBar = styledComponents.styled.div` position: relative; opacity: 1; transition: opacity 100ms; z-index: ${({ $zIndex }) => $zIndex}; `, ChangeBarMarker = styledComponents.styled.div((props2) => { const { media } = theme.getTheme_v2(props2.theme); return styledComponents.css` position: absolute; top: -1px; left: var(--change-bar-offset); width: 1px; bottom: -1px; background-color: var(--card-bg-color); @media (min-width: ${media[0]}px) { display: unset; } &:after { content: ''; display: block; position: absolute; top: 1px; left: 0; width: 1px; bottom: 1px; background-color: var(--card-badge-caution-dot-color); border-radius: 0.5px; } `; }), ChangeBarButton = styledComponents.styled.button((props2) => { const { $withHoverEffect, $isInteractive } = props2; return styledComponents.css` appearance: none; border: 0; outline: 0; display: block; padding: 0; background: transparent; opacity: 0; position: absolute; height: 100%; ${$isInteractive && styledComponents.css` cursor: pointer; pointer-events: all; `} left: calc(-0.25rem + var(--change-bar-offset)); width: calc(1rem - 1px); transition: opacity ${animationSpeed}ms; &:focus { border: 0; outline: 0; } &:focus { border: 0; outline: 0; } ${$withHoverEffect && styledComponents.css` @media (hover: hover) { &:hover { opacity: 0.2; } } `} `; }); function ElementWithChangeBar(props2) { const $ = reactCompilerRuntime.c(18), { children, disabled, hasFocus, isChanged, withHoverEffect: t0, isInteractive: t1 } = props2, withHoverEffect = t0 === void 0 ? !0 : t0, isInteractive = t1 === void 0 ? !0 : t1, { onOpenReviewChanges, isReviewChangesOpen } = React.useContext(_singletons.ConnectorContext), { zIndex } = ui.useLayer(), { t } = useTranslation(); let t2, t3; $[0] !== disabled || $[1] !== isChanged || $[2] !== isInteractive || $[3] !== isReviewChangesOpen || $[4] !== onOpenReviewChanges || $[5] !== t || $[6] !== withHoverEffect || $[7] !== zIndex ? (t3 = disabled || !isChanged ? null : /* @__PURE__ */ jsxRuntime.jsxs(ChangeBar, { "data-testid": "change-bar", $zIndex: zIndex, children: [ /* @__PURE__ */ jsxRuntime.jsx(ChangeBarMarker, { "data-testid": "change-bar__marker" }), /* @__PURE__ */ jsxRuntime.jsx(TooltipDelayGroupProvider.Tooltip, { content: t("changes.change-bar.aria-label"), portal: !0, disabled: !isInteractive, children: /* @__PURE__ */ jsxRuntime.jsx(ChangeBarButton, { "aria-label": t("changes.change-bar.aria-label"), "data-testid": "change-bar__button", onClick: isReviewChangesOpen ? void 0 : onOpenReviewChanges, tabIndex: -1, type: "button", $withHoverEffect: withHoverEffect, $isInteractive: isInteractive }) }) ] }), $[0] = disabled, $[1] = isChanged, $[2] = isInteractive, $[3] = isReviewChangesOpen, $[4] = onOpenReviewChanges, $[5] = t, $[6] = withHoverEffect, $[7] = zIndex, $[8] = t3) : t3 = $[8], t2 = t3; const changeBar = t2; let t4; $[9] !== children ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(FieldWrapper$1, { "data-testid": "change-bar__field-wrapper", children }), $[9] = children, $[10] = t4) : t4 = $[10]; let t5; return $[11] !== changeBar || $[12] !== disabled || $[13] !== hasFocus || $[14] !== isChanged || $[15] !== isReviewChangesOpen || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsxs(ChangeBarWrapper$1, { "data-testid": "change-bar-wrapper", $changed: isChanged, $disabled: disabled, $hasFocus: hasFocus, $isReviewChangeOpen: isReviewChangesOpen, children: [ t4, changeBar ] }), $[11] = changeBar, $[12] = disabled, $[13] = hasFocus, $[14] = isChanged, $[15] = isReviewChangesOpen, $[16] = t4, $[17] = t5) : t5 = $[17], t5; } const ChangeBarWrapper = React.memo(function(props2) { const $ = reactCompilerRuntime.c(34); let children, disabled, hasFocus, isChanged, isInteractive, onMouseEnterProp, onMouseLeaveProp, restProps, t0, withHoverEffect; $[0] !== props2 ? ({ children, disabled, hasFocus, isChanged, onMouseEnter: onMouseEnterProp, onMouseLeave: onMouseLeaveProp, path: t0, withHoverEffect, isInteractive, ...restProps } = props2, $[0] = props2, $[1] = children, $[2] = disabled, $[3] = hasFocus, $[4] = isChanged, $[5] = isInteractive, $[6] = onMouseEnterProp, $[7] = onMouseLeaveProp, $[8] = restProps, $[9] = t0, $[10] = withHoverEffect) : (children = $[1], disabled = $[2], hasFocus = $[3], isChanged = $[4], isInteractive = $[5], onMouseEnterProp = $[6], onMouseLeaveProp = $[7], restProps = $[8], t0 = $[9], withHoverEffect = $[10]); const path = t0 === void 0 ? EMPTY_ARRAY$B : t0, layer = ui.useLayer(), [hasHover, setHover] = React.useState(!1); let t1; $[11] !== onMouseEnterProp ? (t1 = (event) => { onMouseEnterProp?.(event), setHover(!0); }, $[11] = onMouseEnterProp, $[12] = t1) : t1 = $[12]; const onMouseEnter = t1; let t2; $[13] !== onMouseLeaveProp ? (t2 = (event_0) => { onMouseLeaveProp?.(event_0), setHover(!1); }, $[13] = onMouseLeaveProp, $[14] = t2) : t2 = $[14]; const onMouseLeave = t2, [element, setElement] = React.useState(null); let t3; t3 = disabled || !element ? null : `field-${PathUtils__namespace.toString(path)}`; const reporterId = t3; let t4; $[15] !== element || $[16] !== hasFocus || $[17] !== hasHover || $[18] !== isChanged || $[19] !== layer.zIndex || $[20] !== path ? (t4 = () => ({ element, path, isChanged, hasFocus, hasHover, zIndex: layer.zIndex }), $[15] = element, $[16] = hasFocus, $[17] = hasHover, $[18] = isChanged, $[19] = layer.zIndex, $[20] = path, $[21] = t4) : t4 = $[21], useChangeIndicatorsReporter(reporterId, t4, deepEquals__default.default); let t5; $[22] !== children || $[23] !== disabled || $[24] !== hasFocus || $[25] !== isChanged || $[26] !== isInteractive || $[27] !== withHoverEffect ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(ElementWithChangeBar, { hasFocus, isChanged, disabled, withHoverEffect, isInteractive, children }), $[22] = children, $[23] = disabled, $[24] = hasFocus, $[25] = isChanged, $[26] = isInteractive, $[27] = withHoverEffect, $[28] = t5) : t5 = $[28]; let t6; return $[29] !== onMouseEnter || $[30] !== onMouseLeave || $[31] !== restProps || $[32] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx("div", { ...restProps, ref: setElement, onMouseEnter, onMouseLeave, children: t5 }), $[29] = onMouseEnter, $[30] = onMouseLeave, $[31] = restProps, $[32] = t5, $[33] = t6) : t6 = $[33], t6; }); function ChangeIndicator(props2) { const $ = reactCompilerRuntime.c(15); let children, hasFocus, isChanged, path, restProps, withHoverEffect; $[0] !== props2 ? ({ children, hasFocus, isChanged, path, withHoverEffect, ...restProps } = props2, $[0] = props2, $[1] = children, $[2] = hasFocus, $[3] = isChanged, $[4] = path, $[5] = restProps, $[6] = withHoverEffect) : (children = $[1], hasFocus = $[2], isChanged = $[3], path = $[4], restProps = $[5], withHoverEffect = $[6]); const { isInteractive } = React.useContext(_singletons.ConnectorContext); let t0; return $[7] !== children || $[8] !== hasFocus || $[9] !== isChanged || $[10] !== isInteractive || $[11] !== path || $[12] !== restProps || $[13] !== withHoverEffect ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(ChangeBarWrapper, { ...restProps, path, hasFocus, isChanged, withHoverEffect, isInteractive, children }), $[7] = children, $[8] = hasFocus, $[9] = isChanged, $[10] = isInteractive, $[11] = path, $[12] = restProps, $[13] = withHoverEffect, $[14] = t0) : t0 = $[14], t0; } function useOnScroll(callback) { const $ = reactCompilerRuntime.c(4), parentContext = React.useContext(_singletons.ScrollContext); let t0, t1; $[0] !== callback || $[1] !== parentContext ? (t0 = () => parentContext?.subscribe(callback), t1 = [callback, parentContext], $[0] = callback, $[1] = parentContext, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), React.useEffect(t0, t1); } const ScrollContainerComponent = React.forwardRef(function(props2, forwardedRef) { const $ = reactCompilerRuntime.c(22); let onScroll, rest, t0; $[0] !== props2 ? ({ as: t0, onScroll, ...rest } = props2, $[0] = props2, $[1] = onScroll, $[2] = rest, $[3] = t0) : (onScroll = $[1], rest = $[2], t0 = $[3]); const As = t0 === void 0 ? "div" : t0, ref = React.useRef(null); let t1; $[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => ref.current, $[4] = t1) : t1 = $[4], React.useImperativeHandle(forwardedRef, t1); const parentContext = React.useContext(_singletons.ScrollContext), [childContext] = React.useState(_temp$2y); let t2, t3; $[5] !== childContext || $[6] !== onScroll ? (t2 = () => { if (onScroll) return childContext.subscribe(onScroll); }, t3 = [childContext, onScroll], $[5] = childContext, $[6] = onScroll, $[7] = t2, $[8] = t3) : (t2 = $[7], t3 = $[8]), React.useEffect(t2, t3); let t4, t5; $[9] !== childContext || $[10] !== parentContext ? (t4 = () => { if (parentContext) return childContext.subscribe(parentContext.publish); }, t5 = [parentContext, childContext], $[9] = childContext, $[10] = parentContext, $[11] = t4, $[12] = t5) : (t4 = $[11], t5 = $[12]), React.useEffect(t4, t5); let t6, t7; $[13] !== childContext ? (t6 = () => { const handleScroll = (event) => { childContext.publish(event); }, el = ref.current; if (el) return el.addEventListener("scroll", handleScroll, { passive: !0, capture: !0 }), () => { el.removeEventListener("scroll", handleScroll); }; }, t7 = [childContext, ref], $[13] = childContext, $[14] = t6, $[15] = t7) : (t6 = $[14], t7 = $[15]), React.useEffect(t6, t7); let t8; $[16] !== As || $[17] !== rest ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(As, { "data-testid": "scroll-container", ...rest, ref }), $[16] = As, $[17] = rest, $[18] = t8) : t8 = $[18]; let t9; return $[19] !== childContext || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(_singletons.ScrollContext.Provider, { value: childContext, children: t8 }), $[19] = childContext, $[20] = t8, $[21] = t9) : t9 = $[21], t9; }), ScrollContainer = React.memo(ScrollContainerComponent); ScrollContainer.displayName = "Memo(Forwardref(ScrollContainer))"; function _temp$2y() { return createPubSub__default.default(); } const CORNER_RADIUS = 4, INTERACTIVE_STROKE_WIDTH = 16, CONNECTOR_MARGIN = 8, ARROW_MARGIN_X = 8, ARROW_MARGIN_Y = 2, ARROW_SIZE = 4, ARROW_THRESHOLD = 12, STROKE_WIDTH$2 = 1, DEBUG$1 = !1, DEBUG_LAYER_BOUNDS = !1; function findMostSpecificTarget(targetType, id2, values2) { const pathString = id2.slice(id2.indexOf("-") + 1) || "[]", path = PathUtils__namespace.fromString(pathString), exactId = `${targetType}-${PathUtils__namespace.toString(path)}`; if (values2.has(exactId)) return values2.get(exactId); let mostSpecific; for (const [targetId, target] of values2) { if (!("path" in target) || !targetId.startsWith(targetType)) continue; const numEqual = PathUtils__namespace.numEqualSegments(path, target.path), lastPathSegment = target.path[target.path.length - 1], pathOnlyDiffersByKey = numEqual === target.path.length - 1 && types.isKeyedObject(lastPathSegment); if (numEqual !== 0 && !(numEqual !== target.path.length && !pathOnlyDiffersByKey) && (mostSpecific = target, numEqual === path.length)) break; } return mostSpecific; } function hasOverflowScroll(el) { const overflow = getComputedStyle(el).overflow; return overflow.includes("auto") || overflow.includes("scroll"); } function isScrollable(el) { return (el.scrollHeight !== el.offsetHeight || el.scrollWidth !== el.offsetWidth) && hasOverflowScroll(el); } const getOffsetsTo$1 = (source, target) => { const bounds = { top: 0, left: 0, height: target.offsetHeight, width: target.offsetWidth }, rect = { top: 0, left: 0, height: source.offsetHeight, width: source.offsetWidth }; let foundScrollContainer = !1, el = source; for (; el && el !== target && target.contains(el); ) foundScrollContainer && (bounds.top += el.offsetTop, bounds.left += el.offsetLeft), hasOverflowScroll(el) && (bounds.top = el.offsetTop, bounds.height = el.offsetHeight, bounds.left = el.offsetLeft, bounds.width = el.offsetWidth, foundScrollContainer = !0), rect.top += el.offsetTop - el.scrollTop, rect.left += el.offsetLeft - el.scrollLeft, el = el.offsetParent; return { rect, bounds }; }; function isChangeBar(v) { return v[0] !== "changePanel"; } const SCROLL_INTO_VIEW_TOP_PADDING = -15; function scrollIntoView(field) { const element = field.element; if (!element) return; let parentElementWithScroll = element; for (; !isScrollable(parentElementWithScroll); ) if (parentElementWithScroll = parentElementWithScroll.parentElement, !parentElementWithScroll) return; parentElementWithScroll.scroll({ top: parentElementWithScroll.scrollTop + field.rect.top - field.bounds.top + SCROLL_INTO_VIEW_TOP_PADDING, left: 0, behavior: "smooth" }); } function ClampedRect(props2) { const $ = reactCompilerRuntime.c(9); let bounds, rest; $[0] !== props2 ? ({ bounds, ...rest } = props2, $[0] = props2, $[1] = bounds, $[2] = rest) : (bounds = $[1], rest = $[2]); const x = Math.max(bounds.left, props2.left), y = Math.max(props2.top, bounds.top), height = Math.max(0, props2.height - (y - props2.top)), width = Math.max(0, props2.width - (x - props2.left)); let t0; return $[3] !== height || $[4] !== rest || $[5] !== width || $[6] !== x || $[7] !== y ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("rect", { ...rest, x, y, height, width }), $[3] = height, $[4] = rest, $[5] = width, $[6] = x, $[7] = y, $[8] = t0) : t0 = $[8], t0; } styledComponents.styled.rect` stroke: #ccc; fill: none; pointer-events: none; stroke-linecap: round; `; const ConnectorPath = styledComponents.styled.path` fill: none; pointer-events: none; stroke-linejoin: round; stroke: var(--card-badge-caution-dot-color); `, InteractivePath = styledComponents.styled.path` fill: none; pointer-events: stroke; stroke: transparent; cursor: pointer; stroke-linecap: round; stroke-linejoin: round; opacity: 0; &:hover { opacity: 0.2; } `, RightBarWrapper = styledComponents.styled(ClampedRect)` stroke: none; pointer-events: none; fill: var(--card-badge-caution-dot-color); `; function arrowPath(x, y, dir) { return [`M ${x - ARROW_SIZE} ${y - ARROW_SIZE * dir} `, `L ${x} ${y}`, `L ${x + ARROW_SIZE} ${y - ARROW_SIZE * dir}`].join(""); } function moveTo(x, y) { return `M${x} ${y}`; } function lineTo(x, y) { return `L${x} ${y}`; } function join(strings2, delim = "") { return strings2.join(delim); } function quadCurve(x1, y1, x, y) { return `Q${x1} ${y1} ${x} ${y}`; } function generateConnectorPath(line) { const { from, to } = line, { left: fromX, top: fromY } = from, { left: toX, top: toY } = to, cmds = [], r1 = Math.min(CORNER_RADIUS, Math.abs(fromY - toY) / 2); return from.isAbove ? cmds.push(moveTo(fromX + ARROW_MARGIN_X, fromY - ARROW_THRESHOLD + ARROW_MARGIN_Y), lineTo(fromX + ARROW_MARGIN_X, fromY - CORNER_RADIUS), quadCurve(fromX + ARROW_MARGIN_X, fromY, fromX + ARROW_MARGIN_X + CORNER_RADIUS, fromY)) : from.isBelow ? cmds.push(moveTo(fromX + ARROW_MARGIN_X, fromY + ARROW_THRESHOLD - ARROW_MARGIN_Y), lineTo(fromX + ARROW_MARGIN_X, fromY + CORNER_RADIUS), quadCurve(fromX + ARROW_MARGIN_X, fromY, fromX + ARROW_MARGIN_X + CORNER_RADIUS, fromY)) : cmds.push(moveTo(fromX, fromY)), to.isAbove ? fromY < to.bounds.top ? cmds.push(lineTo(to.bounds.left - 8 - r1, fromY), quadCurve(to.bounds.left - 8, fromY, to.bounds.left - 8, fromY + r1), lineTo(to.bounds.left - 8, toY - r1), quadCurve(to.bounds.left - 8, toY, to.bounds.left - 8 + r1, toY), lineTo(to.bounds.left + ARROW_MARGIN_X - CORNER_RADIUS, toY), quadCurve(to.bounds.left + ARROW_MARGIN_X, toY, to.bounds.left + ARROW_MARGIN_X, toY - CORNER_RADIUS), lineTo(to.bounds.left + ARROW_MARGIN_X, toY - ARROW_THRESHOLD + ARROW_MARGIN_Y)) : cmds.push(lineTo(to.bounds.left + ARROW_MARGIN_X - CORNER_RADIUS, fromY), quadCurve(to.bounds.left + ARROW_MARGIN_X, fromY, to.bounds.left + ARROW_MARGIN_X, fromY - CORNER_RADIUS), lineTo(to.bounds.left + ARROW_MARGIN_X, toY - ARROW_THRESHOLD + ARROW_MARGIN_Y)) : to.isBelow ? fromY > to.bounds.top + to.bounds.height ? cmds.push(lineTo(to.bounds.left - ARROW_MARGIN_X - r1, fromY), quadCurve(to.bounds.left - ARROW_MARGIN_X, fromY, to.bounds.left - ARROW_MARGIN_X, fromY - r1), lineTo(to.bounds.left - ARROW_MARGIN_X, toY + r1), quadCurve(to.bounds.left - ARROW_MARGIN_X, toY, to.bounds.left - ARROW_MARGIN_X + r1, toY), lineTo(to.bounds.left + ARROW_MARGIN_X - CORNER_RADIUS, toY), quadCurve(to.bounds.left + ARROW_MARGIN_X, toY, to.bounds.left + ARROW_MARGIN_X, toY + CORNER_RADIUS), lineTo(to.bounds.left + ARROW_MARGIN_X, toY + ARROW_THRESHOLD - ARROW_MARGIN_Y)) : cmds.push(lineTo(to.bo