Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@sanity/visual-editing

Package Overview
Dependencies
Maintainers
113
Versions
301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/visual-editing - npm Package Compare versions

Comparing version
5.1.1
to
5.1.2
+37
-37
dist/_chunks-dts/documentMutator.d.ts

@@ -6,3 +6,3 @@ import { it as VisualEditingNode } from "./types.js";

import * as _sanity_mutate__unstable_machine5 from "@sanity/mutate/_unstable_machine";
import * as xstate91 from "xstate";
import * as xstate47 from "xstate";
import { ActorRefFrom } from "xstate";

@@ -12,3 +12,3 @@ import { SanityEncoder, Transaction } from "@sanity/mutate";

type EmptyActor = typeof emptyActor;
declare const emptyActor: xstate91.ActorRef<xstate91.Snapshot<undefined>, xstate91.AnyEventObject, xstate91.AnyEventObject>;
declare const emptyActor: xstate47.ActorRef<xstate47.Snapshot<undefined>, xstate47.AnyEventObject, xstate47.AnyEventObject>;
declare let actor: MutatorActor | EmptyActor;

@@ -18,3 +18,3 @@ declare const listeners: Set<() => void>;

declare function setActor(nextActor: MutatorActor): void;
declare const createDocumentMutator: (comlink: VisualEditingNode) => xstate91.StateMachine<{
declare const createDocumentMutator: (comlink: VisualEditingNode) => xstate47.StateMachine<{
client: SanityClient;

@@ -54,98 +54,98 @@ sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine5.createSharedListener>;

}, {
[x: string]: xstate91.ActorRefFromLogic<xstate91.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
[x: string]: xstate47.ActorRefFromLogic<xstate47.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate91.EventObject>> | xstate91.ActorRefFromLogic<xstate91.PromiseActorLogic<void, {
}, xstate47.EventObject>> | xstate47.ActorRefFromLogic<xstate47.PromiseActorLogic<void, {
client: SanityClient;
transactions: Transaction[];
}, xstate91.EventObject>> | xstate91.ActorRefFromLogic<xstate91.ObservableActorLogic<_sanity_client16.WelcomeEvent | _sanity_client16.ReconnectEvent | _sanity_client16.MutationEvent, {
}, xstate47.EventObject>> | xstate47.ActorRefFromLogic<xstate47.ObservableActorLogic<_sanity_client16.WelcomeEvent | _sanity_client16.ReconnectEvent | _sanity_client16.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine5.createSharedListener>;
id: string;
}, xstate91.EventObject>> | undefined;
getDocument?: xstate91.ActorRefFromLogic<xstate91.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
}, xstate47.EventObject>> | undefined;
getDocument?: xstate47.ActorRefFromLogic<xstate47.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate91.EventObject>> | undefined;
submitTransactions?: xstate91.ActorRefFromLogic<xstate91.PromiseActorLogic<void, {
}, xstate47.EventObject>> | undefined;
submitTransactions?: xstate47.ActorRefFromLogic<xstate47.PromiseActorLogic<void, {
client: SanityClient;
transactions: Transaction[];
}, xstate91.EventObject>> | undefined;
}, xstate47.EventObject>> | undefined;
}, {
src: "fetch remote snapshot";
logic: xstate91.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
logic: xstate47.PromiseActorLogic<void | _sanity_client16.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate91.EventObject>;
}, xstate47.EventObject>;
id: "getDocument";
} | {
src: "submit mutations as transactions";
logic: xstate91.PromiseActorLogic<void, {
logic: xstate47.PromiseActorLogic<void, {
client: SanityClient;
transactions: Transaction[];
}, xstate91.EventObject>;
}, xstate47.EventObject>;
id: "submitTransactions";
} | {
src: "server-sent events";
logic: xstate91.ObservableActorLogic<_sanity_client16.WelcomeEvent | _sanity_client16.ReconnectEvent | _sanity_client16.MutationEvent, {
logic: xstate47.ObservableActorLogic<_sanity_client16.WelcomeEvent | _sanity_client16.ReconnectEvent | _sanity_client16.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine5.createSharedListener>;
id: string;
}, xstate91.EventObject>;
}, xstate47.EventObject>;
id: string | undefined;
}, {
type: "assign error to context";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "clear error from context";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "connect to server-sent events";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "listen to server-sent events";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "stop listening to server-sent events";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "buffer remote mutation events";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "restore stashed changes";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "rebase fetched remote snapshot";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "apply mendoza patch";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "increment fetch attempts";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "reset fetch attempts";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "increment submit attempts";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "reset submit attempts";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "stage mutation";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "stash mutation";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "rebase local snapshot";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "send pristine event to parent";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "send sync event to parent";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
} | {
type: "send mutation event to parent";
params: xstate91.NonReducibleUnknown;
params: xstate47.NonReducibleUnknown;
}, never, "fetchRemoteSnapshotTimeout" | "submitTransactionsTimeout", "disconnected" | "connecting" | "reconnecting" | "connectFailure" | {

@@ -155,3 +155,3 @@ connected: "loading" | "loadFailure" | {

};
}, "error" | "busy" | "ready", _sanity_mutate__unstable_machine5.DocumentMutatorMachineInput, xstate91.NonReducibleUnknown, xstate91.EventObject, xstate91.MetaObject, {
}, "error" | "busy" | "ready", _sanity_mutate__unstable_machine5.DocumentMutatorMachineInput, xstate47.NonReducibleUnknown, xstate47.EventObject, xstate47.MetaObject, {
id: "document-mutator";

@@ -158,0 +158,0 @@ states: {

@@ -1,1 +0,1 @@

{"version":3,"file":"documentMutator.d.ts","names":[],"sources":["../../src/optimistic/context.ts","../../src/optimistic/state/documentMutator.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAIY,YAAA,GAAe,aAAa,kBAAkB;KAC9C,UAAA,UAAoB;cAEnB,YAAU,QAAA,CAAA,SAAqB,QAAA,CAArB,qBAAA,QAAA,CAAA,cAAA,EAAA,QAAA,CAAA,cAAA;YAEZ,OAAO,eAAe;cAEpB,WAAS;iBAEN,YAAA,QAAoB,eAAe,sBAAsB;iBAIzD,QAAA,YAAoB;cCLvB,iCAAkC,+BAAiB;;;;;;EDRpD,KAAA,oCAAY,IAAA,GAAA,SAAA;EAAkC,cAAA,kCAAA;EAAlB,aAAA,mDAAA;EAAb,cAAA,mDAAA;EAAY,KAAA,EAAA,OAAA;EAC3B,2BAAoB,EAAA,MAAA;EAEnB,0BAA+B,EAAA,MAAA;CAAA,qGAArB;EAAA,IAAA,EAAA,OAAA;CAAA,GAAA;EAAA,IAAA,EAAA,OAAA;CAAA,GAAA;EAEZ,IAAA,EAAA,SAA6C;AAExD,CAAA,GAAa;EAEG,IAAA,EAAA,WAAY;CAAQ,GAAA;EAAe,IAAA,EAAA,SAAA;CAAsB,GAAA;EAAU,IAAA,EAAA,QAAA;EAInE,SAAA,wBAAoB,EAAA;;ECLvB,IAAA,EAAA,QAAA;CAAkC,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiB,IAAA,EAAA,gBAAA"}
{"version":3,"file":"documentMutator.d.ts","names":[],"sources":["../../src/optimistic/context.ts","../../src/optimistic/state/documentMutator.ts"],"mappings":";;;;;;;;KAIY,YAAA,GAAe,YAAA,CAAa,UAAA,QAAkB,oBAAA;AAAA,KAC9C,UAAA,UAAoB,UAAA;AAAA,cAEnB,UAAA,EAAU,QAAA,CAAA,QAAA,CAAqB,QAAA,CAArB,QAAA,aAAA,QAAA,CAAA,cAAA,EAAA,QAAA,CAAA,cAAA;AAAA,YAEZ,KAAA,EAAO,YAAA,GAAe,UAAA;AAAA,cAEpB,SAAA,EAAS,GAAA;AAAA,iBAEN,YAAA,CAAa,KAAA,EAAO,YAAA,GAAe,UAAA,GAAa,KAAA,IAAS,UAAA;AAAA,iBAIzD,QAAA,CAAS,SAAA,EAAW,YAAA;AAAA,cCLvB,qBAAA,GAAyB,OAAA,EAAS,iBAAA,cAAiB,YAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;;AAkEA;;;AAEgB,UAhCC,WAAA,CAgCD;EAAqB,CAAA,EAAA,MAAA;EACnB,CAAA,EAAA,MAAA;EAAqB,CAAA,EAAA,MAAA;EACtB,CAAA,EAAA,MAAA;;;AA4EqB,KAhF1B,kBAAA,GAgF0B;EAI1B,GAAA,CAAA,EAAA;IAKA,IAAA,EAxFG,WAwFH;IAGA,MAAA,EA3FwB,UA2FxB;EAA4B,CAAA,GAAA,IAAA;EAC7B,IAAA,CAAA,EAAA;IACD,IAAA,EA5FM,WA4FN;IAAa,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6BAC1B,oBAAA,GAAuB,oBAAA,IAC/B,aAAA,CAAc,qBAAA,CAAsB,CAAA,gBAAiB,CAAA;;;;KAK7C,sBAAA,WACA,MAAA,oBAA0B,MAAA,6BAC1B,oBAAA,GAAuB,oBAAA,IAC/B,aAAA,CAAc,+BAAA,CAAgC,CAAA,gBAAiB,CAAA;AAAA,KAEvD,mBAAA,GACR,eAAA,GACA,iBAAA,GACA,iBAAA;AAAA,KAGQ,oBAAA,GACR,cAAA,GACA,UAAA,GACA,eAAA,GACA,iBAAA,GACA,eAAA"}

@@ -12,3 +12,3 @@ import { it as VisualEditingNode } from "./types.js";

declare const createDatasetMutator: (comlink: VisualEditingNode) => AnyStateMachine;
type Path<T, K$1 extends keyof T> = K$1 extends string ? T[K$1] extends Record<string, any> ? `${K$1}.${Path<T[K$1], keyof T[K$1]>}` | K$1 : K$1 : never;
type Path<T, K extends keyof T> = K extends string ? T[K] extends Record<string, any> ? `${K}.${Path<T[K], keyof T[K]>}` | K : K : never;
type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : never : P extends keyof T ? T[P] : never;

@@ -15,0 +15,0 @@ type DocumentsMutate = (documentId: string, mutations: Mutation[], options?: {

@@ -1,1 +0,1 @@

{"version":3,"file":"types2.d.ts","names":[],"sources":["../../src/optimistic/state/datasetMutator.ts","../../src/optimistic/types.ts"],"sourcesContent":[],"mappings":";;;;;AA2BU,UADO,0BAAA,SAAmC,IAC1C,CAD+C,2BAC/C,EAAA,IAAA,CAAA,CAAA;EAE2B,MAAA,EAF3B,YAE2B;EAAlB;EAHiC,cAAA,CAAA,EAGjC,UAHiC,CAAA,OAGf,oBAHe,CAAA;;AA0GvC,cAAA,oBAAiC,EAAA,CAAA,OAAA,EAAA,iBAAoB,EAAA,GAAA,eAMjE;KCrIW,0BAAwB,KAAK,qBACrC,EAAE,aAAW,yBACR,OAAK,KAAK,EAAE,YAAU,EAAE,UAAQ,MACnC;KAGM,iCAA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ElB,CAAA,eAAgB,CAAA,GACd,CAAA,CAAE,CAAA;AAAA,KAGI,eAAA,IACV,UAAA,UACA,SAAA,EAAW,QAAA,IACX,OAAA;EAAW,MAAA;IAAoB,QAAA;EAAA;AAAA;AAAA,KAGrB,YAAA,cAA0B,MAAA,eACpC,UAAA,aACG,kBAAA,CAAmB,CAAA;AAAA,KAEZ,yBAAA,WAAoC,MAAA,gBAAsB,MAAA,mBAChE,OAAA;EACA,OAAA;EACA,WAAA;EDN8C;;;ECU9C,QAAA,EAAU,cAAA,CAAe,CAAA;EACzB,WAAA,QAAmB,OAAA,CAAQ,cAAA,CAAe,CAAA;AAAA,MACtC,OAAA,CAAQ,aAAA,IAAiB,aAAA,IAC/B,aAAA;AAAA,KAEQ,kBAAA,WAA6B,MAAA,gBAAsB,MAAA;EDZ7D;;;ECgBA,EAAA;EDhBuD;AAuGzD;;ECnFE,MAAA;EDyFD;;;ECrFC,GAAA;IAAA,IACM,cAAA,CAAe,CAAA;IAAA,WACR,IAAA,CAAK,CAAA,QAAS,CAAA,GAAI,IAAA,EAAM,CAAA,GAAI,SAAA,CAAU,CAAA,EAAG,CAAA;EAAA;EAlD5C;;;EAuDV,WAAA,QAAmB,OAAA,CAAQ,cAAA,CAAe,CAAA;EAvDH;;;EA2DvC,KAAA,GACE,OAAA,EAAS,yBAAA,CAA0B,CAAA,GACnC,OAAA;IAAW,MAAA;MAAoB,QAAA;IAAA;EAAA;AAAA;AAAA,KAIvB,uBAAA;EACV,QAAA,EAAU,CAAA;EACV,EAAA;EACA,UAAA;EACA,IAAA;AAAA;AAAA,KAGU,iBAAA,UAA2B,KAAA,EAAO,CAAA,EAAG,MAAA,EAAQ,uBAAA,CAAwB,CAAA,MAAO,CAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"useOptimistic.d.ts","names":[],"sources":["../../src/react/useDocuments.ts","../../src/react/useOptimistic.ts"],"sourcesContent":[],"mappings":";;iBAoLgB,YAAA,CAAA;eACD;EADC,cAAA,EAEE,eADH;;iBC3KC,qBAAqB,6BACtB,YACJ,kBAAkB,GAAG,KAAK,MAAM,kBAAkB,GAAG,MAC7D"}
{"version":3,"file":"useOptimistic.d.ts","names":[],"sources":["../../src/react/useDocuments.ts","../../src/react/useOptimistic.ts"],"mappings":";;iBAoLgB,YAAA,CAAA;EACd,WAAA,EAAa,YAAA;EACb,cAAA,EAAgB,eAAA;AAAA;AAAA,iBC5KF,aAAA,QAAqB,cAAA,CAAA,CACnC,WAAA,EAAa,CAAA,EACb,OAAA,EAAS,iBAAA,CAAkB,CAAA,EAAG,CAAA,IAAK,KAAA,CAAM,iBAAA,CAAkB,CAAA,EAAG,CAAA,KAC7D,CAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"mutations.js","sources":["../../../../node_modules/.pnpm/@sanity+util@5.6.0_@types+react@19.2.7_debug@4.4.3/node_modules/@sanity/util/lib/paths.js","../../src/react/useOptimisticActor.ts","../../src/react/useDocuments.ts","../../src/util/randomKey.ts","../../src/util/mutations.ts"],"sourcesContent":["import { isIndexSegment, isKeySegment, isIndexTuple } from \"@sanity/types\";\nconst rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g, reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, EMPTY_PATH = [], FOCUS_TERMINATOR = \"$\", GROQ_DATA_TYPE_VALUES = [\"true\", \"false\", \"null\"];\nfunction get(obj, path, defaultVal) {\n const select = typeof path == \"string\" ? fromString(path) : path;\n if (!Array.isArray(select))\n throw new Error(\"Path must be an array or a string\");\n let acc = obj;\n for (let i = 0; i < select.length; i++) {\n const segment = select[i];\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc[segment];\n }\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc.find((item) => item._key === segment._key);\n }\n if (typeof segment == \"string\" && (acc = typeof acc == \"object\" && acc !== null ? acc[segment] : void 0), typeof acc > \"u\")\n return defaultVal;\n }\n return acc;\n}\nconst pathsMemo = /* @__PURE__ */ new Map();\nfunction pathFor(path) {\n if (path.length === 0)\n return EMPTY_PATH;\n const asString = toString(path);\n return pathsMemo.has(asString) ? pathsMemo.get(asString) : (pathsMemo.set(asString, path), Object.freeze(path), path);\n}\nfunction isEqual(path, otherPath) {\n return path.length === otherPath.length && path.every((segment, i) => isSegmentEqual(segment, otherPath[i]));\n}\nfunction numEqualSegments(path, otherPath) {\n const length = Math.min(path.length, otherPath.length);\n for (let i = 0; i < length; i++)\n if (!isSegmentEqual(path[i], otherPath[i]))\n return i;\n return length;\n}\nfunction isSegmentEqual(segmentA, segmentB) {\n return isKeySegment(segmentA) && isKeySegment(segmentB) ? segmentA._key === segmentB._key : isIndexSegment(segmentA) ? Number(segmentA) === Number(segmentB) : isIndexTuple(segmentA) && isIndexTuple(segmentB) ? segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1] : segmentA === segmentB;\n}\nfunction hasFocus(focusPath, path) {\n const withoutTerminator = focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath;\n return isEqual(withoutTerminator, path);\n}\nfunction hasItemFocus(focusPath, item) {\n return focusPath.length === 1 && isSegmentEqual(focusPath[0], item);\n}\nfunction isExpanded(segment, focusPath) {\n const [head, ...tail] = focusPath;\n return tail.length > 0 && isSegmentEqual(segment, head);\n}\nfunction startsWith(prefix, path) {\n return prefix.every((segment, i) => isSegmentEqual(segment, path[i]));\n}\nfunction trimLeft(prefix, path) {\n if (prefix.length === 0 || path.length === 0)\n return path;\n const [prefixHead, ...prefixTail] = prefix, [pathHead, ...pathTail] = path;\n return isSegmentEqual(prefixHead, pathHead) ? pathFor(trimLeft(prefixTail, pathTail)) : path;\n}\nfunction trimRight(suffix, path) {\n const sufLen = suffix.length, pathLen = path.length;\n if (sufLen === 0 || pathLen === 0)\n return path;\n let i = 0;\n for (; i < sufLen && i < pathLen && isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1]); )\n i++;\n return pathFor(path.slice(0, pathLen - i));\n}\nfunction trimChildPath(path, childPath) {\n return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const isHead = i === 0;\n if (typeof segment == \"number\")\n return `${target}[${segment}]`;\n if (typeof segment == \"string\")\n return isHead ? segment : GROQ_DATA_TYPE_VALUES.includes(segment) ? `${target}[\"${segment}\"]` : `${target}.${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nfunction _resolveKeyedPath(value, path) {\n if (path.length === 0)\n return path;\n const [next, ...rest] = path;\n if (typeof next == \"number\") {\n if (!Array.isArray(value) || !(next in value))\n return [];\n const item = value[next];\n return [typeof item?._key == \"string\" ? { _key: item._key } : next, ..._resolveKeyedPath(item, rest)];\n }\n const nextVal = get(value, [next]);\n return [next, ..._resolveKeyedPath(nextVal, rest)];\n}\nfunction resolveKeyedPath(value, path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return pathFor(_resolveKeyedPath(value, path));\n}\nfunction fromString(path) {\n if (typeof path != \"string\")\n throw new Error(\"Path is not a string\");\n const segments = path.match(rePropName);\n if (!segments)\n throw new Error(\"Invalid path string\");\n return segments.map(normalizePathSegment);\n}\nfunction normalizePathSegment(segment) {\n return isIndexSegment(segment) ? normalizeIndexSegment(segment) : isKeySegment(segment) ? normalizeKeySegment(segment) : isIndexTuple(segment) ? normalizeIndexTupleSegment(segment) : segment;\n}\nfunction normalizeIndexSegment(segment) {\n return Number(segment.replace(/[^\\d]/g, \"\"));\n}\nfunction normalizeKeySegment(segment) {\n return { _key: segment.match(reKeySegment)[1] };\n}\nfunction normalizeIndexTupleSegment(segment) {\n const [from, to] = segment.split(\":\").map((seg) => seg === \"\" ? seg : Number(seg));\n return [from, to];\n}\nexport {\n FOCUS_TERMINATOR,\n _resolveKeyedPath,\n fromString,\n get,\n hasFocus,\n hasItemFocus,\n isEqual,\n isExpanded,\n isSegmentEqual,\n numEqualSegments,\n pathFor,\n resolveKeyedPath,\n startsWith,\n toString,\n trimChildPath,\n trimLeft,\n trimRight\n};\n//# sourceMappingURL=paths.js.map\n","import {useCallback, useMemo, useSyncExternalStore} from 'react'\n\nimport {\n actor,\n emptyActor,\n isEmptyActor,\n listeners,\n type EmptyActor,\n type MutatorActor,\n} from '../optimistic/context'\n\nexport function useOptimisticActor(): MutatorActor | EmptyActor {\n const subscribe = useCallback((listener: () => void) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }, [])\n\n const actorRef = useSyncExternalStore(\n subscribe,\n () => actor,\n () => emptyActor,\n )\n\n return actorRef\n}\n\nexport function useOptimisticActorReady(): boolean {\n const actor = useOptimisticActor()\n return useMemo(() => !isEmptyActor(actor), [actor])\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {SanityDocument} from '@sanity/client'\n\nimport {getDraftId, getPublishedId} from '@sanity/client/csm'\nimport {createIfNotExists, patch} from '@sanity/mutate'\nimport {isMaybePreviewIframe, isMaybePreviewWindow} from '@sanity/presentation-comlink'\nimport {get as getAtPath} from '@sanity/util/paths'\nimport {useCallback} from 'react'\n\nimport type {\n DocumentsGet,\n DocumentsMutate,\n OptimisticDocumentPatches,\n Path,\n PathValue,\n} from '../optimistic/types'\n\nimport {isEmptyActor, type MutatorActor} from '../optimistic/context'\nimport {useOptimisticActor} from './useOptimisticActor'\n\nfunction debounce<F extends (...args: Parameters<F>) => ReturnType<F>>(fn: F, timeout: number): F {\n let timer: ReturnType<typeof setTimeout>\n return ((...args: Parameters<F>) => {\n clearTimeout(timer)\n timer = setTimeout(() => {\n fn.apply(fn, args)\n }, timeout)\n }) as F\n}\n\nfunction getDocumentsAndSnapshot<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n const inFrame = isMaybePreviewIframe()\n const inPopUp = isMaybePreviewWindow()\n\n if (isEmptyActor(actor) || (!inFrame && !inPopUp)) {\n throw new Error('The `useDocuments` hook cannot be used in this context')\n }\n\n const draftId = getDraftId(id)\n const publishedId = getPublishedId(id)\n const documents = actor.getSnapshot().context?.documents\n\n const draftDoc = documents?.[draftId]\n const publishedDoc = documents?.[publishedId]\n const doc = draftDoc || publishedDoc\n\n if (!doc) {\n throw new Error(`Document \"${id}\" not found`)\n }\n\n // Helper to get the snapshot from the draft document if it exists, otherwise\n // fall back to the published document\n const getDocumentSnapshot = () =>\n (draftDoc.getSnapshot().context?.local || publishedDoc.getSnapshot().context?.local) as\n | SanityDocument<T>\n | null\n | undefined\n\n const snapshot = getDocumentSnapshot()\n const snapshotPromise = new Promise<SanityDocument<T> | null>((resolve) => {\n if (snapshot) {\n resolve(snapshot)\n } else {\n const subscriber = doc.on('ready', (event) => {\n // Assert type here as the original document mutator machine doesn't\n // emit a 'ready' event. We provide a custom action to emit it in this\n // package's internal `createDatasetMutator` function. <3 xstate.\n const {snapshot} = event as unknown as {snapshot: SanityDocument<T> | null | undefined}\n resolve(snapshot || null)\n subscriber.unsubscribe()\n })\n }\n })\n\n const getSnapshot = () => snapshotPromise\n\n return {\n draftDoc,\n draftId,\n getSnapshot,\n publishedDoc,\n publishedId,\n /**\n * @deprecated - use `getSnapshot` instead\n */\n get snapshot() {\n // Maintain original error throwing behaviour, to avoid breaking changes\n if (!snapshot) {\n throw new Error(`Snapshot for document \"${id}\" not found`)\n }\n return snapshot\n },\n }\n}\n\nfunction createDocumentCommit<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return (): void => {\n const {draftDoc} = getDocumentsAndSnapshot<T>(id, actor)\n draftDoc.send({type: 'submit'})\n }\n}\n\n/**\n * @deprecated - superseded by `createDocumentGetSnapshot`\n */\nfunction createDocumentGet<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return <P extends Path<T, keyof T>>(\n path?: P,\n ): PathValue<T, P> | SanityDocument<T> | undefined => {\n const {snapshot} = getDocumentsAndSnapshot<T>(id, actor)\n\n return path\n ? (getAtPath(snapshot, path) as PathValue<T, P>)\n : (snapshot as unknown as SanityDocument<T>)\n }\n}\n\nfunction createDocumentGetSnapshot<T extends Record<string, any>>(\n id: string,\n actor: MutatorActor,\n): () => Promise<SanityDocument<T> | null> {\n const {getSnapshot} = getDocumentsAndSnapshot<T>(id, actor)\n return getSnapshot\n}\n\nfunction createDocumentPatch<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return async (\n patches: OptimisticDocumentPatches<T>,\n options?: {commit?: boolean | {debounce: number}},\n ): Promise<void> => {\n // Destructure the function result in two steps as we need access to the\n // `result.snapshot` property in the getter, but don't want to execute the\n // getter prematurely as it may throw\n const result = getDocumentsAndSnapshot<T>(id, actor)\n const {draftDoc, draftId, getSnapshot, publishedId} = result\n\n const {commit = true} = options || {}\n\n const context = {\n draftId,\n publishedId,\n /**\n * @deprecated - use `getSnapshot` instead\n */\n get snapshot() {\n return result.snapshot\n },\n getSnapshot,\n }\n\n const resolvedPatches = await (typeof patches === 'function' ? patches(context) : patches)\n\n const _snapshot = await getSnapshot()\n\n if (!_snapshot) {\n throw new Error(`Snapshot for document \"${id}\" not found`)\n }\n\n draftDoc.send({\n type: 'mutate',\n mutations: [\n // Attempt to create the draft document, it might not exist if the\n // snapshot was from the published document\n createIfNotExists({..._snapshot, _id: draftId}),\n // Patch the draft document with the resolved patches\n patch(draftId, resolvedPatches),\n ],\n })\n\n if (commit) {\n if (typeof commit === 'object' && 'debounce' in commit) {\n const debouncedCommit = debounce(() => draftDoc.send({type: 'submit'}), commit.debounce)\n debouncedCommit()\n } else {\n draftDoc.send({type: 'submit'})\n }\n }\n }\n}\n\nexport function useDocuments(): {\n getDocument: DocumentsGet\n mutateDocument: DocumentsMutate\n} {\n const actor = useOptimisticActor() as MutatorActor\n\n const getDocument: DocumentsGet = useCallback(\n <T extends Record<string, any>>(documentId: string) => {\n return {\n id: documentId,\n commit: createDocumentCommit(documentId, actor),\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Type instantiation is excessively deep and possibly infinite.\n get: createDocumentGet(documentId, actor),\n getSnapshot: createDocumentGetSnapshot<T>(documentId, actor),\n patch: createDocumentPatch<T>(documentId, actor),\n }\n },\n [actor],\n )\n\n const mutateDocument: DocumentsMutate = useCallback(\n (id, mutations, options) => {\n const {draftDoc} = getDocumentsAndSnapshot(id, actor)\n const {commit = true} = options || {}\n\n draftDoc.send({\n type: 'mutate',\n mutations: mutations,\n })\n\n if (commit) {\n if (typeof commit === 'object' && 'debounce' in commit) {\n const debouncedCommit = debounce(() => draftDoc.send({type: 'submit'}), commit.debounce)\n debouncedCommit()\n } else {\n draftDoc.send({type: 'submit'})\n }\n }\n },\n [actor],\n )\n\n return {getDocument, mutateDocument}\n}\n","// WHATWG crypto RNG - https://w3c.github.io/webcrypto/Overview.html\nfunction whatwgRNG(length = 16) {\n const rnds8 = new Uint8Array(length)\n crypto.getRandomValues(rnds8)\n return rnds8\n}\n\nconst getByteHexTable = (() => {\n let table: string[]\n return () => {\n if (table) {\n return table\n }\n table = []\n for (let i = 0; i < 256; ++i) {\n table[i] = (i + 0x100).toString(16).slice(1)\n }\n return table\n }\n})()\n\nexport function randomKey(length?: number): string {\n const table = getByteHexTable()\n return whatwgRNG(length)\n .reduce((str, n) => str + table[n], '')\n .slice(0, length)\n}\n","import type {SanityDocument} from '@sanity/client'\nimport type {SanityNode} from '@sanity/presentation-comlink'\n\nimport {at, insert, truncate, type NodePatchList} from '@sanity/mutate'\nimport {get} from '@sanity/util/paths'\n\nimport type {OptimisticDocument} from '../optimistic/types'\n\nimport {randomKey} from './randomKey'\n\nexport function getArrayItemKeyAndParentPath(pathOrNode: string | SanityNode): {\n path: string\n key: string\n hasExplicitKey: boolean\n} {\n const elementPath = typeof pathOrNode === 'string' ? pathOrNode : pathOrNode.path\n\n const lastDotIndex = elementPath.lastIndexOf('.')\n const lastPathItem = elementPath.substring(lastDotIndex + 1, elementPath.length)\n\n if (!lastPathItem.indexOf('[')) throw new Error('Invalid path: not an array')\n\n const lastArrayIndex = elementPath.lastIndexOf('[')\n const path = elementPath.substring(0, lastArrayIndex)\n\n let key\n let hasExplicitKey\n\n if (lastPathItem.includes('_key')) {\n // explicit [_key=\"...\"]\n\n const startIndex = lastPathItem.indexOf('\"') + 1\n const endIndex = lastPathItem.indexOf('\"', startIndex)\n\n key = lastPathItem.substring(startIndex, endIndex)\n\n hasExplicitKey = true\n } else {\n // indexes [int]\n const startIndex = lastPathItem.indexOf('[') + 1\n const endIndex = lastPathItem.indexOf(']', startIndex)\n\n key = lastPathItem.substring(startIndex, endIndex)\n\n hasExplicitKey = false\n }\n\n if (!path || !key) throw new Error('Invalid path')\n\n return {\n path,\n key,\n hasExplicitKey,\n }\n}\n\nexport function getArrayDuplicatePatches(\n node: SanityNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: SanityDocument<Record<string, any>>,\n position: 'before' | 'after' = 'after',\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n\n const item = get(snapshot, node.path) as object\n const duplicate = {...item, _key: randomKey()}\n\n return [at(arrayPath, insert(duplicate, position, {_key: itemKey}))]\n}\n\nexport function getArrayRemovePatches(\n node: SanityNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: SanityDocument<Record<string, any>>,\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n const array = get(snapshot, arrayPath) as {_key: string}[]\n const currentIndex = array.findIndex((item) => item._key === itemKey)\n return [at(arrayPath, truncate(currentIndex, currentIndex + 1))]\n}\n\nexport function getArrayInsertPatches(\n node: SanityNode,\n insertType: string,\n position: 'before' | 'after',\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n const insertKey = randomKey()\n const referenceItem = {_key: itemKey}\n return [at(arrayPath, insert([{_type: insertType, _key: insertKey}], position, referenceItem))]\n}\n\nexport async function getArrayMovePatches(\n node: SanityNode,\n doc: OptimisticDocument,\n moveTo: 'previous' | 'next' | 'first' | 'last',\n): Promise<NodePatchList> {\n if (!node.type) throw new Error('Node type is missing')\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n\n const snapshot = await doc.getSnapshot()\n const array = get(snapshot, arrayPath) as {_key: string}[]\n const item = get(snapshot, node.path)\n const currentIndex = array.findIndex((item) => item._key === itemKey)\n\n let nextIndex = -1\n let position: 'before' | 'after' = 'before'\n\n if (moveTo === 'first') {\n if (currentIndex === 0) return []\n nextIndex = 0\n position = 'before'\n } else if (moveTo === 'last') {\n if (currentIndex === array.length - 1) return []\n nextIndex = -1\n position = 'after'\n } else if (moveTo === 'next') {\n if (currentIndex === array.length - 1) return []\n nextIndex = currentIndex\n position = 'after'\n } else if (moveTo === 'previous') {\n if (currentIndex === 0) return []\n nextIndex = currentIndex - 1\n position = 'before'\n }\n\n return [\n at(arrayPath, truncate(currentIndex, currentIndex + 1)),\n at(arrayPath, insert(item, position, nextIndex)),\n ]\n}\n"],"names":["rePropName","reKeySegment","get","obj","path","defaultVal","select","fromString","Array","isArray","Error","acc","i","length","segment","isIndexSegment","isKeySegment","find","item","_key","segments","match","map","normalizePathSegment","normalizeIndexSegment","normalizeKeySegment","isIndexTuple","normalizeIndexTupleSegment","Number","replace","from","to","split","seg","useOptimisticActor","useSyncExternalStore","_temp","_temp2","_temp3","emptyActor","actor","listener","listeners","add","delete","useOptimisticActorReady","$","_c","t0","isEmptyActor","debounce","fn","timeout","timer","args","clearTimeout","setTimeout","apply","getDocumentsAndSnapshot","id","inFrame","isMaybePreviewIframe","inPopUp","isMaybePreviewWindow","draftId","getDraftId","publishedId","getPublishedId","documents","getSnapshot","context","draftDoc","publishedDoc","doc","snapshot","local","snapshotPromise","Promise","resolve","subscriber","on","event","unsubscribe","createDocumentCommit","send","type","createDocumentGet","getAtPath","createDocumentGetSnapshot","createDocumentPatch","patches","options","result","commit","resolvedPatches","_snapshot","mutations","createIfNotExists","_id","patch","useDocuments","documentId","getDocument","t1","t2","undefined","mutateDocument","whatwgRNG","rnds8","Uint8Array","crypto","getRandomValues","getByteHexTable","table","toString","slice","randomKey","reduce","str","n","getArrayItemKeyAndParentPath","pathOrNode","elementPath","lastDotIndex","lastIndexOf","lastPathItem","substring","indexOf","lastArrayIndex","key","hasExplicitKey","includes","startIndex","endIndex","getArrayDuplicatePatches","node","position","arrayPath","itemKey","duplicate","at","insert","getArrayRemovePatches","currentIndex","findIndex","truncate","getArrayInsertPatches","insertType","insertKey","_type","getArrayMovePatches","moveTo","array","nextIndex"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAMA,aACJ,oGACIC,eAAe;AAWd,SAASC,IAAIC,KAAcC,MAAqBC,YAA+B;AACpF,QAAMC,SAAS,OAAOF,QAAS,WAAWG,WAAWH,IAAI,IAAIA;AAC7D,MAAI,CAACI,MAAMC,QAAQH,MAAM,EACvB,OAAM,IAAII,MAAM,mCAAmC;AAGrD,MAAIC,MAAeR;AACnB,WAASS,IAAI,GAAGA,IAAIN,OAAOO,QAAQD,KAAK;AACtC,UAAME,UAAUR,OAAOM,CAAC;AACxB,QAAIG,eAAeD,OAAO,GAAG;AAC3B,UAAI,CAACN,MAAMC,QAAQE,GAAG,EACpB,QAAON;AAGTM,YAAMA,IAAIG,OAAO;AAAA,IACnB;AAEA,QAAIE,aAAaF,OAAO,GAAG;AACzB,UAAI,CAACN,MAAMC,QAAQE,GAAG,EACpB,QAAON;AAGTM,YAAMA,IAAIM,KAAMC,UAASA,KAAKC,SAASL,QAAQK,IAAI;AAAA,IACrD;AASA,QAPI,OAAOL,WAAY,aACrBH,MACE,OAAOA,OAAQ,YAAYA,QAAQ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WAAW;AAAA,EACb,WAAWe,WAAW,YAAY;AAChC,QAAIR,iBAAiB,EAAG,QAAO,CAAA;AAC/BU,gBAAYV,eAAe,GAC3BP,WAAW;AAAA,EACb;AAEA,SAAO,CACLI,GAAGH,WAAWQ,SAASF,cAAcA,eAAe,CAAC,CAAC,GACtDH,GAAGH,WAAWI,OAAO3H,MAAMsH,UAAUiB,SAAS,CAAC,CAAC;AAEpD;","x_google_ignoreList":[0]}
{"version":3,"file":"mutations.js","sources":["../../../../node_modules/.pnpm/@sanity+util@5.7.0_@types+react@19.2.10_debug@4.4.3/node_modules/@sanity/util/lib/paths.js","../../src/react/useOptimisticActor.ts","../../src/react/useDocuments.ts","../../src/util/randomKey.ts","../../src/util/mutations.ts"],"sourcesContent":["import { isIndexSegment, isKeySegment, isIndexTuple } from \"@sanity/types\";\nconst rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g, reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/, EMPTY_PATH = [], FOCUS_TERMINATOR = \"$\", GROQ_DATA_TYPE_VALUES = [\"true\", \"false\", \"null\"];\nfunction get(obj, path, defaultVal) {\n const select = typeof path == \"string\" ? fromString(path) : path;\n if (!Array.isArray(select))\n throw new Error(\"Path must be an array or a string\");\n let acc = obj;\n for (let i = 0; i < select.length; i++) {\n const segment = select[i];\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc[segment];\n }\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc))\n return defaultVal;\n acc = acc.find((item) => item._key === segment._key);\n }\n if (typeof segment == \"string\" && (acc = typeof acc == \"object\" && acc !== null ? acc[segment] : void 0), typeof acc > \"u\")\n return defaultVal;\n }\n return acc;\n}\nconst pathsMemo = /* @__PURE__ */ new Map();\nfunction pathFor(path) {\n if (path.length === 0)\n return EMPTY_PATH;\n const asString = toString(path);\n return pathsMemo.has(asString) ? pathsMemo.get(asString) : (pathsMemo.set(asString, path), Object.freeze(path), path);\n}\nfunction isEqual(path, otherPath) {\n return path.length === otherPath.length && path.every((segment, i) => isSegmentEqual(segment, otherPath[i]));\n}\nfunction numEqualSegments(path, otherPath) {\n const length = Math.min(path.length, otherPath.length);\n for (let i = 0; i < length; i++)\n if (!isSegmentEqual(path[i], otherPath[i]))\n return i;\n return length;\n}\nfunction isSegmentEqual(segmentA, segmentB) {\n return isKeySegment(segmentA) && isKeySegment(segmentB) ? segmentA._key === segmentB._key : isIndexSegment(segmentA) ? Number(segmentA) === Number(segmentB) : isIndexTuple(segmentA) && isIndexTuple(segmentB) ? segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1] : segmentA === segmentB;\n}\nfunction hasFocus(focusPath, path) {\n const withoutTerminator = focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath;\n return isEqual(withoutTerminator, path);\n}\nfunction hasItemFocus(focusPath, item) {\n return focusPath.length === 1 && isSegmentEqual(focusPath[0], item);\n}\nfunction isExpanded(segment, focusPath) {\n const [head, ...tail] = focusPath;\n return tail.length > 0 && isSegmentEqual(segment, head);\n}\nfunction startsWith(prefix, path) {\n return prefix.every((segment, i) => isSegmentEqual(segment, path[i]));\n}\nfunction trimLeft(prefix, path) {\n if (prefix.length === 0 || path.length === 0)\n return path;\n const [prefixHead, ...prefixTail] = prefix, [pathHead, ...pathTail] = path;\n return isSegmentEqual(prefixHead, pathHead) ? pathFor(trimLeft(prefixTail, pathTail)) : path;\n}\nfunction trimRight(suffix, path) {\n const sufLen = suffix.length, pathLen = path.length;\n if (sufLen === 0 || pathLen === 0)\n return path;\n let i = 0;\n for (; i < sufLen && i < pathLen && isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1]); )\n i++;\n return pathFor(path.slice(0, pathLen - i));\n}\nfunction trimChildPath(path, childPath) {\n return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const isHead = i === 0;\n if (typeof segment == \"number\")\n return `${target}[${segment}]`;\n if (typeof segment == \"string\")\n return isHead ? segment : GROQ_DATA_TYPE_VALUES.includes(segment) ? `${target}[\"${segment}\"]` : `${target}.${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nfunction _resolveKeyedPath(value, path) {\n if (path.length === 0)\n return path;\n const [next, ...rest] = path;\n if (typeof next == \"number\") {\n if (!Array.isArray(value) || !(next in value))\n return [];\n const item = value[next];\n return [typeof item?._key == \"string\" ? { _key: item._key } : next, ..._resolveKeyedPath(item, rest)];\n }\n const nextVal = get(value, [next]);\n return [next, ..._resolveKeyedPath(nextVal, rest)];\n}\nfunction resolveKeyedPath(value, path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return pathFor(_resolveKeyedPath(value, path));\n}\nfunction fromString(path) {\n if (typeof path != \"string\")\n throw new Error(\"Path is not a string\");\n const segments = path.match(rePropName);\n if (!segments)\n throw new Error(\"Invalid path string\");\n return segments.map(normalizePathSegment);\n}\nfunction normalizePathSegment(segment) {\n return isIndexSegment(segment) ? normalizeIndexSegment(segment) : isKeySegment(segment) ? normalizeKeySegment(segment) : isIndexTuple(segment) ? normalizeIndexTupleSegment(segment) : segment;\n}\nfunction normalizeIndexSegment(segment) {\n return Number(segment.replace(/[^\\d]/g, \"\"));\n}\nfunction normalizeKeySegment(segment) {\n return { _key: segment.match(reKeySegment)[1] };\n}\nfunction normalizeIndexTupleSegment(segment) {\n const [from, to] = segment.split(\":\").map((seg) => seg === \"\" ? seg : Number(seg));\n return [from, to];\n}\nexport {\n FOCUS_TERMINATOR,\n _resolveKeyedPath,\n fromString,\n get,\n hasFocus,\n hasItemFocus,\n isEqual,\n isExpanded,\n isSegmentEqual,\n numEqualSegments,\n pathFor,\n resolveKeyedPath,\n startsWith,\n toString,\n trimChildPath,\n trimLeft,\n trimRight\n};\n//# sourceMappingURL=paths.js.map\n","import {useCallback, useMemo, useSyncExternalStore} from 'react'\n\nimport {\n actor,\n emptyActor,\n isEmptyActor,\n listeners,\n type EmptyActor,\n type MutatorActor,\n} from '../optimistic/context'\n\nexport function useOptimisticActor(): MutatorActor | EmptyActor {\n const subscribe = useCallback((listener: () => void) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n }, [])\n\n const actorRef = useSyncExternalStore(\n subscribe,\n () => actor,\n () => emptyActor,\n )\n\n return actorRef\n}\n\nexport function useOptimisticActorReady(): boolean {\n const actor = useOptimisticActor()\n return useMemo(() => !isEmptyActor(actor), [actor])\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {SanityDocument} from '@sanity/client'\n\nimport {getDraftId, getPublishedId} from '@sanity/client/csm'\nimport {createIfNotExists, patch} from '@sanity/mutate'\nimport {isMaybePreviewIframe, isMaybePreviewWindow} from '@sanity/presentation-comlink'\nimport {get as getAtPath} from '@sanity/util/paths'\nimport {useCallback} from 'react'\n\nimport type {\n DocumentsGet,\n DocumentsMutate,\n OptimisticDocumentPatches,\n Path,\n PathValue,\n} from '../optimistic/types'\n\nimport {isEmptyActor, type MutatorActor} from '../optimistic/context'\nimport {useOptimisticActor} from './useOptimisticActor'\n\nfunction debounce<F extends (...args: Parameters<F>) => ReturnType<F>>(fn: F, timeout: number): F {\n let timer: ReturnType<typeof setTimeout>\n return ((...args: Parameters<F>) => {\n clearTimeout(timer)\n timer = setTimeout(() => {\n fn.apply(fn, args)\n }, timeout)\n }) as F\n}\n\nfunction getDocumentsAndSnapshot<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n const inFrame = isMaybePreviewIframe()\n const inPopUp = isMaybePreviewWindow()\n\n if (isEmptyActor(actor) || (!inFrame && !inPopUp)) {\n throw new Error('The `useDocuments` hook cannot be used in this context')\n }\n\n const draftId = getDraftId(id)\n const publishedId = getPublishedId(id)\n const documents = actor.getSnapshot().context?.documents\n\n const draftDoc = documents?.[draftId]\n const publishedDoc = documents?.[publishedId]\n const doc = draftDoc || publishedDoc\n\n if (!doc) {\n throw new Error(`Document \"${id}\" not found`)\n }\n\n // Helper to get the snapshot from the draft document if it exists, otherwise\n // fall back to the published document\n const getDocumentSnapshot = () =>\n (draftDoc.getSnapshot().context?.local || publishedDoc.getSnapshot().context?.local) as\n | SanityDocument<T>\n | null\n | undefined\n\n const snapshot = getDocumentSnapshot()\n const snapshotPromise = new Promise<SanityDocument<T> | null>((resolve) => {\n if (snapshot) {\n resolve(snapshot)\n } else {\n const subscriber = doc.on('ready', (event) => {\n // Assert type here as the original document mutator machine doesn't\n // emit a 'ready' event. We provide a custom action to emit it in this\n // package's internal `createDatasetMutator` function. <3 xstate.\n const {snapshot} = event as unknown as {snapshot: SanityDocument<T> | null | undefined}\n resolve(snapshot || null)\n subscriber.unsubscribe()\n })\n }\n })\n\n const getSnapshot = () => snapshotPromise\n\n return {\n draftDoc,\n draftId,\n getSnapshot,\n publishedDoc,\n publishedId,\n /**\n * @deprecated - use `getSnapshot` instead\n */\n get snapshot() {\n // Maintain original error throwing behaviour, to avoid breaking changes\n if (!snapshot) {\n throw new Error(`Snapshot for document \"${id}\" not found`)\n }\n return snapshot\n },\n }\n}\n\nfunction createDocumentCommit<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return (): void => {\n const {draftDoc} = getDocumentsAndSnapshot<T>(id, actor)\n draftDoc.send({type: 'submit'})\n }\n}\n\n/**\n * @deprecated - superseded by `createDocumentGetSnapshot`\n */\nfunction createDocumentGet<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return <P extends Path<T, keyof T>>(\n path?: P,\n ): PathValue<T, P> | SanityDocument<T> | undefined => {\n const {snapshot} = getDocumentsAndSnapshot<T>(id, actor)\n\n return path\n ? (getAtPath(snapshot, path) as PathValue<T, P>)\n : (snapshot as unknown as SanityDocument<T>)\n }\n}\n\nfunction createDocumentGetSnapshot<T extends Record<string, any>>(\n id: string,\n actor: MutatorActor,\n): () => Promise<SanityDocument<T> | null> {\n const {getSnapshot} = getDocumentsAndSnapshot<T>(id, actor)\n return getSnapshot\n}\n\nfunction createDocumentPatch<T extends Record<string, any>>(id: string, actor: MutatorActor) {\n return async (\n patches: OptimisticDocumentPatches<T>,\n options?: {commit?: boolean | {debounce: number}},\n ): Promise<void> => {\n // Destructure the function result in two steps as we need access to the\n // `result.snapshot` property in the getter, but don't want to execute the\n // getter prematurely as it may throw\n const result = getDocumentsAndSnapshot<T>(id, actor)\n const {draftDoc, draftId, getSnapshot, publishedId} = result\n\n const {commit = true} = options || {}\n\n const context = {\n draftId,\n publishedId,\n /**\n * @deprecated - use `getSnapshot` instead\n */\n get snapshot() {\n return result.snapshot\n },\n getSnapshot,\n }\n\n const resolvedPatches = await (typeof patches === 'function' ? patches(context) : patches)\n\n const _snapshot = await getSnapshot()\n\n if (!_snapshot) {\n throw new Error(`Snapshot for document \"${id}\" not found`)\n }\n\n draftDoc.send({\n type: 'mutate',\n mutations: [\n // Attempt to create the draft document, it might not exist if the\n // snapshot was from the published document\n createIfNotExists({..._snapshot, _id: draftId}),\n // Patch the draft document with the resolved patches\n patch(draftId, resolvedPatches),\n ],\n })\n\n if (commit) {\n if (typeof commit === 'object' && 'debounce' in commit) {\n const debouncedCommit = debounce(() => draftDoc.send({type: 'submit'}), commit.debounce)\n debouncedCommit()\n } else {\n draftDoc.send({type: 'submit'})\n }\n }\n }\n}\n\nexport function useDocuments(): {\n getDocument: DocumentsGet\n mutateDocument: DocumentsMutate\n} {\n const actor = useOptimisticActor() as MutatorActor\n\n const getDocument: DocumentsGet = useCallback(\n <T extends Record<string, any>>(documentId: string) => {\n return {\n id: documentId,\n commit: createDocumentCommit(documentId, actor),\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Type instantiation is excessively deep and possibly infinite.\n get: createDocumentGet(documentId, actor),\n getSnapshot: createDocumentGetSnapshot<T>(documentId, actor),\n patch: createDocumentPatch<T>(documentId, actor),\n }\n },\n [actor],\n )\n\n const mutateDocument: DocumentsMutate = useCallback(\n (id, mutations, options) => {\n const {draftDoc} = getDocumentsAndSnapshot(id, actor)\n const {commit = true} = options || {}\n\n draftDoc.send({\n type: 'mutate',\n mutations: mutations,\n })\n\n if (commit) {\n if (typeof commit === 'object' && 'debounce' in commit) {\n const debouncedCommit = debounce(() => draftDoc.send({type: 'submit'}), commit.debounce)\n debouncedCommit()\n } else {\n draftDoc.send({type: 'submit'})\n }\n }\n },\n [actor],\n )\n\n return {getDocument, mutateDocument}\n}\n","// WHATWG crypto RNG - https://w3c.github.io/webcrypto/Overview.html\nfunction whatwgRNG(length = 16) {\n const rnds8 = new Uint8Array(length)\n crypto.getRandomValues(rnds8)\n return rnds8\n}\n\nconst getByteHexTable = (() => {\n let table: string[]\n return () => {\n if (table) {\n return table\n }\n table = []\n for (let i = 0; i < 256; ++i) {\n table[i] = (i + 0x100).toString(16).slice(1)\n }\n return table\n }\n})()\n\nexport function randomKey(length?: number): string {\n const table = getByteHexTable()\n return whatwgRNG(length)\n .reduce((str, n) => str + table[n], '')\n .slice(0, length)\n}\n","import type {SanityDocument} from '@sanity/client'\nimport type {SanityNode} from '@sanity/presentation-comlink'\n\nimport {at, insert, truncate, type NodePatchList} from '@sanity/mutate'\nimport {get} from '@sanity/util/paths'\n\nimport type {OptimisticDocument} from '../optimistic/types'\n\nimport {randomKey} from './randomKey'\n\nexport function getArrayItemKeyAndParentPath(pathOrNode: string | SanityNode): {\n path: string\n key: string\n hasExplicitKey: boolean\n} {\n const elementPath = typeof pathOrNode === 'string' ? pathOrNode : pathOrNode.path\n\n const lastDotIndex = elementPath.lastIndexOf('.')\n const lastPathItem = elementPath.substring(lastDotIndex + 1, elementPath.length)\n\n if (!lastPathItem.indexOf('[')) throw new Error('Invalid path: not an array')\n\n const lastArrayIndex = elementPath.lastIndexOf('[')\n const path = elementPath.substring(0, lastArrayIndex)\n\n let key\n let hasExplicitKey\n\n if (lastPathItem.includes('_key')) {\n // explicit [_key=\"...\"]\n\n const startIndex = lastPathItem.indexOf('\"') + 1\n const endIndex = lastPathItem.indexOf('\"', startIndex)\n\n key = lastPathItem.substring(startIndex, endIndex)\n\n hasExplicitKey = true\n } else {\n // indexes [int]\n const startIndex = lastPathItem.indexOf('[') + 1\n const endIndex = lastPathItem.indexOf(']', startIndex)\n\n key = lastPathItem.substring(startIndex, endIndex)\n\n hasExplicitKey = false\n }\n\n if (!path || !key) throw new Error('Invalid path')\n\n return {\n path,\n key,\n hasExplicitKey,\n }\n}\n\nexport function getArrayDuplicatePatches(\n node: SanityNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: SanityDocument<Record<string, any>>,\n position: 'before' | 'after' = 'after',\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n\n const item = get(snapshot, node.path) as object\n const duplicate = {...item, _key: randomKey()}\n\n return [at(arrayPath, insert(duplicate, position, {_key: itemKey}))]\n}\n\nexport function getArrayRemovePatches(\n node: SanityNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: SanityDocument<Record<string, any>>,\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n const array = get(snapshot, arrayPath) as {_key: string}[]\n const currentIndex = array.findIndex((item) => item._key === itemKey)\n return [at(arrayPath, truncate(currentIndex, currentIndex + 1))]\n}\n\nexport function getArrayInsertPatches(\n node: SanityNode,\n insertType: string,\n position: 'before' | 'after',\n): NodePatchList {\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n const insertKey = randomKey()\n const referenceItem = {_key: itemKey}\n return [at(arrayPath, insert([{_type: insertType, _key: insertKey}], position, referenceItem))]\n}\n\nexport async function getArrayMovePatches(\n node: SanityNode,\n doc: OptimisticDocument,\n moveTo: 'previous' | 'next' | 'first' | 'last',\n): Promise<NodePatchList> {\n if (!node.type) throw new Error('Node type is missing')\n const {path: arrayPath, key: itemKey} = getArrayItemKeyAndParentPath(node)\n\n const snapshot = await doc.getSnapshot()\n const array = get(snapshot, arrayPath) as {_key: string}[]\n const item = get(snapshot, node.path)\n const currentIndex = array.findIndex((item) => item._key === itemKey)\n\n let nextIndex = -1\n let position: 'before' | 'after' = 'before'\n\n if (moveTo === 'first') {\n if (currentIndex === 0) return []\n nextIndex = 0\n position = 'before'\n } else if (moveTo === 'last') {\n if (currentIndex === array.length - 1) return []\n nextIndex = -1\n position = 'after'\n } else if (moveTo === 'next') {\n if (currentIndex === array.length - 1) return []\n nextIndex = currentIndex\n position = 'after'\n } else if (moveTo === 'previous') {\n if (currentIndex === 0) return []\n nextIndex = currentIndex - 1\n position = 'before'\n }\n\n return [\n at(arrayPath, truncate(currentIndex, currentIndex + 1)),\n at(arrayPath, insert(item, position, nextIndex)),\n ]\n}\n"],"names":["rePropName","reKeySegment","get","obj","path","defaultVal","select","fromString","Array","isArray","Error","acc","i","length","segment","isIndexSegment","isKeySegment","find","item","_key","segments","match","map","normalizePathSegment","normalizeIndexSegment","normalizeKeySegment","isIndexTuple","normalizeIndexTupleSegment","Number","replace","from","to","split","seg","useOptimisticActor","useSyncExternalStore","_temp","_temp2","_temp3","emptyActor","actor","listener","listeners","add","delete","useOptimisticActorReady","$","_c","t0","isEmptyActor","debounce","fn","timeout","timer","args","clearTimeout","setTimeout","apply","getDocumentsAndSnapshot","id","inFrame","isMaybePreviewIframe","inPopUp","isMaybePreviewWindow","draftId","getDraftId","publishedId","getPublishedId","documents","getSnapshot","context","draftDoc","publishedDoc","doc","snapshot","local","snapshotPromise","Promise","resolve","subscriber","on","event","unsubscribe","createDocumentCommit","send","type","createDocumentGet","getAtPath","createDocumentGetSnapshot","createDocumentPatch","patches","options","result","commit","resolvedPatches","_snapshot","mutations","createIfNotExists","_id","patch","useDocuments","documentId","getDocument","t1","t2","undefined","mutateDocument","whatwgRNG","rnds8","Uint8Array","crypto","getRandomValues","getByteHexTable","table","toString","slice","randomKey","reduce","str","n","getArrayItemKeyAndParentPath","pathOrNode","elementPath","lastDotIndex","lastIndexOf","lastPathItem","substring","indexOf","lastArrayIndex","key","hasExplicitKey","includes","startIndex","endIndex","getArrayDuplicatePatches","node","position","arrayPath","itemKey","duplicate","at","insert","getArrayRemovePatches","currentIndex","findIndex","truncate","getArrayInsertPatches","insertType","insertKey","_type","getArrayMovePatches","moveTo","array","nextIndex"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAMA,aACJ,oGACIC,eAAe;AAWd,SAASC,IAAIC,KAAcC,MAAqBC,YAA+B;AACpF,QAAMC,SAAS,OAAOF,QAAS,WAAWG,WAAWH,IAAI,IAAIA;AAC7D,MAAI,CAACI,MAAMC,QAAQH,MAAM,EACvB,OAAM,IAAII,MAAM,mCAAmC;AAGrD,MAAIC,MAAeR;AACnB,WAASS,IAAI,GAAGA,IAAIN,OAAOO,QAAQD,KAAK;AACtC,UAAME,UAAUR,OAAOM,CAAC;AACxB,QAAIG,eAAeD,OAAO,GAAG;AAC3B,UAAI,CAACN,MAAMC,QAAQE,GAAG,EACpB,QAAON;AAGTM,YAAMA,IAAIG,OAAO;AAAA,IACnB;AAEA,QAAIE,aAAaF,OAAO,GAAG;AACzB,UAAI,CAACN,MAAMC,QAAQE,GAAG,EACpB,QAAON;AAGTM,YAAMA,IAAIM,KAAMC,UAASA,KAAKC,SAASL,QAAQK,IAAI;AAAA,IACrD;AASA,QAPI,OAAOL,WAAY,aACrBH,MACE,OAAOA,OAAQ,YAAYA,QAAQ,OAC7BA,IAAgCG,OAAO,IACzC,SAGJ,OAAOH,MAAQ,IACjB,QAAON;AAAAA,EAEX;AAEA,SAAOM;AACT;AAgLO,SAASJ,WAAWH,MAAoB;AAC7C,MAAI,OAAOA,QAAS,SAClB,OAAM,IA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AcA,eAAe,CAAC,CAAC,GACtDH,GAAGH,WAAWI,OAAO3H,MAAMsH,UAAUiB,SAAS,CAAC,CAAC;AAEpD;","x_google_ignoreList":[0]}

@@ -45,3 +45,3 @@ import { createContext, useContext } from "react";

scrollbar-width: none;
&:before {

@@ -48,0 +48,0 @@ content: '';

@@ -1,1 +0,1 @@

{"version":3,"file":"PointerEvents.js","sources":["../../src/util/getNodeIcon.tsx","../../src/ui/PopoverPortal.tsx","../../src/ui/telemetry/TelemetryContext.tsx","../../src/ui/telemetry/useTelemetry.tsx","../../src/overlay-components/components/InsertMenu.tsx","../../src/overlay-components/components/PointerEvents.tsx"],"sourcesContent":["import type {\n SchemaArrayItem,\n SchemaNumberNode,\n SchemaObjectField,\n SchemaStringNode,\n SchemaUnionOption,\n} from '@sanity/presentation-comlink'\n\nimport {\n BlockContentIcon,\n CheckmarkCircleIcon,\n CubeIcon,\n ImageIcon,\n NumberIcon,\n StringIcon,\n ThListIcon,\n} from '@sanity/icons'\n\ntype Option =\n | SchemaNumberNode\n | SchemaStringNode\n | SchemaArrayItem\n | SchemaObjectField\n | SchemaUnionOption\n\nexport function getNodeIcon(option: Option | undefined): React.JSX.Element {\n if (!option) return <CubeIcon />\n\n if (option.type === 'string') {\n return <StringIcon />\n }\n\n if (option.type === 'number') {\n return <NumberIcon />\n }\n\n const {value: node} = option\n\n if ('icon' in option && option.icon) {\n return <div dangerouslySetInnerHTML={{__html: option.icon}} />\n }\n\n const {type} = node\n\n if (type === 'string') {\n return <StringIcon />\n }\n\n if (type === 'boolean') {\n return <CheckmarkCircleIcon />\n }\n\n if (type === 'number') {\n return <NumberIcon />\n }\n\n if (type === 'array' || type === 'union') {\n const of = Array.isArray(node.of) ? node.of : [node.of]\n if (of.some((n) => 'name' in n && n.name === 'block')) {\n return <BlockContentIcon />\n }\n return <ThListIcon />\n }\n\n if (type === 'object') {\n if (option.name === 'image') {\n return <ImageIcon />\n }\n if (option.name === 'block') {\n return <StringIcon />\n }\n }\n\n return <CubeIcon />\n}\n","import {Portal} from '@sanity/ui/_visual-editing'\nimport {type FunctionComponent, type MouseEvent} from 'react'\nimport {css, styled} from 'styled-components'\n\nconst scrollBlockStyles = css`\n overflow-y: scroll;\n overscroll-behavior: contain;\n -ms-overflow-style: none;\n scrollbar-width: none;\n \n &:before {\n content: '';\n display: block;\n height: calc(100% + 1px);\n position: absolute;\n top: 0;\n width: 100%;\n z-index: -1;\n }\n`\n\nconst PortalContainer = styled.div<{$blockScroll: boolean}>`\n height: 100%;\n inset: 0;\n pointer-events: all;\n position: fixed;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n\n ${(props) => props.$blockScroll && scrollBlockStyles}\n`\nconst PortalBackground = styled.div`\n background: transparent;\n height: 100%;\n inset: 0;\n position: absolute;\n width: 100%;\n`\n\ntype PopoverPortalProps = {\n children?: React.ReactNode\n onDismiss?: () => void\n setBoundaryElement?: (element: HTMLDivElement) => void\n blockScroll?: boolean\n}\n\nexport const PopoverPortal: FunctionComponent<PopoverPortalProps> = (props) => {\n return (\n <Portal>\n <PopoverBackground {...props} />\n </Portal>\n )\n}\n\nexport const PopoverBackground: FunctionComponent<{\n children?: React.ReactNode\n onDismiss?: () => void\n setBoundaryElement?: (element: HTMLDivElement) => void\n blockScroll?: boolean\n}> = (props) => {\n const {children, onDismiss, setBoundaryElement, blockScroll = true} = props\n\n // Prevent the event from propagating to the window, so that the controller's\n // `handleBlur` listener is not triggered. This is needed to prevent the\n // context menu from being dismissed when some click causes parent elements to\n // re-render, and the data-attribute method of preventing propagation fails.\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation()\n }\n\n return (\n <PortalContainer\n data-sanity-overlay-element\n ref={setBoundaryElement}\n onClick={handleClick}\n $blockScroll={blockScroll}\n >\n <PortalBackground\n onMouseDownCapture={() => {\n onDismiss?.()\n }}\n />\n {children}\n </PortalContainer>\n )\n}\n","import {defineEvent} from '@sanity/telemetry'\nimport {createContext} from 'react'\n\nexport const events = {\n 'Visual Editing Drag Sequence Completed': defineEvent({\n name: 'Visual Editing Drag Sequence Completed',\n description: 'An array is successfully reordered using drag and drop.',\n version: 1,\n }),\n 'Visual Editing Drag Minimap Enabled': defineEvent({\n name: 'Visual Editing Drag Minimap Enabled',\n description: 'The zoomed-out minimap view is enabled during a drag sequence.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Removed': defineEvent({\n name: 'Visual Editing Context Menu Item Removed',\n description: 'An item is removed using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Duplicated': defineEvent({\n name: 'Visual Editing Context Menu Item Duplicated',\n description: 'An item is duplicated using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Moved': defineEvent({\n name: 'Visual Editing Context Menu Item Moved',\n description: 'An item is moved using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Inserted': defineEvent({\n name: 'Visual Editing Context Menu Item Inserted',\n description: 'An item is inserted using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Insert Menu Item Inserted': defineEvent({\n name: 'Visual Editing Insert Menu Item Inserted',\n description: 'An item is inserted using the Insert Menu.',\n version: 1,\n }),\n 'Visual Editing Overlay Clicked': defineEvent({\n name: 'Visual Editing Overlay Clicked',\n description: 'An Overlay is clicked.',\n version: 1,\n }),\n}\n\ntype EventDataMap = {\n [K in keyof typeof events]: (typeof events)[K] extends ReturnType<typeof defineEvent<infer T>>\n ? T\n : never\n}\n\nexport type TelemetryEventNames = keyof typeof events\n\nexport type TelemetryContextValue = <K extends keyof typeof events>(\n name: K,\n data: EventDataMap[K] extends void ? null | undefined : EventDataMap[K],\n) => void\n\nexport const TelemetryContext = createContext<TelemetryContextValue | undefined>(undefined)\n","import {useContext} from 'react'\n\nimport {TelemetryContext, type TelemetryContextValue} from './TelemetryContext'\n\nexport function useTelemetry(): TelemetryContextValue {\n const context = useContext(TelemetryContext)\n\n if (!context) {\n throw new Error('Telemetry context is missing')\n }\n\n return context\n}\n","import type {InsertMenuOptions} from '@sanity/insert-menu'\nimport type {SchemaUnionNode} from '@sanity/presentation-comlink'\nimport type {SchemaType} from '@sanity/types'\n\nimport {InsertMenu as SanityInsertMenu} from '@sanity/insert-menu'\nimport {Popover} from '@sanity/ui/_visual-editing'\nimport {type FunctionComponent} from 'react'\n\nimport {PopoverPortal} from '../../ui/PopoverPortal'\nimport {getNodeIcon} from '../../util/getNodeIcon'\n\n// @todo How can this be localised?\nconst labels = {\n 'insert-menu.filter.all-items': 'All',\n 'insert-menu.search.no-results': 'No results',\n 'insert-menu.search.placeholder': 'Filter types…',\n 'insert-menu.toggle-grid-view.tooltip': 'Toggle grid view',\n 'insert-menu.toggle-list-view.tooltip': 'Toggle list view',\n} as const\n\nexport interface InsertMenuProps {\n node: SchemaUnionNode\n onSelect: (schemaType: SchemaType) => void\n}\n\nexport const InsertMenu: FunctionComponent<InsertMenuProps> = (props) => {\n const {node, onSelect} = props\n\n const insertMenuOptions = node.options?.insertMenu || {}\n\n const views: InsertMenuOptions['views'] = insertMenuOptions.views?.map((view) => {\n // Map the `previewImageUrls` that Presentation already resolved and\n // serialized back to a function so that InsertMenu can \"resolve\" them\n if (view.name === 'grid') {\n return {\n ...view,\n previewImageUrl: (name) => view.previewImageUrls?.[name],\n }\n }\n return view\n })\n\n return (\n <SanityInsertMenu\n {...insertMenuOptions}\n labels={labels}\n // @ts-expect-error -- @todo map typings\n schemaTypes={node.of.map((type) => ({\n ...type,\n icon: getNodeIcon(type),\n }))}\n onSelect={onSelect}\n views={views}\n />\n )\n}\n\nexport interface InsertMenuPopoverProps extends InsertMenuProps {\n onDismiss: () => void\n referenceElement?: HTMLElement | null\n}\n\nexport const InsertMenuPopover: FunctionComponent<InsertMenuPopoverProps> = (props) => {\n const {node, onDismiss, onSelect, referenceElement} = props\n\n const popoverContent = <InsertMenu node={node} onSelect={onSelect} />\n\n const insertMenuOptions = node.options?.insertMenu || {}\n\n // If the grid view is not enabled, the popover should fit the content. If it\n // is enabled, the popover width needs to be 'forced' to some arbitrary amount\n // to prevent the grid from collapsing to a single column. The '0' size allows\n // for a two column layout\n const width = insertMenuOptions.views?.some((view) => view.name === 'grid') ? 0 : undefined\n\n return (\n <PopoverPortal onDismiss={onDismiss}>\n <Popover\n animate={true}\n constrainSize\n content={popoverContent}\n fallbackPlacements={['bottom']}\n open\n placement={'top'}\n preventOverflow\n referenceElement={referenceElement}\n width={width}\n />\n </PopoverPortal>\n )\n}\n","import type {FunctionComponent, HTMLAttributes, PropsWithChildren} from 'react'\n\nexport const PointerEvents: FunctionComponent<\n PropsWithChildren<HTMLAttributes<HTMLDivElement>>\n> = ({children, style, ...rest}) => {\n return (\n <div style={{...style, pointerEvents: 'all'}} data-sanity-overlay-element {...rest}>\n {children}\n </div>\n )\n}\n"],"names":["getNodeIcon","option","type","value","node","icon","__html","Array","isArray","of","some","n","name","scrollBlockStyles","css","PortalContainer","styled","div","props","$blockScroll","PortalBackground","PopoverPortal","$","_c","t0","PopoverBackground","children","onDismiss","setBoundaryElement","blockScroll","undefined","handleClick","_temp","t1","t2","event","stopPropagation","events","defineEvent","description","version","TelemetryContext","createContext","useTelemetry","context","useContext","Error","labels","InsertMenu","onSelect","options","insertMenu","insertMenuOptions","views","map","_temp2","t3","SanityInsertMenu","InsertMenuPopover","referenceElement","popoverContent","width","_temp3","Symbol","for","view","previewImageUrl","previewImageUrls","PointerEvents","rest","style","pointerEvents"],"mappings":";;;;;;;AAyBO,SAASA,YAAYC,QAA+C;AACzE,MAAI,CAACA,OAAQ,QAAO,oBAAC,UAAA,CAAA,CAAQ;AAE7B,MAAIA,OAAOC,SAAS;AAClB,+BAAQ,YAAA,EAAU;AAGpB,MAAID,OAAOC,SAAS;AAClB,+BAAQ,YAAA,EAAU;AAGpB,QAAM;AAAA,IAACC,OAAOC;AAAAA,EAAAA,IAAQH;AAEtB,MAAI,UAAUA,UAAUA,OAAOI;AAC7B,WAAO,oBAAC,SAAI,yBAAyB;AAAA,MAACC,QAAQL,OAAOI;AAAAA,IAAAA,GAAM;A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AAA,KAAAX,EAAA,CAAA;AAAA,MAAAY;AAAA,SAAAZ,EAAA,CAAA,MAAAI,YAAAJ,SAAA+C,QAAA/C,EAAA,CAAA,MAAAW,MAA5CC,kCAAY,OAAAD,IAAkC,+BAAA,IAA2B,GAAKoC,MAC3E3C,UACH,GAAMJ,OAAAI,UAAAJ,OAAA+C,MAAA/C,OAAAW,IAAAX,OAAAY,MAAAA,KAAAZ,EAAA,CAAA,GAFNY;AAEM;"}
{"version":3,"file":"PointerEvents.js","sources":["../../src/util/getNodeIcon.tsx","../../src/ui/PopoverPortal.tsx","../../src/ui/telemetry/TelemetryContext.tsx","../../src/ui/telemetry/useTelemetry.tsx","../../src/overlay-components/components/InsertMenu.tsx","../../src/overlay-components/components/PointerEvents.tsx"],"sourcesContent":["import type {\n SchemaArrayItem,\n SchemaNumberNode,\n SchemaObjectField,\n SchemaStringNode,\n SchemaUnionOption,\n} from '@sanity/presentation-comlink'\n\nimport {\n BlockContentIcon,\n CheckmarkCircleIcon,\n CubeIcon,\n ImageIcon,\n NumberIcon,\n StringIcon,\n ThListIcon,\n} from '@sanity/icons'\n\ntype Option =\n | SchemaNumberNode\n | SchemaStringNode\n | SchemaArrayItem\n | SchemaObjectField\n | SchemaUnionOption\n\nexport function getNodeIcon(option: Option | undefined): React.JSX.Element {\n if (!option) return <CubeIcon />\n\n if (option.type === 'string') {\n return <StringIcon />\n }\n\n if (option.type === 'number') {\n return <NumberIcon />\n }\n\n const {value: node} = option\n\n if ('icon' in option && option.icon) {\n return <div dangerouslySetInnerHTML={{__html: option.icon}} />\n }\n\n const {type} = node\n\n if (type === 'string') {\n return <StringIcon />\n }\n\n if (type === 'boolean') {\n return <CheckmarkCircleIcon />\n }\n\n if (type === 'number') {\n return <NumberIcon />\n }\n\n if (type === 'array' || type === 'union') {\n const of = Array.isArray(node.of) ? node.of : [node.of]\n if (of.some((n) => 'name' in n && n.name === 'block')) {\n return <BlockContentIcon />\n }\n return <ThListIcon />\n }\n\n if (type === 'object') {\n if (option.name === 'image') {\n return <ImageIcon />\n }\n if (option.name === 'block') {\n return <StringIcon />\n }\n }\n\n return <CubeIcon />\n}\n","import {Portal} from '@sanity/ui/_visual-editing'\nimport {type FunctionComponent, type MouseEvent} from 'react'\nimport {css, styled} from 'styled-components'\n\nconst scrollBlockStyles = css`\n overflow-y: scroll;\n overscroll-behavior: contain;\n -ms-overflow-style: none;\n scrollbar-width: none;\n\n &:before {\n content: '';\n display: block;\n height: calc(100% + 1px);\n position: absolute;\n top: 0;\n width: 100%;\n z-index: -1;\n }\n`\n\nconst PortalContainer = styled.div<{$blockScroll: boolean}>`\n height: 100%;\n inset: 0;\n pointer-events: all;\n position: fixed;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n\n ${(props) => props.$blockScroll && scrollBlockStyles}\n`\nconst PortalBackground = styled.div`\n background: transparent;\n height: 100%;\n inset: 0;\n position: absolute;\n width: 100%;\n`\n\ntype PopoverPortalProps = {\n children?: React.ReactNode\n onDismiss?: () => void\n setBoundaryElement?: (element: HTMLDivElement) => void\n blockScroll?: boolean\n}\n\nexport const PopoverPortal: FunctionComponent<PopoverPortalProps> = (props) => {\n return (\n <Portal>\n <PopoverBackground {...props} />\n </Portal>\n )\n}\n\nexport const PopoverBackground: FunctionComponent<{\n children?: React.ReactNode\n onDismiss?: () => void\n setBoundaryElement?: (element: HTMLDivElement) => void\n blockScroll?: boolean\n}> = (props) => {\n const {children, onDismiss, setBoundaryElement, blockScroll = true} = props\n\n // Prevent the event from propagating to the window, so that the controller's\n // `handleBlur` listener is not triggered. This is needed to prevent the\n // context menu from being dismissed when some click causes parent elements to\n // re-render, and the data-attribute method of preventing propagation fails.\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation()\n }\n\n return (\n <PortalContainer\n data-sanity-overlay-element\n ref={setBoundaryElement}\n onClick={handleClick}\n $blockScroll={blockScroll}\n >\n <PortalBackground\n onMouseDownCapture={() => {\n onDismiss?.()\n }}\n />\n {children}\n </PortalContainer>\n )\n}\n","import {defineEvent} from '@sanity/telemetry'\nimport {createContext} from 'react'\n\nexport const events = {\n 'Visual Editing Drag Sequence Completed': defineEvent({\n name: 'Visual Editing Drag Sequence Completed',\n description: 'An array is successfully reordered using drag and drop.',\n version: 1,\n }),\n 'Visual Editing Drag Minimap Enabled': defineEvent({\n name: 'Visual Editing Drag Minimap Enabled',\n description: 'The zoomed-out minimap view is enabled during a drag sequence.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Removed': defineEvent({\n name: 'Visual Editing Context Menu Item Removed',\n description: 'An item is removed using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Duplicated': defineEvent({\n name: 'Visual Editing Context Menu Item Duplicated',\n description: 'An item is duplicated using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Moved': defineEvent({\n name: 'Visual Editing Context Menu Item Moved',\n description: 'An item is moved using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Context Menu Item Inserted': defineEvent({\n name: 'Visual Editing Context Menu Item Inserted',\n description: 'An item is inserted using the Context Menu.',\n version: 1,\n }),\n 'Visual Editing Insert Menu Item Inserted': defineEvent({\n name: 'Visual Editing Insert Menu Item Inserted',\n description: 'An item is inserted using the Insert Menu.',\n version: 1,\n }),\n 'Visual Editing Overlay Clicked': defineEvent({\n name: 'Visual Editing Overlay Clicked',\n description: 'An Overlay is clicked.',\n version: 1,\n }),\n}\n\ntype EventDataMap = {\n [K in keyof typeof events]: (typeof events)[K] extends ReturnType<typeof defineEvent<infer T>>\n ? T\n : never\n}\n\nexport type TelemetryEventNames = keyof typeof events\n\nexport type TelemetryContextValue = <K extends keyof typeof events>(\n name: K,\n data: EventDataMap[K] extends void ? null | undefined : EventDataMap[K],\n) => void\n\nexport const TelemetryContext = createContext<TelemetryContextValue | undefined>(undefined)\n","import {useContext} from 'react'\n\nimport {TelemetryContext, type TelemetryContextValue} from './TelemetryContext'\n\nexport function useTelemetry(): TelemetryContextValue {\n const context = useContext(TelemetryContext)\n\n if (!context) {\n throw new Error('Telemetry context is missing')\n }\n\n return context\n}\n","import type {InsertMenuOptions} from '@sanity/insert-menu'\nimport type {SchemaUnionNode} from '@sanity/presentation-comlink'\nimport type {SchemaType} from '@sanity/types'\n\nimport {InsertMenu as SanityInsertMenu} from '@sanity/insert-menu'\nimport {Popover} from '@sanity/ui/_visual-editing'\nimport {type FunctionComponent} from 'react'\n\nimport {PopoverPortal} from '../../ui/PopoverPortal'\nimport {getNodeIcon} from '../../util/getNodeIcon'\n\n// @todo How can this be localised?\nconst labels = {\n 'insert-menu.filter.all-items': 'All',\n 'insert-menu.search.no-results': 'No results',\n 'insert-menu.search.placeholder': 'Filter types…',\n 'insert-menu.toggle-grid-view.tooltip': 'Toggle grid view',\n 'insert-menu.toggle-list-view.tooltip': 'Toggle list view',\n} as const\n\nexport interface InsertMenuProps {\n node: SchemaUnionNode\n onSelect: (schemaType: SchemaType) => void\n}\n\nexport const InsertMenu: FunctionComponent<InsertMenuProps> = (props) => {\n const {node, onSelect} = props\n\n const insertMenuOptions = node.options?.insertMenu || {}\n\n const views: InsertMenuOptions['views'] = insertMenuOptions.views?.map((view) => {\n // Map the `previewImageUrls` that Presentation already resolved and\n // serialized back to a function so that InsertMenu can \"resolve\" them\n if (view.name === 'grid') {\n return {\n ...view,\n previewImageUrl: (name) => view.previewImageUrls?.[name],\n }\n }\n return view\n })\n\n return (\n <SanityInsertMenu\n {...insertMenuOptions}\n labels={labels}\n // @ts-expect-error -- @todo map typings\n schemaTypes={node.of.map((type) => ({\n ...type,\n icon: getNodeIcon(type),\n }))}\n onSelect={onSelect}\n views={views}\n />\n )\n}\n\nexport interface InsertMenuPopoverProps extends InsertMenuProps {\n onDismiss: () => void\n referenceElement?: HTMLElement | null\n}\n\nexport const InsertMenuPopover: FunctionComponent<InsertMenuPopoverProps> = (props) => {\n const {node, onDismiss, onSelect, referenceElement} = props\n\n const popoverContent = <InsertMenu node={node} onSelect={onSelect} />\n\n const insertMenuOptions = node.options?.insertMenu || {}\n\n // If the grid view is not enabled, the popover should fit the content. If it\n // is enabled, the popover width needs to be 'forced' to some arbitrary amount\n // to prevent the grid from collapsing to a single column. The '0' size allows\n // for a two column layout\n const width = insertMenuOptions.views?.some((view) => view.name === 'grid') ? 0 : undefined\n\n return (\n <PopoverPortal onDismiss={onDismiss}>\n <Popover\n animate={true}\n constrainSize\n content={popoverContent}\n fallbackPlacements={['bottom']}\n open\n placement={'top'}\n preventOverflow\n referenceElement={referenceElement}\n width={width}\n />\n </PopoverPortal>\n )\n}\n","import type {FunctionComponent, HTMLAttributes, PropsWithChildren} from 'react'\n\nexport const PointerEvents: FunctionComponent<\n PropsWithChildren<HTMLAttributes<HTMLDivElement>>\n> = ({children, style, ...rest}) => {\n return (\n <div style={{...style, pointerEvents: 'all'}} data-sanity-overlay-element {...rest}>\n {children}\n </div>\n )\n}\n"],"names":["getNodeIcon","option","type","value","node","icon","__html","Array","isArray","of","some","n","name","scrollBlockStyles","css","PortalContainer","styled","div","props","$blockScroll","PortalBackground","PopoverPortal","$","_c","t0","PopoverBackground","children","onDismiss","setBoundaryElement","blockScroll","undefined","handleClick","_temp","t1","t2","event","stopPropagation","events","defineEvent","description","version","TelemetryContext","createContext","useTelemetry","context","useContext","Error","labels","InsertMenu","onSelect","options","insertMenu","insertMenuOptions","views","map","_temp2","t3","SanityInsertMenu","InsertMenuPopover","referenceElement","popoverContent","width","_temp3","Symbol","for","view","previewImageUrl","previewImageUrls","PointerEvents","rest","style","pointerEvents"],"mappings":";;;;;;;AAyBO,SAASA,YAAYC,QAA+C;AACzE,MAAI,CAACA,OAAQ,QAAO,oBAAC,UAAA,CAAA,CAAQ;AAE7B,MAAIA,OAAOC,SAAS;AAClB,+BAAQ,YAAA,EAAU;AAGpB,MAAID,OAAOC,SAAS;AAClB,+BAAQ,YAAA,EAAU;AAGpB,QAAM;AAAA,IAACC,OAAOC;AAAAA,EAAAA,IAAQH;AAEtB,MAAI,UAAUA,UAAUA,OAAOI;AAC7B,W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AIqC;AAAAA,IAAKC,eAAiB;AAAA,EAAA,GAAMjD,OAAAgD,OAAAhD,OAAAW,MAAAA,KAAAX,EAAA,CAAA;AAAA,MAAAY;AAAA,SAAAZ,EAAA,CAAA,MAAAI,YAAAJ,SAAA+C,QAAA/C,EAAA,CAAA,MAAAW,MAA5CC,kCAAY,OAAAD,IAAkC,+BAAA,IAA2B,GAAKoC,MAC3E3C,UACH,GAAMJ,OAAAI,UAAAJ,OAAA+C,MAAA/C,OAAAW,IAAAX,OAAAY,MAAAA,KAAAZ,EAAA,CAAA,GAFNY;AAEM;"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../src/controller.ts","../src/ui/enableVisualEditing.tsx","../src/ui/shared-state/useSharedState.ts","../src/util/mutations.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AA4BgB,iBAAA,uBAAA,CAAuB;EAAA,OAAA;EAAA,cAAA;EAAA,OAAA;EAAA,OAAA;EAAA;AAAA,CAAA,EAMpC,cANoC,CAAA,EAMnB,iBANmB;;;;;;;iBCpBvB,mBAAA,WAA6B,uBAA4B;iBCJzD,kHAEA;iBCIA,4BAAA,sBAAkD;;;;AHkBlE,CAAA;;;;;AAMoB,cIyEP,YJzEO,EAAA,OIyEK,cJzEL;;;AC1BpB;;ACJgB,cE4GH,aF5GiB,EAEd,OE0GU,eF1GT;;ACIjB;;ACiGA;AAKa,KAKD,0BAAA,GAA6B,4BALW;AAKpD;AAKA;AAKA;AAKA;AAKY,KAfA,YAAA,GAAe,cAea;AAKxC;;;;AAAiE,KAfrD,eAAA,GAAkB,iBAemC;AAKjE;AAKA;;;AAA2D,KApB/C,kBAAA,GAAqB,oBAoB0B;;;AAK3D;;AAAoE,KApBxD,yBAAA,GAA4B,2BAoB4B;;;;;KAfxD,0BAA0B,oBAA4B,GAAG;;;;;KAKzD,6BAA6B,0BAAkC;;;;;KAK/D,wBAAwB,KAAK,OAAe,GAAG;;;;;KAK/C,iCAAiC,YAAoB,GAAG"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/controller.ts","../src/ui/enableVisualEditing.tsx","../src/ui/shared-state/useSharedState.ts","../src/util/mutations.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;iBA4BgB,uBAAA,CAAA;EACd,OAAA;EACA,cAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA,GACC,cAAA,GAAiB,iBAAA;;;;;;;iBC1BJ,mBAAA,CAAoB,OAAA,GAAS,oBAAA,GAA4B,oBAAA;AAAA,iBCJzD,cAAA,qFAAA,CAEd,GAAA,WAAc,CAAA;AAAA,iBCIA,4BAAA,CAA6B,UAAA,WAAqB,YAAA;EAChE,IAAA;EACA,GAAA;EACA,cAAA;AAAA;;;;;cC8FW,YAAA,SAAY,cAAA;;;;;cAKZ,aAAA,SAAa,eAAA;;;;;KAKd,0BAAA,GAA6B,4BAAA;;;;;KAK7B,YAAA,GAAe,cAAA;;;;;KAKf,eAAA,GAAkB,iBAAA;;;;;KAKlB,kBAAA,GAAqB,oBAAA;;;;;KAKrB,yBAAA,GAA4B,2BAAA;;;;;KAK5B,iBAAA,SAA0B,mBAAA,CAA4B,CAAA,EAAG,CAAA;;;;;KAKzD,uBAAA,MAA6B,yBAAA,CAAkC,CAAA;;;;;KAK/D,IAAA,oBAAwB,CAAA,IAAK,MAAA,CAAe,CAAA,EAAG,CAAA;;;;;KAK/C,SAAA,wBAAiC,WAAA,CAAoB,CAAA,EAAG,CAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/next-pages-router/VisualEditingComponent.tsx","../../src/next-pages-router/VisualEditing.tsx"],"sourcesContent":[],"mappings":";;;;;;AAeiB,UAAA,kBAAA,SAA2B,IAAK,CAAA,oBAAD,EAAA,SAAA,CAAA,CAAA;;ACNhD;;;;;;;ADMiB,iBCND,aAAA,CDMiC,KAAA,ECNZ,kBDMO,CAAA,ECNc,KAAA,CAAM,GAAA,CAAI,ODMpB"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/next-pages-router/VisualEditingComponent.tsx","../../src/next-pages-router/VisualEditing.tsx"],"mappings":";;;;;;UAeiB,kBAAA,SAA2B,IAAA,CAAK,oBAAA;EAAb;;;EAIlC,OAAA;AAAA;;;;iBCVc,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAqB,KAAA,CAAM,GAAA,CAAI,OAAA"}
import { actor, emptyActor, isEmptyActor, listeners, setActor } from "../_chunks-es/context.js";
import { documentMutatorMachine, createSharedListener } from "@sanity/mutate/_unstable_machine";
import { fromPromise, enqueueActions, setup, assign, stopChild, emit, assertEvent } from "xstate";
import { fromPromise, enqueueActions, setup, assign, assertEvent, stopChild, emit } from "xstate";
import { SanityEncoder } from "@sanity/mutate";

@@ -5,0 +5,0 @@ const createDocumentMutator = (comlink) => {

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/overlay-components/components/PointerEvents.tsx","../../src/overlay-components/components/UnionInsertMenuOverlay.tsx","../../src/overlay-components/defineOverlayComponent.ts","../../src/overlay-components/defineOverlayComponents.ts","../../src/overlay-components/defineOverlayPlugin.ts"],"sourcesContent":[],"mappings":";;;cAEa,eAAe,kBAC1B,kBAAkB,eAAe;cC4JtB,wBAAwB;ED7JxB,SAAA,CAAA,EAAA,YAQZ,GAAA,UAAA;EAPkC,eAAA,CAAA,EC+Jb,SD/Ja,CC+JH,cD/JG,CAAA,CAAA,QAAA,GAAA,OAAA,CAAA;CAAf,ECiKlB,iBDjKkB,CCiKF,YDjKE,CAAA,CAAA;iBEEJ,iCAAiC,iBAAiB,0CACrD,WACH,KAAK,eAAe,UAAU;aACzB;EFNF,KAAA,EAAA,OEMmB,KFE/B;CAPkC;iBGAnB,kCAAkC,4BACtC,yBAAyB,YAC3B;;;;AHHV;AACmC,KIGvB,eJHuB,CAAA,CAAA,CAAA,GIGF,MJHE,CAAA,MAAA,EAAA,KAAA,CAAA,SIG4B,CJH5B,GAAA,KAAA,GAAA,IAAA;;;;AADU,KISjC,gCJTiC,CAAA,UISU,MJTV,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GIU3C,eJV2C,CIU3B,CJV2B,CAAA,SAAA,IAAA,GAAA;WIUC;AHmJ9C,CAAA,GAAa;EAGmB,OAAA,CAAA,EGtJ8B,CHsJ9B;CAAV;;;;AAH+B,KG9IzC,yBH8IyC,CAAA,UG9IL,MH8IK,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GAAA;UG7I3C;AFbV,CAAA,GEcI,gCFdkC,CEcD,CFdC,CAAA;;;;AAER,KEiBlB,mBFjBkB,CAAA,UEiBY,MFjBZ,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GEkB5B,eFlB4B,CEkBZ,CFlBY,CAAA,SAAA,IAAA,GAAA,CAAA,MAAA,EEmBf,yBFnBe,CEmBW,CFnBX,CAAA,EAAA,GEmBkB,uBFnBlB,GAAA,CAAA,MAAA,CAAA,EEoBd,yBFpBc,CEoBY,CFpBZ,CAAA,EAAA,GEoBmB,uBFpBnB;;;;AACf,KEwBH,qBFxBG,CAAA,UEwB6B,MFxB7B,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GAAA,CAAA,OAAA,EEyBJ,CFzBI,EAAA,GE0BV,uBF1BU;;;;ACLf;;AACqC,iBCqCrB,mBDrCqB,CAAA,UCqCS,MDrCT,CAAA,MAAA,EAAA,OAAA,CAAA,GCqCmC,MDrCnC,CAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA,kBAAA,ECsCf,qBDtCe,CCsCO,CDtCP,CAAA,CAAA,ECuClC,mBDvCkC,CCuCd,CDvCc,CAAA"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/overlay-components/components/PointerEvents.tsx","../../src/overlay-components/components/UnionInsertMenuOverlay.tsx","../../src/overlay-components/defineOverlayComponent.ts","../../src/overlay-components/defineOverlayComponents.ts","../../src/overlay-components/defineOverlayPlugin.ts"],"mappings":";;;cAEa,aAAA,EAAe,iBAAA,CAC1B,iBAAA,CAAkB,cAAA,CAAe,cAAA;AAAA,cC4JtB,sBAAA,EAAwB,gBAAA;EAEjC,SAAA;EACA,eAAA,GAAkB,SAAA,CAAU,cAAA;AAAA,GAE9B,iBAAA,CAAgB,YAAA;AAAA,iBC/JF,sBAAA,WAAiC,gBAAA,CAAiB,MAAA,wBAAA,CAChE,SAAA,EAAW,CAAA,EACX,KAAA,GAAQ,IAAA,CAAK,cAAA,CAAe,CAAA,SAAU,qBAAA;EACpC,SAAA,EAAW,CAAA;EAAG,KAAA,SAAc,KAAA;AAAA;AAAA,iBCLhB,uBAAA,WAAkC,gBAAA,CAAA,CAChD,QAAA,EAAU,wBAAA,CAAyB,CAAA,WAC3B,QAAA;;;;AHHV;KIIY,eAAA,MAAqB,MAAA,wBAA8B,CAAA;;;;KAKnD,gCAAA,WAA2C,MAAA,qBACrD,eAAA,CAAgB,CAAA;EAAmB,OAAA,EAAS,CAAA;AAAA;EAAM,OAAA,GAAU,CAAA;AAAA;;;;KAKlD,yBAAA,WAAoC,MAAA;EAC9C,KAAA,GAAQ,uBAAA;AAAA,IACN,gCAAA,CAAiC,CAAA;AH4IrC;;;AAAA,KGvIY,mBAAA,WAA8B,MAAA,qBACxC,eAAA,CAAgB,CAAA,kBACX,MAAA,EAAQ,yBAAA,CAA0B,CAAA,MAAO,uBAAA,IACzC,MAAA,GAAS,yBAAA,CAA0B,CAAA,MAAO,uBAAA;;;;KAKrC,qBAAA,WAAgC,MAAA,sBAC1C,OAAA,EAAS,CAAA,KACN,uBAAA;;;;;;iBAOW,mBAAA,WAA8B,MAAA,oBAA0B,MAAA,gBAAA,CACtE,kBAAA,EAAoB,qBAAA,CAAsB,CAAA,IACzC,mBAAA,CAAoB,CAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react-router/VisualEditingComponent.tsx","../../src/react-router/VisualEditing.tsx"],"sourcesContent":[],"mappings":";;;;;;AASiB,UAAA,kBAAA,SAA2B,IAAR,CAAa,oBAAb,EAAA,SAAA,GAAA,SAAA,CAAA,CAAA;EAAa;;;EAYlC,OAAA,CAAA,EAAA,KAAA;EAZ6B;;;ACG5C;sBDOa,8CACqB,0BACnB;;;;;AAZE,iBCGD,aAAA,CDHoB,KAAA,ECGC,kBDHD,CAAA,ECGsB,KAAA,CAAM,GAAA,CAAI,ODHhC,GAAA,IAAA"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react-router/VisualEditingComponent.tsx","../../src/react-router/VisualEditing.tsx"],"mappings":";;;;;;UASiB,kBAAA,SAA2B,IAAA,CAAK,oBAAA;EAAb;;;EAIlC,OAAA;EAOgC;;;;EAFhC,OAAA,IACE,OAAA,EAAS,cAAA,EACT,cAAA,gBAA8B,OAAA,mBACnB,OAAA;AAAA;;;;iBCTC,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAqB,KAAA,CAAM,GAAA,CAAI,OAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ui/VisualEditing.tsx","../../src/react/useOptimisticActor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAgBa;UAAwB;;EAAxB,CAAA,CAAA,EAAmE,KAAA,CAAM,SAwDrF;;AC7DD,CAAA;iBAAgB,kBAAA,CAAA,GAAsB,eAAe"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ui/VisualEditing.tsx","../../src/react/useOptimisticActor.ts"],"mappings":";;;;;;;;;cAgBa,aAAA;EAAA,QAAwB,oBAAA;IAAwB,MAAA;EAAA,IAAmB,KAAA,CAAM,SAAA;;;iBCLtE,kBAAA,CAAA,GAAsB,YAAA,GAAe,UAAA"}
{
"name": "@sanity/visual-editing",
"version": "5.1.1",
"version": "5.1.2",
"keywords": [

@@ -62,25 +62,25 @@ "overlays",

"scroll-into-view-if-needed": "^3.1.0",
"xstate": "^5.25.0",
"@sanity/insert-menu": "^3.0.3",
"@sanity/preview-url-secret": "^4.0.2",
"@sanity/visual-editing-csm": "^3.0.4"
"xstate": "^5.26.0",
"@sanity/insert-menu": "^3.0.4",
"@sanity/visual-editing-csm": "^3.0.5",
"@sanity/preview-url-secret": "^4.0.3"
},
"devDependencies": {
"@sanity/client": "^7.13.2",
"@sanity/client": "^7.14.1",
"@sanity/demo": "^2.0.0",
"@sanity/pkg-utils": "^10.2.1",
"@sanity/pkg-utils": "^10.4.2",
"@sanity/tsconfig": "2.1.0",
"@storybook/addon-essentials": "^8.6.14",
"@storybook/addon-interactions": "^8.6.14",
"@storybook/addon-links": "^8.6.14",
"@storybook/addon-themes": "^8.6.14",
"@storybook/react": "^8.6.14",
"@storybook/react-vite": "^8.6.14",
"@storybook/test": "^8.6.14",
"@sveltejs/adapter-auto": "^6.0.1",
"@sveltejs/kit": "^2.27.0",
"@sveltejs/package": "^2.4.0",
"@sveltejs/vite-plugin-svelte": "^6.1.0",
"@tailwindcss/typography": "^0.5.16",
"@types/react": "^19.2.7",
"@storybook/addon-essentials": "^8.6.15",
"@storybook/addon-interactions": "^8.6.15",
"@storybook/addon-links": "^8.6.15",
"@storybook/addon-themes": "^8.6.15",
"@storybook/react": "^8.6.15",
"@storybook/react-vite": "^8.6.15",
"@storybook/test": "^8.6.15",
"@sveltejs/adapter-auto": "^6.1.1",
"@sveltejs/kit": "^2.50.2",
"@sveltejs/package": "^2.5.7",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tailwindcss/typography": "^0.5.19lint-staged",
"@types/react": "^19.2.10",
"@types/react-dom": "^19.2.3",

@@ -91,11 +91,11 @@ "babel-plugin-react-compiler": "1.0.0",

"happy-dom": "^18.0.1",
"ls-engines": "^0.9.3",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"ls-engines": "^0.10.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-router": "^7.7.1",
"rimraf": "^5.0.5",
"storybook": "^8.6.14",
"styled-components": "^6.1.19",
"svelte": "^5.37.3",
"tailwindcss": "^3.4.17",
"storybook": "^8.6.15",
"styled-components": "^6.3.8",
"svelte": "^5.49.1",
"tailwindcss": "^3.4.19",
"typescript": "5.9.3",

@@ -108,3 +108,3 @@ "uuid": "11.1.0",

"peerDependencies": {
"@sanity/client": "^7.13.2",
"@sanity/client": "^7.14.1",
"@sveltejs/kit": ">= 2",

@@ -111,0 +111,0 @@ "next": ">=16.0.0-0",

@@ -10,3 +10,3 @@ import {Portal} from '@sanity/ui/_visual-editing'

scrollbar-width: none;
&:before {

@@ -13,0 +13,0 @@ content: '';

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