Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/presentation

Package Overview
Dependencies
Maintainers
65
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/presentation - npm Package Compare versions

Comparing version 1.19.12 to 1.19.13

4

dist/_chunks-es/BroadcastDisplayedDocument.js

@@ -9,6 +9,6 @@ import { c } from "react-compiler-runtime";

$[0] !== props.value || $[1] !== setDisplayedDocument ? (t0 = () => {
const timeout = setTimeout(() => setDisplayedDocument?.(props.value), 10);
const timeout = setTimeout(() => setDisplayedDocument == null ? void 0 : setDisplayedDocument(props.value), 10);
return () => clearTimeout(timeout);
}, $[0] = props.value, $[1] = setDisplayedDocument, $[2] = t0) : t0 = $[2];
const t1 = params?.perspective;
const t1 = params == null ? void 0 : params.perspective;
let t2;

@@ -15,0 +15,0 @@ return $[3] !== props.value || $[4] !== setDisplayedDocument || $[5] !== t1 ? (t2 = [t1, props.value, setDisplayedDocument], $[3] = props.value, $[4] = setDisplayedDocument, $[5] = t1, $[6] = t2) : t2 = $[6], useEffect(t0, t2), null;

@@ -1,7 +0,20 @@

import { jsx, jsxs, Fragment } from "react/jsx-runtime";
var __defProp = Object.defineProperty, __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b))
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
return a;
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
import { c } from "react-compiler-runtime";
import { useState, useEffect, createContext, useContext, useCallback, createElement, useLayoutEffect, useMemo, lazy, Suspense } from "react";
import { useState, useEffect, createContext, useContext, createElement, useLayoutEffect, lazy, Suspense } from "react";
import { useDocumentStore, isRecord, isReference, defineLocaleResourceBundle, useTranslation, defineDocumentFieldAction, useWorkspace, pathToString, getPublishedId, definePlugin, isDocumentSchemaType } from "sanity";
import { ComposeIcon, InfoOutlineIcon, ChevronRightIcon, WarningOutlineIcon, ErrorOutlineIcon, DesktopIcon, MasterDetailIcon } from "@sanity/icons";
import { Card, Flex, Box, Text, Spinner, Stack, rem } from "@sanity/ui";
import { Flex, Box, Text, Card, Spinner, Stack, rem } from "@sanity/ui";
import { styled } from "styled-components";

@@ -14,2 +27,10 @@ import get from "lodash/get.js";

const DEFAULT_TOOL_ICON = ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", COMMENTS_INSPECTOR_NAME = "sanity/structure/comments", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = "2023-10-16", MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LIVE_QUERY_CACHE_BATCH_SIZE = 100, LIVE_QUERY_CACHE_SIZE = 2048, POPUP_CHECK_INTERVAL = 1e3;
var __defProp$4 = Object.defineProperty, __defProps$4 = Object.defineProperties, __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$4 = Object.getOwnPropertySymbols, __hasOwnProp$4 = Object.prototype.hasOwnProperty, __propIsEnum$4 = Object.prototype.propertyIsEnumerable, __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$4 = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp$4.call(b, prop) && __defNormalProp$4(a, prop, b[prop]);
if (__getOwnPropSymbols$4)
for (var prop of __getOwnPropSymbols$4(b))
__propIsEnum$4.call(b, prop) && __defNormalProp$4(a, prop, b[prop]);
return a;
}, __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
function keysOf(value) {

@@ -19,6 +40,5 @@ return Object.keys(value);

function setKey(source, key, value) {
return {
...source,
return __spreadProps$4(__spreadValues$4({}, source), {
[key]: value
};
});
}

@@ -34,2 +54,10 @@ function props(options = {}) {

}
var __defProp$3 = Object.defineProperty, __defProps$3 = Object.defineProperties, __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$3 = Object.getOwnPropertySymbols, __hasOwnProp$3 = Object.prototype.hasOwnProperty, __propIsEnum$3 = Object.prototype.propertyIsEnumerable, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$3 = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);
if (__getOwnPropSymbols$3)
for (var prop of __getOwnPropSymbols$3(b))
__propIsEnum$3.call(b, prop) && __defNormalProp$3(a, prop, b[prop]);
return a;
}, __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
const INITIAL_STATE = {

@@ -42,8 +70,5 @@ locations: []

function cleanPreviewable(id, previewable) {
const clean = id ? {
...previewable,
const clean = id ? __spreadProps$3(__spreadValues$3({}, previewable), {
_id: id
} : {
...previewable
};
}) : __spreadValues$3({}, previewable);
return clean._type === "reference" && (delete clean._type, delete clean._ref, delete clean._weak, delete clean._dataset, delete clean._projectId, delete clean._strengthenOnPublish), clean;

@@ -127,6 +152,6 @@ }

$[11] !== result ? (t1 = () => {
const sub = result?.subscribe((state) => {
const sub = result == null ? void 0 : result.subscribe((state) => {
setLocationsState(state || INITIAL_STATE), setLocationsStatus(state ? "resolved" : "empty");
});
return () => sub?.unsubscribe();
return () => sub == null ? void 0 : sub.unsubscribe();
}, t2 = [result], $[11] = result, $[12] = t1, $[13] = t2) : (t1 = $[12], t2 = $[13]), useEffect(t1, t2);

@@ -151,4 +176,13 @@ let t3;

function useCurrentPresentationToolName() {
return usePresentationTool(!1)?.name ?? void 0;
var _a, _b;
return (_b = (_a = usePresentationTool(!1)) == null ? void 0 : _a.name) != null ? _b : void 0;
}
var __defProp$2 = Object.defineProperty, __defProps$2 = Object.defineProperties, __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$2 = Object.getOwnPropertySymbols, __hasOwnProp$2 = Object.prototype.hasOwnProperty, __propIsEnum$2 = Object.prototype.propertyIsEnumerable, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$2 = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);
if (__getOwnPropSymbols$2)
for (var prop of __getOwnPropSymbols$2(b))
__propIsEnum$2.call(b, prop) && __defNormalProp$2(a, prop, b[prop]);
return a;
}, __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
const TONE_ICONS = {

@@ -160,3 +194,3 @@ positive: InfoOutlineIcon,

function LocationsBanner(props2) {
const {
const $ = c(33), {
documentId,

@@ -171,14 +205,37 @@ isResolving,

tone
} = props2.state, len = locations?.length || 0, {
} = props2.state, len = (locations == null ? void 0 : locations.length) || 0, {
t
} = useTranslation(presentationLocaleNamespace), presentation = useContext(PresentationContext), [expanded, setExpanded] = useState(!1), toggle = useCallback(() => {
len && setExpanded((v) => !v);
}, [len]), title = isResolving ? t("locations-banner.resolving.text") : message || t("locations-banner.locations-count", {
} = useTranslation(presentationLocaleNamespace), presentation = useContext(PresentationContext), presentationName = presentation == null ? void 0 : presentation.name, [expanded, setExpanded] = useState(!1);
let t0;
$[0] !== len ? (t0 = () => {
len && setExpanded(_temp$1);
}, $[0] = len, $[1] = t0) : t0 = $[1];
const toggle = t0;
let t1;
$[2] !== isResolving || $[3] !== len || $[4] !== message || $[5] !== t ? (t1 = isResolving ? t("locations-banner.resolving.text") : message || t("locations-banner.locations-count", {
count: len
});
return /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, border: !0, tone, children: /* @__PURE__ */ jsxs("div", { style: {
}), $[2] = isResolving, $[3] = len, $[4] = message, $[5] = t, $[6] = t1) : t1 = $[6];
const title = t1;
let t2;
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
margin: -1
}, children: [
!locations && /* @__PURE__ */ jsxs(Flex, { align: "flex-start", gap: 3, padding: 3, children: [
tone && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: createElement(TONE_ICONS[tone]) }) }),
}, $[7] = t2) : t2 = $[7];
let t3;
$[8] !== locations || $[9] !== options || $[10] !== showPresentationTitle || $[11] !== title || $[12] !== tone ? (t3 = !locations && /* @__PURE__ */ jsxs(Flex, { align: "flex-start", gap: 3, padding: 3, children: [
tone && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: createElement(TONE_ICONS[tone]) }) }),
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
showPresentationTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
options.title || DEFAULT_TOOL_TITLE,
" \xB7 "
] }),
title
] }) })
] }), $[8] = locations, $[9] = options, $[10] = showPresentationTitle, $[11] = title, $[12] = tone, $[13] = t3) : t3 = $[13];
let t4;
$[14] !== documentId || $[15] !== expanded || $[16] !== isResolving || $[17] !== len || $[18] !== locations || $[19] !== options || $[20] !== (presentation == null ? void 0 : presentation.params) || $[21] !== presentationName || $[22] !== schemaType || $[23] !== showPresentationTitle || $[24] !== title || $[25] !== toggle ? (t4 = locations && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Card, { as: len ? "button" : void 0, onClick: toggle, padding: 3, radius: 1, tone: "inherit", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
/* @__PURE__ */ jsx(Box, { flex: "none", children: isResolving ? /* @__PURE__ */ jsx(Spinner, { size: 1 }) : /* @__PURE__ */ jsx(Text, { size: 1, children: len === 0 ? /* @__PURE__ */ jsx(InfoOutlineIcon, {}) : /* @__PURE__ */ jsx(ChevronRightIcon, { style: {
transform: `rotate(${expanded ? "90deg" : 0})`,
transition: "transform 100ms ease-in-out"
} }) }) }),
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [

@@ -191,21 +248,16 @@ showPresentationTitle && /* @__PURE__ */ jsxs(Fragment, { children: [

] }) })
] }),
locations && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Card, { as: len ? "button" : void 0, onClick: toggle, padding: 3, radius: 1, tone: "inherit", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
/* @__PURE__ */ jsx(Box, { flex: "none", children: isResolving ? /* @__PURE__ */ jsx(Spinner, { size: 1 }) : /* @__PURE__ */ jsx(Text, { size: 1, children: len === 0 ? /* @__PURE__ */ jsx(InfoOutlineIcon, {}) : /* @__PURE__ */ jsx(ChevronRightIcon, { style: {
transform: `rotate(${expanded ? "90deg" : 0})`,
transition: "transform 100ms ease-in-out"
} }) }) }),
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
showPresentationTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
options.title || DEFAULT_TOOL_TITLE,
" \xB7 "
] }),
title
] }) })
] }) }),
/* @__PURE__ */ jsx(Stack, { hidden: !expanded, marginTop: 1, space: 1, children: locations.map((l, index) => /* @__PURE__ */ jsx(LocationItem, { active: (options.name || DEFAULT_TOOL_NAME) === presentation?.name && l.href === presentation?.params.preview, documentId, documentType: schemaType.name, node: l, toolName: options.name || DEFAULT_TOOL_NAME }, index)) })
] })
] }) });
] }) }),
/* @__PURE__ */ jsx(Stack, { hidden: !expanded, marginTop: 1, space: 1, children: locations.map((l, index) => /* @__PURE__ */ jsx(LocationItem, { active: (options.name || DEFAULT_TOOL_NAME) === presentationName && l.href === (presentation == null ? void 0 : presentation.params.preview), documentId, documentType: schemaType.name, node: l, toolName: options.name || DEFAULT_TOOL_NAME }, index)) })
] }), $[14] = documentId, $[15] = expanded, $[16] = isResolving, $[17] = len, $[18] = locations, $[19] = options, $[20] = presentation == null ? void 0 : presentation.params, $[21] = presentationName, $[22] = schemaType, $[23] = showPresentationTitle, $[24] = title, $[25] = toggle, $[26] = t4) : t4 = $[26];
let t5;
$[27] !== t3 || $[28] !== t4 ? (t5 = /* @__PURE__ */ jsxs("div", { style: t2, children: [
t3,
t4
] }), $[27] = t3, $[28] = t4, $[29] = t5) : t5 = $[29];
let t6;
return $[30] !== t5 || $[31] !== tone ? (t6 = /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, border: !0, tone, children: t5 }), $[30] = t5, $[31] = tone, $[32] = t6) : t6 = $[32], t6;
}
function _temp$1(v) {
return !v;
}
function LocationItem(props2) {

@@ -218,14 +270,14 @@ const $ = c(26), {

toolName
} = props2, presentation = useContext(PresentationContext), currentPresentationToolName = useCurrentPresentationToolName(), isCurrentTool = toolName === currentPresentationToolName, navigate = presentation?.navigate, t0 = presentation?.structureParams;
} = props2, presentation = useContext(PresentationContext), currentPresentationToolName = useCurrentPresentationToolName(), isCurrentTool = toolName === currentPresentationToolName, navigate = presentation == null ? void 0 : presentation.navigate, t0 = presentation == null ? void 0 : presentation.structureParams;
let t1;
$[0] !== documentId || $[1] !== documentType || $[2] !== node.href || $[3] !== t0 || $[4] !== toolName ? (t1 = {
intent: "edit",
params: {
params: __spreadProps$2(__spreadValues$2({
id: documentId,
type: documentType,
mode: "presentation",
presentation: toolName,
...t0,
presentation: toolName
}, t0), {
preview: node.href
}
})
}, $[0] = documentId, $[1] = documentType, $[2] = node.href, $[3] = t0, $[4] = toolName, $[5] = t1) : t1 = $[5];

@@ -235,3 +287,3 @@ const presentationLinkProps = useIntentLink(t1);

$[6] !== navigate || $[7] !== node.href ? (t2 = () => {
navigate?.({}, {
navigate == null || navigate({}, {
preview: node.href

@@ -259,3 +311,3 @@ });

let t9;
return $[20] !== active || $[21] !== node.href || $[22] !== t3 || $[23] !== t4 || $[24] !== t8 ? (t9 = /* @__PURE__ */ createElement(Card, { ...t3, as: "a", key: node.href, onClick: t4, padding: 3, radius: 1, pressed: active, tone: "inherit" }, t8), $[20] = active, $[21] = node.href, $[22] = t3, $[23] = t4, $[24] = t8, $[25] = t9) : t9 = $[25], t9;
return $[20] !== active || $[21] !== node.href || $[22] !== t3 || $[23] !== t4 || $[24] !== t8 ? (t9 = /* @__PURE__ */ createElement(Card, __spreadProps$2(__spreadValues$2({}, t3), { as: "a", key: node.href, onClick: t4, padding: 3, radius: 1, pressed: active, tone: "inherit" }), t8), $[20] = active, $[21] = node.href, $[22] = t3, $[23] = t4, $[24] = t8, $[25] = t9) : t9 = $[25], t9;
}

@@ -270,2 +322,3 @@ const PresentationDocumentContext = createContext(null), LocationStack = styled(Stack)`

function PresentationDocumentHeader(props2) {
var _a;
const $ = c(20), {

@@ -275,3 +328,3 @@ documentId,

schemaType
} = props2, context = useContext(PresentationDocumentContext), t0 = options.resolve?.locations || options.locate;
} = props2, context = useContext(PresentationDocumentContext), t0 = ((_a = options.resolve) == null ? void 0 : _a.locations) || options.locate;
let t1;

@@ -290,3 +343,3 @@ $[0] !== documentId || $[1] !== schemaType.name || $[2] !== t0 ? (t1 = {

let t2;
$[4] !== context?.options ? (t2 = context?.options || [], $[4] = context?.options, $[5] = t2) : t2 = $[5];
$[4] !== (context == null ? void 0 : context.options) ? (t2 = (context == null ? void 0 : context.options) || [], $[4] = context == null ? void 0 : context.options, $[5] = t2) : t2 = $[5];
const contextOptions = t2;

@@ -306,3 +359,3 @@ let t3;

options
} = props2, parent = useContext(PresentationDocumentContext), parentRegister = parent?.register, [optionsArray, setOptionsArray] = useState(_temp);
} = props2, parent = useContext(PresentationDocumentContext), parentRegister = parent == null ? void 0 : parent.register, [optionsArray, setOptionsArray] = useState(_temp);
let t0;

@@ -314,3 +367,3 @@ $[0] !== parentRegister ? (t0 = (options_0) => parentRegister ? parentRegister(options_0) : (setOptionsArray((prev) => [options_0].concat(prev)), () => {

let t1;
const t2 = parent?.options || optionsArray;
const t2 = (parent == null ? void 0 : parent.options) || optionsArray;
let t3;

@@ -333,32 +386,42 @@ $[2] !== register || $[3] !== t2 ? (t3 = {

}
const openInStructure = defineDocumentFieldAction({
name: "presentation/openInStructure",
useAction({
function useOpenInStructureAction(props2) {
const $ = c(14), {
documentId,
documentType,
path
}) {
const workspace = useWorkspace(), {
navigateIntent
} = useRouter(), presentation = useContext(PresentationContext), defaultStructureTool = useMemo(() => findStructureTool(workspace.tools, documentId, documentType), [documentId, documentType, workspace.tools]);
return {
type: "action",
hidden: !presentation || path.length > 0 || !defaultStructureTool,
icon: defaultStructureTool?.icon || MasterDetailIcon,
title: `Open in ${defaultStructureTool?.title || "Structure"}`,
onAction() {
navigateIntent("edit", {
id: documentId,
type: documentType,
mode: "structure",
path: pathToString(path)
});
},
renderAsButton: !0
};
}
} = props2, workspace = useWorkspace(), {
navigateIntent
} = useRouter(), presentation = useContext(PresentationContext);
let t0, t1;
$[0] !== documentId || $[1] !== documentType || $[2] !== workspace.tools ? (t1 = findStructureTool(workspace.tools, documentId, documentType), $[0] = documentId, $[1] = documentType, $[2] = workspace.tools, $[3] = t1) : t1 = $[3], t0 = t1;
const defaultStructureTool = t0;
let t2;
$[4] !== documentId || $[5] !== documentType || $[6] !== navigateIntent || $[7] !== path ? (t2 = () => {
navigateIntent("edit", {
id: documentId,
type: documentType,
mode: "structure",
path: pathToString(path)
});
}, $[4] = documentId, $[5] = documentType, $[6] = navigateIntent, $[7] = path, $[8] = t2) : t2 = $[8];
const handleAction = t2, t3 = !presentation || path.length > 0 || !defaultStructureTool, t4 = (defaultStructureTool == null ? void 0 : defaultStructureTool.icon) || MasterDetailIcon, t5 = `Open in ${(defaultStructureTool == null ? void 0 : defaultStructureTool.title) || "Structure"}`;
let t6;
return $[9] !== handleAction || $[10] !== t3 || $[11] !== t4 || $[12] !== t5 ? (t6 = {
type: "action",
hidden: t3,
icon: t4,
title: t5,
onAction: handleAction,
renderAsButton: !0
}, $[9] = handleAction, $[10] = t3, $[11] = t4, $[12] = t5, $[13] = t6) : t6 = $[13], t6;
}
const openInStructure = defineDocumentFieldAction({
name: "presentation/openInStructure",
useAction: useOpenInStructureAction
});
function findStructureTool(tools, documentId, documentType) {
var _a;
const results = tools.map((t) => {
const match = t.canHandleIntent?.("edit", {
var _a2;
const match = (_a2 = t.canHandleIntent) == null ? void 0 : _a2.call(t, "edit", {
id: documentId,

@@ -373,7 +436,23 @@ type: documentType,

}), modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode);
return modeMatches.length > 0 ? modeMatches[0].tool : results.filter((t) => t.match)[0]?.tool;
return modeMatches.length > 0 ? modeMatches[0].tool : (_a = results.filter((t) => t.match)[0]) == null ? void 0 : _a.tool;
}
var __defProp$1 = Object.defineProperty, __defProps$1 = Object.defineProperties, __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$1 = Object.getOwnPropertySymbols, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __propIsEnum$1 = Object.prototype.propertyIsEnumerable, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues$1 = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);
if (__getOwnPropSymbols$1)
for (var prop of __getOwnPropSymbols$1(b))
__propIsEnum$1.call(b, prop) && __defNormalProp$1(a, prop, b[prop]);
return a;
}, __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)), __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
if (source != null && __getOwnPropSymbols$1)
for (var prop of __getOwnPropSymbols$1(source))
exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop) && (target[prop] = source[prop]);
return target;
};
const preservedSearchParamKeys = ["preview", "perspective", "viewport"];
function getIntentState(intent, params, routerState, payload) {
const {
const _a = params, {
id,

@@ -383,11 +462,12 @@ mode,

presentation,
type,
...searchParams
} = params, _searchParams = {
...(routerState?._searchParams || []).filter(([key]) => preservedSearchParamKeys.includes(key)).reduce((acc, [key, value]) => ({
...acc,
[key]: value
}), {}),
...searchParams
};
type
} = _a, searchParams = __objRest(_a, [
"id",
"mode",
"path",
"presentation",
"type"
]), preservedSearchParams = ((routerState == null ? void 0 : routerState._searchParams) || []).filter(([key]) => preservedSearchParamKeys.includes(key)).reduce((acc, [key, value]) => __spreadProps$1(__spreadValues$1({}, acc), {
[key]: value
}), {}), _searchParams = __spreadValues$1(__spreadValues$1({}, preservedSearchParams), searchParams);
return intent === "edit" && id ? (_searchParams.preview = _searchParams.preview || new URLSearchParams(window.location.search).get("preview") || "/", {

@@ -427,9 +507,10 @@ type: type || "*",

const presentationTool = definePlugin((options) => {
var _a;
const toolName = options.name || DEFAULT_TOOL_NAME;
"locate" in options && console.warn("Presentation\u2019s `locate` option is deprecated. Use `resolve.locations` instead.");
const hasLocationsResolver = !!(options.resolve?.locations || options.locate);
const hasLocationsResolver = !!((_a = options.resolve) != null && _a.locations || options.locate);
function PresentationDocumentInput(props2) {
const $ = c(19), value = props2.value;
let t0;
$[0] !== value?._id ? (t0 = value?._id ? getPublishedId(value?._id) : void 0, $[0] = value?._id, $[1] = t0) : t0 = $[1];
$[0] !== (value == null ? void 0 : value._id) ? (t0 = value != null && value._id ? getPublishedId(value == null ? void 0 : value._id) : void 0, $[0] = value == null ? void 0 : value._id, $[1] = t0) : t0 = $[1];
const documentId = t0;

@@ -524,8 +605,9 @@ if (isDocumentSchemaType(props2.schemaType)) {

function getGlobalConfig(config2) {
var _a, _b, _c;
return {
lang: config2?.lang ?? store?.lang,
message: config2?.message,
abortEarly: config2?.abortEarly ?? store?.abortEarly,
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly,
skipPipe: config2?.skipPipe
lang: (_a = config2 == null ? void 0 : config2.lang) != null ? _a : store == null ? void 0 : store.lang,
message: config2 == null ? void 0 : config2.message,
abortEarly: (_b = config2 == null ? void 0 : config2.abortEarly) != null ? _b : store == null ? void 0 : store.abortEarly,
abortPipeEarly: (_c = config2 == null ? void 0 : config2.abortPipeEarly) != null ? _c : store == null ? void 0 : store.abortPipeEarly,
skipPipe: config2 == null ? void 0 : config2.skipPipe
};

@@ -535,18 +617,21 @@ }

function getGlobalMessage(lang) {
return store2?.get(lang);
return store2 == null ? void 0 : store2.get(lang);
}
var store3;
function getSchemaMessage(lang) {
return store3?.get(lang);
return store3 == null ? void 0 : store3.get(lang);
}
var store4;
function getSpecificMessage(reference, lang) {
return store4?.get(reference)?.get(lang);
var _a;
return (_a = store4 == null ? void 0 : store4.get(reference)) == null ? void 0 : _a.get(lang);
}
function _stringify(input) {
var _a, _b, _c;
let type = typeof input;
return type === "object" && (type = (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null"), type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type;
return type === "object" && (type = (_c = input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) != null ? _c : "null"), type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type;
}
function _addIssue(context, label, dataset, config2, other) {
const input = other && "input" in other ? other.input : dataset.value, expected = other?.expected ?? context.expects, received = other?.received ?? _stringify(input), issue = {
var _a, _b, _c, _d, _e, _f;
const input = other && "input" in other ? other.input : dataset.value, expected = (_a = other == null ? void 0 : other.expected) != null ? _a : context.expects, received = (_b = other == null ? void 0 : other.received) != null ? _b : _stringify(input), issue = {
kind: context.kind,

@@ -560,4 +645,4 @@ type: context.type,

requirement: context.requirement,
path: other?.path,
issues: other?.issues,
path: other == null ? void 0 : other.path,
issues: other == null ? void 0 : other.issues,
lang: config2.lang,

@@ -569,3 +654,3 @@ abortEarly: config2.abortEarly,

// @ts-expect-error
context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang)
(_f = (_e = (_d = (_c = context.message) != null ? _c : getSpecificMessage(context.reference, issue.lang)) != null ? _d : isSchema ? getSchemaMessage(issue.lang) : null) != null ? _e : config2.message) != null ? _f : getGlobalMessage(issue.lang)
);

@@ -579,6 +664,2 @@ message && (issue.message = typeof message == "function" ? message(issue) : message), isSchema && (dataset.typed = !1), dataset.issues ? dataset.issues.push(issue) : dataset.issues = [issue];

/**
* The error issues.
*/
issues;
/**
* Creates a Valibot error with useful information.

@@ -589,3 +670,8 @@ *

constructor(issues) {
super(issues[0].message), this.name = "ValiError", this.issues = issues;
super(issues[0].message);
/**
* The error issues.
*/
__publicField(this, "issues");
this.name = "ValiError", this.issues = issues;
}

@@ -619,4 +705,3 @@ };

function fallback(schema, fallback2) {
return {
...schema,
return __spreadProps(__spreadValues({}, schema), {
fallback: fallback2,

@@ -629,3 +714,3 @@ _run(dataset, config2) {

}
};
});
}

@@ -664,2 +749,3 @@ function getDefault(schema, dataset, config2) {

_run(dataset, config2) {
var _a;
const input = dataset.value;

@@ -682,3 +768,3 @@ if (input && typeof input == "object") {

for (const issue of valueDataset.issues)
issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], dataset.issues?.push(issue);
issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], (_a = dataset.issues) == null || _a.push(issue);
if (dataset.issues || (dataset.issues = valueDataset.issues), config2.abortEarly) {

@@ -736,2 +822,3 @@ dataset.typed = !1;

_run(dataset, config2) {
var _a, _b;
const input = dataset.value;

@@ -755,3 +842,3 @@ if (input && typeof input == "object") {

for (const issue of keyDataset.issues)
issue.path = [pathItem], dataset.issues?.push(issue);
issue.path = [pathItem], (_a = dataset.issues) == null || _a.push(issue);
if (dataset.issues || (dataset.issues = keyDataset.issues), config2.abortEarly) {

@@ -775,3 +862,3 @@ dataset.typed = !1;

for (const issue of valueDataset.issues)
issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], dataset.issues?.push(issue);
issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], (_b = dataset.issues) == null || _b.push(issue);
if (dataset.issues || (dataset.issues = valueDataset.issues), config2.abortEarly) {

@@ -825,4 +912,3 @@ dataset.typed = !1;

function pipe(...pipe2) {
return {
...pipe2[0],
return __spreadProps(__spreadValues({}, pipe2[0]), {
pipe: pipe2,

@@ -834,3 +920,3 @@ _run(dataset, config2) {

if (config2.skipPipe || dataset.issues && (config2.abortEarly || config2.abortPipeEarly || // TODO: This behavior must be documented!
nextAction?.kind === "schema" || nextAction?.kind === "transformation")) {
(nextAction == null ? void 0 : nextAction.kind) === "schema" || (nextAction == null ? void 0 : nextAction.kind) === "transformation")) {
dataset.typed = !1;

@@ -842,30 +928,32 @@ break;

}
};
});
}
var __defProp2 = Object.defineProperty, __defProps2 = Object.defineProperties, __getOwnPropDescs2 = Object.getOwnPropertyDescriptors, __getOwnPropSymbols2 = Object.getOwnPropertySymbols, __hasOwnProp2 = Object.prototype.hasOwnProperty, __propIsEnum2 = Object.prototype.propertyIsEnumerable, __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues2 = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp2.call(b, prop) && __defNormalProp2(a, prop, b[prop]);
if (__getOwnPropSymbols2)
for (var prop of __getOwnPropSymbols2(b))
__propIsEnum2.call(b, prop) && __defNormalProp2(a, prop, b[prop]);
return a;
}, __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
const ACTION_IFRAME_LOADED = "ACTION_IFRAME_LOADED", ACTION_IFRAME_REFRESH = "ACTION_IFRAME_REFRESH", ACTION_IFRAME_RELOAD = "ACTION_IFRAME_RELOAD", ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE = "ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE", presentationReducer = (state, action) => {
switch (action.type) {
case ACTION_IFRAME_LOADED:
return state.iframe.status === "loaded" ? state : {
...state,
iframe: {
...state.iframe,
return state.iframe.status === "loaded" ? state : __spreadProps2(__spreadValues2({}, state), {
iframe: __spreadProps2(__spreadValues2({}, state.iframe), {
status: "loaded"
}
};
})
});
case ACTION_IFRAME_REFRESH:
return state.iframe.status === "refreshing" ? state : {
...state,
iframe: {
...state.iframe,
return state.iframe.status === "refreshing" ? state : __spreadProps2(__spreadValues2({}, state), {
iframe: __spreadProps2(__spreadValues2({}, state.iframe), {
status: "refreshing"
}
};
})
});
case ACTION_IFRAME_RELOAD:
return state.iframe.status === "reloading" ? state : {
...state,
iframe: {
...state.iframe,
return state.iframe.status === "reloading" ? state : __spreadProps2(__spreadValues2({}, state), {
iframe: __spreadProps2(__spreadValues2({}, state.iframe), {
status: "reloading"
}
};
})
});
case ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE:

@@ -876,9 +964,7 @@ return toggleVisualEditingOverlays(state, action);

}
}, toggleVisualEditingOverlays = (state, action) => state.visualEditing.overlaysEnabled === action.enabled ? state : {
...state,
visualEditing: {
...state.visualEditing,
}, toggleVisualEditingOverlays = (state, action) => state.visualEditing.overlaysEnabled === action.enabled ? state : __spreadProps2(__spreadValues2({}, state), {
visualEditing: __spreadProps2(__spreadValues2({}, state.visualEditing), {
overlaysEnabled: action.enabled
}
}, mainDocumentSchema = fallback(boolean(), !1), iframeStatusSchema = picklist(["loading", "loaded", "refreshing", "reloading"]), initStateSchema = object({
})
}), mainDocumentSchema = fallback(boolean(), !1), iframeStatusSchema = picklist(["loading", "loaded", "refreshing", "reloading"]), initStateSchema = object({
mainDocument: mainDocumentSchema,

@@ -901,6 +987,3 @@ iframe: object({

function presentationReducerInit(state) {
return parse(initStateSchema, {
...INITIAL_PRESENTATION_STATE,
...state
});
return parse(initStateSchema, __spreadValues2(__spreadValues2({}, INITIAL_PRESENTATION_STATE), state));
}

@@ -907,0 +990,0 @@ export {

@@ -13,2 +13,10 @@ import { jsx, Fragment } from "react/jsx-runtime";

import { MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL } from "./index.js";
var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b))
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
return a;
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
function LoaderQueries(props) {

@@ -55,12 +63,14 @@ const {

throw new Error(`Loader query listen heartbeat interval must be at least ${MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL}ms`);
setLiveQueries((prev) => ({
...prev,
[getQueryCacheKey(data_0.query, data_0.params)]: {
perspective: data_0.perspective,
query: data_0.query,
params: data_0.params,
receivedAt: Date.now(),
heartbeat: data_0.heartbeat ?? !1
}
}));
setLiveQueries((prev) => {
var _a;
return __spreadProps(__spreadValues({}, prev), {
[getQueryCacheKey(data_0.query, data_0.params)]: {
perspective: data_0.perspective,
query: data_0.query,
params: data_0.params,
receivedAt: Date.now(),
heartbeat: (_a = data_0.heartbeat) != null ? _a : !1
}
});
});
}

@@ -142,3 +152,3 @@ }), comlink_0.start();

$[0] !== dataset || $[1] !== projectId ? (t0 = (comlink_0, perspective_0, query_0, params_0, result_0, resultSourceMap_0, tags_0) => {
comlink_0?.post("loader/query-change", {
comlink_0 == null || comlink_0.post("loader/query-change", {
projectId,

@@ -180,3 +190,3 @@ dataset,

}, $[0] = t0) : t0 = $[0];
const [revalidate, startRefresh] = useRevalidate(t0), shouldRefetch = revalidate === "refresh" || revalidate === "inflight" || lastLiveEventId !== snapshot?.lastLiveEventId;
const [revalidate, startRefresh] = useRevalidate(t0), shouldRefetch = revalidate === "refresh" || revalidate === "inflight" || lastLiveEventId !== (snapshot == null ? void 0 : snapshot.lastLiveEventId);
let t1, t2;

@@ -208,5 +218,5 @@ $[1] !== client || $[2] !== lastLiveEventId || $[3] !== params || $[4] !== perspective || $[5] !== query || $[6] !== shouldRefetch || $[7] !== startRefresh ? (t1 = () => {

fetching = !1, signal.aborted || (setSnapshot((prev) => ({
result: isEqual(prev?.result, result) ? prev?.result : result,
resultSourceMap: isEqual(prev?.resultSourceMap, resultSourceMap) ? prev?.resultSourceMap : resultSourceMap,
syncTags: isEqual(prev?.syncTags, syncTags) ? prev?.syncTags : syncTags,
result: isEqual(prev == null ? void 0 : prev.result, result) ? prev == null ? void 0 : prev.result : result,
resultSourceMap: isEqual(prev == null ? void 0 : prev.resultSourceMap, resultSourceMap) ? prev == null ? void 0 : prev.resultSourceMap : resultSourceMap,
syncTags: isEqual(prev == null ? void 0 : prev.syncTags, syncTags) ? prev == null ? void 0 : prev.syncTags : syncTags,
lastLiveEventId

@@ -222,3 +232,3 @@ })), fulfilled = !0);

let t3;
$[10] !== snapshot ? (t3 = snapshot ?? {}, $[10] = snapshot, $[11] = t3) : t3 = $[11];
$[10] !== snapshot ? (t3 = snapshot != null ? snapshot : {}, $[10] = snapshot, $[11] = t3) : t3 = $[11];
const {

@@ -260,3 +270,3 @@ result: result_0,

// If _projectId is set, it's a cross dataset reference and we should skip it
!sourceDocument._projectId && liveDocument?._id && getPublishedId(liveDocument._id) === getPublishedId(sourceDocument._id)
!sourceDocument._projectId && liveDocument != null && liveDocument._id && getPublishedId(liveDocument._id) === getPublishedId(sourceDocument._id)
)

@@ -263,0 +273,0 @@ return liveDocument;

@@ -12,2 +12,10 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";

import { MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL, LIVE_QUERY_CACHE_SIZE, LIVE_QUERY_CACHE_BATCH_SIZE } from "./index.js";
var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b))
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
return a;
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
function LoaderQueries(props) {

@@ -55,12 +63,14 @@ const {

throw new Error(`Loader query listen heartbeat interval must be at least ${MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL}ms`);
setLiveQueries((prev) => ({
...prev,
[getQueryCacheKey(data_0.query, data_0.params)]: {
perspective: data_0.perspective,
query: data_0.query,
params: data_0.params,
receivedAt: Date.now(),
heartbeat: data_0.heartbeat ?? !1
}
}));
setLiveQueries((prev) => {
var _a;
return __spreadProps(__spreadValues({}, prev), {
[getQueryCacheKey(data_0.query, data_0.params)]: {
perspective: data_0.perspective,
query: data_0.query,
params: data_0.params,
receivedAt: Date.now(),
heartbeat: (_a = data_0.heartbeat) != null ? _a : !1
}
});
});
}

@@ -130,9 +140,8 @@ }), comlink_0.start();

}).subscribe((update) => {
if (update.type === "mutation" && update.transition === "disappear" && cache.delete(update.documentId) && setDocumentsCacheLastUpdated(Date.now()), update.type !== "mutation" || !update.effects?.apply?.length)
var _a, _b;
if (update.type === "mutation" && update.transition === "disappear" && cache.delete(update.documentId) && setDocumentsCacheLastUpdated(Date.now()), update.type !== "mutation" || !((_b = (_a = update.effects) == null ? void 0 : _a.apply) != null && _b.length))
return;
const cachedDocument = cache.peek(update.documentId);
if (cachedDocument) {
const patchDoc = {
...cachedDocument
};
const patchDoc = __spreadValues({}, cachedDocument);
delete patchDoc._rev;

@@ -165,3 +174,3 @@ const patchedDocument = applyPatch(patchDoc, update.effects.apply);

for (const doc of documents)
doc && doc?._id && (cache.set(doc._id, doc), setDocumentsCacheLastUpdated(Date.now()));
doc && doc != null && doc._id && (cache.set(doc._id, doc), setDocumentsCacheLastUpdated(Date.now()));
}, console.error);

@@ -195,6 +204,6 @@ }, t1 = [cache, client, ids, setDocumentsCacheLastUpdated], $[0] = cache, $[1] = client, $[2] = ids, $[3] = setDocumentsCacheLastUpdated, $[4] = t0, $[5] = t1) : (t0 = $[4], t1 = $[5]), useEffect(t0, t1), null;

}, $[0] = cache, $[1] = client, $[2] = documentsCacheLastUpdated, $[3] = liveDocument, $[4] = params, $[5] = perspective, $[6] = query, $[7] = refreshInterval, $[8] = t0) : t0 = $[8];
const data = useQuerySubscription(t0), result = data?.result, resultSourceMap = data?.resultSourceMap, tags = data?.tags;
const data = useQuerySubscription(t0), result = data == null ? void 0 : data.result, resultSourceMap = data == null ? void 0 : data.resultSourceMap, tags = data == null ? void 0 : data.tags;
let t1, t2;
return $[9] !== comlink || $[10] !== dataset || $[11] !== params || $[12] !== perspective || $[13] !== projectId || $[14] !== query || $[15] !== result || $[16] !== resultSourceMap || $[17] !== tags ? (t1 = () => {
resultSourceMap && comlink?.post("loader/query-change", {
resultSourceMap && (comlink == null || comlink.post("loader/query-change", {
projectId,

@@ -208,3 +217,3 @@ dataset,

tags
});
}));
}, t2 = [comlink, dataset, params, perspective, projectId, query, result, resultSourceMap, tags], $[9] = comlink, $[10] = dataset, $[11] = params, $[12] = perspective, $[13] = projectId, $[14] = query, $[15] = result, $[16] = resultSourceMap, $[17] = tags, $[18] = t1, $[19] = t2) : (t1 = $[18], t2 = $[19]), useEffect(t1, t2), null;

@@ -271,3 +280,3 @@ }

};
}, [client, dataset_0, liveDocument, params, perspective, projectId_0, query, shouldRefetch, startRefresh]), useMemo(() => documentsCacheLastUpdated && snapshot?.resultSourceMap ? {
}, [client, dataset_0, liveDocument, params, perspective, projectId_0, query, shouldRefetch, startRefresh]), useMemo(() => documentsCacheLastUpdated && snapshot != null && snapshot.resultSourceMap ? {
result: turboChargeResultIfSourceMap(cache, liveDocument, snapshot.result, perspective, snapshot.resultSourceMap),

@@ -289,3 +298,3 @@ resultSourceMap: snapshot.resultSourceMap

}
return liveDocument?._id && getPublishedId(liveDocument._id) === getPublishedId(sourceDocument._id) ? liveDocument : cache.get(sourceDocument._id);
return liveDocument != null && liveDocument._id && getPublishedId(liveDocument._id) === getPublishedId(sourceDocument._id) ? liveDocument : cache.get(sourceDocument._id);
},

@@ -292,0 +301,0 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

import { memo, useMemo, useEffect } from "react";
import { Subject, switchMap, combineLatest, share, skipWhile, NEVER, merge, takeUntil, filter, map, debounceTime } from "rxjs";
import { useDocumentPreviewStore, useSchema, getDraftId, getPublishedId } from "sanity";
var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b))
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
return a;
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const PostMessagePreviews = (props) => {

@@ -10,6 +18,5 @@ const {

} = props, documentPreviewStore = useDocumentPreviewStore(), schema = useSchema(), refsSubject = useMemo(() => new Subject(), []), previews$ = useMemo(() => refsSubject.asObservable().pipe(switchMap((refs_0) => combineLatest(refs_0.map((ref) => {
const draftRef = {
...ref,
const draftRef = __spreadProps(__spreadValues({}, ref), {
_id: getDraftId(ref._id)
}, draft$ = perspective === "previewDrafts" ? documentPreviewStore.observeForPreview(draftRef, schema.get(draftRef._type)).pipe(
}), draft$ = perspective === "previewDrafts" ? documentPreviewStore.observeForPreview(draftRef, schema.get(draftRef._type)).pipe(
// Share to prevent double subscribe in the merge

@@ -22,6 +29,5 @@ share(),

NEVER
), publishedRef = {
...ref,
), publishedRef = __spreadProps(__spreadValues({}, ref), {
_id: getPublishedId(ref._id)
}, published$ = documentPreviewStore.observeForPreview(publishedRef, schema.get(publishedRef._type));
}), published$ = documentPreviewStore.observeForPreview(publishedRef, schema.get(publishedRef._type));
return merge(published$.pipe(takeUntil(draft$)), draft$).pipe(filter((p_0) => !!p_0.snapshot), map((p_1) => {

@@ -28,0 +34,0 @@ const snapshot = p_1.snapshot;

@@ -33,14 +33,14 @@ import { jsx } from "react/jsx-runtime";

let t0;
$[0] !== comlink || $[1] !== draft || $[2] !== livePreviewEnabled || $[3] !== prevDraft?._rev || $[4] !== prevPublished?._rev || $[5] !== published ? (t0 = () => {
prevDraft?._rev !== draft?._rev && (startTransition(() => setPrevDraft(draft)), draft && comlink?.post("presentation/refresh", {
$[0] !== comlink || $[1] !== draft || $[2] !== livePreviewEnabled || $[3] !== (prevDraft == null ? void 0 : prevDraft._rev) || $[4] !== (prevPublished == null ? void 0 : prevPublished._rev) || $[5] !== published ? (t0 = () => {
(prevDraft == null ? void 0 : prevDraft._rev) !== (draft == null ? void 0 : draft._rev) && (startTransition(() => setPrevDraft(draft)), draft && (comlink == null || comlink.post("presentation/refresh", {
source: "mutation",
livePreviewEnabled,
document: parseDocument(draft)
})), prevPublished?._rev !== published?._rev && (startTransition(() => setPrevPublished(published)), published && comlink?.post("presentation/refresh", {
}))), (prevPublished == null ? void 0 : prevPublished._rev) !== (published == null ? void 0 : published._rev) && (startTransition(() => setPrevPublished(published)), published && (comlink == null || comlink.post("presentation/refresh", {
source: "mutation",
livePreviewEnabled,
document: parseDocument(published)
}));
}, $[0] = comlink, $[1] = draft, $[2] = livePreviewEnabled, $[3] = prevDraft?._rev, $[4] = prevPublished?._rev, $[5] = published, $[6] = t0) : t0 = $[6];
const t1 = prevDraft?._rev, t2 = prevPublished?._rev;
})));
}, $[0] = comlink, $[1] = draft, $[2] = livePreviewEnabled, $[3] = prevDraft == null ? void 0 : prevDraft._rev, $[4] = prevPublished == null ? void 0 : prevPublished._rev, $[5] = published, $[6] = t0) : t0 = $[6];
const t1 = prevDraft == null ? void 0 : prevDraft._rev, t2 = prevPublished == null ? void 0 : prevPublished._rev;
let t3;

@@ -47,0 +47,0 @@ return $[7] !== comlink || $[8] !== draft || $[9] !== livePreviewEnabled || $[10] !== published || $[11] !== t1 || $[12] !== t2 ? (t3 = [comlink, draft, livePreviewEnabled, t1, t2, published], $[7] = comlink, $[8] = draft, $[9] = livePreviewEnabled, $[10] = published, $[11] = t1, $[12] = t2, $[13] = t3) : t3 = $[13], useEffect(t0, t3), null;

@@ -117,3 +117,12 @@ import { c } from "react-compiler-runtime";

return $[1] !== schemaType.icon || $[2] !== scheme || $[3] !== theme || $[4] !== tone ? (t2 = schemaType.icon ? /* @__PURE__ */ jsx(StyleSheetManager, { sheet: sheet.instance, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, scheme, tone, children: createElement(schemaType.icon) }) }) : null, $[1] = schemaType.icon, $[2] = scheme, $[3] = theme, $[4] = tone, $[5] = t2) : t2 = $[5], t2;
}, documentDefaultFields = (typeName) => ({
};
var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b))
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
return a;
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const documentDefaultFields = (typeName) => ({
_id: {

@@ -157,3 +166,4 @@ type: "objectField",

function createStringNodeDefintion(stringSchemaType) {
const listOptions = stringSchemaType.options?.list;
var _a;
const listOptions = (_a = stringSchemaType.options) == null ? void 0 : _a.list;
return listOptions && Array.isArray(listOptions) ? {

@@ -170,3 +180,4 @@ type: "union",

function createNumberNodeDefintion(numberSchemaType) {
const listOptions = numberSchemaType.options?.list;
var _a;
const listOptions = (_a = numberSchemaType.options) == null ? void 0 : _a.list;
return listOptions && Array.isArray(listOptions) ? {

@@ -281,6 +292,3 @@ type: "union",

icon: extractIcon(schemaType),
fields: {
...documentDefaultFields(schemaType.name),
...object.fields
}
fields: __spreadValues(__spreadValues({}, documentDefaultFields(schemaType.name)), object.fields)
};

@@ -294,3 +302,3 @@ }

type: "object",
fields: {
fields: __spreadValues({
_type: {

@@ -303,5 +311,4 @@ type: "objectField",

}
},
...value.fields
}
}
}, value.fields)
}

@@ -333,3 +340,4 @@ } : {

function convertSchemaType(schemaType) {
if (lastType(schemaType)?.name === "document")
var _a, _b, _c, _d;
if (((_a = lastType(schemaType)) == null ? void 0 : _a.name) === "document")
return createReferenceNode(schemaType.name);

@@ -341,3 +349,3 @@ if (inlineFields.has(schemaType.type))

};
if (schemaType.type?.type?.name === "object")
if (((_c = (_b = schemaType.type) == null ? void 0 : _b.type) == null ? void 0 : _c.name) === "object")
return {

@@ -351,3 +359,3 @@ type: "inline",

return createNumberNodeDefintion(schemaType);
const mapped = typesMap.get(schemaType.type?.name || "");
const mapped = typesMap.get(((_d = schemaType.type) == null ? void 0 : _d.name) || "");
if (mapped)

@@ -370,2 +378,3 @@ return mapped;

function createUnionNodeOptions(schemaType, of) {
var _a;
const {

@@ -375,8 +384,5 @@ options

if (!options) return;
const opts = {
...options
};
return options.insertMenu && (opts.insertMenu = {
...options.insertMenu,
views: options.insertMenu.views?.map((view) => view.name === "grid" ? {
const opts = __spreadValues({}, options);
return options.insertMenu && (opts.insertMenu = __spreadProps(__spreadValues({}, options.insertMenu), {
views: (_a = options.insertMenu.views) == null ? void 0 : _a.map((view) => view.name === "grid" ? {
name: "grid",

@@ -386,7 +392,8 @@ previewImageUrls: view.previewImageUrl ? of.reduce((acc, {

}) => {
const url = view.previewImageUrl?.(name);
var _a2;
const url = (_a2 = view.previewImageUrl) == null ? void 0 : _a2.call(view, name);
if (!url) return acc;
try {
new URL(url), acc[name] = url;
} catch {
} catch (e) {
acc[name] = new URL(url, `${window.location.origin}${basePath ? `${basePath}/` : ""}`).toString();

@@ -397,3 +404,3 @@ }

} : view)
}), opts;
})), opts;
}

@@ -400,0 +407,0 @@ function createArray(arraySchemaType) {

import { jsxs, jsx } from "react/jsx-runtime";
import { motion } from "framer-motion";
import { memo, useMemo } from "react";
var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
/**

@@ -9,3 +10,28 @@ * @license QR Code generator library (TypeScript)

*/
class QrCode {
const _QrCode = class _QrCode2 {
/*-- Constructor (low level) and fields --*/
// Creates a new QR Code with the given version number,
// error correction level, data codeword bytes, and mask number.
// This is a low-level API that most users should not use directly.
// A mid-level API is the encodeSegments() function.
constructor(version, errorCorrectionLevel, dataCodewords, msk) {
if (__publicField(this, "modules", []), __publicField(this, "isFunction", []), this.version = version, this.errorCorrectionLevel = errorCorrectionLevel, version < _QrCode2.MIN_VERSION || version > _QrCode2.MAX_VERSION) throw new RangeError("Version value out of range");
if (msk < -1 || msk > 7) throw new RangeError("Mask value out of range");
this.size = version * 4 + 17;
const row = [];
for (let i = 0; i < this.size; i++) row.push(!1);
for (let i = 0; i < this.size; i++)
this.modules.push(row.slice()), this.isFunction.push(row.slice());
this.drawFunctionPatterns();
const allCodewords = this.addEccAndInterleave(dataCodewords);
if (this.drawCodewords(allCodewords), msk == -1) {
let minPenalty = 1e9;
for (let i = 0; i < 8; i++) {
this.applyMask(i), this.drawFormatBits(i);
const penalty = this.getPenaltyScore();
penalty < minPenalty && (msk = i, minPenalty = penalty), this.applyMask(i);
}
}
assert(0 <= msk && msk <= 7), this.mask = msk, this.applyMask(msk), this.drawFormatBits(msk), this.isFunction = [];
}
/*-- Static factory functions (high level) --*/

@@ -19,3 +45,3 @@ // Returns a QR Code representing the given Unicode text string at the given error correction level.

const segs = QrSegment.makeSegments(text);
return QrCode.encodeSegments(segs, ecl);
return _QrCode2.encodeSegments(segs, ecl);
}

@@ -28,3 +54,3 @@ // Returns a QR Code representing the given binary data at the given error correction level.

const seg = QrSegment.makeBytes(data);
return QrCode.encodeSegments([seg], ecl);
return _QrCode2.encodeSegments([seg], ecl);
}

@@ -42,6 +68,6 @@ /*-- Static factory functions (mid level) --*/

static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = !0) {
if (!(QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= QrCode.MAX_VERSION) || mask < -1 || mask > 7) throw new RangeError("Invalid value");
if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7) throw new RangeError("Invalid value");
let version, dataUsedBits;
for (version = minVersion; ; version++) {
const dataCapacityBits2 = QrCode.getNumDataCodewords(version, ecl) * 8, usedBits = QrSegment.getTotalBits(segs, version);
const dataCapacityBits2 = _QrCode2.getNumDataCodewords(version, ecl) * 8, usedBits = QrSegment.getTotalBits(segs, version);
if (usedBits <= dataCapacityBits2) {

@@ -55,3 +81,3 @@ dataUsedBits = usedBits;

for (const newEcl of [Ecc.MEDIUM, Ecc.QUARTILE, Ecc.HIGH])
boostEcl && dataUsedBits <= QrCode.getNumDataCodewords(version, newEcl) * 8 && (ecl = newEcl);
boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version, newEcl) * 8 && (ecl = newEcl);
const bb = [];

@@ -63,3 +89,3 @@ for (const seg of segs) {

assert(bb.length == dataUsedBits);
const dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8;
const dataCapacityBits = _QrCode2.getNumDataCodewords(version, ecl) * 8;
assert(bb.length <= dataCapacityBits), appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb), appendBits(0, (8 - bb.length % 8) % 8, bb), assert(bb.length % 8 == 0);

@@ -69,40 +95,4 @@ for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 253) appendBits(padByte, 8, bb);

for (; dataCodewords.length * 8 < bb.length; ) dataCodewords.push(0);
return bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7)), new QrCode(version, ecl, dataCodewords, mask);
return bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7)), new _QrCode2(version, ecl, dataCodewords, mask);
}
/*-- Fields --*/
// The width and height of this QR Code, measured in modules, between
// 21 and 177 (inclusive). This is equal to version * 4 + 17.
// The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
// Even if a QR Code is created with automatic masking requested (mask = -1),
// the resulting object still has a mask value between 0 and 7.
// The modules of this QR Code (false = light, true = dark).
// Immutable after constructor finishes. Accessed through getModule().
modules = [];
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
isFunction = [];
/*-- Constructor (low level) and fields --*/
// Creates a new QR Code with the given version number,
// error correction level, data codeword bytes, and mask number.
// This is a low-level API that most users should not use directly.
// A mid-level API is the encodeSegments() function.
constructor(version, errorCorrectionLevel, dataCodewords, msk) {
if (this.version = version, this.errorCorrectionLevel = errorCorrectionLevel, version < QrCode.MIN_VERSION || version > QrCode.MAX_VERSION) throw new RangeError("Version value out of range");
if (msk < -1 || msk > 7) throw new RangeError("Mask value out of range");
this.size = version * 4 + 17;
const row = [];
for (let i = 0; i < this.size; i++) row.push(!1);
for (let i = 0; i < this.size; i++)
this.modules.push(row.slice()), this.isFunction.push(row.slice());
this.drawFunctionPatterns();
const allCodewords = this.addEccAndInterleave(dataCodewords);
if (this.drawCodewords(allCodewords), msk == -1) {
let minPenalty = 1e9;
for (let i = 0; i < 8; i++) {
this.applyMask(i), this.drawFormatBits(i);
const penalty = this.getPenaltyScore();
penalty < minPenalty && (msk = i, minPenalty = penalty), this.applyMask(i);
}
}
assert(0 <= msk && msk <= 7), this.mask = msk, this.applyMask(msk), this.drawFormatBits(msk), this.isFunction = [];
}
/*-- Accessor methods --*/

@@ -184,8 +174,8 @@ // Returns the color of the module (pixel) at the given coordinates, which is false

const ver = this.version, ecl = this.errorCorrectionLevel;
if (data.length != QrCode.getNumDataCodewords(ver, ecl)) throw new RangeError("Invalid argument");
const numBlocks = QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver], blockEccLen = QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver], rawCodewords = Math.floor(QrCode.getNumRawDataModules(ver) / 8), numShortBlocks = numBlocks - rawCodewords % numBlocks, shortBlockLen = Math.floor(rawCodewords / numBlocks), blocks = [], rsDiv = QrCode.reedSolomonComputeDivisor(blockEccLen);
if (data.length != _QrCode2.getNumDataCodewords(ver, ecl)) throw new RangeError("Invalid argument");
const numBlocks = _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver], blockEccLen = _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver], rawCodewords = Math.floor(_QrCode2.getNumRawDataModules(ver) / 8), numShortBlocks = numBlocks - rawCodewords % numBlocks, shortBlockLen = Math.floor(rawCodewords / numBlocks), blocks = [], rsDiv = _QrCode2.reedSolomonComputeDivisor(blockEccLen);
for (let i = 0, k = 0; i < numBlocks; i++) {
const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
k += dat.length;
const ecc = QrCode.reedSolomonComputeRemainder(dat, rsDiv);
const ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
i < numShortBlocks && dat.push(0), blocks.push(dat.concat(ecc));

@@ -203,3 +193,3 @@ }

drawCodewords(data) {
if (data.length != Math.floor(QrCode.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument");
if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument");
let i = 0;

@@ -265,4 +255,4 @@ for (let right = this.size - 1; right >= 1; right -= 2) {

for (let x = 0; x < this.size; x++)
this.modules[y][x] == runColor ? (runX++, runX == 5 ? result += QrCode.PENALTY_N1 : runX > 5 && result++) : (this.finderPenaltyAddHistory(runX, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * QrCode.PENALTY_N3), runColor = this.modules[y][x], runX = 1);
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * QrCode.PENALTY_N3;
this.modules[y][x] == runColor ? (runX++, runX == 5 ? result += _QrCode2.PENALTY_N1 : runX > 5 && result++) : (this.finderPenaltyAddHistory(runX, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3), runColor = this.modules[y][x], runX = 1);
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
}

@@ -273,4 +263,4 @@ for (let x = 0; x < this.size; x++) {

for (let y = 0; y < this.size; y++)
this.modules[y][x] == runColor ? (runY++, runY == 5 ? result += QrCode.PENALTY_N1 : runY > 5 && result++) : (this.finderPenaltyAddHistory(runY, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * QrCode.PENALTY_N3), runColor = this.modules[y][x], runY = 1);
result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * QrCode.PENALTY_N3;
this.modules[y][x] == runColor ? (runY++, runY == 5 ? result += _QrCode2.PENALTY_N1 : runY > 5 && result++) : (this.finderPenaltyAddHistory(runY, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3), runColor = this.modules[y][x], runY = 1);
result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
}

@@ -280,3 +270,3 @@ for (let y = 0; y < this.size - 1; y++)

const color = this.modules[y][x];
color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1] && (result += QrCode.PENALTY_N2);
color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1] && (result += _QrCode2.PENALTY_N2);
}

@@ -286,3 +276,3 @@ let dark = 0;

const total = this.size * this.size, k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
return assert(0 <= k && k <= 9), result += k * QrCode.PENALTY_N4, assert(0 <= result && result <= 2568888), result;
return assert(0 <= k && k <= 9), result += k * _QrCode2.PENALTY_N4, assert(0 <= result && result <= 2568888), result;
}

@@ -305,3 +295,3 @@ /*-- Private helper functions --*/

static getNumRawDataModules(ver) {
if (ver < QrCode.MIN_VERSION || ver > QrCode.MAX_VERSION) throw new RangeError("Version number out of range");
if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION) throw new RangeError("Version number out of range");
let result = (16 * ver + 128) * ver + 64;

@@ -318,3 +308,3 @@ if (ver >= 2) {

static getNumDataCodewords(ver, ecl) {
return Math.floor(QrCode.getNumRawDataModules(ver) / 8) - QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
}

@@ -331,4 +321,4 @@ // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be

for (let j = 0; j < result.length; j++)
result[j] = QrCode.reedSolomonMultiply(result[j], root), j + 1 < result.length && (result[j] ^= result[j + 1]);
root = QrCode.reedSolomonMultiply(root, 2);
result[j] = _QrCode2.reedSolomonMultiply(result[j], root), j + 1 < result.length && (result[j] ^= result[j + 1]);
root = _QrCode2.reedSolomonMultiply(root, 2);
}

@@ -342,3 +332,3 @@ return result;

const factor = b ^ result.shift();
result.push(0), divisor.forEach((coef, i) => result[i] ^= QrCode.reedSolomonMultiply(coef, factor));
result.push(0), divisor.forEach((coef, i) => result[i] ^= _QrCode2.reedSolomonMultiply(coef, factor));
}

@@ -372,37 +362,29 @@ return result;

}
/*-- Constants and tables --*/
// The minimum version number supported in the QR Code Model 2 standard.
static MIN_VERSION = 1;
// The maximum version number supported in the QR Code Model 2 standard.
static MAX_VERSION = 40;
// For use in getPenaltyScore(), when evaluating which mask is best.
static PENALTY_N1 = 3;
static PENALTY_N2 = 3;
static PENALTY_N3 = 40;
static PENALTY_N4 = 10;
static ECC_CODEWORDS_PER_BLOCK = [
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
// Low
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
// Medium
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
// Quartile
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
// High
];
static NUM_ERROR_CORRECTION_BLOCKS = [
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
// Low
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
// Medium
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
// Quartile
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
// High
];
}
};
__publicField(_QrCode, "MIN_VERSION", 1), // The maximum version number supported in the QR Code Model 2 standard.
__publicField(_QrCode, "MAX_VERSION", 40), // For use in getPenaltyScore(), when evaluating which mask is best.
__publicField(_QrCode, "PENALTY_N1", 3), __publicField(_QrCode, "PENALTY_N2", 3), __publicField(_QrCode, "PENALTY_N3", 40), __publicField(_QrCode, "PENALTY_N4", 10), __publicField(_QrCode, "ECC_CODEWORDS_PER_BLOCK", [
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
// Low
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
// Medium
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
// Quartile
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
// High
]), __publicField(_QrCode, "NUM_ERROR_CORRECTION_BLOCKS", [
// Version: (note that index 0 is for padding, and is set to an illegal value)
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
// Low
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
// Medium
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
// Quartile
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
// High
]);
let QrCode = _QrCode;
function appendBits(val, len, bb) {

@@ -418,3 +400,3 @@ if (len < 0 || len > 31 || val >>> len) throw new RangeError("Value out of range");

}
class QrSegment {
const _QrSegment = class _QrSegment2 {
/*-- Static factory functions (mid level) --*/

@@ -427,7 +409,7 @@ // Returns a segment representing the given binary data encoded in

for (const b of data) appendBits(b, 8, bb);
return new QrSegment(Mode.BYTE, data.length, bb);
return new _QrSegment2(Mode.BYTE, data.length, bb);
}
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
static makeNumeric(digits) {
if (!QrSegment.isNumeric(digits)) throw new RangeError("String contains non-numeric characters");
if (!_QrSegment2.isNumeric(digits)) throw new RangeError("String contains non-numeric characters");
const bb = [];

@@ -438,3 +420,3 @@ for (let i = 0; i < digits.length; ) {

}
return new QrSegment(Mode.NUMERIC, digits.length, bb);
return new _QrSegment2(Mode.NUMERIC, digits.length, bb);
}

@@ -445,10 +427,10 @@ // Returns a segment representing the given text string encoded in alphanumeric mode.

static makeAlphanumeric(text) {
if (!QrSegment.isAlphanumeric(text)) throw new RangeError("String contains unencodable characters in alphanumeric mode");
if (!_QrSegment2.isAlphanumeric(text)) throw new RangeError("String contains unencodable characters in alphanumeric mode");
const bb = [];
let i;
for (i = 0; i + 2 <= text.length; i += 2) {
let temp = QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
temp += QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1)), appendBits(temp, 11, bb);
let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1)), appendBits(temp, 11, bb);
}
return i < text.length && appendBits(QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb), new QrSegment(Mode.ALPHANUMERIC, text.length, bb);
return i < text.length && appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb), new _QrSegment2(Mode.ALPHANUMERIC, text.length, bb);
}

@@ -458,3 +440,3 @@ // Returns a new mutable list of zero or more segments to represent the given Unicode text string.

static makeSegments(text) {
return text == "" ? [] : QrSegment.isNumeric(text) ? [QrSegment.makeNumeric(text)] : QrSegment.isAlphanumeric(text) ? [QrSegment.makeAlphanumeric(text)] : [QrSegment.makeBytes(QrSegment.toUtf8ByteArray(text))];
return text == "" ? [] : _QrSegment2.isNumeric(text) ? [_QrSegment2.makeNumeric(text)] : _QrSegment2.isAlphanumeric(text) ? [_QrSegment2.makeAlphanumeric(text)] : [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
}

@@ -472,3 +454,3 @@ // Returns a segment representing an Extended Channel Interpretation

else throw new RangeError("ECI assignment value out of range");
return new QrSegment(Mode.ECI, 0, bb);
return new _QrSegment2(Mode.ECI, 0, bb);
}

@@ -478,3 +460,3 @@ // Tests whether the given string can be encoded as a segment in numeric mode.

static isNumeric(text) {
return QrSegment.NUMERIC_REGEX.test(text);
return _QrSegment2.NUMERIC_REGEX.test(text);
}

@@ -485,3 +467,3 @@ // Tests whether the given string can be encoded as a segment in alphanumeric mode.

static isAlphanumeric(text) {
return QrSegment.ALPHANUMERIC_REGEX.test(text);
return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
}

@@ -520,20 +502,9 @@ /*-- Constructor (low level) and fields --*/

}
/*-- Constants --*/
// Describes precisely all strings that are encodable in numeric mode.
static NUMERIC_REGEX = /^[0-9]*$/;
// Describes precisely all strings that are encodable in alphanumeric mode.
static ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+./:-]*$/;
// The set of all legal characters in alphanumeric mode,
// where each character value maps to the index in the string.
static ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
}
class Ecc {
/*-- Constants --*/
static LOW = new Ecc(0, 1);
// The QR Code can tolerate about 7% erroneous codewords
static MEDIUM = new Ecc(1, 0);
// The QR Code can tolerate about 15% erroneous codewords
static QUARTILE = new Ecc(2, 3);
// The QR Code can tolerate about 25% erroneous codewords
static HIGH = new Ecc(3, 2);
};
__publicField(_QrSegment, "NUMERIC_REGEX", /^[0-9]*$/), // Describes precisely all strings that are encodable in alphanumeric mode.
__publicField(_QrSegment, "ALPHANUMERIC_REGEX", /^[A-Z0-9 $%*+./:-]*$/), // The set of all legal characters in alphanumeric mode,
// where each character value maps to the index in the string.
__publicField(_QrSegment, "ALPHANUMERIC_CHARSET", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:");
let QrSegment = _QrSegment;
const _Ecc = class {
// The QR Code can tolerate about 30% erroneous codewords

@@ -544,10 +515,9 @@ /*-- Constructor and fields --*/

}
}
class Mode {
/*-- Constants --*/
static NUMERIC = new Mode(1, [10, 12, 14]);
static ALPHANUMERIC = new Mode(2, [9, 11, 13]);
static BYTE = new Mode(4, [8, 16, 16]);
static KANJI = new Mode(8, [8, 10, 12]);
static ECI = new Mode(7, [0, 0, 0]);
};
__publicField(_Ecc, "LOW", new _Ecc(0, 1)), // The QR Code can tolerate about 7% erroneous codewords
__publicField(_Ecc, "MEDIUM", new _Ecc(1, 0)), // The QR Code can tolerate about 15% erroneous codewords
__publicField(_Ecc, "QUARTILE", new _Ecc(2, 3)), // The QR Code can tolerate about 25% erroneous codewords
__publicField(_Ecc, "HIGH", new _Ecc(3, 2));
let Ecc = _Ecc;
const _Mode = class {
/*-- Constructor and fields --*/

@@ -563,3 +533,5 @@ constructor(modeBits, numBitsCharCount) {

}
}
};
__publicField(_Mode, "NUMERIC", new _Mode(1, [10, 12, 14])), __publicField(_Mode, "ALPHANUMERIC", new _Mode(2, [9, 11, 13])), __publicField(_Mode, "BYTE", new _Mode(4, [8, 16, 16])), __publicField(_Mode, "KANJI", new _Mode(8, [8, 10, 12])), __publicField(_Mode, "ECI", new _Mode(7, [0, 0, 0]));
let Mode = _Mode;
const ERROR_LEVEL_MAP = {

@@ -669,3 +641,3 @@ L: Ecc.LOW,

size
}), cellsToDraw = useMemo(() => logoSize && calculatedImageSettings?.excavation ? excavateModules(cells, calculatedImageSettings.excavation) : cells, [calculatedImageSettings?.excavation, cells, logoSize]), fgPath = generatePath(cellsToDraw, margin);
}), cellsToDraw = useMemo(() => logoSize && calculatedImageSettings != null && calculatedImageSettings.excavation ? excavateModules(cells, calculatedImageSettings.excavation) : cells, [calculatedImageSettings == null ? void 0 : calculatedImageSettings.excavation, cells, logoSize]), fgPath = generatePath(cellsToDraw, margin);
return /* @__PURE__ */ jsxs("svg", { height: size, width: size, viewBox: `0 0 ${numCells} ${numCells}`, role: "img", children: [

@@ -672,0 +644,0 @@ !!title && /* @__PURE__ */ jsx("title", { children: title }),

{
"name": "@sanity/presentation",
"version": "1.19.12",
"version": "1.19.13",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -44,5 +44,5 @@ "bugs": {

"@sanity/client": "^6.24.1",
"@sanity/icons": "^3.5.0",
"@sanity/icons": "^3.5.3",
"@sanity/logos": "^2.1.13",
"@sanity/ui": "^2.9.1",
"@sanity/ui": "^2.10.11",
"@sanity/uuid": "3.0.2",

@@ -59,7 +59,7 @@ "fast-deep-equal": "3.1.3",

"use-effect-event": "^1.0.2",
"@sanity/comlink": "2.0.2",
"@sanity/preview-url-secret": "2.0.5"
"@sanity/preview-url-secret": "2.0.5",
"@sanity/comlink": "2.0.2"
},
"devDependencies": {
"@sanity/pkg-utils": "6.11.14",
"@sanity/pkg-utils": "6.12.0",
"@types/lodash": "^4.17.13",

@@ -71,10 +71,10 @@ "babel-plugin-react-compiler": "19.0.0-beta-201e55d-20241215",

"react-dom": "^18.3.1",
"sanity": "^3.66.0",
"sanity": "3.68.0",
"styled-components": "6.1.13",
"typescript": "5.7.2",
"vitest": "^2.1.8",
"@repo/eslint-config": "0.0.0",
"@repo/package.config": "0.0.0",
"@repo/prettier-config": "0.0.0",
"@repo/visual-editing-helpers": "0.7.9",
"@repo/eslint-config": "0.0.0"
"@repo/prettier-config": "0.0.0"
},

@@ -81,0 +81,0 @@ "engines": {

import {MasterDetailIcon} from '@sanity/icons'
import {useContext, useMemo} from 'react'
import {type Tool} from 'sanity'
import {type DocumentFieldActionGroup, type DocumentFieldActionProps, type Tool} from 'sanity'
import {useRouter} from 'sanity/router'

@@ -14,30 +14,37 @@ import {

function useOpenInStructureAction(
props: DocumentFieldActionProps,
): DocumentFieldActionItem | DocumentFieldActionGroup {
const {documentId, documentType, path} = props
const workspace = useWorkspace()
const {navigateIntent} = useRouter()
const presentation = useContext(PresentationContext)
const defaultStructureTool = useMemo(
() => findStructureTool(workspace.tools, documentId, documentType),
[documentId, documentType, workspace.tools],
)
const handleAction = () => {
navigateIntent('edit', {
id: documentId,
type: documentType,
mode: 'structure',
path: pathToString(path),
})
}
return {
type: 'action',
hidden: !presentation || path.length > 0 || !defaultStructureTool,
icon: defaultStructureTool?.icon || MasterDetailIcon,
title: `Open in ${defaultStructureTool?.title || 'Structure'}`,
onAction: handleAction,
renderAsButton: true,
}
}
export const openInStructure = defineDocumentFieldAction({
name: 'presentation/openInStructure',
useAction({documentId, documentType, path}) {
const workspace = useWorkspace()
const {navigateIntent} = useRouter()
const presentation = useContext(PresentationContext)
const defaultStructureTool = useMemo(
() => findStructureTool(workspace.tools, documentId, documentType),
[documentId, documentType, workspace.tools],
)
return {
type: 'action',
hidden: !presentation || path.length > 0 || !defaultStructureTool,
icon: defaultStructureTool?.icon || MasterDetailIcon,
title: `Open in ${defaultStructureTool?.title || 'Structure'}`,
onAction() {
navigateIntent('edit', {
id: documentId,
type: documentType,
mode: 'structure',
path: pathToString(path),
})
},
renderAsButton: true,
} satisfies DocumentFieldActionItem
},
useAction: useOpenInStructureAction,
})

@@ -44,0 +51,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc