diff --git a/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.test.tsx b/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.test.tsx
index 28fe22bf5..a61fc422f 100644
--- a/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.test.tsx
+++ b/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.test.tsx
@@ -60,6 +60,7 @@ import {
$createUnknownNode,
$getSelectedParaMarker,
$isGutterMarkerNode,
+ $isImpliedParaNode,
$isParaNode,
$selectParaMarker,
createEmptyHistoryState,
@@ -789,6 +790,214 @@ describe.each(["off", "guarded"] as const)(
},
);
+describe("ParaMarkerSelectionPlugin — the selected marker of an empty paragraph after a chapter", () => {
+ /** `\c 1`, an empty `\s`, then `\p first`, with the plugins a delete on the marker passes through. */
+ async function emptyAfterChapterEnvironment(structureProtectionMode: StructureProtectionMode) {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(
+ () => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterGlyphNode("s")),
+ $createParaNode("p").append($createGutterGlyphNode("p"), $createTextNode("first")),
+ );
+ },
+ <>
+
+
+ >,
+ );
+ return { editor, empty: empty! };
+ }
+
+ const removed = [{ marker: "p", glyphs: 1, text: "first" }];
+
+ /** Asserts the caret landed in the `\p` after the removed paragraph. */
+ function expectCaretInNextPara(editor: LexicalEditor) {
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ const caretPara = selection.focus.getNode().getTopLevelElementOrThrow();
+ expect($isParaNode(caretPara) && caretPara.getMarker()).toBe("p");
+ });
+ }
+
+ it.each(["Backspace", "Delete"])(
+ 'under "guarded", the first %s arms its removal and the second removes it',
+ async (key) => {
+ const { editor, empty } = await emptyAfterChapterEnvironment("guarded");
+ await selectMarkerOf(editor, empty);
+ const before = documentJson(editor);
+
+ await pressKey(editor, key);
+
+ expect(documentJson(editor)).toBe(before);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe(
+ "removeEmptyPara",
+ );
+
+ await pressKey(editor, key);
+
+ expect(paragraphsOf(editor)).toEqual(removed);
+ expectCaretInNextPara(editor);
+ },
+ );
+
+ it.each(["Backspace", "Delete"])('under "off", %s removes it in one press', async (key) => {
+ const { editor, empty } = await emptyAfterChapterEnvironment("off");
+ await selectMarkerOf(editor, empty);
+
+ const event = await pressKey(editor, key);
+
+ expect(event.defaultPrevented).toBe(true);
+ expect(paragraphsOf(editor)).toEqual(removed);
+ expectCaretInNextPara(editor);
+ });
+
+ it('under "off", a backward delete from the caret in it removes it in one press', async () => {
+ const { editor, empty } = await emptyAfterChapterEnvironment("off");
+ await sutUpdate(editor, () => empty.selectEnd());
+
+ await act(async () => {
+ editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true);
+ });
+
+ expect(paragraphsOf(editor)).toEqual(removed);
+ expectCaretInNextPara(editor);
+ });
+
+ it.each([
+ ["guarded", 2],
+ ["off", 1],
+ ] as const)(
+ 'under "%s", alone in its chapter, leaves a blank line with no marker and the caret in it',
+ async (structureProtectionMode, presses) => {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(
+ () => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterGlyphNode("s")),
+ $createImmutableChapterNode("2"),
+ );
+ },
+ <>
+
+
+ >,
+ );
+ await selectMarkerOf(editor, empty!);
+
+ for (let i = 0; i < presses; i++) await pressKey(editor, "Backspace");
+
+ editor.getEditorState().read(() => {
+ const [, blank] = $getRoot().getChildren();
+ expect($isImpliedParaNode(blank) && blank.getTextContent()).toBe("");
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.focus.getNode().getTopLevelElementOrThrow().is(blank)).toBe(true);
+ });
+ },
+ );
+});
+
+describe("ParaMarkerSelectionPlugin — Delete on the selected marker of an empty paragraph", () => {
+ it.each([
+ ["guarded", 2],
+ ["off", 1],
+ ] as const)(
+ 'under "%s", joins it to the paragraph before and leaves the caret there',
+ async (structureProtectionMode, presses) => {
+ let first: ParaNode;
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(
+ () => {
+ first = $createParaNode("p");
+ empty = $createParaNode("s");
+ $getRoot().append(
+ first.append($createGutterGlyphNode("p"), $createTextNode("first")),
+ empty.append($createGutterGlyphNode("s")),
+ $createParaNode("q1").append($createGutterGlyphNode("q1"), $createTextNode("second")),
+ );
+ },
+ <>
+
+
+ >,
+ );
+ await selectMarkerOf(editor, empty!);
+
+ for (let i = 0; i < presses; i++) await pressKey(editor, "Delete");
+
+ expect(paragraphsOf(editor)).toEqual([
+ { marker: "p", glyphs: 1, text: "first" },
+ { marker: "q1", glyphs: 1, text: "second" },
+ ]);
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.focus.getNode().getTopLevelElementOrThrow().getKey()).toBe(
+ first!.getKey(),
+ );
+ });
+ },
+ );
+});
+
+describe("ParaMarkerSelectionPlugin — a backward delete from the start of the paragraph after an empty one", () => {
+ it.each([
+ ["guarded", 2],
+ ["off", 1],
+ ] as const)(
+ 'under "%s", removes the empty paragraph and keeps this one\'s marker and the caret',
+ async (structureProtectionMode, presses) => {
+ let second: ParaNode;
+ let secondText: TextNode;
+ const { editor } = await baseTestEnvironment(
+ () => {
+ second = $createParaNode("q1");
+ secondText = $createTextNode("second");
+ $getRoot().append(
+ $createParaNode("p").append($createGutterGlyphNode("p"), $createTextNode("first")),
+ $createParaNode("s").append($createGutterGlyphNode("s")),
+ second.append($createGutterGlyphNode("q1"), secondText),
+ );
+ },
+ <>
+
+
+ >,
+ );
+ await sutUpdate(editor, () => secondText!.select(0, 0));
+ // Where the removal itself leaves the caret, read from the update that removes the paragraph:
+ // jsdom's DOM selection can move the editor's afterward, which a browser's would not.
+ let caretParaKey: string | undefined;
+ const unregister = editor.registerUpdateListener(({ editorState }) =>
+ editorState.read(() => {
+ const selection = $getSelection();
+ if (caretParaKey || $getRoot().getChildrenSize() > 2 || !$isRangeSelection(selection))
+ return;
+ caretParaKey = selection.focus.getNode().getTopLevelElementOrThrow().getKey();
+ }),
+ );
+
+ for (let i = 0; i < presses; i++)
+ await act(async () => {
+ editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true);
+ });
+ unregister();
+
+ expect(paragraphsOf(editor)).toEqual([
+ { marker: "p", glyphs: 1, text: "first" },
+ { marker: "q1", glyphs: 1, text: "second" },
+ ]);
+ expect(caretParaKey).toBe(second!.getKey());
+ },
+ );
+});
+
describe("ParaMarkerSelectionPlugin — deletion without a Backspace/Delete keydown", () => {
const merged = [
{ marker: "p", glyphs: 1, text: "firstsecond" },
diff --git a/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.tsx b/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.tsx
index 60facf2dd..28f084a3f 100644
--- a/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.tsx
+++ b/libs/shared-react/src/plugins/usj/ParaMarkerSelectionPlugin.tsx
@@ -6,9 +6,10 @@ import {
} from "./ParaMarkerPrefixCursorGuardPlugin";
import { StructureProtectionMode } from "./structure-protection.model";
import {
- $canMergeIntoPrevious,
+ $canDeletePara,
+ $deletePara,
+ $getEmptyParaBefore,
$getGutterParaWithCaretAtStart,
- $mergeParaIntoPrevious,
$placeCaretAfterParaChild,
} from "./structureKeyboard.utils";
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
@@ -100,10 +101,14 @@ const TARGETED_INPUT_TYPES = new Set([
* spellcheck replacement, a drop) acts there instead.
* - Removing the marker (Backspace/Delete, by key, command or input event, or a Backspace from the
* start of the text of a paragraph with no leading verse) merges its paragraph into the one
- * before (`$mergeParaIntoPrevious`) — a no-op with nothing before it, and refused under
+ * before, or removes it when it is empty and right after a chapter (`$deletePara`), leaving a
+ * blank line with no marker when it is the only one in its chapter — a no-op with nothing else
+ * before it. A Backspace from the start of the text whose paragraph has an
+ * empty one before it removes that empty one instead, so this paragraph's text never lands
+ * under the empty one's marker. Refused under
* `"protected"`, as `StructureKeyboardPlugin` refuses the same merge from a caret. Under
* `"guarded"`, it is `StructureKeyboardPlugin`'s two-step delete, as from a caret: the first
- * press arms the merge and keeps the marker selected, the second merges.
+ * press arms the delete and keeps the marker selected, the second performs it.
* - Pointer and clipboard: a click elsewhere, or a cut, copy or paste after the browser's selection
* moved elsewhere, uses that selection; otherwise paste lands at the content start and cut, copy
* and drag-start are refused (the glyph is not content). A drop lands at its drop point, and is
@@ -154,18 +159,20 @@ export function ParaMarkerSelectionPlugin({
const $getActivePara = (): ParaNode | undefined =>
editor.isEditable() ? $getSelectedParaMarkerPara($getSelection()) : undefined;
- // Removing the marker merges its paragraph into the previous one — the paragraph is the
- // operand, never the glyph. Refused under "protected", as `StructureKeyboardPlugin` refuses
- // the same merge from a caret, and a no-op with no paragraph before it. Callers claim the key
- // either way: let through, rich-text would delete the selected glyph itself.
+ // Removing the marker merges its paragraph into the previous one, or removes it when it is
+ // empty and right after a chapter (blanking it when it is the only one in its chapter) — the
+ // paragraph is the operand, never the glyph. Refused
+ // under "protected", as `StructureKeyboardPlugin` refuses the same merge from a caret, and a
+ // no-op with no paragraph before it. Callers claim the key either way: let through, rich-text
+ // would delete the selected glyph itself.
const $removeMarker = (para: SomeParaNode) => {
- if (structureProtectionModeRef.current !== "protected") $mergeParaIntoPrevious(para);
+ if (structureProtectionModeRef.current !== "protected") $deletePara(para);
};
- // Under "guarded", a merge that would happen is left to `StructureKeyboardPlugin`'s two-step
- // delete, which arms it on the first press and performs it on the second.
+ // Under "guarded", a merge or removal that would happen is left to `StructureKeyboardPlugin`'s
+ // two-step delete, which arms it on the first press and performs it on the second.
const $deferToTwoStepDelete = (para: SomeParaNode) =>
- structureProtectionModeRef.current === "guarded" && $canMergeIntoPrevious(para);
+ structureProtectionModeRef.current === "guarded" && $canDeletePara(para);
/**
* Adopts the browser's selection when it has moved off the glyph — a right-click on other text,
@@ -276,8 +283,9 @@ export function ParaMarkerSelectionPlugin({
// Ctrl+H / Ctrl+D, or a programmatic dispatch) removes a selected marker. With no structure
// protection, so does a backward delete from the start of the text of a paragraph with no
// leading verse (a `\q2` line, say), which would otherwise delete the gutter glyph before the
- // caret. Under "guarded" and "protected" that caret gets `StructureKeyboardPlugin`'s answer —
- // arm, or refuse — the one a Backspace keydown there gets.
+ // caret — or, when the paragraph before is empty, it removes that empty one instead. Under
+ // "guarded" and "protected" that caret gets `StructureKeyboardPlugin`'s answer — arm, or
+ // refuse — the one a Backspace keydown there gets.
const $handleDeleteCharacter = (isBackward: boolean): boolean => {
if (!editor.isEditable()) return false;
const markerPara = $getActivePara();
@@ -289,7 +297,10 @@ export function ParaMarkerSelectionPlugin({
if (!isBackward || structureProtectionModeRef.current !== "off") return false;
const para = $getGutterParaWithCaretAtStart($getSelection());
if (!para) return false;
- $mergeParaIntoPrevious(para);
+ // An empty paragraph before goes itself, rather than taking this one's text under its marker.
+ const emptyBefore = $getEmptyParaBefore(para);
+ if (emptyBefore) $deletePara(emptyBefore, "deleteForward");
+ else $deletePara(para);
return true;
};
diff --git a/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.test.tsx b/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.test.tsx
index 50fd0444f..9f6d8849a 100644
--- a/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.test.tsx
+++ b/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.test.tsx
@@ -37,10 +37,12 @@ import {
$createCaretHostNode,
$createChapterNode,
$createGutterMarkerNode,
+ $createImmutableChapterNode,
$createMarkerNode,
$createMarkerTrailingSeparator,
$createParaNode,
$isBookNode,
+ $isImpliedParaNode,
$isParaNode,
BookNode,
createEmptyHistoryState,
@@ -1028,6 +1030,386 @@ describe("StructureKeyboardPlugin — per-edit undo/redo for a run of verse dele
});
});
+/** Each top-level block's marker (`c` for a chapter, none for a line with no marker) and text. */
+function blocksOf(editor: LexicalEditor) {
+ return editor.getEditorState().read(() =>
+ $getRoot()
+ .getChildren()
+ .map((block) => ({
+ marker: $isParaNode(block)
+ ? block.getMarker()
+ : $isImpliedParaNode(block)
+ ? undefined
+ : "c",
+ text: block.getTextContent(),
+ })),
+ );
+}
+
+/** Asserts the caret is collapsed in a line with no marker. */
+function expectCaretInBlankLine(editor: LexicalEditor) {
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.isCollapsed()).toBe(true);
+ expect($isImpliedParaNode(selection.focus.getNode().getTopLevelElementOrThrow())).toBe(true);
+ });
+}
+
+/** Asserts the caret is collapsed somewhere in `para`. */
+function expectCaretIn(editor: LexicalEditor, para: ParaNode) {
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.isCollapsed()).toBe(true);
+ expect(selection.focus.getNode().getTopLevelElementOrThrow().getKey()).toBe(para.getKey());
+ });
+}
+
+// A paragraph right after a chapter has nothing before it to merge into. An empty one loses
+// nothing by going, so it is removed instead, when a paragraph after it in the chapter can take the
+// caret.
+describe("StructureKeyboardPlugin — an empty paragraph after a chapter", () => {
+ it.each([
+ ["with its marker shown", true],
+ ["with no marker shown", false],
+ ])(
+ "Backspace twice removes it (%s) and leaves the caret in the paragraph after it",
+ async (_label, hasGutterMarker) => {
+ let empty: ParaNode;
+ let next: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ next = $createParaNode("p");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ hasGutterMarker ? empty.append($createGutterMarkerNode("\\s ")) : empty,
+ next.append($createTextNode("first")),
+ );
+ });
+ updateSelection(editor, empty!, hasGutterMarker ? 1 : 0);
+
+ await pressKey(editor, "Backspace", 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe(
+ "removeEmptyPara",
+ );
+ await pressKey(editor, "Backspace", 0);
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "c", text: "" },
+ { marker: "p", text: "first" },
+ ]);
+ expectCaretIn(editor, next!);
+ },
+ );
+
+ it("Delete twice removes it and keeps the next paragraph's marker", async () => {
+ let empty: ParaNode;
+ let next: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ next = $createParaNode("p");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterMarkerNode("\\s ")),
+ next.append($createTextNode("first")),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+
+ await pressKey(editor, "Delete", 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe("removeEmptyPara");
+ await pressKey(editor, "Delete", 0);
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "c", text: "" },
+ { marker: "p", text: "first" },
+ ]);
+ expectCaretIn(editor, next!);
+ });
+
+ // Alone in its chapter, it leaves a blank line with no marker, where the user picks one.
+ describe.each([
+ ["the next chapter", () => [$createImmutableChapterNode("2")], [{ marker: "c", text: "" }]],
+ ["the end of the book", () => [], []],
+ ])("when %s follows it", (_label, $following, following) => {
+ it.each(["Backspace", "Delete"])(
+ "%s twice leaves a blank line with no marker and the caret in it",
+ async (key) => {
+ let empty: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterMarkerNode("\\s ")),
+ ...$following(),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+
+ await pressKey(editor, key, 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe(
+ "removeEmptyPara",
+ );
+ await pressKey(editor, key, 0);
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "c", text: "" },
+ { marker: undefined, text: "" },
+ ...following,
+ ]);
+ expectCaretInBlankLine(editor);
+ },
+ );
+
+ it("Backspace in the blank line it leaves is refused, not armed", async () => {
+ let empty: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterMarkerNode("\\s ")),
+ ...$following(),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace", 0);
+ const before = JSON.stringify(editor.getEditorState().toJSON());
+
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace", 0);
+
+ expect(JSON.stringify(editor.getEditorState().toJSON())).toBe(before);
+ expect(editor.getRootElement()?.classList.contains("verse-delete-armed")).toBe(false);
+ });
+ });
+
+ it("is refused under protected structure", async () => {
+ let empty: ParaNode;
+ const { editor } = await protectedEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterMarkerNode("\\s ")),
+ $createParaNode("p").append($createTextNode("first")),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+ const before = JSON.stringify(editor.getEditorState().toJSON());
+
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace", 0);
+
+ expect(JSON.stringify(editor.getEditorState().toJSON())).toBe(before);
+ });
+
+ it("two in a row go one at a time, the caret moving down to the next each time", async () => {
+ let first: ParaNode;
+ let second: ParaNode;
+ let next: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ first = $createParaNode("s");
+ second = $createParaNode("s2");
+ next = $createParaNode("p");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ first.append($createGutterMarkerNode("\\s ")),
+ second.append($createGutterMarkerNode("\\s2 ")),
+ next.append($createTextNode("first")),
+ );
+ });
+ updateSelection(editor, first!, 1);
+
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace");
+
+ expect(blocksOf(editor).map(({ marker }) => marker)).toEqual(["c", "s2", "p"]);
+ expectCaretIn(editor, second!);
+
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace");
+
+ expect(blocksOf(editor).map(({ marker }) => marker)).toEqual(["c", "p"]);
+ expectCaretIn(editor, next!);
+ });
+
+ it("Undo restores the removed paragraph in one step", async () => {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(
+ () => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty.append($createGutterMarkerNode("\\s ")),
+ $createParaNode("p").append($createTextNode("first")),
+ );
+ },
+ <>
+
+
+ >,
+ );
+ updateSelection(editor, empty!, 1);
+ const before = blocksOf(editor);
+
+ await pressKey(editor, "Backspace", 0);
+ await pressKey(editor, "Backspace", 0);
+ expect(blocksOf(editor)).toEqual([
+ { marker: "c", text: "" },
+ { marker: "p", text: "first" },
+ ]);
+
+ await act(async () => {
+ editor.dispatchCommand(UNDO_COMMAND, undefined);
+ });
+
+ expect(blocksOf(editor)).toEqual(before);
+ });
+});
+
+// Delete in an empty paragraph removes that paragraph, as Backspace does: merging the next
+// paragraph up into it would give the next paragraph's text the empty one's marker.
+describe("StructureKeyboardPlugin — Delete in an empty paragraph", () => {
+ it("Delete twice removes the empty paragraph and keeps the next paragraph's marker", async () => {
+ let empty: ParaNode;
+ let next: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ next = $createParaNode("q1");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ empty.append($createGutterMarkerNode("\\s ")),
+ next.append($createTextNode("second")),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+
+ await pressKey(editor, "Delete", 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe("removeEmptyPara");
+ await pressKey(editor, "Delete", 0);
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "p", text: "first" },
+ { marker: "q1", text: "second" },
+ ]);
+ expectCaretIn(editor, next!);
+ });
+
+ it("Delete twice at the end of the paragraph before it removes it and leaves the caret there", async () => {
+ let first: TextNode;
+ const { editor } = await guardedEnvironment(() => {
+ first = $createTextNode("first");
+ $getRoot().append(
+ $createParaNode("p").append(first),
+ $createParaNode("s").append($createGutterMarkerNode("\\s ")),
+ $createParaNode("q1").append($createTextNode("second")),
+ );
+ });
+ updateSelection(editor, first!, 5);
+
+ await pressKey(editor, "Delete", 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe("removeEmptyPara");
+ await pressKey(editor, "Delete");
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "p", text: "first" },
+ { marker: "q1", text: "second" },
+ ]);
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.isCollapsed()).toBe(true);
+ expect(selection.focus.key).toBe(first!.getKey());
+ expect(selection.focus.offset).toBe(5);
+ });
+ });
+
+ it("Delete in one right before a chapter does not remove it", async () => {
+ let empty: ParaNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ empty.append($createGutterMarkerNode("\\s ")),
+ $createChapterNode("2"),
+ $createParaNode("p").append($createTextNode("second")),
+ );
+ });
+ updateSelection(editor, empty!, 1);
+
+ await pressKey(editor, "Delete", 0);
+ await pressKey(editor, "Delete", 0);
+
+ expect(blocksOf(editor).map(({ marker }) => marker)).toEqual(["p", "s", "c", "p"]);
+ });
+});
+
+// Backspace from the start of a paragraph after an empty one removes the empty one, as Delete in it
+// does: merging this paragraph into it would give this paragraph's text the empty one's marker.
+describe("StructureKeyboardPlugin — Backspace after an empty paragraph", () => {
+ it.each([
+ ["with its marker shown", true],
+ ["with no marker shown", false],
+ ])(
+ "Backspace twice removes the empty paragraph (%s) and keeps this paragraph's marker",
+ async (_label, hasGutterMarker) => {
+ let empty: ParaNode;
+ let second: ParaNode;
+ let secondText: TextNode;
+ const { editor } = await guardedEnvironment(() => {
+ empty = $createParaNode("s");
+ second = $createParaNode("q1");
+ secondText = $createTextNode("second");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ hasGutterMarker ? empty.append($createGutterMarkerNode("\\s ")) : empty,
+ second.append(secondText),
+ );
+ });
+ updateSelection(editor, secondText!, 0);
+
+ await pressKey(editor, "Backspace", 0);
+ expect(editor.getRootElement()?.getAttribute("data-verse-delete-kind")).toBe(
+ "removeEmptyPara",
+ );
+ await pressKey(editor, "Backspace");
+
+ expect(blocksOf(editor)).toEqual([
+ { marker: "p", text: "first" },
+ { marker: "q1", text: "second" },
+ ]);
+ expectCaretIn(editor, second!);
+ },
+ );
+
+ // Selecting the empty paragraph's marker would move the caret into that paragraph, so a key
+ // typed after the arm would land there instead of here.
+ it("the first Backspace leaves the caret where it is, not on the empty paragraph's marker", async () => {
+ let secondText: TextNode;
+ const { editor } = await guardedEnvironment(() => {
+ secondText = $createTextNode("second");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ $createParaNode("s").append($createGutterMarkerNode("\\s ")),
+ $createParaNode("q1").append(secondText),
+ );
+ });
+ updateSelection(editor, secondText!, 0);
+
+ await pressKey(editor, "Backspace", 0);
+
+ expect(editor.getRootElement()?.classList.contains("verse-delete-armed")).toBe(true);
+ editor.getEditorState().read(() => {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) throw new Error("expected a range selection");
+ expect(selection.isCollapsed()).toBe(true);
+ expect(selection.focus.key).toBe(secondText!.getKey());
+ expect(selection.focus.offset).toBe(0);
+ });
+ });
+});
+
// The plugin renders no UI; it publishes the armed state to the editor root so the host app can
// render a localized hint (see paranext-core's TwoStepDeleteTooltipOverlay). These assert that
// DOM contract: `data-verse-delete-intent` + `data-verse-delete-kind` for every arm, cleared
diff --git a/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.tsx b/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.tsx
index c95a46fb4..88d4eef3e 100644
--- a/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.tsx
+++ b/libs/shared-react/src/plugins/usj/StructureKeyboardPlugin.tsx
@@ -1,10 +1,12 @@
import {
+ $deletePara,
+ $getParaAncestor,
$isArmedSelection,
$isUnmergeableParaStart,
- $mergeParaIntoPrevious,
$moveCaretPastGutterGlyph,
$narrowSelectionPastGutterGlyph,
$paraDeleteEffect,
+ $paraDeleteIntent,
$placeCaretAtEnd,
$rangeSnapshot,
$sanitizeNodesForProtectedStructure,
@@ -98,10 +100,11 @@ function $restorerFor(selection: RangeSelection): () => void {
* would remove — except inside an opaque block, left to `OpaqueBlockGuardPlugin`, and on the `\id`
* line, which it judges from the caret and then hands on (see `$guardExtendingDelete`).
*
- * A paragraph merge (Backspace at a paragraph's start, Delete at the end of the one before, or
+ * A paragraph delete (Backspace at a paragraph's start, Delete at the end of the one before, or
* either on a selected gutter marker) is two-step too: the first press marks the marker it
- * removes — never the paragraph's text, which stays — and the second merges. A Backspace arm
- * selects that marker; a Delete arm leaves the caret where it is.
+ * removes — never the paragraph's text, which stays — and the second merges, or removes the
+ * paragraph outright when it is empty. A Backspace arm selects that marker; a Delete arm leaves
+ * the caret where it is.
*
* The armed state is published to the DOM (rather than rendered here) so the host app owns the
* user-facing hint: the root element carries the `verse-delete-armed` class plus
@@ -185,8 +188,9 @@ export function StructureKeyboardPlugin({
editor.dispatchCommand(DELETE_CHARACTER_COMMAND, intent === "deleteBackward");
}
} else if ($isSomeParaNode(node)) {
- // Only paragraphs merge into paragraphs; never merge some other ElementNode.
- $mergeParaIntoPrevious(node);
+ // Only a paragraph is merged or removed; never some other ElementNode. The direction was
+ // settled at the arm, where the caret was (see `$paraDeleteIntent`).
+ $deletePara(node, armed.paraIntent ?? intent);
}
return true;
}
@@ -201,16 +205,23 @@ export function StructureKeyboardPlugin({
$setSelection(ns);
setArmedState({ key: target.node.getKey(), kind: target.kind, intent });
} else {
- // A merge removes only the paragraph's marker; its text stays. So a Backspace arm
- // selects the marker, as a click on it would, and never the text. Removing a selected
- // marker joins its paragraph to the one before, whichever key was pressed. A Delete arm
- // keeps the caret at the end of its paragraph: selecting the NEXT paragraph's marker
- // would move the caret there, so typing or an arrow key after the arm would act in that
- // paragraph. With no marker selected, the caret stays where it is, and the armed class
- // (still on the marker, when there is one) and the host's hint say what is armed.
+ // A merge removes only the paragraph's marker; its text stays (an empty paragraph goes
+ // whole). So a Backspace arm on the caret's own paragraph selects its marker, as a click
+ // on it would, and never the text. Removing a selected marker joins its paragraph to the
+ // one before, whichever key was pressed. Any other arm keeps the caret where it is: a
+ // Delete arm, whose target is the NEXT paragraph (or an empty one the caret is in), and a
+ // Backspace arm on an empty paragraph BEFORE the caret's. Selecting that other
+ // paragraph's marker would move the caret there, so typing or an arrow key after the arm
+ // would act in that paragraph. With no marker selected, the armed class (still on the
+ // marker, when there is one) and the host's hint say what is armed.
const isMarkerSelected = !!$getSelectedParaMarkerPara(selection);
+ const caretPara = $isRangeSelection(selection)
+ ? $getParaAncestor(selection.focus.getNode())
+ : undefined;
const glyph =
- intent === "deleteBackward" ? $getSelectableParaMarker(target.node) : undefined;
+ intent === "deleteBackward" && target.node.is(caretPara)
+ ? $getSelectableParaMarker(target.node)
+ : undefined;
const isMarkerArmed = isMarkerSelected || (!!glyph && $selectParaMarker(glyph));
const caret = !isMarkerArmed && $isRangeSelection(selection) ? selection : undefined;
setArmedState({
@@ -221,6 +232,7 @@ export function StructureKeyboardPlugin({
target.node,
isMarkerSelected ? "deleteBackward" : intent,
),
+ paraIntent: $paraDeleteIntent(selection, target.node, intent),
...(caret && {
anchor: snapshotPoint(caret.anchor),
focus: snapshotPoint(caret.focus),
@@ -251,9 +263,9 @@ export function StructureKeyboardPlugin({
event?.preventDefault();
return true;
}
- // A paragraph start with a block before it that it cannot merge into (a chapter, say):
- // refused, as the same key is under "protected". Let through, the native delete would
- // remove that block.
+ // A paragraph start with a block before it that no paragraph delete may act on (a paragraph
+ // with text after a chapter, say): refused, as the same key is under "protected". Let
+ // through, the native delete would remove that block.
if (intent === "deleteBackward" && $isUnmergeableParaStart(selection)) {
event?.preventDefault();
return true;
diff --git a/libs/shared-react/src/plugins/usj/structureKeyboard.utils.test.ts b/libs/shared-react/src/plugins/usj/structureKeyboard.utils.test.ts
index 23c3aa738..0c00b76d1 100644
--- a/libs/shared-react/src/plugins/usj/structureKeyboard.utils.test.ts
+++ b/libs/shared-react/src/plugins/usj/structureKeyboard.utils.test.ts
@@ -57,6 +57,7 @@ import {
$isMarkerNode,
$isMarkerTrailingSeparator,
$isSomeParaNode,
+ ImpliedParaNode,
NBSP,
ParaNode,
} from "shared";
@@ -478,6 +479,98 @@ describe("$structuralDeleteTarget", () => {
});
});
+ it("returns an empty para after a chapter, when a paragraph follows it", async () => {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty,
+ $createParaNode("p").append($createTextNode("first")),
+ );
+ });
+ updateSelection(editor, empty!, 0);
+ editor.getEditorState().read(() => {
+ expect($structuralDeleteTarget($getSelection()!, "deleteBackward")?.node.getKey()).toBe(
+ empty.getKey(),
+ );
+ expect($isUnmergeableParaStart($getSelection()!)).toBe(false);
+ });
+ });
+
+ it.each(["deleteBackward", "deleteForward"] as const)(
+ "%s returns an empty para alone in its chapter",
+ async (intent) => {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createImmutableChapterNode("1"),
+ empty,
+ $createImmutableChapterNode("2"),
+ );
+ });
+ updateSelection(editor, empty!, 0);
+ editor.getEditorState().read(() => {
+ expect($structuralDeleteTarget($getSelection()!, intent)?.node.getKey()).toBe(
+ empty.getKey(),
+ );
+ expect($isUnmergeableParaStart($getSelection()!)).toBe(false);
+ });
+ },
+ );
+
+ it("returns undefined for a blank line with no marker alone in its chapter", async () => {
+ let blank: ImpliedParaNode;
+ const { editor } = await baseTestEnvironment(() => {
+ blank = $createImpliedParaNode();
+ $getRoot().append($createImmutableChapterNode("1"), blank, $createImmutableChapterNode("2"));
+ });
+ updateSelection(editor, blank!, 0);
+ editor.getEditorState().read(() => {
+ expect($structuralDeleteTarget($getSelection()!, "deleteBackward")).toBeUndefined();
+ expect($isUnmergeableParaStart($getSelection()!)).toBe(true);
+ });
+ });
+
+ it("deleteBackward at the start of a para after an empty para → the EMPTY para", async () => {
+ let empty: ParaNode;
+ let t2: TextNode;
+ const { editor } = await baseTestEnvironment(() => {
+ empty = $createParaNode("s");
+ t2 = $createTextNode("second");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ empty,
+ $createParaNode("q1").append(t2),
+ );
+ });
+ updateSelection(editor, t2!, 0);
+ editor.getEditorState().read(() => {
+ expect($structuralDeleteTarget($getSelection()!, "deleteBackward")?.node.getKey()).toBe(
+ empty!.getKey(),
+ );
+ });
+ });
+
+ it("deleteForward in an empty para with a next para → the empty para itself", async () => {
+ let empty: ParaNode;
+ const { editor } = await baseTestEnvironment(() => {
+ empty = $createParaNode("s");
+ $getRoot().append(
+ $createParaNode("p").append($createTextNode("first")),
+ empty,
+ $createParaNode("q1").append($createTextNode("second")),
+ );
+ });
+ updateSelection(editor, empty!, 0);
+ editor.getEditorState().read(() => {
+ expect($structuralDeleteTarget($getSelection()!, "deleteForward")?.node.getKey()).toBe(
+ empty.getKey(),
+ );
+ });
+ });
+
it("returns undefined mid-text", async () => {
let t1: TextNode;
const { editor } = await baseTestEnvironment(() => {
diff --git a/libs/shared-react/src/plugins/usj/structureKeyboard.utils.ts b/libs/shared-react/src/plugins/usj/structureKeyboard.utils.ts
index 77c567c23..886e8e300 100644
--- a/libs/shared-react/src/plugins/usj/structureKeyboard.utils.ts
+++ b/libs/shared-react/src/plugins/usj/structureKeyboard.utils.ts
@@ -17,10 +17,12 @@ import {
} from "lexical";
import {
$caretHostAtBoundary,
+ $createImpliedParaNode,
$getSelectableParaMarker,
$getSelectedParaMarkerPara,
$isCaretHost,
$isGutterMarkerNode,
+ $isMarkerNode,
$isMarkerTrailingSeparator,
$isParaLikeNode,
$isParaNode,
@@ -103,6 +105,8 @@ export interface ArmedDelete {
key: NodeKey;
/** para only: what the second press will do. */
paraEffect?: ParaDeleteEffect;
+ /** para only: the direction the second press acts in (see {@link $paraDeleteIntent}). */
+ paraIntent?: DeleteIntent;
/**
* selection: the armed range's endpoints. para, when the paragraph shows no marker to select:
* the caret's, which the arm leaves where it was.
@@ -130,8 +134,10 @@ export function keyDownToIntent(event: KeyboardEvent): EditIntent | undefined {
* `node`, if any. `ParaLike`, not `SomePara`: the `\id` line is content like any paragraph's —
* protected mode must recognize it as a block boundary too, or a Delete at the line's own end,
* or a selection spanning from it into the next real paragraph, merges right through it.
+ *
+ * Read-only: safe in any read or update.
*/
-function $getParaAncestor(node: LexicalNode | null | undefined): LexicalNode | undefined {
+export function $getParaAncestor(node: LexicalNode | null | undefined): LexicalNode | undefined {
if (!node) return undefined;
if ($isParaLikeNode(node)) return node;
const para = $findMatchingParent(node, (n: LexicalNode) => $isParaLikeNode(n));
@@ -446,12 +452,13 @@ export function $shouldRefuseExtendedDelete(extent: RangeSelection): boolean {
* refusals (the first block's glyph, a forward delete in front of one) have no target to arm, so
* they have no counterpart here.
*
- * Backward: the adjacent verse, else the current paragraph (when it has a paragraph or the `\id`
- * line before it to merge into).
- * Forward: the adjacent verse, else the NEXT paragraph (when a next block exists) — the block
- * whose marker the merge removes.
- * A selected gutter marker (either direction): its paragraph, when there is one before it to merge
- * into.
+ * Backward: the adjacent verse, else an empty paragraph right before the current one
+ * ({@link $getEmptyParaBefore}), else the current paragraph (when {@link $canDeletePara} allows it).
+ * Forward: the adjacent verse, else the current paragraph when it is empty with a paragraph after
+ * it or alone in its chapter, else the NEXT paragraph (when a next block exists) — the block whose
+ * marker the merge removes.
+ * A selected gutter marker (either direction): its paragraph, when {@link $canDeletePara} allows
+ * it.
*/
export function $structuralDeleteTarget(
selection: BaseSelection,
@@ -459,7 +466,7 @@ export function $structuralDeleteTarget(
): DeleteTarget | undefined {
const markerPara = $getSelectedParaMarkerPara(selection);
if (markerPara) {
- return $canMergeIntoPrevious(markerPara) ? { kind: "para", node: markerPara } : undefined;
+ return $canDeletePara(markerPara) ? { kind: "para", node: markerPara } : undefined;
}
if (!$isRangeSelection(selection) || !selection.isCollapsed()) return undefined;
if (intent === "deleteBackward") {
@@ -467,16 +474,26 @@ export function $structuralDeleteTarget(
if (verse) return { kind: "verse", node: verse };
if ($caretAtParaStart(selection)) {
const para = $getParaAncestor(selection.anchor.getNode());
- if ($isSomeParaNode(para) && $canMergeIntoPrevious(para)) return { kind: "para", node: para };
+ if (!$isSomeParaNode(para)) return undefined;
+ // An empty paragraph before goes itself, rather than taking this one's text under its marker.
+ const emptyBefore = $getEmptyParaBefore(para);
+ if (emptyBefore) return { kind: "para", node: emptyBefore };
+ if ($canDeletePara(para)) return { kind: "para", node: para };
}
return undefined;
}
if (intent === "deleteForward") {
const verse = $adjacentVerseMarker(selection, "forward");
if (verse) return { kind: "verse", node: verse };
- if ($caretAtParaEnd(selection) && $hasNeighborBlock(selection, "forward")) {
+ if ($caretAtParaEnd(selection)) {
const para = $getParaAncestor(selection.anchor.getNode());
- const next = para?.getNextSibling();
+ // An empty paragraph goes itself, rather than taking the next one's text under its marker.
+ if (
+ $isSomeParaNode(para) &&
+ ($canRemoveEmptyPara(para) || $canBlankEmptyParaAloneInChapter(para))
+ )
+ return { kind: "para", node: para };
+ const next = $hasNeighborBlock(selection, "forward") ? para?.getNextSibling() : undefined;
if ($isSomeParaNode(next)) return { kind: "para", node: next };
}
return undefined;
@@ -485,9 +502,10 @@ export function $structuralDeleteTarget(
}
/**
- * True when a collapsed caret sits at the start of a paragraph that has a block before it but
- * cannot merge into it — a chapter marker, say. A Backspace there has nothing it may remove, and
- * left to the native delete it would remove that block, so it must be refused.
+ * True when a collapsed caret sits at the start of a paragraph that has a block before it, but that
+ * no paragraph delete may act on ({@link $canDeletePara}) — a paragraph with text right after a
+ * chapter marker, say. A Backspace there has nothing it may remove, and left to the native delete
+ * it would remove that block, so it must be refused.
*
* Read-only: safe in any read or update.
*/
@@ -495,7 +513,7 @@ export function $isUnmergeableParaStart(selection: BaseSelection): boolean {
if (!$caretAtParaStart(selection) || !$hasNeighborBlock(selection, "backward")) return false;
if (!$isRangeSelection(selection)) return false;
const para = $getParaAncestor(selection.anchor.getNode());
- return !$isSomeParaNode(para) || !$canMergeIntoPrevious(para);
+ return !$isSomeParaNode(para) || !$canDeletePara(para);
}
/** True when the live selection still encodes the armed target. */
@@ -538,9 +556,9 @@ export function $isParaEmpty(para: SomeParaNode): boolean {
}
/**
- * What the second press of an armed paragraph delete will do to `para`, the paragraph the merge
- * removes: the current one for a Backspace (or a selected gutter marker), the next one for a
- * Delete.
+ * What the second press of an armed paragraph delete will do to `para`, the paragraph it removes
+ * ({@link $structuralDeleteTarget}): remove it when it is empty, else join it to the paragraph
+ * before (a Backspace, or a selected gutter marker) or pull it up into the current one (a Delete).
*
* Read-only: safe in any read or update.
*/
@@ -549,6 +567,29 @@ export function $paraDeleteEffect(para: SomeParaNode, intent: DeleteIntent): Par
return intent === "deleteForward" ? "joinNextPara" : "joinPreviousPara";
}
+/**
+ * The direction an armed paragraph delete acts on `para` in, which {@link $deletePara} takes. It
+ * acts forward, so an empty `para` goes and the caret moves to the paragraph after it, when that is
+ * where the caret already is: a Delete with the caret inside `para`, or a Backspace from the start
+ * of the paragraph after it. Otherwise it acts backward, joining `para` to the one before: a
+ * selected gutter marker, whichever key was pressed, a Backspace from `para`'s own start, and a
+ * Delete at the end of the paragraph before `para`, which leaves the caret at the end of its own
+ * paragraph.
+ *
+ * Read-only: safe in any read or update.
+ */
+export function $paraDeleteIntent(
+ selection: BaseSelection,
+ para: SomeParaNode,
+ intent: DeleteIntent,
+): DeleteIntent {
+ if (!$isRangeSelection(selection) || $getSelectedParaMarkerPara(selection))
+ return "deleteBackward";
+ const caretPara = $getParaAncestor(selection.focus.getNode());
+ const caretParaAfterDelete = intent === "deleteForward" ? para : para.getNextSibling();
+ return caretParaAfterDelete?.is(caretPara) ? "deleteForward" : "deleteBackward";
+}
+
/** Collapses the caret to the end of `node` (end of its text for a TextNode). */
export function $placeCaretAtEnd(node: LexicalNode): void {
if ($isTextNode(node)) {
@@ -571,6 +612,112 @@ export function $canMergeIntoPrevious(para: SomeParaNode): boolean {
return $isParaLikeNode(para.getPreviousSibling());
}
+/**
+ * True when `para` can be removed outright rather than merged: it is empty, so removing it loses
+ * nothing, and it has a paragraph after it to take the caret. Never in Standard view, where the
+ * marker is editable text and deleting it is a marker edit. {@link $structuralDeleteTarget},
+ * which picks what to arm, and {@link $deletePara}, which carries it out, both judge removal by
+ * this, so they cannot disagree.
+ *
+ * Read-only: safe in any read or update.
+ */
+function $canRemoveEmptyPara(para: SomeParaNode): boolean {
+ return (
+ !$isMarkerNode(para.getFirstChild()) &&
+ $isParaEmpty(para) &&
+ $isParaLikeNode(para.getNextSibling())
+ );
+}
+
+/**
+ * True when `para` is removable ({@link $canRemoveEmptyPara}) and sits right after a chapter. It
+ * has nothing before it to merge into, but removing it loses nothing. Alone in its chapter it is
+ * blanked instead ({@link $canBlankEmptyParaAloneInChapter}), so the chapter keeps a line to type
+ * in.
+ *
+ * Read-only: safe in any read or update.
+ */
+function $canRemoveEmptyParaAfterChapter(para: SomeParaNode): boolean {
+ return $canRemoveEmptyPara(para) && $isSomeChapterNode(para.getPreviousSibling());
+}
+
+/**
+ * True when `para` is an empty paragraph alone in its chapter: a chapter right before it, and the
+ * next chapter or the end of the book right after. Deleting its marker leaves a blank line with no
+ * marker in its place ({@link $deletePara}), where the user picks a marker. A line already without
+ * one has no marker left to delete. Never in Standard view, where the marker is editable text.
+ *
+ * Read-only: safe in any read or update.
+ */
+function $canBlankEmptyParaAloneInChapter(para: SomeParaNode): boolean {
+ const next = para.getNextSibling();
+ return (
+ $isParaNode(para) &&
+ !$isMarkerNode(para.getFirstChild()) &&
+ $isParaEmpty(para) &&
+ $isSomeChapterNode(para.getPreviousSibling()) &&
+ (!next || $isSomeChapterNode(next))
+ );
+}
+
+/**
+ * True when a paragraph delete can act on `para`: merging it into the block before it
+ * ({@link $canMergeIntoPrevious}), or, when it is an empty paragraph right after a chapter,
+ * removing it ({@link $canRemoveEmptyParaAfterChapter}) or blanking it
+ * ({@link $canBlankEmptyParaAloneInChapter}).
+ *
+ * Read-only: safe in any read or update.
+ */
+export function $canDeletePara(para: SomeParaNode): boolean {
+ return (
+ $canMergeIntoPrevious(para) ||
+ $canRemoveEmptyParaAfterChapter(para) ||
+ $canBlankEmptyParaAloneInChapter(para)
+ );
+}
+
+/**
+ * The empty paragraph right before `para`, which a Backspace at `para`'s start removes rather than
+ * merging `para`'s text into it under its marker; undefined when there is none.
+ *
+ * Read-only: safe in any read or update.
+ */
+export function $getEmptyParaBefore(para: SomeParaNode): SomeParaNode | undefined {
+ const prev = para.getPreviousSibling();
+ return $isSomeParaNode(prev) && $canRemoveEmptyPara(prev) ? prev : undefined;
+}
+
+/**
+ * Performs a paragraph delete on `para`. An empty paragraph alone in its chapter becomes a blank
+ * line with no marker, with the caret in it. Any other empty paragraph is removed outright, and the
+ * caret goes to the start of the paragraph after it, when a Delete removes it or there is nothing
+ * before it to merge into (a chapter). Otherwise `para` merges into the block before it
+ * ({@link $mergeParaIntoPrevious}), a no-op when that cannot be done.
+ *
+ * Mutating: call inside `editor.update()` (dispatched from StructureKeyboardPlugin.tsx and
+ * ParaMarkerSelectionPlugin.tsx).
+ *
+ * @param para - The paragraph the delete removes.
+ * @param intent - The key that removes it. Defaults to a Backspace.
+ */
+export function $deletePara(para: SomeParaNode, intent: DeleteIntent = "deleteBackward"): void {
+ if ($canBlankEmptyParaAloneInChapter(para)) {
+ // Its children are only its marker's glyphs, so none come along.
+ const blank = $createImpliedParaNode();
+ para.replace(blank);
+ blank.select(0, 0);
+ return;
+ }
+ if ($canRemoveEmptyPara(para) && (intent === "deleteForward" || !$canMergeIntoPrevious(para))) {
+ const next = para.getNextSibling();
+ para.remove();
+ // Always a paragraph, by `$canRemoveEmptyPara`; the check only narrows its type.
+ if ($isParaLikeNode(next)) $placeCaretAtParaContentStart(next);
+ return;
+ }
+ $mergeParaIntoPrevious(para);
+}
+
/**
* Merge-into-previous semantics for a paragraph delete: move `para`'s children into its
* previous sibling (which keeps ITS marker), remove `para` (dropping its marker), and place the
@@ -580,7 +727,7 @@ export function $canMergeIntoPrevious(para: SomeParaNode): boolean {
* way, since the line is content like any paragraph's; any other previous sibling is a no-op
* (see {@link $canMergeIntoPrevious}).
*
- * Mutating: call inside `editor.update()` (dispatched from StructureKeyboardPlugin.tsx).
+ * Mutating: call inside `editor.update()` (dispatched through {@link $deletePara}).
*
* @param para - The paragraph whose marker is being removed by merging it into its predecessor.
*/
diff --git a/packages/platform/CHANGELOG.md b/packages/platform/CHANGELOG.md
index 578ce7c0c..166f2b85d 100644
--- a/packages/platform/CHANGELOG.md
+++ b/packages/platform/CHANGELOG.md
@@ -223,6 +223,14 @@ refused. The public surface grew substantially; nothing was removed.
### Fixed
+- In views that hide markers, an empty paragraph right after a chapter can now be deleted with
+ Backspace or Delete. When it is the only paragraph in its chapter, it leaves a blank line with no
+ marker, where a marker can be picked with the `\` menu or `formatPara`. A blank line left empty
+ saves as nothing, and a chapter with no line after it now loads with the same blank line, so a
+ click below the chapter number no longer puts the caret before the chapter. Deleting an empty
+ paragraph next to another paragraph, by Delete inside it or by Backspace from the start of the
+ paragraph after it, now removes the empty one instead of moving the other paragraph's text under
+ its marker. None of this applies in Standard view, where markers are editable text.
- A text node holding only zero-width spaces that the author typed (a line-break opportunity in
Thai, Khmer and Lao), which an annotation or other split leaves in a node of its own, is now kept
by `getUsj()`, sent in delta ops, and counted in annotation and OT positions. It used to be taken
diff --git a/packages/platform/dist/index.js b/packages/platform/dist/index.js
index d43efa442..7f03dcb1c 100644
--- a/packages/platform/dist/index.js
+++ b/packages/platform/dist/index.js
@@ -1,36 +1,36 @@
-import { jsx as O, jsxs as ut, Fragment as os } from "react/jsx-runtime";
-import { useEffect as J, forwardRef as Ri, useState as ze, useRef as ae, useCallback as Ke, useMemo as bt, memo as p0, createContext as Wb, useContext as Hb, Children as h0, isValidElement as g0, cloneElement as m0, useLayoutEffect as Po, useImperativeHandle as Rl } from "react";
-import { assertSafeKey as wt, isValidBookCode as y0, MARKER_OBJECT_PROPS as b0, USJ_VERSION as ur, USJ_TYPE as fr, indexesFromUsjJsonPath as Gn, isUsjTextContentLocation as Jr, usjJsonPathFromIndexes as Ht, isUsjPropertyValueLocation as da, isUsjClosingMarkerLocation as as, isUsjClosingAttributeMarkerLocation as pa, isUsjAttributeKeyLocation as ha, isUsjAttributeMarkerLocation as Il, isUsjMarkerLocation as op, getUsjDocumentLocationTypeName as k0, EMPTY_USJ as Gb } from "@eten-tech-foundation/scripture-utilities";
-import { $applyNodeReplacement as St, $parseSerializedNode as Ir, createCommand as Ba, DecoratorNode as za, ElementNode as vr, isHTMLElement as As, TextNode as it, $isRangeSelection as E, $getEditor as Pt, $getNodeByKey as ee, $isTextNode as T, createState as ws, $getState as Te, $getSelection as M, $isNodeSelection as Ns, ParagraphNode as ap, $isRootNode as pn, HISTORIC_TAG as Ll, $createTextNode as Ue, $setState as Wt, $isElementNode as A, NODE_STATE_KEY as Lr, $getCommonAncestor as x0, $createNodeSelection as cp, $setSelection as Mt, $isLineBreakNode as Os, $isDecoratorNode as on, $addUpdateTag as _t, $getRoot as Me, $createRangeSelection as dr, $createPoint as fn, DELETE_CHARACTER_COMMAND as In, COMMAND_PRIORITY_HIGH as Je, DELETE_WORD_COMMAND as cs, DELETE_LINE_COMMAND as Ei, COMMAND_PRIORITY_NORMAL as $r, CONTROLLED_TEXT_INSERTION_COMMAND as Yr, COMMAND_PRIORITY_CRITICAL as ye, PASTE_COMMAND as un, CUT_COMMAND as wn, REMOVE_TEXT_COMMAND as lp, SELECTION_CHANGE_COMMAND as Nn, CLICK_COMMAND as go, COMMAND_PRIORITY_LOW as Nt, COMMAND_PRIORITY_EDITOR as xi, isDOMNode as ga, $getNearestNodeFromDOMNode as qr, $getCharacterOffsets as up, KEY_DOWN_COMMAND as Jn, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as T0, HISTORY_MERGE_TAG as ma, DROP_COMMAND as ql, COPY_COMMAND as Xr, getDOMSelection as Jb, isSelectionWithinEditor as Yb, $createRangeSelectionFromDom as Dl, isDOMTextNode as C0, $getPreviousSelection as Xb, BLUR_COMMAND as fp, SKIP_DOM_SELECTION_TAG as or, FOCUS_COMMAND as Kl, INSERT_PARAGRAPH_COMMAND as Ti, INSERT_LINE_BREAK_COMMAND as Uc, SELECT_ALL_COMMAND as Qb, $selectAll as v0, DRAGSTART_COMMAND as Fc, isExactShortcutMatch as hi, CLEAR_HISTORY_COMMAND as S0, KEY_ESCAPE_COMMAND as dp, BEFORE_INPUT_COMMAND as _0, COMPOSITION_START_COMMAND as E0, $isRootOrShadowRoot as pp, CAN_UNDO_COMMAND as M0, CAN_REDO_COMMAND as P0, $hasUpdateTag as Zb, getDOMSelectionFromTarget as A0, $onUpdate as ek, KEY_ENTER_COMMAND as tk, LineBreakNode as nk, createEditor as hp, $copyNode as w0, getDOMTextNode as N0, UNDO_COMMAND as rk, REDO_COMMAND as ik, CLEAR_EDITOR_COMMAND as O0 } from "lexical";
-import { addClassNamesToElement as Zo, removeClassNamesFromElement as _c, $findMatchingParent as We, $dfsIterator as ja, $dfs as $s, mergeRegister as Ye, registerNestedElementResolver as gp, $unwrapNode as Lf, IS_APPLE as mr } from "@lexical/utils";
-import { useLexicalNodeSelection as $0 } from "@lexical/react/useLexicalNodeSelection";
+import { jsx as O, jsxs as ft, Fragment as as } from "react/jsx-runtime";
+import { useEffect as J, forwardRef as Ii, useState as ze, useRef as ae, useCallback as Ke, useMemo as kt, memo as b0, createContext as Xb, useContext as Qb, Children as k0, isValidElement as x0, cloneElement as T0, useLayoutEffect as Ao, useImperativeHandle as Ll } from "react";
+import { assertSafeKey as wt, isValidBookCode as C0, MARKER_OBJECT_PROPS as v0, USJ_VERSION as ur, USJ_TYPE as fr, indexesFromUsjJsonPath as Gn, isUsjTextContentLocation as Yr, usjJsonPathFromIndexes as Ht, isUsjPropertyValueLocation as da, isUsjClosingMarkerLocation as cs, isUsjClosingAttributeMarkerLocation as pa, isUsjAttributeKeyLocation as ha, isUsjAttributeMarkerLocation as ql, isUsjMarkerLocation as cp, getUsjDocumentLocationTypeName as S0, EMPTY_USJ as Zb } from "@eten-tech-foundation/scripture-utilities";
+import { $applyNodeReplacement as St, $parseSerializedNode as Ir, createCommand as Fa, DecoratorNode as za, ElementNode as vr, isHTMLElement as As, TextNode as at, $isRangeSelection as E, $getEditor as Pt, $getNodeByKey as ee, $isTextNode as C, createState as ws, $getState as Te, $getSelection as M, $isNodeSelection as Ns, ParagraphNode as lp, $isRootNode as pn, HISTORIC_TAG as Dl, $createTextNode as Be, $setState as Wt, $isElementNode as A, NODE_STATE_KEY as Lr, $getCommonAncestor as _0, $createNodeSelection as up, $setSelection as Mt, $isLineBreakNode as Os, $isDecoratorNode as on, $addUpdateTag as _t, $getRoot as Me, $createRangeSelection as dr, $createPoint as fn, DELETE_CHARACTER_COMMAND as Ln, COMMAND_PRIORITY_HIGH as Je, DELETE_WORD_COMMAND as ls, DELETE_LINE_COMMAND as Mi, COMMAND_PRIORITY_NORMAL as $r, CONTROLLED_TEXT_INSERTION_COMMAND as Xr, COMMAND_PRIORITY_CRITICAL as ye, PASTE_COMMAND as un, CUT_COMMAND as Nn, REMOVE_TEXT_COMMAND as fp, SELECTION_CHANGE_COMMAND as On, CLICK_COMMAND as mo, COMMAND_PRIORITY_LOW as Nt, COMMAND_PRIORITY_EDITOR as Ti, isDOMNode as ga, $getNearestNodeFromDOMNode as qr, $getCharacterOffsets as dp, KEY_DOWN_COMMAND as Jn, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as E0, HISTORY_MERGE_TAG as ma, DROP_COMMAND as Kl, COPY_COMMAND as Qr, getDOMSelection as ek, isSelectionWithinEditor as tk, $createRangeSelectionFromDom as Bl, isDOMTextNode as M0, $getPreviousSelection as nk, BLUR_COMMAND as pp, SKIP_DOM_SELECTION_TAG as or, FOCUS_COMMAND as Ul, INSERT_PARAGRAPH_COMMAND as Ci, INSERT_LINE_BREAK_COMMAND as Uc, SELECT_ALL_COMMAND as rk, $selectAll as P0, DRAGSTART_COMMAND as Fc, isExactShortcutMatch as gi, CLEAR_HISTORY_COMMAND as A0, KEY_ESCAPE_COMMAND as hp, BEFORE_INPUT_COMMAND as w0, COMPOSITION_START_COMMAND as N0, $isRootOrShadowRoot as gp, CAN_UNDO_COMMAND as O0, CAN_REDO_COMMAND as $0, $hasUpdateTag as ik, getDOMSelectionFromTarget as R0, $onUpdate as sk, KEY_ENTER_COMMAND as ok, LineBreakNode as ak, createEditor as mp, $copyNode as I0, getDOMTextNode as L0, UNDO_COMMAND as ck, REDO_COMMAND as lk, CLEAR_EDITOR_COMMAND as q0 } from "lexical";
+import { addClassNamesToElement as ea, removeClassNamesFromElement as _c, $findMatchingParent as We, $dfsIterator as ja, $dfs as $s, mergeRegister as Xe, registerNestedElementResolver as yp, $unwrapNode as Kf, IS_APPLE as yr } from "@lexical/utils";
+import { useLexicalNodeSelection as D0 } from "@lexical/react/useLexicalNodeSelection";
import { deepEqual as Tn } from "fast-equals";
-import Qi from "quill-delta";
+import Zi from "quill-delta";
import { useLexicalComposerContext as Pe } from "@lexical/react/LexicalComposerContext";
-import { copyToClipboard as R0, $getLexicalContent as I0 } from "@lexical/clipboard";
-import { graphemeSegments as L0 } from "unicode-segmenter/grapheme";
-import { Canon as Wg } from "@sillsdev/scripture";
-import { TreeView as q0 } from "@lexical/react/LexicalTreeView";
-import * as D0 from "react-dom";
-import { createPortal as ns } from "react-dom";
-import { LexicalComposer as sk } from "@lexical/react/LexicalComposer";
-import { ContentEditable as ok } from "@lexical/react/LexicalContentEditable";
-import { EditorRefPlugin as ak } from "@lexical/react/LexicalEditorRefPlugin";
-import { LexicalErrorBoundary as ck } from "@lexical/react/LexicalErrorBoundary";
-import { HistoryPlugin as lk } from "@lexical/react/LexicalHistoryPlugin";
-import { RichTextPlugin as K0 } from "@lexical/react/LexicalRichTextPlugin";
-import { $setBlocksType as U0, createDOMRange as F0, createRectsFromDOMRange as B0 } from "@lexical/selection";
-import { autoUpdate as z0, computePosition as j0, shift as V0, flip as W0 } from "@floating-ui/dom";
-import { $generateNodesFromDOM as H0 } from "@lexical/html";
-import { AutoFocusPlugin as G0 } from "@lexical/react/LexicalAutoFocusPlugin";
-import { ClearEditorPlugin as J0 } from "@lexical/react/LexicalClearEditorPlugin";
-import { useCollaborationContext as uk, LexicalCollaboration as Y0 } from "@lexical/react/LexicalCollaborationContext";
-import { OnChangePlugin as X0 } from "@lexical/react/LexicalOnChangePlugin";
-import { PlainTextPlugin as Q0 } from "@lexical/react/LexicalPlainTextPlugin";
-import { $rootTextContent as Z0, $isRootTextContentEmpty as eE } from "@lexical/text";
-import { TOGGLE_CONNECT_COMMAND as tE } from "@lexical/yjs";
-import { Array as Hg, Map as Gg, YArrayEvent as nE } from "yjs";
-const zu = (e) => St(Ir(e)), rE = {
+import { copyToClipboard as K0, $getLexicalContent as B0 } from "@lexical/clipboard";
+import { graphemeSegments as U0 } from "unicode-segmenter/grapheme";
+import { Canon as Xg } from "@sillsdev/scripture";
+import { TreeView as F0 } from "@lexical/react/LexicalTreeView";
+import * as z0 from "react-dom";
+import { createPortal as rs } from "react-dom";
+import { LexicalComposer as uk } from "@lexical/react/LexicalComposer";
+import { ContentEditable as fk } from "@lexical/react/LexicalContentEditable";
+import { EditorRefPlugin as dk } from "@lexical/react/LexicalEditorRefPlugin";
+import { LexicalErrorBoundary as pk } from "@lexical/react/LexicalErrorBoundary";
+import { HistoryPlugin as hk } from "@lexical/react/LexicalHistoryPlugin";
+import { RichTextPlugin as j0 } from "@lexical/react/LexicalRichTextPlugin";
+import { $setBlocksType as V0, createDOMRange as W0, createRectsFromDOMRange as H0 } from "@lexical/selection";
+import { autoUpdate as G0, computePosition as J0, shift as Y0, flip as X0 } from "@floating-ui/dom";
+import { $generateNodesFromDOM as Q0 } from "@lexical/html";
+import { AutoFocusPlugin as Z0 } from "@lexical/react/LexicalAutoFocusPlugin";
+import { ClearEditorPlugin as eE } from "@lexical/react/LexicalClearEditorPlugin";
+import { useCollaborationContext as gk, LexicalCollaboration as tE } from "@lexical/react/LexicalCollaborationContext";
+import { OnChangePlugin as nE } from "@lexical/react/LexicalOnChangePlugin";
+import { PlainTextPlugin as rE } from "@lexical/react/LexicalPlainTextPlugin";
+import { $rootTextContent as iE, $isRootTextContentEmpty as sE } from "@lexical/text";
+import { TOGGLE_CONNECT_COMMAND as oE } from "@lexical/yjs";
+import { Array as Qg, Map as Zg, YArrayEvent as aE } from "yjs";
+const Wu = (e) => St(Ir(e)), cE = {
c: ["number"],
ef: ["caller"],
efe: ["caller"],
@@ -41,16 +41,16 @@ const zu = (e) => St(Ir(e)), rE = {
v: ["number"],
x: ["caller"]
};
-function mp(e) {
- return rE[e];
+function bp(e) {
+ return cE[e];
}
-const U = " ", mo = "", It = U, yp = `${U}|`, Ln = "p", ya = "+", fk = "-", Ii = "immutable-note-caller", dk = "immutable-verse", Bc = "chapter", qf = "verse", Jg = "invalid", iE = "text-spacing", sE = "formatted-font", oE = "marker-", Va = "external-usj-mutation", aE = "selection-change", yo = "cursor-change", bp = Ba("APP_PLACED_CARET_COMMAND"), Df = "annotation-change", Ec = "typed-mark-wrap", kp = "delta-change", pk = "marker-settle", cE = [
+const B = " ", yo = "", It = B, kp = `${B}|`, qn = "p", ya = "+", mk = "-", Li = "immutable-note-caller", yk = "immutable-verse", zc = "chapter", Bf = "verse", em = "invalid", lE = "text-spacing", uE = "formatted-font", fE = "marker-", Va = "external-usj-mutation", dE = "selection-change", bo = "cursor-change", xp = Fa("APP_PLACED_CARET_COMMAND"), Uf = "annotation-change", Ec = "typed-mark-wrap", Tp = "delta-change", bk = "marker-settle", pE = [
Va,
- aE,
- yo,
- Df,
- kp
-], hk = 2, ls = "zmsc-s", co = "zmsc-e", lE = [ls, co], uE = [
+ dE,
+ bo,
+ Uf,
+ Tp
+], kk = 2, us = "zmsc-s", co = "zmsc-e", hE = [us, co], gE = [
"ts-s",
"ts-e",
"t-s",
@@ -69,16 +69,16 @@ const U = " ", mo = "", It = U, yp = `${U}|`, Ln = "p", ya = "+", fk = "-",
"qt-s",
"qt-e",
// custom markers used for annotations
- ls,
+ us,
co
-], gk = 1, xp = [
+], xk = 1, Cp = [
"type",
"marker",
"sid",
"eid",
"content"
-], fE = xp.filter((e) => e !== "sid" && e !== "eid");
-class xr extends za {
+], mE = Cp.filter((e) => e !== "sid" && e !== "eid");
+class Tr extends za {
__marker;
__sid;
__eid;
@@ -97,13 +97,13 @@ class xr extends za {
}
static clone(t) {
const { __marker: n, __sid: r, __eid: i, __unknownAttributes: s, __attributeOrder: o, __key: a } = t;
- return new xr(n, r, i, s, a, o);
+ return new Tr(n, r, i, s, a, o);
}
static importJSON(t) {
- return yk().updateFromJSON(t);
+ return Ck().updateFromJSON(t);
}
static isValidMarker(t, n) {
- return t !== void 0 && (uE.includes(t) || t.startsWith("z") || (n?.includes(t) ?? !1));
+ return t !== void 0 && (gE.includes(t) || t.startsWith("z") || (n?.includes(t) ?? !1));
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setSid(t.sid).setEid(t.eid).setUnknownAttributes(t.unknownAttributes).setAttributeOrder(t.attributeOrder);
@@ -187,7 +187,7 @@ class xr extends za {
eid: this.getEid(),
unknownAttributes: this.getUnknownAttributes(),
attributeOrder: this.getAttributeOrder(),
- version: gk
+ version: xk
};
}
// Mutation
@@ -195,18 +195,18 @@ class xr extends za {
return !1;
}
}
-function mk(e) {
- return lE.includes(e);
+function Tk(e) {
+ return hE.includes(e);
}
-function yk(e, t, n, r, i) {
- return St(new xr(e, t, n, r, void 0, i));
+function Ck(e, t, n, r, i) {
+ return St(new Tr(e, t, n, r, void 0, i));
}
function Ve(e) {
- return e instanceof xr;
+ return e instanceof Tr;
}
-const Tp = "f", dE = [
+const vp = "f", yE = [
// Footnote
- Tp,
+ vp,
"fe",
"ef",
"efe",
@@ -217,42 +217,42 @@ const Tp = "f", dE = [
function dc(e) {
return e.startsWith("f") || e.startsWith("ef") ? "footnote" : "crossref";
}
-const pE = [
+const bE = [
"type",
"marker",
"caller",
"category",
"content"
-], bk = 1;
-class at extends vr {
+], vk = 1;
+class lt extends vr {
__marker;
__caller;
__isCollapsed;
__category;
__unknownAttributes;
- constructor(t = Tp, n, r = !0, i, s, o) {
- super(o), this.__marker = t, this.__caller = n ?? (dc(t) === "crossref" ? fk : ya), this.__isCollapsed = r, this.__category = i, this.__unknownAttributes = s;
+ constructor(t = vp, n, r = !0, i, s, o) {
+ super(o), this.__marker = t, this.__caller = n ?? (dc(t) === "crossref" ? mk : ya), this.__isCollapsed = r, this.__category = i, this.__unknownAttributes = s;
}
static getType() {
return "note";
}
static clone(t) {
const { __marker: n, __caller: r, __isCollapsed: i, __category: s, __unknownAttributes: o, __key: a } = t;
- return new at(n, r, i, s, o, a);
+ return new lt(n, r, i, s, o, a);
}
static importDOM() {
return {
- span: (t) => gE(t) ? {
- conversion: hE,
+ span: (t) => xE(t) ? {
+ conversion: kE,
priority: 1
} : null
};
}
static importJSON(t) {
- return Cp().updateFromJSON(t);
+ return Sp().updateFromJSON(t);
}
static isValidMarker(t, n) {
- return t !== void 0 && (dE.includes(t) || (n?.includes(t) ?? !1));
+ return t !== void 0 && (yE.includes(t) || (n?.includes(t) ?? !1));
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setCaller(t.caller).setIsCollapsed(t.isCollapsed).setCategory(t.category).setUnknownAttributes(t.unknownAttributes);
@@ -324,7 +324,7 @@ class at extends vr {
isCollapsed: this.getIsCollapsed(),
category: this.getCategory(),
unknownAttributes: this.getUnknownAttributes(),
- version: bk
+ version: vk
};
}
// Mutation
@@ -335,24 +335,24 @@ class at extends vr {
return !0;
}
}
-function hE(e) {
+function kE(e) {
const t = e.getAttribute("data-marker") ?? "f", n = e.getAttribute("data-caller") ?? "", r = e.classList.contains("collapsed");
- return { node: Cp(t, n, r) };
+ return { node: Sp(t, n, r) };
}
-function Cp(e, t, n, r, i) {
- return St(new at(e, t, n, r, i));
+function Sp(e, t, n, r, i) {
+ return St(new lt(e, t, n, r, i));
}
-function gE(e) {
+function xE(e) {
if (!e)
return !1;
const t = e.getAttribute("data-marker") ?? "";
- return at.isValidMarker(t) && e.classList.contains(at.getType());
+ return lt.isValidMarker(t) && e.classList.contains(lt.getType());
}
function K(e) {
- return e instanceof at;
+ return e instanceof lt;
}
-function mE(e) {
- return e?.type === at.getType();
+function TE(e) {
+ return e?.type === lt.getType();
}
var S;
(function(e) {
@@ -362,7 +362,7 @@ var v;
(function(e) {
e.Paragraph = "Paragraph", e.Character = "Character", e.Note = "Note", e.Milestone = "Milestone", e.Unknown = "Unknown";
})(v || (v = {}));
-const Kf = {
+const Ff = {
id: {
category: S.FileIdentification,
type: v.Paragraph,
@@ -3272,7 +3272,7 @@ const Kf = {
hasEndMarker: !1,
children: void 0
}
-}, ji = {
+}, Vi = {
DivisionMarks: { add: ["v", "c"], remove: [] },
Paragraphs: { add: ["p"], remove: [] },
Poetry: { add: ["q", "q1", "q2", "q3", "q4", "b"], remove: [] },
@@ -3299,14 +3299,14 @@ const Kf = {
],
remove: []
}
-}, Yg = {
- p: { children: ji },
- q: { children: ji },
- q1: { children: ji },
- q2: { children: ji },
- q3: { children: ji },
- q4: { children: ji },
- b: { children: ji },
+}, tm = {
+ p: { children: Vi },
+ q: { children: Vi },
+ q1: { children: Vi },
+ q2: { children: Vi },
+ q3: { children: Vi },
+ q4: { children: Vi },
+ b: { children: Vi },
qm: {
children: {
Paragraphs: { add: ["p"], remove: [] }
@@ -3353,7 +3353,7 @@ const Kf = {
}
};
function Rr(e) {
- const t = Object.hasOwn(Kf, e) ? Kf[e] : void 0, n = Object.hasOwn(Yg, e) ? Yg[e] : void 0;
+ const t = Object.hasOwn(Ff, e) ? Ff[e] : void 0, n = Object.hasOwn(tm, e) ? tm[e] : void 0;
if (!t)
return n?.category !== void 0 && n.type !== void 0 && n.description !== void 0 && n.hasEndMarker !== void 0 ? { ...n } : void 0;
if (!n)
@@ -3378,16 +3378,16 @@ function Rr(e) {
children: r
};
}
-const Wa = "", kk = "v", xk = "c", Vi = "fig", Xg = "tr", Uf = "esb", Tk = "esbe", Qg = "periph", Zg = "alt", em = /^t[hc]([rc]?)(\d+)(?:-(\d+))?$/, yE = {
+const Wa = "", Sk = "v", _k = "c", Wi = "fig", nm = "tr", zf = "esb", Ek = "esbe", rm = "periph", im = "alt", sm = /^t[hc]([rc]?)(\d+)(?:-(\d+))?$/, CE = {
"": "start",
c: "center",
r: "end"
};
-function tm(e) {
+function om(e) {
const [, , t, n] = e;
return n ? /^[1-5]$/.test(t) && /^[2-5]$/.test(n) && Number(n) > Number(t) : /^(?:[1-9]|1[0-2])$/.test(t);
}
-function nm(e) {
+function am(e) {
const t = e.charCodeAt(0);
return t >= 9 && t <= 13 ? !0 : t === 32 || // SPACE
t === 133 || // NEXT LINE
@@ -3400,24 +3400,24 @@ function nm(e) {
t === 8287 || // MEDIUM MATHEMATICAL SPACE
t === 8203;
}
-const bE = /[\u200D\u2003\u2002\u0020\u00A0\u202F\u2009\u200A\u3000\u200B\u200C\u2060\u200E\u200F]/;
-function kE(e) {
+const vE = /[\u200D\u2003\u2002\u0020\u00A0\u202F\u2009\u200A\u3000\u200B\u200C\u2060\u200E\u200F]/;
+function SE(e) {
let t = "", n = !1, r = "\0", i = -1;
for (let s = 0; s < e.length; s += 1) {
const o = e[s];
- o.charCodeAt(0) < 32 ? (n || (i = t.length, t += " "), n = !0) : !n && o === mo && s + 1 < e.length && nm(e[s + 1]) || (nm(o) ? (n || (i = t.length, t += o), n = !0) : bE.test(o) && o === r || (t += o, n = !1, i = -1)), (o === `
+ o.charCodeAt(0) < 32 ? (n || (i = t.length, t += " "), n = !0) : !n && o === yo && s + 1 < e.length && am(e[s + 1]) || (am(o) ? (n || (i = t.length, t += o), n = !0) : vE.test(o) && o === r || (t += o, n = !1, i = -1)), (o === `
` || o === "\r") && i >= 0 && (t = `${t.slice(0, i)}
${t.slice(i + 1)}`), r = o;
}
return t;
}
-function xE(e) {
+function _E(e) {
if (e.length === 0)
return !0;
const t = e[0];
return t === "*" ? !1 : !!(t === "\\" || t === "|" || /[\s\u200B]/.test(t));
}
-function TE(e, t) {
+function EE(e, t) {
let n = t;
for (; n < e.length; ) {
const r = e[n];
@@ -3433,17 +3433,17 @@ function TE(e, t) {
}
return { name: e.slice(t, n), next: n };
}
-function CE(e, t, n) {
+function ME(e, t, n) {
if (!n || !/^[\s\u00A0\u200B]*$/.test(e.slice(0, t)))
return !1;
const r = e[t + 1];
return r === void 0 || r === "\\" || /[\s\u00A0\u200B]/.test(r);
}
-const vE = /^(?:qt[1-5]?|ts)-[se]$/;
-function vp(e) {
- return vE.test(e) || mk(e);
+const PE = /^(?:qt[1-5]?|ts)-[se]$/;
+function _p(e) {
+ return PE.test(e) || Tk(e);
}
-function ju(e, t) {
+function Hu(e, t) {
let n = t;
for (; n < e.length && /[\s\u00A0\u200B]/.test(e[n]); )
n++;
@@ -3455,7 +3455,7 @@ function ju(e, t) {
n++;
return { word: i, next: n };
}
-function SE(e, t) {
+function AE(e, t) {
const n = [];
let r = 0;
for (let i = 0; i < e.length; i++) {
@@ -3466,10 +3466,10 @@ function SE(e, t) {
}
return n;
}
-function _E(e, t, n, r, i) {
+function wE(e, t, n, r, i) {
const s = [];
let o = 0;
- const a = SE(e, r);
+ const a = AE(e, r);
let c = 0, l;
const u = (d) => {
if (!d)
@@ -3489,19 +3489,19 @@ function _E(e, t, n, r, i) {
l = void 0, s.push({ kind: "noteEndingPlaceholder" }), o++;
continue;
}
- const C = e.indexOf("\\", o);
- let x = C === -1 ? e.length : C;
- c < a.length && (x = Math.min(x, a[c])), f(kE(e.slice(o, x))), o = x;
+ const T = e.indexOf("\\", o);
+ let x = T === -1 ? e.length : T;
+ c < a.length && (x = Math.min(x, a[c])), f(SE(e.slice(o, x))), o = x;
continue;
}
- const d = o, { name: p, next: m } = TE(e, o + 1);
+ const d = o, { name: p, next: m } = EE(e, o + 1);
o = m;
const h = () => {
for (; o < e.length && /[\s\u00A0\u200B]/.test(e[o]); )
o++;
};
if (p === "") {
- if (CE(e, d, i)) {
+ if (ME(e, d, i)) {
h(), s.push({ kind: "para", marker: "" });
continue;
}
@@ -3516,65 +3516,65 @@ function _E(e, t, n, r, i) {
p.slice(0, -1) === l && (l = void 0), s.push({ kind: "end", marker: p.slice(0, -1) });
continue;
}
- if (p === kk) {
- const { word: C, next: x } = ju(e, o);
- o = x, s.push({ kind: "verse", number: C });
+ if (p === Sk) {
+ const { word: T, next: x } = Hu(e, o);
+ o = x, s.push({ kind: "verse", number: T });
continue;
}
- if (p === xk) {
- const { word: C, next: x } = ju(e, o);
- o = x, l = void 0, s.push({ kind: "chapter", number: C });
+ if (p === _k) {
+ const { word: T, next: x } = Hu(e, o);
+ o = x, l = void 0, s.push({ kind: "chapter", number: T });
continue;
}
const g = p.startsWith("+"), y = g ? p.slice(1) : p, b = t(y)?.type;
- if (b === v.Note || b === void 0 && at.isValidMarker(p)) {
- const { word: C, next: x } = ju(e, o);
- o = x, l = p, s.push({ kind: "note", marker: p, caller: C });
+ if (b === v.Note || b === void 0 && lt.isValidMarker(p)) {
+ const { word: T, next: x } = Hu(e, o);
+ o = x, l = p, s.push({ kind: "note", marker: p, caller: T });
continue;
}
- if (b === v.Milestone || b === void 0 && vp(p)) {
- const C = RE(e, d, p, o);
- if (C)
- s.push(C.token), C.ejectedText && u(C.ejectedText), o = C.next;
+ if (b === v.Milestone || b === void 0 && _p(p)) {
+ const T = KE(e, d, p, o);
+ if (T)
+ s.push(T.token), T.ejectedText && u(T.ejectedText), o = T.next;
else {
const x = e.indexOf("\\", o), _ = x === -1 ? e.length : x;
u(e.slice(d, _)), o = _;
}
continue;
}
- b === v.Paragraph ? (h(), s.push({ kind: "para", marker: p })) : b === v.Character ? (h(), s.push({ kind: "charOpen", marker: y, isNested: g })) : zc(y) ? (h(), zc(y)?.shape === "para" ? s.push({ kind: "para", marker: p }) : s.push({ kind: "charOpen", marker: y, isNested: g })) : (h(), !(n || l !== void 0) || p === Uf || p === Tk ? s.push({ kind: "para", marker: p }) : s.push({ kind: "charOpen", marker: y, isNested: g }));
+ b === v.Paragraph ? (h(), s.push({ kind: "para", marker: p })) : b === v.Character ? (h(), s.push({ kind: "charOpen", marker: y, isNested: g })) : jc(y) ? (h(), jc(y)?.shape === "para" ? s.push({ kind: "para", marker: p }) : s.push({ kind: "charOpen", marker: y, isNested: g })) : (h(), !(n || l !== void 0) || p === zf || p === Ek ? s.push({ kind: "para", marker: p }) : s.push({ kind: "charOpen", marker: y, isNested: g }));
}
return s;
}
-const rm = {
+const cm = {
ca: { attrName: "altnumber", targetTypes: ["chapter"], shape: "char" },
cp: { attrName: "pubnumber", targetTypes: ["chapter"], shape: "para" },
va: { attrName: "altnumber", targetTypes: ["verse"], shape: "char" },
vp: { attrName: "pubnumber", targetTypes: ["verse"], shape: "char" },
cat: { attrName: "category", targetTypes: ["note", "sidebar"], shape: "char" }
-}, EE = {
+}, NE = {
chapter: ["ca", "cp"],
verse: ["va", "vp"],
note: ["cat"],
sidebar: ["cat"]
};
-function zc(e) {
- return Object.hasOwn(rm, e) ? rm[e] : void 0;
+function jc(e) {
+ return Object.hasOwn(cm, e) ? cm[e] : void 0;
}
-function ME(e) {
- return zc(e) !== void 0;
+function OE(e) {
+ return jc(e) !== void 0;
}
-const PE = /([-\w]+)\s*=\s*"(.*?)"/g, AE = /[\s\u200B]*[\n\r][\s\u200B]*/g, Ck = {
+const $E = /([-\w]+)\s*=\s*"(.*?)"/g, RE = /[\s\u200B]*[\n\r][\s\u200B]*/g, Mk = {
w: "lemma",
rb: "gloss",
xt: "link-href",
jmp: "link-href"
};
-function Ao(e) {
- return Ck[e];
+function wo(e) {
+ return Mk[e];
}
-const wE = /* @__PURE__ */ new Set(["type", "marker", "content"]);
-function NE(e, t) {
+const IE = /* @__PURE__ */ new Set(["type", "marker", "content"]);
+function LE(e, t) {
let n = 0;
for (const r of t) {
const i = r.index;
@@ -3584,13 +3584,13 @@ function NE(e, t) {
}
return e.slice(n).trim() === "";
}
-function ba(e, t, n = Ck[t]) {
- const r = e.replace(AE, " "), i = /* @__PURE__ */ Object.create(null), s = [...r.matchAll(PE)];
+function ba(e, t, n = Mk[t]) {
+ const r = e.replace(RE, " "), i = /* @__PURE__ */ Object.create(null), s = [...r.matchAll($E)];
if (s.length > 0) {
- if (!NE(r, s) || s.some((o) => o[2] === ""))
+ if (!LE(r, s) || s.some((o) => o[2] === ""))
return;
for (const [, o, a] of s)
- wE.has(o) || (i[o] = a);
+ IE.has(o) || (i[o] = a);
return Object.keys(i).length > 0 ? i : void 0;
}
if (r.trim() && n)
@@ -3599,11 +3599,11 @@ function ba(e, t, n = Ck[t]) {
function Ha(e) {
return e.endsWith("-e") ? "eid" : e.startsWith("qt") ? "who" : "sid";
}
-function OE(e) {
- const t = Ul(e)[0], n = typeof t == "object" && "content" in t ? t.content : void 0;
+function qE(e) {
+ const t = Fl(e)[0], n = typeof t == "object" && "content" in t ? t.content : void 0;
return n ? n.some((r, i) => typeof r != "object" || r.type !== "ms" || typeof n[i + 1] != "string" ? !1 : n.slice(i + 2).some((s) => typeof s != "string" && s.type === "unmatched" && s.marker === "*")) : !1;
}
-function $E(e, t, n) {
+function DE(e, t, n) {
let r = t;
for (; r < e.length && /[\s\u00A0\u200B]/.test(e[r]); )
r++;
@@ -3616,7 +3616,7 @@ function $E(e, t, n) {
if (s)
return { attributes: s, next: i + 2 };
}
-function RE(e, t, n, r) {
+function KE(e, t, n, r) {
const i = e.indexOf("\\", r);
if (i === -1 || e.slice(i, i + 2) !== "\\*")
return;
@@ -3637,7 +3637,7 @@ function RE(e, t, n, r) {
next: i,
ejectedText: c.replace(/^[ \u00A0]/, "")
};
- const l = $E(e, i + 2, n);
+ const l = DE(e, i + 2, n);
return l ? {
token: {
kind: "milestone",
@@ -3649,87 +3649,87 @@ function RE(e, t, n, r) {
}
function Ar(e) {
return e.replaceAll(`
-`, " ").replaceAll("~", U);
+`, " ").replaceAll("~", B);
}
-function di(e) {
+function pi(e) {
return e.content || (e.content = []), e.content;
}
-function Ul(e, t) {
+function Fl(e, t) {
const n = [], r = t?.isNoteContext ?? !1;
let i, s;
const o = [];
let a = 0, c, l, u, f;
- const d = () => u ? di(u) : f ? di(f) : n;
+ const d = () => u ? pi(u) : f ? pi(f) : n;
let p = !1;
const m = () => {
if (s)
- return o.length > a ? di(o[o.length - 1].object) : di(s);
+ return o.length > a ? pi(o[o.length - 1].object) : pi(s);
if (o.length > 0)
- return di(o[o.length - 1].object);
+ return pi(o[o.length - 1].object);
if (!i) {
if (p && !r)
return d();
- i = { type: "para", marker: Ln, content: [] }, d().push(i);
+ i = { type: "para", marker: qn, content: [] }, d().push(i);
}
- return di(i);
+ return pi(i);
}, h = (ie) => {
- const B = m();
- typeof ie == "string" && typeof B[B.length - 1] == "string" ? B[B.length - 1] = B[B.length - 1] + ie : B.push(ie);
+ const F = m();
+ typeof ie == "string" && typeof F[F.length - 1] == "string" ? F[F.length - 1] = F[F.length - 1] + ie : F.push(ie);
}, g = (ie) => {
- for (let B = ie; B < o.length; B += 1) {
- const ue = o[B].object;
+ for (let F = ie; F < o.length; F += 1) {
+ const ue = o[F].object;
ue.closed = "false";
}
}, y = () => {
g(0), o.length = 0;
}, b = (ie) => {
s && (o.length > a && (g(a), o.length = a), a = 0, ie || (s.closed = "false"), s = void 0);
- }, C = () => {
+ }, T = () => {
c = void 0, l = void 0;
- }, x = (ie, B, ue) => {
+ }, x = (ie, F, ue) => {
y();
- const [, we, $e, mt] = ue, At = {
+ const [, we, $e, yt] = ue, At = {
type: "table:cell",
- marker: mt ? B.slice(0, B.indexOf("-")) : B,
- align: yE[we],
+ marker: yt ? F.slice(0, F.indexOf("-")) : F,
+ align: CE[we],
content: []
};
- mt && (At.colspan = String(Number(mt) + 1 - Number($e))), di(ie).push(At), i = At;
+ yt && (At.colspan = String(Number(yt) + 1 - Number($e))), pi(ie).push(At), i = At;
}, _ = (ie) => {
u && (ie || (u.closed = "false"), u = void 0);
- }, F = () => {
+ }, U = () => {
f = void 0;
};
- let R, W = -1;
+ let I, V = -1;
const ce = (ie) => {
- R = ie, W = -1;
+ I = ie, V = -1;
};
let se = "", Y;
const be = () => {
se && h(Ar(se)), se = "";
}, Se = (ie = !1) => {
- R?.type === "sidebar" ? se = "" : ie && se.endsWith(`
-`) && (se = se.slice(0, -1)), R = void 0, be();
- }, Fe = () => {
+ I?.type === "sidebar" ? se = "" : ie && se.endsWith(`
+`) && (se = se.slice(0, -1)), I = void 0, be();
+ }, Ue = () => {
if (!Y)
return;
const ie = { type: "char", marker: Y.marker, content: [] };
Y.value && (ie.content = [Ar(Y.value)]), m().push(ie), o.push({ object: ie }), Y = void 0;
- }, I = (ie, B) => {
- p = !1, C(), y(), b(!1), i = { type: "para", marker: ie, content: [] }, B && (i.content = [Ar(B)]), d().push(i);
+ }, R = (ie, F) => {
+ p = !1, T(), y(), b(!1), i = { type: "para", marker: ie, content: [] }, F && (i.content = [Ar(F)]), d().push(i);
}, q = () => {
- Y && (I(Y.marker, Y.value), Y = void 0);
+ Y && (R(Y.marker, Y.value), Y = void 0);
};
let j;
const ne = (ie) => {
if (!j)
return;
- let { value: B } = j;
- j = void 0, ie && B.endsWith(`
-`) && (B = B.slice(0, -1));
- const ue = B.indexOf("|"), we = ue >= 0 ? ba(B.slice(ue + 1), Qg) : void 0, $e = ue >= 0 ? B.slice(0, ue) : B, mt = ue >= 0 && (!we || !!$e && !!we[Zg]), At = mt ? void 0 : we, Ft = mt ? B : $e, cn = {
+ let { value: F } = j;
+ j = void 0, ie && F.endsWith(`
+`) && (F = F.slice(0, -1));
+ const ue = F.indexOf("|"), we = ue >= 0 ? ba(F.slice(ue + 1), rm) : void 0, $e = ue >= 0 ? F.slice(0, ue) : F, yt = ue >= 0 && (!we || !!$e && !!we[im]), At = yt ? void 0 : we, Ut = yt ? F : $e, cn = {
type: "periph",
- ...Ft ? { [Zg]: Ar(Ft) } : {},
+ ...Ut ? { [im]: Ar(Ut) } : {},
...At
};
cn.content = [], d().push(cn), f = cn, i = void 0;
@@ -3738,22 +3738,22 @@ function Ul(e, t) {
const X = () => {
if (N) {
if (N.shape === "para")
- I(Vi, N.value);
+ R(Wi, N.value);
else {
- const ie = { type: "char", marker: Vi, content: [] };
+ const ie = { type: "char", marker: Wi, content: [] };
N.value && (ie.content = [Ar(N.value)]), m().push(ie), o.push({ object: ie });
}
N = void 0;
}
- }, oe = _E(e, t?.getMarker ?? Rr, r, t?.placeholders ?? [], !r && t?.opensNamelessParagraph === !0);
+ }, oe = wE(e, t?.getMarker ?? Rr, r, t?.placeholders ?? [], !r && t?.opensNamelessParagraph === !0);
for (let ie = 0; ie < oe.length; ie++) {
- const B = oe[ie];
+ const F = oe[ie];
if (Y) {
- if (B.kind === "text") {
- Y.value += B.text;
+ if (F.kind === "text") {
+ Y.value += F.text;
continue;
}
- if (Y.shape === "char" && B.kind === "end" && B.marker.replace(/^\+/, "") === Y.marker) {
+ if (Y.shape === "char" && F.kind === "end" && F.marker.replace(/^\+/, "") === Y.marker) {
if (Y.value.trim() === "") {
m().push({ type: "char", marker: Y.marker, content: [] }), Y = void 0, Se();
continue;
@@ -3768,76 +3768,76 @@ function Ul(e, t) {
}
continue;
}
- if (Y.shape === "para" && (B.kind === "para" || B.kind === "chapter")) {
+ if (Y.shape === "para" && (F.kind === "para" || F.kind === "chapter")) {
const ue = Y.value.replace(/[\s\u200B]+$/, "");
- ue === "" ? (I(Y.marker), Y = void 0) : (Object.assign(Y.target, { [Y.attrName]: Ar(ue) }), Y = void 0);
+ ue === "" ? (R(Y.marker), Y = void 0) : (Object.assign(Y.target, { [Y.attrName]: Ar(ue) }), Y = void 0);
} else {
- R = void 0, (B.kind === "para" || B.kind === "chapter") && Y.value.endsWith(`
-`) && (Y.value = Y.value.slice(0, -1)), Y.shape === "para" ? q() : Fe(), ie--;
+ I = void 0, (F.kind === "para" || F.kind === "chapter") && Y.value.endsWith(`
+`) && (Y.value = Y.value.slice(0, -1)), Y.shape === "para" ? q() : Ue(), ie--;
continue;
}
}
if (j) {
- if (B.kind === "text" || B.kind === "optbreak") {
- j.value += B.kind === "text" ? B.text : "//";
+ if (F.kind === "text" || F.kind === "optbreak") {
+ j.value += F.kind === "text" ? F.text : "//";
continue;
}
- ne(B.kind === "para" || B.kind === "chapter"), ie--;
+ ne(F.kind === "para" || F.kind === "chapter"), ie--;
continue;
}
if (N) {
- if (B.kind === "text" || B.kind === "optbreak") {
- N.value += B.kind === "text" ? B.text : "//";
+ if (F.kind === "text" || F.kind === "optbreak") {
+ N.value += F.kind === "text" ? F.text : "//";
continue;
}
- if (B.kind === "end" && B.marker.replace(/^\+/, "") === Vi) {
- const ue = N.value.indexOf("|"), we = ue >= 0 ? ba(N.value.slice(ue + 1), Vi) : void 0;
+ if (F.kind === "end" && F.marker.replace(/^\+/, "") === Wi) {
+ const ue = N.value.indexOf("|"), we = ue >= 0 ? ba(N.value.slice(ue + 1), Wi) : void 0;
if (we) {
const $e = {};
- for (const [Ft, cn] of Object.entries(we))
- $e[Ft === "src" ? "file" : Ft] = cn;
- const mt = {
+ for (const [Ut, cn] of Object.entries(we))
+ $e[Ut === "src" ? "file" : Ut] = cn;
+ const yt = {
type: "figure",
- marker: Vi,
+ marker: Wi,
...$e
}, At = N.value.slice(0, ue);
- At && (mt.content = [Ar(At)]), h(mt), N = void 0;
+ At && (yt.content = [Ar(At)]), h(yt), N = void 0;
continue;
}
}
X(), ie--;
continue;
}
- if (R)
- if (B.kind === "text") {
- if (B.text.includes(`
-`) && /^[\s\u200B]*$/.test(B.text)) {
- se += B.text;
+ if (I)
+ if (F.kind === "text") {
+ if (F.text.includes(`
+`) && /^[\s\u200B]*$/.test(F.text)) {
+ se += F.text;
continue;
}
Se();
- } else if (B.kind === "charOpen" || B.kind === "para") {
- const ue = B.kind === "para" || !B.isNested ? zc(B.marker) : void 0, we = EE[R.type]?.indexOf(B.marker) ?? -1;
- if (ue && ue.targetTypes.includes(R.type) && we > W) {
- W = we, se = "", Y = {
- target: R,
+ } else if (F.kind === "charOpen" || F.kind === "para") {
+ const ue = F.kind === "para" || !F.isNested ? jc(F.marker) : void 0, we = NE[I.type]?.indexOf(F.marker) ?? -1;
+ if (ue && ue.targetTypes.includes(I.type) && we > V) {
+ V = we, se = "", Y = {
+ target: I,
attrName: ue.attrName,
- marker: B.marker,
+ marker: F.marker,
shape: ue.shape,
value: ""
};
continue;
}
- Se(B.kind === "para");
+ Se(F.kind === "para");
} else
- Se(B.kind === "chapter");
- if (!s && !r && (B.kind === "charOpen" && !B.isNested && B.marker === Vi || B.kind === "para" && B.marker === Vi)) {
- y(), N = { shape: B.kind === "charOpen" ? "char" : "para", value: "" };
+ Se(F.kind === "chapter");
+ if (!s && !r && (F.kind === "charOpen" && !F.isNested && F.marker === Wi || F.kind === "para" && F.marker === Wi)) {
+ y(), N = { shape: F.kind === "charOpen" ? "char" : "para", value: "" };
continue;
}
- switch (B.kind) {
+ switch (F.kind) {
case "text": {
- let ue = B.text;
+ let ue = F.text;
if (!s && ue.endsWith(`
`)) {
const we = oe[ie + 1];
@@ -3848,50 +3848,50 @@ function Ul(e, t) {
}
case "para": {
const ue = !s && !r;
- if (ue && B.marker === Xg) {
- y(), c || (c = { type: "table", content: [] }, d().push(c)), l = { type: "table:row", marker: Xg, content: [] }, di(c).push(l), i = l, p = !1;
+ if (ue && F.marker === nm) {
+ y(), c || (c = { type: "table", content: [] }, d().push(c)), l = { type: "table:row", marker: nm, content: [] }, pi(c).push(l), i = l, p = !1;
break;
}
if (ue && l) {
- const we = em.exec(B.marker);
- if (we && tm(we)) {
- x(l, B.marker, we);
+ const we = sm.exec(F.marker);
+ if (we && om(we)) {
+ x(l, F.marker, we);
break;
}
}
- if (C(), !r && B.marker === Uf) {
+ if (T(), !r && F.marker === zf) {
y(), b(!1), _(!1);
const we = {
type: "sidebar",
- marker: Uf,
+ marker: zf,
content: []
};
d().push(we), u = we, i = void 0, ce(u), p = !1;
break;
}
- if (B.marker === Tk && u) {
+ if (F.marker === Ek && u) {
y(), b(!1), _(!0), i = void 0;
break;
}
- if (!r && B.marker === Qg) {
- y(), b(!1), _(!1), F(), j = { value: "" }, i = void 0, p = !1;
+ if (!r && F.marker === rm) {
+ y(), b(!1), _(!1), U(), j = { value: "" }, i = void 0, p = !1;
break;
}
- I(B.marker);
+ R(F.marker);
break;
}
case "verse": {
b(!1);
- const ue = { type: "verse", marker: kk, number: B.number };
+ const ue = { type: "verse", marker: Sk, number: F.number };
h(ue), ce(ue);
break;
}
case "chapter": {
- y(), b(!1), C(), _(!1), F(), i = void 0;
+ y(), b(!1), T(), _(!1), U(), i = void 0;
const ue = {
type: "chapter",
- marker: xk,
- number: B.number
+ marker: _k,
+ number: F.number
};
n.push(ue), ce(ue), p = !0;
break;
@@ -3899,32 +3899,32 @@ function Ul(e, t) {
case "note": {
b(!1);
const ue = m();
- s = { type: "note", marker: B.marker, caller: B.caller, content: [] }, a = o.length, ue.push(s), ce(s);
+ s = { type: "note", marker: F.marker, caller: F.caller, content: [] }, a = o.length, ue.push(s), ce(s);
break;
}
case "charOpen": {
- if (!s && !r && l && !B.isNested) {
- const $e = em.exec(B.marker);
- if ($e && tm($e)) {
- x(l, B.marker, $e);
+ if (!s && !r && l && !F.isNested) {
+ const $e = sm.exec(F.marker);
+ if ($e && om($e)) {
+ x(l, F.marker, $e);
break;
}
}
- if (!B.isNested) {
+ if (!F.isNested) {
const $e = s ? a : 0;
g($e), o.length = $e;
}
- const ue = m(), we = { type: "char", marker: B.marker, content: [] };
+ const ue = m(), we = { type: "char", marker: F.marker, content: [] };
ue.push(we), o.push({ object: we });
break;
}
case "end": {
- const ue = B.marker.replace(/^\+/, ""), we = s ? a : 0, $e = o.findLastIndex((mt, At) => At >= we && mt.object.marker === ue);
- $e >= 0 ? (IE(o[$e].object), g($e + 1), o.length = $e) : s && s.marker === ue ? b(!0) : (g(we), o.length = we, h({ type: "unmatched", marker: `${B.marker}*` }));
+ const ue = F.marker.replace(/^\+/, ""), we = s ? a : 0, $e = o.findLastIndex((yt, At) => At >= we && yt.object.marker === ue);
+ $e >= 0 ? (BE(o[$e].object), g($e + 1), o.length = $e) : s && s.marker === ue ? b(!0) : (g(we), o.length = we, h({ type: "unmatched", marker: `${F.marker}*` }));
break;
}
case "milestone":
- h({ type: "ms", marker: B.marker, ...B.attributes });
+ h({ type: "ms", marker: F.marker, ...F.attributes });
break;
case "optbreak":
h({ type: "optbreak" });
@@ -3937,18 +3937,18 @@ function Ul(e, t) {
if (j && ne(!0), N && X(), Y)
if (Y.shape === "para") {
const ie = Y.value.replace(/[\s\u200B]+$/, "");
- ie === "" ? I(Y.marker) : Object.assign(Y.target, { [Y.attrName]: Ar(ie) }), Y = void 0;
+ ie === "" ? R(Y.marker) : Object.assign(Y.target, { [Y.attrName]: Ar(ie) }), Y = void 0;
} else
Y.value.endsWith(`
-`) && (Y.value = Y.value.slice(0, -1)), Fe();
+`) && (Y.value = Y.value.slice(0, -1)), Ue();
y(), b(!1), _(!1);
- const me = (ie) => {
- for (const B of ie)
- typeof B != "string" && B.content && (me(B.content), B.content.length === 0 && delete B.content);
+ const he = (ie) => {
+ for (const F of ie)
+ typeof F != "string" && F.content && (he(F.content), F.content.length === 0 && delete F.content);
};
- return me(n), n;
+ return he(n), n;
}
-function IE(e) {
+function BE(e) {
const t = e.content;
if (!t || t.length === 0)
return;
@@ -3968,38 +3968,38 @@ function IE(e) {
const a = i.slice(0, s);
t.length = r, a && t.push(a), Object.assign(e, o);
}
-function rt(e, t = !1) {
+function it(e, t = !1) {
return `\\${t ? "+" : ""}${e}`;
}
function pt(e, t = !1) {
return `\\${t ? "+" : ""}${e}*`;
}
function lr(e, t) {
- const n = `${rt(e)}${U}`;
+ const n = `${it(e)}${B}`;
return t ? `${n}${t} ` : n;
}
function qt(e) {
- return " " + e + U;
+ return " " + e + B;
}
-function im(e, t) {
- return e === t || (e === " " || e === U) && (t === " " || t === U);
+function lm(e, t) {
+ return e === t || (e === " " || e === B) && (t === " " || t === B);
}
-function Fl(e, t) {
+function zl(e, t) {
const n = qt(t);
let r = 0;
- for (; r < e.length && r < n.length && im(e[r], n[r]); )
+ for (; r < e.length && r < n.length && lm(e[r], n[r]); )
r += 1;
let i = 0;
- for (; i < e.length - r && i < n.length - r && im(e[e.length - 1 - i], n[n.length - 1 - i]); )
+ for (; i < e.length - r && i < n.length - r && lm(e[e.length - 1 - i], n[n.length - 1 - i]); )
i += 1;
return { start: r, end: e.length - i, missing: r + i < n.length };
}
-function Sp(e, t) {
- const { start: n, end: r } = Fl(e, t);
- return e.slice(n, r).replaceAll(U, " ");
+function Ep(e, t) {
+ const { start: n, end: r } = zl(e, t);
+ return e.slice(n, r).replaceAll(B, " ");
}
-const LE = 1;
-class Yn extends it {
+const UE = 1;
+class Yn extends at {
__marker;
__markerSyntax;
__nested;
@@ -4008,7 +4008,7 @@ class Yn extends it {
// slotting a new field ahead of it would silently reinterpret an existing 3-argument call's
// `NodeKey` as this flag.
constructor(t = "", n = "opening", r, i = !1) {
- super(Zi(t, n, i), r), this.__marker = t, this.__markerSyntax = n, this.__nested = i;
+ super(es(t, n, i), r), this.__marker = t, this.__markerSyntax = n, this.__nested = i;
}
static getType() {
return "marker";
@@ -4025,7 +4025,7 @@ class Yn extends it {
// An EMPTY serialized text is the "build canonical bytes" sentinel — the adaptor's
// createMarker serializes glyphs with `text: ""` and relies on the import deriving them.
// Any non-empty text is the glyph's actual displayed bytes and is kept verbatim.
- text: t.text || Zi(n, r, i)
+ text: t.text || es(n, r, i)
}).getWritable();
return o.__marker = n, o.__markerSyntax = r, o.__nested = i, o;
}
@@ -4033,7 +4033,7 @@ class Yn extends it {
if (this.__marker === t)
return this;
const n = this.getWritable();
- return n.__marker = t, n.__text = Zi(t, n.__markerSyntax, n.__nested), n;
+ return n.__marker = t, n.__text = es(t, n.__markerSyntax, n.__nested), n;
}
getMarker() {
return this.getLatest().__marker;
@@ -4042,7 +4042,7 @@ class Yn extends it {
if (this.__markerSyntax === t)
return this;
const n = this.getWritable();
- return n.__markerSyntax = t, n.__text = Zi(n.__marker, t, n.__nested), n;
+ return n.__markerSyntax = t, n.__text = es(n.__marker, t, n.__nested), n;
}
getMarkerSyntax() {
return this.getLatest().__markerSyntax;
@@ -4051,7 +4051,7 @@ class Yn extends it {
if (this.__nested === t)
return this;
const n = this.getWritable();
- return n.__nested = t, n.__text = Zi(n.__marker, n.__markerSyntax, t), n;
+ return n.__nested = t, n.__text = es(n.__marker, n.__markerSyntax, t), n;
}
getNested() {
return this.getLatest().__nested;
@@ -4074,7 +4074,7 @@ class Yn extends it {
// Only serialize the flag for genuinely nested glyphs; absence means non-nested, so
// existing states (and the overwhelmingly common non-nested markers) stay unchanged.
...this.getNested() ? { nested: !0 } : {},
- version: LE
+ version: UE
};
}
}
@@ -4084,38 +4084,38 @@ function Jt(e, t, n) {
function $(e) {
return e instanceof Yn;
}
-function wo(e) {
+function No(e) {
return e?.type === Yn.getType();
}
function Sr(e) {
- return e.getTextContent() === Zi(e.getMarker(), e.getMarkerSyntax(), e.getNested());
+ return e.getTextContent() === es(e.getMarker(), e.getMarkerSyntax(), e.getNested());
}
-function qE(e) {
- e.setTextContent(Zi(e.getMarker(), e.getMarkerSyntax(), e.getNested()));
+function FE(e) {
+ e.setTextContent(es(e.getMarker(), e.getMarkerSyntax(), e.getNested()));
}
-function Zi(e, t, n = !1) {
- return t === "closing" ? pt(e, n) : t === "selfClosing" ? pt("") : rt(e, n);
+function es(e, t, n = !1) {
+ return t === "closing" ? pt(e, n) : t === "selfClosing" ? pt("") : it(e, n);
}
-const Vt = "internal-comment", DE = [Vt], vk = Object.freeze({}), Ff = Object.freeze({}), Bf = Object.freeze({}), zf = Object.freeze({}), jf = Object.freeze({}), KE = 1, Hi = /* @__PURE__ */ new Map(), Js = /* @__PURE__ */ new Map(), Gi = /* @__PURE__ */ new Map(), Ji = /* @__PURE__ */ new Map(), ka = /* @__PURE__ */ new WeakMap(), xa = /* @__PURE__ */ new WeakMap();
-function UE(e) {
+const Vt = "internal-comment", zE = [Vt], Pk = Object.freeze({}), jf = Object.freeze({}), Vf = Object.freeze({}), Wf = Object.freeze({}), Hf = Object.freeze({}), jE = 1, Gi = /* @__PURE__ */ new Map(), Js = /* @__PURE__ */ new Map(), Ji = /* @__PURE__ */ new Map(), Yi = /* @__PURE__ */ new Map(), ka = /* @__PURE__ */ new WeakMap(), xa = /* @__PURE__ */ new WeakMap();
+function VE(e) {
return ka.set(e, []), xa.set(e, /* @__PURE__ */ new Map()), () => {
ka.delete(e), xa.delete(e);
};
}
-function FE(e) {
+function WE(e) {
const t = ka.get(e);
return t ? (ka.set(e, []), t) : [];
}
-const jc = /* @__PURE__ */ new WeakMap();
+const Vc = /* @__PURE__ */ new WeakMap();
function Mc(e, t) {
return JSON.stringify([e, t]);
}
-function sm(e, t, n, r) {
- let i = jc.get(e);
- r ? (i || jc.set(e, i = /* @__PURE__ */ new Set()), i.add(Mc(t, n))) : (i?.delete(Mc(t, n)), xa.get(e)?.delete(Mc(t, n)));
+function um(e, t, n, r) {
+ let i = Vc.get(e);
+ r ? (i || Vc.set(e, i = /* @__PURE__ */ new Set()), i.add(Mc(t, n))) : (i?.delete(Mc(t, n)), xa.get(e)?.delete(Mc(t, n)));
}
-function BE(e) {
- jc.delete(e), xa.get(e)?.clear();
+function HE(e) {
+ Vc.delete(e), xa.get(e)?.clear();
}
function pc(e, t, n, r) {
const i = e.get(t), s = i?.[n];
@@ -4124,8 +4124,8 @@ function pc(e, t, n, r) {
const o = wr(s, r), a = Object.keys(o).length > 0 ? { ...i, [n]: o } : wr(i, n);
Object.keys(a).length > 0 ? e.set(t, a) : e.delete(t);
}
-function zE(e, t, n) {
- pc(Hi, e, t, n), pc(Js, e, t, n), pc(Gi, e, t, n), pc(Ji, e, t, n);
+function GE(e, t, n) {
+ pc(Gi, e, t, n), pc(Js, e, t, n), pc(Ji, e, t, n), pc(Yi, e, t, n);
}
class vt extends vr {
__typedIDs;
@@ -4137,36 +4137,36 @@ class vt extends vr {
__domOnMouseEnterListener;
__domOnMouseLeaveListener;
__suppressOnRemoveCallbacks;
- constructor(t = vk, n, r, i, s, o) {
- super(o), this.__typedIDs = hc(t), this.__typedOnClicks = Vu(n), this.__typedOnRemoves = Wu(r), this.__typedOnMouseEnters = Hu(i), this.__typedOnMouseLeaves = Gu(s), this.pruneTypedOnClicks(), this.pruneTypedOnRemoves(), this.pruneTypedOnMouseEnters(), this.pruneTypedOnMouseLeaves(), this.syncTypedOnClicksToRegistry(), this.syncTypedOnRemovesToRegistry(), this.syncTypedOnMouseEntersToRegistry(), this.syncTypedOnMouseLeavesToRegistry();
+ constructor(t = Pk, n, r, i, s, o) {
+ super(o), this.__typedIDs = hc(t), this.__typedOnClicks = Gu(n), this.__typedOnRemoves = Ju(r), this.__typedOnMouseEnters = Yu(i), this.__typedOnMouseLeaves = Xu(s), this.pruneTypedOnClicks(), this.pruneTypedOnRemoves(), this.pruneTypedOnMouseEnters(), this.pruneTypedOnMouseLeaves(), this.syncTypedOnClicksToRegistry(), this.syncTypedOnRemovesToRegistry(), this.syncTypedOnMouseEntersToRegistry(), this.syncTypedOnMouseLeavesToRegistry();
}
static getType() {
return "typed-mark";
}
static clone(t) {
- const n = hc(t.__typedIDs), r = Vu(t.__typedOnClicks), i = Wu(t.__typedOnRemoves), s = Hu(t.__typedOnMouseEnters), o = Gu(t.__typedOnMouseLeaves);
+ const n = hc(t.__typedIDs), r = Gu(t.__typedOnClicks), i = Ju(t.__typedOnRemoves), s = Yu(t.__typedOnMouseEnters), o = Xu(t.__typedOnMouseLeaves);
return new vt(n, r, i, s, o, t.__key);
}
static isReservedType(t) {
- return DE.includes(t);
+ return zE.includes(t);
}
static importDOM() {
return null;
}
static importJSON(t) {
- return us().updateFromJSON(t);
+ return fs().updateFromJSON(t);
}
exportJSON() {
return {
...super.exportJSON(),
type: this.getType(),
typedIDs: this.getTypedIDs(),
- version: KE
+ version: jE
};
}
createDOM(t, n) {
const r = document.createElement("mark");
- Zo(r, ...Sk(t.theme, this.__typedIDs));
+ ea(r, ...Ak(t.theme, this.__typedIDs));
const i = this.getOrCreateDOMClickListener(n);
r.addEventListener("click", i);
const s = this.getOrCreateDOMMouseEnterListener(n);
@@ -4180,13 +4180,13 @@ class vt extends vr {
...Object.keys(this.__typedIDs ?? {})
]);
for (const s of i) {
- const o = t.__typedIDs[s] ?? [], a = this.__typedIDs[s] ?? [], c = o.length, l = a.length, u = rs(r.theme.typedMark, s), f = rs(r.theme.typedMarkOverlap, s);
- c !== l && (c === 0 ? l === 1 && Zo(n, u) : l === 0 && _c(n, u), c === 1 ? l === 2 && Zo(n, f) : l === 1 && _c(n, f));
+ const o = t.__typedIDs[s] ?? [], a = this.__typedIDs[s] ?? [], c = o.length, l = a.length, u = is(r.theme.typedMark, s), f = is(r.theme.typedMarkOverlap, s);
+ c !== l && (c === 0 ? l === 1 && ea(n, u) : l === 0 && _c(n, u), c === 1 ? l === 2 && ea(n, f) : l === 1 && _c(n, f));
const d = new Set(o), p = new Set(a);
for (const m of o)
- p.has(m) || _c(n, rs("annotationId", m));
+ p.has(m) || _c(n, is("annotationId", m));
for (const m of a)
- d.has(m) || Zo(n, rs("annotationId", m));
+ d.has(m) || ea(n, is("annotationId", m));
}
return !1;
}
@@ -4204,49 +4204,49 @@ class vt extends vr {
}
getTypedIDs() {
const t = this.getLatest();
- return ge(t) ? t.__typedIDs : {};
+ return me(t) ? t.__typedIDs : {};
}
setTypedIDs(t) {
const n = this.getWritable(), r = hc(n.__typedIDs);
n.__typedIDs = hc(t), n.dispatchRemovedIDs(r, n.__typedIDs, "removed"), n.pruneTypedOnClicks(), n.pruneTypedOnRemoves(), n.pruneTypedOnMouseEnters(), n.pruneTypedOnMouseLeaves(), n.syncTypedOnClicksToRegistry(), n.syncTypedOnRemovesToRegistry(), n.syncTypedOnMouseEntersToRegistry(), n.syncTypedOnMouseLeavesToRegistry();
const i = n.mergeWithAdjacentTypedMarks();
- return i.hasNoIDsForEveryType() && i.getParent() !== null && Vf(i), i;
+ return i.hasNoIDsForEveryType() && i.getParent() !== null && Gf(i), i;
}
setTypedOnClicks(t) {
const n = this.getWritable();
- return n.__typedOnClicks = Vu(t), n.pruneTypedOnClicks(), n.syncTypedOnClicksToRegistry(), n;
+ return n.__typedOnClicks = Gu(t), n.pruneTypedOnClicks(), n.syncTypedOnClicksToRegistry(), n;
}
getTypedOnClicks() {
const t = this.getLatest();
- return ge(t) ? Hi.get(t.getKey()) ?? {} : {};
+ return me(t) ? Gi.get(t.getKey()) ?? {} : {};
}
setTypedOnRemoves(t) {
const n = this.getWritable();
- return n.__typedOnRemoves = Wu(t), n.pruneTypedOnRemoves(), n.syncTypedOnRemovesToRegistry(), n;
+ return n.__typedOnRemoves = Ju(t), n.pruneTypedOnRemoves(), n.syncTypedOnRemovesToRegistry(), n;
}
getTypedOnRemoves() {
const t = this.getLatest();
- return ge(t) ? Js.get(t.getKey()) ?? {} : {};
+ return me(t) ? Js.get(t.getKey()) ?? {} : {};
}
setTypedOnMouseEnters(t) {
const n = this.getWritable();
- return n.__typedOnMouseEnters = Hu(t), n.pruneTypedOnMouseEnters(), n.syncTypedOnMouseEntersToRegistry(), n;
+ return n.__typedOnMouseEnters = Yu(t), n.pruneTypedOnMouseEnters(), n.syncTypedOnMouseEntersToRegistry(), n;
}
getTypedOnMouseEnters() {
const t = this.getLatest();
- return ge(t) ? Gi.get(t.getKey()) ?? {} : {};
+ return me(t) ? Ji.get(t.getKey()) ?? {} : {};
}
setTypedOnMouseLeaves(t) {
const n = this.getWritable();
- return n.__typedOnMouseLeaves = Gu(t), n.pruneTypedOnMouseLeaves(), n.syncTypedOnMouseLeavesToRegistry(), n;
+ return n.__typedOnMouseLeaves = Xu(t), n.pruneTypedOnMouseLeaves(), n.syncTypedOnMouseLeavesToRegistry(), n;
}
getTypedOnMouseLeaves() {
const t = this.getLatest();
- return ge(t) ? Ji.get(t.getKey()) ?? {} : {};
+ return me(t) ? Yi.get(t.getKey()) ?? {} : {};
}
addID(t, n, r, i, s, o) {
const a = this.getWritable();
- if (!ge(a))
+ if (!me(a))
return;
wt(t), wt(n);
let c = a.__typedIDs[t];
@@ -4260,7 +4260,7 @@ class vt extends vr {
}
deleteID(t, n) {
const r = this.getWritable();
- if (!ge(r))
+ if (!me(r))
return;
const i = r.__typedIDs[t];
if (!i || i.length === 0)
@@ -4272,13 +4272,13 @@ class vt extends vr {
}
r.removeOnClickFor(t, n), r.removeOnRemoveFor(t, n), r.removeOnMouseEnterFor(t, n), r.removeOnMouseLeaveFor(t, n), r.pruneTypedOnClicks(), r.pruneTypedOnRemoves(), r.pruneTypedOnMouseEnters(), r.pruneTypedOnMouseLeaves();
const s = r.mergeWithAdjacentTypedMarks();
- s.hasNoIDsForEveryType() && s.getParent() !== null && Vf(s);
+ s.hasNoIDsForEveryType() && s.getParent() !== null && Gf(s);
}
hasNoIDsForEveryType() {
return Object.values(this.getTypedIDs()).every((t) => t === void 0 || t.length === 0);
}
insertNewAfter(t, n = !0) {
- const r = us(this.__typedIDs, this.getTypedOnClicks());
+ const r = fs(this.__typedIDs, this.getTypedOnClicks());
return this.insertAfter(r, n), r;
}
canInsertTextBefore() {
@@ -4304,7 +4304,7 @@ class vt extends vr {
}
remove(t) {
const n = this.getWritable(), r = this.getTypedIDs();
- n.__suppressOnRemoveCallbacks ? n.__suppressOnRemoveCallbacks = void 0 : n.dispatchOnRemoveForTypedIDs(r, "destroyed"), Hi.delete(n.getKey()), Js.delete(n.getKey()), Gi.delete(n.getKey()), Ji.delete(n.getKey()), n.__typedOnClicks = void 0, n.__typedOnRemoves = void 0, n.__typedOnMouseEnters = void 0, n.__typedOnMouseLeaves = void 0, super.remove.call(n, t);
+ n.__suppressOnRemoveCallbacks ? n.__suppressOnRemoveCallbacks = void 0 : n.dispatchOnRemoveForTypedIDs(r, "destroyed"), Gi.delete(n.getKey()), Js.delete(n.getKey()), Ji.delete(n.getKey()), Yi.delete(n.getKey()), n.__typedOnClicks = void 0, n.__typedOnRemoves = void 0, n.__typedOnMouseEnters = void 0, n.__typedOnMouseLeaves = void 0, super.remove.call(n, t);
}
getOrCreateDOMClickListener(t) {
return this.__domOnClickListener || (this.__domOnClickListener = (n) => {
@@ -4312,7 +4312,7 @@ class vt extends vr {
}), this.__domOnClickListener;
}
handleDOMClick(t, n) {
- const r = Hi.get(this.getKey());
+ const r = Gi.get(this.getKey());
if (!r)
return;
const i = [];
@@ -4331,7 +4331,7 @@ class vt extends vr {
}), this.__domOnMouseEnterListener;
}
handleDOMMouseEnter(t, n) {
- const r = Gi.get(this.getKey());
+ const r = Ji.get(this.getKey());
if (!r)
return;
const i = [];
@@ -4350,7 +4350,7 @@ class vt extends vr {
}), this.__domOnMouseLeaveListener;
}
handleDOMMouseLeave(t, n) {
- const r = Ji.get(this.getKey());
+ const r = Yi.get(this.getKey());
if (!r)
return;
const i = [];
@@ -4364,18 +4364,18 @@ class vt extends vr {
o(t, a, c, s);
}
ensureOnClickMapMutable() {
- if (this.__typedOnClicks === void 0 || this.__typedOnClicks === Ff) {
- const t = Hi.get(this.getKey());
+ if (this.__typedOnClicks === void 0 || this.__typedOnClicks === jf) {
+ const t = Gi.get(this.getKey());
this.__typedOnClicks = t ?? {};
}
return this.__typedOnClicks;
}
syncTypedOnClicksToRegistry() {
if (!this.__typedOnClicks || Object.keys(this.__typedOnClicks).length === 0) {
- Hi.delete(this.getKey()), this.__typedOnClicks && Object.keys(this.__typedOnClicks).length === 0 && (this.__typedOnClicks = void 0);
+ Gi.delete(this.getKey()), this.__typedOnClicks && Object.keys(this.__typedOnClicks).length === 0 && (this.__typedOnClicks = void 0);
return;
}
- Hi.set(this.getKey(), this.__typedOnClicks);
+ Gi.set(this.getKey(), this.__typedOnClicks);
}
setOnClickFor(t, n, r) {
wt(t), wt(n);
@@ -4401,7 +4401,7 @@ class vt extends vr {
this.syncTypedOnClicksToRegistry();
}
pruneTypedOnClicks() {
- if (!this.__typedOnClicks || this.__typedOnClicks === Ff) {
+ if (!this.__typedOnClicks || this.__typedOnClicks === jf) {
this.__typedOnClicks = void 0, this.syncTypedOnClicksToRegistry();
return;
}
@@ -4418,7 +4418,7 @@ class vt extends vr {
this.__typedOnClicks = Object.keys(t).length > 0 ? t : void 0, this.syncTypedOnClicksToRegistry();
}
ensureOnRemoveMapMutable() {
- if (this.__typedOnRemoves === void 0 || this.__typedOnRemoves === Bf) {
+ if (this.__typedOnRemoves === void 0 || this.__typedOnRemoves === Vf) {
const t = Js.get(this.getKey());
this.__typedOnRemoves = t ?? {};
}
@@ -4455,7 +4455,7 @@ class vt extends vr {
this.syncTypedOnRemovesToRegistry();
}
pruneTypedOnRemoves() {
- if (!this.__typedOnRemoves || this.__typedOnRemoves === Bf) {
+ if (!this.__typedOnRemoves || this.__typedOnRemoves === Vf) {
this.__typedOnRemoves = void 0, this.syncTypedOnRemovesToRegistry();
return;
}
@@ -4472,18 +4472,18 @@ class vt extends vr {
this.__typedOnRemoves = Object.keys(t).length > 0 ? t : void 0, this.syncTypedOnRemovesToRegistry();
}
ensureOnMouseEnterMapMutable() {
- if (this.__typedOnMouseEnters === void 0 || this.__typedOnMouseEnters === zf) {
- const t = Gi.get(this.getKey());
+ if (this.__typedOnMouseEnters === void 0 || this.__typedOnMouseEnters === Wf) {
+ const t = Ji.get(this.getKey());
this.__typedOnMouseEnters = t ?? {};
}
return this.__typedOnMouseEnters;
}
syncTypedOnMouseEntersToRegistry() {
if (!this.__typedOnMouseEnters || Object.keys(this.__typedOnMouseEnters).length === 0) {
- Gi.delete(this.getKey()), this.__typedOnMouseEnters && Object.keys(this.__typedOnMouseEnters).length === 0 && (this.__typedOnMouseEnters = void 0);
+ Ji.delete(this.getKey()), this.__typedOnMouseEnters && Object.keys(this.__typedOnMouseEnters).length === 0 && (this.__typedOnMouseEnters = void 0);
return;
}
- Gi.set(this.getKey(), this.__typedOnMouseEnters);
+ Ji.set(this.getKey(), this.__typedOnMouseEnters);
}
setOnMouseEnterFor(t, n, r) {
wt(t), wt(n);
@@ -4509,7 +4509,7 @@ class vt extends vr {
this.syncTypedOnMouseEntersToRegistry();
}
pruneTypedOnMouseEnters() {
- if (!this.__typedOnMouseEnters || this.__typedOnMouseEnters === zf) {
+ if (!this.__typedOnMouseEnters || this.__typedOnMouseEnters === Wf) {
this.__typedOnMouseEnters = void 0, this.syncTypedOnMouseEntersToRegistry();
return;
}
@@ -4526,18 +4526,18 @@ class vt extends vr {
this.__typedOnMouseEnters = Object.keys(t).length > 0 ? t : void 0, this.syncTypedOnMouseEntersToRegistry();
}
ensureOnMouseLeaveMapMutable() {
- if (this.__typedOnMouseLeaves === void 0 || this.__typedOnMouseLeaves === jf) {
- const t = Ji.get(this.getKey());
+ if (this.__typedOnMouseLeaves === void 0 || this.__typedOnMouseLeaves === Hf) {
+ const t = Yi.get(this.getKey());
this.__typedOnMouseLeaves = t ?? {};
}
return this.__typedOnMouseLeaves;
}
syncTypedOnMouseLeavesToRegistry() {
if (!this.__typedOnMouseLeaves || Object.keys(this.__typedOnMouseLeaves).length === 0) {
- Ji.delete(this.getKey()), this.__typedOnMouseLeaves && Object.keys(this.__typedOnMouseLeaves).length === 0 && (this.__typedOnMouseLeaves = void 0);
+ Yi.delete(this.getKey()), this.__typedOnMouseLeaves && Object.keys(this.__typedOnMouseLeaves).length === 0 && (this.__typedOnMouseLeaves = void 0);
return;
}
- Ji.set(this.getKey(), this.__typedOnMouseLeaves);
+ Yi.set(this.getKey(), this.__typedOnMouseLeaves);
}
setOnMouseLeaveFor(t, n, r) {
wt(t), wt(n);
@@ -4563,7 +4563,7 @@ class vt extends vr {
this.syncTypedOnMouseLeavesToRegistry();
}
pruneTypedOnMouseLeaves() {
- if (!this.__typedOnMouseLeaves || this.__typedOnMouseLeaves === jf) {
+ if (!this.__typedOnMouseLeaves || this.__typedOnMouseLeaves === Hf) {
this.__typedOnMouseLeaves = void 0, this.syncTypedOnMouseLeavesToRegistry();
return;
}
@@ -4584,7 +4584,7 @@ class vt extends vr {
if (!s)
return;
const o = Pt(), a = Mc(t, n), c = xa.get(o);
- if (jc.get(o)?.has(a) || c?.get(a)?.has(this.getKey())) {
+ if (Vc.get(o)?.has(a) || c?.get(a)?.has(this.getKey())) {
this.removeOnRemoveFor(t, n);
return;
}
@@ -4600,7 +4600,7 @@ class vt extends vr {
this.removeOnRemoveFor(t, n);
}
dispatchRemovedIDs(t, n, r) {
- const i = jE(t, n);
+ const i = JE(t, n);
if (i.length !== 0)
for (const [s, o] of i)
this.invokeOnRemove(s, o, r);
@@ -4615,10 +4615,10 @@ class vt extends vr {
if (this.hasNoIDsForEveryType())
return this;
let t = this.getPreviousSibling();
- for (; ge(t) && am(t.getTypedIDs(), this.getTypedIDs()); )
+ for (; me(t) && dm(t.getTypedIDs(), this.getTypedIDs()); )
this.mergeWithPreviousTypedMark(t), t = this.getPreviousSibling();
let n = this.getNextSibling();
- for (; ge(n) && am(this.getTypedIDs(), n.getTypedIDs()); )
+ for (; me(n) && dm(this.getTypedIDs(), n.getTypedIDs()); )
this.mergeWithNextTypedMark(n), n = this.getNextSibling();
return this;
}
@@ -4635,29 +4635,29 @@ class vt extends vr {
mergeOnClicksFrom(t) {
if (!t || Object.keys(t).length === 0)
return;
- const n = VE(this.getTypedOnClicks(), t);
+ const n = YE(this.getTypedOnClicks(), t);
Object.keys(n).length !== 0 && this.setTypedOnClicks(n);
}
mergeOnRemovesFrom(t) {
if (!t || Object.keys(t).length === 0)
return;
- const n = WE(this.getTypedOnRemoves(), t);
+ const n = XE(this.getTypedOnRemoves(), t);
Object.keys(n).length !== 0 && this.setTypedOnRemoves(n);
}
mergeOnMouseEntersFrom(t) {
if (!t || Object.keys(t).length === 0)
return;
- const n = HE(this.getTypedOnMouseEnters(), t);
+ const n = QE(this.getTypedOnMouseEnters(), t);
Object.keys(n).length !== 0 && this.setTypedOnMouseEnters(n);
}
mergeOnMouseLeavesFrom(t) {
if (!t || Object.keys(t).length === 0)
return;
- const n = GE(this.getTypedOnMouseLeaves(), t);
+ const n = ZE(this.getTypedOnMouseLeaves(), t);
Object.keys(n).length !== 0 && this.setTypedOnMouseLeaves(n);
}
}
-function hc(e = vk) {
+function hc(e = Pk) {
const t = {};
for (const [n, r] of Object.entries(e)) {
if (wt(n), !Array.isArray(r)) {
@@ -4671,8 +4671,8 @@ function hc(e = vk) {
}
return t;
}
-function Vu(e) {
- if (!e || e === Ff)
+function Gu(e) {
+ if (!e || e === jf)
return;
const t = {};
for (const [n, r] of Object.entries(e)) {
@@ -4684,8 +4684,8 @@ function Vu(e) {
}
return Object.keys(t).length > 0 ? t : void 0;
}
-function Wu(e) {
- if (!e || e === Bf)
+function Ju(e) {
+ if (!e || e === Vf)
return;
const t = {};
for (const [n, r] of Object.entries(e)) {
@@ -4697,8 +4697,8 @@ function Wu(e) {
}
return Object.keys(t).length > 0 ? t : void 0;
}
-function Hu(e) {
- if (!e || e === zf)
+function Yu(e) {
+ if (!e || e === Wf)
return;
const t = {};
for (const [n, r] of Object.entries(e)) {
@@ -4710,8 +4710,8 @@ function Hu(e) {
}
return Object.keys(t).length > 0 ? t : void 0;
}
-function Gu(e) {
- if (!e || e === jf)
+function Xu(e) {
+ if (!e || e === Hf)
return;
const t = {};
for (const [n, r] of Object.entries(e)) {
@@ -4729,13 +4729,13 @@ function wr(e, t) {
r !== t && (n[r] = i);
return n;
}
-function om(e) {
+function fm(e) {
const t = {};
for (const [n, r] of Object.entries(e))
!r || r.length === 0 || (t[n] = [...r].sort());
return t;
}
-function jE(e, t) {
+function JE(e, t) {
const n = [];
for (const [r, i] of Object.entries(e)) {
const s = new Set(t[r] ?? []);
@@ -4744,8 +4744,8 @@ function jE(e, t) {
}
return n;
}
-function am(e, t) {
- const n = om(e), r = om(t), i = Object.keys(n).sort(), s = Object.keys(r).sort();
+function dm(e, t) {
+ const n = fm(e), r = fm(t), i = Object.keys(n).sort(), s = Object.keys(r).sort();
if (i.length !== s.length)
return !1;
for (let o = 0; o < i.length; o++) {
@@ -4761,7 +4761,7 @@ function am(e, t) {
}
return !0;
}
-function VE(e, t) {
+function YE(e, t) {
const n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
for (const i of r) {
const s = e[i] ?? {}, o = t[i] ?? {}, a = /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(o)]), c = {};
@@ -4773,7 +4773,7 @@ function VE(e, t) {
}
return n;
}
-function WE(e, t) {
+function XE(e, t) {
const n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
for (const i of r) {
const s = e[i] ?? {}, o = t[i] ?? {}, a = /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(o)]), c = {};
@@ -4785,7 +4785,7 @@ function WE(e, t) {
}
return n;
}
-function HE(e, t) {
+function QE(e, t) {
const n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
for (const i of r) {
const s = e[i] ?? {}, o = t[i] ?? {}, a = /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(o)]), c = {};
@@ -4797,7 +4797,7 @@ function HE(e, t) {
}
return n;
}
-function GE(e, t) {
+function ZE(e, t) {
const n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
for (const i of r) {
const s = e[i] ?? {}, o = t[i] ?? {}, a = /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(o)]), c = {};
@@ -4809,69 +4809,69 @@ function GE(e, t) {
}
return n;
}
-function rs(e, t) {
+function is(e, t) {
return `${e}-${t}`;
}
-function Sk(e, t) {
+function Ak(e, t) {
const n = [];
for (const [r, i] of Object.entries(t)) {
- n.push(rs(e.typedMark, r)), i.length > 1 && n.push(rs(e.typedMarkOverlap, r));
+ n.push(is(e.typedMark, r)), i.length > 1 && n.push(is(e.typedMarkOverlap, r));
for (const s of i)
- n.push(rs("annotationId", s));
+ n.push(is("annotationId", s));
}
return n;
}
-function Ju(e) {
+function Qu(e) {
return `external-${e}`;
}
-function us(e, t, n, r, i) {
+function fs(e, t, n, r, i) {
return St(new vt(e, t, n, r, i));
}
-function ge(e) {
+function me(e) {
return e instanceof vt;
}
-function fs(e) {
+function ds(e) {
return e?.type === vt.getType();
}
-function _k(e, t, n) {
+function wk(e, t, n) {
let r = 0;
for (const i of n) {
const s = ee(i);
- !ge(s) || !s.hasID(e, t) || (r++, s.deleteID(e, t), s.hasNoIDsForEveryType() && Vf(s));
+ !me(s) || !s.hasID(e, t) || (r++, s.deleteID(e, t), s.hasNoIDsForEveryType() && Gf(s));
}
return r;
}
-function Vf(e) {
+function Gf(e) {
const t = e.getChildren();
let n = null;
for (const r of t)
n === null ? e.insertBefore(r) : n.insertAfter(r), n = r;
e.remove();
}
-function JE(e, t, n) {
+function eM(e, t, n) {
let r = e;
for (; r !== null; ) {
- if (ge(r))
+ if (me(r))
return r.getTypedIDs()[t];
- if (T(r) && n === r.getTextContentSize()) {
+ if (C(r) && n === r.getTextContentSize()) {
const i = r.getNextSibling();
- if (ge(i))
+ if (me(i))
return i.getTypedIDs()[t];
}
r = r.getParent();
}
}
-const ds = ws("cid", {
+const ps = ws("cid", {
parse: (e) => typeof e == "string" ? e : void 0
-}), Mi = ws("segment", {
+}), Pi = ws("segment", {
parse: (e) => typeof e == "string" ? e : void 0
}), _e = ws("textType", {
parse: (e) => typeof e == "string" ? e : void 0
-}), Br = "marker-trailing-space", Ek = 1, YE = "attribute-run";
-function Yu(e) {
+}), zr = "marker-trailing-space", Nk = 1, tM = "attribute-run";
+function Zu(e) {
return e === "va" || e === "vp" || e === "ca" || e === "cp" ? `usfm_${e}` : void 0;
}
-class zr extends vr {
+class jr extends vr {
__runKind;
constructor(t, n) {
super(n), this.__runKind = t;
@@ -4881,10 +4881,10 @@ class zr extends vr {
}
static clone(t) {
const { __runKind: n, __key: r } = t;
- return new zr(n, r);
+ return new jr(n, r);
}
static importJSON(t) {
- return Mk(t.runKind).updateFromJSON(t);
+ return Ok(t.runKind).updateFromJSON(t);
}
// No HTML shape ever round-trips: `exportDOM` below contributes no wrapper element of its own
// (a DocumentFragment leaves no markup behind), so there is nothing for a paste to hand back
@@ -4909,15 +4909,15 @@ class zr extends vr {
}
createDOM() {
const t = document.createElement("span");
- t.classList.add(YE);
- const n = Yu(this.__runKind);
+ t.classList.add(tM);
+ const n = Zu(this.__runKind);
return n !== void 0 && t.classList.add(n), t;
}
updateDOM(t, n) {
if (t.__runKind !== this.__runKind) {
- const r = Yu(t.__runKind);
+ const r = Zu(t.__runKind);
r !== void 0 && n.classList.remove(r);
- const i = Yu(this.__runKind);
+ const i = Zu(this.__runKind);
i !== void 0 && n.classList.add(i);
}
return !1;
@@ -4930,7 +4930,7 @@ class zr extends vr {
...super.exportJSON(),
type: this.getType(),
runKind: this.getRunKind(),
- version: Ek
+ version: Nk
};
}
// Mutation
@@ -4941,13 +4941,13 @@ class zr extends vr {
return !0;
}
}
-function Mk(e) {
- return St(new zr(e));
+function Ok(e) {
+ return St(new jr(e));
}
function He(e) {
- return e instanceof zr;
+ return e instanceof jr;
}
-const Pk = [
+const $k = [
"fr",
"fq",
"fqa",
@@ -4960,7 +4960,7 @@ const Pk = [
"fm",
"fdc"
// Deprecated marker.
-], Ak = [
+], Rk = [
"xo",
"xop",
"xk",
@@ -4971,7 +4971,7 @@ const Pk = [
"xnt",
"xdc"
// Deprecated marker.
-], XE = [
+], nM = [
// Chapter & Verse
"ca",
"cp",
@@ -5026,10 +5026,10 @@ const Pk = [
"liv3",
"liv4",
"liv5",
- ...Pk,
- ...Ak
-], wk = 1, QE = ["type", "marker", "content"];
-class nt extends vr {
+ ...$k,
+ ...Rk
+], Ik = 1, rM = ["type", "marker", "content"];
+class rt extends vr {
__marker;
__unknownAttributes;
constructor(t = "", n, r) {
@@ -5040,16 +5040,16 @@ class nt extends vr {
}
static clone(t) {
const { __marker: n, __unknownAttributes: r, __key: i } = t;
- return new nt(n, r, i);
+ return new rt(n, r, i);
}
static isValidMarker(t, n) {
- return t !== void 0 && (XE.includes(t) || (n?.includes(t) ?? !1));
+ return t !== void 0 && (nM.includes(t) || (n?.includes(t) ?? !1));
}
static isValidFootnoteMarker(t) {
- return t !== void 0 && Pk.includes(t);
+ return t !== void 0 && $k.includes(t);
}
static isValidCrossReferenceMarker(t) {
- return t !== void 0 && Ak.includes(t);
+ return t !== void 0 && Rk.includes(t);
}
/**
* Whether a character marker belongs to the note-content families - footnote or cross-reference.
@@ -5063,18 +5063,18 @@ class nt extends vr {
* @returns `true` if the marker is a footnote or cross-reference marker, `false` otherwise.
*/
static isNoteContentMarker(t) {
- return nt.isValidFootnoteMarker(t) || nt.isValidCrossReferenceMarker(t);
+ return rt.isValidFootnoteMarker(t) || rt.isValidCrossReferenceMarker(t);
}
static importDOM() {
return {
- span: (t) => eM(t) ? {
- conversion: ZE,
+ span: (t) => sM(t) ? {
+ conversion: iM,
priority: 1
} : null
};
}
static importJSON(t) {
- return Qr().updateFromJSON(t);
+ return Zr().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setUnknownAttributes(t.unknownAttributes);
@@ -5097,10 +5097,10 @@ class nt extends vr {
}
createDOM(t) {
const n = document.createElement("span");
- return cm(n, this.__marker, t), n.classList.add(this.__type), n;
+ return pm(n, this.__marker, t), n.classList.add(this.__type), n;
}
updateDOM(t, n, r) {
- return t.__marker !== this.__marker && (n.classList.remove(`usfm_${t.__marker}`), cm(n, this.__marker, r)), !1;
+ return t.__marker !== this.__marker && (n.classList.remove(`usfm_${t.__marker}`), pm(n, this.__marker, r)), !1;
}
exportDOM(t) {
const { element: n } = super.exportDOM(t);
@@ -5112,12 +5112,12 @@ class nt extends vr {
type: this.getType(),
marker: this.getMarker(),
unknownAttributes: this.getUnknownAttributes(),
- version: wk
+ version: Ik
};
}
// Mutation
insertNewAfter(t, n) {
- const r = this.getUnknownAttributes()?.closed === "false", i = Qr(this.getMarker(), r ? { closed: "false" } : void 0);
+ const r = this.getUnknownAttributes()?.closed === "false", i = Zr(this.getMarker(), r ? { closed: "false" } : void 0);
return i.setDirection(this.getDirection()), i.setFormat(this.getFormatType()), i.setStyle(this.getTextStyle()), this.insertAfter(i, n), i;
}
canBeEmpty() {
@@ -5127,29 +5127,29 @@ class nt extends vr {
return !0;
}
}
-function cm(e, t, n) {
+function pm(e, t, n) {
e.setAttribute("data-marker", t), n.theme?.showCharMarkerTitles !== !1 ? e.setAttribute("title", t) : e.removeAttribute("title"), e.classList.add(`usfm_${t}`);
}
-function ZE(e) {
+function iM(e) {
const t = e.getAttribute("data-marker") ?? "f";
- return { node: Qr(t) };
+ return { node: Zr(t) };
}
-function Qr(e, t) {
- return St(new nt(e, t));
+function Zr(e, t) {
+ return St(new rt(e, t));
}
-function eM(e) {
+function sM(e) {
if (!e)
return !1;
const t = e.getAttribute("data-marker") ?? "";
- return nt.isValidMarker(t) && e.classList.contains(nt.getType());
+ return rt.isValidMarker(t) && e.classList.contains(rt.getType());
}
function z(e) {
- return e instanceof nt;
+ return e instanceof rt;
}
-function Nk(e) {
- return e?.type === nt.getType();
+function Lk(e) {
+ return e?.type === rt.getType();
}
-const Vc = "v", Ok = 1, tM = [
+const Wc = "v", qk = 1, oM = [
"type",
"marker",
"number",
@@ -5158,7 +5158,7 @@ const Vc = "v", Ok = 1, tM = [
"pubnumber",
"content"
];
-class Lt extends it {
+class Lt extends at {
__marker;
__number;
__sid;
@@ -5166,7 +5166,7 @@ class Lt extends it {
__pubnumber;
__unknownAttributes;
constructor(t = "", n, r, i, s, o, a) {
- super(n ?? t, a), this.__marker = Vc, this.__number = t, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
+ super(n ?? t, a), this.__marker = Wc, this.__number = t, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
}
static getType() {
return "verse";
@@ -5176,7 +5176,7 @@ class Lt extends it {
return new Lt(n, r, i, s, o, a, c);
}
static importJSON(t) {
- return $k().updateFromJSON(t);
+ return Dk().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setNumber(t.number).setSid(t.sid).setAltnumber(t.altnumber).setPubnumber(t.pubnumber).setUnknownAttributes(t.unknownAttributes);
@@ -5235,7 +5235,7 @@ class Lt extends it {
}
createDOM(t) {
const n = super.createDOM(t);
- return n.setAttribute("data-marker", this.__marker), n.classList.add(qf, `usfm_${this.__marker}`), n.setAttribute("data-number", this.__number), n;
+ return n.setAttribute("data-marker", this.__marker), n.classList.add(Bf, `usfm_${this.__marker}`), n.setAttribute("data-number", this.__number), n;
}
updateDOM(t, n, r) {
const i = super.updateDOM(t, n, r);
@@ -5251,25 +5251,25 @@ class Lt extends it {
altnumber: this.getAltnumber(),
pubnumber: this.getPubnumber(),
unknownAttributes: this.getUnknownAttributes(),
- version: Ok
+ version: qk
};
}
}
-function $k(e, t, n, r, i, s) {
+function Dk(e, t, n, r, i, s) {
return St(new Lt(e, t, n, r, i, s));
}
function Le(e) {
return e instanceof Lt;
}
-function _p(e) {
+function Mp(e) {
return e?.type === Lt.getType();
}
-const nM = /* @__PURE__ */ new Set(["closed"]);
-function yr(e, t) {
- const n = Object.entries(e).filter(([r, i]) => i !== void 0 && !nM.has(r));
+const aM = /* @__PURE__ */ new Set(["closed"]);
+function br(e, t) {
+ const n = Object.entries(e).filter(([r, i]) => i !== void 0 && !aM.has(r));
return n.length === 0 ? "" : n.length === 1 && n[0][0] === t && n[0][1] !== "" ? `|${n[0][1]}` : `|${n.map(([r, i]) => `${r}="${i}"`).join(" ")}`;
}
-function Rk(e, t) {
+function Kk(e, t) {
if (!t || t.length === 0)
return e;
const n = {};
@@ -5279,16 +5279,16 @@ function Rk(e, t) {
Object.hasOwn(n, r) || (n[r] = i);
}), n;
}
-function Ik(e) {
- const t = Object.keys(e).filter((r) => !fE.includes(r)), n = [
+function Bk(e) {
+ const t = Object.keys(e).filter((r) => !mE.includes(r)), n = [
...t.filter((r) => r === "sid"),
...t.filter((r) => r === "eid"),
...t.filter((r) => r !== "sid" && r !== "eid")
];
return t.every((r, i) => r === n[i]) ? void 0 : t;
}
-function Lk(e, t, n, r) {
- return Rk(
+function Uk(e, t, n, r) {
+ return Kk(
// Presence, not truthiness: an authored `sid=""` is a byte the document holds, and folding it
// out here deletes it from the displayed run — which a settle then re-derives node state from,
// so the empty value would be gone from the file. Matches `orderedAttributes`' own `in` test
@@ -5301,37 +5301,37 @@ function Lk(e, t, n, r) {
r
);
}
-function ra(e) {
+function ia(e) {
return e.getChildren().find((t) => $(t) && t.getMarkerSyntax() === "closing" && t.getMarker() === e.getMarker());
}
-function rM(e) {
+function cM(e) {
const t = e.getUnknownAttributes();
- return !t || !Object.keys(t).some((r) => r !== "closed") ? !1 : ra(e) === void 0 && qk(e) === void 0;
+ return !t || !Object.keys(t).some((r) => r !== "closed") ? !1 : ia(e) === void 0 && Fk(e) === void 0;
}
-function qk(e) {
- return e.getChildren().find((t) => T(t) && Te(t, _e) === "attribute");
+function Fk(e) {
+ return e.getChildren().find((t) => C(t) && Te(t, _e) === "attribute");
}
function Ta(e, t) {
return Ga(e.getNextSibling(), t);
}
-const iM = /^[ \u00A0]+$/;
-function Ep(e) {
+const lM = /^[ \u00A0]+$/;
+function Pp(e) {
if (Sr(e))
return !0;
if (e.getMarkerSyntax() !== "opening")
return !1;
- const t = rt(e.getMarker(), e.getNested()), n = e.getTextContent();
- return n.startsWith(t) && iM.test(n.slice(t.length));
+ const t = it(e.getMarker(), e.getNested()), n = e.getTextContent();
+ return n.startsWith(t) && lM.test(n.slice(t.length));
}
function Ga(e, t) {
let n, r, i, s;
return He(e) && e.getRunKind() === t && (s = e, e = e.getFirstChild()), $(e) && e.getMarkerSyntax() === "opening" && e.getMarker() === t && // Typed-spacing licensed ({@link $isCanonicalRunOpenerGlyph}): a trailing space typed on the
// opener is at rest, not byte damage.
- Ep(e) && (n = e, e = e.getNextSibling()), T(e) && Te(e, _e) === "attribute" && (r = e, e = e.getNextSibling()), $(e) && e.getMarkerSyntax() === "closing" && e.getMarker() === t && Sr(e) && (i = e), { opener: n, value: r, closer: i, wrapper: s };
+ Pp(e) && (n = e, e = e.getNextSibling()), C(e) && Te(e, _e) === "attribute" && (r = e, e = e.getNextSibling()), $(e) && e.getMarkerSyntax() === "closing" && e.getMarker() === t && Sr(e) && (i = e), { opener: n, value: r, closer: i, wrapper: s };
}
-function sM(e) {
+function uM(e) {
let t = e;
- for (; ge(t); )
+ for (; me(t); )
t = t.getChildren()[0];
return t;
}
@@ -5344,35 +5344,35 @@ function Dt(e) {
break;
n++;
}
- const r = sM(t[n]);
- if (!(!T(r) || r.getType() !== it.getType()))
+ const r = uM(t[n]);
+ if (!(!C(r) || r.getType() !== at.getType()))
return r.getTextContent() === qt(e.getCaller()) || r.isUnmergeable() ? r : void 0;
}
function Ja(e) {
const t = Dt(e);
return t ? Ga(t.getNextSibling(), "cat") : {};
}
-function jr(e) {
+function Vr(e) {
const t = e.getFirstChild();
- if (!(!T(t) || $(t)) && Te(t, _e) !== "attribute")
+ if (!(!C(t) || $(t)) && Te(t, _e) !== "attribute")
return t;
}
-function Mp(e) {
- const t = jr(e);
+function Ap(e) {
+ const t = Vr(e);
return t ? Ga(t.getNextSibling(), "ca") : {};
}
-function Dk(e) {
- const t = jr(e);
+function zk(e) {
+ const t = Vr(e);
if (!t)
return;
const n = Ga(t.getNextSibling(), "ca");
return n.wrapper ?? n.closer ?? t;
}
-function Pp(e) {
- const t = Dk(e);
+function wp(e) {
+ const t = zk(e);
return t ? Ga(t.getNextSibling(), "cp") : {};
}
-function Kk(e) {
+function jk(e) {
const t = e.getParent();
if (!z(t))
return;
@@ -5381,17 +5381,17 @@ function Kk(e) {
for (let r = t.getPreviousSibling(); r; r = r.getPreviousSibling()) {
if (Le(r))
return r;
- if (!($(r) && (r.getMarker() === "va" || r.getMarker() === "vp") || T(r) && Te(r, _e) === "attribute" || z(r) && (r.getMarker() === "va" || r.getMarker() === "vp") || He(r)))
+ if (!($(r) && (r.getMarker() === "va" || r.getMarker() === "vp") || C(r) && Te(r, _e) === "attribute" || z(r) && (r.getMarker() === "va" || r.getMarker() === "vp") || He(r)))
return;
}
}
-function Bl(e) {
+function jl(e) {
let t, n, r, i, s = e.getNextSibling();
return He(s) && s.getRunKind() === "milestone" && (i = s, s = s.getFirstChild()), $(s) && s.getMarkerSyntax() === "opening" && s.getMarker() === e.getMarker() && // Typed-spacing licensed ({@link $isCanonicalRunOpenerGlyph}): a trailing space typed on the
// opener is at rest, not byte damage.
- Ep(s) && (t = s, s = s.getNextSibling()), T(s) && Te(s, _e) === "attribute" && (n = s, s = s.getNextSibling()), $(s) && s.getMarkerSyntax() === "selfClosing" && Sr(s) && (r = s), { opening: t, attribute: n, closing: r, wrapper: i };
+ Pp(s) && (t = s, s = s.getNextSibling()), C(s) && Te(s, _e) === "attribute" && (n = s, s = s.getNextSibling()), $(s) && s.getMarkerSyntax() === "selfClosing" && Sr(s) && (r = s), { opening: t, attribute: n, closing: r, wrapper: i };
}
-const Wc = "c", Uk = 1, oM = [
+const Hc = "c", Vk = 1, fM = [
"type",
"marker",
"number",
@@ -5400,7 +5400,7 @@ const Wc = "c", Uk = 1, oM = [
"pubnumber",
"content"
];
-class $n extends vr {
+class Rn extends vr {
__marker;
__number;
__sid;
@@ -5408,17 +5408,17 @@ class $n extends vr {
__pubnumber;
__unknownAttributes;
constructor(t = "", n, r, i, s, o) {
- super(o), this.__marker = Wc, this.__number = t, this.__sid = n, this.__altnumber = r, this.__pubnumber = i, this.__unknownAttributes = s;
+ super(o), this.__marker = Hc, this.__number = t, this.__sid = n, this.__altnumber = r, this.__pubnumber = i, this.__unknownAttributes = s;
}
static getType() {
return "chapter";
}
static clone(t) {
const { __number: n, __sid: r, __altnumber: i, __pubnumber: s, __unknownAttributes: o, __key: a } = t;
- return new $n(n, r, i, s, o, a);
+ return new Rn(n, r, i, s, o, a);
}
static importJSON(t) {
- return Fk().updateFromJSON(t);
+ return Wk().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setNumber(t.number).setSid(t.sid).setAltnumber(t.altnumber).setPubnumber(t.pubnumber).setUnknownAttributes(t.unknownAttributes);
@@ -5489,7 +5489,7 @@ class $n extends vr {
}
createDOM() {
const t = document.createElement("p");
- return t.setAttribute("data-marker", this.__marker), t.classList.add(Bc, `usfm_${this.__marker}`), t.setAttribute("data-number", this.__number), t;
+ return t.setAttribute("data-marker", this.__marker), t.classList.add(zc, `usfm_${this.__marker}`), t.setAttribute("data-number", this.__number), t;
}
updateDOM(t, n) {
return t.__number !== this.__number && n.setAttribute("data-number", this.__number), !1;
@@ -5504,20 +5504,20 @@ class $n extends vr {
altnumber: this.getAltnumber(),
pubnumber: this.getPubnumber(),
unknownAttributes: this.getUnknownAttributes(),
- version: Uk
+ version: Vk
};
}
}
-function Fk(e, t, n, r, i) {
- return St(new $n(e, t, n, r, i));
+function Wk(e, t, n, r, i) {
+ return St(new Rn(e, t, n, r, i));
}
-function Be(e) {
- return e instanceof $n;
+function Fe(e) {
+ return e instanceof Rn;
}
-function aM(e) {
- return e?.type === $n.getType();
+function dM(e) {
+ return e?.type === Rn.getType();
}
-const cM = ["type", "marker", "content"], Wf = "unknown", Bk = 1, lM = /* @__PURE__ */ new Set(["optbreak", "ref"]);
+const pM = ["type", "marker", "content"], Jf = "unknown", Hk = 1, hM = /* @__PURE__ */ new Set(["optbreak", "ref"]);
class Rs extends vr {
__tag;
__marker;
@@ -5534,14 +5534,14 @@ class Rs extends vr {
}
static importDOM() {
return {
- [Wf]: (t) => fM(t) ? {
- conversion: uM,
+ [Jf]: (t) => mM(t) ? {
+ conversion: gM,
priority: 1
} : null
};
}
static importJSON(t) {
- return Ap().updateFromJSON(t);
+ return Np().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setTag(t.tag).setMarker(t.marker).setUnknownAttributes(t.unknownAttributes);
@@ -5562,7 +5562,7 @@ class Rs extends vr {
* callers must not add or strip spaces next to them.
*/
isInlineTag() {
- return lM.has(this.getTag());
+ return hM.has(this.getTag());
}
setMarker(t) {
if (this.__marker === t)
@@ -5581,7 +5581,7 @@ class Rs extends vr {
return this.getLatest().__unknownAttributes;
}
createDOM() {
- const t = document.createElement(Wf);
+ const t = document.createElement(Jf);
return t.setAttribute("data-tag", this.getTag()), t.setAttribute("data-marker", this.getMarker() ?? ""), t.classList.add(this.isInlineTag() ? "unknown-inline" : "unknown-block"), t.contentEditable = "false", t;
}
updateDOM(t, n) {
@@ -5602,7 +5602,7 @@ class Rs extends vr {
tag: this.getTag(),
marker: this.getMarker(),
unknownAttributes: this.getUnknownAttributes(),
- version: Bk
+ version: Hk
};
}
// Mutation
@@ -5703,33 +5703,33 @@ class Rs extends vr {
return this.getChildren().some((i) => r.some((s) => s.is(i)));
}
}
-function uM(e) {
+function gM(e) {
const t = e.getAttribute("data-tag") ?? "", n = e.getAttribute("data-marker") ?? "";
- return { node: Ap(t, n) };
+ return { node: Np(t, n) };
}
-function Ap(e, t, n) {
+function Np(e, t, n) {
return St(new Rs(e, t, n));
}
-function fM(e) {
- return e?.tagName.toLowerCase() === Wf;
+function mM(e) {
+ return e?.tagName.toLowerCase() === Jf;
}
function Ie(e) {
return e instanceof Rs;
}
-const zk = "table", Hf = "immutable-table", jk = 1, dM = ["type", "marker", "content"];
+const Gk = "table", Yf = "immutable-table", Jk = 1, yM = ["type", "marker", "content"];
class Is extends vr {
__unknownAttributes;
constructor(t, n) {
super(n), this.__unknownAttributes = t;
}
static getType() {
- return Hf;
+ return Yf;
}
static clone(t) {
return new Is(t.__unknownAttributes, t.__key);
}
static importJSON(t) {
- return pM().updateFromJSON(t);
+ return bM().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setUnknownAttributes(t.unknownAttributes);
@@ -5752,9 +5752,9 @@ class Is extends vr {
const t = this.getUnknownAttributes();
return {
...super.exportJSON(),
- type: Hf,
+ type: Yf,
...t !== void 0 && { unknownAttributes: t },
- version: jk
+ version: Jk
};
}
// Shadow root: isolate selection so content doesn't merge across the table boundary.
@@ -5762,23 +5762,23 @@ class Is extends vr {
return !0;
}
}
-function pM(e) {
+function bM(e) {
return St(new Is(e));
}
-function Vk(e) {
+function Yk(e) {
return e instanceof Is;
}
-function hM(e) {
- return e?.type === Hf;
+function kM(e) {
+ return e?.type === Yf;
}
-function Gf(e) {
+function Xf(e) {
for (let t = e.getParent(); t; t = t.getParent())
- if (Ie(t) || Vk(t))
+ if (Ie(t) || Yk(t))
return !0;
return !1;
}
-const Wk = 1;
-class Dr extends ap {
+const Xk = 1;
+class Dr extends lp {
static getType() {
return "implied-para";
}
@@ -5786,128 +5786,128 @@ class Dr extends ap {
return new Dr(t.__key);
}
static importJSON(t) {
- return qn().updateFromJSON(t);
+ return En().updateFromJSON(t);
}
getMarker() {
- return Ln;
+ return qn;
}
exportJSON() {
return {
...super.exportJSON(),
type: this.getType(),
- version: Wk
+ version: Xk
};
}
// Mutation
insertNewAfter(t, n) {
- const r = qn();
+ const r = En();
return r.setTextFormat(t.format), r.setTextStyle(t.style), r.setDirection(this.getDirection()), r.setFormat(this.getFormatType()), r.setStyle(this.getTextStyle()), this.insertAfter(r, n), r;
}
}
-function qn() {
+function En() {
return St(new Dr());
}
-function kt(e) {
+function ht(e) {
return e instanceof Dr;
}
-function zl(e) {
+function Vl(e) {
return e?.type === Dr.getType();
}
-function wp(e) {
- return kt(e) && pn(e.getParent());
+function Op(e) {
+ return ht(e) && pn(e.getParent());
}
-function Hk(e) {
- return ge(e) || wp(e);
+function Qk(e) {
+ return me(e) || Op(e);
}
function Xn(e) {
let t = e.getParent();
- for (; t && Hk(t); )
+ for (; t && Qk(t); )
t = t.getParent();
return t;
}
-function jl(e) {
+function Wl(e) {
return z(Xn(e));
}
-function Np(e, t) {
+function $p(e, t) {
if (e.getMarkerSyntax() === "selfClosing")
return;
const n = e.getMarker();
- return n === t.getMarker() ? jl(t) : t.getChildren().some((i) => z(i) && i.getMarker() === n) ? !0 : void 0;
+ return n === t.getMarker() ? Wl(t) : t.getChildren().some((i) => z(i) && i.getMarker() === n) ? !0 : void 0;
}
-function gM(e) {
+function xM(e) {
e.isAttached() && e.getChildren().forEach((t) => {
if (!$(t))
return;
- const n = Np(t, e);
+ const n = $p(t, e);
n !== void 0 && t.setNested(n);
});
}
-const is = /* @__PURE__ */ new WeakMap();
-function mM(e, t, n) {
+const ss = /* @__PURE__ */ new WeakMap();
+function TM(e, t, n) {
const r = { owners: t, rederive: n };
- return is.set(e, r), () => {
- is.get(e) === r && is.delete(e);
+ return ss.set(e, r), () => {
+ ss.get(e) === r && ss.delete(e);
};
}
-function Gk(e, t, n) {
- const r = is.get(e);
- !r?.rederive || !n.has(Ll) || r.derivedFor === t || (r.rederive(t), r.derivedFor = t);
+function Zk(e, t, n) {
+ const r = ss.get(e);
+ !r?.rederive || !n.has(Dl) || r.derivedFor === t || (r.rederive(t), r.derivedFor = t);
}
-function Jf(e) {
- return is.get(e)?.owners;
+function Qf(e) {
+ return ss.get(e)?.owners;
}
-function Jk(e) {
- return is.get(Pt())?.owners.has(e.getKey()) ?? !1;
+function ex(e) {
+ return ss.get(Pt())?.owners.has(e.getKey()) ?? !1;
}
-function Yk(e) {
- is.get(Pt())?.owners.add(e.getKey());
+function tx(e) {
+ ss.get(Pt())?.owners.add(e.getKey());
}
-function si(e) {
- return T(e) && e.getType() === it.getType() && Te(e, _e) !== "attribute";
+function oi(e) {
+ return C(e) && e.getType() === at.getType() && Te(e, _e) !== "attribute";
}
-function No(e) {
- if (!si(e) || !e.getTextContent().startsWith(U))
+function Oo(e) {
+ if (!oi(e) || !e.getTextContent().startsWith(B))
return 0;
let t = e, n = t.getPreviousSibling(), r = t.getParent();
- for (; r && ge(r); )
+ for (; r && me(r); )
t = r, r = t.getParent(), n ??= t.getPreviousSibling();
if (!z(r))
return 0;
- for (; ge(n); )
+ for (; me(n); )
n = n.getLastChild();
- return !$(n) || n.getMarkerSyntax() !== "opening" ? 0 : Rp(n, r) ? 1 : 0;
+ return !$(n) || n.getMarkerSyntax() !== "opening" ? 0 : Lp(n, r) ? 1 : 0;
}
-function Op(e) {
+function Rp(e) {
let t = e.getNextSibling();
- for (; ge(t); )
+ for (; me(t); )
t = t.getFirstChild();
return t;
}
-function $p(e) {
+function Ip(e) {
const t = e.getPreviousSibling(), n = e.getParent();
- return !$(t) || !z(n) || !Rp(t, n) || !si(e) ? 0 : e.getTextContent().startsWith(U) ? U.length : 0;
+ return !$(t) || !z(n) || !Lp(t, n) || !oi(e) ? 0 : e.getTextContent().startsWith(B) ? B.length : 0;
}
-function Rp(e, t) {
- return e.getMarkerSyntax() === "opening" && Np(e, t) !== void 0;
+function Lp(e, t) {
+ return e.getMarkerSyntax() === "opening" && $p(e, t) !== void 0;
}
-function Oo(e, t) {
- if (!Rp(e, t))
+function $o(e, t) {
+ if (!Lp(e, t))
return;
- const n = e.getNextSibling(), r = Op(e);
+ const n = e.getNextSibling(), r = Rp(e);
if (!(n === null || r === null))
- return $(r) ? Np(r, t) === !0 ? "spacer" : void 0 : si(r) ? r.getTextContent().startsWith(U) ? void 0 : r.is(n) ? "prefix" : "spacer" : "spacer";
+ return $(r) ? $p(r, t) === !0 ? "spacer" : void 0 : oi(r) ? r.getTextContent().startsWith(B) ? void 0 : r.is(n) ? "prefix" : "spacer" : "spacer";
}
-function Ip(e) {
- return !si(Op(e)) || Gf(e) ? !1 : !xE(e.getNextSibling()?.getTextContent() ?? "");
+function qp(e) {
+ return !oi(Rp(e)) || Xf(e) ? !1 : !_E(e.getNextSibling()?.getTextContent() ?? "");
}
-function Xk(e) {
+function nx(e) {
if (e.isAttached()) {
for (const t of e.getChildren())
- if ($(t) && Oo(t, e) !== void 0)
+ if ($(t) && $o(t, e) !== void 0)
return t.getNextSibling()?.getTextContent() ?? "";
}
}
-function Lp(e, t) {
+function Dp(e, t) {
const n = M();
if (!E(n) || !n.isCollapsed())
return !1;
@@ -5919,35 +5919,35 @@ function Lp(e, t) {
for (let i = e.getNextSibling(); i; ) {
if (r.is(i))
return !0;
- if (!ge(i))
+ if (!me(i))
return !1;
i = i.getFirstChild();
}
return !1;
}
-function Qk(e) {
- if (!e.isAttached() || Jk(e))
+function rx(e) {
+ if (!e.isAttached() || ex(e))
return;
- const t = Jf(Pt()) !== void 0;
+ const t = Qf(Pt()) !== void 0;
e.getChildren().forEach((n) => {
if (!$(n))
return;
- const r = Oo(n, e);
- if (r === void 0 || Lp(n, e))
+ const r = $o(n, e);
+ if (r === void 0 || Dp(n, e))
return;
- if (t && Ip(n)) {
- Yk(e);
+ if (t && qp(n)) {
+ tx(e);
return;
}
if (r === "spacer") {
- n.insertAfter(Ue(U));
+ n.insertAfter(Be(B));
return;
}
const i = n.getNextSibling();
- T(i) && (yM(i) || kM(i));
+ C(i) && (CM(i) || SM(i));
});
}
-function yM(e) {
+function CM(e) {
const t = M();
if (!E(t) || !t.isCollapsed())
return !1;
@@ -5955,12 +5955,12 @@ function yM(e) {
if (n.type !== "text" || n.key !== e.getKey() || n.offset === 0)
return !1;
const r = e.getTextContent();
- if (r[n.offset] !== U)
+ if (r[n.offset] !== B)
return !1;
const i = r.slice(0, n.offset);
- return e.setTextContent(U + i + r.slice(n.offset + 1)), e.select(n.offset + 1, n.offset + 1), !0;
+ return e.setTextContent(B + i + r.slice(n.offset + 1)), e.select(n.offset + 1, n.offset + 1), !0;
}
-function bM(e) {
+function vM(e) {
if (e.getMarkerSyntax() !== "opening" || !z(e.getParent()))
return !1;
const t = M();
@@ -5969,47 +5969,47 @@ function bM(e) {
const n = e.getTextContent(), { anchor: r } = t;
if (r.key !== e.getKey() || r.offset !== n.length)
return !1;
- const i = rt(e.getMarker(), e.getNested()), s = n.slice(i.length);
+ const i = it(e.getMarker(), e.getNested()), s = n.slice(i.length);
if (!n.startsWith(i) || !/^[|\s]+$/.test(s))
return !1;
- const o = Op(e);
- if (!si(o))
+ const o = Rp(e);
+ if (!oi(o))
return !1;
const a = o.getTextContent();
- return a.startsWith(U) ? (e.setTextContent(i), o.setTextContent(U + s + a.slice(U.length)), o.select(U.length + s.length, U.length + s.length), !0) : !1;
+ return a.startsWith(B) ? (e.setTextContent(i), o.setTextContent(B + s + a.slice(B.length)), o.select(B.length + s.length, B.length + s.length), !0) : !1;
}
-function Zk(e, t) {
- ge(e.getNextSibling()) && Oo(e, t) === "spacer" && e.insertAfter(Ue(U));
+function ix(e, t) {
+ me(e.getNextSibling()) && $o(e, t) === "spacer" && e.insertAfter(Be(B));
}
-function kM(e) {
- e.setTextContent(U + e.getTextContent());
+function SM(e) {
+ e.setTextContent(B + e.getTextContent());
const t = M();
if (E(t))
for (const n of [t.anchor, t.focus])
n.type === "text" && n.key === e.getKey() && n.set(n.key, n.offset + 1, "text");
}
-function xM(e) {
- return e.isAttached() ? e.getChildren().some((t) => $(t) && Oo(t, e) !== void 0 && Lp(t, e)) : !1;
+function _M(e) {
+ return e.isAttached() ? e.getChildren().some((t) => $(t) && $o(t, e) !== void 0 && Dp(t, e)) : !1;
}
-function qp(e) {
- return e.isAttached() ? e.getChildren().some((t) => $(t) && Oo(t, e) !== void 0 && (Lp(t, e) || Ip(t))) : !1;
+function Kp(e) {
+ return e.isAttached() ? e.getChildren().some((t) => $(t) && $o(t, e) !== void 0 && (Dp(t, e) || qp(t))) : !1;
}
-function Dp(e) {
- return e.isAttached() ? e.getChildren().some((t) => $(t) && Oo(t, e) !== void 0 && Ip(t)) : !1;
+function Bp(e) {
+ return e.isAttached() ? e.getChildren().some((t) => $(t) && $o(t, e) !== void 0 && qp(t)) : !1;
}
-function TM(e) {
- if (xM(e))
+function EM(e) {
+ if (_M(e))
return !0;
const t = M();
if (!E(t) || !t.isCollapsed())
return !1;
const n = t.anchor.getNode();
- return (n.is(e) || e.isParentOf(n)) && qp(e);
+ return (n.is(e) || e.isParentOf(n)) && Kp(e);
}
-const ex = 1, tx = "marker", Kp = ws("isGutterMarker", {
+const sx = 1, ox = "marker", Up = ws("isGutterMarker", {
parse: (e) => e === !0
});
-class hr extends za {
+class gr extends za {
__textType;
__text;
constructor(t = "", n = "", r) {
@@ -6020,18 +6020,18 @@ class hr extends za {
}
static clone(t) {
const { __textType: n, __text: r, __key: i } = t;
- return new hr(n, r, i);
+ return new gr(n, r, i);
}
static importDOM() {
return {
- span: (t) => vM(t) ? {
- conversion: CM,
+ span: (t) => PM(t) ? {
+ conversion: MM,
priority: 1
} : null
};
}
static importJSON(t) {
- return Zr().updateFromJSON(t);
+ return ei().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setTextType(t.textType).setTextContent(t.text);
@@ -6103,7 +6103,7 @@ class hr extends za {
type: this.getType(),
textType: this.getTextType(),
text: this.getTextContent(),
- version: ex
+ version: sx
};
}
// Mutation
@@ -6117,42 +6117,42 @@ class hr extends za {
return !1;
}
}
-function CM(e) {
+function MM(e) {
const t = e.getAttribute("data-text-type") ?? "", n = e.textContent ?? "";
- return { node: Zr(t, n) };
+ return { node: ei(t, n) };
}
-function Zr(e, t) {
- return St(new hr(e, t));
+function ei(e, t) {
+ return St(new gr(e, t));
}
-function nx(e) {
- return Wt(Zr(tx, e), Kp, !0);
+function ax(e) {
+ return Wt(ei(ox, e), Up, !0);
}
-function Un(e) {
- return Yt(e) && Te(e, Kp);
+function Bn(e) {
+ return Yt(e) && Te(e, Up);
}
-function vM(e) {
+function PM(e) {
return e?.tagName === "span";
}
function Yt(e) {
- return e instanceof hr;
+ return e instanceof gr;
}
-function rx(e) {
- return e?.type === hr.getType();
+function cx(e) {
+ return e?.type === gr.getType();
}
-const ix = "file", sx = "src", SM = "colspan", _M = "category", EM = "alt", MM = "closed", PM = "false";
-function AM(e) {
- return e[MM] !== PM;
+const lx = "file", ux = "src", AM = "colspan", wM = "category", NM = "alt", OM = "closed", $M = "false";
+function RM(e) {
+ return e[OM] !== $M;
}
-function wM(e) {
+function IM(e) {
return Object.fromEntries(Object.entries(e).map(([t, n]) => [
- t === ix ? sx : t,
+ t === lx ? ux : t,
n
]));
}
-function NM(e, t) {
- return e === "figure" && t === sx ? ix : t;
+function LM(e, t) {
+ return e === "figure" && t === ux ? lx : t;
}
-function ox(e, t) {
+function fx(e, t) {
if (e === void 0)
return;
const n = Number(t);
@@ -6167,8 +6167,8 @@ function ox(e, t) {
}
return r === e.length ? e : `${e}-${Number(e.slice(r)) + n - 1}`;
}
-function Vl(e, t, n) {
- const r = n ?? {}, i = AM(r);
+function Hl(e, t, n) {
+ const r = n ?? {}, i = RM(r);
switch (e) {
case "optbreak":
return { opening: "//", attributes: "", closingAttributes: "", closing: "" };
@@ -6179,7 +6179,7 @@ function Vl(e, t, n) {
return { opening: `\\${t} `, attributes: "", closingAttributes: "", closing: "" };
case "table:cell":
return {
- opening: `\\${ox(t, r[SM])} `,
+ opening: `\\${fx(t, r[AM])} `,
attributes: "",
closingAttributes: "",
closing: ""
@@ -6188,23 +6188,23 @@ function Vl(e, t, n) {
return {
opening: `\\${t} `,
attributes: "",
- closingAttributes: yr(wM(r), void 0),
+ closingAttributes: br(IM(r), void 0),
closing: i ? `\\${t}*` : ""
};
case "sidebar": {
- const { [_M]: s, ...o } = r;
+ const { [wM]: s, ...o } = r;
return {
opening: "\\esb",
- attributes: (s === void 0 ? "" : ` \\cat ${s}\\cat*`) + yr(o, void 0),
+ attributes: (s === void 0 ? "" : ` \\cat ${s}\\cat*`) + br(o, void 0),
closingAttributes: "",
closing: i ? "\\esbe" : ""
};
}
case "periph": {
- const { [EM]: s, ...o } = r;
+ const { [NM]: s, ...o } = r;
return {
opening: `\\periph ${s ?? ""}`,
- attributes: yr(o, void 0),
+ attributes: br(o, void 0),
closingAttributes: "",
closing: ""
};
@@ -6213,19 +6213,19 @@ function Vl(e, t, n) {
return {
opening: `\\${t} `,
attributes: "",
- closingAttributes: yr(r, void 0),
+ closingAttributes: br(r, void 0),
closing: i ? `\\${t}*` : ""
};
}
}
-const En = { wantsRun: !1, valueText: void 0 }, oi = {};
-function Xu(e, t) {
+const Mn = { wantsRun: !1, valueText: void 0 }, ai = {};
+function ef(e, t) {
if (t === "va")
return e;
const n = Ta(e, "va");
return n.wrapper ?? n.closer ?? e;
}
-function Up(e) {
+function Fp(e) {
const t = M();
if (!E(t) || !t.isCollapsed())
return !1;
@@ -6240,7 +6240,7 @@ function Up(e) {
const r = e.getNextSibling();
return r !== null && n.is(r) && t.anchor.offset === 0;
}
-function Wl(e) {
+function Gl(e) {
const { opener: t, closer: n } = e;
if (!t)
return !1;
@@ -6250,15 +6250,15 @@ function Wl(e) {
const i = r.anchor.getNode(), s = i.is(t) && r.anchor.offset === t.getTextContentSize();
return n ? s || i.is(n) : s;
}
-function OM(e) {
- return He(e) ? e.getRunKind() === "va" || e.getRunKind() === "vp" : $(e) ? e.getMarker() === "va" || e.getMarker() === "vp" : T(e) && Te(e, _e) === "attribute";
+function qM(e) {
+ return He(e) ? e.getRunKind() === "va" || e.getRunKind() === "vp" : $(e) ? e.getMarker() === "va" || e.getMarker() === "vp" : C(e) && Te(e, _e) === "attribute";
}
-function $M(e) {
+function DM(e) {
if ($(e)) {
const r = e.getMarker();
return r === "va" || r === "vp" ? r : void 0;
}
- if (!T(e) || Te(e, _e) !== "attribute")
+ if (!C(e) || Te(e, _e) !== "attribute")
return;
const t = e.getPreviousSibling();
if (!$(t))
@@ -6266,32 +6266,32 @@ function $M(e) {
const n = t.getMarker();
return n === "va" || n === "vp" ? n : void 0;
}
-function Qu(e) {
+function tf(e) {
for (let t = e.getPreviousSibling(); t; t = t.getPreviousSibling()) {
if (Le(t))
return t;
- if (!OM(t))
+ if (!qM(t))
return;
}
}
-function lm(e) {
+function hm(e) {
return {
kind: e,
ownerPredicate: (t) => Le(t),
ownerOf: (t) => {
if (He(t))
- return t.getRunKind() === e ? Qu(t) : void 0;
+ return t.getRunKind() === e ? tf(t) : void 0;
const n = t.getParent();
- return He(n) ? n.getRunKind() === e ? Qu(n) : void 0 : $M(t) === e ? Qu(t) : void 0;
+ return He(n) ? n.getRunKind() === e ? tf(n) : void 0 : DM(t) === e ? tf(t) : void 0;
},
expectedPieces: (t) => {
if (!Le(t))
- return En;
+ return Mn;
const n = e === "va" ? t.getAltnumber() : t.getPubnumber();
- return n === void 0 ? En : { wantsRun: !0, valueText: U + n };
+ return n === void 0 ? Mn : { wantsRun: !0, valueText: B + n };
},
- scanPieces: (t) => Le(t) ? Ta(Xu(t, e), e) : oi,
- graceSite: (t, n) => Le(t) ? !n.opener && !n.closer ? Up(Xu(t, e)) : Wl(n) : !1,
+ scanPieces: (t) => Le(t) ? Ta(ef(t, e), e) : ai,
+ graceSite: (t, n) => Le(t) ? !n.opener && !n.closer ? Fp(ef(t, e)) : Gl(n) : !1,
settleScope: "owner",
deletionPolicy: "retokenize",
byteFormat: {
@@ -6300,11 +6300,11 @@ function lm(e) {
glyphs: "with-value",
glyphMarker: () => e,
closerSyntax: "closing",
- insertRunAfter: (t) => Le(t) ? Xu(t, e) : void 0
+ insertRunAfter: (t) => Le(t) ? ef(t, e) : void 0
}
};
}
-const RM = {
+const KM = {
kind: "separator",
// The NBSP a char span shows after its opening glyph. Its "deletion" is a TEXT mutation (an NBSP
// prefix edit), not node destruction, so it has no owner walk and no destruction pend — its
@@ -6312,32 +6312,32 @@ const RM = {
ownerPredicate: (e) => z(e),
ownerOf: () => {
},
- expectedPieces: () => En,
- scanPieces: () => oi,
- graceSite: (e) => z(e) && TM(e),
+ expectedPieces: () => Mn,
+ scanPieces: () => ai,
+ graceSite: (e) => z(e) && EM(e),
settleScope: "owner",
deletionPolicy: "retokenize",
byteFormat: { writer: "kind-owned", glyphs: "none" }
-}, IM = {
+}, BM = {
kind: "char",
ownerPredicate: (e) => z(e),
ownerOf: (e) => {
- if (!T(e) || Te(e, _e) !== "attribute")
+ if (!C(e) || Te(e, _e) !== "attribute")
return;
const t = e.getParent();
return z(t) ? t : void 0;
},
expectedPieces: (e) => {
- if (!z(e) || ra(e) === void 0)
- return En;
- const t = yr(e.getUnknownAttributes() ?? {}, Ao(e.getMarker()));
- return t === "" ? En : { wantsRun: !0, valueText: t };
+ if (!z(e) || ia(e) === void 0)
+ return Mn;
+ const t = br(e.getUnknownAttributes() ?? {}, wo(e.getMarker()));
+ return t === "" ? Mn : { wantsRun: !0, valueText: t };
},
- scanPieces: (e) => z(e) ? { value: qk(e) } : oi,
+ scanPieces: (e) => z(e) ? { value: Fk(e) } : ai,
graceSite: (e, t) => {
if (!z(e) || t.value)
return !1;
- const n = ra(e);
+ const n = ia(e);
if (!n)
return !1;
const r = M();
@@ -6354,18 +6354,18 @@ const RM = {
byteFormat: {
writer: "owner-children",
glyphs: "none",
- insertRunBefore: (e) => z(e) ? ra(e) : void 0
+ insertRunBefore: (e) => z(e) ? ia(e) : void 0
}
};
-function ax(e) {
+function dx(e) {
if ($(e))
return e.getMarker() === "cat";
- if (!T(e) || Te(e, _e) !== "attribute")
+ if (!C(e) || Te(e, _e) !== "attribute")
return !1;
const t = e.getPreviousSibling();
return $(t) && t.getMarker() === "cat";
}
-function LM(e) {
+function UM(e) {
const t = e.getParent();
if (!K(t))
return;
@@ -6374,34 +6374,34 @@ function LM(e) {
for (let r = e.getPreviousSibling(); r; r = r.getPreviousSibling()) {
if (r.is(n))
return t;
- if (!ax(r))
+ if (!dx(r))
return;
}
}
-const qM = {
+const FM = {
kind: "cat",
ownerPredicate: (e) => K(e),
ownerOf: (e) => {
if (He(e))
return e.getRunKind() === "cat" && K(e.getParent()) ? e.getParent() ?? void 0 : void 0;
const t = e.getParent();
- return He(t) ? t.getRunKind() === "cat" && K(t.getParent()) ? t.getParent() ?? void 0 : void 0 : ax(e) ? LM(e) : void 0;
+ return He(t) ? t.getRunKind() === "cat" && K(t.getParent()) ? t.getParent() ?? void 0 : void 0 : dx(e) ? UM(e) : void 0;
},
expectedPieces: (e) => {
if (!K(e) || e.getIsCollapsed() !== !1)
- return En;
+ return Mn;
const t = e.getCategory();
- return t === void 0 ? En : { wantsRun: !0, valueText: U + t };
+ return t === void 0 ? Mn : { wantsRun: !0, valueText: B + t };
},
- scanPieces: (e) => K(e) ? Ja(e) : oi,
+ scanPieces: (e) => K(e) ? Ja(e) : ai,
graceSite: (e, t) => {
if (!K(e))
return !1;
if (!t.opener && !t.closer) {
const n = Dt(e);
- return n !== void 0 && Up(n);
+ return n !== void 0 && Fp(n);
}
- return Wl(t);
+ return Gl(t);
},
settleScope: "owner",
deletionPolicy: "retokenize",
@@ -6414,15 +6414,15 @@ const qM = {
insertRunAfter: (e) => K(e) ? Dt(e) : void 0
}
};
-function DM(e) {
- return He(e) ? e.getRunKind() === "ca" || e.getRunKind() === "cp" : $(e) ? e.getMarker() === "ca" || e.getMarker() === "cp" : T(e) && Te(e, _e) === "attribute";
+function zM(e) {
+ return He(e) ? e.getRunKind() === "ca" || e.getRunKind() === "cp" : $(e) ? e.getMarker() === "ca" || e.getMarker() === "cp" : C(e) && Te(e, _e) === "attribute";
}
-function KM(e) {
+function jM(e) {
if ($(e)) {
const r = e.getMarker();
return r === "ca" || r === "cp" ? r : void 0;
}
- if (!T(e) || Te(e, _e) !== "attribute")
+ if (!C(e) || Te(e, _e) !== "attribute")
return;
const t = e.getPreviousSibling();
if (!$(t))
@@ -6430,45 +6430,45 @@ function KM(e) {
const n = t.getMarker();
return n === "ca" || n === "cp" ? n : void 0;
}
-function UM(e) {
+function VM(e) {
const t = e.getParent();
- if (!Be(t))
+ if (!Fe(t))
return;
- const n = jr(t);
+ const n = Vr(t);
if (n)
for (let r = e.getPreviousSibling(); r; r = r.getPreviousSibling()) {
if (r.is(n))
return t;
- if (!DM(r))
+ if (!zM(r))
return;
}
}
-function um(e) {
- const t = (n) => Be(n) ? e === "ca" ? jr(n) : Dk(n) : void 0;
+function gm(e) {
+ const t = (n) => Fe(n) ? e === "ca" ? Vr(n) : zk(n) : void 0;
return {
kind: e,
- ownerPredicate: (n) => Be(n),
+ ownerPredicate: (n) => Fe(n),
ownerOf: (n) => {
if (He(n))
- return n.getRunKind() === e && Be(n.getParent()) ? n.getParent() ?? void 0 : void 0;
+ return n.getRunKind() === e && Fe(n.getParent()) ? n.getParent() ?? void 0 : void 0;
const r = n.getParent();
- return He(r) ? r.getRunKind() === e && Be(r.getParent()) ? r.getParent() ?? void 0 : void 0 : KM(n) === e ? UM(n) : void 0;
+ return He(r) ? r.getRunKind() === e && Fe(r.getParent()) ? r.getParent() ?? void 0 : void 0 : jM(n) === e ? VM(n) : void 0;
},
expectedPieces: (n) => {
- if (!Be(n))
- return En;
+ if (!Fe(n))
+ return Mn;
const r = e === "ca" ? n.getAltnumber() : n.getPubnumber();
- return r === void 0 ? En : { wantsRun: !0, valueText: U + r };
+ return r === void 0 ? Mn : { wantsRun: !0, valueText: B + r };
},
- scanPieces: (n) => Be(n) ? e === "ca" ? Mp(n) : Pp(n) : oi,
+ scanPieces: (n) => Fe(n) ? e === "ca" ? Ap(n) : wp(n) : ai,
graceSite: (n, r) => {
- if (!Be(n))
+ if (!Fe(n))
return !1;
if (!r.opener && !r.closer) {
const i = t(n);
- return i !== void 0 && Up(i);
+ return i !== void 0 && Fp(i);
}
- return Wl(r);
+ return Gl(r);
},
settleScope: "owner",
deletionPolicy: "retokenize",
@@ -6482,43 +6482,43 @@ function um(e) {
}
};
}
-function cx(e) {
+function px(e) {
if ($(e)) {
const t = e.getMarkerSyntax();
return t === "selfClosing" || t === "opening";
}
- return T(e) && Te(e, _e) === "attribute";
+ return C(e) && Te(e, _e) === "attribute";
}
-function FM(e) {
+function WM(e) {
for (let t = e.getPreviousSibling(); t; t = t.getPreviousSibling()) {
if (Ve(t)) {
const n = $(e) && e.getMarkerSyntax() === "opening" ? e : void 0;
return !n || n.getMarker() === t.getMarker() ? t : void 0;
}
- if (!cx(t))
+ if (!px(t))
return;
}
}
-const BM = {
+const HM = {
kind: "milestone",
ownerPredicate: (e) => Ve(e),
ownerOf: (e) => {
- const t = He(e) ? e.getRunKind() === "milestone" ? e : void 0 : He(e.getParent()) ? e.getParent() : cx(e) ? e : void 0;
+ const t = He(e) ? e.getRunKind() === "milestone" ? e : void 0 : He(e.getParent()) ? e.getParent() : px(e) ? e : void 0;
if (!t || He(t) && t.getRunKind() !== "milestone")
return;
const n = t.getPreviousSibling();
- return He(t) ? Ve(n) ? n : void 0 : FM(t);
+ return He(t) ? Ve(n) ? n : void 0 : WM(t);
},
expectedPieces: (e) => {
if (!Ve(e))
- return En;
- const t = Lk(e.getSid(), e.getEid(), e.getUnknownAttributes(), e.getAttributeOrder()), n = yr(t, Ha(e.getMarker()));
- return { wantsRun: !0, valueText: n === "" ? void 0 : U + n };
+ return Mn;
+ const t = Uk(e.getSid(), e.getEid(), e.getUnknownAttributes(), e.getAttributeOrder()), n = br(t, Ha(e.getMarker()));
+ return { wantsRun: !0, valueText: n === "" ? void 0 : B + n };
},
scanPieces: (e) => {
if (!Ve(e))
- return oi;
- const { opening: t, attribute: n, closing: r, wrapper: i } = Bl(e);
+ return ai;
+ const { opening: t, attribute: n, closing: r, wrapper: i } = jl(e);
return { opener: t, value: n, closer: r, wrapper: i };
},
graceSite: (e, t) => {
@@ -6534,7 +6534,7 @@ const BM = {
const s = e.getNextSibling();
return s !== null && r.is(s) && n.anchor.offset === 0;
}
- return Wl(t);
+ return Gl(t);
},
settleScope: "owner",
deletionPolicy: "remove-owner",
@@ -6546,13 +6546,13 @@ const BM = {
closerSyntax: "selfClosing",
insertRunAfter: (e) => e
}
-}, zM = Vl("optbreak", void 0, void 0).opening, jM = {
+}, GM = Hl("optbreak", void 0, void 0).opening, JM = {
kind: "optbreak",
ownerPredicate: (e) => Ie(e) && e.getTag() === "optbreak",
ownerOf: (e) => {
const t = e.getParent();
if (!(!Ie(t) || t.getTag() !== "optbreak"))
- return T(e) || Yt(e) ? t : void 0;
+ return C(e) || Yt(e) ? t : void 0;
},
// `valueText` is the RENDERED BYTES the kind owes — so `$runDiverges`'s value-byte comparison
// classifies the scanned token by what it actually spells: a canonical `//` is at rest, a
@@ -6561,13 +6561,13 @@ const BM = {
// CANONICAL optbreak read as diverged while a GUTTED one read as at rest. Nothing ever WRITES
// from this (the `"read-only"` writer returns before any sync write), so the value is purely
// classificatory.
- expectedPieces: () => ({ wantsRun: !0, valueText: zM }),
- scanPieces: (e) => Ie(e) ? { value: e.getFirstChild() ?? void 0 } : oi,
+ expectedPieces: () => ({ wantsRun: !0, valueText: GM }),
+ scanPieces: (e) => Ie(e) ? { value: e.getFirstChild() ?? void 0 } : ai,
graceSite: () => !1,
settleScope: "owner",
deletionPolicy: "remove-owner",
byteFormat: { writer: "read-only", glyphs: "none" }
-}, VM = {
+}, YM = {
kind: "opaqueUnknown",
// Scope is every UnknownNode kind EXCEPT optbreak — `ownerPredicate` excludes it explicitly, so
// `optbreakDescriptor` above is the sole owner of that kind. A non-optbreak UnknownNode is a
@@ -6580,40 +6580,40 @@ const BM = {
ownerPredicate: (e) => Ie(e) && e.getTag() !== "optbreak",
ownerOf: () => {
},
- expectedPieces: () => En,
- scanPieces: () => oi,
+ expectedPieces: () => Mn,
+ scanPieces: () => ai,
graceSite: () => !1,
settleScope: "owner",
deletionPolicy: "none",
byteFormat: { writer: "read-only", glyphs: "none" }
-}, WM = {
+}, XM = {
kind: "nestedGlyph",
// The `+` on a nested span's glyphs. Purely tree-derived and rewritten in place by its own sync;
// there is no state a user edit can leave half-finished, so it owes no pend or deletion duty.
ownerPredicate: (e) => z(e),
ownerOf: () => {
},
- expectedPieces: () => En,
- scanPieces: () => oi,
+ expectedPieces: () => Mn,
+ scanPieces: () => ai,
graceSite: () => !1,
settleScope: "none",
deletionPolicy: "none",
byteFormat: { writer: "kind-owned", glyphs: "none" }
}, Ca = [
- RM,
- IM,
- lm("va"),
- lm("vp"),
- qM,
- um("ca"),
- um("cp"),
+ KM,
BM,
- jM,
- VM,
- WM
-], HM = new Map(Ca.map((e) => [e.kind, e]));
-function ei(e) {
- const t = HM.get(e);
+ hm("va"),
+ hm("vp"),
+ FM,
+ gm("ca"),
+ gm("cp"),
+ HM,
+ JM,
+ YM,
+ XM
+], QM = new Map(Ca.map((e) => [e.kind, e]));
+function ti(e) {
+ const t = QM.get(e);
if (!t)
throw new Error(`No display-run descriptor registered for kind "${e}"`);
return t;
@@ -6625,25 +6625,25 @@ function Kr(e) {
return { owner: n, kind: t.kind };
}
}
-function lx(e) {
+function hx(e) {
return Kr(e) !== void 0;
}
-function GM(e) {
+function ZM(e) {
if (typeof e != "object" || e === null)
return !1;
const { type: t, id: n, start: r, end: i, undisplayed: s } = e;
return typeof t == "string" && typeof n == "string" && Number.isInteger(r) && Number.isInteger(i) && (s === void 0 || typeof s == "boolean");
}
-const Hl = ws("displayAnnotations", {
+const Jl = ws("displayAnnotations", {
parse: (e) => {
if (typeof e != "object" || e === null)
return;
const { basis: t, annotations: n } = e;
- if (!(typeof t != "string" || !Array.isArray(n)) && n.every(GM))
+ if (!(typeof t != "string" || !Array.isArray(n)) && n.every(ZM))
return { basis: t, annotations: n };
}
});
-function JM(e, t) {
+function eP(e, t) {
const n = new Array(e.length).fill(void 0);
let r = 0;
for (; r < e.length && r < t.length && e[r] === t[r]; )
@@ -6660,7 +6660,7 @@ function JM(e, t) {
s[c] === o[l] ? (n[r + c] = r + l, c++, l++) : a[c + 1][l] >= a[c][l + 1] ? c++ : l++;
return n;
}
-function YM(e, t, n) {
+function tP(e, t, n) {
let r, i;
for (let s = t; s < n; s++) {
const o = e[s];
@@ -6668,7 +6668,7 @@ function YM(e, t, n) {
}
return r === void 0 || i === void 0 ? void 0 : [r, i + 1];
}
-const ux = 1, XM = "c", fx = "span";
+const gx = 1, nP = "c", mx = "span";
class Qn extends za {
__marker;
__number;
@@ -6678,7 +6678,7 @@ class Qn extends za {
__pubnumber;
__unknownAttributes;
constructor(t = "", n = !1, r, i, s, o, a) {
- super(a), this.__marker = XM, this.__number = t, this.__showMarker = n, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
+ super(a), this.__marker = nP, this.__number = t, this.__showMarker = n, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
}
static getType() {
return "immutable-chapter";
@@ -6689,14 +6689,14 @@ class Qn extends za {
}
static importDOM() {
return {
- span: (t) => dx(t) ? {
- conversion: QM,
+ span: (t) => yx(t) ? {
+ conversion: rP,
priority: 1
} : null
};
}
static importJSON(t) {
- return Fp().updateFromJSON(t);
+ return zp().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setNumber(t.number).setShowMarker(t.showMarker).setSid(t.sid).setAltnumber(t.altnumber).setPubnumber(t.pubnumber).setUnknownAttributes(t.unknownAttributes);
@@ -6763,15 +6763,15 @@ class Qn extends za {
return this.getLatest().__unknownAttributes;
}
createDOM() {
- const t = document.createElement(fx);
- return t.setAttribute("data-marker", this.__marker), t.classList.add(Bc, `usfm_${this.__marker}`), this.__showMarker && t.classList.add("marker"), t.setAttribute("data-number", this.__number), t;
+ const t = document.createElement(mx);
+ return t.setAttribute("data-marker", this.__marker), t.classList.add(zc, `usfm_${this.__marker}`), this.__showMarker && t.classList.add("marker"), t.setAttribute("data-number", this.__number), t;
}
updateDOM() {
return !1;
}
exportDOM(t) {
const { element: n } = super.exportDOM(t);
- return n && As(n) && (n.setAttribute("data-marker", this.getMarker()), n.classList.add(Bc, `usfm_${this.getMarker()}`), n.setAttribute("data-number", this.getNumber())), { element: n };
+ return n && As(n) && (n.setAttribute("data-marker", this.getMarker()), n.classList.add(zc, `usfm_${this.getMarker()}`), n.setAttribute("data-number", this.getNumber())), { element: n };
}
/**
* VISIBLE bytes with STABLE IDENTITY, which is only safe because of where this node lives.
@@ -6807,7 +6807,7 @@ class Qn extends za {
altnumber: this.getAltnumber(),
pubnumber: this.getPubnumber(),
unknownAttributes: this.getUnknownAttributes(),
- version: ux
+ version: gx
};
}
// Mutation
@@ -6818,29 +6818,29 @@ class Qn extends za {
return !1;
}
}
-function QM(e) {
+function rP(e) {
const t = e.getAttribute("data-number") ?? "0";
- return { node: Fp(t) };
+ return { node: zp(t) };
}
-function Fp(e, t, n, r, i, s) {
+function zp(e, t, n, r, i, s) {
return St(new Qn(e, t, n, r, i, s));
}
-function dx(e) {
- return e ? e.classList.contains(Bc) && e.tagName.toLowerCase() === fx : !1;
+function yx(e) {
+ return e ? e.classList.contains(zc) && e.tagName.toLowerCase() === mx : !1;
}
-function ai(e) {
+function ci(e) {
return e instanceof Qn;
}
-function ZM(e) {
+function iP(e) {
return e?.type === Qn.getType();
}
-const va = "id", px = 1, eP = [
+const va = "id", bx = 1, sP = [
"type",
"marker",
"code",
"content"
];
-class Fn extends vr {
+class Un extends vr {
__marker = va;
__code;
__unknownAttributes;
@@ -6852,14 +6852,14 @@ class Fn extends vr {
}
static clone(t) {
const { __code: n, __unknownAttributes: r, __key: i } = t;
- return new Fn(n, r, i);
+ return new Un(n, r, i);
}
static importJSON(t) {
const { code: n } = t;
- return hx(n).updateFromJSON(t);
+ return kx(n).updateFromJSON(t);
}
static isValidBookCode(t) {
- return y0(t);
+ return C0(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setCode(t.code).setUnknownAttributes(t.unknownAttributes);
@@ -6901,20 +6901,20 @@ class Fn extends vr {
marker: this.getMarker(),
code: this.getCode(),
unknownAttributes: this.getUnknownAttributes(),
- version: px
+ version: bx
};
}
}
-function hx(e, t) {
- return St(new Fn(e, t));
+function kx(e, t) {
+ return St(new Un(e, t));
}
function qe(e) {
- return e instanceof Fn;
+ return e instanceof Un;
}
-function Bp(e) {
- return e?.type === Fn.getType();
+function jp(e) {
+ return e?.type === Un.getType();
}
-const tP = [
+const oP = [
// Identification
"ide",
"sts",
@@ -6992,7 +6992,7 @@ const tP = [
"sd3",
"sd4",
// Body Paragraphs
- Ln,
+ qn,
"m",
"po",
"cls",
@@ -7047,11 +7047,11 @@ const tP = [
"lim4",
// Breaks - see https://docs.usfm.bible/usfm/3.1/char/breaks/pb.html
"pb"
-], gx = 1, nP = ["type", "marker", "content"];
-class Kt extends ap {
+], xx = 1, aP = ["type", "marker", "content"];
+class Kt extends lp {
__marker;
__unknownAttributes;
- constructor(t = Ln, n, r) {
+ constructor(t = qn, n, r) {
super(r), this.__marker = t, this.__unknownAttributes = n;
}
static getType() {
@@ -7062,18 +7062,18 @@ class Kt extends ap {
return new Kt(n, r, i);
}
static isValidMarker(t, n) {
- return t !== void 0 && (tP.includes(t) || (n?.includes(t) ?? !1));
+ return t !== void 0 && (oP.includes(t) || (n?.includes(t) ?? !1));
}
static importDOM() {
return {
p: () => ({
- conversion: rP,
+ conversion: cP,
priority: 1
})
};
}
static importJSON(t) {
- return ps().updateFromJSON(t);
+ return Ai().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setUnknownAttributes(t.unknownAttributes);
@@ -7112,17 +7112,17 @@ class Kt extends ap {
type: this.getType(),
marker: this.getMarker(),
unknownAttributes: this.getUnknownAttributes(),
- version: gx
+ version: xx
};
}
// Mutation
insertNewAfter(t, n) {
- const r = ps(this.getMarker());
+ const r = Ai(this.getMarker());
return r.setTextFormat(t.format), r.setTextStyle(t.style), r.setDirection(this.getDirection()), r.setFormat(this.getFormatType()), r.setStyle(this.getTextStyle()), this.insertAfter(r, n), r;
}
}
-function rP(e) {
- const t = e.getAttribute("data-marker") ?? void 0, n = ps(t);
+function cP(e) {
+ const t = e.getAttribute("data-marker") ?? void 0, n = Ai(t);
if (e.style) {
n.setFormat(e.style.textAlign);
const r = parseInt(e.style.textIndent, 10) / 20;
@@ -7130,74 +7130,74 @@ function rP(e) {
}
return { node: n };
}
-function ps(e, t) {
+function Ai(e, t) {
return St(new Kt(e, t));
}
function ke(e) {
return e instanceof Kt;
}
-function zp(e) {
+function Vp(e) {
return e?.type === Kt.getType();
}
-const mx = /[ \u00A0]{2,}/g, iP = /^[ \u00A0]*/;
-function sP(e) {
- return [...e.matchAll(mx)].map((t) => [
+const Tx = /[ \u00A0]{2,}/g, lP = /^[ \u00A0]*/;
+function uP(e) {
+ return [...e.matchAll(Tx)].map((t) => [
t.index + 1,
t.index + t[0].length
]);
}
-function fm(e) {
- return e.replace(mx, (t) => t[0]);
+function mm(e) {
+ return e.replace(Tx, (t) => t[0]);
}
-function yx(e) {
- return iP.exec(e)?.[0].length ?? 0;
+function Cx(e) {
+ return lP.exec(e)?.[0].length ?? 0;
}
-const oP = "", hs = oP;
-var dm;
+const fP = "", hs = fP;
+var ym;
(function(e) {
e.LEFT = "left", e.RIGHT = "right";
-})(dm || (dm = {}));
-var pm;
+})(ym || (ym = {}));
+var bm;
(function(e) {
e[e.BEFORE = 0] = "BEFORE", e[e.AFTER = 1] = "AFTER";
-})(pm || (pm = {}));
-function aP() {
- return Ue(hs);
+})(bm || (bm = {}));
+function dP() {
+ return Be(hs);
}
-function cP(e) {
+function pP(e) {
return e.length > 0 && e.includes(hs) && e.replaceAll(hs, "") === "";
}
-function Hc(e) {
- return T(e) && cP(e.getTextContent());
+function Gc(e) {
+ return C(e) && pP(e.getTextContent());
}
-const bo = ws("isCaretHost", {
+const ko = ws("isCaretHost", {
parse: (e) => e === !0
});
-function lP() {
- return Wt(aP(), bo, !0);
+function hP() {
+ return Wt(dP(), ko, !0);
}
function Et(e) {
- return T(e) && Te(e, bo) && e.getTextContent() === hs;
+ return C(e) && Te(e, ko) && e.getTextContent() === hs;
}
-function Gc(e) {
- return T(e) && Te(e, bo);
+function Jc(e) {
+ return C(e) && Te(e, ko);
}
function Sa(e) {
- return e[Lr]?.[bo.key] === !0 && e.text === hs;
+ return e[Lr]?.[ko.key] === !0 && e.text === hs;
}
-function bx(e) {
- return aM(e) || ZM(e);
+function Yc(e) {
+ return dM(e) || iP(e);
}
-function ot(e) {
- return Be(e) || ai(e);
+function Ye(e) {
+ return Fe(e) || ci(e);
}
-function kx(e, t) {
- return e.find((n) => ot(n) && n.getNumber() === t.toString());
+function vx(e, t) {
+ return e.find((n) => Ye(n) && n.getNumber() === t.toString());
}
-function uP(e, t = !1) {
- return e.find((n, r) => (!t || r > 0) && ot(n));
+function gP(e, t = !1) {
+ return e.find((n, r) => (!t || r > 0) && Ye(n));
}
-function Yf(e) {
+function Zf(e) {
let t = e;
for (; t && t.getParent() !== null; ) {
const n = t.getPreviousSibling();
@@ -7206,24 +7206,24 @@ function Yf(e) {
t = t.getParent();
}
}
-function fP(e) {
+function mP(e) {
if (!e)
return;
- if (ot(e))
+ if (Ye(e))
return e;
let t = e.getTopLevelElement()?.getPreviousSibling();
- for (; t && !ot(t); )
+ for (; t && !Ye(t); )
t = t.getPreviousSibling();
- if (t && ot(t))
+ if (t && Ye(t))
return t;
}
function hn(e) {
return We(e, K) ?? void 0;
}
-function dP(e) {
- return qe(e) || Be(e) || z(e) || ai(e) || kt(e) || Ve(e) || ke(e) || K(e) || Le(e) || Ie(e);
+function yP(e) {
+ return qe(e) || Fe(e) || z(e) || ci(e) || ht(e) || Ve(e) || ke(e) || K(e) || Le(e) || Ie(e);
}
-function jp(e) {
+function Wp(e) {
if (e.anchor.type === "element") {
const n = e.anchor.getNode(), r = e.anchor.offset;
if (r < n.getChildrenSize())
@@ -7232,23 +7232,23 @@ function jp(e) {
const t = e.anchor.getNode();
return t.getNextSibling() ?? t.getParent()?.getNextSibling() ?? null;
}
-function xx(e) {
+function Sx(e) {
const t = e.anchor.offset;
if (e.anchor.type === "element" && t > 0)
return e.anchor.getNode().getChildAtIndex(t - 1);
const n = e.anchor.getNode();
return n.getPreviousSibling() ?? n.getParent()?.getPreviousSibling() ?? null;
}
-function ct(e) {
- return dt(e) || qe(e);
+function st(e) {
+ return ot(e) || qe(e);
}
-function dt(e) {
- return ke(e) || kt(e);
+function ot(e) {
+ return ke(e) || ht(e);
}
-function pP(e) {
- return zp(e) || zl(e);
+function bP(e) {
+ return Vp(e) || Vl(e);
}
-function ko(e, t) {
+function xo(e, t) {
let n = e.getParent();
for (; n; ) {
if (n.getKey() === t)
@@ -7258,44 +7258,44 @@ function ko(e, t) {
return !1;
}
function gs(e, t) {
- const n = Te(t, ds), r = !!(e.cid && n), i = !e.cid && !n;
+ const n = Te(t, ps), r = !!(e.cid && n), i = !e.cid && !n;
return e.style === t.getMarker() && (i || r && e.cid === n);
}
-function hP(e, t) {
- const n = A(e) ? e : e.getParent(), r = A(t) ? t : t.getParent(), i = n && r ? x0(n, r) : void 0;
+function kP(e, t) {
+ const n = A(e) ? e : e.getParent(), r = A(t) ? t : t.getParent(), i = n && r ? _0(n, r) : void 0;
return i ? i.commonAncestor : void 0;
}
-function gP(e) {
+function xP(e) {
const t = e.getStartEndPoints();
if (!t)
return;
const [n, r] = t, i = e.isBackward() ? n : r;
e.focus.set(i.key, i.offset, i.type), e.anchor.set(i.key, i.offset, i.type);
}
-function ti(e) {
- return e?.type === it.getType();
+function ni(e) {
+ return e?.type === at.getType();
}
-function mP(e, t) {
+function TP(e, t) {
if (!t)
return;
const n = e.findIndex((r) => r === t);
n && (e.length = n);
}
-function yP(e, t) {
+function CP(e, t) {
if (!t)
return e;
const n = t.getIndexWithinParent();
return e.splice(n + 1, e.length - n - 1);
}
-function Tx(e, t, n) {
- const r = rt(e);
+function _x(e, t, n) {
+ const r = it(e);
if (t?.startsWith(r)) {
const i = t.slice(r.length).replace(/^[\s ]+/, ""), s = /^([^ \u00A0\\]+)/.exec(i);
s && (n = s[1]);
}
return n;
}
-function bP(e) {
+function vP(e) {
const t = e[Lr];
if (t && typeof t == "object" && "textType" in t) {
const n = t.textType;
@@ -7303,41 +7303,41 @@ function bP(e) {
return n;
}
}
-function Cx(e) {
- return Sx(e) || ti(e) && bP(e) === "attribute" ? "" : ti(e) && e.text !== U ? e.text : Nk(e) ? e.children.map((t) => Cx(t)).join("") : "";
+function Ex(e) {
+ return Px(e) || ni(e) && vP(e) === "attribute" ? "" : ni(e) && e.text !== B ? e.text : Lk(e) ? e.children.map((t) => Ex(t)).join("") : "";
}
-function kP(e) {
- return e.map((n) => Cx(n)).filter((n) => n.length > 0).join(" ").trim();
+function SP(e) {
+ return e.map((n) => Ex(n)).filter((n) => n.length > 0).join(" ").trim();
}
-function Vp(e) {
+function Hp(e) {
const t = [];
for (const n of e) {
if (!z(n))
continue;
- const r = vx(n);
+ const r = Mx(n);
r !== It && r.length > 0 && t.push(r);
}
return t.join(" ").trim();
}
-function vx(e) {
- return $(e) || On(e) || T(e) && Te(e, _e) === "attribute" ? "" : T(e) ? e.getTextContent() : A(e) ? e.getChildren().map((t) => vx(t)).join("") : "";
+function Mx(e) {
+ return $(e) || $n(e) || C(e) && Te(e, _e) === "attribute" ? "" : C(e) ? e.getTextContent() : A(e) ? e.getChildren().map((t) => Mx(t)).join("") : "";
}
-function On(e) {
+function $n(e) {
return Yt(e) && e.getTextType() === "marker";
}
function Zt(e) {
- return $(e) || On(e);
+ return $(e) || $n(e);
}
-function Wp(e) {
+function Gp(e) {
if (!e || !Zt(e))
return !1;
const t = e.getParent();
return qe(t) && e.is(t.getFirstChild());
}
-function Sx(e) {
- return wo(e) || rx(e) && e.textType === "marker";
+function Px(e) {
+ return No(e) || cx(e) && e.textType === "marker";
}
-function mi(e) {
+function yi(e) {
if (!Ns(e))
return;
const t = e.getNodes();
@@ -7346,39 +7346,39 @@ function mi(e) {
const [n] = t, r = _a(n.getParent());
return r?.is(n) ? r : void 0;
}
-function Tr(e) {
- const t = mi(e)?.getParent();
+function pr(e) {
+ const t = yi(e)?.getParent();
return ke(t) ? t : void 0;
}
function _a(e) {
if (!ke(e))
return;
const t = e.getFirstChild();
- if (Un(t))
+ if (Bn(t))
return We(e, Ie) ? void 0 : t;
}
const Ys = /* @__PURE__ */ new WeakMap();
-function xP(e) {
+function _P(e) {
return Ys.set(e, (Ys.get(e) ?? 0) + 1), () => {
const t = (Ys.get(e) ?? 1) - 1;
t > 0 ? Ys.set(e, t) : Ys.delete(e);
};
}
-function TP() {
+function EP() {
const e = Pt();
return e.isEditable() && (Ys.get(e) ?? 0) > 0;
}
-function _x(e) {
- if (!_a(e.getParent())?.is(e) || !TP())
+function Ax(e) {
+ if (!_a(e.getParent())?.is(e) || !EP())
return !1;
- const t = cp();
+ const t = up();
return t.add(e.getKey()), Mt(t), !0;
}
-function hm(e, t) {
- CP(e, t), e.setMarker(t);
+function km(e, t) {
+ MP(e, t), e.setMarker(t);
}
-function CP(e, t) {
- const n = e.getMarker(), r = rt(n), i = rt(n, !0), s = pt(n), o = pt(n, !0), a = nt.isNoteContentMarker(t);
+function MP(e, t) {
+ const n = e.getMarker(), r = it(n), i = it(n, !0), s = pt(n), o = pt(n, !0), a = rt.isNoteContentMarker(t);
e.getChildren().forEach((c) => {
if (!Zt(c))
return;
@@ -7390,41 +7390,41 @@ function CP(e, t) {
}
if ($(c))
c.setMarker(t);
- else if (On(c)) {
- const d = l.startsWith(rt("", !0));
- c.setTextContent(u ? rt(t, d) : pt(t, d));
+ else if ($n(c)) {
+ const d = l.startsWith(it("", !0));
+ c.setTextContent(u ? it(t, d) : pt(t, d));
}
}
});
}
-function Ct(e, t = b0) {
+function Ct(e, t = v0) {
const n = { ...e };
return t.forEach((r) => {
Reflect.deleteProperty(n, r);
}), Object.keys(n).length === 0 ? void 0 : n;
}
-function ht(e) {
+function gt(e) {
return Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
}
-function Ex(e) {
+function wx(e) {
const t = e instanceof Error ? e.message : String(e);
return t.includes("$caretFromPoint") && (t.includes("does not inherit from ElementNode") || t.includes("does not inherit from TextNode"));
}
-function Mx(e) {
+function Nx(e) {
if (!E(e))
- return gm(e);
+ return xm(e);
const t = e.anchor.getNode();
- if (t && (e.anchor.type === "element" && !A(t) || e.anchor.type === "text" && !T(t)))
+ if (t && (e.anchor.type === "element" && !A(t) || e.anchor.type === "text" && !C(t)))
return t ?? void 0;
try {
- return gm(e) ?? t ?? void 0;
+ return xm(e) ?? t ?? void 0;
} catch (r) {
- if (Ex(r))
+ if (wx(r))
return t ?? void 0;
throw r;
}
}
-function vP(e, t) {
+function PP(e, t) {
if (!t)
return (e + 1).toString();
const n = t.split("-");
@@ -7436,7 +7436,7 @@ function vP(e, t) {
const i = String.fromCharCode(r[2].charCodeAt(0) + 1);
return `${r[1]}${i}`;
}
-function Hp(e, t) {
+function Jp(e, t) {
if (!t)
return !1;
const n = t.split("-").map((r) => parseInt(r));
@@ -7444,72 +7444,72 @@ function Hp(e, t) {
throw new Error("isVerseInRange: invalid range");
return n.length === 1 ? e === n[0] : n.length === 2 && isNaN(n[1]) ? e >= n[0] : (n.length === 2 && isNaN(n[0]) || e >= n[0]) && e <= n[1];
}
-function SP(e) {
+function AP(e) {
return !!e && e.includes("-");
}
-function Px(e) {
+function Ox(e) {
const t = e.split("-"), n = parseInt(t[0], 10), r = t.length > 1 ? parseInt(t[t.length - 1], 10) : n;
return { start: n, end: r };
}
-function gm(e) {
+function xm(e) {
if (!e)
return;
const t = e.getNodes();
if (t.length > 0)
return e.isBackward() ? t[t.length - 1] : t[0];
}
-function Gp(e) {
- if (!T(e))
+function Yp(e) {
+ if (!C(e))
return;
const t = Xn(e);
if (!K(t) || !Dt(t)?.is(e))
return;
- const { start: n, end: r } = Fl(e.getTextContent(), t.getCaller());
+ const { start: n, end: r } = zl(e.getTextContent(), t.getCaller());
return n < r ? { start: n, end: r } : void 0;
}
-function Bn(e) {
+function Fn(e) {
if (!e)
return !1;
- if (Os(e) || $(e) || On(e) || He(e) || e.getType() === Ii || Yt(e) && e.getTextType() === "attribute")
+ if (Os(e) || $(e) || $n(e) || He(e) || e.getType() === Li || Yt(e) && e.getTextType() === "attribute")
return !0;
const t = Xn(e);
- if (Be(t))
+ if (Fe(t))
return !0;
- if (T(e) && K(t) && Dt(t)?.is(e))
- return !Gp(e);
- if (T(e)) {
+ if (C(e) && K(t) && Dt(t)?.is(e))
+ return !Yp(e);
+ if (C(e)) {
const n = Te(e, _e);
- if (n === Br || n === "attribute")
+ if (n === zr || n === "attribute")
return !0;
const r = e.getTextContent();
if (r === "" || Et(e))
return !0;
- if (r === U)
- return !Ax(e);
+ if (r === B)
+ return !$x(e);
}
return !1;
}
-function Ax(e) {
- if (e.getTextContent() !== U || Te(e, _e) !== void 0 || !(ge(e.getParent()) || ge(e.getPreviousSibling()) || ge(e.getNextSibling())) || No(e) > 0)
+function $x(e) {
+ if (e.getTextContent() !== B || Te(e, _e) !== void 0 || !(me(e.getParent()) || me(e.getPreviousSibling()) || me(e.getNextSibling())) || Oo(e) > 0)
return !1;
const n = Xn(e);
- return !z(n) || wx(n, e);
+ return !z(n) || Rx(n, e);
}
-function wx(e, t) {
- return e.getChildren().some((n) => n.is(t) ? !1 : ge(n) ? wx(n, t) : T(n) ? !$(n) && Te(n, _e) === void 0 && n.getTextContent() !== "" && n.getTextContent() !== U && !Et(n) : A(n) && !He(n));
+function Rx(e, t) {
+ return e.getChildren().some((n) => n.is(t) ? !1 : me(n) ? Rx(n, t) : C(n) ? !$(n) && Te(n, _e) === void 0 && n.getTextContent() !== "" && n.getTextContent() !== B && !Et(n) : A(n) && !He(n));
}
function ms() {
- const e = Ue(U);
- return Wt(e, _e, Br), e.setMode("token"), e;
+ const e = Be(B);
+ return Wt(e, _e, zr), e.setMode("token"), e;
}
-function _P(e) {
+function wP(e) {
const t = e.getTextContent();
- t.startsWith(U) || e.setTextContent(U + t);
+ t.startsWith(B) || e.setTextContent(B + t);
}
function an(e) {
- return T(e) && Te(e, _e) === Br;
+ return C(e) && Te(e, _e) === zr;
}
-function Nx(e) {
+function Ix(e) {
const t = e.getFirstChild();
if (!Zt(t) || t === null || an(t.getNextSibling()))
return !1;
@@ -7522,44 +7522,44 @@ function Nx(e) {
const i = t.getNextSibling();
return i !== null && r.is(i) && n.anchor.offset === 0;
}
-function Ox(e) {
- const t = Gp(e);
+function Lx(e) {
+ const t = Yp(e);
return {
- lead: t ? t.start : No(e),
+ lead: t ? t.start : Oo(e),
keptEnd: t ? t.end : e.getTextContentSize()
};
}
-function EP(e) {
+function NP(e) {
return e.every((t) => {
- const { lead: n, keptEnd: r } = Ox(t), i = t.getTextContent().slice(n, r);
- return yx(i) === i.length;
+ const { lead: n, keptEnd: r } = Lx(t), i = t.getTextContent().slice(n, r);
+ return Cx(i) === i.length;
});
}
-function MP(e) {
+function OP(e) {
return Le(e) && e.getAltnumber() === void 0 && e.getPubnumber() === void 0;
}
-function PP(e) {
+function $P(e) {
const t = e.getPreviousSibling();
- return !ot(t) || t.getAltnumber() === void 0 && t.getPubnumber() === void 0;
+ return !Ye(t) || t.getAltnumber() === void 0 && t.getPubnumber() === void 0;
}
-function $x(e, t) {
- if (Be(e))
+function qx(e, t) {
+ if (Fe(e))
return [];
const n = [], r = [];
let i;
const s = () => {
i && (n.push({ type: "text", nodes: i }), i = void 0);
}, o = (a) => {
- if (!Bn(a)) {
- if (wp(a)) {
- s(), PP(a) && r.push(n.length), a.getChildren().forEach(o), s();
+ if (!Fn(a)) {
+ if (Op(a)) {
+ s(), $P(a) && r.push(n.length), a.getChildren().forEach(o), s();
return;
}
- if (Hk(a)) {
+ if (Qk(a)) {
a.getChildren().forEach(o);
return;
}
- if (T(a) && a.getType() === it.getType()) {
+ if (C(a) && a.getType() === at.getType()) {
i ??= [], i.push(a);
return;
}
@@ -7570,37 +7570,37 @@ function $x(e, t) {
if (a.type !== "text")
return !0;
const l = n[c - 1];
- return r.includes(c) || l?.type === "element" && MP(l.node) ? (a.dropsLeadingSpaces = !0, !EP(a.nodes)) : !0;
+ return r.includes(c) || l?.type === "element" && OP(l.node) ? (a.dropsLeadingSpaces = !0, !NP(a.nodes)) : !0;
})) : n;
}
-function AP(e, t) {
+function RP(e, t) {
const n = [];
let r = 0, i = !!e.dropsLeadingSpaces;
for (const s of e.nodes) {
- const { lead: o, keptEnd: a } = Ox(s), c = s.getTextContent().slice(o, a), l = i ? yx(c) : 0;
+ const { lead: o, keptEnd: a } = Lx(s), c = s.getTextContent().slice(o, a), l = i ? Cx(c) : 0;
l < c.length && (i = !1);
- const u = o + l, f = t ? sP(c.slice(l)).map(([p, m]) => [p + u, m + u]) : [];
+ const u = o + l, f = t ? uP(c.slice(l)).map(([p, m]) => [p + u, m + u]) : [];
l > 0 && f.unshift([o, u]), a < s.getTextContentSize() && f.push([a, s.getTextContentSize()]);
const d = s.getTextContentSize() - o - f.reduce((p, [m, h]) => p + h - m, 0);
n.push({ node: s, start: r, lead: o, collapsed: f, length: d }), r += d;
}
return { type: "text", segments: n, length: r };
}
-function Rx(e) {
+function Dx(e) {
return e.lead > 0 ? [[0, e.lead], ...e.collapsed] : e.collapsed;
}
-function wP(e, t) {
+function IP(e, t) {
let n = t;
- for (const [r, i] of Rx(e)) {
+ for (const [r, i] of Dx(e)) {
if (t <= r)
break;
n -= Math.min(t, i) - r;
}
return e.start + n;
}
-function mm(e, t) {
+function Tm(e, t) {
let n = t;
- for (const [r, i] of Rx(e)) {
+ for (const [r, i] of Dx(e)) {
if (r > n)
break;
n += i - r;
@@ -7608,10 +7608,10 @@ function mm(e, t) {
return n;
}
function Xt(e, t) {
- return $x(e, t).map((n) => n.type === "element" ? { type: "element", node: n.node } : AP(n, t));
+ return qx(e, t).map((n) => n.type === "element" ? { type: "element", node: n.node } : RP(n, t));
}
-function NP(e, t, n) {
- return $x(e, n).findIndex((r) => r.type === "element" ? r.node.is(t) : r.nodes.some((i) => i.is(t)));
+function LP(e, t, n) {
+ return qx(e, n).findIndex((r) => r.type === "element" ? r.node.is(t) : r.nodes.some((i) => i.is(t)));
}
function lo(e, t, n) {
const r = Xn(e);
@@ -7624,59 +7624,59 @@ function lo(e, t, n) {
continue;
const a = o.segments.find((c) => c.node.is(e));
if (a)
- return { parent: r, index: s, offset: wP(a, t) };
+ return { parent: r, index: s, offset: IP(a, t) };
}
}
-function OP(e, t) {
+function qP(e, t) {
if (t < 0 || t > e.length)
return;
for (const r of e.segments)
if (t >= r.start && t < r.start + r.length)
- return [r.node, mm(r, t - r.start)];
+ return [r.node, Tm(r, t - r.start)];
const n = e.segments[e.segments.length - 1];
if (n)
- return [n.node, mm(n, t - n.start)];
+ return [n.node, Tm(n, t - n.start)];
}
function io(e, t, n) {
const r = e.getChildAtIndex(t);
- if (wp(e)) {
+ if (Op(e)) {
const s = e.getParentOrThrow();
- return r ? Bn(r) || !Xf(Xt(s, n), r) ? io(e, t + 1, n) : Qf(s, r, n) : io(s, e.getIndexWithinParent() + 1, n);
+ return r ? Fn(r) || !ed(Xt(s, n), r) ? io(e, t + 1, n) : td(s, r, n) : io(s, e.getIndexWithinParent() + 1, n);
}
const i = Xt(e, n);
- return r ? Bn(r) || !Xf(i, r) ? io(e, t + 1, n) : Qf(e, r, n) : { type: "index", index: i.length };
+ return r ? Fn(r) || !ed(i, r) ? io(e, t + 1, n) : td(e, r, n) : { type: "index", index: i.length };
}
-function $P(e, t) {
+function DP(e, t) {
const n = Xn(e);
- if (n && Xf(Xt(n, t), e))
- return { parent: n, point: Qf(n, e, t) };
+ if (n && ed(Xt(n, t), e))
+ return { parent: n, point: td(n, e, t) };
}
-function Xf(e, t) {
- return e.some((n) => n.type === "element" ? n.node.is(t) || ko(n.node, t.getKey()) : n.segments.some((r) => r.node.is(t) || ko(r.node, t.getKey())));
+function ed(e, t) {
+ return e.some((n) => n.type === "element" ? n.node.is(t) || xo(n.node, t.getKey()) : n.segments.some((r) => r.node.is(t) || xo(r.node, t.getKey())));
}
-function Qf(e, t, n) {
+function td(e, t, n) {
const r = Xt(e, n);
for (let i = 0; i < r.length; i++) {
const s = r[i];
if (s.type === "element") {
- if (s.node.is(t) || ko(s.node, t.getKey()))
+ if (s.node.is(t) || xo(s.node, t.getKey()))
return { type: "index", index: i };
continue;
}
for (const o of s.segments)
- if (o.node.is(t) || ko(o.node, t.getKey()))
+ if (o.node.is(t) || xo(o.node, t.getKey()))
return o.start === 0 ? { type: "index", index: i } : { type: "text", index: i, offset: o.start };
}
return { type: "index", index: r.length };
}
-const Jc = "unmatched", Ix = 2;
-function ia(e) {
+const Xc = "unmatched", Kx = 2;
+function sa(e) {
return `\\${e}`;
}
-class _r extends it {
+class _r extends at {
__marker;
constructor(t = "", n) {
- super(ia(t), n), this.__marker = t, this.__mode = 1;
+ super(sa(t), n), this.__marker = t, this.__mode = 1;
}
static getType() {
return "unmatched";
@@ -7687,14 +7687,14 @@ class _r extends it {
}
static importDOM() {
return {
- [Jc]: (t) => IP(t) ? {
- conversion: RP,
+ [Xc]: (t) => BP(t) ? {
+ conversion: KP,
priority: 1
} : null
};
}
static importJSON(t) {
- return Jp().updateFromJSON(t);
+ return Xp().updateFromJSON(t);
}
updateFromJSON(t) {
const n = t.marker ?? "", i = super.updateFromJSON({
@@ -7703,7 +7703,7 @@ class _r extends it {
format: t.format ?? 0,
mode: t.mode ?? "token",
style: t.style ?? "",
- text: t.text ?? ia(n)
+ text: t.text ?? sa(n)
}).getWritable();
return i.__marker = n, i;
}
@@ -7711,29 +7711,29 @@ class _r extends it {
if (this.__marker === t)
return this;
const n = this.getWritable();
- return n.__marker = t, n.__text = ia(t), n;
+ return n.__marker = t, n.__text = sa(t), n;
}
getMarker() {
return this.getLatest().__marker;
}
createDOM(t) {
const n = super.createDOM(t);
- return n.setAttribute("data-marker", this.__marker), n.classList.add(Jg), n.title = ym(this.__marker), n;
+ return n.setAttribute("data-marker", this.__marker), n.classList.add(em), n.title = Cm(this.__marker), n;
}
updateDOM(t, n, r) {
const i = super.updateDOM(t, n, r);
- return t.__marker !== this.__marker && (n.setAttribute("data-marker", this.__marker), n.title = ym(this.__marker)), i;
+ return t.__marker !== this.__marker && (n.setAttribute("data-marker", this.__marker), n.title = Cm(this.__marker)), i;
}
exportDOM() {
- const t = document.createElement(Jc);
- return t.setAttribute("data-marker", this.getMarker()), t.classList.add(Jg), t.textContent = this.getTextContent(), { element: t };
+ const t = document.createElement(Xc);
+ return t.setAttribute("data-marker", this.getMarker()), t.classList.add(em), t.textContent = this.getTextContent(), { element: t };
}
exportJSON() {
return {
...super.exportJSON(),
type: this.getType(),
marker: this.getMarker(),
- version: Ix
+ version: Kx
};
}
canInsertTextBefore() {
@@ -7743,224 +7743,224 @@ class _r extends it {
return !1;
}
}
-function Lx(e) {
- return e.getTextContent() === ia(e.getMarker());
+function Bx(e) {
+ return e.getTextContent() === sa(e.getMarker());
}
-function ym(e) {
+function Cm(e) {
return e.endsWith("*") ? "This closing marker has no matching opening marker!" : "This opening marker has no matching closing marker!";
}
-function RP(e) {
+function KP(e) {
const t = e.getAttribute("data-marker") ?? "";
- return { node: Jp(t) };
+ return { node: Xp(t) };
}
-function Jp(e) {
+function Xp(e) {
return St(new _r(e));
}
-function IP(e) {
- return e?.tagName.toLowerCase() === Jc;
+function BP(e) {
+ return e?.tagName.toLowerCase() === Xc;
}
function bn(e) {
return e instanceof _r;
}
-function LP(e) {
+function UP(e) {
return e?.type === _r.getType();
}
-const qP = /* @__PURE__ */ new Set([
- Ii,
- dk,
- hr.getType(),
+const FP = /* @__PURE__ */ new Set([
+ Li,
+ yk,
+ gr.getType(),
// A chapter in the views without editable markers: the same whole-node treatment as a verse.
Qn.getType()
]);
-function Yp(e) {
- return T(e) && Te(e, _e) === "attribute";
+function Qp(e) {
+ return C(e) && Te(e, _e) === "attribute";
}
-function qx(e) {
- if (!T(e))
+function Ux(e) {
+ if (!C(e))
return !1;
let t = e.getParent();
- for (; ge(t); )
+ for (; me(t); )
t = t.getParent();
- return K(t) ? Dt(t)?.is(e) ?? !1 : Be(t) ? jr(t)?.is(e) ?? !1 : !1;
+ return K(t) ? Dt(t)?.is(e) ?? !1 : Fe(t) ? Vr(t)?.is(e) ?? !1 : !1;
}
-function Xp(e) {
- return on(e) ? qP.has(e.getType()) : !T(e) || an(e) ? !1 : $(e) || Le(e) || Yp(e) || qx(e) || // An unmatched closer (`ImmutableUnmatchedNode`) is a `TextNode` subclass, not a decorator, so
+function Zp(e) {
+ return on(e) ? FP.has(e.getType()) : !C(e) || an(e) ? !1 : $(e) || Le(e) || Qp(e) || Ux(e) || // An unmatched closer (`ImmutableUnmatchedNode`) is a `TextNode` subclass, not a decorator, so
// the decorator-type set above cannot reach it.
bn(e);
}
-function Qp(e) {
- if (!T(e))
+function eh(e) {
+ if (!C(e))
return [0, 0];
if (bn(e))
return [0, e.getTextContentSize()];
const t = e.getTextContent(), n = t.length - t.trimStart().length;
return n === t.length ? [n, n] : [n, t.trimEnd().length];
}
-function Dx(e, t, n) {
+function Fx(e, t, n) {
return e.type === t && e.id === n;
}
-function Kx(e, t) {
+function zx(e, t) {
if (e.basis === t)
return e.annotations;
- const n = JM(e.basis, t);
+ const n = eP(e.basis, t);
return e.annotations.flatMap((r) => {
if (r.start === r.end)
return [r];
- const i = YM(n, r.start, r.end);
+ const i = tP(n, r.start, r.end);
return i ? [{ ...r, start: i[0], end: i[1] }] : [];
});
}
-function Yc(e) {
- return on(e) ? Xc(e) : e.getTextContent();
+function Qc(e) {
+ return on(e) ? Zc(e) : e.getTextContent();
}
-function DP(e) {
+function zP(e) {
return on(e) ? Ls(e) : e.getTextContent();
}
-function Zp(e) {
- const t = Te(e, Hl);
- return t ? Kx(t, Yc(e)) : [];
+function th(e) {
+ const t = Te(e, Jl);
+ return t ? zx(t, Qc(e)) : [];
}
-function KP(e, t) {
+function jP(e, t) {
if (t.start === t.end)
return t;
let n, r;
for (let i = t.start; i < t.end; i++) {
- const s = th.renderedOffset(e, i);
+ const s = rh.renderedOffset(e, i);
if (s === "drawn")
return { type: t.type, id: t.id, start: 0, end: 0 };
s !== void 0 && (n = Math.min(n ?? s, s), r = Math.max(r ?? s + 1, s + 1));
}
return n === void 0 || r === void 0 ? { ...t, undisplayed: !0 } : { type: t.type, id: t.id, start: n, end: r };
}
-function Gr(e) {
- const t = Zp(e);
- return on(e) ? t.map((n) => KP(e, n)) : t;
+function Jr(e) {
+ const t = th(e);
+ return on(e) ? t.map((n) => jP(e, n)) : t;
}
-function eh(e, t) {
+function nh(e, t) {
const n = [...t].sort((r, i) => r.start - i.start || r.end - i.end);
- Wt(e, Hl, n.length > 0 ? { basis: Yc(e), annotations: n } : void 0);
+ Wt(e, Jl, n.length > 0 ? { basis: Qc(e), annotations: n } : void 0);
}
-function bm(e) {
- const t = Gl(e).trim();
+function vm(e) {
+ const t = Yl(e).trim();
if (t)
return t;
- const n = Ls(e), [r, i] = Jl(n);
+ const n = Ls(e), [r, i] = Xl(n);
return n.slice(r, i);
}
-const Ux = {
- holdableText: bm,
+const jx = {
+ holdableText: vm,
renderedOffset: (e, t) => {
- const n = bm(e);
+ const n = vm(e);
if (t >= n.length)
return;
- const r = Ls(e), [i] = Jl(r);
+ const r = Ls(e), [i] = Xl(r);
return r.slice(i, i + n.length) === n ? i + t : "drawn";
}
};
-let th = Ux;
-function UP(e) {
- th = e ?? Ux;
+let rh = jx;
+function VP(e) {
+ rh = e ?? jx;
}
-function Xc(e) {
- return th.holdableText(e);
+function Zc(e) {
+ return rh.holdableText(e);
}
-function FP(e, t, n, r, i) {
+function WP(e, t, n, r, i) {
let s = { type: t, id: n, start: r, end: i };
const o = [];
- for (const a of Zp(e))
- Dx(a, t, n) && a.start <= s.end && s.start <= a.end ? s = {
+ for (const a of th(e))
+ Fx(a, t, n) && a.start <= s.end && s.start <= a.end ? s = {
...s,
start: Math.min(s.start, a.start),
end: Math.max(s.end, a.end)
} : o.push(a);
- eh(e, [...o, s]);
+ nh(e, [...o, s]);
}
-function Fx(e, t, n) {
- const r = Zp(e), i = r.filter((s) => !Dx(s, t, n));
- return i.length === r.length ? !1 : (eh(e, i), !0);
+function Vx(e, t, n) {
+ const r = th(e), i = r.filter((s) => !Fx(s, t, n));
+ return i.length === r.length ? !1 : (nh(e, i), !0);
}
-function Gl(e) {
- if (e.getType() !== Ii)
+function Yl(e) {
+ if (e.getType() !== Li)
return e.getTextContent();
const t = e.getParent();
return K(t) ? t.getCaller() : "";
}
-function BP(e) {
+function HP(e) {
return "getRenderedText" in e && typeof e.getRenderedText == "function";
}
function Ls(e) {
- if (!on(e) || !BP(e))
+ if (!on(e) || !HP(e))
return "";
const t = e.getRenderedText();
return typeof t == "string" ? t : "";
}
-function km(e) {
- return e === mo || /\s/u.test(e);
+function Sm(e) {
+ return e === yo || /\s/u.test(e);
}
-function Jl(e) {
+function Xl(e) {
let t = 0;
- for (; t < e.length && km(e[t]); )
+ for (; t < e.length && Sm(e[t]); )
t++;
if (t === e.length)
return [0, 0];
let n = e.length;
- for (; n > t && km(e[n - 1]); )
+ for (; n > t && Sm(e[n - 1]); )
n--;
return [t, n];
}
-function Zf(e, t) {
+function nd(e, t) {
if (t.undisplayed)
- return Xc(e).slice(t.start, t.end);
+ return Zc(e).slice(t.start, t.end);
if (t.start !== t.end)
- return DP(e).slice(t.start, t.end);
- const n = Xc(e);
+ return zP(e).slice(t.start, t.end);
+ const n = Zc(e);
if (n)
return n;
- const r = Ls(e), [i, s] = Jl(r);
+ const r = Ls(e), [i, s] = Xl(r);
return r.slice(i, s);
}
-function zP(e, t, n) {
- return Gr(e).filter((r) => r.type === t && (r.undisplayed || r.start === r.end || r.start <= n && n <= r.end)).map((r) => r.id);
+function GP(e, t, n) {
+ return Jr(e).filter((r) => r.type === t && (r.undisplayed || r.start === r.end || r.start <= n && n <= r.end)).map((r) => r.id);
}
-function jP(e) {
- const t = Te(e, Hl);
- !t || t.basis === Yc(e) || eh(e, Kx(t, Yc(e)));
+function JP(e) {
+ const t = Te(e, Jl);
+ !t || t.basis === Qc(e) || nh(e, zx(t, Qc(e)));
}
-const Qc = /* @__PURE__ */ new WeakMap();
-function nh(e, t) {
+const el = /* @__PURE__ */ new WeakMap();
+function ih(e, t) {
return JSON.stringify([e, t]);
}
-function VP(e, t, n) {
+function YP(e, t, n) {
const r = Pt();
- let i = Qc.get(r);
- i || (i = /* @__PURE__ */ new Map(), Qc.set(r, i));
- const s = nh(e, t), o = i.get(s), a = Object.fromEntries(Object.entries(n).filter(([, c]) => c !== void 0));
+ let i = el.get(r);
+ i || (i = /* @__PURE__ */ new Map(), el.set(r, i));
+ const s = ih(e, t), o = i.get(s), a = Object.fromEntries(Object.entries(n).filter(([, c]) => c !== void 0));
i.set(s, { ...o, ...a });
}
-function Zc(e, t, n) {
- return Qc.get(e)?.get(nh(t, n));
+function tl(e, t, n) {
+ return el.get(e)?.get(ih(t, n));
}
-function Bx(e, t, n) {
- Qc.get(e)?.delete(nh(t, n));
+function Wx(e, t, n) {
+ el.get(e)?.delete(ih(t, n));
}
-function WP(e, t = []) {
+function XP(e, t = []) {
const r = [
- it,
+ at,
Yn,
Lt,
- hr,
+ gr,
Qn,
...t
- ].filter((i) => e.hasNodes([i])).map((i) => e.registerNodeTransform(i, jP));
+ ].filter((i) => e.hasNodes([i])).map((i) => e.registerNodeTransform(i, JP));
return () => r.forEach((i) => i());
}
-function HP(e) {
- return Le(e) || Ve(e) || He(e) || He(e.getParent()) || qx(e) || bn(e);
+function QP(e) {
+ return Le(e) || Ve(e) || He(e) || He(e.getParent()) || Ux(e) || bn(e);
}
-function rh(e) {
- return T(e) ? e.getTextContentSize() : 1;
+function sh(e) {
+ return C(e) ? e.getTextContentSize() : 1;
}
-function ih(e) {
+function oh(e) {
let t = e;
for (; A(t); ) {
const n = t.getFirstChild();
@@ -7970,7 +7970,7 @@ function ih(e) {
}
return t;
}
-function zx(e) {
+function Hx(e) {
let t = e;
for (; A(t); ) {
const n = t.getLastChild();
@@ -7980,123 +7980,123 @@ function zx(e) {
}
return t;
}
-function xm(e) {
+function _m(e) {
const t = e.getNode();
if (!A(t))
- return { leaf: t, offset: T(t) ? e.offset : Math.min(e.offset, 1) };
+ return { leaf: t, offset: C(t) ? e.offset : Math.min(e.offset, 1) };
const n = t.getChildAtIndex(e.offset);
if (n)
- return { leaf: ih(n), offset: 0 };
+ return { leaf: oh(n), offset: 0 };
const r = t.getLastChild();
if (!r)
return { leaf: t, offset: 0 };
- const i = zx(r);
- return { leaf: i, offset: rh(i) };
+ const i = Hx(r);
+ return { leaf: i, offset: sh(i) };
}
function Pc(e, t) {
return e.leaf.is(t.leaf) ? e.offset - t.offset : e.leaf.isBefore(t.leaf) ? -1 : 1;
}
-function jx(e, t, n) {
- const r = rh(e);
+function Gx(e, t, n) {
+ const r = sh(e);
let i = r;
t.leaf.is(e) ? i = t.offset : t.leaf.isBefore(e) && (i = 0);
let s = 0;
return n.leaf.is(e) ? s = n.offset : e.isBefore(n.leaf) && (s = r), [i, Math.max(i, s)];
}
-function GP(e) {
+function ZP(e) {
for (let t = e; t; t = t.getParent()) {
const n = t.getNextSibling();
if (n)
- return ih(n);
+ return oh(n);
}
}
-function JP(e, t, n) {
- const r = ih(e), i = zx(e);
- if (Pc(t, { leaf: r, offset: 0 }) > 0 || Pc(n, { leaf: i, offset: rh(i) }) < 0)
+function eA(e, t, n) {
+ const r = oh(e), i = Hx(e);
+ if (Pc(t, { leaf: r, offset: 0 }) > 0 || Pc(n, { leaf: i, offset: sh(i) }) < 0)
return !1;
if (an(i)) {
- const s = GP(e);
+ const s = ZP(e);
if (!s || Pc(n, { leaf: s, offset: 0 }) <= 0)
return !1;
}
return !0;
}
-function YP(e, t, n, r) {
- if (!Xp(e))
+function tA(e, t, n, r) {
+ if (!Zp(e))
return;
- const [i, s] = jx(e, t, n);
+ const [i, s] = Gx(e, t, n);
if (s <= i)
return;
- if (!T(e)) {
+ if (!C(e)) {
const l = r?.get(e.getKey());
- return l ? [l.start, l.end] : [0, Xc(e).length];
+ return l ? [l.start, l.end] : [0, Zc(e).length];
}
- const [o, a] = Qp(e), c = [Math.max(i, o), Math.min(s, a)];
+ const [o, a] = eh(e), c = [Math.max(i, o), Math.min(s, a)];
return c[1] > c[0] ? c : void 0;
}
-function sh(e, t, n, r, i, s, o, a = {}) {
+function ah(e, t, n, r, i, s, o, a = {}) {
if (e.isCollapsed())
return;
- const c = e.getNodes(), l = e.isBackward(), [u, f] = l ? [e.focus, e.anchor] : [e.anchor, e.focus], d = xm(u), p = xm(f);
+ const c = e.getNodes(), l = e.isBackward(), [u, f] = l ? [e.focus, e.anchor] : [e.anchor, e.focus], d = _m(u), p = _m(f);
if (Pc(d, p) >= 0)
return;
let m = !1;
const h = (b) => {
- const C = YP(b, d, p, a.decoratorHolds);
- C && (_t(Ec), FP(b, t, n, C[0], C[1]), m = !0);
+ const T = tA(b, d, p, a.decoratorHolds);
+ T && (_t(Ec), WP(b, t, n, T[0], T[1]), m = !0);
};
let g, y;
for (const b of c) {
if (A(y) && y.isParentOf(b))
continue;
- if ($(b) || an(b) || Yp(b) || HP(b)) {
+ if ($(b) || an(b) || Qp(b) || QP(b)) {
h(b), g = b.getParent(), y = void 0;
continue;
}
- let C = null;
- if (T(b)) {
- const [x, _] = jx(b, d, p), F = Math.max(x, No(b));
- if (F >= _)
+ let T = null;
+ if (C(b)) {
+ const [x, _] = Gx(b, d, p), U = Math.max(x, Oo(b));
+ if (U >= _)
continue;
- _t(Ec), C = b.splitText(F, _)[F > 0 ? 1 : 0];
+ _t(Ec), T = b.splitText(U, _)[U > 0 ? 1 : 0];
} else {
- if (ge(b))
+ if (me(b))
continue;
if (A(b) && b.isInline()) {
- if (!JP(b, d, p))
+ if (!eA(b, d, p))
continue;
- C = b;
+ T = b;
}
}
- if (C !== null) {
- if (C && C.is(g))
+ if (T !== null) {
+ if (T && T.is(g))
continue;
_t(Ec);
- const x = C.getParent();
- (x == null || !x.is(g)) && (y = void 0), g = x, y === void 0 && (y = us(), y.addID(t, n, r, i, s, o), C.insertBefore(y)), y.append(C);
+ const x = T.getParent();
+ (x == null || !x.is(g)) && (y = void 0), g = x, y === void 0 && (y = fs(), y.addID(t, n, r, i, s, o), T.insertBefore(y)), y.append(T);
} else
h(b), g = void 0, y = void 0;
}
- m && VP(t, n, { onClick: r, onRemove: i, onMouseEnter: s, onMouseLeave: o }), t === Vt && A(y) && (l ? y.selectStart() : y.selectEnd());
+ m && YP(t, n, { onClick: r, onRemove: i, onMouseEnter: s, onMouseLeave: o }), t === Vt && A(y) && (l ? y.selectStart() : y.selectEnd());
}
-const Vx = "table:row", Tm = "immutable-table-row", Wx = 1, ed = "tr", XP = ["type", "marker", "content"];
+const Jx = "table:row", Em = "immutable-table-row", Yx = 1, rd = "tr", nA = ["type", "marker", "content"];
class qs extends vr {
__marker;
__unknownAttributes;
- constructor(t = ed, n, r) {
+ constructor(t = rd, n, r) {
super(r), this.__marker = t, this.__unknownAttributes = n;
}
static getType() {
- return Tm;
+ return Em;
}
static clone(t) {
return new qs(t.__marker, t.__unknownAttributes, t.__key);
}
static importJSON(t) {
- return QP().updateFromJSON(t);
+ return rA().updateFromJSON(t);
}
updateFromJSON(t) {
- return super.updateFromJSON(t).setMarker(t.marker ?? ed).setUnknownAttributes(t.unknownAttributes);
+ return super.updateFromJSON(t).setMarker(t.marker ?? rd).setUnknownAttributes(t.unknownAttributes);
}
setMarker(t) {
if (this.__marker === t)
@@ -8125,27 +8125,27 @@ class qs extends vr {
const t = this.getUnknownAttributes();
return {
...super.exportJSON(),
- type: Tm,
+ type: Em,
marker: this.getMarker(),
...t !== void 0 && { unknownAttributes: t },
- version: Wx
+ version: Yx
};
}
}
-function QP(e, t) {
+function rA(e, t) {
return St(new qs(e, t));
}
-function Hx(e) {
+function Xx(e) {
return e instanceof qs;
}
-const Gx = "table:cell", Cm = "immutable-table-cell", Jx = 1, td = "tc1", ZP = [
+const Qx = "table:cell", Mm = "immutable-table-cell", Zx = 1, id = "tc1", iA = [
"type",
"marker",
"align",
"colspan",
"content"
];
-function eA(e) {
+function sA(e) {
return e === "start" || e === "center" || e === "end" ? e : void 0;
}
class Ds extends vr {
@@ -8153,21 +8153,21 @@ class Ds extends vr {
__align;
__colspan;
__unknownAttributes;
- constructor(t = td, n, r, i, s) {
+ constructor(t = id, n, r, i, s) {
super(s), this.__marker = t, this.__align = n, this.__colspan = r, this.__unknownAttributes = i;
}
static getType() {
- return Cm;
+ return Mm;
}
static clone(t) {
const { __marker: n, __align: r, __colspan: i, __unknownAttributes: s, __key: o } = t;
return new Ds(n, r, i, s, o);
}
static importJSON(t) {
- return tA().updateFromJSON(t);
+ return oA().updateFromJSON(t);
}
updateFromJSON(t) {
- return super.updateFromJSON(t).setMarker(t.marker ?? td).setAlign(t.align).setColspan(t.colspan).setUnknownAttributes(t.unknownAttributes);
+ return super.updateFromJSON(t).setMarker(t.marker ?? id).setAlign(t.align).setColspan(t.colspan).setUnknownAttributes(t.unknownAttributes);
}
setMarker(t) {
if (this.__marker === t)
@@ -8206,7 +8206,7 @@ class Ds extends vr {
createDOM() {
const t = this.__marker.startsWith("th"), n = document.createElement(t ? "th" : "td");
n.setAttribute("data-marker", this.__marker), n.classList.add("table-cell", `usfm_${this.__marker}`);
- const r = eA(this.__align);
+ const r = sA(this.__align);
return r && (n.style.textAlign = r), this.__colspan && n.setAttribute("colspan", this.__colspan), n;
}
updateDOM(t) {
@@ -8216,31 +8216,31 @@ class Ds extends vr {
const t = this.getAlign(), n = this.getColspan(), r = this.getUnknownAttributes();
return {
...super.exportJSON(),
- type: Cm,
+ type: Mm,
marker: this.getMarker(),
...t !== void 0 && { align: t },
...n !== void 0 && { colspan: n },
...r !== void 0 && { unknownAttributes: r },
- version: Jx
+ version: Zx
};
}
}
-function tA(e, t, n, r) {
+function oA(e, t, n, r) {
return St(new Ds(e, t, n, r));
}
-function nA(e) {
+function aA(e) {
return e instanceof Ds;
}
-const nd = /* @__PURE__ */ new WeakMap();
-function Zu(e, t) {
- t ? nd.set(e, t) : nd.delete(e);
+const sd = /* @__PURE__ */ new WeakMap();
+function nf(e, t) {
+ t ? sd.set(e, t) : sd.delete(e);
}
-function Yl(e) {
- return nd.get(e);
+function Ql(e) {
+ return sd.get(e);
}
function Ks(e, t) {
const n = e.getChildAtIndex(t);
- return T(n) ? n : void 0;
+ return C(n) ? n : void 0;
}
function zn(e, t) {
const n = Ks(e, t);
@@ -8249,42 +8249,42 @@ function zn(e, t) {
function Ea(e) {
return e.getUnknownAttributes()?.closed !== "false";
}
-function rA(e) {
+function cA(e) {
return e.getChildren().some((t) => $(t) && t.getMarkerSyntax() === "closing");
}
-function iA(e) {
+function lA(e) {
return Ea(e) ? void 0 : { closed: "false" };
}
-function sA(e, t, n, r) {
- const i = t.getMarker(), s = jl(t), o = rA(t), a = r ? Jt(i, "opening", s) : void 0;
+function uA(e, t, n, r) {
+ const i = t.getMarker(), s = Wl(t), o = cA(t), a = r ? Jt(i, "opening", s) : void 0;
if (a) {
e.append(a);
const [c] = n;
- si(c) && !c.getTextContent().startsWith(U) && c.setTextContent(U + c.getTextContent());
+ oi(c) && !c.getTextContent().startsWith(B) && c.setTextContent(B + c.getTextContent());
}
- e.append(...n), a && Zk(a, e), o && e.append(Jt(i, "closing", s));
+ e.append(...n), a && ix(a, e), o && e.append(Jt(i, "closing", s));
}
function ys(e) {
return We(e, z) ?? void 0;
}
-function oA(e) {
+function fA(e) {
let t = e.getParent();
for (; z(t); )
t = t.getParent();
return t;
}
-function rd(e) {
- const t = Yx(e);
- return e.getChildren().every((n) => $(n) || t && Te(n, _e) === "attribute" || T(n) && n.getTextContent().replaceAll(U, "") === "");
+function od(e) {
+ const t = eT(e);
+ return e.getChildren().every((n) => $(n) || t && Te(n, _e) === "attribute" || C(n) && n.getTextContent().replaceAll(B, "") === "");
}
-function Yx(e) {
+function eT(e) {
return Ea(e);
}
-function aA(e, t) {
- const n = e.getUnknownAttributes(), r = n ? yr(n, Ao(e.getMarker())) : "";
- r !== "" && t.insertAfter(Ue(r)), e.remove();
+function dA(e, t) {
+ const n = e.getUnknownAttributes(), r = n ? br(n, wo(e.getMarker())) : "";
+ r !== "" && t.insertAfter(Be(r)), e.remove();
}
-function cA(e, t) {
+function pA(e, t) {
if (Ea(e))
return;
const n = e.getUnknownAttributes();
@@ -8292,89 +8292,89 @@ function cA(e, t) {
const r = { ...n };
delete r.closed, e.setUnknownAttributes(Object.keys(r).length > 0 ? r : void 0);
}
- t && e.append(Jt(e.getMarker(), "closing", jl(e)));
+ t && e.append(Jt(e.getMarker(), "closing", Wl(e)));
}
-function lA(e, t) {
+function hA(e, t) {
return z(e) && !Ea(e) && !Ea(t);
}
-function uA(e, t, n) {
- rd(e) && e.getChildren().forEach((s) => {
+function gA(e, t, n) {
+ od(e) && e.getChildren().forEach((s) => {
$(s) || s.remove();
});
const [r] = t;
- n && si(r) && !r.getTextContent().startsWith(U) && r.setTextContent(U + r.getTextContent()), e.append(...t);
+ n && oi(r) && !r.getTextContent().startsWith(B) && r.setTextContent(B + r.getTextContent()), e.append(...t);
const i = e.getFirstChild();
- n && $(i) && i.getMarkerSyntax() === "opening" && Zk(i, e);
+ n && $(i) && i.getMarkerSyntax() === "opening" && ix(i, e);
}
-function fA(e, t, n) {
- const { renderGlyphs: r, closeImplicitSpans: i = !1 } = n, s = Yx(t), o = [];
+function mA(e, t, n) {
+ const { renderGlyphs: r, closeImplicitSpans: i = !1 } = n, s = eT(t), o = [];
for (let l = e.getNextSibling(); l; ) {
const u = l.getNextSibling(), f = $(l) && l.getMarkerSyntax() === "closing", d = s && Te(l, _e) === "attribute";
!f && !d && o.push(l), l = u;
}
- const a = lA(e, t);
+ const a = hA(e, t);
t.insertAfter(e);
let c = e;
if (o.length > 0)
if (a)
- uA(e, o, r);
+ gA(e, o, r);
else {
- const l = Qr(t.getMarker(), iA(t));
- sA(l, t, o, r), e.insertAfter(l), rd(l) ? l.remove() : c = l;
+ const l = Zr(t.getMarker(), lA(t));
+ uA(l, t, o, r), e.insertAfter(l), od(l) ? l.remove() : c = l;
}
- i && !a && cA(t, r), rd(t) && aA(t, c);
+ i && !a && pA(t, r), od(t) && dA(t, c);
}
-function xo(e, t) {
+function To(e, t) {
let n = e.getParent();
for (; z(n); )
- fA(e, n, t), n = e.getParent();
+ mA(e, n, t), n = e.getParent();
}
-function Xl(e) {
- if (T(e) && !$(e)) {
- const t = No(e);
+function Zl(e) {
+ if (C(e) && !$(e)) {
+ const t = Oo(e);
e.select(t, t);
return;
}
if (A(e)) {
- const t = e.getChildren().filter((r) => !$(r)), n = t.find((r, i) => i === t.length - 1 || !T(r) || r.getTextContent() !== U);
+ const t = e.getChildren().filter((r) => !$(r)), n = t.find((r, i) => i === t.length - 1 || !C(r) || r.getTextContent() !== B);
if (n) {
- Xl(n);
+ Zl(n);
return;
}
e.selectEnd();
}
}
-function dA(e) {
+function yA(e) {
return !!(e.opener || e.value || e.closer || e.wrapper);
}
-function id(e) {
+function ad(e) {
return !!(e.opener || e.value || e.closer);
}
-function vm(e) {
+function Pm(e) {
return /^\s/.test(e);
}
-function oh(e, t) {
+function ch(e, t) {
if (e === t)
return !1;
- if (e === void 0 || t === void 0 || !vm(t) || !vm(e))
+ if (e === void 0 || t === void 0 || !Pm(t) || !Pm(e))
return !0;
const n = t.trim();
return n === "" || e.trim() !== n;
}
-function Ql(e, t, n) {
- return n.wantsRun ? oh(t.value?.getTextContent(), n.valueText) || e.byteFormat.glyphs !== "none" && (!t.opener || e.byteFormat.closerSyntax !== "none" && !t.closer) ? !0 : e.byteFormat.writer === "wrapper" && t.wrapper === void 0 : dA(t);
+function eu(e, t, n) {
+ return n.wantsRun ? ch(t.value?.getTextContent(), n.valueText) || e.byteFormat.glyphs !== "none" && (!t.opener || e.byteFormat.closerSyntax !== "none" && !t.closer) ? !0 : e.byteFormat.writer === "wrapper" && t.wrapper === void 0 : yA(t);
}
-function pA(e, t) {
+function bA(e, t) {
if (e.byteFormat.writer !== "wrapper")
return !1;
const n = e.expectedPieces(t);
if (!n.wantsRun)
return !1;
const r = e.scanPieces(t);
- return oh(r.value?.getTextContent(), n.valueText) || e.byteFormat.glyphs !== "none" && (!r.opener || e.byteFormat.closerSyntax !== "none" && !r.closer) ? !1 : r.wrapper === void 0;
+ return ch(r.value?.getTextContent(), n.valueText) || e.byteFormat.glyphs !== "none" && (!r.opener || e.byteFormat.closerSyntax !== "none" && !r.closer) ? !1 : r.wrapper === void 0;
}
-function Xx(e, t) {
- return !id(e.scanPieces(t));
+function tT(e, t) {
+ return !ad(e.scanPieces(t));
}
function Ya(e, t) {
if (!t.isAttached())
@@ -8382,46 +8382,46 @@ function Ya(e, t) {
if (e.byteFormat.writer === "kind-owned")
return e.graceSite(t, {});
const n = e.expectedPieces(t), r = e.scanPieces(t);
- if (!Ql(e, r, n))
+ if (!eu(e, r, n))
return !1;
const i = M();
if (!E(i) || !i.isCollapsed())
return !1;
const s = i.anchor.getNode(), { wrapper: o, value: a } = r;
- return o && (s.is(o) || ko(s, o.getKey())) ? !0 : a ? s.is(a) : e.graceSite(t, r);
+ return o && (s.is(o) || xo(s, o.getKey())) ? !0 : a ? s.is(a) : e.graceSite(t, r);
}
-function hA(e, t, n, r) {
- return !n.wantsRun || id(r) || Yl(Pt()) === "remote" ? !1 : Pt().getEditorState().read(() => {
+function kA(e, t, n, r) {
+ return !n.wantsRun || ad(r) || Ql(Pt()) === "remote" ? !1 : Pt().getEditorState().read(() => {
const i = ee(t.getKey());
- return !i || !e.ownerPredicate(i) ? !1 : id(e.scanPieces(i));
+ return !i || !e.ownerPredicate(i) ? !1 : ad(e.scanPieces(i));
});
}
-function gA(e) {
+function xA(e) {
e.opener?.remove(), e.value?.remove(), e.closer?.remove();
}
-function Sm(e) {
- const t = Ue(e);
+function Am(e) {
+ const t = Be(e);
return Wt(t, _e, "attribute"), t;
}
-function mA(e, t, n) {
+function TA(e, t, n) {
if (n.wrapper)
return n.wrapper;
const { runKind: r, insertRunAfter: i } = e.byteFormat, s = i?.(t);
if (!r || !s)
return;
- const o = Mk(r);
+ const o = Ok(r);
return s.insertAfter(o), n.opener && o.append(n.opener), n.value && o.append(n.value), n.closer && o.append(n.closer), o;
}
-function yA(e, t, n, r) {
+function CA(e, t, n, r) {
const { writer: i, glyphs: s, glyphMarker: o, closerSyntax: a, insertRunBefore: c } = e.byteFormat;
if (i === "owner-children") {
const d = c?.(t);
if (!d || r.valueText === void 0)
return;
- T(n.value) ? n.value.setTextContent(r.valueText) : d.insertBefore(Sm(r.valueText));
+ C(n.value) ? n.value.setTextContent(r.valueText) : d.insertBefore(Am(r.valueText));
return;
}
- const l = mA(e, t, n);
+ const l = TA(e, t, n);
if (!l || s === "none" || !o || !a)
return;
const u = n.opener ?? (() => {
@@ -8429,110 +8429,110 @@ function yA(e, t, n, r) {
return p ? p.insertBefore(d) : l.append(d), d;
})();
let f = n.value;
- r.valueText === void 0 ? (f?.remove(), f = void 0) : T(f) ? oh(f.getTextContent(), r.valueText) && f.setTextContent(r.valueText) : (f = Sm(r.valueText), u.insertAfter(f)), a !== "none" && !n.closer && (f ?? u).insertAfter(Jt(a === "selfClosing" ? "" : o(t), a));
+ r.valueText === void 0 ? (f?.remove(), f = void 0) : C(f) ? ch(f.getTextContent(), r.valueText) && f.setTextContent(r.valueText) : (f = Am(r.valueText), u.insertAfter(f)), a !== "none" && !n.closer && (f ?? u).insertAfter(Jt(a === "selfClosing" ? "" : o(t), a));
}
function Ma(e, t) {
const { writer: n } = e.byteFormat;
if (n === "kind-owned" || n === "read-only" || !t.isAttached())
return;
const r = e.expectedPieces(t), i = e.scanPieces(t);
- if (Ql(e, i, r) && !Jk(t)) {
- if (hA(e, t, r, i)) {
- Yk(t);
+ if (eu(e, i, r) && !ex(t)) {
+ if (kA(e, t, r, i)) {
+ tx(t);
return;
}
if (!Ya(e, t)) {
if (!r.wantsRun) {
- gA(i);
+ xA(i);
return;
}
- yA(e, t, i, r);
+ CA(e, t, i, r);
}
}
}
-function bA(e, t, n) {
+function vA(e, t, n) {
Ma(e, t), t.isAttached() && Ya(e, t) && n.add(t.getKey());
}
function Xa(e) {
- if (!T(e))
+ if (!C(e))
return !1;
if ($(e) || Le(e) || bn(e))
return !0;
const t = Te(e, _e);
- return t === "attribute" || t === Br;
+ return t === "attribute" || t === zr;
}
-function ah(e, t) {
+function lh(e, t) {
return $(e) ? !(t === e.getTextContentSize() && e.getMarkerSyntax() !== "opening" && Sr(e) && z(e.getParent())) : !1;
}
-function kA() {
+function SA() {
const e = M();
- return E(e) ? ah(e.focus.getNode(), e.focus.offset) : !1;
+ return E(e) ? lh(e.focus.getNode(), e.focus.offset) : !1;
}
-function Qx(e) {
+function nT(e) {
if (e.type !== "text")
return;
const t = e.getNode();
- return T(t) && Xa(t) ? t : void 0;
+ return C(t) && Xa(t) ? t : void 0;
}
-function xA(e) {
- const t = Qx(e);
+function _A(e) {
+ const t = nT(e);
if (t)
return e.offset > 0 && e.offset < t.getTextContentSize() ? t : void 0;
}
-function TA(e) {
- const t = Qx(e);
+function EA(e) {
+ const t = nT(e);
if (t)
return e.offset === 0 || e.offset === t.getTextContentSize() ? t : void 0;
}
-function _m(e) {
+function wm(e) {
return { key: e.key, offset: e.offset, type: e.type };
}
-function Em(e, t) {
+function Nm(e, t) {
e.set(t.key, t.offset, t.type);
}
-function CA(e, t) {
- let n = TA(e);
+function MA(e, t) {
+ let n = EA(e);
for (; n; ) {
const r = t === "next" ? n.getNextSibling() : n.getPreviousSibling();
- if (!T(r))
+ if (!C(r))
return;
if (!Xa(r))
return { node: r, offset: t === "next" ? 0 : r.getTextContentSize() };
n = r;
}
}
-function Mm(e, t) {
- const n = CA(e, t);
+function Om(e, t) {
+ const n = MA(e, t);
return n ? (e.set(n.node.getKey(), n.offset, "text"), !0) : !1;
}
-function ch(e) {
+function uh(e) {
if (e.isCollapsed()) {
- const a = xA(e.anchor);
+ const a = _A(e.anchor);
if (!a)
return !1;
const c = a.getTextContentSize();
return e.anchor.set(a.getKey(), c, "text"), e.focus.set(a.getKey(), c, "text"), !0;
}
- const t = e.isBackward(), n = t ? e.focus : e.anchor, r = t ? e.anchor : e.focus, i = [_m(n), _m(r)], s = Mm(n, "next"), o = Mm(r, "previous");
- return !s && !o ? !1 : e.isCollapsed() || e.isBackward() !== t ? (Em(n, i[0]), Em(r, i[1]), !1) : !0;
+ const t = e.isBackward(), n = t ? e.focus : e.anchor, r = t ? e.anchor : e.focus, i = [wm(n), wm(r)], s = Om(n, "next"), o = Om(r, "previous");
+ return !s && !o ? !1 : e.isCollapsed() || e.isBackward() !== t ? (Nm(n, i[0]), Nm(r, i[1]), !1) : !0;
}
-const Zx = ws("verseBlockSource", {
+const rT = ws("verseBlockSource", {
parse: (e) => typeof e == "number" ? e : void 0
-}), el = "verse-block", eT = 1, vA = "verse-block";
-class $o extends vr {
+}), nl = "verse-block", iT = 1, PA = "verse-block";
+class Ro extends vr {
/** The verse marker verbatim. Authoritative: the range is derived from it, never stored. */
__number;
constructor(t = "", n) {
super(n), this.__number = t;
}
static getType() {
- return el;
+ return nl;
}
static clone(t) {
- return new $o(t.__number, t.__key);
+ return new Ro(t.__number, t.__key);
}
static importJSON(t) {
- return SA().updateFromJSON(t);
+ return AA().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setNumber(t.number);
@@ -8548,14 +8548,14 @@ class $o extends vr {
}
/** The first and last verse numbers this block covers. A bridge covers more than one. */
getRange() {
- return Px(this.getNumber());
+ return Ox(this.getNumber());
}
createDOM() {
const t = document.createElement("div");
- return t.classList.add(vA), Pm(t, this.__number), t;
+ return t.classList.add(PA), $m(t, this.__number), t;
}
updateDOM(t, n) {
- return t.__number !== this.__number && Pm(n, this.__number), !1;
+ return t.__number !== this.__number && $m(n, this.__number), !1;
}
// No `exportDOM`/`importDOM`: Lexical's default export already emits `createDOM`'s element, so
// the HTML flavor of a copied passage carries these wrappers, which an ordinary paste unwraps
@@ -8577,42 +8577,42 @@ class $o extends vr {
exportJSON() {
return {
...super.exportJSON(),
- type: el,
+ type: nl,
number: this.getNumber(),
- version: eT
+ version: iT
};
}
canBeEmpty() {
return !1;
}
}
-function Pm(e, t) {
- const { start: n, end: r } = Px(t), i = !isNaN(n) && !isNaN(r) && n <= r;
- e.setAttribute("data-verse-number", t), Am(e, "data-verse-start", i ? n : NaN), Am(e, "data-verse-end", i ? r : NaN);
+function $m(e, t) {
+ const { start: n, end: r } = Ox(t), i = !isNaN(n) && !isNaN(r) && n <= r;
+ e.setAttribute("data-verse-number", t), Rm(e, "data-verse-start", i ? n : NaN), Rm(e, "data-verse-end", i ? r : NaN);
}
-function Am(e, t, n) {
+function Rm(e, t, n) {
isNaN(n) ? e.removeAttribute(t) : e.setAttribute(t, n.toString());
}
-function SA(e) {
- return St(new $o(e));
+function AA(e) {
+ return St(new Ro(e));
}
function bs(e) {
- return e instanceof $o;
+ return e instanceof Ro;
}
-function _A(e) {
- return e?.type === el;
+function wA(e) {
+ return e?.type === nl;
}
-const EA = [
- Fn,
+const NA = [
+ Un,
Qn,
- $n,
+ Rn,
Lt,
- nt,
- at,
- xr,
+ rt,
+ lt,
+ Tr,
Yn,
Rs,
- hr,
+ gr,
_r,
Kt,
Dr,
@@ -8626,10 +8626,10 @@ const EA = [
// every USJ-shaped editor needs the class registered, not only shared-react's (a non-react host,
// e.g. packages/scribe's NoteEditor, builds its editor straight from usjBaseNodes with no
// react-specific node list).
- zr,
+ jr,
{
- replace: ap,
- with: () => qn(),
+ replace: lp,
+ with: () => En(),
withKlass: Dr
}
], ks = {
@@ -15672,13 +15672,13 @@ const EA = [
fontSize: 12
}
}
-}, MA = {
+}, OA = {
paragraph: v.Paragraph,
character: v.Character,
note: v.Note,
milestone: v.Milestone
};
-function lh(e) {
+function fh(e) {
if (!e)
return Rr;
const t = /* @__PURE__ */ new Map();
@@ -15690,7 +15690,7 @@ function lh(e) {
// markers the generated data lacks (`w`, `rb`, `jmp`), and reading the table directly
// demoted exactly those to Uncategorized whenever a project StyleInfo was active.
category: Rr(n)?.category ?? S.Uncategorized,
- type: MA[r.styleType] ?? v.Unknown,
+ type: OA[r.styleType] ?? v.Unknown,
description: r.description ?? "",
hasEndMarker: !!r.endMarker,
children: Rr(n)?.children
@@ -15698,15 +15698,15 @@ function lh(e) {
return t.set(n, i), i;
};
}
-function wm(e, t, n) {
+function Im(e, t, n) {
const r = {
type: fr,
version: ur,
content: e
}, i = t.serializeEditorState(r, n);
- return zl(i.root.children[0]) ? i.root.children[0].children[0] : i.root.children[0];
+ return Vl(i.root.children[0]) ? i.root.children[0].children[0] : i.root.children[0];
}
-const tT = "v", nT = 1, PA = "verse-selected";
+const sT = "v", oT = 1, $A = "verse-selected";
class sn extends za {
__marker;
__number;
@@ -15716,10 +15716,10 @@ class sn extends za {
__pubnumber;
__unknownAttributes;
constructor(t = "", n = !1, r, i, s, o, a) {
- super(a), this.__marker = tT, this.__number = t, this.__showMarker = n, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
+ super(a), this.__marker = sT, this.__number = t, this.__showMarker = n, this.__sid = r, this.__altnumber = i, this.__pubnumber = s, this.__unknownAttributes = o;
}
static getType() {
- return dk;
+ return yk;
}
static clone(t) {
const { __number: n, __showMarker: r, __sid: i, __altnumber: s, __pubnumber: o, __unknownAttributes: a, __key: c } = t;
@@ -15727,14 +15727,14 @@ class sn extends za {
}
static importDOM() {
return {
- span: (t) => NA(t) ? {
- conversion: wA,
+ span: (t) => LA(t) ? {
+ conversion: IA,
priority: 1
} : null
};
}
static importJSON(t) {
- return uh().updateFromJSON(t);
+ return dh().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setMarker(t.marker).setNumber(t.number).setShowMarker(t.showMarker).setSid(t.sid).setAltnumber(t.altnumber).setPubnumber(t.pubnumber).setUnknownAttributes(t.unknownAttributes);
@@ -15802,23 +15802,23 @@ class sn extends za {
}
createDOM() {
const t = document.createElement("span");
- return t.setAttribute("data-marker", this.__marker), t.classList.add(qf, `usfm_${this.__marker}`), this.__showMarker && t.classList.add("marker"), t.setAttribute("data-number", this.__number), t;
+ return t.setAttribute("data-marker", this.__marker), t.classList.add(Bf, `usfm_${this.__marker}`), this.__showMarker && t.classList.add("marker"), t.setAttribute("data-number", this.__number), t;
}
updateDOM() {
return !1;
}
exportDOM(t) {
const { element: n } = super.exportDOM(t);
- return n && As(n) && (n.setAttribute("data-marker", this.getMarker()), n.classList.add(qf, `usfm_${this.getMarker()}`), n.setAttribute("data-number", this.getNumber())), { element: n };
+ return n && As(n) && (n.setAttribute("data-marker", this.getMarker()), n.classList.add(Bf, `usfm_${this.getMarker()}`), n.setAttribute("data-number", this.getNumber())), { element: n };
}
decorate() {
- return O(AA, { nodeKey: this.getKey(), text: this.getRenderedText() });
+ return O(RA, { nodeKey: this.getKey(), text: this.getRenderedText() });
}
/** The text this verse shows on screen: its whole `\v N` glyph, or only its number. */
getRenderedText() {
return this.getShowMarker() ? lr(this.getMarker(), this.getNumber()) : (
// ZWSP added so double click word selection works without including this number.
- mo + this.getNumber() + mo
+ yo + this.getNumber() + yo
);
}
exportJSON() {
@@ -15831,14 +15831,14 @@ class sn extends za {
altnumber: this.getAltnumber(),
pubnumber: this.getPubnumber(),
unknownAttributes: this.getUnknownAttributes(),
- version: nT
+ version: oT
};
}
isSelected(t) {
try {
return super.isSelected(t);
} catch (n) {
- if (Ex(n))
+ if (wx(n))
return !1;
throw n;
}
@@ -15848,51 +15848,51 @@ class sn extends za {
return !1;
}
}
-function AA({ nodeKey: e, text: t }) {
- const [n] = $0(e);
- return O("span", { className: n ? PA : void 0, children: t });
+function RA({ nodeKey: e, text: t }) {
+ const [n] = D0(e);
+ return O("span", { className: n ? $A : void 0, children: t });
}
-function wA(e) {
+function IA(e) {
const t = e.getAttribute("data-number") ?? "0";
- return { node: uh(t) };
+ return { node: dh(t) };
}
-function uh(e, t, n, r, i, s) {
+function dh(e, t, n, r, i, s) {
return St(new sn(e, t, n, r, i, s));
}
-function NA(e) {
- return (e?.getAttribute("data-marker") ?? void 0) === tT;
+function LA(e) {
+ return (e?.getAttribute("data-marker") ?? void 0) === sT;
}
function Er(e) {
return e instanceof sn;
}
-function OA(e) {
+function qA(e) {
return e?.type === sn.getType();
}
function Oe(e) {
return Le(e) || Er(e);
}
-function rT(e) {
- return _p(e) || OA(e);
+function aT(e) {
+ return Mp(e) || qA(e);
}
-function $A(e) {
- return RA(e).find((t) => ke(t));
+function DA(e) {
+ return KA(e).find((t) => ke(t));
}
-function RA(e) {
+function KA(e) {
return e.some(bs) ? e.flatMap((t) => bs(t) ? t.getChildren() : t) : e;
}
-function Zl(e) {
- return A(e) ? bs(e) ? e.getChildren().flatMap(Zl) : e.getChildren() : [];
+function tu(e) {
+ return A(e) ? bs(e) ? e.getChildren().flatMap(tu) : e.getChildren() : [];
}
-function IA(e, t) {
- return Zl(e).find((i) => Oe(i) && Hp(t, i.getNumber()));
+function BA(e, t) {
+ return tu(e).find((i) => Oe(i) && Jp(t, i.getNumber()));
}
-function LA(e, t) {
- return t === 0 ? $A(e) : e.map((n) => IA(n, t)).filter((n) => n)[0];
+function UA(e, t) {
+ return t === 0 ? DA(e) : e.map((n) => BA(n, t)).filter((n) => n)[0];
}
-function tl(e) {
- return Zl(e).find((n) => Oe(n));
+function rl(e) {
+ return tu(e).find((n) => Oe(n));
}
-function iT(e, t) {
+function cT(e, t) {
if (!A(e) || t <= 0)
return;
const n = e.getChildren();
@@ -15902,7 +15902,7 @@ function iT(e, t) {
return i;
}
}
-function qA(e) {
+function FA(e) {
const t = e.getParent();
if (t && A(t)) {
const r = t.getChildren();
@@ -15913,17 +15913,17 @@ function qA(e) {
}
}
let n = t?.getNextSibling();
- for (; n && !ot(n); ) {
- const r = tl(n);
+ for (; n && !Ye(n); ) {
+ const r = rl(n);
if (r)
return r;
n = n.getNextSibling();
}
}
-function nl(e) {
- return Zl(e).findLast((t) => Oe(t));
+function il(e) {
+ return tu(e).findLast((t) => Oe(t));
}
-function DA(e) {
+function zA(e) {
if (!Le(e))
return 0;
const t = e.getNumber();
@@ -15932,7 +15932,7 @@ function DA(e) {
const n = e.getTextContent().indexOf(t);
return n < 0 ? 0 : n + t.length;
}
-function KA(e, t, n) {
+function jA(e, t, n) {
if (!n)
return !1;
const r = t.getParent();
@@ -15942,51 +15942,51 @@ function KA(e, t, n) {
}
return n.getNextSibling() === t;
}
-function UA(e, t) {
+function VA(e, t) {
const n = t.anchor.getNode();
if (n !== e)
- return KA(t, e, n);
- if (T(e)) {
- const r = DA(e);
+ return jA(t, e, n);
+ if (C(e)) {
+ const r = zA(e);
return t.anchor.offset < r;
}
return !0;
}
-function ef(e) {
+function rf(e) {
const t = e.getNumber(), n = Number.parseInt(t ?? "0", 10);
return {
verseNum: n,
verse: t != null && n.toString() !== t ? t : void 0
};
}
-function FA(e) {
- const t = Yf(e);
- if (!(!t || ot(t)))
- return Oe(t) ? t : nl(t) ?? ph(t);
+function WA(e) {
+ const t = Zf(e);
+ if (!(!t || Ye(t)))
+ return Oe(t) ? t : il(t) ?? gh(t);
}
-function BA(e, t) {
+function HA(e, t) {
if (!e)
return { verseNum: 0 };
if (!E(t))
- return ef(e);
+ return rf(e);
const n = Number.parseInt(e.getNumber() ?? "0", 10), r = n <= 1 ? 0 : n - 1;
- if (UA(e, t)) {
- const i = FA(e);
- return i ? ef(i) : { verseNum: r };
+ if (VA(e, t)) {
+ const i = WA(e);
+ return i ? rf(i) : { verseNum: r };
}
- return ef(e);
+ return rf(e);
}
-function zA(e) {
- return dP(e) || Er(e);
+function GA(e) {
+ return yP(e) || Er(e);
}
-function fh(e) {
- if (T(e)) {
+function ph(e) {
+ if (C(e)) {
const t = e.getTextContent();
- !t.endsWith(" ") && !t.endsWith(U) && e.setTextContent(`${t} `);
+ !t.endsWith(" ") && !t.endsWith(B) && e.setTextContent(`${t} `);
}
}
-function sT(e) {
- if (!T(e))
+function lT(e) {
+ if (!C(e))
return;
const t = e.getTextContent();
if (!t.startsWith(" "))
@@ -15998,13 +15998,13 @@ function sT(e) {
for (const s of [i.anchor, i.focus])
s.type === "text" && s.key === e.getKey() && s.set(s.key, Math.max(0, s.offset - r), "text");
}
-function sd(e, t) {
+function cd(e, t) {
return e.getEditorState().read(() => !ee(t));
}
-function jA(e) {
+function JA(e) {
if (!e.isCollapsed())
return !1;
- const t = e.anchor.getNode(), n = dh(t, e);
+ const t = e.anchor.getNode(), n = hh(t, e);
let r;
if (n) {
const i = n.getParent();
@@ -16019,52 +16019,52 @@ function jA(e) {
}
}
if (!r && i) {
- let s = Nm(i);
- for (; s && !ot(s); ) {
- const o = tl(s);
+ let s = Lm(i);
+ for (; s && !Ye(s); ) {
+ const o = rl(s);
if (o) {
r = o;
break;
}
- s = Nm(s);
+ s = Lm(s);
}
}
} else {
let s = t.getTopLevelElement() ?? t;
for (; s; ) {
- const o = tl(s);
+ const o = rl(s);
if (o) {
r = o;
break;
}
- if (s = s.getNextSibling(), s && ot(s))
+ if (s = s.getNextSibling(), s && Ye(s))
break;
}
}
return r ? (r.selectNext(0, 0), !0) : !1;
}
-function VA(e) {
+function YA(e) {
if (!e.isCollapsed())
return !1;
- const t = e.anchor.getNode(), n = dh(t, e);
+ const t = e.anchor.getNode(), n = hh(t, e);
let r;
if (n) {
const i = n.getParent(), s = t.getTopLevelElement();
- if (i && s && s !== i.getTopLevelElement() && (r = n), !r && i && A(i) && (r = iT(i, n.getIndexWithinParent())), !r && i) {
- let o = Om(i);
- for (; o && !ot(o); ) {
- const a = nl(o);
+ if (i && s && s !== i.getTopLevelElement() && (r = n), !r && i && A(i) && (r = cT(i, n.getIndexWithinParent())), !r && i) {
+ let o = qm(i);
+ for (; o && !Ye(o); ) {
+ const a = il(o);
if (a) {
r = a;
break;
}
- o = Om(o);
+ o = qm(o);
}
}
} else {
let s = t.getTopLevelElement()?.getPreviousSibling() ?? null;
- for (; s && !ot(s); ) {
- const o = nl(s);
+ for (; s && !Ye(s); ) {
+ const o = il(s);
if (o) {
r = o;
break;
@@ -16074,69 +16074,69 @@ function VA(e) {
}
return r ? (r.selectNext(0, 0), !0) : !1;
}
-function Nm(e) {
+function Lm(e) {
const t = e.getNextSibling();
if (t)
return t;
const n = e.getTopLevelElement();
return n && n !== e ? n.getNextSibling() : null;
}
-function Om(e) {
+function qm(e) {
const t = e.getPreviousSibling();
if (t)
return t;
const n = e.getTopLevelElement();
return n && n !== e ? n.getPreviousSibling() : null;
}
-function dh(e, t) {
+function hh(e, t) {
if (A(e) && E(t) && t.anchor.key === e.getKey()) {
const r = e.getChildAtIndex(t.anchor.offset);
if (r && Oe(r))
return r;
- const i = iT(e, t.anchor.offset);
+ const i = cT(e, t.anchor.offset);
if (i)
return i;
- const s = tl(e);
+ const s = rl(e);
if (s)
return s;
}
- return ph(e);
+ return gh(e);
}
-function ph(e) {
- if (!e || ot(e))
+function gh(e) {
+ if (!e || Ye(e))
return;
if (Oe(e))
return e;
- let t = Yf(e);
+ let t = Zf(e);
for (; t; ) {
- if (ot(t))
+ if (Ye(t))
return;
if (Oe(t))
return t;
- const n = nl(t);
+ const n = il(t);
if (n)
return n;
- t = Yf(t);
+ t = Zf(t);
}
}
-const WA = ["style"], HA = ["style", "code"], rl = ["style", "cid"], GA = [
+const XA = ["style"], QA = ["style", "code"], sl = ["style", "cid"], ZA = [
"style",
"number",
"sid",
"altnumber",
"pubnumber"
-], JA = [
+], e1 = [
"style",
"number",
"sid",
"altnumber",
"pubnumber"
-], YA = [
+], t1 = [
"style",
"sid",
"eid",
"attributeOrder"
-], XA = ["style", "caller", "category", "contents"], QA = ["tag", "marker", "contents"], ZA = [
+], n1 = ["style", "caller", "category", "contents"], r1 = ["tag", "marker", "contents"], i1 = [
"chapter",
"immutable-chapter",
"verse",
@@ -16147,17 +16147,17 @@ const WA = ["style"], HA = ["style", "code"], rl = ["style", "cid"], GA = [
"unmatched"
], Pa = `
`;
-function e1(e, t) {
+function s1(e, t) {
const n = ee(e);
if (!jn(n))
return;
- const r = hh(n, "apply");
+ const r = mh(n, "apply");
if (r === void 0)
return;
const [i, ...s] = t;
return [{ retain: r }, ...i ? [i] : [], { delete: 1 }, ...s];
}
-function hh(e, t = "delta-doc") {
+function mh(e, t = "delta-doc") {
if (!e)
return;
const n = ja();
@@ -16167,13 +16167,13 @@ function hh(e, t = "delta-doc") {
for (const c of n) {
const l = c.node;
for (let f = i.length - 1; f >= 0; f--)
- if (To(i[f], c)) {
+ if (Co(i[f], c)) {
const d = i[f];
if (i.splice(f, 1), r += 1, a && d.getKey() === a.getKey())
return r - 1;
}
for (let f = s.length - 1; f >= 0; f--)
- To(s[f].node, c) && s.splice(f, 1);
+ Co(s[f].node, c) && s.splice(f, 1);
const u = s[s.length - 1];
if (u) {
if (l.getKey() === o)
@@ -16181,56 +16181,56 @@ function hh(e, t = "delta-doc") {
continue;
}
if (l.getKey() === o) {
- if (ni(l) || jn(l))
+ if (ri(l) || jn(l))
return r;
- ct(l) && (a = l);
+ st(l) && (a = l);
}
- if (ct(l) && (i.includes(l) || i.push(l)), oT(l, t)) {
+ if (st(l) && (i.includes(l) || i.push(l)), uT(l, t)) {
if (l.getKey() === o)
return r;
s.push({ node: l, position: r }), r += 1;
continue;
}
- r += eu(l, t);
+ r += nu(l, t);
}
if (a)
return r;
}
-function $m(e, t, n = "delta-doc") {
- if (e.length < 2 || !r1(e[0]) || !n1(e[1]))
+function Dm(e, t, n = "delta-doc") {
+ if (e.length < 2 || !c1(e[0]) || !a1(e[1]))
return;
const r = e[0].retain;
- return t.read(() => t1(r, n)?.getKey());
+ return t.read(() => o1(r, n)?.getKey());
}
-function t1(e, t = "delta-doc") {
+function o1(e, t = "delta-doc") {
const n = ja();
let r = 0;
const i = [], s = [];
for (const o of n) {
const a = o.node;
for (let u = i.length - 1; u >= 0; u--)
- if (To(i[u], o)) {
+ if (Co(i[u], o)) {
const f = i[u];
if (i.splice(u, 1), r === e)
return f;
r += 1;
}
for (let u = s.length - 1; u >= 0; u--)
- To(s[u].node, o) && s.splice(u, 1);
+ Co(s[u].node, o) && s.splice(u, 1);
const c = s[s.length - 1];
if (c) {
if (c.position === e)
return c.node;
continue;
}
- if (ct(a) && (i.includes(a) || i.push(a)), oT(a, t)) {
+ if (st(a) && (i.includes(a) || i.push(a)), uT(a, t)) {
if (r === e)
return a;
s.push({ node: a, position: r }), r += 1;
continue;
}
- const l = eu(a, t);
- if (ni(a) && l > 0 && e >= r && e < r + l || jn(a) && r === e)
+ const l = nu(a, t);
+ if (ri(a) && l > 0 && e >= r && e < r + l || jn(a) && r === e)
return a;
r += l;
}
@@ -16240,55 +16240,55 @@ function t1(e, t = "delta-doc") {
r += 1;
}
}
-function To(e, t) {
- return e ? t ? !ko(t.node, e.getKey()) : !0 : !1;
+function Co(e, t) {
+ return e ? t ? !xo(t.node, e.getKey()) : !0 : !1;
}
-function ni(e) {
- return T(e) && !jn(e);
+function ri(e) {
+ return C(e) && !jn(e);
}
function jn(e) {
- return ot(e) || Oe(e) || Ve(e) || K(e) || Ie(e) || bn(e);
+ return Ye(e) || Oe(e) || Ve(e) || K(e) || Ie(e) || bn(e);
}
-function gi(e, t) {
+function mi(e, t) {
return t?.insert != null && typeof t.insert == "object" && e in t.insert;
}
-function n1(e) {
+function a1(e) {
if (e.insert == null || typeof e.insert != "object")
return !1;
const t = Object.keys(e.insert)[0];
- return e.insert != null && typeof e.insert == "object" && t in e.insert && ZA.includes(t);
+ return e.insert != null && typeof e.insert == "object" && t in e.insert && i1.includes(t);
}
-function r1(e) {
+function c1(e) {
return e.retain != null && typeof e.retain == "number";
}
-function oT(e, t) {
+function uT(e, t) {
return K(e) || Ie(e) ? !0 : t === "apply" && A(e) && jn(e);
}
-function aT(e) {
+function fT(e) {
const t = e.getParent();
return Zt(e) && ke(t) && t.getFirstChild() === e;
}
-function od(e) {
+function ld(e) {
const t = e.getParent();
return t !== null && We(t, He) !== null;
}
-function i1(e) {
+function l1(e) {
const t = e.getParent();
return z(t) && e.getTextContent() === It && t.getChildrenSize() === 1;
}
-function gh(e) {
+function yh(e) {
const t = Xn(e);
if (!(!K(t) || !Dt(t)?.is(e)))
- return Sp(e.getTextContent(), t.getCaller());
+ return Ep(e.getTextContent(), t.getCaller());
}
-function Rm(e) {
- return !lx(e) && // A caller's typed bytes are respelled as the content they settle into, never sent raw.
- gh(e) === void 0 && eu(e, "delta-doc") === e.getTextContentSize();
+function Km(e) {
+ return !hx(e) && // A caller's typed bytes are respelled as the content they settle into, never sent raw.
+ yh(e) === void 0 && nu(e, "delta-doc") === e.getTextContentSize();
}
-function eu(e, t) {
+function nu(e, t) {
if (jn(e))
return 1;
- if (T(e)) {
+ if (C(e)) {
const n = e.getTextContent();
if (t === "delta-doc" && // A bare caret host (transientCaretHost.utils.ts) is a transient, collab-invisible node:
// its insertion is never emitted, so it contributes nothing to DOC-DELTA positions or the
@@ -16298,28 +16298,28 @@ function eu(e, t) {
// and adds raw `getTextContentSize()`), so excluding it here left a replace-embed retain
// one short whenever a host rested before the target — a footnote-popover save then
// deleted the unit BEFORE the note instead of the note itself.
- (Et(e) || aT(e) || Te(e, _e) === "marker-trailing-space" || // An attribute value keyed by its own state, not by ancestry: a CHAR span's run is a direct
+ (Et(e) || fT(e) || Te(e, _e) === "marker-trailing-space" || // An attribute value keyed by its own state, not by ancestry: a CHAR span's run is a direct
// TextNode child of the span, never wrapped (`displayRunRegistry.ts`'s char descriptor
// writes "owner-children"), so `$hasAttributeRunAncestor` cannot see it. That shape is at
// rest on every `\w …|strong="…"\w*`, and the ops stream already omits those bytes
// (`isNodeAttributeText` in editor-delta.adaptor.ts), so counting them here would put this
// side out of step with the op stream on ordinary Scripture.
- Te(e, _e) === "attribute" || od(e) || // The remaining ops-stream exclusions, so this side and $handleTextNodes count the same
+ Te(e, _e) === "attribute" || ld(e) || // The remaining ops-stream exclusions, so this side and $handleTextNodes count the same
// bytes (docs/standard-view-invariants.md §II — extend the shared list, never fork it):
// the legacy NBSP-`|` byte-prefixed attribute text the ops stream still honors for
// pre-state-tag peers and persisted deltas, and the empty-char placeholder. The
// editable-mode note caller counts only its content bytes, below.
- n.startsWith(yp) || i1(e)))
+ n.startsWith(kp) || l1(e)))
return 0;
- const r = t === "delta-doc" ? gh(e) : void 0;
+ const r = t === "delta-doc" ? yh(e) : void 0;
return r !== void 0 ? r.length : e.getTextContentSize();
}
return 0;
}
-function ad(e, t) {
- const n = { insert: e.__text }, r = Te(e, Mi);
+function ud(e, t) {
+ const n = { insert: e.__text }, r = Te(e, Pi);
if (r && (n.attributes = { segment: r }), t && t.length > 0) {
- const i = cT(t);
+ const i = dT(t);
i && (n.attributes = {
...n.attributes,
char: i
@@ -16327,69 +16327,69 @@ function ad(e, t) {
}
return n;
}
-function Im(e) {
- const t = new Qi();
+function Bm(e) {
+ const t = new Zi();
return e.isEmpty() || e.read(() => {
const n = Me();
if (!n || n.isEmpty())
return;
const r = n.getChildren();
- if (r.length === 1 && kt(r[0]) && (!r[0].getChildren() || r[0].getChildrenSize() === 0))
+ if (r.length === 1 && ht(r[0]) && (!r[0].getChildren() || r[0].getChildrenSize() === 0))
return;
- const i = s1();
+ const i = u1();
for (const s of i)
t.push(s);
}), t;
}
-function tu(e, t) {
+function ru(e, t) {
const n = [], r = $s(e, t), i = [], s = [], o = [], a = /* @__PURE__ */ new Set();
for (let c = 0; c < r.length; c++) {
const l = r[c].node;
- n.push(...Lm(l, c, r, i, s, o, a));
+ n.push(...Um(l, c, r, i, s, o, a));
}
for (const c of i)
- n.push(...Lm(c, r.length, r, i, s, o, a));
+ n.push(...Um(c, r.length, r, i, s, o, a));
return n;
}
-function s1() {
- return tu();
+function u1() {
+ return ru();
}
-function Lm(e, t, n, r, i, s, o) {
+function Um(e, t, n, r, i, s, o) {
if (!e)
return [];
const a = [], c = n[t + 1];
- return o1(e, a, r), a1(e, a, i, s, o), c1(e, t, n, i, o, s, a), ot(e) && a.push(d1(e)), Oe(e) && a.push(h1(e)), Ve(e) && a.push(g1(e)), bn(e) && a.push(m1(e)), u1(e, a, s), l1(e, a, s), x1(c, s), a;
+ return f1(e, a, r), d1(e, a, i, s, o), p1(e, t, n, i, o, s, a), Ye(e) && a.push(y1(e)), Oe(e) && a.push(k1(e)), Ve(e) && a.push(x1(e)), bn(e) && a.push(T1(e)), g1(e, a, s), h1(e, a, s), _1(c, s), a;
}
-function o1(e, t, n) {
+function f1(e, t, n) {
if (!e.isInline()) {
const r = n.pop();
- qe(r) ? t.push(f1(r)) : ke(r) ? t.push(p1(r)) : kt(r) && t.push({ insert: Pa });
+ qe(r) ? t.push(m1(r)) : ke(r) ? t.push(b1(r)) : ht(r) && t.push({ insert: Pa });
}
- ct(e) && (n.includes(e) || n.push(e));
+ st(e) && (n.includes(e) || n.push(e));
}
-function a1(e, t, n, r, i) {
- if (!T(e) || Le(e) || bn(e))
+function d1(e, t, n, r, i) {
+ if (!C(e) || Le(e) || bn(e))
return;
const s = e.getParent();
if (K(s) && s.getFirstChild() === e)
return;
const o = hn(e) !== void 0;
- if ($(e) && (o || aT(e) || od(e) || lx(e)) || Te(e, _e) === "marker-trailing-space")
+ if ($(e) && (o || fT(e) || ld(e) || hx(e)) || Te(e, _e) === "marker-trailing-space")
return;
let a = e.getTextContent();
if (Et(e))
return;
- const c = gh(e);
+ const c = yh(e);
if (c !== void 0) {
if (!c)
return;
a = c;
}
const l = e.getPreviousSibling(), u = z(s) ? s : void 0;
- o && u && l === u.getFirstChild() && (a = a.slice($p(e)));
- const f = a.startsWith(yp) || Te(e, _e) === "attribute" || od(e), d = !!u && a === It && u.getChildrenSize() === 1, p = nu(e, r), m = p ? n.filter((y) => p.children.includes(y)) : n, h = ad(e, m);
+ o && u && l === u.getFirstChild() && (a = a.slice(Ip(e)));
+ const f = a.startsWith(kp) || Te(e, _e) === "attribute" || ld(e), d = !!u && a === It && u.getChildrenSize() === 1, p = iu(e, r), m = p ? n.filter((y) => p.children.includes(y)) : n, h = ud(e, m);
if (h.insert = a, p) {
- if (!a || a === U || f)
+ if (!a || a === B || f)
return;
p.contentsOps?.push(h);
} else
@@ -16399,104 +16399,104 @@ function a1(e, t, n, r, i) {
for (const y of n)
i.add(y);
}
-function c1(e, t, n, r, i, s, o) {
+function p1(e, t, n, r, i, s, o) {
z(e) && !r.includes(e) && r.push(e);
const a = n[t + 1];
for (const c of r.toReversed())
- if (To(c, a)) {
+ if (Co(c, a)) {
if (r.pop(), !i.has(c)) {
- const l = b1(c), u = nu(c, s);
+ const l = v1(c), u = iu(c, s);
u ? u.contentsOps?.push(l) : o.push(l);
}
i.delete(c);
}
}
-function l1(e, t, n) {
+function h1(e, t, n) {
if (!K(e))
return;
- const r = y1(e), i = nu(e, n), s = {
+ const r = C1(e), i = iu(e, n), s = {
node: e,
children: $s(e).map((o) => o.node),
contentsOps: r.insert.note?.contents?.ops
};
n.push(s), i?.contentsOps ? i.contentsOps.push(r) : t.push(r);
}
-function u1(e, t, n) {
+function g1(e, t, n) {
if (!Ie(e))
return;
- const r = k1(e), i = nu(e, n), s = {
+ const r = S1(e), i = iu(e, n), s = {
node: e,
children: $s(e).map((o) => o.node),
contentsOps: r.insert.unknown?.contents?.ops
};
n.push(s), i?.contentsOps ? i.contentsOps.push(r) : t.push(r);
}
-function Li(e, t) {
+function qi(e, t) {
const n = t.getUnknownAttributes();
n && Object.assign(e, n);
}
-function f1(e) {
+function m1(e) {
const t = { style: va, code: e.__code };
- return Li(t, e), { insert: Pa, attributes: { book: t } };
+ return qi(t, e), { insert: Pa, attributes: { book: t } };
}
-function d1(e) {
- const t = { style: Wc, number: e.__number };
- return e.__sid && (t.sid = e.__sid), e.__altnumber && (t.altnumber = e.__altnumber), e.__pubnumber && (t.pubnumber = e.__pubnumber), Li(t, e), { insert: { chapter: t } };
+function y1(e) {
+ const t = { style: Hc, number: e.__number };
+ return e.__sid && (t.sid = e.__sid), e.__altnumber && (t.altnumber = e.__altnumber), e.__pubnumber && (t.pubnumber = e.__pubnumber), qi(t, e), { insert: { chapter: t } };
}
-function p1(e) {
+function b1(e) {
const t = { style: e.__marker };
- return Li(t, e), { insert: Pa, attributes: { para: t } };
+ return qi(t, e), { insert: Pa, attributes: { para: t } };
}
-function h1(e) {
- const t = { style: Vc, number: e.__number };
- return e.__sid && (t.sid = e.__sid), e.__altnumber && (t.altnumber = e.__altnumber), e.__pubnumber && (t.pubnumber = e.__pubnumber), Li(t, e), { insert: { verse: t } };
+function k1(e) {
+ const t = { style: Wc, number: e.__number };
+ return e.__sid && (t.sid = e.__sid), e.__altnumber && (t.altnumber = e.__altnumber), e.__pubnumber && (t.pubnumber = e.__pubnumber), qi(t, e), { insert: { verse: t } };
}
-function g1(e) {
+function x1(e) {
const t = { style: e.__marker };
- return e.__sid && (t.sid = e.__sid), e.__eid && (t.eid = e.__eid), e.__attributeOrder && (t.attributeOrder = e.__attributeOrder), Li(t, e), { insert: { milestone: t } };
+ return e.__sid && (t.sid = e.__sid), e.__eid && (t.eid = e.__eid), e.__attributeOrder && (t.attributeOrder = e.__attributeOrder), qi(t, e), { insert: { milestone: t } };
}
-function m1(e) {
+function T1(e) {
return { insert: { unmatched: { marker: e.__marker } } };
}
-function y1(e) {
+function C1(e) {
const t = {
style: e.__marker,
caller: e.__caller
};
- e.__category && (t.category = e.__category), Li(t, e), e.getChildrenSize() > 1 && (t.contents = { ops: [] });
- const n = { insert: { note: t } }, r = Te(e, Mi);
+ e.__category && (t.category = e.__category), qi(t, e), e.getChildrenSize() > 1 && (t.contents = { ops: [] });
+ const n = { insert: { note: t } }, r = Te(e, Pi);
return r && (n.attributes = { segment: r }), n;
}
-function b1(e) {
- const t = { insert: "" }, n = cT([e]);
+function v1(e) {
+ const t = { insert: "" }, n = dT([e]);
return n && (t.attributes = { char: n }), t;
}
-function k1(e) {
+function S1(e) {
const t = { tag: e.getTag() }, n = e.getMarker();
- return n && (t.marker = n), Li(t, e), e.getChildrenSize() > 0 && (t.contents = { ops: [] }), { insert: { unknown: t } };
+ return n && (t.marker = n), qi(t, e), e.getChildrenSize() > 0 && (t.contents = { ops: [] }), { insert: { unknown: t } };
}
-function nu(e, t) {
+function iu(e, t) {
for (let n = t.length - 1; n >= 0; n--) {
const r = t[n];
if (r.children.includes(e))
return r;
}
}
-function x1(e, t) {
+function _1(e, t) {
for (let n = t.length - 1; n >= 0; n--)
- To(t[n].node, e) && t.splice(n, 1);
+ Co(t[n].node, e) && t.splice(n, 1);
}
-function cT(e) {
+function dT(e) {
if (e.length === 0)
return;
- const t = e.map(T1);
+ const t = e.map(E1);
return t.length === 1 ? t[0] : t;
}
-function T1(e) {
- const t = { style: e.__marker }, n = Te(e, ds);
- return n && (t.cid = n), Li(t, e), t;
+function E1(e) {
+ const t = { style: e.__marker }, n = Te(e, ps);
+ return n && (t.cid = n), qi(t, e), t;
}
-function mh(e) {
+function bh(e) {
let t = 0;
for (const { node: n } of ja())
if (K(n)) {
@@ -16505,7 +16505,7 @@ function mh(e) {
t += 1;
}
}
-function C1(e) {
+function M1(e) {
let t = 0;
for (const { node: n } of ja())
if (K(n)) {
@@ -16514,7 +16514,7 @@ function C1(e) {
t += 1;
}
}
-const lT = 1;
+const pT = 1;
class Dn extends za {
__caller;
__previewText;
@@ -16524,7 +16524,7 @@ class Dn extends za {
});
}
static getType() {
- return Ii;
+ return Li;
}
static clone(t) {
const { __caller: n, __previewText: r, __onClick: i, __key: s } = t;
@@ -16532,14 +16532,14 @@ class Dn extends za {
}
static importDOM() {
return {
- span: (t) => S1(t) ? {
- conversion: v1,
+ span: (t) => A1(t) ? {
+ conversion: P1,
priority: 1
} : null
};
}
static importJSON(t) {
- return yh().updateFromJSON(t);
+ return kh().updateFromJSON(t);
}
updateFromJSON(t) {
return super.updateFromJSON(t).setCaller(t.caller).setPreviewText(t.previewText).setOnClick(t.onClick);
@@ -16586,13 +16586,13 @@ class Dn extends za {
const n = this.getParent();
if (!n)
return null;
- const r = n.getKey(), i = n.getIsCollapsed(), s = this.__key, o = (c) => this.__onClick?.(c, r, i, () => _1(t, r), (l) => E1(t, r, s, l), () => M1(t, r), () => P1(t, r)), a = `${this.__caller}_${this.__previewText}}`.replace(/\s+/g, "").substring(0, 25);
+ const r = n.getKey(), i = n.getIsCollapsed(), s = this.__key, o = (c) => this.__onClick?.(c, r, i, () => w1(t, r), (l) => N1(t, r, s, l), () => O1(t, r), () => $1(t, r)), a = `${this.__caller}_${this.__previewText}}`.replace(/\s+/g, "").substring(0, 25);
return O("button", { onClick: o, title: this.__previewText, "data-caller-id": a, children: this.getRenderedText() });
}
/** The text this caller shows on screen; empty when CSS generates the caller instead. */
getRenderedText() {
const t = this.getLatest(), n = t.getParent(), r = K(n) && n.getIsCollapsed();
- return t.__caller === ya && r ? "" : t.__caller === fk && r ? "*" : t.__caller;
+ return t.__caller === ya && r ? "" : t.__caller === mk && r ? "*" : t.__caller;
}
exportJSON() {
return {
@@ -16600,7 +16600,7 @@ class Dn extends za {
caller: this.getCaller(),
previewText: this.getPreviewText(),
onClick: this.getOnClick(),
- version: lT
+ version: pT
};
}
// Mutation
@@ -16608,20 +16608,20 @@ class Dn extends za {
return !1;
}
}
-function v1(e) {
+function P1(e) {
const t = e.getAttribute("data-caller") ?? "", n = e.getAttribute("data-preview-text") ?? "";
- return { node: yh(t, n) };
+ return { node: kh(t, n) };
}
-function yh(e, t, n) {
+function kh(e, t, n) {
return St(new Dn(e, t, n));
}
-function S1(e) {
+function A1(e) {
return e ? e.classList.contains(Dn.getType()) : !1;
}
-function Ut(e) {
+function Bt(e) {
return e instanceof Dn;
}
-function _1(e, t) {
+function w1(e, t) {
return e.getEditorState().read(() => {
const n = ee(t);
if (!K(n))
@@ -16629,30 +16629,30 @@ function _1(e, t) {
return n.getCaller();
});
}
-function E1(e, t, n, r) {
+function N1(e, t, n, r) {
e.update(() => {
const i = ee(t);
if (!K(i))
throw new Error(`setNoteCaller: Note node not found: ${t}`);
i.setCaller(r);
const s = ee(n);
- if (!Ut(s))
+ if (!Bt(s))
throw new Error(`setNoteCaller: Caller node not found: ${n}`);
s.setCaller(r);
});
}
-function M1(e, t) {
+function O1(e, t) {
return e.getEditorState().read(() => {
const n = ee(t);
if (!K(n))
throw new Error(`getNoteOps: Note node not found: ${t}`);
- return tu(n);
+ return ru(n);
});
}
-function P1(e, t) {
- return e.getEditorState().read(() => mh(t));
+function $1(e, t) {
+ return e.getEditorState().read(() => bh(t));
}
-const A1 = [
+const R1 = [
"a",
"b",
"c",
@@ -16679,29 +16679,29 @@ const A1 = [
"x",
"y",
"z"
-], w1 = ["†"], bh = "formatted", uT = "unformatted", fT = "paragraph-structure", kh = "standard", dT = "block-verse", N1 = {
- [bh]: "Formatted",
- [uT]: "Unformatted",
- [fT]: "Paragraph Structure",
- [kh]: "Standard",
- [dT]: "Block Verse"
+], I1 = ["†"], xh = "formatted", hT = "unformatted", gT = "paragraph-structure", Th = "standard", mT = "block-verse", L1 = {
+ [xh]: "Formatted",
+ [hT]: "Unformatted",
+ [gT]: "Paragraph Structure",
+ [Th]: "Standard",
+ [mT]: "Block Verse"
};
-function qi(e) {
+function Di(e) {
return e?.showParaMarkerPrefixes !== !1;
}
-let xh, Th;
-function O1(e) {
- const t = Ch(e);
+let Ch, vh;
+function q1(e) {
+ const t = Sh(e);
if (!t)
throw new Error(`Invalid view mode: ${e}`);
- xh = e, Th = t;
+ Ch = e, vh = t;
}
-O1(bh);
-const WF = () => xh, Co = () => Th;
-function Ch(e) {
+q1(xh);
+const eF = () => Ch, vo = () => vh;
+function Sh(e) {
let t;
- switch (e ?? xh) {
- case bh:
+ switch (e ?? Ch) {
+ case xh:
t = {
markerMode: "hidden",
noteMode: "collapsed",
@@ -16709,7 +16709,7 @@ function Ch(e) {
isFormattedFont: !0
};
break;
- case uT:
+ case hT:
t = {
markerMode: "editable",
noteMode: "expanded",
@@ -16717,7 +16717,7 @@ function Ch(e) {
isFormattedFont: !1
};
break;
- case fT:
+ case gT:
t = {
markerMode: "hidden",
noteMode: "collapsed",
@@ -16727,7 +16727,7 @@ function Ch(e) {
hasActiveTextFocusBox: !0
};
break;
- case kh:
+ case Th:
t = {
markerMode: "editable",
noteMode: "collapsed",
@@ -16735,7 +16735,7 @@ function Ch(e) {
isFormattedFont: !0
};
break;
- case dT:
+ case mT:
t = {
markerMode: "hidden",
noteMode: "collapsed",
@@ -16747,62 +16747,62 @@ function Ch(e) {
}
return t;
}
-function HF(e) {
+function tF(e) {
if (!e)
return;
- const t = qm(e);
- return Object.keys(N1).find((n) => Tn(qm(Ch(n)), t));
+ const t = Fm(e);
+ return Object.keys(L1).find((n) => Tn(Fm(Sh(n)), t));
}
-const $1 = {
+const D1 = {
showCharMarkerTitles: !0,
hasGutterParaMarkers: !1,
hasActiveTextFocusBox: !1,
verseLayout: "inline"
};
-function qm(e) {
+function Fm(e) {
if (!e)
return e;
const t = Object.fromEntries(Object.entries(e).filter(([, n]) => n !== void 0));
- return { ...$1, ...t };
+ return { ...D1, ...t };
}
-function gt(e) {
+function mt(e) {
if (!e)
return !1;
const { markerMode: t, hasSpacing: n, isFormattedFont: r, hasGutterParaMarkers: i, hasActiveTextFocusBox: s } = e;
return t === "editable" && n && r && !i && !s;
}
-function R1(e) {
+function K1(e) {
if (e)
return Aa(e) ? sn : e.markerMode === "editable" ? Lt : sn;
}
function Aa(e) {
return e?.verseLayout === "block";
}
-function I1(e) {
- const t = [], n = e ?? Th;
- return n && (t.push(`${oE}${n.markerMode}`), n.hasSpacing && t.push(iE), n.isFormattedFont && t.push(sE)), t;
+function B1(e) {
+ const t = [], n = e ?? vh;
+ return n && (t.push(`${fE}${n.markerMode}`), n.hasSpacing && t.push(lE), n.isFormattedFont && t.push(uE)), t;
}
-const L1 = /^(\$(?:\.content\[\d+\])*)(?:\.|$|\[)/;
-function il(e) {
- return L1.exec(e)?.[1] ?? e;
+const U1 = /^(\$(?:\.content\[\d+\])*)(?:\.|$|\[)/;
+function ol(e) {
+ return U1.exec(e)?.[1] ?? e;
}
-function sa(e, t) {
- const n = e.jsonPath.slice(il(e.jsonPath).length);
+function oa(e, t) {
+ const n = e.jsonPath.slice(ol(e.jsonPath).length);
return { ...e, jsonPath: `${Ht(t)}${n}` };
}
-function pT(e) {
+function yT(e) {
const t = [];
let n = 0;
for (const c of Me().getChildren())
- if (!Bn(c))
+ if (!Fn(c))
if (bs(c)) {
const l = n;
- c.getChildren().filter((u) => !Bn(u)).forEach((u, f) => t.push({ node: u, blockPrefix: [l, f], blockBase: 0 })), n += 1;
- } else kt(c) ? (t.push({ node: c, blockPrefix: [], blockBase: n }), n += Xt(c, e).length) : (t.push({ node: c, blockPrefix: [n], blockBase: 0 }), n += 1);
+ c.getChildren().filter((u) => !Fn(u)).forEach((u, f) => t.push({ node: u, blockPrefix: [l, f], blockBase: 0 })), n += 1;
+ } else ht(c) ? (t.push({ node: c, blockPrefix: [], blockBase: n }), n += Xt(c, e).length) : (t.push({ node: c, blockPrefix: [n], blockBase: 0 }), n += 1);
const r = [];
let i = 0, s = 0, o = 0, a;
for (const c of t) {
- const l = A(c.node) ? Xt(c.node, e).length : 0, u = Te(c.node, Zx), f = kt(c.node), d = u === void 0 || u !== a;
+ const l = A(c.node) ? Xt(c.node, e).length : 0, u = Te(c.node, rT), f = ht(c.node), d = u === void 0 || u !== a;
d && (r.length > 0 && (r[r.length - 1].isSourceEnd = !0), s = i, o = 0, f || (i += 1)), r.push({
...c,
count: l,
@@ -16814,31 +16814,31 @@ function pT(e) {
}
return r.length > 0 && (r[r.length - 1].isSourceEnd = !0), r;
}
-function hT(e, t) {
+function bT(e, t) {
return e.length >= t.length && t.every((n, r) => e[r] === n);
}
-function gT(e, t, n, r = !0) {
- const i = e.jsonPath.slice(il(e.jsonPath).length);
- let s = Gn(il(e.jsonPath));
+function kT(e, t, n, r = !0) {
+ const i = e.jsonPath.slice(ol(e.jsonPath).length);
+ let s = Gn(ol(e.jsonPath));
s.length === 1 && t.some((o) => o.blockPrefix.length === 2 && o.blockPrefix[0] === s[0]) && (s = [s[0], 0]);
for (const o of t) {
- if (!hT(s, o.blockPrefix))
+ if (!bT(s, o.blockPrefix))
continue;
const a = s.slice(o.blockPrefix.length);
if (a.length === 0) {
if (o.blockPrefix.length === 0)
continue;
- return r && i === "" && A(o.node) && (!o.isSourceStart || kt(o.node)) ? gT(n(o.node), t, n, !1) : sa(e, o.usjPrefix);
+ return r && i === "" && A(o.node) && (!o.isSourceStart || ht(o.node)) ? kT(n(o.node), t, n, !1) : oa(e, o.usjPrefix);
}
if (!(a[0] < o.blockBase || a[0] >= o.blockBase + o.count))
- return sa(e, [
+ return oa(e, [
...o.usjPrefix,
a[0] - o.blockBase + o.usjBase,
...a.slice(1)
]);
}
}
-function q1(e, t, n) {
+function F1(e, t, n) {
for (const r of t) {
if (r.usjPrefix.length === 0) {
if (e < r.usjBase || e >= r.usjBase + r.count)
@@ -16853,32 +16853,32 @@ function q1(e, t, n) {
}
return { jsonPath: "$", offset: Xt(Me(), n).length };
}
-function Dm(e, t, n) {
- const r = Gn(il(e.jsonPath));
+function zm(e, t, n) {
+ const r = Gn(ol(e.jsonPath));
if (r.length === 0)
- return Jr(e) ? q1(e.offset, t, n) : e;
+ return Yr(e) ? F1(e.offset, t, n) : e;
for (const i of t) {
- if (!hT(r, i.usjPrefix))
+ if (!bT(r, i.usjPrefix))
continue;
const s = r.slice(i.usjPrefix.length);
if (s.length === 0) {
if (i.usjPrefix.length === 0)
continue;
- if (Jr(e)) {
+ if (Yr(e)) {
const o = e.offset - i.usjBase;
if (o < 0 || !i.isSourceEnd && o >= i.count)
continue;
return {
- ...sa(e, i.blockPrefix),
+ ...oa(e, i.blockPrefix),
offset: Math.min(o, i.count) + i.blockBase
};
}
if (!i.isSourceStart)
continue;
- return sa(e, i.blockPrefix);
+ return oa(e, i.blockPrefix);
}
if (!(s[0] < i.usjBase || s[0] >= i.usjBase + i.count))
- return sa(e, [
+ return oa(e, [
...i.blockPrefix,
s[0] - i.usjBase + i.blockBase,
...s.slice(1)
@@ -16887,54 +16887,54 @@ function Dm(e, t, n) {
}
function wa(e, t, n) {
let { start: r } = e, i = e.end ?? r;
- if (wT()) {
- const h = gt(t), g = pT(h), y = Dm(r, g, h), b = i === r ? y : Dm(i, g, h);
+ if (RT()) {
+ const h = mt(t), g = yT(h), y = zm(r, g, h), b = i === r ? y : zm(i, g, h);
if (!y || !b)
return;
r = y, i = b;
}
- const s = !!n?.forAnnotation, o = Fm(r, t, s), a = i === r ? o : Fm(i, t, s), [c, l] = o.point, [u, f] = a.point;
+ const s = !!n?.forAnnotation, o = Wm(r, t, s), a = i === r ? o : Wm(i, t, s), [c, l] = o.point, [u, f] = a.point;
if (!c || !u || l === void 0 || f === void 0)
return;
- let d = Bm(c, l), p = Bm(u, f);
- if (as(i) && i.closingMarkerOffset === 0 && !Tn(i, r) && (p = tw(p[0], p[1], gt(t))), n?.forAnnotation && i !== r) {
+ let d = Hm(c, l), p = Hm(u, f);
+ if (cs(i) && i.closingMarkerOffset === 0 && !Tn(i, r) && (p = ow(p[0], p[1], mt(t))), n?.forAnnotation && i !== r) {
const h = { edge: d, inside: o.insideDecorator }, g = { edge: p, inside: a.insideDecorator };
- [d, p] = D1(h, g), n.decoratorHolds && K1(h, g, n.decoratorHolds);
+ [d, p] = z1(h, g), n.decoratorHolds && j1(h, g, n.decoratorHolds);
}
const m = dr();
- return m.anchor = fn(d[0].getKey(), d[1], dd(d[0])), m.focus = fn(p[0].getKey(), p[1], dd(p[0])), m;
+ return m.anchor = fn(d[0].getKey(), d[1], gd(d[0])), m.focus = fn(p[0].getKey(), p[1], gd(p[0])), m;
}
-function D1(e, t) {
+function z1(e, t) {
const { inside: n } = e, { inside: r } = t;
if (!n && !r)
return [e.edge, t.edge];
- const { sameDecorator: i, reversed: s } = mT(e, t), [o, a] = s ? [t, e] : [e, t], c = o.inside ? cd(o.inside, o.inside.before >= o.inside.total, o.edge) : o.edge;
+ const { sameDecorator: i, reversed: s } = xT(e, t), [o, a] = s ? [t, e] : [e, t], c = o.inside ? fd(o.inside, o.inside.before >= o.inside.total, o.edge) : o.edge;
if (i && n?.before === r?.before)
return [c, c];
- const l = a.inside ? cd(a.inside, a.inside.before > 0, a.edge) : a.edge;
+ const l = a.inside ? fd(a.inside, a.inside.before > 0, a.edge) : a.edge;
return s ? [l, c] : [c, l];
}
-function K1(e, t, n) {
+function j1(e, t, n) {
const { inside: r } = e, { inside: i } = t;
if (!r && !i)
return;
- const { sameDecorator: s, reversed: o } = mT(e, t), [a, c] = o ? [i, r] : [r, i], l = (u, f, d) => {
+ const { sameDecorator: s, reversed: o } = xT(e, t), [a, c] = o ? [i, r] : [r, i], l = (u, f, d) => {
d > f && n.set(u.decorator.getKey(), { start: f, end: d });
};
a && l(a, a.before, s && c ? c.before : a.total), c && !s && l(c, 0, c.before);
}
-function mT(e, t) {
+function xT(e, t) {
const { inside: n } = e, { inside: r } = t;
- return n && r && n.decorator.is(r.decorator) ? { sameDecorator: !0, reversed: r.before < n.before } : { sameDecorator: !1, reversed: U1(t, e) };
+ return n && r && n.decorator.is(r.decorator) ? { sameDecorator: !0, reversed: r.before < n.before } : { sameDecorator: !1, reversed: V1(t, e) };
}
-function cd(e, t, n) {
- const [r, i] = Hr(e.decorator, t);
+function fd(e, t, n) {
+ const [r, i] = Gr(e.decorator, t);
return r && i !== void 0 ? [r, i] : n;
}
-function U1(e, t) {
+function V1(e, t) {
const n = ({ edge: s, inside: o }) => {
- const [a, c] = o ? cd(o, !1, s) : s;
- return fn(a.getKey(), c, dd(a));
+ const [a, c] = o ? fd(o, !1, s) : s;
+ return fn(a.getKey(), c, gd(a));
}, r = n(e), i = n(t);
return r.isBefore(i) ? !0 : i.isBefore(r) ? !1 : !e.inside && !!t.inside;
}
@@ -16942,9 +16942,9 @@ function Qa(e) {
const t = M();
if (!t || !E(t))
return;
- const n = wT() ? pT(gt(e)) : void 0, r = (u, f) => {
+ const n = RT() ? yT(mt(e)) : void 0, r = (u, f) => {
const d = Gt(u, f, e);
- return n ? gT(d, n, (p) => Gt(p, 0, e)) : d;
+ return n ? kT(d, n, (p) => Gt(p, 0, e)) : d;
}, i = t.isBackward() ? t.focus.getNode() : t.anchor.getNode(), s = t.isBackward() ? t.focus.offset : t.anchor.offset, o = r(i, s);
if (!o)
return;
@@ -16954,7 +16954,7 @@ function Qa(e) {
if (l)
return { start: o, end: l };
}
-const bi = {
+const ki = {
va: { markerName: "va", keyName: "altnumber" },
vp: { markerName: "vp", keyName: "pubnumber" },
ca: { markerName: "ca", keyName: "altnumber" },
@@ -16966,7 +16966,7 @@ const bi = {
separator: void 0,
nestedGlyph: void 0,
opaqueUnknown: void 0
-}, F1 = new Map(Object.values(bi).flatMap((e) => e ? [[e.markerName, e.keyName]] : [])), Km = {
+}, W1 = new Map(Object.values(ki).flatMap((e) => e ? [[e.markerName, e.keyName]] : [])), jm = {
va: !0,
vp: !0,
ca: !0,
@@ -16980,20 +16980,20 @@ const bi = {
separator: !1,
nestedGlyph: !1,
opaqueUnknown: !1
-}, B1 = (
+}, H1 = (
// `Object.keys` widens to `string[]`; the mapped type above is what guarantees every key is one.
- Object.keys(Km).filter((e) => Km[e])
-), z1 = /([^\s="|]+)="([^"]*)"/g, j1 = /^[ \u00A0]*\\([^\s\\*]+)[ \u00A0]/;
-function yT(e, t) {
+ Object.keys(jm).filter((e) => jm[e])
+), G1 = /([^\s="|]+)="([^"]*)"/g, J1 = /^[ \u00A0]*\\([^\s\\*]+)[ \u00A0]/;
+function TT(e, t) {
return `${e}['${t}']`;
}
-function ss(e) {
+function os(e) {
return [
{ start: 0, base: 0, bytes: { kind: "marker" } },
{ start: e, base: 0, bytes: { kind: "property", property: "marker" } }
];
}
-function oa(e) {
+function aa(e) {
return [
{
start: 0,
@@ -17002,11 +17002,11 @@ function oa(e) {
}
];
}
-function vh(e) {
+function _h(e) {
const t = Kr(e);
if (!t)
return;
- const n = ei(t.kind).scanPieces(t.owner);
+ const n = ti(t.kind).scanPieces(t.owner);
if (n.opener?.is(e))
return { ...t, role: "opener" };
if (n.value?.is(e))
@@ -17014,9 +17014,9 @@ function vh(e) {
if (n.closer?.is(e))
return { ...t, role: "closer" };
}
-function ru(e, t, n, r = (i) => i) {
+function su(e, t, n, r = (i) => i) {
const i = [];
- for (const s of e.slice(t).matchAll(z1)) {
+ for (const s of e.slice(t).matchAll(G1)) {
const o = s[1], a = r(o);
i.push({
start: t + s.index,
@@ -17033,11 +17033,11 @@ function ru(e, t, n, r = (i) => i) {
{ start: t, base: 0, bytes: { kind: "property", property: n } }
];
}
-function V1(e, t) {
- const n = j1.exec(e);
+function Y1(e, t) {
+ const n = J1.exec(e);
if (!n)
return [];
- const r = n[1], i = n[0].length - r.length - 2, s = F1.get(r) ?? r, o = [];
+ const r = n[1], i = n[0].length - r.length - 2, s = W1.get(r) ?? r, o = [];
i > 0 && o.push({
start: 0,
base: t,
@@ -17046,24 +17046,24 @@ function V1(e, t) {
const a = e.lastIndexOf(`\\${r}*`);
return a > n[0].length && o.push({ start: a, base: 0, bytes: { kind: "closingAttributeMarker", keyName: s } }), o;
}
-function Sh(e) {
- if (On(e)) {
- const t = AT(e), n = e.getTextContent();
- if (Ve(t) && (n === "\\*" || n.startsWith(rt(t.getMarker()))))
+function Eh(e) {
+ if ($n(e)) {
+ const t = $T(e), n = e.getTextContent();
+ if (Ve(t) && (n === "\\*" || n.startsWith(it(t.getMarker()))))
return t;
}
return Xn(e) ?? e;
}
-function W1(e) {
- const t = e.getTextContentSize(), n = vh(e);
+function X1(e) {
+ const t = e.getTextContentSize(), n = _h(e);
if (n && n.role !== "value") {
- const i = bi[n.kind];
+ const i = ki[n.kind];
if (i) {
const { keyName: s } = i;
return {
owner: n.owner,
length: t,
- spans: n.role === "closer" ? oa(s) : [
+ spans: n.role === "closer" ? aa(s) : [
{ start: 0, base: 0, bytes: { kind: "attributeMarker", keyName: s } },
{ start: 1, base: 0, bytes: { kind: "attributeKey", keyName: s } }
]
@@ -17073,59 +17073,59 @@ function W1(e) {
return {
owner: n.owner,
length: t,
- spans: n.role === "closer" ? oa() : ss(1)
+ spans: n.role === "closer" ? aa() : os(1)
};
}
const r = e.getMarkerSyntax();
return {
- owner: Sh(e),
+ owner: Eh(e),
length: t,
spans: r === "opening" ? (
// A nested span's `+` rides between the backslash and the marker name, so the name's
// offsets start one byte later.
- ss(e.getNested() ? 2 : 1)
- ) : oa()
+ os(e.getNested() ? 2 : 1)
+ ) : aa()
};
}
-function H1(e) {
- const t = e.getTextContent(), n = t.length, r = vh(e);
+function Q1(e) {
+ const t = e.getTextContent(), n = t.length, r = _h(e);
if (r?.kind === "optbreak")
return {
owner: r.owner,
length: n,
spans: [{ start: 0, base: 0, bytes: { kind: "marker" } }]
};
- const i = Sh(e);
+ const i = Eh(e);
if (qe(i)) {
- const s = rt(i.getMarker()).length;
- if (t.startsWith(rt(i.getMarker())))
+ const s = it(i.getMarker()).length;
+ if (t.startsWith(it(i.getMarker())))
return {
owner: i,
length: n,
spans: [
- ...ss(1),
+ ...os(1),
{ start: s + 1, base: 0, bytes: { kind: "property", property: "code" } }
]
};
}
if (Ie(i)) {
- const s = Vl(i.getTag(), i.getMarker(), i.getUnknownAttributes());
+ const s = Hl(i.getTag(), i.getMarker(), i.getUnknownAttributes());
if (s.closing !== "" && t === s.closing)
- return { owner: i, length: n, spans: oa() };
+ return { owner: i, length: n, spans: aa() };
if (s.opening !== "" && t === s.opening)
- return { owner: i, length: n, spans: ss(1) };
+ return { owner: i, length: n, spans: os(1) };
}
return {
owner: i,
length: n,
- spans: t.endsWith("*") ? oa() : ss(t.startsWith("\\+") ? 2 : 1)
+ spans: t.endsWith("*") ? aa() : os(t.startsWith("\\+") ? 2 : 1)
};
}
-function G1(e) {
- const t = vh(e);
+function Z1(e) {
+ const t = _h(e);
if (t?.role !== "value")
return;
- const { owner: n, kind: r } = t, i = e.getTextContent(), s = i.length, o = bi[r];
+ const { owner: n, kind: r } = t, i = e.getTextContent(), s = i.length, o = ki[r];
if (o) {
const { markerName: a, keyName: c } = o;
return {
@@ -17145,25 +17145,25 @@ function G1(e) {
length: s,
spans: [
{ start: 0, base: 0, bytes: { kind: "precedingText" } },
- ...ru(i, 1, z(n) ? Ao(n.getMarker()) : void 0)
+ ...su(i, 1, z(n) ? wo(n.getMarker()) : void 0)
]
};
if (r === "milestone" && Ve(n))
- return { owner: n, length: s, spans: bT(n.getMarker(), i) };
+ return { owner: n, length: s, spans: CT(n.getMarker(), i) };
}
-function bT(e, t) {
+function CT(e, t) {
return [
{ start: 0, base: e.length, bytes: { kind: "property", property: "marker" } },
- ...ru(t, 2, Ha(e))
+ ...su(t, 2, Ha(e))
];
}
-function J1(e) {
+function ew(e) {
const t = e.getTextContent(), n = t.length, r = e.getParent();
if (!Ie(r)) {
- const s = AT(e);
- return Ve(s) ? { owner: s, length: n, spans: bT(s.getMarker(), t) } : void 0;
+ const s = $T(e);
+ return Ve(s) ? { owner: s, length: n, spans: CT(s.getMarker(), t) } : void 0;
}
- const i = V1(t, (r.getMarker() ?? "").length);
+ const i = Y1(t, (r.getMarker() ?? "").length);
if (i.length > 0)
return { owner: r, length: n, spans: i };
if (t.startsWith("|"))
@@ -17173,26 +17173,26 @@ function J1(e) {
spans: [
{ start: 0, base: 0, bytes: { kind: "precedingText" } },
// The bytes spell an attribute the way USFM names it, which is not always USJ's name for it.
- ...ru(t, 1, void 0, (s) => NM(r.getTag(), s))
+ ...su(t, 1, void 0, (s) => LM(r.getTag(), s))
]
};
}
-function Um(e, t) {
- const n = rt(e);
+function Vm(e, t) {
+ const n = it(e);
if (t.startsWith(n))
return [
- ...ss(1),
+ ...os(1),
{ start: n.length + 1, base: 0, bytes: { kind: "property", property: "number" } }
];
}
function gn(e) {
if ($(e))
- return W1(e);
- if (On(e))
- return H1(e);
+ return X1(e);
+ if ($n(e))
+ return Q1(e);
if (Yt(e) && e.getTextType() === "attribute")
- return J1(e);
- if (e.getType() === Ii) {
+ return ew(e);
+ if (e.getType() === Li) {
const r = e.getParent();
return K(r) ? {
owner: r,
@@ -17201,18 +17201,18 @@ function gn(e) {
} : void 0;
}
if (Le(e)) {
- const r = Um(e.getMarker(), e.getTextContent());
+ const r = Vm(e.getMarker(), e.getTextContent());
return r ? { owner: e, length: e.getTextContentSize(), spans: r } : void 0;
}
- if (!T(e))
+ if (!C(e))
return;
if (bn(e))
- return { owner: e, length: e.getTextContentSize(), spans: ss(1) };
+ return { owner: e, length: e.getTextContentSize(), spans: os(1) };
if (Te(e, _e) === "attribute")
- return G1(e);
+ return Z1(e);
const t = e.getParent();
- if (Be(t) && jr(t)?.is(e)) {
- const r = Um(t.getMarker(), e.getTextContent());
+ if (Fe(t) && Vr(t)?.is(e)) {
+ const r = Vm(t.getMarker(), e.getTextContent());
return r ? { owner: t, length: e.getTextContentSize(), spans: r } : void 0;
}
const n = Xn(e);
@@ -17232,21 +17232,21 @@ function gn(e) {
]
};
}
-function Di(e) {
- return On(e) || Yt(e) && e.getTextType() === "attribute" || e.getType() === Ii;
+function Ki(e) {
+ return $n(e) || Yt(e) && e.getTextType() === "attribute" || e.getType() === Li;
}
-function iu(e) {
+function ou(e) {
const t = [];
if ((Le(e) || bn(e)) && t.push(e), A(e)) {
- const n = Be(e) ? jr(e) : void 0, r = K(e) ? Dt(e) : void 0;
+ const n = Fe(e) ? Vr(e) : void 0, r = K(e) ? Dt(e) : void 0;
for (const i of e.getChildren())
- r && (r.is(i) || i.isParentOf(r)) ? t.push(r) : ($(i) || On(i) || Yt(i) && i.getTextType() === "attribute" || i.getType() === Ii || n?.is(i)) && t.push(i);
+ r && (r.is(i) || i.isParentOf(r)) ? t.push(r) : ($(i) || $n(i) || Yt(i) && i.getTextType() === "attribute" || i.getType() === Li || n?.is(i)) && t.push(i);
}
if (Ve(e))
- for (let n = e.getNextSibling(); n && Di(n); n = n.getNextSibling())
- (!On(n) || Sh(n).is(e)) && t.push(n);
- for (const n of B1) {
- const r = ei(n);
+ for (let n = e.getNextSibling(); n && Ki(n); n = n.getNextSibling())
+ (!$n(n) || Eh(n).is(e)) && t.push(n);
+ for (const n of H1) {
+ const r = ti(n);
if (!r.ownerPredicate(e))
continue;
const { opener: i, value: s, closer: o } = r.scanPieces(e);
@@ -17257,7 +17257,7 @@ function iu(e) {
function xs(e, t) {
return e.kind !== t.kind ? !1 : e.kind === "property" && t.kind === "property" ? e.property === t.property : (e.kind === "attributeKey" || e.kind === "attributeMarker" || e.kind === "closingAttributeMarker") && "keyName" in t ? e.keyName === t.keyName : !0;
}
-function ld(e, t, n) {
+function dd(e, t, n) {
const r = gn(e);
if (!r || r.spans.length === 0)
return;
@@ -17268,7 +17268,7 @@ function ld(e, t, n) {
break;
s = c;
}
- const o = s.base + (i - s.start), a = Ht(Mn(r.owner, n));
+ const o = s.base + (i - s.start), a = Ht(Pn(r.owner, n));
switch (s.bytes.kind) {
case "marker":
return { jsonPath: a };
@@ -17277,7 +17277,7 @@ function ld(e, t, n) {
case "property": {
const { owner: c } = r, l = s.bytes.property === "number" && Le(c) ? c.getNumber() : void 0;
return {
- jsonPath: yT(a, s.bytes.property),
+ jsonPath: TT(a, s.bytes.property),
propertyOffset: l === void 0 ? o : Math.min(o, l.length)
};
}
@@ -17288,49 +17288,49 @@ function ld(e, t, n) {
case "closingAttributeMarker":
return { jsonPath: a, keyName: s.bytes.keyName, keyClosingMarkerOffset: o };
case "precedingText":
- return Y1(e, n);
+ return tw(e, n);
}
}
-function ud(e, t) {
- return T(e) && !gn(e) && !lo(e, 0, t);
+function pd(e, t) {
+ return C(e) && !gn(e) && !lo(e, 0, t);
}
-function Y1(e, t) {
+function tw(e, t) {
let n = e;
- for (let o = n.getParent(); !n.getPreviousSibling() && ge(o); )
+ for (let o = n.getParent(); !n.getPreviousSibling() && me(o); )
n = o, o = n.getParent();
let r = n.getPreviousSibling();
- for (; r && ud(r, t); )
+ for (; r && pd(r, t); )
r = r.getPreviousSibling();
if (!r)
return;
const i = A(r) ? r.getLastDescendant() : r;
- if (i && (T(i) || Di(i)))
- return ud(i, t) ? void 0 : br(i, i.getTextContentSize(), t);
+ if (i && (C(i) || Ki(i)))
+ return pd(i, t) ? void 0 : kr(i, i.getTextContentSize(), t);
const s = r.getParent();
if (s)
- return br(s, r.getIndexWithinParent() + 1, t);
+ return kr(s, r.getIndexWithinParent() + 1, t);
}
-function Yi(e, t, n) {
- for (const r of iu(e)) {
+function Xi(e, t, n) {
+ for (const r of ou(e)) {
const i = gn(r);
if (!(!i || !i.owner.is(e)))
for (let s = 0; s < i.spans.length; s++) {
const o = i.spans[s];
if (!xs(o.bytes, t))
continue;
- const a = _h(i, s);
+ const a = Mh(i, s);
if (!(n < o.base || n > a))
return [r, o.start + (n - o.base)];
}
}
}
-function _h(e, t) {
+function Mh(e, t) {
const n = e.spans[t], r = e.spans[t + 1];
return r ? n.base + (r.start - n.start) - 1 : n.base + (e.length - n.start);
}
function Vn(e, t) {
- const n = gt(t);
- if (Jr(e)) {
+ const n = mt(t);
+ if (Yr(e)) {
const r = Gn(e.jsonPath);
let i = Me();
for (let s = 0; s < r.length; s++) {
@@ -17340,139 +17340,139 @@ function Vn(e, t) {
if (!o)
return [void 0, void 0];
if (o.type === "text")
- return s !== r.length - 1 ? [void 0, void 0] : OP(o, e.offset) ?? zm(e, n) ?? [void 0, void 0];
+ return s !== r.length - 1 ? [void 0, void 0] : qP(o, e.offset) ?? Gm(e, n) ?? [void 0, void 0];
i = o.node;
}
- return i && A(i) ? Vn(Mh(i, r, e.offset, n), t) : [void 0, void 0];
+ return i && A(i) ? Vn(Ah(i, r, e.offset, n), t) : [void 0, void 0];
}
- if (da(e) || as(e) || pa(e)) {
- const r = zm(e, n);
+ if (da(e) || cs(e) || pa(e)) {
+ const r = Gm(e, n);
if (r)
return r;
}
- if (ha(e) || Il(e)) {
- const r = es(e.jsonPath, n);
+ if (ha(e) || ql(e)) {
+ const r = ts(e.jsonPath, n);
if (!r)
return [void 0, void 0];
- const { keyName: i } = e, s = ha(e) ? Yi(r, { kind: "attributeKey", keyName: i }, e.keyOffset) : Yi(r, { kind: "attributeMarker", keyName: i }, 0);
+ const { keyName: i } = e, s = ha(e) ? Xi(r, { kind: "attributeKey", keyName: i }, e.keyOffset) : Xi(r, { kind: "attributeMarker", keyName: i }, 0);
if (s)
return s;
- const o = nf(r, i);
+ const o = of(r, i);
if (o)
return o;
- const a = cw(r, i);
- return a || (Ve(r) ? Hr(r, !1) : tf(r));
+ const a = pw(r, i);
+ return a || (Ve(r) ? Gr(r, !1) : sf(r));
}
if (pa(e)) {
- const r = es(e.jsonPath, n);
+ const r = ts(e.jsonPath, n);
if (!r)
return [void 0, void 0];
- const i = Yi(r, { kind: "closingAttributeMarker", keyName: e.keyName }, e.keyClosingMarkerOffset);
- return i || (nf(r, e.keyName) ?? tf(r));
+ const i = Xi(r, { kind: "closingAttributeMarker", keyName: e.keyName }, e.keyClosingMarkerOffset);
+ return i || (of(r, e.keyName) ?? sf(r));
}
- if (op(e)) {
- const r = es(e.jsonPath, n);
+ if (cp(e)) {
+ const r = ts(e.jsonPath, n);
if (!r)
return [void 0, void 0];
- const i = Yi(r, { kind: "marker" }, 0);
+ const i = Xi(r, { kind: "marker" }, 0);
if (i)
return i;
const s = A(r) ? r.getFirstChild() : null;
- return s && T(s) ? [s, 0] : Hr(r, !1);
+ return s && C(s) ? [s, 0] : Gr(r, !1);
}
- if (as(e)) {
- const r = es(e.jsonPath, n);
+ if (cs(e)) {
+ const r = ts(e.jsonPath, n);
if (!r)
return [void 0, void 0];
- const i = Yi(r, { kind: "closingMarker" }, e.closingMarkerOffset);
+ const i = Xi(r, { kind: "closingMarker" }, e.closingMarkerOffset);
if (i)
return i;
- const s = Ph(r);
+ const s = wh(r);
if (s !== void 0 && e.closingMarkerOffset >= s)
- return Hr(r, !0);
+ return Gr(r, !0);
if (!A(r))
- return Hr(r, !1);
+ return Gr(r, !1);
const o = r.getLastChild();
- return o && T(o) ? [o, o.getTextContent().length] : [r, r.getChildrenSize()];
+ return o && C(o) ? [o, o.getTextContent().length] : [r, r.getChildrenSize()];
}
if (da(e)) {
- const r = kT(e.jsonPath), i = es(e.jsonPath, n);
+ const r = vT(e.jsonPath), i = ts(e.jsonPath, n);
if (!i || r === void 0)
return [void 0, void 0];
const s = { kind: "property", property: r };
- if (r === "number" && Le(i) && e.propertyOffset === i.getNumber().length + 1 && Eh(i) && iw(i)) {
- const u = rw(i);
+ if (r === "number" && Le(i) && e.propertyOffset === i.getNumber().length + 1 && Ph(i) && lw(i)) {
+ const u = cw(i);
if (u)
return u;
}
- const o = Yi(i, s, e.propertyOffset);
+ const o = Xi(i, s, e.propertyOffset);
if (o)
return o;
- const a = lw(i, s, e.propertyOffset);
+ const a = hw(i, s, e.propertyOffset);
if (a)
return a;
- const c = nf(i, r);
+ const c = of(i, r);
if (c)
return c;
if (A(i)) {
- if (!X1.has(r))
- return tf(i);
+ if (!nw.has(r))
+ return sf(i);
const u = i.getFirstChild();
- return u && T(u) ? [u, 0] : [i, 0];
+ return u && C(u) ? [u, 0] : [i, 0];
}
- const l = uw(i, r);
- return Hr(i, l !== void 0 && e.propertyOffset >= l.length);
+ const l = gw(i, r);
+ return Gr(i, l !== void 0 && e.propertyOffset >= l.length);
}
- throw new Error(`Unsupported UsjDocumentLocation type: ${k0(e)}. All UsjDocumentLocation subtypes should be supported: UsjMarkerLocation, UsjClosingMarkerLocation, UsjTextContentLocation, UsjPropertyValueLocation, UsjAttributeKeyLocation, UsjAttributeMarkerLocation, andUsjClosingAttributeMarkerLocation. Received: ${JSON.stringify(e)}`);
+ throw new Error(`Unsupported UsjDocumentLocation type: ${S0(e)}. All UsjDocumentLocation subtypes should be supported: UsjMarkerLocation, UsjClosingMarkerLocation, UsjTextContentLocation, UsjPropertyValueLocation, UsjAttributeKeyLocation, UsjAttributeMarkerLocation, andUsjClosingAttributeMarkerLocation. Received: ${JSON.stringify(e)}`);
}
-function kT(e) {
+function vT(e) {
const t = /\.(\w+)$|^\$\.(\w+)$|\['([^']+)'\]$/.exec(e);
return t?.[1] ?? t?.[2] ?? t?.[3];
}
-const X1 = /* @__PURE__ */ new Set([
+const nw = /* @__PURE__ */ new Set([
"marker",
"code",
"caller",
"category"
]);
-function fd(e, t) {
+function hd(e, t) {
const n = e.length - e.trimStart().length, r = Math.max(n, e.trimEnd().length);
return { before: Math.min(Math.max(t, n), r) - n, total: r - n };
}
-function Fm(e, t, n) {
+function Wm(e, t, n) {
const r = Vn(e, t), [i, s] = r;
- if (n && !Jr(e)) {
- const c = es(e.jsonPath, gt(t)), l = c && Q1(c, e);
+ if (n && !Yr(e)) {
+ const c = ts(e.jsonPath, mt(t)), l = c && rw(c, e);
if (l)
return l.before > 0 ? { point: r, insideDecorator: l } : { point: r };
}
- if (i && s !== void 0 && s > 0 && Di(i)) {
- const c = Gl(i);
+ if (i && s !== void 0 && s > 0 && Ki(i)) {
+ const c = Yl(i);
return {
point: r,
- insideDecorator: { decorator: i, ...fd(c, s) }
+ insideDecorator: { decorator: i, ...hd(c, s) }
};
}
- if (Jr(e))
+ if (Yr(e))
return { point: r };
- const o = es(e.jsonPath, gt(t));
- if (!Er(o) && !ai(o))
+ const o = ts(e.jsonPath, mt(t));
+ if (!Er(o) && !ci(o))
return { point: r };
- const a = Z1(o, e);
+ const a = iw(o, e);
return a && a.before > 0 ? { point: r, insideDecorator: a } : { point: r };
}
-function xT(e) {
+function ST(e) {
const t = e.getFirstChild();
- if (!t || !On(t))
+ if (!t || !$n(t))
return;
const n = gn(t);
- if (n?.spans[0]?.bytes.kind !== "marker" || !n.owner.is(e) || !e.getChildren().every((c) => Di(c) || T(c) && Bn(c)))
+ if (n?.spans[0]?.bytes.kind !== "marker" || !n.owner.is(e) || !e.getChildren().every((c) => Ki(c) || C(c) && Fn(c)))
return;
- const i = Ao(e.getMarker()), s = yr(e.getUnknownAttributes() ?? {}, i);
+ const i = wo(e.getMarker()), s = br(e.getUnknownAttributes() ?? {}, i);
if (!s)
return;
- const o = ru(s, 1, i);
- if (!iu(e).some((c) => gn(c)?.spans.some((l) => o.some((u) => xs(l.bytes, u.bytes)))))
+ const o = su(s, 1, i);
+ if (!ou(e).some((c) => gn(c)?.spans.some((l) => o.some((u) => xs(l.bytes, u.bytes)))))
return {
decorator: t,
pieces: [
@@ -17484,61 +17484,61 @@ function xT(e) {
]
};
}
-function Q1(e, t) {
- const n = z(e) ? xT(e) : void 0, r = n && TT(t);
+function rw(e, t) {
+ const n = z(e) ? ST(e) : void 0, r = n && _T(t);
if (!n || !r)
return;
let i = 0, s;
for (const { text: o, spans: a } of n.pieces) {
const c = { spans: a, length: o.length };
if (s === void 0) {
- const l = a.findIndex((u, f) => xs(u.bytes, r.bytes) && r.offset >= u.base && r.offset <= _h(c, f));
+ const l = a.findIndex((u, f) => xs(u.bytes, r.bytes) && r.offset >= u.base && r.offset <= Mh(c, f));
if (l >= 0) {
const u = a[l].start + (r.offset - a[l].base);
- s = i + fd(o, u).before;
+ s = i + hd(o, u).before;
}
}
- i += fd(o, 0).total;
+ i += hd(o, 0).total;
}
return s === void 0 ? void 0 : { decorator: n.decorator, before: s, total: i };
}
-function Z1(e, t) {
- const n = TT(t);
+function iw(e, t) {
+ const n = _T(t);
if (!n)
return;
- const r = CT(e), i = r.findIndex((a) => xs(a.bytes, n.bytes));
+ const r = ET(e), i = r.findIndex((a) => xs(a.bytes, n.bytes));
if (i < 0)
return;
const s = r.reduce((a, c) => a + c.length, 0), o = r.slice(0, i).reduce((a, c) => a + c.length, 0) + Math.min(Math.max(n.offset, 0), r[i].length);
return { decorator: e, before: o, total: s };
}
-function TT(e) {
+function _T(e) {
if (ha(e))
return {
bytes: { kind: "attributeKey", keyName: e.keyName },
offset: e.keyOffset
};
- if (Il(e))
+ if (ql(e))
return { bytes: { kind: "attributeMarker", keyName: e.keyName }, offset: 0 };
if (pa(e))
return {
bytes: { kind: "closingAttributeMarker", keyName: e.keyName },
offset: e.keyClosingMarkerOffset
};
- if (op(e))
+ if (cp(e))
return { bytes: { kind: "marker" }, offset: 0 };
if (da(e)) {
- const t = kT(e.jsonPath);
+ const t = vT(e.jsonPath);
return t === void 0 ? void 0 : { bytes: { kind: "property", property: t }, offset: e.propertyOffset };
}
}
-function CT(e) {
+function ET(e) {
const t = (s, o) => ({ bytes: s, text: o, length: o.length }), n = [
t({ kind: "marker" }, "\\"),
// The space after the marker name is inside the glyph Standard view spells, so it counts.
t({ kind: "property", property: "marker" }, `${e.getMarker()} `),
t({ kind: "property", property: "number" }, e.getNumber())
- ], r = ai(e), i = r ? [bi.ca, bi.cp] : [bi.va, bi.vp];
+ ], r = ci(e), i = r ? [ki.ca, ki.cp] : [ki.va, ki.vp];
for (const s of i) {
if (!s)
continue;
@@ -17547,14 +17547,14 @@ function CT(e) {
}
return n;
}
-function ew(e) {
- if (Er(e) || ai(e))
- return CT(e).map(({ text: r }) => r).join("");
- const t = e.getParent(), n = z(t) ? xT(t) : void 0;
- return n?.decorator.is(e) ? n.pieces.map(({ text: r }) => r.trim()).join("") : Gl(e).trim();
+function sw(e) {
+ if (Er(e) || ci(e))
+ return ET(e).map(({ text: r }) => r).join("");
+ const t = e.getParent(), n = z(t) ? ST(t) : void 0;
+ return n?.decorator.is(e) ? n.pieces.map(({ text: r }) => r.trim()).join("") : Yl(e).trim();
}
-function Bm(e, t) {
- if (!Di(e))
+function Hm(e, t) {
+ if (!Ki(e))
return [e, t];
const n = e.getParent();
if (!n || !A(n))
@@ -17562,11 +17562,11 @@ function Bm(e, t) {
const r = e.getIndexWithinParent();
if (r < 0)
return [e, t];
- const i = e.getTextContentSize(), s = t >= i && t > 0 || t === i - 1 && vT.test(e.getTextContent());
+ const i = e.getTextContentSize(), s = t >= i && t > 0 || t === i - 1 && MT.test(e.getTextContent());
return [n, s ? r + 1 : r];
}
-const vT = /[ \u00A0]$/;
-function tw(e, t, n) {
+const MT = /[ \u00A0]$/;
+function ow(e, t, n) {
let r;
if (A(e))
r = t > 0 ? e.getChildAtIndex(t - 1) : null;
@@ -17575,20 +17575,20 @@ function tw(e, t, n) {
else
return [e, t];
let i = !1;
- for (; T(r) && !gn(r) && !lo(r, 0, n); )
+ for (; C(r) && !gn(r) && !lo(r, 0, n); )
r = r.getPreviousSibling(), i = !0;
if (!i)
return [e, t];
const s = r?.getParent();
- if (r && s && Di(r))
+ if (r && s && Ki(r))
return [s, r.getIndexWithinParent() + 1];
const o = A(r) ? r.getLastDescendant() : r;
- return T(o) ? [o, o.getTextContentSize()] : [e, t];
+ return C(o) ? [o, o.getTextContentSize()] : [e, t];
}
-function dd(e) {
+function gd(e) {
return A(e) ? "element" : "text";
}
-function es(e, t) {
+function ts(e, t) {
const n = new RegExp(/^(\$(?:\.content\[\d+\])*)(?:\.|$|\[)/).exec(e), r = n ? n[1] : e, i = Gn(r);
let s = Me();
for (const o of i) {
@@ -17600,130 +17600,130 @@ function es(e, t) {
return s;
}
function Gt(e, t, n) {
- return br(e, t, gt(n));
+ return kr(e, t, mt(n));
}
-function br(e, t, n) {
- const r = T(e) ? Gp(e) : void 0;
- if (T(e) && r && t > r.start) {
+function kr(e, t, n) {
+ const r = C(e) ? Yp(e) : void 0;
+ if (C(e) && r && t > r.start) {
const s = lo(e, t, n);
if (s)
return {
jsonPath: Ht([
- ...Mn(s.parent, n),
+ ...Pn(s.parent, n),
s.index
]),
offset: s.offset
};
}
- if (T(e) && t > 0 && t === e.getTextContentSize() && Eh(e)) {
- const s = nw(e, n);
+ if (C(e) && t > 0 && t === e.getTextContentSize() && Ph(e)) {
+ const s = aw(e, n);
if (s)
return s;
}
- const i = ld(e, t, n);
+ const i = dd(e, t, n);
if (i)
return i;
- if (ge(e)) {
+ if (me(e)) {
const s = e.getChildrenSize(), o = e.getChildAtIndex(Math.min(t, s - 1));
- if (T(o)) {
+ if (C(o)) {
const c = t >= s ? o.getTextContentSize() : 0;
- return br(o, c, n);
+ return kr(o, c, n);
}
if (o && t > 0 && t < s) {
- const c = _T(e, t, n);
+ const c = AT(e, t, n);
if (c)
return c;
}
const a = e.getParent();
if (a) {
const c = e.getIndexWithinParent(), l = t > 0 ? c + 1 : c;
- return br(a, l, n);
+ return kr(a, l, n);
}
}
if (A(e)) {
- const s = e.getChildAtIndex(t), o = s && ST(s);
+ const s = e.getChildAtIndex(t), o = s && PT(s);
if (o) {
- const l = ld(o, 0, n);
+ const l = dd(o, 0, n);
if (l)
return l;
}
- if (s && Di(s))
+ if (s && Ki(s))
return {
- jsonPath: Ht(Mn(e, n))
+ jsonPath: Ht(Pn(e, n))
};
const a = t > 0 ? e.getChildAtIndex(t - 1) : null;
- if (!s && a && MT(a, e))
+ if (!s && a && NT(a, e))
return Ac(e, !0, n);
- if (ot(e) || Bn(e))
+ if (Ye(e) || Fn(e))
return Ac(e, t > 0, n);
- const c = kt(e) && pn(e.getParent()) ? e.getParentOrThrow() : e;
- return ET(c, io(e, t, n), n);
+ const c = ht(e) && pn(e.getParent()) ? e.getParentOrThrow() : e;
+ return wT(c, io(e, t, n), n);
}
- if (T(e)) {
- if (t < No(e)) {
+ if (C(e)) {
+ if (t < Oo(e)) {
const c = e.getPreviousSibling();
if ($(c))
- return br(c, c.getTextContentSize(), n);
+ return kr(c, c.getTextContentSize(), n);
}
const s = lo(e, t, n);
if (s)
return {
jsonPath: Ht([
- ...Mn(s.parent, n),
+ ...Pn(s.parent, n),
s.index
]),
offset: s.offset
};
const o = t > 0;
let a = o ? e.getNextSibling() : e.getPreviousSibling();
- for (; ge(a); )
+ for (; me(a); )
a = o ? a.getFirstChild() : a.getLastChild();
- if (T(a) && (gn(a) || lo(a, 0, n)))
- return br(a, o ? 0 : a.getTextContentSize(), n);
+ if (C(a) && (gn(a) || lo(a, 0, n)))
+ return kr(a, o ? 0 : a.getTextContentSize(), n);
}
return Ac(e, t > 0, n);
}
-function Eh(e) {
- if (!vT.test(e.getTextContent()))
+function Ph(e) {
+ if (!MT.test(e.getTextContent()))
return !1;
if (Le(e))
return !0;
const t = Xn(e);
return K(t) && !!Dt(t)?.is(e);
}
-function nw(e, t) {
+function aw(e, t) {
let n = e;
- for (let s = n.getParent(); !n.getNextSibling() && ge(s); s = n.getParent())
+ for (let s = n.getParent(); !n.getNextSibling() && me(s); s = n.getParent())
n = s;
const r = n.getNextSibling();
if (!r) {
const s = n.getParent();
- return s ? br(s, s.getChildrenSize(), t) : void 0;
+ return s ? kr(s, s.getChildrenSize(), t) : void 0;
}
const i = A(r) ? r.getFirstDescendant() ?? r : r;
- if (!(ud(i, t) || gn(i)?.spans[0]?.bytes.kind === "precedingText"))
- return br(i, 0, t);
+ if (!(pd(i, t) || gn(i)?.spans[0]?.bytes.kind === "precedingText"))
+ return kr(i, 0, t);
}
-function rw(e) {
+function cw(e) {
let t = e.getParent();
- for (; t && !PT(t); )
+ for (; t && !OT(t); )
t = t.getParent();
const n = t?.getNextSibling();
if (!n)
return;
- const r = Yi(n, { kind: "marker" }, 0);
+ const r = Xi(n, { kind: "marker" }, 0);
if (r)
return r;
const i = A(n) ? n.getFirstChild() : null;
- return i && T(i) ? [i, 0] : Hr(n, !1);
+ return i && C(i) ? [i, 0] : Gr(n, !1);
}
-function iw(e) {
+function lw(e) {
let t = e;
- for (let n = t.getParent(); !t.getNextSibling() && ge(n); n = t.getParent())
+ for (let n = t.getParent(); !t.getNextSibling() && me(n); n = t.getParent())
t = n;
return !t.getNextSibling();
}
-function ST(e) {
+function PT(e) {
if (gn(e))
return e;
if (!He(e))
@@ -17731,60 +17731,60 @@ function ST(e) {
const t = e.getFirstDescendant();
return t && gn(t) ? t : void 0;
}
-function _T(e, t, n) {
+function AT(e, t, n) {
for (let r = t; r < e.getChildrenSize(); r++) {
const i = e.getChildAtIndex(r);
if (!i)
return;
- const s = ST(i);
+ const s = PT(i);
if (s)
- return ld(s, 0, n);
- if (T(i) && lo(i, 0, n))
- return br(i, 0, n);
- if (T(i) || Bn(i))
+ return dd(s, 0, n);
+ if (C(i) && lo(i, 0, n))
+ return kr(i, 0, n);
+ if (C(i) || Fn(i))
continue;
- const o = $P(i, n);
+ const o = DP(i, n);
if (o)
- return ET(o.parent, o.point, n);
+ return wT(o.parent, o.point, n);
}
}
-function ET(e, t, n) {
- const r = Mn(e, n);
+function wT(e, t, n) {
+ const r = Pn(e, n);
return t.type === "text" ? {
jsonPath: Ht([...r, t.index]),
offset: t.offset
- } : Mh(e, r, t.index, n);
+ } : Ah(e, r, t.index, n);
}
-function MT(e, t) {
+function NT(e, t) {
const n = gn(e);
return !!n && n.owner.is(t) && n.spans[0]?.bytes.kind === "closingMarker";
}
function Ac(e, t, n) {
const r = e.getParent();
if (!r)
- return { jsonPath: Ht(Mn(e, n)) };
+ return { jsonPath: Ht(Pn(e, n)) };
const i = e.getIndexWithinParent() + (t ? 1 : 0);
- if (ge(r)) {
+ if (me(r)) {
if (i > 0 && i < r.getChildrenSize()) {
- const s = _T(r, i, n);
+ const s = AT(r, i, n);
if (s)
return s;
}
return Ac(r, i > 0, n);
}
- return br(r, i, n);
+ return kr(r, i, n);
}
-function Mh(e, t, n, r) {
+function Ah(e, t, n, r) {
const i = Xt(e, r), s = i[n];
if (!s)
- return sw(e, t, i, r);
+ return uw(e, t, i, r);
const o = Ht([...t, n]);
return s.type === "text" ? { jsonPath: o, offset: 0 } : { jsonPath: o };
}
-function sw(e, t, n, r) {
+function uw(e, t, n, r) {
if (pn(e))
- return sl(e, t, 1, r);
- if (Ph(e) !== void 0) {
+ return al(e, t, 1, r);
+ if (wh(e) !== void 0) {
const o = n.length - 1, a = n[o];
return a?.type === "text" ? {
jsonPath: Ht([...t, o]),
@@ -17795,10 +17795,10 @@ function sw(e, t, n, r) {
};
}
const i = Xn(e), s = t[t.length - 1];
- return PT(e) || !i || s === void 0 ? sl(e, t, 0, r) : Mh(i, t.slice(0, -1), s + 1, r);
+ return OT(e) || !i || s === void 0 ? al(e, t, 0, r) : Ah(i, t.slice(0, -1), s + 1, r);
}
-function sl(e, t, n, r) {
- const i = Ht(t), s = Ph(e);
+function al(e, t, n, r) {
+ const i = Ht(t), s = wh(e);
if (s !== void 0)
return {
jsonPath: i,
@@ -17809,10 +17809,10 @@ function sl(e, t, n, r) {
if (f?.type === "text")
return { jsonPath: Ht(d), offset: f.length + n };
if (f)
- return sl(f.node, d, n, r);
+ return al(f.node, d, n, r);
}
const o = (l, u) => ({
- jsonPath: yT(i, l),
+ jsonPath: TT(i, l),
propertyOffset: u.length + n
}), a = (l, u) => ({
jsonPath: i,
@@ -17821,7 +17821,7 @@ function sl(e, t, n, r) {
});
if (Oe(e))
return e.getPubnumber() !== void 0 ? a("pubnumber", "vp") : e.getAltnumber() !== void 0 ? a("altnumber", "va") : o("number", e.getNumber());
- if (ot(e)) {
+ if (Ye(e)) {
const l = e.getPubnumber();
return l !== void 0 ? o("pubnumber", l) : e.getAltnumber() !== void 0 ? a("altnumber", "ca") : o("number", e.getNumber());
}
@@ -17829,54 +17829,54 @@ function sl(e, t, n, r) {
return o("code", e.getCode());
if (K(e))
return o("caller", e.getCaller());
- const c = Ie(e) ? e.getMarker() : ow(e);
+ const c = Ie(e) ? e.getMarker() : fw(e);
return c === void 0 ? { jsonPath: i } : o("marker", c);
}
-function Ph(e) {
+function wh(e) {
if (z(e))
- return e.getUnknownAttributes()?.closed === "false" ? void 0 : pt(e.getMarker(), jl(e)).length;
+ return e.getUnknownAttributes()?.closed === "false" ? void 0 : pt(e.getMarker(), Wl(e)).length;
if (K(e))
return e.getUnknownAttributes()?.closed === "false" ? void 0 : pt(e.getMarker()).length;
if (Ve(e))
return pt("").length;
if (Ie(e)) {
- const { closing: t } = Vl(e.getTag(), e.getMarker(), e.getUnknownAttributes());
+ const { closing: t } = Hl(e.getTag(), e.getMarker(), e.getUnknownAttributes());
return t === "" ? void 0 : t.length;
}
}
-function PT(e) {
+function OT(e) {
const t = Xn(e);
- return ke(e) || kt(e) || qe(e) || Hx(e) || Ie(e) && e.getTag() === "table:row" || pn(t) || bs(t);
+ return ke(e) || ht(e) || qe(e) || Xx(e) || Ie(e) && e.getTag() === "table:row" || pn(t) || bs(t);
}
-function ow(e) {
- if (ke(e) || z(e) || Ve(e) || Hx(e) || nA(e))
+function fw(e) {
+ if (ke(e) || z(e) || Ve(e) || Xx(e) || aA(e))
return e.getMarker();
}
-function tf(e) {
+function sf(e) {
if (A(e)) {
const n = e.getLastChild();
let r = n;
- for (; r && aw(r, e); )
+ for (; r && dw(r, e); )
r = r.getPreviousSibling();
if (r !== n)
- return T(r) && !gn(r) ? [
+ return C(r) && !gn(r) ? [
r,
- Bn(r) ? 0 : r.getTextContentSize()
+ Fn(r) ? 0 : r.getTextContentSize()
] : [e, r ? r.getIndexWithinParent() + 1 : 0];
- if (n && T(n))
+ if (n && C(n))
return [
n,
- !gn(n) && Bn(n) ? 0 : n.getTextContentSize()
+ !gn(n) && Fn(n) ? 0 : n.getTextContentSize()
];
}
const t = e.getNextSibling();
- return t && A(t) ? [t, 0] : Hr(e, !0);
+ return t && A(t) ? [t, 0] : Gr(e, !0);
}
-function aw(e, t) {
- return Yp(e) || He(e) || Yt(e) && e.getTextType() === "attribute" || MT(e, t);
+function dw(e, t) {
+ return Qp(e) || He(e) || Yt(e) && e.getTextType() === "attribute" || NT(e, t);
}
-function cw(e, t) {
- for (const n of iu(e)) {
+function pw(e, t) {
+ for (const n of ou(e)) {
const r = gn(n);
if (!r?.owner.is(e))
continue;
@@ -17888,33 +17888,33 @@ function cw(e, t) {
return [n, s.start];
}
}
-function lw(e, t, n) {
- for (const r of iu(e)) {
- if (!Di(r))
+function hw(e, t, n) {
+ for (const r of ou(e)) {
+ if (!Ki(r))
continue;
const i = gn(r);
if (!i?.owner.is(e))
continue;
const s = i.spans.findIndex((o) => xs(o.bytes, t));
if (!(s < 0))
- return n > _h(i, s) ? [r, i.spans[s + 1]?.start ?? i.length] : void 0;
+ return n > Mh(i, s) ? [r, i.spans[s + 1]?.start ?? i.length] : void 0;
}
}
-function nf(e, t) {
- if (!K(e) || t !== bi.cat?.keyName)
+function of(e, t) {
+ if (!K(e) || t !== ki.cat?.keyName)
return;
- const n = e.getChildren().find((s) => s.getType() === Ii);
+ const n = e.getChildren().find((s) => s.getType() === Li);
if (!n)
return;
- const [r, i] = Hr(n, !0);
+ const [r, i] = Gr(n, !0);
return r && i !== void 0 ? [r, i] : void 0;
}
-function Hr(e, t) {
+function Gr(e, t) {
const n = e.getParent();
return n ? [n, e.getIndexWithinParent() + (t ? 1 : 0)] : [void 0, void 0];
}
-function uw(e, t) {
- if (Oe(e) || ot(e)) {
+function gw(e, t) {
+ if (Oe(e) || Ye(e)) {
if (t === "number")
return e.getNumber();
if (t === "altnumber")
@@ -17927,56 +17927,56 @@ function uw(e, t) {
if (Ve(e) && t === "marker")
return e.getMarker();
}
-function zm(e, t) {
- const n = Me(), r = sl(n, [], 1, t);
- if (jm(r) !== jm(e))
+function Gm(e, t) {
+ const n = Me(), r = al(n, [], 1, t);
+ if (Jm(r) !== Jm(e))
return;
const i = n.getLastChild();
if (!A(i))
return [n, n.getChildrenSize()];
const s = i.getLastDescendant();
- if (Le(s) && Eh(s))
+ if (Le(s) && Ph(s))
return [s, s.getTextContentSize() - 1];
- if (T(s))
+ if (C(s))
return [s, s.getTextContentSize()];
if (A(s))
return [s, s.getChildrenSize()];
const o = s?.getParent() ?? i;
return [o, o.getChildrenSize()];
}
-function jm(e) {
+function Jm(e) {
return JSON.stringify(Object.entries(e).sort(([t], [n]) => t.localeCompare(n)));
}
-function AT(e) {
+function $T(e) {
let t = e.getPreviousSibling();
for (; t; ) {
- if (!Bn(t))
+ if (!Fn(t))
return t;
t = t.getPreviousSibling();
}
}
-function Mn(e, t) {
+function Pn(e, t) {
const n = [];
let r = e;
for (; r; ) {
const i = Xn(r);
if (!i)
break;
- const s = NP(i, r, t);
+ const s = LP(i, r, t);
s >= 0 && n.unshift(s), r = i;
}
return n;
}
-function wT() {
+function RT() {
for (let e = Me().getFirstChild(); e; e = e.getNextSibling())
if (bs(e))
return !0;
return !1;
}
-function vo(e) {
+function So(e) {
return Yt(e) && qe(e.getParent()) && e.is(e.getParent()?.getFirstChild());
}
-function NT(e) {
+function IT(e) {
const t = Ks(e, 1);
return t ? { key: t.getKey(), offset: 0, type: "text" } : { key: e.getKey(), offset: 1, type: "element" };
}
@@ -17986,13 +17986,13 @@ function Na(e) {
const t = e.isBackward() ? e.focus : e.anchor, n = t.getNode();
if (!(pn(n) && t.offset === 0 || qe(n.getTopLevelElement())))
return !1;
- const i = e.getNodes().find(vo);
+ const i = e.getNodes().find(So);
if (!i)
return !1;
const s = i.getParent();
if (!qe(s))
return !1;
- const o = NT(s);
+ const o = IT(s);
return t.set(o.key, o.offset, o.type), !0;
}
function wc(e) {
@@ -18003,25 +18003,25 @@ function wc(e) {
const { anchor: n } = t;
if (n.type === "text") {
const i = n.getNode();
- if (!(e ? n.offset === 0 : T(i) && n.offset === i.getTextContentSize()))
+ if (!(e ? n.offset === 0 : C(i) && n.offset === i.getTextContentSize()))
return !1;
}
- const r = e ? xx(t) : jp(t);
- return vo(r);
+ const r = e ? Sx(t) : Wp(t);
+ return So(r);
}
return Na(t) && t.isCollapsed();
}
-function fw(e) {
+function mw(e) {
const t = M();
if (!E(t) || !t.isCollapsed())
return !1;
const n = We(t.anchor.getNode(), qe);
- if (!n || !vo(n.getFirstChild()))
+ if (!n || !So(n.getFirstChild()))
return !1;
if (t.modify("extend", e, "lineboundary"), t.isCollapsed())
return wc(e) || t.deleteCharacter(e), !0;
- if (t.getNodes().some(vo)) {
- const r = NT(n);
+ if (t.getNodes().some(So)) {
+ const r = IT(n);
t.focus.set(r.key, r.offset, r.type);
}
return t.isCollapsed() || t.removeText(), !0;
@@ -18030,7 +18030,7 @@ function gc() {
const e = M();
return E(e) && Na(e), !1;
}
-function dw() {
+function yw() {
const e = M();
if (!E(e) || !e.isCollapsed())
return !1;
@@ -18038,26 +18038,26 @@ function dw() {
if (t.type !== "element" || t.offset !== 0)
return !1;
const n = t.getNode();
- return !qe(n) || !vo(n.getFirstChild()) ? !1 : (zn(n, 1), !0);
+ return !qe(n) || !So(n.getFirstChild()) ? !1 : (zn(n, 1), !0);
}
-function pw(e) {
- const t = e.getChildren(), n = `\\${e.getMarker()}`, r = t.findIndex((s) => On(s) && s.getTextContent().startsWith(n));
+function bw(e) {
+ const t = e.getChildren(), n = `\\${e.getMarker()}`, r = t.findIndex((s) => $n(s) && s.getTextContent().startsWith(n));
if (r <= 0)
return;
let i = t[r];
for (const s of t.slice(0, r))
i.insertAfter(s), i = s;
}
-function hw() {
+function kw() {
const [e] = Pe();
- return J(() => gw(e), [e]), J(() => Ye(
- e.registerCommand(In, wc, Je),
- e.registerCommand(cs, wc, Je),
- e.registerCommand(Ei, wc, Je),
+ return J(() => xw(e), [e]), J(() => Xe(
+ e.registerCommand(Ln, wc, Je),
+ e.registerCommand(ls, wc, Je),
+ e.registerCommand(Mi, wc, Je),
// Below the boundary refusal above (which still runs first and can refuse outright), and
// above Lexical's own default DELETE_LINE_COMMAND handling (COMMAND_PRIORITY_EDITOR) — the
// default is exactly what this replaces for a book line, so it must never run for one.
- e.registerCommand(Ei, fw, $r),
+ e.registerCommand(Mi, mw, $r),
// CRITICAL: other handlers for these commands (StructureKeyboardPlugin's CUT_COMMAND/
// PASTE_COMMAND, OpaqueBlockGuardPlugin's CUT_COMMAND) are registered at HIGH or CRITICAL
// too, so this must match the top priority to have any guarantee of running before them —
@@ -18065,40 +18065,40 @@ function hw() {
// not control. Always returns `false` (never claims the command), so running before or after
// another CRITICAL handler that also returns `false` changes nothing either way; it only
// matters relative to a handler that would itself remove the prefix.
- e.registerCommand(Yr, gc, ye),
+ e.registerCommand(Xr, gc, ye),
e.registerCommand(un, gc, ye),
- e.registerCommand(wn, gc, ye),
+ e.registerCommand(Nn, gc, ye),
// REMOVE_TEXT_COMMAND is how drag-move deletion and composition-driven deletes reach a
// non-collapsed selection — neither goes through DELETE_CHARACTER_COMMAND — so it needs the
// same narrowing the other three selection-replacing commands get above.
- e.registerCommand(lp, gc, ye)
- ), [e]), J(() => Ye(
+ e.registerCommand(fp, gc, ye)
+ ), [e]), J(() => Xe(
// Below `DecoratorBoundarySelectionPlugin` (CRITICAL), which can itself produce `(book, 0)`
// when it snaps a caret that landed inside the prefix glyph to the glyph's leading edge; above
// the listeners that report the caret's position (e.g. `OnSelectionChangePlugin`, LOW), so
// they only ever see the corrected one. Never claims the command.
- e.registerCommand(Nn, () => (dw(), !1), Je),
- e.registerNodeTransform(Fn, pw)
+ e.registerCommand(On, () => (yw(), !1), Je),
+ e.registerNodeTransform(Un, bw)
), [e]), null;
}
-function gw(e) {
- return Ye(e.registerCommand(go, mw, Nt), e.registerCommand(go, (t) => (yw(t), !1), xi));
+function xw(e) {
+ return Xe(e.registerCommand(mo, Tw, Nt), e.registerCommand(mo, (t) => (Cw(t), !1), Ti));
}
-function mw(e) {
- return bw(e.target), !1;
+function Tw(e) {
+ return vw(e.target), !1;
}
-function yw(e) {
+function Cw(e) {
const t = e.target;
- if (ga(t) && Un(qr(t)))
+ if (ga(t) && Bn(qr(t)))
return;
const n = M();
- E(n) && kw(n);
+ E(n) && Sw(n);
}
-function su(e) {
+function au(e) {
let t = e.getFirstChild(), n = 0;
for (; t !== null; )
if (Zt(t))
- n++, t = t.getNextSibling(), T(t) && t.getTextContent() === U && (n++, t = t.getNextSibling());
+ n++, t = t.getNextSibling(), C(t) && t.getTextContent() === B && (n++, t = t.getNextSibling());
else if (Oe(t))
n++, t = t.getNextSibling();
else
@@ -18106,77 +18106,77 @@ function su(e) {
return n;
}
function Sn(e) {
- const t = su(e);
+ const t = au(e);
return t === 0 ? !1 : (zn(e, t), !0);
}
-function aa(e) {
+function uo(e) {
Sn(e) || e.selectStart();
}
-function bw(e) {
+function vw(e) {
if (!ga(e))
return !1;
const t = qr(e);
- if (!Un(t))
+ if (!Bn(t))
return !1;
const n = t.getParent();
- return n ? (dt(n) && Sn(n) || zn(n, t.getIndexWithinParent() + 1), !0) : !1;
+ return n ? (ot(n) && Sn(n) || zn(n, t.getIndexWithinParent() + 1), !0) : !1;
}
function js() {
- if (Pt().dispatchCommand(OT, void 0))
+ if (Pt().dispatchCommand(LT, void 0))
return E(M());
- const e = Tr(M());
- return e ? (aa(e), !0) : !1;
+ const e = pr(M());
+ return e ? (uo(e), !0) : !1;
}
-const OT = Ba("REPAIR_PARA_MARKER_SELECTION_COMMAND");
-function $T(e) {
- const t = Tr(e);
+const LT = Fa("REPAIR_PARA_MARKER_SELECTION_COMMAND");
+function qT(e) {
+ const t = pr(e);
if (!t)
return;
- const n = su(t), r = t.getChildAtIndex(n - 1);
- return t.getChildAtIndex(n) ?? (Un(r) ? void 0 : r) ?? t;
+ const n = au(t), r = t.getChildAtIndex(n - 1);
+ return t.getChildAtIndex(n) ?? (Bn(r) ? void 0 : r) ?? t;
}
-function kw(e) {
+function Sw(e) {
if (!e.isCollapsed())
return !1;
const { anchor: t } = e;
if (t.type !== "element" || t.offset !== 0)
return !1;
const n = ee(t.key);
- if (!ct(n))
+ if (!st(n))
return !1;
const r = n.getFirstChild();
- return !On(r) && !Er(r) ? !1 : Sn(n);
+ return !$n(r) && !Er(r) ? !1 : Sn(n);
}
-function xw(e, t) {
+function _w(e, t) {
return e === "f" ? t.defaultFootnoteCaller ?? "+" : e === "x" ? t.defaultCrossRefCaller ?? "-" : e.startsWith("f") ? "+" : "-";
}
-function RT(e, t, n, r, i, s, o) {
- if (!at.isValidMarker(e))
+function DT(e, t, n, r, i, s, o) {
+ if (!lt.isValidMarker(e))
throw new Error(`$insertNote: Invalid note marker '${e}'`);
const a = n ? wa(n, i) : M();
if (!E(a))
return;
- if (IT(a)) {
+ if (KT(a)) {
o?.warn("$insertNote: a note cannot be inserted in a chapter line");
return;
}
- const c = Sw(a, e, r, i, s, o);
+ const c = Aw(a, e, r, i, s, o);
if (c === void 0)
return;
- const l = t ?? xw(e, s), u = LT(e, l, c, i, s, void 0, void 0);
- return vw(u, a, i), u;
+ const l = t ?? _w(e, s), u = BT(e, l, c, i, s, void 0, void 0);
+ return Pw(u, a, i), u;
}
-function Ah(e) {
+function Nh(e) {
return e !== "expanded";
}
-function Tw(e) {
+function Ew(e) {
if (!e.isCollapsed())
return;
const { anchor: t } = e;
if (t.type !== "text")
return;
const n = t.getNode();
- if (!T(n) || !z(n.getParent()))
+ if (!C(n) || !z(n.getParent()))
return;
if ($(n))
return t.offset === 0 && n.getMarkerSyntax() === "closing" ? n : void 0;
@@ -18185,13 +18185,13 @@ function Tw(e) {
const r = n.getNextSibling();
return $(r) && r.getMarkerSyntax() === "closing" ? r : void 0;
}
-function IT(e) {
+function KT(e) {
return [e.anchor, e.focus].some((t) => {
const n = t.getNode();
- return Be(n) || Be(n.getParent());
+ return Fe(n) || Fe(n.getParent());
});
}
-function Cw(e) {
+function Mw(e) {
if (!e.isCollapsed())
return;
const { anchor: t } = e, n = t.getNode();
@@ -18199,36 +18199,36 @@ function Cw(e) {
if (t.offset !== 0 || !$(n))
return;
const i = n.getParent();
- return dt(i) && i.getFirstChild()?.is(n) ? i : void 0;
+ return ot(i) && i.getFirstChild()?.is(n) ? i : void 0;
}
if (!pn(n))
return;
const r = n.getChildAtIndex(t.offset);
- return dt(r) ? r : void 0;
+ return ot(r) ? r : void 0;
}
-function vw(e, t, n) {
- if (IT(t))
+function Pw(e, t, n) {
+ if (KT(t))
return;
- const r = Ah(n?.noteMode);
- e.setIsCollapsed(r), t.isCollapsed() || gP(t), ch(t);
- const i = Cw(t);
+ const r = Nh(n?.noteMode);
+ e.setIsCollapsed(r), t.isCollapsed() || xP(t), uh(t);
+ const i = Mw(t);
if (i && Sn(i)) {
const o = M();
E(o) && (t = o);
}
Mt(t);
- const s = Tw(t);
+ const s = Ew(t);
s ? (s.insertBefore(e), e.selectNext(0, 0)) : t.insertNodes([e]), r || e.getChildren().reverse().find(z)?.selectEnd();
}
function Vs(e, t, n) {
- const r = Qr(e);
+ const r = Zr(e);
r.setUnknownAttributes({ closed: "false" });
const i = n?.markerMode === "editable";
- i ? r.append(Jt(e)) : n?.markerMode === "visible" && r.append(Zr("marker", rt(e)));
- const s = t === "" ? It : i ? U + t : t;
- return r.append(Ue(s)), r;
+ i ? r.append(Jt(e)) : n?.markerMode === "visible" && r.append(ei("marker", it(e)));
+ const s = t === "" ? It : i ? B + t : t;
+ return r.append(Be(s)), r;
}
-function Sw(e, t, n, r, i, s) {
+function Aw(e, t, n, r, i, s) {
const o = [], { chapterNum: a, verseNum: c, verse: l } = n ?? {}, u = i.chapterVerseSeparator ?? ":", f = i.verseRangeSeparator ?? "-", d = a !== void 0 && c !== void 0 ? `${a}${u}${(l ?? `${c}`).replace(/-/g, () => f)} ` : void 0;
switch (t) {
case "f":
@@ -18236,7 +18236,7 @@ function Sw(e, t, n, r, i, s) {
case "ef":
case "efe":
if (d !== void 0 && o.push(Vs("fr", d, r)), !e.isCollapsed()) {
- const p = Wm(e);
+ const p = Xm(e);
p.length > 0 && o.push(Vs("fq", p, r));
}
o.push(Vs("ft", "", r));
@@ -18244,7 +18244,7 @@ function Sw(e, t, n, r, i, s) {
case "x":
case "ex":
if (d !== void 0 && o.push(Vs("xo", d, r)), !e.isCollapsed()) {
- const p = Wm(e);
+ const p = Xm(e);
p.length > 0 && o.push(Vs("xq", p, r));
}
o.push(Vs("xt", "", r));
@@ -18255,24 +18255,24 @@ function Sw(e, t, n, r, i, s) {
}
return o;
}
-function LT(e, t, n, r, i, s, o) {
- const a = o === "false", c = a ? !1 : Ah(r?.noteMode), l = Cp(e, t, c);
- s && Wt(l, Mi, () => s);
+function BT(e, t, n, r, i, s, o) {
+ const a = o === "false", c = a ? !1 : Nh(r?.noteMode), l = Sp(e, t, c);
+ s && Wt(l, Pi, () => s);
const u = r?.isNoteShellEditable === !1;
let f, d;
- r?.markerMode === "editable" ? (f = Jt(e), u && f.setMode("token"), a || (d = Jt(e, "closing"), u && d.setMode("token"))) : r?.markerMode === "visible" && (f = Zr("marker", rt(e) + " "), a || (d = Zr("marker", pt(e))));
+ r?.markerMode === "editable" ? (f = Jt(e), u && f.setMode("token"), a || (d = Jt(e, "closing"), u && d.setMode("token"))) : r?.markerMode === "visible" && (f = ei("marker", it(e) + " "), a || (d = ei("marker", pt(e))));
let p;
if (f && l.append(f), r?.markerMode === "editable" && !c)
- p = Ue(qt(l.__caller)).toggleUnmergeable(), u && p.setMode("token"), l.append(p, ...n);
+ p = Be(qt(l.__caller)).toggleUnmergeable(), u && p.setMode("token"), l.append(p, ...n);
else {
- const m = () => ms(), h = n.flatMap(Ow(m));
+ const m = () => ms(), h = n.flatMap(qw(m));
if (t === "")
l.append(...h);
else {
- const g = Vp(n);
+ const g = Hp(n);
let y = () => {
};
- i?.noteCallerOnClick && (y = i.noteCallerOnClick), p = yh(l.__caller, g, y), l.append(p, m(), ...h);
+ i?.noteCallerOnClick && (y = i.noteCallerOnClick), p = kh(l.__caller, g, y), l.append(p, m(), ...h);
}
}
return d && l.append(d), l;
@@ -18282,7 +18282,7 @@ function Nr(e) {
const t = ee(e);
return K(t) ? t : void 0;
}
- return C1(e);
+ return M1(e);
}
function Nc(e, t) {
const n = t?.noteMode === "collapsed";
@@ -18299,29 +18299,29 @@ function Nc(e, t) {
} else {
const r = e.getChildren(), i = r.slice().reverse().find(z);
if (i)
- _w(i);
+ ww(i);
else {
- const s = wh(e), o = s === -1 ? r.length : s;
+ const s = Oh(e), o = s === -1 ? r.length : s;
e.select(o, o);
}
}
}
-function wh(e) {
+function Oh(e) {
const t = e.getChildrenSize() - 1, n = e.getLastChild();
- return $(n) && n.getMarkerSyntax() === "closing" || On(n) && n.getTextContent() === pt(e.getMarker()) ? t : -1;
+ return $(n) && n.getMarkerSyntax() === "closing" || $n(n) && n.getTextContent() === pt(e.getMarker()) ? t : -1;
}
-function _w(e) {
- const t = wh(e);
+function ww(e) {
+ const t = Oh(e);
if (t === -1) {
e.selectEnd();
return;
}
const n = e.getChildAtIndex(t - 1);
- T(n) && !Bn(n) ? n.selectEnd() : e.select(t, t);
+ C(n) && !Fn(n) ? n.selectEnd() : e.select(t, t);
}
-function qT(e, { isContentChange: t = !1 } = {}) {
+function UT(e, { isContentChange: t = !1 } = {}) {
const n = e.getNextSibling();
- if (T(n) && !Xa(n)) {
+ if (C(n) && !Xa(n)) {
n.select(0, 0);
return;
}
@@ -18329,20 +18329,20 @@ function qT(e, { isContentChange: t = !1 } = {}) {
if (!r)
return;
const i = e.getIndexWithinParent() + 1;
- r.canBeEmpty() ? r.select(i, i) : ou(r, i, { announce: !t });
+ r.canBeEmpty() ? r.select(i, i) : cu(r, i, { announce: !t });
}
-function ou(e, t, { announce: n = !0 } = {}) {
+function cu(e, t, { announce: n = !0 } = {}) {
const r = e.getChildAtIndex(t - 1);
if (!K(r) || r.getIsCollapsed() !== !0) {
e.select(t, t);
return;
}
const i = dr();
- i.anchor.set(e.getKey(), t, "element"), i.focus.set(e.getKey(), t, "element"), Mt(i), n && Pt().dispatchCommand(Nn, void 0);
+ i.anchor.set(e.getKey(), t, "element"), i.focus.set(e.getKey(), t, "element"), Mt(i), n && Pt().dispatchCommand(On, void 0);
}
-function Vm(e, t, n) {
- const r = Dt(e), i = Ew(e, r);
- if (n && KT(i, t, n, DT(e, r)))
+function Ym(e, t, n) {
+ const r = Dt(e), i = Nw(e, r);
+ if (n && zT(i, t, n, FT(e, r)))
return !0;
let s = Math.max(t, 0), o;
for (const { node: c, isGlyph: l, dataStart: u } of i) {
@@ -18360,16 +18360,16 @@ function Vm(e, t, n) {
const a = o.getTextContentSize();
return o.select(a, a), !0;
}
-function Ew(e, t) {
+function Nw(e, t) {
const n = [];
for (const { node: r } of $s(e))
- !T(r) || We(r, He) || (Nh(r, t) ? n.push({ node: r, isGlyph: !1, dataStart: $p(r) }) : Mw(r, e) && n.push({ node: r, isGlyph: !0, dataStart: 0 }));
+ !C(r) || We(r, He) || ($h(r, t) ? n.push({ node: r, isGlyph: !1, dataStart: Ip(r) }) : Ow(r, e) && n.push({ node: r, isGlyph: !0, dataStart: 0 }));
return n;
}
-function Mw(e, t) {
+function Ow(e, t) {
return bn(e) ? !0 : $(e) && !t.is(e.getParent());
}
-function DT(e, t) {
+function FT(e, t) {
return (n) => {
let r = n;
for (; !r.getPreviousSibling(); ) {
@@ -18379,11 +18379,11 @@ function DT(e, t) {
r = o;
}
const i = r.getPreviousSibling(), s = A(i) ? i.getLastDescendant() : i;
- if (T(s) && (t?.is(s) || Nh(s, t)))
+ if (C(s) && (t?.is(s) || $h(s, t)))
return s;
};
}
-function KT(e, t, n, r) {
+function zT(e, t, n, r) {
let i = 0, s = 0;
for (const { node: o, isGlyph: a, dataStart: c } of e) {
if (!a) {
@@ -18393,12 +18393,12 @@ function KT(e, t, n, r) {
continue;
}
if (i === t && s === n.index)
- return Pw(o, n.offset, r), !0;
+ return $w(o, n.offset, r), !0;
s += 1;
}
return !1;
}
-function Pw(e, t, n) {
+function $w(e, t, n) {
const r = e.getTextContentSize(), i = e.isToken() ? r : Math.min(Math.max(t, 0), r), s = i === 0 ? n(e) : void 0;
if (s) {
const o = s.getTextContentSize();
@@ -18406,73 +18406,73 @@ function Pw(e, t, n) {
} else
e.select(i, i);
}
-function Aw(e, t, n) {
+function Rw(e, t, n) {
const { opener: r, value: i, closer: s } = Ja(e);
if (!i)
return !1;
- const o = ww(i);
+ const o = Iw(i);
if (n) {
const c = [];
r && c.push({ node: r, isGlyph: !0, dataStart: 0 }), c.push({ node: i, isGlyph: !1, dataStart: o }), s && c.push({ node: s, isGlyph: !0, dataStart: 0 });
const l = Dt(e);
- if (KT(c, t, n, DT(e, l)))
+ if (zT(c, t, n, FT(e, l)))
return !0;
}
const a = Math.min(o + Math.max(t, 0), i.getTextContentSize());
return i.select(a, a), !0;
}
-function ww(e) {
- return e.getTextContent().startsWith(U) ? U.length : 0;
+function Iw(e) {
+ return e.getTextContent().startsWith(B) ? B.length : 0;
}
-function Nh(e, t) {
- return !T(e) || Bn(e) || Xa(e) ? !1 : !t || !e.is(t);
+function $h(e, t) {
+ return !C(e) || Fn(e) || Xa(e) ? !1 : !t || !e.is(t);
}
-function Nw(e) {
+function Lw(e) {
if (e.getIsCollapsed() !== !1 || e.getChildren().some(z))
return;
const t = Dt(e);
for (const { node: r } of $s(e))
- if (Nh(r, t))
+ if ($h(r, t))
return;
- const n = wh(e);
+ const n = Oh(e);
return n === -1 ? e.getChildrenSize() : n;
}
-function Ow(e) {
+function qw(e) {
return (t) => Yt(t) ? [t] : [t, e()];
}
-function $w(e) {
+function Dw(e) {
const t = e.getParent();
return t !== null && We(t, K) !== null;
}
-function Wm(e) {
+function Xm(e) {
if (!E(e))
return "";
const t = e.getNodes();
if (t.length === 0)
return "";
- const n = t[0], r = t[t.length - 1], i = e.anchor.isBefore(e.focus), [s, o] = up(e);
+ const n = t[0], r = t[t.length - 1], i = e.anchor.isBefore(e.focus), [s, o] = dp(e);
let a = "";
for (const c of t)
- if (!(K(c) || Ut(c) || $w(c)) && !$(c) && !bn(c) && Te(c, _e) !== "attribute") {
+ if (!(K(c) || Bt(c) || Dw(c)) && !$(c) && !bn(c) && Te(c, _e) !== "attribute") {
if (Oe(c)) {
a += `\\+fv ${c.getNumber()}\\+fv*`;
continue;
}
- if (T(c)) {
+ if (C(c)) {
let l = c.getTextContent();
c === n && c === r ? l = s < o ? l.slice(s, o) : l.slice(o, s) : c === n ? l = i ? l.slice(s) : l.slice(o) : c === r && (l = i ? l.slice(0, o) : l.slice(0, s)), a += l;
}
}
return a.replace(/[ \t\r\n\f\v]+/g, " ").trim();
}
-const au = [
+const lu = [
Dn,
sn,
- ...EA
-], Rw = [
- $o,
- ...au
-], Iw = Ri((e, t) => {
+ ...NA
+], Kw = [
+ Ro,
+ ...lu
+], Bw = Ii((e, t) => {
const { coords: n, children: r, style: i, ...s } = e, o = n !== void 0;
return O("div", { ref: t, className: "floating-box", "aria-hidden": !o, style: {
...i,
@@ -18484,14 +18484,14 @@ const au = [
opacity: o ? 1 : 0
}, ...s, children: r });
});
-function Lw() {
+function Uw() {
const [e, t] = ze(void 0), [n, r] = ze(), i = ae(null), s = Ke((a, c) => {
i.current && i.current();
const l = a.commonAncestorContainer.nodeType === a.commonAncestorContainer.TEXT_NODE ? a : a.commonAncestorContainer;
- i.current = z0(l, c, () => {
- j0(l, c, {
+ i.current = G0(l, c, () => {
+ J0(l, c, {
placement: "bottom-start",
- middleware: [V0(), W0()]
+ middleware: [Y0(), X0()]
}).then((u) => {
r(u.placement), t((f) => f?.x === u.x && f?.y === u.y ? f : { x: u.x, y: u.y });
}).catch(() => {
@@ -18503,8 +18503,8 @@ function Lw() {
}, []);
return J(() => o, [o]), { coords: e, placement: n, updatePosition: s, cleanup: o };
}
-function qw({ isOpen: e, floatingBoxRef: t }) {
- const { coords: n, updatePosition: r, cleanup: i, placement: s } = Lw();
+function Fw({ isOpen: e, floatingBoxRef: t }) {
+ const { coords: n, updatePosition: r, cleanup: i, placement: s } = Uw();
return J(() => {
if (!e || !t.current) {
i();
@@ -18518,26 +18518,26 @@ function qw({ isOpen: e, floatingBoxRef: t }) {
return r(o, t.current), i;
}, [i, e, t, r]), { coords: n, placement: s };
}
-const Dw = p0(Iw);
-function UT({ isOpen: e = !1, children: t }) {
- const n = ae(null), { coords: r, placement: i } = qw({ isOpen: e, floatingBoxRef: n }), s = bt(() => r ? typeof t == "function" ? t : () => t : () => null, [t, r]);
- return ns(
- O(Dw, { ref: n, coords: r, style: r ? void 0 : { display: "none" }, children: s({ isOpen: e, placement: i }) }),
+const zw = b0(Bw);
+function jT({ isOpen: e = !1, children: t }) {
+ const n = ae(null), { coords: r, placement: i } = Fw({ isOpen: e, floatingBoxRef: n }), s = kt(() => r ? typeof t == "function" ? t : () => t : () => null, [t, r]);
+ return rs(
+ O(zw, { ref: n, coords: r, style: r ? void 0 : { display: "none" }, children: s({ isOpen: e, placement: i }) }),
// Read at render rather than at module scope: this module sits in the import graph of the
// package's utility entry points, so touching `document` on load throws for any consumer that
// imports one of them outside a DOM environment (a Node-environment unit test, SSR).
document.body
);
}
-const FT = Wb(void 0);
-function Oh() {
- const e = Hb(FT);
+const VT = Xb(void 0);
+function Rh() {
+ const e = Qb(VT);
if (!e)
throw new Error("useMenuContext must be used within a MenuProvider");
return e;
}
-function Kw(e, t) {
- const [n, r] = ze(0), [i, s] = ze(-1), o = bt(() => e ?? [], [e]), a = {
+function jw(e, t) {
+ const [n, r] = ze(0), [i, s] = ze(-1), o = kt(() => e ?? [], [e]), a = {
menuItems: o,
activeIndex: n,
selectedIndex: i,
@@ -18569,22 +18569,22 @@ function Kw(e, t) {
setSelectedIndex: s
};
}
-function Uw({ children: e, menuItems: t, onSelectOption: n, ...r }) {
- const i = Kw(t, n);
- return O(FT.Provider, { value: i, children: O("div", { ...r, children: e }) });
+function Vw({ children: e, menuItems: t, onSelectOption: n, ...r }) {
+ const i = jw(t, n);
+ return O(VT.Provider, { value: i, children: O("div", { ...r, children: e }) });
}
-const BT = Ri(({ index: e, children: t, onMouseEnter: n, onClick: r, ...i }, s) => {
- const { state: { activeIndex: o }, setActiveIndex: a, setSelectedIndex: c, select: l } = Oh(), u = Ke((d) => {
+const WT = Ii(({ index: e, children: t, onMouseEnter: n, onClick: r, ...i }, s) => {
+ const { state: { activeIndex: o }, setActiveIndex: a, setSelectedIndex: c, select: l } = Rh(), u = Ke((d) => {
l(), c(-1), r?.(d);
}, [r, l, c]), f = Ke((d) => {
a(e), n?.(d);
}, [e, a, n]);
return O("button", { ref: s, role: "menuitem", ...i, onClick: u, onMouseEnter: f, "aria-selected": e !== void 0 && o === e ? "true" : void 0, tabIndex: -1, children: t });
});
-function Fw({ children: e, autoIndex: t = !0, ...n }) {
- const r = ae(null), { state: { activeIndex: i, menuItems: s } } = Oh(), o = bt(() => s ? typeof e == "function" ? e : () => e : () => null, [e, s]), a = bt(() => {
+function Ww({ children: e, autoIndex: t = !0, ...n }) {
+ const r = ae(null), { state: { activeIndex: i, menuItems: s } } = Rh(), o = kt(() => s ? typeof e == "function" ? e : () => e : () => null, [e, s]), a = kt(() => {
const c = o(s);
- return t ? h0.map(c, (l, u) => g0(l) && l.type === BT && l.props.index === void 0 ? m0(l, { index: u }) : l) : c;
+ return t ? k0.map(c, (l, u) => x0(l) && l.type === WT && l.props.index === void 0 ? T0(l, { index: u }) : l) : c;
}, [o, t, s]);
return J(() => {
if (r.current) {
@@ -18596,14 +18596,14 @@ function Fw({ children: e, autoIndex: t = !0, ...n }) {
}
}, [i]), O("div", { ref: r, role: "menu", ...n, children: a });
}
-const Bw = (e, t, n) => Oc(e, n).toLowerCase().includes(t.toLowerCase()), Hm = (e) => Object.keys(e).find((t) => typeof e[t] == "string") || "", Oc = (e, t) => {
+const Hw = (e, t, n) => Oc(e, n).toLowerCase().includes(t.toLowerCase()), Qm = (e) => Object.keys(e).find((t) => typeof e[t] == "string") || "", Oc = (e, t) => {
const n = e[t];
return typeof n == "string" ? n : String(n);
};
-function zw(e) {
+function Gw(e) {
const { query: t, items: n, filterBy: r, filter: i, sortBy: s, sortingOptions: o } = e, { caseSensitive: a = !1, priorityOrder: c = ["exact", "startsWith", "contains"] } = o || {}, l = a ? t : t.toLowerCase();
let u, f;
- i ? (f = i, u = n.length > 0 ? Hm(n[0]) : "") : (u = r || (n.length > 0 ? Hm(n[0]) : ""), f = (m, h) => Bw(m, h, u));
+ i ? (f = i, u = n.length > 0 ? Qm(n[0]) : "") : (u = r || (n.length > 0 ? Qm(n[0]) : ""), f = (m, h) => Hw(m, h, u));
const d = s || u, p = /* @__PURE__ */ new Map();
return n.filter((m) => {
try {
@@ -18612,9 +18612,9 @@ function zw(e) {
return console.warn("Error filtering item:", m, h), !1;
}
}).sort((m, h) => {
- const g = (C) => (p.has(C) || p.set(C, Oc(C, d).toLowerCase()), p.get(C) ?? ""), y = a ? Oc(m, d) : g(m), b = a ? Oc(h, d) : g(h);
- for (const C of c)
- switch (C) {
+ const g = (T) => (p.has(T) || p.set(T, Oc(T, d).toLowerCase()), p.get(T) ?? ""), y = a ? Oc(m, d) : g(m), b = a ? Oc(h, d) : g(h);
+ for (const T of c)
+ switch (T) {
case "exact":
if (y === l && b !== l)
return -1;
@@ -18641,14 +18641,14 @@ function zw(e) {
return y.localeCompare(b);
});
}
-const rf = {
- Root: Uw,
- Options: Fw,
- Option: BT
+const af = {
+ Root: Vw,
+ Options: Ww,
+ Option: WT
};
-function jw(e) {
+function Jw(e) {
const { query: t, items: n, filterBy: r, filter: i, sortBy: s, sortingOptions: o } = e;
- return bt(() => zw({
+ return kt(() => Gw({
query: t,
items: n,
filterBy: r,
@@ -18657,16 +18657,16 @@ function jw(e) {
sortingOptions: o
}), [t, n, r, i, s, o]);
}
-function Vw() {
- const { moveUp: e, moveDown: t, select: n } = Oh();
- return bt(() => ({
+function Yw() {
+ const { moveUp: e, moveDown: t, select: n } = Rh();
+ return kt(() => ({
moveUp: e,
moveDown: t,
select: n
}), [e, t, n]);
}
-const Ww = () => {
- const e = Vw(), [t] = Pe();
+const Xw = () => {
+ const e = Yw(), [t] = Pe();
J(() => {
const n = (r) => {
const s = {
@@ -18680,31 +18680,31 @@ const Ww = () => {
return t.registerCommand(Jn, n, Je);
}, [t, e]);
};
-function Hw() {
- return Ww(), null;
+function Qw() {
+ return Xw(), null;
}
-const Gw = ["Shift", "Control", "Alt", "Meta"];
-function zT(e) {
- const { options: t, onSelectOption: n, onClose: r, inverse: i, query: s, menuOpenKey: o, onFilterChange: a, passthroughKeys: c } = e, [l] = Pe(), u = s !== void 0, [f, d] = ze(""), p = u ? s ?? "" : f, m = jw({ query: p, items: t, filterBy: "name" }), h = (g) => {
+const Zw = ["Shift", "Control", "Alt", "Meta"];
+function HT(e) {
+ const { options: t, onSelectOption: n, onClose: r, inverse: i, query: s, menuOpenKey: o, onFilterChange: a, passthroughKeys: c } = e, [l] = Pe(), u = s !== void 0, [f, d] = ze(""), p = u ? s ?? "" : f, m = Jw({ query: p, items: t, filterBy: "name" }), h = (g) => {
r?.(), n ? n(g) : g.action(l);
};
return J(() => {
a?.(p, m);
}, [a, p, m]), J(() => l.registerCommand(Jn, (g) => {
- if (u || c?.includes(g.key) || Gw.includes(g.key))
+ if (u || c?.includes(g.key) || Zw.includes(g.key))
return !1;
if ((g.ctrlKey || g.metaKey || g.altKey) && !g.getModifierState("AltGraph"))
return r?.(), !1;
const b = {
Escape: () => r?.(),
Backspace: () => {
- p.length === 0 ? r?.() : d((C) => C.slice(0, -1));
+ p.length === 0 ? r?.() : d((T) => T.slice(0, -1));
}
}[g.key];
- return b ? (g.stopPropagation(), g.preventDefault(), b(), !0) : g.key.length === 1 ? (g.stopPropagation(), g.preventDefault(), g.key !== o && d((C) => C + g.key), !0) : !1;
- }, Je), [l, u, p, o, r, c]), ut(rf.Root, { className: `autocomplete-menu-container ${i ? "inverse" : ""}`, menuItems: m, onSelectOption: (g) => h(g), children: [!u && O("input", { value: p, type: "text", disabled: !0 }), O(Hw, {}), O(rf.Options, { className: "autocomplete-menu-options", autoIndex: !1, children: (g) => g.map((b, C) => ut(rf.Option, { index: C, children: [O("span", { className: "label", children: b.label ?? b.name }), O("span", { className: "description", children: b.description })] }, b.name)) })] });
+ return b ? (g.stopPropagation(), g.preventDefault(), b(), !0) : g.key.length === 1 ? (g.stopPropagation(), g.preventDefault(), g.key !== o && d((T) => T + g.key), !0) : !1;
+ }, Je), [l, u, p, o, r, c]), ft(af.Root, { className: `autocomplete-menu-container ${i ? "inverse" : ""}`, menuItems: m, onSelectOption: (g) => h(g), children: [!u && O("input", { value: p, type: "text", disabled: !0 }), O(Qw, {}), O(af.Options, { className: "autocomplete-menu-options", autoIndex: !1, children: (g) => g.map((b, T) => ft(af.Option, { index: T, children: [O("span", { className: "label", children: b.label ?? b.name }), O("span", { className: "description", children: b.description })] }, b.name)) })] });
}
-function Jw({ trigger: e, items: t }) {
+function eN({ trigger: e, items: t }) {
const [n] = Pe(), [r, i] = ze(!1), s = Ke((o) => {
o.key === "Escape" && r ? (i(!1), n.focus()) : o.key === e && !r && (o.preventDefault(), i(!0));
}, [n, e, r]);
@@ -18723,10 +18723,10 @@ function Jw({ trigger: e, items: t }) {
const l = M();
!E(l) || c?.is(l) || i(!1);
});
- }), [n]), t && O(UT, { isOpen: r, children: ({ placement: o }) => O(zT, { options: t, onClose: () => i(!1), inverse: o === "top-start", menuOpenKey: e }) });
+ }), [n]), t && O(jT, { isOpen: r, children: ({ placement: o }) => O(HT, { options: t, onClose: () => i(!1), inverse: o === "top-start", menuOpenKey: e }) });
}
-function Yw({ scriptureReference: e, contextMarker: t, getMarkerAction: n }) {
- return { markersMenuItems: bt(() => {
+function tN({ scriptureReference: e, contextMarker: t, getMarkerAction: n }) {
+ return { markersMenuItems: kt(() => {
if (!t || !e)
return;
const i = Rr(t);
@@ -18744,9 +18744,9 @@ function Yw({ scriptureReference: e, contextMarker: t, getMarkerAction: n }) {
}));
}, [t, n, e]) };
}
-function Xw(e, t) {
+function nN(e, t) {
const n = Ls(e);
- if (Er(e) || ai(e)) {
+ if (Er(e) || ci(e)) {
const o = 1 + e.getMarker().length + 1, a = e.getNumber();
if (e.getShowMarker())
return t < o + a.length ? t : void 0;
@@ -18755,20 +18755,20 @@ function Xw(e, t) {
const c = n.indexOf(a);
return c < 0 ? "drawn" : c + t - o;
}
- const r = Gl(e), i = r.length - r.trimStart().length, s = r.trim().length;
+ const r = Yl(e), i = r.length - r.trimStart().length, s = r.trim().length;
if (!(t >= s))
return r === n ? i + t : "drawn";
}
-function Qw() {
+function rN() {
return typeof CSS > "u" || typeof Highlight > "u" || !("highlights" in CSS) ? void 0 : { registry: CSS.highlights, create: () => new Highlight() };
}
-const Gm = /* @__PURE__ */ new Map(), Zw = ["background-color", "color", "text-shadow"], eN = [
+const Zm = /* @__PURE__ */ new Map(), iN = ["background-color", "color", "text-shadow"], sN = [
"text-decoration-line",
"text-decoration-style",
"text-decoration-color",
"text-decoration-thickness"
-], tN = /* @__PURE__ */ new Set(["solid", "double", "dotted", "dashed", "wavy"]);
-function nN(e, t) {
+], oN = /* @__PURE__ */ new Set(["solid", "double", "dotted", "dashed", "wavy"]);
+function aN(e, t) {
const n = e.ownerDocument.defaultView;
if (!n)
return [];
@@ -18776,7 +18776,7 @@ function nN(e, t) {
const f = r.getPropertyValue(u);
return f && f !== i.getPropertyValue(u) ? f : void 0;
}, o = [];
- for (const u of Zw) {
+ for (const u of iN) {
const f = s(u);
f && o.push(`${u}: ${f}`);
}
@@ -18785,7 +18785,7 @@ function nN(e, t) {
if (a) {
if (a !== "none" && s("text-decoration-line")) {
c = !0;
- for (const u of eN) {
+ for (const u of sN) {
const f = s(u);
f && o.push(`${u}: ${f}`);
}
@@ -18796,7 +18796,7 @@ function nN(e, t) {
}
const l = s("border-bottom-style");
if (!c && l && l !== "none") {
- o.push("text-decoration-line: underline", `text-decoration-style: ${tN.has(l) ? l : "solid"}`);
+ o.push("text-decoration-line: underline", `text-decoration-style: ${oN.has(l) ? l : "solid"}`);
const u = r.getPropertyValue("border-bottom-color");
u && o.push(`text-decoration-color: ${u}`);
const f = r.getPropertyValue("border-bottom-width");
@@ -18804,12 +18804,12 @@ function nN(e, t) {
}
return o;
}
-const rN = Math.random().toString(36).slice(2, 10);
-let iN = 0;
-class sN {
+const cN = Math.random().toString(36).slice(2, 10);
+let lN = 0;
+class uN {
api;
probeParent;
- prefix = `editor-annotation-${rN}-${iN++}`;
+ prefix = `editor-annotation-${cN}-${lN++}`;
byClassSet = /* @__PURE__ */ new Map();
byLeaf = /* @__PURE__ */ new Map();
nextName = 0;
@@ -18854,8 +18854,8 @@ class sN {
* paints it with that class set; a class set no piece uses any more is unregistered. */
release(t, n) {
for (const r of t) {
- const i = sf(r.classNames), s = this.byClassSet.get(i);
- !s || (n.some((a) => a.range === r.range && sf(a.classNames) === i) || s.highlight.delete(r.range), --s.uses > 0) || (this.api.registry.delete(s.name), Gm.delete(s.name), this.byClassSet.delete(i), this.queueRender());
+ const i = cf(r.classNames), s = this.byClassSet.get(i);
+ !s || (n.some((a) => a.range === r.range && cf(a.classNames) === i) || s.highlight.delete(r.range), --s.uses > 0) || (this.api.registry.delete(s.name), Zm.delete(s.name), this.byClassSet.delete(i), this.queueRender());
}
}
dispose() {
@@ -18864,11 +18864,11 @@ class sN {
this.disposed = !0, this.observer?.disconnect(), this.style?.remove(), this.probes?.remove();
}
use(t) {
- const n = sf(t);
+ const n = cf(t);
let r = this.byClassSet.get(n);
if (!r) {
const i = `${this.prefix}-${this.nextName++}`, s = this.api.create();
- s.priority = this.nextName, r = { name: i, classNames: t, highlight: s, uses: 0 }, this.byClassSet.set(n, r), this.api.registry.set(i, s), Gm.set(i, t), this.queueRender();
+ s.priority = this.nextName, r = { name: i, classNames: t, highlight: s, uses: 0 }, this.byClassSet.set(n, r), this.api.registry.set(i, s), Zm.set(i, t), this.queueRender();
}
return r.uses++, r;
}
@@ -18901,7 +18901,7 @@ class sN {
}
r.append(...s.map(([, c]) => c));
for (const [c, l] of s)
- this.measured.set(c, nN(l, i));
+ this.measured.set(c, aN(l, i));
const o = [];
for (const [c, { name: l }] of this.byClassSet) {
const u = this.measured.get(c) ?? [];
@@ -18912,14 +18912,14 @@ class sN {
r.replaceChildren();
const a = o.join(`
`);
- this.style?.isConnected || (this.style = n.createElement("style"), this.style.setAttribute(jT, this.prefix), n.head.append(this.style)), this.style.textContent !== a && (this.style.textContent = a);
+ this.style?.isConnected || (this.style = n.createElement("style"), this.style.setAttribute(GT, this.prefix), n.head.append(this.style)), this.style.textContent !== a && (this.style.textContent = a);
}
/**
* Whether any style rule's selector names one of `classNames`. Errs toward yes: a substring match
* counts, and every class set counts while any rule cannot be read.
*/
isNamedByRule(t, n) {
- this.rules || (this.rules = uN(VT(t)), this.ruleCounts = Jm(t));
+ this.rules || (this.rules = gN(JT(t)), this.ruleCounts = ey(t));
const { selectors: r, unreadable: i } = this.rules;
return i || n.some((s) => r.includes(s) || r.includes(s.replace(/[^\w-]/g, "\\$&")));
}
@@ -18933,7 +18933,7 @@ class sN {
if (this.disposed || this.ruleCounts === void 0)
return;
const t = this.probeParent()?.ownerDocument;
- !t || Jm(t) === this.ruleCounts || this.forgetStyles();
+ !t || ey(t) === this.ruleCounts || this.forgetStyles();
}
forgetStyles() {
this.measured.clear(), this.rules = void 0, this.ruleCounts = void 0, this.queueRender();
@@ -18948,10 +18948,10 @@ class sN {
return;
this.observer = new n.MutationObserver((i) => {
const s = (o) => {
- if (pd(o.target))
+ if (md(o.target))
return !0;
const a = [...o.addedNodes, ...o.removedNodes];
- return a.length > 0 && a.every(pd);
+ return a.length > 0 && a.every(md);
};
i.every(s) || this.forgetStyles();
}), this.observer.observe(t.head, { childList: !0, characterData: !0, subtree: !0 });
@@ -18959,22 +18959,22 @@ class sN {
this.observer.observe(t.documentElement, r), t.body && this.observer.observe(t.body, r);
}
}
-const jT = "data-editor-annotation-highlights";
-function pd(e) {
+const GT = "data-editor-annotation-highlights";
+function md(e) {
for (let t = e; t; t = t.parentNode)
- if (oN(t) && t.hasAttribute(jT))
+ if (fN(t) && t.hasAttribute(GT))
return !0;
return !1;
}
-function oN(e) {
+function fN(e) {
return e.nodeType === e.ELEMENT_NODE;
}
-function VT(e) {
+function JT(e) {
const t = "adoptedStyleSheets" in e ? e.adoptedStyleSheets : [];
- return [...e.styleSheets, ...t].filter((n) => !n.ownerNode || !pd(n.ownerNode));
+ return [...e.styleSheets, ...t].filter((n) => !n.ownerNode || !md(n.ownerNode));
}
-function Jm(e) {
- return VT(e).map((t) => {
+function ey(e) {
+ return JT(e).map((t) => {
try {
return t.cssRules.length;
} catch {
@@ -18982,16 +18982,16 @@ function Jm(e) {
}
}).join(",");
}
-function aN(e) {
+function dN(e) {
return "cssRules" in e;
}
-function cN(e) {
+function pN(e) {
return "styleSheet" in e;
}
-function lN(e) {
+function hN(e) {
return "selectorText" in e && typeof e.selectorText == "string";
}
-function uN(e) {
+function gN(e) {
const t = [];
let n = !1;
const r = (i) => {
@@ -19003,17 +19003,17 @@ function uN(e) {
return;
}
for (const o of s)
- lN(o) && t.push(o.selectorText), cN(o) && (o.styleSheet ? r(o.styleSheet) : n = !0), aN(o) && r(o);
+ hN(o) && t.push(o.selectorText), pN(o) && (o.styleSheet ? r(o.styleSheet) : n = !0), dN(o) && r(o);
};
for (const i of e)
r(i);
return { selectors: t.join(`
`), unreadable: n };
}
-function sf(e) {
+function cf(e) {
return JSON.stringify([...e].sort());
}
-function Ym(e, t, n) {
+function ty(e, t, n) {
const r = e.ownerDocument, i = r.createTreeWalker(e, NodeFilter.SHOW_TEXT), s = r.createRange();
let o = 0, a = !1;
for (let c = i.nextNode(); c; c = i.nextNode()) {
@@ -19023,34 +19023,34 @@ function Ym(e, t, n) {
o += l;
}
}
-function fN(e, t, n) {
+function mN(e, t, n) {
return "getClientRects" in e ? Array.from(e.getClientRects()).some((r) => t >= r.left && t <= r.right && n >= r.top && n <= r.bottom) : !1;
}
-function WT(e) {
- return T(e) ? e.getTextContent() : Ls(e);
+function YT(e) {
+ return C(e) ? e.getTextContent() : Ls(e);
}
function ca(e) {
- return WT(e).length;
+ return YT(e).length;
}
-function dN(e, t) {
- if (T(e)) {
+function yN(e, t) {
+ if (C(e)) {
if (an(e))
return !0;
- if (Xp(e)) {
- const [i, s] = Qp(e);
+ if (Zp(e)) {
+ const [i, s] = eh(e);
return t < i || t >= s;
}
- return t < No(e);
+ return t < Oo(e);
}
- const [n, r] = Jl(Ls(e));
+ const [n, r] = Xl(Ls(e));
return t < n || t >= r;
}
-function of(e) {
+function lf(e) {
for (let t = e.getParent(); t; t = t.getParent())
if (A(t) && !t.isInline())
return t.getKey();
}
-function pN(e) {
+function bN(e) {
let t = e;
for (; A(t); ) {
const n = t.getFirstChild();
@@ -19060,37 +19060,37 @@ function pN(e) {
}
return t;
}
-function Xm(e) {
+function ny(e) {
for (let t = e; t; t = t.getParent()) {
const n = t.getNextSibling();
if (n)
- return pN(n);
+ return bN(n);
}
}
-function HT(e) {
- return A(e) ? e.getChildren().flatMap(HT) : [e];
+function XT(e) {
+ return A(e) ? e.getChildren().flatMap(XT) : [e];
}
-const hN = 64;
-function gN(e, t) {
+const kN = 64;
+function xN(e, t) {
const n = /* @__PURE__ */ new Map(), r = (o, a, c) => {
for (let l = a; l < c; l++)
- if (!dN(o, l))
+ if (!yN(o, l))
return !1;
return c > a && n.set(o.getKey(), [a, c]), !0;
};
if (e.leaf.is(t.leaf))
return r(e.leaf, e.end, t.start) ? n : void 0;
- const i = of(e.leaf);
- if (i !== of(t.leaf) || !r(e.leaf, e.end, ca(e.leaf)))
+ const i = lf(e.leaf);
+ if (i !== lf(t.leaf) || !r(e.leaf, e.end, ca(e.leaf)))
return;
- let s = Xm(e.leaf);
- for (let o = 0; s && !s.is(t.leaf); o++, s = Xm(s))
- if (o >= hN || of(s) !== i || on(s) && ca(s) === 0 || !r(s, 0, ca(s)))
+ let s = ny(e.leaf);
+ for (let o = 0; s && !s.is(t.leaf); o++, s = ny(s))
+ if (o >= kN || lf(s) !== i || on(s) && ca(s) === 0 || !r(s, 0, ca(s)))
return;
if (s)
return r(t.leaf, 0, t.start) ? n : void 0;
}
-function mN(e) {
+function TN(e) {
const t = [...e].sort(([r], [i]) => r - i), n = [];
for (const [r, i] of t) {
const s = n[n.length - 1];
@@ -19098,12 +19098,12 @@ function mN(e) {
}
return n;
}
-function yN(e, t, n, r) {
+function CN(e, t, n, r) {
const i = [];
for (const a of n) {
const c = ee(a);
if (c?.isAttached())
- for (const l of Gr(c)) {
+ for (const l of Jr(c)) {
if (l.type !== e || l.id !== t || l.undisplayed)
continue;
const u = l.start === l.end;
@@ -19117,8 +19117,8 @@ function yN(e, t, n, r) {
}
for (const a of r) {
const c = ee(a);
- if (!(!ge(c) || !c.isAttached()))
- for (const l of HT(c))
+ if (!(!me(c) || !c.isAttached()))
+ for (const l of XT(c))
i.push({ leaf: l, start: 0, end: ca(l), inMark: !0 });
}
i.sort((a, c) => a.leaf.is(c.leaf) ? a.start - c.start : a.leaf.isBefore(c.leaf) ? -1 : 1);
@@ -19130,14 +19130,14 @@ function yN(e, t, n, r) {
a.inMark || o(a.leaf.getKey(), a.start, a.end);
const l = i[c + 1];
if (l)
- for (const [u, [f, d]] of gN(a, l) ?? [])
+ for (const [u, [f, d]] of xN(a, l) ?? [])
o(u, f, d);
});
for (const [a, c] of s)
- s.set(a, mN(c));
+ s.set(a, TN(c));
return s;
}
-function bN(e, t) {
+function vN(e, t) {
const n = [...t.values()];
if (e === 0 || n.every((o) => o.length === 1 && o[0][0] <= 0 && o[0][1] >= e))
return { whole: !0 };
@@ -19152,61 +19152,61 @@ function bN(e, t) {
}
return { whole: !1, segments: s };
}
-const kN = "display-annotation", xN = [
- it,
+const SN = "display-annotation", _N = [
+ at,
Yn,
Lt,
- hr,
+ gr,
Dn,
sn,
Qn,
_r
-], GT = /* @__PURE__ */ new Set();
+], QT = /* @__PURE__ */ new Set();
function ir(e, t) {
return JSON.stringify([e, t]);
}
-function TN(e) {
+function EN(e) {
return Array.isArray(e) && e.length === 2 && typeof e[0] == "string" && typeof e[1] == "string";
}
-function jo(e) {
+function Vo(e) {
const t = JSON.parse(e);
- if (!TN(t))
+ if (!EN(t))
throw new Error(`not an annotation index key: ${e}`);
return t;
}
-function JT(e) {
- Wt(e, Hl, void 0), A(e) && e.getChildren().forEach(JT);
+function ZT(e) {
+ Wt(e, Jl, void 0), A(e) && e.getChildren().forEach(ZT);
}
-const af = /* @__PURE__ */ new WeakMap();
-function CN(e) {
- UP({
- holdableText: ew,
- renderedOffset: Xw
+const uf = /* @__PURE__ */ new WeakMap();
+function MN(e) {
+ VP({
+ holdableText: sw,
+ renderedOffset: nN
});
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
let c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
- const u = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakSet(), d = new AbortController(), p = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set();
+ const u = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakSet(), d = new AbortController(), p = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Set();
let x, _ = !1;
- const F = Qw(), R = F ? new sN(F, () => e.getRootElement()?.parentElement ?? null) : void 0;
- let W = /* @__PURE__ */ new Set();
+ const U = rN(), I = U ? new uN(U, () => e.getRootElement()?.parentElement ?? null) : void 0;
+ let V = /* @__PURE__ */ new Set();
const ce = e._config.theme;
function se(L) {
return (t.get(L)?.size ?? 0) + (r.get(L)?.size ?? 0);
}
- function Y(L, V, Z) {
- let te = L.get(V);
- te || L.set(V, te = /* @__PURE__ */ new Set()), te.add(Z);
+ function Y(L, W, Z) {
+ let te = L.get(W);
+ te || L.set(W, te = /* @__PURE__ */ new Set()), te.add(Z);
}
- function be(L, V, Z) {
- const te = L.get(V);
- te?.delete(Z) && (te.size === 0 && L.delete(V), se(V) === 0 && W.add(V));
+ function be(L, W, Z) {
+ const te = L.get(W);
+ te?.delete(Z) && (te.size === 0 && L.delete(W), se(W) === 0 && V.add(W));
}
function Se(L) {
- for (const [V, Z] of Object.entries(L.getTypedIDs()))
+ for (const [W, Z] of Object.entries(L.getTypedIDs()))
for (const te of Z)
- Fe(ir(V, te), V, te);
+ Ue(ir(W, te), W, te);
}
- function Fe(L, V, Z) {
+ function Ue(L, W, Z) {
const te = /* @__PURE__ */ new Set([
...r.get(L) ?? [],
...t.get(L) ?? []
@@ -19215,26 +19215,26 @@ function CN(e) {
if (ve.length === 0)
return;
ve.sort((le, pe) => le.isBefore(pe) ? -1 : 1);
- const de = ve.map((le) => ge(le) ? le.getTextContent() : Gr(le).filter((pe) => pe.type === V && pe.id === Z).map((pe) => Zf(le, pe)).join("")).join("");
+ const de = ve.map((le) => me(le) ? le.getTextContent() : Jr(le).filter((pe) => pe.type === W && pe.id === Z).map((pe) => nd(le, pe)).join("")).join("");
o.set(L, de);
}
- function I(L, V, Z) {
- return h.get(L)?.has(V) ? y.has(L) ? !0 : (R?.leafHighlights(L) ?? []).some((te) => te.annotations.includes(V) && fN(te.range, Z.clientX, Z.clientY)) : !1;
+ function R(L, W, Z) {
+ return h.get(L)?.has(W) ? y.has(L) ? !0 : (I?.leafHighlights(L) ?? []).some((te) => te.annotations.includes(W) && mN(te.range, Z.clientX, Z.clientY)) : !1;
}
- function q(L, V) {
+ function q(L, W) {
const Z = /* @__PURE__ */ new Map();
- for (const te of Gr(L)) {
+ for (const te of Jr(L)) {
const ve = ir(te.type, te.id);
- Z.has(ve) || !I(L.getKey(), ve, V) || Z.set(ve, { annotation: te, text: Zf(L, te) });
+ Z.has(ve) || !R(L.getKey(), ve, W) || Z.set(ve, { annotation: te, text: nd(L, te) });
}
return Z;
}
- function j(L, V, Z) {
+ function j(L, W, Z) {
e.getEditorState().read(() => {
const te = qr(L);
if (!te)
return;
- const ve = Z === "leave" ? /* @__PURE__ */ new Map() : q(te, V), de = (pe, { annotation: xe, text: st }) => Zc(e, xe.type, xe.id)?.[pe]?.(V, xe.type, xe.id, st);
+ const ve = Z === "leave" ? /* @__PURE__ */ new Map() : q(te, W), de = (pe, { annotation: xe, text: ct }) => tl(e, xe.type, xe.id)?.[pe]?.(W, xe.type, xe.id, ct);
if (Z === "onClick") {
ve.forEach((pe) => de("onClick", pe));
return;
@@ -19248,112 +19248,112 @@ function CN(e) {
}, { editor: e });
}
function ne(L) {
- const V = {}, Z = /* @__PURE__ */ new Set();
+ const W = {}, Z = /* @__PURE__ */ new Set();
for (const te of L) {
- const [ve, de] = jo(te), le = V[ve] ??= [];
+ const [ve, de] = Vo(te), le = W[ve] ??= [];
le.includes(de) || le.push(de), b.get(te)?.forEach((pe) => Z.add(pe));
}
- return Object.keys(V).length === 0 ? [] : [
- ...Sk(ce, V),
- kN,
+ return Object.keys(W).length === 0 ? [] : [
+ ...Ak(ce, W),
+ SN,
...Z
].flatMap((te) => te.match(/\S+/g) ?? []);
}
- function N(L, V) {
+ function N(L, W) {
const Z = u.get(L) ?? [];
- _c(L, ...Z.filter((te) => !V.includes(te))), Zo(L, ...V), u.set(L, V);
+ _c(L, ...Z.filter((te) => !W.includes(te))), ea(L, ...W), u.set(L, W);
}
function X(L) {
if (f.has(L))
return;
f.add(L);
- const { signal: V } = d;
- L.addEventListener("click", (Z) => j(L, Z, "onClick"), { signal: V }), L.addEventListener("mouseenter", (Z) => j(L, Z, "move"), { signal: V }), L.addEventListener("mousemove", (Z) => j(L, Z, "move"), { signal: V }), L.addEventListener("mouseleave", (Z) => j(L, Z, "leave"), {
- signal: V
+ const { signal: W } = d;
+ L.addEventListener("click", (Z) => j(L, Z, "onClick"), { signal: W }), L.addEventListener("mouseenter", (Z) => j(L, Z, "move"), { signal: W }), L.addEventListener("mousemove", (Z) => j(L, Z, "move"), { signal: W }), L.addEventListener("mouseleave", (Z) => j(L, Z, "leave"), {
+ signal: W
});
}
function oe(L) {
- const V = ee(L), Z = e.getElementByKey(L), te = h.get(L), ve = g.get(L);
- if (ve && ve !== Z && N(ve, []), C.delete(L), !V || !Z || !te || te.size === 0) {
- Z && N(Z, []), R?.clearLeaf(L), g.delete(L), y.delete(L);
+ const W = ee(L), Z = e.getElementByKey(L), te = h.get(L), ve = g.get(L);
+ if (ve && ve !== Z && N(ve, []), T.delete(L), !W || !Z || !te || te.size === 0) {
+ Z && N(Z, []), I?.clearLeaf(L), g.delete(L), y.delete(L);
return;
}
g.set(L, Z);
- const de = new Map([...te].map((et) => [
- et,
- m.get(et)?.get(L) ?? []
- ])), le = Gr(V).length > 0, pe = WT(V);
- let xe = bN(pe.length, de);
- if (!xe.whole && !R && (xe = le ? { whole: !0 } : { whole: !1, segments: [] }), le && X(Z), xe.whole) {
- R?.clearLeaf(L), y.add(L), N(Z, ne(te));
+ const de = new Map([...te].map((tt) => [
+ tt,
+ m.get(tt)?.get(L) ?? []
+ ])), le = Jr(W).length > 0, pe = YT(W);
+ let xe = vN(pe.length, de);
+ if (!xe.whole && !I && (xe = le ? { whole: !0 } : { whole: !1, segments: [] }), le && X(Z), xe.whole) {
+ I?.clearLeaf(L), y.add(L), N(Z, ne(te));
return;
}
- if (y.delete(L), N(Z, []), !R)
+ if (y.delete(L), N(Z, []), !I)
return;
- const st = [];
- for (const { start: et, end: tn, annotations: Bt } of xe.segments) {
- const er = Ym(Z, et, tn);
- er ? st.push({
- classNames: ne(Bt),
- annotations: Bt,
+ const ct = [];
+ for (const { start: tt, end: tn, annotations: Ft } of xe.segments) {
+ const er = ty(Z, tt, tn);
+ er ? ct.push({
+ classNames: ne(Ft),
+ annotations: Ft,
range: er,
- text: pe.slice(et, tn)
- }) : C.add(L);
+ text: pe.slice(tt, tn)
+ }) : T.add(L);
}
- R.setLeaf(L, st);
+ I.setLeaf(L, ct);
}
- function me(L) {
- if (C.has(L))
+ function he(L) {
+ if (T.has(L))
return !0;
- const V = e.getElementByKey(L);
- return (R?.leafHighlights(L) ?? []).some(({ range: Z, text: te }) => !V || !V.contains(Z.startContainer) || !V.contains(Z.endContainer) || Z.toString() !== te);
+ const W = e.getElementByKey(L);
+ return (I?.leafHighlights(L) ?? []).some(({ range: Z, text: te }) => !W || !W.contains(Z.startContainer) || !W.contains(Z.endContainer) || Z.toString() !== te);
}
function ie() {
- return [...C, ...R?.leafKeys() ?? []].filter(me);
+ return [...T, ...I?.leafKeys() ?? []].filter(he);
}
- function B() {
+ function F() {
_ || e.getEditorState().read(() => new Set(ie()).forEach(oe), { editor: e });
}
function ue(L) {
x?.disconnect(), x = void 0;
- const V = L?.ownerDocument.defaultView;
- !L || !V || !R || (x = new V.MutationObserver(B), x.observe(L, { childList: !0, characterData: !0, subtree: !0 }));
+ const W = L?.ownerDocument.defaultView;
+ !L || !W || !I || (x = new W.MutationObserver(F), x.observe(L, { childList: !0, characterData: !0, subtree: !0 }));
}
function we(L) {
- const V = /* @__PURE__ */ new Set();
+ const W = /* @__PURE__ */ new Set();
for (const te of L)
- h.has(te) && V.add(te);
+ h.has(te) && W.add(te);
const Z = /* @__PURE__ */ new Set([...t.keys(), ...m.keys()]);
for (const [te, ve] of r)
ve.size >= 2 && Z.add(te);
for (const te of Z) {
- const [ve, de] = jo(te), le = yN(ve, de, t.get(te) ?? [], r.get(te) ?? []), pe = m.get(te) ?? /* @__PURE__ */ new Map();
+ const [ve, de] = Vo(te), le = CN(ve, de, t.get(te) ?? [], r.get(te) ?? []), pe = m.get(te) ?? /* @__PURE__ */ new Map();
for (const xe of /* @__PURE__ */ new Set([...pe.keys(), ...le.keys()]))
- JSON.stringify(pe.get(xe)) !== JSON.stringify(le.get(xe)) && V.add(xe);
+ JSON.stringify(pe.get(xe)) !== JSON.stringify(le.get(xe)) && W.add(xe);
for (const xe of pe.keys()) {
if (le.has(xe))
continue;
- const st = h.get(xe);
- st?.delete(te), st?.size === 0 && h.delete(xe);
+ const ct = h.get(xe);
+ ct?.delete(te), ct?.size === 0 && h.delete(xe);
}
for (const xe of le.keys()) {
- let st = h.get(xe);
- st || h.set(xe, st = /* @__PURE__ */ new Set()), st.add(te);
+ let ct = h.get(xe);
+ ct || h.set(xe, ct = /* @__PURE__ */ new Set()), ct.add(te);
}
le.size > 0 ? m.set(te, le) : m.delete(te);
}
for (const [te, ve] of g)
- e.getElementByKey(te) !== ve && V.add(te);
+ e.getElementByKey(te) !== ve && W.add(te);
for (const te of ie())
- V.add(te);
- for (const te of V)
+ W.add(te);
+ for (const te of W)
oe(te);
}
function $e(L) {
_ || e.getEditorState().read(() => we(L), { editor: e });
}
- function mt(L, V) {
- const Z = ir(L, V), te = [], ve = (de) => {
+ function yt(L, W) {
+ const Z = ir(L, W), te = [], ve = (de) => {
const le = de.ownerDocument.createRange();
le.selectNodeContents(de), te.push(le);
};
@@ -19364,140 +19364,140 @@ function CN(e) {
for (const [de, le] of m.get(Z) ?? []) {
const pe = e.getElementByKey(de);
if (pe) {
- if (y.has(de) || !R) {
+ if (y.has(de) || !I) {
ve(pe);
continue;
}
- for (const [xe, st] of le) {
- const et = Ym(pe, xe, st);
- et && te.push(et);
+ for (const [xe, ct] of le) {
+ const tt = ty(pe, xe, ct);
+ tt && te.push(tt);
}
}
}
return te.sort((de, le) => de.compareBoundaryPoints(Range.START_TO_START, le));
}
- function At(L, V, Z, te) {
- const ve = ir(L, V), de = b.get(ve) ?? /* @__PURE__ */ new Set();
+ function At(L, W, Z, te) {
+ const ve = ir(L, W), de = b.get(ve) ?? /* @__PURE__ */ new Set();
de.has(Z) !== te && (te ? de.add(Z) : de.delete(Z), de.size > 0 ? b.set(ve, de) : b.delete(ve), $e(m.get(ve)?.keys() ?? []));
}
- function Ft(L) {
+ function Ut(L) {
e.getEditorState().read(() => {
- const V = /* @__PURE__ */ new Set();
+ const W = /* @__PURE__ */ new Set();
for (const [Z, te] of L) {
- const ve = te === "destroyed" ? null : ee(Z), de = ve ? Gr(ve) : [], le = n.get(Z) ?? [];
+ const ve = te === "destroyed" ? null : ee(Z), de = ve ? Jr(ve) : [], le = n.get(Z) ?? [];
for (const { type: pe, id: xe } of le) {
- const st = ir(pe, xe);
- V.add(st), de.some((et) => et.type === pe && et.id === xe) || be(t, st, Z);
+ const ct = ir(pe, xe);
+ W.add(ct), de.some((tt) => tt.type === pe && tt.id === xe) || be(t, ct, Z);
}
for (const pe of de) {
const xe = ir(pe.type, pe.id);
- V.add(xe), Y(t, xe, Z);
+ W.add(xe), Y(t, xe, Z);
}
de.length > 0 ? n.set(Z, de) : n.delete(Z);
for (let pe = ve?.getParent(); pe; pe = pe.getParent())
- ge(pe) && Se(pe);
+ me(pe) && Se(pe);
}
- for (const Z of V) {
- const [te, ve] = jo(Z);
- Fe(Z, te, ve);
+ for (const Z of W) {
+ const [te, ve] = Vo(Z);
+ Ue(Z, te, ve);
}
}, { editor: e });
}
function cn(L) {
e.getEditorState().read(() => {
- for (const [V, Z] of L) {
- const te = Z === "destroyed" ? null : ee(V), ve = ge(te) ? te : void 0, de = ve ? Object.entries(ve.getTypedIDs()) : [], le = de.flatMap(([xe, st]) => st.map((et) => ir(xe, et)));
- for (const xe of i.get(V) ?? [])
- le.includes(xe) || (be(r, xe, V), ve || l.set(xe, [...l.get(xe) ?? [], V]));
+ for (const [W, Z] of L) {
+ const te = Z === "destroyed" ? null : ee(W), ve = me(te) ? te : void 0, de = ve ? Object.entries(ve.getTypedIDs()) : [], le = de.flatMap(([xe, ct]) => ct.map((tt) => ir(xe, tt)));
+ for (const xe of i.get(W) ?? [])
+ le.includes(xe) || (be(r, xe, W), ve || l.set(xe, [...l.get(xe) ?? [], W]));
for (const xe of le)
- Y(r, xe, V);
- if (le.length > 0 ? i.set(V, le) : i.delete(V), !ve)
+ Y(r, xe, W);
+ if (le.length > 0 ? i.set(W, le) : i.delete(W), !ve)
continue;
Se(ve);
const pe = ve.getTypedOnRemoves();
- for (const [xe, st] of de)
- for (const et of st) {
- const tn = pe[xe]?.[et];
- tn && s.set(ir(xe, et), tn);
+ for (const [xe, ct] of de)
+ for (const tt of ct) {
+ const tn = pe[xe]?.[tt];
+ tn && s.set(ir(xe, tt), tn);
}
}
});
}
- function Xe(L, V, Z) {
- Bx(e, V, Z), s.delete(L), o.delete(L);
+ function Qe(L, W, Z) {
+ Wx(e, W, Z), s.delete(L), o.delete(L);
}
function fe() {
- for (const [L, V] of FE(e))
- Ne(L, V);
+ for (const [L, W] of WE(e))
+ Ne(L, W);
}
- function Ne(L, V) {
- const Z = ir(L, V);
+ function Ne(L, W) {
+ const Z = ir(L, W);
a.add(Z), c.add(Z);
}
function Ui() {
- a.clear(), BE(e);
+ a.clear(), HE(e);
for (const L of /* @__PURE__ */ new Set([...s.keys(), ...o.keys()])) {
if (se(L) > 0)
continue;
- const [V, Z] = jo(L);
- Xe(L, V, Z);
+ const [W, Z] = Vo(L);
+ Qe(L, W, Z);
}
}
- function Qe({ tags: L }) {
+ function Ze({ tags: L }) {
fe();
- const V = W, Z = c, te = l;
- if (W = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), L.has(Va)) {
+ const W = V, Z = c, te = l;
+ if (V = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), L.has(Va)) {
Ui();
return;
}
- if (L.has(Ll))
+ if (L.has(Dl))
return;
const ve = [];
- for (const de of V) {
+ for (const de of W) {
if (se(de) > 0)
continue;
- const [le, pe] = jo(de), xe = Zc(e, le, pe)?.onRemove ?? s.get(de), st = o.get(de) ?? "";
- if (Xe(de, le, pe), !(!xe || a.has(de) || Z.has(de))) {
- a.add(de), sm(e, le, pe, !0);
- for (const et of te.get(de) ?? [])
- zE(et, le, pe);
+ const [le, pe] = Vo(de), xe = tl(e, le, pe)?.onRemove ?? s.get(de), ct = o.get(de) ?? "";
+ if (Qe(de, le, pe), !(!xe || a.has(de) || Z.has(de))) {
+ a.add(de), um(e, le, pe, !0);
+ for (const tt of te.get(de) ?? [])
+ GE(tt, le, pe);
try {
- xe(le, pe, "destroyed", st);
- } catch (et) {
- ve.push(et);
+ xe(le, pe, "destroyed", ct);
+ } catch (tt) {
+ ve.push(tt);
}
}
}
for (const de of ve)
queueMicrotask(() => e._onError(de instanceof Error ? de : new Error(String(de))));
}
- function Zn(L, V) {
+ function Zn(L, W) {
fe();
- const Z = ir(L, V);
- a.delete(Z), sm(e, L, V, !1);
+ const Z = ir(L, W);
+ a.delete(Z), um(e, L, W, !1);
}
- const Ze = Ye(
- ...xN.filter((L) => e.hasNodes([L])).map((L) => e.registerMutationListener(L, Ft, { skipInitialization: !1 })),
+ const et = Xe(
+ ..._N.filter((L) => e.hasNodes([L])).map((L) => e.registerMutationListener(L, Ut, { skipInitialization: !1 })),
e.hasNodes([vt]) ? e.registerMutationListener(vt, cn, {
skipInitialization: !1
}) : () => {
},
- UE(e),
- e.registerUpdateListener(Qe),
- WP(e, [sn, Dn]),
- e.registerUpdateListener(({ dirtyLeaves: L, dirtyElements: V }) => {
- R?.noticeStylesheetChanges(), !(L.size === 0 && V.size === 0) && ($e([...L, ...V.keys()]), x?.takeRecords());
+ VE(e),
+ e.registerUpdateListener(Ze),
+ XP(e, [sn, Dn]),
+ e.registerUpdateListener(({ dirtyLeaves: L, dirtyElements: W }) => {
+ I?.noticeStylesheetChanges(), !(L.size === 0 && W.size === 0) && ($e([...L, ...W.keys()]), x?.takeRecords());
}),
// Also paints what the mutation listeners above found already in the document.
e.registerRootListener((L) => {
ue(L), L && $e([...h.keys()]);
}),
() => {
- _ = !0, d.abort(), R?.dispose(), x?.disconnect();
+ _ = !0, d.abort(), I?.dispose(), x?.disconnect();
},
e.registerCommand(
- T0,
- ({ nodes: L }) => (L.forEach(JT), !1),
+ E0,
+ ({ nodes: L }) => (L.forEach(ZT), !1),
// Critical, and never handling the command, so a handler that does handle it cannot skip the
// strip.
ye
@@ -19505,38 +19505,38 @@ function CN(e) {
);
return {
index: {
- keysFor: (L, V) => t.get(ir(L, V)) ?? GT,
+ keysFor: (L, W) => t.get(ir(L, W)) ?? QT,
noteSet: Zn,
noteReported: Ne,
- hasReported: (L, V) => (fe(), a.has(ir(L, V))),
+ hasReported: (L, W) => (fe(), a.has(ir(L, W))),
setStateClass: At,
- rangesFor: mt
+ rangesFor: yt
},
references: 0,
- unregister: Ze
+ unregister: et
};
}
-function vN(e) {
- let t = af.get(e);
- t || (t = CN(e), af.set(e, t)), t.references++;
+function PN(e) {
+ let t = uf.get(e);
+ t || (t = MN(e), uf.set(e, t)), t.references++;
const n = t;
let r = !1;
return {
index: n.index,
release: () => {
- r || (r = !0, n.references--, !(n.references > 0) && (n.unregister(), af.delete(e)));
+ r || (r = !0, n.references--, !(n.references > 0) && (n.unregister(), uf.delete(e)));
}
};
}
-function YT(e) {
+function eC(e) {
const t = ae(void 0);
- return Po(() => {
- const n = vN(e);
+ return Ao(() => {
+ const n = PN(e);
return t.current = n.index, () => {
t.current = void 0, n.release();
};
- }, [e]), bt(() => ({
- keysFor: (n, r) => t.current?.keysFor(n, r) ?? GT,
+ }, [e]), kt(() => ({
+ keysFor: (n, r) => t.current?.keysFor(n, r) ?? QT,
noteSet: (n, r) => t.current?.noteSet(n, r),
noteReported: (n, r) => t.current?.noteReported(n, r),
setStateClass: (n, r, i, s) => t.current?.setStateClass(n, r, i, s),
@@ -19547,12 +19547,12 @@ function YT(e) {
function la(e, t) {
return `${e}:${t}`;
}
-function SN(e, t) {
+function AN(e, t) {
J(() => {
if (!e.hasNodes([vt]))
throw new Error("AnnotationPlugin: TypedMarkNode not registered on editor!");
const n = /* @__PURE__ */ new Map();
- return Ye(gp(e, vt, (r) => us(r.getTypedIDs(), r.getTypedOnClicks(), r.getTypedOnRemoves(), r.getTypedOnMouseEnters(), r.getTypedOnMouseLeaves()), (r, i) => {
+ return Xe(yp(e, vt, (r) => fs(r.getTypedIDs(), r.getTypedOnClicks(), r.getTypedOnRemoves(), r.getTypedOnMouseEnters(), r.getTypedOnMouseLeaves()), (r, i) => {
const s = r.getTypedOnClicks(), o = r.getTypedOnRemoves(), a = r.getTypedOnMouseEnters(), c = r.getTypedOnMouseLeaves();
for (const [l, u] of Object.entries(r.getTypedIDs()))
u.forEach((f) => {
@@ -19565,7 +19565,7 @@ function SN(e, t) {
for (const [i, s] of r) {
const o = ee(i);
let a = {};
- s === "destroyed" ? a = n.get(i) ?? {} : ge(o) && (a = o.getTypedIDs());
+ s === "destroyed" ? a = n.get(i) ?? {} : me(o) && (a = o.getTypedIDs());
for (const [c, l] of Object.entries(a))
if (!vt.isReservedType(c))
for (const u of l) {
@@ -19577,20 +19577,20 @@ function SN(e, t) {
}, { skipInitialization: !0 }));
}, [e, t]);
}
-const _N = Ri(function({ logger: t, viewOptions: n }, r) {
- const [i] = Pe(), s = bt(() => /* @__PURE__ */ new Map(), []);
- SN(i, s);
- const o = YT(i), a = (c, l, u) => {
- const f = Array.from(u ?? s.get(la(c, l)) ?? []), d = _k(c, l, f), p = [];
+const wN = Ii(function({ logger: t, viewOptions: n }, r) {
+ const [i] = Pe(), s = kt(() => /* @__PURE__ */ new Map(), []);
+ AN(i, s);
+ const o = eC(i), a = (c, l, u) => {
+ const f = Array.from(u ?? s.get(la(c, l)) ?? []), d = wk(c, l, f), p = [];
for (const h of Array.from(o.keysFor(c, l))) {
const g = ee(h);
if (!g)
continue;
- const y = Gr(g).filter((b) => b.type === c && b.id === l);
- Fx(g, c, l) && p.push(...y.map((b) => Zf(g, b)));
+ const y = Jr(g).filter((b) => b.type === c && b.id === l);
+ Vx(g, c, l) && p.push(...y.map((b) => nd(g, b)));
}
- const m = Zc(i, c, l);
- if (Bx(i, c, l), p.length > 0 && m && d === 0 && !o.hasReported(c, l)) {
+ const m = tl(i, c, l);
+ if (Wx(i, c, l), p.length > 0 && m && d === 0 && !o.hasReported(c, l)) {
o.noteReported(c, l);
try {
m.onRemove?.(c, l, "removed", p.join(""));
@@ -19599,7 +19599,7 @@ const _N = Ri(function({ logger: t, viewOptions: n }, r) {
}
}
};
- return Rl(r, () => ({
+ return Ll(r, () => ({
setAnnotation(c, l, u, f, d, p, m) {
if (vt.isReservedType(l))
throw new Error(`setAnnotation: Can't directly set this reserved annotation type '${l}'. Use the appropriate plugin instead.`);
@@ -19620,8 +19620,8 @@ const _N = Ri(function({ logger: t, viewOptions: n }, r) {
t?.error("Failed to find start or end node of the annotation.");
return;
}
- sh(y, l, u, f, d, p, m, { decoratorHolds: g });
- }, { tag: Df });
+ ah(y, l, u, f, d, p, m, { decoratorHolds: g });
+ }, { tag: Uf });
},
removeAnnotation(c, l) {
if (vt.isReservedType(c))
@@ -19629,70 +19629,70 @@ const _N = Ri(function({ logger: t, viewOptions: n }, r) {
const u = s.get(la(c, l));
(u === void 0 || u.size === 0) && o.keysFor(c, l).size === 0 || i.update(() => {
a(c, l, u);
- }, { tag: Df });
+ }, { tag: Uf });
},
getAnnotationRanges(c, l) {
return o.rangesFor(c, l);
}
})), null;
});
-function EN({ dirtyElements: e, dirtyLeaves: t, prevEditorState: n, tags: r }, i) {
+function NN({ dirtyElements: e, dirtyLeaves: t, prevEditorState: n, tags: r }, i) {
return e.size === 0 && t.size === 0 || // A `MARKER_SETTLE_TAG` commit carries the merge tag only to stay out of the undo
// stack — its bytes really did change, so it must reach `onChange` like any edit.
// Without this exemption the cached USJ and the emitted delta both keep showing the
// pre-settle bytes, and the host saves a document the editor is no longer displaying.
- r.has(ma) && !r.has(pk) || i.ignoreTags.some((s) => r.has(s)) || n.isEmpty();
+ r.has(ma) && !r.has(bk) || i.ignoreTags.some((s) => r.has(s)) || n.isEmpty();
}
-function MN(e, { dirtyLeaves: t, prevEditorState: n }) {
- let r = new Qi();
+function ON(e, { dirtyLeaves: t, prevEditorState: n }) {
+ let r = new Zi();
return e.getEditorState().read(() => {
const i = t.values().next().value ?? "", s = ee(i), o = s !== null && hn(s) !== void 0;
- if (t.size === 1 && T(s) && !o && Rm(s)) {
- const a = hh(s);
+ if (t.size === 1 && C(s) && !o && Km(s)) {
+ const a = mh(s);
if (a !== void 0) {
const c = n.read(() => {
const f = ee(i);
- return !T(f) || eu(f, "delta-doc") === 0 ? new Qi([{ insert: "" }]) : Rm(f) ? new Qi([ad(f)]) : void 0;
+ return !C(f) || nu(f, "delta-doc") === 0 ? new Zi([{ insert: "" }]) : Km(f) ? new Zi([ud(f)]) : void 0;
});
if (!c) {
- r = Qm(e, n);
+ r = ry(e, n);
return;
}
- const l = new Qi([ad(s)]), u = new Qi(a > 0 ? [{ retain: a }] : []);
+ const l = new Zi([ud(s)]), u = new Zi(a > 0 ? [{ retain: a }] : []);
r = r.concat(u).concat(c.diff(l));
}
} else
- r = Qm(e, n);
+ r = ry(e, n);
}), r.ops;
}
-function Qm(e, t) {
- return Im(t).diff(Im(e.getEditorState()));
+function ry(e, t) {
+ return Bm(t).diff(Bm(e.getEditorState()));
}
-function PN(e, t, n, r) {
+function $N(e, t, n, r) {
let i = 0;
e.forEach((s) => {
if ("retain" in s)
- i += AN(s, i, t, r);
+ i += RN(s, i, t, r);
else if ("delete" in s) {
if (typeof s.delete != "number" || s.delete <= 0) {
r?.error(`Invalid delete operation: ${JSON.stringify(s)}`);
return;
}
- r?.debug(`Delete: ${s.delete}`), NN(i, s.delete, r);
- } else "insert" in s ? typeof s.insert == "string" ? (r?.debug(`Insert: '${s.insert}'`), i += ON(i, s.insert, s.attributes, t, r)) : typeof s.insert == "object" && s.insert !== null ? (r?.debug(`Insert embed: ${JSON.stringify(s.insert)}`), RN(i, s, t, n, r) ? i += 1 : r?.error(`Failed to process insert embed operation: ${JSON.stringify(s.insert)} at index ${i}. Document may be inconsistent.`)) : r?.error(`Insert of unknown type: ${JSON.stringify(s.insert)}`) : r?.error(`Unknown operation: ${JSON.stringify(s)}`);
+ r?.debug(`Delete: ${s.delete}`), LN(i, s.delete, r);
+ } else "insert" in s ? typeof s.insert == "string" ? (r?.debug(`Insert: '${s.insert}'`), i += qN(i, s.insert, s.attributes, t, r)) : typeof s.insert == "object" && s.insert !== null ? (r?.debug(`Insert embed: ${JSON.stringify(s.insert)}`), KN(i, s, t, n, r) ? i += 1 : r?.error(`Failed to process insert embed operation: ${JSON.stringify(s.insert)} at index ${i}. Document may be inconsistent.`)) : r?.error(`Insert of unknown type: ${JSON.stringify(s.insert)}`) : r?.error(`Unknown operation: ${JSON.stringify(s)}`);
});
}
-function AN(e, t, n, r) {
- return typeof e.retain != "number" || e.retain < 0 ? (r?.error(`Invalid retain operation: ${JSON.stringify(e)}`), 0) : (r?.debug(`Retain: ${e.retain}`), e.attributes && (r?.debug(`Retain attributes: ${JSON.stringify(e.attributes)}`), wN(t, e.retain, e.attributes, n, r)), e.retain);
+function RN(e, t, n, r) {
+ return typeof e.retain != "number" || e.retain < 0 ? (r?.error(`Invalid retain operation: ${JSON.stringify(e)}`), 0) : (r?.debug(`Retain: ${e.retain}`), e.attributes && (r?.debug(`Retain attributes: ${JSON.stringify(e.attributes)}`), IN(t, e.retain, e.attributes, n, r)), e.retain);
}
-function wN(e, t, n, r, i) {
+function IN(e, t, n, r, i) {
i?.debug(`Applying attributes for range [${e}, ${e + t - 1}] with attributes: ${JSON.stringify(n)}`);
let s = t, o = 0, a = -1;
const c = Me();
function l(u) {
if (s <= 0)
return !0;
- if (ni(u)) {
+ if (ri(u)) {
const f = u.getTextContentSize();
if (e < o + f && o < e + t) {
const d = Math.max(0, e - o), p = f - d, m = Math.min(s, p);
@@ -19703,43 +19703,43 @@ function wN(e, t, n, r, i) {
const [, b] = u.splitText(d);
[h] = b.splitText(m);
} else g ? [, h] = u.splitText(d) : y && ([h] = u.splitText(m));
- if (Pi(n)) {
+ if (wi(n)) {
const b = h.getParent();
if (z(b)) {
- const C = n.char;
+ const T = n.char;
let x;
- Array.isArray(C) ? a >= 0 && a <= C.length - 1 && (x = C[a]) : a === 0 && (x = C);
+ Array.isArray(T) ? a >= 0 && a <= T.length - 1 && (x = T[a]) : a === 0 && (x = T);
const _ = x ? gs(x, b) : !1;
- if (_ && Array.isArray(C) && C.length > 1) {
- const F = Ue("");
- h.replace(F);
- const R = typeof n.segment == "string" ? n.segment : void 0, W = Ro(C.slice(1), r, h, R);
- let ce = F;
- for (const se of W)
+ if (_ && Array.isArray(T) && T.length > 1) {
+ const U = Be("");
+ h.replace(U);
+ const I = typeof n.segment == "string" ? n.segment : void 0, V = Io(T.slice(1), r, h, I);
+ let ce = U;
+ for (const se of V)
ce.insertAfter(se), ce = se;
- F.remove(), ar(n, h);
+ U.remove(), ar(n, h);
} else if (_)
ar(n, h);
else {
h.remove();
- const F = Zm(h, n, r, i);
- if (F && F.length > 0) {
- let R = b;
- for (const W of F)
- R.insertAfter(W), R = W;
+ const U = iy(h, n, r, i);
+ if (U && U.length > 0) {
+ let I = b;
+ for (const V of U)
+ I.insertAfter(V), I = V;
}
}
} else {
- const C = Ue("");
- h.replace(C);
- const x = Zm(h, n, r, i);
+ const T = Be("");
+ h.replace(T);
+ const x = iy(h, n, r, i);
if (x && x.length > 0) {
- let _ = C;
- for (const F of x)
- _.insertAfter(F), _ = F;
- C.remove();
+ let _ = T;
+ for (const U of x)
+ _.insertAfter(U), _ = U;
+ T.remove();
} else
- C.replace(h);
+ T.replace(h);
}
} else
ar(n, h);
@@ -19748,34 +19748,34 @@ function wN(e, t, n, r, i) {
}
o += f;
} else if (jn(u))
- e <= o && o < e + t && s > 0 && (ey(u, n), s -= 1), o += 1;
+ e <= o && o < e + t && s > 0 && (sy(u, n), s -= 1), o += 1;
else if (z(u)) {
a += 1;
let f = !1;
if (e <= o && o < e + t && s > 0)
- if (Pi(n)) {
+ if (wi(n)) {
const d = n.char;
let p;
if (Array.isArray(d) ? a >= 0 && a <= d.length - 1 && (p = d[a]) : a === 0 && (p = d), p) {
- hd(u, p.style), typeof p.cid == "string" && Wt(u, ds, () => p.cid);
- const m = Ct(p, rl);
+ yd(u, p.style), typeof p.cid == "string" && Wt(u, ps, () => p.cid);
+ const m = Ct(p, sl);
m && Object.keys(m).length > 0 ? u.setUnknownAttributes({
...u.getUnknownAttributes() ?? {},
...m
}) : u.setUnknownAttributes(void 0);
}
- } else (n.char === !1 || n.char === null || zN(n.char)) && (f = !0);
+ } else (n.char === !1 || n.char === null || GN(n.char)) && (f = !0);
if (s > 0) {
const d = u.getChildren();
for (const p of d) {
if (s <= 0)
break;
if (l(p) && s <= 0)
- return f && Lf(u), !0;
+ return f && Kf(u), !0;
}
}
- f && Lf(u), a -= 1;
- } else if (ct(u)) {
+ f && Kf(u), a -= 1;
+ } else if (st(u)) {
const f = u.getChildren();
for (const p of f) {
if (s <= 0)
@@ -19785,10 +19785,10 @@ function wN(e, t, n, r, i) {
}
const d = 1;
if (e <= o && o < e + s && s > 0) {
- if (!kt(u))
- ey(u, n);
- else if ($h(n)) {
- const p = ZT(n.para, r);
+ if (!ht(u))
+ sy(u, n);
+ else if (Ih(n)) {
+ const p = rC(n.para, r);
p && u.replace(p, !0);
}
s -= d;
@@ -19807,14 +19807,14 @@ function wN(e, t, n, r, i) {
}
l(c), s > 0 && i?.warn(`$applyAttributes: Not all characters in the retain operation (length ${t}) could be processed. Remaining: ${s}. targetIndex: ${e}, final currentIndex: ${o}`);
}
-function Zm(e, t, n, r) {
- const i = typeof t.segment == "string" ? t.segment : void 0, s = Ro(t.char, n, e, i), o = s.find(z);
+function iy(e, t, n, r) {
+ const i = typeof t.segment == "string" ? t.segment : void 0, s = Io(t.char, n, e, i), o = s.find(z);
if (!o) {
r?.error(`Failed to create CharNode for text transformation. Style: ${Array.isArray(t.char) ? t.char[0].style : t.char?.style}. Falling back to standard text attributes.`), ar(t, e);
return;
}
const a = {};
- rC.forEach((u) => {
+ aC.forEach((u) => {
e.hasFormat(u) && (a[u] = "true");
});
const c = {};
@@ -19828,12 +19828,12 @@ function Zm(e, t, n, r) {
};
return Object.keys(l).length > 0 && o.setUnknownAttributes(l), ar(t, e), s;
}
-function XT(e, t) {
+function tC(e, t) {
e.setMarker(t);
const n = e.getFirstChild();
- $(n) ? (n.setMarker(t), n.setTextContent(rt(t))) : Yt(n) && n.getTextType() === "marker" && n.setTextContent(rt(t) + U);
+ $(n) ? (n.setMarker(t), n.setTextContent(it(t))) : Yt(n) && n.getTextType() === "marker" && n.setTextContent(it(t) + B);
}
-function hd(e, t) {
+function yd(e, t) {
const n = e.getMarker();
if (e.setMarker(t), t === n)
return;
@@ -19841,36 +19841,36 @@ function hd(e, t) {
$(o) && o.getMarker() === n && o.setMarker(t);
});
const r = z(e.getParent()), i = e.getFirstChild();
- Yt(i) && i.getTextType() === "marker" && i.getTextContent() === rt(n, r) && i.setTextContent(rt(t, r));
+ Yt(i) && i.getTextType() === "marker" && i.getTextContent() === it(n, r) && i.setTextContent(it(t, r));
const s = e.getLastChild();
Yt(s) && s.getTextType() === "marker" && s.getTextContent() === pt(n, r) && s.setTextContent(pt(t, r));
}
-function ey(e, t) {
+function sy(e, t) {
for (const n of Object.keys(t)) {
const r = t[n];
- if (n === "char" && z(e) && Pi(t)) {
- const i = gd(r);
- if (hd(e, i.style), typeof i.cid == "string") {
+ if (n === "char" && z(e) && wi(t)) {
+ const i = bd(r);
+ if (yd(e, i.style), typeof i.cid == "string") {
const o = i.cid;
- Wt(e, ds, () => o);
+ Wt(e, ps, () => o);
}
- const s = Ct(i, rl);
+ const s = Ct(i, sl);
s && Object.keys(s).length > 0 && e.setUnknownAttributes({
...e.getUnknownAttributes() ?? {},
...s
});
continue;
}
- typeof r == "string" && (ot(e) || Oe(e) || Ve(e) || K(e) || Ie(e) ? e.setUnknownAttributes({
+ typeof r == "string" && (Ye(e) || Oe(e) || Ve(e) || K(e) || Ie(e) ? e.setUnknownAttributes({
...e.getUnknownAttributes() ?? {},
[n]: r
- }) : (qe(e) || ke(e) || z(e)) && (n === "style" && ke(e) ? XT(e, r) : n === "style" && z(e) ? hd(e, r) : n === "code" && qe(e) ? e.setCode(r) : e.setUnknownAttributes({
+ }) : (qe(e) || ke(e) || z(e)) && (n === "style" && ke(e) ? tC(e, r) : n === "style" && z(e) ? yd(e, r) : n === "code" && qe(e) ? e.setCode(r) : e.setUnknownAttributes({
...e.getUnknownAttributes() ?? {},
[n]: r
- })), n === "segment" && Wt(e, Mi, () => r));
+ })), n === "segment" && Wt(e, Pi, () => r));
}
}
-function NN(e, t, n) {
+function LN(e, t, n) {
if (t <= 0)
return;
const r = Me();
@@ -19878,7 +19878,7 @@ function NN(e, t, n) {
function o(a) {
if (s <= 0)
return !0;
- if (ni(a)) {
+ if (ri(a)) {
let c = a.getTextContentSize();
if (e < i + c && i < e + s) {
const l = Math.max(0, e - i), u = c - l, f = Math.min(s, u);
@@ -19887,7 +19887,7 @@ function NN(e, t, n) {
i += c;
} else if (jn(a))
e <= i && i < e + s ? (a.remove(), n?.debug(`Deleted embed node (key: ${a.getKey()}) at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`), s -= 1) : i += 1;
- else if (ct(a)) {
+ else if (st(a)) {
const c = a.getChildren().slice(), l = a.getChildren();
for (const u of l) {
if (s <= 0)
@@ -19895,14 +19895,14 @@ function NN(e, t, n) {
if (o(u) && s <= 0)
return !0;
}
- if (e <= i && i < e + s && ct(a)) {
+ if (e <= i && i < e + s && st(a)) {
s -= 1;
const u = a.getChildren().length;
if (c.length > 0 && u === 0)
- (a.getParent()?.getChildren() ?? []).length > 1 ? (a.remove(), n?.debug(`Removed entire ParaNode that had all its content deleted at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`)) : (a.replace(qn(), !0), n?.debug(`Replaced last ParaNode with ImpliedParaNode at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`));
+ (a.getParent()?.getChildren() ?? []).length > 1 ? (a.remove(), n?.debug(`Removed entire ParaNode that had all its content deleted at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`)) : (a.replace(En(), !0), n?.debug(`Replaced last ParaNode with ImpliedParaNode at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`));
else if (s > 0) {
const p = a.getNextSibling();
- if (p && dt(p)) {
+ if (p && ot(p)) {
let m = i + 1;
const h = p.getChildren();
for (const y of h) {
@@ -19913,15 +19913,15 @@ function NN(e, t, n) {
i = b;
break;
}
- ni(y) ? m += y.getTextContentSize() : jn(y) && (m += 1), i = b;
+ ri(y) ? m += y.getTextContentSize() : jn(y) && (m += 1), i = b;
}
const g = p.getChildren();
for (const y of g)
y.remove(), a.append(y);
p.remove(), n?.debug(`Merged next paragraph into current one after deleting symbolic close at currentIndex: ${i}. Original targetIndex: ${e}, remainingToDelete: ${s}.`);
} else
- a.replace(qn(), !0);
- } else ke(a) ? a.replace(qn(), !0) : a.remove();
+ a.replace(En(), !0);
+ } else ke(a) ? a.replace(En(), !0) : a.remove();
}
i += 1;
} else if (A(a)) {
@@ -19937,47 +19937,47 @@ function NN(e, t, n) {
}
o(r), s > 0 && n?.warn(`Delete operation could not remove all requested characters. Remaining to delete: ${s}. Original targetIndex: ${e}, OT length: ${t}. Final currentIndex: ${i}`);
}
-function ON(e, t, n, r, i) {
+function qN(e, t, n, r, i) {
if (t === Pa)
- return ty(e, n, r, i);
- if (t.endsWith(Pa) && !$h(n)) {
+ return oy(e, n, r, i);
+ if (t.endsWith(Pa) && !Ih(n)) {
const s = t.slice(0, -1);
let o = 0;
if (s.length > 0) {
- if (Pi(n))
+ if (wi(n))
throw new Error("Text + LF should not have char attributes");
- o += ol(e, s, n, i);
+ o += cl(e, s, n, i);
}
- return o += ty(e + o, n, r, i), o;
- } else return Pi(n) ? $N(e, t, n, r, i) : ol(e, t, n, i);
+ return o += oy(e + o, n, r, i), o;
+ } else return wi(n) ? DN(e, t, n, r, i) : cl(e, t, n, i);
}
-function $N(e, t, n, r, i) {
+function DN(e, t, n, r, i) {
i?.debug(`Attempting to insert CharNode with text "${t}" and attributes ${JSON.stringify(n.char)} at index ${e}`);
- const s = Ue(t === "" ? It : t);
+ const s = Be(t === "" ? It : t);
ar(n, s);
let o;
{
let g = function(y) {
- if (ni(y)) {
+ if (ri(y)) {
const b = y.getTextContentSize();
if (e >= h && e < h + b) {
- const C = y.getParent();
- return z(C) && (o = C), !0;
+ const T = y.getParent();
+ return z(T) && (o = T), !0;
}
h += b;
} else if (jn(y))
h += 1;
else if (z(y)) {
const b = y.getChildren();
- for (const C of b)
- if (g(C))
+ for (const T of b)
+ if (g(T))
return !0;
} else if (A(y)) {
const b = y.getChildren();
- for (const C of b)
- if (g(C))
+ for (const T of b)
+ if (g(T))
return !0;
- ct(y) && (h += 1);
+ st(y) && (h += 1);
}
return !1;
};
@@ -19992,25 +19992,25 @@ function $N(e, t, n, r, i) {
m && gs(m, o) ? (a = a.slice(1), a.length === 1 && (a = a[0])) : o = void 0;
}
} else o && (gs(a, o) || (o = void 0));
- const c = typeof n.segment == "string" ? n.segment : void 0, u = Ro(a, r, s, c, o ? [o] : void 0);
+ const c = typeof n.segment == "string" ? n.segment : void 0, u = Io(a, r, s, c, o ? [o] : void 0);
if (u.length === 0)
return t.length;
const f = u.find(z);
if (!f)
- return i?.error(`CharNode style is missing for text "${t}". Attributes: ${JSON.stringify(n.char)}. Falling back to rich text insertion.`), ol(e, t, void 0, i);
+ return i?.error(`CharNode style is missing for text "${t}". Attributes: ${JSON.stringify(n.char)}. Falling back to rich text insertion.`), cl(e, t, void 0, i);
const d = {};
for (const [m, h] of Object.entries(n))
m !== "char" && m !== "segment" && typeof h == "string" && (d[m] = h);
Object.keys(d).length > 0 && f.setUnknownAttributes(d);
let p = !0;
for (const m of u)
- if (!QT(e, m, i)) {
+ if (!nC(e, m, i)) {
p = !1;
break;
}
- return p ? t.length : (i?.error(`Failed to insert CharNode with text "${t}" at index ${e}. Falling back to rich text.`), ol(e, t, void 0, i));
+ return p ? t.length : (i?.error(`Failed to insert CharNode with text "${t}" at index ${e}. Falling back to rich text.`), cl(e, t, void 0, i));
}
-function ol(e, t, n, r) {
+function cl(e, t, n, r) {
if (t.length <= 0)
return r?.debug("Attempted to insert empty string. No action taken."), 0;
const i = Me();
@@ -20018,15 +20018,15 @@ function ol(e, t, n, r) {
function a(c) {
if (o)
return !0;
- if (ni(c)) {
+ if (ri(c)) {
const l = c.getTextContentSize();
if (e >= s && e <= s + l) {
- const u = e - s, f = Ue(t);
+ const u = e - s, f = Be(t);
if (ar(n, f), u === 0)
c.insertBefore(f);
else if (u === l) {
const d = c.getParent();
- z(d) && !Pi(n) ? d.insertAfter(f) : c.insertAfter(f);
+ z(d) && !wi(n) ? d.insertAfter(f) : c.insertAfter(f);
} else {
const [, d] = c.splitText(u);
d.insertBefore(f);
@@ -20038,7 +20038,7 @@ function ol(e, t, n, r) {
s += 1;
else if (z(c)) {
if (!o && e === s) {
- const f = Ue(t);
+ const f = Be(t);
ar(n, f);
const d = c.getFirstChild();
return d ? d.insertBefore(f) : c.append(f), r?.debug(`Inserted text "${t}" at beginning of CharNode ${c.getType()} (key: ${c.getKey()}).`), o = !0, !0;
@@ -20051,12 +20051,12 @@ function ol(e, t, n, r) {
break;
}
if (!o && e === s) {
- const f = Ue(t);
+ const f = Be(t);
return ar(n, f), c.append(f), r?.debug(`Appended text "${t}" to end of CharNode ${c.getType()} (key: ${c.getKey()}).`), o = !0, !0;
}
- } else if (ct(c)) {
+ } else if (st(c)) {
if (!o && e === s) {
- const f = Ue(t);
+ const f = Be(t);
ar(n, f);
const d = c.getFirstChild();
return d ? d.insertBefore(f) : c.append(f), r?.debug(`Inserted text "${t}" at beginning of container ${c.getType()} (key: ${c.getKey()}).`), o = !0, !0;
@@ -20069,7 +20069,7 @@ function ol(e, t, n, r) {
break;
}
if (!o && e === s) {
- const f = Ue(t);
+ const f = Be(t);
return ar(n, f), c.append(f), r?.debug(`Appended text "${t}" to end of container ${c.getType()} (key: ${c.getKey()}).`), o = !0, !0;
}
s += 1;
@@ -20086,38 +20086,38 @@ function ol(e, t, n, r) {
}
if (a(i), !o && e === s) {
r?.debug(`Insertion point matches end of document (targetIndex: ${e}, final currentIndex: ${s}). Appending text to new ParaNode.`);
- const c = Ue(t);
+ const c = Be(t);
ar(n, c);
- const l = qn().append(c);
+ const l = En().append(c);
i.append(l), o = !0;
}
return o ? t.length : (r?.warn(`$insertRichText: Could not find insertion point for text "${t}" at targetIndex ${e}. Final currentIndex: ${s}. Text not inserted.`), 0);
}
-function QT(e, t, n) {
+function nC(e, t, n) {
const r = Me();
let i = 0, s = !1;
function o(a) {
if (s)
return !0;
if (a === r && e === 0 && !r.getFirstChild())
- return t.isInline() ? (n?.debug(`$insertNodeAtCharacterOffset: Inserting inline node ${t.getType()} into empty root, wrapped in ImpliedParaNode. targetIndex: ${e}`), r.append(qn().append(t))) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} directly into empty root. targetIndex: ${e}`), r.append(t)), s = !0, !0;
+ return t.isInline() ? (n?.debug(`$insertNodeAtCharacterOffset: Inserting inline node ${t.getType()} into empty root, wrapped in ImpliedParaNode. targetIndex: ${e}`), r.append(En().append(t))) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} directly into empty root. targetIndex: ${e}`), r.append(t)), s = !0, !0;
if (!A(a))
return !1;
const c = a.getChildren();
for (const l of c) {
if (e === i && !s) {
if (a === r && t.isInline())
- if (dt(l)) {
+ if (ot(l)) {
n?.debug(`$insertNodeAtCharacterOffset: Inserting inline node ${t.getType()} into existing ${l.getType()} at beginning. targetIndex: ${e}`);
const u = l.getFirstChild();
u ? u.insertBefore(t) : l.append(t);
} else
- n?.debug(`$insertNodeAtCharacterOffset: Inserting inline node ${t.getType()} into root before ${l.getType()}, wrapping in ImpliedParaNode. targetIndex: ${e}`), l.insertBefore(qn().append(t));
+ n?.debug(`$insertNodeAtCharacterOffset: Inserting inline node ${t.getType()} into root before ${l.getType()}, wrapping in ImpliedParaNode. targetIndex: ${e}`), l.insertBefore(En().append(t));
else
l.insertBefore(t), n?.debug(`$insertNodeAtCharacterOffset: Inserted node ${t.getType()} (key: ${t.getKey()}) before child ${l.getType()} (key: ${l.getKey()}) in ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, currentIndex: ${i}`);
return s = !0, !0;
}
- if (ni(l)) {
+ if (ri(l)) {
const u = l.getTextContentSize();
if (!s && e > i && e < i + u) {
const f = e - i, [d] = l.splitText(f);
@@ -20129,12 +20129,12 @@ function QT(e, t, n) {
else if (z(l)) {
if (o(l))
return !0;
- } else if (ct(l)) {
+ } else if (st(l)) {
const u = l;
if (o(u))
return !0;
const f = i;
- if (kt(u) && ct(t) && // Target is at the ImpliedPara's implicit newline
+ if (ht(u) && st(t) && // Target is at the ImpliedPara's implicit newline
e === f && !s)
return n?.debug(`$insertNodeAtCharacterOffset: Replacing ImpliedParaNode (key: ${u.getKey()}) with block node '${t.getType()}' (key: ${t.getKey()}) at OT index ${e}.`), l.replace(t, !0), i = f + 1, s = !0, !0;
i += 1;
@@ -20143,29 +20143,29 @@ function QT(e, t, n) {
if (s)
return !0;
}
- return A(a) && !s && (e === i || a === r && e > i) ? a === r ? (t.isInline() ? (n?.debug(`$insertNodeAtCharacterOffset: Appending inline node ${t.getType()} to root. Wrapping in new ImpliedParaNode. targetIndex: ${e}, current document OT length: ${i}.`), r.append(qn().append(t))) : (n?.debug(`$insertNodeAtCharacterOffset: Appending block node ${t.getType()} to root. targetIndex: ${e}, current document OT length: ${i}.`), r.append(t)), s = !0, !0) : (
+ return A(a) && !s && (e === i || a === r && e > i) ? a === r ? (t.isInline() ? (n?.debug(`$insertNodeAtCharacterOffset: Appending inline node ${t.getType()} to root. Wrapping in new ImpliedParaNode. targetIndex: ${e}, current document OT length: ${i}.`), r.append(En().append(t))) : (n?.debug(`$insertNodeAtCharacterOffset: Appending block node ${t.getType()} to root. targetIndex: ${e}, current document OT length: ${i}.`), r.append(t)), s = !0, !0) : (
// Appending to an existing container (ParaNode, ImpliedParaNode)
// currentNode here is the container itself. currentIndex is at the point of currentNode's
// closing marker. targetIndex === currentIndex means we are inserting at the conceptual end
// of this container.
- dt(a) ? kt(a) && ke(t) && e === i ? (n?.debug(`$insertNodeAtCharacterOffset: Replacing ImpliedParaNode container (key: ${a.getKey()}) with ParaNode ${t.getType()} (key: ${t.getKey()}) via append logic. targetIndex: ${e}`), a.replace(t, !0), s = !0, !0) : t.isInline() || !dt(t) ? (n?.debug(`$insertNodeAtCharacterOffset: Appending node ${t.getType()} to existing container ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, container end OT index: ${i}.`), a.append(t), s = !0, !0) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} after container ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, container end OT index: ${i}.`), a.insertAfter(t), s = !0, !0) : (z(a) ? (n?.debug(`$insertNodeAtCharacterOffset: Inserting node ${t.getType()} after CharNode (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.insertAfter(t)) : t.isInline() || !dt(t) ? (n?.debug(`$insertNodeAtCharacterOffset: Appending node ${t.getType()} to generic element ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.append(t)) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} after generic element ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.insertAfter(t)), s = !0, !0)
+ ot(a) ? ht(a) && ke(t) && e === i ? (n?.debug(`$insertNodeAtCharacterOffset: Replacing ImpliedParaNode container (key: ${a.getKey()}) with ParaNode ${t.getType()} (key: ${t.getKey()}) via append logic. targetIndex: ${e}`), a.replace(t, !0), s = !0, !0) : t.isInline() || !ot(t) ? (n?.debug(`$insertNodeAtCharacterOffset: Appending node ${t.getType()} to existing container ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, container end OT index: ${i}.`), a.append(t), s = !0, !0) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} after container ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, container end OT index: ${i}.`), a.insertAfter(t), s = !0, !0) : (z(a) ? (n?.debug(`$insertNodeAtCharacterOffset: Inserting node ${t.getType()} after CharNode (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.insertAfter(t)) : t.isInline() || !ot(t) ? (n?.debug(`$insertNodeAtCharacterOffset: Appending node ${t.getType()} to generic element ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.append(t)) : (n?.debug(`$insertNodeAtCharacterOffset: Inserting block node ${t.getType()} after generic element ${a.getType()} (key: ${a.getKey()}). targetIndex: ${e}, element end OT index: ${i}.`), a.insertAfter(t)), s = !0, !0)
) : s;
}
return o(r), s || n?.warn(`$insertNodeAtCharacterOffset: Could not find insertion point for node ${t.getType()} (key: ${t.getKey()}) at targetIndex ${e}. Final currentIndex: ${i}. Node not inserted.`), s;
}
-function RN(e, t, n, r, i) {
+function KN(e, t, n, r, i) {
let s;
- return gi("chapter", t) ? s = LN(t.insert.chapter, n) : gi("verse", t) ? s = qN(t.insert.verse, n) : gi("ms", t) ? s = DN(t.insert.ms) : gi("note", t) ? s = eC(t, n, r) : gi("unknown", t) ? s = tC(t, n, r, i) : gi("unmatched", t) && (s = UN(t.insert.unmatched, n)), s ? QT(e, s, i) : (i?.error(`$insertEmbedAtCurrentIndex: Cannot create LexicalNode for embed object: ${JSON.stringify(t.insert)}`), !1);
+ return mi("chapter", t) ? s = UN(t.insert.chapter, n) : mi("verse", t) ? s = FN(t.insert.verse, n) : mi("ms", t) ? s = zN(t.insert.ms) : mi("note", t) ? s = iC(t, n, r) : mi("unknown", t) ? s = sC(t, n, r, i) : mi("unmatched", t) && (s = VN(t.insert.unmatched, n)), s ? nC(e, s, i) : (i?.error(`$insertEmbedAtCurrentIndex: Cannot create LexicalNode for embed object: ${JSON.stringify(t.insert)}`), !1);
}
-function ty(e, t, n, r) {
+function oy(e, t, n, r) {
let i;
- $h(t) ? i = ZT(t.para, n) : BN(t) && (i = IN(t.book)), i ??= qn();
- const s = i, o = ke(s), a = kt(s);
+ Ih(t) ? i = rC(t.para, n) : HN(t) && (i = BN(t.book)), i ??= En();
+ const s = i, o = ke(s), a = ht(s);
let c = 0, l = !1;
function u(f) {
if (l)
return !0;
- if (ni(f)) {
+ if (ri(f)) {
const d = f.getTextContentSize();
if (e >= c && e <= c + d) {
const p = f.getParent();
@@ -20183,7 +20183,7 @@ function ty(e, t, n, r) {
c += d;
} else if (jn(f))
c += 1;
- else if (ct(f)) {
+ else if (st(f)) {
const d = f.getChildren();
for (const p of d) {
if (u(p))
@@ -20192,7 +20192,7 @@ function ty(e, t, n, r) {
break;
}
if (e === c) {
- if (kt(f) && s)
+ if (ht(f) && s)
return r?.debug(`Replacing ImpliedParaNode (key: ${f.getKey()}) with ParaNode at targetIndex ${e}`), f.replace(s, !0), l = !0, !0;
if (ke(f) && s) {
const p = f;
@@ -20214,123 +20214,123 @@ function ty(e, t, n, r) {
}
return u(Me()), l || r?.warn(`Could not find location to handle newline with para attributes at targetIndex ${e}. Final currentIndex: ${c}.`), 1;
}
-function IN(e) {
+function BN(e) {
const { style: t, code: n } = e;
- if (!t || t !== va || !n || !Fn.isValidBookCode(n))
+ if (!t || t !== va || !n || !Un.isValidBookCode(n))
return;
- const r = Ct(e, HA);
- return hx(n, r);
+ const r = Ct(e, QA);
+ return kx(n, r);
}
-function ZT(e, t) {
+function rC(e, t) {
const { style: n } = e;
if (!n)
return;
- const r = Ct(e, WA), i = ps(n, r);
- if (!qi(t))
+ const r = Ct(e, XA), i = Ai(n, r);
+ if (!Di(t))
return i;
if (t.markerMode === "editable")
i.append(Jt(n), ms());
else if (t.markerMode === "visible" || t.hasGutterParaMarkers) {
- const s = rt(n) + U;
- i.append(t.hasGutterParaMarkers ? nx(s) : Zr("marker", s));
+ const s = it(n) + B;
+ i.append(t.hasGutterParaMarkers ? ax(s) : ei("marker", s));
}
return i;
}
-function LN(e, t) {
+function UN(e, t) {
if (!e)
return;
const { number: n, sid: r, altnumber: i, pubnumber: s } = e;
if (!n)
return;
- const o = Ct(e, GA);
+ const o = Ct(e, ZA);
let a;
if (t.markerMode === "editable")
- a = Fk(n, r, i, s, o);
+ a = Wk(n, r, i, s, o);
else {
const c = t.markerMode === "visible";
- a = Fp(n, c, r, i, s, o);
+ a = zp(n, c, r, i, s, o);
}
return a;
}
-function qN(e, t) {
+function FN(e, t) {
if (!e)
return;
const { style: n, number: r, sid: i, altnumber: s, pubnumber: o } = e;
if (!r)
return;
- const a = Ct(e, JA);
+ const a = Ct(e, e1);
let c;
if (t.markerMode === "editable") {
if (!n)
return;
const l = lr(n, r);
- c = $k(r, l, i, s, o, a);
+ c = Dk(r, l, i, s, o, a);
} else {
const l = t.markerMode === "visible";
- c = uh(r, l, i, s, o, a);
+ c = dh(r, l, i, s, o, a);
}
return c;
}
-function DN(e) {
+function zN(e) {
if (!e)
return;
const { style: t, sid: n, eid: r, attributeOrder: i } = e;
if (!t)
return;
- const s = Ct(e, YA);
- return yk(t, n, r, s, i);
+ const s = Ct(e, t1);
+ return Ck(t, n, r, s, i);
}
-function eC(e, t, n) {
+function iC(e, t, n) {
const r = e.insert;
if (!r.note)
return;
const { style: i, caller: s, category: o, contents: a } = r.note;
if (!i || s == null)
return;
- const c = Ct(r.note, XA), l = typeof c?.closed == "string" ? c.closed : void 0, u = e.attributes?.segment;
+ const c = Ct(r.note, n1), l = typeof c?.closed == "string" ? c.closed : void 0, u = e.attributes?.segment;
let f;
u && typeof u == "string" && (f = u);
const d = [];
for (const m of a?.ops ?? [])
if (typeof m.insert == "string")
- if (Pi(m.attributes)) {
- const h = Ro(m.attributes.char, t, Ue(m.insert), void 0, nC(m.attributes.char, d), !1, t.markerMode === "editable");
+ if (wi(m.attributes)) {
+ const h = Io(m.attributes.char, t, Be(m.insert), void 0, oC(m.attributes.char, d), !1, t.markerMode === "editable");
d.push(...h);
} else
- d.push(Ue(m.insert));
- return LT(i, s, d, t, n, f, l).setCategory(o).setUnknownAttributes(c);
+ d.push(Be(m.insert));
+ return BT(i, s, d, t, n, f, l).setCategory(o).setUnknownAttributes(c);
}
-function tC(e, t, n, r) {
+function sC(e, t, n, r) {
const i = e.insert.unknown;
if (!i)
return;
const { tag: s, marker: o, contents: a } = i;
if (!s)
return;
- const c = Ct(i, QA), l = Ap(s, o, c), u = a?.ops ?? [];
- u.length > 0 && KN(u, t, n, r).forEach((p) => l.append(p));
+ const c = Ct(i, r1), l = Np(s, o, c), u = a?.ops ?? [];
+ u.length > 0 && jN(u, t, n, r).forEach((p) => l.append(p));
const f = e.attributes?.segment;
- return typeof f == "string" && Wt(l, Mi, () => f), l;
+ return typeof f == "string" && Wt(l, Pi, () => f), l;
}
-function KN(e, t, n, r) {
+function jN(e, t, n, r) {
const i = [];
for (const s of e) {
if (typeof s.insert == "string") {
- if (Pi(s.attributes)) {
- const o = Ue(s.insert), a = Ro(s.attributes.char, t, o, void 0, nC(s.attributes.char, i));
+ if (wi(s.attributes)) {
+ const o = Be(s.insert), a = Io(s.attributes.char, t, o, void 0, oC(s.attributes.char, i));
i.push(...a);
} else
- i.push(Ue(s.insert));
+ i.push(Be(s.insert));
continue;
}
if (!(!s.insert || typeof s.insert != "object")) {
- if (gi("unknown", s)) {
- const o = tC(s, t, n, r);
+ if (mi("unknown", s)) {
+ const o = sC(s, t, n, r);
o && i.push(o);
continue;
}
- if (gi("note", s)) {
- const o = eC(s, t, n);
+ if (mi("note", s)) {
+ const o = iC(s, t, n);
o && i.push(o);
continue;
}
@@ -20339,64 +20339,64 @@ function KN(e, t, n, r) {
}
return i;
}
-function UN(e, t) {
+function VN(e, t) {
if (!e)
return;
const { marker: n } = e;
if (!n)
return;
- const r = Jp(n);
+ const r = Xp(n);
return t.markerMode === "editable" && r.setMode("normal"), r;
}
-function nC(e, t) {
+function oC(e, t) {
if (!(!Array.isArray(e) && e.style === "fp" && !e.cid))
return t;
}
-function gd(e) {
+function bd(e) {
return e.style.startsWith("+") ? { ...e, style: e.style.slice(1) } : e;
}
-function Ro(e, t, n, r, i, s = !1, o = !1) {
- T(n) && n.getTextContentSize() === 0 && n.setTextContent(It);
+function Io(e, t, n, r, i, s = !1, o = !1) {
+ C(n) && n.getTextContentSize() === 0 && n.setTextContent(It);
const a = () => {
- o && T(n) && n.getTextContent() !== It && n.setTextContent(U + n.getTextContent());
+ o && C(n) && n.getTextContent() !== It && n.setTextContent(B + n.getTextContent());
};
if (Array.isArray(e)) {
if (e.length === 0)
throw new Error("Empty charAttr array");
- const c = e.map(gd), l = c[0], u = i?.[i.length - 1];
+ const c = e.map(bd), l = c[0], u = i?.[i.length - 1];
if (z(u) && gs(l, u)) {
if (c.length > 1) {
- const d = Ro(c.slice(1), t, n, void 0, void 0, !0, o);
- cf(u, d);
+ const d = Io(c.slice(1), t, n, void 0, void 0, !0, o);
+ ff(u, d);
} else
- n && cf(u, [n]);
+ n && ff(u, [n]);
return [];
}
a();
const f = c.reduceRight((d, p, m) => {
- const h = Qr(p.style, Ct(p, rl));
- return typeof p.cid == "string" && Wt(h, ds, () => p.cid), r && m === c.length - 1 && Wt(h, Mi, () => r), d && (z(d) && (uf(d.getMarker(), d, t, !0), lf(d, d, t, !0)), h.append(d)), h;
+ const h = Zr(p.style, Ct(p, sl));
+ return typeof p.cid == "string" && Wt(h, ps, () => p.cid), r && m === c.length - 1 && Wt(h, Pi, () => r), d && (z(d) && (pf(d.getMarker(), d, t, !0), df(d, d, t, !0)), h.append(d)), h;
}, n);
- return uf(l.style, f, t, s), lf(f, f, t, s), [f];
+ return pf(l.style, f, t, s), df(f, f, t, s), [f];
} else {
- const c = gd(e), l = i?.[i.length - 1];
+ const c = bd(e), l = i?.[i.length - 1];
if (z(l) && gs(c, l))
- return n && cf(l, [n]), [];
+ return n && ff(l, [n]), [];
a();
- const u = Qr(c.style, Ct(c, rl));
- return typeof c.cid == "string" && Wt(u, ds, () => c.cid), r && Wt(u, Mi, () => r), n && u.append(n), uf(c.style, u, t, s), lf(u, u, t, s), [u];
+ const u = Zr(c.style, Ct(c, sl));
+ return typeof c.cid == "string" && Wt(u, ps, () => c.cid), r && Wt(u, Pi, () => r), n && u.append(n), pf(c.style, u, t, s), df(u, u, t, s), [u];
}
}
-function cf(e, t) {
+function ff(e, t) {
const n = e.getLastChild();
$(n) && n.getMarkerSyntax() === "closing" || Yt(n) && n.getTextType() === "marker" && n.getTextContent() === pt(e.getMarker(), z(e.getParent())) ? t.forEach((i) => n.insertBefore(i)) : e.append(...t);
}
-function lf(e, t, n, r = !1) {
- e.getUnknownAttributes()?.closed !== "false" && FN(e.getMarker(), t, n, !1, r);
+function df(e, t, n, r = !1) {
+ e.getUnknownAttributes()?.closed !== "false" && WN(e.getMarker(), t, n, !1, r);
}
-function uf(e, t, n, r = !1) {
+function pf(e, t, n, r = !1) {
let i;
- if (n?.markerMode === "editable" ? i = Jt(e, "opening", r) : n?.markerMode === "visible" && (i = Zr("marker", rt(e, r))), i)
+ if (n?.markerMode === "editable" ? i = Jt(e, "opening", r) : n?.markerMode === "visible" && (i = ei("marker", it(e, r))), i)
if (Array.isArray(t))
t.push(i);
else {
@@ -20404,20 +20404,20 @@ function uf(e, t, n, r = !1) {
s ? s.insertBefore(i) : t.append(i);
}
}
-function FN(e, t, n, r = !1, i = !1) {
+function WN(e, t, n, r = !1, i = !1) {
let s;
- n?.markerMode === "editable" ? r ? s = Jt("", "selfClosing") : s = Jt(e, "closing", i) : n?.markerMode === "visible" && (s = Zr("marker", r ? pt("") : pt(e, i))), s && (Array.isArray(t) ? t.push(s) : t.append(s));
+ n?.markerMode === "editable" ? r ? s = Jt("", "selfClosing") : s = Jt(e, "closing", i) : n?.markerMode === "visible" && (s = ei("marker", r ? pt("") : pt(e, i))), s && (Array.isArray(t) ? t.push(s) : t.append(s));
}
-function BN(e) {
+function HN(e) {
return !!e && !!e.book && typeof e.book == "object" && e.book !== null && "style" in e.book && typeof e.book.style == "string" && "code" in e.book && typeof e.book.code == "string";
}
-function $h(e) {
+function Ih(e) {
return !!e && !!e.para && typeof e.para == "object" && e.para !== null && "style" in e.para && typeof e.para.style == "string";
}
-function Pi(e) {
+function wi(e) {
return !!e && !!e.char && typeof e.char == "object" && e.char !== null && (!Array.isArray(e.char) && "style" in e.char && typeof e.char.style == "string" || Array.isArray(e.char) && e.char.length > 0 && "style" in e.char[0] && typeof e.char[0].style == "string");
}
-function zN(e) {
+function GN(e) {
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.keys(e).length === 0;
}
function ar(e, t) {
@@ -20425,16 +20425,16 @@ function ar(e, t) {
for (const n of Object.keys(e)) {
if (n === "segment" && typeof e[n] == "string") {
const r = e[n];
- Wt(t, Mi, () => r);
+ Wt(t, Pi, () => r);
continue;
}
- if (jN(n)) {
+ if (JN(n)) {
const r = !!e[n], i = n, s = t.hasFormat(i);
(r && !s || !r && s) && t.toggleFormat(i);
}
}
}
-const rC = [
+const aC = [
"bold",
"underline",
"strikethrough",
@@ -20447,16 +20447,16 @@ const rC = [
"uppercase",
"capitalize"
];
-function jN(e) {
- return rC.includes(e);
+function JN(e) {
+ return aC.includes(e);
}
-function VN() {
+function YN() {
const [e] = Pe();
return J(() => {
- const t = (n) => n instanceof KeyboardEvent && !Rh(n) || !Ts() ? !1 : (n instanceof Event && n.preventDefault(), !0);
- return Ye(
+ const t = (n) => n instanceof KeyboardEvent && !Lh(n) || !Ts() ? !1 : (n instanceof Event && n.preventDefault(), !0);
+ return Xe(
e.registerCommand(Jn, t, Je),
- e.registerCommand(Yr, t, Je),
+ e.registerCommand(Xr, t, Je),
// CUT and PASTE run at CRITICAL because their standard-view handlers — the ones that
// actually copy and then remove — are themselves registered at HIGH, where the winner is
// decided by registration order rather than by intent. A refusal has to outrank the actor it
@@ -20464,47 +20464,47 @@ function VN() {
// cover, TIES with this refusal, so it consults `$selectionReachesIntoOpaqueBlock` itself
// rather than relying on order: an arm this refusal leaves behind would outlive the gesture.
e.registerCommand(un, t, ye),
- e.registerCommand(wn, t, ye),
+ e.registerCommand(Nn, t, ye),
// DROP is judged by the drop TARGET, not the live selection: Lexical dispatches
// DROP_COMMAND straight from the DOM handler with no selection update, so at drop time
// `$getSelection()` still holds whatever was selected when the drag STARTED. Testing that
// inverted both promises above — dragging a caption OUT of a figure was refused (source
// inside), while dragging outside text INTO a caption was allowed (source outside).
- e.registerCommand(ql, (n) => {
+ e.registerCommand(Kl, (n) => {
if (!(n instanceof Event) || !(n.target instanceof Node))
return !1;
const r = qr(n.target);
- return !r || !Ai(r) ? !1 : (n.preventDefault(), !0);
+ return !r || !Ni(r) ? !1 : (n.preventDefault(), !0);
}, Je),
- e.registerCommand(In, t, Je),
- e.registerCommand(cs, t, Je),
- e.registerCommand(Ei, t, Je)
+ e.registerCommand(Ln, t, Je),
+ e.registerCommand(ls, t, Je),
+ e.registerCommand(Mi, t, Je)
);
}, [e]), null;
}
-function Rh(e) {
+function Lh(e) {
return e.isComposing || e.keyCode === 229 ? !0 : !(typeof e.getModifierState == "function" && e.getModifierState("AltGraph")) && (e.ctrlKey || e.metaKey || e.altKey) ? !1 : e.key.length === 1 || e.key === "Backspace" || e.key === "Delete" || e.key === "Enter";
}
-function Ai(e) {
- return We(e, cu) ?? void 0;
+function Ni(e) {
+ return We(e, uu) ?? void 0;
}
-function cu(e) {
- return Ie(e) || Vk(e);
+function uu(e) {
+ return Ie(e) || Yk(e);
}
function Ts() {
const e = M();
- return E(e) && iC(e);
+ return E(e) && cC(e);
}
-function iC(e) {
- return Ai(e.anchor.getNode()) !== void 0 || Ai(e.focus.getNode()) !== void 0;
+function cC(e) {
+ return Ni(e.anchor.getNode()) !== void 0 || Ni(e.focus.getNode()) !== void 0;
}
-function WN(e, t, n) {
+function XN(e, t, n) {
if (e.height === 0)
return !1;
const r = e.height / 4;
return t.some((i) => n === "down" ? i.top >= e.bottom - r : i.bottom <= e.top + r);
}
-function HN(e, t) {
+function QN(e, t) {
if (typeof window > "u")
return !1;
const n = window.getSelection();
@@ -20533,24 +20533,24 @@ function HN(e, t) {
if (!c)
return !1;
const u = document.createRange();
- return u.setStartAfter(c), l ? u.setEndBefore(l) : u.setEnd(r, r.childNodes.length), WN(s, Array.from(u.getClientRects()), t);
+ return u.setStartAfter(c), l ? u.setEndBefore(l) : u.setEnd(r, r.childNodes.length), XN(s, Array.from(u.getClientRects()), t);
} catch {
return !1;
}
}
-function GN(e, t, n, r) {
- if (!cO(t) || HN(e, n))
+function ZN(e, t, n, r) {
+ if (!pO(t) || QN(e, n))
return !1;
- const i = n === "up" ? VA(t) : jA(t);
+ const i = n === "up" ? YA(t) : JA(t);
return i && r.preventDefault(), i;
}
-function JN({ viewOptions: e }) {
+function eO({ viewOptions: e }) {
const [t] = Pe();
- return YN(t, e), null;
+ return tO(t, e), null;
}
-function YN(e, t) {
+function tO(e, t) {
J(() => {
- if (!e.hasNodes([Qn, sn, at]))
+ if (!e.hasNodes([Qn, sn, lt]))
throw new Error("ArrowNavigationPlugin: ImmutableChapterNode, ImmutableVerseNode or NoteNode not registered on editor!");
const n = (r) => {
const i = M();
@@ -20558,7 +20558,7 @@ function YN(e, t) {
return !1;
const s = t?.markerMode === "editable", o = e.getRootElement();
if (s && o && (r.key === "ArrowLeft" || r.key === "ArrowRight") && r.shiftKey && !r.altKey && !r.ctrlKey && !r.metaKey) {
- const u = ny(o), f = rO(i, ry(u, r.key) ? "next" : "previous");
+ const u = ay(o), f = cO(i, cy(u, r.key) ? "next" : "previous");
return f && r.preventDefault(), f;
}
if (!i.isCollapsed())
@@ -20567,61 +20567,61 @@ function YN(e, t) {
if (r.shiftKey || r.altKey || r.ctrlKey || r.metaKey)
return !1;
const u = r.key === "ArrowUp" ? "up" : "down";
- return GN(e, i, u, r);
+ return ZN(e, i, u, r);
}
if (r.key !== "ArrowLeft" && r.key !== "ArrowRight" || !o)
return !1;
- const a = ny(o), c = r.shiftKey || r.altKey || r.ctrlKey || r.metaKey;
+ const a = ay(o), c = r.shiftKey || r.altKey || r.ctrlKey || r.metaKey;
let l = !1;
- return ry(a, r.key) ? l = !c && oy(i, "next") || !c && QN(i) || oO(i) || !c && s && sy(i, "next") : XN(a, r.key) && (l = !c && oy(i, "previous") || !c && ZN(i) || aO(i, t) || !c && s && sy(i, "previous")), l && r.preventDefault(), l;
+ return cy(a, r.key) ? l = !c && fy(i, "next") || !c && rO(i) || fO(i) || !c && s && uy(i, "next") : nO(a, r.key) && (l = !c && fy(i, "previous") || !c && iO(i) || dO(i, t) || !c && s && uy(i, "previous")), l && r.preventDefault(), l;
};
return e.registerCommand(Jn, n, Je);
}, [e, t]);
}
-function ny(e) {
+function ay(e) {
return e.dir || "ltr";
}
-function ry(e, t) {
+function cy(e, t) {
return e === "ltr" && t === "ArrowRight" || e === "rtl" && t === "ArrowLeft";
}
-function XN(e, t) {
+function nO(e, t) {
return e === "ltr" && t === "ArrowLeft" || e === "rtl" && t === "ArrowRight";
}
-function md(e) {
+function kd(e) {
if (!z(e) || e.getMarker() !== "fp")
return;
const t = hn(e);
if (!(!t || t.getIsCollapsed()))
return e;
}
-function QN(e) {
- const t = md(jp(e));
+function rO(e) {
+ const t = kd(Wp(e));
if (!t)
return !1;
const n = e.anchor;
return n.type === "text" && n.offset !== n.getNode().getTextContentSize() ? !1 : (zn(t, 0), !0);
}
-function ZN(e) {
+function iO(e) {
const t = e.anchor, n = t.getNode();
if (t.type === "text") {
- const r = md(n.getParent());
- return !r || !n.is(r.getFirstChild()) ? !1 : t.offset === 1 ? (n.select(0, 0), !0) : t.offset !== 0 ? !1 : iy(r);
+ const r = kd(n.getParent());
+ return !r || !n.is(r.getFirstChild()) ? !1 : t.offset === 1 ? (n.select(0, 0), !0) : t.offset !== 0 ? !1 : ly(r);
}
if (t.offset === 0) {
- const r = md(n);
- return r ? iy(r) : !1;
+ const r = kd(n);
+ return r ? ly(r) : !1;
}
return !1;
}
-function iy(e) {
+function ly(e) {
const t = e.getPreviousSibling();
if (!t)
return !1;
- if (T(t))
+ if (C(t))
return t.select(), !0;
if (A(t)) {
const i = t.getLastDescendant();
- return T(i) ? i.select() : t.selectEnd(), !0;
+ return C(i) ? i.select() : t.selectEnd(), !0;
}
const n = e.getParent();
if (!n)
@@ -20629,39 +20629,39 @@ function iy(e) {
const r = e.getIndexWithinParent();
return n.select(r, r), !0;
}
-const al = typeof Intl.Segmenter > "u" ? void 0 : new Intl.Segmenter(void 0, { granularity: "grapheme" });
-function eO(e) {
- if (al)
- for (const { segment: n } of al.segment(e))
+const ll = typeof Intl.Segmenter > "u" ? void 0 : new Intl.Segmenter(void 0, { granularity: "grapheme" });
+function sO(e) {
+ if (ll)
+ for (const { segment: n } of ll.segment(e))
return n.length;
const t = e.codePointAt(0);
return t === void 0 ? 0 : String.fromCodePoint(t).length;
}
-function tO(e) {
- if (al) {
+function oO(e) {
+ if (ll) {
let r = 0;
- for (const { index: i } of al.segment(e))
+ for (const { index: i } of ll.segment(e))
r = i;
return r;
}
const t = e.codePointAt(Math.max(0, e.length - 2)), n = t !== void 0 && t > 65535;
return Math.max(0, e.length - (n ? 2 : 1));
}
-function sC(e) {
+function lC(e) {
for (let t = e; t; t = t.getParent())
if (A(t) && !t.isInline())
return t;
}
-function oC(e) {
- return !!e && $(e) && Ai(e) !== void 0;
+function uC(e) {
+ return !!e && $(e) && Ni(e) !== void 0;
}
-function So(e) {
- return T(e) && !e.isToken() && !oC(e) && e.getTextContentSize() > 0;
+function _o(e) {
+ return C(e) && !e.isToken() && !uC(e) && e.getTextContentSize() > 0;
}
-function aC(e) {
- return Os(e) ? !0 : K(e) ? e.getIsCollapsed() === !0 : T(e) ? (e.isToken() || oC(e)) && e.getTextContentSize() > 0 : on(e) ? !Ve(e) : !1;
+function fC(e) {
+ return Os(e) ? !0 : K(e) ? e.getIsCollapsed() === !0 : C(e) ? (e.isToken() || uC(e)) && e.getTextContentSize() > 0 : on(e) ? !Ve(e) : !1;
}
-function _o(e, t, n) {
+function Eo(e, t, n) {
for (let r = e; r && !r.is(n); ) {
const i = t === "next" ? r.getNextSibling() : r.getPreviousSibling();
if (i)
@@ -20669,97 +20669,97 @@ function _o(e, t, n) {
r = r.getParent();
}
}
-function lu(e, t, n) {
+function fu(e, t, n) {
for (let r = e; r; ) {
- if (aC(r))
+ if (fC(r))
return r;
if (A(r)) {
- r = (t === "next" ? r.getFirstChild() : r.getLastChild()) ?? _o(r, t, n);
+ r = (t === "next" ? r.getFirstChild() : r.getLastChild()) ?? Eo(r, t, n);
continue;
}
- if (So(r))
+ if (_o(r))
return r;
- r = _o(r, t, n);
+ r = Eo(r, t, n);
}
}
-function Ih(e, t, n, r, i) {
- return n === "element" && A(e) ? e.getChildAtIndex(r === "next" ? t : t - 1) ?? _o(e, r, i) : n === "text" && aC(e) && (r === "next" ? t < e.getTextContentSize() : t > 0) ? e : _o(e, r, i);
+function qh(e, t, n, r, i) {
+ return n === "element" && A(e) ? e.getChildAtIndex(r === "next" ? t : t - 1) ?? Eo(e, r, i) : n === "text" && fC(e) && (r === "next" ? t < e.getTextContentSize() : t > 0) ? e : Eo(e, r, i);
}
-function ff(e, t) {
+function hf(e, t) {
if (e.kind === "text" && e.offset > 0)
return e;
- const n = Ih(e.node, e.offset, e.kind, "previous", t), r = lu(n, "previous", t);
+ const n = qh(e.node, e.offset, e.kind, "previous", t), r = fu(n, "previous", t);
if (!r)
return e;
- if (So(r))
+ if (_o(r))
return { kind: "text", node: r, offset: r.getTextContentSize() };
const i = r.getParent();
return i ? { kind: "element", node: i, offset: r.getIndexWithinParent() + 1 } : e;
}
-function nO(e, t) {
- const n = e.getNode(), r = sC(n);
+function aO(e, t) {
+ const n = e.getNode(), r = lC(n);
if (!r)
return;
- if (e.type === "text" && So(n)) {
+ if (e.type === "text" && _o(n)) {
if (t === "next" && e.offset < n.getTextContentSize() || t === "previous" && e.offset > 1)
return;
if (t === "previous" && e.offset === 1)
- return ff({ kind: "text", node: n, offset: 0 }, r);
+ return hf({ kind: "text", node: n, offset: 0 }, r);
}
- const i = Ih(n, e.offset, e.type, t, r), s = lu(i, t, r);
+ const i = qh(n, e.offset, e.type, t, r), s = fu(i, t, r);
if (!s)
return;
- if (So(s)) {
- const c = s.getTextContent(), l = t === "next" ? eO(c) : tO(c);
- return ff({ kind: "text", node: s, offset: l }, r);
+ if (_o(s)) {
+ const c = s.getTextContent(), l = t === "next" ? sO(c) : oO(c);
+ return hf({ kind: "text", node: s, offset: l }, r);
}
const o = s.getParent();
if (!o)
return;
const a = s.getIndexWithinParent();
- return ff({ kind: "element", node: o, offset: t === "next" ? a + 1 : a }, r);
+ return hf({ kind: "element", node: o, offset: t === "next" ? a + 1 : a }, r);
}
-function cC(e, t, n) {
- const r = n === "collapse" ? e.anchor : e.focus, i = nO(r, t);
- return !i || i.node.is(r.getNode()) && i.offset === r.offset && i.kind === r.type ? !1 : n === "collapse" ? (i.kind === "element" && A(i.node) ? ou(i.node, i.offset) : i.node.select(i.offset, i.offset), !0) : (e.focus.set(i.node.getKey(), i.offset, i.kind), !0);
+function dC(e, t, n) {
+ const r = n === "collapse" ? e.anchor : e.focus, i = aO(r, t);
+ return !i || i.node.is(r.getNode()) && i.offset === r.offset && i.kind === r.type ? !1 : n === "collapse" ? (i.kind === "element" && A(i.node) ? cu(i.node, i.offset) : i.node.select(i.offset, i.offset), !0) : (e.focus.set(i.node.getKey(), i.offset, i.kind), !0);
}
-function sy(e, t) {
- return cC(e, t, "collapse");
+function uy(e, t) {
+ return dC(e, t, "collapse");
}
-function rO(e, t) {
- return cC(e, t, "extend");
+function cO(e, t) {
+ return dC(e, t, "extend");
}
-function iO(e, t, n) {
+function lO(e, t, n) {
const r = e.getNode();
- if (e.type === "text" && So(r) && (t === "next" ? e.offset < r.getTextContentSize() : e.offset > 0))
+ if (e.type === "text" && _o(r) && (t === "next" ? e.offset < r.getTextContentSize() : e.offset > 0))
return !1;
- const i = Ih(r, e.offset, e.type, t, n);
- return lu(i, t, n) === void 0;
+ const i = qh(r, e.offset, e.type, t, n);
+ return fu(i, t, n) === void 0;
}
-function sO(e, t) {
+function uO(e, t) {
const n = Me();
for (let r = e; r; ) {
- const i = _o(r, t, n), s = i && lu(i, t, n);
+ const i = Eo(r, t, n), s = i && fu(i, t, n);
if (!s)
return;
- if (r = Ai(s), !r)
+ if (r = Ni(s), !r)
return s;
}
}
-function oy(e, t) {
+function fy(e, t) {
const n = e.anchor, r = n.getNode();
- if (Ai(r))
+ if (Ni(r))
return !1;
- const i = sC(r);
- if (!i || !iO(n, t, i))
+ const i = lC(r);
+ if (!i || !lO(n, t, i))
return !1;
- const s = _o(i, t, Me()), o = s && Ai(s);
+ const s = Eo(i, t, Me()), o = s && Ni(s);
if (!o)
return !1;
- const a = sO(o, t);
+ const a = uO(o, t);
if (!a)
return !0;
- if (So(a)) {
+ if (_o(a)) {
const u = t === "next" ? 0 : a.getTextContentSize();
return a.select(u, u), !0;
}
@@ -20769,17 +20769,17 @@ function oy(e, t) {
const l = a.getIndexWithinParent() + (t === "next" ? 0 : 1);
return c.select(l, l), !0;
}
-function ay(e) {
+function dy(e) {
const t = e.getParent();
if (!t)
return;
const n = e.getIndexWithinParent() + 1;
- ou(t, n);
+ cu(t, n);
}
-function oO(e) {
- const t = e.anchor.getNode(), n = jp(e);
+function fO(e) {
+ const t = e.anchor.getNode(), n = Wp(e);
if (K(n) && !$(n.getFirstChild())) {
- if (ct(t)) {
+ if (st(t)) {
if (e.anchor.offset === t.getChildrenSize())
return !1;
} else if (!(e.anchor.offset === t.getTextContentSize()))
@@ -20787,27 +20787,27 @@ function oO(e) {
if (n.getIsCollapsed()) {
if (n.is(n.getParent()?.getLastChild())) {
const i = n.getParent()?.getNextSibling();
- return i && !(dt(i) && Sn(i)) && i.selectStart(), !0;
+ return i && !(ot(i) && Sn(i)) && i.selectStart(), !0;
}
} else return Yt(n.getFirstChild()) ? n.select(2, 2) : n.select(1, 1), !0;
}
- if (ct(t) && K(n) && n.getIsCollapsed()) {
+ if (st(t) && K(n) && n.getIsCollapsed()) {
const i = n.getNextSibling();
- return i ? i.selectStart() : ay(n), !0;
+ return i ? i.selectStart() : dy(n), !0;
}
const r = n?.getParent();
if (Yt(n) && K(r) && n.is(r?.getLastChild())) {
const i = r.getNextSibling();
- return i ? i.selectStart() : r.getIsCollapsed() ? ay(r) : r.selectEnd(), !0;
+ return i ? i.selectStart() : r.getIsCollapsed() ? dy(r) : r.selectEnd(), !0;
}
return !1;
}
-function aO(e, t) {
- const n = xx(e);
- if (ai(n) && !n.getPreviousSibling())
+function dO(e, t) {
+ const n = Sx(e);
+ if (ci(n) && !n.getPreviousSibling())
return !0;
const { anchor: r } = e;
- if ((r.type === "element" || r.offset === 0) && vo(n))
+ if ((r.type === "element" || r.offset === 0) && So(n))
return !0;
if (!(e.anchor.offset === 0))
return !1;
@@ -20824,7 +20824,7 @@ function aO(e, t) {
const u = n.getIndexWithinParent();
return l.select(u, u), !0;
}
- if (ct(n) && t?.noteMode === "collapsed") {
+ if (st(n) && t?.noteMode === "collapsed") {
const c = n.getLastChild();
if (!c)
return !1;
@@ -20840,7 +20840,7 @@ function aO(e, t) {
const a = hn(s);
if (!a || a.getIsCollapsed())
return !1;
- if (Ut(n)) {
+ if (Bt(n)) {
const c = a.getParent();
if (!c)
return !1;
@@ -20849,7 +20849,7 @@ function aO(e, t) {
}
return !1;
}
-function cO(e) {
+function pO(e) {
if (e.anchor.type === "element")
return !0;
if (e.anchor.offset !== 0)
@@ -20857,51 +20857,51 @@ function cO(e) {
const t = e.anchor.getNode().getPreviousSibling();
return Oe(t) && on(t);
}
-function lO() {
+function hO() {
const [e] = Pe();
- return uO(e), null;
+ return gO(e), null;
}
-function uO(e) {
+function gO(e) {
J(() => {
- if (!e.hasNodes([nt]))
+ if (!e.hasNodes([rt]))
throw new Error("CharNodePlugin: CharNode not registered on editor!");
- return Ye(
- e.registerNodeTransform(nt, pO),
+ return Xe(
+ e.registerNodeTransform(rt, bO),
// Self-healing nested glyphs: whenever a char span is dirtied (created, moved, merged,
// unwrapped), re-derive its glyphs' `+` from tree position — see nestedGlyphs.utils.ts
// (`shared`) for the full representation rules this enforces.
- e.registerNodeTransform(nt, gM),
+ e.registerNodeTransform(rt, xM),
// Self-healing display separators: every opening char glyph is followed by its NBSP
// separator (text prefix or standalone spacer) — see markerSeparators.utils.ts (`shared`).
- e.registerNodeTransform(nt, Qk),
+ e.registerNodeTransform(rt, rx),
// Self-healing attribute display run: re-derive the `|…` run from unknownAttributes
// whenever a span is dirtied — heals remote collab updates (delta-apply only calls
// setUnknownAttributes) and structure surgery. $syncDisplayRun (displayRunSync.utils.ts,
// `shared`), driven here with the char descriptor from displayRunRegistry.ts (`shared`).
- e.registerNodeTransform(nt, (t) => Ma(ei("char"), t)),
- e.registerNodeTransform(it, hO)
+ e.registerNodeTransform(rt, (t) => Ma(ti("char"), t)),
+ e.registerNodeTransform(at, kO)
);
}, [e]);
}
function $c(e) {
return e.getChildren().some($);
}
-function fO(e, t) {
+function mO(e, t) {
const n = t.getFirstChild();
if (!$(n) || n.getMarkerSyntax() !== "opening")
return !1;
const r = n.getNextSibling();
- if (si(r)) {
+ if (oi(r)) {
const i = r.getTextContent();
- i.startsWith(U) && (i === U ? r.remove() : r.setTextContent(i.slice(U.length)));
+ i.startsWith(B) && (i === B ? r.remove() : r.setTextContent(i.slice(B.length)));
}
return t.splice(1, 0, e.getChildren()), e.remove(), !0;
}
-function dO(e, t) {
+function yO(e, t) {
const n = t.getLastChild(), r = e.getChildren();
$(n) && n.getMarkerSyntax() === "closing" ? r.forEach((i) => n.insertBefore(i)) : t.append(...r), e.remove();
}
-function pO(e) {
+function bO(e) {
if (!z(e))
return;
if (e.isEmpty()) {
@@ -20913,35 +20913,35 @@ function pO(e) {
const t = e.getMarker();
if (t === "fp")
return;
- const n = Te(e, ds), r = e.getUnknownAttributes(), i = e.getNextSibling();
+ const n = Te(e, ps), r = e.getUnknownAttributes(), i = e.getNextSibling();
if (z(i) && gs({ style: t, cid: n }, i) && Tn(r, i.getUnknownAttributes()))
if ($c(i)) {
- if (fO(e, i))
+ if (mO(e, i))
return;
} else
e.append(...i.getChildren()), i.remove();
const s = e.getPreviousSibling();
- z(s) && gs({ style: t, cid: n }, s) && Tn(r, s.getUnknownAttributes()) && ($c(s) ? dO(e, s) : (s.append(...e.getChildren()), e.remove()));
+ z(s) && gs({ style: t, cid: n }, s) && Tn(r, s.getUnknownAttributes()) && ($c(s) ? yO(e, s) : (s.append(...e.getChildren()), e.remove()));
}
-const lC = /* @__PURE__ */ new WeakSet();
-function hO(e) {
+const pC = /* @__PURE__ */ new WeakSet();
+function kO(e) {
const t = e.getParent();
- if (!z(t) || $c(t) || lC.has(e))
+ if (!z(t) || $c(t) || pC.has(e))
return;
const n = e.getTextContent();
if (n.length < 2 || !n.includes(It))
return;
- const r = bO(t.getKey());
+ const r = vO(t.getKey());
if (r === void 0) {
- t.getChildrenSize() === 1 && n.startsWith(It) && !yO(e.getKey()) && !mO(e) && cy(e, 0);
+ t.getChildrenSize() === 1 && n.startsWith(It) && !CO(e.getKey()) && !TO(e) && py(e, 0);
return;
}
if (r !== e.getKey())
return;
- const i = gO(e, n);
- i !== void 0 && cy(e, i);
+ const i = xO(e, n);
+ i !== void 0 && py(e, i);
}
-function gO(e, t) {
+function xO(e, t) {
const n = M();
if (E(n) && n.isCollapsed() && n.anchor.key === e.getKey()) {
const { offset: r } = n.anchor;
@@ -20955,51 +20955,51 @@ function gO(e, t) {
if (t.endsWith(It))
return t.length - 1;
}
-function mO(e) {
+function TO(e) {
const t = M();
return E(t) && t.isCollapsed() && t.anchor.key === e.getKey() && t.anchor.offset === 0;
}
-function cy(e, t) {
+function py(e, t) {
const n = M(), r = E(n) ? [n.anchor, n.focus].filter((a) => a.type === "text" && a.key === e.getKey()) : [], i = r.map((a) => a.offset), s = e.getTextContent(), o = e.setTextContent(s.slice(0, t) + s.slice(t + 1));
- lC.add(o), r.forEach((a, c) => {
+ pC.add(o), r.forEach((a, c) => {
const l = i[c];
a.set(o.getKey(), l > t ? l - 1 : l, "text");
});
}
-function yO(e) {
+function CO(e) {
return Pt().getEditorState().read(() => {
const t = ee(e);
- if (!T(t))
+ if (!C(t))
return !1;
const n = t.getTextContent();
return n !== "" && n !== It;
});
}
-function bO(e) {
+function vO(e) {
return Pt().getEditorState().read(() => {
const t = ee(e);
if (!z(t))
return;
const n = t.getChildren().filter((i) => !on(i)), [r] = n;
- return n.length === 1 && T(r) && r.getTextContent() === It ? r.getKey() : null;
+ return n.length === 1 && C(r) && r.getTextContent() === It ? r.getKey() : null;
});
}
-function uC(e) {
+function hC(e) {
return e.replaceAll(" ", " ");
}
-function fC() {
+function gC() {
const e = M();
return !!e && !e.isCollapsed();
}
-function dC(e) {
- const t = () => !fC();
- return Ye(e.registerCommand(Xr, t, Nt), e.registerCommand(wn, t, Nt));
+function mC(e) {
+ const t = () => !gC();
+ return Xe(e.registerCommand(Qr, t, Nt), e.registerCommand(Nn, t, Nt));
}
-const Lh = (e) => {
- e.dispatchCommand(Xr, null);
-}, qh = (e) => {
- e.dispatchCommand(wn, null);
-}, Dh = (e) => {
+const Dh = (e) => {
+ e.dispatchCommand(Qr, null);
+}, Kh = (e) => {
+ e.dispatchCommand(Nn, null);
+}, Bh = (e) => {
navigator.clipboard.read().then(async (t) => {
if ((await navigator.permissions.query({
// @ts-expect-error These types are incorrect.
@@ -21011,14 +21011,14 @@ const Lh = (e) => {
const r = new DataTransfer(), i = t[0];
for (const o of i.types) {
const a = await (await i.getType(o)).text();
- r.setData(o, uC(a));
+ r.setData(o, hC(a));
}
const s = new ClipboardEvent("paste", {
clipboardData: r
});
e.dispatchCommand(un, s);
});
-}, Kh = (e) => {
+}, Uh = (e) => {
navigator.clipboard.read().then(async () => {
if ((await navigator.permissions.query({
// @ts-expect-error These types are incorrect.
@@ -21028,116 +21028,116 @@ const Lh = (e) => {
return;
}
const n = new DataTransfer(), r = await navigator.clipboard.readText();
- n.setData("text/plain", uC(r));
+ n.setData("text/plain", hC(r));
const i = new ClipboardEvent("paste", {
clipboardData: n
});
e.dispatchCommand(un, i);
});
};
-function kO() {
+function SO() {
const [e] = Pe();
return J(() => {
const t = (n) => {
const { key: r, shiftKey: i, metaKey: s, ctrlKey: o, altKey: a } = n;
- !(mr ? s : o) || a || (!i && r.toLowerCase() === "c" ? (n.preventDefault(), Lh(e)) : !i && r.toLowerCase() === "x" ? (n.preventDefault(), qh(e)) : r.toLowerCase() === "v" && (n.preventDefault(), i ? Kh(e) : Dh(e)));
+ !(yr ? s : o) || a || (!i && r.toLowerCase() === "c" ? (n.preventDefault(), Dh(e)) : !i && r.toLowerCase() === "x" ? (n.preventDefault(), Kh(e)) : r.toLowerCase() === "v" && (n.preventDefault(), i ? Uh(e) : Bh(e)));
};
- return Ye(
+ return Xe(
// Every copy/cut this plugin's shortcuts synthesize — and every one the context menu or an
// editor ref synthesizes against the same editor — passes through this guard.
- dC(e),
+ mC(e),
e.registerRootListener((n, r) => {
r !== null && r.removeEventListener("keydown", t), n !== null && n.addEventListener("keydown", t);
})
);
}, [e]), null;
}
-function yd(e) {
+function xd(e) {
return e.includes("\\") || e.includes("/");
}
-function xO({ logger: e }) {
+function _O({ logger: e }) {
const [t] = Pe();
- return J(() => Ye(
+ return J(() => Xe(
// When the backslash or forward slash key is typed.
t.registerCommand(Jn, (n) => n.key !== "\\" && n.key !== "/" ? !1 : (n.preventDefault(), !0), $r),
// When the backslash or forward slash character is pasted into the editor.
t.registerCommand(un, (n) => {
const r = n.clipboardData?.getData("text/plain");
- return !r || !yd(r) ? !1 : (e?.info("CommandMenuPlugin: paste containing backslash or forward slash ignored."), n.preventDefault(), !0);
+ return !r || !xd(r) ? !1 : (e?.info("CommandMenuPlugin: paste containing backslash or forward slash ignored."), n.preventDefault(), !0);
}, $r),
// When the backslash or forward slash character is dragged into the editor.
- t.registerCommand(ql, (n) => {
+ t.registerCommand(Kl, (n) => {
const r = n.dataTransfer?.getData("text/plain");
- return !r || !yd(r) ? !1 : (e?.info("CommandMenuPlugin: drag containing backslash or forward slash ignored."), n.preventDefault(), !0);
+ return !r || !xd(r) ? !1 : (e?.info("CommandMenuPlugin: drag containing backslash or forward slash ignored."), n.preventDefault(), !0);
}, $r)
), [t, e]), null;
}
-const cl = "editor-context-menu";
-function bd(e) {
- return `${cl}-item-${e}`;
+const ul = "editor-context-menu";
+function Td(e) {
+ return `${ul}-item-${e}`;
}
-const TO = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta"]);
-function CO({ index: e, isSelected: t, onClick: n, onMouseMove: r, option: i }) {
+const EO = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta"]);
+function MO({ index: e, isSelected: t, onClick: n, onMouseMove: r, option: i }) {
let s = "item";
- return t && (s += " selected"), i.isDisabled && (s += " disabled"), O("li", { tabIndex: -1, className: s, role: "option", "aria-selected": t, "aria-disabled": i.isDisabled, id: bd(e), onMouseMove: r, onClick: i.isDisabled ? void 0 : n, children: O("span", { className: "text", children: i.title }) });
+ return t && (s += " selected"), i.isDisabled && (s += " disabled"), O("li", { tabIndex: -1, className: s, role: "option", "aria-selected": t, "aria-disabled": i.isDisabled, id: Td(e), onMouseMove: r, onClick: i.isDisabled ? void 0 : n, children: O("span", { className: "text", children: i.title }) });
}
-function vO({ options: e, selectedItemIndex: t, onOptionClick: n, onOptionMouseMove: r }) {
- return O("div", { className: "typeahead-popover", children: O("ul", { id: cl, role: "listbox", "aria-label": "Editor context menu", children: e.map((i, s) => O(CO, { index: s, isSelected: t === s, onClick: () => n(i, s), onMouseMove: () => r(s), option: i }, `${s}-${i.title}`)) }) });
+function PO({ options: e, selectedItemIndex: t, onOptionClick: n, onOptionMouseMove: r }) {
+ return O("div", { className: "typeahead-popover", children: O("ul", { id: ul, role: "listbox", "aria-label": "Editor context menu", children: e.map((i, s) => O(MO, { index: s, isSelected: t === s, onClick: () => n(i, s), onMouseMove: () => r(s), option: i }, `${s}-${i.title}`)) }) });
}
-let SO = 0;
-class Vo {
+let AO = 0;
+class Wo {
key;
title;
onSelect;
isDisabled;
constructor(t, n) {
- this.key = `context-menu-option-${SO++}`, this.title = t, this.onSelect = n.onSelect.bind(this), this.isDisabled = n.isDisabled || !1;
+ this.key = `context-menu-option-${AO++}`, this.title = t, this.onSelect = n.onSelect.bind(this), this.isDisabled = n.isDisabled || !1;
}
}
-function _O({ options: e } = {}) {
+function wO({ options: e } = {}) {
const [t] = Pe(), [n, r] = ze(() => !t.isEditable()), [i, s] = ze({
isOpen: !1,
x: 0,
y: 0
- }), [o, a] = ze(void 0), c = bt(() => {
+ }), [o, a] = ze(void 0), c = kt(() => {
const d = [
// Cut/Copy with nothing selected leave the clipboard alone rather than writing a placeholder
// over it — `registerEmptyCopyGuard` (mounted below) claims the command, so no selection
// check is needed here. They are not disabled in that case, because this option list is
// built once per editor rather than per menu opening, so its `isDisabled` flags cannot track
// the live selection.
- new Vo("Cut", {
+ new Wo("Cut", {
onSelect: () => {
- qh(t);
+ Kh(t);
},
isDisabled: n
}),
- new Vo("Copy", {
+ new Wo("Copy", {
onSelect: () => {
- Lh(t);
+ Dh(t);
}
}),
- new Vo("Paste", {
+ new Wo("Paste", {
onSelect: () => {
- Dh(t);
+ Bh(t);
},
isDisabled: n
}),
- new Vo("Paste as Plain Text", {
+ new Wo("Paste as Plain Text", {
onSelect: () => {
- Kh(t);
+ Uh(t);
},
isDisabled: n
})
- ], p = (e ?? []).map((m) => new Vo(m.title, { onSelect: m.onSelect, isDisabled: m.isDisabled }));
+ ], p = (e ?? []).map((m) => new Wo(m.title, { onSelect: m.onSelect, isDisabled: m.isDisabled }));
return [...d, ...p];
}, [t, n, e]), l = ae(null), u = ae(null), f = Ke(() => {
s((d) => ({ ...d, isOpen: !1 })), a(void 0);
}, []);
- return J(() => dC(t), [t]), J(() => {
+ return J(() => mC(t), [t]), J(() => {
const d = (p) => {
const m = p.target;
- t.getRootElement() === m || dx(m) || (p.preventDefault(), u.current = document.activeElement, s({ isOpen: !0, x: p.clientX, y: p.clientY }), a(void 0));
+ t.getRootElement() === m || yx(m) || (p.preventDefault(), u.current = document.activeElement, s({ isOpen: !0, x: p.clientX, y: p.clientY }), a(void 0));
};
return t.registerRootListener((p, m) => {
m?.removeEventListener("contextmenu", d), p && p.addEventListener("contextmenu", d);
@@ -21180,7 +21180,7 @@ function _O({ options: e } = {}) {
h.onSelect();
}), f());
} else {
- if (TO.has(p.key))
+ if (EO.has(p.key))
return;
p.preventDefault(), p.stopPropagation();
}
@@ -21191,7 +21191,7 @@ function _O({ options: e } = {}) {
return;
const d = t.getRootElement();
if (d)
- return d.setAttribute("aria-controls", cl), () => {
+ return d.setAttribute("aria-controls", ul), () => {
d.removeAttribute("aria-controls"), d.removeAttribute("aria-activedescendant");
};
}, [t, i.isOpen]), J(() => {
@@ -21204,21 +21204,21 @@ function _O({ options: e } = {}) {
d.removeAttribute("aria-activedescendant");
return;
}
- d.setAttribute("aria-activedescendant", bd(o));
- const p = document.getElementById(cl), m = document.getElementById(bd(o));
+ d.setAttribute("aria-activedescendant", Td(o));
+ const p = document.getElementById(ul), m = document.getElementById(Td(o));
if (!p || !m)
return;
const h = p.getBoundingClientRect(), g = m.getBoundingClientRect(), y = g.top - h.top + p.scrollTop, b = g.bottom - h.top + p.scrollTop;
y < p.scrollTop ? p.scrollTop = y : b > p.scrollTop + p.clientHeight && (p.scrollTop = b - p.clientHeight);
}, [t, i.isOpen, o]), J(() => t.registerEditableListener((d) => {
r(!d);
- }), [t]), Po(() => {
+ }), [t]), Ao(() => {
const d = l.current;
if (!d)
return;
const { width: p, height: m } = d.getBoundingClientRect(), h = Math.max(0, Math.min(i.x, globalThis.innerWidth - p)), g = Math.max(0, Math.min(i.y, globalThis.innerHeight - m));
d.style.left = `${h}px`, d.style.top = `${g}px`, d.style.visibility = "visible";
- }, [i.isOpen, i.x, i.y]), i.isOpen ? D0.createPortal(O("div", { ref: l, className: "typeahead-popover auto-embed-menu", style: {
+ }, [i.isOpen, i.x, i.y]), i.isOpen ? z0.createPortal(O("div", { ref: l, className: "typeahead-popover auto-embed-menu", style: {
left: i.x,
position: "fixed",
top: i.y,
@@ -21226,7 +21226,7 @@ function _O({ options: e } = {}) {
visibility: "hidden",
width: 200,
zIndex: 9999
- }, onPointerDown: (d) => d.stopPropagation(), children: O(vO, { options: c, selectedItemIndex: o, onOptionClick: (d) => {
+ }, onPointerDown: (d) => d.stopPropagation(), children: O(PO, { options: c, selectedItemIndex: o, onOptionClick: (d) => {
d.isDisabled || (t.update(() => {
d.onSelect();
}), f());
@@ -21234,21 +21234,21 @@ function _O({ options: e } = {}) {
a((p) => p === d ? p : d);
} }) }), document.body) : null;
}
-function EO(e, t) {
+function NO(e, t) {
return e.startContainer === t.node && e.startOffset === t.offset;
}
-function MO(e) {
- if (!C0(e.node))
+function OO(e) {
+ if (!M0(e.node))
return "before";
const t = e.node.nodeValue?.length ?? 0;
return e.offset * 2 < t ? "before" : "after";
}
-function PO(e, t) {
- return t && Un(e) || Ut(e);
+function $O(e, t) {
+ return t && Bn(e) || Bt(e);
}
-function df(e, t, n, r) {
+function gf(e, t, n, r) {
const i = qr(t.node);
- if (!on(i) || PO(i, r))
+ if (!on(i) || $O(i, r))
return;
const s = e.getElementByKey(i.getKey());
if (!s || s === t.node || !s.contains(t.node))
@@ -21260,22 +21260,22 @@ function df(e, t, n, r) {
if (!(a < 0))
return { node: o, offset: n === "before" ? a : a + 1 };
}
-function AO(e, t) {
+function RO(e, t) {
if (M())
return !1;
- const n = e.getRootElement(), r = Jb(n?.ownerDocument.defaultView ?? null);
+ const n = e.getRootElement(), r = ek(n?.ownerDocument.defaultView ?? null);
if (!r || r.rangeCount === 0)
return !1;
const { anchorNode: i, anchorOffset: s, focusNode: o, focusOffset: a } = r;
- if (!i || !o || !Yb(e, i, o))
+ if (!i || !o || !tk(e, i, o))
return !1;
const c = { node: i, offset: s }, l = { node: o, offset: a };
let u, f;
if (r.isCollapsed)
- u = df(e, c, MO(c), !0), f = u;
+ u = gf(e, c, OO(c), !0), f = u;
else {
- const g = EO(r.getRangeAt(0), c);
- u = df(e, c, g ? "before" : "after", !1), f = df(e, l, g ? "after" : "before", !1);
+ const g = NO(r.getRangeAt(0), c);
+ u = gf(e, c, g ? "before" : "after", !1), f = gf(e, l, g ? "after" : "before", !1);
}
if (!u && !f)
return !1;
@@ -21284,10 +21284,10 @@ function AO(e, t) {
anchorOffset: d.offset,
focusNode: p.node,
focusOffset: p.offset
- }, h = Dl(m, e);
+ }, h = Bl(m, e);
return h ? (Mt(h), h.dirty = !t, t) : !1;
}
-function wO() {
+function IO() {
const [e] = Pe(), t = ae(!1), n = ae(!1);
return J(() => {
const r = (s) => {
@@ -21304,31 +21304,31 @@ function wO() {
const c = s?.ownerDocument;
c?.addEventListener("pointerdown", r, !0), c?.addEventListener("pointerup", i, !0), c?.addEventListener("pointercancel", i, !0);
});
- }, [e]), J(() => e.registerCommand(Nn, () => (AO(e, t.current) && (n.current = !0), !1), ye), [e]), null;
+ }, [e]), J(() => e.registerCommand(On, () => (RO(e, t.current) && (n.current = !0), !1), ye), [e]), null;
}
-function NO() {
+function LO() {
const [e] = Pe();
return J(() => e.registerCommand(Jn, (t) => {
const { key: n, shiftKey: r, metaKey: i, ctrlKey: s, altKey: o } = t;
- if (!(mr ? i : s) || o)
+ if (!(yr ? i : s) || o)
return !1;
const a = n.toLowerCase();
return !(a === "z" && !r) && !(a === "y" || a === "z" && r) ? !1 : (t.preventDefault(), !0);
}, ye), [e]), null;
}
-function OO({ isEditable: e }) {
+function qO({ isEditable: e }) {
const [t] = Pe();
- return Po(() => {
+ return Ao(() => {
t.setEditable(e);
}, [t, e]), null;
}
-const $O = "data-caret-host", mc = /* @__PURE__ */ new WeakMap();
-function RO(e) {
+const DO = "data-caret-host", mc = /* @__PURE__ */ new WeakMap();
+function KO(e) {
let t = mc.get(e);
- t || (t = { holders: 0, unregister: e.registerMutationListener(it, (s) => {
+ t || (t = { holders: 0, unregister: e.registerMutationListener(at, (s) => {
e.getEditorState().read(() => {
for (const [o, a] of s)
- a !== "destroyed" && e.getElementByKey(o)?.toggleAttribute($O, Et(ee(o)));
+ a !== "destroyed" && e.getElementByKey(o)?.toggleAttribute(DO, Et(ee(o)));
});
}, { skipInitialization: !0 }) }, mc.set(e, t)), t.holders++;
const n = t;
@@ -21337,13 +21337,13 @@ function RO(e) {
r || (r = !0, n.holders--, !(n.holders > 0) && (n.unregister(), mc.get(e) === n && mc.delete(e)));
};
}
-function pf() {
+function mf() {
const e = M();
if (!(!E(e) || !e.isCollapsed()))
return e.anchor.type === "text" ? e.anchor.key : void 0;
}
-function IO(e) {
- const t = Xb();
+function BO(e) {
+ const t = nk();
if (!E(t) || !t.isCollapsed())
return;
const n = e.getTextContent(), r = M(), i = E(r) && r.isCollapsed() && r.anchor.key === e.getKey() ? r.anchor.offset : void 0;
@@ -21353,100 +21353,100 @@ function IO(e) {
e.select(o, o);
}
}
-function Uh(e) {
+function Fh(e) {
const [t] = Pe(), n = ae(void 0), r = Ke((i) => {
let s = !1;
- const o = pf(), a = n.current, c = !!a && Et(ee(a));
+ const o = mf(), a = n.current, c = !!a && Et(ee(a));
a && !c && (n.current = void 0);
let l;
if (i) {
- const d = i.getParentOrThrow(), p = i.getIndexWithinParent() + 1, m = Ks(d, p), h = Hc(m) ? m : void 0;
+ const d = i.getParentOrThrow(), p = i.getIndexWithinParent() + 1, m = Ks(d, p), h = Gc(m) ? m : void 0;
if (h)
n.current = h.getKey(), l = h.getKey();
else {
- const g = lP();
+ const g = hP();
i.insertAfter(g), n.current = g.getKey(), l = g.getKey(), s = !0;
}
zn(d, p);
}
- const u = Xb(), f = E(u) && u.isCollapsed() ? u.anchor.key : void 0;
+ const u = nk(), f = E(u) && u.isCollapsed() ? u.anchor.key : void 0;
for (const d of /* @__PURE__ */ new Set([c ? a : void 0, f])) {
if (!d || d === o || d === l)
continue;
const p = ee(d);
!Et(p) || !p?.isAttached() || (p.remove(), s = !0, n.current === d && (n.current = void 0));
}
- !l && o && o !== n.current && Et(ee(o)) && (n.current = o), s && (_t(yo), _t(ma));
+ !l && o && o !== n.current && Et(ee(o)) && (n.current = o), s && (_t(bo), _t(ma));
}, []);
return J(() => {
const i = () => {
r(e());
}, s = (c) => {
- Et(c) || (n.current === c.getKey() && (n.current = void 0), Te(c, bo) && (Wt(c, bo, !1), IO(c)));
+ Et(c) || (n.current === c.getKey() && (n.current = void 0), Te(c, ko) && (Wt(c, ko, !1), BO(c)));
};
let o = !1;
- const a = Ye(
- t.registerCommand(Nn, () => (i(), !1), xi),
- t.registerCommand(fp, () => {
- const c = pf(), l = n.current ?? (c && Et(ee(c)) ? c : void 0);
+ const a = Xe(
+ t.registerCommand(On, () => (i(), !1), Ti),
+ t.registerCommand(pp, () => {
+ const c = mf(), l = n.current ?? (c && Et(ee(c)) ? c : void 0);
n.current = void 0;
const u = l ? ee(l) : void 0;
- if (!T(u) || !Et(u) || !u.isAttached())
+ if (!C(u) || !Et(u) || !u.isAttached())
return !1;
const f = u.getParentOrThrow(), d = u.getIndexWithinParent(), p = M(), m = E(p) && p.anchor.key === u.getKey() && p.focus.key === u.getKey();
- return u.remove(), m && ou(f, d, { announce: !1 }), _t(yo), _t(ma), _t(or), !1;
- }, xi),
+ return u.remove(), m && cu(f, d, { announce: !1 }), _t(bo), _t(ma), _t(or), !1;
+ }, Ti),
// Focus can return without a selectionchange (the host application refocusing the editor, a
// menu closing), leaving the caret on the hostless point blur left. Re-host in a later
// update, since Lexical can fire focus mid-commit against the frozen state, and only when
// the committed caret lacks a host: an update outside any event reads its selection from
// the DOM, which may not yet hold the committed caret. `editor.read` commits any pending
// update first, so the re-host's tags never cover someone else's edit.
- t.registerCommand(Kl, () => (queueMicrotask(() => {
+ t.registerCommand(Ul, () => (queueMicrotask(() => {
if (o)
return;
t.read(() => {
if (!e())
return !1;
- const l = pf();
- return !l || !Hc(ee(l));
+ const l = mf();
+ return !l || !Gc(ee(l));
}) && t.update(i);
- }), !1), xi),
- t.registerNodeTransform(it, s),
- RO(t)
+ }), !1), Ti),
+ t.registerNodeTransform(at, s),
+ KO(t)
);
return () => {
o = !0, a(), n.current = void 0;
};
}, [t, e, r]), r;
}
-function LO() {
+function UO() {
const e = M();
if (!E(e) || !e.isCollapsed())
return;
const { anchor: t } = e, n = t.getNode(), r = K(n) ? n : n.getParent();
if (!K(r))
return;
- const i = Nw(r);
+ const i = Lw(r);
if (i === void 0)
return;
let s = r.getChildAtIndex(i - 1);
- for (; s && Hc(s); )
+ for (; s && Gc(s); )
s = s.getPreviousSibling();
- if (!s || T(s) && s.isSimpleText())
+ if (!s || C(s) && s.isSimpleText())
return;
const o = s.getIndexWithinParent() + 1;
if (n.is(r))
return t.offset >= o && t.offset <= i ? s : void 0;
if (n.is(s))
- return T(s) && t.offset === s.getTextContentSize() ? s : void 0;
+ return C(s) && t.offset === s.getTextContentSize() ? s : void 0;
const a = n.getIndexWithinParent();
return a >= o && a <= i && t.offset === 0 ? s : void 0;
}
-function qO() {
- return Uh(LO), null;
+function FO() {
+ return Fh(UO), null;
}
-function Fh(e) {
+function zh(e) {
const t = e.getRootElement();
return !!t && t.contains(t.ownerDocument.activeElement);
}
@@ -21458,7 +21458,7 @@ function so(e, ...t) {
});
return n;
}
-function hf(e) {
+function yf(e) {
const t = e.getRootElement(), n = t?.ownerDocument.defaultView?.getSelection();
if (!t || !n?.anchorNode || !t.contains(n.anchorNode))
return;
@@ -21466,7 +21466,7 @@ function hf(e) {
const i = M();
if (!E(i))
return !1;
- const s = Dl(n, e);
+ const s = Bl(n, e);
return !!s && i.is(s);
}, { editor: e }) || n.removeAllRanges();
}
@@ -21478,7 +21478,7 @@ function Xs(e, t) {
}
return n === e ? t() : e.read(t);
}
-function DO() {
+function zO() {
const e = M();
if (!E(e) || !e.isCollapsed())
return;
@@ -21495,12 +21495,12 @@ function DO() {
if (s === void 0 || Oe(s))
return i;
}
-const KO = [
- In,
- cs,
- Ei
+const jO = [
+ Ln,
+ ls,
+ Mi
];
-function UO(e, t, n) {
+function VO(e, t, n) {
const r = M();
if (!E(r) || !r.isCollapsed())
return !1;
@@ -21510,105 +21510,105 @@ function UO(e, t, n) {
const s = i.getParentOrThrow(), o = i.getIndexWithinParent();
return i.remove(), s.select(o, o), e.dispatchCommand(t, n), !0;
}
-function FO() {
+function WO() {
const [e] = Pe();
- return Uh(DO), J(() => Ye(...KO.map((t) => e.registerCommand(t, (n) => UO(e, t, n), Nt))), [e]), null;
+ return Fh(zO), J(() => Xe(...jO.map((t) => e.registerCommand(t, (n) => VO(e, t, n), Nt))), [e]), null;
}
-function BO(e, t) {
+function HO(e, t) {
if (!E(e) || !e.isCollapsed())
return;
const { anchor: n } = e, r = n.getNode();
if (pn(r)) {
const a = r.getChildAtIndex(t === "backward" ? n.offset - 1 : n.offset);
- return Ie(a) ? uy(a, t, !0) : void 0;
+ return Ie(a) ? gy(a, t, !0) : void 0;
}
let i = Oa(r);
if (!i || n.type === "text" && !(t === "backward" ? n.offset === 0 : n.offset === r.getTextContentSize()))
return;
- let s = pC(e, t, i);
+ let s = yC(e, t, i);
const o = [];
for (; ; ) {
for (; s; ) {
if (Ie(s))
o.push(s);
- else if (!HO(s))
+ else if (!QO(s))
break;
- s = wi(s, t, i);
+ s = Oi(s, t, i);
}
if (s || !K(i))
break;
const a = Oa(i.getParentOrThrow());
if (!a)
return;
- s = wi(i, t, a), i = a;
+ s = Oi(i, t, a), i = a;
}
if (o.length > 0)
return { nodes: t === "backward" ? o.reverse() : o, placement: "inline" };
- if (!(s || !ct(i)))
- return uy(i, t, !1);
+ if (!(s || !st(i)))
+ return gy(i, t, !1);
}
-function Xi(e) {
+function Qi(e) {
if (!E(e) || e.isCollapsed())
return [];
const t = [];
for (const n of e.getNodes()) {
- const r = GO(n);
+ const r = ZO(n);
r && !t.some((i) => i.is(r)) && t.push(r);
}
return t;
}
-function ly(e, t) {
+function hy(e, t) {
if (!E(e) || !e.isCollapsed())
return [];
const n = Oa(e.anchor.getNode());
if (!n)
return [];
const r = [];
- let i = pC(e, t, n);
+ let i = yC(e, t, n);
for (; i; )
- Ie(i) && r.push(i), i = wi(i, t, n);
+ Ie(i) && r.push(i), i = Oi(i, t, n);
return t === "backward" ? r.reverse() : r;
}
-function zO(e, t) {
+function GO(e, t) {
const n = e.nodes[0], r = e.nodes[e.nodes.length - 1];
if (e.placement === "inline") {
const s = Oa(n);
- return s ? (t === "backward" ? gC(n, s) : Bh(r, s), !0) : !1;
+ return s ? (t === "backward" ? kC(n, s) : jh(r, s), !0) : !1;
}
if (t === "backward") {
const s = n.getPreviousSibling();
- return ct(s) ? (JO(s), !0) : !1;
+ return st(s) ? (e$(s), !0) : !1;
}
const i = r.getNextSibling();
- return ct(i) ? (Sn(i) || YO(i), !0) : !1;
+ return st(i) ? (Sn(i) || t$(i), !0) : !1;
}
-function jO(e, t) {
+function JO(e, t) {
if (e.placement === "inline")
return !0;
const n = t === "backward" ? e.nodes[0].getPreviousSibling() : e.nodes[e.nodes.length - 1].getNextSibling();
- return ct(n);
+ return st(n);
}
-function VO(e, t) {
+function YO(e, t) {
const n = Oa(t.anchor.getNode()), r = e.getNode();
return !!n && (n.is(r) || n.isParentOf(r));
}
-function WO(e) {
+function XO(e) {
return e.map((t) => {
const n = t.getMarker();
return n ? { tag: t.getTag(), marker: n } : { tag: t.getTag() };
});
}
function Oa(e) {
- return ct(e) || K(e) ? e : We(e, (t) => ct(t) || K(t)) ?? void 0;
+ return st(e) || K(e) ? e : We(e, (t) => st(t) || K(t)) ?? void 0;
}
-function pC(e, t, n) {
+function yC(e, t, n) {
const { anchor: r } = e, i = r.getNode();
if (r.type === "text" || !A(i))
- return wi(i, t, n);
+ return Oi(i, t, n);
const s = i.getChildAtIndex(t === "backward" ? r.offset - 1 : r.offset);
- return s ? uu(s, t, n) : i.is(n) ? void 0 : wi(i, t, n);
+ return s ? du(s, t, n) : i.is(n) ? void 0 : Oi(i, t, n);
}
-function hC(e, t, n) {
+function bC(e, t, n) {
let r = e;
for (; ; ) {
const i = t === "backward" ? r.getPreviousSibling() : r.getNextSibling();
@@ -21620,19 +21620,19 @@ function hC(e, t, n) {
r = s;
}
}
-function uu(e, t, n) {
+function du(e, t, n) {
let r = e;
for (; r; ) {
if (Ie(r) || K(r) || !A(r))
return r;
- r = (t === "backward" ? r.getLastChild() : r.getFirstChild()) ?? hC(r, t, n);
+ r = (t === "backward" ? r.getLastChild() : r.getFirstChild()) ?? bC(r, t, n);
}
}
-function wi(e, t, n) {
- const r = hC(e, t, n);
- return r ? uu(r, t, n) : void 0;
+function Oi(e, t, n) {
+ const r = bC(e, t, n);
+ return r ? du(r, t, n) : void 0;
}
-function uy(e, t, n) {
+function gy(e, t, n) {
const r = [];
let i = n ? e : t === "backward" ? e.getPreviousSibling() : e.getNextSibling();
for (; Ie(i); )
@@ -21640,39 +21640,39 @@ function uy(e, t, n) {
if (r.length !== 0)
return { nodes: t === "backward" ? r.reverse() : r, placement: "block" };
}
-function HO(e) {
- return T(e) && e.getTextContentSize() === 0;
+function QO(e) {
+ return C(e) && e.getTextContentSize() === 0;
}
-function GO(e) {
+function ZO(e) {
let t = Ie(e) ? e : void 0;
for (const n of e.getParents())
Ie(n) && (t = n);
return t;
}
-function gC(e, t) {
- const n = wi(e, "backward", t);
- T(n) && !n.isToken() ? n.select(n.getTextContentSize(), n.getTextContentSize()) : fu(e.getParentOrThrow(), e.getIndexWithinParent());
+function kC(e, t) {
+ const n = Oi(e, "backward", t);
+ C(n) && !n.isToken() ? n.select(n.getTextContentSize(), n.getTextContentSize()) : pu(e.getParentOrThrow(), e.getIndexWithinParent());
}
-function Bh(e, t) {
- const n = wi(e, "forward", t);
- T(n) && !n.isToken() ? n.select(0, 0) : fu(e.getParentOrThrow(), e.getIndexWithinParent() + 1);
+function jh(e, t) {
+ const n = Oi(e, "forward", t);
+ C(n) && !n.isToken() ? n.select(0, 0) : pu(e.getParentOrThrow(), e.getIndexWithinParent() + 1);
}
-function fu(e, t) {
+function pu(e, t) {
const n = dr();
n.anchor.set(e.getKey(), t, "element"), n.focus.set(e.getKey(), t, "element"), Mt(n);
}
-function JO(e) {
+function e$(e) {
const t = e.getLastChild();
- let n = t ? uu(t, "backward", e) : void 0;
+ let n = t ? du(t, "backward", e) : void 0;
for (; Ie(n); )
- n = wi(n, "backward", e);
- n ? T(n) ? n.select(n.getTextContentSize(), n.getTextContentSize()) : Bh(n, e) : fu(e, 0);
+ n = Oi(n, "backward", e);
+ n ? C(n) ? n.select(n.getTextContentSize(), n.getTextContentSize()) : jh(n, e) : pu(e, 0);
}
-function YO(e) {
- const t = e.getFirstChild(), n = t ? uu(t, "forward", e) : void 0;
- n ? T(n) ? n.select(0, 0) : K(n) ? Bh(n, e) : gC(n, e) : fu(e, 0);
+function t$(e) {
+ const t = e.getFirstChild(), n = t ? du(t, "forward", e) : void 0;
+ n ? C(n) ? n.select(0, 0) : K(n) ? jh(n, e) : kC(n, e) : pu(e, 0);
}
-function kr(e) {
+function xr(e) {
if (e.getIsCollapsed() !== !1)
return [];
const t = [];
@@ -21682,45 +21682,45 @@ function kr(e) {
t.push(r);
}
const n = Dt(e);
- return n && t.push(n), t.length > 0 && t.every((r) => T(r) && r.getMode() === "token") ? t : [];
+ return n && t.push(n), t.length > 0 && t.every((r) => C(r) && r.getMode() === "token") ? t : [];
}
-function XO(e) {
+function n$(e) {
const t = e.getParent();
if (K(t))
- return kr(t).some((n) => n.is(e)) ? t : void 0;
+ return xr(t).some((n) => n.is(e)) ? t : void 0;
}
function Za(e) {
- const t = kr(e), n = t[t.length - 1];
+ const t = xr(e), n = t[t.length - 1];
return n ? n.getIndexWithinParent() + 1 : 0;
}
-function ea(e) {
+function ta(e) {
if (e.getIsCollapsed() !== !1)
return;
const t = e.getLastChild();
return $(t) && t.getMarkerSyntax() === "closing" && t.getMode() === "token" ? t : void 0;
}
-function mC(e) {
+function xC(e) {
const t = e.getNode();
if (e.type === "text") {
const r = t.getParent();
- if (K(r) && ea(r)?.is(t))
+ if (K(r) && ta(r)?.is(t))
return e.offset > 0 ? r : void 0;
if (e.offset !== 0)
return;
const i = t.getPreviousSibling();
- return K(i) && ea(i) ? i : void 0;
+ return K(i) && ta(i) ? i : void 0;
}
if (K(t)) {
- const r = ea(t);
+ const r = ta(t);
return r && e.offset > r.getIndexWithinParent() ? t : void 0;
}
if (!A(t) || e.offset === 0)
return;
const n = t.getChildAtIndex(e.offset - 1);
- return K(n) && ea(n) ? n : void 0;
+ return K(n) && ta(n) ? n : void 0;
}
-function yC(e) {
- const t = e.getNode(), n = (i) => K(i) && kr(i).length > 0;
+function TC(e) {
+ const t = e.getNode(), n = (i) => K(i) && xr(i).length > 0;
if (e.type === "text") {
if (e.offset !== t.getTextContentSize())
return;
@@ -21734,100 +21734,100 @@ function yC(e) {
const r = t.getChildAtIndex(e.offset);
return n(r) ? r : void 0;
}
-function bC(e) {
+function CC(e) {
if (e.type !== "text")
return;
- const t = e.getNode(), n = XO(t);
+ const t = e.getNode(), n = n$(t);
if (n)
- return QO(n, t, e.offset) ? void 0 : n;
+ return r$(n, t, e.offset) ? void 0 : n;
}
-function QO(e, t, n) {
- const r = kr(e), i = r[r.length - 1];
+function r$(e, t, n) {
+ const r = xr(e), i = r[r.length - 1];
return i !== void 0 && i.is(t) && n === i.getTextContentSize();
}
-function ZO(e) {
- const t = kr(e), n = t[t.length - 1];
- T(n) ? n.select(n.getTextContentSize(), n.getTextContentSize()) : zn(e, Za(e));
+function i$(e) {
+ const t = xr(e), n = t[t.length - 1];
+ C(n) ? n.select(n.getTextContentSize(), n.getTextContentSize()) : zn(e, Za(e));
}
-function e$() {
+function s$() {
const e = M();
if (!E(e))
return !1;
if (!e.isCollapsed())
- return Vh(e);
- const t = ul(e.anchor) ?? mC(e.anchor);
+ return Hh(e);
+ const t = dl(e.anchor) ?? xC(e.anchor);
if (t) {
- const r = t$(t);
- return e.anchor.is(r) ? !1 : (kC(e, r), !0);
+ const r = o$(t);
+ return e.anchor.is(r) ? !1 : (vC(e, r), !0);
}
- const n = yC(e.anchor) ?? bC(e.anchor);
- return n ? (ZO(n), !0) : !1;
+ const n = TC(e.anchor) ?? CC(e.anchor);
+ return n ? (i$(n), !0) : !1;
}
-function zh(e) {
- const t = kr(e), n = t[t.length - 1];
- return T(n) ? fn(n.getKey(), n.getTextContentSize(), "text") : fn(e.getKey(), Za(e), "element");
+function Vh(e) {
+ const t = xr(e), n = t[t.length - 1];
+ return C(n) ? fn(n.getKey(), n.getTextContentSize(), "text") : fn(e.getKey(), Za(e), "element");
}
-function ll(e) {
+function fl(e) {
const t = e.getLastChild();
return $(t) && t.getMarkerSyntax() === "closing" && t.getMarker() === e.getMarker() ? e.getChildrenSize() - 1 : e.getChildrenSize();
}
-function kd(e) {
- const t = ll(e);
+function Cd(e) {
+ const t = fl(e);
if (t === e.getChildrenSize())
return;
const n = e.getChildAtIndex(t);
- return T(n) ? n : void 0;
+ return C(n) ? n : void 0;
}
-function jh(e) {
- const t = ll(e);
+function Wh(e) {
+ const t = fl(e);
if (t > Za(e)) {
const n = e.getChildAtIndex(t - 1), r = A(n) ? n.getLastDescendant() : n;
- if (T(r))
+ if (C(r))
return fn(r.getKey(), r.getTextContentSize(), "text");
}
- return zh(e);
+ return Vh(e);
}
-function t$(e) {
- const t = ea(e);
- return t ? fn(t.getKey(), 0, "text") : jh(e);
+function o$(e) {
+ const t = ta(e);
+ return t ? fn(t.getKey(), 0, "text") : Wh(e);
}
-function ul(e) {
+function dl(e) {
const t = e.getNode(), n = t.getParent();
- if (K(n) && kr(n).length > 0 && kd(n)?.is(t))
+ if (K(n) && xr(n).length > 0 && Cd(n)?.is(t))
return n;
if (e.type !== "element")
return;
- if (K(t) && kr(t).length > 0 && kd(t))
- return e.offset > ll(t) || e.offset === ll(t) && e.offset > Za(t) ? t : void 0;
+ if (K(t) && xr(t).length > 0 && Cd(t))
+ return e.offset > fl(t) || e.offset === fl(t) && e.offset > Za(t) ? t : void 0;
if (!A(t))
return;
const r = t.getChildAtIndex(e.offset - 1);
- return K(r) && kr(r).length > 0 && !r.getNextSibling() ? r : void 0;
+ return K(r) && xr(r).length > 0 && !r.getNextSibling() ? r : void 0;
}
-function kC(e, t) {
+function vC(e, t) {
e.anchor.set(t.key, t.offset, t.type), e.focus.set(t.key, t.offset, t.type);
}
-function xd(e) {
+function vd(e) {
const t = hn(e);
- return t && kr(t).length > 0 ? t : void 0;
+ return t && xr(t).length > 0 ? t : void 0;
}
-function n$(e) {
+function a$(e) {
for (const t of [e.anchor, e.focus]) {
- const n = xd(t.getNode()) ?? yC(t) ?? mC(t) ?? ul(t);
+ const n = vd(t.getNode()) ?? TC(t) ?? xC(t) ?? dl(t);
if (n)
return n;
}
for (const t of e.getNodes()) {
- const n = xd(t);
+ const n = vd(t);
if (n)
return n;
}
}
-function Vh(e) {
- const t = n$(e);
+function Hh(e) {
+ const t = a$(e);
if (!t)
return !1;
- const n = zh(t), r = jh(t);
+ const n = Vh(t), r = Wh(t);
let i = !1;
for (const s of [e.anchor, e.focus]) {
const o = s.isBefore(n) ? n : r.isBefore(s) ? r : void 0;
@@ -21835,11 +21835,11 @@ function Vh(e) {
}
return i;
}
-function fy(e, t) {
+function my(e, t) {
const n = dr();
return n.anchor.set(e.key, e.offset, e.type), n.focus.set(t.key, t.offset, t.type), n.getTextContent();
}
-function dy(e, t) {
+function yy(e, t) {
const n = e.getElementByKey(t.key);
if (!n)
return;
@@ -21852,11 +21852,11 @@ function dy(e, t) {
const [o] = Array.from(r.getClientRects());
return o?.top;
}
-function py(e, t, n) {
- const r = dy(e, t), i = dy(e, n);
+function by(e, t, n) {
+ const r = yy(e, t), i = yy(e, n);
return r !== void 0 && i !== void 0 && Math.abs(r - i) >= 1;
}
-function r$(e) {
+function c$(e) {
if (e.type === "element") {
const n = e.getNode();
return A(n) ? n.getChildAtIndex(e.offset) ?? void 0 : void 0;
@@ -21864,71 +21864,71 @@ function r$(e) {
const t = e.getNode();
return t.getTextContentSize() === e.offset ? t.getNextSibling() ?? void 0 : void 0;
}
-function xC(e, t, n, r) {
- const i = t.anchor, s = ul(i);
+function SC(e, t, n, r) {
+ const i = t.anchor, s = dl(i);
if (s) {
- const f = i.type === "text" && i.offset === 0, d = jh(s);
- return kC(t, d), n && f && !ul(d) ? xC(e, t, n, r) : !0;
+ const f = i.type === "text" && i.offset === 0, d = Wh(s);
+ return vC(t, d), n && f && !dl(d) ? SC(e, t, n, r) : !0;
}
- const o = xd(i.getNode());
+ const o = vd(i.getNode());
if (!o) {
if (n)
return !1;
- const f = r$(t.focus);
- return K(f) && kr(f).length > 0;
+ const f = c$(t.focus);
+ return K(f) && xr(f).length > 0;
}
- if (bC(i))
+ if (CC(i))
return !0;
- const a = zh(o);
+ const a = Vh(o);
if (n) {
if (!(a.isBefore(i) && !a.is(i)))
return !0;
- const f = fy(a, i);
- return f === "" ? !0 : r === "character" || r === "word" && /[\p{L}\p{N}]/u.test(f) || r === "line" && py(e, a, i) ? !1 : (t.anchor.set(a.key, a.offset, a.type), t.removeText(), !0);
+ const f = my(a, i);
+ return f === "" ? !0 : r === "character" || r === "word" && /[\p{L}\p{N}]/u.test(f) || r === "line" && by(e, a, i) ? !1 : (t.anchor.set(a.key, a.offset, a.type), t.removeText(), !0);
}
if (i.isBefore(a))
return !0;
- const c = kd(o);
+ const c = Cd(o);
if (!c)
return !1;
- const l = fn(c.getKey(), 0, "text"), u = fy(i, l);
- return u === "" ? !0 : r === "character" || r === "word" && /[\p{L}\p{N}]/u.test(u) || r === "line" && py(e, i, l) ? !1 : (t.focus.set(l.key, l.offset, l.type), t.removeText(), !0);
+ const l = fn(c.getKey(), 0, "text"), u = my(i, l);
+ return u === "" ? !0 : r === "character" || r === "word" && /[\p{L}\p{N}]/u.test(u) || r === "line" && by(e, i, l) ? !1 : (t.focus.set(l.key, l.offset, l.type), t.removeText(), !0);
}
-function i$() {
+function l$() {
const [e] = Pe();
return J(() => {
const t = (s) => () => {
const o = M();
- return !E(o) || o.isCollapsed() || !Vh(o) ? !1 : s && o.isCollapsed();
+ return !E(o) || o.isCollapsed() || !Hh(o) ? !1 : s && o.isCollapsed();
}, n = t(!1), r = t(!0), i = (s) => (o) => {
const a = M();
- return E(a) ? a.isCollapsed() ? xC(e, a, o, s) : r() : !1;
+ return E(a) ? a.isCollapsed() ? SC(e, a, o, s) : r() : !1;
};
- return Ye(e.registerCommand(Yr, n, ye), e.registerCommand(un, n, ye), e.registerCommand(Ti, n, ye), e.registerCommand(Uc, n, ye), e.registerCommand(In, i("character"), ye), e.registerCommand(cs, i("word"), ye), e.registerCommand(Ei, i("line"), ye), e.registerCommand(lp, r, ye), e.registerCommand(wn, r, ye));
+ return Xe(e.registerCommand(Xr, n, ye), e.registerCommand(un, n, ye), e.registerCommand(Ci, n, ye), e.registerCommand(Uc, n, ye), e.registerCommand(Ln, i("character"), ye), e.registerCommand(ls, i("word"), ye), e.registerCommand(Mi, i("line"), ye), e.registerCommand(fp, r, ye), e.registerCommand(Nn, r, ye));
}, [e]), J(() => {
const t = () => {
- e$() && e.dispatchCommand(bp, void 0);
+ s$() && e.dispatchCommand(xp, void 0);
};
- return Ye(
- e.registerCommand(Nn, () => (t(), !1), xi),
+ return Xe(
+ e.registerCommand(On, () => (t(), !1), Ti),
// Select-all is the rich-text plugin's `$selectAll`, confined in the same update rather than
// after the selection change it announces, which an edit may come before.
- e.registerCommand(Qb, () => (v0(), t(), !0), Je)
+ e.registerCommand(rk, () => (P0(), t(), !0), Je)
);
}, [e]), null;
}
-const Td = "confirmed-delete";
-function du({ anchor: e, focus: t }) {
+const Sd = "confirmed-delete";
+function hu({ anchor: e, focus: t }) {
const n = ({ key: r, offset: i, type: s }) => ({ key: r, offset: i, type: s });
return { anchor: n(e), focus: n(t) };
}
-function fl(e, t) {
+function pl(e, t) {
return e.key === t.key && e.offset === t.offset && e.type === t.type;
}
function yc(e) {
return { key: e.key, offset: e.offset, type: e.type };
}
-function TC(e) {
+function _C(e) {
if (e.key === "Enter" && !e.shiftKey)
return "insertParagraph";
if (e.key === "Backspace")
@@ -21938,60 +21938,60 @@ function TC(e) {
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey)
return "insertText";
}
-function Ni(e) {
- return e ? ct(e) ? e : We(e, (n) => ct(n)) ?? void 0 : void 0;
+function Br(e) {
+ return e ? st(e) ? e : We(e, (n) => st(n)) ?? void 0 : void 0;
}
-function CC(e) {
+function EC(e) {
if (!E(e))
return !1;
const t = /* @__PURE__ */ new Set();
for (const n of e.getNodes()) {
- if (!e.isCollapsed() && ot(n))
+ if (!e.isCollapsed() && Ye(n))
return !0;
- const r = Ni(n);
+ const r = Br(n);
r && t.add(r.getKey());
}
return t.size > 1;
}
-function vC(e) {
- e.isCollapsed() || EC(e.isBackward() ? e.focus : e.anchor);
+function MC(e) {
+ e.isCollapsed() || wC(e.isBackward() ? e.focus : e.anchor);
}
-function dl(e) {
- const t = SC(e);
- if (!t || _C(t))
+function hl(e) {
+ const t = PC(e);
+ if (!t || AC(t))
return !1;
- EC(e.anchor);
+ wC(e.anchor);
const { key: n, offset: r, type: i } = e.anchor;
return e.focus.set(n, r, i), !0;
}
-function SC(e) {
+function PC(e) {
if (!E(e) || !e.isCollapsed())
return;
const { anchor: t } = e, n = t.getNode();
if (!(t.type !== "element" || t.offset !== 0 || !ke(n)))
- return Un(n.getFirstChild()) ? n : void 0;
+ return Bn(n.getFirstChild()) ? n : void 0;
}
-function _C(e) {
+function AC(e) {
const t = e.getChildAtIndex(1);
- return on(t) || cu(t);
+ return on(t) || uu(t);
}
-function EC(e) {
+function wC(e) {
const t = e.getNode();
- if (e.type !== "element" || e.offset !== 0 || !ke(t) || !Un(t.getFirstChild()))
+ if (e.type !== "element" || e.offset !== 0 || !ke(t) || !Bn(t.getFirstChild()))
return !1;
const n = Ks(t, 1);
return n ? e.set(n.getKey(), 0, "text") : e.set(t.getKey(), 1, "element"), !0;
}
-function Wh(e) {
+function Gh(e) {
return E(e) && e.isCollapsed() && e.anchor.type === "element" || !E(e) && !Ns(e) ? !1 : e.getNodes().some((t) => Oe(t));
}
-function pu(e) {
+function gu(e) {
if (!E(e) || !e.isCollapsed())
return !1;
- const { anchor: t } = e, n = t.getNode(), r = Ni(n);
+ const { anchor: t } = e, n = t.getNode(), r = Br(n);
if (!r || !A(r))
return !1;
- const i = Un(r.getFirstChild()) ? 1 : 0;
+ const i = Bn(r.getFirstChild()) ? 1 : 0;
if (n.is(r))
return t.offset <= i;
if (t.offset !== 0 && !Et(n))
@@ -22005,16 +22005,16 @@ function pu(e) {
}
return !0;
}
-function MC(e) {
- if (!e || !pu(e) || !E(e))
+function NC(e) {
+ if (!e || !gu(e) || !E(e))
return;
- const t = Ni(e.anchor.getNode());
+ const t = Br(e.anchor.getNode());
return ke(t) && _a(t) ? t : void 0;
}
-function PC(e) {
+function OC(e) {
if (!E(e) || !e.isCollapsed())
return !1;
- const { anchor: t } = e, n = t.getNode(), r = Ni(n);
+ const { anchor: t } = e, n = t.getNode(), r = Br(n);
if (!r)
return !1;
if (A(n)) {
@@ -22030,10 +22030,10 @@ function PC(e) {
}
return !0;
}
-function hy(e, t) {
- return !!Cd(e, t);
+function ky(e, t) {
+ return !!_d(e, t);
}
-function Cd(e, t) {
+function _d(e, t) {
if (!E(e) || !e.isCollapsed())
return;
const { anchor: n } = e, r = n.getNode();
@@ -22056,17 +22056,17 @@ function Cd(e, t) {
const s = r.getNextSibling();
return Oe(s) ? s : void 0;
}
-function pl(e, t) {
+function gl(e, t) {
if (!E(e))
return !1;
- const n = Ni(e.anchor.getNode());
+ const n = Br(e.anchor.getNode());
return n ? !!(t === "backward" ? n.getPreviousSibling() : n.getNextSibling()) : !1;
}
-function Ci(e) {
- return Wh(e) || CC(e);
+function vi(e) {
+ return Gh(e) || EC(e);
}
-function uo(e, t) {
- if (Wh(e) || CC(e))
+function fo(e, t) {
+ if (Gh(e) || EC(e))
return !0;
if (!E(e) || !e.isCollapsed())
return !1;
@@ -22074,100 +22074,144 @@ function uo(e, t) {
case "insertParagraph":
return !0;
case "deleteBackward":
- return !!MC(e) || pu(e) && pl(e, "backward") || hy(e, "backward");
+ return !!NC(e) || gu(e) && gl(e, "backward") || ky(e, "backward");
case "deleteForward": {
- const n = SC(e);
- if (n && _C(n))
+ const n = PC(e);
+ if (n && AC(n))
return !0;
const r = e.clone();
- return dl(r), PC(r) && pl(r, "forward") || hy(r, "forward");
+ return hl(r), OC(r) && gl(r, "forward") || ky(r, "forward");
}
case "insertText":
return !1;
}
}
-function AC(e) {
- return iC(e) || Ci(e);
+function $C(e) {
+ return cC(e) || vi(e);
}
-function s$(e, t) {
- const n = Tr(e);
+function u$(e, t) {
+ const n = pr(e);
if (n)
- return hl(n) ? { kind: "para", node: n } : void 0;
+ return ml(n) ? { kind: "para", node: n } : void 0;
if (!(!E(e) || !e.isCollapsed())) {
if (t === "deleteBackward") {
- const r = Cd(e, "backward");
+ const r = _d(e, "backward");
if (r)
return { kind: "verse", node: r };
- if (pu(e)) {
- const i = Ni(e.anchor.getNode());
- if (dt(i) && hl(i))
+ if (gu(e)) {
+ const i = Br(e.anchor.getNode());
+ if (!ot(i))
+ return;
+ const s = LC(i);
+ if (s)
+ return { kind: "para", node: s };
+ if (ml(i))
return { kind: "para", node: i };
}
return;
}
if (t === "deleteForward") {
- const r = Cd(e, "forward");
+ const r = _d(e, "forward");
if (r)
return { kind: "verse", node: r };
- if (PC(e) && pl(e, "forward")) {
- const s = Ni(e.anchor.getNode())?.getNextSibling();
- if (dt(s))
+ if (OC(e)) {
+ const i = Br(e.anchor.getNode());
+ if (ot(i) && (mu(i) || Yh(i)))
+ return { kind: "para", node: i };
+ const s = gl(e, "forward") ? i?.getNextSibling() : void 0;
+ if (ot(s))
return { kind: "para", node: s };
}
return;
}
}
}
-function o$(e) {
- if (!pu(e) || !pl(e, "backward") || !E(e))
+function f$(e) {
+ if (!gu(e) || !gl(e, "backward") || !E(e))
return !1;
- const t = Ni(e.anchor.getNode());
- return !dt(t) || !hl(t);
+ const t = Br(e.anchor.getNode());
+ return !ot(t) || !ml(t);
}
-function gy(e, t) {
- return e ? t.kind === "verse" ? Ns(e) && e.has(t.key) : t.kind === "selection" ? E(e) && !e.isCollapsed() && my(e, t) : Tr(e)?.getKey() === t.key ? !0 : E(e) && my(e, t) : !1;
+function xy(e, t) {
+ return e ? t.kind === "verse" ? Ns(e) && e.has(t.key) : t.kind === "selection" ? E(e) && !e.isCollapsed() && Ty(e, t) : pr(e)?.getKey() === t.key ? !0 : E(e) && Ty(e, t) : !1;
}
-function my(e, t) {
- return !t.anchor || !t.focus ? !1 : fl(e.anchor, t.anchor) && fl(e.focus, t.focus);
+function Ty(e, t) {
+ return !t.anchor || !t.focus ? !1 : pl(e.anchor, t.anchor) && pl(e.focus, t.focus);
}
-function a$(e) {
- return e.getChildren().every((t) => Un(t) || Zt(t) || an(t));
+function Jh(e) {
+ return e.getChildren().every((t) => Bn(t) || Zt(t) || an(t));
}
-function c$(e, t) {
- return a$(e) ? "removeEmptyPara" : t === "deleteForward" ? "joinNextPara" : "joinPreviousPara";
+function d$(e, t) {
+ return Jh(e) ? "removeEmptyPara" : t === "deleteForward" ? "joinNextPara" : "joinPreviousPara";
}
-function wC(e) {
- if (T(e)) {
+function p$(e, t, n) {
+ if (!E(e) || pr(e))
+ return "deleteBackward";
+ const r = Br(e.focus.getNode());
+ return (n === "deleteForward" ? t : t.getNextSibling())?.is(r) ? "deleteForward" : "deleteBackward";
+}
+function RC(e) {
+ if (C(e)) {
const t = e.getTextContentSize();
e.select(t, t);
} else A(e) ? e.selectEnd() : e.selectNext(0, 0);
}
-function hl(e) {
- return ct(e.getPreviousSibling());
+function IC(e) {
+ return st(e.getPreviousSibling());
}
-function vd(e) {
+function mu(e) {
+ return !$(e.getFirstChild()) && Jh(e) && st(e.getNextSibling());
+}
+function h$(e) {
+ return mu(e) && Ye(e.getPreviousSibling());
+}
+function Yh(e) {
+ const t = e.getNextSibling();
+ return ke(e) && !$(e.getFirstChild()) && Jh(e) && Ye(e.getPreviousSibling()) && (!t || Ye(t));
+}
+function ml(e) {
+ return IC(e) || h$(e) || Yh(e);
+}
+function LC(e) {
+ const t = e.getPreviousSibling();
+ return ot(t) && mu(t) ? t : void 0;
+}
+function Rc(e, t = "deleteBackward") {
+ if (Yh(e)) {
+ const n = En();
+ e.replace(n), n.select(0, 0);
+ return;
+ }
+ if (mu(e) && (t === "deleteForward" || !IC(e))) {
+ const n = e.getNextSibling();
+ e.remove(), st(n) && uo(n);
+ return;
+ }
+ g$(e);
+}
+function g$(e) {
const t = e.getPreviousSibling();
- if (!ct(t))
+ if (!st(t))
return;
const n = t.getLastChild(), r = e.getFirstChild(), i = Zt(r), s = e.getChildren().filter((o) => !an(o) && !(i && o.is(r)));
- t.append(...s), e.remove(), NC(t, n);
+ t.append(...s), e.remove(), qC(t, n);
}
-function NC(e, t) {
- !t || Zt(t) || an(t) ? aa(e) : T(t) ? wC(t) : zn(e, t.getIndexWithinParent() + 1);
+function qC(e, t) {
+ !t || Zt(t) || an(t) ? uo(e) : C(t) ? RC(t) : zn(e, t.getIndexWithinParent() + 1);
}
-function OC(e) {
- return Oe(e) || ot(e) ? [] : dt(e) ? e.getChildren().flatMap(OC) : [e];
+function DC(e) {
+ return Oe(e) || Ye(e) ? [] : ot(e) ? e.getChildren().flatMap(DC) : [e];
}
-function l$(e) {
+function m$(e) {
const t = [];
for (const n of e) {
- const r = OC(n);
- r.length !== 0 && (dt(n) && t.length > 0 && t.push(Ue(" ")), t.push(...r));
+ const r = DC(n);
+ r.length !== 0 && (ot(n) && t.length > 0 && t.push(Be(" ")), t.push(...r));
}
return t;
}
-const u$ = /* @__PURE__ */ new Set(["", " "]), yy = 6e4;
-function f$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, onHiddenContentDelete: r, logger: i }) {
+const y$ = /* @__PURE__ */ new Set(["", " "]), Cy = 6e4;
+function b$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, onHiddenContentDelete: r, logger: i }) {
const [s] = Pe(), o = ae(r), a = ae(t), c = ae(n), l = ae(i);
J(() => {
o.current = r, a.current = t, c.current = n, l.current = i;
@@ -22196,26 +22240,26 @@ function f$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, on
return l.current?.error("[HiddenContentDeleteGuard] onHiddenContentDelete failed; keeping the hidden content.", ne), "keep";
}
}, g = (q, j) => l.current?.info(`[HiddenContentDeleteGuard] Dropped the "${q}" answer: ${j}. Nothing was changed.`), y = (q, j, ne, N, X = []) => {
- const oe = [du(q), ...X], me = {
+ const oe = [hu(q), ...X], he = {
...oe[0],
hiddenKeys: j.map((ue) => ue.getKey()),
ranges: oe,
- covered: RC(oe)
+ covered: BC(oe)
}, ie = {
- items: WO(j),
+ items: XO(j),
action: ne,
canSkip: !!N.$keep
};
d = !0;
- const B = setTimeout(() => !p && l.current?.warn(`[HiddenContentDeleteGuard] onHiddenContentDelete has not answered after ${yy / 1e3}s; editing stays held until it does.`), yy);
+ const F = setTimeout(() => !p && l.current?.warn(`[HiddenContentDeleteGuard] onHiddenContentDelete has not answered after ${Cy / 1e3}s; editing stays held until it does.`), Cy);
return h(ie).then((ue) => {
- clearTimeout(B), d = !1, p ? g(ue, "the editor's guard was torn down while asking") : b(me, ue, N);
+ clearTimeout(F), d = !1, p ? g(ue, "the editor's guard was torn down while asking") : b(he, ue, N);
}), !0;
}, b = (q, j, ne) => {
const N = s.getEditorState().read(() => {
- if (!x$(q))
+ if (!M$(q))
return "the selection moved while asking";
- if (!by(q))
+ if (!vy(q))
return "the document changed while asking";
});
if (N) {
@@ -22226,8 +22270,8 @@ function f$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, on
g(j, "the editor has no root element to return focus to");
return;
}
- s.focus(() => queueMicrotask(() => C(q, j, ne)));
- }, C = (q, j, ne) => {
+ s.focus(() => queueMicrotask(() => T(q, j, ne)));
+ }, T = (q, j, ne) => {
if (p) {
g(j, "the editor's guard was torn down while asking");
return;
@@ -22238,11 +22282,11 @@ function f$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, on
g(j, "the editor became read-only while asking");
return;
}
- if (!by(q)) {
+ if (!vy(q)) {
g(j, "the document changed while asking");
return;
}
- if (Mt(gl(q) ?? null), j === "keep") {
+ if (Mt(yl(q) ?? null), j === "keep") {
ne.$keep?.();
return;
}
@@ -22250,124 +22294,124 @@ function f$({ isEnabled: e, structureProtectionMode: t = "off", copyLimit: n, on
}, { discrete: !0 });
const { replay: X } = ne;
N && X && m(() => s.update(() => {
- _t(Td), X();
+ _t(Sd), X();
}, { discrete: !0 }));
}, x = (q, j, ne) => {
const N = a.current === "protected", X = q.clone();
- N && j === "forward" && dl(X);
- const oe = BO(X, j), me = ne === "character" || oe?.placement === "block" ? void 0 : g$(s, q, j, ne, X);
- if (N && me?.measured) {
- const mt = gl(me.measured);
- if (mt && AC(mt) && !(me.leavesLine && oe))
+ N && j === "forward" && hl(X);
+ const oe = HO(X, j), he = ne === "character" || oe?.placement === "block" ? void 0 : C$(s, q, j, ne, X);
+ if (N && he?.measured) {
+ const yt = yl(he.measured);
+ if (yt && $C(yt) && !(he.leavesLine && oe))
return !1;
}
- const ie = b$([...oe?.nodes ?? [], ...me?.hidden ?? []]);
+ const ie = _$([...oe?.nodes ?? [], ...he?.hidden ?? []]);
if (ie.length === 0)
return !1;
- const B = ie.map((mt) => mt.getKey()), ue = !!oe && ie.length === oe.nodes.length && jO(oe, j), we = oe?.nodes.map((mt) => mt.getKey()) ?? [], $e = me?.range;
+ const F = ie.map((yt) => yt.getKey()), ue = !!oe && ie.length === oe.nodes.length && JO(oe, j), we = oe?.nodes.map((yt) => yt.getKey()) ?? [], $e = he?.range;
return y(q, ie, j === "backward" ? "deleteBackward" : "deleteForward", {
- $keep: oe && ue ? () => zO(T$(oe, we), j) : void 0,
+ $keep: oe && ue ? () => GO(P$(oe, we), j) : void 0,
$delete: () => {
- $e && m$($e, N), y$(B);
+ $e && v$($e, N), S$(F);
}
- }, [k$(q, ie, j), ...$e ? [$e] : []]);
- }, _ = (q, j, ne) => y(q, j, "replaceSelection", { replay: ne }), F = () => {
+ }, [E$(q, ie, j), ...$e ? [$e] : []]);
+ }, _ = (q, j, ne) => y(q, j, "replaceSelection", { replay: ne }), U = () => {
if (f || !s.isEditable())
return;
const q = M();
if (!(!E(q) || Ts()))
return q;
- }, R = (q) => (j) => !d || f ? q(j) : (j instanceof Event && j.preventDefault(), !0), W = (q) => a.current === "protected" && Ci(q), ce = (q) => {
+ }, I = (q) => (j) => !d || f ? q(j) : (j instanceof Event && j.preventDefault(), !0), V = (q) => a.current === "protected" && vi(q), ce = (q) => {
if (f)
return !1;
- const j = d$(q);
+ const j = k$(q);
if (d)
- return !j && !Rh(q) ? !1 : (q.preventDefault(), !0);
+ return !j && !Lh(q) ? !1 : (q.preventDefault(), !0);
if (!j)
return !1;
- const ne = F();
+ const ne = U();
if (!ne?.isCollapsed())
return !1;
const N = j.direction === "backward" ? "deleteBackward" : "deleteForward";
- if (a.current === "protected" && uo(ne, N))
+ if (a.current === "protected" && fo(ne, N))
return !1;
const X = x(ne, j.direction, j.granularity);
return X && q.preventDefault(), X;
- }, se = (q, j) => R((ne) => {
- const N = F();
- if (!N || a.current === "protected" && uo(N, ne ? "deleteBackward" : "deleteForward"))
+ }, se = (q, j) => I((ne) => {
+ const N = U();
+ if (!N || a.current === "protected" && fo(N, ne ? "deleteBackward" : "deleteForward"))
return !1;
if (N.isCollapsed())
return x(N, ne ? "backward" : "forward", j);
- const X = Xi(N);
+ const X = Qi(N);
return X.length === 0 ? !1 : _(N, X, () => s.dispatchCommand(q, ne));
- }), Y = (q) => R((j) => {
- const ne = F();
+ }), Y = (q) => I((j) => {
+ const ne = U();
if (!ne || ne.isCollapsed())
return !1;
- const N = Xi(ne);
+ const N = Qi(ne);
return N.length === 0 ? !1 : _(ne, N, () => s.dispatchCommand(q, j));
}), be = (q) => {
- const j = F();
- if (!j || j.isCollapsed() || W(j))
+ const j = U();
+ if (!j || j.isCollapsed() || V(j))
return !1;
- const ne = Xi(j);
+ const ne = Qi(j);
if (ne.length === 0)
return !1;
- const N = typeof q == "string" ? q : q.data ?? q.dataTransfer?.getData("text/plain") ?? "", X = s.isComposing() && u$.has(N);
- return _(j, ne, () => X || N === "" ? s.dispatchCommand(In, !0) : s.dispatchCommand(Yr, N));
+ const N = typeof q == "string" ? q : q.data ?? q.dataTransfer?.getData("text/plain") ?? "", X = s.isComposing() && y$.has(N);
+ return _(j, ne, () => X || N === "" ? s.dispatchCommand(Ln, !0) : s.dispatchCommand(Xr, N));
}, Se = (q) => {
- const j = F();
- return !j || Xi(j).length === 0 ? !1 : bc(q);
- }, Fe = (q) => {
- const j = F();
+ const j = U();
+ return !j || Qi(j).length === 0 ? !1 : bc(q);
+ }, Ue = (q) => {
+ const j = U();
if (!j || j.isCollapsed())
return !1;
const ne = a.current === "protected";
- if (W(j) || p$(q, ne))
+ if (V(j) || x$(q, ne))
return !1;
- const N = Xi(j);
+ const N = Qi(j);
if (N.length === 0)
return !1;
- const X = h$(q);
+ const X = T$(q);
return bc(q), _(j, N, () => s.dispatchCommand(un, X));
- }, I = (q) => {
- const j = F();
- if (!j || j.isCollapsed() || W(j) || ($C(j, a.current === "protected"), j.isCollapsed()))
+ }, R = (q) => {
+ const j = U();
+ if (!j || j.isCollapsed() || V(j) || (KC(j, a.current === "protected"), j.isCollapsed()))
return !1;
- const ne = Xi(j);
- return ne.length === 0 ? !1 : c.current !== void 0 ? bc(q) : (s.dispatchCommand(Xr, q), bc(q), _(j, ne, () => s.dispatchCommand(In, !0)));
+ const ne = Qi(j);
+ return ne.length === 0 ? !1 : c.current !== void 0 ? bc(q) : (s.dispatchCommand(Qr, q), bc(q), _(j, ne, () => s.dispatchCommand(Ln, !0)));
};
- return Ye(() => {
+ return Xe(() => {
p = !0;
- }, s.registerCommand(Jn, ce, ye), s.registerCommand(In, se(In, "character"), ye), s.registerCommand(cs, se(cs, "word"), ye), s.registerCommand(Ei, se(Ei, "line"), ye), s.registerCommand(Yr, R(be), ye), s.registerCommand(Ti, Y(Ti), ye), s.registerCommand(Uc, Y(Uc), ye), s.registerCommand(Fc, Se, ye), s.registerCommand(lp, Se, ye), s.registerCommand(un, R(Fe), ye), s.registerCommand(wn, R(I), ye));
+ }, s.registerCommand(Jn, ce, ye), s.registerCommand(Ln, se(Ln, "character"), ye), s.registerCommand(ls, se(ls, "word"), ye), s.registerCommand(Mi, se(Mi, "line"), ye), s.registerCommand(Xr, I(be), ye), s.registerCommand(Ci, Y(Ci), ye), s.registerCommand(Uc, Y(Uc), ye), s.registerCommand(Fc, Se, ye), s.registerCommand(fp, Se, ye), s.registerCommand(un, I(Ue), ye), s.registerCommand(Nn, I(R), ye));
}, [s, e, u]), null;
}
-function d$(e) {
- const t = mr ? { altKey: !0 } : { ctrlKey: !0 }, n = (r) => mr && hi(e, r, { ctrlKey: !0 });
- if (hi(e, "Backspace", { shiftKey: "any" }) || n("h"))
+function k$(e) {
+ const t = yr ? { altKey: !0 } : { ctrlKey: !0 }, n = (r) => yr && gi(e, r, { ctrlKey: !0 });
+ if (gi(e, "Backspace", { shiftKey: "any" }) || n("h"))
return { direction: "backward", granularity: "character" };
- if (hi(e, "Delete", {}) || n("d"))
+ if (gi(e, "Delete", {}) || n("d"))
return { direction: "forward", granularity: "character" };
- if (hi(e, "Backspace", t))
+ if (gi(e, "Backspace", t))
return { direction: "backward", granularity: "word" };
- if (hi(e, "Delete", t))
+ if (gi(e, "Delete", t))
return { direction: "forward", granularity: "word" };
- if (mr && hi(e, "Backspace", { metaKey: !0 }))
+ if (yr && gi(e, "Backspace", { metaKey: !0 }))
return { direction: "backward", granularity: "line" };
- if (mr && hi(e, "Delete", { metaKey: !0 }) || n("k"))
+ if (yr && gi(e, "Delete", { metaKey: !0 }) || n("k"))
return { direction: "forward", granularity: "line" };
}
function bc(e) {
return e?.preventDefault(), !0;
}
-function p$(e, t) {
+function x$(e, t) {
if (typeof ClipboardEvent > "u" || !(e instanceof ClipboardEvent))
return !1;
const n = e.clipboardData;
- return n ? Array.from(n.types).every((r) => r === "Files") ? !0 : t && n.getData("text/html") ? !1 : yd(n.getData("text/plain")) : !1;
+ return n ? Array.from(n.types).every((r) => r === "Files") ? !0 : t && n.getData("text/html") ? !1 : xd(n.getData("text/plain")) : !1;
}
-function h$(e) {
+function T$(e) {
if (typeof ClipboardEvent > "u" || typeof DataTransfer > "u" || !(e instanceof ClipboardEvent) || !e.clipboardData)
return e;
const t = new DataTransfer();
@@ -22377,77 +22421,77 @@ function h$(e) {
t.items.add(n);
return new ClipboardEvent("paste", { clipboardData: t, cancelable: !0 });
}
-function g$(e, t, n, r, i = t) {
+function C$(e, t, n, r, i = t) {
const s = e.getRootElement()?.ownerDocument.defaultView?.getSelection();
if (!s || typeof s.modify != "function")
- return { hidden: r === "line" ? ly(i, n) : [] };
+ return { hidden: r === "line" ? hy(i, n) : [] };
const o = i.clone();
o.dirty = !0, o.modify("extend", n === "backward", r === "line" ? "lineboundary" : "word"), t.dirty = !0;
- const a = o.isCollapsed() ? void 0 : du(o);
- return VO(o.focus, i) ? { hidden: Xi(o), range: a, measured: a } : { hidden: ly(i, n), measured: a, leavesLine: !0 };
+ const a = o.isCollapsed() ? void 0 : hu(o);
+ return YO(o.focus, i) ? { hidden: Qi(o), range: a, measured: a } : { hidden: hy(i, n), measured: a, leavesLine: !0 };
}
-function m$(e, t) {
- const n = gl(e);
- n && ($C(n, t), !n.isCollapsed() && (Mt(n), n.removeText()));
+function v$(e, t) {
+ const n = yl(e);
+ n && (KC(n, t), !n.isCollapsed() && (Mt(n), n.removeText()));
}
-function $C(e, t) {
- Na(e), t && vC(e), Vh(e);
+function KC(e, t) {
+ Na(e), t && MC(e), Hh(e);
}
-function y$(e) {
+function S$(e) {
for (const t of e) {
const n = ee(t);
Ie(n) && n.isAttached() && n.remove();
}
}
-function b$(e) {
+function _$(e) {
return e.filter((n, r) => e.findIndex((i) => i.is(n)) === r).sort((n, r) => n.isBefore(r) ? -1 : 1);
}
-function gl({ anchor: e, focus: t }) {
+function yl({ anchor: e, focus: t }) {
const n = ({ key: i, offset: s, type: o }) => {
const a = ee(i);
- return !a || !a.isAttached() ? !1 : o === "element" ? A(a) && s <= a.getChildrenSize() : T(a) && s <= a.getTextContentSize();
+ return !a || !a.isAttached() ? !1 : o === "element" ? A(a) && s <= a.getChildrenSize() : C(a) && s <= a.getTextContentSize();
};
if (!n(e) || !n(t))
return;
const r = dr();
return r.anchor.set(e.key, e.offset, e.type), r.focus.set(t.key, t.offset, t.type), r;
}
-function k$(e, t, n) {
+function E$(e, t, n) {
const r = n === "backward" ? t[0] : t[t.length - 1], i = r.getIndexWithinParent() + (n === "backward" ? 0 : 1), s = {
key: r.getParentOrThrow().getKey(),
offset: i,
type: "element"
- }, { anchor: o } = du(e);
+ }, { anchor: o } = hu(e);
return { anchor: o, focus: s };
}
-function RC(e) {
+function BC(e) {
const t = [];
for (const n of e) {
- const r = gl(n);
+ const r = yl(n);
if (!r)
return;
for (const i of r.getNodes())
- t.push(i.getKey(), T(i) ? i.getTextContent() : "");
+ t.push(i.getKey(), C(i) ? i.getTextContent() : "");
}
return t.join("\0");
}
-function by(e) {
- return e.hiddenKeys.every((t) => ee(t)?.isAttached()) && e.covered !== void 0 && RC(e.ranges) === e.covered;
+function vy(e) {
+ return e.hiddenKeys.every((t) => ee(t)?.isAttached()) && e.covered !== void 0 && BC(e.ranges) === e.covered;
}
-function x$(e) {
+function M$(e) {
const t = M();
- return t ? E(t) ? fl(t.anchor, e.anchor) && fl(t.focus, e.focus) : !1 : !0;
+ return t ? E(t) ? pl(t.anchor, e.anchor) && pl(t.focus, e.focus) : !1 : !0;
}
-function T$(e, t) {
+function P$(e, t) {
return { nodes: t.map((r) => ee(r)).filter(Ie), placement: e.placement };
}
-function C$(e) {
+function A$(e) {
let t = e;
for (; t && t.nodeType !== Node.TEXT_NODE; )
t = t.firstChild;
return t ?? void 0;
}
-function v$(e) {
+function w$(e) {
const t = M();
if (!E(t) || !t.isCollapsed())
return;
@@ -22455,16 +22499,16 @@ function v$(e) {
if (!r?.isCollapsed || !i || !n?.contains(i))
return;
const { anchor: s } = t;
- if (s.type === "text" && i === C$(e.getElementByKey(s.key)) && r.anchorOffset === s.offset)
+ if (s.type === "text" && i === A$(e.getElementByKey(s.key)) && r.anchorOffset === s.offset)
return;
- const o = Dl(r, e);
+ const o = Bl(r, e);
o && (o.anchor.key === s.key && o.anchor.offset === s.offset && o.anchor.type === s.type || Mt(o));
}
-function S$() {
+function N$() {
const [e] = Pe();
- return J(() => e.registerCommand(Jn, () => (v$(e), !1), ye), [e]), null;
+ return J(() => e.registerCommand(Jn, () => (w$(e), !1), ye), [e]), null;
}
-function _$({ scripture: e, scriptureRef: t, nodeOptions: n, editorAdaptor: r, viewOptions: i, logger: s }) {
+function O$({ scripture: e, scriptureRef: t, nodeOptions: n, editorAdaptor: r, viewOptions: i, logger: s }) {
const [o] = Pe();
return J(() => {
r.initialize?.(n, s);
@@ -22479,9 +22523,9 @@ function _$({ scripture: e, scriptureRef: t, nodeOptions: n, editorAdaptor: r, v
try {
const l = o.parseEditorState(c);
queueMicrotask(() => {
- const u = Fh(o);
+ const u = zh(o);
o.update(() => {
- u || _t(or), o.setEditorState(l), o.dispatchCommand(S0, void 0);
+ u || _t(or), o.setEditorState(l), o.dispatchCommand(A0, void 0);
}, { tag: Va });
});
} catch {
@@ -22489,22 +22533,22 @@ function _$({ scripture: e, scriptureRef: t, nodeOptions: n, editorAdaptor: r, v
}
}, [o, r, s, e, t, i]), null;
}
-const gf = "caller_highlight", E$ = Ri(function(t, n) {
+const bf = "caller_highlight", $$ = Ii(function(t, n) {
const [r] = Pe(), i = ae(void 0), s = ae(void 0), o = Ke(() => {
const a = i.current, c = a === void 0 ? void 0 : r.getEditorState().read(() => {
const u = Nr(a);
- return u ? (u.getChildren().find(Ut) ?? Dt(u))?.getKey() : void 0;
+ return u ? (u.getChildren().find(Bt) ?? Dt(u))?.getKey() : void 0;
}), l = c ? r.getElementByKey(c) ?? void 0 : void 0;
- s.current && s.current !== l && s.current.classList.remove(gf), l?.classList.add(gf), s.current = l;
+ s.current && s.current !== l && s.current.classList.remove(bf), l?.classList.add(bf), s.current = l;
}, [r]);
- return Rl(n, () => ({
+ return Ll(n, () => ({
setHighlightedNote(a) {
i.current = a === void 0 ? void 0 : Xs(r, () => Nr(a)?.getKey()), o();
}
- }), [r, o]), J(() => Ye(
+ }), [r, o]), J(() => Xe(
// Runs before the update listener below, so the key it re-points to is the one the
// re-application then resolves the caller element from.
- r.registerMutationListener(at, (a, { prevEditorState: c, updateTags: l }) => {
+ r.registerMutationListener(lt, (a, { prevEditorState: c, updateTags: l }) => {
const u = i.current;
if (u === void 0 || a.get(u) !== "destroyed")
return;
@@ -22512,44 +22556,44 @@ const gf = "caller_highlight", E$ = Ri(function(t, n) {
i.current = void 0;
return;
}
- const f = l.has(Va) ? void 0 : c.read(() => mh(u)), d = f === void 0 ? void 0 : r.getEditorState().read(() => Nr(f)?.getKey());
+ const f = l.has(Va) ? void 0 : c.read(() => bh(u)), d = f === void 0 ? void 0 : r.getEditorState().read(() => Nr(f)?.getKey());
i.current = d !== void 0 && a.get(d) === "created" ? d : void 0;
}, { skipInitialization: !0 }),
r.registerUpdateListener(() => o())
- ), [r, o]), J(() => () => s.current?.classList.remove(gf), []), null;
+ ), [r, o]), J(() => () => s.current?.classList.remove(bf), []), null;
});
-function M$({ expandedNoteKeyRef: e, nodeOptions: t, viewOptions: n, logger: r }) {
+function R$({ expandedNoteKeyRef: e, nodeOptions: t, viewOptions: n, logger: r }) {
const [i] = Pe();
- return P$(t, r), A$(i, e, n, r), null;
+ return I$(t, r), L$(i, e, n, r), null;
}
-function P$(e, t) {
+function I$(e, t) {
const n = ae(void 0), r = ae(void 0), i = e.noteCallers, s = e.crossRefCallers;
J(() => {
let o = i;
- (!o || o.length <= 0) && (o = A1), n.current !== o && (n.current = o, ky("note-callers", o, t));
+ (!o || o.length <= 0) && (o = R1), n.current !== o && (n.current = o, Sy("note-callers", o, t));
}, [t, i]), J(() => {
let o = s;
- (!o || o.length <= 0) && (o = w1), r.current !== o && (r.current = o, ky("cross-ref-callers", o, t));
+ (!o || o.length <= 0) && (o = I1), r.current !== o && (r.current = o, Sy("cross-ref-callers", o, t));
}, [t, s]);
}
-function A$(e, t, n, r) {
+function L$(e, t, n, r) {
J(() => {
- if (!e.hasNodes([nt, at, Dn]))
+ if (!e.hasNodes([rt, lt, Dn]))
throw new Error("NoteNodePlugin: CharNode, NoteNode or ImmutableNoteCallerNode not registered on editor!");
- const i = (s) => e.update(() => q$(s));
- return Ye(
+ const i = (s) => e.update(() => j$(s));
+ return Xe(
// Remove NoteNode if it doesn't contain a caller node and ensure typed text goes before it.
- e.registerNodeTransform(at, (s) => w$(s, n)),
+ e.registerNodeTransform(lt, (s) => q$(s, n)),
// Update NoteNodeCaller preview text when NoteNode children text is changed.
- e.registerNodeTransform(nt, O$),
- e.registerNodeTransform(it, $$),
+ e.registerNodeTransform(rt, K$),
+ e.registerNodeTransform(at, B$),
// Ensure a separator after the caller.
- e.registerNodeTransform(Dn, R$),
+ e.registerNodeTransform(Dn, U$),
// Re-generate all note callers when a note is removed.
- e.registerMutationListener(Dn, (s, { prevEditorState: o }) => I$(s, o)),
+ e.registerMutationListener(Dn, (s, { prevEditorState: o }) => F$(s, o)),
// Handle the cursor moving next to a NoteNode. NoteNode arrow key navigation when note is
// after a verse node is handled in the ArrowNavigationPlugin.
- e.registerCommand(Nn, () => L$(e, t, n, r), Nt),
+ e.registerCommand(On, () => z$(e, t, n, r), Nt),
// Handle double-click of a word immediately following a NoteNode (no space between).
e.registerRootListener((s, o) => {
o !== null && o.removeEventListener("dblclick", i), s !== null && s.addEventListener("dblclick", i);
@@ -22557,60 +22601,60 @@ function A$(e, t, n, r) {
);
}, [e, t, r, n]);
}
-function w$(e, t) {
+function q$(e, t) {
const n = e.getChildren();
- if (!n.some((i) => Ut(i)) && t?.markerMode !== "editable" && e.getCaller() !== "" && e.remove(), n.length > 0) {
+ if (!n.some((i) => Bt(i)) && t?.markerMode !== "editable" && e.getCaller() !== "" && e.remove(), n.length > 0) {
const i = n[0];
- T(i) && !$(i) && i.getTextContent() !== qt(e.getCaller()) && e.insertBefore(i);
+ C(i) && !$(i) && i.getTextContent() !== qt(e.getCaller()) && e.insertBefore(i);
}
}
-function IC(e) {
+function UC(e) {
const t = e.getNextSibling();
- an(t) || (T(t) && !$(t) && t.getTextContent() === U ? t.replace(ms()) : e.insertAfter(ms()));
+ an(t) || (C(t) && !$(t) && t.getTextContent() === B ? t.replace(ms()) : e.insertAfter(ms()));
}
-function N$(e) {
- const t = e.getTextContent(), n = t.indexOf(U), r = n < 0 ? t : t.slice(0, n) + t.slice(n + 1);
- if (e.setTextContent(U), !r) {
+function D$(e) {
+ const t = e.getTextContent(), n = t.indexOf(B), r = n < 0 ? t : t.slice(0, n) + t.slice(n + 1);
+ if (e.setTextContent(B), !r) {
e.selectEnd();
return;
}
- const i = Ue(r);
+ const i = Be(r);
e.insertAfter(i), i.selectEnd();
}
-function O$(e) {
- const t = e.getParentOrThrow(), n = t.getChildren(), r = n.find((s) => Ut(s));
+function K$(e) {
+ const t = e.getParentOrThrow(), n = t.getChildren(), r = n.find((s) => Bt(s));
if (!z(e) || !K(t) || !r)
return;
- const i = Vp(n);
- r.getPreviewText() !== i && r.setPreviewText(i), IC(e);
+ const i = Hp(n);
+ r.getPreviewText() !== i && r.setPreviewText(i), UC(e);
}
-function $$(e) {
- const t = hn(e), n = t?.getChildren(), r = n?.find((o) => Ut(o));
- if (!T(e) || !K(t) || !r || !n)
+function B$(e) {
+ const t = hn(e), n = t?.getChildren(), r = n?.find((o) => Bt(o));
+ if (!C(e) || !K(t) || !r || !n)
return;
const i = e.getParent();
- if (K(i) && an(e) && e.getTextContent() !== U && N$(e), z(i) && i.getChildrenSize() === 1) {
+ if (K(i) && an(e) && e.getTextContent() !== B && D$(e), z(i) && i.getChildrenSize() === 1) {
const o = e.getTextContent();
o.length > 1 && o.startsWith(It) && (e.setTextContent(o.slice(1)), e.selectEnd());
}
- const s = Vp(n);
+ const s = Hp(n);
r.getPreviewText() !== s && r.setPreviewText(s);
}
-function R$(e) {
- Ut(e) && IC(e);
+function U$(e) {
+ Bt(e) && UC(e);
}
-function I$(e, t) {
+function F$(e, t) {
for (const [n, r] of e) {
if (r !== "destroyed")
continue;
const i = t.read(() => {
const o = ee(n), a = o?.getParent();
- return Ut(o) && K(a) && a.getCaller() === ya;
+ return Bt(o) && K(a) && a.getCaller() === ya;
}), s = document.querySelector(".editor-input");
!i || !s || (s.classList.add("reset-counters"), s.offsetHeight, s.classList.remove("reset-counters"));
}
}
-function L$(e, t, n, r) {
+function z$(e, t, n, r) {
if (n?.noteMode !== "expandInline")
return !1;
const i = M();
@@ -22623,7 +22667,7 @@ function L$(e, t, n, r) {
t.current !== a.getKey() && (t.current = a.getKey());
else {
const c = ee(t.current);
- c && !c.getIsCollapsed() && (r?.debug("Cursor moved away from NoteNode, collapsing it"), Wo(e, t.current, r)), t.current = void 0;
+ c && !c.getIsCollapsed() && (r?.debug("Cursor moved away from NoteNode, collapsing it"), Ho(e, t.current, r)), t.current = void 0;
}
}
if (s.offset === 0) {
@@ -22631,7 +22675,7 @@ function L$(e, t, n, r) {
if (K(a)) {
r?.debug("Cursor is just after a NoteNode");
const c = a.getKey();
- a.getIsCollapsed() ? t.current = c : t.current = void 0, Wo(e, c, r);
+ a.getIsCollapsed() ? t.current = c : t.current = void 0, Ho(e, c, r);
}
}
if (s.offset === o.getTextContentSize()) {
@@ -22639,29 +22683,29 @@ function L$(e, t, n, r) {
if (K(a)) {
r?.debug("Cursor is just before a NoteNode");
const c = a.getKey();
- a.getIsCollapsed() ? t.current = c : t.current = void 0, Wo(e, c, r);
+ a.getIsCollapsed() ? t.current = c : t.current = void 0, Ho(e, c, r);
} else if (!a) {
const c = We(o, (l) => K(l));
if (c && c.getIsCollapsed() && // `ParaLike`, not `SomePara`: the `\id` line is a `BookNode` and can carry a note like any
// other content container, so a note at its end expands the same way.
- ct(c.getParent()) && c.is(c.getParent()?.getLastChild())) {
+ st(c.getParent()) && c.is(c.getParent()?.getLastChild())) {
r?.debug("Cursor is at end of note at end of para");
const l = c.getKey();
- t.current = l, Wo(e, l, r);
+ t.current = l, Ho(e, l, r);
}
}
}
- if (dt(o)) {
+ if (ot(o)) {
const a = o.getChildAtIndex(s.offset), c = a?.getPreviousSibling();
if (Er(c) && K(a)) {
r?.debug("Cursor is between verse and NoteNode");
const l = a.getKey();
- a.getIsCollapsed() ? t.current = l : t.current = void 0, Wo(e, l, r);
+ a.getIsCollapsed() ? t.current = l : t.current = void 0, Ho(e, l, r);
}
}
return !1;
}
-function Wo(e, t, n) {
+function Ho(e, t, n) {
const r = ee(t);
try {
r?.toggleIsCollapsed();
@@ -22676,23 +22720,23 @@ function Wo(e, t, n) {
throw i;
}
}
-function q$(e) {
+function j$(e) {
const t = M();
if (!E(t))
return;
const n = t.anchor, r = t.focus, i = n.getNode(), s = r.getNode();
- if (K(i) && T(s)) {
+ if (K(i) && C(s)) {
e.preventDefault();
const o = dr();
o.anchor.set(s.getKey(), 0, "text"), o.focus.set(s.getKey(), r.offset, "text"), Mt(o);
}
}
-function ky(e, t, n) {
+function Sy(e, t, n) {
for (const r of document.styleSheets)
try {
const i = r.cssRules || r.rules;
for (const s of i)
- if (D$(s, e)) {
+ if (V$(s, e)) {
const o = t.map((a) => `"${a}"`).join(" ");
s.symbols = o;
return;
@@ -22702,27 +22746,27 @@ function ky(e, t, n) {
}
n?.warn(`Editor: counter style "${e}" not found.`);
}
-function D$(e, t) {
+function V$(e, t) {
return (
// This check could be simpler but as is also works for test mocks.
typeof e == "object" && e !== null && "name" in e && e.name === t && "symbols" in e && typeof e.symbols == "string"
);
}
-function K$({ onChange: e, viewOptions: t }) {
+function W$({ onChange: e, viewOptions: t }) {
const [n] = Pe();
- return J(() => n.registerCommand(Nn, () => {
+ return J(() => n.registerCommand(On, () => {
const r = Qa(t);
return e?.(r), !1;
}, Nt), [n, e, t]), null;
}
-const U$ = "psc-para-marker-selected", F$ = /* @__PURE__ */ new Set(["Process", "Dead"]), B$ = /* @__PURE__ */ new Set([
+const H$ = "psc-para-marker-selected", G$ = /* @__PURE__ */ new Set(["Process", "Dead"]), J$ = /* @__PURE__ */ new Set([
"insertReplacementText",
"insertFromDrop",
"insertFromYank",
"insertFromPaste",
"insertFromPasteAsQuotation"
]);
-function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" }) {
+function Y$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" }) {
const [n] = Pe(), r = ae(e);
J(() => {
r.current = e;
@@ -22734,33 +22778,33 @@ function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" })
let s, o, a, c = !1, l;
const u = () => {
queueMicrotask(() => r.current?.());
- }, f = () => n.isEditable() ? Tr(M()) : void 0, d = (N) => {
- i.current !== "protected" && vd(N);
- }, p = (N) => i.current === "guarded" && hl(N), m = (N) => {
- const X = n.getRootElement(), oe = Jb(X?.ownerDocument.defaultView ?? null), me = oe?.anchorNode;
- if (!oe || !me || !X?.contains(me) || n.getElementByKey(N)?.contains(me))
+ }, f = () => n.isEditable() ? pr(M()) : void 0, d = (N) => {
+ i.current !== "protected" && Rc(N);
+ }, p = (N) => i.current === "guarded" && ml(N), m = (N) => {
+ const X = n.getRootElement(), oe = ek(X?.ownerDocument.defaultView ?? null), he = oe?.anchorNode;
+ if (!oe || !he || !X?.contains(he) || n.getElementByKey(N)?.contains(he))
return !1;
- const ie = Dl(oe, n);
+ const ie = Bl(oe, n);
return ie ? (Mt(ie), !0) : !1;
}, h = (N, X) => {
const oe = N?.startContainer;
if (!N || !oe || !n.getRootElement()?.contains(oe) || n.getElementByKey(X)?.contains(oe))
return !1;
- const me = dr();
- me.applyDOMRange(N);
- const { anchor: ie } = me;
- return ie.key === "root" && ie.offset === 0 && ie.type === "element" ? !1 : (Mt(me), !0);
+ const he = dr();
+ he.applyDOMRange(N);
+ const { anchor: ie } = he;
+ return ie.key === "root" && ie.offset === 0 && ie.type === "element" ? !1 : (Mt(he), !0);
}, g = (N) => {
const X = ga(N.target) ? qr(N.target) : null;
- if (Un(X))
- return _x(X);
- const oe = mi(M()), me = oe?.getParent();
- if (!oe || !dt(me) || !X || m(oe.getKey()) || !on(X))
+ if (Bn(X))
+ return Ax(X);
+ const oe = yi(M()), he = oe?.getParent();
+ if (!oe || !ot(he) || !X || m(oe.getKey()) || !on(X))
return !1;
- const ie = We(X, dt), B = ie ? We(X, (ue) => ue.getParent()?.is(ie) ?? !1) : void 0;
- return dt(ie) && B ? zn(ie, B.getIndexWithinParent() + 1) : aa(me), !1;
+ const ie = We(X, ot), F = ie ? We(X, (ue) => ue.getParent()?.is(ie) ?? !1) : void 0;
+ return ot(ie) && F ? zn(ie, F.getIndexWithinParent() + 1) : uo(he), !1;
}, y = (N) => {
- if (typeof N.key != "string" || I())
+ if (typeof N.key != "string" || R())
return !1;
const X = f();
if (!X)
@@ -22783,7 +22827,7 @@ function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" })
case "Unidentified":
return !1;
default:
- if (!V$(N))
+ if (!Q$(N))
return !1;
}
return Sn(X), !1;
@@ -22795,53 +22839,56 @@ function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" })
return p(X) ? !1 : (d(X), !0);
if (!N || i.current !== "off")
return !1;
- const oe = MC(M());
- return oe ? (vd(oe), !0) : !1;
- }, C = (N) => {
- if (I())
+ const oe = NC(M());
+ if (!oe)
+ return !1;
+ const he = LC(oe);
+ return he ? Rc(he, "deleteForward") : Rc(oe), !0;
+ }, T = (N) => {
+ if (R())
return !1;
const X = f();
if (!X)
return !1;
const { inputType: oe } = N;
if (oe.startsWith("delete"))
- return N.preventDefault(), p(X) ? n.dispatchCommand(In, oe.includes("Backward")) : d(X), !0;
+ return N.preventDefault(), p(X) ? n.dispatchCommand(Ln, oe.includes("Backward")) : d(X), !0;
if (oe === "insertParagraph" && r.current)
return N.preventDefault(), u(), !0;
if (!oe.startsWith("insert"))
return !1;
- const me = X.getFirstChildOrThrow().getKey();
- return B$.has(oe) && (h(N.getTargetRanges?.()[0], me) || m(me)) || Sn(X), !1;
+ const he = X.getFirstChildOrThrow().getKey();
+ return J$.has(oe) && (h(N.getTargetRanges?.()[0], he) || m(he)) || Sn(X), !1;
}, x = () => {
const N = f();
return N && Sn(N), !1;
}, _ = () => {
const N = f();
return N && (m(N.getFirstChildOrThrow().getKey()) || Sn(N)), !1;
- }, F = (N) => (X) => {
- const oe = mi(M());
- return !oe || !n.isEditable() ? !1 : m(oe.getKey()) ? (n.dispatchCommand(N, X), !0) : (H$(X) && X.preventDefault(), !0);
- }, R = (N) => {
+ }, U = (N) => (X) => {
+ const oe = yi(M());
+ return !oe || !n.isEditable() ? !1 : m(oe.getKey()) ? (n.dispatchCommand(N, X), !0) : (eR(X) && X.preventDefault(), !0);
+ }, I = (N) => {
if (!ga(N.target))
return !1;
- const X = mi(M());
+ const X = yi(M());
if (!X)
return !1;
if (qr(N.target)?.is(X))
return N.preventDefault(), !0;
const oe = n.getRootElement()?.ownerDocument;
- return h(oe && J$(oe, N.clientX, N.clientY), X.getKey()), !1;
- }, W = () => {
+ return h(oe && nR(oe, N.clientX, N.clientY), X.getKey()), !1;
+ }, V = () => {
const N = f();
return N ? (Sn(N), !0) : !1;
- }, ce = () => n.getEditorState().read(() => mi(M()) !== void 0), se = () => {
+ }, ce = () => n.getEditorState().read(() => yi(M()) !== void 0), se = () => {
if (c || !n.isEditable() || !ce())
return !1;
const N = n.getRootElement();
- yf(N);
+ xf(N);
const X = N?.ownerDocument.defaultView;
return l !== void 0 && X?.clearTimeout(l), l = X?.setTimeout(() => {
- l = void 0, !c && n.isEditable() && ce() && yf(N);
+ l = void 0, !c && n.isEditable() && ce() && xf(N);
}), !1;
}, Y = (N) => {
"button" in N && N.button !== 0 || (c = !0);
@@ -22849,21 +22896,21 @@ function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" })
c = !1;
}, Se = (N) => {
N.addEventListener("pointerdown", Y, !0), N.addEventListener("pointerup", be, !0), N.addEventListener("pointercancel", be, !0);
- }, Fe = (N) => {
+ }, Ue = (N) => {
N.removeEventListener("pointerdown", Y, !0), N.removeEventListener("pointerup", be, !0), N.removeEventListener("pointercancel", be, !0);
- }, I = () => {
+ }, R = () => {
const N = M();
- if (!a || !LC(N, a.glyphKey))
+ if (!a || !FC(N, a.glyphKey))
return !1;
- const { paraKey: X, previousKey: oe, nextKey: me } = a;
+ const { paraKey: X, previousKey: oe, nextKey: he } = a;
a = void 0;
- const ie = ee(X), B = oe ? ee(oe) : null, ue = me ? ee(me) : null;
- return dt(ie) && ie.isAttached() ? aa(ie) : dt(B) && B.isAttached() ? NC(B, B.getLastChild()) : dt(ue) && ue.isAttached() ? aa(ue) : Mt(null), !0;
+ const ie = ee(X), F = oe ? ee(oe) : null, ue = he ? ee(he) : null;
+ return ot(ie) && ie.isAttached() ? uo(ie) : ot(F) && F.isAttached() ? qC(F, F.getLastChild()) : ot(ue) && ue.isAttached() ? uo(ue) : Mt(null), !0;
}, q = (N) => {
const X = n.isEditable() ? N : void 0, oe = X?.paraKey;
- s !== oe && mf(n, s, !1), s = oe, mf(n, oe, !0), o = xy(n, o, X?.glyphKey);
+ s !== oe && kf(n, s, !1), s = oe, kf(n, oe, !0), o = _y(n, o, X?.glyphKey);
}, j = (N = n.getEditorState()) => N.read(() => {
- const X = mi(M()), oe = X?.getParent();
+ const X = yi(M()), oe = X?.getParent();
if (!(!X || !oe))
return {
glyphKey: X.getKey(),
@@ -22871,59 +22918,59 @@ function z$({ onParaMarkerMenuRequest: e, structureProtectionMode: t = "off" })
previousKey: oe.getPreviousSibling()?.getKey(),
nextKey: oe.getNextSibling()?.getKey()
};
- }), ne = Ye(xP(n), n.registerEditableListener(() => q(j())), n.registerRootListener((N, X) => {
- X && Fe(X.ownerDocument), N && Se(N.ownerDocument);
+ }), ne = Xe(_P(n), n.registerEditableListener(() => q(j())), n.registerRootListener((N, X) => {
+ X && Ue(X.ownerDocument), N && Se(N.ownerDocument);
}), () => {
const N = n.getRootElement()?.ownerDocument;
- N && Fe(N), l !== void 0 && N?.defaultView?.clearTimeout(l);
- }, n.registerCommand(go, g, ye), n.registerCommand(Jn, y, ye), n.registerCommand(dp, W, ye), n.registerCommand(In, b, ye), n.registerCommand(_0, C, ye), n.registerCommand(E0, x, ye), n.registerCommand(Yr, x, ye), n.registerCommand(un, _, ye), n.registerCommand(wn, F(wn), ye), n.registerCommand(Xr, F(Xr), ye), n.registerCommand(Fc, F(Fc), ye), n.registerCommand(ql, R, ye), n.registerCommand(Kl, se, ye), n.registerCommand(OT, I, ye), n.registerUpdateListener(({ editorState: N }) => {
+ N && Ue(N), l !== void 0 && N?.defaultView?.clearTimeout(l);
+ }, n.registerCommand(mo, g, ye), n.registerCommand(Jn, y, ye), n.registerCommand(hp, V, ye), n.registerCommand(Ln, b, ye), n.registerCommand(w0, T, ye), n.registerCommand(N0, x, ye), n.registerCommand(Xr, x, ye), n.registerCommand(un, _, ye), n.registerCommand(Nn, U(Nn), ye), n.registerCommand(Qr, U(Qr), ye), n.registerCommand(Fc, U(Fc), ye), n.registerCommand(Kl, I, ye), n.registerCommand(Ul, se, ye), n.registerCommand(LT, R, ye), n.registerUpdateListener(({ editorState: N }) => {
const X = j(N);
- (X || !j$(N, a?.glyphKey)) && (a = X), q(X), X && n.isEditable() && yf(n.getRootElement());
+ (X || !X$(N, a?.glyphKey)) && (a = X), q(X), X && n.isEditable() && xf(n.getRootElement());
}));
return () => {
- ne(), mf(n, s, !1), xy(n, o, void 0);
+ ne(), kf(n, s, !1), _y(n, o, void 0);
};
}, [n]), null;
}
-function LC(e, t) {
- return !Ns(e) || mi(e) ? !1 : e.has(t) || e.getNodes().length === 0;
+function FC(e, t) {
+ return !Ns(e) || yi(e) ? !1 : e.has(t) || e.getNodes().length === 0;
}
-function j$(e, t) {
- return t === void 0 ? !1 : e.read(() => LC(M(), t));
+function X$(e, t) {
+ return t === void 0 ? !1 : e.read(() => FC(M(), t));
}
-function V$(e) {
- return Rh(e) || F$.has(e.key) ? !0 : e.ctrlKey || e.metaKey || e.altKey && !mr ? !1 : W$(e.key);
+function Q$(e) {
+ return Lh(e) || G$.has(e.key) ? !0 : e.ctrlKey || e.metaKey || e.altKey && !yr ? !1 : Z$(e.key);
}
-function W$(e) {
+function Z$(e) {
return [...e].length === 1;
}
-function H$(e) {
+function eR(e) {
return typeof e == "object" && e !== null && typeof e.preventDefault == "function";
}
-function mf(e, t, n) {
+function kf(e, t, n) {
if (t === void 0)
return;
const r = e.getElementByKey(t);
- r && r.classList.toggle(U$, n);
+ r && r.classList.toggle(H$, n);
}
-const G$ = "psc-para-marker-";
-function xy(e, t, n) {
+const tR = "psc-para-marker-";
+function _y(e, t, n) {
const r = e.getRootElement(), i = n === void 0 ? null : e.getElementByKey(n), s = t === void 0 ? null : e.getElementByKey(t);
if (s && s !== i && (s.removeAttribute("role"), s.removeAttribute("aria-selected")), !!r) {
if (!i || n === void 0) {
t !== void 0 && r.removeAttribute("aria-activedescendant");
return;
}
- return i.id || (i.id = `${G$}${e.getKey()}-${n}`), i.setAttribute("role", "option"), i.setAttribute("aria-selected", "true"), r.setAttribute("aria-activedescendant", i.id), n;
+ return i.id || (i.id = `${tR}${e.getKey()}-${n}`), i.setAttribute("role", "option"), i.setAttribute("aria-selected", "true"), r.setAttribute("aria-activedescendant", i.id), n;
}
}
-function yf(e) {
+function xf(e) {
if (!e)
return;
const t = e.ownerDocument.defaultView?.getSelection();
!t || t.rangeCount === 0 || t.anchorNode && e.contains(t.anchorNode) && t.removeAllRanges();
}
-function J$(e, t, n) {
+function nR(e, t, n) {
if (typeof e.caretRangeFromPoint == "function")
return e.caretRangeFromPoint(t, n) ?? void 0;
if (typeof e.caretPositionFromPoint != "function")
@@ -22934,30 +22981,30 @@ function J$(e, t, n) {
const i = e.createRange();
return i.setStart(r.offsetNode, r.offset), i.collapse(!0), i;
}
-function Y$() {
+function rR() {
const [e] = Pe();
- return X$(e), null;
+ return iR(e), null;
}
-function X$(e) {
+function iR(e) {
J(() => {
if (!e.hasNodes([Kt]))
throw new Error("ParaNodePlugin: ParaNode not registered on editor!");
- return e.registerNodeTransform(Kt, (t) => Q$(t, e));
+ return e.registerNodeTransform(Kt, (t) => sR(t, e));
}, [e]);
}
-function Q$(e, t) {
- if (!Yl(t) && sd(t, e.getKey())) {
+function sR(e, t) {
+ if (!Ql(t) && cd(t, e.getKey())) {
const i = e.getFirstChild();
- sT(Un(i) ? i.getNextSibling() : i);
+ lT(Bn(i) ? i.getNextSibling() : i);
}
!ke(e) || e.getMarker() !== "b" || e.isEmpty() || !t.getEditorState().read(() => {
const i = ee(e.getKey());
return ke(i) && (i?.isEmpty() ?? !1);
}) || e.clear();
}
-function qC({ onStateChange: e }) {
+function zC({ onStateChange: e }) {
const [t] = Pe(), [n, r] = ze(t), i = ae(!1), s = ae(!1), o = ae(void 0), a = ae(void 0), c = Ke(() => {
- const l = M(), u = n.isEditable() ? Tr(l) : void 0;
+ const l = M(), u = n.isEditable() ? pr(l) : void 0;
if (u && n.getElementByKey(u.getKey()) !== null) {
o.current = u.getMarker(), a.current = u.getMarker(), e?.({
canUndo: i.current,
@@ -22971,12 +23018,12 @@ function qC({ onStateChange: e }) {
if (E(l)) {
const d = l.anchor.getNode(), p = l.focus.getNode();
let m = d.getKey() === "root" ? d : We(d, (b) => {
- const C = b.getParent();
- return C !== null && pp(C);
+ const T = b.getParent();
+ return T !== null && gp(T);
});
m === null && (m = d.getTopLevelElementOrThrow()), bs(m) && (m = We(d, ke) ?? m);
- const h = m.getKey(), g = n.getElementByKey(h), y = hP(d, p);
- if (y && zA(y) && (f = y.getMarker()), g !== null && (ke(m) || qe(m) || ai(m))) {
+ const h = m.getKey(), g = n.getElementByKey(h), y = kP(d, p);
+ if (y && GA(y) && (f = y.getMarker()), g !== null && (ke(m) || qe(m) || ci(m))) {
o.current = m.getMarker(), a.current = f, e?.({
canUndo: i.current,
canRedo: s.current,
@@ -22988,31 +23035,31 @@ function qC({ onStateChange: e }) {
}
a.current = f;
}, [n, e]);
- return J(() => t.registerCommand(Nn, (l, u) => (c(), r(u), !1), ye), [t, c]), J(() => Ye(n.registerUpdateListener(({ editorState: l }) => {
+ return J(() => t.registerCommand(On, (l, u) => (c(), r(u), !1), ye), [t, c]), J(() => Xe(n.registerUpdateListener(({ editorState: l }) => {
l.read(() => {
c();
});
- }), n.registerCommand(M0, (l) => (i.current = l, e?.({
+ }), n.registerCommand(O0, (l) => (i.current = l, e?.({
canUndo: i.current,
canRedo: s.current,
blockMarker: o.current,
contextMarker: a.current
- }), !1), ye), n.registerCommand(P0, (l) => (s.current = l, e?.({
+ }), !1), ye), n.registerCommand($0, (l) => (s.current = l, e?.({
canUndo: i.current,
canRedo: s.current,
blockMarker: o.current,
contextMarker: a.current
}), !1), ye)), [c, n, e]), null;
}
-function Ty(e, t) {
+function Ey(e, t) {
(t == null || t > e.length) && (t = e.length);
for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
return r;
}
-function Z$(e) {
+function oR(e) {
if (Array.isArray(e)) return e;
}
-function eR(e, t) {
+function aR(e, t) {
var n = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
if (n != null) {
var r, i, s, o, a = [], c = !0, l = !1;
@@ -23030,142 +23077,142 @@ function eR(e, t) {
return a;
}
}
-function tR() {
+function cR() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
-function nR(e, t) {
- return Z$(e) || eR(e, t) || rR(e, t) || tR();
+function lR(e, t) {
+ return oR(e) || aR(e, t) || uR(e, t) || cR();
}
-function rR(e, t) {
+function uR(e, t) {
if (e) {
- if (typeof e == "string") return Ty(e, t);
+ if (typeof e == "string") return Ey(e, t);
var n = {}.toString.call(e).slice(8, -1);
- return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? Ty(e, t) : void 0;
+ return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? Ey(e, t) : void 0;
}
}
-const DC = Object.entries, Cy = Object.setPrototypeOf, iR = Object.isFrozen, sR = Object.getPrototypeOf, oR = Object.getOwnPropertyDescriptor;
-let Qt = Object.freeze, en = Object.seal, Qs = Object.create, KC = typeof Reflect < "u" && Reflect, Sd = KC.apply, _d = KC.construct;
+const jC = Object.entries, My = Object.setPrototypeOf, fR = Object.isFrozen, dR = Object.getPrototypeOf, pR = Object.getOwnPropertyDescriptor;
+let Qt = Object.freeze, en = Object.seal, Qs = Object.create, VC = typeof Reflect < "u" && Reflect, Ed = VC.apply, Md = VC.construct;
Qt || (Qt = function(t) {
return t;
});
en || (en = function(t) {
return t;
});
-Sd || (Sd = function(t, n) {
+Ed || (Ed = function(t, n) {
for (var r = arguments.length, i = new Array(r > 2 ? r - 2 : 0), s = 2; s < r; s++)
i[s - 2] = arguments[s];
return t.apply(n, i);
});
-_d || (_d = function(t) {
+Md || (Md = function(t) {
for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++)
r[i - 1] = arguments[i];
return new t(...r);
});
-const Ws = $t(Array.prototype.forEach), aR = $t(Array.prototype.lastIndexOf), vy = $t(Array.prototype.pop), Hs = $t(Array.prototype.push), cR = $t(Array.prototype.splice), yi = Array.isArray, ta = $t(String.prototype.toLowerCase), bf = $t(String.prototype.toString), Sy = $t(String.prototype.match), Ho = $t(String.prototype.replace), _y = $t(String.prototype.indexOf), lR = $t(String.prototype.trim), uR = $t(Number.prototype.toString), fR = $t(Boolean.prototype.toString), Ey = typeof BigInt > "u" ? null : $t(BigInt.prototype.toString), My = typeof Symbol > "u" ? null : $t(Symbol.prototype.toString), jt = $t(Object.prototype.hasOwnProperty), Go = $t(Object.prototype.toString), zt = $t(RegExp.prototype.test), Wi = dR(TypeError);
+const Ws = $t(Array.prototype.forEach), hR = $t(Array.prototype.lastIndexOf), Py = $t(Array.prototype.pop), Hs = $t(Array.prototype.push), gR = $t(Array.prototype.splice), bi = Array.isArray, na = $t(String.prototype.toLowerCase), Tf = $t(String.prototype.toString), Ay = $t(String.prototype.match), Go = $t(String.prototype.replace), wy = $t(String.prototype.indexOf), mR = $t(String.prototype.trim), yR = $t(Number.prototype.toString), bR = $t(Boolean.prototype.toString), Ny = typeof BigInt > "u" ? null : $t(BigInt.prototype.toString), Oy = typeof Symbol > "u" ? null : $t(Symbol.prototype.toString), jt = $t(Object.prototype.hasOwnProperty), Jo = $t(Object.prototype.toString), zt = $t(RegExp.prototype.test), Hi = kR(TypeError);
function $t(e) {
return function(t) {
t instanceof RegExp && (t.lastIndex = 0);
for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++)
r[i - 1] = arguments[i];
- return Sd(e, t, r);
+ return Ed(e, t, r);
};
}
-function dR(e) {
+function kR(e) {
return function() {
for (var t = arguments.length, n = new Array(t), r = 0; r < t; r++)
n[r] = arguments[r];
- return _d(e, n);
+ return Md(e, n);
};
}
function je(e, t) {
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ta;
- if (Cy && Cy(e, null), !yi(t))
+ let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : na;
+ if (My && My(e, null), !bi(t))
return e;
let r = t.length;
for (; r--; ) {
let i = t[r];
if (typeof i == "string") {
const s = n(i);
- s !== i && (iR(t) || (t[r] = s), i = s);
+ s !== i && (fR(t) || (t[r] = s), i = s);
}
e[i] = !0;
}
return e;
}
-function pR(e) {
+function xR(e) {
for (let t = 0; t < e.length; t++)
jt(e, t) || (e[t] = null);
return e;
}
function nn(e) {
const t = Qs(null);
- for (const r of DC(e)) {
- var n = nR(r, 2);
+ for (const r of jC(e)) {
+ var n = lR(r, 2);
const i = n[0], s = n[1];
- jt(e, i) && (yi(s) ? t[i] = pR(s) : s && typeof s == "object" && s.constructor === Object ? t[i] = nn(s) : t[i] = s);
+ jt(e, i) && (bi(s) ? t[i] = xR(s) : s && typeof s == "object" && s.constructor === Object ? t[i] = nn(s) : t[i] = s);
}
return t;
}
-function hR(e) {
+function TR(e) {
switch (typeof e) {
case "string":
return e;
case "number":
- return uR(e);
+ return yR(e);
case "boolean":
- return fR(e);
+ return bR(e);
case "bigint":
- return Ey ? Ey(e) : "0";
+ return Ny ? Ny(e) : "0";
case "symbol":
- return My ? My(e) : "Symbol()";
+ return Oy ? Oy(e) : "Symbol()";
case "undefined":
- return Go(e);
+ return Jo(e);
case "function":
case "object": {
if (e === null)
- return Go(e);
- const t = e, n = gr(t, "toString");
+ return Jo(e);
+ const t = e, n = mr(t, "toString");
if (typeof n == "function") {
const r = n(t);
- return typeof r == "string" ? r : Go(r);
+ return typeof r == "string" ? r : Jo(r);
}
- return Go(e);
+ return Jo(e);
}
default:
- return Go(e);
+ return Jo(e);
}
}
-function gr(e, t) {
+function mr(e, t) {
for (; e !== null; ) {
- const r = oR(e, t);
+ const r = pR(e, t);
if (r) {
if (r.get)
return $t(r.get);
if (typeof r.value == "function")
return $t(r.value);
}
- e = sR(e);
+ e = dR(e);
}
function n() {
return null;
}
return n;
}
-function gR(e) {
+function CR(e) {
try {
return zt(e, ""), !0;
} catch {
return !1;
}
}
-const Py = Qt(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), kf = Qt(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), xf = Qt(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), mR = Qt(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Tf = Qt(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), yR = Qt(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ay = Qt(["#text"]), wy = Qt(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), Cf = Qt(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Ny = Qt(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), kc = Qt(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), bR = en(/{{[\w\W]*|^[\w\W]*}}/g), kR = en(/<%[\w\W]*|^[\w\W]*%>/g), xR = en(/\${[\w\W]*/g), TR = en(/^data-[\-\w.\u00B7-\uFFFF]+$/), CR = en(/^aria-[\-\w]+$/), Oy = en(
+const $y = Qt(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Cf = Qt(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), vf = Qt(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), vR = Qt(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Sf = Qt(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), SR = Qt(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ry = Qt(["#text"]), Iy = Qt(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), _f = Qt(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Ly = Qt(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), kc = Qt(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), _R = en(/{{[\w\W]*|^[\w\W]*}}/g), ER = en(/<%[\w\W]*|^[\w\W]*%>/g), MR = en(/\${[\w\W]*/g), PR = en(/^data-[\-\w.\u00B7-\uFFFF]+$/), AR = en(/^aria-[\-\w]+$/), qy = en(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
// eslint-disable-line no-useless-escape
-), vR = en(/^(?:\w+script|data):/i), SR = en(
+), wR = en(/^(?:\w+script|data):/i), NR = en(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
// eslint-disable-line no-control-regex
-), _R = en(/^html$/i), ER = en(/^[a-z][.\w]*(-[.\w]+)+$/i), $y = en(/<[/\w!]/g), Ry = en(/<[/\w]/g), MR = en(/<\/no(script|embed|frames)/i), PR = en(/\/>/i), Rn = {
+), OR = en(/^html$/i), $R = en(/^[a-z][.\w]*(-[.\w]+)+$/i), Dy = en(/<[/\w!]/g), Ky = en(/<[/\w]/g), RR = en(/<\/no(script|embed|frames)/i), IR = en(/\/>/i), In = {
element: 1,
attribute: 2,
text: 3,
@@ -23181,9 +23228,9 @@ const Py = Qt(["a", "abbr", "acronym", "address", "area", "article", "aside", "a
documentFragment: 11,
notation: 12
// Deprecated
-}, AR = function() {
+}, LR = function() {
return typeof window > "u" ? null : window;
-}, wR = function(t, n) {
+}, qR = function(t, n) {
if (typeof t != "object" || typeof t.createPolicy != "function")
return null;
let r = null;
@@ -23202,7 +23249,7 @@ const Py = Qt(["a", "abbr", "acronym", "address", "area", "article", "aside", "a
} catch {
return console.warn("TrustedTypes policy " + s + " could not be created."), null;
}
-}, Iy = function() {
+}, By = function() {
return {
afterSanitizeAttributes: [],
afterSanitizeElements: [],
@@ -23214,53 +23261,53 @@ const Py = Qt(["a", "abbr", "acronym", "address", "area", "article", "aside", "a
uponSanitizeElement: [],
uponSanitizeShadowNode: []
};
-}, pi = function(t, n, r, i) {
- return jt(t, n) && yi(t[n]) ? je(i.base ? nn(i.base) : {}, t[n], i.transform) : r;
+}, hi = function(t, n, r, i) {
+ return jt(t, n) && bi(t[n]) ? je(i.base ? nn(i.base) : {}, t[n], i.transform) : r;
};
-function UC() {
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : AR();
- const t = (Q) => UC(Q);
- if (t.version = "3.4.13", t.removed = [], !e || !e.document || e.document.nodeType !== Rn.document || !e.Element)
+function WC() {
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : LR();
+ const t = (Q) => WC(Q);
+ if (t.version = "3.4.13", t.removed = [], !e || !e.document || e.document.nodeType !== In.document || !e.Element)
return t.isSupported = !1, t;
let n = e.document;
const r = n, i = r.currentScript;
e.DocumentFragment;
const s = e.HTMLTemplateElement, o = e.Node, a = e.Element, c = e.NodeFilter, l = e.NamedNodeMap;
l === void 0 && (e.NamedNodeMap || e.MozNamedAttrMap), e.HTMLFormElement;
- const u = e.DOMParser, f = e.trustedTypes, d = a.prototype, p = gr(d, "cloneNode"), m = gr(d, "remove"), h = gr(d, "nextSibling"), g = gr(d, "childNodes"), y = gr(d, "parentNode"), b = gr(d, "shadowRoot"), C = gr(d, "attributes"), x = o && o.prototype ? gr(o.prototype, "nodeType") : null, _ = o && o.prototype ? gr(o.prototype, "nodeName") : null, F = o && o.prototype ? gr(o.prototype, "ownerDocument") : null;
+ const u = e.DOMParser, f = e.trustedTypes, d = a.prototype, p = mr(d, "cloneNode"), m = mr(d, "remove"), h = mr(d, "nextSibling"), g = mr(d, "childNodes"), y = mr(d, "parentNode"), b = mr(d, "shadowRoot"), T = mr(d, "attributes"), x = o && o.prototype ? mr(o.prototype, "nodeType") : null, _ = o && o.prototype ? mr(o.prototype, "nodeName") : null, U = o && o.prototype ? mr(o.prototype, "ownerDocument") : null;
if (typeof s == "function") {
const Q = n.createElement("template");
Q.content && Q.content.ownerDocument && (n = Q.content.ownerDocument);
}
- let R, W = "", ce, se = !1, Y = 0;
+ let I, V = "", ce, se = !1, Y = 0;
const be = function() {
if (Y > 0)
- throw Wi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
+ throw Hi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
}, Se = function(k) {
be(), Y++;
try {
- return R.createHTML(k);
+ return I.createHTML(k);
} finally {
Y--;
}
- }, Fe = function(k) {
+ }, Ue = function(k) {
be(), Y++;
try {
- return R.createScriptURL(k);
+ return I.createScriptURL(k);
} finally {
Y--;
}
- }, I = function() {
- return se || (ce = wR(f, i), se = !0), ce;
+ }, R = function() {
+ return se || (ce = qR(f, i), se = !0), ce;
}, q = n, j = q.implementation, ne = q.createNodeIterator, N = q.createDocumentFragment, X = q.getElementsByTagName, oe = r.importNode;
- let me = Iy();
- t.isSupported = typeof DC == "function" && typeof y == "function" && j && j.createHTMLDocument !== void 0;
- const ie = bR, B = kR, ue = xR, we = TR, $e = CR, mt = vR, At = SR, Ft = ER;
- let cn = Oy, Xe = null;
- const fe = je({}, [...Py, ...kf, ...xf, ...Tf, ...Ay]);
+ let he = By();
+ t.isSupported = typeof jC == "function" && typeof y == "function" && j && j.createHTMLDocument !== void 0;
+ const ie = _R, F = ER, ue = MR, we = PR, $e = AR, yt = wR, At = NR, Ut = $R;
+ let cn = qy, Qe = null;
+ const fe = je({}, [...$y, ...Cf, ...vf, ...Sf, ...Ry]);
let Ne = null;
- const Ui = je({}, [...wy, ...Cf, ...Ny, ...kc]);
- let Qe = Object.seal(Qs(null, {
+ const Ui = je({}, [...Iy, ..._f, ...Ly, ...kc]);
+ let Ze = Object.seal(Qs(null, {
tagNameCheck: {
writable: !0,
configurable: !1,
@@ -23279,7 +23326,7 @@ function UC() {
enumerable: !0,
value: !1
}
- })), Zn = null, Ze = null;
+ })), Zn = null, et = null;
const L = Object.seal(Qs(null, {
tagCheck: {
writable: !0,
@@ -23294,9 +23341,9 @@ function UC() {
value: null
}
}));
- let V = !0, Z = !0, te = !1, ve = !0, de = !1, le = !0, pe = !1, xe = !1, st = null, et = null, tn = !1, Bt = !1, er = !1, li = !1, ac = !0, Ko = !1;
+ let W = !0, Z = !0, te = !1, ve = !0, de = !1, le = !0, pe = !1, xe = !1, ct = null, tt = null, tn = !1, Ft = !1, er = !1, ui = !1, ac = !0, Bo = !1;
const Uo = "user-content-";
- let Fi = !0, Fs = !1, Vr = {}, w = null;
+ let Fi = !0, Us = !1, Wr = {}, w = null;
const D = je({}, [
"annotation-xml",
"audio",
@@ -23337,72 +23384,72 @@ function UC() {
let G = null;
const re = je({}, ["audio", "video", "img", "source", "image", "track"]);
let Re = null;
- const De = je({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Ge = "http://www.w3.org/1998/Math/MathML", tt = "http://www.w3.org/2000/svg", ft = "http://www.w3.org/1999/xhtml";
- let yt = ft, Rt = !1, tr = null;
- const nr = je({}, [Ge, tt, ft], bf), rr = Qt(["mi", "mo", "mn", "ms", "mtext"]);
- let ui = je({}, rr);
- const Bi = Qt(["annotation-xml"]);
- let Du = je({}, Bi);
- const Q_ = je({}, ["title", "style", "font", "a", "script"]);
+ const De = je({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Ge = "http://www.w3.org/1998/Math/MathML", nt = "http://www.w3.org/2000/svg", dt = "http://www.w3.org/1999/xhtml";
+ let bt = dt, Rt = !1, tr = null;
+ const nr = je({}, [Ge, nt, dt], Tf), rr = Qt(["mi", "mo", "mn", "ms", "mtext"]);
+ let fi = je({}, rr);
+ const zi = Qt(["annotation-xml"]);
+ let Uu = je({}, zi);
+ const r0 = je({}, ["title", "style", "font", "a", "script"]);
let Fo = null;
- const Z_ = ["application/xhtml+xml", "text/html"], e0 = "text/html";
- let xt = null, Bs = null;
- const t0 = n.createElement("form"), Lg = function(k) {
+ const i0 = ["application/xhtml+xml", "text/html"], s0 = "text/html";
+ let xt = null, Fs = null;
+ const o0 = n.createElement("form"), Ug = function(k) {
return k instanceof RegExp || k instanceof Function;
- }, Ku = function() {
+ }, Fu = function() {
let k = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
- if (Bs && Bs === k)
+ if (Fs && Fs === k)
return;
(!k || typeof k != "object") && (k = {}), k = nn(k), Fo = // eslint-disable-next-line unicorn/prefer-includes
- Z_.indexOf(k.PARSER_MEDIA_TYPE) === -1 ? e0 : k.PARSER_MEDIA_TYPE, xt = Fo === "application/xhtml+xml" ? bf : ta, Xe = pi(k, "ALLOWED_TAGS", fe, {
+ i0.indexOf(k.PARSER_MEDIA_TYPE) === -1 ? s0 : k.PARSER_MEDIA_TYPE, xt = Fo === "application/xhtml+xml" ? Tf : na, Qe = hi(k, "ALLOWED_TAGS", fe, {
transform: xt
- }), Ne = pi(k, "ALLOWED_ATTR", Ui, {
+ }), Ne = hi(k, "ALLOWED_ATTR", Ui, {
transform: xt
- }), tr = pi(k, "ALLOWED_NAMESPACES", nr, {
- transform: bf
- }), Re = pi(k, "ADD_URI_SAFE_ATTR", De, {
+ }), tr = hi(k, "ALLOWED_NAMESPACES", nr, {
+ transform: Tf
+ }), Re = hi(k, "ADD_URI_SAFE_ATTR", De, {
transform: xt,
base: De
- }), G = pi(k, "ADD_DATA_URI_TAGS", re, {
+ }), G = hi(k, "ADD_DATA_URI_TAGS", re, {
transform: xt,
base: re
- }), w = pi(k, "FORBID_CONTENTS", D, {
+ }), w = hi(k, "FORBID_CONTENTS", D, {
transform: xt
- }), Zn = pi(k, "FORBID_TAGS", nn({}), {
+ }), Zn = hi(k, "FORBID_TAGS", nn({}), {
transform: xt
- }), Ze = pi(k, "FORBID_ATTR", nn({}), {
+ }), et = hi(k, "FORBID_ATTR", nn({}), {
transform: xt
- }), Vr = jt(k, "USE_PROFILES") ? k.USE_PROFILES && typeof k.USE_PROFILES == "object" ? nn(k.USE_PROFILES) : k.USE_PROFILES : !1, V = k.ALLOW_ARIA_ATTR !== !1, Z = k.ALLOW_DATA_ATTR !== !1, te = k.ALLOW_UNKNOWN_PROTOCOLS || !1, ve = k.ALLOW_SELF_CLOSE_IN_ATTR !== !1, de = k.SAFE_FOR_TEMPLATES || !1, le = k.SAFE_FOR_XML !== !1, pe = k.WHOLE_DOCUMENT || !1, Bt = k.RETURN_DOM || !1, er = k.RETURN_DOM_FRAGMENT || !1, li = k.RETURN_TRUSTED_TYPE || !1, tn = k.FORCE_BODY || !1, ac = k.SANITIZE_DOM !== !1, Ko = k.SANITIZE_NAMED_PROPS || !1, Fi = k.KEEP_CONTENT !== !1, Fs = k.IN_PLACE || !1, cn = gR(k.ALLOWED_URI_REGEXP) ? k.ALLOWED_URI_REGEXP : Oy, yt = typeof k.NAMESPACE == "string" ? k.NAMESPACE : ft, ui = jt(k, "MATHML_TEXT_INTEGRATION_POINTS") && k.MATHML_TEXT_INTEGRATION_POINTS && typeof k.MATHML_TEXT_INTEGRATION_POINTS == "object" ? nn(k.MATHML_TEXT_INTEGRATION_POINTS) : je({}, rr), Du = jt(k, "HTML_INTEGRATION_POINTS") && k.HTML_INTEGRATION_POINTS && typeof k.HTML_INTEGRATION_POINTS == "object" ? nn(k.HTML_INTEGRATION_POINTS) : je({}, Bi);
+ }), Wr = jt(k, "USE_PROFILES") ? k.USE_PROFILES && typeof k.USE_PROFILES == "object" ? nn(k.USE_PROFILES) : k.USE_PROFILES : !1, W = k.ALLOW_ARIA_ATTR !== !1, Z = k.ALLOW_DATA_ATTR !== !1, te = k.ALLOW_UNKNOWN_PROTOCOLS || !1, ve = k.ALLOW_SELF_CLOSE_IN_ATTR !== !1, de = k.SAFE_FOR_TEMPLATES || !1, le = k.SAFE_FOR_XML !== !1, pe = k.WHOLE_DOCUMENT || !1, Ft = k.RETURN_DOM || !1, er = k.RETURN_DOM_FRAGMENT || !1, ui = k.RETURN_TRUSTED_TYPE || !1, tn = k.FORCE_BODY || !1, ac = k.SANITIZE_DOM !== !1, Bo = k.SANITIZE_NAMED_PROPS || !1, Fi = k.KEEP_CONTENT !== !1, Us = k.IN_PLACE || !1, cn = CR(k.ALLOWED_URI_REGEXP) ? k.ALLOWED_URI_REGEXP : qy, bt = typeof k.NAMESPACE == "string" ? k.NAMESPACE : dt, fi = jt(k, "MATHML_TEXT_INTEGRATION_POINTS") && k.MATHML_TEXT_INTEGRATION_POINTS && typeof k.MATHML_TEXT_INTEGRATION_POINTS == "object" ? nn(k.MATHML_TEXT_INTEGRATION_POINTS) : je({}, rr), Uu = jt(k, "HTML_INTEGRATION_POINTS") && k.HTML_INTEGRATION_POINTS && typeof k.HTML_INTEGRATION_POINTS == "object" ? nn(k.HTML_INTEGRATION_POINTS) : je({}, zi);
const P = jt(k, "CUSTOM_ELEMENT_HANDLING") && k.CUSTOM_ELEMENT_HANDLING && typeof k.CUSTOM_ELEMENT_HANDLING == "object" ? nn(k.CUSTOM_ELEMENT_HANDLING) : Qs(null);
- if (Qe = Qs(null), jt(P, "tagNameCheck") && Lg(P.tagNameCheck) && (Qe.tagNameCheck = P.tagNameCheck), jt(P, "attributeNameCheck") && Lg(P.attributeNameCheck) && (Qe.attributeNameCheck = P.attributeNameCheck), jt(P, "allowCustomizedBuiltInElements") && typeof P.allowCustomizedBuiltInElements == "boolean" && (Qe.allowCustomizedBuiltInElements = P.allowCustomizedBuiltInElements), en(Qe), de && (Z = !1), er && (Bt = !0), Vr && (Xe = je({}, Ay), Ne = Qs(null), Vr.html === !0 && (je(Xe, Py), je(Ne, wy)), Vr.svg === !0 && (je(Xe, kf), je(Ne, Cf), je(Ne, kc)), Vr.svgFilters === !0 && (je(Xe, xf), je(Ne, Cf), je(Ne, kc)), Vr.mathMl === !0 && (je(Xe, Tf), je(Ne, Ny), je(Ne, kc))), L.tagCheck = null, L.attributeCheck = null, jt(k, "ADD_TAGS") && (typeof k.ADD_TAGS == "function" ? L.tagCheck = k.ADD_TAGS : yi(k.ADD_TAGS) && (Xe === fe && (Xe = nn(Xe)), je(Xe, k.ADD_TAGS, xt))), jt(k, "ADD_ATTR") && (typeof k.ADD_ATTR == "function" ? L.attributeCheck = k.ADD_ATTR : yi(k.ADD_ATTR) && (Ne === Ui && (Ne = nn(Ne)), je(Ne, k.ADD_ATTR, xt))), jt(k, "ADD_URI_SAFE_ATTR") && yi(k.ADD_URI_SAFE_ATTR) && je(Re, k.ADD_URI_SAFE_ATTR, xt), jt(k, "FORBID_CONTENTS") && yi(k.FORBID_CONTENTS) && (w === D && (w = nn(w)), je(w, k.FORBID_CONTENTS, xt)), jt(k, "ADD_FORBID_CONTENTS") && yi(k.ADD_FORBID_CONTENTS) && (w === D && (w = nn(w)), je(w, k.ADD_FORBID_CONTENTS, xt)), Fi && (Xe["#text"] = !0), pe && je(Xe, ["html", "head", "body"]), Xe.table && (je(Xe, ["tbody"]), delete Zn.tbody), k.TRUSTED_TYPES_POLICY) {
+ if (Ze = Qs(null), jt(P, "tagNameCheck") && Ug(P.tagNameCheck) && (Ze.tagNameCheck = P.tagNameCheck), jt(P, "attributeNameCheck") && Ug(P.attributeNameCheck) && (Ze.attributeNameCheck = P.attributeNameCheck), jt(P, "allowCustomizedBuiltInElements") && typeof P.allowCustomizedBuiltInElements == "boolean" && (Ze.allowCustomizedBuiltInElements = P.allowCustomizedBuiltInElements), en(Ze), de && (Z = !1), er && (Ft = !0), Wr && (Qe = je({}, Ry), Ne = Qs(null), Wr.html === !0 && (je(Qe, $y), je(Ne, Iy)), Wr.svg === !0 && (je(Qe, Cf), je(Ne, _f), je(Ne, kc)), Wr.svgFilters === !0 && (je(Qe, vf), je(Ne, _f), je(Ne, kc)), Wr.mathMl === !0 && (je(Qe, Sf), je(Ne, Ly), je(Ne, kc))), L.tagCheck = null, L.attributeCheck = null, jt(k, "ADD_TAGS") && (typeof k.ADD_TAGS == "function" ? L.tagCheck = k.ADD_TAGS : bi(k.ADD_TAGS) && (Qe === fe && (Qe = nn(Qe)), je(Qe, k.ADD_TAGS, xt))), jt(k, "ADD_ATTR") && (typeof k.ADD_ATTR == "function" ? L.attributeCheck = k.ADD_ATTR : bi(k.ADD_ATTR) && (Ne === Ui && (Ne = nn(Ne)), je(Ne, k.ADD_ATTR, xt))), jt(k, "ADD_URI_SAFE_ATTR") && bi(k.ADD_URI_SAFE_ATTR) && je(Re, k.ADD_URI_SAFE_ATTR, xt), jt(k, "FORBID_CONTENTS") && bi(k.FORBID_CONTENTS) && (w === D && (w = nn(w)), je(w, k.FORBID_CONTENTS, xt)), jt(k, "ADD_FORBID_CONTENTS") && bi(k.ADD_FORBID_CONTENTS) && (w === D && (w = nn(w)), je(w, k.ADD_FORBID_CONTENTS, xt)), Fi && (Qe["#text"] = !0), pe && je(Qe, ["html", "head", "body"]), Qe.table && (je(Qe, ["tbody"]), delete Zn.tbody), k.TRUSTED_TYPES_POLICY) {
if (typeof k.TRUSTED_TYPES_POLICY.createHTML != "function")
- throw Wi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
+ throw Hi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
if (typeof k.TRUSTED_TYPES_POLICY.createScriptURL != "function")
- throw Wi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
- const H = R;
- R = k.TRUSTED_TYPES_POLICY;
+ throw Hi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
+ const H = I;
+ I = k.TRUSTED_TYPES_POLICY;
try {
- W = Se("");
- } catch (he) {
- throw R = H, he;
+ V = Se("");
+ } catch (ge) {
+ throw I = H, ge;
}
- } else k.TRUSTED_TYPES_POLICY === null ? (R = void 0, W = "") : (R === void 0 && (R = I()), R && typeof W == "string" && (W = Se("")));
- Qt && Qt(k), Bs = k;
- }, qg = je({}, [...kf, ...xf, ...mR]), Dg = je({}, [...Tf, ...yR]), n0 = function(k, P, H) {
- return P.namespaceURI === ft ? k === "svg" : P.namespaceURI === Ge ? k === "svg" && (H === "annotation-xml" || ui[H]) : !!qg[k];
- }, r0 = function(k, P, H) {
- return P.namespaceURI === ft ? k === "math" : P.namespaceURI === tt ? k === "math" && Du[H] : !!Dg[k];
- }, i0 = function(k, P, H) {
- return P.namespaceURI === tt && !Du[H] || P.namespaceURI === Ge && !ui[H] ? !1 : !Dg[k] && (Q_[k] || !qg[k]);
- }, s0 = function(k) {
+ } else k.TRUSTED_TYPES_POLICY === null ? (I = void 0, V = "") : (I === void 0 && (I = R()), I && typeof V == "string" && (V = Se("")));
+ Qt && Qt(k), Fs = k;
+ }, Fg = je({}, [...Cf, ...vf, ...vR]), zg = je({}, [...Sf, ...SR]), a0 = function(k, P, H) {
+ return P.namespaceURI === dt ? k === "svg" : P.namespaceURI === Ge ? k === "svg" && (H === "annotation-xml" || fi[H]) : !!Fg[k];
+ }, c0 = function(k, P, H) {
+ return P.namespaceURI === dt ? k === "math" : P.namespaceURI === nt ? k === "math" && Uu[H] : !!zg[k];
+ }, l0 = function(k, P, H) {
+ return P.namespaceURI === nt && !Uu[H] || P.namespaceURI === Ge && !fi[H] ? !1 : !zg[k] && (r0[k] || !Fg[k]);
+ }, u0 = function(k) {
let P = y(k);
(!P || !P.tagName) && (P = {
- namespaceURI: yt,
+ namespaceURI: bt,
tagName: "template"
});
- const H = ta(k.tagName), he = ta(P.tagName);
- return tr[k.namespaceURI] ? k.namespaceURI === tt ? n0(H, P, he) : k.namespaceURI === Ge ? r0(H, P, he) : k.namespaceURI === ft ? i0(H, P, he) : !!(Fo === "application/xhtml+xml" && tr[k.namespaceURI]) : !1;
- }, fi = function(k) {
+ const H = na(k.tagName), ge = na(P.tagName);
+ return tr[k.namespaceURI] ? k.namespaceURI === nt ? a0(H, P, ge) : k.namespaceURI === Ge ? c0(H, P, ge) : k.namespaceURI === dt ? l0(H, P, ge) : !!(Fo === "application/xhtml+xml" && tr[k.namespaceURI]) : !1;
+ }, di = function(k) {
Hs(t.removed, {
element: k
});
@@ -23410,33 +23457,33 @@ function UC() {
y(k).removeChild(k);
} catch {
if (m(k), !y(k))
- throw Wi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
+ throw Hi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
}
}, cc = function(k) {
- Bo(k);
+ zo(k);
const P = g(k);
if (P) {
- const he = [];
+ const ge = [];
Ws(P, (Ce) => {
- Hs(he, Ce);
- }), Ws(he, (Ce) => {
+ Hs(ge, Ce);
+ }), Ws(ge, (Ce) => {
try {
m(Ce);
} catch {
}
});
}
- const H = C(k);
+ const H = T(k);
if (H)
- for (let he = H.length - 1; he >= 0; --he) {
- const Ce = H[he], Ae = Ce && Ce.name;
+ for (let ge = H.length - 1; ge >= 0; --ge) {
+ const Ce = H[ge], Ae = Ce && Ce.name;
if (typeof Ae == "string")
try {
k.removeAttribute(Ae);
} catch {
}
}
- }, zi = function(k, P) {
+ }, ji = function(k, P) {
try {
Hs(t.removed, {
attribute: P.getAttributeNode(k),
@@ -23449,9 +23496,9 @@ function UC() {
});
}
if (P.removeAttribute(k), k === "is")
- if (Bt || er)
+ if (Ft || er)
try {
- fi(P);
+ di(P);
} catch {
}
else
@@ -23459,44 +23506,44 @@ function UC() {
P.setAttribute(k, "");
} catch {
}
- }, o0 = function(k) {
- const P = C(k);
+ }, f0 = function(k) {
+ const P = T(k);
if (P)
for (let H = P.length - 1; H >= 0; --H) {
- const he = P[H], Ce = he && he.name;
+ const ge = P[H], Ce = ge && ge.name;
if (!(typeof Ce != "string" || Ne[xt(Ce)]))
try {
k.removeAttribute(Ce);
} catch {
}
}
- }, Bo = function(k) {
+ }, zo = function(k) {
const P = [k];
for (; P.length > 0; ) {
const H = P.pop();
- (x ? x(H) : H.nodeType) === Rn.element && o0(H);
+ (x ? x(H) : H.nodeType) === In.element && f0(H);
const Ce = g(H);
if (Ce)
for (let Ae = Ce.length - 1; Ae >= 0; --Ae)
P.push(Ce[Ae]);
}
- }, a0 = function(k) {
+ }, d0 = function(k) {
if (!le)
return;
const P = [k];
for (; P.length > 0; ) {
- const H = P.pop(), he = x ? x(H) : H.nodeType;
- if (he === Rn.processingInstruction || he === Rn.comment && zt(Ry, H.data)) {
+ const H = P.pop(), ge = x ? x(H) : H.nodeType;
+ if (ge === In.processingInstruction || ge === In.comment && zt(Ky, H.data)) {
try {
m(H);
} catch {
}
continue;
}
- if (he === Rn.element) {
- const Ae = H, lt = xt(_ ? _(H) : H.nodeName);
+ if (ge === In.element) {
+ const Ae = H, ut = xt(_ ? _(H) : H.nodeName);
try {
- Ae.hasAttribute && Ae.hasAttribute("patchsrc") && Ae.removeAttribute("patchsrc"), Ae.hasAttribute && Ae.hasAttribute("for") && lt !== "label" && lt !== "output" && Ae.removeAttribute("for");
+ Ae.hasAttribute && Ae.hasAttribute("patchsrc") && Ae.removeAttribute("patchsrc"), Ae.hasAttribute && Ae.hasAttribute("for") && ut !== "label" && ut !== "output" && Ae.removeAttribute("for");
} catch {
}
}
@@ -23505,32 +23552,32 @@ function UC() {
for (let Ae = Ce.length - 1; Ae >= 0; --Ae)
P.push(Ce[Ae]);
}
- }, Kg = function(k) {
+ }, jg = function(k) {
let P = null, H = null;
if (tn)
k = "" + k;
else {
- const Ae = Sy(k, /^[\r\n\t ]+/);
+ const Ae = Ay(k, /^[\r\n\t ]+/);
H = Ae && Ae[0];
}
- Fo === "application/xhtml+xml" && yt === ft && (k = '
' + k + "");
- const he = R ? Se(k) : k;
- if (yt === ft)
+ Fo === "application/xhtml+xml" && bt === dt && (k = '' + k + "");
+ const ge = I ? Se(k) : k;
+ if (bt === dt)
try {
- P = new u().parseFromString(he, Fo);
+ P = new u().parseFromString(ge, Fo);
} catch {
}
if (!P || !P.documentElement) {
- P = j.createDocument(yt, "template", null);
+ P = j.createDocument(bt, "template", null);
try {
- P.documentElement.innerHTML = Rt ? W : he;
+ P.documentElement.innerHTML = Rt ? V : ge;
} catch {
}
}
const Ce = P.body || P.documentElement;
- return k && H && Ce.insertBefore(n.createTextNode(H), Ce.childNodes[0] || null), yt === ft ? X.call(P, pe ? "html" : "body")[0] : pe ? P.documentElement : Ce;
- }, Ug = function(k) {
- const P = F ? F(k) : k.ownerDocument;
+ return k && H && Ce.insertBefore(n.createTextNode(H), Ce.childNodes[0] || null), bt === dt ? X.call(P, pe ? "html" : "body")[0] : pe ? P.documentElement : Ce;
+ }, Vg = function(k) {
+ const P = U ? U(k) : k.ownerDocument;
return ne.call(
P || k,
k,
@@ -23539,23 +23586,23 @@ function UC() {
null
);
}, lc = function(k) {
- return k = Ho(k, ie, " "), k = Ho(k, B, " "), k = Ho(k, ue, " "), k;
- }, Uu = function(k) {
+ return k = Go(k, ie, " "), k = Go(k, F, " "), k = Go(k, ue, " "), k;
+ }, zu = function(k) {
var P;
k.normalize();
- const H = F ? F(k) : k.ownerDocument, he = ne.call(
+ const H = U ? U(k) : k.ownerDocument, ge = ne.call(
H || k,
k,
// eslint-disable-next-line no-bitwise
c.SHOW_TEXT | c.SHOW_COMMENT | c.SHOW_CDATA_SECTION | c.SHOW_PROCESSING_INSTRUCTION,
null
);
- let Ce = he.nextNode();
+ let Ce = ge.nextNode();
for (; Ce; )
- Ce.data = lc(Ce.data), Ce = he.nextNode();
+ Ce.data = lc(Ce.data), Ce = ge.nextNode();
const Ae = (P = k.querySelectorAll) === null || P === void 0 ? void 0 : P.call(k, "template");
- Ae && Ws(Ae, (lt) => {
- zs(lt.content) && Uu(lt.content);
+ Ae && Ws(Ae, (ut) => {
+ zs(ut.content) && zu(ut.content);
});
}, uc = function(k) {
const P = _ ? _(k) : null;
@@ -23564,7 +23611,7 @@ function UC() {
// makes the direct read diverge from the cached read; a clean form
// (same-realm OR foreign-realm) has both reads pointing at the same
// canonical NamedNodeMap.
- k.attributes !== C(k) || typeof k.removeAttribute != "function" || typeof k.setAttribute != "function" || typeof k.namespaceURI != "string" || typeof k.insertBefore != "function" || typeof k.hasChildNodes != "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
+ k.attributes !== T(k) || typeof k.removeAttribute != "function" || typeof k.setAttribute != "function" || typeof k.namespaceURI != "string" || typeof k.insertBefore != "function" || typeof k.hasChildNodes != "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
// returns the integer 1 for any Element regardless of realm; direct
// read on a clobbered form (e.g. ) returns
// the named child element. Cheap addition — nodeType is read from
@@ -23587,11 +23634,11 @@ function UC() {
if (!x || typeof k != "object" || k === null)
return !1;
try {
- return x(k) === Rn.documentFragment;
+ return x(k) === In.documentFragment;
} catch {
return !1;
}
- }, zo = function(k) {
+ }, jo = function(k) {
if (!x || typeof k != "object" || k === null)
return !1;
try {
@@ -23602,64 +23649,64 @@ function UC() {
};
function Pr(Q, k, P) {
Q.length !== 0 && Ws(Q, (H) => {
- H.call(t, k, P, Bs);
+ H.call(t, k, P, Fs);
});
}
- const c0 = function(k, P) {
- return !!(le && k.hasChildNodes() && !zo(k.firstElementChild) && zt($y, k.textContent) && zt($y, k.innerHTML) || le && k.namespaceURI === ft && P === "style" && zo(k.firstElementChild) || k.nodeType === Rn.processingInstruction || le && k.nodeType === Rn.comment && zt(Ry, k.data));
- }, l0 = function(k, P, H) {
- if (!Zn[P] && jg(P) && (Qe.tagNameCheck instanceof RegExp && zt(Qe.tagNameCheck, P) || Qe.tagNameCheck instanceof Function && Qe.tagNameCheck(P)))
+ const p0 = function(k, P) {
+ return !!(le && k.hasChildNodes() && !jo(k.firstElementChild) && zt(Dy, k.textContent) && zt(Dy, k.innerHTML) || le && k.namespaceURI === dt && P === "style" && jo(k.firstElementChild) || k.nodeType === In.processingInstruction || le && k.nodeType === In.comment && zt(Ky, k.data));
+ }, h0 = function(k, P, H) {
+ if (!Zn[P] && Jg(P) && (Ze.tagNameCheck instanceof RegExp && zt(Ze.tagNameCheck, P) || Ze.tagNameCheck instanceof Function && Ze.tagNameCheck(P)))
return !1;
if (Fi && !w[P]) {
- const he = y(k), Ce = g(k);
- if (Ce && he) {
+ const ge = y(k), Ce = g(k);
+ if (Ce && ge) {
const Ae = Ce.length;
- for (let lt = Ae - 1; lt >= 0; --lt) {
- const Tt = k === H ? p(Ce[lt], !0) : Ce[lt];
- he.insertBefore(Tt, h(k));
+ for (let ut = Ae - 1; ut >= 0; --ut) {
+ const Tt = k === H ? p(Ce[ut], !0) : Ce[ut];
+ ge.insertBefore(Tt, h(k));
}
}
}
- return fi(k), !0;
- }, Fg = function(k, P, H, he) {
- return k.length === 0 ? P : P === H || P === he ? nn(P) : P;
- }, Bg = function(k, P) {
- if (Pr(me.beforeSanitizeElements, k, null), k !== P && y(k) === null)
- return Fs && Bo(k), !0;
+ return di(k), !0;
+ }, Wg = function(k, P, H, ge) {
+ return k.length === 0 ? P : P === H || P === ge ? nn(P) : P;
+ }, Hg = function(k, P) {
+ if (Pr(he.beforeSanitizeElements, k, null), k !== P && y(k) === null)
+ return Us && zo(k), !0;
if (uc(k))
- return fi(k), !0;
+ return di(k), !0;
const H = xt(_ ? _(k) : k.nodeName);
- if (Xe = Fg(me.uponSanitizeElement, Xe, fe, st), Pr(me.uponSanitizeElement, k, {
+ if (Qe = Wg(he.uponSanitizeElement, Qe, fe, ct), Pr(he.uponSanitizeElement, k, {
tagName: H,
- allowedTags: Xe
+ allowedTags: Qe
}), k !== P && y(k) === null)
- return Fs && Bo(k), !0;
- if (c0(k, H))
- return fi(k), !0;
- if (Zn[H] || !(L.tagCheck instanceof Function && L.tagCheck(H)) && !Xe[H]) {
- const Ce = l0(k, H, P);
- return Ce === !1 && Pr(me.afterSanitizeElements, k, null), Ce;
- }
- if ((x ? x(k) : k.nodeType) === Rn.element && !s0(k) || (H === "noscript" || H === "noembed" || H === "noframes") && zt(MR, k.innerHTML))
- return fi(k), !0;
- if (de && k.nodeType === Rn.text) {
+ return Us && zo(k), !0;
+ if (p0(k, H))
+ return di(k), !0;
+ if (Zn[H] || !(L.tagCheck instanceof Function && L.tagCheck(H)) && !Qe[H]) {
+ const Ce = h0(k, H, P);
+ return Ce === !1 && Pr(he.afterSanitizeElements, k, null), Ce;
+ }
+ if ((x ? x(k) : k.nodeType) === In.element && !u0(k) || (H === "noscript" || H === "noembed" || H === "noframes") && zt(RR, k.innerHTML))
+ return di(k), !0;
+ if (de && k.nodeType === In.text) {
const Ce = lc(k.textContent);
k.textContent !== Ce && (Hs(t.removed, {
element: k.cloneNode()
}), k.textContent = Ce);
}
- return Pr(me.afterSanitizeElements, k, null), !1;
- }, zg = function(k, P, H) {
- if (Ze[P] || le && P === "patchsrc" || le && P === "for" && k !== "label" && k !== "output" || ac && (P === "id" || P === "name") && (H in n || H in t0))
+ return Pr(he.afterSanitizeElements, k, null), !1;
+ }, Gg = function(k, P, H) {
+ if (et[P] || le && P === "patchsrc" || le && P === "for" && k !== "label" && k !== "output" || ac && (P === "id" || P === "name") && (H in n || H in o0))
return !1;
- const he = Ne[P] || L.attributeCheck instanceof Function && L.attributeCheck(P, k);
+ const ge = Ne[P] || L.attributeCheck instanceof Function && L.attributeCheck(P, k);
if (!(Z && zt(we, P))) {
- if (!(V && zt($e, P))) {
- if (he) {
+ if (!(W && zt($e, P))) {
+ if (ge) {
if (!Re[P]) {
- if (!zt(cn, Ho(H, At, ""))) {
- if (!((P === "src" || P === "xlink:href" || P === "href") && k !== "script" && _y(H, "data:") === 0 && G[k])) {
- if (!(te && !zt(mt, Ho(H, At, "")))) {
+ if (!zt(cn, Go(H, At, ""))) {
+ if (!((P === "src" || P === "xlink:href" || P === "href") && k !== "script" && wy(H, "data:") === 0 && G[k])) {
+ if (!(te && !zt(yt, Go(H, At, "")))) {
if (H)
return !1;
}
@@ -23670,36 +23717,36 @@ function UC() {
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
- !(jg(k) && (Qe.tagNameCheck instanceof RegExp && zt(Qe.tagNameCheck, k) || Qe.tagNameCheck instanceof Function && Qe.tagNameCheck(k)) && (Qe.attributeNameCheck instanceof RegExp && zt(Qe.attributeNameCheck, P) || Qe.attributeNameCheck instanceof Function && Qe.attributeNameCheck(P, k)) || // Alternative, second condition checks if it's an `is`-attribute, AND
+ !(Jg(k) && (Ze.tagNameCheck instanceof RegExp && zt(Ze.tagNameCheck, k) || Ze.tagNameCheck instanceof Function && Ze.tagNameCheck(k)) && (Ze.attributeNameCheck instanceof RegExp && zt(Ze.attributeNameCheck, P) || Ze.attributeNameCheck instanceof Function && Ze.attributeNameCheck(P, k)) || // Alternative, second condition checks if it's an `is`-attribute, AND
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
- P === "is" && Qe.allowCustomizedBuiltInElements && (Qe.tagNameCheck instanceof RegExp && zt(Qe.tagNameCheck, H) || Qe.tagNameCheck instanceof Function && Qe.tagNameCheck(H)))
+ P === "is" && Ze.allowCustomizedBuiltInElements && (Ze.tagNameCheck instanceof RegExp && zt(Ze.tagNameCheck, H) || Ze.tagNameCheck instanceof Function && Ze.tagNameCheck(H)))
) return !1;
}
}
return !0;
- }, u0 = je({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), jg = function(k) {
- return !u0[ta(k)] && zt(Ft, k);
- }, f0 = function(k, P, H, he) {
- if (R && typeof f == "object" && typeof f.getAttributeType == "function" && !H)
+ }, g0 = je({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), Jg = function(k) {
+ return !g0[na(k)] && zt(Ut, k);
+ }, m0 = function(k, P, H, ge) {
+ if (I && typeof f == "object" && typeof f.getAttributeType == "function" && !H)
switch (f.getAttributeType(k, P)) {
case "TrustedHTML":
- return Se(he);
+ return Se(ge);
case "TrustedScriptURL":
- return Fe(he);
+ return Ue(ge);
}
- return he;
- }, d0 = function(k, P, H, he) {
+ return ge;
+ }, y0 = function(k, P, H, ge) {
try {
- H ? k.setAttributeNS(H, P, he) : k.setAttribute(P, he), uc(k) ? fi(k) : vy(t.removed);
+ H ? k.setAttributeNS(H, P, ge) : k.setAttribute(P, ge), uc(k) ? di(k) : Py(t.removed);
} catch {
- zi(P, k);
+ ji(P, k);
}
- }, Vg = function(k) {
- Pr(me.beforeSanitizeAttributes, k, null);
+ }, Yg = function(k) {
+ Pr(he.beforeSanitizeAttributes, k, null);
const P = k.attributes;
if (!P || uc(k))
return;
- Ne = Fg(me.uponSanitizeAttribute, Ne, Ui, et);
+ Ne = Wg(he.uponSanitizeAttribute, Ne, Ui, tt);
const H = {
attrName: "",
attrValue: "",
@@ -23707,46 +23754,46 @@ function UC() {
allowedAttributes: Ne,
forceKeepAttr: void 0
};
- let he = P.length;
+ let ge = P.length;
const Ce = xt(k.nodeName);
- for (; he--; ) {
- const Ae = P[he], lt = Ae.name, Tt = Ae.namespaceURI, kn = Ae.value, xn = xt(lt), Bu = kn;
- let ln = lt === "value" ? Bu : lR(Bu);
- if (H.attrName = xn, H.attrValue = ln, H.keepAttr = !0, H.forceKeepAttr = void 0, Pr(me.uponSanitizeAttribute, k, H), ln = H.attrValue, Ko && (xn === "id" || xn === "name") && _y(ln, Uo) !== 0 && (zi(lt, k), ln = Uo + ln), le && zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, ln)) {
- zi(lt, k);
+ for (; ge--; ) {
+ const Ae = P[ge], ut = Ae.name, Tt = Ae.namespaceURI, kn = Ae.value, xn = xt(ut), Vu = kn;
+ let ln = ut === "value" ? Vu : mR(Vu);
+ if (H.attrName = xn, H.attrValue = ln, H.keepAttr = !0, H.forceKeepAttr = void 0, Pr(he.uponSanitizeAttribute, k, H), ln = H.attrValue, Bo && (xn === "id" || xn === "name") && wy(ln, Uo) !== 0 && (ji(ut, k), ln = Uo + ln), le && zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, ln)) {
+ ji(ut, k);
continue;
}
- if (xn === "attributename" && Sy(ln, "href")) {
- zi(lt, k);
+ if (xn === "attributename" && Ay(ln, "href")) {
+ ji(ut, k);
continue;
}
if (!H.forceKeepAttr) {
if (!H.keepAttr) {
- zi(lt, k);
+ ji(ut, k);
continue;
}
- if (!ve && zt(PR, ln)) {
- zi(lt, k);
+ if (!ve && zt(IR, ln)) {
+ ji(ut, k);
continue;
}
- if (de && (ln = lc(ln)), !zg(Ce, xn, ln)) {
- zi(lt, k);
+ if (de && (ln = lc(ln)), !Gg(Ce, xn, ln)) {
+ ji(ut, k);
continue;
}
- ln = f0(Ce, xn, Tt, ln), ln !== Bu && d0(k, lt, Tt, ln);
+ ln = m0(Ce, xn, Tt, ln), ln !== Vu && y0(k, ut, Tt, ln);
}
}
- Pr(me.afterSanitizeAttributes, k, null);
+ Pr(he.afterSanitizeAttributes, k, null);
}, fc = function(k) {
let P = null;
- const H = Ug(k);
- for (Pr(me.beforeSanitizeShadowDOM, k, null); P = H.nextNode(); )
- if (Pr(me.uponSanitizeShadowNode, P, null), Bg(P, k), Vg(P), zs(P.content) && fc(P.content), (x ? x(P) : P.nodeType) === Rn.element) {
+ const H = Vg(k);
+ for (Pr(he.beforeSanitizeShadowDOM, k, null); P = H.nextNode(); )
+ if (Pr(he.uponSanitizeShadowNode, P, null), Hg(P, k), Yg(P), zs(P.content) && fc(P.content), (x ? x(P) : P.nodeType) === In.element) {
const Ce = b(P);
- zs(Ce) && (Fu(Ce), fc(Ce));
+ zs(Ce) && (ju(Ce), fc(Ce));
}
- Pr(me.afterSanitizeShadowDOM, k, null);
- }, Fu = function(k) {
+ Pr(he.afterSanitizeShadowDOM, k, null);
+ }, ju = function(k) {
const P = [{
node: k,
shadow: null
@@ -23757,17 +23804,17 @@ function UC() {
fc(H.shadow);
continue;
}
- const he = H.node, Ae = (x ? x(he) : he.nodeType) === Rn.element, lt = g(he);
- if (lt)
- for (let Tt = lt.length - 1; Tt >= 0; --Tt)
+ const ge = H.node, Ae = (x ? x(ge) : ge.nodeType) === In.element, ut = g(ge);
+ if (ut)
+ for (let Tt = ut.length - 1; Tt >= 0; --Tt)
P.push({
- node: lt[Tt],
+ node: ut[Tt],
shadow: null
});
if (Ae) {
- const Tt = _ ? _(he) : null;
+ const Tt = _ ? _(ge) : null;
if (typeof Tt == "string" && xt(Tt) === "template") {
- const kn = he.content;
+ const kn = ge.content;
zs(kn) && P.push({
node: kn,
shadow: null
@@ -23775,7 +23822,7 @@ function UC() {
}
}
if (Ae) {
- const Tt = b(he);
+ const Tt = b(ge);
zs(Tt) && P.push({
node: null,
shadow: Tt
@@ -23787,54 +23834,54 @@ function UC() {
}
};
return t.sanitize = function(Q) {
- let k = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, P = null, H = null, he = null, Ce = null;
- if (Rt = !Q, Rt && (Q = ""), typeof Q != "string" && !zo(Q) && (Q = hR(Q), typeof Q != "string"))
- throw Wi("dirty is not a string, aborting");
+ let k = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, P = null, H = null, ge = null, Ce = null;
+ if (Rt = !Q, Rt && (Q = ""), typeof Q != "string" && !jo(Q) && (Q = TR(Q), typeof Q != "string"))
+ throw Hi("dirty is not a string, aborting");
if (!t.isSupported)
return Q;
- xe ? (Xe = st, Ne = et) : Ku(k), (me.uponSanitizeElement.length > 0 || me.uponSanitizeAttribute.length > 0) && (Xe = nn(Xe)), me.uponSanitizeAttribute.length > 0 && (Ne = nn(Ne)), t.removed = [];
- const Ae = Fs && typeof Q != "string" && zo(Q);
+ xe ? (Qe = ct, Ne = tt) : Fu(k), (he.uponSanitizeElement.length > 0 || he.uponSanitizeAttribute.length > 0) && (Qe = nn(Qe)), he.uponSanitizeAttribute.length > 0 && (Ne = nn(Ne)), t.removed = [];
+ const Ae = Us && typeof Q != "string" && jo(Q);
if (Ae) {
- a0(Q);
+ d0(Q);
const kn = _ ? _(Q) : Q.nodeName;
if (typeof kn == "string") {
const xn = xt(kn);
- if (!Xe[xn] || Zn[xn])
- throw cc(Q), Wi("root node is forbidden and cannot be sanitized in-place");
+ if (!Qe[xn] || Zn[xn])
+ throw cc(Q), Hi("root node is forbidden and cannot be sanitized in-place");
}
if (uc(Q))
- throw cc(Q), Wi("root node is clobbered and cannot be sanitized in-place");
+ throw cc(Q), Hi("root node is clobbered and cannot be sanitized in-place");
try {
- Fu(Q);
+ ju(Q);
} catch (xn) {
throw cc(Q), xn;
}
- } else if (zo(Q))
- P = Kg(""), H = P.ownerDocument.importNode(Q, !0), H.nodeType === Rn.element && H.nodeName === "BODY" || H.nodeName === "HTML" ? P = H : P.appendChild(H), Fu(H);
+ } else if (jo(Q))
+ P = jg(""), H = P.ownerDocument.importNode(Q, !0), H.nodeType === In.element && H.nodeName === "BODY" || H.nodeName === "HTML" ? P = H : P.appendChild(H), ju(H);
else {
- if (!Bt && !de && !pe && // eslint-disable-next-line unicorn/prefer-includes
+ if (!Ft && !de && !pe && // eslint-disable-next-line unicorn/prefer-includes
Q.indexOf("<") === -1)
- return R && li ? Se(Q) : Q;
- if (P = Kg(Q), !P)
- return Bt ? null : li ? W : "";
+ return I && ui ? Se(Q) : Q;
+ if (P = jg(Q), !P)
+ return Ft ? null : ui ? V : "";
}
- P && tn && fi(P.firstChild);
- const lt = Ae ? Q : P;
+ P && tn && di(P.firstChild);
+ const ut = Ae ? Q : P;
try {
- const kn = Ug(lt);
- for (; he = kn.nextNode(); )
- Bg(he, lt), Vg(he), zs(he.content) && fc(he.content);
+ const kn = Vg(ut);
+ for (; ge = kn.nextNode(); )
+ Hg(ge, ut), Yg(ge), zs(ge.content) && fc(ge.content);
} catch (kn) {
throw Ae && (cc(Q), Ws(t.removed, (xn) => {
- xn.element && Bo(xn.element);
+ xn.element && zo(xn.element);
})), kn;
}
if (Ae)
return Ws(t.removed, (kn) => {
- kn.element && Bo(kn.element);
- }), de && Uu(Q), Q;
- if (Bt) {
- if (de && Uu(P), er)
+ kn.element && zo(kn.element);
+ }), de && zu(Q), Q;
+ if (Ft) {
+ if (de && zu(P), er)
for (Ce = N.call(P.ownerDocument); P.firstChild; )
Ce.appendChild(P.firstChild);
else
@@ -23842,42 +23889,42 @@ function UC() {
return (Ne.shadowroot || Ne.shadowrootmode) && (Ce = oe.call(r, Ce, !0)), Ce;
}
let Tt = pe ? P.outerHTML : P.innerHTML;
- return pe && Xe["!doctype"] && P.ownerDocument && P.ownerDocument.doctype && P.ownerDocument.doctype.name && zt(_R, P.ownerDocument.doctype.name) && (Tt = "
-` + Tt), de && (Tt = lc(Tt)), R && li ? Se(Tt) : Tt;
+ return pe && Qe["!doctype"] && P.ownerDocument && P.ownerDocument.doctype && P.ownerDocument.doctype.name && zt(OR, P.ownerDocument.doctype.name) && (Tt = "
+` + Tt), de && (Tt = lc(Tt)), I && ui ? Se(Tt) : Tt;
}, t.setConfig = function() {
let Q = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
- Ku(Q), xe = !0, st = Xe, et = Ne;
+ Fu(Q), xe = !0, ct = Qe, tt = Ne;
}, t.clearConfig = function() {
- Bs = null, xe = !1, st = null, et = null, R = ce, W = "";
+ Fs = null, xe = !1, ct = null, tt = null, I = ce, V = "";
}, t.isValidAttribute = function(Q, k, P) {
- Bs || Ku({});
- const H = xt(Q), he = xt(k);
- return zg(H, he, P);
+ Fs || Fu({});
+ const H = xt(Q), ge = xt(k);
+ return Gg(H, ge, P);
}, t.addHook = function(Q, k) {
- typeof k == "function" && jt(me, Q) && Hs(me[Q], k);
+ typeof k == "function" && jt(he, Q) && Hs(he[Q], k);
}, t.removeHook = function(Q, k) {
- if (jt(me, Q)) {
+ if (jt(he, Q)) {
if (k !== void 0) {
- const P = aR(me[Q], k);
- return P === -1 ? void 0 : cR(me[Q], P, 1)[0];
+ const P = hR(he[Q], k);
+ return P === -1 ? void 0 : gR(he[Q], P, 1)[0];
}
- return vy(me[Q]);
+ return Py(he[Q]);
}
}, t.removeHooks = function(Q) {
- jt(me, Q) && (me[Q] = []);
+ jt(he, Q) && (he[Q] = []);
}, t.removeAllHooks = function() {
- me = Iy();
+ he = By();
}, t;
}
-var NR = UC();
-const Ly = "para-merge-armed", FC = "--para-merge-armed-text-left", BC = "--para-merge-armed-text-width";
-function OR(e) {
- const { anchor: t, focus: n } = du(e);
+var DR = WC();
+const Uy = "para-merge-armed", HC = "--para-merge-armed-text-left", GC = "--para-merge-armed-text-width";
+function KR(e) {
+ const { anchor: t, focus: n } = hu(e);
return () => {
e.anchor.set(t.key, t.offset, t.type), e.focus.set(n.key, n.offset, n.type);
};
}
-function $R({ structureProtectionMode: e = "off" }) {
+function BR({ structureProtectionMode: e = "off" }) {
const [t] = Pe(), n = ae(void 0), [r, i] = ze(void 0), s = Ke((o) => {
n.current = o, i(o);
}, []);
@@ -23885,116 +23932,117 @@ function $R({ structureProtectionMode: e = "off" }) {
if (e === "off")
return;
const o = (h) => {
- const g = TC(h);
+ const g = _C(h);
if (!g)
return !1;
const y = M();
- return e === "protected" ? y && uo(y, g) ? (h.preventDefault(), !0) : !1 : g !== "deleteBackward" && g !== "deleteForward" ? !1 : a(g, h);
+ return e === "protected" ? y && fo(y, g) ? (h.preventDefault(), !0) : !1 : g !== "deleteBackward" && g !== "deleteForward" ? !1 : a(g, h);
}, a = (h, g) => {
const y = M(), b = n.current;
- if (b && y && gy(y, b)) {
+ if (b && y && xy(y, b)) {
if (s(void 0), g?.preventDefault(), h !== b.intent)
return !0;
const x = ee(b.key) ?? void 0;
if (b.kind === "verse") {
if (x) {
- const _ = x.getParent(), F = x.getPreviousSibling(), R = x.getNextSibling();
- x.remove(), F ? wC(F) : R && T(R) ? R.select(0, 0) : _?.selectStart();
+ const _ = x.getParent(), U = x.getPreviousSibling(), I = x.getNextSibling();
+ x.remove(), U ? RC(U) : I && C(I) ? I.select(0, 0) : _?.selectStart();
}
- } else b.kind === "selection" ? E(y) && (Na(y), _t(Td), t.dispatchCommand(In, h === "deleteBackward")) : dt(x) && vd(x);
+ } else b.kind === "selection" ? E(y) && (Na(y), _t(Sd), t.dispatchCommand(Ln, h === "deleteBackward")) : ot(x) && Rc(x, b.paraIntent ?? h);
return !0;
}
if (!y)
return !1;
- const C = s$(y, h);
- if (C) {
- if (C.kind === "verse") {
- const x = cp();
- x.add(C.node.getKey()), Mt(x), s({ key: C.node.getKey(), kind: C.kind, intent: h });
+ const T = u$(y, h);
+ if (T) {
+ if (T.kind === "verse") {
+ const x = up();
+ x.add(T.node.getKey()), Mt(x), s({ key: T.node.getKey(), kind: T.kind, intent: h });
} else {
- const x = !!Tr(y), _ = h === "deleteBackward" ? _a(C.node) : void 0, R = !(x || !!_ && _x(_)) && E(y) ? y : void 0;
+ const x = !!pr(y), _ = E(y) ? Br(y.focus.getNode()) : void 0, U = h === "deleteBackward" && T.node.is(_) ? _a(T.node) : void 0, V = !(x || !!U && Ax(U)) && E(y) ? y : void 0;
s({
- key: C.node.getKey(),
- kind: C.kind,
+ key: T.node.getKey(),
+ kind: T.kind,
intent: h,
- paraEffect: c$(C.node, x ? "deleteBackward" : h),
- ...R && {
- anchor: yc(R.anchor),
- focus: yc(R.focus)
+ paraEffect: d$(T.node, x ? "deleteBackward" : h),
+ paraIntent: p$(y, T.node, h),
+ ...V && {
+ anchor: yc(V.anchor),
+ focus: yc(V.focus)
}
});
}
return g?.preventDefault(), !0;
}
- if (E(y) && !y.isCollapsed() && Wh(y)) {
- const x = y.getNodes().filter(Oe).map((R) => R.getKey()), { anchor: _, focus: F } = y;
+ if (E(y) && !y.isCollapsed() && Gh(y)) {
+ const x = y.getNodes().filter(Oe).map((I) => I.getKey()), { anchor: _, focus: U } = y;
return s({
kind: "selection",
intent: h,
key: x[0],
anchor: yc(_),
- focus: yc(F)
+ focus: yc(U)
}), g?.preventDefault(), !0;
}
- return h === "deleteBackward" && o$(y) ? (g?.preventDefault(), !0) : !1;
+ return h === "deleteBackward" && f$(y) ? (g?.preventDefault(), !0) : !1;
}, c = (h) => {
if (e !== "protected")
return !1;
const g = M();
- return !g || !Ci(g) ? !1 : (h instanceof Event && h.preventDefault(), !0);
+ return !g || !vi(g) ? !1 : (h instanceof Event && h.preventDefault(), !0);
}, l = (h, g) => {
if (!h)
return !1;
- const y = NR.sanitize(h), b = new DOMParser().parseFromString(y, "text/html");
- b.querySelectorAll(`[data-text-type="${tx}"]`).forEach((_) => _.remove());
- const C = l$(H0(t, b)), x = M();
- return E(x) && x.insertNodes(C), g.preventDefault(), !0;
+ const y = DR.sanitize(h), b = new DOMParser().parseFromString(y, "text/html");
+ b.querySelectorAll(`[data-text-type="${ox}"]`).forEach((_) => _.remove());
+ const T = m$(Q0(t, b)), x = M();
+ return E(x) && x.insertNodes(T), g.preventDefault(), !0;
}, u = (h) => {
if (e !== "protected")
return !1;
const g = M();
- return g && Ci(g) ? (h.preventDefault(), !0) : l(h.clipboardData?.getData("text/html"), h);
+ return g && vi(g) ? (h.preventDefault(), !0) : l(h.clipboardData?.getData("text/html"), h);
}, f = (h) => {
if (e !== "protected")
return !1;
const g = M();
- return g && Ci(g) ? (h.preventDefault(), !0) : l(h.dataTransfer?.getData("text/html"), h);
+ return g && vi(g) ? (h.preventDefault(), !0) : l(h.dataTransfer?.getData("text/html"), h);
}, d = (h) => {
if (!t.isEditable())
return !1;
const g = h ? "deleteBackward" : "deleteForward";
if (e === "protected") {
const y = M();
- return y ? uo(y, g) ? !0 : (!h && E(y) && dl(y), !1) : !1;
+ return y ? fo(y, g) ? !0 : (!h && E(y) && hl(y), !1) : !1;
}
- return Zb(Td) ? !1 : a(g, void 0);
+ return ik(Sd) ? !1 : a(g, void 0);
}, p = (h) => (g) => {
if (e !== "protected" || !t.isEditable() || Ts())
return !1;
const y = M();
if (!E(y))
return !1;
- const b = g ? "deleteBackward" : "deleteForward", C = OR(y);
+ const b = g ? "deleteBackward" : "deleteForward", T = KR(y);
if (y.isCollapsed()) {
- if (uo(y, b))
+ if (fo(y, b))
return !0;
if (We(y.anchor.getNode(), qe))
return !1;
- if (g || dl(y), y.modify("extend", g, h), y.isCollapsed() && y.modify("extend", g, "character"), y.isCollapsed())
- return C(), !0;
+ if (g || hl(y), y.modify("extend", g, h), y.isCollapsed() && y.modify("extend", g, "character"), y.isCollapsed())
+ return T(), !0;
}
- return AC(y) || (Na(y), vC(y), y.isCollapsed()) ? (C(), !0) : (y.removeText(), !0);
+ return $C(y) || (Na(y), MC(y), y.isCollapsed()) ? (T(), !0) : (y.removeText(), !0);
}, m = () => {
const h = n.current;
h && t.getEditorState().read(() => {
- gy(M(), h) || s(void 0);
+ xy(M(), h) || s(void 0);
});
};
- return Ye(
+ return Xe(
t.registerCommand(Jn, o, Je),
- t.registerCommand(In, d, Je),
- t.registerCommand(cs, p("word"), Je),
- t.registerCommand(Ei, p("lineboundary"), Je),
+ t.registerCommand(Ln, d, Je),
+ t.registerCommand(ls, p("word"), Je),
+ t.registerCommand(Mi, p("lineboundary"), Je),
// CUT at CRITICAL, unlike KEY_DOWN above: a refusal has to outrank the actor it refuses,
// not tie with it. The handlers that PERFORM a cut (the Standard-view and Markers-view
// clipboard claims) register at HIGH, and at equal rank the winner is mount order — an
@@ -24002,11 +24050,11 @@ function $R({ structureProtectionMode: e = "off" }) {
// plugin were added between them. `OpaqueBlockGuardPlugin` states the same rule for the same
// reason. KEY_DOWN stays at HIGH: it has no same-priority actor to outrank, and
// `MarkerEditPlugin`'s KEY_DOWN handler must keep running ahead of it on every keystroke.
- t.registerCommand(wn, c, ye),
+ t.registerCommand(Nn, c, ye),
t.registerCommand(un, u, Je),
t.registerCommand(Fc, c, Je),
- t.registerCommand(ql, f, Je),
- t.registerCommand(Yr, c, Je),
+ t.registerCommand(Kl, f, Je),
+ t.registerCommand(Xr, c, Je),
t.registerUpdateListener(m)
);
}, [t, e, s]), J(() => {
@@ -24015,12 +24063,12 @@ function $R({ structureProtectionMode: e = "off" }) {
return;
o.classList.toggle("verse-delete-armed", !!r), r ? (o.setAttribute("data-verse-delete-intent", r.intent), o.setAttribute("data-verse-delete-kind", r.paraEffect ?? r.kind)) : (o.removeAttribute("data-verse-delete-intent"), o.removeAttribute("data-verse-delete-kind"));
const a = r?.kind === "para" ? t.getEditorState().read(() => _a(ee(r.key))?.getKey() ?? r.key) : void 0, c = a ? t.getElementByKey(a) : void 0;
- return c?.classList.add(Ly), a !== r?.key && c && RR(c), () => {
- o.classList.remove("verse-delete-armed"), o.removeAttribute("data-verse-delete-intent"), o.removeAttribute("data-verse-delete-kind"), c?.classList.remove(Ly), c?.style.removeProperty(FC), c?.style.removeProperty(BC);
+ return c?.classList.add(Uy), a !== r?.key && c && UR(c), () => {
+ o.classList.remove("verse-delete-armed"), o.removeAttribute("data-verse-delete-intent"), o.removeAttribute("data-verse-delete-kind"), c?.classList.remove(Uy), c?.style.removeProperty(HC), c?.style.removeProperty(GC);
};
}, [t, r]), null;
}
-function RR(e) {
+function UR(e) {
const t = e.firstChild;
if (t?.nodeType !== Node.TEXT_NODE)
return;
@@ -24028,23 +24076,23 @@ function RR(e) {
if (n.setStart(t, 0), n.setEnd(t, (t.textContent ?? "").trimEnd().length), typeof n.getBoundingClientRect != "function")
return;
const r = n.getBoundingClientRect(), i = e.getBoundingClientRect();
- e.style.setProperty(FC, `${r.left - i.left}px`), e.style.setProperty(BC, `${r.width}px`);
+ e.style.setProperty(HC, `${r.left - i.left}px`), e.style.setProperty(GC, `${r.width}px`);
}
-const GF = {
+const nF = {
ltr: "Left-to-right",
rtl: "Right-to-left",
auto: "Automatic"
};
-function IR({ textDirection: e }) {
+function FR({ textDirection: e }) {
const [t] = Pe();
- return LR(t, e), null;
+ return zR(t, e), null;
}
-function LR(e, t) {
- J(() => (qy(e, t), e.registerUpdateListener(({ dirtyElements: n }) => {
- n.size > 0 && qy(e, t);
+function zR(e, t) {
+ J(() => (Fy(e, t), e.registerUpdateListener(({ dirtyElements: n }) => {
+ n.size > 0 && Fy(e, t);
})), [e, t]);
}
-function qy(e, t) {
+function Fy(e, t) {
if (t === "auto")
return;
const n = e.getRootElement();
@@ -24052,19 +24100,19 @@ function qy(e, t) {
const r = e._config.theme.placeholder, i = document.getElementsByClassName(r)[0];
i && (i.dir = t);
}
-function qR() {
+function jR() {
const [e] = Pe();
- return DR(e), null;
+ return VR(e), null;
}
-function DR(e) {
+function VR(e) {
J(() => {
- if (!e.hasNodes([nt, sn, at, it, Lt]))
+ if (!e.hasNodes([rt, sn, lt, at, Lt]))
throw new Error("TextSpacingPlugin: CharNode, ImmutableVerseNode, NoteNode, TextNode or VerseNode not registered on editor!");
- return Ye(
- e.registerNodeTransform(it, KR),
- e.registerNodeTransform(it, (t) => UR(t, e)),
- e.registerNodeTransform(Lt, Dy),
- e.registerNodeTransform(sn, Dy),
+ return Xe(
+ e.registerNodeTransform(at, WR),
+ e.registerNodeTransform(at, (t) => HR(t, e)),
+ e.registerNodeTransform(Lt, zy),
+ e.registerNodeTransform(sn, zy),
// Self-healing \va/\vp display runs: re-derive them from altnumber/pubnumber whenever
// a verse is dirtied — heals remote collab updates (delta-apply only calls setAltnumber/
// setPubnumber) and structure surgery. Registered here (not a dedicated VerseNodePlugin,
@@ -24074,26 +24122,26 @@ function DR(e) {
// driven `\va` first so `\vp`'s scan and insertion anchor find the healed `\va` wrapper
// already in place.
e.registerNodeTransform(Lt, (t) => {
- Ma(ei("va"), t), Ma(ei("vp"), t);
+ Ma(ti("va"), t), Ma(ti("vp"), t);
})
);
}, [e]);
}
-function KR(e) {
+function WR(e) {
if (!e.isAttached())
return;
- if (Gc(e)) {
+ if (Jc(e)) {
const s = e.getNextSibling(), o = e.getPreviousSibling();
Oe(s) && o && !Oe(o) && s.markDirty();
return;
}
- const t = e.getTextContent(), n = Ky(e, "next"), r = e.getParent();
- if (e.getMode() !== "normal" || t.endsWith(" ") && t.length > 1 || K(n) || z(r) || z(n) || ge(r) || ge(n) || Ie(r) || // An adjacent TextNode is the same logical text run (IME composition and annotation-wrap
+ const t = e.getTextContent(), n = jy(e, "next"), r = e.getParent();
+ if (e.getMode() !== "normal" || t.endsWith(" ") && t.length > 1 || K(n) || z(r) || z(n) || me(r) || me(n) || Ie(r) || // An adjacent TextNode is the same logical text run (IME composition and annotation-wrap
// splits leave runs as multiple nodes, e.g. a segmented composition node that Lexical
// won't merge). No structural space belongs inside a run — inserting one corrupts the
// word itself (#513, complex scripts worst). This also protects a space-only node in front
// of real text from the empty-verse cleanup below.
- T(n) || // An optbreak (`//`) — like a ref — is an inline UnknownNode carrying SIGNIFICANT surrounding
+ C(n) || // An optbreak (`//`) — like a ref — is an inline UnknownNode carrying SIGNIFICANT surrounding
// whitespace (Paratext 9 preserves the spaces around `//` byte-for-byte). Forcing a trailing
// space onto the text before one — or removing a lone space there — corrupts the authored form
// and makes the space impossible to delete (the transform re-adds it every keystroke). Text
@@ -24113,39 +24161,39 @@ function KR(e) {
// too.
He(r))
return;
- if (Oe(Ky(e, "previous")) && (t === "" || t === " ")) {
+ if (Oe(jy(e, "previous")) && (t === "" || t === " ")) {
t !== "" && e.setTextContent("");
return;
}
- Oe(n) && fh(e);
+ Oe(n) && ph(e);
}
-function UR(e, t) {
+function HR(e, t) {
const n = e.getParent();
- !Ie(n) || !e.isAttached() || Zb(Ec) || sd(t, e.getKey()) && !sd(t, n.getKey()) && n.insertAfter(e);
+ !Ie(n) || !e.isAttached() || ik(Ec) || cd(t, e.getKey()) && !cd(t, n.getKey()) && n.insertAfter(e);
}
-function Dy(e) {
+function zy(e) {
if (!e.isAttached())
return;
let t = e.getPreviousSibling();
- const n = t && Gc(t) ? t : void 0;
- for (n && (t = n.getPreviousSibling()); ge(t); )
+ const n = t && Jc(t) ? t : void 0;
+ for (n && (t = n.getPreviousSibling()); me(t); )
t = t.getLastChild();
- t && Gc(t) && (t = t.getPreviousSibling()), (z(t) || Er(e) && T(t) && ge(t.getParent()) && !FR(t)) && (n ?? e).insertBefore(Ue(" "));
+ t && Jc(t) && (t = t.getPreviousSibling()), (z(t) || Er(e) && C(t) && me(t.getParent()) && !GR(t)) && (n ?? e).insertBefore(Be(" "));
}
-function Ky(e, t) {
+function jy(e, t) {
const n = t === "next" ? e.getNextSibling() : e.getPreviousSibling();
- return !n || !Gc(n) ? n : t === "next" ? n.getNextSibling() : n.getPreviousSibling();
+ return !n || !Jc(n) ? n : t === "next" ? n.getNextSibling() : n.getPreviousSibling();
}
-function FR(e) {
+function GR(e) {
const t = e.getTextContent();
- return t.endsWith(" ") || t.endsWith(U);
+ return t.endsWith(" ") || t.endsWith(B);
}
-function hu(e) {
+function yu(e) {
if (!K(e) || e.getIsCollapsed() !== !0)
return;
let t = e;
for (; ; ) {
- if (t.getNextSiblings().some((i) => !Hc(i)))
+ if (t.getNextSiblings().some((i) => !Gc(i)))
return;
const r = t.getParent();
if (!r)
@@ -24155,43 +24203,43 @@ function hu(e) {
t = r;
}
}
-function BR(e) {
+function JR(e) {
if (e.type !== "element")
return;
const t = e.getNode();
if (A(t))
return t.getChildAtIndex(e.offset - 1) ?? void 0;
}
-function zR() {
+function YR() {
const e = M();
if (!(!E(e) || !e.isCollapsed()))
- return hu(BR(e.anchor));
+ return yu(JR(e.anchor));
}
-function jR(e) {
+function XR(e) {
const t = M();
let n;
- return E(t) ? t.isCollapsed() && (n = t.anchor.getNode()) : t || (n = zC(e.target)), n ? hu(We(n, K)) : void 0;
+ return E(t) ? t.isCollapsed() && (n = t.anchor.getNode()) : t || (n = JC(e.target)), n ? yu(We(n, K)) : void 0;
}
-function zC(e) {
- const t = A0(e)?.anchorNode;
+function JC(e) {
+ const t = R0(e)?.anchorNode;
if (ga(t))
return qr(t) ?? void 0;
}
-function VR(e) {
+function QR(e) {
if (M())
return;
- const t = zC(e);
- return t ? hu(We(t, K)) : void 0;
+ const t = JC(e);
+ return t ? yu(We(t, K)) : void 0;
}
-function Uy(e) {
+function Vy(e) {
const t = We(e.getNode(), K);
return t?.getIsCollapsed() === !0 ? t : void 0;
}
-function WR() {
+function ZR() {
const e = M();
if (!E(e) || e.isCollapsed())
return !1;
- const [t, n] = e.isBackward() ? [e.focus, e.anchor] : [e.anchor, e.focus], r = Uy(t), i = Uy(n);
+ const [t, n] = e.isBackward() ? [e.focus, e.anchor] : [e.anchor, e.focus], r = Vy(t), i = Vy(n);
if (r && i && r.is(i))
return !1;
let s = !1;
@@ -24200,11 +24248,11 @@ function WR() {
const a = i?.getParent();
return i && a && (n.set(a.getKey(), i.getIndexWithinParent() + 1, "element"), s = !0), s;
}
-const HR = 500;
-function GR(e) {
+const eI = 500;
+function tI(e) {
return e.shiftKey || e.altKey ? !1 : e.key === "End" || e.key === "ArrowDown" && e.metaKey;
}
-function JR() {
+function nI() {
const e = M();
if (!E(e) || e.isCollapsed())
return;
@@ -24213,44 +24261,44 @@ function JR() {
return;
const r = t.getNode();
if (A(r))
- return hu(r.getChildAtIndex(t.offset));
+ return yu(r.getChildAtIndex(t.offset));
}
-function YR() {
- const [e] = Pe(), t = Uh(zR), n = ae(void 0);
- return J(() => Ye(e.registerCommand(
+function rI() {
+ const [e] = Pe(), t = Fh(YR), n = ae(void 0);
+ return J(() => Xe(e.registerCommand(
Jn,
- (r) => (n.current = GR(r) ? performance.now() : void 0, !1),
+ (r) => (n.current = tI(r) ? performance.now() : void 0, !1),
// Only observes the press, and must see it whether or not a handler further down claims it.
ye
- ), e.registerCommand(Nn, () => {
- if (n.current !== void 0 && performance.now() - n.current < HR) {
- const s = JR();
+ ), e.registerCommand(On, () => {
+ if (n.current !== void 0 && performance.now() - n.current < eI) {
+ const s = nI();
if (s)
return t(s), !1;
}
- if (WR())
- return _t(yo), so(e, yo), !1;
- const i = VR(e.getRootElement());
+ if (ZR())
+ return _t(bo), so(e, bo), !1;
+ const i = QR(e.getRootElement());
return i && t(i), !1;
- }, xi), e.registerCommand(go, (r) => {
- const i = jR(r);
+ }, Ti), e.registerCommand(mo, (r) => {
+ const i = XR(r);
return i && t(i), !1;
- }, xi)), [e, t]), null;
+ }, Ti)), [e, t]), null;
}
-function XR({ trigger: e, scriptureReference: t, contextMarker: n, getMarkerAction: r }) {
- const { markersMenuItems: i } = Yw({
+function iI({ trigger: e, scriptureReference: t, contextMarker: n, getMarkerAction: r }) {
+ const { markersMenuItems: i } = tN({
scriptureReference: t,
contextMarker: n,
getMarkerAction: r
});
- return O(Jw, { trigger: e, items: i });
+ return O(eN, { trigger: e, items: i });
}
-function QR({ trigger: e, scrRef: t, contextMarker: n, getMarkerAction: r, editableHarness: i }) {
- const { book: s, chapterNum: o, verseNum: a, verse: c, versificationStr: l } = t, u = bt(() => ({ book: s, chapterNum: o, verseNum: a, verse: c, versificationStr: l }), [s, o, a, c, l]);
- return i ? O(tI, { trigger: e, harness: i }) : O(XR, { trigger: e, scriptureReference: u, contextMarker: n, getMarkerAction: r });
+function sI({ trigger: e, scrRef: t, contextMarker: n, getMarkerAction: r, editableHarness: i }) {
+ const { book: s, chapterNum: o, verseNum: a, verse: c, versificationStr: l } = t, u = kt(() => ({ book: s, chapterNum: o, verseNum: a, verse: c, versificationStr: l }), [s, o, a, c, l]);
+ return i ? O(cI, { trigger: e, harness: i }) : O(iI, { trigger: e, scriptureReference: u, contextMarker: n, getMarkerAction: r });
}
-const ZR = [" ", "*"];
-function eI(e, t) {
+const oI = [" ", "*"];
+function aI(e, t) {
return {
name: e.marker,
label: e.marker,
@@ -24263,7 +24311,7 @@ function eI(e, t) {
applyOpts: t
};
}
-function tI({ trigger: e, harness: t }) {
+function cI({ trigger: e, harness: t }) {
const [n] = Pe(), [r, i] = ze(void 0), s = ae({ query: "", options: [] }), o = ae(0), a = Ke((d, p, m) => {
const h = p.find((g) => g.kind === "note" && g.marker === d);
if (h) {
@@ -24275,7 +24323,7 @@ function tI({ trigger: e, harness: t }) {
E(g) && g.insertText(`${e}${d}${m ? " " : ""}`);
});
}, [n, t, e]);
- J(() => Ye(n.registerCommand(Jn, (d) => {
+ J(() => Xe(n.registerCommand(Jn, (d) => {
if (r) {
if ((d.key === "Enter" || d.key === "Tab") && s.current.options.length === 0)
return d.preventDefault(), d.stopPropagation(), !0;
@@ -24284,7 +24332,7 @@ function tI({ trigger: e, harness: t }) {
if (d.key === e && r.trigger === "backslash" && !r.hasTextSelection) {
d.preventDefault(), d.stopPropagation();
const h = s.current.query;
- return h ? (a(h, r.items, !1), ek(() => {
+ return h ? (a(h, r.items, !1), sk(() => {
const g = t.getContext();
s.current = { query: "", options: [] }, o.current += 1, i(g ? {
trigger: "backslash",
@@ -24316,7 +24364,7 @@ function tI({ trigger: e, harness: t }) {
items: t.getItems(p),
session: o.current
}), !0) : !1;
- }, Je), n.registerCommand(tk, (d) => {
+ }, Je), n.registerCommand(ok, (d) => {
if (r || d === null || d.shiftKey)
return !1;
const p = t.getContext();
@@ -24332,52 +24380,52 @@ function tI({ trigger: e, harness: t }) {
}, []), u = Ke((d) => {
const { markerMenuItem: p, applyOpts: m } = d;
t.apply(p, m);
- }, [t]), f = bt(() => r?.items.map((d) => (
+ }, [t]), f = kt(() => r?.items.map((d) => (
// `literalPrefixLanded` is constant `false` under the active palette: the trigger never
// lands, so an item commit never has a literal prefix to clean up. The field stays in
// the apply contract because hosts whose own palettes DO land literals still pass true.
- eI(d, { trigger: r.trigger, literalPrefixLanded: !1 })
+ aI(d, { trigger: r.trigger, literalPrefixLanded: !1 })
)), [r]);
- return r && O(UT, { isOpen: !0, children: ({ placement: d }) => O(
- zT,
- { options: f ?? [], onSelectOption: u, onClose: c, onFilterChange: l, inverse: d === "top-start", menuOpenKey: e, passthroughKeys: r.trigger === "backslash" ? ZR : void 0 },
+ return r && O(jT, { isOpen: !0, children: ({ placement: d }) => O(
+ HT,
+ { options: f ?? [], onSelectOption: u, onClose: c, onFilterChange: l, inverse: d === "top-start", menuOpenKey: e, passthroughKeys: r.trigger === "backslash" ? oI : void 0 },
r.session
) });
}
-function nI(e) {
- return e.replaceAll(U, "~").replace(/ {2,}/g, (n) => U.repeat(n.length));
+function lI(e) {
+ return e.replaceAll(B, "~").replace(/ {2,}/g, (n) => B.repeat(n.length));
}
-function Ed(e) {
- return e.replaceAll(U, " ").replaceAll("~", U);
+function Pd(e) {
+ return e.replaceAll(B, " ").replaceAll("~", B);
}
-let ml;
-function rI(e) {
- e && (ml = e);
+let bl;
+function uI(e) {
+ e && (bl = e);
}
function Zs(e) {
- return gt(e);
+ return mt(e);
}
-function iI(e, t) {
- return e.isEmpty() ? Gb : jC(e.toJSON(), t);
+function fI(e, t) {
+ return e.isEmpty() ? Zb : YC(e.toJSON(), t);
}
-function jC(e, t) {
+function YC(e, t) {
if (!e.root || !e.root.children) return;
const n = e.root.children;
- if (n.length === 1 && zl(n[0]) && (!n[0].children || n[0].children.length === 0))
- return Gb;
- if (n.some(_A)) {
- ml?.error(
+ if (n.length === 1 && Vl(n[0]) && (!n[0].children || n[0].children.length === 0))
+ return Zb;
+ if (n.some(wA)) {
+ bl?.error(
"Block verse layout is not round-trippable to USJ. VerseBlockNode is read-only view state; use the source USJ instead."
);
return;
}
- const r = SI(n, t);
+ const r = NI(n, t);
return r ? { type: fr, version: ur, content: r } : void 0;
}
-function sI(e, t) {
+function dI(e, t) {
const { type: n, marker: r, unknownAttributes: i } = e;
let s;
- return e.code !== "" && (s = e.code), ht({
+ return e.code !== "" && (s = e.code), gt({
type: n,
marker: r,
code: s,
@@ -24385,10 +24433,10 @@ function sI(e, t) {
content: t
});
}
-function oI(e) {
+function pI(e) {
const { marker: t, number: n, sid: r, altnumber: i, pubnumber: s, unknownAttributes: o } = e;
- return ht({
- type: $n.getType(),
+ return gt({
+ type: Rn.getType(),
marker: t,
number: n,
sid: r,
@@ -24397,11 +24445,11 @@ function oI(e) {
...o
});
}
-function aI(e, t) {
+function hI(e, t) {
const { marker: n, sid: r, altnumber: i, pubnumber: s, unknownAttributes: o } = e, a = t && typeof t[0] == "string" ? t[0] : void 0;
let { number: c } = e;
- return c = Tx(n, a, c), ht({
- type: $n.getType(),
+ return c = _x(n, a, c), gt({
+ type: Rn.getType(),
marker: n,
number: c,
sid: r,
@@ -24410,10 +24458,10 @@ function aI(e, t) {
...o
});
}
-function cI(e) {
+function gI(e) {
const { marker: t, sid: n, altnumber: r, pubnumber: i, unknownAttributes: s } = e, { text: o } = e;
let { number: a } = e;
- return a = Tx(t, o, a), ht({
+ return a = _x(t, o, a), gt({
type: Lt.getType(),
marker: t,
number: a,
@@ -24423,36 +24471,36 @@ function cI(e) {
...s
});
}
-function lI(e, t) {
+function mI(e, t) {
const { type: n, marker: r, unknownAttributes: i } = e;
- return ht({
+ return gt({
type: n,
marker: r === "" ? void 0 : r,
...i,
content: t
});
}
-function uI(e, t) {
+function yI(e, t) {
const { type: n, marker: r, unknownAttributes: i } = e;
- return ht({
+ return gt({
type: n,
marker: r,
...i,
content: t
});
}
-function fI(e, t) {
+function bI(e, t) {
const { unknownAttributes: n } = e;
- return ht({ type: zk, ...n, content: t });
+ return gt({ type: Gk, ...n, content: t });
}
-function dI(e, t) {
+function kI(e, t) {
const { marker: n, unknownAttributes: r } = e;
- return ht({ type: Vx, marker: n, ...r, content: t });
+ return gt({ type: Jx, marker: n, ...r, content: t });
}
-function pI(e, t) {
+function xI(e, t) {
const { marker: n, align: r, colspan: i, unknownAttributes: s } = e;
- return ht({
- type: Gx,
+ return gt({
+ type: Qx,
marker: n,
align: r,
colspan: i,
@@ -24460,26 +24508,26 @@ function pI(e, t) {
content: t
});
}
-function Md(e) {
+function Ad(e) {
const t = e?.[0];
if (!e || typeof t != "string" || !t.startsWith(" ")) return e;
const n = t.replace(/^ +/, "");
return n ? [n, ...e.slice(1)] : e.slice(1);
}
-function hI(e) {
+function TI(e) {
return e.flatMap((t, n) => {
const r = e[n - 1];
- if (typeof t != "string" || !gI(r)) return [t];
+ if (typeof t != "string" || !CI(r)) return [t];
const i = t.replace(/^ +/, "");
return i ? [i] : [];
});
}
-function gI(e) {
+function CI(e) {
return typeof e == "object" && e.type === Lt.getType() && e.altnumber === void 0 && e.pubnumber === void 0;
}
-function mI(e, t) {
+function vI(e, t) {
const { type: n, marker: r, caller: i, category: s, unknownAttributes: o } = e;
- return ht({
+ return gt({
type: n,
marker: r,
caller: i,
@@ -24490,40 +24538,40 @@ function mI(e, t) {
}
function eo(e) {
const { type: t, marker: n, sid: r, eid: i, unknownAttributes: s, attributeOrder: o } = e;
- return ht({
+ return gt({
type: t,
marker: n === "" ? void 0 : n,
- ...Rk({ sid: r, eid: i, ...s }, o)
+ ...Kk({ sid: r, eid: i, ...s }, o)
});
}
-function yI(e) {
+function SI(e) {
return e.text;
}
-function bI(e, t) {
+function _I(e, t) {
const { tag: n, marker: r, unknownAttributes: i } = e;
- return ht({
+ return gt({
type: n,
marker: r,
...i,
content: t
});
}
-function kI(e) {
+function EI(e) {
const { marker: t } = e;
return {
- type: Jc,
+ type: Xc,
marker: t === "" ? void 0 : t
};
}
-function Rc(e, t) {
+function Ic(e, t) {
const n = e[e.length - 1];
n && typeof n == "string" ? e[e.length - 1] = n + t : e.push(t);
}
-function VC(e) {
- return fs(e) && e.typedIDs[Vt] !== void 0;
+function XC(e) {
+ return ds(e) && e.typedIDs[Vt] !== void 0;
}
-function xI(e, t, n, r, i) {
- const s = xr.getType(), o = t.filter((l) => !n.includes(l));
+function MI(e, t, n, r, i) {
+ const s = Tr.getType(), o = t.filter((l) => !n.includes(l));
if (n.filter((l) => !t.includes(l)).forEach((l) => {
const u = eo({
type: s,
@@ -24534,14 +24582,14 @@ function xI(e, t, n, r, i) {
}), o.forEach((l) => {
const u = eo({
type: s,
- marker: ls,
+ marker: us,
sid: l
});
i.push(u);
}), t.length === 0) {
const l = eo({
type: s,
- marker: ls
+ marker: us
});
i.push(l);
}
@@ -24552,7 +24600,7 @@ function xI(e, t, n, r, i) {
});
i.push(l);
}
- !VC(r) && t.forEach((l) => {
+ !XC(r) && t.forEach((l) => {
const u = eo({
type: s,
marker: co,
@@ -24561,59 +24609,59 @@ function xI(e, t, n, r, i) {
i.push(u);
});
}
-function Pd(e, t, n, r) {
+function wd(e, t, n, r) {
if (!r) return !1;
let i = t > 0 ? e[t - 1] : n;
- for (; i && fs(i); ) {
+ for (; i && ds(i); ) {
const { children: s } = i;
i = s.length > 0 ? s[s.length - 1] : void 0;
}
- return !wo(i) || i.markerSyntax !== "opening" ? !1 : i.marker === r.marker ? !0 : r.children.some(
- (s) => Nk(s) && s.marker === i.marker
+ return !No(i) || i.markerSyntax !== "opening" ? !1 : i.marker === r.marker ? !0 : r.children.some(
+ (s) => Lk(s) && s.marker === i.marker
);
}
-function TI(e, t, n, r, i) {
+function PI(e, t, n, r, i) {
const s = e[t];
- return !ti(s) || s.text !== U || !(i || fs(e[t - 1]) || fs(e[t + 1])) || s[Lr]?.textType !== void 0 || Pd(e, t, n, r) ? !1 : !r || WC(r.children, s);
+ return !ni(s) || s.text !== B || !(i || ds(e[t - 1]) || ds(e[t + 1])) || s[Lr]?.textType !== void 0 || wd(e, t, n, r) ? !1 : !r || QC(r.children, s);
}
-function WC(e, t) {
- return e.some((n) => n === t ? !1 : fs(n) ? WC(n.children, t) : wo(n) ? !1 : ti(n) ? n[Lr]?.textType === void 0 && n.text !== "" && n.text !== U && !Sa(n) : "children" in n && n.type !== zr.getType());
+function QC(e, t) {
+ return e.some((n) => n === t ? !1 : ds(n) ? QC(n.children, t) : No(n) ? !1 : ni(n) ? n[Lr]?.textType === void 0 && n.text !== "" && n.text !== B && !Sa(n) : "children" in n && n.type !== jr.getType());
}
-function CI(e) {
+function AI(e) {
let t = e;
- for (; fs(t); ) t = t.children[0];
+ for (; ds(t); ) t = t.children[0];
return t;
}
-function vI(e, t) {
+function wI(e, t) {
let n = 0;
for (; n < e.length; ) {
const s = e[n];
- if (!wo(s) || s.markerSyntax !== "opening") break;
+ if (!No(s) || s.markerSyntax !== "opening") break;
n++;
}
- const r = CI(e[n]);
- return ti(r) ? r.text === qt(t) ? { node: r, caller: t } : Math.floor(r.detail / hk) % 2 === 1 ? { node: r, caller: t } : void 0 : void 0;
+ const r = AI(e[n]);
+ return ni(r) ? r.text === qt(t) ? { node: r, caller: t } : Math.floor(r.detail / kk) % 2 === 1 ? { node: r, caller: t } : void 0 : void 0;
}
function sr(e, t, n, r, i, s = !1) {
const o = [];
let a, c = [];
e.forEach((u, f) => {
- const d = u, p = u, m = u, h = u, g = u, y = u, b = u, C = u;
+ const d = u, p = u, m = u, h = u, g = u, y = u, b = u, T = u;
switch (u.type) {
- case Fn.getType():
+ case Un.getType():
o.push(
- sI(
+ dI(
d,
sr(d.children, t)
)
);
break;
case Qn.getType():
- o.push(oI(u));
+ o.push(pI(u));
break;
- case $n.getType():
+ case Rn.getType():
o.push(
- aI(
+ hI(
p,
sr(p.children, t)
)
@@ -24621,11 +24669,11 @@ function sr(e, t, n, r, i, s = !1) {
break;
case sn.getType():
case Lt.getType():
- o.push(cI(u));
+ o.push(gI(u));
break;
- case nt.getType():
+ case rt.getType():
o.push(
- lI(
+ mI(
m,
sr(m.children, t, void 0, m)
)
@@ -24633,14 +24681,14 @@ function sr(e, t, n, r, i, s = !1) {
break;
case Kt.getType(): {
let x = sr(h.children, t);
- Zs(t) && (x = Md(x)), o.push(
- uI(h, x?.length ? x : void 0)
+ Zs(t) && (x = Ad(x)), o.push(
+ yI(h, x?.length ? x : void 0)
);
break;
}
case Is.getType():
o.push(
- fI(
+ bI(
u,
sr(u.children, t)
)
@@ -24648,7 +24696,7 @@ function sr(e, t, n, r, i, s = !1) {
break;
case qs.getType():
o.push(
- dI(
+ kI(
u,
sr(u.children, t)
)
@@ -24656,30 +24704,30 @@ function sr(e, t, n, r, i, s = !1) {
break;
case Ds.getType():
o.push(
- pI(
+ xI(
u,
sr(u.children, t)
)
);
break;
- case at.getType(): {
+ case lt.getType(): {
const x = sr(
g.children,
t,
- vI(g.children, g.caller)
+ wI(g.children, g.caller)
);
o.push(
- mI(
+ vI(
g,
- Zs(t) && g.category === void 0 ? Md(x) : x
+ Zs(t) && g.category === void 0 ? Ad(x) : x
)
);
break;
}
- case zr.getType():
- case hr.getType():
+ case jr.getType():
+ case gr.getType():
case Dn.getType():
- case nk.getType():
+ case ak.getType():
case Yn.getType():
break;
case vt.getType():
@@ -24694,20 +24742,20 @@ function sr(e, t, n, r, i, s = !1) {
const x = b.typedIDs[Vt];
if (x) {
const _ = e[f + 1];
- xI(a, x, c, _, o), c = VC(_) ? x : [];
+ MI(a, x, c, _, o), c = XC(_) ? x : [];
} else {
const _ = a.shift();
- _ && (typeof _ == "string" ? Rc(o, _) : o.push(_)), a.length > 0 && o.push(...a);
+ _ && (typeof _ == "string" ? Ic(o, _) : o.push(_)), a.length > 0 && o.push(...a);
}
}
break;
- case xr.getType():
+ case Tr.getType():
o.push(eo(u));
break;
- case it.getType():
+ case at.getType():
if (n && u === n.node) {
- let x = Sp(n.node.text, n.caller);
- Zs(t) && (x = Ed(fm(x))), x && Rc(o, x);
+ let x = Ep(n.node.text, n.caller);
+ Zs(t) && (x = Pd(mm(x))), x && Ic(o, x);
break;
}
if (y.text && // Drop a bare caret host (transientCaretHost.utils.ts), recognized by its mark: a
@@ -24724,84 +24772,84 @@ function sr(e, t, n, r, i, s = !1) {
// of rewriting a lone " " into exactly this shape, so in standard view only an
// authored lone-NBSP data string (displayed as `~`, never as a bare NBSP node) is at
// stake — leaving the drop to genuinely structural nodes.
- (y.text !== U || TI(e, f, i, r, s)) && // The untagged NBSP-`|` form of milestone attribute text. Text right after a char span's
+ (y.text !== B || PI(e, f, i, r, s)) && // The untagged NBSP-`|` form of milestone attribute text. Text right after a char span's
// opening glyph is never that: its NBSP is the span's separator, and a `|…` after it is
// content the attribute grammar left literal (`\w |lemma="g"grace\w*` — Paratext 9
// parses attributes only when the whole `|…` tail before the closer matches), so it is
// kept like any other content text.
- !(y.text.startsWith(yp) && !Pd(e, f, i, r)) && // Char-span attribute display runs (bare `|…`, no NBSP prefix — see
+ !(y.text.startsWith(kp) && !wd(e, f, i, r)) && // Char-span attribute display runs (bare `|…`, no NBSP prefix — see
// usj-editor.adaptor's `addCharAttributes`) carry no NBSP prefix to strip against, so
// the prefix check above can't catch them; the textType state tag is the only signal.
y[Lr]?.textType !== "attribute") {
- let x = yI(y);
- t?.markerMode === "editable" && Pd(e, f, i, r) && x.startsWith(U) && (x = x.slice(1)), Zs(t) && (x = Ed(fm(x))), Rc(o, x);
+ let x = SI(y);
+ t?.markerMode === "editable" && wd(e, f, i, r) && x.startsWith(B) && (x = x.slice(1)), Zs(t) && (x = Pd(mm(x))), Ic(o, x);
}
break;
case Rs.getType():
o.push(
- bI(
- C,
- sr(C.children, t)
+ _I(
+ T,
+ sr(T.children, t)
)
);
break;
case _r.getType():
- o.push(kI(u));
+ o.push(EI(u));
break;
- case $o.getType():
- ml?.error("Block verse layout is not round-trippable to USJ; skipping the block.");
+ case Ro.getType():
+ bl?.error("Block verse layout is not round-trippable to USJ; skipping the block.");
break;
default:
- ml?.error(`Unexpected node type '${u.type}'!`);
+ bl?.error(`Unexpected node type '${u.type}'!`);
}
});
- const l = Zs(t) ? hI(o) : o;
+ const l = Zs(t) ? TI(o) : o;
return l.length > 0 ? l : void 0;
}
-function SI(e, t) {
+function NI(e, t) {
const n = [];
let r = [];
const i = () => {
n.push(...sr(r, t) ?? []), r = [];
};
for (const s of e) {
- if (!zl(s)) {
+ if (!Vl(s)) {
r.push(s);
continue;
}
i();
let o = sr(s.children, t);
- const a = n.at(-1), c = typeof a == "object" && a.type === $n.getType() && (a.altnumber !== void 0 || a.pubnumber !== void 0);
- Zs(t) && !c && (o = Md(o)), o?.forEach(
- (l) => typeof l == "string" ? Rc(n, l) : n.push(l)
+ const a = n.at(-1), c = typeof a == "object" && a.type === Rn.getType() && (a.altnumber !== void 0 || a.pubnumber !== void 0);
+ Zs(t) && !c && (o = Ad(o)), o?.forEach(
+ (l) => typeof l == "string" ? Ic(n, l) : n.push(l)
);
}
return i(), n.length > 0 ? n : void 0;
}
const to = {
- initialize: rI,
- deserializeEditorState: iI
-}, _I = /^sd\d*$/, EI = /* @__PURE__ */ new Set([
- ...Object.entries(Kf).filter(
- ([e, t]) => t.category === S.TitlesHeadings && t.type === v.Paragraph && !_I.test(e)
+ initialize: uI,
+ deserializeEditorState: fI
+}, OI = /^sd\d*$/, $I = /* @__PURE__ */ new Set([
+ ...Object.entries(Ff).filter(
+ ([e, t]) => t.category === S.TitlesHeadings && t.type === v.Paragraph && !OI.test(e)
).map(([e]) => e),
"qa"
]);
-function MI(e, t) {
+function RI(e, t) {
const n = [];
let r;
for (const [i, s] of e.entries()) {
- if (Bp(s) || bx(s)) {
+ if (jp(s) || Yc(s)) {
r = void 0, n.push(s);
continue;
}
- if (!pP(s)) {
- t && yl(s) && t.warn(
+ if (!bP(s)) {
+ t && kl(s) && t.warn(
`Verses inside a '${s.type}' are not grouped into blocks; the whole node stays with the surrounding verse.`
), r ? r.children.push(s) : n.push(s);
continue;
}
- if (zp(s) && EI.has(s.marker) && !yl(s)) {
+ if (Vp(s) && $I.has(s.marker) && !kl(s)) {
r = void 0, n.push(s);
continue;
}
@@ -24809,82 +24857,82 @@ function MI(e, t) {
r ? r.children.push(s) : n.push(s);
continue;
}
- HC(s.children, t).forEach((o) => {
- const a = PI(s, o.nodes, i);
+ ZC(s.children, t).forEach((o) => {
+ const a = II(s, o.nodes, i);
if (!o.verse) {
if (!a) return;
r ? r.children.push(a) : n.push(a);
return;
}
- r = AI(o.verse), n.push(r), a && r.children.push(a);
+ r = LI(o.verse), n.push(r), a && r.children.push(a);
});
}
return n;
}
-function HC(e, t) {
+function ZC(e, t) {
const n = [{ nodes: [] }], r = (i) => n[n.length - 1].nodes.push(i);
return e.forEach((i) => {
- if (GC(i)) {
+ if (ev(i)) {
n.push({ verse: i, nodes: [i] });
return;
}
- if (fs(i)) {
- const s = HC(i.children, t), [o, ...a] = s;
- o.nodes.length > 0 && r(Fy(i, o.nodes)), a.forEach((c) => {
- n.push({ verse: c.verse, nodes: [Fy(i, c.nodes)] });
+ if (ds(i)) {
+ const s = ZC(i.children, t), [o, ...a] = s;
+ o.nodes.length > 0 && r(Wy(i, o.nodes)), a.forEach((c) => {
+ n.push({ verse: c.verse, nodes: [Wy(i, c.nodes)] });
});
return;
}
- t && yl(i) && t?.warn(
+ t && kl(i) && t?.warn(
`Verse marker nested inside a '${i.type}' node was not grouped into a block.`
), r(i);
}), n;
}
-function Fy(e, t) {
+function Wy(e, t) {
return { ...e, children: t };
}
-function GC(e) {
- return rT(e) && e.number !== "";
+function ev(e) {
+ return aT(e) && e.number !== "";
}
-function yl(e) {
+function kl(e) {
const t = e.children;
- return Array.isArray(t) ? t.some((n) => GC(n) || yl(n)) : !1;
+ return Array.isArray(t) ? t.some((n) => ev(n) || kl(n)) : !1;
}
-function PI(e, t, n) {
+function II(e, t, n) {
if (t.length !== 0)
return {
...e,
children: t,
- [Lr]: { ...e[Lr], [Zx.key]: n }
+ [Lr]: { ...e[Lr], [rT.key]: n }
};
}
-function AI(e) {
+function LI(e) {
return {
- type: el,
+ type: nl,
number: e.number,
children: [],
direction: null,
format: "",
indent: 0,
- version: eT
+ version: iT
};
}
-const By = XC([]), wI = {
- type: nk.getType(),
+const Hy = Qh([]), qI = {
+ type: ak.getType(),
version: 1
};
-let Hh = [], Ee, Cs, JC, Pn;
-function NI(e, t) {
- Hh = [], RI(e), II(t);
+let Xh = [], Ee, Cs, tv, An;
+function DI(e, t) {
+ Xh = [], UI(e), FI(t);
}
-function OI(e = 0) {
+function KI(e = 0) {
}
-function $I(e, t) {
- Ee = t ?? Co();
+function BI(e, t) {
+ Ee = t ?? vo();
let n;
- return e ? (e.type !== fr && Pn?.warn(`This USJ type '${e.type}' didn't match the expected type '${fr}'.`), e.version !== ur && Pn?.warn(
+ return e ? (e.type !== fr && An?.warn(`This USJ type '${e.type}' didn't match the expected type '${fr}'.`), e.version !== ur && An?.warn(
`This USJ version '${e.version}' didn't match the expected version '${ur}'.`
- ), e.content.length > 0 ? (n = Od(Wr(e.content)), Aa(Ee) && (n = MI(n, Pn))) : n = [By]) : n = [By], JC?.(Hh), {
+ ), e.content.length > 0 ? (n = Rd(Hr(e.content)), Aa(Ee) && (n = RI(n, An)), Ee.markerMode !== "editable" && (n = l2(n))) : n = [Hy]) : n = [Hy], tv?.(Xh), {
root: {
children: n,
direction: null,
@@ -24895,27 +24943,27 @@ function $I(e, t) {
}
};
}
-function RI(e) {
- e && (Cs = e), e?.addMissingComments && (JC = e.addMissingComments);
+function UI(e) {
+ e && (Cs = e), e?.addMissingComments && (tv = e.addMissingComments);
}
-function II(e) {
- e && (Pn = e);
+function FI(e) {
+ e && (An = e);
}
-function YC() {
- return gt(Ee);
+function nv() {
+ return mt(Ee);
}
-function LI(e, t) {
+function zI(e, t) {
let { marker: n } = e;
- n !== va && Pn?.warn(`Unexpected book marker '${n}'!`), n = n ?? va;
+ n !== va && An?.warn(`Unexpected book marker '${n}'!`), n = n ?? va;
const { code: r } = e;
- (!r || !Fn.isValidBookCode(r)) && Pn?.warn(`Unexpected book code '${r}'!`);
+ (!r || !Un.isValidBookCode(r)) && An?.warn(`Unexpected book code '${r}'!`);
const i = [];
Ee?.markerMode === "editable" || Ee?.markerMode === "visible" ? i.push(
- _n("marker", rt(n) + " " + r + U)
- ) : Ee?.hasGutterParaMarkers && i.push(_n("marker", rt(n) + U, !0)), i.push(...t);
- const s = Ct(e, eP);
- return ht({
- type: Fn.getType(),
+ _n("marker", it(n) + " " + r + B)
+ ) : Ee?.hasGutterParaMarkers && i.push(_n("marker", it(n) + B, !0)), i.push(...t);
+ const s = Ct(e, sP);
+ return gt({
+ type: Un.getType(),
marker: n,
code: r ?? "",
unknownAttributes: s,
@@ -24923,20 +24971,20 @@ function LI(e, t) {
direction: null,
format: "",
indent: 0,
- version: px
+ version: bx
});
}
-function qI(e) {
+function jI(e) {
let { marker: t } = e;
- t !== Wc && Pn?.warn(`Unexpected chapter marker '${t}'!`), t = t ?? Wc;
- const { number: n, sid: r, altnumber: i, pubnumber: s } = e, o = Ct(e, oM);
+ t !== Hc && An?.warn(`Unexpected chapter marker '${t}'!`), t = t ?? Hc;
+ const { number: n, sid: r, altnumber: i, pubnumber: s } = e, o = Ct(e, fM);
let a;
Ee?.markerMode === "visible" && (a = !0);
const c = [
mn(lr(t, n) ?? "")
];
- return Ee?.markerMode === "editable" && e2(i, s, c), Ee?.markerMode === "editable" ? ht({
- type: $n.getType(),
+ return Ee?.markerMode === "editable" && a2(i, s, c), Ee?.markerMode === "editable" ? gt({
+ type: Rn.getType(),
marker: t,
number: n ?? "",
sid: r,
@@ -24947,8 +24995,8 @@ function qI(e) {
direction: null,
format: "",
indent: 0,
- version: Uk
- }) : ht({
+ version: Vk
+ }) : gt({
type: Qn.getType(),
marker: t,
number: n ?? "",
@@ -24957,17 +25005,17 @@ function qI(e) {
altnumber: i,
pubnumber: s,
unknownAttributes: o,
- version: ux
+ version: gx
});
}
-function DI(e) {
+function VI(e) {
let { marker: t } = e;
- t !== Vc && Pn?.warn(`Unexpected verse marker '${t}'!`), t = t ?? Vc;
- const { number: n, sid: r, altnumber: i, pubnumber: s } = e, a = (R1(Ee) ?? sn).getType(), c = Ee?.markerMode === "editable" ? Ok : nT;
+ t !== Wc && An?.warn(`Unexpected verse marker '${t}'!`), t = t ?? Wc;
+ const { number: n, sid: r, altnumber: i, pubnumber: s } = e, a = (K1(Ee) ?? sn).getType(), c = Ee?.markerMode === "editable" ? qk : oT;
let l, u;
Ee?.markerMode === "editable" ? l = lr(t, n) : Ee?.markerMode === "visible" && (u = !0);
- const f = Ct(e, tM);
- return ht({
+ const f = Ct(e, oM);
+ return gt({
type: a,
text: l,
...l === void 0 ? void 0 : { detail: 0, format: 0, mode: "normal", style: "" },
@@ -24981,28 +25029,28 @@ function DI(e) {
version: c
});
}
-function KI(e, t = [], n = !1) {
+function WI(e, t = [], n = !1) {
let { marker: r } = e;
- nt.isValidMarker(r, Cs?.extraValidMarkers) || Pn?.warn(`Unexpected char marker '${r}'!`), r = r ?? "";
+ rt.isValidMarker(r, Cs?.extraValidMarkers) || An?.warn(`Unexpected char marker '${r}'!`), r = r ?? "";
const i = [];
if (Ee?.markerMode === "editable") {
const [a] = t;
- ti(a) ? a.text = U + a.text : a && t.unshift(mn(U));
+ ni(a) ? a.text = B + a.text : a && t.unshift(mn(B));
}
- t.length === 0 && t.push(mn(It)), Ad(e.marker ?? "", i, n), i.push(...t);
- const s = e.closed === "false", o = Ct(e, QE);
- return s || YI(r, o, i), s || wd(e.marker ?? "", i, !1, n), ht({
- type: nt.getType(),
+ t.length === 0 && t.push(mn(It)), Nd(e.marker ?? "", i, n), i.push(...t);
+ const s = e.closed === "false", o = Ct(e, rM);
+ return s || r2(r, o, i), s || Od(e.marker ?? "", i, !1, n), gt({
+ type: rt.getType(),
marker: r,
unknownAttributes: o,
children: i,
direction: null,
format: "",
indent: 0,
- version: wk
+ version: Ik
});
}
-function XC(e) {
+function Qh(e) {
return {
type: Dr.getType(),
children: e,
@@ -25011,30 +25059,30 @@ function XC(e) {
indent: 0,
textFormat: 0,
textStyle: "",
- version: Wk
+ version: Xk
};
}
-function UI(e, t = []) {
+function HI(e, t = []) {
let { marker: n } = e;
- Kt.isValidMarker(n, Cs?.extraValidMarkers) || Pn?.warn(`Unexpected para marker '${n}'!`), n = n ?? Ln;
+ Kt.isValidMarker(n, Cs?.extraValidMarkers) || An?.warn(`Unexpected para marker '${n}'!`), n = n ?? qn;
const r = [];
- if (qi(Ee) && (Ee?.markerMode === "editable" ? r.push(
+ if (Di(Ee) && (Ee?.markerMode === "editable" ? r.push(
dn(n),
- mn(U, Br, "token")
+ mn(B, zr, "token")
) : (Ee?.markerMode === "visible" || Ee?.hasGutterParaMarkers) && r.push(
_n(
"marker",
- rt(n) + U,
+ it(n) + B,
Ee?.hasGutterParaMarkers
)
- )), r.push(...t), YC()) {
+ )), r.push(...t), nv()) {
const s = r.find(
- (o) => !wo(o) && !(ti(o) && o.text === U)
+ (o) => !No(o) && !(ni(o) && o.text === B)
);
- ti(s) && !/^ +$/.test(s.text) && (s.text = s.text.replace(/^ +/, (o) => U.repeat(o.length)));
+ ni(s) && !/^ +$/.test(s.text) && (s.text = s.text.replace(/^ +/, (o) => B.repeat(o.length)));
}
- const i = Ct(e, nP);
- return ht({
+ const i = Ct(e, aP);
+ return gt({
type: Kt.getType(),
marker: n,
unknownAttributes: i,
@@ -25044,101 +25092,101 @@ function UI(e, t = []) {
indent: 0,
textFormat: 0,
textStyle: "",
- version: gx
+ version: xx
});
}
-function Gh() {
+function Zh() {
return {
direction: null,
format: "",
indent: 0
};
}
-function FI(e, t = []) {
- const n = Ct(e, dM);
- return ht({
- ...Gh(),
+function GI(e, t = []) {
+ const n = Ct(e, yM);
+ return gt({
+ ...Zh(),
type: Is.getType(),
unknownAttributes: n,
children: t,
- version: jk
+ version: Jk
});
}
-function BI(e, t = []) {
- const n = Ct(e, XP), r = e.marker ?? ed, i = [];
+function JI(e, t = []) {
+ const n = Ct(e, nA), r = e.marker ?? rd, i = [];
return Ee?.markerMode === "editable" ? i.push(
dn(r),
- mn(U, Br, "token")
+ mn(B, zr, "token")
) : (Ee?.markerMode === "visible" || Ee?.hasGutterParaMarkers) && i.push(
_n(
"marker",
- rt(r) + U,
+ it(r) + B,
Ee?.hasGutterParaMarkers
)
- ), i.push(...t), ht({
- ...Gh(),
+ ), i.push(...t), gt({
+ ...Zh(),
type: qs.getType(),
marker: r,
unknownAttributes: n,
children: i,
- version: Wx
+ version: Yx
});
}
-function zI(e, t = []) {
- const { marker: n, align: r, colspan: i } = e, s = [], o = n ?? td, a = ox(o, i) ?? o;
+function YI(e, t = []) {
+ const { marker: n, align: r, colspan: i } = e, s = [], o = n ?? id, a = fx(o, i) ?? o;
Ee?.markerMode === "editable" ? s.push(
dn(a),
- mn(U, Br, "token")
+ mn(B, zr, "token")
) : (Ee?.markerMode === "visible" || Ee?.hasGutterParaMarkers) && s.push(
_n(
"marker",
- rt(a) + U,
+ it(a) + B,
Ee?.hasGutterParaMarkers
)
), s.push(...t);
const c = Ct(
e,
- ZP
+ iA
);
- return ht({
- ...Gh(),
+ return gt({
+ ...Zh(),
type: Ds.getType(),
marker: o,
align: r,
colspan: i,
unknownAttributes: c,
children: s,
- version: Jx
+ version: Zx
});
}
-function jI(e, t) {
- const n = kP(t);
+function XI(e, t) {
+ const n = SP(t);
let r = () => {
};
- return Cs?.noteCallerOnClick && (r = Cs.noteCallerOnClick), ht({
+ return Cs?.noteCallerOnClick && (r = Cs.noteCallerOnClick), gt({
type: Dn.getType(),
caller: e,
previewText: n,
onClick: r,
- version: lT
+ version: pT
});
}
-function VI(e, t) {
+function QI(e, t) {
let { marker: n } = e;
- at.isValidMarker(n, Cs?.extraValidMarkers) || Pn?.warn(`Unexpected note marker '${n}'!`), n = n ?? Tp;
- const { category: r } = e, i = e.caller ?? "*", s = e.closed === "false", o = s ? !1 : Ah(Ee?.noteMode), a = Ct(e, pE), c = Ee?.isNoteShellEditable === !1 ? "token" : "normal";
+ lt.isValidMarker(n, Cs?.extraValidMarkers) || An?.warn(`Unexpected note marker '${n}'!`), n = n ?? vp;
+ const { category: r } = e, i = e.caller ?? "*", s = e.closed === "false", o = s ? !1 : Nh(Ee?.noteMode), a = Ct(e, bE), c = Ee?.isNoteShellEditable === !1 ? "token" : "normal";
let l, u;
- Ee?.markerMode === "editable" ? (l = dn(n, "opening", !1, c), s || (u = dn(n, "closing", !1, c))) : Ee?.markerMode === "visible" && (l = _n("marker", rt(n) + " "), s || (u = _n("marker", pt(n))));
+ Ee?.markerMode === "editable" ? (l = dn(n, "opening", !1, c), s || (u = dn(n, "closing", !1, c))) : Ee?.markerMode === "visible" && (l = _n("marker", it(n) + " "), s || (u = _n("marker", pt(n))));
const f = [];
let d;
if (l && f.push(l), Ee?.markerMode === "editable" && !o)
- d = mn(qt(i), void 0, c), d.detail = hk, f.push(d), ZI(r, f), f.push(...t);
+ d = mn(qt(i), void 0, c), d.detail = kk, f.push(d), o2(r, f), f.push(...t);
else {
- const p = mn(U, Br, "token");
- d = jI(i, t), f.push(d, p, ...t.flatMap(WI(p)));
+ const p = mn(B, zr, "token");
+ d = XI(i, t), f.push(d, p, ...t.flatMap(ZI(p)));
}
- return u && f.push(u), ht({
- type: at.getType(),
+ return u && f.push(u), gt({
+ type: lt.getType(),
marker: n,
caller: i,
isCollapsed: o,
@@ -25148,27 +25196,27 @@ function VI(e, t) {
direction: null,
format: "",
indent: 0,
- version: bk
+ version: vk
});
}
-function WI(e) {
- return (t) => rx(t) ? [t] : [t, e];
+function ZI(e) {
+ return (t) => cx(t) ? [t] : [t, e];
}
-function HI(e) {
+function e2(e) {
let { marker: t } = e;
- (!t || !xr.isValidMarker(t, Cs?.extraValidMarkers)) && Pn?.warn(`Unexpected milestone marker '${t}'!`), t = t ?? "";
- const { sid: n, eid: r } = e, i = Ct(e, xp), s = Ik(e);
- return ht({
- type: xr.getType(),
+ (!t || !Tr.isValidMarker(t, Cs?.extraValidMarkers)) && An?.warn(`Unexpected milestone marker '${t}'!`), t = t ?? "";
+ const { sid: n, eid: r } = e, i = Ct(e, Cp), s = Bk(e);
+ return gt({
+ type: Tr.getType(),
marker: t,
sid: n,
eid: r,
unknownAttributes: i,
attributeOrder: s,
- version: gk
+ version: xk
});
}
-function zy(e, t = []) {
+function Gy(e, t = []) {
return {
type: vt.getType(),
typedIDs: { [Vt]: t },
@@ -25179,10 +25227,10 @@ function zy(e, t = []) {
version: 1
};
}
-function GI(e, t) {
- const { marker: n } = e, r = e.type, i = Ct(e, cM), s = [];
+function t2(e, t) {
+ const { marker: n } = e, r = e.type, i = Ct(e, pM), s = [];
if (Ee?.markerMode === "editable") {
- const { opening: o, attributes: a, closingAttributes: c, closing: l } = Vl(
+ const { opening: o, attributes: a, closingAttributes: c, closing: l } = Hl(
r,
n,
i
@@ -25191,8 +25239,8 @@ function GI(e, t) {
} else
s.push(...t);
return s.forEach((o) => {
- ti(o) && (o.mode = "token");
- }), ht({
+ ni(o) && (o.mode = "token");
+ }), gt({
type: Rs.getType(),
tag: r,
marker: n,
@@ -25201,14 +25249,14 @@ function GI(e, t) {
direction: null,
format: "",
indent: 0,
- version: Bk
+ version: Hk
});
}
-function JI(e) {
+function n2(e) {
return {
type: _r.getType(),
marker: e,
- text: ia(e),
+ text: sa(e),
detail: 0,
format: 0,
// Editable marker mode edits the flagged bytes in place (the marker-edit engine pends and
@@ -25216,7 +25264,7 @@ function JI(e) {
// atomic "token" text there — steppable and deletable whole, but not editable inside.
mode: Ee?.markerMode === "editable" ? "normal" : "token",
style: "",
- version: Ix
+ version: Kx
};
}
function dn(e, t = "opening", n = !1, r = "normal") {
@@ -25236,7 +25284,7 @@ function dn(e, t = "opening", n = !1, r = "normal") {
}
function mn(e, t = void 0, n = "normal") {
const r = {
- type: it.getType(),
+ type: at.getType(),
text: e,
detail: 0,
format: 0,
@@ -25248,28 +25296,28 @@ function mn(e, t = void 0, n = "normal") {
}
function _n(e, t, n = !1) {
const r = {
- type: hr.getType(),
+ type: gr.getType(),
text: t,
textType: e,
- version: ex
+ version: sx
};
- return n && (r[Lr] = { [Kp.key]: !0 }), r;
+ return n && (r[Lr] = { [Up.key]: !0 }), r;
}
function $a(e, t) {
return {
- type: zr.getType(),
+ type: jr.getType(),
runKind: e,
children: t,
direction: null,
format: "",
indent: 0,
- version: Ek
+ version: Nk
};
}
-function Ad(e, t, n = !1) {
- Ee?.markerMode === "editable" ? t.push(dn(e, "opening", n)) : Ee?.markerMode === "visible" && t.push(_n("marker", rt(e, n)));
+function Nd(e, t, n = !1) {
+ Ee?.markerMode === "editable" ? t.push(dn(e, "opening", n)) : Ee?.markerMode === "visible" && t.push(_n("marker", it(e, n)));
}
-function wd(e, t, n = !1, r = !1) {
+function Od(e, t, n = !1, r = !1) {
Ee?.markerMode === "editable" ? n ? t.push(dn("", "selfClosing")) : t.push(dn(e, "closing", r)) : Ee?.markerMode === "visible" && t.push(
_n(
"marker",
@@ -25277,234 +25325,240 @@ function wd(e, t, n = !1, r = !1) {
)
);
}
-function YI(e, t, n) {
+function r2(e, t, n) {
if (Ee?.markerMode !== "editable" || !t) return;
- const r = yr(t, Ao(e));
+ const r = br(t, wo(e));
r && n.push(mn(r, "attribute"));
}
-function jy(e, t) {
+function Jy(e, t) {
if (e.type !== "ms" || Ee?.markerMode !== "editable" && Ee?.markerMode !== "visible") return;
- const { marker: n, sid: r, eid: i } = e, s = Ct(e, xp), o = Lk(
+ const { marker: n, sid: r, eid: i } = e, s = Ct(e, Cp), o = Uk(
r,
i,
s,
- Ik(e)
- ), a = yr(o, Ha(n ?? ""));
+ Bk(e)
+ ), a = br(o, Ha(n ?? ""));
if (!a) return;
- const c = U + a;
+ const c = B + a;
Ee?.markerMode === "editable" ? t.push(mn(c, "attribute")) : t.push(_n("attribute", c));
}
-function XI(e, t) {
+function i2(e, t) {
const n = e.marker ?? "";
if (Ee?.markerMode === "editable") {
const r = [];
- Ad(n, r), jy(e, r), wd(n, r, !0), t.push($a("milestone", r));
+ Nd(n, r), Jy(e, r), Od(n, r, !0), t.push($a("milestone", r));
} else
- Ad(n, t), jy(e, t), wd(n, t, !0);
+ Nd(n, t), Jy(e, t), Od(n, t, !0);
}
-function Vy(e, t, n) {
+function Yy(e, t, n) {
t !== void 0 && n.push(
$a(e, [
dn(e, "opening"),
- mn(U + t, "attribute"),
+ mn(B + t, "attribute"),
dn(e, "closing")
])
);
}
-function QI(e, t) {
- Ee?.markerMode === "editable" && (Vy("va", e.altnumber, t), Vy("vp", e.pubnumber, t));
+function s2(e, t) {
+ Ee?.markerMode === "editable" && (Yy("va", e.altnumber, t), Yy("vp", e.pubnumber, t));
}
-function ZI(e, t) {
+function o2(e, t) {
e !== void 0 && t.push(
$a("cat", [
dn("cat", "opening"),
- mn(U + e, "attribute"),
+ mn(B + e, "attribute"),
dn("cat", "closing")
])
);
}
-function e2(e, t, n) {
+function a2(e, t, n) {
e !== void 0 && n.push(
$a("ca", [
dn("ca", "opening"),
- mn(U + e, "attribute"),
+ mn(B + e, "attribute"),
dn("ca", "closing")
])
), t !== void 0 && n.push(
$a("cp", [
dn("cp", "opening"),
- mn(U + t, "attribute")
+ mn(B + t, "attribute")
])
);
}
-function Wy(e, t) {
+function Xy(e, t) {
return e.length <= 0 || t === 0 ? e : e.map((n) => n - t);
}
-function t2(e, t) {
+function c2(e, t) {
const n = e.indexOf(t, 0);
n > -1 && e.splice(n, 1);
}
-function Hy(e, t) {
- t.marker === ls && t.sid !== void 0 && e.push(t.sid), t.marker === co && t.eid !== void 0 && t2(e, t.eid);
+function Qy(e, t) {
+ t.marker === us && t.sid !== void 0 && e.push(t.sid), t.marker === co && t.eid !== void 0 && c2(e, t.eid);
}
-function Nd(e, t, n = !1, r = []) {
+function $d(e, t, n = !1, r = []) {
if (t.length <= 0 || t[0] >= e.length) return e;
const i = t.shift(), s = t.length > 0 ? t.shift() : e.length - 1;
if (i === void 0 || s === void 0 || s >= e.length || e.length <= 0)
return e;
- const o = e.slice(0, i), a = n ? [zy(o, [...r])] : o, c = e[i];
- Hy(r, c);
- const l = Nd(
+ const o = e.slice(0, i), a = n ? [Gy(o, [...r])] : o, c = e[i];
+ Qy(r, c);
+ const l = $d(
e.slice(i + 1, s),
- Wy(t, i + 1),
- c.marker === ls,
+ Xy(t, i + 1),
+ c.marker === us,
r
- ), u = zy(l, [...r]), f = e[s];
- Hy(r, f);
- const d = Nd(
+ ), u = Gy(l, [...r]), f = e[s];
+ Qy(r, f);
+ const d = $d(
e.slice(s + 1),
- Wy(t, s + 1),
- f.marker === ls,
+ Xy(t, s + 1),
+ f.marker === us,
r
);
return [...a, u, ...d];
}
-function Wr(e, t = !1) {
+function Hr(e, t = !1) {
const n = [], r = [];
return e?.forEach((i) => {
if (typeof i == "string")
- i && r.push(mn(YC() ? nI(i) : i));
+ i && r.push(mn(nv() ? lI(i) : i));
else if (!i.type)
- Pn?.error("Marker type is missing!");
+ An?.error("Marker type is missing!");
else
switch (i.type) {
- case Fn.getType():
- r.push(LI(i, Wr(i.content)));
+ case Un.getType():
+ r.push(zI(i, Hr(i.content)));
break;
- case $n.getType():
- r.push(qI(i));
+ case Rn.getType():
+ r.push(jI(i));
break;
case Lt.getType():
- Ee?.hasSpacing || r.push(wI), r.push(DI(i)), QI(i, r);
+ Ee?.hasSpacing || r.push(qI), r.push(VI(i)), s2(i, r);
break;
- case nt.getType():
+ case rt.getType():
r.push(
- KI(i, Wr(i.content, !0), t)
+ WI(i, Hr(i.content, !0), t)
);
break;
case Kt.getType():
- r.push(UI(i, Wr(i.content)));
+ r.push(HI(i, Hr(i.content)));
break;
- case at.getType():
- r.push(VI(i, Wr(i.content)));
+ case lt.getType():
+ r.push(QI(i, Hr(i.content)));
break;
- case xr.getType():
- mk(i.marker ?? "") && (n.push(r.length), i.sid !== void 0 && Hh?.push(i.sid)), r.push(HI(i)), XI(i, r);
+ case Tr.getType():
+ Tk(i.marker ?? "") && (n.push(r.length), i.sid !== void 0 && Xh?.push(i.sid)), r.push(e2(i)), i2(i, r);
break;
case _r.getType():
- r.push(JI(i.marker ?? ""));
+ r.push(n2(i.marker ?? ""));
break;
- case zk:
- r.push(FI(i, Wr(i.content)));
+ case Gk:
+ r.push(GI(i, Hr(i.content)));
break;
- case Vx:
- r.push(BI(i, Wr(i.content)));
+ case Jx:
+ r.push(JI(i, Hr(i.content)));
break;
- case Gx:
- r.push(zI(i, Wr(i.content)));
+ case Qx:
+ r.push(YI(i, Hr(i.content)));
break;
default:
- Pn?.warn(`Unknown type-marker '${i.type}-${i.marker}'!`), r.push(GI(i, Wr(i.content)));
+ An?.warn(`Unknown type-marker '${i.type}-${i.marker}'!`), r.push(t2(i, Hr(i.content)));
}
- }), Nd(r, n);
+ }), $d(r, n);
}
-function Od(e) {
+function Rd(e) {
const t = e.findIndex(
- (r) => Bp(r) || bx(r) || zp(r) || // A table is a block root in its own right; without this it would be swept into an implied
+ (r) => jp(r) || Yc(r) || Vp(r) || // A table is a block root in its own right; without this it would be swept into an implied
// para alongside any sibling text/verse nodes.
- hM(r)
+ kM(r)
);
if (t >= 0) {
- const r = Od(e.slice(0, t)), i = e[t], s = Od(e.slice(t + 1));
+ const r = Rd(e.slice(0, t)), i = e[t], s = Rd(e.slice(t + 1));
return [...r, i, ...s];
- } else if (e.some((r) => "text" in r && "mode" in r || rT(r)))
- return [XC(e)];
+ } else if (e.some((r) => "text" in r && "mode" in r || aT(r)))
+ return [Qh(e)];
return e;
}
-const pr = {
- initialize: NI,
- reset: OI,
- serializeEditorState: $I
+function l2(e) {
+ return e.flatMap((t, n) => {
+ const r = e[n + 1];
+ return Yc(t) && (!r || Yc(r)) ? [t, Qh([])] : [t];
+ });
+}
+const hr = {
+ initialize: DI,
+ reset: KI,
+ serializeEditorState: BI
};
-function QC(e) {
+function rv(e) {
if (e && !$(e)) {
- if (T(e)) return e;
+ if (C(e)) return e;
if (A(e))
for (const t of e.getChildren()) {
- const n = QC(t);
+ const n = rv(t);
if (n) return n;
}
}
}
-function n2() {
+function u2() {
const e = M();
if (!E(e)) return !1;
if (e.isCollapsed()) {
const t = e.anchor.getNode(), n = e.anchor.offset;
- if ((T(t) && !$(t) ? ys(t) : void 0) && T(t)) {
- const i = Ue(" ");
+ if ((C(t) && !$(t) ? ys(t) : void 0) && C(t)) {
+ const i = Be(" ");
if (n <= 0) t.insertBefore(i);
else if (n >= t.getTextContentSize()) t.insertAfter(i);
else {
const [o] = t.splitText(n);
o.insertAfter(i);
}
- xo(i, { renderGlyphs: !0, closeImplicitSpans: !0 });
- const s = QC(i.getNextSibling());
+ To(i, { renderGlyphs: !0, closeImplicitSpans: !0 });
+ const s = rv(i.getNextSibling());
if (s) {
- const o = s.getTextContent(), a = o.startsWith(U) ? U : "", c = o.slice(a.length);
+ const o = s.getTextContent(), a = o.startsWith(B) ? B : "", c = o.slice(a.length);
c.startsWith(" ") && s.setTextContent(a + c.slice(1));
}
return i.select(1, 1), !0;
}
- return T(t) && t.getTextContent()[n] === " " ? (t.select(n + 1, n + 1), !0) : (e.insertText(" "), !0);
+ return C(t) && t.getTextContent()[n] === " " ? (t.select(n + 1, n + 1), !0) : (e.insertText(" "), !0);
}
- for (const t of ZC(e)) {
+ for (const t of iv(e)) {
if (!ys(t)) continue;
- xo(t, { renderGlyphs: !0, closeImplicitSpans: !0 });
+ To(t, { renderGlyphs: !0, closeImplicitSpans: !0 });
const n = t.getLatest(), r = n.getTextContent();
- r.startsWith(U) && n.setTextContent(r.slice(U.length));
+ r.startsWith(B) && n.setTextContent(r.slice(B.length));
}
return !0;
}
-function ZC(e) {
- const [t, n] = up(e), [r, i] = e.isBackward() ? [n, t] : [t, n], s = e.getNodes(), o = [];
+function iv(e) {
+ const [t, n] = dp(e), [r, i] = e.isBackward() ? [n, t] : [t, n], s = e.getNodes(), o = [];
return s.forEach((a, c) => {
- if (!T(a) || $(a) || Te(a, _e) === "attribute") return;
+ if (!C(a) || $(a) || Te(a, _e) === "attribute") return;
const l = a.getTextContentSize(), u = c === 0 ? r : 0, f = c === s.length - 1 ? Math.min(i, l) : l;
if (u >= f) return;
const d = a.splitText(u, f), p = d.length === 3 ? d[1] : f === l ? d[d.length - 1] : d[0];
p && o.push(p);
}), o;
}
-function ev(e) {
+function sv(e) {
let t = e;
- for (; z(t) || ge(t); ) t = t.getParent();
+ for (; z(t) || me(t); ) t = t.getParent();
return t;
}
-function tv(e) {
- const t = ev(e.getParent());
- return dt(t) ? t : void 0;
+function ov(e) {
+ const t = sv(e.getParent());
+ return ot(t) ? t : void 0;
}
-function r2() {
+function f2() {
const e = M();
if (!E(e)) return !1;
const t = e.focus.getNode();
- return ys(t) ? !!tv(t) : !1;
+ return ys(t) ? !!ov(t) : !1;
}
-function nv(e) {
- const t = Ue(""), n = e.getNode(), r = e.offset;
- if (T(n))
+function av(e) {
+ const t = Be(""), n = e.getNode(), r = e.offset;
+ if (C(n))
if (r <= 0) n.insertBefore(t);
else if (r >= n.getTextContentSize()) n.insertAfter(t);
else {
@@ -25518,12 +25572,12 @@ function nv(e) {
else return { parent: void 0, moving: [] };
}
for (let o = t.getParent(); ; o = t.getParent())
- if (z(o)) xo(t, { renderGlyphs: !0 });
- else if (!ge(o) || !i2(t, o)) break;
+ if (z(o)) To(t, { renderGlyphs: !0 });
+ else if (!me(o) || !d2(t, o)) break;
const i = t.getNextSiblings(), s = t.getParent() ?? void 0;
return t.remove(), { parent: s, moving: i };
}
-function i2(e, t) {
+function d2(e, t) {
const n = e.getNextSiblings();
if (!e.getPreviousSibling())
return t.insertBefore(e), !0;
@@ -25534,9 +25588,9 @@ function i2(e, t) {
const i = t.insertNewAfter(r, !1);
return i ? (i.append(...n), t.insertAfter(e), !0) : !1;
}
-function rv(e) {
+function cv(e) {
const t = e.anchor.getNode();
- if ($(t) && !ah(t, e.anchor.offset)) {
+ if ($(t) && !lh(t, e.anchor.offset)) {
const n = t.getParent();
if (z(n) && t.is(n.getLastChild())) {
n.selectNext(0, 0);
@@ -25546,40 +25600,40 @@ function rv(e) {
}
return e;
}
-function iv() {
+function lv() {
const e = M();
if (!E(e) || !e.isCollapsed()) return !1;
- const t = rv(e);
+ const t = cv(e);
if (!t) return !1;
const n = t.anchor.getNode();
- if (!T(n) || $(n) || !ys(n)) return !1;
- const r = tv(n);
+ if (!C(n) || $(n) || !ys(n)) return !1;
+ const r = ov(n);
if (!r) return !1;
- const { moving: i } = nv(t.anchor), s = r.insertNewAfter(t, !1);
+ const { moving: i } = av(t.anchor), s = r.insertNewAfter(t, !1);
s.append(...i);
let o = i[0];
- for (; ge(o); ) o = o.getFirstChild() ?? void 0;
- return z(o) ? Xl(o) : s.select(0, 0), !0;
+ for (; me(o); ) o = o.getFirstChild() ?? void 0;
+ return z(o) ? Zl(o) : s.select(0, 0), !0;
}
-const yn = String.raw`\w-`, sv = "a-z0-9", s2 = `[a-z][${sv}]*`, ov = new RegExp(
+const yn = String.raw`\w-`, uv = "a-z0-9", p2 = `[a-z][${uv}]*`, fv = new RegExp(
String.raw`^\\(\+?[${yn}]+)[ \u00A0]$`
-), Io = new RegExp(String.raw`^\\(\+?[${yn}]+)$`), o2 = new RegExp(String.raw`^\\\+?[${yn}]*\*$`), a2 = new RegExp(
+), Lo = new RegExp(String.raw`^\\(\+?[${yn}]+)$`), h2 = new RegExp(String.raw`^\\\+?[${yn}]*\*$`), g2 = new RegExp(
String.raw`^\\(\+?[${yn}]+)(?:[ \u00A0]|$)`
-), c2 = new RegExp(
+), m2 = new RegExp(
String.raw`^\\(\+?)([${yn}]+)`
-), av = new RegExp(
+), dv = new RegExp(
String.raw`^(?:[${yn}]+[*\\]?|[*\\])$`
-), l2 = new RegExp(
+), y2 = new RegExp(
String.raw`\\\+?[${yn}]+(?:\\?\*|[ \u00A0])`
-), cv = new RegExp(
+), pv = new RegExp(
String.raw`\\\+?[${yn}]*$`
-), u2 = new RegExp(
- String.raw`^\\(${s2})( |$)`
-), f2 = new RegExp(
- String.raw`\\[${sv}+*]*$`,
+), b2 = new RegExp(
+ String.raw`^\\(${p2})( |$)`
+), k2 = new RegExp(
+ String.raw`\\[${uv}+*]*$`,
"i"
-), bl = "", Gy = "|", ki = "\\", vf = "+", d2 = /([-\w]+)="(.*?)"/g, p2 = /* @__PURE__ */ new Set(["type", "marker", "content", "closed"]), h2 = /* @__PURE__ */ new Map([["file", "src"]]);
-class Jh {
+), xl = "", Zy = "|", xi = "\\", Ef = "+", x2 = /([-\w]+)="(.*?)"/g, T2 = /* @__PURE__ */ new Set(["type", "marker", "content", "closed"]), C2 = /* @__PURE__ */ new Map([["file", "src"]]);
+class eg {
segments = [];
/** Differing segments are never merged: the boundary between two of them (two adjacent literals)
* is a position both sides share. */
@@ -25608,14 +25662,14 @@ class Jh {
this.push(n, n + o, i, i + o, !0), this.push(n + o, c - a, i + o, l - a, !1), this.push(c - a, c, l - a, l, !0);
}
}
-function Jy(e, t) {
- const n = [e.indexOf(ki, t + 1), e.indexOf(bl, t + 1)].filter(
+function eb(e, t) {
+ const n = [e.indexOf(xi, t + 1), e.indexOf(xl, t + 1)].filter(
(r) => r >= 0
);
return n.length > 0 ? Math.min(...n) : e.length;
}
-function Yy(e) {
- const t = e.slice(1), n = [...t.matchAll(d2)];
+function tb(e) {
+ const t = e.slice(1), n = [...t.matchAll(x2)];
return n.length > 0 ? n.map((r) => r[0]).join("") !== t || n.some((r) => r[2] === "") ? void 0 : n.map((r) => {
const i = 1 + (r.index ?? 0), s = i + r[1].length + 2;
return {
@@ -25637,10 +25691,10 @@ function Yy(e) {
}
] : void 0;
}
-function g2(e, t) {
+function v2(e, t) {
const n = e.map(
- (o, a) => o.name === void 0 || !p2.has(o.name) && !e.slice(a + 1).some((c) => c.name === o.name)
- ), r = (o, a) => o.value === a.value && (a.name === void 0 || o.name === a.name || o.name !== void 0 && h2.get(o.name) === a.name), i = /* @__PURE__ */ new Set(), s = [];
+ (o, a) => o.name === void 0 || !T2.has(o.name) && !e.slice(a + 1).some((c) => c.name === o.name)
+ ), r = (o, a) => o.value === a.value && (a.name === void 0 || o.name === a.name || o.name !== void 0 && C2.get(o.name) === a.name), i = /* @__PURE__ */ new Set(), s = [];
return t.forEach((o, a) => {
const c = e.findIndex(
(l, u) => n[u] && !i.has(u) && r(l, o)
@@ -25648,7 +25702,7 @@ function g2(e, t) {
c < 0 || (i.add(c), s.push([c, a]));
}), s;
}
-function Xy(e, t, n) {
+function nb(e, t, n) {
let r = 0, i = -1;
for (const s of e) {
if (!s.same) continue;
@@ -25657,19 +25711,19 @@ function Xy(e, t, n) {
}
return r;
}
-function m2(e, t, n, r, i) {
+function S2(e, t, n, r, i) {
if (e === t) {
n.push(r, r + e.length, i, i + t.length, !0);
return;
}
- const s = Yy(e), o = Yy(t);
+ const s = tb(e), o = tb(t);
if (!s || !o) {
n.push(r, r + 1, i, i + 1, !0), n.pushStretch(e.slice(1), r + 1, t.slice(1), i + 1);
return;
}
- const a = new Jh();
+ const a = new eg();
a.push(0, 1, 0, 1, !0);
- const c = g2(s, o);
+ const c = v2(s, o);
for (const [d, p] of c) {
const m = s[d], h = o[p];
a.pushStretch(
@@ -25687,13 +25741,13 @@ function m2(e, t, n, r, i) {
const l = [...a.segments], u = new Set(c.map(([d]) => d));
s.forEach((d, p) => {
if (u.has(p)) return;
- const m = Xy(l, d.start, "live");
+ const m = nb(l, d.start, "live");
a.push(d.start, d.end, m, m, !1);
});
const f = new Set(c.map(([, d]) => d));
o.forEach((d, p) => {
if (f.has(p)) return;
- const m = Xy(l, d.start, "settled");
+ const m = nb(l, d.start, "settled");
a.push(m, m, d.start, d.end, !1);
}), a.segments.sort(
(d, p) => d.settledStart - p.settledStart || d.settledEnd - p.settledEnd || d.liveStart - p.liveStart
@@ -25707,25 +25761,25 @@ function m2(e, t, n, r, i) {
)
);
}
-function lv(e, t, n, r, i) {
+function hv(e, t, n, r, i) {
let s = t, o = 0;
for (; s < e.length && o < n.length; ) {
- const c = n[o] === bl && e[s] !== bl ? i.spellings?.get(o) : void 0;
+ const c = n[o] === xl && e[s] !== xl ? i.spellings?.get(o) : void 0;
if (c !== void 0) {
- const u = new Jh(), f = lv(e, s, c, u, { prefix: !0 });
+ const u = new eg(), f = hv(e, s, c, u, { prefix: !0 });
i.literals?.set(o, {
liveStart: s,
liveEnd: f,
- inner: { segments: x2(u.segments, s) }
+ inner: { segments: P2(u.segments, s) }
}), r.push(s, f, o, o + 1, !1), s = f, o += 1;
continue;
}
- if (e[s] === Gy && n[o] === Gy) {
- const u = Jy(e, s), f = Jy(n, o);
- m2(e.slice(s, u), n.slice(o, f), r, s, o), s = u, o = f;
+ if (e[s] === Zy && n[o] === Zy) {
+ const u = eb(e, s), f = eb(n, o);
+ S2(e.slice(s, u), n.slice(o, f), r, s, o), s = u, o = f;
continue;
}
- const l = n[o] === ki ? y2(e, s, n, o) || k2(e, s, n, o, i.spellings) || (!i.prefix && s === 0 && o === 0 ? b2(e, n) : 0) : 0;
+ const l = n[o] === xi ? _2(e, s, n, o) || M2(e, s, n, o, i.spellings) || (!i.prefix && s === 0 && o === 0 ? E2(e, n) : 0) : 0;
if (l > 0) {
r.push(s, s, o, o + l, !1), o += l;
continue;
@@ -25734,12 +25788,12 @@ function lv(e, t, n, r, i) {
r.push(s, s + 1, o, o + 1, !0), s += 1, o += 1;
continue;
}
- if (e[s - 1] === ki && n[o - 1] === ki && e[s] === vf != (n[o] === vf)) {
- e[s] === vf ? (r.push(s, s + 1, o, o, !1, !0), s += 1) : (r.push(s, s, o, o + 1, !1, !0), o += 1);
+ if (e[s - 1] === xi && n[o - 1] === xi && e[s] === Ef != (n[o] === Ef)) {
+ e[s] === Ef ? (r.push(s, s + 1, o, o, !1, !0), s += 1) : (r.push(s, s, o, o + 1, !1, !0), o += 1);
continue;
}
if (i.prefix) {
- const u = n.lastIndexOf(ki), f = u >= o ? n.slice(u) : void 0, d = f === void 0 ? -1 : e.indexOf(f, s);
+ const u = n.lastIndexOf(xi), f = u >= o ? n.slice(u) : void 0, d = f === void 0 ? -1 : e.indexOf(f, s);
return f === void 0 || d < 0 ? (r.push(s, s, o, n.length, !1), s) : (r.pushStretch(e.slice(s, d), s, n.slice(o, u), o), r.push(d, d + f.length, u, n.length, !0), d + f.length);
}
return r.pushStretch(e.slice(s), s, n.slice(o), o), e.length;
@@ -25748,35 +25802,35 @@ function lv(e, t, n, r, i) {
return r.push(s, a, o, n.length, !1), a;
}
const oo = /\\\+?[\w-]+/y;
-function y2(e, t, n, r) {
+function _2(e, t, n, r) {
oo.lastIndex = r;
const i = oo.exec(n)?.[0];
- return !i || n[r + i.length] !== ki ? 0 : n.startsWith(i, r + i.length) && e.startsWith(i, t) && !e.startsWith(i, t + i.length) ? i.length : 0;
+ return !i || n[r + i.length] !== xi ? 0 : n.startsWith(i, r + i.length) && e.startsWith(i, t) && !e.startsWith(i, t + i.length) ? i.length : 0;
}
const xc = "\\p";
-function b2(e, t) {
- return !t.startsWith(xc) || t[xc.length] !== ki ? 0 : e[0] === ki && !e.startsWith(xc) ? xc.length : 0;
+function E2(e, t) {
+ return !t.startsWith(xc) || t[xc.length] !== xi ? 0 : e[0] === xi && !e.startsWith(xc) ? xc.length : 0;
}
-function k2(e, t, n, r, i) {
+function M2(e, t, n, r, i) {
oo.lastIndex = r;
const s = oo.exec(n)?.[0];
- if (!s || n[r + s.length] !== bl) return 0;
+ if (!s || n[r + s.length] !== xl) return 0;
const o = i?.get(r + s.length);
if (o === void 0 || e.startsWith(s, t)) return 0;
oo.lastIndex = 0;
const a = oo.exec(o)?.[0];
return a !== void 0 && e.startsWith(a, t) ? s.length : 0;
}
-function x2(e, t) {
+function P2(e, t) {
return e.map((n) => ({
...n,
liveStart: n.liveStart - t,
liveEnd: n.liveEnd - t
}));
}
-function T2(e, t, n) {
- const r = new Jh(), i = /* @__PURE__ */ new Map();
- return lv(e, 0, t, r, { prefix: !1, spellings: n, literals: i }), { alignment: { segments: r.segments }, literals: i };
+function A2(e, t, n) {
+ const r = new eg(), i = /* @__PURE__ */ new Map();
+ return hv(e, 0, t, r, { prefix: !1, spellings: n, literals: i }), { alignment: { segments: r.segments }, literals: i };
}
function ec(e, t) {
return t === "live" ? {
@@ -25791,13 +25845,13 @@ function ec(e, t) {
otherEnd: e.liveEnd
};
}
-function uv(e, t, n) {
+function gv(e, t, n) {
return e.segments.find((r) => {
const { start: i, end: s } = ec(r, n);
return i <= t && t < s;
});
}
-function fv(e, t) {
+function mv(e, t) {
let n = 0, r = 0;
for (const i of e.segments) {
const { end: s, otherEnd: o } = ec(i, t);
@@ -25805,34 +25859,34 @@ function fv(e, t) {
}
return [n, r];
}
-function Yh(e, t, n) {
- const r = uv(e, t, n);
+function tg(e, t, n) {
+ const r = gv(e, t, n);
if (r) {
const { start: o, otherStart: a } = ec(r, n);
return r.same ? a + (t - o) : void 0;
}
- const [i, s] = fv(e, n);
+ const [i, s] = mv(e, n);
return t === i ? s : void 0;
}
-function Lo(e, t, n) {
- const r = uv(e, t, n);
+function qo(e, t, n) {
+ const r = gv(e, t, n);
if (r) {
const { start: i, otherStart: s } = ec(r, n);
return r.same ? s + (t - i) : s;
}
- return fv(e, n)[1];
+ return mv(e, n)[1];
}
-function C2(e, t) {
- const n = Lo(e, t, "settled"), r = e.segments.find(
+function w2(e, t) {
+ const n = qo(e, t, "settled"), r = e.segments.find(
(i) => i.nesting && i.settledStart === t && i.settledEnd === t && i.liveEnd === n
);
return r ? r.liveStart : n;
}
const Wn = /\s/;
-function v2(e, t) {
+function N2(e, t) {
return `\\${e} ${t}\\${e}*`;
}
-function $d(e) {
+function Id(e) {
const t = [];
for (const r of e.spans)
for (let i = r.start; i < r.end; i += 1) {
@@ -25842,22 +25896,22 @@ function $d(e) {
const n = e.spans.filter((r) => r.isSentinel).map((r) => r.start);
return { bytes: t, placeholders: n };
}
-function Ic({ bytes: e }, t) {
+function Lc({ bytes: e }, t) {
return e.filter((n) => n.position < t && !n.isWs).length;
}
-function S2({ bytes: e }, t) {
+function O2({ bytes: e }, t) {
let n = 0;
for (const r of e) r.position < t && (n = r.isWs ? n + 1 : 0);
return n;
}
-function Rd({ bytes: e }) {
+function Ld({ bytes: e }) {
return e.filter((t) => !t.isWs);
}
-const Qy = "cat", _2 = "category";
-function E2(e) {
- return T(e) && e.getTextContent().trim() === "";
+const rb = "cat", $2 = "category";
+function R2(e) {
+ return C(e) && e.getTextContent().trim() === "";
}
-function M2(e) {
+function I2(e) {
const t = { text: "", spans: [], sentinels: [] }, n = [], r = (a, c) => {
t.spans.push({
key: a.getKey(),
@@ -25866,10 +25920,10 @@ function M2(e) {
isSentinel: !1
}), t.text += c;
}, i = (a, c) => {
- r(a, v2(Qy, c)), n.push({
+ r(a, N2(rb, c)), n.push({
ownerKey: a.getKey(),
- markerName: Qy,
- keyName: _2,
+ markerName: rb,
+ keyName: $2,
valueLength: c.length
});
}, s = (a) => {
@@ -25878,46 +25932,46 @@ function M2(e) {
const f = Dt(a);
let d = !1;
for (const p of a.getChildren())
- u !== void 0 && d && !E2(p) && (i(a, u), u = void 0), o(p), (Ut(p) || f && (f.is(p) || p.isParentOf(f))) && (d = !0);
+ u !== void 0 && d && !R2(p) && (i(a, u), u = void 0), o(p), (Bt(p) || f && (f.is(p) || p.isParentOf(f))) && (d = !0);
u !== void 0 && i(a, u);
}, o = (a) => {
- if (Ut(a)) {
+ if (Bt(a)) {
const c = a.getParent();
r(a, K(c) ? c.getCaller() : "");
- } else T(a) || Yt(a) ? r(a, a.getTextContent()) : K(a) ? s(a) : A(a) && a.getChildren().forEach(o);
+ } else C(a) || Yt(a) ? r(a, a.getTextContent()) : K(a) ? s(a) : A(a) && a.getChildren().forEach(o);
};
return e.forEach(o), { spelling: t, foldedAttributes: n };
}
-function Xh(e) {
- const t = $d(e);
+function ng(e) {
+ const t = Id(e);
return {
runs: e.sentinels.map((n, r) => {
- const { spelling: i, foldedAttributes: s } = M2(n);
+ const { spelling: i, foldedAttributes: s } = I2(n);
return {
memberCount: n.length,
- before: Ic(t, t.placeholders[r] ?? e.text.length),
+ before: Lc(t, t.placeholders[r] ?? e.text.length),
spelling: i,
foldedAttributes: s,
- spelled: Rd($d(i)).map(({ byte: o }) => o).join("")
+ spelled: Ld(Id(i)).map(({ byte: o }) => o).join("")
};
}),
- bytes: Rd(t).map(({ byte: n }) => n).join("")
+ bytes: Ld(t).map(({ byte: n }) => n).join("")
};
}
-function kl(e, t) {
+function Tl(e, t) {
return {
- facts: $d(e),
+ facts: Id(e),
carried: e.sentinels.map((n, r) => {
const i = new Set(t[r]?.map((s) => s.getKey()));
return n.map((s) => i.has(s.getKey()));
})
};
}
-function xl(e, t) {
+function Cl(e, t) {
const n = e.carried.map(
(d) => d.map(() => {
})
- ), r = Rd(e.facts), { alignment: i, literals: s } = T2(
+ ), r = Ld(e.facts), { alignment: i, literals: s } = A2(
r.map(({ byte: d }) => d).join(""),
t.bytes,
new Map(t.runs.map((d) => [d.before, d.spelled]))
@@ -25942,19 +25996,19 @@ function xl(e, t) {
e.carried.forEach((d, p) => {
const m = e.facts.placeholders[p];
if (m === void 0 || a(d) === 0) return;
- const h = Yh(i, Ic(e.facts, m), "live"), g = h === void 0 ? void 0 : u.get(h);
+ const h = tg(i, Lc(e.facts, m), "live"), g = h === void 0 ? void 0 : u.get(h);
g === void 0 || t.runs[g].memberCount !== a(d) || o(p, g);
});
const f = [];
for (const [d, p] of s) {
const m = u.get(d);
if (m === void 0) continue;
- const h = t.runs[m], g = r[p.liveStart]?.position ?? Number.POSITIVE_INFINITY, y = p.liveEnd > p.liveStart ? r[p.liveEnd - 1].position + 1 : g, b = Ic(e.facts, g);
+ const h = t.runs[m], g = r[p.liveStart]?.position ?? Number.POSITIVE_INFINITY, y = p.liveEnd > p.liveStart ? r[p.liveEnd - 1].position + 1 : g, b = Lc(e.facts, g);
f.push({
sentinelIndex: m,
liveBefore: b,
- liveLength: Ic(e.facts, y) - b,
- liveWsBefore: S2(e.facts, g),
+ liveLength: Lc(e.facts, y) - b,
+ liveWsBefore: O2(e.facts, g),
settledBefore: h.before,
spelling: h.spelling,
inner: p.inner,
@@ -25965,7 +26019,7 @@ function xl(e, t) {
}
function tc(e, t, n) {
return {
- nonWsBefore: Lo(
+ nonWsBefore: qo(
e,
t.nonWsBefore,
n === "toSettled" ? "live" : "settled"
@@ -25973,19 +26027,19 @@ function tc(e, t, n) {
wsRun: t.wsRun
};
}
-function dv(e, t, n) {
- return Yh(e.inner, t, n === "toSpelling" ? "live" : "settled");
+function yv(e, t, n) {
+ return tg(e.inner, t, n === "toSpelling" ? "live" : "settled");
}
-function pv(e, t) {
+function bv(e, t) {
return e.find(
(n) => t.nonWsBefore === n.liveBefore && t.wsRun >= n.liveWsBefore
);
}
-function Qh(e, t) {
+function rg(e, t) {
for (const n of e) {
const r = t.nonWsBefore - n.liveBefore;
if (r <= 0 || r >= n.liveLength) continue;
- const i = dv(n, r, "toSpelling");
+ const i = yv(n, r, "toSpelling");
return {
run: n,
count: r,
@@ -25993,7 +26047,7 @@ function Qh(e, t) {
};
}
}
-function gu(e, t) {
+function bu(e, t) {
const n = /* @__PURE__ */ new Map();
e.sentinels.forEach(
(r, i) => r.forEach(
@@ -26005,7 +26059,7 @@ function gu(e, t) {
if (i) return i;
}
}
-function mu(e, t) {
+function ku(e, t) {
const n = [];
for (let r = t; r; r = r.getParent()) {
if (r.is(e)) return n;
@@ -26013,14 +26067,14 @@ function mu(e, t) {
}
}
const Ot = Wa;
-function hv(e) {
- return e.length > 1 && e.startsWith(U) && e.charAt(1) !== Ot ? e.slice(1) : e;
+function kv(e) {
+ return e.length > 1 && e.startsWith(B) && e.charAt(1) !== Ot ? e.slice(1) : e;
}
-function Zy(e) {
- return wo(e) ? e.markerSyntax ?? "opening" : void 0;
+function ib(e) {
+ return No(e) ? e.markerSyntax ?? "opening" : void 0;
}
-function gv(e, t, n, r) {
- const i = { ...r, noteMode: "expanded" }, s = pr.serializeEditorState(
+function xv(e, t, n, r) {
+ const i = { ...r, noteMode: "expanded" }, s = hr.serializeEditorState(
{
type: fr,
version: ur,
@@ -26039,16 +26093,16 @@ function gv(e, t, n, r) {
).root.children, o = s.length === 1 ? s[0] : void 0, a = Array.isArray(o?.children) ? o.children : void 0;
if (!a) return { failure: "shape" };
let c = 0;
- for (; Zy(a[c]) === "opening"; ) c++;
+ for (; ib(a[c]) === "opening"; ) c++;
if (a[c]?.text !== qt(e.getCaller())) return { failure: "caller" };
c++;
let u = a.length;
- for (; u > c && Zy(a[u - 1]) === "closing"; )
+ for (; u > c && ib(a[u - 1]) === "closing"; )
u--;
const f = a.slice(c, u);
return f.length === 0 ? { failure: "empty" } : { children: f };
}
-function mv(e, t) {
+function Tv(e, t) {
if (e.getUnknownAttributes()?.closed !== "false") return;
const n = `${e.getMarker()}*`, r = t.findIndex(
(i) => typeof i == "object" && i.type === "unmatched" && i.marker === n
@@ -26056,10 +26110,10 @@ function mv(e, t) {
if (!(r < 0))
return { before: t.slice(0, r), after: t.slice(r + 1) };
}
-function yv(e, t, n, r, i) {
+function Cv(e, t, n, r, i) {
const s = Object.fromEntries(
Object.entries(e.getUnknownAttributes() ?? {}).filter(([u]) => u !== "closed")
- ), o = pr.serializeEditorState(
+ ), o = hr.serializeEditorState(
{
type: fr,
version: ur,
@@ -26082,26 +26136,26 @@ function yv(e, t, n, r, i) {
]
},
i
- ).root.children, a = o.length === 1 ? o[0] : void 0, c = Array.isArray(a?.children) ? a.children : void 0, l = c?.findIndex((u) => u.type === at.getType()) ?? -1;
+ ).root.children, a = o.length === 1 ? o[0] : void 0, c = Array.isArray(a?.children) ? a.children : void 0, l = c?.findIndex((u) => u.type === lt.getType()) ?? -1;
if (!(!c || l < 0))
return c.slice(l);
}
-function bv(e, t, n, r) {
+function vv(e, t, n, r) {
const i = e.getCode(), s = {
...e.getUnknownAttributes(),
type: "book",
marker: e.getMarker(),
...i !== "" && { code: i },
content: t
- }, [o, ...a] = pr.serializeEditorState(
+ }, [o, ...a] = hr.serializeEditorState(
{ type: fr, version: ur, content: [s, ...n] },
r
).root.children;
- if (!Bp(o)) return { failure: "shape" };
- const c = Sx(o.children[0]) ? o.children.slice(1) : o.children;
+ if (!jp(o)) return { failure: "shape" };
+ const c = Px(o.children[0]) ? o.children.slice(1) : o.children;
return c.length === 0 && a.length === 0 ? { failure: "empty" } : { children: c, followingBlocks: a };
}
-function Jo(e, t, n) {
+function Yo(e, t, n) {
e.spans.push({
key: t.getKey(),
start: e.text.length,
@@ -26109,9 +26163,9 @@ function Jo(e, t, n) {
isSentinel: !1
}), e.text += n;
}
-function Yo(e, t) {
- const n = cv.exec(e.text)?.[0];
- n !== void 0 && (e.text += n === "\\" ? U : " "), e.spans.push({
+function Xo(e, t) {
+ const n = pv.exec(e.text)?.[0];
+ n !== void 0 && (e.text += n === "\\" ? B : " "), e.spans.push({
key: t[0].getKey(),
start: e.text.length,
end: e.text.length + 1,
@@ -26119,47 +26173,47 @@ function Yo(e, t) {
}), e.sentinels.push(t), e.text += Ot;
}
function rn(e) {
- return e.replaceAll(U, " ");
+ return e.replaceAll(B, " ");
}
-const P2 = `\\${U}${Ot}`;
-function kv(e) {
+const L2 = `\\${B}${Ot}`;
+function Sv(e) {
return e.forEach((t, n) => {
- typeof t == "string" ? e[n] = t.replaceAll(P2, `\\${Ot}`) : t.content && kv(t.content);
+ typeof t == "string" ? e[n] = t.replaceAll(L2, `\\${Ot}`) : t.content && Sv(t.content);
}), e;
}
-const xv = "\u2028";
-function Zh(e) {
- return e.replaceAll(xv, "");
+const _v = "\u2028";
+function ig(e) {
+ return e.replaceAll(_v, "");
}
-function eg(e) {
- return e ? xv : " ";
+function sg(e) {
+ return e ? _v : " ";
}
-function A2(e) {
+function q2(e) {
return K(e[0]) ? "note" : Le(e[0]) ? "verse" : "other";
}
-function qo(e, t) {
- return kv(
- Ul(Zh(e.text), {
+function Do(e, t) {
+ return Sv(
+ Fl(ig(e.text), {
...t,
- placeholders: e.sentinels.map(A2)
+ placeholders: e.sentinels.map(q2)
})
);
}
-function w2(e, t, n = !1, r = !1) {
- if (gt(t)) return rn(e);
- if (e === U && !r) return " ";
- const i = n && e.startsWith(U), s = i ? e.slice(1) : e, o = n && !i ? N2.exec(s) : null;
- return o ? `${o[0]} ${s.slice(o[0].length + 1).replaceAll(U, "~")}` : (i ? " " : "") + s.replaceAll(U, "~");
+function D2(e, t, n = !1, r = !1) {
+ if (mt(t)) return rn(e);
+ if (e === B && !r) return " ";
+ const i = n && e.startsWith(B), s = i ? e.slice(1) : e, o = n && !i ? K2.exec(s) : null;
+ return o ? `${o[0]} ${s.slice(o[0].length + 1).replaceAll(B, "~")}` : (i ? " " : "") + s.replaceAll(B, "~");
}
-const N2 = /^[^\s\u200B\\|*]+(?=\u00A0)/;
-function fo(e) {
+const K2 = /^[^\s\u200B\\|*]+(?=\u00A0)/;
+function po(e) {
const t = e.getTextContent();
return an(e) && /^[\s\u00A0]*$/.test(t) ? " " : t;
}
-function yu(e, t) {
+function xu(e, t) {
const n = e[t];
if (!Ve(n)) return [];
- const { attribute: r, closing: i, wrapper: s } = Bl(n);
+ const { attribute: r, closing: i, wrapper: s } = jl(n);
if (s) return [s];
const o = n.getNextSibling();
if (!$(o) || o.getMarkerSyntax() !== "opening" || o.getMarker() !== n.getMarker())
@@ -26167,10 +26221,10 @@ function yu(e, t) {
const a = [o];
return r && a.push(r), i && a.push(i), a;
}
-function Tv(e) {
+function Ev(e) {
return e.some((t) => t.getTextContent().length > 0);
}
-function bu(e, t) {
+function Tu(e, t) {
const n = [];
let r = e[t];
for (const i of ["va", "vp"]) {
@@ -26184,61 +26238,61 @@ function bu(e, t) {
}
return n;
}
-function tg(e) {
+function og(e) {
return !!e.getUnknownAttributes();
}
-function ku(e, t) {
+function Cu(e, t) {
const n = t(e)?.type;
- return n === v.Milestone || n === void 0 && vp(e);
+ return n === v.Milestone || n === void 0 && _p(e);
}
-function ng(e) {
+function ag(e) {
return e.getIsCollapsed() !== !1 || e.getChildren().some((n) => $(n) && n.getMode() === "token") || Object.keys(e.getUnknownAttributes() ?? {}).some((n) => n !== "closed") ? !1 : e.getChildren().some((n) => {
if (!$(n) || Sr(n)) return !1;
if (n.getMarkerSyntax() !== "opening") return !0;
- const r = n.getTextContent(), i = (Io.exec(r) ?? ov.exec(r))?.[1];
- return i === void 0 || i.startsWith("+") || !at.isValidMarker(i) || n.getMarker() !== e.getMarker();
+ const r = n.getTextContent(), i = (Lo.exec(r) ?? fv.exec(r))?.[1];
+ return i === void 0 || i.startsWith("+") || !lt.isValidMarker(i) || n.getMarker() !== e.getMarker();
});
}
-function xu(e, t) {
- return Ve(e) ? !ku(e.getMarker(), t) : K(e) ? !ng(e) : Ie(e) ? !0 : Le(e) ? tg(e) : z(e) ? Cv(e, t) : !1;
+function vu(e, t) {
+ return Ve(e) ? !Cu(e.getMarker(), t) : K(e) ? !ag(e) : Ie(e) ? !0 : Le(e) ? og(e) : z(e) ? Mv(e, t) : !1;
}
-function Cv(e, t) {
- return vv(e, e.getMarker(), t);
+function Mv(e, t) {
+ return Pv(e, e.getMarker(), t);
}
-function vv(e, t, n) {
- return rM(e) ? !0 : ME(t) || n(t) !== void 0 || O2(e) && !$2(e) ? !1 : t !== e.getMarker() || !R2(e);
+function Pv(e, t, n) {
+ return cM(e) ? !0 : OE(t) || n(t) !== void 0 || B2(e) && !U2(e) ? !1 : t !== e.getMarker() || !F2(e);
}
-function O2(e) {
+function B2(e) {
const t = e.getParent();
return t !== null && hn(t) !== void 0;
}
-function $2(e) {
+function U2(e) {
const t = e.getUnknownAttributes();
return !!t && Object.keys(t).some((n) => n !== "closed");
}
-function R2(e) {
+function F2(e) {
const t = e.getChildren().filter((i) => $(i) && i.getMarker() === e.getMarker()).filter($);
if (t.some((i) => !Sr(i))) return !0;
const n = t.some((i) => i.getMarkerSyntax() === "opening"), r = t.some((i) => i.getMarkerSyntax() === "closing");
return !n && r;
}
-function Sv(e) {
+function Av(e) {
let t = e, n = t.getParent();
- for (; !t.getNextSibling() && ge(n); )
+ for (; !t.getNextSibling() && me(n); )
t = n, n = t.getParent();
let r = t.getNextSibling();
- for (; ge(r); ) r = r.getFirstChild();
+ for (; me(r); ) r = r.getFirstChild();
return Le(r);
}
const Cn = "", vn = "";
-function eb(e) {
+function sb(e) {
return e.flatMap((t) => He(t) ? t.getChildren() : [t]);
}
-function I2(e) {
+function z2(e) {
const t = [], n = /* @__PURE__ */ new Set();
let r = !1;
const i = (s) => {
- if (ge(s)) {
+ if (me(s)) {
r = !0, s.getChildren().forEach(i), r = !0;
return;
}
@@ -26246,15 +26300,15 @@ function I2(e) {
};
return e.forEach(i), { nodes: t, splitByMark: n };
}
-function L2(e, t) {
- return T(e) && !Et(e) && !Le(e) && !$(e) && !bn(e) && !xu(e, t) && Te(e, _e) !== "attribute";
+function j2(e, t) {
+ return C(e) && !Et(e) && !Le(e) && !$(e) && !bn(e) && !vu(e, t) && Te(e, _e) !== "attribute";
}
function no(e, t, n, r = !1, i) {
for (let s = 0; s < e.length; s++) {
const o = e[s];
if (Ve(o)) {
- const a = yu(e, s);
- ku(o.getMarker(), n) && Tv(a) ? (t.push(
+ const a = xu(e, s);
+ Cu(o.getMarker(), n) && Ev(a) ? (t.push(
Cn,
"ms",
// `marker` is part of the state for the same reason the attributes below are, and it is
@@ -26279,10 +26333,10 @@ function no(e, t, n, r = !1, i) {
unknownAttributes: o.getUnknownAttributes() ?? null,
attributeOrder: o.getAttributeOrder() ?? null
})
- ), no(eb(a), t, n), t.push(vn)) : t.push(Ot), s += a.length;
+ ), no(sb(a), t, n), t.push(vn)) : t.push(Ot), s += a.length;
} else if (Le(o)) {
- const a = bu(e, s);
- tg(o) ? t.push(Ot) : (t.push(
+ const a = Tu(e, s);
+ og(o) ? t.push(Ot) : (t.push(
Cn,
"verse",
rn(o.getTextContent()),
@@ -26291,7 +26345,7 @@ function no(e, t, n, r = !1, i) {
altnumber: o.getAltnumber() ?? null,
pubnumber: o.getPubnumber() ?? null
})
- ), no(eb(a), t, n), t.push(vn)), s += a.length;
+ ), no(sb(a), t, n), t.push(vn)), s += a.length;
} else if ($(o))
t.push(Cn, "marker", rn(o.getTextContent()), vn);
else if (bn(o))
@@ -26302,34 +26356,34 @@ function no(e, t, n, r = !1, i) {
o.getMarker(),
vn
);
- else if (xu(o, n))
+ else if (vu(o, n))
t.push(Ot);
else if (Os(o))
- t.push(eg(Sv(o)));
+ t.push(sg(Av(o)));
else {
if (Et(o))
continue;
- if (T(o) && Te(o, _e) === "attribute")
+ if (C(o) && Te(o, _e) === "attribute")
t.push(
Cn,
"attribute",
- rn(fo(o)),
+ rn(po(o)),
vn
);
- else if (T(o)) {
- let a = fo(o);
+ else if (C(o)) {
+ let a = po(o);
if (r) {
let c = e[s + 1];
- for (; i?.has(c) && L2(c, n); )
- a += fo(c), s += 1, c = e[s + 1];
- a = hv(a);
+ for (; i?.has(c) && j2(c, n); )
+ a += po(c), s += 1, c = e[s + 1];
+ a = kv(a);
}
t.push(rn(a));
} else if (z(o)) {
t.push(Cn, "char", JSON.stringify(o.getUnknownAttributes() ?? null));
- const { nodes: a, splitByMark: c } = I2(o.getChildren());
+ const { nodes: a, splitByMark: c } = z2(o.getChildren());
no(a, t, n, !0, c), t.push(vn);
- } else ge(o) ? no(o.getChildren(), t, n, r) : A(o) ? (t.push(Cn, o.getType()), no(o.getChildren(), t, n), t.push(vn)) : t.push(Ot);
+ } else me(o) ? no(o.getChildren(), t, n, r) : A(o) ? (t.push(Cn, o.getType()), no(o.getChildren(), t, n), t.push(vn)) : t.push(Ot);
}
}
}
@@ -26345,30 +26399,30 @@ function Or(e) {
const { text: t } = e;
return typeof t == "string" ? t : void 0;
}
-function q2(e) {
+function V2(e) {
return e.$?.textType;
}
-function vi(e) {
+function Si(e) {
return e.type ?? "";
}
-function Tu(e, t, n) {
- return t === "closing" ? pt(e, n) : t === "selfClosing" ? pt("") : rt(e, n);
+function Su(e, t, n) {
+ return t === "closing" ? pt(e, n) : t === "selfClosing" ? pt("") : it(e, n);
}
-function Sf(e, t) {
+function Mf(e, t) {
const n = e[t];
- if (!(!n || vi(n) !== "attribute-run"))
+ if (!(!n || Si(n) !== "attribute-run"))
return Hn(n) ?? [];
}
function Fr(e, t) {
const n = [];
- return na(e, n, t), n.join("");
+ return ra(e, n, t), n.join("");
}
-function na(e, t, n, r = !1) {
+function ra(e, t, n, r = !1) {
for (let i = 0; i < e.length; i++) {
- const s = e[i], o = vi(s);
+ const s = e[i], o = Si(s);
if (o === "ms") {
- const l = s, u = Sf(e, i + 1);
- u && ku(l.marker ?? "", n) ? (t.push(
+ const l = s, u = Mf(e, i + 1);
+ u && Cu(l.marker ?? "", n) ? (t.push(
Cn,
"ms",
// `marker` mirrored from `$appendSignature`'s fold: a glyph RENAME leaves the displayed
@@ -26383,7 +26437,7 @@ function na(e, t, n, r = !1) {
unknownAttributes: l.unknownAttributes ?? null,
attributeOrder: l.attributeOrder ?? null
})
- ), na(u, t, n), t.push(vn), i += 1) : t.push(Ot);
+ ), ra(u, t, n), t.push(vn), i += 1) : t.push(Ot);
continue;
}
if (o === "verse") {
@@ -26402,9 +26456,9 @@ function na(e, t, n, r = !1) {
pubnumber: l.pubnumber ?? null
})
);
- let u = 0, f = Sf(e, i + 1 + u);
+ let u = 0, f = Mf(e, i + 1 + u);
for (; f; )
- na(f, t, n), u++, f = Sf(e, i + 1 + u);
+ ra(f, t, n), u++, f = Mf(e, i + 1 + u);
t.push(vn), i += u;
continue;
}
@@ -26414,19 +26468,19 @@ function na(e, t, n, r = !1) {
Cn,
"marker",
rn(
- Tu(l.marker ?? "", l.markerSyntax, l.nested)
+ Su(l.marker ?? "", l.markerSyntax, l.nested)
),
vn
);
continue;
}
if (o === "linebreak") {
- t.push(eg(_p(e[i + 1])));
+ t.push(sg(Mp(e[i + 1])));
continue;
}
if (o === "char") {
const l = s;
- t.push(Cn, "char", JSON.stringify(l.unknownAttributes ?? null)), na(Hn(s) ?? [], t, n, !0), t.push(vn);
+ t.push(Cn, "char", JSON.stringify(l.unknownAttributes ?? null)), ra(Hn(s) ?? [], t, n, !0), t.push(vn);
continue;
}
if (o === "note" || o === "unknown") {
@@ -26434,30 +26488,30 @@ function na(e, t, n, r = !1) {
continue;
}
if (o === "unmatched") {
- const l = LP(s) ? s.marker : "";
+ const l = UP(s) ? s.marker : "";
t.push(Cn, "unmatched", rn(Or(s) ?? ""), l), t.push(vn);
continue;
}
const a = Or(s);
if (a !== void 0 && Sa(s)) continue;
- if (a !== void 0 && q2(s) === "attribute") {
+ if (a !== void 0 && V2(s) === "attribute") {
t.push(Cn, "attribute", rn(a), vn);
continue;
}
if (a !== void 0) {
- t.push(rn(r ? hv(a) : a));
+ t.push(rn(r ? kv(a) : a));
continue;
}
const c = Hn(s);
- c ? (t.push(Cn, o), na(c, t, n), t.push(vn)) : t.push(Ot);
+ c ? (t.push(Cn, o), ra(c, t, n), t.push(vn)) : t.push(Ot);
}
}
-function Oi(e) {
+function $i(e) {
let t = 0;
for (const n of e) {
const r = Hn(n);
if (r) {
- t += Oi(r);
+ t += $i(r);
continue;
}
const i = Or(n);
@@ -26466,7 +26520,7 @@ function Oi(e) {
}
return t;
}
-function Eo(e, t, n, r, i) {
+function Mo(e, t, n, r, i) {
Kn(e.getChildren(), t, n, r, i);
}
function Kn(e, t, n, r, i) {
@@ -26477,50 +26531,50 @@ function Kn(e, t, n, r, i) {
for (let o = 0; o < e.length; o++) {
const a = e[o];
if ($(a))
- Jo(t, a, rn(a.getTextContent()));
+ Yo(t, a, rn(a.getTextContent()));
else if (Ve(a)) {
s();
- const c = yu(e, o);
- ku(a.getMarker(), n) && Tv(c) ? Kn(c, t, n, r) : Yo(t, [a, ...c]), o += c.length;
- } else if (K(a) && ng(a)) {
+ const c = xu(e, o);
+ Cu(a.getMarker(), n) && Ev(c) ? Kn(c, t, n, r) : Xo(t, [a, ...c]), o += c.length;
+ } else if (K(a) && ag(a)) {
s();
const c = Dt(a);
for (const l of a.getChildren())
- c?.is(l) ? Jo(t, l, rn(l.getTextContent())) : Kn([l], t, n, r);
+ c?.is(l) ? Yo(t, l, rn(l.getTextContent())) : Kn([l], t, n, r);
} else if (K(a) || Ie(a))
- s(), Yo(t, [a]);
+ s(), Xo(t, [a]);
else if (Le(a)) {
s();
- const c = bu(e, o);
- tg(a) ? Yo(t, [a, ...c]) : (Jo(t, a, rn(fo(a))), Kn(c, t, n, r)), o += c.length;
+ const c = Tu(e, o);
+ og(a) ? Xo(t, [a, ...c]) : (Yo(t, a, rn(po(a))), Kn(c, t, n, r)), o += c.length;
} else if (z(a))
- s(), Cv(a, n) ? Yo(t, [a]) : Eo(a, t, n, r, { pending: !0 });
+ s(), Mv(a, n) ? Xo(t, [a]) : Mo(a, t, n, r, { pending: !0 });
else if (Os(a))
- s(), Jo(t, a, eg(Sv(a)));
+ s(), Yo(t, a, sg(Av(a)));
else {
if (Et(a))
continue;
- if (T(a)) {
- const c = a.getParent(), l = an(a) || Te(a, _e) === "attribute" || Be(c) && !!jr(c)?.is(a), u = s() && !l;
- Jo(
+ if (C(a)) {
+ const c = a.getParent(), l = an(a) || Te(a, _e) === "attribute" || Fe(c) && !!Vr(c)?.is(a), u = s() && !l;
+ Yo(
t,
a,
- l ? rn(fo(a)) : w2(
- fo(a),
+ l ? rn(po(a)) : D2(
+ po(a),
r,
u,
- Ax(a)
+ $x(a)
)
);
- } else A(a) ? Eo(a, t, n, r, i) : (s(), Yo(t, [a]));
+ } else A(a) ? Mo(a, t, n, r, i) : (s(), Xo(t, [a]));
}
}
}
-function rg(e) {
+function cg(e) {
const [t] = e;
return ke(t) && t.getMarker() === "";
}
-function ig(e, t, n) {
+function lg(e, t, n) {
if (e.getUnknownAttributes()) return;
const r = t(e.getMarker())?.type;
if (r !== void 0 && r !== v.Unknown && r !== v.Paragraph)
@@ -26528,33 +26582,33 @@ function ig(e, t, n) {
for (let s = e.getParent(); s !== null; s = s.getParent())
if (Ie(s)) return;
const i = { text: "", spans: [], sentinels: [] };
- return Eo(e, i, t, n), i;
+ return Mo(e, i, t, n), i;
}
-function D2(e, t, n) {
+function W2(e, t, n) {
const r = { text: "", spans: [], sentinels: [] };
- return Eo(e, r, t, n), r;
+ return Mo(e, r, t, n), r;
}
-function sg(e, t, n) {
+function ug(e, t, n) {
if (e.length === 0 || !e.every(ke)) return;
const r = { text: "", spans: [], sentinels: [] };
- return og(r, e, t, n) ? r : void 0;
+ return fg(r, e, t, n) ? r : void 0;
}
-function Id(e, t, n) {
+function qd(e, t, n) {
const r = { text: "", spans: [], sentinels: [] };
for (const i of e)
if (ke(i)) {
- const s = ig(i, t, n);
+ const s = lg(i, t, n);
if (!s) return;
const o = r.text.length;
s.spans.forEach(
(a) => r.spans.push({ ...a, start: a.start + o, end: a.end + o })
), r.sentinels.push(...s.sentinels), r.text += s.text;
- } else Be(i) ? Kn(i.getChildren(), r, t, n) : Kn([i], r, t, n);
+ } else Fe(i) ? Kn(i.getChildren(), r, t, n) : Kn([i], r, t, n);
return r;
}
-function og(e, t, n, r) {
+function fg(e, t, n, r) {
for (const i of t) {
- const s = ig(i, n, r);
+ const s = lg(i, n, r);
if (!s) return !1;
e.text.length > 0 && (e.text += " ");
const o = e.text.length;
@@ -26564,10 +26618,10 @@ function og(e, t, n, r) {
}
return !0;
}
-function Cu(e, t) {
+function _u(e, t) {
let n = 0;
const r = (i) => {
- if (T(i)) {
+ if (C(i)) {
let s = i;
for (; s; ) {
const a = s.getTextContent().indexOf(Ot);
@@ -26591,33 +26645,33 @@ function Ra(e, t = []) {
Le(n) ? t.push(n) : A(n) && Ra(n.getChildren(), t);
return t;
}
-function vu(e) {
+function Eu(e) {
let t = 0;
const n = (r) => {
- if (T(r))
+ if (C(r))
for (const i of r.getTextContent()) i === Ot && t++;
else A(r) && r.getChildren().forEach(n);
};
return e.forEach(n), t;
}
-function ci(e) {
+function li(e) {
let t = 0;
for (const n of e)
if (typeof n == "string")
for (const r of n) r === Ot && t++;
- else n.content && (t += ci(n.content));
+ else n.content && (t += li(n.content));
return t;
}
-function Su(e, t, n, r = { text: "", spans: [], sentinels: [] }) {
+function Mu(e, t, n, r = { text: "", spans: [], sentinels: [] }) {
for (const i of e)
- r.text.length > 0 && (r.text += " "), A(i) && Eo(i, r, t, n);
+ r.text.length > 0 && (r.text += " "), A(i) && Mo(i, r, t, n);
return r;
}
-function _v(e, t, n, r) {
- const { out: i } = Pu(e, n, r);
- return Su(t, n, r, i);
+function wv(e, t, n, r) {
+ const { out: i } = Nu(e, n, r);
+ return Mu(t, n, r, i);
}
-function Si(e, t, n) {
+function _i(e, t, n) {
let r = 0, i = 0;
for (const s of e.spans) {
const o = s.end - s.start, a = s.key === t, c = a ? Math.min(s.isSentinel ? 1 : n, o) : o;
@@ -26626,33 +26680,33 @@ function Si(e, t, n) {
if (a) return { nonWsBefore: r, wsRun: i };
}
}
-function Ld(e, t) {
- t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => Ld(n, t));
+function Dd(e, t) {
+ t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => Dd(n, t));
}
-function ag(e, t, n) {
+function dg(e, t, n) {
return e.spans.find(
(r) => !r.isSentinel && r.key === t && n <= r.end - r.start
);
}
-function po(e, t, n) {
+function ho(e, t, n) {
const r = (f, d) => {
- const p = Si(e, f, d), m = ag(e, f, d);
+ const p = _i(e, f, d), m = dg(e, f, d);
return p && m ? { anchor: p, position: m.start + d } : void 0;
}, i = (f) => {
- const d = f.end - f.start, p = Si(e, f.key, d);
+ const d = f.end - f.start, p = _i(e, f.key, d);
return p ? { anchor: p, position: f.start + d } : void 0;
};
if (Et(t)) {
const f = t.getParent();
- return f ? po(e, f, t.getIndexWithinParent()) : void 0;
+ return f ? ho(e, f, t.getIndexWithinParent()) : void 0;
}
if (!A(t)) return r(t.getKey(), n);
const s = /* @__PURE__ */ new Set();
- t.getChildren().slice(0, n).forEach((f) => Ld(f, s));
+ t.getChildren().slice(0, n).forEach((f) => Dd(f, s));
const o = [...e.spans].reverse().find((f) => s.has(f.key));
if (o) return i(o);
const a = /* @__PURE__ */ new Set();
- Ld(t, a);
+ Dd(t, a);
const c = e.spans.find((f) => a.has(f.key));
if (c && !c.isSentinel) return r(c.key, 0);
const l = [...e.spans].reverse().find((f) => !a.has(f.key) && ee(f.key)?.isBefore(t));
@@ -26665,7 +26719,7 @@ function ao(e) {
const t = ee(e.key);
return $(t) && t.getMarkerSyntax() !== "opening";
}
-function qd(e) {
+function Kd(e) {
const t = ee(e.key);
if (!$(t)) return;
const n = t.getParent();
@@ -26678,15 +26732,15 @@ function qd(e) {
type: "element"
};
}
-function _f(e) {
+function Pf(e) {
const t = ee(e.key), n = t?.getParent(), r = n?.getChildren();
if (!t || !n || !r) return;
const i = r.findIndex((a) => a.is(t));
if (i < 0) return;
- const s = Le(t) ? bu(r, i) : Ve(t) ? yu(r, i) : [], o = s[s.length - 1] ?? t;
+ const s = Le(t) ? Tu(r, i) : Ve(t) ? xu(r, i) : [], o = s[s.length - 1] ?? t;
return { key: n.getKey(), offset: o.getIndexWithinParent() + 1, type: "element" };
}
-function An(e, t, {
+function wn(e, t, {
addressDisplayBytes: n = !1,
endAfterSkippedConstruct: r = !1
} = {}) {
@@ -26700,8 +26754,8 @@ function An(e, t, {
break;
}
for (let b = 0; b < g; b++) {
- const C = i[h.start + b];
- if (c === 0 && (l === 0 || !Wn.test(C))) {
+ const T = i[h.start + b];
+ if (c === 0 && (l === 0 || !Wn.test(T))) {
if (y) {
o = { key: h.key, offset: b };
break e;
@@ -26709,7 +26763,7 @@ function An(e, t, {
u = !0;
continue e;
}
- c > 0 ? Wn.test(C) || c-- : l--;
+ c > 0 ? Wn.test(T) || c-- : l--;
}
if (c === 0 && l === 0) {
const b = s[m + 1]?.isSentinel === !0;
@@ -26717,13 +26771,13 @@ function An(e, t, {
o = { key: h.key, offset: g };
break;
}
- const C = s[m + 1];
- if (r && !y && C && (C.isSentinel || ao(C))) {
- const x = h.isSentinel ? _f(h) : qd(h);
+ const T = s[m + 1];
+ if (r && !y && T && (T.isSentinel || ao(T))) {
+ const x = h.isSentinel ? Pf(h) : Kd(h);
if (x) return x;
}
if (h.isSentinel && b) {
- const x = _f(h);
+ const x = Pf(h);
if (x) return x;
}
y && (a = { key: h.key, offset: g }), u = !0;
@@ -26736,26 +26790,26 @@ function An(e, t, {
return { key: f.key, offset: f.end - f.start, type: "text" };
const d = s[s.length - 1];
if (d && ao(d)) {
- const m = qd(d);
+ const m = Kd(d);
if (m) return m;
}
if (d?.isSentinel) {
- const m = _f(d);
+ const m = Pf(d);
if (m) return m;
}
const p = [...s].reverse().find((m) => !m.isSentinel && !ao(m));
if (p) return { key: p.key, offset: p.end - p.start, type: "text" };
}
-function Ev(e, t = []) {
+function Nv(e, t = []) {
for (const n of e)
- ge(n) && t.push(n), A(n) && Ev(n.getChildren(), t);
+ me(n) && t.push(n), A(n) && Nv(n.getChildren(), t);
return t;
}
-function Mv(e, t = /* @__PURE__ */ new Set()) {
- return t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => Mv(n, t)), t;
+function Ov(e, t = /* @__PURE__ */ new Set()) {
+ return t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => Ov(n, t)), t;
}
-function K2(e, t, n) {
- const r = Si(e, t.key, n);
+function H2(e, t, n) {
+ const r = _i(e, t.key, n);
if (r)
return t.isSentinel ? {
kind: "preserved",
@@ -26765,13 +26819,13 @@ function K2(e, t, n) {
}
function nc(e, t, n = t.sentinels, r) {
const i = [];
- for (const o of Ev(e)) {
- const a = Mv(o), c = t.spans.filter((b) => a.has(b.key)), l = c[0], u = c[c.length - 1];
+ for (const o of Nv(e)) {
+ const a = Ov(o), c = t.spans.filter((b) => a.has(b.key)), l = c[0], u = c[c.length - 1];
if (!l || !u) continue;
- const f = K2(t, l, 0), d = Si(t, u.key, u.end - u.start);
+ const f = H2(t, l, 0), d = _i(t, u.key, u.end - u.start);
if (!f || !d) continue;
const p = o.getTypedOnClicks(), m = o.getTypedOnRemoves(), h = o.getTypedOnMouseEnters(), g = o.getTypedOnMouseLeaves(), y = Object.entries(o.getTypedIDs()).flatMap(
- ([b, C]) => C.map((x) => ({
+ ([b, T]) => T.map((x) => ({
type: b,
id: x,
onClick: p[b]?.[x],
@@ -26784,11 +26838,11 @@ function nc(e, t, n = t.sentinels, r) {
}
const s = (o) => {
const a = o.getKey();
- for (const c of Gr(o)) {
- if (c.start === c.end || !ag(t, a, c.start)) continue;
- const l = Si(t, a, c.start), u = Si(t, a, c.end);
+ for (const c of Jr(o)) {
+ if (c.start === c.end || !dg(t, a, c.start)) continue;
+ const l = _i(t, a, c.start), u = _i(t, a, c.end);
if (!l || !u) continue;
- const f = r && Zc(r, c.type, c.id);
+ const f = r && tl(r, c.type, c.id);
i.push({
annotations: [
{
@@ -26806,20 +26860,20 @@ function nc(e, t, n = t.sentinels, r) {
}
A(o) && o.getChildren().forEach(s);
};
- return e.forEach(s), { ranges: i, live: i.length > 0 ? kl(t, n) : void 0 };
+ return e.forEach(s), { ranges: i, live: i.length > 0 ? Tl(t, n) : void 0 };
}
-function U2(e, t, n) {
- const r = Pv(e);
+function G2(e, t, n) {
+ const r = $v(e);
if (!r) return;
const i = r[r.length - 1].getNextSibling();
- if (!ge(i) || !i.hasID(t, n)) return;
+ if (!me(i) || !i.hasID(t, n)) return;
const s = i.getFirstChild();
s && r.forEach((o) => s.insertBefore(o));
}
-function F2(e, t) {
- const n = Pv(e);
+function J2(e, t) {
+ const n = $v(e);
if (!n) return;
- const r = us();
+ const r = fs();
r.addID(
t.type,
t.id,
@@ -26829,53 +26883,53 @@ function F2(e, t) {
t.onMouseLeave
), n[0].insertBefore(r), r.append(...n);
}
-function Pv(e) {
+function $v(e) {
const t = ee(e), n = t?.getParent()?.getChildren();
if (!t || !n) return;
const r = n.findIndex((s) => s.is(t));
if (r < 0) return;
- const i = Le(t) ? bu(n, r) : Ve(t) ? yu(n, r) : [];
+ const i = Le(t) ? Tu(n, r) : Ve(t) ? xu(n, r) : [];
return [t, ...i];
}
-function Av(e, t, n, r) {
- const i = n.settledOnlyRuns, s = { addressDisplayBytes: r, endAfterSkippedConstruct: !r }, o = Qh(i, e);
+function Rv(e, t, n, r) {
+ const i = n.settledOnlyRuns, s = { addressDisplayBytes: r, endAfterSkippedConstruct: !r }, o = rg(i, e);
if (o) {
if (!o.within) return;
- const u = An(o.run.spelling, o.within, s);
+ const u = wn(o.run.spelling, o.within, s);
return u ? { point: u, at: o.within.nonWsBefore, literalRun: o.run.sentinelIndex } : void 0;
}
- const a = r && pv(i, e);
+ const a = r && bv(i, e);
if (a) {
const u = t.sentinels[a.sentinelIndex]?.[0]?.getKey(), f = {
nonWsBefore: a.settledBefore + 1,
wsRun: 0
- }, d = An(t, f, s);
+ }, d = wn(t, f, s);
return d && u ? { point: d, at: f.nonWsBefore, preservedKey: u } : void 0;
}
- const c = tc(n.alignment, e, "toSettled"), l = An(t, c, s);
+ const c = tc(n.alignment, e, "toSettled"), l = wn(t, c, s);
return l && { point: l, at: c.nonWsBefore };
}
-function B2(e, t, n) {
- if (e.kind === "byte") return Av(e.anchor, t, n, !0);
+function Y2(e, t, n) {
+ if (e.kind === "byte") return Rv(e.anchor, t, n, !0);
const r = n.sentinelMap[e.run]?.find((a) => a !== void 0), i = r && t.sentinels[r.sentinelIndex]?.[0]?.getKey();
if (!i) return;
- const s = tc(n.alignment, e.anchor, "toSettled"), o = An(t, s, { addressDisplayBytes: !0 });
+ const s = tc(n.alignment, e.anchor, "toSettled"), o = wn(t, s, { addressDisplayBytes: !0 });
return o && { point: o, at: s.nonWsBefore, preservedKey: i };
}
-function tb(e) {
+function ob(e) {
if (e.type !== "text") return e;
const t = ee(e.key);
- if (T(t)) return e;
+ if (C(t)) return e;
const n = t?.getParent();
if (!t || !n) return;
const r = t.getIndexWithinParent() + (e.offset > 0 ? 1 : 0);
return { key: n.getKey(), offset: r, type: "element" };
}
-function z2(e, t) {
+function X2(e, t) {
const n = (s) => {
if (s.type !== "text") return s;
const o = ee(s.key), a = o?.getParent();
- return !T(o) || !a ? s : s.offset === 0 ? { key: a.getKey(), offset: o.getIndexWithinParent(), type: "element" } : s.offset === o.getTextContentSize() ? { key: a.getKey(), offset: o.getIndexWithinParent() + 1, type: "element" } : s;
+ return !C(o) || !a ? s : s.offset === 0 ? { key: a.getKey(), offset: o.getIndexWithinParent(), type: "element" } : s.offset === o.getTextContentSize() ? { key: a.getKey(), offset: o.getIndexWithinParent() + 1, type: "element" } : s;
}, r = n(e), i = n(t);
return r.key === i.key && r.offset === i.offset && r.type === i.type;
}
@@ -26886,19 +26940,19 @@ function rc({ ranges: e, live: t }, n) {
for (const s of i.annotations) {
const o = n();
if (!o) continue;
- const a = xl(t, Xh(o)), c = B2(i.start, o, a), l = Av(i.end, o, a, !1);
+ const a = Cl(t, ng(o)), c = Y2(i.start, o, a), l = Rv(i.end, o, a, !1);
if (!c || !l || c.literalRun !== l.literalRun) continue;
const u = i.start.anchor;
if (c.at === l.at && u.nonWsBefore !== i.end.nonWsBefore && !c.preservedKey)
continue;
- const { preservedKey: f } = c, d = tb(c.point), p = tb(l.point);
+ const { preservedKey: f } = c, d = ob(c.point), p = ob(l.point);
if (!d || !p) continue;
- if (z2(d, p)) {
- f && F2(f, s);
+ if (X2(d, p)) {
+ f && J2(f, s);
continue;
}
const m = dr();
- m.anchor.set(d.key, d.offset, d.type), m.focus.set(p.key, p.offset, p.type), sh(
+ m.anchor.set(d.key, d.offset, d.type), m.focus.set(p.key, p.offset, p.type), ah(
m,
s.type,
s.id,
@@ -26906,11 +26960,11 @@ function rc({ ranges: e, live: t }, n) {
s.onRemove,
s.onMouseEnter,
s.onMouseLeave
- ), f && U2(f, s.type, s.id);
+ ), f && G2(f, s.type, s.id);
}
Mt(r);
}
-function cg(e, t, n) {
+function pg(e, t, n) {
if (n <= t) return e;
const r = n - t, i = (s) => s <= t ? s : s >= n ? s - r : t;
return {
@@ -26923,28 +26977,28 @@ function cg(e, t, n) {
sentinels: e.sentinels
};
}
-function wv(e, t) {
+function Iv(e, t) {
return e.sentinels.filter((r, i) => r.length > 0 && (t[i]?.length ?? 0) === 0).map((r) => r[0].getKey()).reverse().reduce((r, i) => {
const s = r.spans.find((o) => o.isSentinel && o.key === i);
- return s ? cg(r, s.start, s.end) : r;
+ return s ? pg(r, s.start, s.end) : r;
}, e);
}
-function Ki(e) {
+function Bi(e) {
const t = e.exportJSON();
- return A(e) && Array.isArray(t.children) && e.getChildren().forEach((n) => t.children?.push(Ki(n))), t;
+ return A(e) && Array.isArray(t.children) && e.getChildren().forEach((n) => t.children?.push(Bi(n))), t;
}
-function _u(e, t, n) {
- const r = e.find(Be);
- if (!r) return Id(e, t, n);
+function Pu(e, t, n) {
+ const r = e.find(Fe);
+ if (!r) return qd(e, t, n);
const i = new Set(
- [r, ...ri(r)].map((s) => s.getKey())
+ [r, ...ii(r)].map((s) => s.getKey())
);
- return e.every((s) => i.has(s.getKey())) ? fg(r, t, n) : Id(e, t, n);
+ return e.every((s) => i.has(s.getKey())) ? mg(r, t, n) : qd(e, t, n);
}
-function Eu(e, t, n, r, i, s, o) {
+function Au(e, t, n, r, i, s, o) {
const a = nc(
e,
- wv(t, n),
+ Iv(t, n),
n
);
if (a.ranges.length === 0) return r;
@@ -26954,16 +27008,16 @@ function Eu(e, t, n, r, i, s, o) {
...f,
annotations: f.annotations.map(({ type: d, id: p }) => ({ type: d, id: p }))
}))
- }, l = hp({
- nodes: [vt, ...au],
+ }, l = mp({
+ nodes: [vt, ...lu],
onError: (f) => {
throw f;
}
});
- gp(
+ yp(
l,
vt,
- (f) => us(f.getTypedIDs()),
+ (f) => fs(f.getTypedIDs()),
(f, d) => Object.entries(f.getTypedIDs()).forEach(
([p, m]) => m.forEach((h) => d.addID(p, h))
)
@@ -26971,15 +27025,15 @@ function Eu(e, t, n, r, i, s, o) {
let u;
return l.update(
() => {
- const f = Me(), d = i === "noteContent" ? qn() : f;
+ const f = Me(), d = i === "noteContent" ? En() : f;
d !== f && f.append(d), u = d.getKey(), r.forEach((m) => d.append(Ir(m))), rc(c, () => {
const m = d.getChildren();
- if (i === "paras") return Su(m, s, o);
+ if (i === "paras") return Mu(m, s, o);
if (i === "chapter")
- return _u(m, s, o);
+ return Pu(m, s, o);
if (i === "bookLine") {
const [g, ...y] = m;
- return qe(g) ? _v(g, y, s, o) : void 0;
+ return qe(g) ? wv(g, y, s, o) : void 0;
}
const h = { text: "", spans: [], sentinels: [] };
return Kn(m, h, s, o), h;
@@ -26988,22 +27042,22 @@ function Eu(e, t, n, r, i, s, o) {
{ discrete: !0 }
), l.getEditorState().read(() => {
const f = u === void 0 ? void 0 : ee(u);
- return A(f) ? f.getChildren().map(Ki) : r;
+ return A(f) ? f.getChildren().map(Bi) : r;
});
}
-function Dd(e) {
+function Bd(e) {
const t = ee(e.key);
if (!t?.isAttached()) return !1;
if (e.type === "text")
- return T(t) ? (t.select(e.offset, e.offset), !0) : !1;
+ return C(t) ? (t.select(e.offset, e.offset), !0) : !1;
if (!A(t)) return !1;
const n = dr();
return n.anchor.set(e.key, e.offset, "element"), n.focus.set(e.key, e.offset, "element"), Mt(n), !0;
}
-function j2(e, t, n) {
- const r = An(e, t);
+function Q2(e, t, n) {
+ const r = wn(e, t);
if (r?.type === "text") {
- if (Dd(r)) return;
+ if (Bd(r)) return;
} else if (r) {
const i = ee(r.key), s = A(i) ? i.getChildAtIndex(r.offset - 1) : void 0;
if (s) {
@@ -27013,13 +27067,13 @@ function j2(e, t, n) {
}
n.find(A)?.selectStart();
}
-function Mu(e, t) {
- const n = t.getNode(), r = gu(e, n), i = r && mu(r.member, n);
+function wu(e, t) {
+ const n = t.getNode(), r = bu(e, n), i = r && ku(r.member, n);
return {
// An element point (a click past a paragraph's trailing note) has no span of its own, and
// neither does a caret host, so each is spelled from the child bytes beside it, the same way a
// settled position spells one.
- anchor: t.type === "element" || Et(n) ? po(e, n, t.offset)?.anchor : Si(e, t.key, t.offset),
+ anchor: t.type === "element" || Et(n) ? ho(e, n, t.offset)?.anchor : _i(e, t.key, t.offset),
inRun: r && i ? {
sentinelIndex: r.sentinelIndex,
memberIndex: r.memberIndex,
@@ -27027,51 +27081,51 @@ function Mu(e, t) {
offset: t.offset,
type: t.type
} : void 0,
- live: kl(e, e.sentinels)
+ live: Tl(e, e.sentinels)
};
}
-function Nv(e, t, n) {
- const r = t && xl(t.live, Xh(e));
+function Lv(e, t, n) {
+ const r = t && Cl(t.live, ng(e));
if (t?.inRun && r) {
const { sentinelIndex: o, memberIndex: a, path: c, offset: l, type: u } = t.inRun, f = r.sentinelMap[o]?.[a];
let d = f && e.sentinels[f.sentinelIndex]?.[f.memberIndex];
for (const p of c)
d = A(d) ? d.getChildAtIndex(p) ?? void 0 : void 0;
- if (d && Dd({ key: d.getKey(), offset: l, type: u })) return;
+ if (d && Bd({ key: d.getKey(), offset: l, type: u })) return;
}
if (!t?.anchor || !r) {
n.find(A)?.selectStart();
return;
}
- const { anchor: i } = t, s = Qh(r.settledOnlyRuns, i);
+ const { anchor: i } = t, s = rg(r.settledOnlyRuns, i);
if (s) {
const o = s.within ?? {
- nonWsBefore: Lo(s.run.inner, s.count, "live"),
+ nonWsBefore: qo(s.run.inner, s.count, "live"),
wsRun: i.wsRun
- }, a = An(s.run.spelling, o);
- if (a && Dd(a)) return;
+ }, a = wn(s.run.spelling, o);
+ if (a && Bd(a)) return;
}
- j2(
+ Q2(
e,
tc(r.alignment, i, "toSettled"),
n
);
}
-function Ov(e, t, n, r, i) {
- n && Nv(Su(e, r, i), t, e);
+function qv(e, t, n, r, i) {
+ n && Lv(Mu(e, r, i), t, e);
}
-function $v(e, t, n, r, i) {
+function Dv(e, t, n, r, i) {
if (!n) return;
if (!t?.anchor && !t?.inRun) {
- V2(e, r);
+ Z2(e, r);
return;
}
const s = { text: "", spans: [], sentinels: [] };
- Kn(e, s, r, i), Nv(s, t, e);
+ Kn(e, s, r, i), Lv(s, t, e);
}
-function V2(e, t) {
+function Z2(e, t) {
const n = e.find(A);
- if (n && xu(n, t)) {
+ if (n && vu(n, t)) {
const r = n.getParent();
if (r) {
const i = n.getIndexWithinParent();
@@ -27081,9 +27135,9 @@ function V2(e, t) {
}
n?.selectStart();
}
-function Rv(e, t) {
+function Kv(e, t) {
if (e.length === 0) return !1;
- const { viewOptions: n, getMarker: r, logger: i } = t, s = sg(e, r, n);
+ const { viewOptions: n, getMarker: r, logger: i } = t, s = ug(e, r, n);
if (!s)
return i?.debug("[MarkerEdit] Tier 2 skipped: paragraph excluded by guard rails"), !1;
let o, a = !1;
@@ -27094,37 +27148,37 @@ function Rv(e, t) {
a = !0;
break;
}
- c.isCollapsed() && (o = Mu(s, c.anchor));
+ c.isCollapsed() && (o = wu(s, c.anchor));
}
- const l = nc(e, s, void 0, Pt()), u = qo(s, {
+ const l = nc(e, s, void 0, Pt()), u = Do(s, {
getMarker: r,
- opensNamelessParagraph: rg(e)
+ opensNamelessParagraph: cg(e)
});
if (u.length === 0)
return i?.debug("[MarkerEdit] Tier 2 skipped: tokenizer produced no content"), !1;
- if (ci(u) !== s.sentinels.length)
+ if (li(u) !== s.sentinels.length)
return i?.warn("[MarkerEdit] Tier 2 aborted: sentinel/preserved-node count mismatch"), !1;
- const f = pr.serializeEditorState(
+ const f = hr.serializeEditorState(
{ type: fr, version: ur, content: u },
n
);
if (Fr(f.root.children, r) === Ur(e, r))
return i?.debug("[MarkerEdit] Tier 2 skipped: rebuild is a no-op (fixed point)"), !1;
const d = f.root.children.map((g) => Ir(g));
- if (vu(d) !== s.sentinels.length)
+ if (Eu(d) !== s.sentinels.length)
return i?.warn("[MarkerEdit] Tier 2 aborted: serialized sentinel/preserved-node count mismatch"), !1;
const p = Ra(e).map((g) => ({
number: g.getNumber(),
sid: g.getSid()
})), m = e[0];
- d.forEach((g) => m.insertBefore(g)), Cu(d, s.sentinels), e.forEach((g) => g.remove());
+ d.forEach((g) => m.insertBefore(g)), _u(d, s.sentinels), e.forEach((g) => g.remove());
const h = Ra(d);
for (let g = 0; g < p.length && g < h.length; g++)
h[g].getNumber() === p[g].number && h[g].setSid(p[g].sid);
- return rc(l, () => Su(d, r, n)), Ov(d, o, a, r, n), !0;
+ return rc(l, () => Mu(d, r, n)), qv(d, o, a, r, n), !0;
}
-function W2(e) {
- if (e.getIsCollapsed() !== !1 || !at.isValidMarker(e.getMarker())) return;
+function eL(e) {
+ if (e.getIsCollapsed() !== !1 || !lt.isValidMarker(e.getMarker())) return;
const t = e.getChildren();
let n = 0;
for (; n < t.length; ) {
@@ -27133,7 +27187,7 @@ function W2(e) {
n++;
}
const r = t[n];
- if (!r || !(Ut(r) || T(r) && r.getTextContent() === qt(e.getCaller()))) return;
+ if (!r || !(Bt(r) || C(r) && r.getTextContent() === qt(e.getCaller()))) return;
n++;
let s = t.length;
for (; s > n; ) {
@@ -27144,16 +27198,16 @@ function W2(e) {
return t.slice(n, s);
}
function vs(e, t, n) {
- const r = W2(e);
+ const r = eL(e);
if (!r) return;
const i = { text: "", spans: [], sentinels: [] };
return Kn(r, i, t, n), { out: i, contentNodes: r };
}
-function lg(e, t, n) {
+function hg(e, t, n) {
const r = { text: "", spans: [], sentinels: [] };
return Kn(e, r, t, n), r;
}
-function Iv(e) {
+function Bv(e) {
const t = e[0];
if (typeof t != "object" || t.type !== "char" || t.marker !== "cat" || !Object.keys(t).every((s) => s === "type" || s === "marker" || s === "content") || !t.content || t.content.length !== 1) return;
const r = t.content[0];
@@ -27162,7 +27216,7 @@ function Iv(e) {
if (i !== "")
return e.shift(), i;
}
-function H2(e, t) {
+function tL(e, t) {
const { viewOptions: n, getMarker: r, logger: i } = t, s = vs(e, r, n);
if (!s)
return i?.debug("[MarkerEdit] Note Tier 2 skipped: note excluded by guard rails"), !1;
@@ -27170,27 +27224,27 @@ function H2(e, t) {
let c, l = !1;
const u = M();
if (E(u)) {
- for (let R = u.anchor.getNode(); R; R = R.getParent())
- if (e.is(R)) {
+ for (let I = u.anchor.getNode(); I; I = I.getParent())
+ if (e.is(I)) {
l = !0;
break;
}
- u.isCollapsed() && (c = Mu(o, u.anchor));
+ u.isCollapsed() && (c = wu(o, u.anchor));
}
- const f = nc(a, o, void 0, Pt()), d = qo(o, {
+ const f = nc(a, o, void 0, Pt()), d = Do(o, {
getMarker: r,
isNoteContext: !0
});
if (d.length === 0)
return i?.debug("[MarkerEdit] Note Tier 2 skipped: tokenizer produced no content"), !1;
- if (ci(d) !== o.sentinels.length)
+ if (li(d) !== o.sentinels.length)
return i?.warn("[MarkerEdit] Note Tier 2 aborted: sentinel/preserved-node count mismatch"), !1;
const [p] = d;
if (d.length !== 1 || typeof p != "object" || p.type !== "para")
return i?.warn("[MarkerEdit] Note Tier 2 aborted: unexpected tokenized shape"), !1;
- const m = p.content ?? [], h = Iv(m), g = mv(e, m);
+ const m = p.content ?? [], h = Bv(m), g = Tv(e, m);
if (g)
- return G2(
+ return nL(
e,
g,
h,
@@ -27198,101 +27252,101 @@ function H2(e, t) {
t,
l
);
- const y = gv(e, m, h, n);
+ const y = xv(e, m, h, n);
if (y.failure !== void 0)
return y.failure === "empty" ? i?.debug("[MarkerEdit] Note Tier 2 skipped: no content nodes after unwrap") : i?.warn(
y.failure === "caller" ? "[MarkerEdit] Note Tier 2 aborted: serialized note lacks the editable caller" : "[MarkerEdit] Note Tier 2 aborted: unexpected serialized shape"
), !1;
- if (Oi(y.children) !== o.sentinels.length)
+ if ($i(y.children) !== o.sentinels.length)
return i?.warn(
"[MarkerEdit] Note Tier 2 aborted: serialized sentinel/preserved-node count mismatch"
), !1;
const b = e.getCategory() !== h;
if (b && e.setCategory(h), Fr(y.children, r) === Ur(a, r))
return i?.debug("[MarkerEdit] Note Tier 2 skipped: rebuild is a no-op (fixed point)"), b;
- const C = y.children.map((R) => Ir(R));
- if (vu(C) !== o.sentinels.length)
+ const T = y.children.map((I) => Ir(I));
+ if (Eu(T) !== o.sentinels.length)
return i?.warn("[MarkerEdit] Note Tier 2 aborted: parsed sentinel/preserved-node count mismatch"), b;
const x = a[0];
if (x)
- C.forEach((R) => x.insertBefore(R));
+ T.forEach((I) => x.insertBefore(I));
else {
- const R = e.getChildren().find((W) => $(W) && W.getMarkerSyntax() === "closing");
- C.forEach((W) => R ? R.insertBefore(W) : e.append(W));
+ const I = e.getChildren().find((V) => $(V) && V.getMarkerSyntax() === "closing");
+ T.forEach((V) => I ? I.insertBefore(V) : e.append(V));
}
- Cu(C, o.sentinels);
- const _ = new Set(o.sentinels.flat().map((R) => R.getKey()));
- a.forEach((R) => {
- _.has(R.getKey()) || (ge(R) && (R.getWritable().__suppressOnRemoveCallbacks = !0), R.remove());
+ _u(T, o.sentinels);
+ const _ = new Set(o.sentinels.flat().map((I) => I.getKey()));
+ a.forEach((I) => {
+ _.has(I.getKey()) || (me(I) && (I.getWritable().__suppressOnRemoveCallbacks = !0), I.remove());
});
- const F = () => vs(e, r, n);
- return rc(f, () => F()?.out), $v(
- F()?.contentNodes ?? C,
+ const U = () => vs(e, r, n);
+ return rc(f, () => U()?.out), Dv(
+ U()?.contentNodes ?? T,
c,
l,
r,
n
), !0;
}
-function G2(e, { before: t, after: n }, r, i, s, o) {
- const { viewOptions: a, logger: c } = s, l = yv(
+function nL(e, { before: t, after: n }, r, i, s, o) {
+ const { viewOptions: a, logger: c } = s, l = Cv(
e,
t,
n,
r,
a
);
- if (!l || Oi(l) !== i.length)
+ if (!l || $i(l) !== i.length)
return c?.warn("[MarkerEdit] Note close aborted: the closed note does not carry its content"), !1;
const u = l.map((m) => Ir(m)), [f] = u;
- if (!K(f) || vu(u) !== i.length)
+ if (!K(f) || Eu(u) !== i.length)
return c?.warn("[MarkerEdit] Note close aborted: the closed note does not carry its content"), !1;
let d = e;
for (const m of u)
d.insertAfter(m), d = m;
- Cu(u, i);
+ _u(u, i);
const p = e.getChildren();
- return e.append(...f.getChildren()), p.forEach((m) => m.remove()), e.setCaller(f.getCaller()).setCategory(f.getCategory()).setUnknownAttributes(f.getUnknownAttributes()).setIsCollapsed(f.getIsCollapsed()), f.remove(), o && (e.getIsCollapsed() !== !0 && a?.isNoteShellEditable === !1 ? Nc(e, a) : qT(e, { isContentChange: !0 })), !0;
+ return e.append(...f.getChildren()), p.forEach((m) => m.remove()), e.setCaller(f.getCaller()).setCategory(f.getCategory()).setUnknownAttributes(f.getUnknownAttributes()).setIsCollapsed(f.getIsCollapsed()), f.remove(), o && (e.getIsCollapsed() !== !0 && a?.isNoteShellEditable === !1 ? Nc(e, a) : UT(e, { isContentChange: !0 })), !0;
}
-function Lv(e) {
+function Uv(e) {
const t = e.getChildren();
- return Wp(t[0]) ? t.slice(1) : t;
+ return Gp(t[0]) ? t.slice(1) : t;
}
-function Pu(e, t, n) {
- const r = Lv(e), i = { text: "", spans: [], sentinels: [] };
+function Nu(e, t, n) {
+ const r = Uv(e), i = { text: "", spans: [], sentinels: [] };
return Kn(r, i, t, n), { out: i, contentNodes: r };
}
-const J2 = new RegExp(
- `^(?:[\\s\\u200B]*[\\r\\n][\\s\\u200B]*)?\\\\${Ln}(?=[\\s\\u200B\\\\|]|$)`
+const rL = new RegExp(
+ `^(?:[\\s\\u200B]*[\\r\\n][\\s\\u200B]*)?\\\\${qn}(?=[\\s\\u200B\\\\|]|$)`
);
-function qv(e, t) {
- const n = qo(e, { getMarker: t }), [r, ...i] = n;
- return typeof r == "object" && r.type === "para" && r.marker === Ln && !J2.test(e.text) ? { content: n, lineContent: r.content ?? [], followingBlocks: i } : { content: n, lineContent: [], followingBlocks: n };
+function Fv(e, t) {
+ const n = Do(e, { getMarker: t }), [r, ...i] = n;
+ return typeof r == "object" && r.type === "para" && r.marker === qn && !rL.test(e.text) ? { content: n, lineContent: r.content ?? [], followingBlocks: i } : { content: n, lineContent: [], followingBlocks: n };
}
-function Dv(e, t, n = []) {
- const { viewOptions: r, getMarker: i, logger: s } = t, { out: o, contentNodes: a } = Pu(e, i, r);
- if (!og(o, n, i, r))
+function zv(e, t, n = []) {
+ const { viewOptions: r, getMarker: i, logger: s } = t, { out: o, contentNodes: a } = Nu(e, i, r);
+ if (!fg(o, n, i, r))
return s?.debug("[MarkerEdit] Book Tier 2 skipped: paragraph excluded by guard rails"), !1;
const c = [e, ...n];
let l, u = !1;
const f = M();
if (E(f)) {
- for (let W = f.anchor.getNode(); W; W = W.getParent())
- if (c.some((ce) => ce.is(W))) {
+ for (let V = f.anchor.getNode(); V; V = V.getParent())
+ if (c.some((ce) => ce.is(V))) {
u = !0;
break;
}
- f.isCollapsed() && (l = Mu(o, f.anchor));
+ f.isCollapsed() && (l = wu(o, f.anchor));
}
const d = nc(
[...a, ...n],
o,
void 0,
Pt()
- ), p = qv(o, i);
- if (ci(p.content) !== o.sentinels.length)
+ ), p = Fv(o, i);
+ if (li(p.content) !== o.sentinels.length)
return s?.warn("[MarkerEdit] Book Tier 2 aborted: sentinel/preserved-node count mismatch"), !1;
- const m = bv(
+ const m = vv(
e,
p.lineContent,
p.followingBlocks,
@@ -27301,84 +27355,84 @@ function Dv(e, t, n = []) {
if (m.failure !== void 0)
return m.failure === "empty" ? s?.debug("[MarkerEdit] Book Tier 2 skipped: no content nodes after unwrap") : s?.warn("[MarkerEdit] Book Tier 2 aborted: unexpected serialized shape"), !1;
const h = [...m.children, ...m.followingBlocks];
- if (Oi(h) !== o.sentinels.length)
+ if ($i(h) !== o.sentinels.length)
return s?.warn("[MarkerEdit] Book Tier 2 aborted: serialized sentinel/preserved-node mismatch"), !1;
if (m.followingBlocks.length === n.length && Fr(m.followingBlocks, i) === Ur(n, i) && Fr(m.children, i) === Ur(a, i))
return s?.debug("[MarkerEdit] Book Tier 2 skipped: rebuild is a no-op (fixed point)"), !1;
- const g = m.children.map((W) => Ir(W)), y = m.followingBlocks.map((W) => Ir(W)), b = [...g, ...y];
- if (vu(b) !== o.sentinels.length)
+ const g = m.children.map((V) => Ir(V)), y = m.followingBlocks.map((V) => Ir(V)), b = [...g, ...y];
+ if (Eu(b) !== o.sentinels.length)
return s?.warn("[MarkerEdit] Book Tier 2 aborted: parsed sentinel/preserved-node mismatch"), !1;
- const C = Ra([...a, ...n]).map((W) => ({
- number: W.getNumber(),
- sid: W.getSid()
+ const T = Ra([...a, ...n]).map((V) => ({
+ number: V.getNumber(),
+ sid: V.getSid()
})), x = a[0];
- x ? g.forEach((W) => x.insertBefore(W)) : g.forEach((W) => e.append(W)), y.reduce((W, ce) => W.insertAfter(ce), e), Cu(b, o.sentinels);
- const _ = new Set(o.sentinels.flat().map((W) => W.getKey()));
- a.forEach((W) => {
- _.has(W.getKey()) || (ge(W) && (W.getWritable().__suppressOnRemoveCallbacks = !0), W.remove());
- }), n.forEach((W) => W.remove()), rc(
+ x ? g.forEach((V) => x.insertBefore(V)) : g.forEach((V) => e.append(V)), y.reduce((V, ce) => V.insertAfter(ce), e), _u(b, o.sentinels);
+ const _ = new Set(o.sentinels.flat().map((V) => V.getKey()));
+ a.forEach((V) => {
+ _.has(V.getKey()) || (me(V) && (V.getWritable().__suppressOnRemoveCallbacks = !0), V.remove());
+ }), n.forEach((V) => V.remove()), rc(
d,
- () => _v(e, y, i, r)
+ () => wv(e, y, i, r)
);
- const F = [...Lv(e), ...y], R = Ra(F);
- for (let W = 0; W < C.length && W < R.length; W++)
- R[W].getNumber() === C[W].number && R[W].setSid(C[W].sid);
- return $v(
- F,
+ const U = [...Uv(e), ...y], I = Ra(U);
+ for (let V = 0; V < T.length && V < I.length; V++)
+ I[V].getNumber() === T[V].number && I[V].setSid(T[V].sid);
+ return Dv(
+ U,
l,
u,
i,
r
), !0;
}
-const Kv = /* @__PURE__ */ new Set(["ca", "cp"]), ug = "cp";
-function Uv(e) {
- if (!kt(e)) return !1;
+const jv = /* @__PURE__ */ new Set(["ca", "cp"]), gg = "cp";
+function Vv(e) {
+ if (!ht(e)) return !1;
const t = { text: "", spans: [], sentinels: [] };
- if (Eo(e, t, Rr, void 0), t.sentinels.length > 0) return !1;
+ if (Mo(e, t, Rr, void 0), t.sentinels.length > 0) return !1;
const n = t.text;
if (n.trim() === "") return !1;
- const r = Ul(Zh(n), {
+ const r = Fl(ig(n), {
getMarker: Rr
}), [i] = r, s = r.length === 1 && typeof i == "object" && i.type === "para" && i.marker === "p" && !/^\s*\\p\s/.test(n) ? i.content ?? [] : r;
return s.length === 0 ? !1 : s.every(
- (o) => typeof o == "string" ? o.trim() === "" : (o.type === "char" || o.type === "para") && (o.marker === "ca" || o.marker === ug)
+ (o) => typeof o == "string" ? o.trim() === "" : (o.type === "char" || o.type === "para") && (o.marker === "ca" || o.marker === gg)
);
}
-function ri(e) {
+function ii(e) {
const t = [];
for (let n = e.getNextSibling(); n; n = n.getNextSibling()) {
- if (z(n) && Kv.has(n.getMarker()) || Uv(n)) {
+ if (z(n) && jv.has(n.getMarker()) || Vv(n)) {
t.push(n);
continue;
}
- ke(n) && n.getMarker() === ug && t.push(n);
+ ke(n) && n.getMarker() === gg && t.push(n);
break;
}
return t;
}
-function Y2(e) {
- const t = (r) => z(r) && Kv.has(r.getMarker()) || Uv(r);
- if (t(e) || ke(e) && e.getMarker() === ug)
+function iL(e) {
+ const t = (r) => z(r) && jv.has(r.getMarker()) || Vv(r);
+ if (t(e) || ke(e) && e.getMarker() === gg)
for (let r = e.getPreviousSibling(); r; r = r.getPreviousSibling()) {
- if (Be(r)) return r;
+ if (Fe(r)) return r;
if (!t(r)) return;
}
}
-function fg(e, t, n) {
+function mg(e, t, n) {
if (Object.keys(e.getUnknownAttributes() ?? {}).length > 0) return;
- const r = ri(e);
+ const r = ii(e);
if (r.some((s) => ke(s) && s.getUnknownAttributes())) return;
const i = { text: "", spans: [], sentinels: [] };
if (Kn(e.getChildren(), i, t, n), Kn(r, i, t, n), !(i.sentinels.length > 0))
return i;
}
-const nb = /^\\(?:\s|$)/, X2 = /^\s*\\p(?:\s|$)/;
-function Fv(e, t) {
- const n = Ul(Zh(e), {
+const ab = /^\\(?:\s|$)/, sL = /^\s*\\p(?:\s|$)/;
+function Wv(e, t) {
+ const n = Fl(ig(e), {
getMarker: t
}), [r, ...i] = n;
- if (typeof r != "object" || r.type !== "para" || r.marker !== "p" || X2.test(e))
+ if (typeof r != "object" || r.type !== "para" || r.marker !== "p" || sL.test(e))
return n;
const s = [...r.content ?? []], o = s.at(-1);
if (typeof o == "string") {
@@ -27386,35 +27440,35 @@ function Fv(e, t) {
l ? s[s.length - 1] = l : s.pop();
}
const [a, ...c] = s;
- if (typeof a == "string" && nb.test(a)) {
- const l = a.replace(nb, "");
+ if (typeof a == "string" && ab.test(a)) {
+ const l = a.replace(ab, "");
return [{ type: "para", marker: "", content: l ? [l, ...c] : c }, ...i];
}
return [...s, ...i];
}
-function Bv(e, t, n) {
+function Hv(e, t, n) {
return e === void 0 || /^\s/.test(n ?? "") ? !1 : t !== void 0 ? !/\s$/.test(t) : e !== Yn.getType();
}
-function zv(e) {
- return e === it.getType() || e === Lt.getType();
+function Gv(e) {
+ return e === at.getType() || e === Lt.getType();
}
-function Q2(e) {
- if (!kt(e)) return;
+function oL(e) {
+ if (!ht(e)) return;
const t = e.getPreviousSibling();
- if (!ke(t) && !kt(t)) return;
+ if (!ke(t) && !ht(t)) return;
const n = e.getChildren(), r = t.getLastChild(), i = n.at(0), s = r?.getType();
- Bv(
+ Hv(
s,
- r && s && zv(s) ? r.getTextContent() : void 0,
- T(i) ? i.getTextContent() : void 0
- ) && t.append(Ue(" ")), t.append(...n), e.remove();
+ r && s && Gv(s) ? r.getTextContent() : void 0,
+ C(i) ? i.getTextContent() : void 0
+ ) && t.append(Be(" ")), t.append(...n), e.remove();
}
-function Z2(e, t) {
- if (vi(e) !== it.getType() || vi(t) !== it.getType()) return !1;
+function aL(e, t) {
+ if (Si(e) !== at.getType() || Si(t) !== at.getType()) return !1;
const { text: n, ...r } = e, { text: i, ...s } = t;
return JSON.stringify(r) === JSON.stringify(s);
}
-const eL = {
+const cL = {
type: "text",
version: 1,
detail: 0,
@@ -27423,30 +27477,30 @@ const eL = {
style: "",
text: " "
};
-function jv(e, t) {
+function Jv(e, t) {
const n = e.at(t), r = t > 0 ? e[t - 1] : void 0;
- if (!n || !r || vi(n) !== Dr.getType()) return;
- const i = vi(r);
+ if (!n || !r || Si(n) !== Dr.getType()) return;
+ const i = Si(r);
if (i !== Kt.getType() && i !== Dr.getType()) return;
const s = Hn(n), o = Hn(r);
if (!s || !o) return;
- const a = o.at(-1), c = s.at(0), l = a ? vi(a) : void 0;
- Bv(
+ const a = o.at(-1), c = s.at(0), l = a ? Si(a) : void 0;
+ Hv(
l,
- a && l && zv(l) ? Or(a) : void 0,
+ a && l && Gv(l) ? Or(a) : void 0,
c ? Or(c) : void 0
- ) && o.push({ ...eL });
+ ) && o.push({ ...cL });
for (const u of s) {
const f = o.at(-1);
- f && Z2(f, u) ? Object.assign(f, { text: `${Or(f) ?? ""}${Or(u) ?? ""}` }) : o.push(u);
+ f && aL(f, u) ? Object.assign(f, { text: `${Or(f) ?? ""}${Or(u) ?? ""}` }) : o.push(u);
}
e.splice(t, 1);
}
-function rb(e) {
+function cb(e) {
return typeof e == "object" && e.type === "chapter";
}
-function Vv(e, t) {
- const { viewOptions: n, getMarker: r, logger: i } = t, s = [e, ...ri(e)], o = fg(e, r, n);
+function Yv(e, t) {
+ const { viewOptions: n, getMarker: r, logger: i } = t, s = [e, ...ii(e)], o = mg(e, r, n);
if (!o)
return i?.debug("[MarkerEdit] Chapter Tier 2 skipped: chapter excluded by guard rails"), !1;
let a, c = !1;
@@ -27457,16 +27511,16 @@ function Vv(e, t) {
c = !0;
break;
}
- l.isCollapsed() && (a = Mu(o, l.anchor));
+ l.isCollapsed() && (a = wu(o, l.anchor));
}
- const u = nc(s, o, void 0, Pt()), f = Fv(o.text, r);
+ const u = nc(s, o, void 0, Pt()), f = Wv(o.text, r);
if (f.length === 0 && c)
return i?.debug("[MarkerEdit] Chapter Tier 2 deferred: emptied chapter line holds the caret"), !1;
- if (ci(f) !== 0)
+ if (li(f) !== 0)
return i?.warn("[MarkerEdit] Chapter Tier 2 aborted: unexpected preserved-node placeholder"), !1;
- const [d] = f, p = rb(d) ? d : void 0, m = f.find(rb);
+ const [d] = f, p = cb(d) ? d : void 0, m = f.find(cb);
m && e.getSid() !== void 0 && (m.sid = e.getSid());
- const h = pr.serializeEditorState(
+ const h = hr.serializeEditorState(
{ type: fr, version: ur, content: f },
n
);
@@ -27477,32 +27531,32 @@ function Vv(e, t) {
const g = h.root.children.map((y) => Ir(y));
return g.forEach((y) => e.insertBefore(y)), s.forEach((y) => y.remove()), rc(
u,
- () => _u(g, r, n)
- ), Ov(g, a, c, r, n), Q2(g.at(0)), !0;
+ () => Pu(g, r, n)
+ ), qv(g, a, c, r, n), oL(g.at(0)), !0;
}
function Ia(e) {
let t, n;
for (let r = e; r; r = r.getParent()) {
if (Ie(r)) return;
- !t && (K(r) && !ng(r) || ke(r) || Be(r) || qe(r)) && (t = r), pn(r.getParent()) && (n = r);
+ !t && (K(r) && !ag(r) || ke(r) || Fe(r) || qe(r)) && (t = r), pn(r.getParent()) && (n = r);
}
- return t && !t.is(n) ? t : (n ? Y2(n) : void 0) ?? t;
+ return t && !t.is(n) ? t : (n ? iL(n) : void 0) ?? t;
}
function cr(e, t) {
const n = Ia(e);
- return n ? K(n) ? H2(n, t) : Be(n) ? Vv(n, t) : qe(n) ? Dv(n, t) : Rv([n], t) : !1;
+ return n ? K(n) ? tL(n, t) : Fe(n) ? Yv(n, t) : qe(n) ? zv(n, t) : Kv([n], t) : !1;
}
-const tL = /* @__PURE__ */ new Set(["type", "marker", "content", "closed"]);
-function ib(e, t) {
+const lL = /* @__PURE__ */ new Set(["type", "marker", "content", "closed"]);
+function lb(e, t) {
const n = Object.entries(e).filter(
- (r) => typeof r[1] == "string" && !tL.has(r[0])
+ (r) => typeof r[1] == "string" && !lL.has(r[0])
);
if (n.length !== 0) {
t.push("|");
for (const [r, i] of n) t.push(`${r}="${i}"`);
}
}
-function Lc(e, t) {
+function qc(e, t) {
if (e)
for (const n of e) {
if (typeof n == "string") {
@@ -27518,27 +27572,27 @@ function Lc(e, t) {
t.push(`\\${r} ${n.number ?? ""}`), n.altnumber !== void 0 && t.push(`\\ca ${n.altnumber}\\ca*`), n.pubnumber !== void 0 && t.push(`\\cp ${n.pubnumber}`);
break;
case "ms":
- t.push(`\\${r}`), ib(n, t), t.push("\\*");
+ t.push(`\\${r}`), lb(n, t), t.push("\\*");
break;
case "unmatched":
t.push(`\\${r}`);
break;
case "char":
- t.push(`\\${r} `), Lc(n.content, t), ib(n, t), i !== "false" && t.push(`\\${r}*`);
+ t.push(`\\${r} `), qc(n.content, t), lb(n, t), i !== "false" && t.push(`\\${r}*`);
break;
case "note": {
const s = n.caller, o = n.category;
- t.push(`\\${r} ${s ?? ""}`), o !== void 0 && t.push(`\\cat ${o}\\cat*`), Lc(n.content, t), i !== "false" && t.push(`\\${r}*`);
+ t.push(`\\${r} ${s ?? ""}`), o !== void 0 && t.push(`\\cat ${o}\\cat*`), qc(n.content, t), i !== "false" && t.push(`\\${r}*`);
break;
}
default:
- t.push(`\\${r} `), Lc(n.content, t);
+ t.push(`\\${r} `), qc(n.content, t);
}
}
}
-function sb(e, t, n) {
+function ub(e, t, n) {
const r = Ia(e);
- if (!ct(r)) return !1;
+ if (!st(r)) return !1;
const i = M();
if (!E(i) || !i.isCollapsed()) return !1;
let s = !1;
@@ -27548,19 +27602,19 @@ function sb(e, t, n) {
break;
}
if (!s) return !1;
- const o = qe(r) ? Pu(r, t, n).out : ig(r, t, n);
+ const o = qe(r) ? Nu(r, t, n).out : lg(r, t, n);
if (!o) return !1;
- const a = qo(o, {
+ const a = Do(o, {
getMarker: t,
- opensNamelessParagraph: rg([r])
+ opensNamelessParagraph: cg([r])
});
if (a.length === 0) return !1;
const c = /* @__PURE__ */ new Map();
for (const u of o.text)
Wn.test(u) || c.set(u, (c.get(u) ?? 0) + 1);
const l = [];
- Lc(a, l);
- for (const u of l.join("").replaceAll(U, "~")) {
+ qc(a, l);
+ for (const u of l.join("").replaceAll(B, "~")) {
if (Wn.test(u)) continue;
const f = c.get(u);
f !== void 0 && f > 0 && c.set(u, f - 1);
@@ -27568,25 +27622,25 @@ function sb(e, t, n) {
for (const u of c.values()) if (u > 0) return !0;
return !1;
}
-function dg(e, t) {
- return Hv(e, t, v.Paragraph);
+function yg(e, t) {
+ return Qv(e, t, v.Paragraph);
}
-function Wv(e, t) {
- return Hv(e, t, v.Character);
+function Xv(e, t) {
+ return Qv(e, t, v.Character);
}
-function Hv(e, t, n) {
+function Qv(e, t, n) {
const r = e.replace(/^\+/, "");
if (r === "v" || r === "c") return !1;
const i = t(r)?.type;
- return i !== void 0 && i !== v.Unknown ? i === n : !(at.isValidMarker(r) || vp(r));
+ return i !== void 0 && i !== v.Unknown ? i === n : !(lt.isValidMarker(r) || _p(r));
}
-function nL(e) {
+function uL(e) {
return [Jt(e), ms()];
}
-function pg(e) {
+function bg(e) {
zn(e, 2);
}
-function rL(e) {
+function fL(e) {
const t = M();
if (!E(t) || !t.isCollapsed()) return !1;
const { anchor: n } = t;
@@ -27595,33 +27649,33 @@ function rL(e) {
return r !== null && n.key === r.getKey() && n.offset === 0;
}
function La(e) {
- const t = rL(e);
- e.splice(0, 0, nL(e.getMarker())), t && pg(e);
+ const t = fL(e);
+ e.splice(0, 0, uL(e.getMarker())), t && bg(e);
}
-function Au(e, t) {
- e.setMarker(t), La(e), pg(e);
+function Ou(e, t) {
+ e.setMarker(t), La(e), bg(e);
}
-function iL(e, t) {
+function dL(e, t) {
const n = e.getFirstChild();
if (!n) return;
const r = n.getNextSibling();
if (!an(r)) {
- if (T(r) && !$(r) && /^[ \u00A0]$/.test(r.getTextContent())) {
+ if (C(r) && !$(r) && /^[ \u00A0]$/.test(r.getTextContent())) {
if (t.collapsedDeleteCaretParas?.has(e.getKey())) {
t.pendingKeys.add(e.getKey());
return;
}
- r.setTextContent(U), Wt(r, _e, Br), r.setMode("token");
+ r.setTextContent(B), Wt(r, _e, zr), r.setMode("token");
return;
}
- if (Nx(e)) {
+ if (Ix(e)) {
t.pendingKeys.add(e.getKey());
return;
}
n.insertAfter(ms());
}
}
-function ob(e, t, n) {
+function fb(e, t, n) {
const r = e.getNode();
if (r.is(t))
return n === "start" ? e.offset === 0 : e.offset === t.getChildrenSize();
@@ -27639,7 +27693,7 @@ function ua(e) {
for (let t = e; t; t = t.getParent())
if (ke(t)) return t;
}
-function sL(e) {
+function pL(e) {
const t = e.isBackward(), n = t ? e.focus : e.anchor, r = t ? e.anchor : e.focus, i = /* @__PURE__ */ new Set();
for (const s of e.getNodes()) {
const o = ua(s);
@@ -27647,17 +27701,17 @@ function sL(e) {
}
return [...i].filter((s) => {
const o = ua(n.getNode())?.is(s) ?? !1, a = ua(r.getNode())?.is(s) ?? !1;
- return !(o && !ob(n, s, "start") || a && !ob(r, s, "end"));
+ return !(o && !fb(n, s, "start") || a && !fb(r, s, "end"));
});
}
-function Kd(e) {
+function Ud(e) {
const t = e.wholeParaDeleteExpected;
if (!t) return;
const n = M();
if (!(!E(n) || n.isCollapsed()))
- for (const r of sL(n)) t.add(r.getKey());
+ for (const r of pL(n)) t.add(r.getKey());
}
-function oL(e) {
+function hL(e) {
const t = e.collapsedDeleteCaretParas;
if (!t) return;
const n = M();
@@ -27665,25 +27719,25 @@ function oL(e) {
const r = ua(n.focus.getNode());
r && t.add(r.getKey());
}
-function aL(e) {
+function gL(e) {
const t = M();
- !E(t) || t.isCollapsed() || t.getNodes().some((n) => $(n)) && (Kd(e), t.removeText());
+ !E(t) || t.isCollapsed() || t.getNodes().some((n) => $(n)) && (Ud(e), t.removeText());
}
-const cL = new RegExp(
+const mL = new RegExp(
String.raw`^\\\+?([${yn}]+)(?:[ \u00A0]|$)`
);
-function lL(e, t) {
- const n = cL.exec(e.getTextContent());
- return !!n && dg(n[1], t);
+function yL(e, t) {
+ const n = mL.exec(e.getTextContent());
+ return !!n && yg(n[1], t);
}
-function uL(e, t) {
- if (!qi(t.viewOptions)) return;
+function bL(e, t) {
+ if (!Di(t.viewOptions)) return;
if (Zt(e.getFirstChild())) {
- iL(e, t);
+ dL(e, t);
return;
}
if (t.splitExpected.current) {
- if (lL(e, t.getMarker)) return;
+ if (yL(e, t.getMarker)) return;
La(e), t.logger?.debug(`[MarkerEdit] injected prefix for split para "${e.getMarker()}"`);
return;
}
@@ -27691,14 +27745,14 @@ function uL(e, t) {
const r = t.wholeParaDeleteExpected?.has(e.getKey()) ?? !1, i = t.collapsedDeleteCaretParas?.has(e.getKey()) ?? !1;
if (!r && !i) return;
if (t.wholeParaDeleteExpected?.delete(e.getKey()), t.collapsedDeleteCaretParas?.delete(e.getKey()), !e.getParent()?.getChildren().some((o) => ke(o) && !o.is(e))) {
- Au(e, Ln), t.logger?.debug("[MarkerEdit] whole-para delete of the last para: reset to \\p");
+ Ou(e, qn), t.logger?.debug("[MarkerEdit] whole-para delete of the last para: reset to \\p");
return;
}
e.remove(), t.logger?.debug("[MarkerEdit] removed para whose whole representation was deleted");
return;
}
const n = e.getPreviousSibling();
- if (ct(n)) {
+ if (st(n)) {
const r = e.getChildren().filter((a) => !an(a)), i = M();
let s = !1;
if (E(i) && i.isCollapsed()) {
@@ -27711,46 +27765,46 @@ function uL(e, t) {
n.append(...r), e.remove(), s && zn(n, o), t.logger?.debug("[MarkerEdit] merged marker-deleted para into previous");
return;
}
- e.setMarker(Ln), La(e);
+ e.setMarker(qn), La(e);
}
-function fL(e) {
+function kL(e) {
const t = e.getUnknownAttributes();
if (!t) return;
- const n = yr(t, Ao(e.getMarker()));
+ const n = br(t, wo(e.getMarker()));
return n === "" ? void 0 : n;
}
-function Gv(e) {
+function Zv(e) {
const t = e.getChildren().filter((s) => !$(s) && Te(s, _e) !== "attribute"), n = t[0];
- n && T(n) && n.getTextContent().startsWith(U) && n.setTextContent(n.getTextContent().slice(1));
- const r = fL(e);
- r && t.push(Ue(r));
+ n && C(n) && n.getTextContent().startsWith(B) && n.setTextContent(n.getTextContent().slice(1));
+ const r = kL(e);
+ r && t.push(Be(r));
let i = e;
for (const s of t)
i.insertAfter(s), i = s;
e.remove();
}
-function dL(e) {
+function xL(e) {
const t = e.getNode();
let n;
- if (e.type === "element" && A(t) ? n = t.getChildAtIndex(e.offset) : $(t) && e.offset === 0 ? n = t : T(t) && e.offset === t.getTextContentSize() && (n = t.getNextSibling()), z(n) && (n = n.getFirstChild()), !$(n) || n.getMarkerSyntax() !== "opening") return;
+ if (e.type === "element" && A(t) ? n = t.getChildAtIndex(e.offset) : $(t) && e.offset === 0 ? n = t : C(t) && e.offset === t.getTextContentSize() && (n = t.getNextSibling()), z(n) && (n = n.getFirstChild()), !$(n) || n.getMarkerSyntax() !== "opening") return;
const r = n.getParent();
if (!(!z(r) || !n.is(r.getFirstChild())))
return n.getTextContentSize() === 1 ? n : void 0;
}
-function pL() {
+function TL() {
const e = M();
if (!E(e) || !e.isCollapsed()) return !1;
- const t = dL(e.anchor), n = t?.getParent();
+ const t = xL(e.anchor), n = t?.getParent();
if (!t || !z(n)) return !1;
const r = t.getNextSibling();
- return t.remove(), si(r) && r.getTextContent().startsWith(U) && r.setTextContent(` ${r.getTextContent().slice(U.length)}`), Gv(n), T(r) && r.isAttached() && r.select(0, 0), !0;
+ return t.remove(), oi(r) && r.getTextContent().startsWith(B) && r.setTextContent(` ${r.getTextContent().slice(B.length)}`), Zv(n), C(r) && r.isAttached() && r.select(0, 0), !0;
}
-function hL(e, t) {
+function CL(e, t) {
const n = e.getChildren(), r = n.some((s) => $(s) && s.getMarkerSyntax() === "opening");
if (e.getIsCollapsed() !== !0) {
if (r) return;
const s = n[0], o = n[n.length - 1];
- if (T(s) && s.isUnmergeable() && s.getMode() === "token" || $(o) && o.getMarkerSyntax() === "closing" && o.getMode() === "token") {
+ if (C(s) && s.isUnmergeable() && s.getMode() === "token" || $(o) && o.getMarkerSyntax() === "closing" && o.getMode() === "token") {
const u = Jt(e.getMarker());
u.setMode("token");
const f = e.getFirstChild();
@@ -27758,11 +27812,11 @@ function hL(e, t) {
return;
}
const a = e.getCaller(), c = n.some(
- (u) => T(u) && !$(u) && u.getTextContent() === qt(a)
+ (u) => C(u) && !$(u) && u.getTextContent() === qt(a)
), l = $s(e).some(({ node: u }) => $(u));
if (!c && !l) return;
n.forEach((u) => {
- $(u) || (T(u) && u.getTextContent() === qt(a) && u.setTextContent(a ? ` ${a} ` : " "), e.insertBefore(u));
+ $(u) || (C(u) && u.getTextContent() === qt(a) && u.setTextContent(a ? ` ${a} ` : " "), e.insertBefore(u));
}), e.remove(), t.logger?.debug(
"[MarkerEdit] unwrapped expanded note whose opening glyph was deleted (content preserved)"
);
@@ -27771,66 +27825,66 @@ function hL(e, t) {
const i = n.some((s) => $(s) && s.getMarkerSyntax() === "closing");
r !== i && (e.remove(), t.logger?.debug("[MarkerEdit] removed collapsed note with damaged glyph pair"));
}
-function gL(e, t) {
+function vL(e, t) {
if (e.isEmpty()) return;
const n = e.getFirstChild();
if (!($(n) && n.getMarkerSyntax() === "opening")) {
- Gv(e), t.logger?.debug(`[MarkerEdit] unwrapped char span "${e.getMarker()}"`);
+ Zv(e), t.logger?.debug(`[MarkerEdit] unwrapped char span "${e.getMarker()}"`);
return;
}
const i = e.getUnknownAttributes()?.closed !== "false", s = e.getChildren().some((o) => $(o) && o.getMarkerSyntax() === "closing");
i && !s && cr(e, t);
}
-function Ud(e) {
+function Fd(e) {
if (e === void 0) return;
const t = Number(e);
return Number.isFinite(t) ? Math.max(0, Math.floor(t)) : 0;
}
-function Jv(e, t) {
+function eS(e, t) {
if (!t || !("clipboardData" in t)) return !1;
const n = e.getRootElement()?.ownerDocument.getSelection(), r = n?.anchorNode, i = n?.focusNode;
- return !!r && !!i && !Yb(e, r, i);
+ return !!r && !!i && !tk(e, r, i);
}
-function Yv(e, t) {
- return e.length <= t ? e : e.slice(0, hg(e, t));
+function tS(e, t) {
+ return e.length <= t ? e : e.slice(0, kg(e, t));
}
-function hg(e, t) {
+function kg(e, t) {
if (t >= e.length) return e.length;
let n = 0;
- for (const { index: r, segment: i } of L0(e)) {
+ for (const { index: r, segment: i } of U0(e)) {
if (r + i.length > t) break;
n = r + i.length;
}
return n;
}
-const mL = 16;
-function yL(e, { $isHidden: t, $measure: n } = {}) {
- const r = (b) => t ? gg(b, t).length : b.getTextContent().length;
+const SL = 16;
+function _L(e, { $isHidden: t, $measure: n } = {}) {
+ const r = (b) => t ? xg(b, t).length : b.getTextContent().length;
n ??= r;
const i = M();
if (!E(i) || i.isCollapsed() || n(i) <= e) return !1;
- const [s, o] = i.isBackward() ? [i.focus, i.anchor] : [i.anchor, i.focus], a = { key: s.key, offset: s.offset, type: s.type }, c = Tl(s), l = Tl(o), u = i.getNodes(), f = new Map(u.map((b) => [b.getKey(), xL(b)])), d = u.length > 0 ? f.get(u[0].getKey()) : void 0, p = d && bL(s, d) ? d : void 0, m = (b) => {
- const C = b > 0 ? kL(u, f, p, c, l, b, t) : void 0;
- return i.anchor.set(a.key, a.offset, a.type), C ? i.focus.set(C.node.getKey(), C.offset, "text") : i.focus.set(a.key, a.offset, a.type), i.setCachedNodes(null), !!C;
+ const [s, o] = i.isBackward() ? [i.focus, i.anchor] : [i.anchor, i.focus], a = { key: s.key, offset: s.offset, type: s.type }, c = vl(s), l = vl(o), u = i.getNodes(), f = new Map(u.map((b) => [b.getKey(), PL(b)])), d = u.length > 0 ? f.get(u[0].getKey()) : void 0, p = d && EL(s, d) ? d : void 0, m = (b) => {
+ const T = b > 0 ? ML(u, f, p, c, l, b, t) : void 0;
+ return i.anchor.set(a.key, a.offset, a.type), T ? i.focus.set(T.node.getKey(), T.offset, "text") : i.focus.set(a.key, a.offset, a.type), i.setCachedNodes(null), !!T;
};
let h = Math.min(e, r(i));
if (m(h) && n(i) <= e) return !0;
let g = 0, y = 0;
h -= 1;
- for (let b = 0; b < mL && g <= h; b++) {
- const C = Math.floor((g + h) / 2);
- m(C) && n(i) <= e ? (y = C, g = C + 1) : h = C - 1;
+ for (let b = 0; b < SL && g <= h; b++) {
+ const T = Math.floor((g + h) / 2);
+ m(T) && n(i) <= e ? (y = T, g = T + 1) : h = T - 1;
}
return m(y), !0;
}
-function Fd(e) {
- return e.isToken() || Xa(e) || Be(e.getParent());
+function zd(e) {
+ return e.isToken() || Xa(e) || Fe(e.getParent());
}
-function bL(e, t) {
+function EL(e, t) {
const n = A(t) ? t.getAllTextNodes()[0] : void 0;
return !!n && fn(n.getKey(), 0, "text").isBefore(e);
}
-function kL(e, t, n, r, i, s, o) {
+function ML(e, t, n, r, i, s, o) {
const a = e.length - 1;
let c = 0, l = !0, u, f;
const d = /* @__PURE__ */ new Map(), p = (h) => {
@@ -27839,7 +27893,7 @@ function kL(e, t, n, r, i, s, o) {
}, m = (h) => {
let g = f ? f.endBefore : h;
for (; ; ) {
- const y = TL(g, e, r);
+ const y = AL(g, e, r);
if (!y || !g || y.node.is(g.node)) return y;
const b = p(y.node);
if (!b || b.is(p(g.node))) return y;
@@ -27857,14 +27911,14 @@ function kL(e, t, n, r, i, s, o) {
l = !g.isEmpty();
continue;
}
- if (l = !1, T(g)) {
- const b = h === 0 ? r : 0, C = h === a ? i : g.getTextContentSize(), x = C - b, _ = Fd(g);
+ if (l = !1, C(g)) {
+ const b = h === 0 ? r : 0, T = h === a ? i : g.getTextContentSize(), x = T - b, _ = zd(g);
if (_ && c + x > s) return m(u);
if (!_ && c + x >= s) {
- const F = hg(g.getTextContent(), b + (s - c));
- return m({ node: g, offset: Math.max(b, F) });
+ const U = kg(g.getTextContent(), b + (s - c));
+ return m({ node: g, offset: Math.max(b, U) });
}
- c += x, u = { node: g, offset: C };
+ c += x, u = { node: g, offset: T };
} else if (on(g) || Os(g)) {
const b = g.getTextContentSize();
if (c + b > s) return m(u);
@@ -27874,13 +27928,13 @@ function kL(e, t, n, r, i, s, o) {
}
return m(u);
}
-function xL(e) {
+function PL(e) {
let t;
for (let n = e; n; n = n.getParent())
- (K(n) || cu(n)) && (t = n);
+ (K(n) || uu(n)) && (t = n);
return t;
}
-function TL(e, t, n) {
+function AL(e, t, n) {
if (!e) return e;
const r = We(e.node, (g) => A(g) && !g.isInline()), i = A(r) ? r.getAllTextNodes() : [e.node], s = i.findIndex((g) => g.is(e.node));
if (s < 0) return e;
@@ -27889,22 +27943,22 @@ function TL(e, t, n) {
const l = [];
for (let g = o; g <= a; g++)
l.push(c.length), c += i[g].getTextContent();
- const u = l[s - o], f = u + e.offset, d = hg(c, f);
+ const u = l[s - o], f = u + e.offset, d = kg(c, f);
if (d === f) return e;
const p = (g) => t[0]?.is(g) ?? !1;
- if (Fd(e.node)) return { ...e, offset: p(e.node) ? n : 0 };
+ if (zd(e.node)) return { ...e, offset: p(e.node) ? n : 0 };
if (d >= u) {
const g = d - u;
return g >= (p(e.node) ? n : 0) ? { ...e, offset: g } : void 0;
}
const m = s > o ? i[s - 1] : void 0;
if (!m || !t.some((g) => g.is(m))) return;
- if (Fd(m))
+ if (zd(m))
return { node: m, offset: p(m) ? n : 0 };
const h = d - l[0];
return h >= (p(m) ? n : 0) ? { node: m, offset: h } : void 0;
}
-function gg(e, t) {
+function xg(e, t) {
const n = e.getNodes(), r = n.length - 1, [i, s] = e.isBackward() ? [e.focus, e.anchor] : [e.anchor, e.focus], o = r === 0 && i.type === "element" && s.type === "element" && i.offset !== s.offset;
let a = "", c = !0;
return n.forEach((l, u) => {
@@ -27914,23 +27968,23 @@ function gg(e, t) {
`), c = !l.isEmpty();
return;
}
- if (c = !1, T(l)) {
+ if (c = !1, C(l)) {
const f = l.getTextContent();
o ? a += f : a += f.slice(
- u === 0 ? Tl(i) : 0,
- u === r ? Tl(s) : f.length
+ u === 0 ? vl(i) : 0,
+ u === r ? vl(s) : f.length
);
} else (on(l) || Os(l)) && (u !== r || !e.isCollapsed()) && (a += l.getTextContent());
}
}), a;
}
-function Bd(e) {
+function jd(e) {
const t = e.getParent();
return !!t && We(t, (n) => K(n) && !!n.getIsCollapsed()) !== null;
}
-function Xv(e) {
+function nS(e) {
const t = /* @__PURE__ */ new Map(), n = (i) => {
- Ut(i) && t.set(i.getKey(), i.getPreviewText().length);
+ Bt(i) && t.set(i.getKey(), i.getPreviewText().length);
};
for (const i of e)
if (n(i), A(i)) for (const { node: s } of $s(i)) n(s);
@@ -27938,19 +27992,19 @@ function Xv(e) {
for (const i of t.values()) r += i;
return r;
}
-function CL(e) {
+function wL(e) {
return e.getNodes().some(
- (t) => on(t) || K(t) || Oe(t) || ot(t) || cu(t)
+ (t) => on(t) || K(t) || Oe(t) || Ye(t) || uu(t)
);
}
-function Tl(e) {
+function vl(e) {
if (e.type === "text") return e.offset;
const t = e.getNode();
return A(t) && e.offset === t.getChildrenSize() ? t.getTextContent().length : 0;
}
-function Qv(e) {
+function rS(e) {
const t = e.getParent();
- if (!K(t) || t.getIsCollapsed() !== !1 || !mp(t.getMarker())?.includes("caller")) return !1;
+ if (!K(t) || t.getIsCollapsed() !== !1 || !bp(t.getMarker())?.includes("caller")) return !1;
const n = t.getChildren();
let r = 0;
for (; r < n.length; ) {
@@ -27960,58 +28014,58 @@ function Qv(e) {
}
return e.is(n[r]);
}
-const Cl = "usfm:", Zv = "usfmopen", eS = "usfmclosed";
-function vL(e) {
+const Sl = "usfm:", iS = "usfmopen", sS = "usfmclosed";
+function NL(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
-const SL = new RegExp(
- [Cl, Zv, eS].map(vL).join("|")
-), _L = "\uFEFF", EL = /^usfm_(.+)$/;
-function ML(e) {
+const OL = new RegExp(
+ [Sl, iS, sS].map(NL).join("|")
+), $L = "\uFEFF", RL = /^usfm_(.+)$/;
+function IL(e) {
return e.nodeType === Node.ELEMENT_NODE;
}
-function PL(e) {
+function LL(e) {
return e.replace(
/%([0-9a-fA-F]{4})/g,
(t, n) => String.fromCharCode(Number.parseInt(n, 16))
);
}
-function AL(e) {
- return e.startsWith(Cl) ? PL(e.slice(Cl.length)).replace(/\r\n?|\n/g, " ") : "";
+function qL(e) {
+ return e.startsWith(Sl) ? LL(e.slice(Sl.length)).replace(/\r\n?|\n/g, " ") : "";
}
-function tS(e) {
+function oS(e) {
for (const t of e.classList) {
- const n = EL.exec(t);
+ const n = RL.exec(t);
if (n) return n[1];
}
}
-function wL(e) {
- const t = tS(e);
+function DL(e) {
+ const t = oS(e);
if (t !== void 0)
return e.classList.contains("nested") ? `+${t}` : t;
}
-function NL(e) {
+function KL(e) {
const t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_COMMENT);
for (let n = t.nextNode(); n; n = t.nextNode())
- if ((n.nodeValue ?? "").startsWith(Cl)) return !0;
+ if ((n.nodeValue ?? "").startsWith(Sl)) return !0;
for (const n of e.querySelectorAll("*")) {
const { classList: r } = n;
- if (!(!r.contains(Zv) && !r.contains(eS)) && tS(n) !== void 0)
+ if (!(!r.contains(iS) && !r.contains(sS)) && oS(n) !== void 0)
return !0;
}
return !1;
}
-function nS(e, t, n) {
+function aS(e, t, n) {
if (e.nodeType === Node.TEXT_NODE) {
t || n.push(e.nodeValue ?? "");
return;
}
if (e.nodeType === Node.COMMENT_NODE) {
- n.push(AL(e.nodeValue ?? ""));
+ n.push(qL(e.nodeValue ?? ""));
return;
}
- if (!ML(e)) return;
- const { classList: r } = e, i = (u) => e.childNodes.forEach((f) => nS(f, u, n));
+ if (!IL(e)) return;
+ const { classList: r } = e, i = (u) => e.childNodes.forEach((f) => aS(f, u, n));
if (t) {
i(!r.contains("include"));
return;
@@ -28030,51 +28084,51 @@ function nS(e, t, n) {
n.push(e.textContent ?? "");
return;
}
- const o = s === "div" || s === "tr", a = o || s === "span" || s === "th" || s === "td" ? wL(e) : void 0, c = a !== void 0 && r.contains("usfmopen"), l = a !== void 0 && r.contains("usfmclosed");
+ const o = s === "div" || s === "tr", a = o || s === "span" || s === "th" || s === "td" ? DL(e) : void 0, c = a !== void 0 && r.contains("usfmopen"), l = a !== void 0 && r.contains("usfmclosed");
o && n.push(`
`), (c || l) && n.push(`\\${a} `), i(!1), l && n.push(`\\${a}*`), o && n.push(`
`);
}
-function OL(e) {
- if (!SL.test(e)) return;
+function BL(e) {
+ if (!OL.test(e)) return;
const { body: t } = new DOMParser().parseFromString(e, "text/html");
- if (t.querySelectorAll("script,style,template").forEach((r) => r.remove()), !NL(t)) return;
+ if (t.querySelectorAll("script,style,template").forEach((r) => r.remove()), !KL(t)) return;
const n = [];
- return t.childNodes.forEach((r) => nS(r, !1, n)), n.join("").replaceAll(_L, "").replaceAll(U, " ").replace(/\r\n?/g, `
+ return t.childNodes.forEach((r) => aS(r, !1, n)), n.join("").replaceAll($L, "").replaceAll(B, " ").replace(/\r\n?/g, `
`).replace(/\n+/g, `
`).replace(/^\n|\n$/g, "");
}
-function $L(e) {
- const t = e.getTextContent(), n = t === U;
+function UL(e) {
+ const t = e.getTextContent(), n = t === B;
if (!n && !t.includes(" ")) return;
const r = Te(e, _e);
- if (r === "attribute" || r === Br || Qv(e)) return;
+ if (r === "attribute" || r === zr || rS(e)) return;
for (let a = e.getParent(); a; a = a.getParent())
- if (Be(a) || Ie(a)) return;
+ if (Fe(a) || Ie(a)) return;
if (n) {
- RL(e) && e.setTextContent(" ");
+ FL(e) && e.setTextContent(" ");
return;
}
- const i = t.startsWith(U) && z(e.getParent()), s = i ? t.slice(1) : t, o = (i ? U : "") + s.replace(/ (?=[ \u00A0])/g, U).replace(new RegExp("(?<=\\u00A0) ", "g"), U);
+ const i = t.startsWith(B) && z(e.getParent()), s = i ? t.slice(1) : t, o = (i ? B : "") + s.replace(/ (?=[ \u00A0])/g, B).replace(new RegExp("(?<=\\u00A0) ", "g"), B);
o !== t && e.setTextContent(o);
}
-function RL(e) {
+function FL(e) {
if (e.getMode() !== "normal" || Te(e, _e) !== void 0) return !1;
const t = e.getParent();
- if (ge(t) || He(t) || K(t) && t.getChildren().some(Ut)) return !1;
+ if (me(t) || He(t) || K(t) && t.getChildren().some(Bt)) return !1;
const n = e.getPreviousSibling();
if ((z(t) || K(t)) && !n) return !1;
const r = e.getNextSibling();
- return !$(n) && !ge(n) && !ge(r);
+ return !$(n) && !me(n) && !me(r);
}
-function IL(e) {
+function zL(e) {
const { body: t } = new DOMParser().parseFromString(e, "text/html");
return t.querySelectorAll("script,style,template").forEach((n) => n.remove()), t.querySelectorAll("br").forEach((n) => n.replaceWith(`
`)), t.querySelectorAll("p,div,li,td,th,tr,h1,h2,h3,h4,h5,h6,blockquote,pre").forEach((n) => n.after(`
`)), (t.textContent ?? "").replace(/\n+/g, `
`).replace(/^\n|\n$/g, "");
}
-function LL(e, t) {
+function jL(e, t) {
if (!e) return !1;
try {
const n = JSON.parse(e);
@@ -28085,89 +28139,89 @@ function LL(e, t) {
return !1;
}
}
-function qc(e, t) {
+function Dc(e, t) {
const n = e && typeof e == "object" && "clipboardData" in e ? e.clipboardData : void 0;
if (n)
- return rS(n, t);
+ return cS(n, t);
}
-function rS(e, t) {
+function cS(e, t) {
const n = (o) => o.replace(/\r\n?/g, `
-`), r = n(e.getData("text/plain")), i = e.getData("text/html"), s = i ? OL(i) : void 0;
+`), r = n(e.getData("text/plain")), i = e.getData("text/html"), s = i ? BL(i) : void 0;
return {
- text: s ? n(s) : r || (i ? n(IL(i)) : ""),
- isInternal: LL(
+ text: s ? n(s) : r || (i ? n(zL(i)) : ""),
+ isInternal: jL(
e.getData("application/x-lexical-editor"),
t
)
};
}
-const ab = String.raw`\\(?:\+?[${yn}]+\*?|\*)`, qL = new RegExp(
- String.raw`(?<=${ab})\u00A0|\u00A0(?=${ab})`,
+const db = String.raw`\\(?:\+?[${yn}]+\*?|\*)`, VL = new RegExp(
+ String.raw`(?<=${db})\u00A0|\u00A0(?=${db})`,
"g"
);
-function mg(e) {
- return e.replace(/^\u00A0+/gm, (t) => " ".repeat(t.length)).replace(qL, " ").replaceAll(U, "~");
+function Tg(e) {
+ return e.replace(/^\u00A0+/gm, (t) => " ".repeat(t.length)).replace(VL, " ").replaceAll(B, "~");
}
-const iS = new RegExp(
+const lS = new RegExp(
String.raw`\\c(?![${yn}])[ \u00A0]*[^\s\\]*`,
"g"
-), sS = new RegExp(String.raw`\\id(?![${yn}])[^\n\\]*`, "g"), DL = new RegExp(
- String.raw`^(?:${iS.source}|${sS.source})`
+), uS = new RegExp(String.raw`\\id(?![${yn}])[^\n\\]*`, "g"), WL = new RegExp(
+ String.raw`^(?:${lS.source}|${uS.source})`
);
-function vl(e) {
+function _l(e) {
return e.split(`
`).map((t) => {
- const n = t.replace(iS, "").replace(sS, "");
- return DL.test(t) && n.trim() === "" && t.trim() !== "" ? void 0 : n;
+ const n = t.replace(lS, "").replace(uS, "");
+ return WL.test(t) && n.trim() === "" && t.trim() !== "" ? void 0 : n;
}).filter((t) => t !== void 0).join(`
`);
}
-const KL = new RegExp(
+const HL = new RegExp(
String.raw`\\v(?![${yn}*])[ \u00A0]*[^\s\\]*[ \u00A0]?`,
"g"
-), UL = new RegExp(
+), GL = new RegExp(
String.raw`\\([${yn}]+)(?![${yn}*])[ \u00A0]?`,
"g"
);
-function Sl(e, t) {
- return e.replace(KL, "").replace(
- UL,
+function El(e, t) {
+ return e.replace(HL, "").replace(
+ GL,
(n, r) => t(r)?.type === v.Paragraph ? "" : n
);
}
-function zd(e) {
- if (T(e) && Te(e, _e) === "attribute") return !0;
+function Vd(e) {
+ if (C(e) && Te(e, _e) === "attribute") return !0;
for (let t = e; t; t = t.getParent())
if (He(t)) return !0;
return !1;
}
-function FL(e) {
- return zd(e.anchor.getNode()) || zd(e.focus.getNode());
+function JL(e) {
+ return Vd(e.anchor.getNode()) || Vd(e.focus.getNode());
}
-function BL(e) {
+function YL(e) {
const { anchor: t, focus: n } = e;
- return t.key === n.key && zd(t.getNode());
+ return t.key === n.key && Vd(t.getNode());
}
-function zL(e, t, n, r) {
- const s = BL(e) ? n ? Sl(t, r) : t : mg(
- n ? Sl(vl(t), r) : vl(t)
+function XL(e, t, n, r) {
+ const s = YL(e) ? n ? El(t, r) : t : Tg(
+ n ? El(_l(t), r) : _l(t)
);
s && e.insertText(s.replace(/\n/g, " "));
}
-function jL(e, t = !1, n = () => {
+function QL(e, t = !1, n = () => {
}, r = () => {
}) {
- const i = qc(e, Pt()._config.namespace);
+ const i = Dc(e, Pt()._config.namespace);
if (!i) return !1;
- const s = M(), o = E(s) && FL(s);
- if (!o && i.isInternal && !t || t && E(s) && Ci(s))
+ const s = M(), o = E(s) && JL(s);
+ if (!o && i.isInternal && !t || t && E(s) && vi(s))
return !1;
const { text: a } = i;
- return !a || !E(s) ? !1 : (e?.preventDefault(), o ? (zL(s, a, t, r), !0) : (oS(s, a, t, n, r), !0));
+ return !a || !E(s) ? !1 : (e?.preventDefault(), o ? (XL(s, a, t, r), !0) : (fS(s, a, t, n, r), !0));
}
-function oS(e, t, n, r, i) {
- const s = vl(t), o = mg(
- n ? Sl(s, i) : s
+function fS(e, t, n, r, i) {
+ const s = _l(t), o = Tg(
+ n ? El(s, i) : s
);
if (!o) return;
const a = o.split(`
@@ -28183,229 +28237,229 @@ function oS(e, t, n, r, i) {
r(), e.isCollapsed() || e.removeText();
const c = Pt();
a.forEach((l, u) => {
- if (u > 0 && c.dispatchCommand(Ti, void 0), l === "") return;
+ if (u > 0 && c.dispatchCommand(Ci, void 0), l === "") return;
const f = M();
E(f) && f.insertText(l);
});
}
-function VL(e) {
- if (e.getTextContent() !== U) return !1;
+function ZL(e) {
+ if (e.getTextContent() !== B) return !1;
const t = e.getParent();
- return K(t) ? !Ut(e.getPreviousSibling()) : !1;
+ return K(t) ? !Bt(e.getPreviousSibling()) : !1;
}
-function WL(e, t) {
- if (t || e.getTextContent() !== U) return "";
+function eq(e, t) {
+ if (t || e.getTextContent() !== B) return "";
const n = e.getParent();
- if (!K(n) || !Ut(e.getPreviousSibling())) return "";
+ if (!K(n) || !Bt(e.getPreviousSibling())) return "";
const r = n.getCategory();
return r ? `\\cat ${r}\\cat*` : "";
}
-function HL(e) {
+function tq(e) {
const t = e.getParent();
return (K(t) ? t.getCaller() : void 0) || ya;
}
-function GL(e) {
+function nq(e) {
const t = e.getParent();
- return !t || Ai(t) === void 0;
+ return !t || Ni(t) === void 0;
}
-function yg(e) {
+function Cg(e) {
const t = e.getNodes();
if (t.length === 0) return "";
- const n = t[0], r = t[t.length - 1], { anchor: i, focus: s } = e, o = i.isBefore(s), [a, c] = up(e);
+ const n = t[0], r = t[t.length - 1], { anchor: i, focus: s } = e, o = i.isBefore(s), [a, c] = dp(e);
let l = "", u = !0;
for (const f of t) {
if (A(f) && !f.isInline()) {
- !u && GL(f) && (l += `
+ !u && nq(f) && (l += `
`), u = !f.isEmpty();
continue;
}
- if (u = !1, Ut(f))
- (f !== r || !e.isCollapsed()) && (l += (f === n ? "" : " ") + HL(f));
- else if (T(f)) {
+ if (u = !1, Bt(f))
+ (f !== r || !e.isCollapsed()) && (l += (f === n ? "" : " ") + tq(f));
+ else if (C(f)) {
let d = f.getTextContent();
- f === n ? f === r ? (i.type !== "element" || s.type !== "element" || s.offset === i.offset) && (d = a < c ? d.slice(a, c) : d.slice(c, a)) : d = o ? d.slice(a) : d.slice(c) : f === r && (d = o ? d.slice(0, c) : d.slice(0, a)), l += VL(f) ? "" : d.replaceAll(U, " ") + WL(f, f === r);
- } else (on(f) || Os(f)) && (f !== r || !e.isCollapsed()) && (l += f.getTextContent().replaceAll(U, " "));
+ f === n ? f === r ? (i.type !== "element" || s.type !== "element" || s.offset === i.offset) && (d = a < c ? d.slice(a, c) : d.slice(c, a)) : d = o ? d.slice(a) : d.slice(c) : f === r && (d = o ? d.slice(0, c) : d.slice(0, a)), l += ZL(f) ? "" : d.replaceAll(B, " ") + eq(f, f === r);
+ } else (on(f) || Os(f)) && (f !== r || !e.isCollapsed()) && (l += f.getTextContent().replaceAll(B, " "));
}
return l;
}
-function aS(e) {
+function dS(e) {
return e.split(`
`).map((t) => t.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")).map(
(t) => t ? `
${t}
` : ""
).join("");
}
-function JL(e) {
+function rq(e) {
return e.getNodes().some(
(t) => [t, ...t.getParents()].some(
- (n) => qe(n) || Be(n)
+ (n) => qe(n) || Fe(n)
)
);
}
-function YL(e) {
+function iq(e) {
const t = M();
if (!E(t) || t.isCollapsed()) return;
- const n = yg(t), r = {
+ const n = Cg(t), r = {
"text/plain": n,
- "text/html": aS(n)
+ "text/html": dS(n)
};
- if (Ts() || JL(t)) return r;
- const i = I0(e);
+ if (Ts() || rq(t)) return r;
+ const i = B0(e);
return i && (r["application/x-lexical-editor"] = i), r;
}
-function cb(e, t, n, r) {
+function pb(e, t, n, r) {
const i = M();
if (!E(i) || i.isCollapsed())
- return (!e || !("clipboardData" in e)) && !fC();
- const s = YL(t);
- return s ? (r !== void 0 && delete s["application/x-lexical-editor"], cS(e, t, i, s, n, r)) : !1;
+ return (!e || !("clipboardData" in e)) && !gC();
+ const s = iq(t);
+ return s ? (r !== void 0 && delete s["application/x-lexical-editor"], pS(e, t, i, s, n, r)) : !1;
}
-function cS(e, t, n, r, i, s) {
- const o = Ud(s);
- if (o !== void 0 && Jv(t, e)) return !1;
+function pS(e, t, n, r, i, s) {
+ const o = Fd(s);
+ if (o !== void 0 && eS(t, e)) return !1;
const a = r["text/plain"] ?? "";
return o !== void 0 && a.length > o ? (process.env.NODE_ENV !== "production" && console.warn(
"@eten-tech-foundation/platform-editor: a copy reached the clipboard over its copy limit; writing shortened plain text only."
- ), jd(e, t, { "text/plain": Yv(a, o) })) : jd(
+ ), Wd(e, t, { "text/plain": tS(a, o) })) : Wd(
e,
t,
r,
i && t.isEditable() ? () => n.removeText() : void 0
);
}
-function jd(e, t, n, r) {
+function Wd(e, t, n, r) {
const i = !n["text/plain"];
if (!e || !("clipboardData" in e))
- return i || R0(t, null, n), r?.(), !0;
+ return i || K0(t, null, n), r?.(), !0;
if (e.clipboardData == null) return !1;
if (e.preventDefault(), !i)
for (const [s, o] of Object.entries(n)) e.clipboardData.setData(s, o);
return r?.(), !0;
}
function Ss(e) {
- return We(e, Be) ?? void 0;
+ return We(e, Fe) ?? void 0;
}
-function lS(e) {
+function hS(e) {
return [e.anchor.getNode(), e.focus.getNode(), ...e.getNodes()].some(
(t) => Ss(t) !== void 0
);
}
-function bg() {
+function vg() {
const e = M();
if (!E(e)) return;
if (!e.isCollapsed()) {
- if (!lS(e)) return;
+ if (!hS(e)) return;
e.removeText();
}
const t = M();
return E(t) ? Ss(t.focus.getNode()) : void 0;
}
-function uS(e, t) {
- const n = bg();
+function gS(e, t) {
+ const n = vg();
if (!n) return !1;
- const r = ps(e);
- return n.insertAfter(r), qi(t) ? Au(r, e) : r.selectStart(), !0;
+ const r = Ai(e);
+ return n.insertAfter(r), Di(t) ? Ou(r, e) : r.selectStart(), !0;
}
-function XL() {
+function sq() {
const e = M();
- return E(e) && !e.isCollapsed() && Ss(e.anchor.getNode())?.is(Ss(e.focus.getNode())) ? !0 : bg() !== void 0;
+ return E(e) && !e.isCollapsed() && Ss(e.anchor.getNode())?.is(Ss(e.focus.getNode())) ? !0 : vg() !== void 0;
}
-function QL(e) {
- if (!lS(e)) return !1;
+function oq(e) {
+ if (!hS(e)) return !1;
if (!e.isCollapsed()) return !0;
- const t = e.focus.getNode(), n = Ss(t), r = n && jr(n);
+ const t = e.focus.getNode(), n = Ss(t), r = n && Vr(n);
return !(r?.is(t) && e.focus.offset === r.getTextContentSize());
}
-function fS(e, t, n, r) {
+function mS(e, t, n, r) {
const i = M();
- if (t && E(i) && QL(i))
+ if (t && E(i) && oq(i))
return !0;
- if (!bg()) return !1;
+ if (!vg()) return !1;
const s = M();
- return e && E(s) && oS(s, e, t, n, r), !0;
+ return e && E(s) && fS(s, e, t, n, r), !0;
}
const Tc = "";
-function ZL(e, t) {
- const { opener: n, value: r, wrapper: i } = Pp(e), s = i ?? n;
+function aq(e, t) {
+ const { opener: n, value: r, wrapper: i } = wp(e), s = i ?? n;
if (!s) return !1;
const o = t.focus.getNode();
return o.is(e) ? t.focus.offset > s.getIndexWithinParent() : [i, n, r].some(
(a) => a && (a.is(o) || a.isParentOf(o))
);
}
-function eq(e, t, n) {
- const { closer: r, wrapper: i } = Mp(e), s = i ?? r;
+function cq(e, t, n) {
+ const { closer: r, wrapper: i } = Ap(e), s = i ?? r;
if (!s) return t;
const o = n.focus.getNode();
return (o.is(e) ? n.focus.offset > t.getIndexWithinParent() + 1 : !o.is(t)) ? s : t;
}
-function Vd(e) {
+function Hd(e) {
const t = M();
if (!E(t)) return !0;
const n = Ss(t.focus.getNode());
if (!n || !n.is(Ss(t.anchor.getNode()))) return !0;
- const r = jr(n);
+ const r = Vr(n);
if (!r) return !1;
- if (ZL(n, t)) {
- const f = Ue("");
- return (ri(n).at(-1) ?? n).insertAfter(
- qn().append(f)
+ if (aq(n, t)) {
+ const f = Be("");
+ return (ii(n).at(-1) ?? n).insertAfter(
+ En().append(f)
), f.select(0, 0), !0;
}
- const i = n.getPreviousSibling(), s = (ri(n).at(-1) ?? n).getNextSibling(), o = eq(n, r, t), a = o.is(r) && !/\s$/.test(r.getTextContent()) ? " " : "", c = Ue(a + Tc);
- if (o.insertAfter(c), !Vv(n, e))
+ const i = n.getPreviousSibling(), s = (ii(n).at(-1) ?? n).getNextSibling(), o = cq(n, r, t), a = o.is(r) && !/\s$/.test(r.getTextContent()) ? " " : "", c = Be(a + Tc);
+ if (o.insertAfter(c), !Yv(n, e))
return c.remove(), !1;
- const l = tq(i, s).flatMap((f) => A(f) ? f.getAllTextNodes() : [f]).find((f) => T(f) && f.getTextContent().includes(Tc));
- if (!T(l)) return !1;
+ const l = lq(i, s).flatMap((f) => A(f) ? f.getAllTextNodes() : [f]).find((f) => C(f) && f.getTextContent().includes(Tc));
+ if (!C(l)) return !1;
const u = l.getTextContent().indexOf(Tc);
return l.setTextContent(l.getTextContent().replace(Tc, "")), l.select(u, u), !0;
}
-function tq(e, t) {
+function lq(e, t) {
const n = [];
for (let r = e ? e.getNextSibling() : Me().getFirstChild(); r && !r.is(t); r = r.getNextSibling())
n.push(r);
return n;
}
-const nq = /^\+/;
-function wu(e, t) {
- const n = t.replace(nq, "");
+const uq = /^\+/;
+function $u(e, t) {
+ const n = t.replace(uq, "");
return Object.hasOwn(e.markers, n) ? e.markers[n] : void 0;
}
function ic(e, t) {
- const n = wu(e, t);
+ const n = $u(e, t);
if (n)
return { marker: t, rank: n.rank ?? 0, occursUnder: n.occursUnder ?? [] };
}
-function dS(e, t) {
+function yS(e, t) {
if (e.length === 0) return { keep: 0, joins: !0 };
if (t.occursUnder.length === 0) return { keep: e.length, joins: !1 };
for (let n = e.length - 1; n >= 0; n--)
if (t.occursUnder.includes(e[n].marker) && (n === e.length - 1 || t.rank === 0 || e[n + 1].rank <= t.rank))
return { keep: n + 1, joins: !0 };
}
-function kg(e, t) {
- return dS(e, t) !== void 0;
+function Sg(e, t) {
+ return yS(e, t) !== void 0;
}
-function lb(e, t) {
- const n = dS(e, t);
+function hb(e, t) {
+ const n = yS(e, t);
return n ? (n.joins && (e.length = n.keep, e.push(t)), !0) : !1;
}
-function xg(e, t, n) {
+function _g(e, t, n) {
const r = ic(t, n);
- return r ? lb(e, r) ? "valid" : "invalid" : (lb(e, { marker: n, rank: 0, occursUnder: [] }), "unknown");
+ return r ? hb(e, r) ? "valid" : "invalid" : (hb(e, { marker: n, rank: 0, occursUnder: [] }), "unknown");
}
-function Nu(e, t) {
+function Ru(e, t) {
const n = [];
- for (const r of t) xg(n, e, r);
+ for (const r of t) _g(n, e, r);
return n;
}
-function rq(e) {
+function fq(e) {
const t = ic(e, "c") ?? { marker: "c", rank: 0, occursUnder: ["id"] };
- return [...Nu(e, ["id"]), { ...t, rank: Number.POSITIVE_INFINITY }];
+ return [...Ru(e, ["id"]), { ...t, rank: Number.POSITIVE_INFINITY }];
}
-function Tg(e) {
- if (qe(e) || ot(e) || ke(e)) return e.getMarker();
+function Eg(e) {
+ if (qe(e) || Ye(e) || ke(e)) return e.getMarker();
}
-function Wd(e, t, n) {
+function Gd(e, t, n) {
const r = A(e) ? e.getChildren().filter($) : [];
if (r.length === 0) {
n.set(e.getKey(), t);
@@ -28413,91 +28467,91 @@ function Wd(e, t, n) {
}
for (const i of r) n.set(i.getKey(), t);
}
-function iq(e, t, n, r, i) {
- const s = wu(r, t);
+function dq(e, t, n, r, i) {
+ const s = $u(r, t);
if (!s) {
- Wd(e, "unknown", i);
+ Gd(e, "unknown", i);
return;
}
if (n === void 0) return;
const o = s.occursUnder ?? [];
- o.length > 0 && !o.includes(n) && Wd(e, "invalid", i);
+ o.length > 0 && !o.includes(n) && Gd(e, "invalid", i);
}
-function ho(e, t, n, r, i) {
+function go(e, t, n, r, i) {
for (const s of e.getChildren())
if (z(s)) {
const o = s.getMarker();
- i || iq(s, o, t, n, r), ho(s, t, n, r, i || o === "xq");
+ i || dq(s, o, t, n, r), go(s, t, n, r, i || o === "xq");
} else if (Oe(s)) {
if (i) continue;
- const o = wu(n, "v");
+ const o = $u(n, "v");
o ? t !== void 0 && (o.occursUnder ?? []).length > 0 && !(o.occursUnder ?? []).includes(t) && r.set(s.getKey(), "invalid") : r.set(s.getKey(), "unknown");
- } else K(s) ? ho(s, s.getMarker(), n, r, i) : Ie(s) || A(s) && ho(s, t, n, r, i);
+ } else K(s) ? go(s, s.getMarker(), n, r, i) : Ie(s) || A(s) && go(s, t, n, r, i);
}
-function sq(e, t) {
+function pq(e, t) {
const n = /* @__PURE__ */ new Map(), r = [], i = (s) => !t || t.has(s.getKey());
for (const s of Me().getChildren()) {
if (Ie(s)) continue;
- const o = Tg(s);
+ const o = Eg(s);
if (o !== void 0) {
- const a = xg(r, e, o);
- a !== "valid" && Wd(s, a, n);
+ const a = _g(r, e, o);
+ a !== "valid" && Gd(s, a, n);
}
- qe(s) ? i(s) && ho(s, void 0, e, n, !1) : ot(s) || (ke(s) ? i(s) && ho(s, s.getMarker(), e, n, !1) : A(s) && i(s) && ho(s, "p", e, n, !1));
+ qe(s) ? i(s) && go(s, void 0, e, n, !1) : Ye(s) || (ke(s) ? i(s) && go(s, s.getMarker(), e, n, !1) : A(s) && i(s) && go(s, "p", e, n, !1));
}
return n;
}
-function pS() {
+function bS() {
const e = Me().getChildren().find(qe)?.getCode();
- return !e || !Wg.isExtraMaterial(e) || Wg.extraBooks().includes(e);
+ return !e || !Xg.isExtraMaterial(e) || Xg.extraBooks().includes(e);
}
-function Cg(e) {
- return e === 1 && pS() && !Me().getChildren().some(ot);
+function Mg(e) {
+ return e === 1 && bS() && !Me().getChildren().some(Ye);
}
-function vg(e) {
- if (!Cg(e)) return !1;
+function Pg(e) {
+ if (!Mg(e)) return !1;
const t = M();
return E(t) ? t.isCollapsed() && !hn(t.focus.getNode()) : !t?.getNodes().some((n) => hn(n));
}
-function oq(e) {
- const t = rq(e), n = Nu(e, ["id"]);
+function hq(e) {
+ const t = fq(e), n = Ru(e, ["id"]);
return Me().getChildren().find((r) => {
if (qe(r)) return !1;
- const i = Tg(r);
+ const i = Eg(r);
if (i === void 0) return !0;
- const s = xg(n, e, i), o = ic(e, i);
- return !o || o.occursUnder.length === 0 ? !0 : s === "invalid" && kg(t, o);
+ const s = _g(n, e, i), o = ic(e, i);
+ return !o || o.occursUnder.length === 0 ? !0 : s === "invalid" && Sg(t, o);
});
}
-function aq(e, t) {
- return !T(e) || Xp(e) ? !1 : (gt(t) ? Ed(e.getTextContent()) : e.getTextContent()).replaceAll(mo, "").trim() !== "";
+function gq(e, t) {
+ return !C(e) || Zp(e) ? !1 : (mt(t) ? Pd(e.getTextContent()) : e.getTextContent()).replaceAll(yo, "").trim() !== "";
}
-function cq(e, t) {
+function mq(e, t) {
for (const { node: n } of ja(e, Me().getLastDescendant() ?? e))
- if (Oe(n) || K(n) || Ve(n) || Ie(n) || aq(n, t))
+ if (Oe(n) || K(n) || Ve(n) || Ie(n) || gq(n, t))
return !0;
return !1;
}
-function Sg({
+function Ag({
chapterNum: e,
verseCount: t = 0,
viewOptions: n,
styleInfo: r = ks
}) {
- if (!Cg(e)) return !1;
- const i = oq(r), s = t > 0 && i && cq(i, n) ? 0 : t, o = [{ type: "chapter", marker: "c", number: `${e}` }];
+ if (!Mg(e)) return !1;
+ const i = hq(r), s = t > 0 && i && mq(i, n) ? 0 : t, o = [{ type: "chapter", marker: "c", number: `${e}` }];
for (let d = 1; d <= s; d += 1)
o.push({ type: "verse", marker: "v", number: `${d}` });
- const c = pr.serializeEditorState(
+ const c = hr.serializeEditorState(
{ type: fr, version: ur, content: o },
n
).root.children.map((d) => Ir(d));
for (const d of c)
i ? i.insertBefore(d) : Me().append(d);
const [l, u] = c, f = A(u) ? u.getFirstChild() : void 0;
- return A(l) ? l.selectEnd() : f ? f.selectNext() : (ke(i) || kt(i)) && i.select(0, 0), !0;
+ return A(l) ? l.selectEnd() : f ? f.selectNext() : (ke(i) || ht(i)) && i.select(0, 0), !0;
}
-const hS = {
+const kS = {
c: {
// Deliberately still trusts reference.chapterNum, unlike `v` below - the chapter-number
// reinstatement work (a separate branch/PR) owns rewriting this action to scan the tree.
@@ -28506,23 +28560,23 @@ const hS = {
return { content: [{
type: "chapter",
marker: "c",
- number: `${kx(Me().getChildren(), t) !== void 0 ? t + 1 : t}`
+ number: `${vx(Me().getChildren(), t) !== void 0 ? t + 1 : t}`
}] };
}
},
v: {
action: () => {
- const e = M(), t = Mx(e), n = ph(t);
+ const e = M(), t = Nx(e), n = gh(t);
let r, i = !1;
if (!n)
r = "1";
else {
const o = n.getNumber();
- r = vP(0, o);
- const a = qA(n);
+ r = PP(0, o);
+ const a = FA(n);
if (a) {
const c = a.getNumber();
- i = r === c || SP(c) && Hp(parseInt(r, 10), c);
+ i = r === c || AP(c) && Jp(parseInt(r, 10), c);
}
}
return { content: [{
@@ -28533,35 +28587,35 @@ const hS = {
}
}
};
-function Hd(e, t) {
- return at.isValidMarker(e, t) || !!hS[e] || Kt.isValidMarker(e, t) || nt.isValidMarker(e, t);
+function Jd(e, t) {
+ return lt.isValidMarker(e, t) || !!kS[e] || Kt.isValidMarker(e, t) || rt.isValidMarker(e, t);
}
-function lq(e, t) {
- return nt.isNoteContentMarker(e) ? !1 : nt.isValidMarker(e, t);
+function yq(e, t) {
+ return rt.isNoteContentMarker(e) ? !1 : rt.isValidMarker(e, t);
}
-function gS(e, t, n, r, i, s) {
- const o = RT(
+function xS(e, t, n, r, i, s) {
+ const o = DT(
e,
void 0,
void 0,
t,
- r ?? Co(),
+ r ?? vo(),
i ?? {},
s
);
return o && !o.getIsCollapsed() && (n.current = o.getKey()), o?.getKey();
}
-function Gd(e, t, n, r, i, s, o) {
+function Yd(e, t, n, r, i, s, o) {
const a = {
- viewOptions: n ?? Co(),
- getMarker: lh(o ?? ks),
+ viewOptions: n ?? vo(),
+ getMarker: fh(o ?? ks),
logger: i
};
- if (at.isValidMarker(e, r?.extraValidMarkers)) {
+ if (lt.isValidMarker(e, r?.extraValidMarkers)) {
let u;
return { action: (d) => {
d.editor.update(() => {
- Vd(a) && (u = gS(
+ Hd(a) && (u = xS(
e,
d.reference,
t,
@@ -28572,91 +28626,91 @@ function Gd(e, t, n, r, i, s, o) {
}, s);
}, label: void 0, getInsertedNoteKey: () => u };
}
- const c = gq(e, r?.extraValidMarkers);
+ const c = vq(e, r?.extraValidMarkers);
return c ? { action: (u) => {
u.editor.update(() => {
if (e === "c") {
const { chapterNum: g } = u.reference;
- if (!pS()) return;
- if (Cg(g)) {
- vg(g) && Sg({ chapterNum: g, viewOptions: n, styleInfo: o });
+ if (!bS()) return;
+ if (Mg(g)) {
+ Pg(g) && Ag({ chapterNum: g, viewOptions: n, styleInfo: o });
return;
}
}
- if (!Vd(a)) return;
+ if (!Hd(a)) return;
const f = M();
- E(f) && (ch(f), u.noteText = f.getTextContent());
- const { content: d, highlightInserted: p } = c.action(u), m = wm(d, pr, n), h = zu(m);
+ E(f) && (uh(f), u.noteText = f.getTextContent());
+ const { content: d, highlightInserted: p } = c.action(u), m = Im(d, hr, n), h = Wu(m);
if (E(f)) {
- const g = f.anchor.getNode(), y = g.getParent(), b = ys(g), C = f.anchor.key === f.focus.key;
- if (z(h) && b && C && !Ef(h, o))
- dq(
+ const g = f.anchor.getNode(), y = g.getParent(), b = ys(g), T = f.anchor.key === f.focus.key;
+ if (z(h) && b && T && !Af(h, o))
+ xq(
f,
h,
g,
n?.markerMode === "editable"
);
- else if (z(h) && !C && !Ef(h, o) && pq(f))
- hq(f, h, n?.markerMode === "editable");
+ else if (z(h) && !T && !Af(h, o) && Tq(f))
+ Cq(f, h, n?.markerMode === "editable");
else if (f.getTextContent().length > 0)
- mq(
+ Sq(
f,
- () => zu(m)
+ () => Wu(m)
);
else if (A(h) && !h.isInline()) {
const x = f.insertParagraph();
if (x) {
const _ = x.getChildren();
- h.append(..._), x.replace(h), dt(h) && Sn(h) || h.selectStart();
+ h.append(..._), x.replace(h), ot(h) && Sn(h) || h.selectStart();
}
- } else if (z(h) && T(g) && !$(g) && z(g.getParent()) && f.isCollapsed() && // NEST-able only. A non-NEST style at a caret inside ANY char span — nested or note-level
+ } else if (z(h) && C(g) && !$(g) && z(g.getParent()) && f.isCollapsed() && // NEST-able only. A non-NEST style at a caret inside ANY char span — nested or note-level
// — is already claimed by the `$applyNonNestInsideChar` branch above, whose guard is this
// one minus this test. Stating it here rather than branching on it inside keeps that
// division visible at the guard instead of implying a second non-NEST path exists.
- Ef(h, o)) {
+ Af(h, o)) {
const x = g.getParent();
if (z(x)) {
const _ = f.anchor.offset;
if (_ === 0) g.insertBefore(h);
else if (_ >= g.getTextContentSize()) g.insertAfter(h);
else {
- const [R] = g.splitText(_);
- R.insertAfter(h);
+ const [I] = g.splitText(_);
+ I.insertAfter(h);
}
- h.getChildren().forEach((R) => {
- $(R) && R.setNested(!0);
+ h.getChildren().forEach((I) => {
+ $(I) && I.setNested(!0);
});
- const F = h.getChildren().find((R) => T(R) && !$(R));
- F && T(F) ? F.select(
- F.getTextContentSize(),
- F.getTextContentSize()
+ const U = h.getChildren().find((I) => C(I) && !$(I));
+ U && C(U) ? U.select(
+ U.getTextContentSize(),
+ U.getTextContentSize()
) : h.selectEnd();
}
- } else if (T(g) && !$(g) && f.isCollapsed() && (K(y) || z(y) && K(y.getParent()))) {
- const x = z(y) ? y : void 0, _ = x ? uq(g, f.anchor.offset) : [];
- let R = (x ?? g).insertAfter(h);
- if (On(h)) {
- const W = {
- ...n || Co(),
+ } else if (C(g) && !$(g) && f.isCollapsed() && (K(y) || z(y) && K(y.getParent()))) {
+ const x = z(y) ? y : void 0, _ = x ? bq(g, f.anchor.offset) : [];
+ let I = (x ?? g).insertAfter(h);
+ if ($n(h)) {
+ const V = {
+ ...n || vo(),
markerMode: "hidden"
- }, ce = wm(
+ }, ce = Im(
d,
- pr,
- W
- ), se = zu(ce);
- R = R.insertAfter(se);
+ hr,
+ V
+ ), se = Wu(ce);
+ I = I.insertAfter(se);
}
if (_.length > 0 && x) {
- const W = _l(x).append(..._);
- R.insertAfter(W), x.isEmpty() && x.remove();
- } else T(R.getNextSibling()) || R.insertAfter(ms());
- A(R) && R.selectEnd();
- } else if (f.insertNodes([h]), Eq(h), p) {
- const x = cp();
+ const V = Ml(x).append(..._);
+ I.insertAfter(V), x.isEmpty() && x.remove();
+ } else C(I.getNextSibling()) || I.insertAfter(ms());
+ A(I) && I.selectEnd();
+ } else if (f.insertNodes([h]), Rq(h), p) {
+ const x = up();
x.add(h.getKey()), Mt(x);
} else if (z(h)) {
- const x = h.getChildren().find((_) => T(_) && !$(_));
- x && T(x) ? x.select(
+ const x = h.getChildren().find((_) => C(_) && !$(_));
+ x && C(x) ? x.select(
x.getTextContentSize(),
x.getTextContentSize()
) : h.selectEnd();
@@ -28672,15 +28726,15 @@ function Gd(e, t, n, r, i, s, o) {
}, label: c?.label } : { action: () => {
}, label: void 0 };
}
-function uq(e, t) {
+function bq(e, t) {
const n = e.getTextContentSize();
let r;
return t <= 0 ? r = e : t >= n ? r = e.getNextSibling() : r = e.splitText(t)[1] ?? e.getNextSibling(), r ? [r, ...r.getNextSiblings()] : [];
}
-function Ef(e, t) {
+function Af(e, t) {
return ((t ?? ks).markers[e.getMarker()]?.occursUnder ?? []).includes("NEST") && e.getUnknownAttributes()?.closed !== "false";
}
-function fq(e, t) {
+function kq(e, t) {
t && e.getChildren().forEach((i) => {
$(i) && i.setNested(!0);
}), e.getChildren().some((i) => $(i) && i.getMarkerSyntax() === "closing") || e.append(Jt(e.getMarker(), "closing", t));
@@ -28690,19 +28744,19 @@ function fq(e, t) {
delete i.closed, e.setUnknownAttributes(Object.keys(i).length > 0 ? i : void 0);
}
}
-function dq(e, t, n, r) {
+function xq(e, t, n, r) {
let i = t;
if (e.anchor.type === "element" && z(n)) {
const o = n.getChildren(), a = o[e.anchor.offset - 1], c = o[e.anchor.offset];
a ? a.insertAfter(t) : c ? c.insertBefore(t) : n.append(t);
- } else if (e.isCollapsed() || !T(n)) {
+ } else if (e.isCollapsed() || !C(n)) {
const o = e.anchor.offset;
- if (T(n) && o > 0 && o < n.getTextContentSize()) {
+ if (C(n) && o > 0 && o < n.getTextContentSize()) {
const [a] = n.splitText(o);
a.insertAfter(t);
- } else T(n) && o >= n.getTextContentSize() ? n.insertAfter(t) : n.insertBefore(t);
+ } else C(n) && o >= n.getTextContentSize() ? n.insertAfter(t) : n.insertBefore(t);
} else {
- const [o, a] = Mo(e);
+ const [o, a] = Po(e);
let c = n;
if (o > 0) {
const l = c.splitText(o);
@@ -28710,20 +28764,20 @@ function dq(e, t, n, r) {
}
c.getTextContentSize() > a - o && (c = c.splitText(a - o)[0]), i = c;
}
- if (xo(i, { renderGlyphs: r }), i !== t) {
- i.insertBefore(t), T(i) && !i.getTextContent().startsWith(U) && i.setTextContent(U + i.getTextContent());
- const o = t.getChildren().find((a) => T(a) && !$(a));
+ if (To(i, { renderGlyphs: r }), i !== t) {
+ i.insertBefore(t), C(i) && !i.getTextContent().startsWith(B) && i.setTextContent(B + i.getTextContent());
+ const o = t.getChildren().find((a) => C(a) && !$(a));
o ? o.replace(i) : t.append(i);
}
- const s = t.getChildren().find((o) => T(o) && !$(o));
- T(s) ? s.select(s.getTextContentSize(), s.getTextContentSize()) : t.selectEnd();
+ const s = t.getChildren().find((o) => C(o) && !$(o));
+ C(s) ? s.select(s.getTextContentSize(), s.getTextContentSize()) : t.selectEnd();
}
-function pq(e) {
+function Tq(e) {
let t, n = !1;
for (const r of e.getNodes()) {
if ($(r) || z(r)) continue;
- if (!T(r) || r.getType() !== it.getType() || Te(r, _e) === "attribute") return !1;
- const i = oA(r);
+ if (!C(r) || r.getType() !== at.getType() || Te(r, _e) === "attribute") return !1;
+ const i = fA(r);
if (!i) return !1;
if (t === void 0) t = i;
else if (!t.is(i)) return !1;
@@ -28731,18 +28785,18 @@ function pq(e) {
}
return n;
}
-function hq(e, t, n) {
- const r = ZC(e);
+function Cq(e, t, n) {
+ const r = iv(e);
if (r.length === 0) return;
r.forEach((a) => {
if (!ys(a)) return;
- xo(a, { renderGlyphs: n });
+ To(a, { renderGlyphs: n });
const c = a.getLatest(), l = c.getTextContent();
- l.startsWith(U) && c.setTextContent(l.slice(U.length));
+ l.startsWith(B) && c.setTextContent(l.slice(B.length));
});
const i = r[0].getLatest();
- i.insertBefore(t), i.getTextContent().startsWith(U) || i.setTextContent(U + i.getTextContent());
- const s = t.getChildren().find((a) => T(a) && !$(a));
+ i.insertBefore(t), i.getTextContent().startsWith(B) || i.setTextContent(B + i.getTextContent());
+ const s = t.getChildren().find((a) => C(a) && !$(a));
s ? s.replace(i) : t.append(i);
let o = i.getLatest();
r.slice(1).forEach((a) => {
@@ -28750,24 +28804,24 @@ function hq(e, t, n) {
o.insertAfter(c), o = c;
}), o.select(o.getTextContentSize(), o.getTextContentSize());
}
-function gq(e, t) {
- let n = hS[e];
+function vq(e, t) {
+ let n = kS[e];
return n || (Kt.isValidMarker(e, t) ? n = {
action: () => ({ content: [{ type: Kt.getType(), marker: e, content: [] }] })
- } : nt.isValidMarker(e, t) && (n = {
+ } : rt.isValidMarker(e, t) && (n = {
action: () => {
- const r = { type: nt.getType(), marker: e };
- return (nt.isValidFootnoteMarker(e) || nt.isValidCrossReferenceMarker(e)) && (r.closed = "false"), { content: [r] };
+ const r = { type: rt.getType(), marker: e };
+ return (rt.isValidFootnoteMarker(e) || rt.isValidCrossReferenceMarker(e)) && (r.closed = "false"), { content: [r] };
}
})), n;
}
-function mq(e, t) {
- const n = e.getNodes(), [r, i] = Mo(e);
+function Sq(e, t) {
+ const n = e.getNodes(), [r, i] = Po(e);
let s;
n.forEach((o, a) => {
if (A(s) && s.isParentOf(o))
return;
- const c = mS(
+ const c = TS(
o,
a === 0,
a === n.length - 1,
@@ -28779,33 +28833,33 @@ function mq(e, t) {
return;
}
let l = !1;
- s || (s = t(), c.insertBefore(s), l = !0, z(s) && s.getChildren().some((f) => $(f) && f.getMarkerSyntax() === "opening") && fq(s, z(s.getParent()))), bq(c, s, l);
- }), (T(s) || A(s)) && s.selectEnd();
+ s || (s = t(), c.insertBefore(s), l = !0, z(s) && s.getChildren().some((f) => $(f) && f.getMarkerSyntax() === "opening") && kq(s, z(s.getParent()))), Eq(c, s, l);
+ }), (C(s) || A(s)) && s.selectEnd();
}
-function Mo(e) {
+function Po(e) {
const t = e.anchor.offset, n = e.focus.offset;
return e.isBackward() ? [n, t] : [t, n];
}
-function _g(e) {
- return ge(e) || K(e) || K(e.getParent());
+function wg(e) {
+ return me(e) || K(e) || K(e.getParent());
}
-function mS(e, t, n, r, i) {
- if (!_g(e)) {
- if (T(e))
- return yq(e, t, n, r, i);
+function TS(e, t, n, r, i) {
+ if (!wg(e)) {
+ if (C(e))
+ return _q(e, t, n, r, i);
if (A(e) && e.isInline())
return e;
}
}
-function yq(e, t, n, r, i) {
+function _q(e, t, n, r, i) {
const s = e.getTextContentSize(), o = t ? r : 0, a = n ? i : s;
if (o === 0 && a === 0) return;
const c = e.splitText(o, a);
return c.length === 1 ? c[0] : c.length === 3 || a === s ? c[1] : c[0];
}
-function bq(e, t, n) {
- if (T(t)) {
- const r = Jd(e, t);
+function Eq(e, t, n) {
+ if (C(t)) {
+ const r = Xd(e, t);
t.setTextContent(r), e.remove();
} else if (A(t)) {
const r = t.getChildren(), i = r.find(
@@ -28819,32 +28873,32 @@ function bq(e, t, n) {
for (let o = 0; o < s; o++) t.getFirstChild()?.remove();
} else
t.append(e);
- Jd(e, t), n && z(t) && t.getChildren().some((s) => $(s)) && T(e) && !$(e) && !e.getTextContent().startsWith(U) && e.setTextContent(U + e.getTextContent());
+ Xd(e, t), n && z(t) && t.getChildren().some((s) => $(s)) && C(e) && !$(e) && !e.getTextContent().startsWith(B) && e.setTextContent(B + e.getTextContent());
}
}
-function Jd(e, t) {
+function Xd(e, t) {
let n = e.getTextContent();
- if (T(e) && t.isInline() && n.startsWith(" ") && n.trimStart() !== "") {
+ if (C(e) && t.isInline() && n.startsWith(" ") && n.trimStart() !== "") {
n = n.trimStart(), e.setTextContent(n);
const r = t.getPreviousSibling();
- fh(r), T(r) || t.insertBefore(Ue(" "));
+ ph(r), C(r) || t.insertBefore(Be(" "));
}
return n;
}
-function yS(e, t, n) {
+function CS(e, t, n) {
if (e.isCollapsed()) {
const u = e.anchor.getNode(), f = e.anchor.offset, d = _s(u, t);
if (!d) return !1;
- const p = T(u) ? u.getTextContentSize() : 0;
- if (ub(d, n), T(u) && u.isAttached()) {
+ const p = C(u) ? u.getTextContentSize() : 0;
+ if (gb(d, n), C(u) && u.isAttached()) {
const m = u.getTextContentSize(), h = Math.max(p - m, 0), g = Math.max(0, Math.min(f - h, m)), y = M();
E(y) && y.setTextNodeRange(u, g, u, g);
}
return !0;
}
- const r = e.getNodes(), i = e.isBackward(), [s, o] = Mo(e);
- if (!Mg(r, t, s, o)) return !1;
- const a = Eg(r, s, o);
+ const r = e.getNodes(), i = e.isBackward(), [s, o] = Po(e);
+ if (!Og(r, t, s, o)) return !1;
+ const a = Ng(r, s, o);
if (a.length === 0) return !1;
const c = /* @__PURE__ */ new Set();
let l = !1;
@@ -28852,11 +28906,11 @@ function yS(e, t, n) {
const f = _s(u, t);
if (!f || c.has(f.getKey())) return;
c.add(f.getKey());
- const d = TS(f, a);
- d && (ub(d, n), l = !0);
- }), CS(a, i), l;
+ const d = ES(f, a);
+ d && (gb(d, n), l = !0);
+ }), MS(a, i), l;
}
-function ub(e, t) {
+function gb(e, t) {
e.getChildren().forEach((r) => {
Zt(r) && r.remove();
});
@@ -28867,142 +28921,142 @@ function ub(e, t) {
}
t?.markerMode === "editable" && n.forEach((r) => {
const i = r.getTextContent();
- T(r) && i.startsWith(U) && r.setTextContent(i.slice(U.length));
- }), Lf(e);
+ C(r) && i.startsWith(B) && r.setTextContent(i.slice(B.length));
+ }), Kf(e);
}
-function Eg(e, t, n) {
+function Ng(e, t, n) {
const r = [];
return e.forEach((i, s) => {
- const o = mS(
+ const o = TS(
i,
s === 0,
s === e.length - 1,
t,
n
);
- T(o) && r.push(o);
+ C(o) && r.push(o);
}), r;
}
function _s(e, t) {
let n = e, r;
- for (; n && !dt(n); ) {
+ for (; n && !ot(n); ) {
if (K(n)) return;
!r && z(n) && (t === void 0 || n.getMarker() === t) && (r = n), n = n.getParent();
}
return r;
}
-function bS(e) {
+function vS(e) {
const t = We(
e,
- (n) => K(n) || dt(n)
+ (n) => K(n) || ot(n)
);
return K(t);
}
-function kS(e) {
+function SS(e) {
return e.filter(
- (t) => !_g(t) && (T(t) || A(t) && t.isInline())
+ (t) => !wg(t) && (C(t) || A(t) && t.isInline())
);
}
-function kq(e, t, n) {
+function Mq(e, t, n) {
const r = /* @__PURE__ */ new Set();
return e.forEach((i, s) => {
- if (!T(i) || _g(i)) return;
+ if (!C(i) || wg(i)) return;
const o = i.getTextContentSize(), a = s === 0 ? t : 0, c = s === e.length - 1 ? n : o;
a === 0 && c === o && r.add(i.getKey());
}), r;
}
-function xq(e, t, n) {
+function Pq(e, t, n) {
return e.getChildren().some(
- (r) => A(r) && t.some((i) => r.isParentOf(i)) && !xS(r, n)
+ (r) => A(r) && t.some((i) => r.isParentOf(i)) && !_S(r, n)
);
}
-function Mg(e, t, n, r, i) {
- const s = kS(e), o = kq(e, n, r), a = /* @__PURE__ */ new Set();
+function Og(e, t, n, r, i) {
+ const s = SS(e), o = Mq(e, n, r), a = /* @__PURE__ */ new Set();
return s.some((c) => {
const l = _s(c, t);
- return !l || a.has(l.getKey()) || (a.add(l.getKey()), l.getMarker() === i) ? !1 : !xq(l, s, o);
+ return !l || a.has(l.getKey()) || (a.add(l.getKey()), l.getMarker() === i) ? !1 : !Pq(l, s, o);
});
}
-function xS(e, t) {
+function _S(e, t) {
return e.getAllTextNodes().every((n) => t.has(n.getKey()) || Zt(n));
}
-function TS(e, t) {
+function ES(e, t) {
const n = new Set(t.map((l) => l.getKey())), r = e.getChildren(), i = [];
for (const [l, u] of r.entries())
if (n.has(u.getKey()))
i.push(l);
else if (A(u) && t.some((f) => u.isParentOf(f))) {
- if (!xS(u, n)) return;
+ if (!_S(u, n)) return;
i.push(l);
}
if (i.length === 0) return;
let s = i[0], o = i[i.length - 1];
if (s > 0 && Zt(r[s - 1]) && (s -= 1), o < r.length - 1 && Zt(r[o + 1]) && (o += 1), s === 0 && o === r.length - 1) return e;
const a = r.slice(o + 1);
- a.length > 0 && e.insertAfter(_l(e).append(...a));
+ a.length > 0 && e.insertAfter(Ml(e).append(...a));
const c = r.slice(0, s);
- return c.length > 0 && e.insertBefore(_l(e).append(...c)), e;
+ return c.length > 0 && e.insertBefore(Ml(e).append(...c)), e;
}
-function _l(e) {
- return w0(e);
+function Ml(e) {
+ return I0(e);
}
-function CS(e, t) {
+function MS(e, t) {
const n = M(), r = e[0], i = e[e.length - 1];
if (!E(n) || !r.isAttached() || !i.isAttached())
return;
const s = i.getTextContentSize();
t ? n.setTextNodeRange(i, s, r, 0) : n.setTextNodeRange(r, 0, i, s);
}
-function Tq(e, t, n) {
+function Aq(e, t, n) {
if (e.isCollapsed()) {
const l = _s(e.anchor.getNode(), n);
- return !l || l.getMarker() === t ? !1 : (hm(l, t), !0);
+ return !l || l.getMarker() === t ? !1 : (km(l, t), !0);
}
- const r = e.getNodes(), [i, s] = Mo(e);
- if (!Mg(r, n, i, s, t)) return !1;
- const o = Eg(r, i, s);
+ const r = e.getNodes(), [i, s] = Po(e);
+ if (!Og(r, n, i, s, t)) return !1;
+ const o = Ng(r, i, s);
if (o.length === 0) return !1;
const a = /* @__PURE__ */ new Set();
let c = !1;
return o.forEach((l) => {
const u = _s(l, n);
if (!u || a.has(u.getKey()) || (a.add(u.getKey()), u.getMarker() === t)) return;
- const f = TS(u, o);
- f && (hm(f, t), c = !0);
+ const f = ES(u, o);
+ f && (km(f, t), c = !0);
}), c;
}
-function Cq(e, t, n, r) {
+function wq(e, t, n, r) {
if (e.isCollapsed()) return !1;
const i = n?.filter(
(g) => g !== t
- ), s = e.getNodes(), [o, a] = Mo(e);
+ ), s = e.getNodes(), [o, a] = Po(e);
if (!!!i?.some(
- (g) => Mg(s, g, o, a)
- ) && !vq(s, t)) return !1;
+ (g) => Og(s, g, o, a)
+ ) && !Nq(s, t)) return !1;
let l = !1;
i?.forEach((g) => {
const y = M();
- E(y) && yS(y, g, r) && (l = !0);
+ E(y) && CS(y, g, r) && (l = !0);
});
const u = M();
if (!E(u)) return l;
- const f = u.isBackward(), [d, p] = Mo(u), m = Eg(
+ const f = u.isBackward(), [d, p] = Po(u), m = Ng(
u.getNodes(),
d,
p
);
if (m.length === 0) return l;
const h = m.filter(
- (g) => !bS(g) && !_s(g, t)
+ (g) => !vS(g) && !_s(g, t)
);
- return h.length > 0 && (Sq(h).forEach((g) => _q(g, t)), l = !0), CS(m, f), l;
+ return h.length > 0 && (Oq(h).forEach((g) => $q(g, t)), l = !0), MS(m, f), l;
}
-function vq(e, t) {
- return kS(e).some(
- (n) => !bS(n) && !_s(n, t)
+function Nq(e, t) {
+ return SS(e).some(
+ (n) => !vS(n) && !_s(n, t)
);
}
-function Sq(e) {
+function Oq(e) {
const t = [];
let n;
return e.forEach((r) => {
@@ -29010,16 +29064,16 @@ function Sq(e) {
n && i?.getNextSibling()?.is(r) ? n.push(r) : (n = [r], t.push(n));
}), t;
}
-function _q(e, t) {
+function $q(e, t) {
const n = e[0].getPreviousSibling(), r = e[e.length - 1].getNextSibling(), i = [n, r].find(
(a) => z(a) && a.getMarker() === t
- ), s = i ? _l(i) : Qr(t);
- e[0].insertBefore(s), s.append(...e), i === n || Jd(e[0], s);
+ ), s = i ? Ml(i) : Zr(t);
+ e[0].insertBefore(s), s.append(...e), i === n || Xd(e[0], s);
}
-function Eq(e) {
- Oe(e) && (fh(e.getPreviousSibling()), sT(e.getNextSibling()));
+function Rq(e) {
+ Oe(e) && (ph(e.getPreviousSibling()), lT(e.getNextSibling()));
}
-const vS = {
+const PS = {
chapter: "chapter",
verse: "verse",
char: "char",
@@ -29034,13 +29088,13 @@ const vS = {
strikethrough: "editor-text-strikethrough",
underlineStrikethrough: "editor-text-underlineStrikethrough"
}
-}, fb = "psc-active-text", Mf = "psc-empty-text", Pf = "psc-empty-text-active";
-function Mq({ viewOptions: e }) {
+}, mb = "psc-active-text", wf = "psc-empty-text", Nf = "psc-empty-text-active";
+function Iq({ viewOptions: e }) {
const [t] = Pe(), n = ae(void 0), r = ae(!1), i = e?.hasActiveTextFocusBox ?? !1;
return J(() => {
if (!i) return;
function s(a) {
- n.current && t.getElementByKey(n.current)?.classList.remove(fb), n.current = a, a && t.getElementByKey(a)?.classList.add(fb);
+ n.current && t.getElementByKey(n.current)?.classList.remove(mb), n.current = a, a && t.getElementByKey(a)?.classList.add(mb);
}
const o = [
// Clicking the ellipsis placeholder (rendered as ::after on the empty verse span) hits the
@@ -29050,11 +29104,11 @@ function Mq({ viewOptions: e }) {
// handlers already run inside an editor update, so we set selection directly here rather than
// calling editor.update() from a DOM listener.
t.registerCommand(
- go,
+ mo,
(a) => {
const c = a.target;
if (!(c instanceof Element)) return !1;
- const l = c.closest(`.${Mf}, .${Pf}`);
+ const l = c.closest(`.${wf}, .${Nf}`);
if (!l) return !1;
const u = qr(l);
if (!Oe(u)) return !1;
@@ -29068,51 +29122,51 @@ function Mq({ viewOptions: e }) {
return !1;
}
const p = u.getIndexWithinParent() + 1, m = f.getChildAtIndex(p);
- return T(m) && Et(m) ? m.select(0, 0) : f.select(p, p), !1;
+ return C(m) && Et(m) ? m.select(0, 0) : f.select(p, p), !1;
},
Nt
),
t.registerUpdateListener(({ editorState: a }) => {
const { newActiveKey: c, activeVerseKey: l, emptyKeys: u, nonEmptyKeys: f } = a.read(() => {
- const m = Af(), h = Pq(), g = [], y = [];
+ const m = Of(), h = Lq(), g = [], y = [];
return Me().getChildren().forEach((b) => {
if (!A(b)) return;
- const { emptyKeys: C, nonEmptyKeys: x } = wq(b);
- g.push(...C), y.push(...x);
+ const { emptyKeys: T, nonEmptyKeys: x } = Dq(b);
+ g.push(...T), y.push(...x);
}), { newActiveKey: m, activeVerseKey: h, emptyKeys: g, nonEmptyKeys: y };
}), d = !r.current, p = d ? c : void 0;
p !== n.current && s(p), u.forEach((m) => {
const h = d && m === l, g = t.getElementByKey(m)?.classList;
- g?.toggle(Mf, !h), g?.toggle(Pf, h);
+ g?.toggle(wf, !h), g?.toggle(Nf, h);
}), f.forEach(
- (m) => t.getElementByKey(m)?.classList.remove(Mf, Pf)
+ (m) => t.getElementByKey(m)?.classList.remove(wf, Nf)
);
}),
t.registerCommand(
- fp,
+ pp,
() => (r.current = !0, s(void 0), !1),
Nt
),
t.registerCommand(
- Kl,
+ Ul,
() => {
r.current = !1;
- const a = t.getEditorState().read(Af);
+ const a = t.getEditorState().read(Of);
return a !== n.current && s(a), !1;
},
Nt
)
];
- return s(t.getEditorState().read(Af)), Ye(...o);
+ return s(t.getEditorState().read(Of)), Xe(...o);
}, [t, i]), null;
}
-function Af() {
- return Aq(M() ?? void 0)?.getKey();
+function Of() {
+ return qq(M() ?? void 0)?.getKey();
}
-function Pq() {
- const e = M(), t = Tr(e);
+function Lq() {
+ const e = M(), t = pr(e);
if (t)
- return t.getChildren().slice(0, su(t)).findLast(Oe)?.getKey();
+ return t.getChildren().slice(0, au(t)).findLast(Oe)?.getKey();
if (!E(e)) return;
const n = e.anchor, r = n.getNode(), i = r.getTopLevelElement();
if (!A(i)) return;
@@ -29132,13 +29186,13 @@ function Pq() {
Oe(o[c]) && (a = o[c].getKey());
return a;
}
-function Aq(e) {
- const t = Tr(e);
+function qq(e) {
+ const t = pr(e);
if (t) return t.getTopLevelElement() ?? t;
if (E(e))
return e.anchor.getNode().getTopLevelElement() ?? void 0;
}
-function wq(e) {
+function Dq(e) {
const t = e.getChildren(), n = [], r = [];
for (let i = 0; i < t.length; i++) {
const s = t[i];
@@ -29147,7 +29201,7 @@ function wq(e) {
for (let a = i + 1; a < t.length; a++) {
const c = t[a];
if (Oe(c)) break;
- if (!(Yt(c) || $(c)) && c.getTextContent().replaceAll(mo, "").trim() !== "") {
+ if (!(Yt(c) || $(c)) && c.getTextContent().replaceAll(yo, "").trim() !== "") {
o = !0;
break;
}
@@ -29156,46 +29210,46 @@ function wq(e) {
}
return { emptyKeys: n, nonEmptyKeys: r };
}
-function Yd(e, t) {
+function Qd(e, t) {
const n = Qa(t);
if (!n?.end) return;
- const r = Nq(e, t);
+ const r = Kq(e, t);
if (r)
return r.state.read(
() => {
const i = wa(n, r.standardViewOptions);
- return i ? yg(i) : void 0;
+ return i ? Cg(i) : void 0;
},
{ editor: r.editor }
);
}
-const wf = /* @__PURE__ */ new WeakMap();
-function Nq(e, t) {
+const $f = /* @__PURE__ */ new WeakMap();
+function Kq(e, t) {
const n = e.getEditorState();
- if (wf.has(n)) {
- const i = wf.get(n);
+ if ($f.has(n)) {
+ const i = $f.get(n);
if (!i || i.viewOptions === t) return i;
}
- const r = Oq(n, t);
- return wf.set(n, r), r;
+ const r = Bq(n, t);
+ return $f.set(n, r), r;
}
-function Oq(e, t) {
- const n = Ch(kh);
+function Bq(e, t) {
+ const n = Sh(Th);
if (!n) return;
const r = to.deserializeEditorState(e, t);
if (!r) return;
- const i = hp({
+ const i = mp({
namespace: "markers-view-copy",
- nodes: [vt, ...au],
+ nodes: [vt, ...lu],
onError: (o) => {
throw o;
}
}), s = i.parseEditorState(
- pr.serializeEditorState(r, n)
+ hr.serializeEditorState(r, n)
);
return { viewOptions: t, standardViewOptions: n, editor: i, state: s };
}
-function $q({
+function Uq({
viewOptions: e,
copyLimit: t
}) {
@@ -29204,8 +29258,8 @@ function $q({
const r = (i, s) => {
const o = M();
if (!E(o) || o.isCollapsed()) return !1;
- const a = Yd(n, e);
- return a === void 0 ? !1 : cS(
+ const a = Qd(n, e);
+ return a === void 0 ? !1 : pS(
// COPY_COMMAND's payload is `ClipboardEvent | KeyboardEvent | null`, and jsdom (our test
// environment) has no `ClipboardEvent` for `instanceof` to narrow against, so this
// duck-checks the one property `$writeCopyPayload` needs. `in` throws on a non-object, so
@@ -29213,52 +29267,52 @@ function $q({
i && typeof i == "object" && "clipboardData" in i ? i : null,
n,
o,
- { "text/plain": a, "text/html": aS(a) },
+ { "text/plain": a, "text/html": dS(a) },
s,
t
);
};
- return Ye(
- n.registerCommand(Xr, (i) => r(i, !1), Je),
- n.registerCommand(wn, (i) => r(i, !0), Je)
+ return Xe(
+ n.registerCommand(Qr, (i) => r(i, !1), Je),
+ n.registerCommand(Nn, (i) => r(i, !0), Je)
);
}, [n, e, t]), null;
}
-const db = /* @__PURE__ */ new WeakMap();
-function Rq({
+const yb = /* @__PURE__ */ new WeakMap();
+function Fq({
limit: e,
viewOptions: t
}) {
- const [n] = Pe(), r = ae(Ud(e)), i = ae(t), s = ae(!1), o = ae(void 0);
+ const [n] = Pe(), r = ae(Fd(e)), i = ae(t), s = ae(!1), o = ae(void 0);
return J(() => {
- r.current = Ud(e), i.current = t, o.current?.();
+ r.current = Fd(e), i.current = t, o.current?.();
}, [e, t]), J(() => {
let a, c;
const l = (y) => {
const b = r.current;
if (b === void 0) return;
- const C = db.get(y);
- if (y.defaultPrevented && C === void 0) return;
+ const T = yb.get(y);
+ if (y.defaultPrevented && T === void 0) return;
const x = n.getRootElement();
if (!x) return;
const _ = x.ownerDocument.getSelection();
- if (!_ || !qq(_, x)) return;
+ if (!_ || !Vq(_, x)) return;
y.preventDefault();
- const F = Yv(
- C ?? _.toString().replaceAll(U, " "),
+ const U = tS(
+ T ?? _.toString().replaceAll(B, " "),
b
);
- db.set(y, F);
- const R = y.clipboardData;
- if (R) {
- if (!F) {
- C !== void 0 && R.clearData();
+ yb.set(y, U);
+ const I = y.clipboardData;
+ if (I) {
+ if (!U) {
+ T !== void 0 && I.clearData();
return;
}
- R.setData("text/plain", F);
+ I.setData("text/plain", U);
}
}, u = (y) => {
- r.current !== void 0 && hi(y, "a", { ctrlKey: !mr, metaKey: mr }) && (Kq(c?.activeElement, n.getRootElement()) || y.preventDefault());
+ r.current !== void 0 && gi(y, "a", { ctrlKey: !yr, metaKey: yr }) && (Hq(c?.activeElement, n.getRootElement()) || y.preventDefault());
}, f = () => {
c?.removeEventListener("copy", l), c?.removeEventListener("keydown", u, !0), c = void 0;
}, d = () => {
@@ -29268,43 +29322,43 @@ function Rq({
o.current = d;
const p = (y) => (y?.preventDefault(), !0), m = (y) => {
const b = r.current;
- if (b === void 0 || (s.current = !1, Jv(n, y))) return !1;
+ if (b === void 0 || (s.current = !1, eS(n, y))) return !1;
if (b <= 0) return p(y);
- const C = M();
- if (Ns(C))
- return C.getTextContent().length + Xv(C.getNodes()) <= b ? !1 : p(y);
- if (!E(C) || C.isCollapsed()) return !1;
- const x = Iq(n, i.current);
- return x.$size(C) <= b ? !1 : (yL(b, x.options), C.isCollapsed() ? p(y) : (n.isEditable() || ek(() => Lq(n)), s.current = !0, !1));
+ const T = M();
+ if (Ns(T))
+ return T.getTextContent().length + nS(T.getNodes()) <= b ? !1 : p(y);
+ if (!E(T) || T.isCollapsed()) return !1;
+ const x = zq(n, i.current);
+ return x.$size(T) <= b ? !1 : (_L(b, x.options), T.isCollapsed() ? p(y) : (n.isEditable() || sk(() => jq(n)), s.current = !0, !1));
}, h = (y, b) => {
if (r.current === void 0 || !s.current) return !1;
s.current = !1;
- const C = M();
- if (!E(C) || C.isCollapsed()) return !1;
- const x = b && n.isEditable() && !CL(C);
- return jd(
+ const T = M();
+ if (!E(T) || T.isCollapsed()) return !1;
+ const x = b && n.isEditable() && !wL(T);
+ return Wd(
y && typeof y == "object" && "clipboardData" in y ? y : null,
n,
- { "text/plain": gg(C, Bd) },
- x ? () => C.removeText() : void 0
+ { "text/plain": xg(T, jd) },
+ x ? () => T.removeText() : void 0
);
- }, g = Ye(
- n.registerCommand(Xr, m, ye),
- n.registerCommand(wn, m, ye),
+ }, g = Xe(
+ n.registerCommand(Qr, m, ye),
+ n.registerCommand(Nn, m, ye),
n.registerCommand(
- Xr,
+ Qr,
(y) => h(y, !1),
$r
),
n.registerCommand(
- wn,
+ Nn,
(y) => h(y, !0),
$r
),
// The page key-down listener's `preventDefault` does not stop an editable editor from
// dispatching its own Select All, so this swallows it. A read-only editor never dispatches it.
n.registerCommand(
- Qb,
+ rk,
(y) => r.current === void 0 ? !1 : (y?.preventDefault(), !0),
ye
),
@@ -29317,40 +29371,40 @@ function Rq({
};
}, [n]), null;
}
-function Iq(e, t) {
- if (gt(t)) {
- const r = (i) => yg(i).length;
+function zq(e, t) {
+ if (mt(t)) {
+ const r = (i) => Cg(i).length;
return { $size: r, options: { $measure: r } };
}
const n = t?.markerMode === "visible" ? t : void 0;
- if (n && Yd(e, n) !== void 0) {
- const r = (i) => Yd(e, n)?.length ?? gg(i, Bd).length;
+ if (n && Qd(e, n) !== void 0) {
+ const r = (i) => Qd(e, n)?.length ?? xg(i, jd).length;
return { $size: r, options: { $measure: r } };
}
return {
- $size: (r) => r.getTextContent().length + Xv(r.getNodes()),
- options: { $isHidden: Bd }
+ $size: (r) => r.getTextContent().length + nS(r.getNodes()),
+ options: { $isHidden: jd }
};
}
-function Lq(e) {
+function jq(e) {
e.getEditorState().read(() => {
const t = M(), n = e.getRootElement()?.ownerDocument.getSelection();
if (!E(t) || !n) return;
- const r = pb(e, t.anchor), i = pb(e, t.focus);
+ const r = bb(e, t.anchor), i = bb(e, t.focus);
r && i && n.setBaseAndExtent(...r, ...i);
});
}
-function pb(e, t) {
+function bb(e, t) {
const n = e.getElementByKey(t.key);
if (!n) return;
if (t.type === "text") {
- const a = N0(n);
+ const a = L0(n);
return a ? [a, t.offset] : void 0;
}
const r = t.getNode(), i = A(r) ? r.getChildAtIndex(t.offset) : null, s = i ? e.getElementByKey(i.getKey()) : null, o = s?.parentNode;
return !s || !o ? [n, n.childNodes.length] : [o, Array.prototype.indexOf.call(o.childNodes, s)];
}
-function qq(e, t) {
+function Vq(e, t) {
const n = t.ownerDocument.createRange();
n.selectNodeContents(t);
for (let r = 0; r < e.rangeCount; r++) {
@@ -29359,57 +29413,57 @@ function qq(e, t) {
}
return !1;
}
-const Dq = /* @__PURE__ */ new Set(["text", "search", "email", "url", "tel", "password", "number"]);
-function Kq(e, t) {
- return e ? e instanceof HTMLTextAreaElement ? !0 : e instanceof HTMLInputElement ? Dq.has(e.type) : !(e instanceof HTMLElement) || !e.isContentEditable ? !1 : !t?.contains(e) : !1;
+const Wq = /* @__PURE__ */ new Set(["text", "search", "email", "url", "tel", "password", "number"]);
+function Hq(e, t) {
+ return e ? e instanceof HTMLTextAreaElement ? !0 : e instanceof HTMLInputElement ? Wq.has(e.type) : !(e instanceof HTMLElement) || !e.isContentEditable ? !1 : !t?.contains(e) : !1;
}
-function Uq(e) {
+function Gq(e) {
return !!e?.includes("(basic)");
}
-function Fq(e) {
+function Jq(e) {
if (e !== void 0)
return e.replace(/\s*\(basic\)/g, "").trim();
}
-function SS(e, t) {
- return !e.startsWith("zpa") && e !== "c" && Hd(e, t);
+function AS(e, t) {
+ return !e.startsWith("zpa") && e !== "c" && Jd(e, t);
}
function fa(e, t) {
return {
marker: e.marker,
kind: t,
// `isBasic` reads the ORIGINAL description; the emitted one has the token removed.
- description: Fq(e.description),
- isBasic: Uq(e.description)
+ description: Jq(e.description),
+ isBasic: Gq(e.description)
};
}
-function Bq(e, t) {
+function Yq(e, t) {
const n = (s) => {
const o = /^(.*?)(\d+)$/.exec(s);
return o ? { prefix: o[1], digits: Number(o[2]) } : { prefix: s };
}, r = n(e), i = n(t);
return r.prefix !== i.prefix ? r.prefix < i.prefix ? -1 : 1 : r.digits === void 0 ? i.digits === void 0 ? 0 : -1 : i.digits === void 0 ? 1 : r.digits - i.digits;
}
-function El(e, t) {
- return e.isBasic !== t.isBasic ? e.isBasic ? -1 : 1 : Bq(e.marker, t.marker);
+function Pl(e, t) {
+ return e.isBasic !== t.isBasic ? e.isBasic ? -1 : 1 : Yq(e.marker, t.marker);
}
-function _S(e, t, n) {
+function wS(e, t, n) {
if (t.noteMarker) return [];
- const r = Nu(e, t.previousParaMarkers);
+ const r = Ru(e, t.previousParaMarkers);
return Object.values(e.markers).filter(
- (i) => i.styleType === "paragraph" && SS(i.marker, n)
+ (i) => i.styleType === "paragraph" && AS(i.marker, n)
).filter((i) => {
const s = ic(e, i.marker);
- return s !== void 0 && kg(r, s);
- }).map((i) => fa(i, "paragraph")).sort(El);
+ return s !== void 0 && Sg(r, s);
+ }).map((i) => fa(i, "paragraph")).sort(Pl);
}
-function zq(e, t, n) {
+function Xq(e, t, n) {
const { noteMarker: r, paraMarker: i } = t, s = Object.values(e.markers).filter(
- (c) => SS(c.marker, n)
+ (c) => AS(c.marker, n)
);
if (r)
return s.filter(
(c) => c.styleType === "character" && (c.occursUnder ?? []).includes(r)
- ).map((c) => fa(c, "character")).sort(El);
+ ).map((c) => fa(c, "character")).sort(Pl);
if (!i) return [];
const o = s.filter((c) => {
if (c.styleType !== "character") return !1;
@@ -29419,120 +29473,120 @@ function zq(e, t, n) {
return [
...o.map((c) => fa(c, "character")),
...a.map((c) => fa(c, "note"))
- ].sort(El);
+ ].sort(Pl);
}
-function jq(e, t) {
+function Qq(e, t) {
return t.map((n, r) => {
const i = e.markers[n]?.endMarker ?? `${n}*`;
return { marker: `${r === t.length - 1 ? "" : "+"}${i}`, kind: "closeTag", isBasic: !1 };
});
}
-function Vq(e, t) {
+function Zq(e, t) {
return e.isBasic === t.isBasic ? 0 : e.isBasic ? -1 : 1;
}
-function Wq(e, t, n, r) {
- const i = jq(e, t.openCharMarkers), s = zq(e, t, n);
- return i.length === 0 && s.length === 0 ? [] : [...i, ...ES(s, r)].sort(Vq);
+function eD(e, t, n, r) {
+ const i = Qq(e, t.openCharMarkers), s = Xq(e, t, n);
+ return i.length === 0 && s.length === 0 ? [] : [...i, ...NS(s, r)].sort(Zq);
}
-function Hq(e, t, n) {
- const r = Gq(e, t);
+function tD(e, t, n) {
+ const r = nD(e, t);
if (t.source === "character") {
- const i = Wq(e, t, n, r);
+ const i = eD(e, t, n, r);
if (i.length > 0) return i;
}
- return ES(_S(e, t, n), r);
+ return NS(wS(e, t, n), r);
}
-function Gq(e, t) {
+function nD(e, t) {
if (!t.canInsertChapter) return;
- const n = wu(e, "c");
+ const n = $u(e, "c");
return n ? fa(n, "paragraph") : void 0;
}
-function ES(e, t) {
- return t ? [...e, t].sort(El) : e;
+function NS(e, t) {
+ return t ? [...e, t].sort(Pl) : e;
}
-function Jq(e, t, n) {
- const r = _S(e, t, n), i = Nu(e, t.previousParaMarkers), s = ic(e, "ip"), a = !t.previousParaMarkers.includes("c") && s && kg(i, s) ? "ip" : "p", c = r.findIndex((u) => u.marker === a);
+function rD(e, t, n) {
+ const r = wS(e, t, n), i = Ru(e, t.previousParaMarkers), s = ic(e, "ip"), a = !t.previousParaMarkers.includes("c") && s && Sg(i, s) ? "ip" : "p", c = r.findIndex((u) => u.marker === a);
if (c <= 0) return r;
const [l] = r.splice(c, 1);
return [l, ...r];
}
-function Pg(e, t, n) {
- if (!$(e.getFirstChild()) && n?.markerMode === "editable" && qi(n)) {
- Au(e, t);
+function $g(e, t, n) {
+ if (!$(e.getFirstChild()) && n?.markerMode === "editable" && Di(n)) {
+ Ou(e, t);
return;
}
- XT(e, t);
+ tC(e, t);
}
-function MS() {
+function OS() {
const e = M();
if (!E(e)) return "declined";
if (!e.isCollapsed()) {
- const t = PS(e);
- return t !== "removed" ? t : (Xd(), "handled");
+ const t = $S(e);
+ return t !== "removed" ? t : (Zd(), "handled");
}
- return Xd() ? "handled" : "declined";
+ return Zd() ? "handled" : "declined";
}
-function Yq(e, t) {
+function iD(e, t) {
if (!t) return e;
- const n = u2.exec(e);
+ const n = b2.exec(e);
if (!n) return e;
const r = n[1];
return r === "c" || r === "v" || t(r)?.type !== v.Paragraph ? e : e.slice(n[0].length);
}
-function hb(e, t) {
+function kb(e, t) {
const n = M();
if (!E(n)) return "declined";
if (n.isCollapsed()) {
- if (!AS())
+ if (!RS())
return "declined";
} else {
- const s = PS(n);
+ const s = $S(n);
if (s !== "removed") return s;
}
const [r, ...i] = e.map(
- (s) => Yq(s, t)
+ (s) => iD(s, t)
);
- gb(r ?? "");
+ xb(r ?? "");
for (const s of i)
- Xd(), gb(s);
+ Zd(), xb(s);
return "handled";
}
-function Xq(e) {
+function sD(e) {
const t = e.getRootElement(), n = t?.ownerDocument.getSelection(), r = n?.anchorNode;
if (!t || !n || !r || !t.contains(r)) return !1;
const i = qr(r);
if (!i) return !1;
const s = hn(i);
- if (!s || s.getIsCollapsed() !== !1 || s.is(i) || !T(i) || $(i)) return !1;
+ if (!s || s.getIsCollapsed() !== !1 || s.is(i) || !C(i) || $(i)) return !1;
const o = Math.min(n.anchorOffset, i.getTextContentSize());
return i.select(o, o), !0;
}
-function PS(e) {
+function $S(e) {
const t = hn(e.anchor.getNode()), n = hn(e.focus.getNode()), r = t?.getIsCollapsed() === !1, i = n?.getIsCollapsed() === !1;
- return !r && !i ? "declined" : (e.removeText(), Qq() ? "removed" : "needs-plain-split");
+ return !r && !i ? "declined" : (e.removeText(), oD() ? "removed" : "needs-plain-split");
}
-function gb(e) {
+function xb(e) {
if (e === "") return;
const t = M();
E(t) && t.insertText(e);
}
-function Qq() {
+function oD() {
const e = M();
if (!E(e) || !e.isCollapsed()) return !1;
const t = hn(e.anchor.getNode());
return !t || t.getIsCollapsed() !== !1 ? !1 : t.getChildren().some((n) => $(n) && n.getMarkerSyntax() === "opening");
}
-function AS() {
+function RS() {
const e = M();
if (!E(e) || !e.isCollapsed()) return;
const t = e.anchor.getNode(), n = hn(t);
if (!(!n || n.getIsCollapsed() !== !1 || n.is(t)))
return n;
}
-function Xd() {
+function Zd() {
const e = M();
if (!E(e) || !e.isCollapsed()) return !1;
- const t = e.anchor.getNode(), n = AS();
+ const t = e.anchor.getNode(), n = RS();
if (!n) return !1;
let r = t;
for (; !n.is(r.getParent()); ) {
@@ -29540,9 +29594,9 @@ function Xd() {
if (!l) return !1;
r = l;
}
- const i = Qr("fp", { closed: "false" });
+ const i = Zr("fp", { closed: "false" });
i.append(Jt("fp"));
- const s = T(t) && !$(t) ? t : void 0, o = e.anchor.offset, a = s?.getTextContentSize() ?? 0, c = s !== void 0 && s.is(r);
+ const s = C(t) && !$(t) ? t : void 0, o = e.anchor.offset, a = s?.getTextContentSize() ?? 0, c = s !== void 0 && s.is(r);
if (s && !c) {
if (o <= 0) s.insertBefore(i);
else if (o >= a) s.insertAfter(i);
@@ -29550,48 +29604,48 @@ function Xd() {
const [, l] = s.splitText(o);
l.insertBefore(i);
}
- xo(i, { renderGlyphs: !0 });
+ To(i, { renderGlyphs: !0 });
} else {
const l = s && o < a ? [o === 0 ? s : s.splitText(o)[1]] : [];
r.insertAfter(i);
const [u] = l;
- u && (_P(u), i.append(u));
+ u && (wP(u), i.append(u));
}
- return i.getChildren().every($) && i.append(Ue(It)), wS(i), !0;
+ return i.getChildren().every($) && i.append(Be(It)), IS(i), !0;
}
-function wS(e) {
+function IS(e) {
const t = e.getChildren().find((n) => !$(n));
- if (T(t)) {
- const n = $p(t);
+ if (C(t)) {
+ const n = Ip(t);
t.select(n, n);
return;
}
if (A(t)) {
- wS(t);
+ IS(t);
return;
}
e.selectEnd();
}
-function Zq(e) {
+function aD(e) {
const t = [];
let n = e;
for (; n; )
z(n) && t.push(n.getMarker()), n = n.getParent();
return t;
}
-function eD(e) {
+function cD(e) {
const t = e.getTopLevelElement(), n = [];
for (const r of Me().getChildren()) {
- const i = Tg(r);
+ const i = Eg(r);
if (t && r.is(t)) {
- (qe(r) || ot(r)) && n.push(r.getMarker());
+ (qe(r) || Ye(r)) && n.push(r.getMarker());
break;
}
i !== void 0 && n.push(i);
}
return n;
}
-function tD(e) {
+function lD(e) {
let t = e;
for (; A(t); ) {
const n = t.getFirstChild();
@@ -29600,9 +29654,9 @@ function tD(e) {
}
return t;
}
-function nD(e, t, n) {
+function uD(e, t, n) {
const r = e.getFirstChild();
- if (!r) return !1;
+ if (!r) return t.is(e) && n === 0;
let i = r;
if (Zt(r)) {
if (t.is(r)) return !0;
@@ -29611,16 +29665,16 @@ function nD(e, t, n) {
i = i.getNextSibling();
}
}
- return i ? t.is(tD(i)) && n === 0 : !1;
+ return i ? t.is(lD(i)) && n === 0 : !1;
}
-function rD(e, t, n) {
+function fD(e, t, n) {
const r = e.getFirstChild();
if (!r || !Zt(r)) return !1;
if (t.is(r)) return !0;
const i = r.getNextSibling();
return i !== null && an(i) && t.is(i) && n === 0;
}
-function iD() {
+function dD() {
if (typeof window > "u" || typeof window.getSelection != "function") return;
const e = window.getSelection();
if (!e || e.rangeCount === 0) return;
@@ -29629,8 +29683,8 @@ function iD() {
const { x: n, y: r, width: i, height: s } = t.getBoundingClientRect();
return { x: n, y: r, width: i, height: s };
}
-function sD(e) {
- const t = $T(e);
+function pD(e) {
+ const t = qT(e);
if (t) return { node: t, offset: 0, hasTextSelection: !1 };
if (!E(e)) return;
const { focus: n } = e;
@@ -29640,68 +29694,69 @@ function sD(e) {
hasTextSelection: !e.isCollapsed()
};
}
-function oD(e, t) {
- const n = M(), r = sD(n);
+function hD(e, t) {
+ const n = M(), r = pD(n);
if (!r) return;
- const { node: i, offset: s, hasTextSelection: o } = r, a = We(i, ke), c = a ? void 0 : We(i, qe), l = !o && !c && (!a || rD(a, i, s)) ? "paragraph" : "character", u = hn(i);
+ const { node: i, offset: s, hasTextSelection: o } = r, a = We(i, ke), c = a ? void 0 : We(i, qe), l = !o && !c && (!a || fD(a, i, s)) ? "paragraph" : "character", u = hn(i);
return {
source: l,
// The book reports `id` as its own block marker: PT9's character source filters on the
// enclosing paragraph's marker (`occursUnder` empty or containing it), and without one it
// returns an empty list that falls back to the paragraph palette.
paraMarker: a?.getMarker() ?? c?.getMarker(),
- previousParaMarkers: eD(i),
- openCharMarkers: Zq(i),
+ previousParaMarkers: cD(i),
+ openCharMarkers: aD(i),
noteMarker: u?.getMarker(),
hasTextSelection: o,
// The trailing edge of a canonical closing glyph counts as AFTER the marker, not inside it
// (see $isPointInMarkerGlyphText) — Enter there opens the paragraph menu exactly as at the
// end of a plain-text paragraph.
- inMarkerText: ah(i, s),
- canInsertChapter: vg(t),
- anchorRect: aD(e, mi(n)) ?? iD()
+ inMarkerText: lh(i, s),
+ canInsertChapter: Pg(t),
+ anchorRect: gD(e, yi(n)) ?? dD()
};
}
-function aD(e, t) {
+function gD(e, t) {
const n = t && e?.getElementByKey(t.getKey());
if (!n) return;
const { x: r, y: i, width: s, height: o } = n.getBoundingClientRect();
return { x: r, y: i, width: s, height: o };
}
-function cD() {
+function mD() {
const e = M();
if (!E(e) || !e.isCollapsed()) return;
const t = e.anchor.getNode();
- if (!T(t) || $(t)) return;
- const n = e.anchor.offset, r = t.getTextContent().slice(0, n), i = f2.exec(r);
+ if (!C(t) || $(t)) return;
+ const n = e.anchor.offset, r = t.getTextContent().slice(0, n), i = k2.exec(r);
i && t.spliceText(n - i[0].length, i[0].length, "", !0);
}
-function lD(e, t, n) {
- Pg(e, t, n), pg(e);
+function yD(e, t, n) {
+ $g(e, t, n), bg(e);
}
-function uD(e, t, n) {
+function bD(e, t, n) {
const r = M();
if (!E(r)) return;
- const i = r.focus.getNode(), s = We(i, ke);
- if (t === "backslash" && s && nD(s, i, r.focus.offset)) {
- lD(s, e, n);
+ const i = r.focus.getNode(), s = We(i, ot);
+ if (t === "backslash" && s && uD(s, i, r.focus.offset)) {
+ const o = ht(s) ? s.replace(Ai(e), !0) : s;
+ yD(o, e, n);
return;
}
- Qd(e, n);
+ ep(e, n);
}
-function NS(e, t) {
- const n = e.getNode(), r = ev(A(n) ? n : n.getParent());
+function LS(e, t) {
+ const n = e.getNode(), r = sv(A(n) ? n : n.getParent());
return t.is(r);
}
-function fD(e, t) {
+function kD(e, t) {
const n = e.getNode();
- return !t.is(n) && !t.isParentOf(n) ? !1 : !NS(e, t);
+ return !t.is(n) && !t.isParentOf(n) ? !1 : !LS(e, t);
}
-function Ml(e, t, n) {
+function Al(e, t, n) {
const r = n.getIndexWithinParent();
e.getNode().is(t) && e.offset <= r && e.set(t.getKey(), r + 1, "element");
}
-function dD(e) {
+function xD(e) {
if (e.type !== "text" || e.offset !== 0) return e;
const t = e.getNode();
if (!$(t) || t.getMarkerSyntax() !== "opening") return e;
@@ -29710,53 +29765,53 @@ function dD(e) {
const r = n.getParent();
return r ? fn(r.getKey(), n.getIndexWithinParent(), "element") : e;
}
-function pD(e, t, n) {
+function TD(e, t, n) {
const r = M();
if (!E(r)) return !1;
const i = r.isBackward() ? r.focus : r.anchor;
- if (!NS(i, e)) return !1;
+ if (!LS(i, e)) return !1;
const s = r.isBackward() ? r.anchor : r.focus;
- if (!r.isCollapsed() && fD(s, e)) return !1;
- const o = Wp(e.getFirstChild()) ? e.getFirstChild() : void 0;
- o && (Ml(r.anchor, e, o), Ml(r.focus, e, o)), r.isCollapsed() || r.removeText();
+ if (!r.isCollapsed() && kD(s, e)) return !1;
+ const o = Gp(e.getFirstChild()) ? e.getFirstChild() : void 0;
+ o && (Al(r.anchor, e, o), Al(r.focus, e, o)), r.isCollapsed() || r.removeText();
const a = M();
if (!E(a) || !a.isCollapsed()) return !1;
- const c = rv(a);
+ const c = cv(a);
if (!c) return !1;
- const { parent: l, moving: u } = nv(
- dD(c.anchor)
+ const { parent: l, moving: u } = av(
+ xD(c.anchor)
);
if (!e.is(l)) return !1;
- const f = u.filter((m) => !m.is(o)), d = ps(t);
+ const f = u.filter((m) => !m.is(o)), d = Ai(t);
e.insertAfter(d), d.append(...f);
const [p] = f;
- return z(p) ? Xl(p) : d.select(0, 0), qi(n) && La(d), !0;
+ return z(p) ? Zl(p) : d.select(0, 0), Di(n) && La(d), !0;
}
-function hD(e, t) {
+function CD(e, t) {
const n = M();
return !E(n) || !n.isCollapsed() ? !1 : (n.insertText(`\\${e}${t?.trailingSpace === !1 ? "" : " "}`), !0);
}
-function OS(e) {
+function qS(e) {
const t = M();
return E(t) ? (t.insertText(`\\${e}*`), !0) : !1;
}
-function gD(e) {
+function vD(e) {
const t = We(e.anchor.getNode(), qe);
if (!t) return;
const n = t.getFirstChild();
- !n || !Wp(n) || (Ml(e.anchor, t, n), Ml(e.focus, t, n));
+ !n || !Gp(n) || (Al(e.anchor, t, n), Al(e.focus, t, n));
}
-function mD(e, t, n, r) {
+function SD(e, t, n, r) {
const i = M();
- if (E(i) ? gD(i) : r.logger?.warn(
+ if (E(i) ? vD(i) : r.logger?.warn(
"$applyMarkerMenuSelection: no range selection — cleanup/insert will no-op (editor blurred?)"
- ), t.literalPrefixLanded && cD(), e.kind === "closeTag") {
- OS(e.marker.replace(/\*$/, ""));
+ ), t.literalPrefixLanded && mD(), e.kind === "closeTag") {
+ qS(e.marker.replace(/\*$/, ""));
return;
}
- if (e.marker === "fp" && MS() !== "declined") return;
+ if (e.marker === "fp" && OS() !== "declined") return;
if (e.marker === "c") {
- vg(n.chapterNum) && Sg({
+ Pg(n.chapterNum) && Ag({
chapterNum: n.chapterNum,
viewOptions: r.viewOptions,
styleInfo: r.styleInfo
@@ -29766,15 +29821,15 @@ function mD(e, t, n, r) {
return;
}
if (e.kind === "paragraph" && Kt.isValidMarker(e.marker, r.nodeOptions?.extraValidMarkers)) {
- uD(e.marker, t.trigger, r.viewOptions);
+ bD(e.marker, t.trigger, r.viewOptions);
return;
}
- if (at.isValidMarker(e.marker, r.nodeOptions?.extraValidMarkers))
- return Vd({
- viewOptions: r.viewOptions ?? Co(),
- getMarker: lh(r.styleInfo ?? ks),
+ if (lt.isValidMarker(e.marker, r.nodeOptions?.extraValidMarkers))
+ return Hd({
+ viewOptions: r.viewOptions ?? vo(),
+ getMarker: fh(r.styleInfo ?? ks),
logger: r.logger
- }) ? gS(
+ }) ? xS(
e.marker,
n,
r.expandedNoteKeyRef,
@@ -29782,7 +29837,7 @@ function mD(e, t, n, r) {
r.nodeOptions,
r.logger
) : void 0;
- Gd(
+ Yd(
e.marker,
r.expandedNoteKeyRef,
r.viewOptions,
@@ -29792,37 +29847,37 @@ function mD(e, t, n, r) {
r.styleInfo
).action({ editor: Pt(), reference: n });
}
-function Qd(e, t) {
- if (uS(e, t)) return !0;
+function ep(e, t) {
+ if (gS(e, t)) return !0;
const n = M();
if (!E(n)) return !1;
- ch(n);
+ uh(n);
const r = (n.isBackward() ? n.focus : n.anchor).getNode();
if (!We(r, ke)) {
const o = We(r, qe);
- if (o) return pD(o, e, t);
+ if (o) return TD(o, e, t);
}
- const i = qi(t);
- if (iv()) {
+ const i = Di(t);
+ if (lv()) {
const o = M();
if (!E(o)) return !1;
const a = We(o.anchor.getNode(), ke);
return a ? (a.setMarker(e), i && La(a), !0) : !1;
}
const s = n.insertParagraph();
- return ke(s) ? (i ? Au(s, e) : s.setMarker(e), !0) : !1;
+ return ke(s) ? (i ? Ou(s, e) : s.setMarker(e), !0) : !1;
}
-function yD() {
+function _D() {
const [e] = Pe();
- return J(() => e.registerCommand(dp, () => !0, Nt), [e]), null;
+ return J(() => e.registerCommand(hp, () => !0, Nt), [e]), null;
}
-function bD(e, t) {
+function ED(e, t) {
if (!e.startsWith("\\")) return !0;
- const n = a2.exec(e)?.[1];
- return n === void 0 ? !1 : !dg(n, t);
+ const n = g2.exec(e)?.[1];
+ return n === void 0 ? !1 : !yg(n, t);
}
-function $S(e, t) {
- if (e.getMarkerSyntax() !== "opening" || !bD(e.getTextContent(), t)) return;
+function DS(e, t) {
+ if (e.getMarkerSyntax() !== "opening" || !ED(e.getTextContent(), t)) return;
const n = e.getParent();
if (!ke(n)) return;
const r = t(n.getMarker())?.type;
@@ -29831,103 +29886,103 @@ function $S(e, t) {
if (!(!ke(i) && !qe(i)))
return [i, n];
}
-function RS(e, t) {
- const n = $S(e, t.getMarker);
+function KS(e, t) {
+ const n = DS(e, t.getMarker);
if (!n) return !1;
const [r, i] = n;
- return qe(r) ? Dv(r, t, [i]) : Rv([r, i], t);
+ return qe(r) ? zv(r, t, [i]) : Kv([r, i], t);
}
-function kD(e, t) {
+function MD(e, t) {
const n = M();
E(n) && [n.anchor, n.focus].forEach((r) => {
r.key === e.getKey() && r.offset > t && r.set(e.getKey(), t, "text");
});
}
-function IS(e) {
- const t = c2.exec(e);
+function BS(e) {
+ const t = m2.exec(e);
if (!t) return;
const n = 1 + t[1].length;
return { start: n, end: n + t[2].length };
}
-function xD(e) {
+function PD(e) {
const t = M();
if (!E(t) || !t.isCollapsed() || t.anchor.key !== e.getKey()) return;
- const n = IS(e.getTextContent());
+ const n = BS(e.getTextContent());
if (!n) return;
const { offset: r } = t.anchor;
if (!(r < n.start || r > n.end))
return r - n.start;
}
-function TD(e) {
+function AD(e) {
const t = M();
if (!E(t) || !t.isCollapsed() || t.anchor.key !== e.getKey()) return;
const n = e.getNextSibling();
- if (K(e.getParent()) && T(n)) {
+ if (K(e.getParent()) && C(n)) {
const r = n.getNextSibling();
if (z(r)) {
- Xl(r);
+ Zl(r);
return;
}
}
- T(n) ? n.select(1, 1) : e.select(e.getTextContentSize(), e.getTextContentSize());
+ C(n) ? n.select(1, 1) : e.select(e.getTextContentSize(), e.getTextContentSize());
}
-function mb(e, t) {
+function Tb(e, t) {
if (t !== void 0) {
- const n = e.getLatest(), r = IS(n.getTextContent());
+ const n = e.getLatest(), r = BS(n.getTextContent());
if (r) {
const i = Math.min(r.start + t, r.end);
n.select(i, i);
return;
}
}
- TD(e);
+ AD(e);
}
-function Zd(e, t) {
+function tp(e, t) {
return e.replace(/^\+/, "") !== t.replace(/^\+/, "");
}
-function LS(e, t, n) {
+function US(e, t, n) {
if (t.startsWith("+") !== e.getNested())
return cr(e, n);
- const r = xD(e), i = e.getParent();
+ const r = PD(e), i = e.getParent();
if (ke(i)) {
- if (!dg(t, n.getMarker))
- return RS(e, n) ? (n.logger?.debug(
+ if (!yg(t, n.getMarker))
+ return KS(e, n) ? (n.logger?.debug(
`[MarkerEdit] unknown-split paragraph rejoined its predecessor on rename to "${t}"`
), !0) : cr(e, n);
const s = e.getMarker();
- return i.setMarker(t), e.setMarker(t), Zd(s, t) && mb(e, r), n.logger?.debug(`[MarkerEdit] para marker renamed to "${t}"`), !0;
+ return i.setMarker(t), e.setMarker(t), tp(s, t) && Tb(e, r), n.logger?.debug(`[MarkerEdit] para marker renamed to "${t}"`), !0;
}
if (z(i) || K(i)) {
const s = t.replace(/^\+/, "");
- if (!(z(i) ? Wv(t, n.getMarker) : at.isValidMarker(s)) || z(i) && Dp(i))
+ if (!(z(i) ? Xv(t, n.getMarker) : lt.isValidMarker(s)) || z(i) && Bp(i))
return cr(e, n);
const a = e.getMarker();
if (i.getMarker() !== a)
return cr(e, n);
i.setMarker(s);
const c = i.getChildren().filter($).filter((l) => l.getMarkerSyntax() === "closing" && l.getMarker() === a).at(-1);
- return c && (kD(c, pt(s, c.getNested()).length), c.setMarker(s)), e.setMarker(s), Zd(a, s) && mb(e, r), n.logger?.debug(`[MarkerEdit] ${i.getType()} marker renamed to "${s}"`), !0;
+ return c && (MD(c, pt(s, c.getNested()).length), c.setMarker(s)), e.setMarker(s), tp(a, s) && Tb(e, r), n.logger?.debug(`[MarkerEdit] ${i.getType()} marker renamed to "${s}"`), !0;
}
return cr(e, n);
}
-function qS(e, t) {
+function FS(e, t) {
if (!$(e) || e.getMarkerSyntax() !== "opening") return;
const n = e.getParent();
if (!z(n) || !n.getFirstChild()?.is(e)) return;
- const r = Io.exec(e.getTextContent());
+ const r = Lo.exec(e.getTextContent());
if (!r) return;
const i = r[1];
- if (i.startsWith("+") !== e.getNested() || !Wv(i, t)) return;
+ if (i.startsWith("+") !== e.getNested() || !Xv(i, t)) return;
const s = e.getMarker();
if (n.getMarker() !== s) return;
const o = i.replace(/^\+/, "");
- if (Zd(s, o) && !Dp(n))
- return { char: n, glyph: e, closer: CD(n, s), newMarker: o };
+ if (tp(s, o) && !Bp(n))
+ return { char: n, glyph: e, closer: wD(n, s), newMarker: o };
}
-function CD(e, t) {
+function wD(e, t) {
return e.getChildren().filter($).filter((n) => n.getMarkerSyntax() === "closing" && n.getMarker() === t).at(-1);
}
-function vD(e) {
+function ND(e) {
const t = M();
if (!E(t)) return !1;
const n = t.isCollapsed() ? [t.anchor] : [t.anchor, t.focus];
@@ -29947,7 +30002,7 @@ function vD(e) {
}
return !!(!t.isCollapsed() && t.getNodes().some((r) => r.is(e)));
}
-function SD(e) {
+function OD(e) {
const t = e.getTextContent(), n = e.getMarkerSyntax() === "closing", r = (n ? /[ \u00A0]+$/ : /^[ \u00A0]+/).exec(t)?.[0];
if (!r || r.length === t.length) return !1;
const i = e.getParent();
@@ -29964,7 +30019,7 @@ function SD(e) {
s = i;
}
const o = n ? s.getNextSibling() : s.getPreviousSibling();
- if (!T(o)) return !1;
+ if (!C(o)) return !1;
const a = n ? t.slice(0, t.length - r.length) : t.slice(r.length);
if (e.setTextContent(a), !Sr(e))
return e.setTextContent(t), !1;
@@ -29979,37 +30034,37 @@ function SD(e) {
const u = o.getTextContentSize();
return o.setTextContent(o.getTextContent() + r), l !== void 0 && (l <= r.length ? o.select(u + l, u + l) : e.select(l - r.length, l - r.length)), !0;
}
-function _D(e, t) {
+function $D(e, t) {
const n = e.getTextContent();
if (Sr(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
- if (He(e.getParent()) && Ep(e)) {
+ if (He(e.getParent()) && Pp(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
- if (!t.pendingKeys.has(e.getKey()) && !vD(e)) {
- qE(e), t.logger?.debug(
+ if (!t.pendingKeys.has(e.getKey()) && !ND(e)) {
+ FE(e), t.logger?.debug(
`[MarkerEdit] healed machine-drifted glyph bytes back to "${e.getTextContent()}"`
);
return;
}
- if (SD(e)) {
+ if (OD(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
if (e.getMarkerSyntax() === "opening") {
- if (bM(e) || ID(e)) {
+ if (vM(e) || zD(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
- const r = ov.exec(n);
+ const r = fv.exec(n);
if (r) {
- t.pendingKeys.delete(e.getKey()), LS(e, r[1], t);
+ t.pendingKeys.delete(e.getKey()), US(e, r[1], t);
return;
}
- if (o2.test(n)) {
+ if (h2.test(n)) {
t.pendingKeys.delete(e.getKey()), cr(e, t);
return;
}
@@ -30018,42 +30073,42 @@ function _D(e, t) {
}
if (e.getMarkerSyntax() === "closing") {
const r = e.getParent(), i = pt(e.getMarker(), e.getNested());
- if ((z(r) || K(r)) && !pp(r.getParent()) && e.getMarker() === r.getMarker() && r.getLastChild()?.is(e) && n.startsWith(i) && n.length > i.length) {
- const s = M(), o = E(s) && s.isCollapsed() && s.anchor.key === e.getKey() && s.anchor.offset > i.length ? s.anchor.offset - i.length : void 0, a = Ue(n.slice(i.length));
+ if ((z(r) || K(r)) && !gp(r.getParent()) && e.getMarker() === r.getMarker() && r.getLastChild()?.is(e) && n.startsWith(i) && n.length > i.length) {
+ const s = M(), o = E(s) && s.isCollapsed() && s.anchor.key === e.getKey() && s.anchor.offset > i.length ? s.anchor.offset - i.length : void 0, a = Be(n.slice(i.length));
e.setTextContent(i), r.insertAfter(a), o !== void 0 && a.select(o, o), t.pendingKeys.delete(e.getKey());
return;
}
}
- if (ED(e)) {
+ if (RD(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
t.pendingKeys.add(e.getKey());
}
-function ED(e) {
+function RD(e) {
if (e.getMarkerSyntax() !== "selfClosing" || !Ve(Kr(e)?.owner)) return !1;
const t = pt(""), n = e.getTextContent();
if (!n.startsWith(t) || n.length === t.length) return !1;
const r = e.getParent(), i = He(r) ? r : e;
if (He(r) && !r.getLastChild()?.is(e)) return !1;
const s = i.getParent();
- if (!s || pp(s)) return !1;
- const o = M(), a = E(o) && o.isCollapsed() && o.anchor.key === e.getKey() && o.anchor.offset > t.length ? o.anchor.offset - t.length : void 0, c = Ue(n.slice(t.length));
+ if (!s || gp(s)) return !1;
+ const o = M(), a = E(o) && o.isCollapsed() && o.anchor.key === e.getKey() && o.anchor.offset > t.length ? o.anchor.offset - t.length : void 0, c = Be(n.slice(t.length));
return e.setTextContent(t), i.insertAfter(c), a !== void 0 && c.select(a, a), !0;
}
-function MD(e, t) {
+function ID(e, t) {
if (e.getTextContent() === "") {
t.pendingKeys.delete(e.getKey()), e.remove();
return;
}
- if (Lx(e)) {
+ if (Bx(e)) {
t.pendingKeys.delete(e.getKey());
return;
}
t.pendingKeys.add(e.getKey());
}
-function DS(e) {
- if (!mp(e)?.length)
+function zS(e) {
+ if (!bp(e)?.length)
throw new Error(`marker "${e}" declares no leading attributes in the markers map`);
return {
// `\m`, separator, value word, then either nothing-yet (unterminated), or a
@@ -30079,15 +30134,15 @@ function DS(e) {
valueTerminated: new RegExp(`^\\\\${e}[ ]+([^ \\\\]+)[ ]+$`)
};
}
-const Xo = DS("v"), PD = DS("c"), Nf = /^[ \u00A0]*$/;
-function yb(e, t, n) {
+const Qo = zS("v"), LD = zS("c"), Rf = /^[ \u00A0]*$/;
+function Cb(e, t, n) {
const r = e.getNextSibling();
- if (T(r) && r.getType() === it.getType() && r.getMode() === "normal" && Te(r, _e) !== "attribute")
+ if (C(r) && r.getType() === at.getType() && r.getMode() === "normal" && Te(r, _e) !== "attribute")
return r.setTextContent(t + r.getTextContent()), n !== void 0 && r.select(n, n), r;
- const i = Ue(t);
+ const i = Be(t);
return e.insertAfter(i), n !== void 0 && i.select(n, n), i;
}
-function AD(e, t) {
+function qD(e, t) {
const n = e.getTextContent(), r = lr("v", e.getNumber());
if (n === r) {
t.pendingKeys.delete(e.getKey());
@@ -30096,28 +30151,28 @@ function AD(e, t) {
const i = /^[ \u00A0]+/.exec(n);
if (i) {
const m = n.slice(i[0].length);
- if (Xo.midEdit.test(m)) {
+ if (Qo.midEdit.test(m)) {
t.pendingKeys.add(e.getKey());
return;
}
- const h = Xo.valueAndRest.exec(m);
- if (h && Nf.test(h[2] ?? "")) {
+ const h = Qo.valueAndRest.exec(m);
+ if (h && Rf.test(h[2] ?? "")) {
t.pendingKeys.delete(e.getKey()), h[1] !== e.getNumber() && e.setNumber(h[1]);
return;
}
}
- if (Xo.midEdit.test(n)) {
+ if (Qo.midEdit.test(n)) {
t.pendingKeys.add(e.getKey());
return;
}
- const s = Xo.valueAndRest.exec(n);
+ const s = Qo.valueAndRest.exec(n);
if (!s) {
- const m = Xo.markerRest.exec(n);
+ const m = Qo.markerRest.exec(n);
if (m) {
- const [, h, g, y] = m, b = M(), C = E(b) && b.isCollapsed() && b.anchor.key === e.getKey() ? b.anchor.offset : void 0;
+ const [, h, g, y] = m, b = M(), T = E(b) && b.isCollapsed() && b.anchor.key === e.getKey() ? b.anchor.offset : void 0;
t.pendingKeys.delete(e.getKey()), e.setNumber(g), e.setTextContent(lr("v", g));
- const x = C !== void 0 && C >= h.length ? Math.min(C - h.length, y.length) : void 0;
- yb(e, y, x);
+ const x = T !== void 0 && T >= h.length ? Math.min(T - h.length, y.length) : void 0;
+ Cb(e, y, x);
return;
}
t.pendingKeys.delete(e.getKey()), cr(e, t);
@@ -30128,16 +30183,16 @@ function AD(e, t) {
t.pendingKeys.add(e.getKey());
return;
}
- if (t.pendingKeys.delete(e.getKey()), Nf.test(a ?? "")) {
+ if (t.pendingKeys.delete(e.getKey()), Rf.test(a ?? "")) {
o !== e.getNumber() && e.setNumber(o);
return;
}
- const c = M(), l = E(c) && c.isCollapsed() && c.anchor.key === e.getKey() ? c.anchor.offset : void 0, u = a ?? "", f = n.length - u.length, d = l !== void 0 && l >= f ? l - f : void 0, p = d !== void 0 && Nf.test(u.slice(d)) ? u.slice(0, d) : u;
- e.setNumber(o), e.setTextContent(lr("v", o)), p && yb(e, p, d ?? p.length);
+ const c = M(), l = E(c) && c.isCollapsed() && c.anchor.key === e.getKey() ? c.anchor.offset : void 0, u = a ?? "", f = n.length - u.length, d = l !== void 0 && l >= f ? l - f : void 0, p = d !== void 0 && Rf.test(u.slice(d)) ? u.slice(0, d) : u;
+ e.setNumber(o), e.setTextContent(lr("v", o)), p && Cb(e, p, d ?? p.length);
}
-const wD = /^[ \u00A0]+([^ \u00A0\\]*)[ \u00A0]([\s\S]*)$/;
-function ND(e, t) {
- if (!Qv(e)) return !1;
+const DD = /^[ \u00A0]+([^ \u00A0\\]*)[ \u00A0]([\s\S]*)$/;
+function KD(e, t) {
+ if (!rS(e)) return !1;
const n = e.getParent();
if (!K(n)) return !1;
const r = n.getCaller(), i = e.getTextContent();
@@ -30145,25 +30200,25 @@ function ND(e, t) {
return t.pendingKeys.delete(e.getKey()), !0;
if (!e.isUnmergeable()) return !1;
t.pendingKeys.delete(e.getKey());
- const s = wD.exec(i);
- return s ? ($D(e, n, s[1], s[2]), !0) : RD(e, r) ? !0 : Fl(i, r).missing && /^[ \u00A0]/.test(i) && !i.includes("\\") && KS(e) ? (t.pendingKeys.add(e.getKey()), !0) : (US(e, n), !0);
+ const s = DD.exec(i);
+ return s ? (UD(e, n, s[1], s[2]), !0) : FD(e, r) ? !0 : zl(i, r).missing && /^[ \u00A0]/.test(i) && !i.includes("\\") && jS(e) ? (t.pendingKeys.add(e.getKey()), !0) : (VS(e, n), !0);
}
-function OD(e) {
- if (!$u(e)) return !1;
+function BD(e) {
+ if (!Lu(e)) return !1;
const t = e.getTextContent(), n = /^[ \u00A0]+/.exec(t)?.[0];
if (!n) return !1;
- const r = e.getPreviousSibling(), i = T(r) && r.getMode() === "token" && !!Ou(r);
- if (!T(r) || !(Le(r) || i)) return !1;
+ const r = e.getPreviousSibling(), i = C(r) && r.getMode() === "token" && !!Iu(r);
+ if (!C(r) || !(Le(r) || i)) return !1;
const s = M();
if (!E(s) || !s.isCollapsed() || s.anchor.key !== e.getKey() || s.anchor.offset > n.length)
return !1;
const o = s.anchor.offset, a = t.slice(n.length), c = r.getTextContentSize();
return r.getMode() === "token" ? r.select(c, c) : (r.setTextContent(r.getTextContent() + n), r.select(c + o, c + o)), a ? e.setTextContent(a) : e.remove(), !0;
}
-function $D(e, t, n, r) {
+function UD(e, t, n, r) {
const i = e.getTextContent(), s = i.length - r.length, o = /^[ \u00A0]*/.exec(i)?.[0].length ?? 0, a = M(), c = E(a) && a.isCollapsed() && a.anchor.key === e.getKey() ? a.anchor.offset : void 0;
t.getCaller() !== n && t.setCaller(n), e.setTextContent(qt(n));
- const l = r ? BS(t, e, r.replaceAll(U, " ")) : void 0;
+ const l = r ? HS(t, e, r.replaceAll(B, " ")) : void 0;
if (c === void 0) return;
if (c >= s) {
const f = c - s;
@@ -30173,31 +30228,31 @@ function $D(e, t, n, r) {
const u = 1 + Math.min(Math.max(c - o, 0), n.length);
e.select(u, u);
}
-function RD(e, t) {
+function FD(e, t) {
const n = M();
if (!E(n) || !n.isCollapsed()) return !1;
const { anchor: r } = n;
if (r.key !== e.getKey() || r.type !== "text") return !1;
const i = e.getTextContent(), s = i.slice(0, r.offset);
- if (i.slice(r.offset) !== qt(t) || !av.test(s) || s.includes("\\")) return !1;
+ if (i.slice(r.offset) !== qt(t) || !dv.test(s) || s.includes("\\")) return !1;
const o = e.getPreviousSibling();
- if (!$(o) || o.getMarkerSyntax() !== "opening" || !Io.test(o.getTextContent())) return !1;
+ if (!$(o) || o.getMarkerSyntax() !== "opening" || !Lo.test(o.getTextContent())) return !1;
const a = o.getTextContent() + s;
return e.setTextContent(qt(t)), o.setTextContent(a), o.select(a.length, a.length), !0;
}
-function ID(e) {
+function zD(e) {
const t = e.getParent();
if (!K(t) || t.getIsCollapsed() !== !1) return !1;
const n = M();
if (!E(n) || !n.isCollapsed()) return !1;
const r = e.getTextContent(), { anchor: i } = n;
if (i.key !== e.getKey() || i.offset !== r.length) return !1;
- const s = rt(e.getMarker()), o = r.slice(s.length);
+ const s = it(e.getMarker()), o = r.slice(s.length);
if (!r.startsWith(s) || !/^[|\\\s]+$/.test(o)) return !1;
const a = e.getNextSibling();
- return !T(a) || $(a) || !a.isUnmergeable() ? !1 : (e.setTextContent(s), a.setTextContent(o + a.getTextContent()), a.select(o.length, o.length), !0);
+ return !C(a) || $(a) || !a.isUnmergeable() ? !1 : (e.setTextContent(s), a.setTextContent(o + a.getTextContent()), a.select(o.length, o.length), !0);
}
-function KS(e) {
+function jS(e) {
const t = M();
if (!E(t) || !t.isCollapsed()) return !1;
const { anchor: n } = t;
@@ -30205,51 +30260,51 @@ function KS(e) {
const r = e.getNextSibling();
return n.offset === 0 && r !== null && n.key === r.getKey();
}
-function US(e, t) {
- const n = t.getCaller(), r = e.getTextContent(), { start: i } = Fl(r, n), s = Sp(r, n), o = M(), a = E(o) && o.isCollapsed() && o.anchor.key === e.getKey() ? o.anchor.offset : void 0;
+function VS(e, t) {
+ const n = t.getCaller(), r = e.getTextContent(), { start: i } = zl(r, n), s = Ep(r, n), o = M(), a = E(o) && o.isCollapsed() && o.anchor.key === e.getKey() ? o.anchor.offset : void 0;
e.setTextContent(qt(n));
- const c = s ? BS(t, e, s) : void 0;
+ const c = s ? HS(t, e, s) : void 0;
if (a !== void 0)
if (c && a >= i) {
const l = Math.min(a - i, s.length);
c.select(l, l);
- } else zS(t, e);
+ } else GS(t, e);
}
-function Ou(e) {
- if (!T(e) || $(e) || !e.isUnmergeable()) return;
+function Iu(e) {
+ if (!C(e) || $(e) || !e.isUnmergeable()) return;
const t = e.getParent();
if (!K(t) || t.getIsCollapsed() !== !1) return;
let n = t.getFirstChild();
for (; $(n) && n.getMarkerSyntax() === "opening"; ) n = n.getNextSibling();
return e.is(n) ? t : void 0;
}
-function LD(e, t, n) {
- const r = Ou(e);
- if (!(!r || !T(e)))
- return e.getTextContent() === qt(r.getCaller()) ? !1 : n === "idle" && KS(e) ? (t.pendingKeys.add(e.getKey()), !1) : (US(e, r), !0);
+function jD(e, t, n) {
+ const r = Iu(e);
+ if (!(!r || !C(e)))
+ return e.getTextContent() === qt(r.getCaller()) ? !1 : n === "idle" && jS(e) ? (t.pendingKeys.add(e.getKey()), !1) : (VS(e, r), !0);
}
-function FS(e, t) {
+function WS(e, t) {
const { wrapper: n, closer: r } = Ja(e);
return (n ?? r ?? t).getNextSibling();
}
-function $u(e) {
- return T(e) && e.getType() === it.getType() && e.getMode() === "normal" && !e.isUnmergeable() && Te(e, _e) !== "attribute";
+function Lu(e) {
+ return C(e) && e.getType() === at.getType() && e.getMode() === "normal" && !e.isUnmergeable() && Te(e, _e) !== "attribute";
}
-function BS(e, t, n) {
- const r = FS(e, t);
- if ($u(r))
+function HS(e, t, n) {
+ const r = WS(e, t);
+ if (Lu(r))
return r.setTextContent(n + r.getTextContent()), r;
- const i = Ue(n);
+ const i = Be(n);
return r ? r.insertBefore(i) : e.append(i), i;
}
-function zS(e, t) {
- const n = FS(e, t);
- $u(n) ? n.select(0, 0) : n ? e.select(n.getIndexWithinParent(), n.getIndexWithinParent()) : e.select(e.getChildrenSize(), e.getChildrenSize());
+function GS(e, t) {
+ const n = WS(e, t);
+ Lu(n) ? n.select(0, 0) : n ? e.select(n.getIndexWithinParent(), n.getIndexWithinParent()) : e.select(e.getChildrenSize(), e.getChildrenSize());
}
-function qD(e, t) {
+function VD(e, t) {
if (!e.isAttached() || e.getIsCollapsed() !== !1) return;
const n = e.getCaller();
- if (!mp(e.getMarker())?.includes("caller")) return;
+ if (!bp(e.getMarker())?.includes("caller")) return;
const r = e.getChildren();
let i = 0;
for (; i < r.length; ) {
@@ -30259,14 +30314,14 @@ function qD(e, t) {
}
if (i === 0) return;
const s = r[i];
- if (T(s) && !$(s) && (s.isUnmergeable() || s.getTextContent() === qt(n)))
+ if (C(s) && !$(s) && (s.isUnmergeable() || s.getTextContent() === qt(n)))
return;
- const o = Ue(qt(n)).toggleUnmergeable();
+ const o = Be(qt(n)).toggleUnmergeable();
t.viewOptions?.isNoteShellEditable === !1 && o.setMode("token"), r[i - 1].insertAfter(o);
const a = M();
- E(a) && a.isCollapsed() && (a.anchor.key === r[i - 1].getKey() || a.anchor.key === e.getKey() && a.anchor.offset === i) && zS(e, o);
+ E(a) && a.isCollapsed() && (a.anchor.key === r[i - 1].getKey() || a.anchor.key === e.getKey() && a.anchor.offset === i) && GS(e, o);
}
-function DD(e) {
+function WD(e) {
if (!e.isAttached() || e.getIsCollapsed() !== !1) return;
const t = e.getChildren(), n = t.find(
(o) => $(o) && o.getMarkerSyntax() === "opening"
@@ -30279,33 +30334,33 @@ function DD(e) {
for (let o = r.getNextSibling(); o; o = r.getNextSibling())
r.insertBefore(o);
const i = r.getPreviousSibling(), s = i?.getPreviousSibling();
- $u(i) && z(s) && !s.getChildren().some((o) => $(o) && o.getMarkerSyntax() === "closing") && s.append(i);
+ Lu(i) && z(s) && !s.getChildren().some((o) => $(o) && o.getMarkerSyntax() === "closing") && s.append(i);
}
-function KD(e) {
+function HD(e) {
if (e.getChildrenSize() === 0) {
e.remove();
return;
}
const t = e.getFirstChild();
- if (!T(t)) return;
+ if (!C(t)) return;
const n = lr("c", e.getNumber()), r = t.getTextContent();
if (r === n) return;
- const i = /^[ \u00A0]+/.exec(r), s = i ? r.slice(i[0].length) : r, o = PD.valueTerminated.exec(s);
+ const i = /^[ \u00A0]+/.exec(r), s = i ? r.slice(i[0].length) : r, o = LD.valueTerminated.exec(s);
o && o[1] !== e.getNumber() && e.setNumber(o[1]);
}
-function jS(e) {
+function JS(e) {
if (Ve(e)) {
- const { wrapper: t } = Bl(e);
+ const { wrapper: t } = jl(e);
return t && t.getChildrenSize() === 0 ? [t] : [];
}
if (K(e)) {
const { wrapper: t } = Ja(e);
return t && t.getChildrenSize() === 0 ? [t] : [];
}
- if (Be(e)) {
- const t = [], n = Mp(e);
+ if (Fe(e)) {
+ const t = [], n = Ap(e);
n.wrapper && n.wrapper.getChildrenSize() === 0 && t.push(n.wrapper);
- const r = Pp(e);
+ const r = wp(e);
return r.wrapper && r.wrapper.getChildrenSize() === 0 && t.push(r.wrapper), t;
}
if (Le(e)) {
@@ -30316,28 +30371,28 @@ function jS(e) {
}
return [];
}
-function UD(e) {
+function GD(e) {
const t = M();
if (!E(t) || !t.isCollapsed()) return !1;
const n = t.anchor.getNode();
- return jS(e).some((r) => n.is(r));
+ return JS(e).some((r) => n.is(r));
}
-function FD(e, t, n = "departure") {
+function JD(e, t, n = "departure") {
let r = !1;
const i = n === "departure";
- if (i && ke(e) && Nx(e))
+ if (i && ke(e) && Ix(e))
return t.pendingKeys.add(e.getKey()), { handled: !0, mutated: !1 };
for (const l of Ca)
- if (l.settleScope !== "none" && l.ownerPredicate(e) && Ya(l, e) && (i || UD(e)))
+ if (l.settleScope !== "none" && l.ownerPredicate(e) && Ya(l, e) && (i || GD(e)))
return t.pendingKeys.add(e.getKey()), { handled: !0, mutated: !1 };
- for (const l of jS(e))
+ for (const l of JS(e))
l.remove(), r = !0;
let s = !1;
- z(e) && Xk(e) !== void 0 && !Dp(e) && (Qk(e), s = !0, r = !0);
+ z(e) && nx(e) !== void 0 && !Bp(e) && (rx(e), s = !0, r = !0);
let o = !1, a = !1, c = !1;
for (const l of Ca)
if (l.settleScope !== "none" && l.ownerPredicate(e)) {
- if (pA(l, e)) {
+ if (bA(l, e)) {
Ma(l, e), a = !0, r = !0;
continue;
}
@@ -30345,34 +30400,34 @@ function FD(e, t, n = "departure") {
o = !0;
continue;
}
- if (l.deletionPolicy === "remove-owner" && Xx(l, e))
+ if (l.deletionPolicy === "remove-owner" && tT(l, e))
return e.remove(), { handled: !0, mutated: !0 };
- Ql(l, l.scanPieces(e), l.expectedPieces(e)) && (c = !0);
+ eu(l, l.scanPieces(e), l.expectedPieces(e)) && (c = !0);
}
return (a || s) && !c ? { handled: !0, mutated: r } : { handled: o, mutated: r };
}
-function bb(e) {
- return T(e) && e.getType() === it.getType() && e.getMode() === "normal" && Te(e, _e) !== "attribute";
+function vb(e) {
+ return C(e) && e.getType() === at.getType() && e.getMode() === "normal" && Te(e, _e) !== "attribute";
}
-function BD(e) {
+function YD(e) {
const t = /* @__PURE__ */ new Set();
if (e === void 0) return t;
t.add(e);
const n = ee(e);
if (!n?.isAttached()) return t;
- for (let r = n.getPreviousSibling(); r && bb(r); r = r.getPreviousSibling())
+ for (let r = n.getPreviousSibling(); r && vb(r); r = r.getPreviousSibling())
t.add(r.getKey());
- for (let r = n.getNextSibling(); r && bb(r); r = r.getNextSibling())
+ for (let r = n.getNextSibling(); r && vb(r); r = r.getNextSibling())
t.add(r.getKey());
return t;
}
function Cc(e, t, n = "departure") {
let r = !1;
if (e.pendingKeys.size === 0) return r;
- const i = BD(t), s = [...e.pendingKeys].filter((l) => !i.has(l)), o = new Set(
+ const i = YD(t), s = [...e.pendingKeys].filter((l) => !i.has(l)), o = new Set(
s.filter((l) => {
const u = ee(l);
- return !!u?.isAttached() && !!qS(u, e.getMarker);
+ return !!u?.isAttached() && !!FS(u, e.getMarker);
})
), a = [
...s.filter((l) => o.has(l)),
@@ -30384,16 +30439,16 @@ function Cc(e, t, n = "departure") {
e.pendingKeys.delete(l);
continue;
}
- if (Ou(u)) {
- e.pendingKeys.delete(l), r = LD(u, e, n) || r;
+ if (Iu(u)) {
+ e.pendingKeys.delete(l), r = jD(u, e, n) || r;
continue;
}
if ($(u)) {
e.pendingKeys.delete(l);
const h = u.getTextContent();
if (Sr(u)) continue;
- const g = Io.exec(h);
- u.getMarkerSyntax() === "opening" && g ? r = LS(u, g[1], e) || r : n === "idle" && sb(u, e.getMarker, e.viewOptions) ? e.pendingKeys.add(l) : RS(u, e) ? (r = !0, e.logger?.debug(
+ const g = Lo.exec(h);
+ u.getMarkerSyntax() === "opening" && g ? r = US(u, g[1], e) || r : n === "idle" && ub(u, e.getMarker, e.viewOptions) ? e.pendingKeys.add(l) : KS(u, e) ? (r = !0, e.logger?.debug(
"[MarkerEdit] unknown-split paragraph rejoined its predecessor on marker degradation"
)) : r = cr(u, e) || r;
continue;
@@ -30408,9 +30463,9 @@ function Cc(e, t, n = "departure") {
continue;
}
e.pendingKeys.delete(l), l !== p && e.pendingKeys.delete(p), c.add(p);
- const m = FD(d, e, n);
+ const m = JD(d, e, n);
if (r = m.mutated || r, !m.handled) {
- if (n === "idle" && sb(d, e.getMarker, e.viewOptions)) {
+ if (n === "idle" && ub(d, e.getMarker, e.viewOptions)) {
e.pendingKeys.add(p);
continue;
}
@@ -30419,28 +30474,28 @@ function Cc(e, t, n = "departure") {
}
return r;
}
-function VS(e) {
+function YS(e) {
if (bn(e.getNextSibling())) return !0;
for (let t = e.getParent(); t; t = t.getParent())
- if (z(t)) return ra(t) !== void 0;
+ if (z(t)) return ia(t) !== void 0;
return !1;
}
-function zD(e) {
+function XD(e) {
const t = Kr(e);
if (!t) return !1;
- const n = ei(t.kind);
- return !Ql(
+ const n = ti(t.kind);
+ return !eu(
n,
n.scanPieces(t.owner),
n.expectedPieces(t.owner)
);
}
-function kb(e) {
+function Sb(e) {
let t = e.getParent();
- for (; ge(t); ) t = t.getParent();
+ for (; me(t); ) t = t.getParent();
return z(t) ? t : void 0;
}
-function jD(e, t) {
+function QD(e, t) {
const n = M();
if (!E(n) || !n.isCollapsed()) return !1;
const { anchor: r } = n;
@@ -30448,39 +30503,39 @@ function jD(e, t) {
const i = t.getFirstChild();
if (!$(i) || i.getMarkerSyntax() !== "opening") return !1;
let s = i.getNextSibling();
- for (; ge(s); ) s = s.getFirstChild();
- if (!e.is(s) || !Io.test(i.getTextContent())) return !1;
+ for (; me(s); ) s = s.getFirstChild();
+ if (!e.is(s) || !Lo.test(i.getTextContent())) return !1;
const o = e.getTextContent(), a = o.slice(0, r.offset);
- if (!av.test(a) || o[r.offset] !== U) return !1;
+ if (!dv.test(a) || o[r.offset] !== B) return !1;
const c = i.getTextContent() + a;
return e.setTextContent(o.slice(a.length)), i.setTextContent(c), i.select(c.length, c.length), !0;
}
-function VD(e, t) {
+function ZD(e, t) {
const n = e.getTextContent(), r = Te(e, _e), i = e.getParent();
- if (r !== "attribute" && Be(i)) {
+ if (r !== "attribute" && Fe(i)) {
n.replace(/^[ \u00A0]+/, "") === lr("c", i.getNumber()) ? t.pendingKeys.delete(e.getKey()) : t.pendingKeys.add(e.getKey());
return;
}
- if (ND(e, t) || OD(e)) return;
+ if (KD(e, t) || BD(e)) return;
if (r === "attribute") {
- zD(e) ? t.pendingKeys.delete(e.getKey()) : t.pendingKeys.add(e.getKey());
+ XD(e) ? t.pendingKeys.delete(e.getKey()) : t.pendingKeys.add(e.getKey());
return;
}
- const s = kb(e);
- if (s && jD(e, s)) {
+ const s = Sb(e);
+ if (s && QD(e, s)) {
t.pendingKeys.delete(e.getKey());
return;
}
if (!n.includes("\\")) {
- n.includes("|") && VS(e) || n.includes("//") && !Gf(e) || Kk(e) || Be(Ia(e)) ? t.pendingKeys.add(e.getKey()) : t.pendingKeys.delete(e.getKey());
- const c = kb(e);
- c && qp(c) ? t.pendingKeys.add(c.getKey()) : c && Xk(c) !== void 0 && c.markDirty();
+ n.includes("|") && YS(e) || n.includes("//") && !Xf(e) || jk(e) || Fe(Ia(e)) ? t.pendingKeys.add(e.getKey()) : t.pendingKeys.delete(e.getKey());
+ const c = Sb(e);
+ c && Kp(c) ? t.pendingKeys.add(c.getKey()) : c && nx(c) !== void 0 && c.markDirty();
return;
}
- if (Gf(e)) return;
+ if (Xf(e)) return;
const o = M(), a = E(o) && o.isCollapsed() && o.anchor.key === e.getKey() ? n.slice(0, o.anchor.offset) : n;
- if (l2.test(a)) {
- if (OE(n)) {
+ if (y2.test(a)) {
+ if (qE(n)) {
t.pendingKeys.add(e.getKey());
return;
}
@@ -30492,43 +30547,43 @@ function VD(e, t) {
} else
t.pendingKeys.add(e.getKey());
}
-function WD(e, t) {
- return e.deletionPolicy !== "remove-owner" || e.byteFormat.writer !== "read-only" ? !1 : Xx(e, t);
+function eK(e, t) {
+ return e.deletionPolicy !== "remove-owner" || e.byteFormat.writer !== "read-only" ? !1 : tT(e, t);
}
-function HD(e) {
+function tK(e) {
const t = (n) => {
if ($(n)) {
Sr(n) || e.pendingKeys.add(n.getKey());
return;
}
if (bn(n)) {
- Lx(n) || e.pendingKeys.add(n.getKey());
+ Bx(n) || e.pendingKeys.add(n.getKey());
return;
}
for (const r of Ca)
- r.settleScope !== "none" && r.ownerPredicate(n) && (Ya(r, n) || WD(r, n)) && e.pendingKeys.add(n.getKey());
+ r.settleScope !== "none" && r.ownerPredicate(n) && (Ya(r, n) || eK(r, n)) && e.pendingKeys.add(n.getKey());
if (Le(n)) {
n.getTextContent() !== lr("v", n.getNumber()) && e.pendingKeys.add(n.getKey());
return;
}
- if (T(n)) {
- if (n.getType() !== it.getType() || Te(n, _e) === "attribute") return;
+ if (C(n)) {
+ if (n.getType() !== at.getType() || Te(n, _e) === "attribute") return;
const r = n.getParent();
- if (Be(r)) {
+ if (Fe(r)) {
n.getTextContent() !== lr("c", r.getNumber()) && e.pendingKeys.add(n.getKey());
return;
}
- const i = Ou(n);
+ const i = Iu(n);
if (i) {
n.getTextContent() !== qt(i.getCaller()) && e.pendingKeys.add(n.getKey());
return;
}
const s = n.getTextContent();
- (s.includes("\\") || s.includes("|") && VS(n) || s.includes("//") || Kk(n) !== void 0) && e.pendingKeys.add(n.getKey());
+ (s.includes("\\") || s.includes("|") && YS(n) || s.includes("//") || jk(n) !== void 0) && e.pendingKeys.add(n.getKey());
return;
}
if (z(n)) {
- qp(n) && e.pendingKeys.add(n.getKey()), n.getChildren().forEach(t);
+ Kp(n) && e.pendingKeys.add(n.getKey()), n.getChildren().forEach(t);
return;
}
if (!Ie(n)) {
@@ -30542,16 +30597,16 @@ function HD(e) {
};
Me().getChildren().forEach(t);
}
-const WS = Ba(
+const XS = Fa(
"COMMIT_PENDING_MARKERS_COMMAND"
-), HS = Ba(
+), QS = Fa(
"SET_MARKER_SETTLE_SUSPENDED_COMMAND"
);
-function Of(e) {
+function If(e) {
const t = e();
- return _t(ma), _t(pk), t;
+ return _t(ma), _t(bk), t;
}
-const xb = 8, Tb = 1e3, GD = 1e3;
+const _b = 8, Eb = 1e3, nK = 1e3;
function Gs(e, t) {
const n = Le(e) ? ["va", "vp"] : Ve(e) ? ["milestone"] : K(e) ? ["cat"] : (
// A chapter's two runs must be driven in this order — `\cp`'s scan and insertion
@@ -30560,11 +30615,11 @@ function Gs(e, t) {
["ca", "cp"]
);
for (const r of n)
- bA(ei(r), e, t.pendingKeys);
+ vA(ti(r), e, t.pendingKeys);
}
-function JD(e, t) {
+function rK(e, t) {
const n = (r, i) => {
- if (i.updateTags.has(Ll) || Yl(e) === "remote")
+ if (i.updateTags.has(Dl) || Ql(e) === "remote")
return;
const s = [];
i.prevEditorState.read(() => {
@@ -30578,11 +30633,11 @@ function JD(e, t) {
}), s.length !== 0 && e.getEditorState().read(() => {
for (const { owner: o, kind: a } of s) {
const c = ee(o.getKey());
- c?.isAttached() && ei(a).expectedPieces(c).wantsRun && t.pendingKeys.add(c.getKey());
+ c?.isAttached() && ti(a).expectedPieces(c).wantsRun && t.pendingKeys.add(c.getKey());
}
});
};
- return Ye(
+ return Xe(
// Registered for the four node classes a display-run piece (or a whole run
// wrapper) can be — a plain TextNode (a char span's `|…` run, a verse's `\va`/`\vp` value, a
// milestone's attribute text), a MarkerNode (a run's opening/closing glyphs, which
@@ -30593,33 +30648,33 @@ function JD(e, t) {
// subclass does not make the TextNode registration see it, mirroring the transform dispatch
// the TextNode catch-all transform's own comment documents — so each class needs its own
// registration.
- e.registerMutationListener(it, n),
+ e.registerMutationListener(at, n),
e.registerMutationListener(Yn, n),
- e.registerMutationListener(hr, n),
- e.registerMutationListener(zr, n)
+ e.registerMutationListener(gr, n),
+ e.registerMutationListener(jr, n)
);
}
-function Pl(e, t) {
+function wl(e, t) {
if (e.structureProtectionMode !== "protected") return !1;
const n = M();
- return n ? t ? uo(n, t) : E(n) && Ci(n) : !1;
+ return n ? t ? fo(n, t) : E(n) && vi(n) : !1;
}
-function YD(e, t, n) {
- return Ye(
+function iK(e, t, n) {
+ return Xe(
e.registerCommand(
un,
(r) => {
- if (Ts() || Pl(t)) return !1;
- const i = qc(r, e._config.namespace);
+ if (Ts() || wl(t)) return !1;
+ const i = Dc(r, e._config.namespace);
if (!i || !i.text.includes(`
`)) return !1;
- const s = n ? vl(i.text) : i.text, o = n && t.structureProtectionMode === "protected" ? Sl(s, t.getMarker) : s, a = n ? mg(o) : o;
+ const s = n ? _l(i.text) : i.text, o = n && t.structureProtectionMode === "protected" ? El(s, t.getMarker) : s, a = n ? Tg(o) : o;
if (a.includes(`
`)) {
const c = a.split(`
`);
- let l = hb(c, t.getMarker);
- if (l === "declined" && Xq(e) && (l = hb(c, t.getMarker)), l === "handled")
+ let l = kb(c, t.getMarker);
+ if (l === "declined" && sD(e) && (l = kb(c, t.getMarker)), l === "handled")
return r?.preventDefault(), !0;
}
return !1;
@@ -30629,10 +30684,10 @@ function YD(e, t, n) {
e.registerCommand(
un,
(r) => {
- if (Ts() || Pl(t)) return !1;
- const i = qc(r, e._config.namespace);
+ if (Ts() || wl(t)) return !1;
+ const i = Dc(r, e._config.namespace);
if (!i) return !1;
- const s = fS(
+ const s = mS(
i.text,
t.structureProtectionMode === "protected",
() => {
@@ -30647,14 +30702,14 @@ function YD(e, t, n) {
e.registerCommand(
un,
(r) => {
- const i = qc(r, e._config.namespace);
+ const i = Dc(r, e._config.namespace);
if (!i || i.isInternal || !i.text) return !1;
const s = i.text.split(`
`);
- if (s.length < 2 || !r2()) return !1;
+ if (s.length < 2 || !f2()) return !1;
const o = M();
- return t.structureProtectionMode === "protected" && E(o) && Ci(o) ? !1 : (r?.preventDefault(), E(o) && !o.isCollapsed() && o.removeText(), s.forEach((a, c) => {
- if (c > 0 && e.dispatchCommand(Ti, void 0), a === "") return;
+ return t.structureProtectionMode === "protected" && E(o) && vi(o) ? !1 : (r?.preventDefault(), E(o) && !o.isCollapsed() && o.removeText(), s.forEach((a, c) => {
+ if (c > 0 && e.dispatchCommand(Ci, void 0), a === "") return;
const l = M();
E(l) && l.insertText(a);
}), !0);
@@ -30668,7 +30723,7 @@ function YD(e, t, n) {
)
);
}
-function XD({
+function sK({
viewOptions: e,
getMarker: t,
logger: n,
@@ -30676,7 +30731,7 @@ function XD({
structureProtectionMode: i = "off",
copyLimit: s
}) {
- const [o] = Pe(), a = e?.markerMode === "editable", c = !!e && gt(e), l = ae(void 0), u = ae(r), f = ae(!1), d = ae(s);
+ const [o] = Pe(), a = e?.markerMode === "editable", c = !!e && mt(e), l = ae(void 0), u = ae(r), f = ae(!1), d = ae(s);
return J(() => {
u.current = r, d.current = s;
const p = l.current;
@@ -30695,22 +30750,22 @@ function XD({
structureProtectionMode: i
};
l.current = p;
- const m = mM(
+ const m = TM(
o,
p.pendingKeys,
- (I) => {
- p.pendingKeys.clear(), I.read(() => HD(p));
+ (R) => {
+ p.pendingKeys.clear(), R.read(() => tK(p));
}
);
- let h, g = !1, y = !1, b, C = !1, x = !1, _ = 0;
- const F = () => _ < xb ? !1 : (p.logger?.warn(
- `[MarkerEdit] settle cascade exceeded ${xb} consecutive mutating passes; leaving ${p.pendingKeys.size} node(s) pending. This is a rebuild that never reaches a fixed point — pending keys: ${[...p.pendingKeys].join(", ")}`
- ), !0), R = (I, q = "departure", j = !1) => {
- const ne = j && !Fh(o), N = ne ? so(o, or) : void 0;
+ let h, g = !1, y = !1, b, T = !1, x = !1, _ = 0;
+ const U = () => _ < _b ? !1 : (p.logger?.warn(
+ `[MarkerEdit] settle cascade exceeded ${_b} consecutive mutating passes; leaving ${p.pendingKeys.size} node(s) pending. This is a rebuild that never reaches a fixed point — pending keys: ${[...p.pendingKeys].join(", ")}`
+ ), !0), I = (R, q = "departure", j = !1) => {
+ const ne = j && !zh(o), N = ne ? so(o, or) : void 0;
o.update(
() => {
- ne && _t(or), _ = Of(
- () => Cc(p, I, q)
+ ne && _t(or), _ = If(
+ () => Cc(p, R, q)
) ? _ + 1 : 0;
},
// DISCRETE whenever the tag is in play, the way `commitPendingMarkerEdits` does it:
@@ -30723,42 +30778,42 @@ function XD({
ne ? { discrete: !0 } : void 0
), N?.();
};
- let W = !1, ce;
+ let V = !1, ce;
const se = () => {
ce !== void 0 && clearTimeout(ce), ce = void 0;
- }, Y = (I) => {
- f.current !== I && (f.current = I, W = !1, se(), I ? (be !== void 0 && clearTimeout(be), be = void 0) : queueMicrotask(() => {
- x || f.current || (!g && !F() && R(h, "departure", !0), Se());
+ }, Y = (R) => {
+ f.current !== R && (f.current = R, V = !1, se(), R ? (be !== void 0 && clearTimeout(be), be = void 0) : queueMicrotask(() => {
+ x || f.current || (!g && !U() && I(h, "departure", !0), Se());
}));
};
let be;
const Se = () => {
if (be !== void 0 && clearTimeout(be), be = void 0, x || p.pendingKeys.size === 0 || f.current) return;
- const I = u.current ?? GD;
- I < 0 || (be = setTimeout(() => {
- be = void 0, !(x || p.pendingKeys.size === 0) && (g || F() || R(void 0, "idle"));
- }, I));
- }, Fe = Ye(
- o.registerNodeTransform(Yn, (I) => {
+ const R = u.current ?? nK;
+ R < 0 || (be = setTimeout(() => {
+ be = void 0, !(x || p.pendingKeys.size === 0) && (g || U() || I(void 0, "idle"));
+ }, R));
+ }, Ue = Xe(
+ o.registerNodeTransform(Yn, (R) => {
if (o.isComposing()) return;
- _D(I, p);
- const q = Kr(I);
- q && (Le(q.owner) || K(q.owner) || Be(q.owner) || Ve(q.owner) && Bl(q.owner).wrapper === void 0) && Gs(q.owner, p);
+ $D(R, p);
+ const q = Kr(R);
+ q && (Le(q.owner) || K(q.owner) || Fe(q.owner) || Ve(q.owner) && jl(q.owner).wrapper === void 0) && Gs(q.owner, p);
}),
- o.registerNodeTransform(Lt, (I) => {
- o.isComposing() || (AD(I, p), Gs(I, p));
+ o.registerNodeTransform(Lt, (R) => {
+ o.isComposing() || (qD(R, p), Gs(R, p));
}),
- o.registerNodeTransform($n, (I) => {
- o.isComposing() || (KD(I), I.isAttached() && Gs(I, p));
+ o.registerNodeTransform(Rn, (R) => {
+ o.isComposing() || (HD(R), R.isAttached() && Gs(R, p));
}),
- o.registerNodeTransform(Kt, (I) => {
- o.isComposing() || uL(I, p);
+ o.registerNodeTransform(Kt, (R) => {
+ o.isComposing() || bL(R, p);
}),
- o.registerNodeTransform(nt, (I) => {
+ o.registerNodeTransform(rt, (R) => {
if (!o.isComposing()) {
- gL(I, p);
+ vL(R, p);
for (const q of ["separator", "char"])
- I.isAttached() && Ya(ei(q), I) && p.pendingKeys.add(I.getKey());
+ R.isAttached() && Ya(ti(q), R) && p.pendingKeys.add(R.getKey());
}
}),
// Self-healing milestone display run (the shared $syncDisplayRun driver,
@@ -30774,29 +30829,29 @@ function XD({
// representation, so deleting all of it must delete the milestone, not resurrect the run)
// — the sync leaves it alone and the milestone is pended for the caret-departure settle
// ($resolvePendingMarkers).
- o.registerNodeTransform(xr, (I) => {
- o.isComposing() || Gs(I, p);
+ o.registerNodeTransform(Tr, (R) => {
+ o.isComposing() || Gs(R, p);
}),
- o.registerNodeTransform(zr, (I) => {
+ o.registerNodeTransform(jr, (R) => {
if (o.isComposing()) return;
- const q = Kr(I);
- q && (Ve(q.owner) || Le(q.owner) || K(q.owner) || Be(q.owner)) && Gs(q.owner, p);
+ const q = Kr(R);
+ q && (Ve(q.owner) || Le(q.owner) || K(q.owner) || Fe(q.owner)) && Gs(q.owner, p);
}),
- o.registerNodeTransform(at, (I) => {
- o.isComposing() || (hL(I, p), qD(I, p), DD(I), Gs(I, p));
+ o.registerNodeTransform(lt, (R) => {
+ o.isComposing() || (CL(R, p), VD(R, p), WD(R), Gs(R, p));
}),
// Unmatched-marker bytes are editable text in this mode; their edits pend and settle
// exactly like closer-glyph edits (see $unmatchedNodeTransform). Its own registration —
// Lexical dispatches transforms by exact node type, so neither the TextNode catch-all
// below nor the MarkerNode transform above ever fires for this subclass.
- o.registerNodeTransform(_r, (I) => {
- o.isComposing() || MD(I, p);
+ o.registerNodeTransform(_r, (R) => {
+ o.isComposing() || ID(R, p);
}),
// Plain-TextNode catch-all for typed/pasted literal backslash sequences (Tier 2).
// Lexical dispatches transforms by exact node type, so this never fires for
// MarkerNode/VerseNode subclasses — TextSpacingPlugin relies on the same fact.
- o.registerNodeTransform(it, (I) => {
- o.isComposing() || VD(I, p);
+ o.registerNodeTransform(at, (R) => {
+ o.isComposing() || ZD(R, p);
}),
// Plain TextNodes can't emit a DOM class from node state the way
// ImmutableTypedTextNode does in createDOM(), so a char span's own `|…` attribute run
@@ -30828,10 +30883,10 @@ function XD({
// marker-specific `usfm_va`/`usfm_vp` superscript coloring, until the wrap lands — a brief,
// imperceptible gap in a transient shape nothing at rest builds anymore.
o.registerMutationListener(
- it,
- (I) => {
+ at,
+ (R) => {
o.getEditorState().read(() => {
- for (const [q, j] of I) {
+ for (const [q, j] of R) {
if (j === "destroyed") continue;
const ne = ee(q);
!ne || Te(ne, _e) !== "attribute" || He(ne.getParent()) || o.getElementByKey(q)?.classList.add("attribute");
@@ -30840,20 +30895,20 @@ function XD({
},
{ skipInitialization: !1 }
),
- JD(o, p),
+ rK(o, p),
...c ? [
- o.registerNodeTransform(it, (I) => {
- o.isComposing() || $L(I);
+ o.registerNodeTransform(at, (R) => {
+ o.isComposing() || UL(R);
}),
o.registerCommand(
- Xr,
- (I) => cb(
+ Qr,
+ (R) => pb(
// COPY_COMMAND's payload is `ClipboardEvent | KeyboardEvent | null`. A plain
// `event instanceof ClipboardEvent` narrows this correctly in real browsers,
// but jsdom (our test environment) doesn't implement `ClipboardEvent` at all —
// `instanceof` against the undefined global throws — so this duck-checks the
// one property `$handleCopyForStandardView` actually needs instead.
- I && typeof I == "object" && "clipboardData" in I ? I : null,
+ R && typeof R == "object" && "clipboardData" in R ? R : null,
o,
!1,
d.current
@@ -30861,14 +30916,14 @@ function XD({
Je
),
o.registerCommand(
- wn,
- (I) => (
+ Nn,
+ (R) => (
// A structure-protected document's cut of a selection `StructureKeyboardPlugin`
// refuses to replace is that plugin's to refuse: it registers CUT at CRITICAL for
// exactly that reason, so it has already had its turn by the time this claim runs
// and a selection reaching here is one it allowed.
- cb(
- I && typeof I == "object" && "clipboardData" in I ? I : null,
+ pb(
+ R && typeof R == "object" && "clipboardData" in R ? R : null,
o,
!0,
d.current
@@ -30878,9 +30933,9 @@ function XD({
),
o.registerCommand(
un,
- (I) => jL(
+ (R) => QL(
// Same jsdom-safe duck-check as COPY above.
- I && typeof I == "object" && "clipboardData" in I ? I : null,
+ R && typeof R == "object" && "clipboardData" in R ? R : null,
p.structureProtectionMode === "protected",
// Consumed by $paraMarkerDeletionTransform below, same as the
// INSERT_PARAGRAPH_COMMAND and LOW-priority PASTE_COMMAND handlers arm it for
@@ -30895,39 +30950,39 @@ function XD({
)
] : [],
o.registerCommand(
- wn,
- () => (!Pl(p) && !Ts() && Kd(p), !1),
+ Nn,
+ () => (!wl(p) && !Ts() && Ud(p), !1),
ye
),
o.registerCommand(
- Yr,
- () => (o.isComposing() || aL(p), !1),
+ Xr,
+ () => (o.isComposing() || gL(p), !1),
$r
),
o.registerCommand(
- In,
- (I) => I || o.isComposing() ? !1 : pL(),
+ Ln,
+ (R) => R || o.isComposing() ? !1 : TL(),
$r
),
o.registerCommand(
- go,
+ mo,
() => (g = !1, _ = 0, Se(), !1),
Nt
),
o.registerCommand(
Jn,
- (I) => (g = !1, _ = 0, Se(), (I.key === "Backspace" || I.key === "Delete") && !Pl(p, TC(I)) && (Kd(p), oL(p), queueMicrotask(() => {
+ (R) => (g = !1, _ = 0, Se(), (R.key === "Backspace" || R.key === "Delete") && !wl(p, _C(R)) && (Ud(p), hL(p), queueMicrotask(() => {
p.wholeParaDeleteExpected?.clear(), p.collapsedDeleteCaretParas?.clear();
- })), o.isComposing() || !I.ctrlKey || I.altKey || I.shiftKey || I.metaKey || I.key !== " " && I.code !== "Space" || !n2() ? !1 : (I.preventDefault(), !0)),
+ })), o.isComposing() || !R.ctrlKey || R.altKey || R.shiftKey || R.metaKey || R.key !== " " && R.code !== "Space" || !u2() ? !1 : (R.preventDefault(), !0)),
Je
),
o.registerCommand(
- tk,
- (I) => {
- const q = MS();
- q === "needs-plain-split" && o.dispatchCommand(Ti, void 0);
- const j = q !== "declined" || kA();
- return j && I?.preventDefault(), Cc(p), j;
+ ok,
+ (R) => {
+ const q = OS();
+ q === "needs-plain-split" && o.dispatchCommand(Ci, void 0);
+ const j = q !== "declined" || SA();
+ return j && R?.preventDefault(), Cc(p), j;
},
Je
),
@@ -30935,13 +30990,13 @@ function XD({
// refused (see chapterLine.utils.ts). CRITICAL so both run ahead of every split, including
// this plugin's own char-stack split below.
o.registerCommand(
- Ti,
- () => uS(Ln, p.viewOptions),
+ Ci,
+ () => gS(qn, p.viewOptions),
ye
),
o.registerCommand(
Uc,
- () => XL(),
+ () => sq(),
ye
),
// A drop inserts through Lexical's clipboard path, which splits at every line break without
@@ -30949,11 +31004,11 @@ function XD({
// as a paste there does. LOW: below structure protection's HIGH block and the NORMAL
// replace-selection delete, above Lexical's own insertion at EDITOR.
o.registerCommand(
- Yr,
- (I) => {
- if (typeof I == "string" || !I.dataTransfer) return !1;
- const { text: q } = rS(I.dataTransfer, o._config.namespace);
- return !!q && fS(
+ Xr,
+ (R) => {
+ if (typeof R == "string" || !R.dataTransfer) return !1;
+ const { text: q } = cS(R.dataTransfer, o._config.namespace);
+ return !!q && mS(
q,
p.structureProtectionMode === "protected",
() => {
@@ -30965,14 +31020,14 @@ function XD({
Nt
),
o.registerCommand(
- Ti,
- () => (p.splitExpected.current = !0, iv()),
+ Ci,
+ () => (p.splitExpected.current = !0, lv()),
Je
),
- YD(o, p, c),
+ iK(o, p, c),
o.registerCommand(
- HS,
- (I) => (Y(I), !0),
+ QS,
+ (R) => (Y(R), !0),
// LOW, matching the sibling host-dispatched `COMMIT_PENDING_MARKERS_COMMAND` below. This
// command has exactly one handler, so priority decides nothing; CRITICAL is reserved in
// this file for handlers that must beat Lexical's built-ins on NATIVE commands, and using
@@ -30980,84 +31035,84 @@ function XD({
Nt
),
o.registerCommand(
- Kl,
- () => (f.current && W && (se(), ce = setTimeout(() => {
+ Ul,
+ () => (f.current && V && (se(), ce = setTimeout(() => {
if (ce = void 0, x || !f.current) return;
- const I = o.getRootElement(), q = I?.ownerDocument, j = q?.activeElement;
- !I || !q?.hasFocus() || !j || !(I === j || I.contains(j)) || (p.logger?.warn(
- `[MarkerEdit] marker settling has been suspended while the editor held focus for ${Tb}ms, so the suspension was lifted and held edits settled. The host did not resume on one of its close paths.`
+ const R = o.getRootElement(), q = R?.ownerDocument, j = q?.activeElement;
+ !R || !q?.hasFocus() || !j || !(R === j || R.contains(j)) || (p.logger?.warn(
+ `[MarkerEdit] marker settling has been suspended while the editor held focus for ${Eb}ms, so the suspension was lifted and held edits settled. The host did not resume on one of its close paths.`
), Y(!1));
- }, Tb)), !1),
+ }, Eb)), !1),
Nt
),
o.registerCommand(
- WS,
+ XS,
() => {
if (g) return !0;
- const I = o.getRootElement(), q = I?.ownerDocument, j = !!I && !!q && q.hasFocus() && I.contains(q.activeElement);
+ const R = o.getRootElement(), q = R?.ownerDocument, j = !!R && !!q && q.hasFocus() && R.contains(q.activeElement);
let ne;
if (j) {
const N = M();
ne = E(N) ? N.focus.key : h;
}
- return Of(() => Cc(p, ne)), !0;
+ return If(() => Cc(p, ne)), !0;
},
Nt
),
o.registerCommand(
- bp,
+ xp,
() => (y = !0, !1),
Nt
),
o.registerCommand(
- fp,
+ pp,
() => {
if (f.current)
- return W = !0, se(), !1;
+ return V = !0, se(), !1;
if (g) return !1;
- const I = M(), q = E(I) ? I.focus.key : h;
- return Of(() => Cc(p, q)), !1;
+ const R = M(), q = E(R) ? R.focus.key : h;
+ return If(() => Cc(p, q)), !1;
},
Nt
),
- o.registerUpdateListener(({ editorState: I, tags: q }) => {
- const j = y || q.has(yo);
+ o.registerUpdateListener(({ editorState: R, tags: q }) => {
+ const j = y || q.has(bo);
y = !1, p.splitExpected.current = !1, p.wholeParaDeleteExpected?.clear(), p.collapsedDeleteCaretParas?.clear(), p.rebuildAttempted.clear();
- const ne = I.read(() => {
+ const ne = R.read(() => {
const X = M();
return E(X) ? X.focus.key : void 0;
}), N = b;
- if (ne !== void 0 && (b = ne), q.has(Ll)) {
- Gk(o, I, q), g = !0, ne !== void 0 && (h = ne);
+ if (ne !== void 0 && (b = ne), q.has(Dl)) {
+ Zk(o, R, q), g = !0, ne !== void 0 && (h = ne);
return;
}
if (j) {
ne !== void 0 && ne !== N && (g = !0);
return;
}
- g || (ne !== void 0 && (h = ne), Se(), !(C || ne === void 0) && [...p.pendingKeys].some((X) => X !== ne) && (C = !0, queueMicrotask(() => {
- C = !1, !x && (f.current || F() || R(h));
+ g || (ne !== void 0 && (h = ne), Se(), !(T || ne === void 0) && [...p.pendingKeys].some((X) => X !== ne) && (T = !0, queueMicrotask(() => {
+ T = !1, !x && (f.current || U() || I(h));
})));
})
);
return () => {
- x = !0, be !== void 0 && clearTimeout(be), be = void 0, se(), m(), Fe(), l.current = void 0;
+ x = !0, be !== void 0 && clearTimeout(be), be = void 0, se(), m(), Ue(), l.current = void 0;
};
}, [o, a, c]), null;
}
-const QD = ["status_unknown", "status_invalid"], GS = {
+const oK = ["status_unknown", "status_invalid"], ZS = {
unknown: "This marker is not in the stylesheet!",
invalid: "This marker is not valid here!"
-}, ZD = Object.values(GS);
-function eK(e, t) {
+}, aK = Object.values(ZS);
+function cK(e, t) {
e.classList.toggle("status_unknown", t === "unknown"), e.classList.toggle("status_invalid", t === "invalid");
- const n = GS[t];
+ const n = ZS[t];
e.getAttribute("aria-description") !== n && (e.setAttribute("aria-description", n), e.title = n);
}
-function Cb(e) {
- e.classList.remove(...QD), e.removeAttribute("aria-description"), ZD.includes(e.title) && e.removeAttribute("title");
+function Mb(e) {
+ e.classList.remove(...oK), e.removeAttribute("aria-description"), aK.includes(e.title) && e.removeAttribute("title");
}
-function tK(e, t, n, r) {
+function lK(e, t, n, r) {
const i = (a) => a.read(() => Me().getChildrenKeys()), s = i(t), o = i(e);
if (!(s.length !== o.length || s.some((a, c) => a !== o[c])))
return e.read(() => {
@@ -31070,11 +31125,11 @@ function tK(e, t, n, r) {
return a;
});
}
-function nK(e) {
+function uK(e) {
const t = ee(e), n = t?.getTopLevelElement();
return !t || !n ? !1 : t.getKey() === n.getKey() ? !0 : $(t) && t.getParent()?.getKey() === n.getKey();
}
-function rK({
+function fK({
viewOptions: e,
styleInfo: t,
logger: n
@@ -31086,12 +31141,12 @@ function rK({
let o = /* @__PURE__ */ new Map();
const a = (l) => {
r.isComposing() || r.getEditorState().read(() => {
- const u = sq(s, l);
+ const u = pq(s, l);
let f = u;
if (l) {
f = new Map(u);
for (const [d, p] of o) {
- if (f.has(d) || nK(d)) continue;
+ if (f.has(d) || uK(d)) continue;
const m = ee(d)?.getTopLevelElement();
!m || l.has(m.getKey()) || f.set(d, p);
}
@@ -31099,11 +31154,11 @@ function rK({
for (const [d] of o) {
if (f.has(d)) continue;
const p = r.getElementByKey(d);
- p && Cb(p);
+ p && Mb(p);
}
for (const [d, p] of f) {
const m = r.getElementByKey(d);
- m && eK(m, p);
+ m && cK(m, p);
}
o = f, n?.debug(`[MarkerValidation] pass: ${f.size} flagged`);
});
@@ -31112,7 +31167,7 @@ function rK({
const c = r.registerUpdateListener(
({ editorState: l, prevEditorState: u, dirtyElements: f, dirtyLeaves: d }) => {
f.size === 0 && d.size === 0 || a(
- tK(l, u, f, d)
+ lK(l, u, f, d)
);
}
);
@@ -31120,21 +31175,21 @@ function rK({
c();
for (const [l] of o) {
const u = r.getElementByKey(l);
- u && Cb(u);
+ u && Mb(u);
}
};
}, [r, i, t, n]), null;
}
-function Us(e, t, n) {
+function Bs(e, t, n) {
const r = Math.min(e.length, t.length);
for (let i = 0; i < r; i++) {
const s = e[i], o = t[i];
n.set(s.getKey(), { node: o, siblings: t });
const a = Hn(o);
- a && A(s) && Us(s.getChildren(), a, n);
+ a && A(s) && Bs(s.getChildren(), a, n);
}
}
-const JS = /* @__PURE__ */ new WeakMap();
+const e_ = /* @__PURE__ */ new WeakMap();
function qa(e, t, n = 0) {
let r = n;
const i = (s) => {
@@ -31151,7 +31206,7 @@ function qa(e, t, n = 0) {
const p = u[d];
if (d > 0)
for (const m of t[r++] ?? [])
- f.push(m, ...JS.get(m) ?? []);
+ f.push(m, ...e_.get(m) ?? []);
if (p.length > 0) {
const m = {
...a,
@@ -31165,7 +31220,7 @@ function qa(e, t, n = 0) {
};
return i(e), r;
}
-function ii(e, t, n) {
+function si(e, t, n) {
const r = [], i = [];
for (const s of e.sentinels) {
const o = [], a = [];
@@ -31179,27 +31234,27 @@ function ii(e, t, n) {
}
return { live: r, serialized: i };
}
-function YS(e, t) {
+function t_(e, t) {
const n = [];
for (const r of e)
- xu(r, t) || ((ke(r) || z(r)) && n.push(r.getMarker()), A(r) && n.push(...YS(r.getChildren(), t)));
+ vu(r, t) || ((ke(r) || z(r)) && n.push(r.getMarker()), A(r) && n.push(...t_(r.getChildren(), t)));
return n;
}
-function XS(e) {
+function n_(e) {
const t = [];
for (const n of e) {
- const r = vi(n);
+ const r = Si(n);
(r === "para" || r === "char") && t.push(n.marker ?? "");
const i = Hn(n);
- i && t.push(...XS(i));
+ i && t.push(...n_(i));
}
return t;
}
function Da(e, t, n) {
- const r = YS(e, n), i = XS(t);
+ const r = t_(e, n), i = n_(t);
return r.length === i.length && r.every((s, o) => s === i[o]);
}
-function QS(e, t) {
+function r_(e, t) {
if (!e || e.input.run.length === 0) return;
const n = M();
let r, i;
@@ -31210,14 +31265,14 @@ function QS(e, t) {
r = ee(t.key), i = t.offset;
else
return;
- if (!(!T(r) || !r.isAttached()) && !(e.nodeKey !== void 0 && r.getKey() !== e.nodeKey) && r.getTextContent().slice(0, i).endsWith(e.input.run))
+ if (!(!C(r) || !r.isAttached()) && !(e.nodeKey !== void 0 && r.getKey() !== e.nodeKey) && r.getTextContent().slice(0, i).endsWith(e.input.run))
return { node: r, caretOffset: i, run: e.input.run };
}
-function Ru(e, t) {
- const n = t && ZS(e, t);
- return n ? cg(e, n.start, n.end) : e;
+function qu(e, t) {
+ const n = t && i_(e, t);
+ return n ? pg(e, n.start, n.end) : e;
}
-function ZS(e, t) {
+function i_(e, t) {
const n = t.node.getKey(), r = e.spans.find(
(o) => !o.isSentinel && o.key === n
);
@@ -31226,29 +31281,29 @@ function ZS(e, t) {
if (!(s < r.start) && e.text.slice(s, i) === t.run)
return { start: s, end: i };
}
-function e_(e, t, n, r, i, s) {
- const { viewOptions: o, getMarker: a, logger: c } = n, l = sg(e, a, o);
+function s_(e, t, n, r, i, s) {
+ const { viewOptions: o, getMarker: a, logger: c } = n, l = ug(e, a, o);
if (!l) return;
- const u = Iu(l, s, n), f = Ru(u, i), d = qo(f, {
+ const u = Du(l, s, n), f = qu(u, i), d = Do(f, {
getMarker: a,
- opensNamelessParagraph: rg(e)
+ opensNamelessParagraph: cg(e)
});
if (d.length === 0) return;
- if (ci(d) !== u.sentinels.length) {
+ if (li(d) !== u.sentinels.length) {
c?.warn("[MarkerEdit] Settled USJ skipped: sentinel/preserved-node count mismatch");
return;
}
- const p = pr.serializeEditorState(
+ const p = hr.serializeEditorState(
{ type: fr, version: ur, content: d },
o
).root.children;
- if (Oi(p) !== u.sentinels.length) {
+ if ($i(p) !== u.sentinels.length) {
c?.warn(
"[MarkerEdit] Settled USJ skipped: serialized sentinel/preserved-node count mismatch"
);
return;
}
- const m = ii(u, t, r);
+ const m = si(u, t, r);
if (!m) {
c?.warn("[MarkerEdit] Settled USJ skipped: a preserved node had no serialized form");
return;
@@ -31258,10 +31313,10 @@ function e_(e, t, n, r, i, s) {
return;
}
qa(p, m.serialized);
- const g = t_(e), y = Ag(p);
+ const g = o_(e), y = Rg(p);
for (let b = 0; b < g.length && b < y.length; b++)
g[b].sid !== void 0 && y[b].number === g[b].number && (y[b].sid = g[b].sid);
- return Eu(
+ return Au(
e,
f,
m.live,
@@ -31271,32 +31326,32 @@ function e_(e, t, n, r, i, s) {
o
);
}
-function t_(e) {
+function o_(e) {
const t = [], n = (r) => {
Le(r) ? t.push({ number: r.getNumber(), sid: r.getSid() }) : A(r) && r.getChildren().forEach(n);
};
return e.forEach(n), t;
}
-function Ag(e) {
+function Rg(e) {
const t = [];
for (const n of e) {
- _p(n) && t.push(n);
+ Mp(n) && t.push(n);
const r = Hn(n);
- r && t.push(...Ag(r));
+ r && t.push(...Rg(r));
}
return t;
}
-function iK(e, t, n, r, i, s) {
+function dK(e, t, n, r, i, s) {
const { viewOptions: o, getMarker: a, logger: c } = n, l = vs(e, a, o);
if (!l) return;
const { contentNodes: u } = l;
if (u.length === 0) return;
- const f = Iu(l.out, s, n), d = Ru(f, i), p = qo(d, {
+ const f = Du(l.out, s, n), d = qu(f, i), p = Do(d, {
getMarker: a,
isNoteContext: !0
});
if (p.length === 0) return;
- if (ci(p) !== f.sentinels.length) {
+ if (li(p) !== f.sentinels.length) {
c?.warn("[MarkerEdit] Settled note USJ skipped: sentinel/preserved-node count mismatch");
return;
}
@@ -31305,41 +31360,41 @@ function iK(e, t, n, r, i, s) {
c?.warn("[MarkerEdit] Settled note USJ skipped: unexpected tokenized shape");
return;
}
- const h = m.content ?? [], g = Iv(h), y = e.getCategory() !== g, b = mv(e, h);
+ const h = m.content ?? [], g = Bv(h), y = e.getCategory() !== g, b = Tv(e, h);
if (b) {
- const F = yv(
+ const U = Cv(
e,
b.before,
b.after,
g,
o
);
- if (!F || Oi(F) !== f.sentinels.length) {
+ if (!U || $i(U) !== f.sentinels.length) {
c?.warn("[MarkerEdit] Settled note USJ skipped: the closed note lost its content");
return;
}
- const R = ii(f, t, r);
- return R ? (qa(F, R.serialized), {
+ const I = si(f, t, r);
+ return I ? (qa(U, I.serialized), {
rebuilt: void 0,
contentNodes: u,
category: g,
categoryChanged: !1,
- closedAs: F
+ closedAs: U
}) : void 0;
}
- const C = gv(e, h, g, o);
- if (C.failure !== void 0) {
- C.failure === "shape" ? c?.warn("[MarkerEdit] Settled note USJ skipped: unexpected serialized shape") : C.failure === "caller" && c?.warn("[MarkerEdit] Settled note USJ skipped: serialized note lacks the caller");
+ const T = xv(e, h, g, o);
+ if (T.failure !== void 0) {
+ T.failure === "shape" ? c?.warn("[MarkerEdit] Settled note USJ skipped: unexpected serialized shape") : T.failure === "caller" && c?.warn("[MarkerEdit] Settled note USJ skipped: serialized note lacks the caller");
return;
}
- const x = C.children;
- if (Oi(x) !== f.sentinels.length) {
+ const x = T.children;
+ if ($i(x) !== f.sentinels.length) {
c?.warn(
"[MarkerEdit] Settled note USJ skipped: serialized sentinel/preserved-node count mismatch"
);
return;
}
- const _ = ii(f, t, r);
+ const _ = si(f, t, r);
if (!_) {
c?.warn("[MarkerEdit] Settled note USJ skipped: a preserved node had no serialized form");
return;
@@ -31352,7 +31407,7 @@ function iK(e, t, n, r, i, s) {
}
return qa(x, _.serialized), {
// Annotation marks, mirroring `$rebuildNoteContent`'s carry.
- rebuilt: Eu(
+ rebuilt: Au(
u,
d,
_.live,
@@ -31366,16 +31421,16 @@ function iK(e, t, n, r, i, s) {
categoryChanged: y
};
}
-function vb(e) {
+function Pb(e) {
return e.$?.textType;
}
-function sK(e, t) {
+function pK(e, t) {
const n = e, r = t;
- return n.type === "text" && r.type === "text" && n.format === r.format && n.style === r.style && n.mode === r.mode && n.detail === r.detail && vb(e) === vb(t) && // Lexical never merges a caret host with its neighbor (its mark is node state that differs),
+ return n.type === "text" && r.type === "text" && n.format === r.format && n.style === r.style && n.mode === r.mode && n.detail === r.detail && Pb(e) === Pb(t) && // Lexical never merges a caret host with its neighbor (its mark is node state that differs),
// and merged in, its placeholder would reach the save as authored text.
!Sa(e) && !Sa(t);
}
-function oK(e) {
+function hK(e) {
const t = [];
for (const n of e) {
const r = ee(n);
@@ -31383,13 +31438,13 @@ function oK(e) {
}
return t;
}
-function aK(e) {
+function gK(e) {
if (!$(e) || e.getMarkerSyntax() !== "opening") return;
const t = e.getParent();
if (!K(t)) return;
const n = e.getTextContent();
if (Sr(e)) return;
- const r = Io.exec(n);
+ const r = Lo.exec(n);
if (!r) return;
const i = r[1];
if (i.startsWith("+")) return;
@@ -31397,21 +31452,21 @@ function aK(e) {
if (t.getMarker() === s)
return { glyph: e, note: t, oldMarker: s, newMarker: i };
}
-function Al(e, t) {
+function Nl(e, t) {
const n = e;
- n.marker = t, n.text = Tu(t, n.markerSyntax, n.nested);
+ n.marker = t, n.text = Su(t, n.markerSyntax, n.nested);
}
-function n_(e, t) {
+function a_(e, t) {
const { glyph: n, note: r, oldMarker: i, newMarker: s } = e;
- if (!at.isValidMarker(s)) return;
+ if (!lt.isValidMarker(s)) return;
const o = t.get(r.getKey());
o && (o.node.marker = s);
const a = t.get(n.getKey());
- a && Al(a.node, s);
+ a && Nl(a.node, s);
const c = r.getChildren().filter($).filter((u) => u.getMarkerSyntax() === "closing" && u.getMarker() === i).at(-1), l = c && t.get(c.getKey());
- l && Al(l.node, s);
+ l && Nl(l.node, s);
}
-function r_(e, t, n, r) {
+function c_(e, t, n, r) {
const i = r.length - (n - t);
return {
text: e.text.slice(0, t) + r + e.text.slice(n),
@@ -31423,17 +31478,17 @@ function r_(e, t, n, r) {
sentinels: e.sentinels
};
}
-function cK(e, t, n) {
+function mK(e, t, n) {
const r = e.spans.find((i) => i.key === t && !i.isSentinel);
- return r ? r_(e, r.start, r.end, n) : e;
+ return r ? c_(e, r.start, r.end, n) : e;
}
-function i_(e, t = /* @__PURE__ */ new Set()) {
- return t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => i_(n, t)), t;
+function l_(e, t = /* @__PURE__ */ new Set()) {
+ return t.add(e.getKey()), A(e) && e.getChildren().forEach((n) => l_(n, t)), t;
}
-function lK(e, t) {
- const n = i_(t), r = e.spans.filter((d) => n.has(d.key));
+function yK(e, t) {
+ const n = l_(t), r = e.spans.filter((d) => n.has(d.key));
if (r.length === 0) return e;
- const i = Math.min(...r.map((d) => d.start)), s = Math.max(...r.map((d) => d.end)), o = e.spans.filter((d) => d.isSentinel && d.start < i).length, a = r.filter((d) => d.isSentinel).length, c = cv.test(e.text.slice(0, i)) ? " " : "", l = r_(e, i, s, c + Ot), u = i + c.length, f = [...e.sentinels];
+ const i = Math.min(...r.map((d) => d.start)), s = Math.max(...r.map((d) => d.end)), o = e.spans.filter((d) => d.isSentinel && d.start < i).length, a = r.filter((d) => d.isSentinel).length, c = pv.test(e.text.slice(0, i)) ? " " : "", l = c_(e, i, s, c + Ot), u = i + c.length, f = [...e.sentinels];
return f.splice(o, a, [t]), {
text: l.text,
spans: [
@@ -31443,39 +31498,39 @@ function lK(e, t) {
sentinels: f
};
}
-function Iu(e, t, n) {
+function Du(e, t, n) {
let r = e;
for (const { char: i, glyph: s, closer: o, newMarker: a } of t?.values() ?? [])
if (r.spans.some((c) => c.key === s.getKey())) {
- if (vv(i, a, n.getMarker)) {
- r = lK(r, i);
+ if (Pv(i, a, n.getMarker)) {
+ r = yK(r, i);
continue;
}
- o && (r = cK(
+ o && (r = mK(
r,
o.getKey(),
- rn(Tu(a, "closing", o.getNested()))
+ rn(Su(a, "closing", o.getNested()))
));
}
return r;
}
-function s_(e, t) {
+function u_(e, t) {
const { char: n, glyph: r, closer: i, newMarker: s } = e, o = t.get(n.getKey());
o && (o.node.marker = s);
const a = t.get(r.getKey());
- a && Al(a.node, s);
+ a && Nl(a.node, s);
const c = i && t.get(i.getKey());
- c && Al(c.node, s);
+ c && Nl(c.node, s);
}
-function uK(e, t, n, r, i, s, o) {
- const { viewOptions: a, getMarker: c, logger: l } = n, u = Pu(e, c, a), { contentNodes: f } = u;
- if (f.length === 0 && s.length === 0 || !og(u.out, s, c, a)) return;
- const d = Iu(u.out, o, n), p = Ru(d, i), m = qv(p, c);
- if (ci(m.content) !== d.sentinels.length) {
+function bK(e, t, n, r, i, s, o) {
+ const { viewOptions: a, getMarker: c, logger: l } = n, u = Nu(e, c, a), { contentNodes: f } = u;
+ if (f.length === 0 && s.length === 0 || !fg(u.out, s, c, a)) return;
+ const d = Du(u.out, o, n), p = qu(d, i), m = Fv(p, c);
+ if (li(m.content) !== d.sentinels.length) {
l?.warn("[MarkerEdit] Settled book USJ skipped: sentinel/preserved-node count mismatch");
return;
}
- const h = bv(
+ const h = vv(
e,
m.lineContent,
m.followingBlocks,
@@ -31486,13 +31541,13 @@ function uK(e, t, n, r, i, s, o) {
return;
}
const { children: g, followingBlocks: y } = h;
- if (Oi([...g, ...y]) !== d.sentinels.length) {
+ if ($i([...g, ...y]) !== d.sentinels.length) {
l?.warn(
"[MarkerEdit] Settled book USJ skipped: serialized sentinel/preserved-node count mismatch"
);
return;
}
- const b = ii(d, t, r);
+ const b = si(d, t, r);
if (!b) {
l?.warn("[MarkerEdit] Settled book USJ skipped: a preserved node had no serialized form");
return;
@@ -31501,28 +31556,28 @@ function uK(e, t, n, r, i, s, o) {
l?.debug("[MarkerEdit] Settled book USJ skipped: rebuild is a no-op (fixed point)");
return;
}
- const C = qa(g, b.serialized);
- qa(y, b.serialized, C);
- const x = t_([...f, ...s]), _ = Ag([...g, ...y]);
+ const T = qa(g, b.serialized);
+ qa(y, b.serialized, T);
+ const x = o_([...f, ...s]), _ = Rg([...g, ...y]);
for (let se = 0; se < x.length && se < _.length; se++)
x[se].sid !== void 0 && _[se].number === x[se].number && (_[se].sid = x[se].sid);
- const F = { ...e.exportJSON(), children: g }, [R, ...W] = Eu(
+ const U = { ...e.exportJSON(), children: g }, [I, ...V] = Au(
[...f, ...s],
p,
b.live,
- [F, ...y],
+ [U, ...y],
"bookLine",
c,
a
- ), ce = R && Hn(R);
+ ), ce = I && Hn(I);
if (ce)
- return { rebuilt: ce, contentNodes: f, followingBlocks: W };
+ return { rebuilt: ce, contentNodes: f, followingBlocks: V };
}
-function o_(e, t, n, r) {
- const { viewOptions: i, getMarker: s, logger: o } = t, a = fg(e, s, i);
+function f_(e, t, n, r) {
+ const { viewOptions: i, getMarker: s, logger: o } = t, a = mg(e, s, i);
if (!a) return;
- const c = Iu(a, r, t), l = Ru(c, n), u = Fv(l.text, s);
- if (ci(u) !== 0) {
+ const c = Du(a, r, t), l = qu(c, n), u = Wv(l.text, s);
+ if (li(u) !== 0) {
o?.warn("[MarkerEdit] Settled chapter USJ skipped: unexpected preserved-node placeholder");
return;
}
@@ -31530,15 +31585,15 @@ function o_(e, t, n, r) {
(y) => typeof y == "object" && y.type === "chapter"
);
f && e.getSid() !== void 0 && (f.sid = e.getSid());
- const d = pr.serializeEditorState(
+ const d = hr.serializeEditorState(
{ type: fr, version: ur, content: u },
i
- ).root.children, [p] = u, m = typeof p == "object" && p.type === "chapter", h = [e, ...ri(e)];
+ ).root.children, [p] = u, m = typeof p == "object" && p.type === "chapter", h = [e, ...ii(e)];
if (!(!m || e.getNumber() !== (p.number ?? "") || e.getAltnumber() !== p.altnumber || e.getPubnumber() !== p.pubnumber) && Fr(d, s) === Ur(h, s) && Da(h, d, s)) {
o?.debug("[MarkerEdit] Settled chapter USJ skipped: rebuild is a no-op (fixed point)");
return;
}
- return Eu(
+ return Au(
h,
l,
[],
@@ -31548,14 +31603,14 @@ function o_(e, t, n, r) {
i
);
}
-function a_(e, t, n) {
+function d_(e, t, n) {
const r = /* @__PURE__ */ new Map(), i = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), f = (m) => {
- K(m) ? s.set(m.getKey(), m) : Be(m) ? o.set(m.getKey(), m) : qe(m) ? a.set(m.getKey(), m) : r.set(m.getKey(), [m]);
+ K(m) ? s.set(m.getKey(), m) : Fe(m) ? o.set(m.getKey(), m) : qe(m) ? a.set(m.getKey(), m) : r.set(m.getKey(), [m]);
};
for (const m of e) {
const h = ee(m);
if (!h?.isAttached()) continue;
- const g = qS(h, t.getMarker);
+ const g = FS(h, t.getMarker);
if (g) {
u.set(g.char.getKey(), g);
continue;
@@ -31563,11 +31618,11 @@ function a_(e, t, n) {
const y = Ia(h);
if (y) {
if (f(y), $(h)) {
- const b = $S(h, t.getMarker);
+ const b = DS(h, t.getMarker);
b && i.push(b);
}
if (K(y)) {
- const b = aK(h);
+ const b = gK(h);
b && l.set(y.getKey(), b);
}
}
@@ -31581,7 +31636,7 @@ function a_(e, t, n) {
const m = Ia(n.node);
m && !d.has(m.getKey()) && f(m);
}
- const p = oK(e);
+ const p = hK(e);
return {
paraScopes: r,
noteScopes: s,
@@ -31594,22 +31649,22 @@ function a_(e, t, n) {
huskKeys: new Set(p.map((m) => m.getKey()))
};
}
-function c_(e, t) {
+function p_(e, t) {
e.splice(t, 1);
const n = e[t - 1], r = e[t], i = n && Or(n), s = r && Or(r);
- n && r && i !== void 0 && s !== void 0 && sK(n, r) && (n.text = i + s, e.splice(t, 1));
+ n && r && i !== void 0 && s !== void 0 && pK(n, r) && (n.text = i + s, e.splice(t, 1));
}
function Es(e, t, n, r, i, s) {
const o = t.get(e.getKey()), a = o ? Hn(o.node) : void 0;
if (!o || !a) return !1;
- const c = iK(e, t, n, r, i, s);
+ const c = dK(e, t, n, r, i, s);
if (!c) return !1;
if (c.closedAs) {
const f = o.siblings.indexOf(o.node);
if (f < 0) return !1;
const [d, ...p] = c.closedAs, m = o.node;
for (const h of Object.keys(m)) Reflect.deleteProperty(m, h);
- return Object.assign(m, d), o.siblings.splice(f + 1, 0, ...p), p.length > 0 && JS.set(o.node, p), !0;
+ return Object.assign(m, d), o.siblings.splice(f + 1, 0, ...p), p.length > 0 && e_.set(o.node, p), !0;
}
if (c.categoryChanged) {
const f = o.node;
@@ -31621,10 +31676,10 @@ function Es(e, t, n, r, i, s) {
const u = a.indexOf(l.node);
return u < 0 ? c.categoryChanged : (a.splice(u, c.contentNodes.length, ...c.rebuilt), !0);
}
-function l_(e, t, n, r, i, s, o) {
+function h_(e, t, n, r, i, s, o) {
const a = n.get(e.getKey()), c = a ? Hn(a.node) : void 0;
if (!a || !c) return !1;
- const l = uK(
+ const l = bK(
e,
n,
r,
@@ -31639,8 +31694,8 @@ function l_(e, t, n, r, i, s, o) {
const d = f ? c.indexOf(f.node) : c.length, p = a.siblings.indexOf(a.node);
return d < 0 || p < 0 ? !1 : (c.splice(d, l.contentNodes.length, ...l.rebuilt), a.siblings.splice(p + 1, t.length, ...l.followingBlocks), !0);
}
-function fK(e, t, n, r, i) {
- const s = QS(r, i);
+function kK(e, t, n, r, i) {
+ const s = r_(r, i);
if (t.size === 0 && !s) return;
const {
paraScopes: o,
@@ -31652,19 +31707,19 @@ function fK(e, t, n, r, i) {
charOpenerRenames: d,
husks: p,
huskKeys: m
- } = a_(t, n, s);
+ } = d_(t, n, s);
if (o.size === 0 && a.size === 0 && c.size === 0 && d.size === 0 && l.size === 0 && p.length === 0)
return;
const h = /* @__PURE__ */ new Map();
- Us(Me().getChildren(), e.root.children, h);
- for (const g of f.values()) n_(g, h);
- for (const g of d.values()) s_(g, h);
+ Bs(Me().getChildren(), e.root.children, h);
+ for (const g of f.values()) a_(g, h);
+ for (const g of d.values()) u_(g, h);
for (const g of a.values())
Es(g, h, n, m, s, d);
for (const g of o.values()) {
const y = h.get(g[0].getKey());
if (!y) continue;
- const b = e_(
+ const b = s_(
g,
h,
n,
@@ -31673,11 +31728,11 @@ function fK(e, t, n, r, i) {
d
);
if (!b) continue;
- const C = y.siblings.indexOf(y.node);
- C < 0 || y.siblings.splice(C, g.length, ...b);
+ const T = y.siblings.indexOf(y.node);
+ T < 0 || y.siblings.splice(T, g.length, ...b);
}
for (const g of l.values())
- l_(
+ h_(
g,
u.get(g.getKey()) ?? [],
h,
@@ -31689,111 +31744,111 @@ function fK(e, t, n, r, i) {
for (const g of c.values()) {
const y = h.get(g.getKey());
if (!y) continue;
- const b = 1 + ri(g).length, C = o_(g, n, s, d);
- if (!C) continue;
+ const b = 1 + ii(g).length, T = f_(g, n, s, d);
+ if (!T) continue;
const x = y.siblings.indexOf(y.node);
- x < 0 || (y.siblings.splice(x, b, ...C), jv(y.siblings, x));
+ x < 0 || (y.siblings.splice(x, b, ...T), Jv(y.siblings, x));
}
for (const g of p) {
const y = h.get(g.getKey());
if (!y) continue;
const b = y.siblings.indexOf(y.node);
- b < 0 || c_(y.siblings, b);
+ b < 0 || p_(y.siblings, b);
}
- return jC(e, n.viewOptions);
+ return YC(e, n.viewOptions);
}
-function dK({
+function xK({
viewOptions: e,
logger: t
}) {
- const [n] = Pe(), r = qi(e) && (e?.markerMode === "visible" || (e?.hasGutterParaMarkers ?? !1)), i = e?.hasGutterParaMarkers ?? !1;
+ const [n] = Pe(), r = Di(e) && (e?.markerMode === "visible" || (e?.hasGutterParaMarkers ?? !1)), i = e?.hasGutterParaMarkers ?? !1;
return J(() => {
if (r)
return n.registerNodeTransform(
Kt,
- (s) => i ? hK(s) : pK(s, t)
+ (s) => i ? CK(s) : TK(s, t)
);
}, [n, r, i, t]), null;
}
-function pK(e, t) {
- e.getMarker() !== Ln && (e.isEmpty() || Zt(e.getFirstChild()) || (t?.debug(
- `[ParaMarkerPrefixGuard] Resetting paragraph "${e.getMarker()}" → "${Ln}" (key ${e.getKey()})`
- ), e.setMarker(Ln)));
+function TK(e, t) {
+ e.getMarker() !== qn && (e.isEmpty() || Zt(e.getFirstChild()) || (t?.debug(
+ `[ParaMarkerPrefixGuard] Resetting paragraph "${e.getMarker()}" → "${qn}" (key ${e.getKey()})`
+ ), e.setMarker(qn)));
}
-function hK(e) {
+function CK(e) {
const t = e.getFirstChild();
- if (Zt(t) && !Un(t)) return;
- const n = rt(e.getMarker()) + U, [r = nx(n), ...i] = e.getChildren().filter(Un).sort((c, l) => Number(l.is(t)) - Number(c.is(t)));
+ if (Zt(t) && !Bn(t)) return;
+ const n = it(e.getMarker()) + B, [r = ax(n), ...i] = e.getChildren().filter(Bn).sort((c, l) => Number(l.is(t)) - Number(c.is(t)));
for (const c of i) c.remove();
if (r.getTextContent() !== n && r.setTextContent(n), r.is(t)) return;
t ? t.insertBefore(r) : e.append(r);
const s = M();
if (!E(s)) return;
- const o = su(e), a = Ks(e, o);
+ const o = au(e), a = Ks(e, o);
for (const c of [s.anchor, s.focus])
c.type === "element" && c.key === e.getKey() && c.offset < o && (a ? c.set(a.getKey(), 0, "text") : c.set(e.getKey(), o, "element"));
}
-function Qo(e) {
+function Zo(e) {
return e.pendedKeys.size === 0 && !e.transientInput;
}
-const gK = /^(\$(?:\.content\[\d+\])*)(?:\.|$|\[)/;
+const vK = /^(\$(?:\.content\[\d+\])*)(?:\.|$|\[)/;
function Mr(e) {
- return gK.exec(e)?.[1] ?? e;
+ return vK.exec(e)?.[1] ?? e;
}
function Cr(e, t) {
const n = e.jsonPath.slice(Mr(e.jsonPath).length);
return { ...e, jsonPath: `${Ht(t)}${n}` };
}
-function Do(e, t) {
+function Ko(e, t) {
return e.length === t.length && e.every((n, r) => n === t[r]);
}
-function u_(e) {
- if (op(e) || as(e)) return !0;
- const t = f_(e);
+function g_(e) {
+ if (cp(e) || cs(e)) return !0;
+ const t = m_(e);
return t === "marker" || t === "caller";
}
-const mK = /^\['([^']+)'\]$/;
-function f_(e) {
+const SK = /^\['([^']+)'\]$/;
+function m_(e) {
if (da(e))
- return mK.exec(
+ return SK.exec(
e.jsonPath.slice(Mr(e.jsonPath).length)
)?.[1];
}
-function ep(e, t, n) {
- return u_(e) && Do(
+function np(e, t, n) {
+ return g_(e) && Ko(
Gn(Mr(e.jsonPath)),
- Mn(t, gt(n))
+ Pn(t, mt(n))
);
}
-function d_(e, t, n) {
+function y_(e, t, n) {
if (!e.isAttached()) return;
const [r, i] = Vn(
- Cr(t, Mn(e, gt(n))),
+ Cr(t, Pn(e, mt(n))),
n
);
if (!(!r || i === void 0))
return { key: r.getKey(), offset: i, type: A(r) ? "element" : "text" };
}
-function wg(e, t) {
- const n = An(e, t, { addressDisplayBytes: !0 }), r = n && ee(n.key);
+function Ig(e, t) {
+ const n = wn(e, t, { addressDisplayBytes: !0 }), r = n && ee(n.key);
return n && n.offset > 0 && $(r) && r.getMarkerSyntax() !== "opening" ? n : void 0;
}
-function p_(e, t) {
- const n = An(e, t, { addressDisplayBytes: !0 });
+function b_(e, t) {
+ const n = wn(e, t, { addressDisplayBytes: !0 });
if (!n || n.offset !== 0) return;
const r = e.spans.findIndex((o) => o.key === n.key), i = e.spans[r], s = r > 0 ? e.spans[r - 1] : void 0;
if (!(!i || !ao(i) || !s || s.end !== i.start || !ao(s)))
- return qd(s);
+ return Kd(s);
}
-function yK(e, t) {
- const n = wg(e, t);
+function _K(e, t) {
+ const n = Ig(e, t);
if (n) return n;
- const r = p_(e, t);
+ const r = b_(e, t);
if (r) return r;
- const i = An(e, t);
- return i && bK(e, i);
+ const i = wn(e, t);
+ return i && EK(e, i);
}
-function bK(e, t) {
+function EK(e, t) {
if (t.type !== "text") return t;
const n = e.spans.findIndex((a) => a.key === t.key), r = e.spans[n], i = e.spans[n + 1];
if (!r || !i || r.end === r.start || t.offset !== r.end - r.start)
@@ -31801,45 +31856,45 @@ function bK(e, t) {
const s = e.text[i.start] === "\\", o = Wn.test(e.text[r.end - 1]);
return s || o ? { key: i.key, offset: 0, type: "text" } : t;
}
-function h_(e) {
+function k_(e) {
const t = e.markerName.length + 2, n = t + e.valueLength;
return { valueStart: t, closerStart: n, closerLength: e.markerName.length + 2 };
}
-function kK(e, t, n) {
- const { keyName: r } = e, { valueStart: i, closerStart: s } = h_(e);
+function MK(e, t, n) {
+ const { keyName: r } = e, { valueStart: i, closerStart: s } = k_(e);
return n === 0 ? { jsonPath: t, keyName: r } : n < i ? { jsonPath: t, keyName: r, keyOffset: n - 1 } : n < s ? {
jsonPath: `${t}['${r}']`,
propertyOffset: n - i
} : { jsonPath: t, keyName: r, keyClosingMarkerOffset: n - s };
}
-function xK(e, t) {
- const { valueStart: n, closerStart: r, closerLength: i } = h_(e), s = (o, a, c) => o >= 0 && o <= a ? c + o : void 0;
+function PK(e, t) {
+ const { valueStart: n, closerStart: r, closerLength: i } = k_(e), s = (o, a, c) => o >= 0 && o <= a ? c + o : void 0;
if (ha(t))
return s(t.keyOffset, e.markerName.length, 1);
if (pa(t))
return s(t.keyClosingMarkerOffset, i, r);
- if (Il(t)) return 0;
+ if (ql(t)) return 0;
if (da(t))
return s(t.propertyOffset, e.valueLength, n);
}
-function TK(e) {
- return ha(e) || pa(e) || Il(e) ? e.keyName : f_(e);
+function AK(e) {
+ return ha(e) || pa(e) || ql(e) ? e.keyName : m_(e);
}
-function CK(e, t, n) {
- const r = yK(e.spelling, t), i = r && ee(r.key);
+function wK(e, t, n) {
+ const r = _K(e.spelling, t), i = r && ee(r.key);
if (!r || !i) return;
const s = e.foldedAttributes.find((o) => o.ownerKey === r.key);
- return s ? kK(
+ return s ? MK(
s,
- Ht(Mn(i, gt(n))),
+ Ht(Pn(i, mt(n))),
r.offset
) : Gt(i, r.offset, n);
}
-function vK(e, t) {
+function NK(e, t) {
let n = Me();
for (let r = 0; r < t.length; r += 1) {
if (!A(n)) return;
- const i = Xt(n, gt(e.viewOptions))[t[r]];
+ const i = Xt(n, mt(e.viewOptions))[t[r]];
if (i?.type !== "element") return;
n = i.node;
const s = e.byFirstLiveKey.get(n.getKey());
@@ -31847,12 +31902,12 @@ function vK(e, t) {
return { plan: s, scratchIndexes: [0, ...t.slice(r + 1)] };
}
}
-function SK(e, t) {
+function OK(e, t) {
for (const n of e.byFirstLiveKey.values()) {
const r = n.closedNote;
if (!r || !n.liveNodes[0].isAttached()) continue;
- const i = Fa(e, n), s = (i?.length ?? 0) - 1, o = r.scratchNotePath.length - 1;
- if (!i || s < 0 || o < 0 || t.length <= s || !Do(t.slice(0, s), i.slice(0, s))) continue;
+ const i = Ua(e, n), s = (i?.length ?? 0) - 1, o = r.scratchNotePath.length - 1;
+ if (!i || s < 0 || o < 0 || t.length <= s || !Ko(t.slice(0, s), i.slice(0, s))) continue;
const a = t[s] - i[s];
if (!(a < 0 || a >= r.settledItemsFromNote))
return {
@@ -31865,21 +31920,21 @@ function SK(e, t) {
};
}
}
-function wl(e, t) {
+function Ol(e, t) {
const n = Gn(Mr(t.jsonPath));
if (n.length === 0) {
- if (!Jr(t)) return { kind: "live", location: t };
+ if (!Yr(t)) return { kind: "live", location: t };
const a = e.settledToLiveTopIndex(t.offset);
if (!a) {
const c = Xt(
Me(),
- gt(e.viewOptions)
+ mt(e.viewOptions)
).length;
return { kind: "live", location: { ...t, offset: c } };
}
- return a.plan && a.indexWithinScope > 0 ? wl(e, { jsonPath: Ht([t.offset]) }) : { kind: "live", location: { ...t, offset: a.liveIndex } };
+ return a.plan && a.indexWithinScope > 0 ? Ol(e, { jsonPath: Ht([t.offset]) }) : { kind: "live", location: { ...t, offset: a.liveIndex } };
}
- const r = SK(e, n);
+ const r = OK(e, n);
if (r) return { kind: "scope", ...r, location: t };
const i = e.settledToLiveTopIndex(n[0]);
if (!i) return;
@@ -31890,55 +31945,55 @@ function wl(e, t) {
scratchIndexes: [i.indexWithinScope, ...n.slice(1)],
location: t
};
- const s = [i.liveIndex, ...n.slice(1)], o = vK(e, s);
+ const s = [i.liveIndex, ...n.slice(1)], o = NK(e, s);
return o ? { kind: "scope", plan: o.plan, scratchIndexes: o.scratchIndexes, location: t } : { kind: "live", location: Cr(t, s) };
}
-function g_(e, t, n) {
- const r = TK(t);
+function x_(e, t, n) {
+ const r = AK(t);
if (r === void 0) return;
const i = Gn(Mr(t.jsonPath));
for (const s of e)
for (const o of s.foldedAttributes) {
const a = ee(o.ownerKey);
- if (o.keyName !== r || !a || !Do(Mn(a, gt(n)), i))
+ if (o.keyName !== r || !a || !Ko(Pn(a, mt(n)), i))
continue;
- const c = xK(o, t), l = s.spelling.spans.find((f) => f.key === o.ownerKey), u = c !== void 0 && l ? Si(s.spelling, o.ownerKey, c) : void 0;
+ const c = PK(o, t), l = s.spelling.spans.find((f) => f.key === o.ownerKey), u = c !== void 0 && l ? _i(s.spelling, o.ownerKey, c) : void 0;
return c === void 0 || !l || !u ? { resolution: void 0 } : {
resolution: {
kind: "literal",
run: s,
anchor: u,
- atWordByte: Dc(s.spelling, l.start + c)
+ atWordByte: Kc(s.spelling, l.start + c)
}
};
}
}
-function _K(e, t, n, r) {
- const i = g_(t, n, r.viewOptions);
+function $K(e, t, n, r) {
+ const i = x_(t, n, r.viewOptions);
if (i) return i.resolution;
const [s, o] = Vn(n, r.viewOptions);
if (!s || o === void 0) return;
- const a = gu(e, s), c = a && t.find((d) => d.sentinelIndex === a.sentinelIndex);
+ const a = bu(e, s), c = a && t.find((d) => d.sentinelIndex === a.sentinelIndex);
if (c) {
- const d = po(c.spelling, s, o);
+ const d = ho(c.spelling, s, o);
return d && {
kind: "literal",
run: c,
anchor: d.anchor,
- atWordByte: Dc(c.spelling, d.position)
+ atWordByte: Kc(c.spelling, d.position)
};
}
if (!a) {
- const d = po(e, s, o);
+ const d = ho(e, s, o);
return d ? {
kind: "anchor",
anchor: d.anchor,
- atWordByte: Dc(e, d.position)
+ atWordByte: Kc(e, d.position)
} : void 0;
}
- const l = mu(a.member, s);
+ const l = ku(a.member, s);
if (!l) return;
- const u = K(a.member) ? vs(a.member, r.getMarker, r.viewOptions)?.out : void 0, f = u && po(u, s, o);
+ const u = K(a.member) ? vs(a.member, r.getMarker, r.viewOptions)?.out : void 0, f = u && ho(u, s, o);
return {
kind: "preserved",
sentinelIndex: a.sentinelIndex,
@@ -31948,24 +32003,24 @@ function _K(e, t, n, r) {
type: A(s) ? "element" : "text",
noteAnchor: f && {
anchor: f.anchor,
- atWordByte: Dc(u, f.position)
+ atWordByte: Kc(u, f.position)
},
- isNoteOwnBytes: K(a.member) && ep(n, a.member, r.viewOptions)
+ isNoteOwnBytes: K(a.member) && np(n, a.member, r.viewOptions)
};
}
-function EK(e, t, n) {
- const r = g_(e, t, n);
+function RK(e, t, n) {
+ const r = x_(e, t, n);
if (r) return r.resolution !== void 0;
const [i, s] = Vn(t, n);
return i !== void 0 && s !== void 0;
}
-function Dc(e, t) {
+function Kc(e, t) {
const n = e.text[t];
return n !== void 0 && !Wn.test(n);
}
-function m_(e, t) {
+function T_(e, t) {
if (t.type !== "text") return t;
- const n = ag(e, t.key, t.offset);
+ const n = dg(e, t.key, t.offset);
if (!n) return t;
const r = n.end - n.start;
let i = t.offset;
@@ -31976,7 +32031,7 @@ function Ka(e, t) {
const n = e.liveCut;
return !t || !n || t.type !== "text" || t.key !== n.key ? t : t.offset >= n.nodeOffset ? { ...t, offset: t.offset + n.length } : t;
}
-function MK(e, t) {
+function IK(e, t) {
for (let n = 0; n < e.length; n += 1) {
const r = e[n];
for (let i = 0; i < r.length; i += 1) {
@@ -31986,11 +32041,11 @@ function MK(e, t) {
}
}
}
-function Ng(e) {
+function Lg(e) {
const { liveFragment: t, scratchFragment: n, sentinelMap: r, alignment: i } = e;
return t && n && r && i ? { liveFragment: t, scratchFragment: n, sentinelMap: r, alignment: i } : void 0;
}
-function y_(e) {
+function C_(e) {
const t = e.liveNodes[0];
if (!t.isAttached()) return;
if (e.kind !== "note" && A(t))
@@ -31998,15 +32053,15 @@ function y_(e) {
const n = t.getParent();
return n ? { key: n.getKey(), offset: t.getIndexWithinParent(), type: "element" } : void 0;
}
-function _i(e, t) {
+function Ei(e, t) {
return t?.warn(
`[positions] A settled location in a pending ${e.kind} scope could not be lined up with its live bytes; it resolves to the front of the scope.`
- ), y_(e);
+ ), C_(e);
}
-function $f(e, t) {
- return t?.error("settled-position basis out of date — rebuilt"), y_(e);
+function Lf(e, t) {
+ return t?.error("settled-position basis out of date — rebuilt"), C_(e);
}
-function Sb(e) {
+function Ab(e) {
const t = [];
let n = 0;
for (const r of e.spans) {
@@ -32016,24 +32071,24 @@ function Sb(e) {
}
return t;
}
-function PK(e, t, n, r) {
- const { liveFragment: i, scratchFragment: s, alignment: o } = t, a = Sb(s)[n];
- if (a === void 0) return _i(e, r);
- const c = Sb(i).findIndex(
- (d) => d !== void 0 && Yh(o, d, "live") === a
+function LK(e, t, n, r) {
+ const { liveFragment: i, scratchFragment: s, alignment: o } = t, a = Ab(s)[n];
+ if (a === void 0) return Ei(e, r);
+ const c = Ab(i).findIndex(
+ (d) => d !== void 0 && tg(o, d, "live") === a
), l = c < 0 ? void 0 : i.sentinels[c]?.[0], u = l?.isAttached() ? l.getParent() : void 0;
if (l && u)
return { key: u.getKey(), offset: l.getIndexWithinParent(), type: "element" };
- const f = An(i, {
- nonWsBefore: Lo(o, a, "settled"),
+ const f = wn(i, {
+ nonWsBefore: qo(o, a, "settled"),
wsRun: 0
});
- return f ? Ka(e, f) : _i(e, r);
+ return f ? Ka(e, f) : Ei(e, r);
}
-function b_(e, t, n, r, i, s) {
- const o = Ng(e);
- if (!o) return _i(e, s);
- const a = !Jr(r), c = E_(
+function v_(e, t, n, r, i, s) {
+ const o = Lg(e);
+ if (!o) return Ei(e, s);
+ const a = !Yr(r), c = N_(
o.alignment,
t.nonWsBefore,
o.scratchFragment.text,
@@ -32041,51 +32096,51 @@ function b_(e, t, n, r, i, s) {
o.liveFragment.text,
tc(o.alignment, t, "toLive")
), l = (f) => {
- const d = wg(o.liveFragment, f);
+ const d = Ig(o.liveFragment, f);
if (d) return Ka(e, d);
- const p = An(
+ const p = wn(
o.liveFragment,
- Rg(o.liveFragment, f, a),
+ Kg(o.liveFragment, f, a),
{ addressDisplayBytes: a }
);
return Ka(
e,
- p && n ? m_(o.liveFragment, p) : p
+ p && n ? T_(o.liveFragment, p) : p
);
- }, u = C2(o.alignment, t.nonWsBefore);
+ }, u = w2(o.alignment, t.nonWsBefore);
if (u < c.nonWsBefore) {
const f = l({ ...c, nonWsBefore: u }), d = f && ee(f.key);
- if (f && d && T_(d, f.offset, i)) return f;
+ if (f && d && E_(d, f.offset, i)) return f;
}
- return l(c) ?? _i(e, s);
+ return l(c) ?? Ei(e, s);
}
-function AK(e, t, n, r, i, s) {
- const o = MK(n.sentinelMap, r);
- if (!o) return PK(t, n, r.sentinelIndex, s);
+function qK(e, t, n, r, i, s) {
+ const o = IK(n.sentinelMap, r);
+ if (!o) return LK(t, n, r.sentinelIndex, s);
const a = n.liveFragment.sentinels[o.sentinelIndex]?.[o.memberIndex];
- if (!a?.isAttached()) return $f(t, s);
+ if (!a?.isAttached()) return Lf(t, s);
const c = e.byFirstLiveKey.get(a.getKey());
if (c?.kind === "note" && r.isNoteOwnBytes)
- return d_(a, i, e.viewOptions);
+ return y_(a, i, e.viewOptions);
if (c?.kind === "note")
- return r.noteAnchor ? b_(
+ return r.noteAnchor ? v_(
c,
r.noteAnchor.anchor,
r.noteAnchor.atWordByte,
i,
e.viewOptions,
s
- ) : _i(c, s);
+ ) : Ei(c, s);
let l = a;
for (const u of r.path) {
- if (!A(l)) return $f(t, s);
+ if (!A(l)) return Lf(t, s);
const f = l.getChildAtIndex(u);
- if (!f) return $f(t, s);
+ if (!f) return Lf(t, s);
l = f;
}
return { key: l.getKey(), offset: r.offset, type: r.type };
}
-function wK(e, t, n) {
+function DK(e, t, n) {
if (!e.scratch.getEditorState().read(() => {
const [o, a] = Vn(t, n);
return pn(o) && a !== void 0 && a >= o.getChildrenSize();
@@ -32094,75 +32149,75 @@ function wK(e, t, n) {
if (pn(s))
return { key: s.getKey(), offset: i.getIndexWithinParent() + 1, type: "element" };
}
-function NK(e, t, n) {
- const r = $K(e, t, n);
+function KK(e, t, n) {
+ const r = UK(e, t, n);
if (!r) return r;
const i = Cr(n.location, n.scratchIndexes);
return n.plan.scratch.getEditorState().read(() => {
const [o, a] = Vn(i, t.viewOptions);
- return T(o) && a !== void 0 && a > 0 && a === o.getTextContentSize();
- }) ? OK(t, r, n.location) : r;
+ return C(o) && a !== void 0 && a > 0 && a === o.getTextContentSize();
+ }) ? BK(t, r, n.location) : r;
}
-function OK(e, t, n) {
+function BK(e, t, n) {
const r = ee(t.key);
- if (t.type !== "text" || !T(r)) return t;
+ if (t.type !== "text" || !C(r)) return t;
const i = JSON.stringify(n);
let s = t, o = { node: r, offset: t.offset };
- for (const a of x_(r, t.offset)) {
+ for (const a of __(r, t.offset)) {
if (a.node.is(o.node) && a.offset === o.offset) continue;
if (a.node.is(o.node)) {
const l = a.node.getTextContent()[a.offset];
if (l === void 0 || !Wn.test(l)) break;
} else if (o.offset !== 0) break;
o = a;
- const c = np(e, a.node, a.offset);
+ const c = ip(e, a.node, a.offset);
JSON.stringify(c) === i && (s = { key: a.node.getKey(), offset: a.offset, type: "text" });
}
return s;
}
-function $K(e, t, n) {
+function UK(e, t, n) {
const { plan: r } = n, { logger: i, viewOptions: s } = e.tier2, o = r.closedNote?.scratchNotePath;
- if (r.kind === "note" && (o ? Do(n.scratchIndexes, o) && !as(n.location) : n.scratchIndexes.length === 1) && u_(n.location))
- return d_(r.liveNodes[0], n.location, t.viewOptions);
+ if (r.kind === "note" && (o ? Ko(n.scratchIndexes, o) && !cs(n.location) : n.scratchIndexes.length === 1) && g_(n.location))
+ return y_(r.liveNodes[0], n.location, t.viewOptions);
const a = Cr(n.location, n.scratchIndexes);
- if (!r.scratch.getEditorState().read(() => EK(r.settledOnlyRuns, a, s))) return;
- const l = wK(r, a, s);
+ if (!r.scratch.getEditorState().read(() => RK(r.settledOnlyRuns, a, s))) return;
+ const l = DK(r, a, s);
if (l) return l;
- const u = Ng(r);
- if (!u) return _i(r, i);
+ const u = Lg(r);
+ if (!u) return Ei(r, i);
const f = r.scratch.getEditorState().read(
- () => _K(
+ () => $K(
u.scratchFragment,
r.settledOnlyRuns,
a,
e.tier2
)
);
- if (!f) return _i(r, i);
+ if (!f) return Ei(r, i);
if (f.kind === "preserved")
- return AK(t, r, u, f, n.location, i);
+ return qK(t, r, u, f, n.location, i);
if (f.kind === "literal") {
- const { run: d, anchor: p } = f, m = dv(d, p.nonWsBefore, "toLiteral") ?? Lo(d.inner, p.nonWsBefore, "settled"), h = !Jr(n.location), g = Rg(
+ const { run: d, anchor: p } = f, m = yv(d, p.nonWsBefore, "toLiteral") ?? qo(d.inner, p.nonWsBefore, "settled"), h = !Yr(n.location), g = Kg(
u.liveFragment,
{
nonWsBefore: d.liveBefore + m,
wsRun: p.nonWsBefore === 0 ? d.liveWsBefore + p.wsRun : p.wsRun
},
h
- ), y = An(u.liveFragment, g, {
+ ), y = wn(u.liveFragment, g, {
addressDisplayBytes: !0
}), b = y && ee(y.key);
if (y && $(b) && b.getMarkerSyntax() !== "opening")
return Ka(r, y);
- const C = An(u.liveFragment, g, {
+ const T = wn(u.liveFragment, g, {
addressDisplayBytes: h
});
- return C ? Ka(
+ return T ? Ka(
r,
- f.atWordByte ? m_(u.liveFragment, C) : C
- ) : _i(r, i);
+ f.atWordByte ? T_(u.liveFragment, T) : T
+ ) : Ei(r, i);
}
- return b_(
+ return v_(
r,
f.anchor,
f.atWordByte,
@@ -32171,40 +32226,40 @@ function $K(e, t, n) {
i
);
}
-function _b(e, t, n) {
- const r = wl(t, n);
+function wb(e, t, n) {
+ const r = Ol(t, n);
if (!r) return;
if (r.kind === "live") {
- const o = RK(t, r.location);
+ const o = FK(t, r.location);
if (o) return o;
const [a, c] = Vn(r.location, t.viewOptions);
return a && c !== void 0 ? r.location : void 0;
}
- const i = NK(e, t, r), s = i && ee(i.key);
- return s ? LK(s, i.offset, t.viewOptions, r.plan.liveNodes) : void 0;
+ const i = KK(e, t, r), s = i && ee(i.key);
+ return s ? jK(s, i.offset, t.viewOptions, r.plan.liveNodes) : void 0;
}
-function Eb(e, t) {
+function Nb(e, t) {
let n = 0;
for (; n < e.length && n < t.length && e[n] === t[n]; ) n += 1;
return n;
}
-function k_(e, t, n) {
- const r = Eb(e, t), i = Math.min(
- Eb([...e].reverse().join(""), [...t].reverse().join("")),
+function S_(e, t, n) {
+ const r = Nb(e, t), i = Math.min(
+ Nb([...e].reverse().join(""), [...t].reverse().join("")),
e.length - r,
t.length - r
);
return n <= r ? n : n >= e.length - i ? n - e.length + t.length : r;
}
-function RK(e, t) {
- if (!as(t)) return;
+function FK(e, t) {
+ if (!cs(t)) return;
const n = Gn(Mr(t.jsonPath));
for (const [r, i] of e.renamedClosers) {
const s = ee(r)?.getParent();
- if (!(!s || !Do(Mn(s, gt(e.viewOptions)), n)))
+ if (!(!s || !Ko(Pn(s, mt(e.viewOptions)), n)))
return {
...t,
- closingMarkerOffset: k_(
+ closingMarkerOffset: S_(
i.settled,
i.live,
Math.min(t.closingMarkerOffset, i.settled.length)
@@ -32212,7 +32267,7 @@ function RK(e, t) {
};
}
}
-function Mb(e) {
+function Ob(e) {
for (let t = e; t; t = t.getParent()) {
let n = t.getPreviousSibling();
if (n) {
@@ -32223,51 +32278,51 @@ function Mb(e) {
}
return null;
}
-function IK(e, t) {
+function zK(e, t) {
for (let n = e; n; n = n.getParent())
if (t.some((r) => r.is(n))) return !0;
return !1;
}
-function* x_(e, t, n) {
+function* __(e, t, n) {
let r = e;
- if (T(e)) for (let i = t; i >= 0; i -= 1) yield { node: e, offset: i };
+ if (C(e)) for (let i = t; i >= 0; i -= 1) yield { node: e, offset: i };
else if (A(e)) {
const i = e.getChildAtIndex(Math.min(t, e.getChildrenSize()));
if (i) r = i;
else {
const s = e.getLastDescendant();
- if (T(s))
+ if (C(s))
for (let o = s.getTextContentSize(); o >= 0; o -= 1) yield { node: s, offset: o };
r = s ?? e;
}
}
- for (let i = Mb(r); i; i = Mb(i))
- if (T(i)) {
- if (n && !IK(i, n)) return;
+ for (let i = Ob(r); i; i = Ob(i))
+ if (C(i)) {
+ if (n && !zK(i, n)) return;
for (let s = i.getTextContentSize(); s >= 0; s -= 1) yield { node: i, offset: s };
}
}
-function LK(e, t, n, r) {
- const i = Gt(e, t, n), s = Ua([e, t]);
- if (!s || Ua(Vn(i, n))?.is(s)) return i;
- const o = (l, u) => T_(l, u, n), a = Og(e, t), c = a && o(a.node, a.offset);
+function jK(e, t, n, r) {
+ const i = Gt(e, t, n), s = Ba([e, t]);
+ if (!s || Ba(Vn(i, n))?.is(s)) return i;
+ const o = (l, u) => E_(l, u, n), a = qg(e, t), c = a && o(a.node, a.offset);
if (c) return c;
- for (const l of x_(e, t, r)) {
+ for (const l of __(e, t, r)) {
if (l.node.is(e) && l.offset === t) continue;
const u = o(l.node, l.offset);
if (u) return u;
}
return i;
}
-function T_(e, t, n) {
- const r = Gt(e, t, n), i = Ua(Vn(r, n));
+function E_(e, t, n) {
+ const r = Gt(e, t, n), i = Ba(Vn(r, n));
if (!i) return;
if (i.is(fn(e.getKey(), t, "text"))) return r;
- const s = Og(e, t);
+ const s = qg(e, t);
return s && i.is(fn(s.node.getKey(), s.offset, "text")) ? r : void 0;
}
-function Og(e, t) {
- if (!T(e)) return;
+function qg(e, t) {
+ if (!C(e)) return;
const n = t === e.getTextContentSize();
if (!n && t !== 0) return;
let r = e, i = n ? r.getNextSibling() : r.getPreviousSibling();
@@ -32281,78 +32336,78 @@ function Og(e, t) {
if (!s) return;
i = s;
}
- if (T(i))
+ if (C(i))
return { node: i, offset: n ? 0 : i.getTextContentSize() };
}
-function Ua([e, t]) {
+function Ba([e, t]) {
if (!e || t === void 0) return;
- if (T(e)) return fn(e.getKey(), t, "text");
+ if (C(e)) return fn(e.getKey(), t, "text");
if (A(e)) return fn(e.getKey(), t, "element");
const n = e.getParent();
if (!n) return;
const r = e.getIndexWithinParent() + (t > 0 ? 1 : 0);
return fn(n.getKey(), r, "element");
}
-function C_(e, t, n) {
+function M_(e, t, n) {
const r = Vn(e, n), i = Vn(t, n), [s, o] = r, [a, c] = i;
if (s && a && s.is(a))
return o !== void 0 && c !== void 0 && o > c;
- const l = Ua(r), u = Ua(i);
+ const l = Ba(r), u = Ba(i);
return !!l && !!u && u.isBefore(l);
}
-function v_(e, t, n) {
- const r = wl(e, t), i = wl(e, n);
+function P_(e, t, n) {
+ const r = Ol(e, t), i = Ol(e, n);
if (!(r?.kind !== "scope" || i?.kind !== "scope" || r.plan !== i.plan))
return r.plan.scratch.getEditorState().read(
- () => C_(
+ () => M_(
Cr(r.location, r.scratchIndexes),
Cr(i.location, i.scratchIndexes),
e.viewOptions
)
);
}
-function qK(e, t, n) {
+function VK(e, t, n) {
if (t.byFirstLiveKey.size === 0 && t.renamedClosers.size === 0) return n;
- const r = _b(e, t, n.start);
+ const r = wb(e, t, n.start);
if (!r) return;
if (!n.end) return { ...n, start: r };
- const i = _b(e, t, n.end);
+ const i = wb(e, t, n.end);
if (!i) return;
- const s = v_(t, n.start, n.end);
- return s !== void 0 && C_(r, i, t.viewOptions) !== s ? { ...n, start: i, end: r } : { ...n, start: r, end: i };
+ const s = P_(t, n.start, n.end);
+ return s !== void 0 && M_(r, i, t.viewOptions) !== s ? { ...n, start: i, end: r } : { ...n, start: r, end: i };
}
-function tp(e, t) {
+function rp(e, t) {
const n = Gn(Mr(t.jsonPath));
return n.length === 0 ? t : Cr(t, [
e.liveToSettledTopIndex(n[0]),
...n.slice(1)
]);
}
-function S_(e, t) {
+function A_(e, t) {
const n = e.closedNoteScopeOver(t.liveNodes[0]);
if (n && n !== t) return n;
const r = t.liveNodes[0].getParent(), i = r ? e.planContaining(r) : void 0;
return i === t ? void 0 : i;
}
-function Fa(e, t) {
- const n = t.liveNodes[0], r = S_(e, t);
+function Ua(e, t) {
+ const n = t.liveNodes[0], r = A_(e, t);
if (r) {
- const s = Lu(e, r, n, 0);
+ const s = Ku(e, r, n, 0);
return typeof s == "object" ? Gn(Mr(s.jsonPath)) : void 0;
}
- const i = DK(n, e.viewOptions);
+ const i = WK(n, e.viewOptions);
return i.length === 0 ? i : [e.liveToSettledTopIndex(i[0]), ...i.slice(1)];
}
-function DK(e, t) {
- const n = gt(t);
- return !kt(e) || !pn(e.getParent()) ? Mn(e, n) : [io(e, 0, n).index];
+function WK(e, t) {
+ const n = mt(t);
+ return !ht(e) || !pn(e.getParent()) ? Pn(e, n) : [io(e, 0, n).index];
}
-function $g(e, t, n) {
+function Dg(e, t, n) {
if (!t) return;
const r = e.closedNote?.scratchNotePath;
if (r) {
const a = r.length - 1, c = t.at(-1);
- return c === void 0 || a < 0 || n.length <= a || !Do(n.slice(0, a), r.slice(0, a)) || n[a] < r[a] ? void 0 : [
+ return c === void 0 || a < 0 || n.length <= a || !Ko(n.slice(0, a), r.slice(0, a)) || n[a] < r[a] ? void 0 : [
...t.slice(0, -1),
c + n[a] - r[a],
...n.slice(a + 1)
@@ -32364,11 +32419,11 @@ function $g(e, t, n) {
const o = t[0];
return o === void 0 ? void 0 : [o + i, ...s];
}
-function KK(e, t, n) {
+function HK(e, t, n) {
const r = e.liveCut;
return !r || t.getKey() !== r.key || n <= r.nodeOffset ? n : Math.max(r.nodeOffset, n - r.length);
}
-function UK(e, t, n, r, i) {
+function GK(e, t, n, r, i) {
let s = e.sentinels[t.sentinelIndex]?.[t.memberIndex];
if (s) {
for (const o of n) {
@@ -32380,30 +32435,30 @@ function UK(e, t, n, r, i) {
return Gt(s, r, i);
}
}
-function FK(e, t) {
- const n = pv(e, t);
+function JK(e, t) {
+ const n = bv(e, t);
if (n)
return {
run: n,
within: { nonWsBefore: 0, wsRun: t.wsRun - n.liveWsBefore }
};
- const r = Qh(e, t);
+ const r = rg(e, t);
if (r)
return {
run: r.run,
within: r.within ?? {
- nonWsBefore: Lo(r.run.inner, r.count, "live"),
+ nonWsBefore: qo(r.run.inner, r.count, "live"),
wsRun: t.wsRun
}
};
}
-function BK(e, t) {
+function YK(e, t) {
if (e.isSentinel) return !1;
if (t) return !0;
const n = ee(e.key);
return !($(n) && n.getMarkerSyntax() !== "opening");
}
-function Rg(e, t, n) {
+function Kg(e, t, n) {
let r = 0, i = 0;
for (const s of e.spans)
for (let o = s.start; o < s.end; o += 1) {
@@ -32411,18 +32466,18 @@ function Rg(e, t, n) {
if (r < t.nonWsBefore)
a || (r += 1);
else if (a) i += 1;
- else return i >= t.wsRun || BK(s, n) ? t : { ...t, wsRun: i };
+ else return i >= t.wsRun || YK(s, n) ? t : { ...t, wsRun: i };
}
return t;
}
-function __(e, t, n, r, i, s) {
- const { liveFragment: o, scratchFragment: a, sentinelMap: c, alignment: l } = t, u = gu(o, n);
+function w_(e, t, n, r, i, s) {
+ const { liveFragment: o, scratchFragment: a, sentinelMap: c, alignment: l } = t, u = bu(o, n);
if (u) {
const g = o.sentinels[u.sentinelIndex];
if (!c[u.sentinelIndex]?.some((x) => x !== void 0)) {
const x = g[0].getParent();
if (x)
- return __(
+ return w_(
e,
t,
x,
@@ -32433,46 +32488,46 @@ function __(e, t, n, r, i, s) {
s?.error("settled-position basis out of date — rebuilt");
return;
}
- const y = mu(u.member, n);
+ const y = ku(u.member, n);
if (!y) {
s?.error("settled-position basis out of date — rebuilt");
return;
}
const b = c[u.sentinelIndex]?.[u.memberIndex];
if (!b) return;
- const C = e.scratch.getEditorState().read(
- () => UK(a, b, y, r, i)
+ const T = e.scratch.getEditorState().read(
+ () => GK(a, b, y, r, i)
);
- if (C) return C;
+ if (T) return T;
s?.error("settled-position basis out of date — rebuilt");
return;
}
- const f = po(o, n, KK(e, n, r));
+ const f = ho(o, n, HK(e, n, r));
if (!f) return;
- const d = FK(e.settledOnlyRuns, f.anchor);
+ const d = JK(e.settledOnlyRuns, f.anchor);
if (d)
- return e.scratch.getEditorState().read(() => CK(d.run, d.within, i));
- const p = tc(l, f.anchor, "toSettled"), m = E_(
+ return e.scratch.getEditorState().read(() => wK(d.run, d.within, i));
+ const p = tc(l, f.anchor, "toSettled"), m = N_(
l,
p.nonWsBefore,
o.text,
f.anchor,
a.text,
p
- ), h = !Jr(
+ ), h = !Yr(
Gt(n, r, i)
);
return e.scratch.getEditorState().read(() => {
- const g = wg(a, m), y = g && ee(g.key);
+ const g = Ig(a, m), y = g && ee(g.key);
if (y) return Gt(y, g.offset, i);
- const b = p_(a, m), C = b && ee(b.key);
- if (C)
- return Gt(C, b.offset, i);
- const x = Rg(a, m, h), _ = An(a, x, { addressDisplayBytes: h });
- return _ && zK(_, i);
+ const b = b_(a, m), T = b && ee(b.key);
+ if (T)
+ return Gt(T, b.offset, i);
+ const x = Kg(a, m, h), _ = wn(a, x, { addressDisplayBytes: h });
+ return _ && XK(_, i);
});
}
-function Pb(e, t) {
+function $b(e, t) {
let n = 0, r = 0;
for (const i of e) {
if (Wn.test(i)) {
@@ -32484,17 +32539,17 @@ function Pb(e, t) {
}
return r;
}
-function E_(e, t, n, r, i, s) {
+function N_(e, t, n, r, i, s) {
if (!e.segments.some(
(c) => !c.same && c.liveStart === c.liveEnd && c.settledEnd > c.settledStart && c.settledEnd === t
)) return s;
- const a = Pb(n, r.nonWsBefore) - r.wsRun;
+ const a = $b(n, r.nonWsBefore) - r.wsRun;
return {
...s,
- wsRun: Math.max(0, Pb(i, s.nonWsBefore) - a)
+ wsRun: Math.max(0, $b(i, s.nonWsBefore) - a)
};
}
-function zK(e, t) {
+function XK(e, t) {
const n = ee(e.key);
if (!n) return;
const r = A(n) && e.offset >= n.getChildrenSize() && (pn(n) || n.getLastDescendant()?.is(Me().getLastDescendant())) && n.getLastDescendant();
@@ -32504,26 +32559,26 @@ function zK(e, t) {
t
) : Gt(n, e.offset, t);
}
-function Lu(e, t, n, r) {
+function Ku(e, t, n, r) {
if (t.kind === "note") {
- const a = t.liveNodes[0], c = K(a) && Dt(a)?.is(n) && r === n.getTextContentSize() ? Og(n, r) : void 0;
- if (c && !ep(
+ const a = t.liveNodes[0], c = K(a) && Dt(a)?.is(n) && r === n.getTextContentSize() ? qg(n, r) : void 0;
+ if (c && !np(
Gt(c.node, c.offset, e.viewOptions),
a,
e.viewOptions
)) {
- const u = Lu(e, t, c.node, c.offset);
+ const u = Ku(e, t, c.node, c.offset);
if (typeof u == "object") return u;
}
const l = Gt(n, r, e.viewOptions);
- if (ep(l, a, e.viewOptions)) {
- const u = Fa(e, t);
+ if (np(l, a, e.viewOptions)) {
+ const u = Ua(e, t);
return u && Cr(l, u);
}
}
- const i = Ng(t);
+ const i = Lg(t);
if (!i) return;
- const s = __(
+ const s = w_(
t,
i,
n,
@@ -32532,62 +32587,62 @@ function Lu(e, t, n, r) {
e.logger
);
if (typeof s != "object") return s;
- const o = $g(
+ const o = Dg(
t,
- Fa(e, t),
+ Ua(e, t),
Gn(Mr(s.jsonPath))
);
return o && Cr(s, o);
}
-function jK(e) {
+function QK(e) {
const t = [], n = (r) => {
if (A(r))
r.getChildren().forEach((i, s) => {
t.push({ node: r, offset: s }), n(i);
}), t.push({ node: r, offset: r.getChildrenSize() });
- else if (T(r))
+ else if (C(r))
for (let i = 0; i <= r.getTextContentSize(); i += 1)
t.push({ node: r, offset: i });
};
return e.liveNodes.forEach(n), t;
}
-function VK(e, t) {
- const n = t.scratch.getEditorState().read(() => Gt(Me(), 0, e.viewOptions)), r = $g(
+function ZK(e, t) {
+ const n = t.scratch.getEditorState().read(() => Gt(Me(), 0, e.viewOptions)), r = Dg(
t,
- Fa(e, t),
+ Ua(e, t),
Gn(Mr(n.jsonPath))
);
if (r) return Cr(n, r);
const i = t.liveNodes[0], s = i.getParent();
if (!s) return;
- const o = S_(e, t);
- return o ? P_(e, o, s, i.getIndexWithinParent()) : tp(
+ const o = A_(e, t);
+ return o ? $_(e, o, s, i.getIndexWithinParent()) : rp(
e,
Gt(s, i.getIndexWithinParent(), e.viewOptions)
);
}
-function M_(e, t, n) {
- const r = jK(t), i = n ? r.findIndex((s) => s.node.is(n.node) && s.offset === n.offset) : -1;
+function O_(e, t, n) {
+ const r = QK(t), i = n ? r.findIndex((s) => s.node.is(n.node) && s.offset === n.offset) : -1;
for (let s = (i < 0 ? r.length : i) - 1; s >= 0; s -= 1) {
- const { node: o, offset: a } = r[s], c = Lu(e, t, o, a);
+ const { node: o, offset: a } = r[s], c = Ku(e, t, o, a);
if (typeof c == "object") return c;
}
- return VK(e, t);
+ return ZK(e, t);
}
-function P_(e, t, n, r) {
- return Lu(e, t, n, r) ?? M_(e, t, { node: n, offset: r });
+function $_(e, t, n, r) {
+ return Ku(e, t, n, r) ?? O_(e, t, { node: n, offset: r });
}
-function np(e, t, n) {
+function ip(e, t, n) {
const r = e.planContaining(t);
- if (r) return P_(e, r, t, n);
+ if (r) return $_(e, r, t, n);
const i = e.renamedClosers.get(t.getKey());
if (i) {
const a = Gt(t, n, e.viewOptions);
- return tp(
+ return rp(
e,
- as(a) ? {
+ cs(a) ? {
...a,
- closingMarkerOffset: k_(
+ closingMarkerOffset: S_(
i.live,
i.settled,
a.closingMarkerOffset
@@ -32596,44 +32651,44 @@ function np(e, t, n) {
);
}
const s = pn(t) && n >= t.getChildrenSize() && t.getLastChild(), o = s ? e.planContaining(s) : void 0;
- return o ? WK(e, o) ?? M_(e, o, void 0) : tp(e, Gt(t, n, e.viewOptions));
+ return o ? eB(e, o) ?? O_(e, o, void 0) : rp(e, Gt(t, n, e.viewOptions));
}
-function WK(e, t) {
+function eB(e, t) {
const n = t.scratch.getEditorState().read(() => {
const i = Me();
return Gt(i, i.getChildrenSize(), e.viewOptions);
- }), r = $g(
+ }), r = Dg(
t,
- Fa(e, t),
+ Ua(e, t),
Gn(Mr(n.jsonPath))
);
return r && Cr(n, r);
}
-function HK(e) {
+function tB(e) {
const t = Qa(e.viewOptions);
if (!t || e.byFirstLiveKey.size === 0 && e.renamedClosers.size === 0)
return t;
const n = M();
if (!E(n)) return;
- const r = n.isBackward(), i = r ? n.focus : n.anchor, s = np(e, i.getNode(), i.offset);
+ const r = n.isBackward(), i = r ? n.focus : n.anchor, s = ip(e, i.getNode(), i.offset);
if (!s) return;
if (n.isCollapsed()) return { start: s };
- const o = r ? n.anchor : n.focus, a = np(e, o.getNode(), o.offset);
+ const o = r ? n.anchor : n.focus, a = ip(e, o.getNode(), o.offset);
if (a)
- return v_(e, s, a) === !0 ? { start: a, end: s } : { start: s, end: a };
+ return P_(e, s, a) === !0 ? { start: a, end: s } : { start: s, end: a };
}
-function A_(e, t, n) {
+function R_(e, t, n) {
if (e === "para") {
const [i] = t;
- return t.length === 1 && kt(i) ? D2(i, n.getMarker, n.viewOptions) : t.every(ke) ? sg(t, n.getMarker, n.viewOptions) : Id(t, n.getMarker, n.viewOptions);
+ return t.length === 1 && ht(i) ? W2(i, n.getMarker, n.viewOptions) : t.every(ke) ? ug(t, n.getMarker, n.viewOptions) : qd(t, n.getMarker, n.viewOptions);
}
if (e === "chapter")
- return _u(t, n.getMarker, n.viewOptions);
+ return Pu(t, n.getMarker, n.viewOptions);
const r = t.find(K);
return r && vs(r, n.getMarker, n.viewOptions)?.out;
}
-function GK(e, t) {
- const n = hp({
+function nB(e, t) {
+ const n = mp({
nodes: [...e],
onError: (r) => {
throw r;
@@ -32652,15 +32707,15 @@ function GK(e, t) {
}
return n;
}
-const Ab = "\0";
-function w_(e, t = []) {
+const Rb = "\0";
+function I_(e, t = []) {
for (const n of e)
- t.push(n.getKey()), A(n) && w_(n.getChildren(), t);
+ t.push(n.getKey()), A(n) && I_(n.getChildren(), t);
return t;
}
-function JK(e, t, n, r, i) {
- const s = `${r.viewOptions.markerMode}/${r.viewOptions.noteMode}`, o = t.map((l) => l.getTextContent()).join(Ab), a = w_(t).join(" "), c = i ? `${i.node.getKey()}:${i.run}@${i.caretOffset}` : "";
- return [e, s, n, o, a, c].join(Ab);
+function rB(e, t, n, r, i) {
+ const s = `${r.viewOptions.markerMode}/${r.viewOptions.noteMode}`, o = t.map((l) => l.getTextContent()).join(Rb), a = I_(t).join(" "), c = i ? `${i.node.getKey()}:${i.run}@${i.caretOffset}` : "";
+ return [e, s, n, o, a, c].join(Rb);
}
function sc(e, t = []) {
for (const n of e)
@@ -32668,13 +32723,13 @@ function sc(e, t = []) {
return t;
}
function Ms(e, t, n, r, i, s, o, a = () => ({
- fragment: A_(e, Me().getChildren(), o.tier2)
+ fragment: R_(e, Me().getChildren(), o.tier2)
})) {
- const c = GK(o.nodes, i);
+ const c = nB(o.nodes, i);
if (c)
- return N_(e, t, n, r, c, s, o, a);
+ return L_(e, t, n, r, c, s, o, a);
}
-function N_(e, t, n, r, i, s, o, a) {
+function L_(e, t, n, r, i, s, o, a) {
const c = i.getEditorState().read(() => {
const g = a();
if (!g) return;
@@ -32682,10 +32737,10 @@ function N_(e, t, n, r, i, s, o, a) {
return {
settledCount: Xt(
Me(),
- gt(o.tier2.viewOptions)
+ mt(o.tier2.viewOptions)
).length,
scratchFragment: y,
- settledSide: y && Xh(y),
+ settledSide: y && ng(y),
closedNote: g.closedNote
};
});
@@ -32700,10 +32755,10 @@ function N_(e, t, n, r, i, s, o, a) {
...d && { closedNote: d }
};
if ((n?.sentinels.length ?? 0) === 0 && (f?.runs.length ?? 0) === 0) {
- const g = n && f && xl(kl(n, []), f).alignment;
+ const g = n && f && Cl(Tl(n, []), f).alignment;
return { ...p, liveFragment: n, sentinelMap: [], settledOnlyRuns: [], alignment: g };
}
- const m = n && s && wv(n, s.live), h = m && f && xl(kl(m, s.live), f);
+ const m = n && s && Iv(n, s.live), h = m && f && Cl(Tl(m, s.live), f);
return h ? { ...p, liveFragment: m, ...h } : {
...p,
liveFragment: n,
@@ -32714,9 +32769,9 @@ function N_(e, t, n, r, i, s, o, a) {
}
function Ps(e, t) {
if (!e || !t) return { liveFragment: e, liveCut: void 0 };
- const n = ZS(e, t);
+ const n = i_(e, t);
return n ? {
- liveFragment: cg(e, n.start, n.end),
+ liveFragment: pg(e, n.start, n.end),
liveCut: {
key: t.node.getKey(),
nodeOffset: t.caretOffset - t.run.length,
@@ -32726,17 +32781,17 @@ function Ps(e, t) {
}
function oc(e, t) {
for (const n of e.noteGlyphRenames.values())
- n_(n, t);
+ a_(n, t);
for (const n of e.charOpenerRenames.values())
- s_(n, t);
+ u_(n, t);
}
-function YK(e, t) {
+function iB(e, t) {
const n = e.getKey();
return t.bookScopes.has(n) || [...t.paraScopes.values(), ...t.bookTrailingParas.values()].some(
(r) => r.some((i) => i.getKey() === n)
);
}
-function XK(e) {
+function sB(e) {
const t = e.getChildren();
let n = 0;
for (; n < t.length; ) {
@@ -32746,13 +32801,13 @@ function XK(e) {
}
return n < t.length ? t.slice(n + 1) : void 0;
}
-function QK(e, t, n, r) {
+function oB(e, t, n, r) {
const { getMarker: i, viewOptions: s } = n.tier2;
if (e.getUnknownAttributes()?.closed !== "false") return;
- const o = e.getTopLevelElement(), a = o && mu(o, e), c = vs(e, i, s)?.contentNodes;
- if (!o || !a || !c || YK(o, t)) return;
- const l = e.getNextSiblings(), u = lg([...c, ...l], i, s), f = Ki(o), d = /* @__PURE__ */ new Map();
- if (Us([o], [f], d), oc(t, d), sc([o]).filter((y) => !y.is(e) && t.noteScopes.has(y.getKey())).forEach(
+ const o = e.getTopLevelElement(), a = o && ku(o, e), c = vs(e, i, s)?.contentNodes;
+ if (!o || !a || !c || iB(o, t)) return;
+ const l = e.getNextSiblings(), u = hg([...c, ...l], i, s), f = Bi(o), d = /* @__PURE__ */ new Map();
+ if (Bs([o], [f], d), oc(t, d), sc([o]).filter((y) => !y.is(e) && t.noteScopes.has(y.getKey())).forEach(
(y) => Es(
y,
d,
@@ -32771,9 +32826,9 @@ function QK(e, t, n, r) {
))
return;
const p = d.get(e.getKey())?.node;
- if (!mE(p) || p.unknownAttributes?.closed === "false")
+ if (!TE(p) || p.unknownAttributes?.closed === "false")
return;
- const { liveFragment: m, liveCut: h } = Ps(u, r), g = ii(u, d, t.huskKeys);
+ const { liveFragment: m, liveCut: h } = Ps(u, r), g = si(u, d, t.huskKeys);
return Ms(
"note",
[e, ...l],
@@ -32786,18 +32841,18 @@ function QK(e, t, n, r) {
let y = Me().getFirstChild();
for (const b of a)
y = A(y) ? y.getChildAtIndex(b) : null;
- return K(y) ? O_(y, n.tier2) : void 0;
+ return K(y) ? q_(y, n.tier2) : void 0;
}
);
}
-function O_(e, { getMarker: t, viewOptions: n }) {
- const r = XK(e), i = e.getParent();
+function q_(e, { getMarker: t, viewOptions: n }) {
+ const r = sB(e), i = e.getParent();
if (!r || !i) return;
- const s = Mn(e, gt(n)), o = s.at(-1);
+ const s = Pn(e, mt(n)), o = s.at(-1);
if (o === void 0) return;
- const a = s.length === 1 ? Me() : i, c = Xt(a, gt(n));
+ const a = s.length === 1 ? Me() : i, c = Xt(a, mt(n));
return {
- fragment: lg(
+ fragment: hg(
[...r, ...e.getNextSiblings()],
t,
n
@@ -32805,13 +32860,13 @@ function O_(e, { getMarker: t, viewOptions: n }) {
closedNote: { scratchNotePath: s, settledItemsFromNote: c.length - o }
};
}
-function ZK(e, t, n, r, i) {
- const { getMarker: s, viewOptions: o } = r.tier2, { liveFragment: a, sentinelMap: c, scratchFragment: l } = e, u = a && gu(a, t), f = u && u.member.is(t) ? c?.[u.sentinelIndex]?.[u.memberIndex] : void 0, d = vs(t, s, o)?.contentNodes;
+function aB(e, t, n, r, i) {
+ const { getMarker: s, viewOptions: o } = r.tier2, { liveFragment: a, sentinelMap: c, scratchFragment: l } = e, u = a && bu(a, t), f = u && u.member.is(t) ? c?.[u.sentinelIndex]?.[u.memberIndex] : void 0, d = vs(t, s, o)?.contentNodes;
if (!f || !l || !d) return;
- const p = t.getNextSiblings(), m = lg([...d, ...p], s, o), { liveFragment: h, liveCut: g } = Ps(m, i), y = {
- live: m.sentinels.map((b) => b.filter((C) => !n.huskKeys.has(C.getKey())))
+ const p = t.getNextSiblings(), m = hg([...d, ...p], s, o), { liveFragment: h, liveCut: g } = Ps(m, i), y = {
+ live: m.sentinels.map((b) => b.filter((T) => !n.huskKeys.has(T.getKey())))
};
- return N_(
+ return L_(
"note",
[t, ...p],
h,
@@ -32822,15 +32877,15 @@ function ZK(e, t, n, r, i) {
() => {
const b = l.sentinels[f.sentinelIndex]?.[f.memberIndex];
if (!(!K(b) || b.getUnknownAttributes()?.closed === "false"))
- return O_(b, r.tier2);
+ return q_(b, r.tier2);
}
);
}
-function eU(e, t, n, r, i) {
- const s = QK(e, n, r, i);
+function cB(e, t, n, r, i) {
+ const s = oB(e, n, r, i);
if (s) return s;
- const { liveFragment: o, liveCut: a } = Ps(t, i), c = Ki(e), l = /* @__PURE__ */ new Map();
- if (Us([e], [c], l), oc(n, l), !Es(
+ const { liveFragment: o, liveCut: a } = Ps(t, i), c = Bi(e), l = /* @__PURE__ */ new Map();
+ if (Bs([e], [c], l), oc(n, l), !Es(
e,
l,
r.tier2,
@@ -32839,12 +32894,12 @@ function eU(e, t, n, r, i) {
n.charOpenerRenames
))
return;
- const u = t && ii(t, l, n.huskKeys);
+ const u = t && si(t, l, n.huskKeys);
return Ms("note", [e], o, a, [c], u, r);
}
-function tU(e, t, n, r, i) {
- const { liveFragment: s, liveCut: o } = Ps(t, i), a = e.map(Ki), c = /* @__PURE__ */ new Map();
- Us(e, a, c), oc(n, c), sc(e).filter((f) => n.noteScopes.has(f.getKey())).forEach(
+function lB(e, t, n, r, i) {
+ const { liveFragment: s, liveCut: o } = Ps(t, i), a = e.map(Bi), c = /* @__PURE__ */ new Map();
+ Bs(e, a, c), oc(n, c), sc(e).filter((f) => n.noteScopes.has(f.getKey())).forEach(
(f) => Es(
f,
c,
@@ -32854,7 +32909,7 @@ function tU(e, t, n, r, i) {
n.charOpenerRenames
)
);
- const l = e_(
+ const l = s_(
e,
c,
r.tier2,
@@ -32863,12 +32918,12 @@ function tU(e, t, n, r, i) {
n.charOpenerRenames
);
if (!l) return;
- const u = t && ii(t, c, n.huskKeys);
+ const u = t && si(t, c, n.huskKeys);
return Ms("para", e, s, o, l, u, r);
}
-function nU(e, t, n, r, i, s) {
- const { liveFragment: o, liveCut: a } = Ps(n, s), c = [e, ...t], l = c.map(Ki), u = /* @__PURE__ */ new Map();
- if (Us(c, l, u), oc(r, u), sc(c).filter((d) => r.noteScopes.has(d.getKey())).forEach(
+function uB(e, t, n, r, i, s) {
+ const { liveFragment: o, liveCut: a } = Ps(n, s), c = [e, ...t], l = c.map(Bi), u = /* @__PURE__ */ new Map();
+ if (Bs(c, l, u), oc(r, u), sc(c).filter((d) => r.noteScopes.has(d.getKey())).forEach(
(d) => Es(
d,
u,
@@ -32877,7 +32932,7 @@ function nU(e, t, n, r, i, s) {
s,
r.charOpenerRenames
)
- ), !l_(
+ ), !h_(
e,
t,
u,
@@ -32887,20 +32942,20 @@ function nU(e, t, n, r, i, s) {
r.charOpenerRenames
))
return;
- const f = n && ii(n, u, r.huskKeys);
+ const f = n && si(n, u, r.huskKeys);
return Ms("para", c, o, a, l, f, i);
}
-function rU(e, t, n, r, i) {
- const s = o_(e, r.tier2, i, n.charOpenerRenames);
+function fB(e, t, n, r, i) {
+ const s = f_(e, r.tier2, i, n.charOpenerRenames);
if (!s) return;
- const o = [e, ...ri(e)], a = e.getPreviousSibling(), c = [...n.paraScopes.values()].some(
+ const o = [e, ...ii(e)], a = e.getPreviousSibling(), c = [...n.paraScopes.values()].some(
(f) => f.some((d) => d.is(a))
);
- if ((ke(a) || kt(a)) && !c) {
- const f = [Ki(a), ...s];
- if (jv(f, 1), f.length === s.length) {
+ if ((ke(a) || ht(a)) && !c) {
+ const f = [Bi(a), ...s];
+ if (Jv(f, 1), f.length === s.length) {
const d = [a, ...o], { liveFragment: p, liveCut: m } = Ps(
- _u(d, r.tier2.getMarker, r.tier2.viewOptions),
+ Pu(d, r.tier2.getMarker, r.tier2.viewOptions),
i
);
return Ms(
@@ -32917,9 +32972,9 @@ function rU(e, t, n, r, i) {
const { liveFragment: l, liveCut: u } = Ps(t, i);
return Ms("chapter", o, l, u, s, void 0, r);
}
-function iU(e, t, n, r, i, s) {
- const o = Ki(e), a = /* @__PURE__ */ new Map();
- Us([e], [o], a), oc(r, a), sc([e]).filter((u) => r.noteScopes.has(u.getKey())).forEach(
+function dB(e, t, n, r, i, s) {
+ const o = Bi(e), a = /* @__PURE__ */ new Map();
+ Bs([e], [o], a), oc(r, a), sc([e]).filter((u) => r.noteScopes.has(u.getKey())).forEach(
(u) => Es(
u,
a,
@@ -32934,18 +32989,18 @@ function iU(e, t, n, r, i, s) {
const f = a.get(u.getKey());
if (!f) continue;
const d = f.siblings.indexOf(f.node);
- d < 0 || (c_(f.siblings, d), c.add(u.getKey()));
+ d < 0 || (p_(f.siblings, d), c.add(u.getKey()));
}
if (c.size === 0) return;
- const l = t && ii(t, a, c);
+ const l = t && si(t, a, c);
return Ms("para", [e], t, void 0, [o], l, i);
}
-function sU(e, t) {
+function pB(e, t) {
for (let n = e; n; n = n.getParent())
if (t.has(n.getKey())) return !0;
return !1;
}
-function wb(e, t, n = /* @__PURE__ */ new Map()) {
+function Ib(e, t, n = /* @__PURE__ */ new Map()) {
return {
renamedClosers: n,
closedNoteScopeOver: () => {
@@ -32959,20 +33014,20 @@ function wb(e, t, n = /* @__PURE__ */ new Map()) {
logger: t
};
}
-function oU(e) {
+function hB(e) {
return e.liveNodes.every((n) => n.isAttached()) ? (e.liveFragment?.spans ?? []).every((n) => ee(n.key) !== null) : !1;
}
-function Kc(e) {
+function Bc(e) {
return (e.type === "element" ? e.node : e.segments[0]?.node)?.getTopLevelElement() ?? null;
}
-function aU(e, t, n = /* @__PURE__ */ new Map()) {
+function gB(e, t, n = /* @__PURE__ */ new Map()) {
const r = Xt(Me(), t), i = [], s = [];
let o = 0;
for (let a = 0; a < r.length; ) {
- const c = Kc(r[a]), l = c && e.get(c.getKey());
+ const c = Bc(r[a]), l = c && e.get(c.getKey());
if (!l) {
i[a] = o, s.push({ liveIndex: a, indexWithinScope: 0 }), o += 1, a += 1;
- const d = r[a] && Kc(r[a]), p = c && !d?.is(c) ? n.get(c.getKey()) : 0;
+ const d = r[a] && Bc(r[a]), p = c && !d?.is(c) ? n.get(c.getKey()) : 0;
for (let m = 0; m < (p ?? 0); m += 1)
s.push({ liveIndex: a, indexWithinScope: 0 }), o += 1;
continue;
@@ -32980,7 +33035,7 @@ function aU(e, t, n = /* @__PURE__ */ new Map()) {
const u = new Set(l.liveNodes.map((d) => d.getKey()));
let f = 0;
for (; a + f < r.length; ) {
- const d = Kc(r[a + f]);
+ const d = Bc(r[a + f]);
if (!d || !u.has(d.getKey())) break;
f += 1;
}
@@ -32992,41 +33047,41 @@ function aU(e, t, n = /* @__PURE__ */ new Map()) {
}
return { liveToSettled: i, settledToLive: s };
}
-function cU(e, t) {
+function mB(e, t) {
const n = /* @__PURE__ */ new Map();
for (const r of e.values()) {
const i = r.liveNodes[0], s = r.closedNote?.settledItemsFromNote, o = i.getTopLevelElement();
- if (s === void 0 || !kt(o) || !i.isAttached()) continue;
- const [a, ...c] = Mn(i, t);
+ if (s === void 0 || !ht(o) || !i.isAttached()) continue;
+ const [a, ...c] = Pn(i, t);
if (a === void 0 || c.length > 0) continue;
- const l = Xt(Me(), t).slice(a).filter((u) => Kc(u)?.is(o)).length;
+ const l = Xt(Me(), t).slice(a).filter((u) => Bc(u)?.is(o)).length;
s > l && n.set(o.getKey(), s - l);
}
return n;
}
-function Nb(e) {
- const t = QS(e.transientInput, e.lastKnownCaret);
+function Lb(e) {
+ const t = r_(e.transientInput, e.lastKnownCaret);
if (e.pendedKeys.size === 0 && !t)
- return e.cache.entries.clear(), wb(e.tier2.viewOptions, e.tier2.logger);
+ return e.cache.entries.clear(), Ib(e.tier2.viewOptions, e.tier2.logger);
e.cache.getMarker !== e.tier2.getMarker && (e.cache.entries.clear(), e.cache.getMarker = e.tier2.getMarker);
- const n = a_(e.pendedKeys, e.tier2, t), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), a = (h, g) => {
+ const n = d_(e.pendedKeys, e.tier2, t), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), a = (h, g) => {
if (!h) return;
const y = h.liveNodes[0].getKey();
- r.set(y, h), h.liveNodes.forEach((b, C) => {
- (C === 0 || !i.has(b.getKey())) && i.set(b.getKey(), h);
+ r.set(y, h), h.liveNodes.forEach((b, T) => {
+ (T === 0 || !i.has(b.getKey())) && i.set(b.getKey(), h);
}), g && h.liveNodes.forEach((b) => s.set(b.getKey(), h));
}, c = (h, g, y, b) => {
o.add(h);
- const C = A_(g, y, e.tier2), x = JK(
+ const T = R_(g, y, e.tier2), x = rB(
g,
y,
- C?.text ?? "",
+ T?.text ?? "",
e.tier2,
t
), _ = e.cache.entries.get(h);
- if (_?.signature === x && oU(_.plan)) return _.plan;
- const F = b(C);
- return F ? e.cache.entries.set(h, { signature: x, plan: F }) : e.cache.entries.delete(h), F;
+ if (_?.signature === x && hB(_.plan)) return _.plan;
+ const U = b(T);
+ return U ? e.cache.entries.set(h, { signature: x, plan: U }) : e.cache.entries.delete(h), U;
};
for (const h of n.noteScopes.values())
a(
@@ -33034,7 +33089,7 @@ function Nb(e) {
h.getKey(),
"note",
h.getUnknownAttributes()?.closed === "false" ? [h, ...h.getNextSiblings()] : [h],
- (g) => eU(h, g, n, e, t)
+ (g) => cB(h, g, n, e, t)
),
!1
);
@@ -33044,7 +33099,7 @@ function Nb(e) {
h[0].getKey(),
"para",
h,
- (g) => tU(h, g, n, e, t)
+ (g) => lB(h, g, n, e, t)
),
!0
);
@@ -33055,7 +33110,7 @@ function Nb(e) {
h.getKey(),
"para",
[h, ...g],
- (y) => nU(h, g, y, n, e, t)
+ (y) => uB(h, g, y, n, e, t)
),
!0
);
@@ -33065,15 +33120,15 @@ function Nb(e) {
c(
h.getKey(),
"chapter",
- [h, ...ri(h)],
- (g) => rU(h, g, n, e, t)
+ [h, ...ii(h)],
+ (g) => fB(h, g, n, e, t)
),
!0
);
const l = /* @__PURE__ */ new Map();
for (const h of n.husks) {
const g = h.getTopLevelElement();
- if (!(ke(g) || kt(g)) || sU(h, i)) continue;
+ if (!(ke(g) || ht(g)) || pB(h, i)) continue;
const y = l.get(g.getKey()) ?? { para: g, husks: [] };
y.husks.push(h), l.set(g.getKey(), y);
}
@@ -33083,18 +33138,18 @@ function Nb(e) {
h,
"para",
[g],
- (b) => iU(g, b, y, n, e, t)
+ (b) => dB(g, b, y, n, e, t)
),
!0
);
for (const h of n.noteScopes.values()) {
if (h.getUnknownAttributes()?.closed !== "false") continue;
- const g = h.getTopLevelElement(), y = g ? s.get(g.getKey()) : void 0, b = y && ZK(y, h, n, e, t);
+ const g = h.getTopLevelElement(), y = g ? s.get(g.getKey()) : void 0, b = y && aB(y, h, n, e, t);
if (!b) continue;
- const C = r.get(h.getKey());
+ const T = r.get(h.getKey());
r.set(h.getKey(), b), b.liveNodes.forEach((x, _) => {
- const F = i.get(x.getKey());
- (_ === 0 || !F || F === C) && i.set(x.getKey(), b);
+ const U = i.get(x.getKey());
+ (_ === 0 || !U || U === T) && i.set(x.getKey(), b);
});
}
const u = /* @__PURE__ */ new Map();
@@ -33106,14 +33161,14 @@ function Nb(e) {
for (const { closer: h, newMarker: g } of n.charOpenerRenames.values())
h && f.set(h.getKey(), {
live: h.getTextContent(),
- settled: Tu(g, "closing", h.getNested())
+ settled: Su(g, "closing", h.getNested())
});
if (r.size === 0)
- return wb(e.tier2.viewOptions, e.tier2.logger, f);
- const d = gt(e.tier2.viewOptions), { liveToSettled: p, settledToLive: m } = aU(
+ return Ib(e.tier2.viewOptions, e.tier2.logger, f);
+ const d = mt(e.tier2.viewOptions), { liveToSettled: p, settledToLive: m } = gB(
s,
d,
- cU(r, d)
+ mB(r, d)
);
return {
byFirstLiveKey: r,
@@ -33131,7 +33186,7 @@ function Nb(e) {
logger: e.tier2.logger
};
}
-function lU({
+function yB({
scrRef: e,
onScrRefChange: t
}) {
@@ -33144,15 +33199,15 @@ function lU({
});
return J(() => {
const i = r.current, s = i.scrRef;
- i.scrRef = e, i.onScrRefChange = t, Nl(s, e) || uU(i, n, e);
+ i.scrRef = e, i.onScrRefChange = t, $l(s, e) || bB(i, n, e);
}, [n, e, t]), J(
() => n.registerMutationListener(
- Fn,
+ Un,
(i, { prevEditorState: s }) => {
const o = [...i.values()];
if (o.every((c) => c === "destroyed")) return;
- const a = rp(n);
- Ob(r.current, n, a, {
+ const a = sp(n);
+ qb(r.current, n, a, {
hasCreated: o.includes("created"),
hasDestroyed: o.includes("destroyed"),
isSameDocumentReload: vc(s) === vc(n.getEditorState())
@@ -33164,7 +33219,7 @@ function lU({
), J(() => {
const i = (a) => a.read(
() => new Set(
- Me().getChildren().filter(ot).map((c) => c.getKey())
+ Me().getChildren().filter(Ye).map((c) => c.getKey())
)
);
let s;
@@ -33173,14 +33228,14 @@ function lU({
if (s === c) return;
s = c;
const u = a === c ? /* @__PURE__ */ new Set() : i(a), f = i(c), d = [...f].some((p) => !u.has(p));
- d && (rp(n) || Ob(r.current, n, void 0, {
+ d && (sp(n) || qb(r.current, n, void 0, {
hasCreated: d,
hasDestroyed: [...u].some((p) => !f.has(p)),
isSameDocumentReload: vc(a) === vc(c)
}));
};
- return Ye(
- ...[$n, Qn].map(
+ return Xe(
+ ...[Rn, Qn].map(
(a) => n.registerMutationListener(
a,
(c, { prevEditorState: l }) => o(l),
@@ -33190,10 +33245,10 @@ function lU({
);
}, [n]), J(
() => n.registerCommand(
- Nn,
+ On,
() => {
const i = r.current;
- return i.phase === "idle" && gU(i, $_()), !1;
+ return i.phase === "idle" && vB(i, D_()), !1;
},
Nt
),
@@ -33202,92 +33257,92 @@ function lU({
const i = (s) => {
[...s.values()].some(
(a) => a === "created" || a === "destroyed"
- ) && queueMicrotask(() => n.dispatchCommand(Nn, void 0));
+ ) && queueMicrotask(() => n.dispatchCommand(On, void 0));
};
- return Ye(
+ return Xe(
n.registerMutationListener(sn, i),
n.registerMutationListener(Lt, i)
);
}, [n]), J(() => {
- const i = () => kU(r.current);
+ const i = () => MB(r.current);
return n.registerRootListener((s, o) => {
o?.removeEventListener("pointerdown", i), o?.removeEventListener("keydown", i), o?.removeEventListener("beforeinput", i), s?.addEventListener("pointerdown", i), s?.addEventListener("keydown", i), s?.addEventListener("beforeinput", i);
});
}, [n]), null;
}
-function uU(e, t, n) {
- if (fU(e, n)) return;
+function bB(e, t, n) {
+ if (kB(e, n)) return;
e.phase = "navigating", e.pendingEchoes.length = 0;
- const r = rp(t);
- (!r || r === n.book) && t.update(() => R_(t, n.chapterNum, n.verseNum));
+ const r = sp(t);
+ (!r || r === n.book) && t.update(() => K_(t, n.chapterNum, n.verseNum));
}
-function fU(e, t) {
- const n = e.pendingEchoes.findIndex((r) => Nl(r, t));
+function kB(e, t) {
+ const n = e.pendingEchoes.findIndex((r) => $l(r, t));
return n < 0 ? !1 : (e.pendingEchoes.splice(0, n + 1), e.phase = "idle", !0);
}
-function dU(e) {
- return $T(e) ?? Mx(e);
+function xB(e) {
+ return qT(e) ?? Nx(e);
}
-function $_() {
- const e = M(), t = dU(e);
+function D_() {
+ const e = M(), t = xB(e);
if (!t) return;
- const n = Ig(), r = fP(t);
+ const n = Bg(), r = mP(t);
if (!r && !n) return;
const i = r ? parseInt(r.getNumber() ?? "1", 10) : 1;
if (Number.isNaN(i)) return;
- const s = dh(t, e), { verseNum: o, verse: a } = BA(s ?? void 0, e);
+ const s = hh(t, e), { verseNum: o, verse: a } = HA(s ?? void 0, e);
if (!Number.isNaN(o))
return { book: n?.getCode() || void 0, chapterNum: i, verseNum: o, verse: a };
}
-function rp(e) {
- return e.getEditorState().read(() => Ig()?.getCode() || void 0);
+function sp(e) {
+ return e.getEditorState().read(() => Bg()?.getCode() || void 0);
}
-function Ig() {
+function Bg() {
return Me().getChildren().find(qe);
}
-function Ob(e, t, n, r) {
+function qb(e, t, n, r) {
const i = r.hasCreated && !e.sawDocument;
if (r.hasCreated && (e.sawDocument = !0), e.phase === "navigating") {
- r.hasCreated && (!n || n === e.scrRef.book) && Rf(e, t);
+ r.hasCreated && (!n || n === e.scrRef.book) && qf(e, t);
return;
}
- r.hasCreated && r.hasDestroyed ? (r.isSameDocumentReload || Rf(e, t), e.phase = "navigating") : i && Rf(e, t), n && n !== e.scrRef.book && q_(e, { ...e.scrRef, book: n }) && (e.phase = "navigating");
+ r.hasCreated && r.hasDestroyed ? (r.isSameDocumentReload || qf(e, t), e.phase = "navigating") : i && qf(e, t), n && n !== e.scrRef.book && F_(e, { ...e.scrRef, book: n }) && (e.phase = "navigating");
}
-function Rf(e, t) {
+function qf(e, t) {
queueMicrotask(() => {
t.update(
- () => R_(t, e.scrRef.chapterNum, e.scrRef.verseNum)
+ () => K_(t, e.scrRef.chapterNum, e.scrRef.verseNum)
);
});
}
-function R_(e, t, n) {
+function K_(e, t, n) {
const r = M()?.clone();
- pU(t, n);
+ TB(t, n);
const i = M();
- i && !(r && i.is(r)) && e.dispatchCommand(bp, void 0);
+ i && !(r && i.is(r)) && e.dispatchCommand(xp, void 0);
}
-function pU(e, t) {
- const n = $_();
- if (n?.chapterNum === e && (n.verse ? L_(t, n.verse) : n.verseNum === t))
+function TB(e, t) {
+ const n = D_();
+ if (n?.chapterNum === e && (n.verse ? U_(t, n.verse) : n.verseNum === t))
return;
- const r = Me().getChildren(), i = kx(r, e);
+ const r = Me().getChildren(), i = vx(r, e);
if (!i) return;
- const s = yP(r, i), o = uP(s, !0);
- mP(s, o);
+ const s = CP(r, i), o = gP(s, !0);
+ TP(s, o);
let a;
try {
- a = LA(s, t);
+ a = UA(s, t);
} catch {
return;
}
- a && (ke(a) ? !T(a.getFirstChild()) && Sn(a) || zn(a, 0) : hU(a));
+ a && (ke(a) ? !C(a.getFirstChild()) && Sn(a) || zn(a, 0) : CB(a));
}
-function hU(e) {
+function CB(e) {
const t = e.getParent();
if (!t) return;
const n = e.getIndexWithinParent() + 1, r = t.getChildAtIndex(n);
if (!r || Oe(r)) {
- T(e) ? e.selectEnd() : zn(t, n);
+ C(e) ? e.selectEnd() : zn(t, n);
return;
}
const i = Ks(t, n);
@@ -33295,38 +33350,38 @@ function hU(e) {
i.select(0, 0);
return;
}
- if (T(e)) {
+ if (C(e)) {
e.selectEnd();
return;
}
- const s = A(r) && !K(r) ? I_(r) : void 0;
+ const s = A(r) && !K(r) ? B_(r) : void 0;
s ? s.select(0, 0) : zn(t, n);
}
-function I_(e) {
+function B_(e) {
const t = e.getFirstChild();
- if (T(t)) return t;
- if (A(t) && !K(t)) return I_(t);
+ if (C(t)) return t;
+ if (A(t) && !K(t)) return B_(t);
}
function vc(e) {
return e.read(() => {
- const t = Me().getChildren().find(ot);
- return `${Ig()?.getCode() ?? ""}|${t?.getNumber() ?? ""}`;
+ const t = Me().getChildren().find(Ye);
+ return `${Bg()?.getCode() ?? ""}|${t?.getNumber() ?? ""}`;
});
}
-function gU(e, t) {
- e.phase !== "navigating" && t && (mU(t, e.scrRef) || q_(e, yU(t, e.scrRef)));
+function vB(e, t) {
+ e.phase !== "navigating" && t && (SB(t, e.scrRef) || F_(e, _B(t, e.scrRef)));
}
-function mU(e, t) {
- return e.book && e.book !== t.book || e.chapterNum !== t.chapterNum ? !1 : e.verse ? L_(t.verseNum, e.verse) : t.verseNum === e.verseNum;
+function SB(e, t) {
+ return e.book && e.book !== t.book || e.chapterNum !== t.chapterNum ? !1 : e.verse ? U_(t.verseNum, e.verse) : t.verseNum === e.verseNum;
}
-function L_(e, t) {
+function U_(e, t) {
try {
- return Hp(e, t);
+ return Jp(e, t);
} catch {
return !1;
}
}
-function yU(e, t) {
+function _B(e, t) {
const n = {
book: e.book || t.book,
chapterNum: e.chapterNum,
@@ -33334,26 +33389,26 @@ function yU(e, t) {
};
return e.verse != null && (n.verse = e.verse), t.versificationStr != null && (n.versificationStr = t.versificationStr), n;
}
-const bU = 8;
-function q_(e, t) {
- return Nl(t, e.scrRef) || e.pendingEchoes.some((n) => Nl(n, t)) ? !1 : (e.pendingEchoes.push(t), e.pendingEchoes.length > bU && e.pendingEchoes.shift(), e.onScrRefChange(t), !0);
+const EB = 8;
+function F_(e, t) {
+ return $l(t, e.scrRef) || e.pendingEchoes.some((n) => $l(n, t)) ? !1 : (e.pendingEchoes.push(t), e.pendingEchoes.length > EB && e.pendingEchoes.shift(), e.onScrRefChange(t), !0);
}
-function Nl(e, t) {
+function $l(e, t) {
return e.book === t.book && e.chapterNum === t.chapterNum && e.verseNum === t.verseNum && (e.verse ?? void 0) === (t.verse ?? void 0);
}
-function kU(e) {
+function MB(e) {
e.phase = "idle";
}
-function xU(e) {
- return qe(e) ? `${e.__code}` : Be(e) ? `${e.__marker} "${e.__number}"` : z(e) ? `${e.__marker}` : ai(e) ? `${e.__marker} "${e.__number}"` : Ut(e) ? `${e.__caller}` : Er(e) ? `${e.__marker} "${e.__number}"` : K(e) ? `${e.__marker} "${e.__caller}"` + (e.__isCollapsed ? " (collapsed)" : " (expanded)") : ke(e) ? `${e.__marker}` : T(e) ? `"${e.__text}"${TU(e)}` : ge(e) ? `ids: [ ${JSON.stringify(e.getTypedIDs())} ]` : Le(e) ? `${e.__marker} "${e.__number}"` : "";
+function PB(e) {
+ return qe(e) ? `${e.__code}` : Fe(e) ? `${e.__marker} "${e.__number}"` : z(e) ? `${e.__marker}` : ci(e) ? `${e.__marker} "${e.__number}"` : Bt(e) ? `${e.__caller}` : Er(e) ? `${e.__marker} "${e.__number}"` : K(e) ? `${e.__marker} "${e.__caller}"` + (e.__isCollapsed ? " (collapsed)" : " (expanded)") : ke(e) ? `${e.__marker}` : C(e) ? `"${e.__text}"${AB(e)}` : me(e) ? `ids: [ ${JSON.stringify(e.getTypedIDs())} ]` : Le(e) ? `${e.__marker} "${e.__number}"` : "";
}
-function TU(e) {
+function AB(e) {
return e.__state ? " " + JSON.stringify(e.__state.toJSON()[Lr]) : "";
}
-function CU() {
+function wB() {
const [e] = Pe();
return /* @__PURE__ */ O(
- q0,
+ F0,
{
viewClassName: "tree-view-output",
treeTypeButtonClassName: "debug-treetype-button",
@@ -33361,19 +33416,19 @@ function CU() {
timeTravelButtonClassName: "debug-timetravel-button",
timeTravelPanelSliderClassName: "debug-timetravel-panel-slider",
timeTravelPanelButtonClassName: "debug-timetravel-panel-button",
- customPrintNode: xU,
+ customPrintNode: PB,
editor: e
}
);
}
-const D_ = Wb(null), $b = 4;
-function vU({
+const z_ = Xb(null), Db = 4;
+function NB({
children: e,
className: t,
onClick: n,
title: r
}) {
- const i = ae(null), s = Hb(D_);
+ const i = ae(null), s = Qb(z_);
if (s === null)
throw new Error("DropDownItem must be used within a DropDown");
const { registerItem: o } = s;
@@ -33381,7 +33436,7 @@ function vU({
i && i.current && o(i);
}, [i, o]), /* @__PURE__ */ O("button", { className: t, onClick: n, ref: i, title: r, type: "button", children: e });
}
-function SU({
+function OB({
children: e,
dropDownRef: t,
onClose: n
@@ -33399,13 +33454,13 @@ function SU({
const p = r.indexOf(d) - 1;
return r[p === -1 ? r.length - 1 : p];
}) : f === "ArrowDown" && o((d) => d ? r[r.indexOf(d) + 1] : r[0]);
- }, l = bt(() => ({ registerItem: a }), [a]);
+ }, l = kt(() => ({ registerItem: a }), [a]);
return J(() => {
const u = s ?? r?.[0];
u?.current && u.current.focus();
- }, [r, s]), /* @__PURE__ */ O(D_.Provider, { value: l, children: /* @__PURE__ */ O("div", { className: "dropdown", ref: t, onKeyDown: c, children: e }) });
+ }, [r, s]), /* @__PURE__ */ O(z_.Provider, { value: l, children: /* @__PURE__ */ O("div", { className: "dropdown", ref: t, onKeyDown: c, children: e }) });
}
-function _U({
+function $B({
disabled: e = !1,
buttonLabel: t,
buttonAriaLabel: n,
@@ -33421,7 +33476,7 @@ function _U({
const d = c.current, p = a.current;
if (l && d !== null && p !== null) {
const { top: m, left: h } = d.getBoundingClientRect();
- p.style.top = `${m + d.offsetHeight + $b}px`, p.style.left = `${Math.min(h, window.innerWidth - p.offsetWidth - 20)}px`;
+ p.style.top = `${m + d.offsetHeight + Db}px`, p.style.left = `${Math.min(h, window.innerWidth - p.offsetWidth - 20)}px`;
}
}, [a, c, l]), J(() => {
const d = c.current;
@@ -33441,7 +33496,7 @@ function _U({
if (l) {
const p = c.current, m = a.current;
if (p !== null && m !== null) {
- const { top: h } = p.getBoundingClientRect(), g = h + p.offsetHeight + $b;
+ const { top: h } = p.getBoundingClientRect(), g = h + p.offsetHeight + Db;
g !== m.getBoundingClientRect().top && (m.style.top = `${g}px`);
}
}
@@ -33449,8 +33504,8 @@ function _U({
return document.addEventListener("scroll", d), () => {
document.removeEventListener("scroll", d);
};
- }, [c, a, l]), /* @__PURE__ */ ut(os, { children: [
- /* @__PURE__ */ ut(
+ }, [c, a, l]), /* @__PURE__ */ ft(as, { children: [
+ /* @__PURE__ */ ft(
"button",
{
type: "button",
@@ -33466,13 +33521,13 @@ function _U({
]
}
),
- l && ns(
- /* @__PURE__ */ O(SU, { dropDownRef: a, onClose: f, children: s }),
+ l && rs(
+ /* @__PURE__ */ O(OB, { dropDownRef: a, onClose: f, children: s }),
document.body
)
] });
}
-const ip = {
+const op = {
m: "m - Paragraph - Margin - No First Line Indent",
ms: "ms - Heading - Major Section Level 1",
nb: "nb - Paragraph - No Break with Previous Paragraph",
@@ -33483,8 +33538,8 @@ const ip = {
r: "r - Heading - Parallel References",
s: "s - Heading - Section Level 1"
// do not allow `b - Poetry - Stanza Break (Blank Line)` here to avoid a USFM validity issue.
-}, sp = {
- ...ip,
+}, ap = {
+ ...op,
// File / header
cl: "cl - Chapter - Publishing Label",
h: "h - File - Header",
@@ -33589,27 +33644,27 @@ const ip = {
// Tables
tr: "tr - Table - Row"
};
-function EU({
+function RB({
editorRef: e,
blockMarker: t,
disabled: n = !1
}) {
return /* @__PURE__ */ O(
- _U,
+ $B,
{
disabled: n,
buttonClassName: "toolbar-item block-controls",
- buttonIconClassName: "icon block-marker " + MU(t),
- buttonLabel: PU(t),
+ buttonIconClassName: "icon block-marker " + IB(t),
+ buttonLabel: LB(t),
buttonAriaLabel: "Formatting options for block type",
- children: Object.keys(ip).map((r) => /* @__PURE__ */ ut(
- vU,
+ children: Object.keys(op).map((r) => /* @__PURE__ */ ft(
+ NB,
{
- className: "item block-marker " + AU(t === r),
+ className: "item block-marker " + qB(t === r),
onClick: () => e.current?.formatPara(r),
children: [
/* @__PURE__ */ O("i", { className: "icon block-marker " + r }),
- /* @__PURE__ */ O("span", { className: "text usfm_" + r, children: ip[r] })
+ /* @__PURE__ */ O("span", { className: "text usfm_" + r, children: op[r] })
]
},
r
@@ -33617,19 +33672,19 @@ function EU({
}
);
}
-function MU(e) {
- return e && e in sp ? e : "ban";
+function IB(e) {
+ return e && e in ap ? e : "ban";
}
-function PU(e) {
- return e && e in sp ? sp[e] : "No Style";
+function LB(e) {
+ return e && e in ap ? ap[e] : "No Style";
}
-function AU(e) {
+function qB(e) {
return e ? "active dropdown-item-active" : "";
}
-function Rb() {
+function Kb() {
return /* @__PURE__ */ O("div", { className: "divider" });
}
-const wU = Ri(function({ editorRef: t, isReadonly: n = !1, onStateChange: r }, i) {
+const DB = Ii(function({ editorRef: t, isReadonly: n = !1, onStateChange: r }, i) {
const [s] = Pe(), [o, a] = ze(s), [c, l] = ze(), [u, f] = ze(!1), [d, p] = ze(!1), m = Ke(
({
canUndo: h,
@@ -33647,20 +33702,20 @@ const wU = Ri(function({ editorRef: t, isReadonly: n = !1, onStateChange: r }, i
[r]
);
return J(() => s.registerCommand(
- Nn,
+ On,
(h, g) => (a(g), !1),
ye
- ), [s]), /* @__PURE__ */ ut(os, { children: [
- /* @__PURE__ */ O(qC, { onStateChange: m }),
- /* @__PURE__ */ ut("div", { className: "toolbar", children: [
+ ), [s]), /* @__PURE__ */ ft(as, { children: [
+ /* @__PURE__ */ O(zC, { onStateChange: m }),
+ /* @__PURE__ */ ft("div", { className: "toolbar", children: [
/* @__PURE__ */ O(
"button",
{
disabled: !u || n,
onClick: () => {
- o.dispatchCommand(rk, void 0);
+ o.dispatchCommand(ck, void 0);
},
- title: mr ? "Undo (⌘Z)" : "Undo (Ctrl+Z)",
+ title: yr ? "Undo (⌘Z)" : "Undo (Ctrl+Z)",
type: "button",
className: "toolbar-item spaced",
"aria-label": "Undo",
@@ -33672,47 +33727,47 @@ const wU = Ri(function({ editorRef: t, isReadonly: n = !1, onStateChange: r }, i
{
disabled: !d || n,
onClick: () => {
- o.dispatchCommand(ik, void 0);
+ o.dispatchCommand(lk, void 0);
},
- title: mr ? "Redo (⌘Y)" : "Redo (Ctrl+Y)",
+ title: yr ? "Redo (⌘Y)" : "Redo (Ctrl+Y)",
type: "button",
className: "toolbar-item",
"aria-label": "Redo",
children: /* @__PURE__ */ O("i", { className: "format redo" })
}
),
- /* @__PURE__ */ O(Rb, {}),
- o === s && /* @__PURE__ */ ut(os, { children: [
+ /* @__PURE__ */ O(Kb, {}),
+ o === s && /* @__PURE__ */ ft(as, { children: [
/* @__PURE__ */ O(
- EU,
+ RB,
{
editorRef: t,
blockMarker: c,
disabled: n
}
),
- /* @__PURE__ */ O(Rb, {})
+ /* @__PURE__ */ O(Kb, {})
] }),
/* @__PURE__ */ O("div", { ref: i, className: "end-container" })
] })
] });
-}), NU = Co(), OU = {}, $U = {}, Ib = cE.filter((e) => e !== kp);
-function RU() {
+}), KB = vo(), BB = {}, UB = {}, Bb = pE.filter((e) => e !== Tp);
+function FB() {
return /* @__PURE__ */ O("div", { className: "editor-placeholder", children: "Enter some Scripture..." });
}
-function Lb(e) {
+function Ub(e) {
return e.type === "text" && e.offset !== 0 && e.offset !== e.getNode().getTextContentSize();
}
-function qb() {
+function Fb() {
const e = M();
if (!E(e) || !e.isCollapsed()) return;
const t = e.focus.getNode();
- return T(t) ? { key: t.getKey(), offset: e.focus.offset } : void 0;
+ return C(t) ? { key: t.getKey(), offset: e.focus.offset } : void 0;
}
-function IU(e, t, n) {
+function zB(e, t, n) {
if (!e || t.end && !Tn(t.end, t.start)) return;
const r = ee(e.key);
- if (!T(r) || e.offset > r.getTextContentSize()) return;
+ if (!C(r) || e.offset > r.getTextContentSize()) return;
const i = dr();
i.anchor.set(e.key, e.offset, "text"), i.focus.set(e.key, e.offset, "text");
const s = M();
@@ -33720,7 +33775,7 @@ function IU(e, t, n) {
const o = Qa(n);
return Mt(s), o && Tn(o.start, t.start) ? i : void 0;
}
-function LU(e) {
+function jB(e) {
const t = [], n = (r, i) => r?.forEach((s, o) => {
if (typeof s != "object") return;
const a = [...i, o];
@@ -33728,14 +33783,14 @@ function LU(e) {
});
return n(e?.content, []), t;
}
-function qU(e, t) {
+function VB(e, t) {
return e.editorState === t.editorState && e.pendedKeys === t.pendedKeys && e.transientInput === t.transientInput && e.caretKey === t.caretKey && e.caretOffset === t.caretOffset && e.viewOptions === t.viewOptions && e.getMarker === t.getMarker;
}
-function DU({
+function WB({
listener: e
}) {
const [t] = Pe();
- return Po(
+ return Ao(
() => t.registerUpdateListener((n) => e(n, t)),
[t, e]
), null;
@@ -33743,23 +33798,23 @@ function DU({
function Sc(e, t) {
e && !e.getIsCollapsed() && (t.current = e.getKey());
}
-function Db(e) {
+function zb(e) {
const t = e.getNextSiblings(), n = t.at(0), r = t.at(-1);
if (!n || !r) return [];
const i = A(r) ? r.getLastDescendant() ?? r : r;
- return tu(n, i);
+ return ru(n, i);
}
-function Kb(e, t, n) {
- U0(e, () => ps(t));
+function jb(e, t, n) {
+ V0(e, () => Ai(t));
const r = M();
if (!E(r)) return;
const i = /* @__PURE__ */ new Set();
r.getNodes().forEach((s) => {
const o = s.getTopLevelElement();
ke(o) && i.add(o);
- }), i.forEach((s) => Pg(s, t, n));
+ }), i.forEach((s) => $g(s, t, n));
}
-const K_ = Ri(function({
+const j_ = Ii(function({
defaultUsj: t,
scrRef: n,
onScrRefChange: r,
@@ -33771,45 +33826,45 @@ const K_ = Ri(function({
logger: l,
children: u
}, f) {
- const d = ae(null), p = ae(null), m = ae(null), h = ae(null), g = ae(t), y = ae(!1), b = ae(void 0), C = ae(void 0), x = ae(void 0), _ = ae({ entries: /* @__PURE__ */ new Map() }), F = ae(void 0), R = ae(0), W = ae(!0), ce = ae(void 0), [se, Y] = ze(t), [be, Se] = ze(0), [Fe, I] = ze(), {
+ const d = ae(null), p = ae(null), m = ae(null), h = ae(null), g = ae(t), y = ae(!1), b = ae(void 0), T = ae(void 0), x = ae(void 0), _ = ae({ entries: /* @__PURE__ */ new Map() }), U = ae(void 0), I = ae(0), V = ae(!0), ce = ae(void 0), [se, Y] = ze(t), [be, Se] = ze(0), [Ue, R] = ze(), {
isReadonly: q = !1,
structureProtectionMode: j = "off",
onHiddenContentDelete: ne,
hasExternalUI: N = !1,
hasSpellCheck: X = !1,
textDirection: oe = "ltr",
- markerMenuTrigger: me = "\\",
+ markerMenuTrigger: he = "\\",
view: ie,
- nodes: B,
+ nodes: F,
debug: ue = !1,
contextMenu: we,
styleInfo: $e,
- markerSettleDelayMs: mt,
+ markerSettleDelayMs: yt,
copyLimit: At
- } = c ?? $U, Ft = ie ?? NU, cn = Aa(Ft) && (Ft.markerMode !== "hidden" || !Ft.hasSpacing || Ft.hasGutterParaMarkers || Ft.hasActiveTextFocusBox) ? {
- ...Ft,
+ } = c ?? UB, Ut = ie ?? KB, cn = Aa(Ut) && (Ut.markerMode !== "hidden" || !Ut.hasSpacing || Ut.hasGutterParaMarkers || Ut.hasActiveTextFocusBox) ? {
+ ...Ut,
markerMode: "hidden",
hasSpacing: !0,
hasGutterParaMarkers: !1,
hasActiveTextFocusBox: !1
- } : Ft, Xe = ae(cn);
- Tn(Xe.current, cn) || (Xe.current = cn);
- const fe = Xe.current, Ne = bt(() => B ?? OU, [B]), Ui = bt(() => we, [we]), Qe = bt(
- () => lh($e ?? ks),
+ } : Ut, Qe = ae(cn);
+ Tn(Qe.current, cn) || (Qe.current = cn);
+ const fe = Qe.current, Ne = kt(() => F ?? BB, [F]), Ui = kt(() => we, [we]), Ze = kt(
+ () => fh($e ?? ks),
[$e]
), Zn = ae(l);
Tn(Zn.current, l) || (Zn.current = l);
- const Ze = Zn.current, L = Aa(fe), V = q || L, Z = cn !== Ft;
+ const et = Zn.current, L = Aa(fe), W = q || L, Z = cn !== Ut;
J(() => {
- L && !q && Ze?.error(
+ L && !q && et?.error(
"Editor: the block verse layout is read-only; ignoring `isReadonly: false`. Set `isReadonly: true` alongside `verseLayout: 'block'`."
- ), Z && Ze?.warn(
+ ), Z && et?.warn(
"Editor: a visible `markerMode`, `hasSpacing: false`, `hasGutterParaMarkers` and `hasActiveTextFocusBox` are not supported with the block verse layout and are ignored."
- ), fe?.markerMode === "visible" && !q && Ze?.warn(
+ ), fe?.markerMode === "visible" && !q && et?.warn(
"Editor: `markerMode: 'visible'` renders markers as read-only glyphs, but the editor is editable and no marker repair runs there. Pass `isReadonly: true` alongside it."
);
- }, [L, q, Z, Ze, fe?.markerMode]);
- const te = ae(null), ve = bt(() => {
+ }, [L, q, Z, et, fe?.markerMode]);
+ const te = ae(null), ve = kt(() => {
if (fe.markerMode !== "editable") return;
const w = $e ?? ks;
return {
@@ -33817,12 +33872,12 @@ const K_ = Ri(function({
// The context object is always one this same harness produced via `getContext()` above
// (never externally supplied), so it really is a full `MarkerMenuContext` at runtime -
// the cast bridges shared-react's structural `MarkerMenuContextLike` back to it.
- getItems: (D) => Hq(
+ getItems: (D) => tD(
w,
D,
Ne.extraValidMarkers
),
- getEnterItems: (D) => Jq(
+ getEnterItems: (D) => rD(
w,
D,
Ne.extraValidMarkers
@@ -33841,15 +33896,15 @@ const K_ = Ri(function({
`Cannot ${w} in the block verse layout; it is a read-only view whose structure does not match the source USJ.`
);
}, le = (w) => {
- if (de(w), V) throw new Error(`Cannot ${w} in readonly mode`);
- }, pe = bt(
- () => [vt, ...L ? Rw : au],
+ if (de(w), W) throw new Error(`Cannot ${w} in readonly mode`);
+ }, pe = kt(
+ () => [vt, ...L ? Kw : lu],
[L]
- ), xe = () => !!d.current && Fh(d.current), st = bt(
+ ), xe = () => !!d.current && zh(d.current), ct = kt(
() => ({
namespace: "platformEditor",
- theme: { ...vS, showCharMarkerTitles: fe.showCharMarkerTitles },
- editable: !V,
+ theme: { ...PS, showCharMarkerTitles: fe.showCharMarkerTitles },
+ editable: !W,
editorState: void 0,
// Handling of errors during update
onError(w) {
@@ -33857,11 +33912,11 @@ const K_ = Ri(function({
},
nodes: pe
}),
- [V, pe, fe.showCharMarkerTitles]
+ [W, pe, fe.showCharMarkerTitles]
);
- to.initialize(Ze);
- function et(w) {
- if (w !== void 0 && !lq(w, Ne.extraValidMarkers))
+ to.initialize(et);
+ function tt(w) {
+ if (w !== void 0 && !yq(w, Ne.extraValidMarkers))
throw new Error(`Unsupported character marker '${w}'`);
}
const tn = Ke(() => {
@@ -33871,7 +33926,7 @@ const K_ = Ri(function({
if (!y.current) return;
const Rt = to.deserializeEditorState(w.getEditorState(), fe);
Rt && (g.current = Rt, y.current = !1);
- }, G = Jf(w), re = C.current;
+ }, G = Qf(w), re = T.current;
if ((!G || G.size === 0) && !re)
return D(), g.current;
const Re = w.getEditorState(), De = x.current, Ge = {
@@ -33881,72 +33936,72 @@ const K_ = Ri(function({
caretKey: De?.key,
caretOffset: De?.offset,
viewOptions: fe,
- getMarker: Qe
- }, tt = F.current;
- if (tt && qU(tt.key, Ge)) return tt.usj;
- const ft = Re.toJSON(), yt = Re.read(
- () => fK(
- ft,
+ getMarker: Ze
+ }, nt = U.current;
+ if (nt && VB(nt.key, Ge)) return nt.usj;
+ const dt = Re.toJSON(), bt = Re.read(
+ () => kK(
+ dt,
G ?? /* @__PURE__ */ new Set(),
- { viewOptions: fe, getMarker: Qe, logger: Ze },
+ { viewOptions: fe, getMarker: Ze, logger: et },
re,
De
)
);
- return yt ? (F.current = { key: Ge, usj: yt }, yt) : (D(), g.current);
- }, [fe, Qe, Ze]), Bt = Ke(() => {
+ return bt ? (U.current = { key: Ge, usj: bt }, bt) : (D(), g.current);
+ }, [fe, Ze, et]), Ft = Ke(() => {
const w = d.current;
if (!w) return;
const D = {
- pendedKeys: Jf(w) ?? /* @__PURE__ */ new Set(),
- transientInput: C.current,
+ pendedKeys: Qf(w) ?? /* @__PURE__ */ new Set(),
+ transientInput: T.current,
lastKnownCaret: x.current,
- tier2: { viewOptions: fe, getMarker: Qe, logger: Ze },
+ tier2: { viewOptions: fe, getMarker: Ze, logger: et },
nodes: pe,
cache: _.current
};
- return Qo(D) && D.cache.entries.clear(), D;
- }, [fe, Qe, Ze, pe]), er = Ke(
+ return Zo(D) && D.cache.entries.clear(), D;
+ }, [fe, Ze, et, pe]), er = Ke(
(w) => {
- const D = d.current, G = Bt();
+ const D = d.current, G = Ft();
if (!(!D || !G))
- return Qo(G) ? w : D.getEditorState().read(() => {
- const re = Nb(G);
- return qK(G, re, w);
+ return Zo(G) ? w : D.getEditorState().read(() => {
+ const re = Lb(G);
+ return VK(G, re, w);
});
},
- [Bt]
+ [Ft]
);
- J(() => (W.current = !0, () => {
- W.current = !1;
+ J(() => (V.current = !0, () => {
+ V.current = !1;
}), []);
- const li = Ke(
+ const ui = Ke(
(w, D) => w.read(() => {
- const G = Bt(), re = G && HK(Nb(G));
- return !re && E(M()) && Ze?.warn(
+ const G = Ft(), re = G && tB(Lb(G));
+ return !re && E(M()) && et?.warn(
`${D} refused: the selection could not be expressed against the document the host is reading`
), re;
}),
- [Bt, Ze]
+ [Ft, et]
), ac = Ke(
(w) => {
if (!i) return;
- const D = d.current, G = Bt();
- R.current += 1;
- const re = R.current;
- if (!D || !G || Qo(G)) {
+ const D = d.current, G = Ft();
+ I.current += 1;
+ const re = I.current;
+ if (!D || !G || Zo(G)) {
i(w);
return;
}
queueMicrotask(() => {
- if (!W.current || re !== R.current || d.current !== D) return;
- const Re = li(D, "onSelectionChange");
- re === R.current && i(Re);
+ if (!V.current || re !== I.current || d.current !== D) return;
+ const Re = ui(D, "onSelectionChange");
+ re === I.current && i(Re);
});
},
- [i, Bt, li]
+ [i, Ft, ui]
);
- function Ko(w, D, G) {
+ function Bo(w, D, G) {
if (L && D === "remote") {
Zn.current?.error(
"Editor: ignoring a remote update in the block verse layout; reload the view with the new USJ instead."
@@ -33960,11 +34015,11 @@ const K_ = Ri(function({
let Ge = !1;
re.update(
() => {
- Zu(re, D), D === "remote" && _t(kp), Re || _t(or), G && _t(G);
+ nf(re, D), D === "remote" && _t(Tp), Re || _t(or), G && _t(G);
try {
- PN(w, fe, Ne, Ze);
- } catch (tt) {
- throw Ge = !0, Zu(re, void 0), De?.(), tt;
+ $N(w, fe, Ne, et);
+ } catch (nt) {
+ throw Ge = !0, nf(re, void 0), De?.(), nt;
}
},
{
@@ -33981,14 +34036,14 @@ const K_ = Ri(function({
// guard has actually happened, never before.
onUpdate: () => {
if (Ge) return;
- Zu(re, void 0), De?.(), Re || hf(re);
- const tt = re.getEditorState(), ft = to.deserializeEditorState(tt, fe);
- if (!ft) return;
- const yt = !Tn(g.current, ft);
- yt && (g.current = ft);
+ nf(re, void 0), De?.(), Re || yf(re);
+ const nt = re.getEditorState(), dt = to.deserializeEditorState(nt, fe);
+ if (!dt) return;
+ const bt = !Tn(g.current, dt);
+ bt && (g.current = dt);
const Rt = tn();
- if (Rt && (yt || !Tn(se, ft))) {
- const tr = $m(w, tt, "apply");
+ if (Rt && (bt || !Tn(se, dt))) {
+ const tr = Dm(w, nt, "apply");
ce.current = Rt, s?.(Rt, w, D, tr);
}
}
@@ -34010,26 +34065,26 @@ const K_ = Ri(function({
return xe();
},
undo() {
- d.current?.dispatchCommand(rk, void 0);
+ d.current?.dispatchCommand(ck, void 0);
},
redo() {
- d.current?.dispatchCommand(ik, void 0);
+ d.current?.dispatchCommand(lk, void 0);
},
// Both leave the clipboard untouched when nothing is selected, rather than writing a
// placeholder over it — `ClipboardPlugin`'s guard claims the command (shared-react's
// `registerEmptyCopyGuard`). Going through `copySelection`/`cutSelection` rather than
// dispatching here keeps that one seam named.
cut() {
- le("cut"), d.current && qh(d.current);
+ le("cut"), d.current && Kh(d.current);
},
copy() {
- d.current && Lh(d.current);
+ d.current && Dh(d.current);
},
paste() {
- le("paste"), d.current && Dh(d.current);
+ le("paste"), d.current && Bh(d.current);
},
pastePlainText() {
- le("paste as plain text"), d.current && Kh(d.current);
+ le("paste as plain text"), d.current && Uh(d.current);
},
getUsj() {
return tn();
@@ -34040,38 +34095,38 @@ const K_ = Ri(function({
const D = !xe(), G = D ? so(w, or) : void 0;
w.update(
() => {
- D && _t(or), w.dispatchCommand(WS, void 0);
+ D && _t(or), w.dispatchCommand(XS, void 0);
},
{ discrete: !0 }
- ), G?.(), D && hf(w);
+ ), G?.(), D && yf(w);
},
setMarkerSettleSuspended(w) {
- d.current?.dispatchCommand(HS, w);
+ d.current?.dispatchCommand(QS, w);
},
setTransientInput(w) {
if (!w) {
- C.current = void 0;
+ T.current = void 0;
return;
}
const D = d.current?.getEditorState().read(() => {
const G = M();
return E(G) && G.isCollapsed() ? G.focus.key : void 0;
});
- C.current = { input: w, nodeKey: D ?? x.current?.key };
+ T.current = { input: w, nodeKey: D ?? x.current?.key };
},
setUsj(w, D) {
const G = Tn(g.current, w) || Tn(tn(), w);
if (D?.force || !G) {
- g.current = w, y.current = !1, F.current = void 0, C.current = void 0;
+ g.current = w, y.current = !1, U.current = void 0, T.current = void 0;
const re = Tn(se, w);
Y(w), re && Se((Re) => Re + 1);
}
},
applyUpdate(w, D = "remote") {
- Ko(w, D);
+ Bo(w, D);
},
replaceEmbedUpdate(w, D) {
- const G = d.current?.read(() => e1(w, D));
+ const G = d.current?.read(() => s1(w, D));
G ? this.applyUpdate(G) : l?.warn(
`replaceEmbedUpdate: no embed found for key "${w}" — update dropped (stale key after a setUsj reload?)`
);
@@ -34081,59 +34136,59 @@ const K_ = Ri(function({
if (!w) return;
w.read(() => {
});
- const D = Bt();
- return !D || Qo(D) ? w.read(() => Qa(fe)) : li(w, "getSelection");
+ const D = Ft();
+ return !D || Zo(D) ? w.read(() => Qa(fe)) : ui(w, "getSelection");
},
getSelectedParaMarker() {
const w = d.current;
if (w?.isEditable())
- return w.getEditorState().read(() => Tr(M())?.getMarker());
+ return w.getEditorState().read(() => pr(M())?.getMarker());
},
setSelection(w) {
const D = er(w);
if (!D) {
- Ze?.warn(
+ et?.warn(
"setSelection refused: the position could not be resolved against the document currently being edited"
);
return;
}
d.current?.update(() => {
- const G = IU(x.current, D, fe) ?? wa(D, fe);
- G !== void 0 && (Mt(G), (!Pt().isEditable() || Lb(G.anchor) && Lb(G.focus)) && d.current?.dispatchCommand(Nn, void 0));
+ const G = zB(x.current, D, fe) ?? wa(D, fe);
+ G !== void 0 && (Mt(G), (!Pt().isEditable() || Ub(G.anchor) && Ub(G.focus)) && d.current?.dispatchCommand(On, void 0));
});
},
setAnnotation(w, D, G, re, Re) {
- let De, Ge, tt, ft;
- typeof re == "function" || re === void 0 ? (De = re, Ge = Re) : (De = re.onClick, Ge = re.onRemove, tt = re.onMouseEnter, ft = re.onMouseLeave);
- const yt = er(w);
- if (!yt) {
- Ze?.warn(
+ let De, Ge, nt, dt;
+ typeof re == "function" || re === void 0 ? (De = re, Ge = Re) : (De = re.onClick, Ge = re.onRemove, nt = re.onMouseEnter, dt = re.onMouseLeave);
+ const bt = er(w);
+ if (!bt) {
+ et?.warn(
`setAnnotation refused for ${D} "${G}": the range could not be resolved against the document currently being edited`
);
return;
}
p.current?.setAnnotation(
- yt,
- Ju(D),
+ bt,
+ Qu(D),
G,
De,
Ge,
- tt,
- ft
+ nt,
+ dt
);
},
removeAnnotation(w, D) {
- p.current?.removeAnnotation(Ju(w), D);
+ p.current?.removeAnnotation(Qu(w), D);
},
getAnnotationRanges(w, D) {
- return p.current?.getAnnotationRanges(Ju(w), D) ?? [];
+ return p.current?.getAnnotationRanges(Qu(w), D) ?? [];
},
formatPara(w) {
le("format a paragraph"), d.current?.update(
() => {
- const D = M(), G = Tr(D);
+ const D = M(), G = pr(D);
if (G) {
- Pg(G, w, fe);
+ $g(G, w, fe);
return;
}
if (!E(D)) {
@@ -34144,33 +34199,33 @@ const K_ = Ri(function({
}
const re = D.isBackward() ? D.focus : D.anchor, Re = We(re.getNode(), qe);
if (Re) {
- const De = D.isBackward() ? D.anchor : D.focus, tt = !D.isCollapsed() && !Re.is(De.getNode()) && !Re.isParentOf(De.getNode()) ? { key: De.key, offset: De.offset, type: De.type } : void 0, ft = dr();
- if (ft.anchor.set(re.key, re.offset, re.type), ft.focus.set(re.key, re.offset, re.type), Mt(ft), !Qd(w, fe)) {
+ const De = D.isBackward() ? D.anchor : D.focus, nt = !D.isCollapsed() && !Re.is(De.getNode()) && !Re.isParentOf(De.getNode()) ? { key: De.key, offset: De.offset, type: De.type } : void 0, dt = dr();
+ if (dt.anchor.set(re.key, re.offset, re.type), dt.focus.set(re.key, re.offset, re.type), Mt(dt), !ep(w, fe)) {
l?.warn(
`formatPara refused: could not split the \\id line at the caret to retag with "${w}"`
);
return;
}
- if (!tt) return;
- const yt = ee(tt.key);
- if (!yt?.isAttached()) return;
- const Rt = yt.getTopLevelElement();
+ if (!nt) return;
+ const bt = ee(nt.key);
+ if (!bt?.isAttached()) return;
+ const Rt = bt.getTopLevelElement();
if (!Rt) return;
const tr = Re.getNextSibling();
if (!ke(tr)) return;
let nr = tr.getNextSibling();
for (; nr; ) {
- const rr = nr.is(Rt), ui = nr.getNextSibling();
+ const rr = nr.is(Rt), fi = nr.getNextSibling();
if (ke(nr)) {
- const Bi = dr();
- Bi.anchor.set(nr.getKey(), 0, "element"), Bi.focus.set(nr.getKey(), nr.getChildrenSize(), "element"), Mt(Bi), Kb(Bi, w, fe);
+ const zi = dr();
+ zi.anchor.set(nr.getKey(), 0, "element"), zi.focus.set(nr.getKey(), nr.getChildrenSize(), "element"), Mt(zi), jb(zi, w, fe);
}
if (rr) break;
- nr = ui;
+ nr = fi;
}
return;
}
- Kb(D, w, fe);
+ jb(D, w, fe);
},
{ discrete: !0 }
);
@@ -34181,39 +34236,39 @@ const K_ = Ri(function({
);
},
removeCharacterMarker(w) {
- if (V) throw new Error("Cannot remove character marker in readonly mode");
- et(w);
+ if (W) throw new Error("Cannot remove character marker in readonly mode");
+ tt(w);
let D = !1;
return d.current?.update(
() => {
const G = M();
- E(G) && (D = yS(G, w, fe));
+ E(G) && (D = CS(G, w, fe));
},
{ discrete: !0 }
), D;
},
replaceCharacterMarker(w, D) {
- if (V) throw new Error("Cannot replace character marker in readonly mode");
- et(w), et(D);
+ if (W) throw new Error("Cannot replace character marker in readonly mode");
+ tt(w), tt(D);
let G = !1;
return d.current?.update(
() => {
const re = M();
- E(re) && (G = Tq(re, w, D));
+ E(re) && (G = Aq(re, w, D));
},
{ discrete: !0 }
), G;
},
extendCharacterMarker(w, D) {
- if (V) throw new Error("Cannot extend character marker in readonly mode");
- et(w), D?.forEach(
- (re) => et(re)
+ if (W) throw new Error("Cannot extend character marker in readonly mode");
+ tt(w), D?.forEach(
+ (re) => tt(re)
);
let G = !1;
return d.current?.update(
() => {
const re = M();
- E(re) && (G = Cq(
+ E(re) && (G = wq(
re,
w,
D,
@@ -34224,25 +34279,25 @@ const K_ = Ri(function({
), G;
},
insertMarker(w) {
- if (V) throw new Error("Cannot insert marker in readonly mode");
+ if (W) throw new Error("Cannot insert marker in readonly mode");
if (!n) throw new Error("Cannot insert marker without a scripture reference (scrRef)");
if (!d.current) return;
- if (!Hd(w, Ne.extraValidMarkers))
+ if (!Jd(w, Ne.extraValidMarkers))
throw new Error(`Unsupported marker '${w}'`);
d.current.update(js, { discrete: !0 });
- const D = Gd(
+ const D = Yd(
w,
b,
fe,
Ne,
- Ze,
+ et,
void 0,
$e
);
return D.action({ editor: d.current, reference: n }), D.getInsertedNoteKey?.();
},
insertFirstChapter(w) {
- if (V) throw new Error("Cannot insert a chapter in readonly mode");
+ if (W) throw new Error("Cannot insert a chapter in readonly mode");
if (!n)
throw new Error("Cannot insert a chapter without a scripture reference (scrRef)");
if (!d.current) return !1;
@@ -34250,7 +34305,7 @@ const K_ = Ri(function({
let G = !1;
return d.current.update(
() => {
- G = Sg({ chapterNum: D, verseCount: w, viewOptions: fe, styleInfo: $e });
+ G = Ag({ chapterNum: D, verseCount: w, viewOptions: fe, styleInfo: $e });
},
{ discrete: !0 }
), G;
@@ -34258,7 +34313,7 @@ const K_ = Ri(function({
getMarkerMenuContext() {
if (q) return;
const w = d.current;
- return w?.getEditorState().read(() => oD(w, n?.chapterNum));
+ return w?.getEditorState().read(() => hD(w, n?.chapterNum));
},
applyMarkerMenuSelection(w, D) {
if (q) throw new Error("Cannot apply marker menu selection in readonly mode");
@@ -34267,11 +34322,11 @@ const K_ = Ri(function({
"Cannot apply marker menu selection without a scripture reference (scrRef)"
);
if (!d.current) return;
- if (w.kind !== "closeTag" && !Hd(w.marker, Ne.extraValidMarkers))
+ if (w.kind !== "closeTag" && !Jd(w.marker, Ne.extraValidMarkers))
throw new Error(`Unsupported marker '${w.marker}'`);
let G;
return d.current.update(() => {
- js(), G = mD(w, D, n, {
+ js(), G = SD(w, D, n, {
expandedNoteKeyRef: b,
viewOptions: fe,
nodeOptions: Ne,
@@ -34283,7 +34338,7 @@ const K_ = Ri(function({
splitParagraphWithMarker(w) {
if (q) throw new Error("Cannot split paragraph in readonly mode");
d.current && d.current.update(() => {
- js(), Qd(w, fe);
+ js(), ep(w, fe);
});
},
commitTypedMarker(w, D) {
@@ -34291,7 +34346,7 @@ const K_ = Ri(function({
if (!d.current) return !1;
let G = !1;
return d.current.update(() => {
- js(), G = hD(w, D), G || l?.warn(
+ js(), G = CD(w, D), G || l?.warn(
"commitTypedMarker refused: requires a collapsed range selection (wrap a selection via applyMarkerMenuSelection instead)"
);
}), G;
@@ -34301,7 +34356,7 @@ const K_ = Ri(function({
if (!d.current) return !1;
let D = !1;
return d.current.update(() => {
- js(), D = OS(w), D || l?.warn(
+ js(), D = qS(w), D || l?.warn(
"commitTypedCloser refused: requires a range selection to commit the closer at"
);
}), D;
@@ -34310,7 +34365,7 @@ const K_ = Ri(function({
le("insert a note");
const re = G && er(G);
if (G && !re) {
- Ze?.warn(
+ et?.warn(
`insertNote refused for \\${w}: the position could not be resolved against the document currently being edited`
);
return;
@@ -34318,14 +34373,14 @@ const K_ = Ri(function({
d.current?.update(
() => {
js();
- const Re = RT(
+ const Re = DT(
w,
D,
re,
n,
fe,
Ne,
- Ze
+ et
);
Sc(Re, b);
},
@@ -34335,20 +34390,20 @@ const K_ = Ri(function({
selectNote(w) {
const D = d.current;
if (!D) return;
- const G = Bt();
- if (typeof w == "string" || !G || Qo(G)) {
+ const G = Ft();
+ if (typeof w == "string" || !G || Zo(G)) {
D.update(() => {
const De = Nr(w);
De && (Nc(De, fe), Sc(De, b));
});
return;
}
- const re = LU(tn())[w], Re = re ? er({ start: { jsonPath: re } }) : void 0;
+ const re = jB(tn())[w], Re = re ? er({ start: { jsonPath: re } }) : void 0;
Re && D.update(() => {
const [De, Ge] = Vn(Re.start, fe);
if (!De || Ge === void 0) return;
- const tt = K(De) ? De : We(De, K);
- K(tt) ? (Nc(tt, fe), Sc(tt, b)) : T(De) && De.select(Ge, Ge);
+ const nt = K(De) ? De : We(De, K);
+ K(nt) ? (Nc(nt, fe), Sc(nt, b)) : C(De) && De.select(Ge, Ge);
});
},
selectAfterNote(w) {
@@ -34359,18 +34414,18 @@ const K_ = Ri(function({
() => {
G && _t(or);
const Re = Nr(w);
- Re && qT(Re);
+ Re && UT(Re);
},
{ discrete: !0 }
), re?.(), G) {
- hf(D);
+ yf(D);
const Re = so(
D,
or
);
D.update(
() => {
- _t(or), D.dispatchCommand(Nn, void 0);
+ _t(or), D.dispatchCommand(On, void 0);
},
{ discrete: !0 }
), Re();
@@ -34381,7 +34436,7 @@ const K_ = Ri(function({
const re = Nr(w);
if (!re) return;
const Re = G?.glyph;
- (G?.field === "category" ? Aw(re, D, Re) || Vm(re, 0) : Vm(re, D, Re)) || Nc(re, fe), Sc(re, b);
+ (G?.field === "category" ? Rw(re, D, Re) || Ym(re, 0) : Ym(re, D, Re)) || Nc(re, fe), Sc(re, b);
});
},
getNoteOps(w) {
@@ -34389,35 +34444,35 @@ const K_ = Ri(function({
return D ? Xs(D, () => {
const G = Nr(w);
if (G)
- return tu(G);
+ return ru(G);
}) : void 0;
},
getOpsAfterNote(w) {
const D = d.current;
return D ? Xs(D, () => {
const G = Nr(w);
- return G ? Db(G) : void 0;
+ return G ? zb(G) : void 0;
}) : void 0;
},
takeOpsAfterNote(w) {
const D = d.current, G = D ? Xs(D, () => {
const Ge = Nr(w);
if (!Ge) return;
- const tt = hh(Ge, "apply");
- return { ops: Db(Ge), notePosition: tt };
+ const nt = mh(Ge, "apply");
+ return { ops: zb(Ge), notePosition: nt };
}) : void 0;
if (!G) return;
const { ops: re, notePosition: Re } = G;
if (re.length === 0 || Re === void 0) return re;
const De = re.reduce(
- (Ge, tt) => Ge + (typeof tt.insert == "string" ? tt.insert.length : 1),
+ (Ge, nt) => Ge + (typeof nt.insert == "string" ? nt.insert.length : 1),
0
);
- return Ko([{ retain: Re + 1 }, { delete: De }], "remote", ma), re;
+ return Bo([{ retain: Re + 1 }, { delete: De }], "remote", ma), re;
},
getNoteIndex(w) {
const D = d.current;
- return D ? Xs(D, () => mh(w)) : void 0;
+ return D ? Xs(D, () => bh(w)) : void 0;
},
getNoteKey(w) {
const D = d.current;
@@ -34430,109 +34485,109 @@ const K_ = Ri(function({
return h;
}
};
- te.current = Uo, Rl(f, () => Uo), J(() => {
+ te.current = Uo, Ll(f, () => Uo), J(() => {
const w = d.current;
if (w)
return w.registerUpdateListener(({ editorState: D }) => {
- const G = D.read(qb);
+ const G = D.read(Fb);
G && (x.current = G);
});
}, []);
const Fi = ae({ onUsjChange: s, viewOptions: fe, isBlockVerse: L, readSettledUsj: tn });
Fi.current = { onUsjChange: s, viewOptions: fe, isBlockVerse: L, readSettledUsj: tn };
- const Fs = Ke((w, D) => {
+ const Us = Ke((w, D) => {
const { editorState: G, dirtyElements: re, dirtyLeaves: Re, tags: De } = w;
if (re.size === 0 && Re.size === 0) return;
if (De.has(Va)) {
- const rr = Fi.current, ui = !rr.isBlockVerse && to.deserializeEditorState(G, rr.viewOptions);
- ui && (g.current = ui), ce.current = g.current;
+ const rr = Fi.current, fi = !rr.isBlockVerse && to.deserializeEditorState(G, rr.viewOptions);
+ fi && (g.current = fi), ce.current = g.current;
return;
}
- if (Yl(D)) return;
- if (Ib.some((rr) => De.has(rr))) {
+ if (Ql(D)) return;
+ if (Bb.some((rr) => De.has(rr))) {
y.current = !0;
return;
}
const Ge = Fi.current;
if (Ge.isBlockVerse) return;
- Gk(D, G, De);
- const tt = G.read(qb);
- tt && (x.current = tt);
- const ft = EN(w, {
- ignoreTags: Ib
- }), yt = ft ? [] : new Qi(G.read(() => MN(D, w))).chop().ops;
- if (!ft) {
+ Zk(D, G, De);
+ const nt = G.read(Fb);
+ nt && (x.current = nt);
+ const dt = NN(w, {
+ ignoreTags: Bb
+ }), bt = dt ? [] : new Zi(G.read(() => ON(D, w))).chop().ops;
+ if (!dt) {
const rr = to.deserializeEditorState(G, Ge.viewOptions);
rr && (g.current = rr);
}
if (!Ge.onUsjChange) return;
const Rt = Ge.readSettledUsj();
- if (!Rt || yt.length === 0 && Tn(ce.current, Rt)) return;
- if (ce.current = Rt, yt.length === 0) {
+ if (!Rt || bt.length === 0 && Tn(ce.current, Rt)) return;
+ if (ce.current = Rt, bt.length === 0) {
Ge.onUsjChange(Rt, void 0, "local", void 0);
return;
}
- const tr = $m(yt, G), nr = tr && !w.prevEditorState.read(() => ee(tr)) ? tr : void 0;
- Ge.onUsjChange(Rt, yt, "local", nr);
- }, []), Vr = Ke(
+ const tr = Dm(bt, G), nr = tr && !w.prevEditorState.read(() => ee(tr)) ? tr : void 0;
+ Ge.onUsjChange(Rt, bt, "local", nr);
+ }, []), Wr = Ke(
(w) => {
- I(w.contextMarker), o?.(w);
+ R(w.contextMarker), o?.(w);
},
[o]
);
return (
// A Lexical editor's node types are fixed when it is created, so switching layouts has to
// recreate it. The key never changes for the inline layouts, which leave `verseLayout` unset.
- /* @__PURE__ */ ut(sk, { initialConfig: st, children: [
- /* @__PURE__ */ O(OO, { isEditable: !V }),
- /* @__PURE__ */ O(S$, {}),
- /* @__PURE__ */ ut("div", { className: "editor-container", children: [
- N ? /* @__PURE__ */ O(qC, { onStateChange: Vr }) : /* @__PURE__ */ O(
+ /* @__PURE__ */ ft(uk, { initialConfig: ct, children: [
+ /* @__PURE__ */ O(qO, { isEditable: !W }),
+ /* @__PURE__ */ O(N$, {}),
+ /* @__PURE__ */ ft("div", { className: "editor-container", children: [
+ N ? /* @__PURE__ */ O(zC, { onStateChange: Wr }) : /* @__PURE__ */ O(
"div",
{
- className: "editor-toolbar-container" + (V ? "-readonly" : "-editable"),
+ className: "editor-toolbar-container" + (W ? "-readonly" : "-editable"),
children: /* @__PURE__ */ O(
- wU,
+ DB,
{
ref: h,
editorRef: te,
- isReadonly: V,
- onStateChange: Vr
+ isReadonly: W,
+ onStateChange: Wr
}
)
}
),
- /* @__PURE__ */ ut("div", { className: "editor-inner", children: [
- /* @__PURE__ */ O(ak, { editorRef: d }),
+ /* @__PURE__ */ ft("div", { className: "editor-inner", children: [
+ /* @__PURE__ */ O(dk, { editorRef: d }),
/* @__PURE__ */ O(
- K0,
+ j0,
{
contentEditable: /* @__PURE__ */ O(
- ok,
+ fk,
{
- className: `editor-input usfm ${I1(fe).join(" ")}${fe.hasGutterParaMarkers ? " psc-gutter-markers" : ""}${fe.hasActiveTextFocusBox ? " psc-active-focus" : ""}`,
+ className: `editor-input usfm ${B1(fe).join(" ")}${fe.hasGutterParaMarkers ? " psc-gutter-markers" : ""}${fe.hasActiveTextFocusBox ? " psc-active-focus" : ""}`,
spellCheck: X
}
),
- placeholder: /* @__PURE__ */ O(RU, {}),
- ErrorBoundary: ck
+ placeholder: /* @__PURE__ */ O(FB, {}),
+ ErrorBoundary: pk
}
),
- N && /* @__PURE__ */ O(NO, {}),
- /* @__PURE__ */ O(lk, {}),
- n && r && /* @__PURE__ */ O(lU, { scrRef: n, onScrRefChange: r }),
+ N && /* @__PURE__ */ O(LO, {}),
+ /* @__PURE__ */ O(hk, {}),
+ n && r && /* @__PURE__ */ O(yB, { scrRef: n, onScrRefChange: r }),
n && !N && /* @__PURE__ */ O(
- QR,
+ sI,
{
- trigger: me,
+ trigger: he,
scrRef: n,
- contextMarker: Fe,
- getMarkerAction: (w) => Gd(
+ contextMarker: Ue,
+ getMarkerAction: (w) => Yd(
w,
b,
fe,
Ne,
- Ze,
+ et,
void 0,
$e
),
@@ -34540,147 +34595,147 @@ const K_ = Ri(function({
}
),
/* @__PURE__ */ O(
- _$,
+ O$,
{
scripture: se,
scriptureRef: g,
nodeOptions: Ne,
- editorAdaptor: pr,
+ editorAdaptor: hr,
viewOptions: fe,
- logger: Ze
+ logger: et
},
be
),
- /* @__PURE__ */ O(K$, { onChange: ac, viewOptions: fe }),
- /* @__PURE__ */ O(DU, { listener: Fs }),
- /* @__PURE__ */ O(Mq, { viewOptions: fe }),
- /* @__PURE__ */ O(_N, { ref: p, logger: Ze, viewOptions: fe }),
- /* @__PURE__ */ O(JN, { viewOptions: fe }),
- /* @__PURE__ */ O(lO, {}),
- /* @__PURE__ */ O(kO, {}),
- fe?.markerMode !== "editable" && /* @__PURE__ */ O(xO, { logger: Ze }),
- /* @__PURE__ */ O(_O, { options: Ui }),
- /* @__PURE__ */ O(Rq, { limit: At, viewOptions: fe }),
- /* @__PURE__ */ O(wO, {}),
- /* @__PURE__ */ O(qO, {}),
+ /* @__PURE__ */ O(W$, { onChange: ac, viewOptions: fe }),
+ /* @__PURE__ */ O(WB, { listener: Us }),
+ /* @__PURE__ */ O(Iq, { viewOptions: fe }),
+ /* @__PURE__ */ O(wN, { ref: p, logger: et, viewOptions: fe }),
+ /* @__PURE__ */ O(eO, { viewOptions: fe }),
+ /* @__PURE__ */ O(hO, {}),
+ /* @__PURE__ */ O(SO, {}),
+ fe?.markerMode !== "editable" && /* @__PURE__ */ O(_O, { logger: et }),
+ /* @__PURE__ */ O(wO, { options: Ui }),
+ /* @__PURE__ */ O(Fq, { limit: At, viewOptions: fe }),
+ /* @__PURE__ */ O(IO, {}),
/* @__PURE__ */ O(FO, {}),
- /* @__PURE__ */ O(yD, {}),
+ /* @__PURE__ */ O(WO, {}),
+ /* @__PURE__ */ O(_D, {}),
/* @__PURE__ */ O(
- f$,
+ b$,
{
isEnabled: fe?.markerMode !== "editable",
structureProtectionMode: j,
copyLimit: At,
onHiddenContentDelete: ne,
- logger: Ze
+ logger: et
}
),
/* @__PURE__ */ O(
- XD,
+ sK,
{
viewOptions: fe,
- getMarker: Qe,
- logger: Ze,
- markerSettleDelayMs: mt,
+ getMarker: Ze,
+ logger: et,
+ markerSettleDelayMs: yt,
structureProtectionMode: j,
copyLimit: At
}
),
- fe?.markerMode === "visible" && /* @__PURE__ */ O($q, { viewOptions: fe, copyLimit: At }),
+ fe?.markerMode === "visible" && /* @__PURE__ */ O(Uq, { viewOptions: fe, copyLimit: At }),
/* @__PURE__ */ O(
- rK,
+ fK,
{
styleInfo: $e,
viewOptions: fe,
- logger: Ze
+ logger: et
}
),
- /* @__PURE__ */ O(E$, { ref: m }),
+ /* @__PURE__ */ O($$, { ref: m }),
/* @__PURE__ */ O(
- M$,
+ R$,
{
expandedNoteKeyRef: b,
nodeOptions: Ne,
viewOptions: fe,
- logger: Ze
+ logger: et
}
),
- /* @__PURE__ */ O(i$, {}),
- /* @__PURE__ */ O(VN, {}),
- /* @__PURE__ */ O(hw, {}),
- /* @__PURE__ */ O(dK, { viewOptions: fe, logger: Ze }),
+ /* @__PURE__ */ O(l$, {}),
+ /* @__PURE__ */ O(YN, {}),
+ /* @__PURE__ */ O(kw, {}),
+ /* @__PURE__ */ O(xK, { viewOptions: fe, logger: et }),
/* @__PURE__ */ O(
- z$,
+ Y$,
{
onParaMarkerMenuRequest: a,
structureProtectionMode: j
}
),
- /* @__PURE__ */ O(Y$, {}),
- /* @__PURE__ */ O($R, { structureProtectionMode: j }),
- /* @__PURE__ */ O(IR, { textDirection: oe }),
- /* @__PURE__ */ O(qR, {}),
- /* @__PURE__ */ O(YR, {}),
+ /* @__PURE__ */ O(rR, {}),
+ /* @__PURE__ */ O(BR, { structureProtectionMode: j }),
+ /* @__PURE__ */ O(FR, { textDirection: oe }),
+ /* @__PURE__ */ O(jR, {}),
+ /* @__PURE__ */ O(rI, {}),
u
] }),
- ue && /* @__PURE__ */ O(CU, {})
+ ue && /* @__PURE__ */ O(wB, {})
] })
] }, fe.verseLayout ?? "inline")
);
-}), JF = Ri(function(t, n) {
+}), rF = Ii(function(t, n) {
const { children: r, ...i } = t;
- return /* @__PURE__ */ O(K_, { ref: n, ...i });
+ return /* @__PURE__ */ O(j_, { ref: n, ...i });
});
-function Ub(e, t) {
- const n = T(e) ? JE(e, Vt, t) ?? [] : [], r = zP(e, Vt, t);
+function Vb(e, t) {
+ const n = C(e) ? eM(e, Vt, t) ?? [] : [], r = GP(e, Vt, t);
return [.../* @__PURE__ */ new Set([...n, ...r])];
}
-function KU(e, t, n) {
- _k(Vt, e, t);
+function HB(e, t, n) {
+ wk(Vt, e, t);
for (const r of n) {
const i = ee(r);
- i && Fx(i, Vt, e);
+ i && Vx(i, Vt, e);
}
}
-function UU(e, t) {
+function GB(e, t) {
const n = Array.from(t, (s) => ee(s)).filter(
(s) => s !== null
);
n.sort((s, o) => s.isBefore(o) ? -1 : 1);
const r = n[0];
if (!r) return;
- if (T(r)) {
- const s = Gr(r).find(
+ if (C(r)) {
+ const s = Jr(r).find(
(a) => a.type === Vt && a.id === e
- ), o = Math.max(Qp(r)[0], s?.start ?? 0);
+ ), o = Math.max(eh(r)[0], s?.start ?? 0);
r.select(o, o);
return;
}
const i = r.getParent();
i && i.select(r.getIndexWithinParent(), r.getIndexWithinParent());
}
-function U_() {
+function V_() {
return Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);
}
-function Ol(e, t, n, r, i) {
+function Rl(e, t, n, r, i) {
return {
author: t,
content: e,
deleted: i === void 0 ? !1 : i,
- id: n === void 0 ? U_() : n,
+ id: n === void 0 ? V_() : n,
timeStamp: r === void 0 ? performance.timeOrigin + performance.now() : r,
type: "comment"
};
}
-function F_(e, t, n) {
+function W_(e, t, n) {
return {
comments: t,
- id: n === void 0 ? U_() : n,
+ id: n === void 0 ? V_() : n,
quote: e,
type: "thread"
};
}
-function Fb(e) {
+function Wb(e) {
return {
comments: Array.from(e.comments),
id: e.id,
@@ -34688,7 +34743,7 @@ function Fb(e) {
type: "thread"
};
}
-function FU(e) {
+function JB(e) {
return {
author: e.author,
content: "[Deleted Comment]",
@@ -34698,12 +34753,12 @@ function FU(e) {
type: "comment"
};
}
-function If(e) {
+function Df(e) {
const t = e._changeListeners;
for (const n of t)
n();
}
-class BU {
+class YB {
_editor;
_comments;
_changeListeners;
@@ -34740,7 +34795,7 @@ class BU {
* @param comments - The new Comments array.
*/
setComments(t) {
- this._comments = t, If(this);
+ this._comments = t, Df(this);
}
/**
* Adds a comment or thread to the store.
@@ -34755,7 +34810,7 @@ class BU {
for (let o = 0; o < i.length; o++) {
const a = i[o];
if (a.type === "thread" && a.id === n.id) {
- const c = Fb(a);
+ const c = Wb(a);
i.splice(o, 1, c);
const l = r !== void 0 ? r : c.comments.length;
if (this.isCollaborative() && s !== null) {
@@ -34776,7 +34831,7 @@ class BU {
s.insert(o, [a]);
}), i.splice(o, 0, t);
}
- this._comments = i, If(this);
+ this._comments = i, Df(this);
}
/**
* Deletes a comment or thread from the store.
@@ -34792,7 +34847,7 @@ class BU {
for (let o = 0; o < r.length; o++) {
const a = r[o];
if (a.type === "thread" && a.id === n.id) {
- const c = Fb(a);
+ const c = Wb(a);
r.splice(o, 1, c);
const l = c.comments;
if (s = l.indexOf(t), this.isCollaborative() && i !== null) {
@@ -34809,9 +34864,9 @@ class BU {
s = r.indexOf(t), this.isCollaborative() && i !== null && this._withRemoteTransaction(() => {
i.delete(s);
}), r.splice(s, 1);
- return this._comments = r, If(this), t.type === "comment" ? {
+ return this._comments = r, Df(this), t.type === "comment" ? {
index: s,
- markedComment: FU(t)
+ markedComment: JB(t)
} : null;
}
/**
@@ -34841,16 +34896,16 @@ class BU {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_getCollabComments() {
const t = this._collabProvider;
- return t !== null ? t.doc.get("comments", Hg) : null;
+ return t !== null ? t.doc.get("comments", Qg) : null;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_createCollabSharedMap(t) {
- const n = new Gg(), r = t.type, i = t.id;
+ const n = new Zg(), r = t.type, i = t.id;
if (n.set("type", r), n.set("id", i), r === "comment")
n.set("author", t.author), n.set("content", t.content), n.set("deleted", t.deleted), n.set("timeStamp", t.timeStamp);
else {
n.set("quote", t.quote);
- const s = new Hg();
+ const s = new Qg();
t.comments.forEach((o, a) => {
const c = this._createCollabSharedMap(o);
s.insert(a, [c]);
@@ -34874,33 +34929,33 @@ class BU {
} catch {
}
}, s = this._editor.registerCommand(
- tE,
+ oE,
(a) => (r !== void 0 && i !== void 0 && (a ? (this.logger?.info("Comments connected!"), r()) : (this.logger?.info("Comments disconnected!"), i())), !1),
Nt
), o = (a, c) => {
if (c.origin !== this) {
for (const l of a)
- if (l instanceof nE) {
+ if (l instanceof aE) {
const u = l.target, f = l.delta;
let d = 0;
for (const p of f) {
- const m = p.insert, h = p.retain, g = p.delete, y = u.parent, b = u === n ? void 0 : y instanceof Gg && this._comments.find((C) => C.id === y.get("id"));
+ const m = p.insert, h = p.retain, g = p.delete, y = u.parent, b = u === n ? void 0 : y instanceof Zg && this._comments.find((T) => T.id === y.get("id"));
if (Array.isArray(m)) {
- const C = d;
+ const T = d;
m.slice().reverse().forEach((x) => {
- const _ = x.get("id"), R = x.get("type") === "thread" ? F_(
+ const _ = x.get("id"), I = x.get("type") === "thread" ? W_(
x.get("quote"),
x.get("comments").toArray().map(
- (W) => Ol(
- W.get("content"),
- W.get("author"),
- W.get("id"),
- W.get("timeStamp"),
- W.get("deleted")
+ (V) => Rl(
+ V.get("content"),
+ V.get("author"),
+ V.get("id"),
+ V.get("timeStamp"),
+ V.get("deleted")
)
),
_
- ) : Ol(
+ ) : Rl(
x.get("content"),
x.get("author"),
_,
@@ -34908,13 +34963,13 @@ class BU {
x.get("deleted")
);
this._withLocalTransaction(() => {
- this.addComment(R, b, C);
+ this.addComment(I, b, T);
});
});
} else if (typeof h == "number")
d += h;
else if (typeof g == "number")
- for (let C = 0; C < g; C++) {
+ for (let T = 0; T < g; T++) {
const x = b === void 0 || b === !1 ? this._comments[d] : b.comments[d];
this._withLocalTransaction(() => {
this.deleteCommentOrThread(x, b);
@@ -34929,13 +34984,13 @@ class BU {
});
}
}
-function zU(e) {
+function XB(e) {
const [t, n] = ze(e.getComments());
return J(() => e.registerOnChange(() => {
n(e.getComments());
}), [e]), t;
}
-function jU({
+function QB({
onClose: e,
children: t,
title: n,
@@ -34955,7 +35010,7 @@ function jU({
return c !== null && (s = c.parentElement, s !== null && s.addEventListener("click", a)), window.addEventListener("keydown", o), () => {
window.removeEventListener("keydown", o), s !== null && s?.removeEventListener("click", a);
};
- }, [r, e]), /* @__PURE__ */ O("div", { className: "Modal__overlay", role: "dialog", children: /* @__PURE__ */ ut("div", { className: "Modal__modal", tabIndex: -1, ref: i, children: [
+ }, [r, e]), /* @__PURE__ */ O("div", { className: "Modal__overlay", role: "dialog", children: /* @__PURE__ */ ft("div", { className: "Modal__modal", tabIndex: -1, ref: i, children: [
/* @__PURE__ */ O("h2", { className: "Modal__title", children: n }),
/* @__PURE__ */ O(
"button",
@@ -34970,25 +35025,25 @@ function jU({
/* @__PURE__ */ O("div", { className: "Modal__content", children: t })
] }) });
}
-function VU({
+function ZB({
onClose: e,
children: t,
title: n,
closeOnClickOutside: r = !1
}) {
- return ns(
- /* @__PURE__ */ O(jU, { onClose: e, title: n, closeOnClickOutside: r, children: t }),
+ return rs(
+ /* @__PURE__ */ O(QB, { onClose: e, title: n, closeOnClickOutside: r, children: t }),
document.body
);
}
-function B_() {
+function H_() {
const [e, t] = ze(null), n = Ke(() => {
t(null);
- }, []), r = bt(() => {
+ }, []), r = kt(() => {
if (e === null)
return null;
const { title: s, content: o, closeOnClickOutside: a } = e;
- return /* @__PURE__ */ O(VU, { onClose: n, title: s, closeOnClickOutside: a, children: o });
+ return /* @__PURE__ */ O(ZB, { onClose: n, title: s, closeOnClickOutside: a, children: o });
}, [e, n]), i = Ke(
(s, o, a = !1) => {
t({
@@ -35001,14 +35056,14 @@ function B_() {
);
return [r, i];
}
-const WU = {
- ...vS,
+const eU = {
+ ...PS,
paragraph: "CommentEditorTheme__paragraph"
};
-function HU(...e) {
+function tU(...e) {
return e.filter(Boolean).join(" ");
}
-function $i({
+function Ri({
"data-test-id": e,
children: t,
className: n,
@@ -35021,7 +35076,7 @@ function $i({
"button",
{
disabled: i,
- className: HU(
+ className: tU(
"Button__root",
i && "Button__disabled",
s && "Button__small",
@@ -35035,19 +35090,19 @@ function $i({
}
);
}
-function GU({
+function nU({
className: e
}) {
- return /* @__PURE__ */ O(ok, { className: e || "ContentEditable__root" });
+ return /* @__PURE__ */ O(fk, { className: e || "ContentEditable__root" });
}
-function JU({
+function rU({
children: e,
className: t
}) {
return /* @__PURE__ */ O("div", { className: t || "Placeholder__root", children: e });
}
-const Bb = Ba("INSERT_INLINE_COMMAND");
-function YU({
+const Hb = Fa("INSERT_INLINE_COMMAND");
+function iU({
anchorKey: e,
editor: t,
showComments: n,
@@ -35062,19 +35117,19 @@ function YU({
}, [e, t]);
return J(() => (window.addEventListener("resize", s), () => {
window.removeEventListener("resize", s);
- }), [t, s]), Po(() => {
+ }), [t, s]), Ao(() => {
s();
}, [e, t, n, s]), /* @__PURE__ */ O("div", { className: "CommentPlugin_AddCommentBox", ref: i, children: /* @__PURE__ */ O("button", { className: "CommentPlugin_AddCommentBox_button", onClick: r, children: /* @__PURE__ */ O("i", { className: "icon add-comment" }) }) });
}
-function XU({ onEscape: e }) {
+function sU({ onEscape: e }) {
const [t] = Pe();
return J(() => t.registerCommand(
- dp,
+ hp,
(n) => e(n),
$r
), [t, e]), null;
}
-function z_({
+function G_({
className: e,
autoFocus: t,
onEscape: n,
@@ -35082,84 +35137,84 @@ function z_({
editorRef: i,
placeholder: s = "Type a comment..."
}) {
- return /* @__PURE__ */ O(sk, { initialConfig: {
+ return /* @__PURE__ */ O(uk, { initialConfig: {
namespace: "Commenting",
nodes: [],
onError: (a) => {
throw a;
},
- theme: WU
- }, children: /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentInputBox_EditorContainer", children: [
+ theme: eU
+ }, children: /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentInputBox_EditorContainer", children: [
/* @__PURE__ */ O(
- Q0,
+ rE,
{
- contentEditable: /* @__PURE__ */ O(GU, { className: e }),
- placeholder: /* @__PURE__ */ O(JU, { children: s }),
- ErrorBoundary: ck
+ contentEditable: /* @__PURE__ */ O(nU, { className: e }),
+ placeholder: /* @__PURE__ */ O(rU, { children: s }),
+ ErrorBoundary: pk
}
),
- /* @__PURE__ */ O(X0, { onChange: r }),
- /* @__PURE__ */ O(lk, {}),
- t !== !1 && /* @__PURE__ */ O(G0, {}),
- /* @__PURE__ */ O(XU, { onEscape: n }),
- /* @__PURE__ */ O(J0, {}),
- i !== void 0 && /* @__PURE__ */ O(ak, { editorRef: i })
+ /* @__PURE__ */ O(nE, { onChange: r }),
+ /* @__PURE__ */ O(hk, {}),
+ t !== !1 && /* @__PURE__ */ O(Z0, {}),
+ /* @__PURE__ */ O(sU, { onEscape: n }),
+ /* @__PURE__ */ O(eE, {}),
+ i !== void 0 && /* @__PURE__ */ O(dk, { editorRef: i })
] }) });
}
-function j_(e, t) {
+function J_(e, t) {
return Ke(
(n, r) => {
n.read(() => {
- e(Z0()), t(!eE(r.isComposing(), !0));
+ e(iE()), t(!sE(r.isComposing(), !0));
});
},
[t, e]
);
}
-function QU({
+function oU({
editor: e,
cancelAddComment: t,
submitAddComment: n
}) {
- const [r, i] = ze(""), [s, o] = ze(!1), a = ae(null), c = bt(
+ const [r, i] = ze(""), [s, o] = ze(!1), a = ae(null), c = kt(
() => ({
container: document.createElement("div"),
elements: []
}),
[]
- ), l = ae(null), u = W_(), f = Ke(() => {
+ ), l = ae(null), u = X_(), f = Ke(() => {
e.getEditorState().read(() => {
const h = M();
if (E(h)) {
l.current = h.clone();
- const g = h.anchor, y = h.focus, b = F0(
+ const g = h.anchor, y = h.focus, b = W0(
e,
g.getNode(),
g.offset,
y.getNode(),
y.offset
- ), C = a.current;
- if (b !== null && C !== null) {
- const { left: x, bottom: _, width: F } = b.getBoundingClientRect(), R = B0(e, b);
- let W = R.length === 1 ? x + F / 2 - 125 : x - 125;
- W < 10 && (W = 10), C.style.left = `${W}px`, C.style.top = `${_ + 20 + (window.pageYOffset || document.documentElement.scrollTop)}px`;
- const ce = R.length, { container: se } = c, Y = c.elements, be = Y.length;
+ ), T = a.current;
+ if (b !== null && T !== null) {
+ const { left: x, bottom: _, width: U } = b.getBoundingClientRect(), I = H0(e, b);
+ let V = I.length === 1 ? x + U / 2 - 125 : x - 125;
+ V < 10 && (V = 10), T.style.left = `${V}px`, T.style.top = `${_ + 20 + (window.pageYOffset || document.documentElement.scrollTop)}px`;
+ const ce = I.length, { container: se } = c, Y = c.elements, be = Y.length;
for (let Se = 0; Se < ce; Se++) {
- const Fe = R[Se];
- let I = Y[Se];
- I === void 0 && (I = document.createElement("span"), Y[Se] = I, se.appendChild(I));
- const j = `position:absolute;top:${Fe.top + (window.pageYOffset || document.documentElement.scrollTop)}px;left:${Fe.left}px;height:${Fe.height}px;width:${Fe.width}px;background-color:rgba(255, 212, 0, 0.3);pointer-events:none;z-index:5;`;
- I.style.cssText = j;
+ const Ue = I[Se];
+ let R = Y[Se];
+ R === void 0 && (R = document.createElement("span"), Y[Se] = R, se.appendChild(R));
+ const j = `position:absolute;top:${Ue.top + (window.pageYOffset || document.documentElement.scrollTop)}px;left:${Ue.left}px;height:${Ue.height}px;width:${Ue.width}px;background-color:rgba(255, 212, 0, 0.3);pointer-events:none;z-index:5;`;
+ R.style.cssText = j;
}
for (let Se = be - 1; Se >= ce; Se--) {
- const Fe = Y[Se];
- se.removeChild(Fe), Y.pop();
+ const Ue = Y[Se];
+ se.removeChild(Ue), Y.pop();
}
}
}
});
}, [e, c]);
- Po(() => {
+ Ao(() => {
f();
const h = c.container, g = document.body;
return g !== null ? (g.appendChild(h), () => {
@@ -35176,26 +35231,26 @@ function QU({
return g ? g.getTextContent() : "";
});
h.length > 100 && (h = h.slice(0, 99) + "…"), n(
- F_(h, [Ol(r, u)]),
+ W_(h, [Rl(r, u)]),
!0,
void 0,
l.current
), l.current = null;
}
- }, m = j_(i, o);
- return /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentInputBox", ref: a, children: [
+ }, m = J_(i, o);
+ return /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentInputBox", ref: a, children: [
/* @__PURE__ */ O(
- z_,
+ G_,
{
className: "CommentPlugin_CommentInputBox_Editor",
onEscape: d,
onChange: m
}
),
- /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentInputBox_Buttons", children: [
- /* @__PURE__ */ O($i, { onClick: t, className: "CommentPlugin_CommentInputBox_Button", children: "Cancel" }),
+ /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentInputBox_Buttons", children: [
+ /* @__PURE__ */ O(Ri, { onClick: t, className: "CommentPlugin_CommentInputBox_Button", children: "Cancel" }),
/* @__PURE__ */ O(
- $i,
+ Ri,
{
onClick: p,
disabled: !s,
@@ -35206,15 +35261,15 @@ function QU({
] })
] });
}
-function ZU({
+function aU({
submitAddComment: e,
thread: t,
placeholder: n
}) {
- const [r, i] = ze(""), [s, o] = ze(!1), a = ae(null), c = W_(), l = j_(i, o);
- return /* @__PURE__ */ ut(os, { children: [
+ const [r, i] = ze(""), [s, o] = ze(!1), a = ae(null), c = X_(), l = J_(i, o);
+ return /* @__PURE__ */ ft(as, { children: [
/* @__PURE__ */ O(
- z_,
+ G_,
{
className: "CommentPlugin_CommentsPanel_Editor",
autoFocus: !1,
@@ -35225,14 +35280,14 @@ function ZU({
}
),
/* @__PURE__ */ O(
- $i,
+ Ri,
{
className: "CommentPlugin_CommentsPanel_SendButton",
onClick: () => {
if (s) {
- e(Ol(r, c), !1, t);
+ e(Rl(r, c), !1, t);
const f = a.current;
- f !== null && f.dispatchCommand(O0, void 0);
+ f !== null && f.dispatchCommand(q0, void 0);
}
},
disabled: !s,
@@ -35241,19 +35296,19 @@ function ZU({
)
] });
}
-function V_({
+function Y_({
commentOrThread: e,
deleteCommentOrThread: t,
onClose: n,
thread: r = void 0
}) {
- return /* @__PURE__ */ ut(os, { children: [
+ return /* @__PURE__ */ ft(as, { children: [
"Are you sure you want to delete this ",
e.type,
"?",
- /* @__PURE__ */ ut("div", { className: "Modal__content", children: [
+ /* @__PURE__ */ ft("div", { className: "Modal__content", children: [
/* @__PURE__ */ O(
- $i,
+ Ri,
{
onClick: () => {
t(e, r), n();
@@ -35263,7 +35318,7 @@ function V_({
),
" ",
/* @__PURE__ */ O(
- $i,
+ Ri,
{
onClick: () => {
n();
@@ -35274,7 +35329,7 @@ function V_({
] })
] });
}
-function zb({
+function Gb({
comment: e,
deleteComment: t,
thread: n,
@@ -35291,23 +35346,23 @@ function zb({
window.clearInterval(f);
};
}, []);
- const o = Math.round((e.timeStamp - i) / 1e3), a = Math.round(o / 60), [c, l] = B_();
- return /* @__PURE__ */ ut("li", { className: "CommentPlugin_CommentsPanel_List_Comment", children: [
- /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentsPanel_List_Details", children: [
+ const o = Math.round((e.timeStamp - i) / 1e3), a = Math.round(o / 60), [c, l] = H_();
+ return /* @__PURE__ */ ft("li", { className: "CommentPlugin_CommentsPanel_List_Comment", children: [
+ /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentsPanel_List_Details", children: [
/* @__PURE__ */ O("span", { className: "CommentPlugin_CommentsPanel_List_Comment_Author", children: e.author }),
- /* @__PURE__ */ ut("span", { className: "CommentPlugin_CommentsPanel_List_Comment_Time", children: [
+ /* @__PURE__ */ ft("span", { className: "CommentPlugin_CommentsPanel_List_Comment_Time", children: [
"· ",
o > -10 ? "Just now" : r.format(a, "minute")
] })
] }),
/* @__PURE__ */ O("p", { className: e.deleted ? "CommentPlugin_CommentsPanel_DeletedComment" : "", children: e.content }),
- !e.deleted && /* @__PURE__ */ ut(os, { children: [
+ !e.deleted && /* @__PURE__ */ ft(as, { children: [
/* @__PURE__ */ O(
- $i,
+ Ri,
{
onClick: () => {
l("Delete Comment", (u) => /* @__PURE__ */ O(
- V_,
+ Y_,
{
commentOrThread: e,
deleteCommentOrThread: t,
@@ -35324,7 +35379,7 @@ function zb({
] })
] });
}
-function eF({
+function cU({
activeIDs: e,
comments: t,
deleteCommentOrThread: n,
@@ -35333,7 +35388,7 @@ function eF({
submitAddComment: s,
markNodeMap: o
}) {
- const [a] = Pe(), [c, l] = ze(0), [u, f] = B_(), d = bt(
+ const [a] = Pe(), [c, l] = ze(0), [u, f] = H_(), d = kt(
() => new Intl.RelativeTimeFormat("en", {
localeMatcher: "best fit",
numeric: "auto",
@@ -35352,7 +35407,7 @@ function eF({
const m = p.id;
if (p.type === "thread") {
const h = e !== null && e.indexOf(m) !== -1;
- return /* @__PURE__ */ ut(
+ return /* @__PURE__ */ ft(
"li",
{
onClick: () => {
@@ -35362,7 +35417,7 @@ function eF({
a.update(
() => {
const x = Array.from(y)[0], _ = ee(x);
- ge(_) && _.selectStart();
+ me(_) && _.selectStart();
},
{
onUpdate() {
@@ -35372,10 +35427,10 @@ function eF({
);
return;
}
- const C = r.keysFor(Vt, m);
- C.size !== 0 && a.update(
+ const T = r.keysFor(Vt, m);
+ T.size !== 0 && a.update(
() => {
- UU(m, C);
+ GB(m, T);
},
{
onUpdate() {
@@ -35386,17 +35441,17 @@ function eF({
},
className: `CommentPlugin_CommentsPanel_List_Thread ${o.has(m) || r.keysFor(Vt, m).size > 0 ? "interactive" : ""} ${e.indexOf(m) === -1 ? "" : "active"}`,
children: [
- /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentsPanel_List_Thread_QuoteBox", children: [
- /* @__PURE__ */ ut("blockquote", { className: "CommentPlugin_CommentsPanel_List_Thread_Quote", children: [
+ /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentsPanel_List_Thread_QuoteBox", children: [
+ /* @__PURE__ */ ft("blockquote", { className: "CommentPlugin_CommentsPanel_List_Thread_Quote", children: [
"> ",
/* @__PURE__ */ O("span", { children: p.quote })
] }),
/* @__PURE__ */ O(
- $i,
+ Ri,
{
onClick: () => {
f("Delete Thread", (y) => /* @__PURE__ */ O(
- V_,
+ Y_,
{
commentOrThread: p,
deleteCommentOrThread: n,
@@ -35411,7 +35466,7 @@ function eF({
u
] }),
/* @__PURE__ */ O("ul", { className: "CommentPlugin_CommentsPanel_List_Thread_Comments", children: p.comments.map((y) => /* @__PURE__ */ O(
- zb,
+ Gb,
{
comment: y,
deleteComment: n,
@@ -35421,7 +35476,7 @@ function eF({
y.id
)) }),
/* @__PURE__ */ O("div", { className: "CommentPlugin_CommentsPanel_List_Thread_Editor", children: /* @__PURE__ */ O(
- ZU,
+ aU,
{
submitAddComment: s,
thread: p,
@@ -35434,7 +35489,7 @@ function eF({
);
}
return /* @__PURE__ */ O(
- zb,
+ Gb,
{
comment: p,
deleteComment: n,
@@ -35444,7 +35499,7 @@ function eF({
);
}) });
}
-function tF({
+function lU({
activeIDs: e,
deleteCommentOrThread: t,
comments: n,
@@ -35453,10 +35508,10 @@ function tF({
displayIndex: s
}) {
const o = ae(null), a = n.length === 0;
- return /* @__PURE__ */ ut("div", { className: "CommentPlugin_CommentsPanel", children: [
+ return /* @__PURE__ */ ft("div", { className: "CommentPlugin_CommentsPanel", children: [
/* @__PURE__ */ O("h2", { className: "CommentPlugin_CommentsPanel_Heading", children: "Comments" }),
a ? /* @__PURE__ */ O("div", { className: "CommentPlugin_CommentsPanel_Empty", children: "No Comments" }) : /* @__PURE__ */ O(
- eF,
+ cU,
{
activeIDs: e,
comments: n,
@@ -35469,11 +35524,11 @@ function tF({
)
] });
}
-function W_() {
- const e = uk(), { yjsDocMap: t, name: n } = e;
+function X_() {
+ const e = gk(), { yjsDocMap: t, name: n } = e;
return t.has("comments") ? n : "Scripture User";
}
-function nF({
+function uU({
providerFactory: e,
setCommentStore: t,
onChange: n,
@@ -35481,10 +35536,10 @@ function nF({
commentContainerRef: i,
logger: s
}) {
- const o = uk(), [a] = Pe(), c = bt(() => {
- const ce = new BU(a, s);
+ const o = gk(), [a] = Pe(), c = kt(() => {
+ const ce = new YB(a, s);
return n && ce.registerOnChange(n), t?.(ce), ce;
- }, [a, s, n, t]), l = zU(c), u = bt(() => /* @__PURE__ */ new Map(), []), f = YT(a), [d, p] = ze(), [m, h] = ze([]), [g, y] = ze(!1), [b, C] = ze(!1), { yjsDocMap: x } = o;
+ }, [a, s, n, t]), l = XB(c), u = kt(() => /* @__PURE__ */ new Map(), []), f = eC(a), [d, p] = ze(), [m, h] = ze([]), [g, y] = ze(!1), [b, T] = ze(!1), { yjsDocMap: x } = o;
J(() => {
if (e) {
const ce = e("comments", x);
@@ -35498,7 +35553,7 @@ function nF({
const ce = M();
ce !== null && (ce.dirty = !0);
}), y(!1);
- }, [a]), F = Ke(
+ }, [a]), U = Ke(
(ce, se) => {
if (ce.type === "comment") {
const Y = c.deleteCommentOrThread(ce, se);
@@ -35511,16 +35566,16 @@ function nF({
const Y = se !== void 0 ? se.id : ce.id, be = u.get(Y), Se = f.keysFor(Vt, Y);
(be !== void 0 && be.size > 0 || Se.size > 0) && setTimeout(() => {
a.update(() => {
- KU(Y, be ?? [], Se);
+ HB(Y, be ?? [], Se);
});
});
}
},
[c, f, a, u]
- ), R = Ke(
+ ), I = Ke(
(ce, se, Y, be) => {
c.addComment(ce, Y), se && (a.update(() => {
- E(be) && sh(be, Vt, ce.id);
+ E(be) && ah(be, Vt, ce.id);
}), y(!1));
},
[c, a]
@@ -35530,14 +35585,14 @@ function nF({
let se;
const Y = () => {
se = window.setTimeout(() => {
- C(!0);
+ T(!0);
}, 0);
};
for (const be of m) {
const Se = u.get(be) ?? [];
- for (const Fe of Se) {
- const I = a.getElementByKey(Fe);
- I !== null && (I.classList.add("selected"), ce.push(I), Y());
+ for (const Ue of Se) {
+ const R = a.getElementByKey(Ue);
+ R !== null && (R.classList.add("selected"), ce.push(R), Y());
}
f.keysFor(Vt, be).size > 0 && (f.setStateClass(Vt, be, "selected", !0), Y());
}
@@ -35552,15 +35607,15 @@ function nF({
if (!a.hasNodes([vt]))
throw new Error("CommentPlugin: TypedMarkNode not registered on editor!");
const ce = /* @__PURE__ */ new Map();
- return Ye(
- gp(
+ return Xe(
+ yp(
a,
vt,
- (se) => us(se.getTypedIDs()),
+ (se) => fs(se.getTypedIDs()),
(se, Y) => {
for (const [be, Se] of Object.entries(se.getTypedIDs()))
- Se.forEach((Fe) => {
- Y.addID(be, Fe);
+ Se.forEach((Ue) => {
+ Y.addID(be, Ue);
});
}
),
@@ -35570,11 +35625,11 @@ function nF({
a.getEditorState().read(() => {
for (const [Y, be] of se) {
const Se = ee(Y);
- let Fe = [];
- be === "destroyed" ? Fe = ce.get(Y) ?? [] : ge(Se) && (Fe = Se.getTypedIDs()[Vt] ?? []);
- for (const I of Fe) {
- let q = u.get(I);
- ce.set(Y, Fe), be === "destroyed" ? q !== void 0 && (q.delete(Y), q.size === 0 && u.delete(I)) : (q === void 0 && (q = /* @__PURE__ */ new Set(), u.set(I, q)), q.has(Y) || q.add(Y));
+ let Ue = [];
+ be === "destroyed" ? Ue = ce.get(Y) ?? [] : me(Se) && (Ue = Se.getTypedIDs()[Vt] ?? []);
+ for (const R of Ue) {
+ let q = u.get(R);
+ ce.set(Y, Ue), be === "destroyed" ? q !== void 0 && (q.delete(Y), q.size === 0 && u.delete(R)) : (q === void 0 && (q = /* @__PURE__ */ new Set(), u.set(R, q)), q.has(Y) || q.add(Y));
}
}
});
@@ -35584,84 +35639,84 @@ function nF({
a.registerUpdateListener(({ editorState: se, tags: Y }) => {
se.read(() => {
const be = M();
- let Se = !1, Fe = !1;
+ let Se = !1, Ue = !1;
if (E(be)) {
- const { anchor: I } = be, q = I.getNode();
- if (T(q)) {
- const j = Ub(q, I.offset);
- h(j), Se = !0, be.isCollapsed() || (p(q.getKey()), Fe = !0);
- } else if (I.type === "element" && A(q)) {
+ const { anchor: R } = be, q = R.getNode();
+ if (C(q)) {
+ const j = Vb(q, R.offset);
+ h(j), Se = !0, be.isCollapsed() || (p(q.getKey()), Ue = !0);
+ } else if (R.type === "element" && A(q)) {
const j = q.getChildren(), ne = /* @__PURE__ */ new Set();
for (const [N, X] of [
- [j[I.offset - 1], !0],
- [j[I.offset], !1]
+ [j[R.offset - 1], !0],
+ [j[R.offset], !1]
]) {
if (!N) continue;
- const oe = X && T(N) ? N.getTextContentSize() : 0;
- Ub(N, oe).forEach((me) => ne.add(me));
+ const oe = X && C(N) ? N.getTextContentSize() : 0;
+ Vb(N, oe).forEach((he) => ne.add(he));
}
ne.size > 0 && (h([...ne]), Se = !0);
}
}
- Se || h((I) => I.length === 0 ? I : []), Fe || p(null), !Y.has("collaboration") && E(be) && y(!1);
+ Se || h((R) => R.length === 0 ? R : []), Ue || p(null), !Y.has("collaboration") && E(be) && y(!1);
});
}),
a.registerCommand(
- Bb,
+ Hb,
() => {
const se = window.getSelection();
return se !== null && se.removeAllRanges(), y(!0), !0;
},
- xi
+ Ti
)
);
}, [a, u]);
- const W = () => {
- a.dispatchCommand(Bb, void 0);
+ const V = () => {
+ a.dispatchCommand(Hb, void 0);
};
- return /* @__PURE__ */ ut(os, { children: [
- g && ns(
+ return /* @__PURE__ */ ft(as, { children: [
+ g && rs(
/* @__PURE__ */ O(
- QU,
+ oU,
{
editor: a,
cancelAddComment: _,
- submitAddComment: R
+ submitAddComment: I
}
),
document.body
),
- d != null && !g && ns(
+ d != null && !g && rs(
/* @__PURE__ */ O(
- YU,
+ iU,
{
anchorKey: d,
editor: a,
showComments: b,
- onAddComment: W
+ onAddComment: V
}
),
document.body
),
- r !== null && ns(
+ r !== null && rs(
/* @__PURE__ */ O(
- $i,
+ Ri,
{
className: `CommentPlugin_ShowCommentsButton ${b ? "active" : ""}`,
- onClick: () => C(!b),
+ onClick: () => T(!b),
title: b ? "Hide Comments" : "Show Comments",
children: /* @__PURE__ */ O("i", { className: "comments" })
}
),
r?.current ?? document.body
),
- b && ns(
+ b && rs(
/* @__PURE__ */ O(
- tF,
+ lU,
{
comments: l,
- submitAddComment: R,
- deleteCommentOrThread: F,
+ submitAddComment: I,
+ deleteCommentOrThread: U,
activeIDs: m,
markNodeMap: u,
displayIndex: f
@@ -35671,13 +35726,13 @@ function nF({
)
] });
}
-function rF() {
+function fU() {
const e = ae(void 0), t = Ke((n) => {
e.current = n;
}, []);
return [e, t];
}
-function iF(e, t) {
+function dU(e, t) {
const n = t.current?.getComments() ?? [], r = n?.map((s) => s.id), i = e.map((s) => {
const o = r.findIndex((a) => a === s);
return o !== void 0 && o >= 0 ? n[o] : {
@@ -35700,21 +35755,21 @@ function iF(e, t) {
e.includes(s.id) || i.push(s);
}), i && t.current?.setComments(i);
}
-function sF(e, t) {
+function pU(e, t) {
J(() => {
e.options ??= {}, e.options.nodes ??= {}, e.options.nodes.addMissingComments = (n) => {
- iF(n, t);
+ dU(n, t);
};
}, [t, e]);
}
-const YF = Ri(function(t, n) {
- const r = ae(null), i = ae(!0), s = ae(null), [o, a] = ze(null), { children: c, onCommentChange: l, onUsjChange: u, showCommentsContainerRef: f, ...d } = t, { logger: p, options: { isReadonly: m, view: h } = {} } = t, g = (m ?? !1) || Aa(h), [y, b] = rF();
- sF(d, y), J(() => {
+const iF = Ii(function(t, n) {
+ const r = ae(null), i = ae(!0), s = ae(null), [o, a] = ze(null), { children: c, onCommentChange: l, onUsjChange: u, showCommentsContainerRef: f, ...d } = t, { logger: p, options: { isReadonly: m, view: h } = {} } = t, g = (m ?? !1) || Aa(h), [y, b] = fU();
+ pU(d, y), J(() => {
if (process.env.NODE_ENV !== "production") {
const _ = "@eten-tech-foundation/platform-editor: Marginal is deprecated and will be removed in a future release.";
p?.warn(_), p || console.warn(_);
}
- }, [p]), Rl(n, () => ({
+ }, [p]), Ll(n, () => ({
focus() {
r.current?.focus();
},
@@ -35751,14 +35806,14 @@ const YF = Ri(function(t, n) {
setTransientInput(_) {
r.current?.setTransientInput(_);
},
- setUsj(_, F) {
- r.current?.setUsj(_, F);
+ setUsj(_, U) {
+ r.current?.setUsj(_, U);
},
- applyUpdate(_, F) {
- r.current?.applyUpdate(_, F);
+ applyUpdate(_, U) {
+ r.current?.applyUpdate(_, U);
},
- replaceEmbedUpdate(_, F) {
- return r.current?.replaceEmbedUpdate(_, F);
+ replaceEmbedUpdate(_, U) {
+ return r.current?.replaceEmbedUpdate(_, U);
},
getSelection() {
return r.current?.getSelection();
@@ -35769,14 +35824,14 @@ const YF = Ri(function(t, n) {
setSelection(_) {
r.current?.setSelection(_);
},
- setAnnotation(_, F, R, W, ce) {
- typeof W == "function" || W === void 0 ? r.current?.setAnnotation(_, F, R, W, ce) : r.current?.setAnnotation(_, F, R, W);
+ setAnnotation(_, U, I, V, ce) {
+ typeof V == "function" || V === void 0 ? r.current?.setAnnotation(_, U, I, V, ce) : r.current?.setAnnotation(_, U, I, V);
},
- removeAnnotation(_, F) {
- r.current?.removeAnnotation(_, F);
+ removeAnnotation(_, U) {
+ r.current?.removeAnnotation(_, U);
},
- getAnnotationRanges(_, F) {
- return r.current?.getAnnotationRanges(_, F) ?? [];
+ getAnnotationRanges(_, U) {
+ return r.current?.getAnnotationRanges(_, U) ?? [];
},
formatPara(_) {
r.current?.formatPara(_);
@@ -35787,11 +35842,11 @@ const YF = Ri(function(t, n) {
removeCharacterMarker(_) {
return r.current?.removeCharacterMarker(_) ?? !1;
},
- replaceCharacterMarker(_, F) {
- return r.current?.replaceCharacterMarker(_, F) ?? !1;
+ replaceCharacterMarker(_, U) {
+ return r.current?.replaceCharacterMarker(_, U) ?? !1;
},
- extendCharacterMarker(_, F) {
- return r.current?.extendCharacterMarker(_, F) ?? !1;
+ extendCharacterMarker(_, U) {
+ return r.current?.extendCharacterMarker(_, U) ?? !1;
},
insertMarker(_) {
return r.current?.insertMarker(_);
@@ -35802,20 +35857,20 @@ const YF = Ri(function(t, n) {
getMarkerMenuContext() {
return r.current?.getMarkerMenuContext();
},
- applyMarkerMenuSelection(_, F) {
- return r.current?.applyMarkerMenuSelection(_, F);
+ applyMarkerMenuSelection(_, U) {
+ return r.current?.applyMarkerMenuSelection(_, U);
},
splitParagraphWithMarker(_) {
r.current?.splitParagraphWithMarker(_);
},
- commitTypedMarker(_, F) {
- return r.current?.commitTypedMarker(_, F) ?? !1;
+ commitTypedMarker(_, U) {
+ return r.current?.commitTypedMarker(_, U) ?? !1;
},
commitTypedCloser(_) {
return r.current?.commitTypedCloser(_) ?? !1;
},
- insertNote(_, F, R) {
- r.current?.insertNote(_, F, R);
+ insertNote(_, U, I) {
+ r.current?.insertNote(_, U, I);
},
selectNote(_) {
r.current?.selectNote(_);
@@ -35823,8 +35878,8 @@ const YF = Ri(function(t, n) {
selectAfterNote(_) {
r.current?.selectAfterNote(_);
},
- selectNoteTextOffset(_, F, R) {
- r.current?.selectNoteTextOffset(_, F, R);
+ selectNoteTextOffset(_, U, I) {
+ r.current?.selectNoteTextOffset(_, U, I);
},
getNoteOps(_) {
return r.current?.getNoteOps(_);
@@ -35851,11 +35906,11 @@ const YF = Ri(function(t, n) {
return o;
}
}));
- const C = Ke(
- (_, F, R, W) => {
+ const T = Ke(
+ (_, U, I, V) => {
if (!u) return;
const ce = y.current?.getComments();
- u(_, ce, F, R, W);
+ u(_, ce, U, I, V);
},
[y, u]
), x = Ke(() => {
@@ -35866,9 +35921,9 @@ const YF = Ri(function(t, n) {
const _ = y.current?.getComments();
l(_);
}, [y, i, l]);
- return J(() => (a(r.current?.toolbarEndRef ?? null), () => a(null)), []), /* @__PURE__ */ O(Y0, { children: /* @__PURE__ */ ut(K_, { ref: r, onUsjChange: C, ...d, children: [
+ return J(() => (a(r.current?.toolbarEndRef ?? null), () => a(null)), []), /* @__PURE__ */ O(tE, { children: /* @__PURE__ */ ft(j_, { ref: r, onUsjChange: T, ...d, children: [
/* @__PURE__ */ O(
- nF,
+ uU,
{
setCommentStore: b,
onChange: x,
@@ -35880,125 +35935,125 @@ const YF = Ri(function(t, n) {
/* @__PURE__ */ O("div", { ref: s, className: "comment-container" })
] }) });
});
-function ts(e) {
+function ns(e) {
return e.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
}
-function oF(e) {
+function hU(e) {
return e.replace(/["\\\n\r\f<>]/g, (t) => t === `
` ? "\\a " : t === "\r" ? "\\d " : t === "\f" ? "\\c " : t === "<" ? "\\3C " : t === ">" ? "\\3E " : `\\${t}`);
}
-function aF(e) {
+function gU(e) {
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/[^\w-]/g, (t) => `\\${t}`);
}
-const cF = /^[#\w().,%/\s-]+$/;
+const mU = /^[#\w().,%/\s-]+$/;
function ro(e) {
return e != null;
}
-const lF = {
+const yU = {
left: "left",
right: "right",
center: "center",
both: "justify"
-}, uF = {
+}, bU = {
left: "right",
right: "left"
-}, fF = "var(--usj-font-fallback, serif)";
-function H_(e, t) {
+}, kU = "var(--usj-font-fallback, serif)";
+function Q_(e, t) {
const n = [e];
- return t && t !== e && n.push(t), `font-family: ${n.map((i) => `"${oF(i)}"`).join(", ")}, ${fF}`;
+ return t && t !== e && n.push(t), `font-family: ${n.map((i) => `"${hU(i)}"`).join(", ")}, ${kU}`;
}
-const $l = ".editor-input.usfm", dF = /^[\w.#[\]="':()>+~*,\s-]+$/;
-function G_(e, t) {
- return dF.test(e) ? e : (console.warn(
- `[${t}] Ignoring unsafe containerSelector "${e}"; using "${$l}".`
- ), $l);
+const Il = ".editor-input.usfm", xU = /^[\w.#[\]="':()>+~*,\s-]+$/;
+function Z_(e, t) {
+ return xU.test(e) ? e : (console.warn(
+ `[${t}] Ignoring unsafe containerSelector "${e}"; using "${Il}".`
+ ), Il);
}
-function J_(e, t) {
- return e.fontName ? H_(e.fontName, t) : void 0;
+function e0(e, t) {
+ return e.fontName ? Q_(e.fontName, t) : void 0;
}
-function qu(e) {
+function Bu(e) {
return ro(e) && Number.isFinite(e) && e > 0;
}
-function pF(e, t, n, r, i) {
- const s = [], o = J_(t, i);
- if (o && s.push(o), t.bold && s.push("font-weight: bold"), t.italic && s.push("font-style: italic"), t.color && (cF.test(t.color) ? s.push(`color: ${t.color}`) : console.warn(
+function TU(e, t, n, r, i) {
+ const s = [], o = e0(t, i);
+ if (o && s.push(o), t.bold && s.push("font-weight: bold"), t.italic && s.push("font-style: italic"), t.color && (mU.test(t.color) ? s.push(`color: ${t.color}`) : console.warn(
`[generateUsjCss] Skipping unsafe color "${t.color}" for marker "${e}".`
- )), qu(t.fontSize) && s.push(`font-size: ${Math.floor(t.fontSize * 100 / 12)}%`), ro(t.firstLineIndent) && s.push(`text-indent: ${ts(t.firstLineIndent * 20 * n)}vw`), ro(t.leftMargin) && t.leftMargin >= 0 && s.push(`margin-${r ? "right" : "left"}: ${ts(t.leftMargin * 20 * n)}vw`), ro(t.rightMargin) && t.rightMargin >= 0 && s.push(
- `margin-${r ? "left" : "right"}: ${ts(t.rightMargin * 20 * n)}vw`
- ), ro(t.spaceBefore) && t.spaceBefore >= 0 && s.push(`margin-top: ${ts(t.spaceBefore * n)}pt`), ro(t.spaceAfter) && t.spaceAfter >= 0 && s.push(`margin-bottom: ${ts(t.spaceAfter * n)}pt`), t.lineSpacing === 1 ? s.push("line-height: 1.5") : t.lineSpacing === 2 && s.push("line-height: 2"), t.subscript ? s.push("vertical-align: text-bottom", "font-size: 66%") : t.superscript && s.push("vertical-align: text-top", "font-size: 66%"), t.underline && s.push("text-decoration: underline"), t.smallCaps && s.push("font-variant: small-caps"), t.justification) {
- const a = lF[r ? uF[t.justification] ?? t.justification : t.justification];
+ )), Bu(t.fontSize) && s.push(`font-size: ${Math.floor(t.fontSize * 100 / 12)}%`), ro(t.firstLineIndent) && s.push(`text-indent: ${ns(t.firstLineIndent * 20 * n)}vw`), ro(t.leftMargin) && t.leftMargin >= 0 && s.push(`margin-${r ? "right" : "left"}: ${ns(t.leftMargin * 20 * n)}vw`), ro(t.rightMargin) && t.rightMargin >= 0 && s.push(
+ `margin-${r ? "left" : "right"}: ${ns(t.rightMargin * 20 * n)}vw`
+ ), ro(t.spaceBefore) && t.spaceBefore >= 0 && s.push(`margin-top: ${ns(t.spaceBefore * n)}pt`), ro(t.spaceAfter) && t.spaceAfter >= 0 && s.push(`margin-bottom: ${ns(t.spaceAfter * n)}pt`), t.lineSpacing === 1 ? s.push("line-height: 1.5") : t.lineSpacing === 2 && s.push("line-height: 2"), t.subscript ? s.push("vertical-align: text-bottom", "font-size: 66%") : t.superscript && s.push("vertical-align: text-top", "font-size: 66%"), t.underline && s.push("text-decoration: underline"), t.smallCaps && s.push("font-variant: small-caps"), t.justification) {
+ const a = yU[r ? bU[t.justification] ?? t.justification : t.justification];
a && s.push(`text-align: ${a}`);
}
return t.textProperties?.includes("verse") && s.push("white-space: nowrap", "unicode-bidi: embed"), s;
}
-const jb = { c: 150, ca: 133, cp: 150 };
-function Vb(e, t) {
- return e && qu(e.fontSize) ? Math.floor(e.fontSize * 100 / 12) : t;
+const Jb = { c: 150, ca: 133, cp: 150 };
+function Yb(e, t) {
+ return e && Bu(e.fontSize) ? Math.floor(e.fontSize * 100 / 12) : t;
}
-function hF(e, t) {
+function CU(e, t) {
if (["c", "ca", "cp"].filter((i) => {
const s = e.markers[i];
- return s && qu(s.fontSize);
+ return s && Bu(s.fontSize);
}).length === 0) return [];
- const r = Vb(e.markers.c, jb.c);
+ const r = Yb(e.markers.c, Jb.c);
return ["ca", "cp"].map((i) => {
- const s = Vb(
+ const s = Yb(
e.markers[i],
- jb[i]
- ), o = ts(s * 100 / r);
+ Jb[i]
+ ), o = ns(s * 100 / r);
return `${t} .usfm_c .usfm_${i}.usfm_${i} { font-size: ${o}%; }`;
});
}
-function Y_(e, t, n) {
+function t0(e, t, n) {
const r = [];
- return e.defaultFont && r.push(H_(e.defaultFont)), qu(e.defaultFontSize) && r.push(`font-size: ${ts(e.defaultFontSize * t)}pt`), r.length > 0 ? `${n} { ${r.join("; ")}; }` : void 0;
+ return e.defaultFont && r.push(Q_(e.defaultFont)), Bu(e.defaultFontSize) && r.push(`font-size: ${ns(e.defaultFontSize * t)}pt`), r.length > 0 ? `${n} { ${r.join("; ")}; }` : void 0;
}
-function X_(e, t, n) {
- return `${e} .usfm_${aF(t)} { ${n.join("; ")}; }`;
+function n0(e, t, n) {
+ return `${e} .usfm_${gU(t)} { ${n.join("; ")}; }`;
}
-function XF(e, t = {}) {
- const { zoom: n = 1, rtl: r = !1, containerSelector: i = $l } = t, s = G_(i, "generateUsjCss"), o = [], a = Y_(e, n, s);
+function sF(e, t = {}) {
+ const { zoom: n = 1, rtl: r = !1, containerSelector: i = Il } = t, s = Z_(i, "generateUsjCss"), o = [], a = t0(e, n, s);
a && o.push(a);
for (const [c, l] of Object.entries(e.markers)) {
- const u = pF(c, l, n, r, e.defaultFont);
- u.length > 0 && o.push(X_(s, c, u));
+ const u = TU(c, l, n, r, e.defaultFont);
+ u.length > 0 && o.push(n0(s, c, u));
}
- return o.push(...hF(e, s)), o.join(`
+ return o.push(...CU(e, s)), o.join(`
`);
}
-function QF(e, t = {}) {
- const { zoom: n = 1, containerSelector: r = $l } = t, i = G_(r, "generateUsjFontCss"), s = [], o = Y_(e, n, i);
+function oF(e, t = {}) {
+ const { zoom: n = 1, containerSelector: r = Il } = t, i = Z_(r, "generateUsjFontCss"), s = [], o = t0(e, n, i);
o && s.push(o);
for (const [a, c] of Object.entries(e.markers)) {
- const l = J_(c, e.defaultFont);
- l && s.push(X_(i, a, [l]));
+ const l = e0(c, e.defaultFont);
+ l && s.push(n0(i, a, [l]));
}
return s.join(`
`);
}
export {
- dT as BLOCK_VERSE_VIEW_MODE,
+ mT as BLOCK_VERSE_VIEW_MODE,
S as CategoryType,
- JF as Editorial,
+ rF as Editorial,
ya as GENERATOR_NOTE_CALLER,
- fk as HIDDEN_NOTE_CALLER,
- YF as Marginal,
+ mk as HIDDEN_NOTE_CALLER,
+ iF as Marginal,
v as MarkerType,
- fT as PARAGRAPH_STRUCTURE_VIEW_MODE,
- kh as STANDARD_VIEW_MODE,
+ gT as PARAGRAPH_STRUCTURE_VIEW_MODE,
+ Th as STANDARD_VIEW_MODE,
ks as defaultStyleInfo,
- GF as directionToNames,
- zw as filterAndRankItems,
- XF as generateUsjCss,
- QF as generateUsjFontCss,
- WF as getDefaultViewMode,
- Co as getDefaultViewOptions,
- Jq as getEnterMenuItems,
- Hq as getMarkerMenuItems,
- HF as getViewMode,
- Ch as getViewOptions,
+ nF as directionToNames,
+ Gw as filterAndRankItems,
+ sF as generateUsjCss,
+ oF as generateUsjFontCss,
+ eF as getDefaultViewMode,
+ vo as getDefaultViewOptions,
+ rD as getEnterMenuItems,
+ tD as getMarkerMenuItems,
+ tF as getViewMode,
+ Sh as getViewOptions,
Aa as isBlockVerseLayout,
- gi as isInsertEmbedOpOfType,
- N1 as viewModeToViewNames
+ mi as isInsertEmbedOpOfType,
+ L1 as viewModeToViewNames
};
//# sourceMappingURL=index.js.map
diff --git a/packages/platform/dist/index.js.map b/packages/platform/dist/index.js.map
index 461df74f5..bb11e11ac 100644
--- a/packages/platform/dist/index.js.map
+++ b/packages/platform/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.js","sources":["../../../libs/shared/dist/converters/usfm/emptyUsfmNodes.js","../../../libs/shared/dist/converters/usfm/leadingAttributes.js","../../../libs/shared/dist/nodes/usj/node-constants.js","../../../libs/shared/dist/nodes/usj/MilestoneNode.js","../../../libs/shared/dist/nodes/usj/NoteNode.js","../../../libs/shared/dist/utils/usfm/usfmTypes.js","../../../libs/shared/dist/utils/usfm/usfmMarkers.js","../../../libs/shared/dist/utils/usfm/usfmMarkersOverwrites.js","../../../libs/shared/dist/utils/usfm/getMarker.js","../../../libs/shared/dist/converters/usfm/usfmFragmentToUsj.js","../../../libs/shared/dist/nodes/usj/markerText.utils.js","../../../libs/shared/dist/nodes/features/MarkerNode.js","../../../libs/shared/dist/nodes/features/TypedMarkNode.js","../../../libs/shared/dist/nodes/collab/delta.state.js","../../../libs/shared/dist/nodes/usj/AttributeRunNode.js","../../../libs/shared/dist/nodes/usj/CharNode.js","../../../libs/shared/dist/nodes/usj/VerseNode.js","../../../libs/shared/dist/nodes/usj/attributeDisplay.utils.js","../../../libs/shared/dist/nodes/usj/ChapterNode.js","../../../libs/shared/dist/nodes/features/UnknownNode.js","../../../libs/shared/dist/nodes/usj/ImmutableTableNode.js","../../../libs/shared/dist/nodes/usj/literalOnlyBlock.utils.js","../../../libs/shared/dist/nodes/usj/ImpliedParaNode.js","../../../libs/shared/dist/nodes/usj/logicalParent.utils.js","../../../libs/shared/dist/nodes/usj/nestedGlyphs.utils.js","../../../libs/shared/dist/nodes/usj/pendedDisplayOwners.utils.js","../../../libs/shared/dist/nodes/usj/markerSeparators.utils.js","../../../libs/shared/dist/nodes/features/ImmutableTypedTextNode.js","../../../libs/shared/dist/nodes/features/unknownUsfm.utils.js","../../../libs/shared/dist/displayRun/displayRunRegistry.js","../../../libs/shared/dist/displayRun/displayRunOwner.utils.js","../../../libs/shared/dist/nodes/features/displayAnnotations.state.js","../../../libs/shared/dist/nodes/usj/ImmutableChapterNode.js","../../../libs/shared/dist/nodes/usj/BookNode.js","../../../libs/shared/dist/nodes/usj/ParaNode.js","../../../libs/shared/dist/nodes/usj/spaceRuns.utils.js","../../../libs/shared/dist/plugins/CursorHandler/core/utils/constants.js","../../../libs/shared/dist/plugins/CursorHandler/core/utils/index.js","../../../libs/shared/dist/nodes/usj/transientCaretHost.utils.js","../../../libs/shared/dist/nodes/usj/node.utils.js","../../../libs/shared/dist/nodes/features/ImmutableUnmatchedNode.js","../../../libs/shared/dist/nodes/features/displayAnnotations.utils.js","../../../libs/shared/dist/nodes/features/typedMarkWrap.utils.js","../../../libs/shared/dist/nodes/usj/ImmutableTableRowNode.js","../../../libs/shared/dist/nodes/usj/ImmutableTableCellNode.js","../../../libs/shared/dist/nodes/usj/applyingUpdate.utils.js","../../../libs/shared/dist/nodes/usj/caretBoundaries.utils.js","../../../libs/shared/dist/nodes/usj/charGlyphs.utils.js","../../../libs/shared/dist/nodes/usj/charStack.utils.js","../../../libs/shared/dist/nodes/usj/displayRunSync.utils.js","../../../libs/shared/dist/nodes/usj/glyphPositions.utils.js","../../../libs/shared/dist/nodes/usj/VerseBlockNode.js","../../../libs/shared/dist/nodes/usj/index.js","../../../libs/shared/dist/utils/usfm/defaultStyleInfo.js","../../../libs/shared/dist/utils/usfm/styleInfo.js","../../../libs/shared/dist/utils/usj/contentToLexicalNode.js","../../../libs/shared-react/dist/nodes/usj/ImmutableVerseNode.js","../../../libs/shared-react/dist/nodes/usj/node-react.utils.js","../../../libs/shared-react/dist/plugins/usj/collab/rich-text-ot.model.js","../../../libs/shared-react/dist/plugins/usj/collab/delta-common.utils.js","../../../libs/shared-react/dist/plugins/usj/collab/editor-delta.adaptor.js","../../../libs/shared-react/dist/nodes/usj/note-index.utils.js","../../../libs/shared-react/dist/nodes/usj/ImmutableNoteCallerNode.js","../../../libs/shared-react/dist/views/view-mode.model.js","../../../libs/shared-react/dist/views/view-options.utils.js","../../../libs/shared-react/dist/plugins/usj/annotation/blockVerseLocations.utils.js","../../../libs/shared-react/dist/plugins/usj/annotation/selection.utils.js","../../../libs/shared-react/dist/plugins/usj/ParaMarkerPrefixCursorGuardPlugin.js","../../../libs/shared-react/dist/nodes/usj/note.utils.js","../../../libs/shared-react/dist/nodes/usj/index.js","../../../libs/shared-react/dist/plugins/FloatingBox/FloatingBox.js","../../../libs/shared-react/dist/plugins/FloatingBox/useFloatingPosition.js","../../../libs/shared-react/dist/plugins/FloatingBox/useCursorCoords.js","../../../libs/shared-react/dist/plugins/FloatingBox/FloatingBoxAtCursor.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/MenuContext.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/useMenuCore.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/Root.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/Option.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/Options.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/filterAndRankItems.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/index.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/useFilteredItems.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/useMenuActions.js","../../../libs/shared-react/dist/plugins/NodesMenu/Menu/useLexicalMenuNavigation.js","../../../libs/shared-react/dist/plugins/NodesMenu/LexicalMenuNavigation.js","../../../libs/shared-react/dist/plugins/NodesMenu/NodeSelectionMenu.js","../../../libs/shared-react/dist/plugins/NodesMenu/index.js","../../../libs/shared-react/dist/plugins/PerfNodesItems/useUsfmMarkersForMenu.js","../../../libs/shared-react/dist/plugins/usj/annotation/decoratorHolds.utils.js","../../../libs/shared-react/dist/plugins/usj/annotation/annotationHighlights.js","../../../libs/shared-react/dist/plugins/usj/annotation/annotationPaint.utils.js","../../../libs/shared-react/dist/plugins/usj/annotation/displayAnnotations.index.js","../../../libs/shared-react/dist/plugins/usj/annotation/AnnotationPlugin.js","../../../libs/shared-react/dist/plugins/usj/collab/DeltaOnChangePlugin.js","../../../libs/shared-react/dist/plugins/usj/collab/delta-apply-update.utils.js","../../../libs/shared-react/dist/plugins/usj/OpaqueBlockGuardPlugin.js","../../../libs/shared-react/dist/plugins/usj/ArrowNavigationPlugin.js","../../../libs/shared-react/dist/plugins/usj/CharNodePlugin.js","../../../libs/shared-react/dist/plugins/usj/clipboard.utils.js","../../../libs/shared-react/dist/plugins/usj/ClipboardPlugin.js","../../../libs/shared-react/dist/plugins/usj/CommandMenuPlugin.js","../../../libs/shared-react/dist/plugins/usj/ContextMenuPlugin.js","../../../libs/shared-react/dist/plugins/usj/DecoratorBoundarySelectionPlugin.js","../../../libs/shared-react/dist/plugins/usj/DisableHistoryShortcutsPlugin.js","../../../libs/shared-react/dist/plugins/usj/EditablePlugin.js","../../../libs/shared-react/dist/plugins/usj/transientCaretHost.js","../../../libs/shared-react/dist/plugins/usj/EmptyNoteCaretGuardPlugin.js","../../../libs/shared-react/dist/plugins/usj/editorUpdate.utils.js","../../../libs/shared-react/dist/plugins/usj/EmptyVerseCaretGuardPlugin.js","../../../libs/shared-react/dist/plugins/usj/hiddenContentDelete.utils.js","../../../libs/shared-react/dist/plugins/usj/NoteShellCaretGuardPlugin.js","../../../libs/shared-react/dist/plugins/usj/structureKeyboard.utils.js","../../../libs/shared-react/dist/plugins/usj/HiddenContentDeleteGuardPlugin.js","../../../libs/shared-react/dist/plugins/usj/KeyDownCaretSyncPlugin.js","../../../libs/shared-react/dist/plugins/usj/LoadStatePlugin.js","../../../libs/shared-react/dist/plugins/usj/NoteCallerHighlightPlugin.js","../../../libs/shared-react/dist/plugins/usj/NoteNodePlugin.js","../../../libs/shared-react/dist/plugins/usj/OnSelectionChangePlugin.js","../../../libs/shared-react/dist/plugins/usj/ParaMarkerSelectionPlugin.js","../../../libs/shared-react/dist/plugins/usj/ParaNodePlugin.js","../../../libs/shared-react/dist/plugins/usj/StateChangePlugin.js","../../../node_modules/.pnpm/dompurify@3.4.13/node_modules/dompurify/dist/purify.es.mjs","../../../libs/shared-react/dist/plugins/usj/StructureKeyboardPlugin.js","../../../libs/shared-react/dist/plugins/usj/text-direction.model.js","../../../libs/shared-react/dist/plugins/usj/TextDirectionPlugin.js","../../../libs/shared-react/dist/plugins/usj/TextSpacingPlugin.js","../../../libs/shared-react/dist/plugins/usj/TrailingNoteCaretGuardPlugin.js","../../../libs/shared-react/dist/plugins/UsfmNodesMenuPlugin.js","../../../libs/shared-react/dist/plugins/usj/UsjNodesMenuPlugin.js","../src/editor/markerEdit/whitespaceDisplay.utils.ts","../src/editor/adaptors/editor-usj.adaptor.ts","../src/editor/adaptors/verse-block.utils.ts","../src/editor/adaptors/usj-editor.adaptor.ts","../src/editor/markerEdit/charFormatting.utils.ts","../src/editor/markerEdit/markerName.pattern.ts","../src/editor/markerEdit/usfmByteAlignment.utils.ts","../src/editor/markerEdit/settledOnlyRuns.utils.ts","../src/editor/markerEdit/settleShared.utils.ts","../src/editor/markerEdit/tier2Rebuild.utils.ts","../src/editor/markerEdit/markerKind.utils.ts","../src/editor/markerEdit/markerEditDeletion.utils.ts","../src/editor/copyLimit/copyLimit.utils.ts","../src/editor/markerEdit/noteCallerSlot.utils.ts","../src/editor/markerEdit/paratext9Clipboard.utils.ts","../src/editor/markerEdit/whitespaceDisplay.plugin.utils.ts","../src/editor/markerEdit/chapterLine.utils.ts","../src/editor/markerEdit/markerValidation.utils.ts","../src/editor/markerEdit/firstChapter.utils.ts","../src/editor/adaptors/usj-marker-action.utils.ts","../src/editor/editor.theme.ts","../src/editor/ActiveTextPlugin.tsx","../src/editor/MarkersViewCopyPlugin.tsx","../src/editor/copyLimit/CopyLimitPlugin.tsx","../src/editor/markerMenu/markerItemSource.ts","../src/editor/markerEdit/applyParaMarker.utils.ts","../src/editor/markerEdit/markerEditNote.utils.ts","../src/editor/markerMenu/markerMenuContext.utils.ts","../src/editor/markerMenu/markerMenuApply.utils.ts","../src/editor/EscapeKeyPlugin.tsx","../src/editor/markerEdit/markerEditTier1.utils.ts","../src/editor/markerEdit/markerEditTier2Trigger.utils.ts","../src/editor/markerEdit/MarkerEditPlugin.tsx","../src/editor/markerEdit/MarkerValidationPlugin.tsx","../src/editor/markerEdit/virtualSettle.utils.ts","../src/editor/ParaMarkerPrefixGuardPlugin.tsx","../src/editor/positions/settledPositions.model.ts","../src/editor/positions/settledPositions.utils.ts","../src/editor/positions/settledScopes.utils.ts","../src/editor/ScriptureReferencePlugin.tsx","../src/editor/TreeViewPlugin.tsx","../src/editor/toolbar/DropDown.tsx","../src/editor/toolbar/BlockFormatDropDown.tsx","../src/editor/toolbar/ToolbarPlugin.tsx","../src/editor/Editor.tsx","../src/Editorial.tsx","../src/marginal/comments/commentAnnotations.utils.ts","../src/marginal/comments/commenting.ts","../src/marginal/comments/ui/Modal.tsx","../src/marginal/comments/use-modal.hook.tsx","../src/marginal/comments/comment-editor.theme.ts","../src/marginal/comments/join-classes.util.ts","../src/marginal/comments/ui/Button.tsx","../src/marginal/comments/ui/ContentEditable.tsx","../src/marginal/comments/ui/Placeholder.tsx","../src/marginal/comments/CommentPlugin.tsx","../src/marginal/comments/use-comment-store-ref.hook.tsx","../src/marginal/comments/use-missing-comments-props.hook.tsx","../src/marginal/Marginal.tsx","../src/editor/generateUsjCss.ts"],"sourcesContent":["import { $applyNodeReplacement, $createParagraphNode, $insertNodes, $isRootOrShadowRoot, $parseSerializedNode, } from \"lexical\";\nimport { $wrapNodeInElement } from \"@lexical/utils\";\nexport const $createNodeFromSerializedNode = (serializedNode) => {\n return $applyNodeReplacement($parseSerializedNode(serializedNode));\n};\nexport const $insertUsfmNode = (serializedNode) => {\n const newNode = $createNodeFromSerializedNode(serializedNode);\n $insertNodes([newNode]);\n if ($isRootOrShadowRoot(newNode.getParentOrThrow())) {\n $wrapNodeInElement(newNode, $createParagraphNode).selectEnd();\n }\n return newNode;\n};\n","/**\n * The markers map's `leadingAttributes` relation — which markers take a value written directly\n * after the marker, separated only by whitespace, and stored as an attribute rather than as\n * text: `\\v`/`\\c`'s number, the note-marker family's caller, `\\id`'s code.\n *\n * ONE rule follows from the declaration, with no per-marker exceptions: whitespace between the\n * marker and its leading-attribute value is structural and collapses to one, so `\\v 5` is\n * verse 5, `\\f +` has caller `+`, and `\\id MAT` has code `MAT`. The fragment tokenizer's own\n * word scan (`getNextWord`, usfmFragmentToUsj.ts) already implements the collapse; this module\n * is the declarative side, so Tier-1 glyph arms (platform's marker-edit engine) can consume the\n * same marker/attribute knowledge instead of hardcoding per-marker lists.\n *\n * The table is a VENDORED SLICE of paranext-core's\n * `lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.0.model.ts`\n * (`USFM_MARKERS_MAP.markers`, every `leadingAttributes` field verbatim; 3.1 declares the\n * identical set) — the source of truth lives there; re-copy when it changes (the same\n * convention as `attributeMarkersMapAgreement.test.ts`'s slice and the vendored\n * `testUsfmCorpus` fixtures). scripture-editors has no dependency on `platform-bible-utils`,\n * so a live import is not available.\n */\n/** Vendored from `USFM_MARKERS_MAP.markers`: every marker with a `leadingAttributes` field,\n * verbatim, ORDERED by the order the values must appear in after the marker. */\nconst LEADING_ATTRIBUTES = {\n c: [\"number\"],\n ef: [\"caller\"],\n efe: [\"caller\"],\n ex: [\"caller\"],\n f: [\"caller\"],\n fe: [\"caller\"],\n id: [\"code\"],\n v: [\"number\"],\n x: [\"caller\"],\n};\n/**\n * The ordered leading-attribute names the markers map declares for `marker`, or `undefined`\n * for a marker that declares none. Read-only map data — callable from any context.\n */\nexport function leadingAttributeNames(marker) {\n return LEADING_ATTRIBUTES[marker];\n}\n","/** This file avoids a circular dependency between `CharNode.ts` and `node.utils.ts`. */\nimport { createCommand } from \"lexical\";\n/** Non-breaking space (U+00A0). */\nexport const NBSP = \"\\u00A0\";\n/** Zero-width space (U+200B). */\nexport const ZWSP = \"\\u200B\";\nexport const EMPTY_CHAR_PLACEHOLDER_TEXT = NBSP;\nexport const NODE_ATTRIBUTE_PREFIX = `${NBSP}|`;\nexport const PARA_MARKER_DEFAULT = \"p\";\n/**\n * Note caller will be auto-generated.\n * @public\n */\nexport const GENERATOR_NOTE_CALLER = \"+\";\n/**\n * Hidden note caller will not be auto-generated, and will not be displayed in some views.\n * @public\n */\nexport const HIDDEN_NOTE_CALLER = \"-\";\n/**\n * Registered type name of the decorator node a collapsed note renders its caller with\n * (shared-react's `ImmutableNoteCallerNode`). Declared here because this layer must recognize the\n * node — the editor→USJ conversion emits nothing for it, so it holds no USJ content position —\n * while being unable to import a react-layer class. The class itself returns this constant from\n * `getType()`, so the name lives in exactly one place.\n */\nexport const IMMUTABLE_NOTE_CALLER_NODE_TYPE = \"immutable-note-caller\";\n/**\n * Registered type name of the decorator node a verse renders as outside editable marker mode\n * (shared-react's `ImmutableVerseNode`), declared here for the same reason as\n * {@link IMMUTABLE_NOTE_CALLER_NODE_TYPE}. The class returns this constant from `getType()`.\n */\nexport const IMMUTABLE_VERSE_NODE_TYPE = \"immutable-verse\";\nexport const CHAPTER_CLASS_NAME = \"chapter\";\nexport const VERSE_CLASS_NAME = \"verse\";\nexport const INVALID_CLASS_NAME = \"invalid\";\nexport const TEXT_SPACING_CLASS_NAME = \"text-spacing\";\nexport const FORMATTED_FONT_CLASS_NAME = \"formatted-font\";\nexport const MARKER_MODE_CLASS_NAME_PREFIX = \"marker-\";\nexport const EXTERNAL_USJ_MUTATION_TAG = \"external-usj-mutation\";\nexport const SELECTION_CHANGE_TAG = \"selection-change\";\n/**\n * Tags a commit that moves the caret AND changes a node on the editor's own initiative (a transient\n * caret host created or dropped), keeping it out of the host's USJ-change handling. Never put it on\n * an update that only moves the caret: Lexical clears an update's tags only when its commit changes\n * a node, so the tag would ride along on the user's next edit and hide that edit from the host. Use\n * {@link APP_PLACED_CARET_COMMAND} for a caret-only move.\n */\nexport const CURSOR_CHANGE_TAG = \"cursor-change\";\n/**\n * Dispatched inside an update that moves ONLY the caret on the editor's own initiative — following\n * a scripture-reference navigation, or steering the caret off something it cannot rest on — so a\n * listener can tell that move from the user's own. A command rather than {@link CURSOR_CHANGE_TAG}\n * because a tag on a caret-only update outlives it (see the tag's own comment).\n */\nexport const APP_PLACED_CARET_COMMAND = createCommand(\"APP_PLACED_CARET_COMMAND\");\nexport const ANNOTATION_CHANGE_TAG = \"annotation-change\";\n/**\n * The tag every update that wraps a selection in a `TypedMarkNode` carries. The wrap splits\n * text nodes, and the pieces it creates are the same content in new nodes — never typed text.\n */\nexport const TYPED_MARK_WRAP_TAG = \"typed-mark-wrap\";\nexport const DELTA_CHANGE_TAG = \"delta-change\";\n/**\n * Marks a commit that carries Lexical's `HISTORY_MERGE_TAG` yet still CHANGES the document — a\n * marker-edit settle, which must never become its own undo entry but is a real content change the\n * host has to see. The merge tag carries two meanings that normally coincide (\"do not push a\n * history entry\" and \"nothing to report\"); this tag is how such a commit says it means only the\n * first, so USJ-change consumers do not skip it.\n */\nexport const MARKER_SETTLE_TAG = \"marker-settle\";\n/** Tags that should not be present when handling a USJ change. */\nexport const blackListedChangeTags = [\n EXTERNAL_USJ_MUTATION_TAG,\n SELECTION_CHANGE_TAG,\n CURSOR_CHANGE_TAG,\n ANNOTATION_CHANGE_TAG,\n DELTA_CHANGE_TAG,\n];\n/**\n * The `detail` flag of a text node Lexical's normalization never merges with an adjacent text node\n * (`TextNode.toggleUnmergeable`) — what an expanded note's editable caller text carries, read off\n * its serialized form. Lexical keeps its detail flags internal, so the value is spelled here.\n */\nexport const UNMERGEABLE_TEXT_DETAIL = 2;\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/ms/index.html */\nimport { $applyNodeReplacement, DecoratorNode, } from \"lexical\";\nexport const STARTING_MS_COMMENT_MARKER = \"zmsc-s\";\nexport const ENDING_MS_COMMENT_MARKER = \"zmsc-e\";\n/** Milestone markers used to mark a comment annotation */\nconst milestoneCommentMarkers = [STARTING_MS_COMMENT_MARKER, ENDING_MS_COMMENT_MARKER];\n/** @see https://docs.usfm.bible/usfm/3.1/ms/index.html */\nconst VALID_MILESTONE_MARKERS = [\n \"ts-s\",\n \"ts-e\",\n \"t-s\",\n \"t-e\",\n \"ts\",\n \"qt1-s\",\n \"qt1-e\",\n \"qt2-s\",\n \"qt2-e\",\n \"qt3-s\",\n \"qt3-e\",\n \"qt4-s\",\n \"qt4-e\",\n \"qt5-s\",\n \"qt5-e\",\n \"qt-s\",\n \"qt-e\",\n // custom markers used for annotations\n STARTING_MS_COMMENT_MARKER,\n ENDING_MS_COMMENT_MARKER,\n];\nexport const MILESTONE_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const MS_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"sid\",\n \"eid\",\n \"content\",\n];\n/**\n * The milestone `MarkerObject` properties that are never attribute bytes. Everything ELSE a\n * milestone carries — `sid` and `eid` just as much as an unknown attribute like `who` — is written\n * into its `|…` run, so those are the names that have an order relative to one another. Derived\n * from {@link MS_MARKER_OBJECT_PROPS} so the two cannot drift.\n */\nexport const MS_NON_ATTRIBUTE_PROPS = MS_MARKER_OBJECT_PROPS.filter((property) => property !== \"sid\" && property !== \"eid\");\nexport class MilestoneNode extends DecoratorNode {\n __marker;\n __sid;\n __eid;\n __unknownAttributes;\n __attributeOrder;\n // `attributeOrder` rides AFTER `key`, never ahead of it: a node's key is the last argument\n // every Lexical node constructor took before this field existed, and slotting the new field\n // ahead of it would silently reinterpret an existing 5-argument call's NodeKey as the order\n // list (TypeScript consumers get a compile error; JavaScript consumers get corruption). Same\n // rule as MarkerNode's constructor.\n constructor(marker = \"\", sid, eid, unknownAttributes, key, attributeOrder) {\n super(key);\n this.__marker = marker;\n this.__sid = sid;\n this.__eid = eid;\n this.__unknownAttributes = unknownAttributes;\n this.__attributeOrder = attributeOrder;\n }\n static getType() {\n return \"ms\";\n }\n static clone(node) {\n const { __marker, __sid, __eid, __unknownAttributes, __attributeOrder, __key } = node;\n return new MilestoneNode(__marker, __sid, __eid, __unknownAttributes, __key, __attributeOrder);\n }\n static importJSON(serializedNode) {\n return $createMilestoneNode().updateFromJSON(serializedNode);\n }\n static isValidMarker(marker, extraValidMarkers) {\n return (marker !== undefined &&\n (VALID_MILESTONE_MARKERS.includes(marker) ||\n marker.startsWith(\"z\") ||\n (extraValidMarkers?.includes(marker) ?? false)));\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setSid(serializedNode.sid)\n .setEid(serializedNode.eid)\n .setUnknownAttributes(serializedNode.unknownAttributes)\n .setAttributeOrder(serializedNode.attributeOrder);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setSid(sid) {\n if (this.__sid === sid)\n return this;\n const self = this.getWritable();\n self.__sid = sid;\n return self;\n }\n getSid() {\n const self = this.getLatest();\n return self.__sid;\n }\n setEid(eid) {\n if (this.__eid === eid)\n return this;\n const self = this.getWritable();\n self.__eid = eid;\n return self;\n }\n getEid() {\n const self = this.getLatest();\n return self.__eid;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n setAttributeOrder(attributeOrder) {\n const self = this.getWritable();\n self.__attributeOrder = attributeOrder;\n return self;\n }\n /**\n * The authored attribute order this milestone was loaded with, or `undefined` when its order is\n * the canonical one. Feed it to `milestoneAttributes` (attributeDisplay.utils.ts) — every site\n * that turns a milestone back into bytes or back into USJ goes through there, so the order\n * cannot be honored in one place and dropped in another.\n */\n getAttributeOrder() {\n const self = this.getLatest();\n return self.__attributeOrder;\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(this.__type, `usfm_${this.__marker}`);\n return dom;\n }\n updateDOM() {\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n /**\n * A milestone paints nothing of its own: in editable marker mode its `\\qt-s …\\*` glyphs are real\n * sibling nodes, and in the other modes an `ImmutableTypedTextNode` carries them.\n *\n * Keep this payload EMPTY. A decorator payload with STABLE IDENTITY is unsound for any node that\n * can be re-parented, and a milestone can be — it rides a Tier-2 paragraph rebuild as a preserved\n * sentinel and is moved into the freshly created paragraph, whose children Lexical builds new\n * elements for. Lexical skips notifying its decorator listener whenever the payload is unchanged\n * (`reconcileDecorator` bails on `currentDecorators[key] === decorator`, and equal strings always\n * compare equal), so `@lexical/react`'s portal would stay bound to the OLD, detached element and\n * the live one would render nothing from then on. `\"\"` is what makes that harmless here: there is\n * nothing to lose. Giving this node visible payload would reintroduce exactly that defect — render\n * such bytes from `createDOM` instead, the way `ImmutableTypedTextNode` does.\n */\n decorate() {\n return \"\";\n }\n exportJSON() {\n return {\n type: this.getType(),\n marker: this.getMarker(),\n sid: this.getSid(),\n eid: this.getEid(),\n unknownAttributes: this.getUnknownAttributes(),\n attributeOrder: this.getAttributeOrder(),\n version: MILESTONE_VERSION,\n };\n }\n // Mutation\n isKeyboardSelectable() {\n return false;\n }\n}\nexport function isMilestoneCommentMarker(marker) {\n return milestoneCommentMarkers.includes(marker);\n}\nexport function $createMilestoneNode(marker, sid, eid, unknownAttributes, attributeOrder) {\n return $applyNodeReplacement(new MilestoneNode(marker, sid, eid, unknownAttributes, undefined, attributeOrder));\n}\nexport function $isMilestoneNode(node) {\n return node instanceof MilestoneNode;\n}\nexport function isSerializedMilestoneNode(node) {\n return node?.type === MilestoneNode.getType();\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/note/index.html */\nimport { GENERATOR_NOTE_CALLER, HIDDEN_NOTE_CALLER } from \"./node-constants.js\";\nimport { $applyNodeReplacement, ElementNode, isHTMLElement, } from \"lexical\";\nexport const DEFAULT_NOTE_MARKER = \"f\";\n/** @see https://docs.usfm.bible/usfm/3.1/note/index.html */\nconst VALID_NOTE_MARKERS = [\n // Footnote\n DEFAULT_NOTE_MARKER,\n \"fe\",\n \"ef\",\n \"efe\",\n // Cross Reference\n \"x\",\n \"ex\",\n];\n/**\n * Classifies a note marker into its caller family, matching PT9's Standard view rule\n * (Paratext repo `ParatextInternalShared/ScriptureViews/Standard.xslt` lines 446-449): a note is a\n * footnote iff its style starts with `f` or starts with `ef`; EVERY other note style — `x`, `ex`,\n * and any custom note marker — uses the cross-reference caller sequence.\n *\n * Note the deliberate consequence for custom markers: a custom note marker that does not start\n * with `f`/`ef` (e.g. `zfn`) classifies as a cross-reference — auto-callers from the\n * cross-reference sequence, hidden-caller default — exactly as PT9 renders it, even if the marker\n * is semantically a footnote.\n *\n * @param marker - The note marker to classify (e.g. `f`, `x`, `ef`, or a custom marker).\n * @returns `\"footnote\"` for `f*`/`ef*` markers, `\"crossref\"` for everything else.\n */\nexport function getNoteKind(marker) {\n return marker.startsWith(\"f\") || marker.startsWith(\"ef\") ? \"footnote\" : \"crossref\";\n}\n/** List of known properties of `MarkerObject` */\nexport const NOTE_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"caller\",\n \"category\",\n \"content\",\n];\nexport const NOTE_VERSION = 1;\nexport class NoteNode extends ElementNode {\n __marker;\n __caller;\n __isCollapsed;\n __category;\n __unknownAttributes;\n constructor(marker = DEFAULT_NOTE_MARKER, caller, isCollapsed = true, category, unknownAttributes, key) {\n super(key);\n this.__marker = marker;\n this.__caller =\n caller ?? (getNoteKind(marker) === \"crossref\" ? HIDDEN_NOTE_CALLER : GENERATOR_NOTE_CALLER);\n this.__isCollapsed = isCollapsed;\n this.__category = category;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"note\";\n }\n static clone(node) {\n const { __marker, __caller, __isCollapsed, __category, __unknownAttributes, __key } = node;\n return new NoteNode(__marker, __caller, __isCollapsed, __category, __unknownAttributes, __key);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isNoteElement(node))\n return null;\n return {\n conversion: $convertNoteElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createNoteNode().updateFromJSON(serializedNode);\n }\n static isValidMarker(marker, extraValidMarkers) {\n return (marker !== undefined &&\n (VALID_NOTE_MARKERS.includes(marker) ||\n (extraValidMarkers?.includes(marker) ?? false)));\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setCaller(serializedNode.caller)\n .setIsCollapsed(serializedNode.isCollapsed)\n .setCategory(serializedNode.category)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setCaller(caller) {\n if (this.__caller === caller)\n return this;\n const self = this.getWritable();\n self.__caller = caller;\n return self;\n }\n getCaller() {\n const self = this.getLatest();\n return self.__caller;\n }\n setIsCollapsed(isCollapsed) {\n if (this.__isCollapsed === isCollapsed)\n return this;\n const self = this.getWritable();\n self.__isCollapsed = isCollapsed;\n return self;\n }\n toggleIsCollapsed() {\n const self = this.getWritable();\n self.__isCollapsed = !self.__isCollapsed;\n return self;\n }\n getIsCollapsed() {\n const self = this.getLatest();\n return self.__isCollapsed;\n }\n setCategory(category) {\n if (this.__category === category)\n return this;\n const self = this.getWritable();\n self.__category = category;\n return self;\n }\n getCategory() {\n const self = this.getLatest();\n return self.__category;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(this.__type, `usfm_${this.__marker}`, this.__isCollapsed ? \"collapsed\" : \"expanded\");\n dom.setAttribute(\"data-caller\", this.__caller);\n // The stylesheet's `+`-caller counter rules select on the caller family, not per-marker\n // classes, so custom note markers number correctly (see `getNoteKind` for the PT9 rule).\n dom.setAttribute(\"data-note-kind\", getNoteKind(this.__marker));\n return dom;\n }\n updateDOM(prevNode, dom) {\n // Returning true tells Lexical that this node needs its DOM element\n // replacing with a new copy from createDOM.\n if (prevNode.__isCollapsed !== this.__isCollapsed)\n return true;\n if (prevNode.__marker !== this.__marker) {\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.remove(`usfm_${prevNode.__marker}`);\n dom.classList.add(`usfm_${this.__marker}`);\n dom.setAttribute(\"data-note-kind\", getNoteKind(this.__marker));\n }\n if (prevNode.__caller !== this.__caller)\n dom.setAttribute(\"data-caller\", this.__caller);\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(this.getType(), `usfm_${this.getMarker()}`, this.getIsCollapsed() ? \"collapsed\" : \"expanded\");\n element.setAttribute(\"data-caller\", this.getCaller());\n element.setAttribute(\"data-note-kind\", getNoteKind(this.getMarker()));\n }\n return { element };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n caller: this.getCaller(),\n isCollapsed: this.getIsCollapsed(),\n category: this.getCategory(),\n unknownAttributes: this.getUnknownAttributes(),\n version: NOTE_VERSION,\n };\n }\n // Mutation\n canBeEmpty() {\n return false;\n }\n isInline() {\n return true;\n }\n}\nfunction $convertNoteElement(element) {\n const marker = element.getAttribute(\"data-marker\") ?? \"f\";\n const caller = element.getAttribute(\"data-caller\") ?? \"\";\n const isCollapsed = element.classList.contains(\"collapsed\");\n const node = $createNoteNode(marker, caller, isCollapsed);\n return { node };\n}\nexport function $createNoteNode(marker, caller, isCollapsed, category, unknownAttributes) {\n return $applyNodeReplacement(new NoteNode(marker, caller, isCollapsed, category, unknownAttributes));\n}\nfunction isNoteElement(node) {\n if (!node)\n return false;\n const marker = node.getAttribute(\"data-marker\") ?? \"\";\n return NoteNode.isValidMarker(marker) && node.classList.contains(NoteNode.getType());\n}\nexport function $isNoteNode(node) {\n return node instanceof NoteNode;\n}\nexport function isSerializedNoteNode(node) {\n return node?.type === NoteNode.getType();\n}\n","/** Generated file using `nx generate markers-data` with 'tools/usfm-markers/src/generators/markers-data/data/usfm.sty' */\n/** @public */\nexport var CategoryType;\n(function (CategoryType) {\n CategoryType[\"FileIdentification\"] = \"FileIdentification\";\n CategoryType[\"Headers\"] = \"Headers\";\n CategoryType[\"Remarks\"] = \"Remarks\";\n CategoryType[\"Introduction\"] = \"Introduction\";\n CategoryType[\"DivisionMarks\"] = \"DivisionMarks\";\n CategoryType[\"Paragraphs\"] = \"Paragraphs\";\n CategoryType[\"Poetry\"] = \"Poetry\";\n CategoryType[\"TitlesHeadings\"] = \"TitlesHeadings\";\n CategoryType[\"Tables\"] = \"Tables\";\n CategoryType[\"CenterTables\"] = \"CenterTables\";\n CategoryType[\"RightTables\"] = \"RightTables\";\n CategoryType[\"Lists\"] = \"Lists\";\n CategoryType[\"Footnotes\"] = \"Footnotes\";\n CategoryType[\"CrossReferences\"] = \"CrossReferences\";\n CategoryType[\"SpecialText\"] = \"SpecialText\";\n CategoryType[\"CharacterStyling\"] = \"CharacterStyling\";\n CategoryType[\"Breaks\"] = \"Breaks\";\n CategoryType[\"SpecialFeatures\"] = \"SpecialFeatures\";\n CategoryType[\"PeripheralReferences\"] = \"PeripheralReferences\";\n CategoryType[\"PeripheralMaterials\"] = \"PeripheralMaterials\";\n CategoryType[\"Uncategorized\"] = \"Uncategorized\";\n})(CategoryType || (CategoryType = {}));\n/** @public */\nexport var MarkerType;\n(function (MarkerType) {\n MarkerType[\"Paragraph\"] = \"Paragraph\";\n MarkerType[\"Character\"] = \"Character\";\n MarkerType[\"Note\"] = \"Note\";\n MarkerType[\"Milestone\"] = \"Milestone\";\n MarkerType[\"Unknown\"] = \"Unknown\";\n})(MarkerType || (MarkerType = {}));\n","/** Generated file using `nx generate markers-data` with 'tools/usfm-markers/src/generators/markers-data/data/usfm.sty' */\nimport { CategoryType, MarkerType } from \"./usfmTypes.js\";\nexport const usfmMarkers = {\n id: {\n category: CategoryType.FileIdentification,\n type: MarkerType.Paragraph,\n description: \"File identification information (BOOKID, FILENAME, EDITOR, MODIFICATION DATE)\",\n hasEndMarker: false,\n children: {\n FileIdentification: [\"usfm\", \"ide\"],\n Headers: [\"h\", \"h1\", \"h2\", \"h3\", \"toc1\", \"toc2\", \"toc3\"],\n Remarks: [\"rem\", \"sts\", \"restore\"],\n Introduction: [\n \"imt\",\n \"imt1\",\n \"imt2\",\n \"imt3\",\n \"imt4\",\n \"imte\",\n \"imte1\",\n \"imte2\",\n \"is\",\n \"is1\",\n \"is2\",\n \"iot\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ior\",\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"ib\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"iex\",\n \"ie\",\n ],\n DivisionMarks: [\"c\", \"cl\"],\n TitlesHeadings: [\"mt\", \"mt1\", \"mt2\", \"mt3\", \"mt4\"],\n },\n },\n usfm: {\n category: CategoryType.FileIdentification,\n type: MarkerType.Paragraph,\n description: \"File markup version information\",\n hasEndMarker: false,\n children: undefined,\n },\n ide: {\n category: CategoryType.FileIdentification,\n type: MarkerType.Paragraph,\n description: \"File encoding information\",\n hasEndMarker: false,\n children: {\n Remarks: [\"rem\", \"sts\"],\n },\n },\n h: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Running header text for a book (basic)\",\n hasEndMarker: false,\n children: {\n Headers: [\"toc1\", \"toc2\", \"toc3\", \"toca1\", \"toca2\", \"toca3\"],\n },\n },\n h1: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Running header text\",\n hasEndMarker: false,\n children: {\n Headers: [\"toc1\", \"toc2\", \"toc3\", \"toca1\", \"toca2\", \"toca3\"],\n },\n },\n h2: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Running header text, left side of page\",\n hasEndMarker: false,\n children: {\n Headers: [\"toc1\", \"toc2\", \"toc3\", \"toca1\", \"toca2\", \"toca3\"],\n },\n },\n h3: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Running header text, right side of page\",\n hasEndMarker: false,\n children: {\n Headers: [\"toc1\", \"toc2\", \"toc3\", \"toca1\", \"toca2\", \"toca3\"],\n },\n },\n toc1: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Long table of contents text\",\n hasEndMarker: false,\n children: undefined,\n },\n toc2: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Short table of contents text\",\n hasEndMarker: false,\n children: undefined,\n },\n toc3: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Book Abbreviation\",\n hasEndMarker: false,\n children: undefined,\n },\n toca1: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Alternative language long table of contents text\",\n hasEndMarker: false,\n children: undefined,\n },\n toca2: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Alternative language short table of contents text\",\n hasEndMarker: false,\n children: undefined,\n },\n toca3: {\n category: CategoryType.Headers,\n type: MarkerType.Paragraph,\n description: \"Alternative language book Abbreviation\",\n hasEndMarker: false,\n children: undefined,\n },\n rem: {\n category: CategoryType.Remarks,\n type: MarkerType.Paragraph,\n description: \"Comments and remarks\",\n hasEndMarker: false,\n children: undefined,\n },\n sts: {\n category: CategoryType.Remarks,\n type: MarkerType.Paragraph,\n description: \"Status of this file\",\n hasEndMarker: false,\n children: undefined,\n },\n restore: {\n category: CategoryType.Remarks,\n type: MarkerType.Paragraph,\n description: \"Project restore information\",\n hasEndMarker: false,\n children: undefined,\n },\n imt: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title, level 1 (if single level) (basic)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imt1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imt2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imt3: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title, level 3\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imt4: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title, level 4 (usually within parenthesis)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imte: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title at introduction end, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imte1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title at introduction end, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n imte2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction major title at introduction end, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n is: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction section heading, level 1 (if single level) (basic)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n CharacterStyling: [\"no\"],\n },\n },\n is1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction section heading, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n is2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction section heading, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n SpecialText: [\"bk\"],\n },\n },\n iot: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline title (basic)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CharacterStyling: [\"no\"],\n },\n },\n io: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline text, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"ior\", \"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n io1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline text, level 1 (if multiple levels) (basic)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"ior\", \"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n io2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline text, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"ior\", \"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n io3: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline text, level 3\",\n hasEndMarker: false,\n children: {\n Introduction: [\"ior\", \"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n io4: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction outline text, level 4\",\n hasEndMarker: false,\n children: {\n Introduction: [\"ior\", \"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ior: {\n category: CategoryType.Introduction,\n type: MarkerType.Character,\n description: \"Introduction references range for outline entry; for marking references separately\",\n hasEndMarker: true,\n children: undefined,\n },\n ip: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph (basic)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n im: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph, with no first line indent (may occur after poetry)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ipi: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph, indented, with first line indent\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n imi: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph text, indented, with no first line indent\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ili: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ili1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ili2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ipq: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph, quote from the body text\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n imq: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph, quote from the body text, with no first line indent\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ipr: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction prose paragraph, right aligned\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ib: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction blank line\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n },\n },\n iq: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction poetry text, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n iq1: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction poetry text, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n iq2: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction poetry text, level 2\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n iq3: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction poetry text, level 3\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n iex: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)\",\n hasEndMarker: false,\n children: {\n Introduction: [\"iqt\"],\n CharacterStyling: [\"no\"],\n },\n },\n iqt: {\n category: CategoryType.Introduction,\n type: MarkerType.Character,\n description: \"For quoted scripture text appearing in the introduction\",\n hasEndMarker: true,\n children: undefined,\n },\n ie: {\n category: CategoryType.Introduction,\n type: MarkerType.Paragraph,\n description: \"Introduction ending marker\",\n hasEndMarker: false,\n children: undefined,\n },\n c: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Paragraph,\n description: \"Chapter number (necessary for normal Paratext operation)\",\n hasEndMarker: false,\n children: {\n DivisionMarks: [\"ca\", \"cp\", \"cl\", \"cd\"],\n Paragraphs: [\"p\", \"m\", \"po\", \"pr\", \"cls\", \"pi\", \"pi1\", \"pi2\", \"pi3\", \"pc\", \"mi\", \"nb\"],\n Poetry: [\"q\", \"q1\", \"q2\", \"q3\", \"q4\", \"qc\", \"qr\", \"qa\", \"qd\", \"b\"],\n TitlesHeadings: [\n \"mte\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"ms3\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"r\",\n \"sp\",\n \"d\",\n \"sd\",\n \"sd1\",\n \"sd2\",\n \"sd3\",\n \"sd4\",\n ],\n Lists: [\"lh\", \"li\", \"li1\", \"li2\", \"li3\", \"li4\", \"lf\", \"lim\", \"lim1\", \"lim2\", \"lim3\", \"lim4\"],\n Footnotes: [\"f\", \"fe\"],\n SpecialText: [\"lit\"],\n Breaks: [\"pb\"],\n },\n },\n ca: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Character,\n description: \"Second (alternate) chapter number (for coding dual versification; useful for places where different traditions of chapter breaks need to be supported in the same translation)\",\n hasEndMarker: true,\n children: undefined,\n },\n cp: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Paragraph,\n description: \"Published chapter number (chapter string that should appear in the published text)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\"],\n },\n },\n cl: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Paragraph,\n description: \"Chapter label used for translations that add a word such as 'Chapter' before chapter numbers (e.g. Psalms). The subsequent text is the chapter label.\",\n hasEndMarker: false,\n children: undefined,\n },\n cd: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Paragraph,\n description: \"Chapter Description (Publishing option D, e.g. in Russian Bibles)\",\n hasEndMarker: false,\n children: {\n DivisionMarks: [\"vp\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n v: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Character,\n description: \"A verse number (Necessary for normal paratext operation) (basic)\",\n hasEndMarker: false,\n children: undefined,\n },\n va: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Character,\n description: \"Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)\",\n hasEndMarker: true,\n children: undefined,\n },\n vp: {\n category: CategoryType.DivisionMarks,\n type: MarkerType.Character,\n description: \"Published verse marker (verse string that should appear in the published text)\",\n hasEndMarker: true,\n children: undefined,\n },\n p: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, with first line indent (basic)\",\n hasEndMarker: false,\n children: {\n Paragraphs: [\"pmo\", \"pm\", \"pmc\", \"pmr\"],\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n m: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, with no first line indent (may occur after poetry) (basic)\",\n hasEndMarker: false,\n children: {\n Paragraphs: [\"pmo\", \"pm\", \"pmc\", \"pmr\"],\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n po: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Letter opening\",\n hasEndMarker: false,\n children: {\n Paragraphs: [\"pmo\", \"pm\", \"pmc\", \"pmr\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pr: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Text refrain (paragraph text, right aligned)\",\n hasEndMarker: false,\n children: {\n Paragraphs: [\"pmo\", \"pm\", \"pmc\", \"pmr\"],\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n cls: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Letter Closing\",\n hasEndMarker: false,\n children: {\n SpecialText: [\"tl\", \"sig\", \"pn\", \"png\", \"addpn\", \"add\"],\n },\n },\n pmo: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Embedded text opening\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pm: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Embedded text paragraph\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pmc: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Embedded text closing\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pmr: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Embedded text refrain (e.g. Then all the people shall say, 'Amen!')\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pi: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse (basic)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pi1: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pi2: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, level 2 indent, with first line indent; often used for discourse\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pi3: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, level 3 indent, with first line indent; often used for discourse\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n pc: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, centered (for Inscription)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n mi: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, indented, with no first line indent; often used for discourse\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n nb: {\n category: CategoryType.Paragraphs,\n type: MarkerType.Paragraph,\n description: \"Paragraph text, with no break from previous paragraph text (at chapter boundary) (basic)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n q: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, level 1 indent (if single level)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n q1: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, level 1 indent (if multiple levels) (basic)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n q2: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, level 2 indent (basic)\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n q3: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, level 3 indent\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n q4: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, level 4 indent\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qc: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, centered\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qr: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, Right Aligned\",\n hasEndMarker: false,\n children: {\n Poetry: [\"qs\", \"qac\", \"qm\", \"qm1\", \"qm2\", \"qm3\"],\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qs: {\n category: CategoryType.Poetry,\n type: MarkerType.Character,\n description: \"Poetry text, Selah\",\n hasEndMarker: true,\n children: {\n Footnotes: [\"f\"],\n CrossReferences: [\"x\"],\n },\n },\n qa: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, Acrostic marker/heading\",\n hasEndMarker: false,\n children: undefined,\n },\n qac: {\n category: CategoryType.Poetry,\n type: MarkerType.Character,\n description: \"Poetry text, Acrostic markup of the first character of a line of acrostic poetry\",\n hasEndMarker: true,\n children: undefined,\n },\n qm: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, embedded, level 1 indent (if single level)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qm1: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, embedded, level 1 indent (if multiple levels)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qm2: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, embedded, level 2 indent\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qm3: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text, embedded, level 3 indent\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n qd: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte1\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n b: {\n category: CategoryType.Poetry,\n type: MarkerType.Paragraph,\n description: \"Poetry text stanza break (e.g. stanza break) (basic)\",\n hasEndMarker: false,\n children: undefined,\n },\n mt: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"The main title of the book (if single level)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\"],\n CrossReferences: [\"x\"],\n },\n },\n mt1: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"The main title of the book (if multiple levels) (basic)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\"],\n CrossReferences: [\"x\"],\n },\n },\n mt2: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A secondary title usually occurring before the main title (basic)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\"],\n CrossReferences: [\"x\"],\n },\n },\n mt3: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A secondary title occurring after the main title\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\"],\n CrossReferences: [\"x\"],\n },\n },\n mt4: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A small secondary title sometimes occurring within parentheses\",\n hasEndMarker: false,\n children: undefined,\n },\n mte: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"The main title of the book repeated at the end of the book, level 1 (if single level)\",\n hasEndMarker: false,\n children: undefined,\n },\n mte1: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"The main title of the book repeated at the end of the book, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mte2\"],\n },\n },\n mte2: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A secondary title occurring before or after the 'ending' main title\",\n hasEndMarker: false,\n children: undefined,\n },\n ms: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A major section division heading, level 1 (if single level) (basic)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mr\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ms1: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A major section division heading, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mr\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ms2: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A major section division heading, level 2\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mr\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n ms3: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A major section division heading, level 3\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"mr\"],\n Footnotes: [\"f\", \"fe\"],\n },\n },\n mr: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A major section division references range heading (basic)\",\n hasEndMarker: false,\n children: undefined,\n },\n s: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section heading, level 1 (if single level) (basic)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"sr\", \"r\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n s1: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section heading, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"sr\", \"r\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n s2: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section heading, level 2 (e.g. Proverbs 22-24)\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"sr\", \"r\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n s3: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section heading, level 3 (e.g. Genesis 'The First Day')\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"sr\", \"r\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"no\", \"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n s4: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section heading, level 4\",\n hasEndMarker: false,\n children: {\n TitlesHeadings: [\"sr\", \"r\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n sr: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A section division references range heading\",\n hasEndMarker: false,\n children: undefined,\n },\n r: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Parallel reference(s) (basic)\",\n hasEndMarker: false,\n children: undefined,\n },\n sp: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A heading, to identify the speaker (e.g. Job)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n d: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"A Hebrew text heading, to provide description (e.g. Psalms)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n sd: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Vertical space used to divide the text into sections, level 1 (if single level)\",\n hasEndMarker: false,\n children: undefined,\n },\n sd1: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Vertical space used to divide the text into sections, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: undefined,\n },\n sd2: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Vertical space used to divide the text into sections, level 2\",\n hasEndMarker: false,\n children: undefined,\n },\n sd3: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Vertical space used to divide the text into sections, level 3\",\n hasEndMarker: false,\n children: undefined,\n },\n sd4: {\n category: CategoryType.TitlesHeadings,\n type: MarkerType.Paragraph,\n description: \"Vertical space used to divide the text into sections, level 4\",\n hasEndMarker: false,\n children: undefined,\n },\n lh: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"List header (introductory remark)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n li: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n li1: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n li2: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 2\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n li3: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 3\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n li4: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"A list entry, level 4\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lf: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"List footer (concluding remark)\",\n hasEndMarker: false,\n children: {\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lim: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"An embedded list entry, level 1 (if single level)\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lim1: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"An embedded list entry, level 1 (if multiple levels)\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lim2: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"An embedded list entry, level 2\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lim3: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"An embedded list item, level 3\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n lim4: {\n category: CategoryType.Lists,\n type: MarkerType.Paragraph,\n description: \"An embedded list entry, level 4\",\n hasEndMarker: false,\n children: {\n Lists: [\"litl\", \"lik\", \"liv\", \"liv1\", \"liv2\", \"liv3\", \"liv4\", \"liv5\"],\n Footnotes: [\"f\", \"fe\", \"fm\"],\n CrossReferences: [\"x\", \"xt\", \"rq\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n litl: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"List entry total text\",\n hasEndMarker: true,\n children: undefined,\n },\n lik: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry key text\",\n hasEndMarker: true,\n children: undefined,\n },\n liv: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 1 content (if single value)\",\n hasEndMarker: true,\n children: undefined,\n },\n liv1: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 1 content (if multiple values)\",\n hasEndMarker: true,\n children: undefined,\n },\n liv2: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 2 content\",\n hasEndMarker: true,\n children: undefined,\n },\n liv3: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 3 content\",\n hasEndMarker: true,\n children: undefined,\n },\n liv4: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 4 content\",\n hasEndMarker: true,\n children: undefined,\n },\n liv5: {\n category: CategoryType.Lists,\n type: MarkerType.Character,\n description: \"Structured list entry value 5 content\",\n hasEndMarker: true,\n children: undefined,\n },\n f: {\n category: CategoryType.Footnotes,\n type: MarkerType.Note,\n description: \"A Footnote text item (basic)\",\n hasEndMarker: true,\n children: {\n Footnotes: [\"fr\", \"ft\", \"fk\", \"fq\", \"fqa\", \"fl\", \"fw\", \"fp\", \"fv\", \"fdc\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n fe: {\n category: CategoryType.Footnotes,\n type: MarkerType.Note,\n description: \"An Endnote text item\",\n hasEndMarker: true,\n children: {\n Footnotes: [\"fr\", \"ft\", \"fk\", \"fq\", \"fqa\", \"fl\", \"fw\", \"fp\", \"fv\", \"fdc\"],\n CrossReferences: [\"xt\"],\n SpecialText: [\n \"qt\",\n \"nd\",\n \"tl\",\n \"dc\",\n \"bk\",\n \"sig\",\n \"pn\",\n \"png\",\n \"addpn\",\n \"wj\",\n \"k\",\n \"sls\",\n \"ord\",\n \"add\",\n ],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n fr: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"The origin reference for the footnote (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n ft: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"Footnote text, Protocanon (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n fk: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A footnote keyword (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n fq: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A footnote scripture quote or alternate rendering (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n fqa: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A footnote alternate rendering for a portion of scripture text\",\n hasEndMarker: true,\n children: undefined,\n },\n fl: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A footnote label text item, for marking or 'labelling' the type or alternate translation being provided in the note.\",\n hasEndMarker: true,\n children: undefined,\n },\n fw: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.\",\n hasEndMarker: true,\n children: undefined,\n },\n fp: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A Footnote additional paragraph marker\",\n hasEndMarker: true,\n children: undefined,\n },\n fv: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"A verse number within the footnote text\",\n hasEndMarker: true,\n children: undefined,\n },\n fdc: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"Footnote text, applies to Deuterocanon only\",\n hasEndMarker: true,\n children: undefined,\n },\n fm: {\n category: CategoryType.Footnotes,\n type: MarkerType.Character,\n description: \"An additional footnote marker location for a previous footnote\",\n hasEndMarker: true,\n children: undefined,\n },\n x: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Note,\n description: \"A list of cross references (basic)\",\n hasEndMarker: true,\n children: {\n CrossReferences: [\"xo\", \"xop\", \"xt\", \"xta\", \"xk\", \"xq\", \"xot\", \"xnt\", \"xdc\"],\n CharacterStyling: [\"it\", \"bd\", \"bdit\", \"em\", \"sc\", \"sup\"],\n },\n },\n xo: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"The cross reference origin reference (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n xop: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"Published cross reference origin reference (origin reference that should appear in the published text)\",\n hasEndMarker: true,\n children: undefined,\n },\n xt: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"The cross reference target reference(s), protocanon only (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n xta: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"Cross reference target references added text\",\n hasEndMarker: true,\n children: undefined,\n },\n xk: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"A cross reference keyword\",\n hasEndMarker: true,\n children: undefined,\n },\n xq: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"A cross-reference quotation from the scripture text\",\n hasEndMarker: true,\n children: undefined,\n },\n xot: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"Cross-reference target reference(s), Old Testament only\",\n hasEndMarker: true,\n children: undefined,\n },\n xnt: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"Cross-reference target reference(s), New Testament only\",\n hasEndMarker: true,\n children: undefined,\n },\n xdc: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"Cross-reference target reference(s), Deuterocanon only\",\n hasEndMarker: true,\n children: undefined,\n },\n rq: {\n category: CategoryType.CrossReferences,\n type: MarkerType.Character,\n description: \"A cross-reference indicating the source text for the preceding quotation.\",\n hasEndMarker: true,\n children: undefined,\n },\n qt: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For Old Testament quoted text appearing in the New Testament (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n nd: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For name of deity (basic)\",\n hasEndMarker: true,\n children: undefined,\n },\n tl: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For transliterated words\",\n hasEndMarker: true,\n children: undefined,\n },\n dc: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"Deuterocanonical/LXX additions or insertions in the Protocanonical text\",\n hasEndMarker: true,\n children: undefined,\n },\n bk: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For the quoted name of a book\",\n hasEndMarker: true,\n children: undefined,\n },\n sig: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For the signature of the author of an Epistle\",\n hasEndMarker: true,\n children: undefined,\n },\n pn: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For a proper name\",\n hasEndMarker: true,\n children: undefined,\n },\n png: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For a geographic proper name\",\n hasEndMarker: true,\n children: undefined,\n },\n addpn: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For chinese words to be dot underline & underline\",\n hasEndMarker: true,\n children: undefined,\n },\n wj: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For marking the words of Jesus\",\n hasEndMarker: true,\n children: undefined,\n },\n k: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For a keyword\",\n hasEndMarker: true,\n children: undefined,\n },\n sls: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"To represent where the original text is in a secondary language or from an alternate text source\",\n hasEndMarker: true,\n children: undefined,\n },\n ord: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For the text portion of an ordinal number\",\n hasEndMarker: true,\n children: undefined,\n },\n add: {\n category: CategoryType.SpecialText,\n type: MarkerType.Character,\n description: \"For a translational addition to the text\",\n hasEndMarker: true,\n children: undefined,\n },\n lit: {\n category: CategoryType.SpecialText,\n type: MarkerType.Paragraph,\n description: \"For a comment or note inserted for liturgical use\",\n hasEndMarker: false,\n children: undefined,\n },\n no: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, use normal text\",\n hasEndMarker: true,\n children: undefined,\n },\n it: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, use italic text\",\n hasEndMarker: true,\n children: undefined,\n },\n bd: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, use bold text\",\n hasEndMarker: true,\n children: undefined,\n },\n bdit: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, use bold + italic text\",\n hasEndMarker: true,\n children: undefined,\n },\n em: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, use emphasized text style\",\n hasEndMarker: true,\n children: undefined,\n },\n sc: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, for small capitalization text\",\n hasEndMarker: true,\n children: undefined,\n },\n sup: {\n category: CategoryType.CharacterStyling,\n type: MarkerType.Character,\n description: \"A character style, for superscript text. Typically for use in critical edition footnotes.\",\n hasEndMarker: true,\n children: undefined,\n },\n pb: {\n category: CategoryType.Breaks,\n type: MarkerType.Paragraph,\n description: \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n hasEndMarker: false,\n children: undefined,\n },\n};\n","import { CategoryType, MarkerType } from \"./usfmTypes.js\";\nconst paragraphChildren = {\n DivisionMarks: { add: [\"v\", \"c\"], remove: [] },\n Paragraphs: { add: [\"p\"], remove: [] },\n Poetry: { add: [\"q\", \"q1\", \"q2\", \"q3\", \"q4\", \"b\"], remove: [] },\n TitlesHeadings: {\n add: [\n \"mte\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"ms3\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"r\",\n \"sp\",\n \"d\",\n \"sd\",\n \"sd1\",\n \"sd2\",\n \"sd3\",\n \"sd4\",\n ],\n remove: [],\n },\n};\nconst usfmMarkersOverwrites = {\n p: { children: paragraphChildren },\n q: { children: paragraphChildren },\n q1: { children: paragraphChildren },\n q2: { children: paragraphChildren },\n q3: { children: paragraphChildren },\n q4: { children: paragraphChildren },\n b: { children: paragraphChildren },\n qm: {\n children: {\n Paragraphs: { add: [\"p\"], remove: [] },\n },\n },\n c: {\n type: MarkerType.Paragraph,\n children: null,\n },\n v: {\n children: null,\n },\n // The following are attribute-bearing character markers present in usfm.sty and in\n // CharNode's VALID_CHAR_MARKERS, but absent from the generated usfmMarkers data.\n // They are defined here as complete entries rather than hand-edited into the\n // generated file, which would be silently lost on regeneration.\n w: {\n category: CategoryType.SpecialFeatures,\n type: MarkerType.Character,\n description: \"A wordlist/glossary/dictionary entry marker for study/analysis purposes\",\n hasEndMarker: true,\n },\n rb: {\n category: CategoryType.SpecialFeatures,\n type: MarkerType.Character,\n description: \"A ruby glossing marker for study/analysis purposes\",\n hasEndMarker: true,\n },\n jmp: {\n category: CategoryType.SpecialFeatures,\n type: MarkerType.Character,\n description: \"A hyperlink marker for study/analysis purposes\",\n hasEndMarker: true,\n },\n // The generated table has no `fig`, but `usfm.sty` does (and so does the stylesheet data every\n // project supplies). Without an entry here, a document parsed BEFORE its project stylesheet\n // resolves falls back to this table, reads `\\fig` as an unknown marker, and breaks the figure\n // into its own paragraph with the closer stranded as unmatched.\n fig: {\n category: CategoryType.SpecialFeatures,\n type: MarkerType.Character,\n description: \"Illustration [Columns to span, height, filename, caption text]\",\n hasEndMarker: true,\n },\n};\nexport default usfmMarkersOverwrites;\n","import { usfmMarkers } from \"./usfmMarkers.js\";\nimport usfmMarkersOverwrites from \"./usfmMarkersOverwrites.js\";\n//NOTE: We can make this reusable if we agree on a common usfmMarkers object for all editors and use the overwrites objects as a parameter for this function.\nfunction getMarker(marker) {\n // Own-property lookups: both tables are plain object literals, so a bare index resolves\n // Object.prototype members — a marker named `constructor`, `toString`, `__proto__`, … answered\n // with a Function, which spreads to a truthy Marker carrying no category/type/hasEndMarker.\n // Callers read a truthy result as \"this marker is known\", so a stray `\\constructor` typed by a\n // user classified as a real marker with an undefined type. (`createMarkerLookup` in\n // styleInfo.ts guards its own table the same way.)\n const baseMarker = Object.hasOwn(usfmMarkers, marker) ? usfmMarkers[marker] : undefined;\n const overwrite = Object.hasOwn(usfmMarkersOverwrites, marker)\n ? usfmMarkersOverwrites[marker]\n : undefined;\n if (!baseMarker) {\n // The overwrites file can ADD markers the generated data lacks — but with no base to fill\n // gaps, only an overwrite carrying the FULL required Marker shape may stand alone. A partial\n // overwrite (e.g. `type` set but no category/description/hasEndMarker) is not a valid Marker,\n // so the `as Marker` cast would lie about it; refuse rather than return a malformed object.\n if (overwrite?.category !== undefined &&\n overwrite.type !== undefined &&\n overwrite.description !== undefined &&\n overwrite.hasEndMarker !== undefined)\n // A COPY: the table entry is module-level shared state, and handing it out lets any caller\n // that edits the returned Marker corrupt that marker for the whole process.\n return { ...overwrite };\n return undefined;\n }\n if (!overwrite) {\n return baseMarker;\n }\n let mergedChildren = baseMarker.children ? { ...baseMarker.children } : undefined;\n if (overwrite.children === null) {\n mergedChildren = undefined;\n }\n if (overwrite.children) {\n mergedChildren = mergedChildren || {};\n for (const [category, modification] of Object.entries(overwrite.children)) {\n const categoryType = category;\n if (modification === null) {\n // Remove the entire category if it exists\n Reflect.deleteProperty(mergedChildren, categoryType);\n }\n else {\n // Update children for this category\n let currentChildren = mergedChildren[categoryType] || [];\n if (modification.remove) {\n currentChildren = currentChildren.filter((child) => !modification.remove.includes(child));\n }\n if (modification.add) {\n currentChildren = [...new Set([...currentChildren, ...modification.add])];\n }\n if (currentChildren.length > 0) {\n mergedChildren[categoryType] = currentChildren;\n }\n else {\n Reflect.deleteProperty(mergedChildren, categoryType);\n }\n }\n }\n // If mergedChildren is empty, set it to undefined\n if (Object.keys(mergedChildren).length === 0) {\n mergedChildren = undefined;\n }\n }\n return {\n ...baseMarker,\n ...overwrite,\n children: mergedChildren,\n };\n}\nexport default getMarker;\n","/**\n * StyleInfo-driven USFM fragment tokenizer for Tier 2 paragraph re-tokenization.\n * Reference semantics: ParatextData `UsfmToken.Tokenize` —\n * fragment-level tokenization only; document-level validation stays out. Marker\n * kinds come from the bundled usfm.sty-derived `usfmMarkers` map via `getMarker`\n * by default, or from `options.getMarker` (a project `StyleInfo`-backed\n * `MarkerLookup`) when supplied — classification is stylesheet-first:\n * a marker the lookup KNOWS is classified by its declared type, full stop.\n *\n * Markers the effective stylesheet does NOT know (`kind === undefined`) fall\n * back to name-pattern heuristics — `NoteNode.isValidMarker`, and for\n * milestones only the stylesheet-family names (`\\qt#-s/-e`, `\\ts-s/-e`, plus\n * the `zmsc-*` comment markers; see `isMilestoneHeuristicName`) — and\n * failing those, resolve by context exactly like PT9's\n * `UsfmParser.DetermineUnknownTokenType`: PARAGRAPH in body text, CHARACTER\n * inside a note (`options.isNoteContext`), except `esb`/`esbe`, which PT9\n * always treats as paragraphs (`UsfmToken.cs:405-421`). An unmatched closer\n * (known or unknown marker, no open frame to close) becomes a\n * `{ type: \"unmatched\", marker: \"*\" }` USJ object (PT9 `sink.Unmatched`,\n * `UsxUsfmParserSink.cs:262-266`), not literal text.\n *\n * Literal-text degradation remains only for fragments the\n * tokenizer cannot confidently parse at all: a bare `\\`, or an unterminated\n * milestone (stylesheet-declared, or matching the suffix convention above).\n * Content between a milestone's marker and its `\\*` is NOT literal: a\n * milestone cannot hold content, so it ends where the content begins, the\n * content follows it as a sibling, and the author's `\\*` becomes an unmatched\n * element. A stray `\\*` with no milestone to close is NOT literal either — it\n * becomes an unmatched element (see above).\n *\n * Figures, tables, sidebars, and peripheral divisions assemble to their faithful\n * USJ shapes at the assembly level, marker-name driven (they are parser-level\n * structures in ParatextData, independent of stylesheet classification):\n * `\\fig …\\fig*` folds to an inline `figure` object (USFM's `src` attribute\n * renamed to USX/USJ's `file`), `\\tr` plus `t[hc][rc]#(-#)` cell markers build\n * `table` → `table:row` → `table:cell` with name-derived `align`/`colspan`,\n * `\\esb`…`\\esbe` wraps the following blocks in a `sidebar` (`\\cat` directly\n * after `\\esb` folds to its `category`), and `\\periph` opens a `periph`\n * division that takes every following block until the next `\\periph`, a\n * chapter, or the fragment end — its marker line splitting at the first `|`\n * into the division title (`alt`) and an ordinary attribute list. Anything off\n * the clean shapes — nested markup or positional (USFM 2.0) attributes in a\n * figure, a missing `\\fig*`, a cell marker with no open row, a periph\n * attribute list that does not parse — degrades to the plain char/para output\n * the marker classification produces on its own.\n *\n * Input is USFM text: `~` means NBSP; each {@link PRESERVED_NODE_PLACEHOLDER} stands for one node\n * the caller keeps out of the bytes (see {@link UsfmFragmentOptions.placeholders}).\n */\nimport { NBSP, PARA_MARKER_DEFAULT, ZWSP } from \"../../nodes/usj/node-constants.js\";\nimport { isMilestoneCommentMarker } from \"../../nodes/usj/MilestoneNode.js\";\nimport { NoteNode } from \"../../nodes/usj/NoteNode.js\";\nimport getMarker from \"../../utils/usfm/getMarker.js\";\nimport { MarkerType } from \"../../utils/usfm/usfmTypes.js\";\n/**\n * The character a caller puts in a fragment in place of one node it keeps out of the bytes (a\n * collapsed note, a milestone the tokenizer cannot re-derive, …) and puts back over the parsed\n * output afterwards. The placeholder itself lands in the output as one text character.\n *\n * The node's own bytes start with a marker, so the placeholder parses the way that marker's `\\`\n * does: it ends any word being read in front of it — a marker name, a note caller, a verse or\n * chapter number — exactly as ParatextData's `UsfmToken.Tokenize` ends one at a `\\`.\n */\nexport const PRESERVED_NODE_PLACEHOLDER = \"\\uFFFC\";\nconst VERSE_MARKER = \"v\";\nconst CHAPTER_MARKER = \"c\";\nconst FIGURE_MARKER = \"fig\";\nconst TABLE_ROW_MARKER = \"tr\";\nconst SIDEBAR_MARKER = \"esb\";\nconst SIDEBAR_END_MARKER = \"esbe\";\nconst PERIPH_MARKER = \"periph\";\n/** The USJ property a periph's marker-line title lands on — the same name a pipe pair would use,\n * which is why a line carrying both spellings is refused rather than resolved. */\nconst PERIPH_TITLE_ATTRIBUTE = \"alt\";\n/**\n * Table cell marker names: `t` + header/cell (`h`/`c`) + optional alignment infix (`r`/`c`) +\n * starting column + optional span end column (`th1`, `tc13`, `thr5`, `thc3-4`, `tcr1-4`).\n * ParatextData derives the whole cell shape from the name alone — no stylesheet entry needed.\n */\nconst TABLE_CELL_MARKER_REGEX = /^t[hc]([rc]?)(\\d+)(?:-(\\d+))?$/;\n/** Cell alignment from the marker-name infix after `t[hc]`: `th1`/`tc1` → start,\n * `thc1`/`tcc1` → center, `thr1`/`tcr1` → end (ParatextData's name-derived alignment). */\nconst TABLE_CELL_ALIGN_BY_INFIX = {\n \"\": \"start\",\n c: \"center\",\n r: \"end\",\n};\n/**\n * Whether a cell-marker name match is a cell ParatextData recognizes. A rangeless cell\n * covers columns 1–12 spelled with no leading zeros: usfm.sty declares exactly\n * th1–th12/tc1–tc12 (and their r/c variants) and ParatextData's tag lookup is by LITERAL\n * name (`ScrStylesheet.GetTagIndex` is a string-keyed dictionary, no numeric parse), so\n * `\\tc13` and `\\tc01` are both unknown markers. A RANGED cell is narrower: ParatextData's\n * range test (`ScrStylesheet.IsCellRange`, regex `^(t[ch][cr]?[1-5])-([2-5])$` plus\n * `colSpan >= 2`) takes only single-digit spans that start in columns 1–5, end in 2–5, and\n * grow left-to-right — `\\thc4-2` (reversed), `\\tc2-2` (no growth), and `\\thc11-13`\n * (multi-digit columns) are all unknown markers too.\n */\nfunction isRecognizedTableCell(cellMatch) {\n const [, , spanStart, spanEnd] = cellMatch;\n if (!spanEnd)\n return /^(?:[1-9]|1[0-2])$/.test(spanStart);\n return (/^[1-5]$/.test(spanStart) && /^[2-5]$/.test(spanEnd) && Number(spanEnd) > Number(spanStart));\n}\n/**\n * PT9 `UsfmToken.IsNonSemanticWhiteSpace`: everything .NET counts as whitespace EXCEPT IDEOGRAPHIC\n * SPACE (U+3000), plus ZWSP (U+200B). U+3000 is excluded so it survives as authored content, and\n * ZWJ/ZWNJ are deliberately absent — Paratext treats them as content, not spacing.\n */\nfunction isNonSemanticWhiteSpace(ch) {\n const code = ch.charCodeAt(0);\n // TAB, LF, VT, FF, CR — the control characters .NET counts as whitespace\n if (code >= 0x09 && code <= 0x0d)\n return true;\n return (code === 0x20 || // SPACE\n code === 0x85 || // NEXT LINE\n code === 0xa0 || // NO-BREAK SPACE\n code === 0x1680 || // OGHAM SPACE MARK\n (code >= 0x2000 && code <= 0x200a) || // EN QUAD through HAIR SPACE\n code === 0x2028 || // LINE SEPARATOR\n code === 0x2029 || // PARAGRAPH SEPARATOR\n code === 0x202f || // NARROW NO-BREAK SPACE\n code === 0x205f || // MEDIUM MATHEMATICAL SPACE\n code === 0x200b // ZERO WIDTH SPACE\n );\n}\n/**\n * PT9 `CharExtensions.IsInvisibleCharOrWhitespace`: the invisible characters Paratext supports\n * explicitly. Used only to collapse a character repeated immediately after itself.\n */\nconst INVISIBLE_CHAR_OR_WHITESPACE = /[\\u200D\\u2003\\u2002\\u0020\\u00A0\\u202F\\u2009\\u200A\\u3000\\u200B\\u200C\\u2060\\u200E\\u200F]/;\n/**\n * Collapse whitespace runs (PT9 `UsfmToken.RegularizeSpaces`); keep U+FFFC.\n *\n * A run collapses to its FIRST character kept verbatim, not to a plain space: NBSP stays NBSP and a\n * ZWSP between two words stays ZWSP. That distinction is not cosmetic — ZWSP is the word-break\n * character in Thai, Khmer, and Lao, so flattening it to a space would rewrite those texts on every\n * settle. `platform-bible-utils`' `normalizeScriptureSpaces` is the same algorithm; the two are\n * independent ports of one Paratext function and must agree.\n *\n * The one deliberate departure from PT9: a run containing a line break collapses to `\"\\n\"` rather\n * than `\" \"`, so the attribute-marker fold logic can tell STRUCTURAL whitespace (line-end, folds\n * across: `\\ca 1 ca\\ca*` ⏎ `\\cp 1 cp`) from same-line spaces (content per Paratext, blocking the\n * fold: `\\va 12 va\\va* \\vp` keeps vp standalone). Content text normalizes the `\"\\n\"` back to `\" \"`\n * in `toUsjText`.\n *\n * Exported so the Paratext test vectors it must reproduce can be asserted directly, without the\n * marker-boundary handling of a full fragment parse in between.\n */\nexport function regularizeSpaces(text) {\n let result = \"\";\n let lastCharWasSpace = false;\n // Placeholder previous character, so the first iteration cannot report a duplicate\n let prevCh = \"\\0\";\n // Where the character standing in for the run being collapsed was written, so a line break\n // arriving later in the same run can promote it to \"\\n\" after the fact\n let runIndex = -1;\n for (let i = 0; i < text.length; i += 1) {\n const ch = text[i];\n if (ch.charCodeAt(0) < 32) {\n // Control characters, CR/LF, and TAB become spaces\n if (!lastCharWasSpace) {\n runIndex = result.length;\n result += \" \";\n }\n lastCharWasSpace = true;\n }\n else if (!lastCharWasSpace &&\n ch === ZWSP &&\n i + 1 < text.length &&\n isNonSemanticWhiteSpace(text[i + 1])) {\n // ZWSP is redundant when a space follows it\n }\n else if (isNonSemanticWhiteSpace(ch)) {\n // Keep the run's first space exactly as authored\n if (!lastCharWasSpace) {\n runIndex = result.length;\n result += ch;\n }\n lastCharWasSpace = true;\n }\n else if (INVISIBLE_CHAR_OR_WHITESPACE.test(ch) && ch === prevCh) {\n // An invisible character repeated immediately collapses to one\n }\n else {\n result += ch;\n lastCharWasSpace = false;\n runIndex = -1;\n }\n if ((ch === \"\\n\" || ch === \"\\r\") && runIndex >= 0) {\n result = `${result.slice(0, runIndex)}\\n${result.slice(runIndex + 1)}`;\n }\n prevCh = ch;\n }\n return result;\n}\n/**\n * The tokenize-identity predicate for an engine-owned separator: whether deleting the structural\n * space that ends a marker's name leaves the surrounding bytes tokenizing IDENTICALLY, given the\n * bytes that follow the separator. Defined here, beside {@link scanMarkerName}, because it IS that\n * scan's rule read backwards — the two must never drift.\n *\n * | Following bytes | Without the separator | Same meaning? |\n * | --- | --- | --- |\n * | `\\wj stuff` | `\\nd\\wj stuff` | yes — the name scan stops at `\\` either way. Heal. |\n * | `\\|x=\"y\"` | `\\nd\\|x=\"y\"` | yes — the name scan stops at `\\|` either way. Heal. |\n * | `things` | `\\ndthings` | no — the marker is now `ndthings`. Rename. |\n * | `*stuff` | `\\nd*stuff` | no — that is a CLOSING marker. Do not heal. |\n *\n * The `*` row is why this is defined by MEANING and not by a terminator character class: `*` is\n * one of the scan's terminators, but it ends the token AND changes what the token is, so an\n * allowlist built from terminators would wrongly heal it and silently prevent the user from\n * typing a closer.\n *\n * The question is local — it depends only on the first following byte — so callers get an O(1)\n * answer for the common shapes and fall back to a scoped re-tokenization only when this returns\n * `false` (the bytes then genuinely mean something new).\n *\n * @param followingBytes - The displayed bytes immediately after the separator's site.\n * @returns `true` when removing the separator cannot change the token stream.\n */\nexport function separatorRemovalTokenizesIdentically(followingBytes) {\n if (followingBytes.length === 0)\n return true;\n const ch = followingBytes[0];\n if (ch === \"*\")\n return false; // completes a closing marker\n if (ch === \"\\\\\" || ch === \"|\")\n return true; // the name scan stops here either way\n if (/[\\s\\u200B]/.test(ch))\n return true; // more whitespace: the run still separates\n return false; // a name character: the marker name grows through it\n}\n/** Marker name chars per PT9 scan: stop at `\\`, `|`, whitespace; `*` ends and is included. */\nfunction scanMarkerName(fragment, start) {\n let index = start;\n while (index < fragment.length) {\n const ch = fragment[index];\n if (ch === \"\\\\\" || ch === \"|\" || ch === PRESERVED_NODE_PLACEHOLDER)\n break;\n if (ch === \"*\") {\n index++;\n break;\n }\n if (/[\\s\\u200B]/.test(ch))\n break;\n index++;\n }\n return { name: fragment.slice(start, index), next: index };\n}\n/**\n * Whether the bare `\\` at `start` is the marker of a nameless paragraph — the empty name\n * ParatextData 9.6 reads in `\\ df` (`df`): its tokenizer reads a marker at a\n * token start even when the name is empty, and resolves that unknown token as a paragraph in body\n * text (UsfmParser.DetermineUnknownTokenType). A `\\` after text stays text there, because its text\n * scan only stops at a `\\` followed by a name character.\n *\n * Read so only where the caller says the fragment opens with a nameless paragraph's glyph\n * ({@link UsfmFragmentOptions.opensNamelessParagraph}), and only for the first `\\` of the\n * fragment, with nothing but whitespace in front of it — where a `\\p` would still open a paragraph\n * of its own. Everywhere else a bare `\\` stays literal, ParatextData's token starts included: a\n * `\\` typed right after another marker, or left by deleting a marker's name, is text the user has\n * not named yet, not a paragraph break.\n *\n * The name ends where it would after a named marker: at whitespace, at the end, or at another\n * `\\`. A `\\` directly before `|` or a preserved-node placeholder stays literal.\n */\nfunction readsAsNamelessMarker(fragment, start, opensNamelessParagraph) {\n if (!opensNamelessParagraph)\n return false;\n if (!/^[\\s\\u00A0\\u200B]*$/.test(fragment.slice(0, start)))\n return false;\n const following = fragment[start + 1];\n return following === undefined || following === \"\\\\\" || /[\\s\\u00A0\\u200B]/.test(following);\n}\n/** Milestone names the Paratext stylesheet family declares: `\\qt-s/-e`, `\\qt1-s`…`\\qt5-e`,\n * `\\ts-s/-e`. */\nconst STYLESHEET_MILESTONE_NAME_REGEX = /^(?:qt[1-5]?|ts)-[se]$/;\n/**\n * Milestone-name heuristic for markers ABSENT from the effective stylesheet: only names the\n * Paratext stylesheet family actually declares as milestones, plus the editor's own annotation\n * comment markers — so the heuristic predicts what ParatextData's stylesheet-driven parse\n * produces for the same bytes. Deliberately EXCLUDED: bare `ts`, `t-s`, `t-e` — syntactically\n * valid milestones, but no stylesheet declares them, so ParatextData parses them as unknown\n * markers (paragraph in body text) and any milestone produced here would flip to that shape on\n * the next chapter read. Also excluded: `MilestoneNode.isValidMarker`'s generic `z`-prefix\n * wildcard, which would classify any custom.sty-style marker (e.g. `\\zfoo`) as a milestone and\n * keep unknown-marker resolution (`DetermineUnknownTokenType`) from ever seeing it. A project\n * that declares any of these in custom.sty gets them classified stylesheet-first with no code\n * change.\n */\nexport function isMilestoneHeuristicName(name) {\n return STYLESHEET_MILESTONE_NAME_REGEX.test(name) || isMilestoneCommentMarker(name);\n}\n/** PT9 `GetNextWord`: skip leading whitespace, take up to whitespace or `\\` — or a placeholder,\n * which stands for bytes that start with `\\`. */\nfunction getNextWord(fragment, start) {\n let index = start;\n while (index < fragment.length && /[\\s\\u00A0\\u200B]/.test(fragment[index]))\n index++;\n const wordStart = index;\n while (index < fragment.length &&\n fragment[index] !== PRESERVED_NODE_PLACEHOLDER &&\n !/[\\s\\u00A0\\u200B\\\\]/.test(fragment[index]))\n index++;\n const word = fragment.slice(wordStart, index);\n while (index < fragment.length && /[\\s\\u00A0\\u200B]/.test(fragment[index]))\n index++;\n return { word, next: index };\n}\n/** The fragment offsets of the placeholders that stand for a note or a verse, in order. */\nfunction noteEndingPlaceholderOffsets(fragment, placeholders) {\n const offsets = [];\n let ordinal = 0;\n for (let offset = 0; offset < fragment.length; offset++) {\n if (fragment[offset] !== PRESERVED_NODE_PLACEHOLDER)\n continue;\n const kind = placeholders[ordinal];\n ordinal++;\n if (kind === \"note\" || kind === \"verse\")\n offsets.push(offset);\n }\n return offsets;\n}\nfunction tokenize(fragment, getMarkerFn, isNoteContext, placeholders, opensNamelessParagraph) {\n const tokens = [];\n let index = 0;\n const noteEnding = noteEndingPlaceholderOffsets(fragment, placeholders);\n let nextNoteEnding = 0;\n // PT9 resolves an unknown marker against the OPEN ELEMENT STACK, not against the fragment it\n // started in (`State.Stack.Exists(e => e.Type == Note)`, UsfmParser.cs). A note opened inside\n // this fragment puts one on that stack just as surely as being handed note content does, so\n // track it: without this, an unknown marker inside `\\f ... \\f*` classifies as a PARAGRAPH and\n // tears the note in half, stranding its closer.\n let openNoteMarker;\n const pushText = (text) => {\n if (!text)\n return;\n const prev = tokens[tokens.length - 1];\n if (prev?.kind === \"text\")\n prev.text += text;\n else\n tokens.push({ kind: \"text\", text });\n };\n // `//` mid-text is USFM's discretionary line break (PT9 tokenizes it wherever it appears,\n // spec-blind — even inside a URL); the surrounding text is kept byte-exact.\n const pushTextWithOptbreaks = (text) => {\n const parts = text.split(\"//\");\n parts.forEach((part, partIndex) => {\n if (partIndex > 0)\n tokens.push({ kind: \"optbreak\" });\n pushText(part);\n });\n };\n while (index < fragment.length) {\n if (fragment[index] !== \"\\\\\") {\n while (nextNoteEnding < noteEnding.length && noteEnding[nextNoteEnding] < index)\n nextNoteEnding++;\n if (noteEnding[nextNoteEnding] === index) {\n openNoteMarker = undefined;\n tokens.push({ kind: \"noteEndingPlaceholder\" });\n index++;\n continue;\n }\n const nextMarker = fragment.indexOf(\"\\\\\", index);\n let end = nextMarker === -1 ? fragment.length : nextMarker;\n if (nextNoteEnding < noteEnding.length)\n end = Math.min(end, noteEnding[nextNoteEnding]);\n pushTextWithOptbreaks(regularizeSpaces(fragment.slice(index, end)));\n index = end;\n continue;\n }\n const rawStart = index;\n const { name, next } = scanMarkerName(fragment, index + 1);\n index = next;\n // Consume the separator whitespace after an opening marker (PT9 skips it) — all leading\n // whitespace, not just a single space.\n const consumeSeparator = () => {\n while (index < fragment.length && /[\\s\\u00A0\\u200B]/.test(fragment[index]))\n index++;\n };\n if (name === \"\") {\n if (readsAsNamelessMarker(fragment, rawStart, opensNamelessParagraph)) {\n consumeSeparator();\n tokens.push({ kind: \"para\", marker: \"\" });\n continue;\n }\n // Bare `\\` anywhere else — literal (degradation property).\n pushText(fragment.slice(rawStart, index));\n continue;\n }\n if (name === \"*\") {\n // Stray `\\*` with no milestone to close (milestone closes are consumed by\n // scanMilestone): PT9 sink.Unmatched — route through the end-token path so it becomes\n // an `{ type: \"unmatched\", marker: \"*\" }` object, which serializes back to `\\*`.\n tokens.push({ kind: \"end\", marker: \"\" });\n continue;\n }\n if (name.endsWith(\"*\")) {\n if (name.slice(0, -1) === openNoteMarker)\n openNoteMarker = undefined;\n tokens.push({ kind: \"end\", marker: name.slice(0, -1) });\n continue;\n }\n if (name === VERSE_MARKER) {\n const { word, next: afterWord } = getNextWord(fragment, index);\n index = afterWord;\n tokens.push({ kind: \"verse\", number: word });\n continue;\n }\n if (name === CHAPTER_MARKER) {\n const { word, next: afterWord } = getNextWord(fragment, index);\n index = afterWord;\n openNoteMarker = undefined; // PT9 CloseAll: a chapter empties the element stack\n tokens.push({ kind: \"chapter\", number: word });\n continue;\n }\n // Stylesheet-first (PT9: the stylesheet always classifies; our pattern\n // heuristics only stand in for markers ABSENT from the effective sheet).\n const isNested = name.startsWith(\"+\");\n const clean = isNested ? name.slice(1) : name;\n const kind = getMarkerFn(clean)?.type;\n if (kind === MarkerType.Note || (kind === undefined && NoteNode.isValidMarker(name))) {\n const { word, next: afterWord } = getNextWord(fragment, index);\n index = afterWord;\n openNoteMarker = name;\n // ParatextData's reading: the next word, stopping at a `\\`, and an empty caller when there is\n // none (UsxUsfmParserSink.StartNote writes `caller=\"\"`).\n tokens.push({ kind: \"note\", marker: name, caller: word });\n continue;\n }\n if (kind === MarkerType.Milestone || (kind === undefined && isMilestoneHeuristicName(name))) {\n const milestone = scanMilestone(fragment, rawStart, name, index);\n if (milestone) {\n tokens.push(milestone.token);\n if (milestone.ejectedText)\n pushText(milestone.ejectedText);\n index = milestone.next;\n }\n else {\n // Not `\\*`-terminated: keep the raw text through the next `\\` (PT9 behavior).\n const endOfText = fragment.indexOf(\"\\\\\", index);\n const end = endOfText === -1 ? fragment.length : endOfText;\n pushText(fragment.slice(rawStart, end));\n index = end;\n }\n continue;\n }\n if (kind === MarkerType.Paragraph) {\n consumeSeparator();\n tokens.push({ kind: \"para\", marker: name });\n }\n else if (kind === MarkerType.Character) {\n consumeSeparator();\n tokens.push({ kind: \"charOpen\", marker: clean, isNested });\n }\n else if (attributeMarker(clean)) {\n // Attribute markers (ca/cp/va/vp/cat) are parser-level in ParatextData, not stylesheet\n // entries — classify them by their fixed shape when the sheet doesn't know them, so\n // the assembly loop can fold them onto their target (or keep them standalone).\n consumeSeparator();\n if (attributeMarker(clean)?.shape === \"para\")\n tokens.push({ kind: \"para\", marker: name });\n else\n tokens.push({ kind: \"charOpen\", marker: clean, isNested });\n }\n else {\n // Unknown to the effective stylesheet: PT9 resolves by context\n // (DetermineUnknownTokenType): PARAGRAPH in body text, CHARACTER inside\n // a note; `esb`/`esbe` are explicitly paragraphs (UsfmToken.cs:405-421).\n // A non-`+` char run closes any open char style unconditionally, same as\n // a known Character token (UsfmParser.cs:247).\n consumeSeparator();\n const insideNote = isNoteContext || openNoteMarker !== undefined;\n if (!insideNote || name === SIDEBAR_MARKER || name === SIDEBAR_END_MARKER)\n tokens.push({ kind: \"para\", marker: name });\n else\n tokens.push({ kind: \"charOpen\", marker: clean, isNested });\n }\n }\n return tokens;\n}\n/**\n * USFM attribute markers: markers that describe the PREVIOUS marker and become an attribute on\n * it in USX/USJ when they directly follow it (whitespace only between, plain-text content) —\n * `\\c 1 \\ca 2\\ca*` → `chapter{altnumber:\"2\"}`. Standalone occurrences (not adjacent to a\n * supporting target, or carrying markup in their content) stay ordinary markers, exactly as\n * ParatextData emits them. The relation data is parser-level in ParatextData (not in any\n * stylesheet), so it is hardcoded here; `cat` supports two target types — an open note\n * (`f`/`fe`/`x`/`ef`/`efe`/`ex`) and an `esb` sidebar — so `targetTypes` is a list.\n *\n * This table models the PARSER, keyed by USJ node type, deliberately matching ParatextData's\n * fold-at-parse behavior (which is keyed by token TYPE, not by a host-marker list). The markers\n * map in paranext-core (`markers-map-3.0.model.ts`) models the SERIALIZER and keys the same\n * relation by host MARKER NAME. The two agree on every shared fact — the agreement test beside\n * this module (`attributeMarkersMapAgreement.test.ts`) pins that, and pins the keying\n * difference explicitly. Parser-only behaviors (a same-line space before the marker blocks the\n * fold; markup in the content aborts it; an empty span never folds) stay local to this\n * converter and are pinned in its own tests.\n */\nexport const ATTRIBUTE_MARKERS = {\n ca: { attrName: \"altnumber\", targetTypes: [\"chapter\"], shape: \"char\" },\n cp: { attrName: \"pubnumber\", targetTypes: [\"chapter\"], shape: \"para\" },\n va: { attrName: \"altnumber\", targetTypes: [\"verse\"], shape: \"char\" },\n vp: { attrName: \"pubnumber\", targetTypes: [\"verse\"], shape: \"char\" },\n cat: { attrName: \"category\", targetTypes: [\"note\", \"sidebar\"], shape: \"char\" },\n};\n/**\n * The order a target's attribute markers fold in, by USJ node type. ParatextData folds each one\n * ONCE, in this order, from the tokens directly after the target: the Chapter case asks for one\n * `\\ca` and then one `\\cp` (UsfmParser.cs:320-321), the Verse case one `\\va` and then one `\\vp`\n * (:338-339), a note or sidebar one `\\cat` (:378-386, :473-481). A second `\\ca`, or a `\\ca` after\n * the `\\cp`, is left for the parser to process as an ordinary marker, so its bytes stay in the\n * document rather than overwriting the attribute an earlier span set.\n */\nconst ATTRIBUTE_FOLD_ORDER = {\n chapter: [\"ca\", \"cp\"],\n verse: [\"va\", \"vp\"],\n note: [\"cat\"],\n sidebar: [\"cat\"],\n};\n/**\n * The attribute-marker entry for `marker`, or undefined if there is none.\n *\n * Goes through `Object.hasOwn` rather than indexing directly: a marker whose name collides with an\n * `Object.prototype` member (`\\toString`, `\\constructor`) would otherwise resolve to the inherited\n * function and read as a declared attribute marker.\n */\nfunction attributeMarker(marker) {\n return Object.hasOwn(ATTRIBUTE_MARKERS, marker) ? ATTRIBUTE_MARKERS[marker] : undefined;\n}\n/**\n * Whether `marker` is one this parser folds onto a host node ({@link ATTRIBUTE_MARKERS}).\n *\n * The distinction a stylesheet cannot make: an attribute marker's round trip is defined by this\n * table, not by usfm.sty, so the tokenizer re-derives one whether or not the stylesheet declares\n * it. `\\cat` is the case that matters — it is the only attribute marker usfm.sty omits, so a\n * stylesheet-keyed \"can the engine re-derive this span?\" test is the one place the two records\n * disagree, and it reads `\\cat` as an unknown custom marker.\n */\nexport function isAttributeMarker(marker) {\n return attributeMarker(marker) !== undefined;\n}\nconst ATTRIBUTE_PAIR_REGEX = /([-\\w]+)\\s*=\\s*\"(.*?)\"/g;\n/**\n * Whitespace run containing a line break, inside attribute text. ParatextData regularizes\n * text BEFORE attribute parsing ever sees it (`UsfmToken.Tokenize` calls `RegularizeSpaces`\n * — control whitespace becomes deduplicated plain spaces — and only then hands the text to\n * `HandleAttributes`), so a line break inside an attribute span reaches its `.*?`-based\n * value pattern as a plain space, never as a newline. Milestone and figure attribute text\n * here is sliced from the raw fragment (or still carries the collapsed `\"\\n\"` run marker),\n * so the same normalization must run before matching — without it the value capture (`.`\n * never matches a line terminator) fails on a wrapped value and the whole string would\n * leak into the default attribute.\n */\nconst ATTRIBUTE_LINE_BREAK_RUN_REGEX = /[\\s\\u200B]*[\\n\\r][\\s\\u200B]*/g;\n/**\n * USFM 3 default attribute per marker (subset; unmapped bare values stay literal).\n *\n * `xt`/`jmp` use the USFM/USX/USJ **3.0** name `link-href`: this pipeline pins USJ 3.0 (chapter\n * data round-trips through ParatextData, and the host downgrades 3.1), and every 3.0 consumer —\n * ParatextData serialization, checks, link handling — reads `link-href`. USFM 3.1 renamed it to\n * `href`; switch these when the pipeline moves to 3.1.\n */\nconst DEFAULT_MARKER_ATTRIBUTES = {\n w: \"lemma\",\n rb: \"gloss\",\n xt: \"link-href\",\n jmp: \"link-href\",\n};\n/**\n * Character marker default attribute lookup for USFM 3 (shared with display builders).\n * Returns the default attribute name for a given character marker, or undefined if the marker\n * has no default attribute.\n */\nexport function defaultMarkerAttribute(marker) {\n return DEFAULT_MARKER_ATTRIBUTES[marker];\n}\n/**\n * USJ structural keys that a parsed attribute may never overwrite: the callers merge parsed\n * attributes straight onto the node object (`Object.assign` / spread), so an attribute literally\n * named `type`, `marker`, or `content` would clobber the node's own identity or replace its\n * content array with a string. Such attributes are dropped.\n */\nconst RESERVED_NODE_KEYS = new Set([\"type\", \"marker\", \"content\"]);\n/**\n * Whether `pairs` consume all of `text` apart from whitespace — i.e. the attribute list parsed\n * completely rather than partly. Each match must start where the previous one ended (whitespace\n * aside), and the last must reach the end.\n */\nfunction pairsCoverList(text, pairs) {\n let cursor = 0;\n for (const pair of pairs) {\n const start = pair.index;\n if (start === undefined)\n return false;\n if (text.slice(cursor, start).trim() !== \"\")\n return false;\n cursor = start + pair[0].length;\n }\n return text.slice(cursor).trim() === \"\";\n}\nfunction parseAttributeText(attributeText, marker, defaultAttributeName = DEFAULT_MARKER_ATTRIBUTES[marker]) {\n const regularizedText = attributeText.replace(ATTRIBUTE_LINE_BREAK_RUN_REGEX, \" \");\n // Null-prototype accumulator: on a plain `{}`, `attributes[\"__proto__\"] = value` hits\n // Object.prototype's accessor and is a silent no-op, so an attribute literally named\n // `__proto__` would parse successfully and lose its pair. An own property on a null-prototype\n // object survives spread and JSON like any other key.\n const attributes = Object.create(null);\n const pairs = [...regularizedText.matchAll(ATTRIBUTE_PAIR_REGEX)];\n if (pairs.length > 0) {\n // The pairs must account for the WHOLE list, with nothing but whitespace between and after\n // them. The regex is global, so without this it happily skips over anything it cannot match:\n // `gloss=\"st\"uff\"` matched `gloss=\"st\"` and the leftover `uff\"` vanished, taking bytes the\n // author wrote and could see. USFM has no way to escape a quote inside a value, so such a list\n // is genuinely ambiguous and there is no reading of it to salvage — refusing the whole list\n // hands it back to the caller, which keeps it as literal text (`extractAttributes`). That is\n // Paratext 9's behavior, and the only lossless one: every byte stays on screen and in the file,\n // where the author can see what is wrong and fix it.\n if (!pairsCoverList(regularizedText, pairs))\n return undefined;\n // An EMPTY value refuses the whole list too, matching Paratext 9. `|who=\"\"` is not a reading\n // Paratext will ever agree with, so parsing it here would make the editor the only thing in the\n // pipeline that believes the attribute exists — and the byte the author actually wrote is the\n // literal text, which the refusal keeps. Note this is the opposite call from the USJ side, where\n // an empty value arriving as real state is honoured and written out; there it is unambiguous\n // data, here it is bytes Paratext reads as text.\n if (pairs.some((pair) => pair[2] === \"\"))\n return undefined;\n for (const [, name, value] of pairs) {\n if (!RESERVED_NODE_KEYS.has(name))\n attributes[name] = value;\n }\n return Object.keys(attributes).length > 0 ? attributes : undefined;\n }\n // Bare (default-attribute) value: keep it byte-exact (past the line-break regularization\n // above), whitespace included — ParatextData treats the space before the closing marker as\n // part of the value (`\\w marker|stuff \\w*` → lemma=\"stuff \"; `\\qt-s |TJ \\*` → who=\"TJ \").\n // The USFM 3 spec calls that space structural, but Paratext keeps it as content, and this\n // pipeline round-trips through ParatextData.\n if (regularizedText.trim() && defaultAttributeName)\n return { [defaultAttributeName]: regularizedText };\n return undefined;\n}\n/**\n * Default attribute for stylesheet-family milestone names (USFM 3.0): quotation starts take\n * `who`, every `-e` end takes `eid`, and other starts (`\\ts-s`, comment markers) take `sid`.\n */\nexport function milestoneDefaultAttribute(name) {\n if (name.endsWith(\"-e\"))\n return \"eid\";\n return name.startsWith(\"qt\") ? \"who\" : \"sid\";\n}\n/**\n * Whether re-tokenizing `text` would EJECT bytes out of a milestone — the shapes where a milestone\n * ends early and content it cannot hold follows it as a sibling, leaving the author's `\\*`\n * unmatched.\n *\n * Answered by running the real tokenizer rather than re-deriving the conditions, so it cannot drift\n * from {@link scanMilestone}. Callers use this to defer such a rebuild to the settle instead of\n * applying it mid-keystroke, because ejection MOVES bytes and doing that under the caret rearranges\n * the line the user is still typing on. Only ejection earns that deferral: a well-formed milestone\n * rearranges nothing and applies where it stands, the instant its `\\*` is typed.\n *\n * The ejected shape is BOTH halves together — content immediately after the milestone AND the\n * author's own `\\*` stranded past that content as an unmatched closing marker. Asking only for\n * the first half counts ordinary body text following a well-formed milestone, which is the common\n * case and not an ejection at all; the leftover unmatched `\\*` is the observable that tells the\n * two apart. The content run may tokenize into several items (an ejected list containing `//`\n * splits around an optbreak), so the closer is looked for anywhere past it rather than adjacent.\n */\nexport function milestoneEjectionPending(text) {\n const content = usfmFragmentToUsjContent(text)[0];\n const items = typeof content === \"object\" && \"content\" in content ? content.content : undefined;\n if (!items)\n return false;\n return items.some((item, index) => {\n if (typeof item !== \"object\" || item.type !== \"ms\")\n return false;\n if (typeof items[index + 1] !== \"string\")\n return false;\n return items\n .slice(index + 2)\n .some((later) => typeof later !== \"string\" && later.type === \"unmatched\" && later.marker === \"*\");\n });\n}\n/**\n * An attribute list sitting AFTER a closed milestone that belongs back INSIDE it — the shape\n * ejection leaves behind once the author repairs the bytes. `\\qt1-s\\*|who=\"person\"\\*` reads as\n * the milestone the author meant, `\\qt1-s |who=\"person\"\\*`.\n *\n * Two conditions, and both are load-bearing.\n *\n * The author's own trailing `\\*` is what marks the run as a milestone's list rather than body\n * text: content that merely begins with `|` has no closer after it, so this can never quietly eat\n * ordinary bytes. Whitespace between the milestone's closer and the `|` is tolerated — it is the\n * separator the author would have typed inside the milestone anyway.\n *\n * The list must PARSE, and that is what keeps absorption and ejection from chasing each other.\n * Ejection puts an unparseable list OUTSIDE the milestone ({@link scanMilestone}); absorbing one\n * back in would produce bytes that eject again, and the two would trade the same run forever.\n * `|who=\"\"` does not parse, so the ejected spelling stays ejected and the pair terminates.\n *\n * Returns the parsed list and where scanning resumes (past its `\\*`), or undefined for every\n * shape that is not this one.\n */\nfunction scanAbsorbableAttributes(fragment, start, name) {\n let index = start;\n while (index < fragment.length && /[\\s\\u00A0\\u200B]/.test(fragment[index]))\n index++;\n if (fragment[index] !== \"|\")\n return undefined;\n const closeIndex = fragment.indexOf(\"\\\\\", index);\n if (closeIndex === -1 || fragment.slice(closeIndex, closeIndex + 2) !== \"\\\\*\")\n return undefined;\n const attributes = parseAttributeText(fragment.slice(index + 1, closeIndex), name, milestoneDefaultAttribute(name));\n if (!attributes)\n return undefined;\n return { attributes, next: closeIndex + 2 };\n}\n/**\n * A milestone must be terminated by `\\*` (PT9 `MilestoneEnded`); attributes may\n * follow a `|` between the marker and the `\\*`.\n */\nfunction scanMilestone(fragment, _rawStart, name, index) {\n const closeIndex = fragment.indexOf(\"\\\\\", index);\n if (closeIndex === -1 || fragment.slice(closeIndex, closeIndex + 2) !== \"\\\\*\")\n return undefined;\n // Slices up to the FIRST backslash at or after `index`, so `between` cannot contain one: the\n // milestone's attribute region ends at whatever markup follows it.\n const between = fragment.slice(index, closeIndex);\n const pipeIndex = between.indexOf(\"|\");\n let attributes;\n if (pipeIndex >= 0) {\n attributes = parseAttributeText(between.slice(pipeIndex + 1), name, milestoneDefaultAttribute(name));\n // A list with CONTENT that will not parse becomes CONTENT, and a milestone cannot hold\n // content — so the milestone ends immediately and the bytes follow it as siblings. Resuming\n // the scan at the `|` is what produces that: the milestone token closes here, the unparsed\n // bytes are read as ordinary text, and the author's `\\*` is left to scan as an unmatched\n // closing marker. `\\qt1-s |who=\"\"\\*` therefore reads exactly as `\\qt1-s\\*|who=\"\"\\*` already\n // does — a closed milestone, the literal text, and one unmatched `\\*` — which is Paratext 9's\n // reading and keeps every byte.\n //\n // Refusing the whole token instead would lose the milestone the author did write, and building\n // it while dropping the attribute bytes would lose those; this loses neither. A bare `|` with\n // nothing after it is not this case — there are no bytes to keep, and dropping it is the\n // ratified answer for a `|` typed into a milestone glyph.\n if (!attributes && between.slice(pipeIndex + 1).trim() !== \"\") {\n // Content BEFORE the `|` is ejected here too, for the same reason the valid-attribute path\n // below ejects it: it is bytes the milestone cannot hold, and resuming the scan at the `|`\n // would skip straight past it. `\\\\qt1-s things|who=\"\"\\\\*` keeps `things` as a sibling\n // rather than deleting it, and still converges — re-tokenizing the ejected spelling\n // `\\\\qt1-s\\\\*things|who=\"\"\\\\*` reaches the same tree.\n const beforePipe = between.slice(0, pipeIndex);\n return {\n token: { kind: \"milestone\", marker: name },\n next: index + pipeIndex,\n ejectedText: beforePipe.trim() !== \"\" ? beforePipe.replace(/^[ \\u00A0]/, \"\") : undefined,\n };\n }\n }\n // Content a milestone cannot hold — the bytes before a valid attribute list, or, when there is\n // no `|` at all, everything between the marker and the closer. A milestone is self-closing, so\n // it ENDS where that content begins: the content follows it as a sibling, and the author's `\\*`\n // is left to scan as an unmatched closing marker. Valid attributes stay, because they are\n // genuinely the milestone's own; only what it cannot hold moves.\n //\n // That is what ParatextData writes to disk — `\\qt1-s stuff\\*` is saved as `\\qt1-s\\*stuff\\*` —\n // so the two spellings must tokenize IDENTICALLY for a reload to be a fixed point. Reading the\n // stray content as literal text instead dissolves the milestone the author did write, leaving\n // the editor disagreeing with the file.\n //\n // Resuming at `closeIndex` is what leaves the `\\*` unmatched, and the leading separator space\n // belongs to the marker rather than the content, so it goes with the marker.\n const ejected = pipeIndex >= 0 ? between.slice(0, pipeIndex) : between;\n if (ejected.trim() !== \"\")\n return {\n token: { kind: \"milestone\", marker: name, attributes },\n next: closeIndex,\n ejectedText: ejected.replace(/^[ \\u00A0]/, \"\"),\n };\n // A repaired attribute list left sitting past the closer folds back in, its values overwriting\n // any the milestone already carries: the list the author just fixed is the one they mean. Only\n // the clean path absorbs: when content was ejected above, the `\\*` is deliberately left to scan\n // as an unmatched closer, so there is no \"past the closer\" position to absorb from.\n const absorbed = scanAbsorbableAttributes(fragment, closeIndex + 2, name);\n if (absorbed)\n return {\n token: {\n kind: \"milestone\",\n marker: name,\n attributes: { ...attributes, ...absorbed.attributes },\n },\n next: absorbed.next,\n };\n return { token: { kind: \"milestone\", marker: name, attributes }, next: closeIndex + 2 };\n}\n/** Convert `~` to NBSP for USJ text content (PT9 read-side `UsfmParser` behavior), and\n * normalize the line-break marker `regularizeSpaces` preserved back to a plain space. */\nfunction toUsjText(text) {\n return text.replaceAll(\"\\n\", \" \").replaceAll(\"~\", NBSP);\n}\n/** Get (and lazily initialize) a marker object's content array without a non-null assertion. */\nfunction getContent(object) {\n if (!object.content)\n object.content = [];\n return object.content;\n}\nexport function usfmFragmentToUsjContent(fragment, options) {\n const result = [];\n const isNoteContext = options?.isNoteContext ?? false;\n let para;\n let note;\n const charStack = [];\n // Char-stack depth at the moment the open note started: frames BELOW it enclose the note\n // (USX nests the note inside them and the span continues after it — `\\wj a \\f …\\f* b\\wj*`\n // puts both the note and \" b\" inside the wj span); frames AT/ABOVE it were opened inside\n // the note's content and close with it. Only meaningful while `note` is set.\n let noteBaseDepth = 0;\n // ---- opaque-structure state (tables, sidebars) ----\n // Current open table and its open row. `\\tr` creates both (consecutive rows share one\n // table); a cell marker then points `para` at the cell object, so ALL ordinary content\n // handling (text, char spans, notes, verses) lands inside the cell unchanged. While the\n // table is open, `para` is always its open row or a cell of that row.\n let table;\n let tableRow;\n // Current open sidebar: `\\esb`…`\\esbe` wraps subsequent top-level blocks (paragraphs and\n // tables). Implicit close (fragment end or a chapter token) marks it closed=\"false\" —\n // ParatextData auto-closes sidebars at the chapter boundary.\n let sidebar;\n // Current open peripheral division: `\\periph` opens one and takes every following block into\n // it. Nothing closes a division but the next `\\periph`, a chapter boundary, or the end of the\n // fragment — USFM gives a division marker no closing bytes at all, so unlike a sidebar there is\n // no terminated/implicit distinction to record. The marker LINE's own text (the division title\n // and its attribute list) is captured first; see `periphCapture`.\n let periph;\n /** Where top-level blocks (paragraphs, tables) land: an open sidebar's content, else an open\n * peripheral division's content, else the fragment result. */\n const blockTarget = () => {\n if (sidebar)\n return getContent(sidebar);\n if (periph)\n return getContent(periph);\n return result;\n };\n // True between a chapter token and the next opened block: loose content there sits at the\n // DOCUMENT ROOT in ParatextData's output, not in an implied paragraph — text typed after\n // `\\c 1` saves as its own ` text` line, and 2SA-2's unclosed `\\ca` strands a root char.\n // Fragment-LEADING bare content keeps the implied-`\\p` wrap (the note-content rebuild\n // depends on unwrapping it), so this is scoped to post-chapter position only.\n let atChapterRootScope = false;\n const container = () => {\n if (note) {\n // Inside the note, only frames opened WITHIN it receive content; the enclosing\n // frames are suspended until the note closes.\n if (charStack.length > noteBaseDepth)\n return getContent(charStack[charStack.length - 1].object);\n return getContent(note);\n }\n if (charStack.length > 0)\n return getContent(charStack[charStack.length - 1].object);\n if (!para) {\n if (atChapterRootScope && !isNoteContext)\n return blockTarget();\n para = { type: \"para\", marker: PARA_MARKER_DEFAULT, content: [] };\n blockTarget().push(para);\n }\n return getContent(para);\n };\n const pushContent = (item) => {\n const target = container();\n if (typeof item === \"string\" && typeof target[target.length - 1] === \"string\") {\n target[target.length - 1] = target[target.length - 1] + item;\n }\n else {\n target.push(item);\n }\n };\n // Implicit close: every still-open char span gets closed=\"false\", mirroring ParatextData\n // (a span only stays unmarked when the user's own `\\marker*` terminated it).\n const markImplicitlyClosed = (fromIndex) => {\n for (let i = fromIndex; i < charStack.length; i += 1) {\n const object = charStack[i].object;\n object.closed = \"false\";\n }\n };\n const closeCharStack = () => {\n markImplicitlyClosed(0);\n charStack.length = 0;\n };\n const closeNote = (terminated) => {\n if (!note)\n return;\n // Chars opened INSIDE the note close with it (implicitly); frames below the note\n // boundary survive — the enclosing span continues after the note.\n if (charStack.length > noteBaseDepth) {\n markImplicitlyClosed(noteBaseDepth);\n charStack.length = noteBaseDepth;\n }\n noteBaseDepth = 0;\n if (!terminated)\n note.closed = \"false\";\n note = undefined;\n };\n // Tables have no closing marker and no `closed` metadata: the table object is already in\n // place, so ending one just drops the open-row state — rows/cells never resume.\n const endTable = () => {\n table = undefined;\n tableRow = undefined;\n };\n /**\n * Open a cell in the current row and make it the content container: text, char spans, notes and\n * verses then flow into it through the ordinary `para`-based container logic. Shared by both\n * token kinds a cell marker can arrive as — a stylesheet that knows `\\th1`/`\\tc1` classifies\n * them as Character (usfm.sty does), one that does not delivers them as unknown paragraph\n * markers, and ParatextData derives a cell from the NAME either way.\n */\n const pushTableCell = (row, marker, cellMatch) => {\n closeCharStack();\n const [, alignInfix, spanStart, spanEnd] = cellMatch;\n // The cell keeps only the starting column in its marker (`thc3-4` → `thc3`); the span width\n // becomes `colspan`, a string of columns spanned (`thc3-4` → \"2\").\n const cell = {\n type: \"table:cell\",\n marker: spanEnd ? marker.slice(0, marker.indexOf(\"-\")) : marker,\n align: TABLE_CELL_ALIGN_BY_INFIX[alignInfix],\n content: [],\n };\n if (spanEnd)\n cell.colspan = String(Number(spanEnd) + 1 - Number(spanStart));\n getContent(row).push(cell);\n para = cell;\n };\n const closeSidebar = (terminated) => {\n if (!sidebar)\n return;\n // Only `\\esbe` terminates a sidebar explicitly; an implicit close (fragment end or a\n // chapter boundary) gets closed=\"false\", mirroring ParatextData's auto-close.\n if (!terminated)\n sidebar.closed = \"false\";\n sidebar = undefined;\n };\n /** End the open division. Nothing to record: a division has no closing bytes to be missing. */\n const closePeriph = () => {\n periph = undefined;\n };\n // ---- attribute-marker folding state (see ATTRIBUTE_MARKERS) ----\n // The most recent chapter/verse/note object, still \"receptive\": an adjacent attribute\n // marker folds onto it as an attribute. Any real content clears it.\n let attrTarget;\n // How far through its target's fold order (`ATTRIBUTE_FOLD_ORDER`) the receptive window has\n // folded: each attribute marker folds once, and only after the ones before it.\n let attrFoldedThrough = -1;\n /** Open the receptive window on `target`, which has folded nothing yet. */\n const receiveAttributes = (target) => {\n attrTarget = target;\n attrFoldedThrough = -1;\n };\n // Whitespace-only text held while attrTarget is receptive: structural (dropped) if an\n // attribute marker follows; ordinary content (flushed) otherwise.\n let heldWhitespace = \"\";\n // An attribute-marker span currently being captured for folding. Aborts to a standalone\n // marker the moment its content turns out to be markup, exactly as ParatextData keeps a\n // `\\cat` with markup or a `\\cp` with markers as its own marker.\n let attrCapture;\n const flushHeldWhitespace = () => {\n if (heldWhitespace)\n pushContent(toUsjText(heldWhitespace));\n heldWhitespace = \"\";\n };\n const clearAttrTarget = (atBlockBoundary = false) => {\n // Line-end whitespace held while a SIDEBAR was receptive is structural: sidebar content\n // is block-level (paragraphs and tables), so the line break between `\\esb`/`\\cat` and\n // the first block never becomes text — ParatextData emits none there. Held whitespace\n // for the other targets (chapter/verse/note) flushes as content, EXCEPT its trailing\n // line break at a block boundary: ParatextData strips the space a line break leaves\n // behind when the next token is a paragraph/book/chapter (UsfmParser's Text case,\n // \"strip final space\"), so `\\c 1` ⏎ `\\ca 2\\ca*` ⏎ `\\p` puts no stray text at the root.\n // Before an INLINE token the space survives — a `\\cat` fold followed by `\\ft` keeps its\n // space inside the note.\n if (attrTarget?.type === \"sidebar\")\n heldWhitespace = \"\";\n else if (atBlockBoundary && heldWhitespace.endsWith(\"\\n\"))\n heldWhitespace = heldWhitespace.slice(0, -1);\n attrTarget = undefined;\n flushHeldWhitespace();\n };\n /** Abort a char-shaped capture: materialize the standalone open span (frame stays open —\n * nested markup and the eventual closer process normally). */\n const materializeCaptureAsChar = () => {\n if (!attrCapture)\n return;\n const object = { type: \"char\", marker: attrCapture.marker, content: [] };\n if (attrCapture.value)\n object.content = [toUsjText(attrCapture.value)];\n container().push(object);\n charStack.push({ object });\n attrCapture = undefined;\n };\n /** Start an ordinary paragraph block. Any non-row/cell paragraph-kind marker also ends an\n * open table — ParatextData never resumes a table across another block. */\n const startParagraph = (marker, initialText) => {\n atChapterRootScope = false;\n endTable();\n closeCharStack();\n closeNote(false);\n para = { type: \"para\", marker, content: [] };\n if (initialText)\n para.content = [toUsjText(initialText)];\n blockTarget().push(para);\n };\n /** Abort a para-shaped capture (`\\cp` with markup): materialize the standalone paragraph. */\n const materializeCaptureAsPara = () => {\n if (!attrCapture)\n return;\n startParagraph(attrCapture.marker, attrCapture.value);\n attrCapture = undefined;\n };\n // ---- peripheral-division capture state ----\n // The text of a `\\periph` marker line, collected between the marker and the next marker token.\n // `\\periph` has no closing bytes, so the next marker is the only thing that ends the line —\n // the same delimiter whether a USFM writer put the division on its own line or a copy laid the\n // whole construct out on one (a line break is ordinary whitespace to a tokenizer). That is what\n // lets a Tier-2 rebuild, which only ever re-tokenizes a single paragraph's bytes, reassemble a\n // whole division from one fragment.\n let periphCapture;\n /**\n * Close the captured marker line and open the division it describes: everything before the\n * line's first `|` is the division title (USX/USJ's `alt`), the rest an ordinary named-attribute\n * list.\n *\n * A list that does not parse is REFUSED, and so is one that spells the TITLE a second time\n * (`alt`, alongside a non-empty marker-line title): the two spellings are the same USJ property,\n * there is no reading that keeps both, and picking one would silently destroy bytes the author\n * can still see. `alt` on a TITLELESS line collides with nothing and is read normally. The editor\n * can never author the colliding shape — periph's display renders `alt` AS the marker-line title\n * (`unknownUsfm.utils.ts`), never as a pipe pair.\n *\n * Refusing the list does NOT refuse the division. `\\periph` opens a peripheral division for its\n * own sake — it has no closing marker and nothing else delimits it, so the division's extent is\n * a property of the marker, not of its attributes. Paratext 9 reads it the same way: a failed\n * `SetAttributes` leaves the marker-line text alone (`ParatextData/UsfmToken.cs`) and the USX\n * writer still opens `` for any `\\periph` token, with an empty `id`\n * (`ParatextData/UsxUsfmParserSink.cs`). Demoting the division to an ordinary paragraph would\n * re-parent every block it contained up to the root instead. The refused bytes survive as the\n * division's own title, where the author can still see and fix them, and they serialize back\n * byte-for-byte (`alt` renders as literal marker content, not a pipe pair).\n *\n * @param atBlockBoundary - Whether the token that ended the line starts a new block (or the\n * fragment ended). The line's trailing line break is structural there, the same rule the text\n * case applies: the line ends where the next block marker begins, and ParatextData emits no\n * content for it.\n */\n const finishPeriphLine = (atBlockBoundary) => {\n if (!periphCapture)\n return;\n let { value } = periphCapture;\n periphCapture = undefined;\n if (atBlockBoundary && value.endsWith(\"\\n\"))\n value = value.slice(0, -1);\n const pipeIndex = value.indexOf(\"|\");\n const parsed = pipeIndex >= 0 ? parseAttributeText(value.slice(pipeIndex + 1), PERIPH_MARKER) : undefined;\n const parsedTitle = pipeIndex >= 0 ? value.slice(0, pipeIndex) : value;\n const refused = pipeIndex >= 0 && (!parsed || (!!parsedTitle && !!parsed[PERIPH_TITLE_ATTRIBUTE]));\n const attributes = refused ? undefined : parsed;\n const title = refused ? value : parsedTitle;\n const opened = {\n type: \"periph\",\n ...(title ? { [PERIPH_TITLE_ATTRIBUTE]: toUsjText(title) } : {}),\n ...attributes,\n };\n opened.content = [];\n // Landed BEFORE `periph` is set, for the same reason the sidebar assembly does it: an already\n // open division would otherwise take the new one into its own content.\n blockTarget().push(opened);\n periph = opened;\n para = undefined;\n };\n // ---- figure capture state ----\n // A `\\fig …\\fig*` span being collected for faithful `figure` emission (ParatextData turns\n // the span into `{ type: \"figure\", … }`). Only a clean span folds: plain-text content with\n // `name=\"value\"` attributes and an explicit `\\fig*`. Anything else — nested markup, USFM\n // 2.0 positional attributes, no closer — degrades to exactly what the marker's own\n // classification produced before figure support (a char span or an unknown paragraph).\n let figCapture;\n /** Degrade an unfoldable figure span: a char frame (stays open — the eventual closer or\n * auto-close processes normally) or an unknown paragraph, matching pre-figure output. */\n const materializeFigCapture = () => {\n if (!figCapture)\n return;\n if (figCapture.shape === \"para\") {\n startParagraph(FIGURE_MARKER, figCapture.value);\n }\n else {\n const object = { type: \"char\", marker: FIGURE_MARKER, content: [] };\n if (figCapture.value)\n object.content = [toUsjText(figCapture.value)];\n container().push(object);\n charStack.push({ object });\n }\n figCapture = undefined;\n };\n const tokens = tokenize(fragment, options?.getMarker ?? getMarker, isNoteContext, options?.placeholders ?? [], !isNoteContext && options?.opensNamelessParagraph === true);\n for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {\n const token = tokens[tokenIndex];\n if (attrCapture) {\n if (token.kind === \"text\") {\n attrCapture.value += token.text;\n continue;\n }\n if (attrCapture.shape === \"char\" &&\n token.kind === \"end\" &&\n token.marker.replace(/^\\+/, \"\") === attrCapture.marker) {\n // The fold to an attribute requires NON-EMPTY content (PT9\n // `FindOtherVerseOrChapterNumber` folds only when `tokens[+2].Text != null`, and its\n // tokenizer never produces an empty text token). An EMPTY span (any spelling —\n // `\\va \\va*`, `\\va\\va*`, `\\va \\va*`) is NEVER an empty attribute: it stays a\n // first-class, explicitly-closed char element sitting after its target. The closer is\n // consumed here (no open frame is pushed), so the span is closed with no `closed`\n // metadata, exactly like any user-closed span.\n if (attrCapture.value.trim() === \"\") {\n container().push({ type: \"char\", marker: attrCapture.marker, content: [] });\n attrCapture = undefined;\n // The materialized element is REAL CONTENT, so the target stops being receptive — the\n // same rule a plain-text token applies through `clearAttrTarget` above. Without this, a\n // following attribute marker folded ACROSS the element now separating it from its target\n // (`\\v 11 \\va\\va*\\vp 11 vp\\vp*` put `pubnumber` on the verse while the `\\va` char trailed\n // behind it), and USJ cannot express that order: serializing back put the published\n // number FIRST, silently rewriting the document as `\\v 11 \\vp 11 vp\\vp*\\va \\va*`.\n // ParatextData folds NEITHER marker here — captured from `GetChapterUsx`, it emits\n // `11 vp` in document order.\n clearAttrTarget();\n continue;\n }\n // Explicit close with plain-text content: fold as the target's attribute, TRIMMED —\n // ParatextData trims every folded value (`FindOtherVerseOrChapterNumber` reads\n // `tokens[index + skip + 2].Text.Trim()`, and the note/sidebar category lookups do\n // `tokens[index + 2].Text.Trim()`), so `\\ca 2 \\ca*` yields altnumber \"2\". Any space\n // AFTER the closer is content, not structural — Paratext keeps it in the text\n // (`\\vp 11 vp\\vp* This…` → text starts with the space), per its\n // treat-space-after-attribute-markers-as-content behavior.\n Object.assign(attrCapture.target, {\n [attrCapture.attrName]: toUsjText(attrCapture.value.trim()),\n });\n const foldedMarker = attrCapture.marker;\n attrCapture = undefined;\n // The chapter path alone consumes ONE whitespace-only token after a successful fold,\n // unconditionally — not gated on a `\\cp` following — so a same-line space between\n // `\\ca*` and `\\cp` is structural and `\\cp` still folds, and the space before an\n // ordinary char span vanishes too. The verse path has no such skip: the identical\n // space between `\\va*` and `\\vp` BLOCKS the `\\vp` fold (the v12 rule). Both sides are\n // captured through ParatextData in paranext-core's\n // VerseAttributeFoldRoundTripCaptureTests (`FilledCaThenCp_BothFold`,\n // `SpaceAfterFoldedCa_IsConsumedEvenWithoutCp`,\n // `SpaceBetweenVaCloserAndVp_BlocksVpFold_SpaceIsContent`).\n if (foldedMarker === \"ca\") {\n const next = tokens[tokenIndex + 1];\n if (next?.kind === \"text\" && /^[\\s\\u200B]*$/.test(next.text))\n tokenIndex++;\n }\n continue;\n }\n if (attrCapture.shape === \"para\" && (token.kind === \"para\" || token.kind === \"chapter\")) {\n const cpValue = attrCapture.value.replace(/[\\s\\u200B]+$/, \"\");\n if (cpValue === \"\") {\n // Empty `\\cp` (paragraph-shaped, no end marker): PT9 never yields an empty pubnumber \\u2014\n // it stays a first-class (empty) para element. Materialize the standalone paragraph\n // with no content, then fall through to process the boundary token normally.\n //\n // Unlike the char-shaped empty branch above, this one deliberately does NOT clear\n // `attrTarget` (`startParagraph` leaves it alone), so the receptive window survives a\n // materialized empty `\\cp`. That is audited, not overlooked, on two counts.\n //\n // A CHAR-shaped attribute marker cannot reach the surviving window at all, so the\n // document-order rewrite the char branch closes has no para-shaped twin. This branch only\n // runs when the token that ENDS the capture is a para/chapter boundary; `\\ca` is\n // char-shaped, so it arrives while the capture is still open and falls to the\n // unfoldable-markup arm below, which clears `attrTarget` BEFORE materializing the\n // paragraph. `\\c 1` \\u23ce `\\cp ` \\u23ce `\\ca 2\\ca*` \\u23ce `\\p body` therefore leaves the chapter with\n // no altnumber and the `\\ca` an ordinary char span (pinned in usfmFragmentToUsj.test.ts).\n //\n // What DOES re-enter the window is a foldable PARA token, and `cp` is the only\n // `shape: \"para\"` attribute marker \\u2014 so that means a degenerate duplicate `\\cp` on one\n // chapter. It does not fold: the empty span was the chapter's one `\\cp`\n // (`ATTRIBUTE_FOLD_ORDER`), and ParatextData folds neither of the two.\n startParagraph(attrCapture.marker);\n attrCapture = undefined;\n }\n else {\n // The cp \"paragraph\" ended with plain-text content only: fold (trailing line\n // whitespace is structural).\n Object.assign(attrCapture.target, { [attrCapture.attrName]: toUsjText(cpValue) });\n attrCapture = undefined;\n }\n // fall through to process the boundary token normally\n }\n else {\n // Markup inside the span (or a mismatched closer): not foldable — materialize the\n // standalone marker, then reprocess this token normally. A trailing line break in the\n // captured value before a BLOCK boundary is structural, same as the text-case rule\n // (`\\ca 2 ca` ⏎ `\\cp` materializes content \"2 ca\", not \"2 ca \").\n attrTarget = undefined;\n if ((token.kind === \"para\" || token.kind === \"chapter\") && attrCapture.value.endsWith(\"\\n\"))\n attrCapture.value = attrCapture.value.slice(0, -1);\n if (attrCapture.shape === \"para\")\n materializeCaptureAsPara();\n else\n materializeCaptureAsChar();\n tokenIndex--;\n continue;\n }\n }\n if (periphCapture) {\n // The marker line runs to the next marker token. An optbreak rejoins as the literal `//`\n // the author typed, for the same reason the figure capture rejoins one: `//` inside an\n // attribute value (a URL, say) is plain value bytes to ParatextData, which strips the\n // attribute segment out at tokenize-time before its `//` pass ever runs.\n if (token.kind === \"text\" || token.kind === \"optbreak\") {\n periphCapture.value += token.kind === \"text\" ? token.text : \"//\";\n continue;\n }\n finishPeriphLine(token.kind === \"para\" || token.kind === \"chapter\");\n tokenIndex--;\n continue;\n }\n if (figCapture) {\n if (token.kind === \"text\" || token.kind === \"optbreak\") {\n // The tokenizer splits `//` into optbreak tokens spec-blind — including inside what\n // will become the `|attributes` segment, where ParatextData treats `//` as plain\n // value bytes (`UsfmToken.HandleAttributes` strips the segment out of the text run at\n // tokenize-time, before the parser's `//`→optbreak pass ever runs), so an attribute\n // value carrying a URL must reach `parseAttributeText` below byte-exact. Rejoining\n // every optbreak here (not just post-`|` ones) is safe: a clean figure's description\n // already folds to one flat string with no discretionary-break fidelity of its own\n // (see the `figure.content` assembly below and `materializeFigCapture`'s degrade\n // path), so a pre-`|` `//` landing back as literal text is no regression.\n //\n // This deliberately duplicates `extractAttributes`' optbreak→`//` byte mapping rather\n // than sharing a helper: that function rejoins an already-ASSEMBLED content array\n // post-hoc (strings and `{type:\"optbreak\"}` objects), while this path rejoins the token\n // STREAM as it arrives into a plain string accumulator — the two operate on different\n // shapes at different pipeline stages, and the shared knowledge is just the single\n // byte fact that an optbreak was a literal `//`.\n figCapture.value += token.kind === \"text\" ? token.text : \"//\";\n continue;\n }\n if (token.kind === \"end\" && token.marker.replace(/^\\+/, \"\") === FIGURE_MARKER) {\n const pipeIndex = figCapture.value.indexOf(\"|\");\n const attributes = pipeIndex >= 0\n ? parseAttributeText(figCapture.value.slice(pipeIndex + 1), FIGURE_MARKER)\n : undefined;\n if (attributes) {\n // Clean span: emit the faithful figure. USFM's `src` attribute is `file` in\n // USX/USJ (renamed in place to keep the author's attribute order); the pre-`|`\n // description is the figure's content, omitted when empty (as ParatextData does).\n const figureAttributes = {};\n for (const [name, value] of Object.entries(attributes))\n figureAttributes[name === \"src\" ? \"file\" : name] = value;\n const figure = {\n type: \"figure\",\n marker: FIGURE_MARKER,\n ...figureAttributes,\n };\n const description = figCapture.value.slice(0, pipeIndex);\n if (description)\n figure.content = [toUsjText(description)];\n pushContent(figure);\n figCapture = undefined;\n continue;\n }\n // No `name=\"value\"` attributes (USFM 2.0 positional syntax, or no `|` at all): fall\n // through to degrade — the reprocessed closer then closes the materialized char\n // frame (or lands unmatched in the materialized paragraph), exactly as before.\n }\n // Markup inside the span, a foreign closer, or unfoldable attributes: degrade, then\n // reprocess this token against the materialized span.\n materializeFigCapture();\n tokenIndex--;\n continue;\n }\n if (attrTarget) {\n if (token.kind === \"text\") {\n // Only LINE-BREAK whitespace between the target and its attribute marker is\n // structural (`\\ca 1 ca\\ca*` \\u23CE `\\cp 1 cp` still folds cp). A same-line space is\n // content per Paratext and BLOCKS the fold \\u2014 `\\va 12 va\\va* \\vp 12 vp\\vp*` keeps\n // altnumber but leaves vp a standalone marker with the space in the text.\n if (token.text.includes(\"\\n\") && /^[\\s\\u200B]*$/.test(token.text)) {\n heldWhitespace += token.text;\n continue;\n }\n clearAttrTarget();\n }\n else if (token.kind === \"charOpen\" || token.kind === \"para\") {\n const foldable = token.kind === \"para\" || !token.isNested ? attributeMarker(token.marker) : undefined;\n const foldIndex = ATTRIBUTE_FOLD_ORDER[attrTarget.type]?.indexOf(token.marker) ?? -1;\n if (foldable &&\n foldable.targetTypes.includes(attrTarget.type) &&\n foldIndex > attrFoldedThrough) {\n attrFoldedThrough = foldIndex;\n // Whitespace between the target and its attribute marker is structural — dropped.\n heldWhitespace = \"\";\n attrCapture = {\n target: attrTarget,\n attrName: foldable.attrName,\n marker: token.marker,\n shape: foldable.shape,\n value: \"\",\n };\n // attrTarget stays receptive: a chapter takes BOTH \\ca and \\cp.\n continue;\n }\n clearAttrTarget(token.kind === \"para\");\n }\n else {\n clearAttrTarget(token.kind === \"chapter\");\n }\n }\n // ---- `\\fig` interception (marker-name driven, like ParatextData's parser figures) ----\n // `\\fig` reaches assembly as charOpen (a sheet that knows it as Character) or para\n // (unknown marker); BOTH fold to a `figure` when the span is clean. Note content keeps\n // the plain char behavior — this tokenizer does not build figures inside notes. Opening\n // a figure auto-closes open char spans exactly as its Character classification would\n // (UsfmParser.cs:247), so the success and degrade paths continue from the same stack.\n if (!note &&\n !isNoteContext &&\n ((token.kind === \"charOpen\" && !token.isNested && token.marker === FIGURE_MARKER) ||\n (token.kind === \"para\" && token.marker === FIGURE_MARKER))) {\n closeCharStack();\n figCapture = { shape: token.kind === \"charOpen\" ? \"char\" : \"para\", value: \"\" };\n continue;\n }\n switch (token.kind) {\n case \"text\": {\n let text = token.text;\n // A text run's trailing LINE BREAK before a block boundary (a paragraph-kind or\n // chapter token, or fragment end) is structural — the line ends where the next block\n // marker begins, and ParatextData emits no content there. A line break before an\n // INLINE token (char/note/verse/milestone: an ordinary line wrap) stays a content\n // space, as does any typed same-line space. Engine fragments carry no line breaks,\n // so only whole-file/direct-converter input reaches this path; `regularizeSpaces`\n // collapsed the run to `\"\\n\"`. Note interiors keep the pre-existing space (a note\n // terminated by a line-end block boundary is not corpus-attested).\n if (!note && text.endsWith(\"\\n\")) {\n const next = tokens[tokenIndex + 1];\n if (next === undefined || next.kind === \"para\" || next.kind === \"chapter\")\n text = text.slice(0, -1);\n }\n if (text)\n pushContent(toUsjText(text));\n break;\n }\n case \"para\": {\n // ---- table assembly ----\n // Row/cell markers reach assembly as para tokens (paragraph styles, or unknown to\n // the sheet). Table shapes never engage inside note content — a row/cell marker\n // there keeps its plain resolution, and ParatextData builds no tables there either.\n const tableEligible = !note && !isNoteContext;\n if (tableEligible && token.marker === TABLE_ROW_MARKER) {\n closeCharStack();\n // Consecutive `\\tr`s share one table; the first creates it.\n if (!table) {\n table = { type: \"table\", content: [] };\n blockTarget().push(table);\n }\n tableRow = { type: \"table:row\", marker: TABLE_ROW_MARKER, content: [] };\n getContent(table).push(tableRow);\n // Content before the first cell marker (degenerate) lands in the row itself.\n para = tableRow;\n atChapterRootScope = false;\n break;\n }\n if (tableEligible && tableRow) {\n const cellMatch = TABLE_CELL_MARKER_REGEX.exec(token.marker);\n // A name outside what ParatextData recognizes as a cell (see\n // isRecognizedTableCell) is an unknown marker that ENDS the table (and the next\n // `\\tr` starts a fresh one).\n if (cellMatch && isRecognizedTableCell(cellMatch)) {\n pushTableCell(tableRow, token.marker, cellMatch);\n break;\n }\n }\n // Any other paragraph-kind token (esb/esbe included) ends an open table; the token\n // itself then processes normally. A cell marker with NO open row is not table\n // content — it stays an unknown paragraph, exactly as ParatextData splits it out.\n endTable();\n // ---- sidebar assembly ----\n if (!isNoteContext && token.marker === SIDEBAR_MARKER) {\n closeCharStack();\n closeNote(false);\n // Sidebars never nest: an unterminated previous sidebar closes implicitly.\n closeSidebar(false);\n // Landed BEFORE `sidebar` is set: `blockTarget()` answers \"the open sidebar's content\"\n // whenever one is open, so assigning first would nest the new sidebar inside itself.\n const opened = {\n type: \"sidebar\",\n marker: SIDEBAR_MARKER,\n content: [],\n };\n blockTarget().push(opened);\n sidebar = opened;\n para = undefined;\n receiveAttributes(sidebar); // receptive to \\cat (directly after \\esb only)\n atChapterRootScope = false;\n break;\n }\n if (token.marker === SIDEBAR_END_MARKER && sidebar) {\n closeCharStack();\n closeNote(false);\n // `\\esbe` terminates the sidebar and is consumed — it emits nothing itself. With\n // no open sidebar it falls through to today's unknown-paragraph behavior.\n closeSidebar(true);\n para = undefined;\n break;\n }\n // ---- peripheral-division assembly ----\n if (!isNoteContext && token.marker === PERIPH_MARKER) {\n closeCharStack();\n closeNote(false);\n // A division ends every block structure open inside it, including a sidebar the author\n // never terminated; divisions themselves never nest.\n closeSidebar(false);\n closePeriph();\n periphCapture = { value: \"\" };\n para = undefined;\n atChapterRootScope = false;\n break;\n }\n startParagraph(token.marker);\n break;\n }\n case \"verse\": {\n // A verse closes an open note but — for USFM ≤3.0 — does NOT close open char styles: the\n // unclosed span continues across the verse and the verse milestone nests inside it (PT9\n // UsfmParser Verse case: `if (!RequiresPlusOnNestedStyles()) CloseCharStyles()`, and\n // RequiresPlusOnNestedStyles() is true for ≤3.0). This pipeline targets ≤3.0; when the\n // ParatextData dependency moves past 9.6 the close-at-verse must become version-switched\n // (guarded by the upgrade tripwire, alongside close-on-bare and `+` emission).\n closeNote(false);\n const verse = { type: \"verse\", marker: VERSE_MARKER, number: token.number };\n pushContent(verse);\n receiveAttributes(verse); // receptive to \\va/\\vp\n break;\n }\n case \"chapter\": {\n closeCharStack();\n closeNote(false);\n // A chapter boundary ends any open table and implicitly closes an open sidebar\n // (ParatextData auto-closes sidebars at the end of the chapter). A peripheral division\n // ends there too: chapters are book body, which is never division content.\n endTable();\n closeSidebar(false);\n closePeriph();\n para = undefined;\n const chapter = {\n type: \"chapter\",\n marker: CHAPTER_MARKER,\n number: token.number,\n };\n result.push(chapter);\n receiveAttributes(chapter); // receptive to \\ca/\\cp\n atChapterRootScope = true;\n break;\n }\n case \"note\": {\n // A note does NOT close open char spans: USX nests the note inside them and the\n // enclosing span continues after it (`\\wj a \\f …\\f* b\\wj*` → wj contains [text,\n // note, text]). Notes themselves never nest, so a previous open note closes first.\n closeNote(false);\n const target = container();\n note = { type: \"note\", marker: token.marker, caller: token.caller, content: [] };\n noteBaseDepth = charStack.length;\n target.push(note);\n receiveAttributes(note); // receptive to \\cat (right after the caller only)\n break;\n }\n case \"charOpen\": {\n // A cell marker inside an OPEN row is a cell, whichever token kind the stylesheet's\n // classification made it: usfm.sty declares `\\th1`/`\\tc1`/… as Character styles, so with a\n // real project sheet they arrive here rather than as paragraph tokens, and without this a\n // table copied out of the editor pastes back as loose char spans inside empty rows.\n // Guarded on an open row — only `\\tr` opens one — so a char span that merely shares a\n // cell marker's name outside a table keeps its ordinary resolution, and a NESTED span\n // (`\\+tc1`) is never a cell.\n if (!note && !isNoteContext && tableRow && !token.isNested) {\n const cellMatch = TABLE_CELL_MARKER_REGEX.exec(token.marker);\n if (cellMatch && isRecognizedTableCell(cellMatch)) {\n pushTableCell(tableRow, token.marker, cellMatch);\n break;\n }\n }\n // A new non-nested char marker auto-closes open char styles (PT9) — but never\n // across an open note's boundary: the frames enclosing the note stay open.\n if (!token.isNested) {\n const base = note ? noteBaseDepth : 0;\n markImplicitlyClosed(base);\n charStack.length = base;\n }\n const target = container();\n const object = { type: \"char\", marker: token.marker, content: [] };\n target.push(object);\n charStack.push({ object });\n break;\n }\n case \"end\": {\n const marker = token.marker.replace(/^\\+/, \"\");\n // While a note is open, a closer only matches frames opened INSIDE it — it must not\n // reach across the note boundary and close an enclosing span from within the note.\n const searchBase = note ? noteBaseDepth : 0;\n const frameIndex = charStack.findLastIndex((frame, index) => index >= searchBase && frame.object.marker === marker);\n if (frameIndex >= 0) {\n extractAttributes(charStack[frameIndex].object);\n // Nested spans above the explicitly-closed frame are closed IMPLICITLY by it.\n markImplicitlyClosed(frameIndex + 1);\n charStack.length = frameIndex;\n }\n else if (note && note.marker === marker) {\n // Explicit note close: chars opened inside the note close implicitly with it;\n // frames enclosing the note survive (closeNote truncates to the note boundary).\n closeNote(true);\n }\n else {\n // Unmatched closer: PT9 first pops every open char style above the note/para boundary\n // (UsfmParser End token: the while-loop closes each Char element on top of the stack\n // until it matches or hits a non-char element; with no match here they all close as\n // closed=\"false\"), THEN flags the stray closer (PT9 sink.Unmatched,\n // UsxUsfmParserSink.cs:262-266) — an unmatched element rendered as ImmutableUnmatchedNode\n // with the existing `.invalid` styling that serializes back to the same text. Closing\n // the open frames first keeps the following text in the paragraph/note instead of\n // swallowing it into a span PT9 has already terminated.\n markImplicitlyClosed(searchBase);\n charStack.length = searchBase;\n pushContent({ type: \"unmatched\", marker: `${token.marker}*` });\n }\n break;\n }\n case \"milestone\":\n pushContent({ type: \"ms\", marker: token.marker, ...token.attributes });\n break;\n case \"optbreak\":\n pushContent({ type: \"optbreak\" });\n break;\n case \"noteEndingPlaceholder\":\n closeNote(false);\n pushContent(PRESERVED_NODE_PLACEHOLDER);\n break;\n }\n }\n // Fragment ended on a `\\periph` marker line: the division has its title and attributes but no\n // content, which is a complete division — a periph never had a closer to be missing.\n if (periphCapture)\n finishPeriphLine(true);\n // Fragment ended mid-figure: no `\\fig*` closer — degrade to the plain char/para span.\n if (figCapture)\n materializeFigCapture();\n if (attrCapture) {\n // Fragment ended mid-capture. A para-shaped capture (`\\cp 1 cp` at fragment end) folds —\n // the paragraph ended with plain-text content. A char-shaped capture never saw its\n // closer, so it stays a standalone (implicitly closed) span.\n if (attrCapture.shape === \"para\") {\n const cpValue = attrCapture.value.replace(/[\\s\\u200B]+$/, \"\");\n // Empty `\\cp` at fragment end stays a first-class empty para (never an empty pubnumber);\n // a non-empty one folds as the pubnumber.\n if (cpValue === \"\")\n startParagraph(attrCapture.marker);\n else\n Object.assign(attrCapture.target, { [attrCapture.attrName]: toUsjText(cpValue) });\n attrCapture = undefined;\n }\n else {\n // Trailing line break at the fragment-end boundary is structural (text-case rule).\n if (attrCapture.value.endsWith(\"\\n\"))\n attrCapture.value = attrCapture.value.slice(0, -1);\n materializeCaptureAsChar();\n }\n }\n closeCharStack();\n closeNote(false);\n // Fragment ended without `\\esbe`: the sidebar closes implicitly (closed=\"false\").\n closeSidebar(false);\n // Drop empty content arrays (USJ omits `content` for empty paras).\n const dropEmpty = (items) => {\n for (const item of items) {\n if (typeof item === \"string\")\n continue;\n if (item.content) {\n dropEmpty(item.content);\n if (item.content.length === 0)\n delete item.content;\n }\n }\n };\n dropEmpty(result);\n return result;\n}\n/**\n * On explicit close, split a trailing `|attributes` chunk off the span's trailing text run.\n *\n * The tokenizer splits `//` into optbreak tokens spec-blind, so an attribute segment whose\n * VALUE contains `//` (a URL in `link-href`, say) arrives here as interleaved strings and\n * optbreak objects. ParatextData never does that: `UsfmToken.HandleAttributes` strips the\n * attribute segment out of the text run at tokenize-time — splitting the run at its FIRST `|` —\n * and only the remaining content text ever reaches the `//`→optbreak pass (UsfmParser's Text\n * case). So the trailing run (the maximal contiguous string/optbreak suffix, which by\n * construction came from ONE original text run) is rejoined byte-exact — each optbreak was a\n * literal `//` — before attribute parsing, and only pre-pipe optbreaks survive as content.\n * When the segment does not parse, the content stays as-is, split optbreaks included: that too\n * is ParatextData (a failed `SetAttributes` leaves the run literal TEXT, whose post-pipe `//`\n * then genuinely becomes optional breaks).\n */\nfunction extractAttributes(object) {\n const content = object.content;\n if (!content || content.length === 0)\n return;\n // Trailing text run: the maximal contiguous suffix of strings and optbreak objects.\n let runStart = content.length;\n while (runStart > 0) {\n const item = content[runStart - 1];\n if (typeof item !== \"string\" && item.type !== \"optbreak\")\n break;\n runStart--;\n }\n // First pipe-carrying string within the run (PT9: `text.IndexOf('|')` on the whole run).\n const pipeItemIndex = content.findIndex((item, index) => index >= runStart && typeof item === \"string\" && item.includes(\"|\"));\n if (pipeItemIndex < 0)\n return;\n const rejoined = content\n .slice(pipeItemIndex)\n .map((item) => (typeof item === \"string\" ? item : \"//\"))\n .join(\"\");\n const pipeIndex = rejoined.indexOf(\"|\");\n const attributes = parseAttributeText(rejoined.slice(pipeIndex + 1), object.marker ?? \"\");\n if (!attributes)\n return;\n const text = rejoined.slice(0, pipeIndex);\n content.length = pipeItemIndex;\n if (text)\n content.push(text);\n Object.assign(object, attributes);\n}\n","/**\n * The display text of USFM markers and note callers: pure string builders with no node\n * dependencies, kept in a module of their own so node classes and the node utilities can both use\n * them without importing each other.\n */\nimport { NBSP } from \"./node-constants.js\";\n/**\n * Gets the opening marker text.\n * @param marker - The USFM marker.\n * @param nested - Whether the span nests inside another char span. A nested span's marker carries\n * the `+` prefix (`\\+w`) — ParatextData's writer rule and PT9's on-screen display for USFM ≤3.0,\n * where `+` is what makes a bare char marker nest instead of closing the enclosing span. The\n * glyph must show it so a re-tokenization of the visible text reproduces the same nesting.\n * @returns the opening marker text.\n */\nexport function openingMarkerText(marker, nested = false) {\n return `\\\\${nested ? \"+\" : \"\"}${marker}`;\n}\n/**\n * Gets the closing marker text.\n * @param marker - The USFM marker.\n * @param nested - Whether the span nests inside another char span (see {@link openingMarkerText}).\n * @returns the closing marker text.\n */\nexport function closingMarkerText(marker, nested = false) {\n return `\\\\${nested ? \"+\" : \"\"}${marker}*`;\n}\n/**\n * Gets the open marker text with the marker visible: the marker, a no-break separator, and then\n * the content and a trailing space when there is content (`\\v` + NBSP + `2` + space).\n *\n * With no content yet the text ends in the no-break separator (`\\v` + NBSP), the place the content\n * is typed. It must be a no-break space: a verse glyph renders `white-space: nowrap`, which removes\n * a plain space at the end of a line, so a plain separator at the end of a paragraph would show no\n * space and no caret after the marker. The trailing space after content is plain on purpose: at\n * the end of a line it is invisible, and the caret rests right after the content.\n * @param marker - Verse marker.\n * @param content - Content such as chapter or verse number.\n * @returns the marker text with the open marker visible.\n */\nexport function getVisibleOpenMarkerText(marker, content) {\n const text = `${openingMarkerText(marker)}${NBSP}`;\n return content ? `${text}${content} ` : text;\n}\n/**\n * Get editable note caller text.\n * @param noteCaller - Note caller.\n * @returns caller text.\n */\nexport function getEditableCallerText(noteCaller) {\n return \" \" + noteCaller + NBSP;\n}\n/** Whether `a` and `b` are the same caller-text byte: a space and a no-break space are both the\n * whitespace around the caller, whichever the view displays. */\nfunction isSameCallerByte(a, b) {\n return a === b || ((a === \" \" || a === NBSP) && (b === \" \" || b === NBSP));\n}\n/**\n * Where the bytes typed into an expanded note's editable caller text start and end, and whether\n * any of the caller's own bytes are gone: what is left of `text` once the bytes it still starts\n * and ends with, from the caller's own spelling ({@link getEditableCallerText}), are set aside.\n * The caller's bytes are `missing` when those leading and trailing bytes are not its whole\n * spelling — some were deleted or typed over.\n */\nexport function typedCallerRange(text, caller) {\n const canonical = getEditableCallerText(caller);\n let start = 0;\n while (start < text.length &&\n start < canonical.length &&\n isSameCallerByte(text[start], canonical[start]))\n start += 1;\n let kept = 0;\n while (kept < text.length - start &&\n kept < canonical.length - start &&\n isSameCallerByte(text[text.length - 1 - kept], canonical[canonical.length - 1 - kept]))\n kept += 1;\n return { start, end: text.length - kept, missing: start + kept < canonical.length };\n}\n/**\n * The bytes typed into an expanded note's editable caller text, spelled as the note's content\n * reads them (a no-break space as the space it stands for): what a caller that is not put back as\n * a caller word gives its note's content. See {@link typedCallerRange}.\n */\nexport function typedCallerBytes(text, caller) {\n const { start, end } = typedCallerRange(text, caller);\n return text.slice(start, end).replaceAll(NBSP, \" \");\n}\n","/** Marker node used when displaying USFM */\nimport { closingMarkerText, openingMarkerText } from \"../usj/markerText.utils.js\";\nimport { $applyNodeReplacement, TextNode, } from \"lexical\";\nexport const MARKER_VERSION = 1;\nexport class MarkerNode extends TextNode {\n __marker;\n __markerSyntax;\n __nested;\n // `key` stays in Lexical's own third-parameter slot (`TextNode(text, key)`), with `nested`\n // appended after it: a node's key is the last argument every Lexical node constructor takes, and\n // slotting a new field ahead of it would silently reinterpret an existing 3-argument call's\n // `NodeKey` as this flag.\n constructor(marker = \"\", markerSyntax = \"opening\", key, nested = false) {\n super(getMarkerText(marker, markerSyntax, nested), key);\n this.__marker = marker;\n this.__markerSyntax = markerSyntax;\n this.__nested = nested;\n }\n static getType() {\n return \"marker\";\n }\n static clone(node) {\n return new MarkerNode(node.__marker, node.__markerSyntax, node.__key, node.__nested);\n }\n static importJSON(serializedNode) {\n return $createMarkerNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n const { marker, markerSyntax = \"opening\", nested = false } = serializedNode;\n const self = super.updateFromJSON({\n ...serializedNode,\n // An EMPTY serialized text is the \"build canonical bytes\" sentinel — the adaptor's\n // createMarker serializes glyphs with `text: \"\"` and relies on the import deriving them.\n // Any non-empty text is the glyph's actual displayed bytes and is kept verbatim.\n text: serializedNode.text || getMarkerText(marker, markerSyntax, nested),\n });\n // Assigned directly rather than via setMarker/setMarkerSyntax/setNested, which rewrite the\n // just-applied text to canonical and lose a serialized mid-edit divergence: a glyph whose\n // `*` the user deleted must round-trip through parseEditorState or clipboard\n // deserialization still divergent — rewriting it here heals against a user edit, and\n // $isCanonicalMarkerNode then wrongly reports the glyph at rest. Same treatment as\n // ImmutableUnmatchedNode.updateFromJSON.\n const writable = self.getWritable();\n writable.__marker = marker;\n writable.__markerSyntax = markerSyntax;\n writable.__nested = nested;\n return writable;\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n self.__text = getMarkerText(marker, self.__markerSyntax, self.__nested);\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setMarkerSyntax(markerSyntax) {\n if (this.__markerSyntax === markerSyntax)\n return this;\n const self = this.getWritable();\n self.__markerSyntax = markerSyntax;\n self.__text = getMarkerText(self.__marker, markerSyntax, self.__nested);\n return self;\n }\n getMarkerSyntax() {\n const self = this.getLatest();\n return self.__markerSyntax;\n }\n setNested(nested) {\n if (this.__nested === nested)\n return this;\n const self = this.getWritable();\n self.__nested = nested;\n self.__text = getMarkerText(self.__marker, self.__markerSyntax, nested);\n return self;\n }\n getNested() {\n const self = this.getLatest();\n return self.__nested;\n }\n createDOM(config) {\n const dom = super.createDOM(config);\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(this.__markerSyntax);\n return dom;\n }\n updateDOM(prevNode, dom, config) {\n // TextNode implements updateDOM, so unlike CharNode.updateDOM this can - and must - defer to\n // super: its return value decides whether Lexical reuses the element or rebuilds it via\n // createDOM. On reuse, createDOM does not run again, so the marker-derived attribute and class\n // it set have to be rewritten here by hand. setMarker/setMarkerSyntax already reconcile the\n // visible text; without this the presentational data-marker and syntax class go stale, which is\n // the same gap CharNode.updateDOM closes for the char span.\n const isRecreated = super.updateDOM(prevNode, dom, config);\n if (prevNode.__marker !== this.__marker)\n dom.setAttribute(\"data-marker\", this.__marker);\n if (prevNode.__markerSyntax !== this.__markerSyntax) {\n dom.classList.remove(prevNode.__markerSyntax);\n dom.classList.add(this.__markerSyntax);\n }\n return isRecreated;\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n text: this.getTextContent(),\n marker: this.getMarker(),\n markerSyntax: this.getMarkerSyntax(),\n // Only serialize the flag for genuinely nested glyphs; absence means non-nested, so\n // existing states (and the overwhelmingly common non-nested markers) stay unchanged.\n ...(this.getNested() ? { nested: true } : {}),\n version: MARKER_VERSION,\n };\n }\n}\nexport function $createMarkerNode(marker, markerSyntax, nested) {\n return $applyNodeReplacement(new MarkerNode(marker, markerSyntax, undefined, nested));\n}\nexport function $isMarkerNode(node) {\n return node instanceof MarkerNode;\n}\nexport function isSerializedMarkerNode(node) {\n return node?.type === MarkerNode.getType();\n}\n/**\n * Whether `node`'s RENDERED bytes still spell the glyph its own state describes — the single\n * definition of \"this glyph is at rest\", as opposed to mid-edit (pend-shaped).\n *\n * A glyph's text is a cache of (marker, syntax, nested) that only the setters below rewrite, so a\n * user edit to the displayed characters — deleting the `*` from `\\va*`, backspacing into `\\qt-s` —\n * leaves the node's state fully intact while the bytes on screen say something else. Anything that\n * classifies a glyph must ask this, not just the state: a glyph whose bytes have drifted is\n * mid-edit, and treating it as canonical is how a run comes to be canonical to one subsystem and\n * pending to another at the same time. That standing disagreement is the defect shape this\n * predicate exists to make impossible, so it belongs next to the `__text` writer it mirrors, not\n * beside any one of its callers — the marker transform, the pending-marker resolve, the historic\n * re-pend scan, the read-only settle, and the display-run piece scanners all key on it. A nested\n * span's `\\+w*` is canonical FOR A NESTED GLYPH; the `+` comes from the node's own stored nesting,\n * so a rest-state nested glyph is never mistaken for a damaged one.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isCanonicalMarkerNode(node) {\n return (node.getTextContent() ===\n getMarkerText(node.getMarker(), node.getMarkerSyntax(), node.getNested()));\n}\n/**\n * Rewrite `node`'s rendered bytes to the canonical spelling of its own (marker, syntax, nested)\n * state — the HEAL arm for machine drift on a glyph's displayed characters. The one writer of the\n * canonical form lives in this module ({@link getMarkerText}); exposing the restore here keeps a\n * healer from re-deriving the spelling and drifting from it. Callers own the provenance decision\n * (invariants: machine drift heals, a user edit pends) — this function only writes the bytes.\n *\n * Mutating: call inside `editor.update()` (dispatched from the marker-edit engine's `MarkerNode`\n * transform when a non-user divergence is detected).\n */\nexport function $restoreCanonicalMarkerText(node) {\n node.setTextContent(getMarkerText(node.getMarker(), node.getMarkerSyntax(), node.getNested()));\n}\n/**\n * The single writer of a glyph's `__text` — the ONLY place the `+` becomes literal characters.\n * `marker` is always clean (`\"w\"`); `nested` contributes the `+` (`\\+w`). Called from the\n * constructor and every setter, so `__text` always reflects (marker, syntax, nested) — keeping\n * the cached text honest is therefore exactly the job of keeping `nested` honest, which\n * `$syncNestedGlyphs` (nestedGlyphs.utils.ts) does from tree position.\n */\nfunction getMarkerText(marker, markerSyntax, nested = false) {\n // The self-closing form is a milestone terminator (`\\*`); milestones never nest inside a char\n // span, so the `+` prefix does not apply to it.\n if (markerSyntax === \"closing\")\n return closingMarkerText(marker, nested);\n if (markerSyntax === \"selfClosing\")\n return closingMarkerText(\"\");\n return openingMarkerText(marker, nested);\n}\n","/**\n * Adapted from https://github.com/facebook/lexical/blob/92c47217244f9d3c22a59728633fb41a10420724/packages/lexical-mark/src/MarkNode.ts\n * This adaption allows for different types of marks while still only requiring one mark to enclose\n * a selection.\n */\nimport { assertSafeKey } from \"@eten-tech-foundation/scripture-utilities\";\nimport { addClassNamesToElement, removeClassNamesFromElement } from \"@lexical/utils\";\nimport { $applyNodeReplacement, $getEditor, $getNodeByKey, $isRangeSelection, $isTextNode, ElementNode, } from \"lexical\";\n/** Reserved mark type for CommentPlugin. */\nexport const COMMENT_MARK_TYPE = \"internal-comment\";\nconst reservedTypes = [COMMENT_MARK_TYPE];\nconst NO_IDS = Object.freeze({});\nconst NO_ON_CLICKS = Object.freeze({});\nconst NO_ON_REMOVES = Object.freeze({});\nconst NO_ON_MOUSE_ENTERS = Object.freeze({});\nconst NO_ON_MOUSE_LEAVES = Object.freeze({});\nconst TYPED_MARK_VERSION = 1;\nconst typedOnClickRegistry = new Map();\nconst typedOnRemoveRegistry = new Map();\nconst typedOnMouseEnterRegistry = new Map();\nconst typedOnMouseLeaveRegistry = new Map();\n/** Per editor a reporter listens to, the `type`/`id` pairs whose `onRemove` a mark has called\n * since the last take. An editor nobody listens to has no entry, so nothing piles up for it. */\nconst removalReports = new WeakMap();\n/** Per editor a reporter listens to, the marks that have reported each `type`/`id`'s removal since\n * it was last set (by {@link removalKey}). An undo brings a mark back under its own key, so a mark\n * found here has already told the host and stays quiet the next time it goes. */\nconst reportedMarks = new WeakMap();\n/**\n * Start recording the `type`/`id` pairs whose `onRemove` a mark of `editor` calls, for\n * {@link takeTypedMarkRemovalReports}. Returns the function that stops it and drops what was not\n * taken. One reporter per editor: a second call restarts the record.\n */\nexport function listenForTypedMarkRemovalReports(editor) {\n removalReports.set(editor, []);\n reportedMarks.set(editor, new Map());\n return () => {\n removalReports.delete(editor);\n reportedMarks.delete(editor);\n };\n}\n/**\n * The `type`/`id` pairs whose `onRemove` a mark of `editor` has called since the last take, so a\n * reporter that runs after the commit knows the host has already heard of them. Clears the list.\n * Empty unless {@link listenForTypedMarkRemovalReports} is recording for `editor`.\n */\nexport function takeTypedMarkRemovalReports(editor) {\n const taken = removalReports.get(editor);\n if (!taken)\n return [];\n removalReports.set(editor, []);\n return taken;\n}\n/** Per editor, the `type`/`id` pairs whose removal no mark reports any more. */\nconst silencedRemovals = new WeakMap();\n/** One key per `type`/`id` pair. JSON, not a delimiter join: a type or id may itself contain any\n * delimiter character, NUL included. */\nfunction removalKey(type, id) {\n return JSON.stringify([type, id]);\n}\n/**\n * Stop, or resume, every mark of `editor` reporting the removal of `type`/`id`. A reporter that has\n * already told the host an annotation is gone silences it, so a mark an undo brings back cannot\n * report it a second time. Resuming starts a new lifecycle, in which every mark may report once\n * again.\n */\nexport function setTypedMarkRemovalSilenced(editor, type, id, silenced) {\n let keys = silencedRemovals.get(editor);\n if (silenced) {\n if (!keys)\n silencedRemovals.set(editor, (keys = new Set()));\n keys.add(removalKey(type, id));\n }\n else {\n keys?.delete(removalKey(type, id));\n reportedMarks.get(editor)?.delete(removalKey(type, id));\n }\n}\n/** Resume reporting every silenced removal in `editor`. */\nexport function clearTypedMarkRemovalSilences(editor) {\n silencedRemovals.delete(editor);\n reportedMarks.get(editor)?.clear();\n}\n/** Drop the callback for `type`/`id` from `registry`'s entry for `key`. */\nfunction dropRegisteredCallback(registry, key, type, id) {\n const entry = registry.get(key);\n const typeCallbacks = entry?.[type];\n if (!entry || !typeCallbacks || !(id in typeCallbacks))\n return;\n const remaining = omitRecordKey(typeCallbacks, id);\n const next = Object.keys(remaining).length > 0\n ? { ...entry, [type]: remaining }\n : omitRecordKey(entry, type);\n if (Object.keys(next).length > 0)\n registry.set(key, next);\n else\n registry.delete(key);\n}\n/**\n * Drop mark `key`'s callbacks for `type`/`id`, as `remove()` drops a mark's callbacks, for a mark\n * that left the document without `remove()` running.\n */\nexport function forgetTypedMarkCallbacks(key, type, id) {\n dropRegisteredCallback(typedOnClickRegistry, key, type, id);\n dropRegisteredCallback(typedOnRemoveRegistry, key, type, id);\n dropRegisteredCallback(typedOnMouseEnterRegistry, key, type, id);\n dropRegisteredCallback(typedOnMouseLeaveRegistry, key, type, id);\n}\nexport class TypedMarkNode extends ElementNode {\n __typedIDs;\n __typedOnClicks;\n __typedOnRemoves;\n __typedOnMouseEnters;\n __typedOnMouseLeaves;\n __domOnClickListener;\n __domOnMouseEnterListener;\n __domOnMouseLeaveListener;\n __suppressOnRemoveCallbacks;\n constructor(typedIds = NO_IDS, typedOnClicks, typedOnRemoves, typedOnMouseEnters, typedOnMouseLeaves, key) {\n super(key);\n this.__typedIDs = cloneTypedIDs(typedIds);\n this.__typedOnClicks = cloneTypedOnClicks(typedOnClicks);\n this.__typedOnRemoves = cloneTypedOnRemoves(typedOnRemoves);\n this.__typedOnMouseEnters = cloneTypedOnMouseEnters(typedOnMouseEnters);\n this.__typedOnMouseLeaves = cloneTypedOnMouseLeaves(typedOnMouseLeaves);\n this.pruneTypedOnClicks();\n this.pruneTypedOnRemoves();\n this.pruneTypedOnMouseEnters();\n this.pruneTypedOnMouseLeaves();\n this.syncTypedOnClicksToRegistry();\n this.syncTypedOnRemovesToRegistry();\n this.syncTypedOnMouseEntersToRegistry();\n this.syncTypedOnMouseLeavesToRegistry();\n }\n static getType() {\n return \"typed-mark\";\n }\n static clone(node) {\n const __typedIDs = cloneTypedIDs(node.__typedIDs);\n const __typedOnClicks = cloneTypedOnClicks(node.__typedOnClicks);\n const __typedOnRemoves = cloneTypedOnRemoves(node.__typedOnRemoves);\n const __typedOnMouseEnters = cloneTypedOnMouseEnters(node.__typedOnMouseEnters);\n const __typedOnMouseLeaves = cloneTypedOnMouseLeaves(node.__typedOnMouseLeaves);\n return new TypedMarkNode(__typedIDs, __typedOnClicks, __typedOnRemoves, __typedOnMouseEnters, __typedOnMouseLeaves, node.__key);\n }\n static isReservedType(type) {\n return reservedTypes.includes(type);\n }\n static importDOM() {\n return null;\n }\n static importJSON(serializedNode) {\n return $createTypedMarkNode().updateFromJSON(serializedNode);\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n typedIDs: this.getTypedIDs(),\n version: TYPED_MARK_VERSION,\n };\n }\n createDOM(config, editor) {\n const element = document.createElement(\"mark\");\n addClassNamesToElement(element, ...typedMarkClassNames(config.theme, this.__typedIDs));\n const clickListener = this.getOrCreateDOMClickListener(editor);\n element.addEventListener(\"click\", clickListener);\n const mouseEnterListener = this.getOrCreateDOMMouseEnterListener(editor);\n element.addEventListener(\"mouseenter\", mouseEnterListener);\n const mouseLeaveListener = this.getOrCreateDOMMouseLeaveListener(editor);\n element.addEventListener(\"mouseleave\", mouseLeaveListener);\n return element;\n }\n updateDOM(prevNode, element, config) {\n const types = new Set([\n ...Object.keys(prevNode.__typedIDs ?? {}),\n ...Object.keys(this.__typedIDs ?? {}),\n ]);\n for (const type of types) {\n const prevIDs = prevNode.__typedIDs[type] ?? [];\n const nextIDs = this.__typedIDs[type] ?? [];\n const prevIDsCount = prevIDs.length;\n const nextIDsCount = nextIDs.length;\n const markTheme = getTypedClassName(config.theme.typedMark, type);\n const overlapTheme = getTypedClassName(config.theme.typedMarkOverlap, type);\n if (prevIDsCount !== nextIDsCount) {\n if (prevIDsCount === 0) {\n if (nextIDsCount === 1)\n addClassNamesToElement(element, markTheme);\n }\n else if (nextIDsCount === 0) {\n removeClassNamesFromElement(element, markTheme);\n }\n if (prevIDsCount === 1) {\n if (nextIDsCount === 2)\n addClassNamesToElement(element, overlapTheme);\n }\n else if (nextIDsCount === 1) {\n removeClassNamesFromElement(element, overlapTheme);\n }\n }\n const prevIDsSet = new Set(prevIDs);\n const nextIDsSet = new Set(nextIDs);\n for (const id of prevIDs) {\n if (!nextIDsSet.has(id)) {\n removeClassNamesFromElement(element, getTypedClassName(\"annotationId\", id));\n }\n }\n for (const id of nextIDs) {\n if (!prevIDsSet.has(id)) {\n addClassNamesToElement(element, getTypedClassName(\"annotationId\", id));\n }\n }\n }\n return false;\n }\n updateFromJSON(serializedNode) {\n return super.updateFromJSON(serializedNode).setTypedIDs(serializedNode.typedIDs);\n }\n hasID(type, id) {\n const typedIDs = this.getTypedIDs();\n const ids = typedIDs[type];\n if (!ids)\n return false;\n for (const existingId of ids) {\n if (id === existingId) {\n return true;\n }\n }\n return false;\n }\n getTypedIDs() {\n const self = this.getLatest();\n return $isTypedMarkNode(self) ? self.__typedIDs : {};\n }\n setTypedIDs(ids) {\n const self = this.getWritable();\n const previousIDs = cloneTypedIDs(self.__typedIDs);\n self.__typedIDs = cloneTypedIDs(ids);\n self.dispatchRemovedIDs(previousIDs, self.__typedIDs, \"removed\");\n self.pruneTypedOnClicks();\n self.pruneTypedOnRemoves();\n self.pruneTypedOnMouseEnters();\n self.pruneTypedOnMouseLeaves();\n self.syncTypedOnClicksToRegistry();\n self.syncTypedOnRemovesToRegistry();\n self.syncTypedOnMouseEntersToRegistry();\n self.syncTypedOnMouseLeavesToRegistry();\n const mergedNode = self.mergeWithAdjacentTypedMarks();\n if (mergedNode.hasNoIDsForEveryType() && mergedNode.getParent() !== null)\n $unwrapTypedMarkNode(mergedNode);\n return mergedNode;\n }\n setTypedOnClicks(typedOnClicks) {\n const self = this.getWritable();\n self.__typedOnClicks = cloneTypedOnClicks(typedOnClicks);\n self.pruneTypedOnClicks();\n self.syncTypedOnClicksToRegistry();\n return self;\n }\n getTypedOnClicks() {\n const self = this.getLatest();\n if (!$isTypedMarkNode(self))\n return {};\n const stored = typedOnClickRegistry.get(self.getKey());\n return stored ?? {};\n }\n setTypedOnRemoves(typedOnRemoves) {\n const self = this.getWritable();\n self.__typedOnRemoves = cloneTypedOnRemoves(typedOnRemoves);\n self.pruneTypedOnRemoves();\n self.syncTypedOnRemovesToRegistry();\n return self;\n }\n getTypedOnRemoves() {\n const self = this.getLatest();\n if (!$isTypedMarkNode(self))\n return {};\n const stored = typedOnRemoveRegistry.get(self.getKey());\n return stored ?? {};\n }\n setTypedOnMouseEnters(typedOnMouseEnters) {\n const self = this.getWritable();\n self.__typedOnMouseEnters = cloneTypedOnMouseEnters(typedOnMouseEnters);\n self.pruneTypedOnMouseEnters();\n self.syncTypedOnMouseEntersToRegistry();\n return self;\n }\n getTypedOnMouseEnters() {\n const self = this.getLatest();\n if (!$isTypedMarkNode(self))\n return {};\n const stored = typedOnMouseEnterRegistry.get(self.getKey());\n return stored ?? {};\n }\n setTypedOnMouseLeaves(typedOnMouseLeaves) {\n const self = this.getWritable();\n self.__typedOnMouseLeaves = cloneTypedOnMouseLeaves(typedOnMouseLeaves);\n self.pruneTypedOnMouseLeaves();\n self.syncTypedOnMouseLeavesToRegistry();\n return self;\n }\n getTypedOnMouseLeaves() {\n const self = this.getLatest();\n if (!$isTypedMarkNode(self))\n return {};\n const stored = typedOnMouseLeaveRegistry.get(self.getKey());\n return stored ?? {};\n }\n addID(type, id, onClick, onRemove, onMouseEnter, onMouseLeave) {\n const self = this.getWritable();\n if (!$isTypedMarkNode(self))\n return;\n assertSafeKey(type);\n assertSafeKey(id);\n let ids = self.__typedIDs[type];\n if (!ids) {\n ids = [];\n self.__typedIDs[type] = ids;\n }\n for (const existingId of ids) {\n if (id === existingId) {\n if (onClick)\n self.setOnClickFor(type, id, onClick);\n if (onRemove)\n self.setOnRemoveFor(type, id, onRemove);\n if (onMouseEnter)\n self.setOnMouseEnterFor(type, id, onMouseEnter);\n if (onMouseLeave)\n self.setOnMouseLeaveFor(type, id, onMouseLeave);\n return;\n }\n }\n ids.push(id);\n if (onClick)\n self.setOnClickFor(type, id, onClick);\n if (onRemove)\n self.setOnRemoveFor(type, id, onRemove);\n if (onMouseEnter)\n self.setOnMouseEnterFor(type, id, onMouseEnter);\n if (onMouseLeave)\n self.setOnMouseLeaveFor(type, id, onMouseLeave);\n }\n deleteID(type, id) {\n const self = this.getWritable();\n if (!$isTypedMarkNode(self))\n return;\n const ids = self.__typedIDs[type];\n if (!ids || ids.length === 0)\n return;\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n ids.splice(i, 1);\n self.invokeOnRemove(type, id, \"removed\");\n break;\n }\n }\n self.removeOnClickFor(type, id);\n self.removeOnRemoveFor(type, id);\n self.removeOnMouseEnterFor(type, id);\n self.removeOnMouseLeaveFor(type, id);\n self.pruneTypedOnClicks();\n self.pruneTypedOnRemoves();\n self.pruneTypedOnMouseEnters();\n self.pruneTypedOnMouseLeaves();\n const mergedNode = self.mergeWithAdjacentTypedMarks();\n if (mergedNode.hasNoIDsForEveryType() && mergedNode.getParent() !== null)\n $unwrapTypedMarkNode(mergedNode);\n }\n hasNoIDsForEveryType() {\n return Object.values(this.getTypedIDs()).every((ids) => ids === undefined || ids.length === 0);\n }\n insertNewAfter(_selection, restoreSelection = true) {\n const node = $createTypedMarkNode(this.__typedIDs, this.getTypedOnClicks());\n this.insertAfter(node, restoreSelection);\n return node;\n }\n canInsertTextBefore() {\n return false;\n }\n canInsertTextAfter() {\n return false;\n }\n canBeEmpty() {\n return false;\n }\n isInline() {\n return true;\n }\n extractWithChild(_child, selection, destination) {\n if (!$isRangeSelection(selection) || destination === \"html\") {\n return false;\n }\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = anchor.getNode();\n const focusNode = focus.getNode();\n const isBackward = selection.isBackward();\n const selectionLength = isBackward\n ? anchor.offset - focus.offset\n : focus.offset - anchor.offset;\n return (this.isParentOf(anchorNode) &&\n this.isParentOf(focusNode) &&\n this.getTextContent().length === selectionLength);\n }\n excludeFromCopy(destination) {\n return destination !== \"clone\";\n }\n remove(preserveEmptyParent) {\n const self = this.getWritable();\n const typedIDs = this.getTypedIDs();\n if (self.__suppressOnRemoveCallbacks) {\n self.__suppressOnRemoveCallbacks = undefined;\n }\n else {\n self.dispatchOnRemoveForTypedIDs(typedIDs, \"destroyed\");\n }\n typedOnClickRegistry.delete(self.getKey());\n typedOnRemoveRegistry.delete(self.getKey());\n typedOnMouseEnterRegistry.delete(self.getKey());\n typedOnMouseLeaveRegistry.delete(self.getKey());\n self.__typedOnClicks = undefined;\n self.__typedOnRemoves = undefined;\n self.__typedOnMouseEnters = undefined;\n self.__typedOnMouseLeaves = undefined;\n super.remove.call(self, preserveEmptyParent);\n }\n getOrCreateDOMClickListener(editor) {\n if (!this.__domOnClickListener) {\n this.__domOnClickListener = (event) => {\n this.handleDOMClick(event, editor);\n };\n }\n return this.__domOnClickListener;\n }\n handleDOMClick(event, editor) {\n const typedOnClicks = typedOnClickRegistry.get(this.getKey());\n if (!typedOnClicks)\n return;\n const callbacks = [];\n for (const [type, callbacksById] of Object.entries(typedOnClicks)) {\n for (const [id, callback] of Object.entries(callbacksById)) {\n if (callback)\n callbacks.push([callback, type, id]);\n }\n }\n if (callbacks.length === 0)\n return;\n const textContent = editor.read(() => this.getTextContent());\n for (const [callback, type, id] of callbacks) {\n callback(event, type, id, textContent);\n }\n }\n getOrCreateDOMMouseEnterListener(editor) {\n if (!this.__domOnMouseEnterListener) {\n this.__domOnMouseEnterListener = (event) => {\n this.handleDOMMouseEnter(event, editor);\n };\n }\n return this.__domOnMouseEnterListener;\n }\n handleDOMMouseEnter(event, editor) {\n const typedOnMouseEnters = typedOnMouseEnterRegistry.get(this.getKey());\n if (!typedOnMouseEnters)\n return;\n const callbacks = [];\n for (const [type, callbacksById] of Object.entries(typedOnMouseEnters)) {\n for (const [id, callback] of Object.entries(callbacksById)) {\n if (callback)\n callbacks.push([callback, type, id]);\n }\n }\n if (callbacks.length === 0)\n return;\n const textContent = editor.read(() => this.getTextContent());\n for (const [callback, type, id] of callbacks) {\n callback(event, type, id, textContent);\n }\n }\n getOrCreateDOMMouseLeaveListener(editor) {\n if (!this.__domOnMouseLeaveListener) {\n this.__domOnMouseLeaveListener = (event) => {\n this.handleDOMMouseLeave(event, editor);\n };\n }\n return this.__domOnMouseLeaveListener;\n }\n handleDOMMouseLeave(event, editor) {\n const typedOnMouseLeaves = typedOnMouseLeaveRegistry.get(this.getKey());\n if (!typedOnMouseLeaves)\n return;\n const callbacks = [];\n for (const [type, callbacksById] of Object.entries(typedOnMouseLeaves)) {\n for (const [id, callback] of Object.entries(callbacksById)) {\n if (callback)\n callbacks.push([callback, type, id]);\n }\n }\n if (callbacks.length === 0)\n return;\n const textContent = editor.read(() => this.getTextContent());\n for (const [callback, type, id] of callbacks) {\n callback(event, type, id, textContent);\n }\n }\n ensureOnClickMapMutable() {\n if (this.__typedOnClicks === undefined || this.__typedOnClicks === NO_ON_CLICKS) {\n const existing = typedOnClickRegistry.get(this.getKey());\n this.__typedOnClicks = existing ?? {};\n }\n return this.__typedOnClicks;\n }\n syncTypedOnClicksToRegistry() {\n if (!this.__typedOnClicks || Object.keys(this.__typedOnClicks).length === 0) {\n typedOnClickRegistry.delete(this.getKey());\n if (this.__typedOnClicks && Object.keys(this.__typedOnClicks).length === 0) {\n this.__typedOnClicks = undefined;\n }\n return;\n }\n typedOnClickRegistry.set(this.getKey(), this.__typedOnClicks);\n }\n setOnClickFor(type, id, onClick) {\n assertSafeKey(type);\n assertSafeKey(id);\n const callbacks = this.ensureOnClickMapMutable();\n const typeCallbacks = callbacks[type] ?? (callbacks[type] = {});\n typeCallbacks[id] = onClick;\n this.syncTypedOnClicksToRegistry();\n }\n removeOnClickFor(type, id) {\n if (!this.__typedOnClicks)\n return;\n const typeCallbacks = this.__typedOnClicks[type];\n if (!typeCallbacks)\n return;\n const updatedTypeCallbacks = omitRecordKey(typeCallbacks, id);\n const hasRemainingCallbacks = Object.keys(updatedTypeCallbacks).length > 0;\n if (hasRemainingCallbacks) {\n this.__typedOnClicks = {\n ...this.__typedOnClicks,\n [type]: updatedTypeCallbacks,\n };\n }\n else {\n const remainingCallbacks = omitRecordKey(this.__typedOnClicks, type);\n this.__typedOnClicks =\n Object.keys(remainingCallbacks).length > 0 ? remainingCallbacks : undefined;\n }\n this.syncTypedOnClicksToRegistry();\n }\n pruneTypedOnClicks() {\n if (!this.__typedOnClicks || this.__typedOnClicks === NO_ON_CLICKS) {\n this.__typedOnClicks = undefined;\n this.syncTypedOnClicksToRegistry();\n return;\n }\n const nextTypedOnClicks = {};\n for (const [type, callbacks] of Object.entries(this.__typedOnClicks)) {\n const ids = this.__typedIDs[type];\n if (!ids || ids.length === 0) {\n continue;\n }\n const idSet = new Set(ids);\n const filteredCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n if (idSet.has(id)) {\n filteredCallbacks[id] = callback;\n }\n }\n if (Object.keys(filteredCallbacks).length > 0) {\n nextTypedOnClicks[type] = filteredCallbacks;\n }\n }\n this.__typedOnClicks =\n Object.keys(nextTypedOnClicks).length > 0 ? nextTypedOnClicks : undefined;\n this.syncTypedOnClicksToRegistry();\n }\n ensureOnRemoveMapMutable() {\n if (this.__typedOnRemoves === undefined || this.__typedOnRemoves === NO_ON_REMOVES) {\n const existing = typedOnRemoveRegistry.get(this.getKey());\n this.__typedOnRemoves = existing ?? {};\n }\n return this.__typedOnRemoves;\n }\n syncTypedOnRemovesToRegistry() {\n if (!this.__typedOnRemoves || Object.keys(this.__typedOnRemoves).length === 0) {\n typedOnRemoveRegistry.delete(this.getKey());\n if (this.__typedOnRemoves && Object.keys(this.__typedOnRemoves).length === 0) {\n this.__typedOnRemoves = undefined;\n }\n return;\n }\n typedOnRemoveRegistry.set(this.getKey(), this.__typedOnRemoves);\n }\n setOnRemoveFor(type, id, onRemove) {\n assertSafeKey(type);\n assertSafeKey(id);\n const callbacks = this.ensureOnRemoveMapMutable();\n const typeCallbacks = callbacks[type] ?? (callbacks[type] = {});\n typeCallbacks[id] = onRemove;\n this.syncTypedOnRemovesToRegistry();\n }\n removeOnRemoveFor(type, id) {\n if (!this.__typedOnRemoves)\n return;\n const typeCallbacks = this.__typedOnRemoves[type];\n if (!typeCallbacks)\n return;\n const updatedTypeCallbacks = omitRecordKey(typeCallbacks, id);\n const hasRemainingCallbacks = Object.keys(updatedTypeCallbacks).length > 0;\n if (hasRemainingCallbacks) {\n this.__typedOnRemoves = {\n ...this.__typedOnRemoves,\n [type]: updatedTypeCallbacks,\n };\n }\n else {\n const remainingCallbacks = omitRecordKey(this.__typedOnRemoves, type);\n this.__typedOnRemoves =\n Object.keys(remainingCallbacks).length > 0 ? remainingCallbacks : undefined;\n }\n this.syncTypedOnRemovesToRegistry();\n }\n pruneTypedOnRemoves() {\n if (!this.__typedOnRemoves || this.__typedOnRemoves === NO_ON_REMOVES) {\n this.__typedOnRemoves = undefined;\n this.syncTypedOnRemovesToRegistry();\n return;\n }\n const nextTypedOnRemoves = {};\n for (const [type, callbacks] of Object.entries(this.__typedOnRemoves)) {\n const ids = this.__typedIDs[type];\n if (!ids || ids.length === 0)\n continue;\n const idSet = new Set(ids);\n const filteredCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n if (idSet.has(id))\n filteredCallbacks[id] = callback;\n }\n if (Object.keys(filteredCallbacks).length > 0) {\n nextTypedOnRemoves[type] = filteredCallbacks;\n }\n }\n this.__typedOnRemoves =\n Object.keys(nextTypedOnRemoves).length > 0 ? nextTypedOnRemoves : undefined;\n this.syncTypedOnRemovesToRegistry();\n }\n ensureOnMouseEnterMapMutable() {\n if (this.__typedOnMouseEnters === undefined ||\n this.__typedOnMouseEnters === NO_ON_MOUSE_ENTERS) {\n const existing = typedOnMouseEnterRegistry.get(this.getKey());\n this.__typedOnMouseEnters = existing ?? {};\n }\n return this.__typedOnMouseEnters;\n }\n syncTypedOnMouseEntersToRegistry() {\n if (!this.__typedOnMouseEnters || Object.keys(this.__typedOnMouseEnters).length === 0) {\n typedOnMouseEnterRegistry.delete(this.getKey());\n if (this.__typedOnMouseEnters && Object.keys(this.__typedOnMouseEnters).length === 0) {\n this.__typedOnMouseEnters = undefined;\n }\n return;\n }\n typedOnMouseEnterRegistry.set(this.getKey(), this.__typedOnMouseEnters);\n }\n setOnMouseEnterFor(type, id, onMouseEnter) {\n assertSafeKey(type);\n assertSafeKey(id);\n const callbacks = this.ensureOnMouseEnterMapMutable();\n const typeCallbacks = callbacks[type] ?? (callbacks[type] = {});\n typeCallbacks[id] = onMouseEnter;\n this.syncTypedOnMouseEntersToRegistry();\n }\n removeOnMouseEnterFor(type, id) {\n if (!this.__typedOnMouseEnters)\n return;\n const typeCallbacks = this.__typedOnMouseEnters[type];\n if (!typeCallbacks)\n return;\n const updatedTypeCallbacks = omitRecordKey(typeCallbacks, id);\n const hasRemainingCallbacks = Object.keys(updatedTypeCallbacks).length > 0;\n if (hasRemainingCallbacks) {\n this.__typedOnMouseEnters = {\n ...this.__typedOnMouseEnters,\n [type]: updatedTypeCallbacks,\n };\n }\n else {\n const remainingCallbacks = omitRecordKey(this.__typedOnMouseEnters, type);\n this.__typedOnMouseEnters =\n Object.keys(remainingCallbacks).length > 0 ? remainingCallbacks : undefined;\n }\n this.syncTypedOnMouseEntersToRegistry();\n }\n pruneTypedOnMouseEnters() {\n if (!this.__typedOnMouseEnters || this.__typedOnMouseEnters === NO_ON_MOUSE_ENTERS) {\n this.__typedOnMouseEnters = undefined;\n this.syncTypedOnMouseEntersToRegistry();\n return;\n }\n const nextTypedOnMouseEnters = {};\n for (const [type, callbacks] of Object.entries(this.__typedOnMouseEnters)) {\n const ids = this.__typedIDs[type];\n if (!ids || ids.length === 0) {\n continue;\n }\n const idSet = new Set(ids);\n const filteredCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n if (idSet.has(id)) {\n filteredCallbacks[id] = callback;\n }\n }\n if (Object.keys(filteredCallbacks).length > 0) {\n nextTypedOnMouseEnters[type] = filteredCallbacks;\n }\n }\n this.__typedOnMouseEnters =\n Object.keys(nextTypedOnMouseEnters).length > 0 ? nextTypedOnMouseEnters : undefined;\n this.syncTypedOnMouseEntersToRegistry();\n }\n ensureOnMouseLeaveMapMutable() {\n if (this.__typedOnMouseLeaves === undefined ||\n this.__typedOnMouseLeaves === NO_ON_MOUSE_LEAVES) {\n const existing = typedOnMouseLeaveRegistry.get(this.getKey());\n this.__typedOnMouseLeaves = existing ?? {};\n }\n return this.__typedOnMouseLeaves;\n }\n syncTypedOnMouseLeavesToRegistry() {\n if (!this.__typedOnMouseLeaves || Object.keys(this.__typedOnMouseLeaves).length === 0) {\n typedOnMouseLeaveRegistry.delete(this.getKey());\n if (this.__typedOnMouseLeaves && Object.keys(this.__typedOnMouseLeaves).length === 0) {\n this.__typedOnMouseLeaves = undefined;\n }\n return;\n }\n typedOnMouseLeaveRegistry.set(this.getKey(), this.__typedOnMouseLeaves);\n }\n setOnMouseLeaveFor(type, id, onMouseLeave) {\n assertSafeKey(type);\n assertSafeKey(id);\n const callbacks = this.ensureOnMouseLeaveMapMutable();\n const typeCallbacks = callbacks[type] ?? (callbacks[type] = {});\n typeCallbacks[id] = onMouseLeave;\n this.syncTypedOnMouseLeavesToRegistry();\n }\n removeOnMouseLeaveFor(type, id) {\n if (!this.__typedOnMouseLeaves)\n return;\n const typeCallbacks = this.__typedOnMouseLeaves[type];\n if (!typeCallbacks)\n return;\n const updatedTypeCallbacks = omitRecordKey(typeCallbacks, id);\n const hasRemainingCallbacks = Object.keys(updatedTypeCallbacks).length > 0;\n if (hasRemainingCallbacks) {\n this.__typedOnMouseLeaves = {\n ...this.__typedOnMouseLeaves,\n [type]: updatedTypeCallbacks,\n };\n }\n else {\n const remainingCallbacks = omitRecordKey(this.__typedOnMouseLeaves, type);\n this.__typedOnMouseLeaves =\n Object.keys(remainingCallbacks).length > 0 ? remainingCallbacks : undefined;\n }\n this.syncTypedOnMouseLeavesToRegistry();\n }\n pruneTypedOnMouseLeaves() {\n if (!this.__typedOnMouseLeaves || this.__typedOnMouseLeaves === NO_ON_MOUSE_LEAVES) {\n this.__typedOnMouseLeaves = undefined;\n this.syncTypedOnMouseLeavesToRegistry();\n return;\n }\n const nextTypedOnMouseLeaves = {};\n for (const [type, callbacks] of Object.entries(this.__typedOnMouseLeaves)) {\n const ids = this.__typedIDs[type];\n if (!ids || ids.length === 0) {\n continue;\n }\n const idSet = new Set(ids);\n const filteredCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n if (idSet.has(id)) {\n filteredCallbacks[id] = callback;\n }\n }\n if (Object.keys(filteredCallbacks).length > 0) {\n nextTypedOnMouseLeaves[type] = filteredCallbacks;\n }\n }\n this.__typedOnMouseLeaves =\n Object.keys(nextTypedOnMouseLeaves).length > 0 ? nextTypedOnMouseLeaves : undefined;\n this.syncTypedOnMouseLeavesToRegistry();\n }\n invokeOnRemove(type, id, cause) {\n const callbacks = this.getTypedOnRemoves();\n const callback = callbacks[type]?.[id];\n if (!callback)\n return;\n const editor = $getEditor();\n const key = removalKey(type, id);\n const reportedHere = reportedMarks.get(editor);\n if (silencedRemovals.get(editor)?.has(key) || reportedHere?.get(key)?.has(this.getKey())) {\n this.removeOnRemoveFor(type, id);\n return;\n }\n removalReports.get(editor)?.push([type, id]);\n if (reportedHere) {\n let marks = reportedHere.get(key);\n if (!marks)\n reportedHere.set(key, (marks = new Set()));\n marks.add(this.getKey());\n }\n try {\n callback(type, id, cause, this.getTextContent());\n }\n catch (error) {\n // Thrown here, a host's error would make Lexical discard the whole update — the user's edit\n // with it — and skip this removal's other reports. The editor's error handler gets it once\n // the update is done instead.\n queueMicrotask(() => editor._onError(error instanceof Error ? error : new Error(String(error))));\n }\n this.removeOnRemoveFor(type, id);\n }\n dispatchRemovedIDs(previous, next, cause) {\n const removedPairs = collectRemovedTypeIdPairs(previous, next);\n if (removedPairs.length === 0)\n return;\n for (const [type, id] of removedPairs)\n this.invokeOnRemove(type, id, cause);\n }\n dispatchOnRemoveForTypedIDs(typedIDs, cause) {\n for (const [type, ids] of Object.entries(typedIDs)) {\n if (!ids)\n continue;\n for (const id of ids)\n this.invokeOnRemove(type, id, cause);\n }\n }\n mergeWithAdjacentTypedMarks() {\n if (this.hasNoIDsForEveryType())\n return this;\n let previousSibling = this.getPreviousSibling();\n while ($isTypedMarkNode(previousSibling) &&\n typedIDsAreEqual(previousSibling.getTypedIDs(), this.getTypedIDs())) {\n this.mergeWithPreviousTypedMark(previousSibling);\n previousSibling = this.getPreviousSibling();\n }\n let nextSibling = this.getNextSibling();\n while ($isTypedMarkNode(nextSibling) &&\n typedIDsAreEqual(this.getTypedIDs(), nextSibling.getTypedIDs())) {\n this.mergeWithNextTypedMark(nextSibling);\n nextSibling = this.getNextSibling();\n }\n return this;\n }\n mergeWithPreviousTypedMark(previous) {\n this.mergeOnClicksFrom(previous.getTypedOnClicks());\n this.mergeOnRemovesFrom(previous.getTypedOnRemoves());\n this.mergeOnMouseEntersFrom(previous.getTypedOnMouseEnters());\n this.mergeOnMouseLeavesFrom(previous.getTypedOnMouseLeaves());\n const previousChildren = previous.getChildren();\n if (previousChildren.length > 0) {\n this.splice(0, 0, previousChildren);\n }\n previous.getWritable().__suppressOnRemoveCallbacks = true;\n previous.remove();\n }\n mergeWithNextTypedMark(next) {\n this.mergeOnClicksFrom(next.getTypedOnClicks());\n this.mergeOnRemovesFrom(next.getTypedOnRemoves());\n this.mergeOnMouseEntersFrom(next.getTypedOnMouseEnters());\n this.mergeOnMouseLeavesFrom(next.getTypedOnMouseLeaves());\n const nextChildren = next.getChildren();\n if (nextChildren.length > 0) {\n this.append(...nextChildren);\n }\n next.getWritable().__suppressOnRemoveCallbacks = true;\n next.remove();\n }\n mergeOnClicksFrom(additional) {\n if (!additional || Object.keys(additional).length === 0)\n return;\n const merged = mergeTypedOnClickMaps(this.getTypedOnClicks(), additional);\n if (Object.keys(merged).length === 0)\n return;\n this.setTypedOnClicks(merged);\n }\n mergeOnRemovesFrom(additional) {\n if (!additional || Object.keys(additional).length === 0)\n return;\n const merged = mergeTypedOnRemoveMaps(this.getTypedOnRemoves(), additional);\n if (Object.keys(merged).length === 0)\n return;\n this.setTypedOnRemoves(merged);\n }\n mergeOnMouseEntersFrom(additional) {\n if (!additional || Object.keys(additional).length === 0)\n return;\n const merged = mergeTypedOnMouseEnterMaps(this.getTypedOnMouseEnters(), additional);\n if (Object.keys(merged).length === 0)\n return;\n this.setTypedOnMouseEnters(merged);\n }\n mergeOnMouseLeavesFrom(additional) {\n if (!additional || Object.keys(additional).length === 0)\n return;\n const merged = mergeTypedOnMouseLeaveMaps(this.getTypedOnMouseLeaves(), additional);\n if (Object.keys(merged).length === 0)\n return;\n this.setTypedOnMouseLeaves(merged);\n }\n}\nfunction cloneTypedIDs(typedIds = NO_IDS) {\n const clone = {};\n for (const [type, ids] of Object.entries(typedIds)) {\n assertSafeKey(type);\n if (!Array.isArray(ids)) {\n clone[type] = [];\n continue;\n }\n const clonedIds = [];\n for (const id of ids) {\n assertSafeKey(id);\n clonedIds.push(id);\n }\n clone[type] = clonedIds;\n }\n return clone;\n}\nfunction cloneTypedOnClicks(typedOnClicks) {\n if (!typedOnClicks || typedOnClicks === NO_ON_CLICKS)\n return undefined;\n const clone = {};\n for (const [type, callbacks] of Object.entries(typedOnClicks)) {\n assertSafeKey(type);\n const clonedCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n assertSafeKey(id);\n clonedCallbacks[id] = callback;\n }\n if (Object.keys(clonedCallbacks).length > 0)\n clone[type] = clonedCallbacks;\n }\n return Object.keys(clone).length > 0 ? clone : undefined;\n}\nfunction cloneTypedOnRemoves(typedOnRemoves) {\n if (!typedOnRemoves || typedOnRemoves === NO_ON_REMOVES)\n return undefined;\n const clone = {};\n for (const [type, callbacks] of Object.entries(typedOnRemoves)) {\n assertSafeKey(type);\n const clonedCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n assertSafeKey(id);\n clonedCallbacks[id] = callback;\n }\n if (Object.keys(clonedCallbacks).length > 0)\n clone[type] = clonedCallbacks;\n }\n return Object.keys(clone).length > 0 ? clone : undefined;\n}\nfunction cloneTypedOnMouseEnters(typedOnMouseEnters) {\n if (!typedOnMouseEnters || typedOnMouseEnters === NO_ON_MOUSE_ENTERS)\n return undefined;\n const clone = {};\n for (const [type, callbacks] of Object.entries(typedOnMouseEnters)) {\n assertSafeKey(type);\n const clonedCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n assertSafeKey(id);\n clonedCallbacks[id] = callback;\n }\n if (Object.keys(clonedCallbacks).length > 0)\n clone[type] = clonedCallbacks;\n }\n return Object.keys(clone).length > 0 ? clone : undefined;\n}\nfunction cloneTypedOnMouseLeaves(typedOnMouseLeaves) {\n if (!typedOnMouseLeaves || typedOnMouseLeaves === NO_ON_MOUSE_LEAVES)\n return undefined;\n const clone = {};\n for (const [type, callbacks] of Object.entries(typedOnMouseLeaves)) {\n assertSafeKey(type);\n const clonedCallbacks = {};\n for (const [id, callback] of Object.entries(callbacks)) {\n assertSafeKey(id);\n clonedCallbacks[id] = callback;\n }\n if (Object.keys(clonedCallbacks).length > 0)\n clone[type] = clonedCallbacks;\n }\n return Object.keys(clone).length > 0 ? clone : undefined;\n}\nfunction omitRecordKey(source, keyToOmit) {\n const result = {};\n for (const [currentKey, value] of Object.entries(source)) {\n if (currentKey !== keyToOmit) {\n result[currentKey] = value;\n }\n }\n return result;\n}\nfunction normalizeTypedIDs(source) {\n const normalized = {};\n for (const [type, ids] of Object.entries(source)) {\n if (!ids || ids.length === 0)\n continue;\n normalized[type] = [...ids].sort();\n }\n return normalized;\n}\nfunction collectRemovedTypeIdPairs(previous, next) {\n const removed = [];\n for (const [type, previousIds] of Object.entries(previous)) {\n const nextIds = new Set(next[type] ?? []);\n for (const id of previousIds ?? []) {\n if (!nextIds.has(id))\n removed.push([type, id]);\n }\n }\n return removed;\n}\nfunction typedIDsAreEqual(a, b) {\n const normalizedA = normalizeTypedIDs(a);\n const normalizedB = normalizeTypedIDs(b);\n const typesA = Object.keys(normalizedA).sort();\n const typesB = Object.keys(normalizedB).sort();\n if (typesA.length !== typesB.length)\n return false;\n for (let i = 0; i < typesA.length; i++) {\n const type = typesA[i];\n if (type !== typesB[i])\n return false;\n const idsA = normalizedA[type];\n const idsB = normalizedB[type];\n if (!idsA || !idsB || idsA.length !== idsB.length)\n return false;\n for (let j = 0; j < idsA.length; j++) {\n if (idsA[j] !== idsB[j])\n return false;\n }\n }\n return true;\n}\nfunction mergeTypedOnClickMaps(primary, secondary) {\n const merged = {};\n const types = new Set([...Object.keys(primary), ...Object.keys(secondary)]);\n for (const type of types) {\n const primaryCallbacks = primary[type] ?? {};\n const secondaryCallbacks = secondary[type] ?? {};\n const ids = new Set([...Object.keys(primaryCallbacks), ...Object.keys(secondaryCallbacks)]);\n const mergedCallbacks = {};\n for (const id of ids) {\n const callback = primaryCallbacks[id] ?? secondaryCallbacks[id];\n if (callback)\n mergedCallbacks[id] = callback;\n }\n if (Object.keys(mergedCallbacks).length > 0)\n merged[type] = mergedCallbacks;\n }\n return merged;\n}\nfunction mergeTypedOnRemoveMaps(primary, secondary) {\n const merged = {};\n const types = new Set([...Object.keys(primary), ...Object.keys(secondary)]);\n for (const type of types) {\n const primaryCallbacks = primary[type] ?? {};\n const secondaryCallbacks = secondary[type] ?? {};\n const ids = new Set([...Object.keys(primaryCallbacks), ...Object.keys(secondaryCallbacks)]);\n const mergedCallbacks = {};\n for (const id of ids) {\n const callback = primaryCallbacks[id] ?? secondaryCallbacks[id];\n if (callback)\n mergedCallbacks[id] = callback;\n }\n if (Object.keys(mergedCallbacks).length > 0)\n merged[type] = mergedCallbacks;\n }\n return merged;\n}\nfunction mergeTypedOnMouseEnterMaps(primary, secondary) {\n const merged = {};\n const types = new Set([...Object.keys(primary), ...Object.keys(secondary)]);\n for (const type of types) {\n const primaryCallbacks = primary[type] ?? {};\n const secondaryCallbacks = secondary[type] ?? {};\n const ids = new Set([...Object.keys(primaryCallbacks), ...Object.keys(secondaryCallbacks)]);\n const mergedCallbacks = {};\n for (const id of ids) {\n const callback = primaryCallbacks[id] ?? secondaryCallbacks[id];\n if (callback)\n mergedCallbacks[id] = callback;\n }\n if (Object.keys(mergedCallbacks).length > 0)\n merged[type] = mergedCallbacks;\n }\n return merged;\n}\nfunction mergeTypedOnMouseLeaveMaps(primary, secondary) {\n const merged = {};\n const types = new Set([...Object.keys(primary), ...Object.keys(secondary)]);\n for (const type of types) {\n const primaryCallbacks = primary[type] ?? {};\n const secondaryCallbacks = secondary[type] ?? {};\n const ids = new Set([...Object.keys(primaryCallbacks), ...Object.keys(secondaryCallbacks)]);\n const mergedCallbacks = {};\n for (const id of ids) {\n const callback = primaryCallbacks[id] ?? secondaryCallbacks[id];\n if (callback)\n mergedCallbacks[id] = callback;\n }\n if (Object.keys(mergedCallbacks).length > 0)\n merged[type] = mergedCallbacks;\n }\n return merged;\n}\nfunction getTypedClassName(className, type) {\n return `${className}-${type}`;\n}\n/**\n * The CSS class names an annotation carrying `typedIDs` is painted with: per type\n * `-`, `-` whenever two ids of the type paint\n * the same text, and `annotationId-` per id. A `` and the display bytes an annotation is\n * held on are painted with the same names, so one host stylesheet styles both.\n */\nexport function typedMarkClassNames(theme, typedIDs) {\n const names = [];\n for (const [type, ids] of Object.entries(typedIDs)) {\n names.push(getTypedClassName(theme.typedMark, type));\n if (ids.length > 1)\n names.push(getTypedClassName(theme.typedMarkOverlap, type));\n for (const id of ids)\n names.push(getTypedClassName(\"annotationId\", id));\n }\n return names;\n}\n/**\n * Gets the external typed mark type.\n *\n * @remarks\n * This is used to ensure unique identification of external typed marks. Along with reserved types\n * prefaced with 'internal-' for internal typed marks @see {@link COMMENT_MARK_TYPE}.\n */\nexport function externalTypedMarkType(type) {\n return `external-${type}`;\n}\nexport function $createTypedMarkNode(typedIds, typedOnClicks, typedOnRemoves, typedOnMouseEnters, typedOnMouseLeaves) {\n return $applyNodeReplacement(new TypedMarkNode(typedIds, typedOnClicks, typedOnRemoves, typedOnMouseEnters, typedOnMouseLeaves));\n}\nexport function $isTypedMarkNode(node) {\n return node instanceof TypedMarkNode;\n}\nexport function isSerializedTypedMarkNode(node) {\n return node?.type === TypedMarkNode.getType();\n}\n/**\n * Remove `type`/`id` from every mark in `markKeys` still holding it (`deleteID`), unwrapping any\n * mark `deleteID` leaves holding no id of any type. Returns how many marks held it.\n */\nexport function $removeTypedMarkId(type, id, markKeys) {\n let count = 0;\n for (const key of markKeys) {\n const node = $getNodeByKey(key);\n if (!$isTypedMarkNode(node) || !node.hasID(type, id))\n continue;\n count++;\n node.deleteID(type, id);\n if (node.hasNoIDsForEveryType())\n $unwrapTypedMarkNode(node);\n }\n return count;\n}\n// #region adapted from https://github.com/facebook/lexical/blob/92c47217244f9d3c22a59728633fb41a10420724/packages/lexical-mark/src/index.ts\nexport function $unwrapTypedMarkNode(node) {\n const children = node.getChildren();\n let target = null;\n for (const child of children) {\n if (target === null) {\n node.insertBefore(child);\n }\n else {\n target.insertAfter(child);\n }\n target = child;\n }\n node.remove();\n}\nexport function $getMarkIDs(node, type, offset) {\n let currentNode = node;\n while (currentNode !== null) {\n if ($isTypedMarkNode(currentNode)) {\n return currentNode.getTypedIDs()[type];\n }\n else if ($isTextNode(currentNode) && offset === currentNode.getTextContentSize()) {\n const nextSibling = currentNode.getNextSibling();\n if ($isTypedMarkNode(nextSibling)) {\n return nextSibling.getTypedIDs()[type];\n }\n }\n currentNode = currentNode.getParent();\n }\n return undefined;\n}\n// #endregion\n","import { createState } from \"lexical\";\n/** Should only be used with CharNodes. */\nexport const charIdState = createState(\"cid\", {\n parse: (v) => (typeof v === \"string\" ? v : undefined),\n});\n/** Can be used on any standard USJ node. */\nexport const segmentState = createState(\"segment\", {\n parse: (v) => (typeof v === \"string\" ? v : undefined),\n});\n/** Should be used with TextNodes. */\nexport const textTypeState = createState(\"textType\", {\n parse: (v) => (typeof v === \"string\" ? v : undefined),\n});\n/**\n * `textTypeState` value tagging the engine-owned NBSP separator between an editable marker glyph\n * and its content (the `[glyph, separator, ...content]` prefix layout). The runtime creator and\n * reader key on this constant — `$createMarkerTrailingSeparator` and\n * `$isMarkerTrailingSeparator` (node.utils.ts) — as does the forward adaptor building the\n * serialized twin for a paragraph's own prefix.\n *\n * It is NOT the only spelling in the codebase: four sites write the tag as a raw string, so\n * changing this value means changing them too. One is a CREATOR — the forward adaptor's table-cell\n * separator (usj-editor.adaptor.ts), whose sibling paragraph-prefix creator a few lines away does\n * use the constant. The other three are readers: the two collab paths that keep the separator's\n * text out of content ops (editor-delta.adaptor.ts and delta-common.utils.ts), and the settled-note\n * unwrap that reads the tag off a SERIALIZED node's `$.textType` (virtualSettle.utils.ts).\n */\nexport const MARKER_TRAILING_SPACE_TEXT_TYPE = \"marker-trailing-space\";\n","/**\n * `AttributeRunNode` — the ONE sibling `ElementNode` that holds a leaf display owner's attribute\n * display run: a verse's `\\va`/`\\vp` value triplet, or a milestone's attribute value. Both owners\n * are leaves that cannot hold children of their own — a `VerseNode` is itself a `TextNode`, and a\n * `MilestoneNode` is a `DecoratorNode` — unlike a `CharNode`, whose attribute run lives INSIDE the\n * span as ordinary children. `AttributeRunNode` gives those two owners the same \"run lives inside\n * a container\" shape a char span already has, without changing either owner's own node type.\n *\n * Its children are the run's pieces — `MarkerNode` opening/closing (or self-closing) glyphs and,\n * in between, the attribute-tagged value `TextNode` (textType \"attribute\") — the same pieces that\n * used to ride as bare following siblings directly on the owner's parent. The wrapper itself\n * contributes no USFM bytes of its own: it is pure editor-owned structure, never part of a\n * conversion to USJ in its own right — only its children's bytes matter.\n *\n * Ownership is POSITION-derived, not stored: the wrapper directly follows the leaf it belongs to —\n * a verse's `\\va` wrapper follows the `VerseNode` itself, and its `\\vp` wrapper follows the `\\va`\n * wrapper (or the verse, when no `\\va` wrapper exists); a milestone's wrapper follows the\n * `MilestoneNode`. Nothing stores a back-reference — a caller locates a wrapper by walking from\n * its owner, the same sibling-walk shape the pre-wrapper display-run code already used.\n *\n * An `AttributeRunNode` with no children is a transient husk — every piece of its run was deleted,\n * leaving an empty wrapper with nothing left to display. It is not itself meaningful state: the\n * marker-edit engine's deletion driver removes empty wrappers as part of settling a deletion, the\n * same way a milestone with its run entirely gone is itself removed. `canBeEmpty()` reports `true`\n * so Lexical's own empty-element normalization does not race that driver by deleting the wrapper\n * on its own schedule.\n */\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\nexport const ATTRIBUTE_RUN_VERSION = 1;\n/** The class every `AttributeRunNode` carries, regardless of `runKind`. */\nexport const ATTRIBUTE_RUN_CLASS_NAME = \"attribute-run\";\n/** The `usfm_` DOM class a runKind's wrapper carries so the stylesheet styles the run\n * exactly like the standalone `char ` span it folds from/unfolds to — or `undefined` for\n * the kinds with no such stylesheet hook (see `createDOM`'s comment). */\nfunction runKindMarkerClass(runKind) {\n return runKind === \"va\" || runKind === \"vp\" || runKind === \"ca\" || runKind === \"cp\"\n ? `usfm_${runKind}`\n : undefined;\n}\nexport class AttributeRunNode extends ElementNode {\n __runKind;\n constructor(runKind, key) {\n super(key);\n this.__runKind = runKind;\n }\n static getType() {\n return \"attribute-run\";\n }\n static clone(node) {\n const { __runKind, __key } = node;\n return new AttributeRunNode(__runKind, __key);\n }\n static importJSON(serializedNode) {\n return $createAttributeRunNode(serializedNode.runKind).updateFromJSON(serializedNode);\n }\n // No HTML shape ever round-trips: `exportDOM` below contributes no wrapper element of its own\n // (a DocumentFragment leaves no markup behind), so there is nothing for a paste to hand back\n // for conversion.\n // Declared explicitly (rather than left unimplemented) so Lexical's dev-mode registration check\n // — which otherwise warns that a custom `exportDOM` needs a matching `importDOM` — recognizes the\n // omission as deliberate.\n static importDOM() {\n return null;\n }\n updateFromJSON(serializedNode) {\n return super.updateFromJSON(serializedNode).setRunKind(serializedNode.runKind);\n }\n setRunKind(runKind) {\n if (this.__runKind === runKind)\n return this;\n const self = this.getWritable();\n self.__runKind = runKind;\n return self;\n }\n getRunKind() {\n const self = this.getLatest();\n return self.__runKind;\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.classList.add(ATTRIBUTE_RUN_CLASS_NAME);\n // va/vp/ca/cp carry a marker-specific class (matching a standalone CharNode's\n // `usfm_` class, per CharNode.test.ts's standalone-attribute-marker pin), so the\n // stylesheet styles the run and the standalone span IDENTICALLY — the run must not look\n // different just because the same bytes currently ride as an attribute. \"milestone\" gets\n // nothing extra — a milestone's marker varies per instance (ts-s, qt1-e, ...) and is not a\n // fixed stylesheet hook — and \"cat\" has no standalone stylesheet styling to match.\n const markerClass = runKindMarkerClass(this.__runKind);\n if (markerClass !== undefined)\n dom.classList.add(markerClass);\n return dom;\n }\n updateDOM(prevNode, dom) {\n // On a key-reused node whose runKind changed, sync the usfm_ class in place so\n // createDOM's discriminator doesn't go stale. `attribute-run` never changes (always present on\n // every runKind), so only the marker-class toggle needs syncing here.\n if (prevNode.__runKind !== this.__runKind) {\n const prevClass = runKindMarkerClass(prevNode.__runKind);\n if (prevClass !== undefined)\n dom.classList.remove(prevClass);\n const nextClass = runKindMarkerClass(this.__runKind);\n if (nextClass !== undefined)\n dom.classList.add(nextClass);\n }\n // Returning false keeps the existing DOM element (updated in place, never recreated — the\n // run-piece children reconcile independently).\n return false;\n }\n exportDOM() {\n // A DocumentFragment rather than null: @lexical/html's $appendNodesToHTML treats a null element\n // as \"skip this subtree\" and never walks the children, which would drop the run's glyphs AND its\n // value text (the \"2\" of `\\va 2\\va*`) from any DOM-export html while getTextContent() keeps them\n // on text/plain. That export is what the HIDDEN-marker views' copy still ships, and what any\n // consumer re-importing html through $generateNodesFromDOM reads; an editable-marker view's own\n // `text/html` is the copy walker's USFM bytes instead and never reaches this method. The\n // fragment exports the children while still contributing no wrapper markup of its own.\n return { element: document.createDocumentFragment() };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n runKind: this.getRunKind(),\n version: ATTRIBUTE_RUN_VERSION,\n };\n }\n // Mutation\n canBeEmpty() {\n return true;\n }\n isInline() {\n return true;\n }\n}\nexport function $createAttributeRunNode(runKind) {\n return $applyNodeReplacement(new AttributeRunNode(runKind));\n}\nexport function $isAttributeRunNode(node) {\n return node instanceof AttributeRunNode;\n}\nexport function isSerializedAttributeRunNode(node) {\n return node?.type === AttributeRunNode.getType();\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/char/index.html */\nimport { $applyNodeReplacement, ElementNode, isHTMLElement, } from \"lexical\";\n/** @see https://docs.usfm.bible/usfm/3.1/char/notes/footnote/index.html */\nconst VALID_CHAR_FOOTNOTE_MARKERS = [\n \"fr\",\n \"fq\",\n \"fqa\",\n \"fk\",\n \"ft\",\n \"fl\",\n \"fw\",\n \"fp\",\n \"fv\",\n \"fm\",\n \"fdc\", // Deprecated marker.\n];\n/** @see https://docs.usfm.bible/usfm/3.1/char/notes/crossref/index.html */\nconst VALID_CHAR_CROSS_REFERENCE_MARKERS = [\n \"xo\",\n \"xop\",\n \"xk\",\n \"xq\",\n \"xt\",\n \"xta\",\n \"xot\",\n \"xnt\",\n \"xdc\", // Deprecated marker.\n];\n/** @see https://docs.usfm.bible/usfm/3.1/char/index.html */\nconst VALID_CHAR_MARKERS = [\n // Chapter & Verse\n \"ca\",\n \"cp\",\n \"va\",\n \"vp\",\n // Text Features\n \"add\",\n \"bk\",\n \"dc\",\n \"em\",\n \"jmp\",\n \"k\",\n \"nd\",\n \"ord\",\n \"pn\",\n \"png\",\n \"qt\",\n \"rb\",\n \"rq\",\n // \"ref\", // This has its own tag and is not a Char\n \"sig\",\n \"sls\",\n \"tl\",\n \"w\",\n \"wa\",\n \"wg\",\n \"wh\",\n \"wj\",\n \"addpn\", // Deprecated marker.\n \"pro\", // Deprecated marker.\n // Text Formatting\n \"bd\",\n \"it\",\n \"bdit\",\n \"no\",\n \"sc\",\n \"sup\",\n // Introductions\n \"ior\",\n \"iqt\",\n // Poetry\n \"qac\",\n \"qs\",\n // Lists\n \"litl\",\n \"lik\",\n \"liv\",\n \"liv1\",\n \"liv2\",\n \"liv3\",\n \"liv4\",\n \"liv5\",\n ...VALID_CHAR_FOOTNOTE_MARKERS,\n ...VALID_CHAR_CROSS_REFERENCE_MARKERS,\n];\nexport const CHAR_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const CHAR_MARKER_OBJECT_PROPS = [\"type\", \"marker\", \"content\"];\nexport class CharNode extends ElementNode {\n __marker;\n __unknownAttributes;\n constructor(marker = \"\", unknownAttributes, key) {\n super(key);\n this.__marker = marker;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"char\";\n }\n static clone(node) {\n const { __marker, __unknownAttributes, __key } = node;\n return new CharNode(__marker, __unknownAttributes, __key);\n }\n static isValidMarker(marker, extraValidMarkers) {\n return (marker !== undefined &&\n (VALID_CHAR_MARKERS.includes(marker) || (extraValidMarkers?.includes(marker) ?? false)));\n }\n static isValidFootnoteMarker(marker) {\n return marker !== undefined && VALID_CHAR_FOOTNOTE_MARKERS.includes(marker);\n }\n static isValidCrossReferenceMarker(marker) {\n return marker !== undefined && VALID_CHAR_CROSS_REFERENCE_MARKERS.includes(marker);\n }\n /**\n * Whether a character marker belongs to the note-content families - footnote or cross-reference.\n *\n * These markers only ever occur inside a `NoteNode`, and unlike every other character marker they\n * are written without a closing marker. Callers branch on this for one reason or the other, so the\n * predicate names the family rather than either consequence; each call site documents which\n * consequence it cares about.\n *\n * @param marker - The character marker to check.\n * @returns `true` if the marker is a footnote or cross-reference marker, `false` otherwise.\n */\n static isNoteContentMarker(marker) {\n return CharNode.isValidFootnoteMarker(marker) || CharNode.isValidCrossReferenceMarker(marker);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isCharElement(node))\n return null;\n return {\n conversion: $convertCharElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createCharNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM(config) {\n const dom = document.createElement(\"span\");\n applyMarkerToDom(dom, this.__marker, config);\n dom.classList.add(this.__type);\n return dom;\n }\n updateDOM(prevNode, dom, config) {\n // Returning false tells Lexical the element can be reused — but reuse means createDOM does not\n // run again, so a marker change has to be written onto the existing element by hand: the\n // data-marker, the title (gated by showCharMarkerTitles, same as createDOM), and the usfm_*\n // class.\n //\n // Scope: this span's own attributes and classes, nothing else. The synthesized marker children\n // that markerMode \"editable\"/\"visible\" add are not touched here - $setCharNodeMarker\n // (node.utils.ts) is what retargets those, and callers changing a marker on a rendered node\n // should go through it. The collaboration path in delta-apply-update.utils.ts still calls\n // setMarker directly, so it gets this attribute refresh but not the child retargeting.\n //\n // No super.updateDOM() call, unlike ParaNode.updateDOM: ParaNode extends ParagraphNode, which\n // implements it. CharNode extends ElementNode, which does not, so super would reach\n // LexicalNode's base method and throw.\n if (prevNode.__marker !== this.__marker) {\n dom.classList.remove(`usfm_${prevNode.__marker}`);\n // The same writes createDOM makes, so the two paths cannot drift: a reused element ends up\n // indistinguishable from a freshly created one, title gating included.\n applyMarkerToDom(dom, this.__marker, config);\n }\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(this.getType(), `usfm_${this.getMarker()}`);\n }\n return { element };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n unknownAttributes: this.getUnknownAttributes(),\n version: CHAR_VERSION,\n };\n }\n // Mutation\n insertNewAfter(_selection, restoreSelection) {\n // The continuation span keeps the implicit-close convention when this span has it: splitting\n // an unclosed (closed=\"false\") span yields two unclosed spans — the same structural-state rule\n // as the marker-edit split paths ($splitCharNodeAt, $liftOutOfChar). Other unknownAttributes\n // are deliberately NOT copied (duplicating them would double the `|name=\"value\"` bytes on\n // serialization).\n const isUnclosed = this.getUnknownAttributes()?.closed === \"false\";\n const newElement = $createCharNode(this.getMarker(), isUnclosed ? { closed: \"false\" } : undefined);\n newElement.setDirection(this.getDirection());\n newElement.setFormat(this.getFormatType());\n newElement.setStyle(this.getTextStyle());\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n canBeEmpty() {\n return false;\n }\n isInline() {\n return true;\n }\n}\n/**\n * Write a marker onto a `CharNode`'s rendered span.\n *\n * Shared by `createDOM` and `updateDOM` so the created and the reused element can't drift. Only the\n * `usfm_*` class is added, never removed — `updateDOM` removes the previous marker's class itself,\n * and `createDOM` has no previous marker to remove.\n *\n * @param dom - The span to write to.\n * @param marker - The character marker to apply.\n * @param config - The editor config, read for the `showCharMarkerTitles` theme flag.\n */\nfunction applyMarkerToDom(dom, marker, config) {\n dom.setAttribute(\"data-marker\", marker);\n // Consumers can suppress the per-char marker tooltip via\n // `ViewOptions.showCharMarkerTitles = false` - useful when the marker name shouldn't\n // surface as a browser tooltip on every char span. Default (undefined or true) preserves\n // the marker hint for consumers that want it while authoring USFM.\n if (config.theme?.showCharMarkerTitles !== false) {\n dom.setAttribute(\"title\", marker);\n }\n else {\n // Clear any title a previous render left behind; on a reused element the gate can flip.\n dom.removeAttribute(\"title\");\n }\n dom.classList.add(`usfm_${marker}`);\n}\nfunction $convertCharElement(element) {\n const marker = element.getAttribute(\"data-marker\") ?? \"f\";\n const node = $createCharNode(marker);\n return { node };\n}\nexport function $createCharNode(marker, unknownAttributes) {\n return $applyNodeReplacement(new CharNode(marker, unknownAttributes));\n}\nfunction isCharElement(node) {\n if (!node)\n return false;\n const marker = node.getAttribute(\"data-marker\") ?? \"\";\n return CharNode.isValidMarker(marker) && node.classList.contains(CharNode.getType());\n}\nexport function $isCharNode(node) {\n return node instanceof CharNode;\n}\nexport function isSerializedCharNode(node) {\n return node?.type === CharNode.getType();\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/cv/v.html */\nimport { VERSE_CLASS_NAME } from \"./node-constants.js\";\nimport { $applyNodeReplacement, TextNode, } from \"lexical\";\nexport const VERSE_MARKER = \"v\";\nexport const VERSE_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const VERSE_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"number\",\n \"sid\",\n \"altnumber\",\n \"pubnumber\",\n \"content\",\n];\nexport class VerseNode extends TextNode {\n __marker;\n __number;\n __sid;\n __altnumber;\n __pubnumber;\n __unknownAttributes;\n constructor(verseNumber = \"\", text, sid, altnumber, pubnumber, unknownAttributes, key) {\n super(text ?? verseNumber, key);\n this.__marker = VERSE_MARKER;\n this.__number = verseNumber;\n this.__sid = sid;\n this.__altnumber = altnumber;\n this.__pubnumber = pubnumber;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"verse\";\n }\n static clone(node) {\n const { __number, __text, __sid, __altnumber, __pubnumber, __unknownAttributes, __key } = node;\n return new VerseNode(__number, __text, __sid, __altnumber, __pubnumber, __unknownAttributes, __key);\n }\n static importJSON(serializedNode) {\n return $createVerseNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setNumber(serializedNode.number)\n .setSid(serializedNode.sid)\n .setAltnumber(serializedNode.altnumber)\n .setPubnumber(serializedNode.pubnumber)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setNumber(verseNumber) {\n if (this.__number === verseNumber)\n return this;\n const self = this.getWritable();\n self.__number = verseNumber;\n return self;\n }\n getNumber() {\n const self = this.getLatest();\n return self.__number;\n }\n setSid(sid) {\n if (this.__sid === sid)\n return this;\n const self = this.getWritable();\n self.__sid = sid;\n return self;\n }\n getSid() {\n const self = this.getLatest();\n return self.__sid;\n }\n setAltnumber(altnumber) {\n if (this.__altnumber === altnumber)\n return this;\n const self = this.getWritable();\n self.__altnumber = altnumber;\n return self;\n }\n getAltnumber() {\n const self = this.getLatest();\n return self.__altnumber;\n }\n setPubnumber(pubnumber) {\n if (this.__pubnumber === pubnumber)\n return this;\n const self = this.getWritable();\n self.__pubnumber = pubnumber;\n return self;\n }\n getPubnumber() {\n const self = this.getLatest();\n return self.__pubnumber;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM(config) {\n const dom = super.createDOM(config);\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(VERSE_CLASS_NAME, `usfm_${this.__marker}`);\n dom.setAttribute(\"data-number\", this.__number);\n return dom;\n }\n updateDOM(prevNode, dom, config) {\n const recreate = super.updateDOM(prevNode, dom, config);\n if (!recreate && prevNode.__number !== this.__number)\n dom.setAttribute(\"data-number\", this.__number);\n return recreate;\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n number: this.getNumber(),\n sid: this.getSid(),\n altnumber: this.getAltnumber(),\n pubnumber: this.getPubnumber(),\n unknownAttributes: this.getUnknownAttributes(),\n version: VERSE_VERSION,\n };\n }\n}\nexport function $createVerseNode(verseNumber, text, sid, altnumber, pubnumber, unknownAttributes) {\n return $applyNodeReplacement(new VerseNode(verseNumber, text, sid, altnumber, pubnumber, unknownAttributes));\n}\nexport function $isVerseNode(node) {\n return node instanceof VerseNode;\n}\nexport function isSerializedVerseNode(node) {\n return node?.type === VerseNode.getType();\n}\n","/**\n * Attribute display runs: the single place that owns HOW a node's USFM attribute bytes\n * (`|lemma=\"grace\" strong=\"G5485\"`, `|gloss`) are rendered as engine-owned display text and kept\n * in sync. Sibling of nestedGlyphs.utils.ts (glyph `+`) and markerSeparators.utils.ts (opener\n * separators), following the same owning-module shape.\n *\n * ## The representations (who owns what)\n *\n * - **Node state is the truth.** Char-span attributes live in `CharNode.__unknownAttributes`;\n * milestone attributes in `MilestoneNode` props + `__unknownAttributes`; a verse's `\\va`/`\\vp`\n * values in `VerseNode.__altnumber`/`__pubnumber`. The display run is a derived cache, never a\n * second store.\n * - **The display run** is a TextNode tagged textType \"attribute\" holding the canonical PT9 byte\n * form produced by {@link canonicalAttributeText}: a lone default attribute collapses to\n * `|value`; anything else is `|name=\"value\" …` (double quotes, single spaces, insertion\n * order). `closed` is derived metadata, never displayed. Char runs are bare `|…` directly\n * before the closing glyph (PT9's shape; an NBSP prefix would flatten to a space and leak\n * into span content on a Tier-2 rebuild). Milestone runs keep the NBSP+`|` prefix — that NBSP\n * flattens to the space genuinely in the file (`\\qt-s |sid=\"…\"\\*`). A verse's `\\va`/`\\vp`\n * values aren't `name=\"value\"` attribute bytes at all — PT9 displays them as their own\n * `MarkerNode` open + NBSP-prefixed value TextNode + `MarkerNode` close triplet, riding as the\n * verse's FOLLOWING SIBLINGS (a `VerseNode` is itself a TextNode, not a container). A\n * milestone's run is shaped the same way — opening `MarkerNode` + optional NBSP-prefixed\n * attribute TextNode + self-closing `MarkerNode` `\\*`, riding as the `MilestoneNode`'s\n * FOLLOWING SIBLINGS (a `MilestoneNode` is a `DecoratorNode`, so it cannot hold children\n * either) — except the glyphs themselves are unconditional: a milestone always shows its\n * opening/self-closing pair, with only the middle attribute text coming and going.\n * - **Excluded from data paths**: textType \"attribute\" text never enters OT content ops or the\n * editor→USJ conversion; the Tier-2 fragment is the one place it DOES flow, so edited bytes\n * re-tokenize back into node state (extractAttributes / scanMilestone).\n *\n * ## Keeping the cache honest\n *\n * Builders construct the run (usj-editor.adaptor's `createChar`/`addAttributes`/\n * `addVerseAttributes`; transforms do not run on `setEditorState`). A char span's own run, a\n * verse's `\\va`/`\\vp` runs, and a milestone's run all follow the identical contract through the\n * shared `$syncDisplayRun` driver (displayRunSync.utils.ts), parameterized by each kind's own\n * descriptor rather than defined in this module — re-deriving the run whenever its owner is\n * dirtied, healing remote collab updates (the collab materializer's `$createMilestone` builds a\n * BARE `MilestoneNode` with no run at all — delta-apply-update.utils.ts) and structure surgery.\n * While the collapsed caret sits inside the run the sync leaves it alone (mid-edit grace); the\n * marker-edit engine settles it on caret departure by pending the edited run into its Tier-2\n * completion path — the displayed bytes re-tokenize back into node state (last-write-wins,\n * uniformly across chars, verses, and milestones), and a milestone whose run was deleted OUTRIGHT\n * (the shared `$runEntirelyAbsent` check, displayRunSync.utils.ts, parameterized by the milestone\n * descriptor) is itself removed, since the run is its entire byte representation. `MilestoneNode`\n * is the SAME type in every mode — unlike the char/verse EDITABLE node types, which never appear\n * outside editable mode — so its sync is registered only in `MarkerEditPlugin.tsx`, which is itself\n * markerMode-\"editable\"-gated, to keep visible/hidden mode's `ImmutableTypedTextNode`-based\n * milestone runs (built by the adaptor, never edited) untouched.\n */\nimport { $isCanonicalMarkerNode, $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { $isTypedMarkNode } from \"../features/TypedMarkNode.js\";\nimport { textTypeState } from \"../collab/delta.state.js\";\nimport { $isAttributeRunNode } from \"./AttributeRunNode.js\";\nimport { $isCharNode } from \"./CharNode.js\";\nimport { MS_NON_ATTRIBUTE_PROPS } from \"./MilestoneNode.js\";\nimport { getEditableCallerText, openingMarkerText } from \"./markerText.utils.js\";\nimport { $isVerseNode } from \"./VerseNode.js\";\nimport { $getState, $isTextNode, TextNode } from \"lexical\";\n/** USJ artifacts that are not USFM attribute bytes and must never display. */\nexport const ATTRIBUTE_EXCLUDED_KEYS = new Set([\"closed\"]);\n/**\n * The canonical PT9 byte form of an attribute set, including the leading `|` — or `\"\"` when\n * nothing displays. A lone attribute that IS the marker's default collapses to the bare value\n * (`|gloss`); everything else is explicit `name=\"value\"` pairs, double-quoted, single-spaced,\n * insertion order. Values are kept byte-exact (ParatextData treats trailing space as value).\n */\nexport function canonicalAttributeText(attributes, defaultAttributeName) {\n const entries = Object.entries(attributes).filter(([name, value]) => value !== undefined && !ATTRIBUTE_EXCLUDED_KEYS.has(name));\n if (entries.length === 0)\n return \"\";\n // The bare-value collapse requires a NON-EMPTY value: a lone `|` is a byte sequence the\n // tokenizer refuses outright (`parseAttributeText`, PT9 parity), so collapsing an empty\n // default value displayed a run whose settle re-read it as plain content — the attribute\n // name vanished from the file and a stray `|` landed in the scripture text. The explicit\n // `name=\"\"` form keeps the name on screen, and a refused re-tokenize then degrades to\n // visible literal bytes instead of silently corrupting.\n if (entries.length === 1 && entries[0][0] === defaultAttributeName && entries[0][1] !== \"\")\n return `|${entries[0][1]}`;\n return `|${entries.map(([name, value]) => `${name}=\"${value}\"`).join(\" \")}`;\n}\n/**\n * Re-keys `attributes` into `attributeOrder`, appending any name the order does not mention after\n * the ones it does, in their existing order. Both kinds of mismatch are expected rather than\n * exceptional, so neither is an error: the settle re-derives a milestone's attributes from its\n * DISPLAYED BYTES, so an edit can drop a name the order still lists or add one it never knew\n * about, and the surviving names must keep their authored positions either way.\n *\n * Membership is tested by presence, not against `undefined`, so a genuinely empty value (`sid=\"\"`)\n * keeps its authored slot rather than being silently relocated to the end. `Object.hasOwn` rather\n * than `in`: USFM attribute names are unconstrained, so an attribute literally named `toString` or\n * `constructor` reads as already-present on a plain object and would be dropped from the output —\n * deleting the author's bytes — while `in attributes` would copy a native function into the bag.\n */\nexport function orderedAttributes(attributes, attributeOrder) {\n if (!attributeOrder || attributeOrder.length === 0)\n return attributes;\n const ordered = {};\n attributeOrder.forEach((name) => {\n if (Object.hasOwn(attributes, name))\n ordered[name] = attributes[name];\n });\n Object.entries(attributes).forEach(([name, value]) => {\n if (!Object.hasOwn(ordered, name))\n ordered[name] = value;\n });\n return ordered;\n}\n/**\n * The order `markerObject` authored its attributes in — or `undefined` when that is already the\n * CANONICAL order, which is `sid`, then `eid`, then everything else in the order it appeared.\n *\n * Returning `undefined` for the canonical case is what keeps this change invisible to every\n * document that does not need it: `MilestoneNode.attributeOrder` then stays absent, so canonically\n * ordered milestones serialize byte-identically to before and no stored state has to be migrated.\n *\n * Which names take part is defined by {@link MS_NON_ATTRIBUTE_PROPS}: `type`, `marker`, and\n * `content` are never attribute bytes; `sid` and `eid` are ordinary keys of the USJ marker object\n * that render into the same `|…` run as `who`, so they order against the rest with no special case.\n */\nexport function milestoneAttributeOrder(markerObject) {\n const authored = Object.keys(markerObject).filter((name) => !MS_NON_ATTRIBUTE_PROPS.includes(name));\n const canonical = [\n ...authored.filter((name) => name === \"sid\"),\n ...authored.filter((name) => name === \"eid\"),\n ...authored.filter((name) => name !== \"sid\" && name !== \"eid\"),\n ];\n return authored.every((name, index) => name === canonical[index]) ? undefined : authored;\n}\n/**\n * The attribute object a milestone's canonical display text is derived from: `sid`/`eid` folded\n * in first (their real USJ-object positions), then whatever else the marker carries (chiefly\n * `who`). Shared by usj-editor.adaptor's `addAttributes` (building the run from a `MarkerObject`)\n * and the milestone descriptor's `expectedPieces` (displayRun/displayRunRegistry.ts, healing it\n * from a live `MilestoneNode`'s fields through the shared `$syncDisplayRun` driver) so the two\n * sites — one USJ-shaped, one node-shaped — can never drift on WHICH fields make up a milestone's\n * displayed attributes.\n *\n * `attributeOrder` overrides that sid-first default with the order the document actually authored\n * ({@link milestoneAttributeOrder}), which Paratext 9 preserves and the USJ-to-USFM writer emits\n * verbatim — so folding in a fixed order would rewrite bytes in the file. It is `undefined` for\n * every milestone whose source was already canonical, which is the overwhelming majority.\n */\nexport function milestoneAttributes(sid, eid, unknownAttributes, attributeOrder) {\n return orderedAttributes(\n // Presence, not truthiness: an authored `sid=\"\"` is a byte the document holds, and folding it\n // out here deletes it from the displayed run — which a settle then re-derives node state from,\n // so the empty value would be gone from the file. Matches `orderedAttributes`' own `in` test\n // directly above, which exists for exactly this reason.\n {\n ...(sid !== undefined && { sid }),\n ...(eid !== undefined && { eid }),\n ...unknownAttributes,\n }, attributeOrder);\n}\n/**\n * `char`'s own closing glyph among its direct children, if any — the display run's insertion\n * anchor, and the tree signal for whether a run may exist at all. A span whose closing glyph is\n * skipped (a `closed=\"false\"` span — the state that makes footnote/cross-ref content chars and any\n * other genuinely-unclosed span render closer-less) or simply absent never renders one: `createChar`\n * (usj-editor.adaptor) never builds a run there, so the sync must not fabricate one either —\n * deriving the rule from tree shape rather than viewOptions also keeps the sync a no-op outside\n * editable mode, where char spans carry no MarkerNode glyphs at all.\n */\nexport function $charClosingGlyph(char) {\n return char\n .getChildren()\n .find((child) => $isMarkerNode(child) &&\n child.getMarkerSyntax() === \"closing\" &&\n child.getMarker() === char.getMarker());\n}\n/**\n * True when `char` carries attribute bytes that Tier-2 re-tokenization can never recover: real\n * (non-`closed`) attributes with NEITHER a closing glyph ({@link $charClosingGlyph}) NOR an\n * existing display run ({@link $charAttributeDisplayNode}) anywhere among its children. EITHER\n * anchor alone is enough to recover: a live display run carries the bytes into the fragment\n * regardless of the closer (a closer edit — deleted, damaged — re-tokenizes and settles, possibly\n * degrading to literal content, exactly like any other char content); a live closing glyph gives\n * `extractAttributes` a well-defined close event even if the run itself was just deleted (settles\n * to no attributes). Only when BOTH are absent — a `closed=\"false\"` span skips the glyph AND never\n * gets a run built for it — does an attribute such as `link-href` on an unclosed span have no\n * visible representation anywhere in the tree for the Tier-2 fragment builder to pick up. (An\n * explicitly-closed `\\xt`, by contrast, renders its closing glyph, so its attribute run IS built\n * and the span is recoverable.) A span with unrecoverable attributes must stay a Tier-2 sentinel\n * (preserve-or-refuse, tier2Rebuild.utils.ts): recursing into it would silently drop the attribute.\n */\nexport function $hasUnrecoverableAttributes(char) {\n const attributes = char.getUnknownAttributes();\n if (!attributes)\n return false;\n const hasRealAttributes = Object.keys(attributes).some((name) => name !== \"closed\");\n if (!hasRealAttributes)\n return false;\n return $charClosingGlyph(char) === undefined && $charAttributeDisplayNode(char) === undefined;\n}\n/**\n * `char`'s direct-child display run — the TextNode tagged textType \"attribute\" — or `undefined`\n * if none exists.\n */\nexport function $charAttributeDisplayNode(char) {\n return char\n .getChildren()\n .find((child) => $isTextNode(child) && $getState(child, textTypeState) === \"attribute\");\n}\n/**\n * A verse attribute marker's run pieces — opener `MarkerNode` (matching `marker`), value TextNode\n * (textType \"attribute\"), closer `MarkerNode` — scanned tolerantly in their fixed order starting\n * immediately after `after`, with EACH piece individually optional. Mirrors\n * {@link $milestoneAttributeRunPieces}: a mid-edit tree can be missing any subset — deleting just\n * the value leaves opener + closer debris — and the tolerant scan lets callers recognize and grace\n * that partial state and repair only the genuinely missing pieces around whatever survives, never\n * duplicating a leftover. The old all-or-nothing model returned \"no run at all\" for a\n * value-deleted run and re-derived a whole new opener/value/closer over the surviving debris on the\n * next sync (the value-deletion resurrect/duplicate bug).\n *\n * When `after`'s immediately following sibling is an `AttributeRunNode` whose `runKind` matches\n * `marker`, the SAME tolerant scan runs over the wrapper's CHILDREN instead of `after`'s siblings\n * — a wrapper's children are the run's pieces in the identical fixed order, so redirecting the\n * cursor's starting point is the only change needed. The adaptor always builds this shape now; the\n * sync still heals whichever shape — loose siblings (a pre-flip editor state, an undo stack, or a\n * collab-materialized bare owner) or an existing wrapper — is actually in the tree.\n *\n * A glyph is a piece only while its RENDERED BYTES still spell what its state describes\n * ({@link $isCanonicalMarkerNode}). Editing a glyph's characters leaves its marker and syntax\n * untouched, so a state-only scan reports a damaged `\\va` (the `*` deleted) as a perfectly good\n * closer: the run reads canonical here while the marker engine holds the same glyph pending,\n * and that standing disagreement is what silently suppressed the run's mid-edit caret grace —\n * `$runDiverges` saw nothing wrong, so the settle re-tokenized the whole paragraph out from\n * under the caret two keystrokes into the edit. Byte-damaged glyphs are therefore reported\n * ABSENT, which is the truth the rest of the pipeline already knows how to handle: the run\n * diverges, the caret graces it, and departure settles it.\n *\n * Exported (mirrors {@link $milestoneAttributeRunPieces}) so `markerEditTier1.utils.ts`'s\n * deletion-settle path (`packages/platform`) can locate a verse's wrapper(s) directly to detect\n * and clean up an emptied husk.\n */\nexport function $verseAttributeRunPieces(after, marker) {\n return $attributeMarkerRunPieces(after.getNextSibling(), marker);\n}\n/** The separator-run alphabet — plain space and NBSP, the whitespace class the marker-edit\n * engine's separator runs are built from. */\nconst TYPED_SPACING_ONLY_REGEX = /^[ \\u00A0]+$/;\n/**\n * Whether a display-run OPENING glyph's bytes are canonical, or canonical plus trailing TYPED\n * SPACING. A space typed at the end of a run's opening glyph is the same gesture as one typed\n * beside its value — the typed-space-stays rule: the writer emits structural whitespace itself,\n * so the byte never reaches the file. Reporting the glyph byte-damaged instead routed the\n * keystroke into a settle that discarded the space while the caret advanced past the run — a\n * keystroke accepted and then discarded (\"no silent no-ops\"). Openers only: a closer's `*` is\n * its final byte, so trailing bytes there genuinely respell it. Only for glyphs the CALLER knows\n * are run pieces — a char or para opener's spacing story belongs to its separator machinery\n * (markerSeparators.utils.ts), never to this license.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $isCanonicalRunOpenerGlyph(node) {\n if ($isCanonicalMarkerNode(node))\n return true;\n if (node.getMarkerSyntax() !== \"opening\")\n return false;\n const canonical = openingMarkerText(node.getMarker(), node.getNested());\n const text = node.getTextContent();\n return text.startsWith(canonical) && TYPED_SPACING_ONLY_REGEX.test(text.slice(canonical.length));\n}\n/**\n * The shared tolerant scan behind {@link $verseAttributeRunPieces} and\n * {@link $noteCategoryRunPieces}: an attribute MARKER's run pieces — opener `MarkerNode`\n * (matching `marker`), value TextNode (textType \"attribute\"), closer `MarkerNode` — read in their\n * fixed order starting at `cursor`, each piece individually optional, descending into an\n * `AttributeRunNode` wrapper whose `runKind` matches `marker` when one sits at `cursor`. The two\n * public entry points differ only in where the run RIDES (a verse's following siblings vs a\n * note's children after the caller), which is entirely captured by the starting cursor.\n */\nfunction $attributeMarkerRunPieces(cursor, marker) {\n let opener;\n let value;\n let closer;\n let wrapper;\n if ($isAttributeRunNode(cursor) && cursor.getRunKind() === marker) {\n wrapper = cursor;\n cursor = cursor.getFirstChild();\n }\n if ($isMarkerNode(cursor) &&\n cursor.getMarkerSyntax() === \"opening\" &&\n cursor.getMarker() === marker &&\n // Typed-spacing licensed ({@link $isCanonicalRunOpenerGlyph}): a trailing space typed on the\n // opener is at rest, not byte damage.\n $isCanonicalRunOpenerGlyph(cursor)) {\n opener = cursor;\n cursor = cursor.getNextSibling();\n }\n // A MarkerNode is itself a TextNode subclass, so the attribute-state check (never set on a\n // glyph) is what keeps a closer from being misread as the value.\n if ($isTextNode(cursor) && $getState(cursor, textTypeState) === \"attribute\") {\n value = cursor;\n cursor = cursor.getNextSibling();\n }\n if ($isMarkerNode(cursor) &&\n cursor.getMarkerSyntax() === \"closing\" &&\n cursor.getMarker() === marker &&\n $isCanonicalMarkerNode(cursor))\n closer = cursor;\n return { opener, value, closer, wrapper };\n}\n/**\n * The node an annotation mark wraps, unwrapped — marks are transparent to every USJ-facing view\n * of the tree (the exporter splices them, the logical content model splices them), so a slot that\n * identifies a node by its position among its parent's children has to see through one or the\n * construct dissolves the moment a comment is placed on it. Nested marks only exist transiently\n * before the AnnotationPlugin flattens them, hence the loop.\n */\nfunction $throughMarks(node) {\n let current = node;\n while ($isTypedMarkNode(current))\n current = current.getChildren()[0];\n return current;\n}\n/**\n * The TextNode carrying a note's EDITABLE caller (` + ` with an NBSP tail —\n * `getEditableCallerText`), skipping any leading opening glyph(s) and looking through any\n * annotation mark wrapping it — the anchor a note's `\\cat` run scans from and is inserted after.\n * `undefined` outside the expanded editable shape: a collapsed note renders its caller as a\n * DecoratorNode and deliberately shows no category run, and visible/hidden modes build no\n * editable caller at all. Deriving the anchor from tree shape (rather than viewOptions) keeps the\n * cat sync a structural no-op in every mode that never builds the run, the same rule\n * {@link $charClosingGlyph} applies for a char span's run.\n *\n * The text is the caller's while its bytes are damaged too: the unmergeable text the note builders\n * make for the caller and nothing else (`toggleUnmergeable`), which waits as the user left it\n * while the caret is at it (the marker-edit engine's caller transform). Any other text in the slot\n * — content left there once the caller text was removed — is content, unless it spells the caller\n * exactly (a shape built without the flag).\n */\nexport function $noteEditableCallerNode(note) {\n const children = note.getChildren();\n let index = 0;\n while (index < children.length) {\n const child = children[index];\n if (!$isMarkerNode(child) || child.getMarkerSyntax() !== \"opening\")\n break;\n index++;\n }\n const caller = $throughMarks(children[index]);\n if (!$isTextNode(caller) || caller.getType() !== TextNode.getType())\n return undefined;\n if (caller.getTextContent() === getEditableCallerText(note.getCaller()))\n return caller;\n return caller.isUnmergeable() ? caller : undefined;\n}\n/**\n * A note's `\\cat` category display run — the same opener/value/closer triplet shape a verse's\n * `\\va`/`\\vp` runs take ({@link $verseAttributeRunPieces}), riding as the note's CHILDREN\n * directly after the editable caller (a `NoteNode` is an ElementNode, so unlike the leaf owners\n * its run needs no sibling position). Empty pieces when the note has no editable caller anchor —\n * the collapsed and non-editable shapes, which never carry a run.\n */\nexport function $noteCategoryRunPieces(note) {\n const caller = $noteEditableCallerNode(note);\n if (!caller)\n return {};\n return $attributeMarkerRunPieces(caller.getNextSibling(), \"cat\");\n}\n/**\n * The plain TextNode carrying an editable chapter's `\\c N` glyph — its first child — the anchor\n * a chapter's `\\ca` run scans from and is inserted after. Accepts the node while it remains a\n * plain (non-glyph, non-attribute) TextNode even when its BYTES are mid-edit — unlike the note's\n * caller, the chapter glyph is itself editable display text, so an exact-text requirement would\n * dissolve the anchor on the first keystroke of a number rename. `undefined` when the glyph text\n * was deleted outright or the chapter is not the editable element shape.\n */\nexport function $chapterGlyphTextNode(chapter) {\n const first = chapter.getFirstChild();\n if (!$isTextNode(first) || $isMarkerNode(first))\n return undefined;\n if ($getState(first, textTypeState) === \"attribute\")\n return undefined;\n return first;\n}\n/**\n * A chapter's `\\ca` alternate-number display run — the identical triplet shape and child\n * position as a note's `\\cat` run ({@link $noteCategoryRunPieces}): an editable `ChapterNode` is\n * an ElementNode, and the run rides directly after its `\\c N` glyph text, where the file puts\n * the span (`\\c 1 \\ca 2\\ca*`). Empty pieces when the glyph anchor is gone.\n */\nexport function $chapterAltnumberRunPieces(chapter) {\n const glyph = $chapterGlyphTextNode(chapter);\n if (!glyph)\n return {};\n return $attributeMarkerRunPieces(glyph.getNextSibling(), \"ca\");\n}\n/** The child a chapter's `\\cp` run is anchored after: `\\ca`'s wrapper (or, while caret-grace\n * defers the wrap, its loose closer), else the `\\c N` glyph text — the chapter twin of\n * `$verseRunAnchor`'s `\\vp` arm. Shared by the scanner and the writer so the two can never\n * disagree about where the run belongs. `undefined` when the glyph anchor is gone. */\nexport function $chapterCpAnchor(chapter) {\n const glyph = $chapterGlyphTextNode(chapter);\n if (!glyph)\n return undefined;\n const ca = $attributeMarkerRunPieces(glyph.getNextSibling(), \"ca\");\n return ca.wrapper ?? ca.closer ?? glyph;\n}\n/**\n * A chapter's `\\cp` published-number display run — opener glyph + NBSP-prefixed value, with NO\n * closing glyph: `\\cp`'s span closes implicitly at the next block boundary in the file, so its\n * displayed run is bounded by its wrapper alone. Rides directly after the `\\ca` run (or the\n * `\\c N` glyph when there is none) — document order `ca` before `cp`, the order ParatextData\n * preserves on disk. Empty pieces when the glyph anchor is gone.\n */\nexport function $chapterPubnumberRunPieces(chapter) {\n const anchor = $chapterCpAnchor(chapter);\n if (!anchor)\n return {};\n return $attributeMarkerRunPieces(anchor.getNextSibling(), \"cp\");\n}\n/**\n * The VerseNode whose `\\va`/`\\vp` SOURCE span `node` is content of, or `undefined`. A settled\n * empty run leaves a standalone `char va`/`char vp` span in the verse's run position (displayed\n * `\\va \\va*`); a value typed into it is an ordinary content edit that no textType tag marks, so\n * the pend decision must key on the SITE — content of a va/vp span whose sibling chain reaches\n * back to a verse over run pieces only — for departure's re-tokenize to fold the bytes onto the\n * verse (the tokenizer's attrCapture). A va/vp span NOT in a verse's run position re-tokenizes\n * to itself (fixed point) and settles nothing — pending it is harmless. A preceding run piece may\n * be loose (a bare `MarkerNode`/attribute `TextNode`) or a whole `AttributeRunNode` wrapper\n * crossed in one step — the adaptor always builds a wanted run wrapped now, so a `\\vp` span\n * sitting behind a WRAPPED `\\va` run (the only shape an altnumber-bearing verse can have\n * post-migration) must still walk past it to reach the verse. Sibling walk to `$ownerOfRunPiece`'s\n * verse descriptors (displayRunRegistry.ts): those start from a run PIECE — including an opening\n * glyph, the shape MarkerEditPlugin.tsx's MarkerNode transform re-drives its sync/pend from — and\n * walk back to find the owning verse; this one starts from a SOURCE SPAN's content text and walks\n * back to find the owning verse for the pend decision. Both classify the same run-piece shapes\n * over the same sibling chain and must keep agreeing on what counts as one.\n */\nexport function $verseOfAttributeSourceText(node) {\n const span = node.getParent();\n if (!$isCharNode(span))\n return undefined;\n const marker = span.getMarker();\n if (marker !== \"va\" && marker !== \"vp\")\n return undefined;\n for (let prev = span.getPreviousSibling(); prev; prev = prev.getPreviousSibling()) {\n if ($isVerseNode(prev))\n return prev;\n const isRunPiece = ($isMarkerNode(prev) && (prev.getMarker() === \"va\" || prev.getMarker() === \"vp\")) ||\n ($isTextNode(prev) && $getState(prev, textTypeState) === \"attribute\") ||\n ($isCharNode(prev) && (prev.getMarker() === \"va\" || prev.getMarker() === \"vp\")) ||\n $isAttributeRunNode(prev);\n if (!isRunPiece)\n return undefined;\n }\n return undefined;\n}\n/**\n * A milestone's display-run pieces, scanned tolerantly in their fixed order — opening\n * `MarkerNode` (matching `milestone`'s own marker), attribute TextNode (textType \"attribute\"),\n * self-closing `MarkerNode` — with EACH piece individually optional: a bare collab-materialized\n * milestone has none of them, and a mid-edit tree can be missing any subset (only the opening\n * deleted leaves attribute + closer debris; only the closer deleted leaves opening + attribute).\n * The tolerant scan lets callers repair only the genuinely missing/stale pieces around whatever\n * survives — never duplicating a leftover — and lets the shared `$runEntirelyAbsent` check\n * (displayRunSync.utils.ts, parameterized by the milestone descriptor) distinguish \"every byte of\n * the run deleted\" from a partial mangle. Exported as the single definition of \"a milestone's run\"\n * — the Tier-2 rebuild's `$milestoneDisplayRun` delegates to it so the sync and the rebuild can\n * never disagree about which siblings make up the run.\n *\n * When `milestone`'s immediately following sibling is an `AttributeRunNode` whose `runKind` is\n * `\"milestone\"`, the SAME tolerant scan runs over the wrapper's CHILDREN instead of `milestone`'s\n * siblings — a wrapper's children are the run's pieces in the identical fixed order, so\n * redirecting the cursor's starting point is the only change needed. The adaptor always builds\n * this shape now; the sync still heals whichever shape — loose siblings (a pre-flip editor state,\n * an undo stack, or a collab-materialized bare milestone) or an existing wrapper — is actually in\n * the tree.\n *\n * As in {@link $verseAttributeRunPieces}, a glyph counts as a piece only while its rendered bytes\n * still spell what its state describes ({@link $isCanonicalMarkerNode}) — a byte-damaged glyph is\n * reported absent so the run diverges and the caret can grace the mid-edit shape.\n */\nexport function $milestoneAttributeRunPieces(milestone) {\n let opening;\n let attribute;\n let closing;\n let wrapper;\n let cursor = milestone.getNextSibling();\n if ($isAttributeRunNode(cursor) && cursor.getRunKind() === \"milestone\") {\n wrapper = cursor;\n cursor = cursor.getFirstChild();\n }\n if ($isMarkerNode(cursor) &&\n cursor.getMarkerSyntax() === \"opening\" &&\n cursor.getMarker() === milestone.getMarker() &&\n // Typed-spacing licensed ({@link $isCanonicalRunOpenerGlyph}): a trailing space typed on the\n // opener is at rest, not byte damage.\n $isCanonicalRunOpenerGlyph(cursor)) {\n opening = cursor;\n cursor = cursor.getNextSibling();\n }\n if ($isTextNode(cursor) && $getState(cursor, textTypeState) === \"attribute\") {\n attribute = cursor;\n cursor = cursor.getNextSibling();\n }\n if ($isMarkerNode(cursor) &&\n cursor.getMarkerSyntax() === \"selfClosing\" &&\n $isCanonicalMarkerNode(cursor))\n closing = cursor;\n return { opening, attribute, closing, wrapper };\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/cv/c.html */\nimport { CHAPTER_CLASS_NAME } from \"./node-constants.js\";\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\nexport const CHAPTER_MARKER = \"c\";\nexport const CHAPTER_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const CHAPTER_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"number\",\n \"sid\",\n \"altnumber\",\n \"pubnumber\",\n \"content\",\n];\nexport class ChapterNode extends ElementNode {\n __marker;\n __number;\n __sid;\n __altnumber;\n __pubnumber;\n __unknownAttributes;\n constructor(chapterNumber = \"\", sid, altnumber, pubnumber, unknownAttributes, key) {\n super(key);\n this.__marker = CHAPTER_MARKER;\n this.__number = chapterNumber;\n this.__sid = sid;\n this.__altnumber = altnumber;\n this.__pubnumber = pubnumber;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"chapter\";\n }\n static clone(node) {\n const { __number, __sid, __altnumber, __pubnumber, __unknownAttributes, __key } = node;\n return new ChapterNode(__number, __sid, __altnumber, __pubnumber, __unknownAttributes, __key);\n }\n static importJSON(serializedNode) {\n return $createChapterNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setNumber(serializedNode.number)\n .setSid(serializedNode.sid)\n .setAltnumber(serializedNode.altnumber)\n .setPubnumber(serializedNode.pubnumber)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setNumber(chapterNumber) {\n if (this.__number === chapterNumber)\n return this;\n const self = this.getWritable();\n self.__number = chapterNumber;\n return self;\n }\n getNumber() {\n const self = this.getLatest();\n return self.__number;\n }\n setSid(sid) {\n if (this.__sid === sid)\n return this;\n const self = this.getWritable();\n self.__sid = sid;\n return self;\n }\n getSid() {\n const self = this.getLatest();\n return self.__sid;\n }\n setAltnumber(altnumber) {\n if (this.__altnumber === altnumber)\n return this;\n const self = this.getWritable();\n self.__altnumber = altnumber;\n return self;\n }\n getAltnumber() {\n const self = this.getLatest();\n return self.__altnumber;\n }\n setPubnumber(pubnumber) {\n if (this.__pubnumber === pubnumber)\n return this;\n const self = this.getWritable();\n self.__pubnumber = pubnumber;\n return self;\n }\n getPubnumber() {\n const self = this.getLatest();\n return self.__pubnumber;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n /**\n * A chapter holds its own marker bytes and nothing else, and serializes as its number alone, so\n * it must never take in another block's content: whatever landed in it would stay on screen and\n * be dropped on save. Reporting that it cannot be empty is what keeps Lexical from treating it as\n * a block to merge a following paragraph into when a deletion starts on the chapter line, and\n * what removes the chapter once every byte of its marker is deleted. Editors that let the caret\n * into a chapter must handle splits there themselves, since Lexical then has no block to split\n * (see the platform editor's `chapterLine.utils.ts`).\n */\n canBeEmpty() {\n return false;\n }\n createDOM() {\n const dom = document.createElement(\"p\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(CHAPTER_CLASS_NAME, `usfm_${this.__marker}`);\n dom.setAttribute(\"data-number\", this.__number);\n return dom;\n }\n updateDOM(prevNode, dom) {\n if (prevNode.__number !== this.__number)\n dom.setAttribute(\"data-number\", this.__number);\n // Returning false keeps the existing DOM element (children reconcile independently).\n return false;\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n number: this.getNumber(),\n sid: this.getSid(),\n altnumber: this.getAltnumber(),\n pubnumber: this.getPubnumber(),\n unknownAttributes: this.getUnknownAttributes(),\n version: CHAPTER_VERSION,\n };\n }\n}\nexport function $createChapterNode(chapterNumber, sid, altnumber, pubnumber, unknownAttributes) {\n return $applyNodeReplacement(new ChapterNode(chapterNumber, sid, altnumber, pubnumber, unknownAttributes));\n}\nexport function $isChapterNode(node) {\n return node instanceof ChapterNode;\n}\nexport function isSerializedChapterNode(node) {\n return node?.type === ChapterNode.getType();\n}\n","import { $applyNodeReplacement, $getSelection, $isNodeSelection, ElementNode, } from \"lexical\";\n/** List of known properties of `MarkerObject` */\nexport const UNKNOWN_MARKER_OBJECT_PROPS = [\"type\", \"marker\", \"content\"];\nexport const UNKNOWN_TAG_NAME = \"unknown\";\nexport const UNKNOWN_VERSION = 1;\n/**\n * `UnknownNode` tags that render inline instead of as a subdued block container: a line-level box\n * in the middle of a sentence would be visibly wrong. These are the two corpus-proven\n * mid-paragraph constructs — both nest INSIDE a ``'s running text in the corpus fixtures\n * (\"optional line break (optbreak)\" and \"cross-reference ref target\"), and\n * `packages/utilities/src/converters/usj/converter-test.data.ts:2571,2581` shows both becoming\n * `UnknownNode`s (tags \"optbreak\" and \"ref\"):\n *\n * - `\\optbreak` — PT9 renders it as a literal `//` token mid-sentence; `createUnknown`\n * (usj-editor.adaptor.ts) renders that token as the node's own display child in editable\n * mode, via `unknownDisplayParts` (unknownUsfm.utils.ts).\n * - `\\ref` — a cross-reference target with real child text that must display inline; it carries\n * no USFM bytes of its own, so it gets no display children at all.\n *\n * Everything else (table/figure/sidebar/periph/...) stays block-level.\n */\nconst INLINE_UNKNOWN_TAGS = new Set([\"optbreak\", \"ref\"]);\nexport class UnknownNode extends ElementNode {\n __tag;\n __marker;\n __unknownAttributes;\n constructor(tag = \"\", marker, unknownAttributes, key) {\n super(key);\n this.__tag = tag;\n this.__marker = marker;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"unknown\";\n }\n static clone(node) {\n const { __tag, __marker, __unknownAttributes, __key } = node;\n return new UnknownNode(__tag, __marker, __unknownAttributes, __key);\n }\n static importDOM() {\n return {\n [UNKNOWN_TAG_NAME]: (node) => {\n if (!isUnknownElement(node))\n return null;\n return {\n conversion: $convertUnknownElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createUnknownNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setTag(serializedNode.tag)\n .setMarker(serializedNode.marker)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setTag(tag) {\n if (this.__tag === tag)\n return this;\n const self = this.getWritable();\n self.__tag = tag;\n return self;\n }\n getTag() {\n const self = this.getLatest();\n return self.__tag;\n }\n /**\n * Whether this unknown renders inline (optbreak, ref) rather than as a block box (figure,\n * sidebar, periph, ...). Inline unknowns sit within paragraph prose and carry SIGNIFICANT\n * surrounding whitespace — the spaces Paratext 9 preserves byte-for-byte around `//` — so\n * callers must not add or strip spaces next to them.\n */\n isInlineTag() {\n return INLINE_UNKNOWN_TAGS.has(this.getTag());\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(UNKNOWN_TAG_NAME);\n // data-tag records the UnknownNode's USJ type so importDOM's $convertUnknownElement can read it\n // back on a DOM round-trip. The inline-vs-block CSS treatment is driven by the class chosen from\n // INLINE_UNKNOWN_TAGS below, not by data-tag; optbreak's `//` token renders as a real child text\n // node (see createUnknown in usj-editor.adaptor.ts), not a CSS-generated label.\n dom.setAttribute(\"data-tag\", this.getTag());\n dom.setAttribute(\"data-marker\", this.getMarker() ?? \"\");\n dom.classList.add(this.isInlineTag() ? \"unknown-inline\" : \"unknown-block\");\n // Read-only whole-block: no inline display:none here (that hid the content in every view).\n // Visibility is CSS-mode-gated in usj-nodes.css (hidden by default, revealed as a subdued\n // block/token in standard view's .marker-editable scope). contentEditable=false stops the\n // browser from placing a native caret inside it, so caret navigation skips over the whole\n // node like any decorator node.\n dom.contentEditable = \"false\";\n return dom;\n }\n updateDOM(prevNode, dom) {\n // On a key-reused node whose tag/marker changed, sync the attributes and the inline-vs-block\n // class in place so createDOM's discriminators (data-tag/data-marker, unknown-inline vs\n // unknown-block) don't go stale. tag drives both data-tag and the class; marker drives\n // data-marker (empty string when absent, mirroring createDOM).\n if (prevNode.__tag !== this.__tag) {\n dom.setAttribute(\"data-tag\", this.__tag);\n const inline = this.isInlineTag();\n dom.classList.toggle(\"unknown-inline\", inline);\n dom.classList.toggle(\"unknown-block\", !inline);\n }\n if ((prevNode.__marker ?? \"\") !== (this.__marker ?? \"\"))\n dom.setAttribute(\"data-marker\", this.__marker ?? \"\");\n // Returning false keeps the existing DOM element (updated in place, never recreated — this\n // preserves contentEditable=false and the caret-skip behavior).\n return false;\n }\n exportDOM() {\n return { element: null };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n tag: this.getTag(),\n marker: this.getMarker(),\n unknownAttributes: this.getUnknownAttributes(),\n version: UNKNOWN_VERSION,\n };\n }\n // Mutation\n canBeEmpty() {\n return true;\n }\n isInline() {\n return true;\n }\n extractWithChild() {\n return false;\n }\n // A CHILD-BEARING `UnknownNode` of any kind stays IN the copy. This affects ONLY the\n // `application/x-lexical-editor` (lexical-JSON) flavor, for two independent reasons: an\n // editable-marker view's own `text/html` is not a DOM export at all (Standard view renders the\n // copy walker's USFM bytes — `usfmToClipboardHtml`, platform's whitespaceDisplay.plugin.utils.ts),\n // and where Lexical's exporter DOES run, `$appendNodesToHTML` (`@lexical/html`) computes this same\n // `excludeFromCopy('html')` value but returns early on `exportDOM()`'s unconditional\n // `{element: null}` BEFORE ever consulting it. `'clone'` is never passed by any Lexical-shipped\n // code path in the installed version, so an unconditional `destination !== \"clone\"` would\n // exclude every `UnknownNode` from the lexical-JSON flavor outright.\n //\n // Excluding a node does not drop it silently: `$appendNodesToJSON` HOISTS the excluded node's own\n // children into its parent's list in its place. Every kind's marker and attribute bytes are\n // content-free `ImmutableTypedTextNode` display decorators (`unknownDisplayParts` builds them\n // identically for all of them), so hoisting strands decorators that still `decorate()` their own\n // literal text as loose siblings with no owning wrapper: the pasted document RENDERS the\n // construct's full USFM bytes while its USJ has lost the node and every attribute on it — a\n // convincing display over missing data, which a save then persists with no error.\n //\n // The `getChildrenSize() > 0` guard excludes a node with no children of its OWN — of any kind,\n // and for whatever reason it has none — because that is exactly when `text/plain` also emits\n // nothing for it, and the two carriers must agree. Three shapes reach it, and only the first is\n // a husk: an optbreak whose `//` display child was deleted (`markerEditTier1.utils.ts`'s\n // husk-removal check recognizes it by that same zero-child shape); a content-less construct in\n // an editable-marker view, where the marker/attribute display bytes `createUnknown`\n // (`usj-editor.adaptor.ts`) prepends are themselves children, so only a kind with no display\n // bytes at all can be childless; and, in a HIDDEN-marker view, ANY content-less construct — a\n // caption-less `figure`, an empty `ref`, every optbreak — because `createUnknown` builds no\n // display children there at all. The last is prose-copy semantics rather than a husk: a\n // hidden-marker view copies what it shows, and it shows no bytes for a construct with no\n // content.\n //\n // The guard does NOT, on its own, cover a DIFFERENT carrier-agreement gap: a selection whose\n // ending boundary resolves to an ELEMENT-type point ON this node at offset 0 (touching the\n // wrapper without covering any of its content) still marks a CHILD-BEARING node \"selected\" under\n // Lexical's default `isSelected` (key-membership in `selection.getNodes()`, unaffected by this\n // node's own child count), so `$appendNodesToJSON` would serialize a CHILDLESS placeholder for a\n // node that has children, disagreeing with `text/plain` (`$selectionToUsfmText`, which walks that\n // same `getNodes()` list and correctly emits nothing for this boundary). The `isSelected`\n // override below closes that second gap at its actual source, since `excludeFromCopy` has no\n // visibility into which of a node's children a given selection will include — for every\n // construct whose display bytes lead, which is all of them but `ref`; see that override for the\n // one shape it deliberately does not close, and why.\n excludeFromCopy(destination) {\n return this.getChildrenSize() > 0 ? false : destination !== \"clone\";\n }\n // An `UnknownNode` is only meaningfully \"selected\" (and so only copy-included, per the\n // `excludeFromCopy` guard above) when at least one of its own children is — mirrors\n // `$selectionToUsfmText`'s copy walker so both clipboard carriers agree at the same selection\n // boundary, the same way Lexical's own base `isSelected` (`LexicalNode.prototype.isSelected`)\n // already special-cases an inline DECORATOR node sitting as a parent's last child at an\n // exactly-there boundary point, for the identical reason. Without this, a selection ending\n // exactly at this node's own start (an ElementNode touch-boundary that covers none of its\n // content) still counts the WRAPPER as selected via the default `ElementNode.isSelected`\n // (key-membership in `selection.getNodes()`), while no child is — producing a childless entry in\n // the `application/x-lexical-editor` copy with nothing corresponding to it in `text/plain`.\n //\n // Child MEMBERSHIP is the test, deliberately, and not the narrower \"does the selection cover a\n // child's CONTENT\". The two differ for exactly one shape, because that boundary reaches the\n // children two ways depending on what the first child IS. A construct whose display bytes lead\n // (a `figure`'s `\\fig ` glyph, an optbreak's `//`) starts with a DECORATOR: the element-type\n // point stays one, no child is in `getNodes()`, and both carriers agree. A construct with no\n // display bytes (a `ref`, whose container USFM never carried) starts with a real `TextNode`, and\n // Lexical normalizes that same point into a TEXT point at the child's offset 0 — the child is in\n // `getNodes()` contributing zero characters, so `text/plain` emits nothing for it while this\n // predicate still answers true and the construct rides along in the lexical flavor.\n //\n // Answering false there is WORSE, not better, and measurably so. Excluding the wrapper does not\n // drop it quietly: `$appendNodesToJSON` HOISTS its children in its place, and `createUnknown`\n // stamps `mode:\"token\"` on every text child, which `$sliceSelectedTextNodeContent` refuses to\n // slice — so the zero-width child keeps its full text, the emptied-text reset never fires, and\n // the copy ends up carrying the construct's CHARACTERS with the wrapper and its attributes\n // silently gone. That is the convincing-lie hazard this whole pair exists to prevent. Membership\n // keeps the construct whole, so the lexical flavor is a SUPERSET of `text/plain` at that one\n // boundary rather than a structural loss. That residual stands deliberately: closing it needs a\n // lever Lexical does not offer — `exportNodeToJSON` requires every ElementNode's `exportJSON()`\n // to return a `children` array, so a node cannot say \"drop me AND my children\".\n isSelected(selection) {\n const targetSelection = selection ?? $getSelection();\n if (!targetSelection)\n return false;\n // A `NodeSelection` marks a node selected by its OWN key, never by its children's, so the\n // child-membership test below cannot see one and the base predicate has to answer first.\n // Answering false there does not drop the construct quietly — `$appendNodesToJSON` HOISTS its\n // (also unselected) children in its place — so a node the user selected outright would copy as\n // nothing at all, the same convincing-lie hazard the range case above exists to prevent.\n if ($isNodeSelection(targetSelection) && super.isSelected(targetSelection))\n return true;\n // A caret selects nothing, though its one point puts the child it rests in into `getNodes()`.\n // (`NodeSelection.isCollapsed()` is always false, so this cannot shadow the branch above.)\n if (targetSelection.isCollapsed())\n return false;\n const selectedNodes = targetSelection.getNodes();\n return this.getChildren().some((child) => selectedNodes.some((node) => node.is(child)));\n }\n}\nfunction $convertUnknownElement(element) {\n const tag = element.getAttribute(\"data-tag\") ?? \"\";\n const marker = element.getAttribute(\"data-marker\") ?? \"\";\n const node = $createUnknownNode(tag, marker);\n return { node };\n}\nexport function $createUnknownNode(tag, marker, unknownAttributes) {\n return $applyNodeReplacement(new UnknownNode(tag, marker, unknownAttributes));\n}\nfunction isUnknownElement(node) {\n // `tagName` is upper-cased for HTML-namespace elements, so compare case-insensitively.\n return node?.tagName.toLowerCase() === UNKNOWN_TAG_NAME;\n}\nexport function $isUnknownNode(node) {\n return node instanceof UnknownNode;\n}\nexport function isSerializedUnknownNode(node) {\n return node?.type === UnknownNode.getType();\n}\n","/** Conforms with USJ v3.1 tables @see https://docs.usfm.bible/usfm/3.1/para/table.html */\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\n/** USJ marker type this node renders; the forward adaptor matches USJ input against it. */\nexport const TABLE_TYPE = \"table\";\nexport const IMMUTABLE_TABLE_TYPE = \"immutable-table\";\nexport const IMMUTABLE_TABLE_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const TABLE_MARKER_OBJECT_PROPS = [\"type\", \"marker\", \"content\"];\nexport class ImmutableTableNode extends ElementNode {\n __unknownAttributes;\n constructor(unknownAttributes, key) {\n super(key);\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return IMMUTABLE_TABLE_TYPE;\n }\n static clone(node) {\n return new ImmutableTableNode(node.__unknownAttributes, node.__key);\n }\n static importJSON(serializedNode) {\n return $createImmutableTableNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n return this.getLatest().__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(\"table\");\n dom.classList.add(\"table\");\n // Read-only whole-block: the same treatment tables had while they were `UnknownNode`s, and the\n // one `UnknownNode` still gives the other Tier-3 kinds (figures, sidebars, periph) — visible\n // and byte-preserved, but not editable. contentEditable=false stops the browser from placing a\n // native caret inside, so caret navigation skips the table like a decorator node. Set on the\n // container so it covers every row and cell. Editing tables is not supported yet; whether and\n // how they become editable is still open. Set as an ATTRIBUTE rather than via the\n // `contentEditable` IDL property (which `UnknownNode` uses): the two are equivalent in a\n // browser, but jsdom does not reflect the property back to the attribute, so only this form is\n // assertable in tests.\n dom.setAttribute(\"contenteditable\", \"false\");\n return dom;\n }\n updateDOM() {\n return false;\n }\n exportJSON() {\n const unknownAttributes = this.getUnknownAttributes();\n return {\n ...super.exportJSON(),\n type: IMMUTABLE_TABLE_TYPE,\n ...(unknownAttributes !== undefined && { unknownAttributes }),\n version: IMMUTABLE_TABLE_VERSION,\n };\n }\n // Shadow root: isolate selection so content doesn't merge across the table boundary.\n isShadowRoot() {\n return true;\n }\n}\nexport function $createImmutableTableNode(unknownAttributes) {\n return $applyNodeReplacement(new ImmutableTableNode(unknownAttributes));\n}\nexport function $isImmutableTableNode(node) {\n return node instanceof ImmutableTableNode;\n}\nexport function isSerializedImmutableTableNode(node) {\n return node?.type === IMMUTABLE_TABLE_TYPE;\n}\n","import { $isUnknownNode } from \"../features/UnknownNode.js\";\nimport { $isImmutableTableNode } from \"./ImmutableTableNode.js\";\n/**\n * Whether `node` sits inside a block whose text the tokenizer keeps literal — an opaque\n * `UnknownNode` block (sidebar, periph, figure, …) or a table. These are the degradation-property\n * contexts no settle scope re-tokenizes (the marker-edit engine's paragraph guard rails and its\n * opaque-block bail), so a divergence there can never settle: whatever would re-tokenize elsewhere\n * must either be left alone or healed in place here, never pended.\n *\n * Tables have no settle scope: their cells hold ordinary `TextNode`s, so the engine's text\n * transform does run on them, and a cell whose text contains `//` (a URL, say — the tokenizer\n * reads `//` as an optbreak wherever it appears) would otherwise pend a key nothing can ever\n * settle. Chapters and books are not in this list: `$rebuildChapter` and `$rebuildBook` are their\n * settle scopes, so a chapter's display bytes and the `\\id` line's content pend and settle like\n * any paragraph's.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isInLiteralOnlyBlock(node) {\n for (let parent = node.getParent(); parent; parent = parent.getParent())\n if ($isUnknownNode(parent) || $isImmutableTableNode(parent))\n return true;\n return false;\n}\n","/** Conforms with USJ v3.1 and adapted from @see https://docs.usfm.bible/usfm/3.1/para/index.html */\nimport { $applyNodeReplacement, ParagraphNode, } from \"lexical\";\nimport { PARA_MARKER_DEFAULT } from \"./node-constants.js\";\nexport const IMPLIED_PARA_VERSION = 1;\nexport class ImpliedParaNode extends ParagraphNode {\n static getType() {\n return \"implied-para\";\n }\n static clone(node) {\n return new ImpliedParaNode(node.__key);\n }\n static importJSON(serializedNode) {\n return $createImpliedParaNode().updateFromJSON(serializedNode);\n }\n getMarker() {\n return PARA_MARKER_DEFAULT;\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n version: IMPLIED_PARA_VERSION,\n };\n }\n // Mutation\n insertNewAfter(rangeSelection, restoreSelection) {\n const newElement = $createImpliedParaNode();\n newElement.setTextFormat(rangeSelection.format);\n newElement.setTextStyle(rangeSelection.style);\n newElement.setDirection(this.getDirection());\n newElement.setFormat(this.getFormatType());\n newElement.setStyle(this.getTextStyle());\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n}\nexport function $createImpliedParaNode() {\n return $applyNodeReplacement(new ImpliedParaNode());\n}\nexport function $isImpliedParaNode(node) {\n return node instanceof ImpliedParaNode;\n}\nexport function isSerializedImpliedParaNode(node) {\n return node?.type === ImpliedParaNode.getType();\n}\n","/**\n * Which element owns a node's logical content index. Annotation marks and the root's implied\n * paragraph are transparent in USJ, so the owner can be further up than the raw parent. Kept apart\n * from the node utilities so modules those utilities import can ask the same question.\n */\nimport { $isRootNode } from \"lexical\";\nimport { $isTypedMarkNode } from \"../features/TypedMarkNode.js\";\nimport { $isImpliedParaNode } from \"./ImpliedParaNode.js\";\n/**\n * Whether `node` is an implied paragraph the editor→USJ conversion splices away: one directly under\n * the root, where the loader puts content that comes before a document's first block. Its children\n * are the root's own content items in USJ, so it is as transparent to content indexes as an\n * annotation mark. The conversion splices root children only, so an implied paragraph anywhere\n * else keeps its index.\n */\nexport function $isSplicedImpliedPara(node) {\n return $isImpliedParaNode(node) && $isRootNode(node.getParent());\n}\n/** Whether `node` contributes no content item of its own, its children standing in its place: an\n * annotation mark, or an implied paragraph the conversion splices away. */\nexport function $isContentTransparent(node) {\n return $isTypedMarkNode(node) || $isSplicedImpliedPara(node);\n}\n/**\n * Gets the nearest ancestor that owns the node's logical content index — skipping annotation\n * wrappers and the root's implied paragraph, which are transparent in USJ.\n * @param node - The node to get the logical parent of.\n * @returns the logical parent element, or `null` at the root.\n */\nexport function $getLogicalParent(node) {\n let parent = node.getParent();\n while (parent && $isContentTransparent(parent))\n parent = parent.getParent();\n return parent;\n}\n","/**\n * Nested inline-marker glyphs: the single place that owns HOW the `+` prefix (`\\+w …\\+w*`) is\n * represented and kept in sync.\n *\n * ## The representations (who owns what)\n *\n * - **Tree containment is the truth.** A char span is nested iff its parent is another CharNode\n * ({@link $isNestedCharNode}) — exactly USJ/USX's model, where nesting is element containment\n * and no `+` exists in any marker name.\n * - **Markers are always CLEAN** (`\"w\"`, never `\"+w\"`), in CharNode state, in USJ, and in the\n * OT/collab delta (which conveys nesting by char-ARRAY position, outermost-first; see\n * `$buildCharItem` in editor-delta.adaptor and `$createNestedChars` in delta-apply-update —\n * both in `shared-react`'s collab plugin).\n * - **Only the rendered glyph text carries the `+`** — USFM's serialization of nesting, and PT9's\n * on-screen display for USFM ≤3.0. `MarkerNode` caches it: Lexical renders a TextNode's stored\n * `__text` (there is no computed-text hook, and nothing re-runs when an ANCESTOR moves), so the\n * `+` must be baked into `__text`. `MarkerNode.__nested` is the flag that `getMarkerText`\n * derives it from — see MarkerNode.ts, which points back here.\n *\n * ## Keeping the cache honest\n *\n * Because `__text` is a cache of tree-derived state, every path that BUILDS glyphs sets `nested`\n * at construction (the USJ load adaptor's `createChar`, `$splitCharNodeAt`, the marker-apply\n * paths, the collab materializer) — construction-time correctness matters because transforms do\n * not run on `setEditorState` (initial load / restored states render straight from serialized\n * `__text`). {@link $syncNestedGlyphs} is the safety net for everything AFTER load: registered as\n * a CharNode transform (CharNodePlugin in `shared-react`), it re-derives each glyph's `nested`\n * from tree position whenever a span is dirtied, so structure surgery that forgets to refresh\n * glyphs (a move, an unwrap, a merge) self-heals instead of leaving a stale `+` that Tier-2\n * re-tokenization would misread (`\\+w` with nothing open parses as an unknown marker; a missing\n * `+` flattens the nesting via close-on-bare).\n */\nimport { $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { $isCharNode } from \"./CharNode.js\";\nimport { $getLogicalParent } from \"./logicalParent.utils.js\";\n/** Whether `char` is a nested char span — its LOGICAL parent is another char span. Read through\n * `$getLogicalParent`, never the raw parent: an annotation `TypedMarkNode` wrapped around the\n * span is presentation-transparent in USJ, and a raw-parent read made a genuinely nested span\n * read as un-nested — the sync then stripped its glyphs' `+`, and the bare inner marker\n * re-tokenized as closing the outer span. The one derivation rule for the glyph `+`; every\n * representation above follows from this. */\nexport function $isNestedCharNode(char) {\n return $isCharNode($getLogicalParent(char));\n}\n/**\n * Which char span a glyph that is a DIRECT child of `char` describes:\n *\n * - `char` itself (`glyph.getMarker() === char.getMarker()`) — the span's own opener/closer;\n * nested iff `char` is nested.\n * - A nested CHILD span with that marker (the collab-flattened shape, where an inner span's\n * glyphs sit as siblings around the inner CharNode) — nested by construction.\n * - Neither — e.g. a milestone's display run (`\\qt-s` … `\\*`) rendered inside the span. Not a\n * char glyph at all: milestones never take the `+`, so it is left untouched.\n *\n * Exported as the shared \"is this a char-span glyph, and of which span?\" classifier — the\n * display-separator sync (markerSeparators.utils.ts) uses the same distinction to know which\n * opening glyphs take a separator.\n *\n * @returns the nested value the glyph must carry, or `undefined` to leave the glyph alone.\n */\nexport function $charGlyphNestedValue(glyph, char) {\n if (glyph.getMarkerSyntax() === \"selfClosing\")\n return undefined;\n const marker = glyph.getMarker();\n if (marker === char.getMarker())\n return $isNestedCharNode(char);\n const describesNestedChild = char\n .getChildren()\n .some((child) => $isCharNode(child) && child.getMarker() === marker);\n return describesNestedChild ? true : undefined;\n}\n/**\n * Re-derive the `nested` flag (and thereby the `+` in the glyph text) of `char`'s direct marker\n * glyphs from tree position. Idempotent — `setNested` writes only on change, so a second pass is\n * a no-op and the registering transform converges.\n *\n * @param char - The char span whose glyphs to sync. Must be called inside `editor.update()`.\n */\nexport function $syncNestedGlyphs(char) {\n // An earlier transform in the same pass may have merged/removed the span (adjacent-span\n // combining); a detached span has no tree position to derive from.\n if (!char.isAttached())\n return;\n char.getChildren().forEach((child) => {\n if (!$isMarkerNode(child))\n return;\n const nested = $charGlyphNestedValue(child, char);\n if (nested !== undefined)\n child.setNested(nested);\n });\n}\n","/**\n * Editor-scoped registry of display-run OWNER keys the marker-edit engine currently holds\n * pending. The engine (MarkerEditPlugin, platform) registers its live pending set here so the\n * self-healing display syncs — which live in shared/shared-react and cannot import the engine —\n * can leave a pended owner's run alone instead of resurrecting a deletion the engine has not\n * settled yet. Keyed per editor (main editor and footnote popover each register their own set).\n */\nimport { $getEditor, HISTORIC_TAG, } from \"lexical\";\nconst pendedOwnersByEditor = new WeakMap();\n/**\n * Publishes the engine's live pending set for `editor`.\n *\n * @param rederive - Rebuilds `owners` from a history-restored state's bytes. Lexical restores an\n * undo/redo state without running node transforms, so nothing re-pends a restored literal unless\n * this runs; see {@link ensurePendedDisplayOwnersCurrent}.\n * @returns A function that unregisters the set, if it is still the registered one.\n */\nexport function registerPendedDisplayOwners(editor, owners, rederive) {\n const entry = { owners, rederive };\n pendedOwnersByEditor.set(editor, entry);\n return () => {\n if (pendedOwnersByEditor.get(editor) === entry)\n pendedOwnersByEditor.delete(editor);\n };\n}\n/**\n * Re-derive the pend set for a history-restored state if not yet done for that state. Idempotent.\n *\n * Any update listener that reads the pend set for a commit calls this first, so what it reads does\n * not depend on whether the engine's own listener ran before it: listener order follows\n * registration order, which a re-mounted plugin changes. Only a commit tagged `HISTORIC_TAG` is\n * re-derived; every other commit's pends are already current, because the engine's node transforms\n * maintain them inside the update. Keyed on the state object, which is safe because Lexical clones\n * a restored state before committing it, so no two restores ever commit the same object.\n */\nexport function ensurePendedDisplayOwnersCurrent(editor, editorState, tags) {\n const entry = pendedOwnersByEditor.get(editor);\n if (!entry?.rederive || !tags.has(HISTORIC_TAG) || entry.derivedFor === editorState)\n return;\n entry.rederive(editorState);\n entry.derivedFor = editorState;\n}\n/**\n * The live pending-owner set registered for `editor`, or `undefined` when no marker-edit engine is\n * mounted on it (a non-editable marker mode, or an editor that has torn down). The SAME mutable Set\n * the engine holds, not a snapshot — a reader that keeps the reference sees later pends — so\n * callers must treat it as read-only. Takes the editor explicitly rather than reading `$getEditor()`\n * so it can be called from outside a read/update (the editor-facing `getUsj()` path decides whether\n * to enter a read at all based on whether anything is pending).\n */\nexport function getPendedDisplayOwners(editor) {\n return pendedOwnersByEditor.get(editor)?.owners;\n}\n/** Whether `node`'s key is pended in the active editor. Call inside a read/update. */\nexport function $isDisplayOwnerPended(node) {\n return pendedOwnersByEditor.get($getEditor())?.owners.has(node.getKey()) ?? false;\n}\n/**\n * Lets the shared self-healing display-run sync (`$syncDisplayRun`, displayRunSync.utils.ts)\n * report that it just found an owner's run destroyed by something other than itself, so the\n * marker-edit engine settles it on caret departure instead of the sync resurrecting it. Writes\n * directly into the SAME mutable Set `registerPendedDisplayOwners` was given, rather than\n * routing the report back through one of the engine's own node transforms: which plugin's\n * transform runs first on a shared dirty node depends on mount order (the sync and the engine\n * are registered by separate, independently ordered plugins), so a report that only took effect\n * via a later engine-side transform would still lose the race whenever the sync happens to run\n * first. A direct write has no such ordering dependency. Call inside a read/update. No-op if no\n * engine is currently registered for the active editor.\n */\nexport function $reportDestroyedDisplayOwner(node) {\n pendedOwnersByEditor.get($getEditor())?.owners.add(node.getKey());\n}\n","/**\n * Editable-mode display separators after opening char glyphs: the single place that owns HOW the\n * space the user sees after `\\nd` is represented and kept in sync. Sibling of\n * nestedGlyphs.utils.ts, which owns the glyph `+` the same way.\n *\n * ## The convention\n *\n * In editable marker mode an opening char glyph (`\\nd`) is followed on screen by a separator —\n * the space PT9 shows and the serializer writes after the marker. That separator is\n * PRESENTATION-ONLY state: the USFM writer emits the space after an opening marker structurally\n * and the tokenizer consumes it, so no separator ever lives in USJ content or in the saved bytes\n * as data. In the editor it is an NBSP (never a plain space, so it cannot word-wrap away from its\n * glyph), stored as:\n *\n * - a prefix of the following text (`\\nd` + `⍽one`) when the glyph is directly followed by plain\n * text — the shape `createChar` (usj-editor.adaptor), `$splitCharNodeAt`, and the marker-apply\n * paths build, and the reverse adaptor strips on save;\n * - a standalone NBSP text node when the glyph is directly followed by an element (a nested char\n * span, note, milestone, or verse: `\\nd` + `⍽` + `\\+wj …`) — NBSP-only text nodes are\n * presentation-only by convention (`$shouldIgnoreNodeForContentIndexes`) and dropped by the\n * editor→USJ conversion.\n *\n * ## Keeping it in sync\n *\n * Builders construct the separator (transforms do not run on `setEditorState`, so loaded states\n * must render correctly as-is), and {@link $syncOpenerSeparators} — registered as a CharNode\n * transform in CharNodePlugin — re-derives it whenever a span is dirtied, healing paths that\n * restructure spans without rebuilding them through an adaptor.\n *\n * A missing separator is healed back in place only when the displayed bytes tokenize IDENTICALLY\n * without it (`separatorRemovalTokenizesIdentically`, beside the tokenizer's own name scan): `\\nd`\n * before `\\`, `|` or more whitespace means the same with or without the space, so restoring it is\n * display canonicalization. Anything else is the user's bytes — `\\ndthings` renames the marker and\n * `\\nd*` is a closer, whether the separator was deleted or typed over — and healing it back would\n * rewrite what the screen shows. For those the marker-edit engine pends the span\n * ({@link $hasUnsettledSeparatorGap}), graces it while the caret is anywhere inside it\n * ({@link $hasCaretGracedSeparatorGap}), and settles it on caret departure by re-tokenizing, so the\n * displayed bytes win; the sync leaves a pended span alone and hands such a gap to the engine\n * instead of healing it. Deleting a separator must always be ALLOWED: while the collapsed caret sits\n * at the deletion point ({@link $hasCaretHeldSeparatorGap}) even a healable gap waits for departure.\n *\n * An annotation mark is transparent to all of this: a range into a span wraps its content in a\n * `TypedMarkNode`, and the text the gap is decided by — and the caret boundary — is the mark's\n * first text, not the mark element.\n *\n * Only char-span glyphs take a separator — a milestone's display run inside a span is left\n * alone — so which glyphs qualify is decided by the same classifier the nested-`+` sync uses\n * ({@link $charGlyphNestedValue}).\n */\nimport { separatorRemovalTokenizesIdentically } from \"../../converters/usfm/usfmFragmentToUsj.js\";\nimport { $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { $isTypedMarkNode } from \"../features/TypedMarkNode.js\";\nimport { textTypeState } from \"../collab/delta.state.js\";\nimport { $isCharNode } from \"./CharNode.js\";\nimport { $isInLiteralOnlyBlock } from \"./literalOnlyBlock.utils.js\";\nimport { $charGlyphNestedValue } from \"./nestedGlyphs.utils.js\";\nimport { openingMarkerText } from \"./markerText.utils.js\";\nimport { NBSP } from \"./node-constants.js\";\nimport { $isDisplayOwnerPended, $reportDestroyedDisplayOwner, getPendedDisplayOwners, } from \"./pendedDisplayOwners.utils.js\";\nimport { $createTextNode, $getEditor, $getSelection, $getState, $isRangeSelection, $isTextNode, TextNode, } from \"lexical\";\n/**\n * Whether `node` is text that may carry a char-span separator NBSP as its own PREFIX: exactly a\n * plain `TextNode` — subclasses (`VerseNode`, `ImmutableUnmatchedNode`, `MarkerNode`) render their\n * own marker bytes, and splicing an NBSP into those rewrites a glyph — and not an attribute\n * display run (textType \"attribute\"), whose `|…` bytes are engine-owned canonical output that an\n * NBSP prefix would corrupt. THE one predicate for every site that splices a separator into\n * leading text ({@link $openerSeparatorGap} here, plus the continuation/absorb span builders in\n * charGlyphs.utils.ts and charStack.utils.ts), so the rule cannot drift between them; anything\n * else takes a standalone NBSP spacer instead.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $isSeparatorPrefixHostText(node) {\n return ($isTextNode(node) &&\n node.getType() === TextNode.getType() &&\n $getState(node, textTypeState) !== \"attribute\");\n}\n/**\n * How many of `node`'s leading characters are the char-span separator rather than content: `1`\n * when `node` is a plain TextNode carrying an opening char glyph's separator NBSP as its prefix,\n * `0` otherwise.\n *\n * The separator is display state the editor→USJ conversion strips, so that byte is not part of\n * the span's USJ text: anything that measures content or maps between live and settled text\n * offsets must skip it, or every offset inside a char span is off by one. Shape-based on purpose\n * — glyph adjacency, not view options, which this layer does not see. The editor→USJ\n * conversion's strip (`precedesOpeningCharGlyph` in `editor-usj.adaptor.ts`, every editable view)\n * decides the same way over the serialized tree, so an authored `~` right after a nested closer,\n * or leading a span's content once a mark split the separator off, survives the export.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $charSeparatorPrefixLength(node) {\n if (!$isSeparatorPrefixHostText(node) || !node.getTextContent().startsWith(NBSP))\n return 0;\n // The span is the nearest non-annotation ancestor, and the glyph is whatever sits immediately\n // before the text in document order within it — annotation wrappers are transparent on BOTH\n // sides. A host can annotate a range that starts on the opening glyph (a marker location), so\n // the glyph can share the text's mark, sit in a mark of its own, or be a plain sibling of the\n // mark the text is in.\n let child = node;\n let previous = child.getPreviousSibling();\n let parent = child.getParent();\n while (parent && $isTypedMarkNode(parent)) {\n child = parent;\n parent = child.getParent();\n previous ??= child.getPreviousSibling();\n }\n if (!$isCharNode(parent))\n return 0;\n // A mark that ends right before the text hides the glyph as its last descendant.\n while ($isTypedMarkNode(previous))\n previous = previous.getLastChild();\n if (!$isMarkerNode(previous) || previous.getMarkerSyntax() !== \"opening\")\n return 0;\n // Only char-span glyphs take a separator (not a milestone's display run) — the same classifier\n // $openerSeparatorGap builds one with, so reading and writing can never disagree about which\n // glyphs own one.\n return $ownsOpenerSeparator(previous, parent) ? 1 : 0;\n}\n/**\n * The node whose leading bytes follow `opener`'s separator site: the glyph's next sibling, read\n * through any annotation marks to the first node that is not one. A range into a span wraps the\n * content in a `TypedMarkNode`, which is presentation only — whether a separator is owed, and what\n * removing it would mean, is a question about that content.\n */\nfunction $contentAfterOpener(opener) {\n let node = opener.getNextSibling();\n while ($isTypedMarkNode(node))\n node = node.getFirstChild();\n return node;\n}\n/**\n * How many leading UTF-16 code units of `node` are an opening glyph's display separator rather\n * than content: `NBSP.length` when `node` is {@link $isSeparatorPrefixHostText} text directly\n * after a char-span opening glyph and starts with the NBSP, otherwise 0. That is exactly the slot\n * {@link $openerSeparatorGap} fills — a prefix of the following text, or a standalone spacer,\n * which is separator in its entirety — so a position counted over a span's CONTENT skips the byte\n * the builders and the sync put there and nothing else. An NBSP anywhere else is the author's own\n * `~` and stays content: after a nested closer (`\\ft A\\+nd x\\+nd*~B`), after a milestone's display\n * glyph, or in a span rendered without glyphs.\n *\n * The reading for sites that turn a text node's bytes into content, such as caret placement\n * inside a span or a note, where the text is a direct child of the span. Positions that must see\n * through annotation marks (a mark can split the separator off, or hold the glyph) read\n * {@link $charSeparatorPrefixLength} instead, which agrees with this one wherever no mark\n * intervenes. The collab emit path (editor-delta.adaptor.ts) narrows\n * this: it calls this function only for a span's OWN opener (its first child), matching the\n * reverse adaptor's `content[0]` strip, so a nested opener's separator is left in the emitted text\n * and reaches peers as ordinary content, like any other byte the collab-flattened shape exposes.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $separatorPrefixLength(node) {\n const opener = node.getPreviousSibling();\n const char = node.getParent();\n if (!$isMarkerNode(opener) || !$isCharNode(char) || !$ownsOpenerSeparator(opener, char))\n return 0;\n if (!$isSeparatorPrefixHostText(node))\n return 0;\n return node.getTextContent().startsWith(NBSP) ? NBSP.length : 0;\n}\n/**\n * Whether `opener` (a direct child of `char`) is an opening glyph that takes a display separator\n * at all — a char-span glyph (not a milestone's display run). Shared by\n * {@link $separatorPrefixLength}, {@link $charSeparatorPrefixLength} and\n * {@link $openerSeparatorGap}, the sites that otherwise repeat this same test.\n */\nfunction $ownsOpenerSeparator(opener, char) {\n return (opener.getMarkerSyntax() === \"opening\" && $charGlyphNestedValue(opener, char) !== undefined);\n}\n/**\n * Where a separator is missing after `opener` (a direct child of `char`):\n *\n * - `\"prefix\"` — the glyph is directly followed by plain text that lacks the NBSP prefix;\n * - `\"spacer\"` — the glyph is followed by an element (or, in the collab-flattened shape, a nested\n * span's opening glyph) with no standalone NBSP spacer between them, or by an annotation mark\n * whose text lacks the NBSP prefix (the separator then stands in front of the mark, the shape\n * the wrap itself leaves);\n * - `undefined` — no separator is owed: the glyph is not a char-span glyph (a milestone's display\n * run), has nothing after it, sits directly before a non-nested glyph, or its separator exists.\n */\nfunction $openerSeparatorGap(opener, char) {\n if (!$ownsOpenerSeparator(opener, char))\n return undefined;\n const next = opener.getNextSibling();\n const content = $contentAfterOpener(opener);\n if (next === null || content === null)\n return undefined;\n if ($isMarkerNode(content)) {\n // Opening glyph directly before another glyph: in the collab-flattened shape that next glyph\n // opens a nested span (`\\add\\+wj …`) and the separator goes between them. Any other adjacent\n // glyph (the span's own closer on a degenerate empty span) takes none.\n return $charGlyphNestedValue(content, char) === true ? \"spacer\" : undefined;\n }\n // Plain text directly after the glyph carries the separator as its prefix — see\n // $isSeparatorPrefixHostText for what qualifies and why.\n if ($isSeparatorPrefixHostText(content)) {\n if (content.getTextContent().startsWith(NBSP))\n return undefined;\n return content.is(next) ? \"prefix\" : \"spacer\";\n }\n // Element content (nested char span, note, milestone, verse), TextNode subclasses, and\n // attribute-run text: standalone NBSP spacer.\n return \"spacer\";\n}\n/**\n * Whether the bytes after `opener`'s separator site are the user's to decide rather than the\n * sync's to heal: the site is followed by plain content text (read through annotation marks) whose\n * first byte would change the token stream if the separator stayed gone — a name character that\n * the marker name runs into, or the `*` of a closer. Element content, glyphs and attribute runs\n * all begin with bytes the name scan stops at, so their gaps always heal. So does any gap in a\n * block no settle scope re-tokenizes ({@link $isInLiteralOnlyBlock}: a table cell, the `\\id`\n * line, an opaque block): nothing could ever settle the new name there, and healing keeps the\n * screen equal to what the writer saves.\n */\nfunction $isRenamingGap(opener) {\n if (!$isSeparatorPrefixHostText($contentAfterOpener(opener)))\n return false;\n if ($isInLiteralOnlyBlock(opener))\n return false;\n return !separatorRemovalTokenizesIdentically(opener.getNextSibling()?.getTextContent() ?? \"\");\n}\n/**\n * The displayed bytes immediately after `char`'s first missing-separator site, or `undefined`\n * when every opening glyph's separator is present (or none is owed). This is the input the\n * tokenize-identity predicate (`separatorRemovalTokenizesIdentically`, the fragment tokenizer's\n * sibling) needs to decide whether the missing byte may be healed in place or the bytes now mean\n * something new and must re-tokenize. Read-only: call inside `editor.getEditorState().read(...)`\n * or an update.\n */\nexport function $openerSeparatorGapFollowingBytes(char) {\n if (!char.isAttached())\n return undefined;\n for (const child of char.getChildren()) {\n if (!$isMarkerNode(child))\n continue;\n if ($openerSeparatorGap(child, char) === undefined)\n continue;\n return child.getNextSibling()?.getTextContent() ?? \"\";\n }\n return undefined;\n}\n/**\n * Whether the collapsed caret sits at `opener`'s separator site — on the glyph itself, on the\n * span (an element point), or at the very start of the node after the glyph (read through any\n * annotation marks, so the start of a mark's first text counts). This is where the caret lands\n * when the user deletes the separator, and deleting must always be allowed: while the caret stays\n * here the sync leaves the gap alone (mid-edit grace), and the marker-edit engine settles the span\n * on caret departure (it pends spans reported by {@link $hasCaretHeldSeparatorGap}).\n */\nfunction $isCaretAtOpenerBoundary(opener, char) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n if (anchorNode.is(opener) || anchorNode.is(char))\n return true;\n if (selection.anchor.offset !== 0)\n return false;\n for (let node = opener.getNextSibling(); node;) {\n if (anchorNode.is(node))\n return true;\n if (!$isTypedMarkNode(node))\n return false;\n node = node.getFirstChild();\n }\n return false;\n}\n/**\n * Ensure every opening char glyph among `char`'s direct children is followed by its display\n * separator — except one whose separator site holds the collapsed caret (see\n * {@link $isCaretAtOpenerBoundary}), and, while a marker-edit engine is mounted, one whose\n * following bytes would read differently with the separator back: that span is reported to the\n * engine, which settles it by re-tokenizing what the screen shows. A span the engine already holds\n * pending is left alone entirely — its settle decides. Without an engine (a host with no editable\n * marker mode) every gap heals. Idempotent — a healed span passes untouched, so the registering\n * transform converges.\n *\n * The healed spacer is a plain NBSP text node, the same shape the forward adaptor builds for a span\n * whose content starts with an element: a char span's separator is recognized by position (the\n * NBSP right after its opening glyph), not by the tagged token separator a paragraph or note glyph\n * takes, and typing next to it must stay ordinary text editing.\n *\n * @param char - The char span whose separators to sync. Must be called inside `editor.update()`.\n */\nexport function $syncOpenerSeparators(char) {\n // An earlier transform in the same pass may have merged/removed the span.\n if (!char.isAttached())\n return;\n if ($isDisplayOwnerPended(char))\n return;\n const isEngineMounted = getPendedDisplayOwners($getEditor()) !== undefined;\n char.getChildren().forEach((child) => {\n if (!$isMarkerNode(child))\n return;\n const gap = $openerSeparatorGap(child, char);\n if (gap === undefined)\n return;\n if ($isCaretAtOpenerBoundary(child, char))\n return;\n if (isEngineMounted && $isRenamingGap(child)) {\n $reportDestroyedDisplayOwner(char);\n return;\n }\n if (gap === \"spacer\") {\n child.insertAfter($createTextNode(NBSP));\n return;\n }\n const next = child.getNextSibling();\n if (!$isTextNode(next))\n return;\n if (!$moveTypedBytesBehindSeparator(next))\n $prefixSeparator(next);\n });\n}\n/**\n * Bytes typed with the caret between an opening glyph and its separator (`\\w|⍽grace`, caret\n * behind the `|`): the separator is still there, behind them, so they move behind it rather than\n * a second separator going in front of them — which would leave the first one inside the content\n * (a lemma ` grace` where the user typed `|grace`). Recognized by the caret sitting right after\n * the typed bytes, on the separator; a text whose separator was deleted has no such caret and is\n * prefixed as usual.\n *\n * @returns Whether the bytes were moved.\n */\nfunction $moveTypedBytesBehindSeparator(text) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const { anchor } = selection;\n if (anchor.type !== \"text\" || anchor.key !== text.getKey() || anchor.offset === 0)\n return false;\n const content = text.getTextContent();\n if (content[anchor.offset] !== NBSP)\n return false;\n const typed = content.slice(0, anchor.offset);\n text.setTextContent(NBSP + typed + content.slice(anchor.offset + 1));\n text.select(anchor.offset + 1, anchor.offset + 1);\n return true;\n}\n/**\n * Bytes typed at the END of a char span's opening glyph that the marker name cannot take and that\n * read with the content rather than the marker — a `|` or whitespace (`\\w|` in front of `⍽grace`)\n * — move behind the separator that still follows the glyph, the shape the same keystroke leaves\n * with the caret at the content's front ({@link $moveTypedBytesBehindSeparator}). The two carets\n * are one place on screen and must save one file: the lemma `grace`, not ` grace`. Bytes that do\n * read with the marker (a name byte, `*`, `\\`) stay in the glyph.\n *\n * Decided by where the caret is: only a collapsed caret at the glyph's end moves bytes, so a glyph\n * whose separator was deleted, or a rename in progress, keeps its bytes.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @returns Whether the bytes moved; the glyph is then canonical again.\n */\nexport function $moveGlyphTailBehindSeparator(opener) {\n if (opener.getMarkerSyntax() !== \"opening\" || !$isCharNode(opener.getParent()))\n return false;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const text = opener.getTextContent();\n const { anchor } = selection;\n if (anchor.key !== opener.getKey() || anchor.offset !== text.length)\n return false;\n const spelled = openingMarkerText(opener.getMarker(), opener.getNested());\n const tail = text.slice(spelled.length);\n if (!text.startsWith(spelled) || !/^[|\\s]+$/.test(tail))\n return false;\n const content = $contentAfterOpener(opener);\n if (!$isSeparatorPrefixHostText(content))\n return false;\n const contentText = content.getTextContent();\n if (!contentText.startsWith(NBSP))\n return false;\n opener.setTextContent(spelled);\n content.setTextContent(NBSP + tail + contentText.slice(NBSP.length));\n content.select(NBSP.length + tail.length, NBSP.length + tail.length);\n return true;\n}\n/**\n * Give `opener`, a char span's opening glyph that a builder just made, the standalone spacer it owes\n * in front of an annotation mark — the shape {@link $syncOpenerSeparators} heals that gap to, when\n * it heals it. A builder adds it rather than waiting for the sync, because the sync leaves a gap in\n * front of a mark over a name byte to the marker-edit engine as the user's possible rename\n * ({@link $isRenamingGap}), and bytes a builder just put behind a glyph it made are no rename. Any\n * other element after the glyph begins with bytes the name scan stops at, so the sync heals its gap.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $insertOwedOpenerSpacer(opener, char) {\n if (!$isTypedMarkNode(opener.getNextSibling()))\n return;\n if ($openerSeparatorGap(opener, char) === \"spacer\")\n opener.insertAfter($createTextNode(NBSP));\n}\n/** Prefix `text` with the separator NBSP, keeping any selection point inside it on the same\n * character it was on. */\nfunction $prefixSeparator(text) {\n text.setTextContent(NBSP + text.getTextContent());\n const selection = $getSelection();\n if (!$isRangeSelection(selection))\n return;\n for (const point of [selection.anchor, selection.focus])\n if (point.type === \"text\" && point.key === text.getKey())\n point.set(point.key, point.offset + 1, \"text\");\n}\n/**\n * True when `char` has a separator gap the sync is deliberately leaving alone because the caret\n * sits at it (a just-deleted separator). The marker-edit engine pends such spans so caret\n * departure settles them.\n */\nexport function $hasCaretHeldSeparatorGap(char) {\n if (!char.isAttached())\n return false;\n return char\n .getChildren()\n .some((child) => $isMarkerNode(child) &&\n $openerSeparatorGap(child, char) !== undefined &&\n $isCaretAtOpenerBoundary(child, char));\n}\n/**\n * True when `char` has a separator gap the sync must leave for the marker-edit engine: the caret\n * sits at its site (see {@link $hasCaretHeldSeparatorGap}), or the bytes after it would read\n * differently with the separator back (a letter the marker name runs into, or the `*` of a closer)\n * — the gap a type-over leaves as readily as a deletion. The engine pends such a span and settles\n * it on caret departure: a healable gap in place, any other by re-tokenizing the displayed bytes.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $hasUnsettledSeparatorGap(char) {\n if (!char.isAttached())\n return false;\n return char\n .getChildren()\n .some((child) => $isMarkerNode(child) &&\n $openerSeparatorGap(child, char) !== undefined &&\n ($isCaretAtOpenerBoundary(child, char) || $isRenamingGap(child)));\n}\n/**\n * True when `char` has a separator gap that settles by re-tokenizing rather than healing in place:\n * the bytes after it would read differently with the separator back, in a block that has a settle\n * scope. The settle's in-place heal and the sync decide by this same rule, so a gap the sync would\n * heal is never re-tokenized on departure, and the reverse.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $hasRenamingSeparatorGap(char) {\n if (!char.isAttached())\n return false;\n return char\n .getChildren()\n .some((child) => $isMarkerNode(child) &&\n $openerSeparatorGap(child, char) !== undefined &&\n $isRenamingGap(child));\n}\n/**\n * Whether the collapsed caret holds `char`'s separator gap for the user: it sits at the gap's site\n * ({@link $hasCaretHeldSeparatorGap}), or anywhere inside the span while the gap is one the bytes\n * decide ({@link $hasUnsettledSeparatorGap}) — the user is still typing the new marker name, and\n * settling now would split the paragraph under the caret after the first keystroke.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $hasCaretGracedSeparatorGap(char) {\n if ($hasCaretHeldSeparatorGap(char))\n return true;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const isCaretInSpan = anchorNode.is(char) || char.isParentOf(anchorNode);\n return isCaretInSpan && $hasUnsettledSeparatorGap(char);\n}\n","import { $applyNodeReplacement, $getState, $setState, createState, DecoratorNode, isHTMLElement, } from \"lexical\";\nexport const IMMUTABLE_TYPED_TEXT_VERSION = 1;\n/** The `textType` every USFM marker glyph carries, whichever way the view renders it. */\nexport const MARKER_TEXT_TYPE = \"marker\";\n/**\n * Marks a marker glyph as one the view renders in the GUTTER — the fixed column beside the text\n * (`hasGutterParaMarkers`) — rather than inline among the words.\n *\n * The distinction cannot be read off the node's class or its `textType`: the gutter aid and\n * markerMode \"visible\"'s INLINE glyph are both an `ImmutableTypedTextNode` with\n * `textType: \"marker\"`. Nor can it be read off the view, because \"is this marker in the gutter?\" is\n * asked one node at a time — a document can carry gutter markers and inline glyphs at once (a\n * book's `\\id` line, for one). So the fact travels on the node that has it, set where the glyph is\n * built. It separates three cases, each decided per node: an inline glyph keeps its caret; a gutter\n * glyph is never a caret position; and a paragraph's gutter glyph is also a selection target\n * (`$getSelectedParaMarker`, node.utils.ts) that admits a retag or, on Backspace/Delete, a merge\n * into the previous paragraph. This is the one place that explanation lives; the plugins that act\n * on it link here.\n *\n * Set on the SERIALIZED twin by the USJ→editor adaptor's `createImmutableTypedText`\n * (usj-editor.adaptor.ts, platform), which builds JSON rather than live nodes — the same split the\n * `textType` state already has.\n */\nexport const gutterMarkerState = createState(\"isGutterMarker\", {\n parse: (value) => value === true,\n});\nexport class ImmutableTypedTextNode extends DecoratorNode {\n __textType;\n __text;\n constructor(textType = \"\", text = \"\", key) {\n super(key);\n this.__textType = textType;\n this.__text = text;\n }\n static getType() {\n return \"immutable-typed-text\";\n }\n static clone(node) {\n const { __textType, __text, __key } = node;\n return new ImmutableTypedTextNode(__textType, __text, __key);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isTypedTextElement(node))\n return null;\n return {\n conversion: $convertImmutableTypedTextElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createImmutableTypedTextNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setTextType(serializedNode.textType)\n .setTextContent(serializedNode.text);\n }\n setTextType(textType) {\n if (this.__textType === textType)\n return this;\n const self = this.getWritable();\n self.__textType = textType;\n return self;\n }\n getTextType() {\n const self = this.getLatest();\n return self.__textType;\n }\n setTextContent(text) {\n if (this.__text === text)\n return this;\n const self = this.getWritable();\n self.__text = text;\n return self;\n }\n getTextContent() {\n const self = this.getLatest();\n return self.__text;\n }\n /** The text this glyph shows on screen, which {@link createDOM} writes into its element. */\n getRenderedText() {\n return this.getTextContent();\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.setAttribute(\"data-text-type\", this.__textType);\n dom.classList.add(this.__textType);\n // The glyph bytes are written into the element itself, NOT rendered through the decorator\n // portal — see `decorate` for why. The resulting DOM is identical either way (React rendered\n // the same string as this element's only text child), so nothing downstream changes shape.\n dom.textContent = this.__text;\n return dom;\n }\n updateDOM(prevNode, dom) {\n // Keep the rendered bytes in step with an in-place `setTextContent` (the JSON update path is\n // its only caller); the guard means an untouched node writes nothing. `__textType` is\n // deliberately NOT re-applied here — it is only ever set while building a node from JSON,\n // before this element exists, so the class list has never been able to go stale, and\n // re-deriving it would be a behavior change this fix does not need.\n if (prevNode.__text !== this.__text)\n dom.textContent = this.__text;\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-text-type\", this.getTextType());\n }\n return { element };\n }\n /**\n * No decorator payload: the glyph bytes are rendered by {@link createDOM} instead.\n *\n * This node used to return its text here, so `@lexical/react`'s `useDecorators` painted the\n * bytes into this element through a React portal. That is unsound for a value with STABLE\n * IDENTITY. Lexical only notifies its decorator listener when the decorator value actually\n * changes — `reconcileDecorator` bails on `currentDecorators[key] === decorator` — and two equal\n * strings always compare equal. So whenever Lexical DESTROYS and RE-CREATES this node's element\n * while the node itself survives (`$createNode` runs for every child of a freshly created parent,\n * which is exactly what re-parenting a node does), the map never changed, no listener fired,\n * `useDecorators` never rebuilt its portal list, and the portal stayed pointed at the OLD,\n * detached element. The new element was left permanently EMPTY — the glyph vanished from the\n * screen while the node, the USJ, and the file on disk all still carried it, and only remounting\n * the editor brought it back.\n *\n * The marker-edit engine re-parents preserved nodes on every Tier-2 paragraph rebuild\n * (`$replaceSentinels`, tier2Rebuild.utils.ts, moves each preserved node into the rebuilt\n * paragraph), so an `\\optbreak`'s `//` token — a child of the preserved `UnknownNode` — blanked\n * out the first time anything else in its paragraph settled. Rendering from `createDOM` removes\n * the portal indirection entirely: the bytes travel with the element that carries them, so any\n * number of re-parents keeps them, and there is one less React portal per glyph.\n */\n decorate() {\n return null;\n }\n exportJSON() {\n return {\n // Spread first so this node's own properties win: super contributes the NodeState (e.g.\n // `gutterMarkerState`), which `updateFromJSON` reads back, so a glyph that round-trips\n // through JSON stays the same KIND of glyph.\n ...super.exportJSON(),\n type: this.getType(),\n textType: this.getTextType(),\n text: this.getTextContent(),\n version: IMMUTABLE_TYPED_TEXT_VERSION,\n };\n }\n // Mutation\n /**\n * Stays `false` even though a paragraph's gutter glyph can be selected: it is selected only by\n * clicking it (`ParaMarkerSelectionPlugin`, shared-react), and arrow keys never stop on it.\n * Returning `true` would also change Lexical's native Backspace-beside-a-decorator behavior at\n * every paragraph start, where `StructureKeyboardPlugin` arms paragraph merges.\n */\n isKeyboardSelectable() {\n return false;\n }\n}\nfunction $convertImmutableTypedTextElement(element) {\n const textType = element.getAttribute(\"data-text-type\") ?? \"\";\n const text = element.textContent ?? \"\";\n const node = $createImmutableTypedTextNode(textType, text);\n return { node };\n}\nexport function $createImmutableTypedTextNode(textType, text) {\n return $applyNodeReplacement(new ImmutableTypedTextNode(textType, text));\n}\n/**\n * Creates a marker glyph that renders in the gutter — see {@link gutterMarkerState}.\n *\n * @param text - The glyph's bytes, e.g. `\\q1` plus its separator.\n * @returns the marker node, flagged as gutter-rendered.\n */\nexport function $createGutterMarkerNode(text) {\n return $setState($createImmutableTypedTextNode(MARKER_TEXT_TYPE, text), gutterMarkerState, true);\n}\n/**\n * Whether the node is a marker glyph the view renders in the gutter, which is never a place a\n * caret may come to rest — though a paragraph's gutter glyph can be selected whole (see\n * {@link gutterMarkerState}).\n *\n * @param node - The node to check.\n * @returns `true` for a gutter-rendered marker glyph.\n */\nexport function $isGutterMarkerNode(node) {\n return $isImmutableTypedTextNode(node) && $getState(node, gutterMarkerState);\n}\nfunction isTypedTextElement(node) {\n // NOTE: `tagName` is upper-cased for HTML-namespace elements, so this comparison never matches\n // and the `span` conversion above is unreachable. Correcting the case ALONE is not the fix: this\n // predicate's only discriminator is the tag, so a case-insensitive compare makes this node claim\n // EVERY pasted `` at priority 1 — including the verse spans that\n // `StructureKeyboardPlugin`'s paste sanitizer expects to strip down to text. A real fix also has\n // to narrow the predicate (the `data-text-type` attribute `exportDOM` emits is the natural\n // discriminator). Under structure protection, a pasted marker glyph is dropped before parsing\n // (`StructureKeyboardPlugin`'s paste sanitizer removes every `MARKER_TEXT_TYPE` element); outside\n // it, one still arrives as plain marker text.\n return node?.tagName === \"span\";\n}\nexport function $isImmutableTypedTextNode(node) {\n return node instanceof ImmutableTypedTextNode;\n}\nexport function isSerializedImmutableTypedTextNode(node) {\n return node?.type === ImmutableTypedTextNode.getType();\n}\n","/**\n * Unknown-node USFM byte rendering: the single place that owns HOW an `UnknownNode`'s opening\n * marker, attribute, and closing marker bytes are computed for read-only display. Sibling of\n * attributeDisplay.utils.ts (char/verse attribute display runs), following the same owning-module\n * shape, but for a different tree: `UnknownNode`'s kinds (figure, table/table:row/table:cell,\n * sidebar, periph, ref, optbreak) carry no USFM byte representation anywhere in the tree —\n * markers and attributes are simply invisible today. The renderer that flanks a node's existing\n * content children with the bytes this module computes lives elsewhere; this module is the pure\n * byte-computation function it calls.\n *\n * ## Why these bytes carry no round-trip obligation\n *\n * Every kind here stays a Tier-2 sentinel — unlike char spans and verses (attributeDisplay.utils.ts),\n * which grew live display runs that re-tokenize on edit. These bytes only need to be CORRECT\n * USFM, not byte-identical to whatever produced the node; nothing here ever re-tokenizes back\n * into node state, so there is no cache to keep honest and no sync to register.\n *\n * ## Per-kind shapes\n *\n * All four parts are OPAQUE bytes for the consumer to concatenate around the node's content,\n * never to parse. The `attributes` part carries only bytes that belong BETWEEN the opening and\n * the content (sidebar's `\\cat …\\cat*` marker run, periph's marker-line pipe pairs; `\"\"` for\n * every other kind). USFM pipe attributes on span-shaped kinds (the generic default, figure)\n * come AFTER content, directly before the closer, so those kinds populate `closingAttributes`\n * instead — kept as its own part (rather than folded into `closing`) so the consumer can style\n * the `|…` run dimmer than the closer glyph, matching PT9's attribute-run display. Concatenating\n * `closingAttributes + closing` reproduces the exact same bytes a single `closing` string used\n * to carry.\n *\n * - **Generic default** (any kind without a special case below): `\\{marker} ` opening, a\n * `closingAttributes` of {@link canonicalAttributeText} named pairs — always explicit\n * `name=\"value\"`, never the default-attribute collapse, because unknown kinds carry no\n * StyleInfo default to collapse against — and a `closing` of `\\{marker}*` (the char-span shape:\n * `\\zzz content|foo=\"bar\"\\zzz*`).\n * - **optbreak** — PT9 renders `\\optbreak` as the literal token `//`, not a marker: the opening\n * IS the bare text `//`, with no attributes and no closing glyph.\n * - **figure** — USFM 3.0 puts the caption first (`\\fig caption|src=\"…\"\\fig*`), so the attribute\n * bytes go in `closingAttributes`, ahead of the `closing` glyph. USX/USJ's `file` attribute is\n * USFM's `src` (the tokenizer performs the same rename in the other direction;\n * usfmFragmentToUsj.ts); rendering reverses it back so the bytes match what a `\\fig …\\fig*`\n * span actually carries in the file.\n * - **table / table:row / table:cell** — tables have no USFM pipe-attribute syntax at all; a\n * cell's `align`/`colspan` are ENCODED in the marker name itself (`\\thc3-4`), never rendered\n * as attribute bytes. The container contributes no bytes of its own; a row opens with `\\tr `;\n * a cell opens with its own marker, re-encoding a `colspan` back into the span suffix the\n * tokenizer trimmed off (marker `thc3` + colspan `2` → `\\thc3-4 `; see\n * {@link tableCellMarkerWithSpan}); neither ever closes.\n * - **sidebar** — `\\esb`/`\\esbe` bracket the block. A `category` attribute is not a pipe\n * attribute at all but its own char-shaped marker directly after `\\esb`\n * (`\\esb \\cat Missions\\cat*`), mirroring how the tokenizer folds a `\\cat` onto a receptive\n * sidebar (usfmFragmentToUsj.ts).\n * - **periph** — `alt` is a text-content attribute: its value renders as literal marker content\n * right after `\\periph` (`\\periph Title`) rather than a pipe attribute; any remaining\n * attributes (e.g. `id`) are ordinary named pairs. `periph` is an open-ended division marker,\n * so it never closes.\n * - **ref** — a generated wrapper around cross-reference target text; USJ invented this\n * container, USFM never carried it, so it contributes no bytes at all — only its child text\n * renders, as-is.\n *\n * ## Unterminated constructs render no closer\n *\n * Cutting across every kind above: a construct the source never terminated (`closed=\"false\"`) has\n * no closing bytes in the file, so it displays none. Char spans already work this way — see\n * `$charClosingGlyph` (attributeDisplay.utils.ts) — and the rule is the same one for the same\n * reason: a closer shown for bytes the document does not contain is a byte the user can neither\n * edit away nor save.\n */\nimport { canonicalAttributeText } from \"../usj/attributeDisplay.utils.js\";\n/** The USJ attribute name a figure's file reference is stored under — renamed from USFM's `src`\n * by the tokenizer (usfmFragmentToUsj.ts) on the way in; rendering reverses it back. */\nconst FIGURE_FILE_ATTRIBUTE = \"file\";\nconst FIGURE_SRC_ATTRIBUTE = \"src\";\n/** The cell attribute holding the span COUNT the tokenizer derived from the marker's trimmed\n * span suffix; re-encoded back into the opening marker rather than rendered as a pipe pair. */\nconst TABLE_CELL_COLSPAN_ATTRIBUTE = \"colspan\";\n/** The sidebar attribute that renders as its own `\\cat …\\cat*` marker rather than a pipe pair. */\nconst SIDEBAR_CATEGORY_ATTRIBUTE = \"category\";\n/** The periph attribute that renders as literal marker content rather than a pipe pair. */\nconst PERIPH_TEXT_CONTENT_ATTRIBUTE = \"alt\";\n/** The USJ metadata flagging a construct the source never terminated. */\nconst IMPLICITLY_CLOSED_ATTRIBUTE = \"closed\";\nconst IMPLICITLY_CLOSED_VALUE = \"false\";\n/**\n * Whether the source terminated this construct with its own closing bytes. An implicitly closed\n * one (`closed=\"false\"` — the tokenizer's mark for a sidebar the fragment or chapter boundary\n * auto-closed, and USX's same flag read back) has no closing bytes in the file, so it must display\n * none: char spans already follow exactly this rule (`$charClosingGlyph`,\n * attributeDisplay.utils.ts — `createChar` builds no closing glyph for such a span and the display\n * sync must not fabricate one). A closer shown for bytes the document does not contain is one the\n * user can neither edit away nor save.\n */\nfunction isExplicitlyClosed(attributes) {\n return attributes[IMPLICITLY_CLOSED_ATTRIBUTE] !== IMPLICITLY_CLOSED_VALUE;\n}\n/** `attributes` with `file` renamed to `src` in place — the USX/USJ naming reversed back to the\n * byte name a figure's file attribute is actually written with in USFM. Key order is preserved\n * (a `Object.entries` map, not a delete-then-add) so a renamed `file` renders wherever it\n * originally sat among the figure's other attributes. */\nfunction renameFigureFileToSrc(attributes) {\n return Object.fromEntries(Object.entries(attributes).map(([name, value]) => [\n name === FIGURE_FILE_ATTRIBUTE ? FIGURE_SRC_ATTRIBUTE : name,\n value,\n ]));\n}\n/**\n * The USJ name of the attribute an `UnknownNode` of kind `tag` displays under `usfmName` — the\n * inverse of the rename its display applies ({@link unknownDisplayParts}): a figure's `src` bytes\n * are its USJ `file` attribute. Every other name is the same in both.\n */\nexport function unknownUsjAttributeName(tag, usfmName) {\n return tag === \"figure\" && usfmName === FIGURE_SRC_ATTRIBUTE ? FIGURE_FILE_ATTRIBUTE : usfmName;\n}\n/**\n * The cell's opening marker with its span suffix re-encoded from `colspan`. Exported because a\n * cell's display bytes are built by `ImmutableTableCellNode`'s own adaptor path (the kind stopped\n * being an `UnknownNode`), and both builders must spell a spanning cell the same way. The tokenizer\n * (usfmFragmentToUsj.ts, table-cell assembly) splits a spanning cell marker apart on the way in —\n * `\\thc3-4` becomes marker `thc3` (span suffix trimmed off after the start column) plus colspan\n * `\"2\"` (the COUNT of columns spanned, end − start + 1) — so rendering the stored marker bare\n * would silently narrow the cell to a single column. Re-encoding reverses the split: end column =\n * start + count − 1. A `colspan` that is not a real span (absent, non-numeric, or below 2) or a\n * marker with no trailing start column to count from yields the bare marker rather than a garbage\n * suffix.\n */\nexport function tableCellMarkerWithSpan(marker, colspan) {\n if (marker === undefined)\n return undefined;\n const spanCount = Number(colspan);\n if (!Number.isInteger(spanCount) || spanCount < 2)\n return marker;\n // The trailing start column is found by a manual backward scan rather than `/(\\d+)$/`: an\n // end-anchored greedy digit run makes the regex engine retry the match from every position of a\n // long digit run (quadratic on adversarial markers like \"000…0X\"), while the scan is linear.\n // Byte-identical to the regex for every input — a marker that is ALL digits contributes the\n // whole string as its start column, exactly as `(\\d+)$` would match it.\n let digitsStart = marker.length;\n while (digitsStart > 0) {\n const charCode = marker.charCodeAt(digitsStart - 1);\n if (charCode < 0x30 || charCode > 0x39)\n break; // outside '0'..'9'\n digitsStart -= 1;\n }\n if (digitsStart === marker.length)\n return marker;\n return `${marker}-${Number(marker.slice(digitsStart)) + spanCount - 1}`;\n}\n/**\n * The USFM byte strings to render around an `UnknownNode`'s existing content children —\n * `opening` and `attributes` before the content, `closingAttributes` then `closing` after it (see\n * {@link UnknownDisplayParts} for what each part carries per kind) — computed purely from the\n * node's stored `tag` (USJ `type`), `marker`, and `unknownAttributes`. Pure function; read-only\n * display only (see module doc for why these bytes carry no round-trip obligation).\n *\n * @param tag - The `UnknownNode`'s USJ type (e.g. \"figure\", \"table:row\", \"optbreak\").\n * @param marker - The node's stored USFM marker, when the USJ shape carries one.\n * @param unknownAttributes - The node's stored attribute bag, when the USJ shape carries one.\n */\nexport function unknownDisplayParts(tag, marker, unknownAttributes) {\n const attributes = unknownAttributes ?? {};\n const closed = isExplicitlyClosed(attributes);\n switch (tag) {\n case \"optbreak\":\n return { opening: \"//\", attributes: \"\", closingAttributes: \"\", closing: \"\" };\n case \"ref\":\n case \"table\":\n // Generated wrapper (ref) and bare container (table): neither carries USFM bytes of its\n // own — a table's bytes live entirely on its table:row/table:cell children.\n return { opening: \"\", attributes: \"\", closingAttributes: \"\", closing: \"\" };\n case \"table:row\":\n return { opening: `\\\\${marker} `, attributes: \"\", closingAttributes: \"\", closing: \"\" };\n case \"table:cell\":\n // The marker name itself IS the cell's shape (`\\tc1`, `\\thc3-4`, …): `align` is already\n // encoded in it, and a `colspan` re-encodes into its span suffix (see\n // tableCellMarkerWithSpan) — neither ever renders as pipe-attribute bytes, which USFM\n // tables do not have.\n return {\n opening: `\\\\${tableCellMarkerWithSpan(marker, attributes[TABLE_CELL_COLSPAN_ATTRIBUTE])} `,\n attributes: \"\",\n closingAttributes: \"\",\n closing: \"\",\n };\n case \"figure\":\n // USFM 3.0 figures put the caption FIRST (`\\fig caption|src=\"…\"\\fig*`), so the attribute\n // bytes go in closingAttributes, ahead of the closing glyph — rendering them between the\n // opening and the caption would strand the caption after the attribute list, which is\n // invalid USFM. Kept as its own part (rather than folded into `closing`) so the caller can\n // style the `|…` run dimmer than the `\\fig*` glyph, matching PT9's attribute-run display.\n return {\n opening: `\\\\${marker} `,\n attributes: \"\",\n closingAttributes: canonicalAttributeText(renameFigureFileToSrc(attributes), undefined),\n closing: closed ? `\\\\${marker}*` : \"\",\n };\n case \"sidebar\": {\n const { [SIDEBAR_CATEGORY_ATTRIBUTE]: category, ...rest } = attributes;\n const categoryBytes = category === undefined ? \"\" : ` \\\\cat ${category}\\\\cat*`;\n return {\n opening: \"\\\\esb\",\n attributes: categoryBytes + canonicalAttributeText(rest, undefined),\n closingAttributes: \"\",\n closing: closed ? \"\\\\esbe\" : \"\",\n };\n }\n case \"periph\": {\n const { [PERIPH_TEXT_CONTENT_ATTRIBUTE]: alt, ...rest } = attributes;\n return {\n opening: `\\\\periph ${alt ?? \"\"}`,\n attributes: canonicalAttributeText(rest, undefined),\n closingAttributes: \"\",\n closing: \"\",\n };\n }\n default:\n // Char-span shape is the natural default for an attributed unknown span: content first,\n // pipe attributes directly before the closer (`\\zzz content|foo=\"bar\"\\zzz*`) — kept as its\n // own closingAttributes part (rather than folded into `closing`) so the caller can style\n // the `|…` run dimmer than the `\\zzz*` glyph, matching PT9's attribute-run display.\n return {\n opening: `\\\\${marker} `,\n attributes: \"\",\n closingAttributes: canonicalAttributeText(attributes, undefined),\n closing: closed ? `\\\\${marker}*` : \"\",\n };\n }\n}\n","/**\n * The display-run registry: one {@link DisplayRunDescriptor} per engine-owned display kind.\n *\n * Assembled HERE rather than in `nodes/usj` because a descriptor's byte derivation needs the\n * converters (`defaultMarkerAttribute`, `milestoneDefaultAttribute`) and `nodes/usj` must not\n * import from `converters/usfm`, which already imports FROM `nodes/usj`. This module sits above\n * both, so it can hold the assembly without a cycle — the same layering `plugins/PerfOperations`\n * uses. The drivers that CONSUME descriptors take one as a parameter and stay in `nodes/usj`.\n *\n * Each descriptor's `ownerOf` implements the ONE owner walk for its kind, keyed on marker\n * identity: only pieces of that same kind's run may sit between a candidate piece and its owner,\n * so a foreign glyph or unrelated content ends the walk with no owner. `$ownerOfRunPiece`\n * (displayRunOwner.utils.ts) is the single classifier that consults every descriptor in order.\n */\nimport { $chapterAltnumberRunPieces, $chapterCpAnchor, $chapterGlyphTextNode, $chapterPubnumberRunPieces, $charAttributeDisplayNode, $charClosingGlyph, $milestoneAttributeRunPieces, $noteCategoryRunPieces, $noteEditableCallerNode, $verseAttributeRunPieces, canonicalAttributeText, milestoneAttributes, } from \"../nodes/usj/attributeDisplay.utils.js\";\nimport { $isAttributeRunNode } from \"../nodes/usj/AttributeRunNode.js\";\nimport { $isChapterNode } from \"../nodes/usj/ChapterNode.js\";\nimport { $isCharNode } from \"../nodes/usj/CharNode.js\";\nimport { $isNoteNode } from \"../nodes/usj/NoteNode.js\";\nimport { $hasCaretGracedSeparatorGap } from \"../nodes/usj/markerSeparators.utils.js\";\nimport { $isMilestoneNode } from \"../nodes/usj/MilestoneNode.js\";\nimport { NBSP } from \"../nodes/usj/node-constants.js\";\nimport { $isVerseNode } from \"../nodes/usj/VerseNode.js\";\nimport { textTypeState } from \"../nodes/collab/delta.state.js\";\nimport { $isImmutableTypedTextNode } from \"../nodes/features/ImmutableTypedTextNode.js\";\nimport { $isMarkerNode } from \"../nodes/features/MarkerNode.js\";\nimport { $isUnknownNode } from \"../nodes/features/UnknownNode.js\";\nimport { unknownDisplayParts } from \"../nodes/features/unknownUsfm.utils.js\";\nimport { defaultMarkerAttribute, milestoneDefaultAttribute, } from \"../converters/usfm/usfmFragmentToUsj.js\";\nimport { $getSelection, $getState, $isElementNode, $isRangeSelection, $isTextNode, } from \"lexical\";\n/** No run wanted and no value — the answer for an owner whose state carries nothing to display,\n * and the safe answer when a descriptor is handed a node of the wrong type. */\nconst NO_RUN = { wantsRun: false, valueText: undefined };\n/** No pieces found — the answer when a descriptor is handed a node of the wrong type. */\nconst NO_PIECES = {};\n/** The sibling a verse's run for `marker` is anchored after: the verse itself for `\\va`, and\n * `\\va`'s wrapper (or, while caret-grace defers the wrap, its loose closer) for `\\vp`. Shared by\n * the scanner and the writer so the two can never disagree about where a run belongs. */\nfunction $verseRunAnchor(verse, marker) {\n if (marker === \"va\")\n return verse;\n const va = $verseAttributeRunPieces(verse, \"va\");\n return va.wrapper ?? va.closer ?? verse;\n}\n/** The caret arm a run graces when NO piece survives: the run's insertion point is the end of\n * its anchor or the very start of the anchor's next sibling, where a range deletion collapses\n * the caret. An ELEMENT anchor (a chapter `\\cp` run's anchor is the `\\ca` run's WRAPPER) has no\n * text end of its own — the collapse point is the end of its last descendant text piece (the\n * `\\ca` closer glyph), so that arm is checked too. The shared reporter already graces the\n * wrapper's subtree and the live value node. */\nfunction $verseFlankGrace(anchor) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n if (anchorNode.is(anchor) && selection.anchor.offset === anchor.getTextContentSize())\n return true;\n if ($isElementNode(anchor)) {\n const last = anchor.getLastDescendant();\n if (last !== null &&\n anchorNode.is(last) &&\n selection.anchor.offset === last.getTextContentSize())\n return true;\n }\n const next = anchor.getNextSibling();\n return next !== null && anchorNode.is(next) && selection.anchor.offset === 0;\n}\n/** The caret arm shared by verse and milestone runs when only the VALUE was deleted beside a\n * surviving opening glyph: the end of the opening glyph's own text, or the trailing glyph. */\nfunction $glyphDebrisGrace(pieces) {\n const { opener, closer } = pieces;\n if (!opener)\n return false;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const atOpenerEnd = anchorNode.is(opener) && selection.anchor.offset === opener.getTextContentSize();\n if (closer)\n return atOpenerEnd || anchorNode.is(closer);\n return atOpenerEnd;\n}\n/** Whether `node` is a piece of a verse's `\\va`/`\\vp` run — a whole wrapper (crossed in one step,\n * so a `\\vp` piece's walk passes its own `\\va` wrapper), a `va`/`vp` glyph riding loose, or a\n * loose attribute-tagged value. Loose shapes are transient (an undo stack, a collab-materialized\n * bare verse, a mid-edit tree with one marker wrapped and the other not) but real for a commit. */\nfunction $isVerseRunPiece(node) {\n if ($isAttributeRunNode(node))\n return node.getRunKind() === \"va\" || node.getRunKind() === \"vp\";\n if ($isMarkerNode(node))\n return node.getMarker() === \"va\" || node.getMarker() === \"vp\";\n return $isTextNode(node) && $getState(node, textTypeState) === \"attribute\";\n}\n/** The `va`/`vp` marker a loose piece belongs to: its own marker for a glyph, and for a value the\n * marker of the glyph immediately before it — the run pieces' fixed order puts a value's own opener\n * exactly one step back, even in the previous state where that opener is also being destroyed.\n *\n * The value arm requires the candidate to BE a run piece (an attribute-tagged TextNode), not merely\n * to sit behind one, mirroring the milestone side's `$isMilestoneRunPiece` rule. Position alone is\n * not enough: the ordinary verse text that follows a settled `\\va …\\va*` run also has that run's\n * closing glyph as its previous sibling, and claiming it would pend the verse — and run a settle\n * plus a whole-paragraph rebuild — for a deletion in unrelated content. */\nfunction $loosePieceMarker(node) {\n if ($isMarkerNode(node)) {\n const marker = node.getMarker();\n return marker === \"va\" || marker === \"vp\" ? marker : undefined;\n }\n if (!$isTextNode(node) || $getState(node, textTypeState) !== \"attribute\")\n return undefined;\n const previous = node.getPreviousSibling();\n if (!$isMarkerNode(previous))\n return undefined;\n const marker = previous.getMarker();\n return marker === \"va\" || marker === \"vp\" ? marker : undefined;\n}\n/** Walk back from `start` over `marker`'s own run pieces to the VerseNode the run rides on. */\nfunction $verseOfRunChain(start) {\n for (let previous = start.getPreviousSibling(); previous; previous = previous.getPreviousSibling()) {\n if ($isVerseNode(previous))\n return previous;\n if (!$isVerseRunPiece(previous))\n return undefined;\n }\n return undefined;\n}\nfunction verseDescriptor(marker) {\n return {\n kind: marker,\n ownerPredicate: (node) => $isVerseNode(node),\n ownerOf: (node) => {\n // A wrapper of this marker is its own walk start; a piece INSIDE one is only positioned\n // relative to its siblings within the wrapper, so the walk starts from the wrapper instead.\n if ($isAttributeRunNode(node))\n return node.getRunKind() === marker ? $verseOfRunChain(node) : undefined;\n const parent = node.getParent();\n if ($isAttributeRunNode(parent))\n return parent.getRunKind() === marker ? $verseOfRunChain(parent) : undefined;\n return $loosePieceMarker(node) === marker ? $verseOfRunChain(node) : undefined;\n },\n expectedPieces: (owner) => {\n if (!$isVerseNode(owner))\n return NO_RUN;\n const value = marker === \"va\" ? owner.getAltnumber() : owner.getPubnumber();\n if (value === undefined)\n return NO_RUN;\n return { wantsRun: true, valueText: NBSP + value };\n },\n scanPieces: (owner) => $isVerseNode(owner)\n ? $verseAttributeRunPieces($verseRunAnchor(owner, marker), marker)\n : NO_PIECES,\n graceSite: (owner, pieces) => {\n if (!$isVerseNode(owner))\n return false;\n if (!pieces.opener && !pieces.closer)\n return $verseFlankGrace($verseRunAnchor(owner, marker));\n return $glyphDebrisGrace(pieces);\n },\n settleScope: \"owner\",\n deletionPolicy: \"retokenize\",\n byteFormat: {\n writer: \"wrapper\",\n runKind: marker,\n glyphs: \"with-value\",\n glyphMarker: () => marker,\n closerSyntax: \"closing\",\n insertRunAfter: (owner) => ($isVerseNode(owner) ? $verseRunAnchor(owner, marker) : undefined),\n },\n };\n}\nconst separatorDescriptor = {\n kind: \"separator\",\n // The NBSP a char span shows after its opening glyph. Its \"deletion\" is a TEXT mutation (an NBSP\n // prefix edit), not node destruction, so it has no owner walk and no destruction pend — its\n // caret-grace path is what settles it, exactly as before joining the registry.\n ownerPredicate: (node) => $isCharNode(node),\n ownerOf: () => undefined,\n expectedPieces: () => NO_RUN,\n scanPieces: () => NO_PIECES,\n graceSite: (owner) => $isCharNode(owner) && $hasCaretGracedSeparatorGap(owner),\n settleScope: \"owner\",\n deletionPolicy: \"retokenize\",\n byteFormat: { writer: \"kind-owned\", glyphs: \"none\" },\n};\nconst charDescriptor = {\n kind: \"char\",\n ownerPredicate: (node) => $isCharNode(node),\n ownerOf: (node) => {\n // A char span's run is a direct TextNode child, never wrapped and never a glyph.\n if (!$isTextNode(node) || $getState(node, textTypeState) !== \"attribute\")\n return undefined;\n const parent = node.getParent();\n return $isCharNode(parent) ? parent : undefined;\n },\n expectedPieces: (owner) => {\n if (!$isCharNode(owner))\n return NO_RUN;\n // A span with no closing glyph never carries a run regardless of its attributes: the adaptor\n // never builds one there, so the sync must not fabricate one either.\n if ($charClosingGlyph(owner) === undefined)\n return NO_RUN;\n const text = canonicalAttributeText(owner.getUnknownAttributes() ?? {}, defaultMarkerAttribute(owner.getMarker()));\n return text === \"\" ? NO_RUN : { wantsRun: true, valueText: text };\n },\n scanPieces: (owner) => $isCharNode(owner) ? { value: $charAttributeDisplayNode(owner) } : NO_PIECES,\n graceSite: (owner, pieces) => {\n // The insertion-point arms for a run that is missing: the closing glyph the run would be\n // inserted before, or the text-end of the content immediately preceding that glyph.\n if (!$isCharNode(owner) || pieces.value)\n return false;\n const closingGlyph = $charClosingGlyph(owner);\n if (!closingGlyph)\n return false;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n if (anchorNode.is(closingGlyph))\n return true;\n const lastContent = closingGlyph.getPreviousSibling();\n return (lastContent !== null &&\n anchorNode.is(lastContent) &&\n selection.anchor.offset === lastContent.getTextContentSize());\n },\n settleScope: \"owner\",\n deletionPolicy: \"retokenize\",\n byteFormat: {\n writer: \"owner-children\",\n glyphs: \"none\",\n insertRunBefore: (owner) => ($isCharNode(owner) ? $charClosingGlyph(owner) : undefined),\n },\n};\n/** Whether `node` is a loose piece of a note's `\\cat` run — a `cat` glyph, or an attribute-tagged\n * value whose own opener (one step back, the run pieces' fixed order) is a `cat` glyph. The value\n * arm requires the candidate to BE a run piece, mirroring `$loosePieceMarker`'s rule for verses:\n * position alone must not claim ordinary note content that happens to follow a settled run. */\nfunction $isLooseCatPiece(node) {\n if ($isMarkerNode(node))\n return node.getMarker() === \"cat\";\n if (!$isTextNode(node) || $getState(node, textTypeState) !== \"attribute\")\n return false;\n const previous = node.getPreviousSibling();\n return $isMarkerNode(previous) && previous.getMarker() === \"cat\";\n}\n/** Walk back from `start` over the cat run's own pieces to the editable caller anchor, and from\n * there to the NoteNode the run rides in. A piece's parent must BE the note (loose pieces are the\n * note's direct children); crossing anything that is not a cat piece ends the walk with no owner. */\nfunction $noteOfCatChain(start) {\n const parent = start.getParent();\n if (!$isNoteNode(parent))\n return undefined;\n const anchor = $noteEditableCallerNode(parent);\n if (!anchor)\n return undefined;\n for (let previous = start.getPreviousSibling(); previous; previous = previous.getPreviousSibling()) {\n if (previous.is(anchor))\n return parent;\n if (!$isLooseCatPiece(previous))\n return undefined;\n }\n return undefined;\n}\nconst catDescriptor = {\n kind: \"cat\",\n ownerPredicate: (node) => $isNoteNode(node),\n ownerOf: (node) => {\n // A note's run rides as its CHILDREN (a NoteNode is an ElementNode), so the wrapper's parent\n // IS the owner — no sibling chain to walk for the wrapped shape. Loose pieces walk back to\n // the caller anchor exactly like a verse's loose pieces walk back to their verse.\n if ($isAttributeRunNode(node))\n return node.getRunKind() === \"cat\" && $isNoteNode(node.getParent())\n ? (node.getParent() ?? undefined)\n : undefined;\n const parent = node.getParent();\n if ($isAttributeRunNode(parent))\n return parent.getRunKind() === \"cat\" && $isNoteNode(parent.getParent())\n ? (parent.getParent() ?? undefined)\n : undefined;\n return $isLooseCatPiece(node) ? $noteOfCatChain(node) : undefined;\n },\n expectedPieces: (owner) => {\n if (!$isNoteNode(owner))\n return NO_RUN;\n // Collapsed notes deliberately do not display the category (their content is not inline\n // display text at all), and only the expanded editable shape carries the caller anchor the\n // run is positioned by.\n if (owner.getIsCollapsed() !== false)\n return NO_RUN;\n const category = owner.getCategory();\n if (category === undefined)\n return NO_RUN;\n return { wantsRun: true, valueText: NBSP + category };\n },\n scanPieces: (owner) => ($isNoteNode(owner) ? $noteCategoryRunPieces(owner) : NO_PIECES),\n graceSite: (owner, pieces) => {\n if (!$isNoteNode(owner))\n return false;\n if (!pieces.opener && !pieces.closer) {\n const anchor = $noteEditableCallerNode(owner);\n return anchor !== undefined && $verseFlankGrace(anchor);\n }\n return $glyphDebrisGrace(pieces);\n },\n settleScope: \"owner\",\n deletionPolicy: \"retokenize\",\n byteFormat: {\n writer: \"wrapper\",\n runKind: \"cat\",\n glyphs: \"with-value\",\n glyphMarker: () => \"cat\",\n closerSyntax: \"closing\",\n insertRunAfter: (owner) => ($isNoteNode(owner) ? $noteEditableCallerNode(owner) : undefined),\n },\n};\n/** Whether `node` is a piece of a chapter's `\\ca`/`\\cp` runs — a whole wrapper of either kind\n * (crossed in one step, so a loose `\\cp` piece's walk passes the `\\ca` wrapper), a `ca`/`cp`\n * glyph riding loose, or a loose attribute-tagged value — the chapter twin of\n * `$isVerseRunPiece`. */\nfunction $isChapterRunPiece(node) {\n if ($isAttributeRunNode(node))\n return node.getRunKind() === \"ca\" || node.getRunKind() === \"cp\";\n if ($isMarkerNode(node))\n return node.getMarker() === \"ca\" || node.getMarker() === \"cp\";\n return $isTextNode(node) && $getState(node, textTypeState) === \"attribute\";\n}\n/** The `ca`/`cp` marker a loose chapter piece belongs to — the chapter twin of\n * `$loosePieceMarker`, with the same value-arm rule (the candidate must BE a run piece whose own\n * opener sits one step back; position alone must not claim unrelated content). */\nfunction $chapterLoosePieceMarker(node) {\n if ($isMarkerNode(node)) {\n const marker = node.getMarker();\n return marker === \"ca\" || marker === \"cp\" ? marker : undefined;\n }\n if (!$isTextNode(node) || $getState(node, textTypeState) !== \"attribute\")\n return undefined;\n const previous = node.getPreviousSibling();\n if (!$isMarkerNode(previous))\n return undefined;\n const marker = previous.getMarker();\n return marker === \"ca\" || marker === \"cp\" ? marker : undefined;\n}\n/** Walk back from `start` over the chapter runs' own pieces (of EITHER kind — a `\\cp` piece's\n * walk crosses the whole `\\ca` wrapper in one step) to the chapter's `\\c N` glyph anchor, and\n * from there to the ChapterNode the runs ride in — the chapter twin of `$verseOfRunChain`. */\nfunction $chapterOfRunChain(start) {\n const parent = start.getParent();\n if (!$isChapterNode(parent))\n return undefined;\n const anchor = $chapterGlyphTextNode(parent);\n if (!anchor)\n return undefined;\n for (let previous = start.getPreviousSibling(); previous; previous = previous.getPreviousSibling()) {\n if (previous.is(anchor))\n return parent;\n if (!$isChapterRunPiece(previous))\n return undefined;\n }\n return undefined;\n}\n/** One chapter attribute-marker descriptor — `\"ca\"` (altnumber; opener + value + closer) or\n * `\"cp\"` (pubnumber; opener + value, NO closer: the span closes implicitly at the next block\n * boundary in the file, so its wrapper alone bounds the value). The runs ride as the editable\n * chapter's CHILDREN in document order — glyph text, then `\\ca`'s wrapper, then `\\cp`'s — the\n * same-line byte position the chapter fragment re-tokenizes and ParatextData's own chapter-path\n * folding accepts. */\nfunction chapterDescriptor(marker) {\n const $anchor = (chapter) => !$isChapterNode(chapter)\n ? undefined\n : marker === \"ca\"\n ? $chapterGlyphTextNode(chapter)\n : $chapterCpAnchor(chapter);\n return {\n kind: marker,\n ownerPredicate: (node) => $isChapterNode(node),\n ownerOf: (node) => {\n if ($isAttributeRunNode(node))\n return node.getRunKind() === marker && $isChapterNode(node.getParent())\n ? (node.getParent() ?? undefined)\n : undefined;\n const parent = node.getParent();\n if ($isAttributeRunNode(parent))\n return parent.getRunKind() === marker && $isChapterNode(parent.getParent())\n ? (parent.getParent() ?? undefined)\n : undefined;\n return $chapterLoosePieceMarker(node) === marker ? $chapterOfRunChain(node) : undefined;\n },\n expectedPieces: (owner) => {\n if (!$isChapterNode(owner))\n return NO_RUN;\n const value = marker === \"ca\" ? owner.getAltnumber() : owner.getPubnumber();\n if (value === undefined)\n return NO_RUN;\n return { wantsRun: true, valueText: NBSP + value };\n },\n scanPieces: (owner) => !$isChapterNode(owner)\n ? NO_PIECES\n : marker === \"ca\"\n ? $chapterAltnumberRunPieces(owner)\n : $chapterPubnumberRunPieces(owner),\n graceSite: (owner, pieces) => {\n if (!$isChapterNode(owner))\n return false;\n if (!pieces.opener && !pieces.closer) {\n const anchor = $anchor(owner);\n return anchor !== undefined && $verseFlankGrace(anchor);\n }\n return $glyphDebrisGrace(pieces);\n },\n settleScope: \"owner\",\n deletionPolicy: \"retokenize\",\n byteFormat: {\n writer: \"wrapper\",\n runKind: marker,\n glyphs: \"with-value\",\n glyphMarker: () => marker,\n closerSyntax: marker === \"ca\" ? \"closing\" : \"none\",\n insertRunAfter: $anchor,\n },\n };\n}\n/** Whether `node` is a loose piece of a milestone's run — an opening glyph, a self-closing glyph,\n * or an attribute-tagged value. A milestone's opening glyph carries the milestone's OWN marker,\n * which the chain walk re-checks against the candidate owner. */\nfunction $isMilestoneRunPiece(node) {\n if ($isMarkerNode(node)) {\n const syntax = node.getMarkerSyntax();\n return syntax === \"selfClosing\" || syntax === \"opening\";\n }\n return $isTextNode(node) && $getState(node, textTypeState) === \"attribute\";\n}\n/** Walk back from a LOOSE milestone run piece over the run's other loose pieces to the milestone,\n * requiring a matching marker on any opening glyph crossed. */\nfunction $milestoneOfLooseChain(start) {\n for (let previous = start.getPreviousSibling(); previous; previous = previous.getPreviousSibling()) {\n if ($isMilestoneNode(previous)) {\n const opening = $isMarkerNode(start) && start.getMarkerSyntax() === \"opening\" ? start : undefined;\n return !opening || opening.getMarker() === previous.getMarker() ? previous : undefined;\n }\n if (!$isMilestoneRunPiece(previous))\n return undefined;\n }\n return undefined;\n}\nconst milestoneDescriptor = {\n kind: \"milestone\",\n ownerPredicate: (node) => $isMilestoneNode(node),\n ownerOf: (node) => {\n const start = $isAttributeRunNode(node)\n ? node.getRunKind() === \"milestone\"\n ? node\n : undefined\n : $isAttributeRunNode(node.getParent())\n ? node.getParent()\n : $isMilestoneRunPiece(node)\n ? node\n : undefined;\n if (!start)\n return undefined;\n if ($isAttributeRunNode(start) && start.getRunKind() !== \"milestone\")\n return undefined;\n const previous = start.getPreviousSibling();\n // A milestone's run is a SINGLE wrapper (or one contiguous loose group) directly following its\n // milestone — there is no second marker to cross, unlike a verse's `\\va`/`\\vp` pair. A WRAPPER\n // requires direct adjacency to the milestone (the builder always creates/heals it immediately\n // after — never behind intervening debris), so it gets no chain walk of its own; a LOOSE piece\n // delegates entirely to $milestoneOfLooseChain, which both walks the chain AND re-checks marker\n // identity against any opening glyph it crosses — the check the retired sibling walk lacked, so\n // a foreign opening glyph (any marker) adjacent to a milestone must not classify it as owner.\n if ($isAttributeRunNode(start))\n return $isMilestoneNode(previous) ? previous : undefined;\n return $milestoneOfLooseChain(start);\n },\n expectedPieces: (owner) => {\n if (!$isMilestoneNode(owner))\n return NO_RUN;\n const attributes = milestoneAttributes(owner.getSid(), owner.getEid(), owner.getUnknownAttributes(), owner.getAttributeOrder());\n const text = canonicalAttributeText(attributes, milestoneDefaultAttribute(owner.getMarker()));\n // The glyph pair is unconditional: a milestone always displays `\\qt-s …\\*`, so the run is\n // wanted even when no attribute text rides between the glyphs.\n return { wantsRun: true, valueText: text === \"\" ? undefined : NBSP + text };\n },\n scanPieces: (owner) => {\n if (!$isMilestoneNode(owner))\n return NO_PIECES;\n // $milestoneAttributeRunPieces names its fields opening/attribute/closing (its own long-lived\n // vocabulary, shared with the Tier-2 rebuild); ScannedRun's fields are opener/value/closer —\n // the descriptor registry's cross-kind vocabulary. Translate rather than rename either side.\n //\n // This translation is NOT enforced by the compiler: MilestoneRunPieces's fields\n // (opening/attribute/closing/wrapper) and ScannedRun's fields (opener/value/closer/wrapper)\n // are ALL optional on both sides, so returning $milestoneAttributeRunPieces(owner) directly —\n // the untranslated shape — type-checks with zero errors (verified directly: `tsc --build`\n // reports nothing). Excess-property checking only fires on fresh object literals, not on a\n // value flowing through a function call, and an all-optional target type has no required\n // field whose absence would fail assignability either. The wrong shape compiles clean and\n // then reads as permanently empty at runtime (opener/value/closer come back undefined\n // forever) — displayRunRegistry.test.ts's scanPieces suite is what actually catches this.\n const { opening, attribute, closing, wrapper } = $milestoneAttributeRunPieces(owner);\n return { opener: opening, value: attribute, closer: closing, wrapper };\n },\n graceSite: (owner, pieces) => {\n if (!$isMilestoneNode(owner))\n return false;\n if (!pieces.opener && !pieces.closer) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const previous = owner.getPreviousSibling();\n if (previous !== null &&\n anchorNode.is(previous) &&\n selection.anchor.offset === previous.getTextContentSize())\n return true;\n const next = owner.getNextSibling();\n return next !== null && anchorNode.is(next) && selection.anchor.offset === 0;\n }\n return $glyphDebrisGrace(pieces);\n },\n settleScope: \"owner\",\n deletionPolicy: \"remove-owner\",\n byteFormat: {\n writer: \"wrapper\",\n runKind: \"milestone\",\n glyphs: \"unconditional\",\n glyphMarker: (owner) => ($isMilestoneNode(owner) ? owner.getMarker() : \"\"),\n closerSyntax: \"selfClosing\",\n insertRunAfter: (owner) => owner,\n },\n};\n/** The optbreak's entire byte representation — the literal `//` token — derived from the ONE\n * renderer of unknown-kind bytes so the registry can never drift from what is actually drawn. */\nconst optbreakDisplayText = unknownDisplayParts(\"optbreak\", undefined, undefined).opening;\nconst optbreakDescriptor = {\n kind: \"optbreak\",\n ownerPredicate: (node) => $isUnknownNode(node) && node.getTag() === \"optbreak\",\n ownerOf: (node) => {\n // The adaptor renders the `//` token as an ImmutableTypedTextNode (a read-only DecoratorNode),\n // but an edited optbreak can hold a plain TextNode instead, so both are recognized.\n const parent = node.getParent();\n if (!$isUnknownNode(parent) || parent.getTag() !== \"optbreak\")\n return undefined;\n return $isTextNode(node) || $isImmutableTypedTextNode(node) ? parent : undefined;\n },\n // `valueText` is the RENDERED BYTES the kind owes — so `$runDiverges`'s value-byte comparison\n // classifies the scanned token by what it actually spells: a canonical `//` is at rest, a\n // byte-damaged or deleted token diverges. With `valueText: undefined` (the pre-audit shape)\n // both answers were backwards: a canonical token's text never equalled `undefined`, so a\n // CANONICAL optbreak read as diverged while a GUTTED one read as at rest. Nothing ever WRITES\n // from this (the `\"read-only\"` writer returns before any sync write), so the value is purely\n // classificatory.\n expectedPieces: () => ({ wantsRun: true, valueText: optbreakDisplayText }),\n scanPieces: (owner) => $isUnknownNode(owner) ? { value: owner.getFirstChild() ?? undefined } : NO_PIECES,\n graceSite: () => false,\n settleScope: \"owner\",\n deletionPolicy: \"remove-owner\",\n byteFormat: { writer: \"read-only\", glyphs: \"none\" },\n};\nconst opaqueUnknownDescriptor = {\n kind: \"opaqueUnknown\",\n // Scope is every UnknownNode kind EXCEPT optbreak — `ownerPredicate` excludes it explicitly, so\n // `optbreakDescriptor` above is the sole owner of that kind. A non-optbreak UnknownNode is a\n // permanent Tier-2 sentinel whose bytes are read-only rendering, never re-tokenized: it owns no\n // display run, but is recognized so the settle reports it handled and the caller never routes one\n // through a rebuild that would bail. (A pended optbreak that does NOT match `optbreakDescriptor`'s\n // `remove-owner` shape — i.e. isn't entirely absent — falls through unhandled by either\n // descriptor instead; harmlessly inert, since `$settleScopeForNode` refuses every `UnknownNode`\n // outright, so the caller's `$requestTier2ForNode` fallback always bails on it too.)\n ownerPredicate: (node) => $isUnknownNode(node) && node.getTag() !== \"optbreak\",\n ownerOf: () => undefined,\n expectedPieces: () => NO_RUN,\n scanPieces: () => NO_PIECES,\n graceSite: () => false,\n settleScope: \"owner\",\n deletionPolicy: \"none\",\n byteFormat: { writer: \"read-only\", glyphs: \"none\" },\n};\nconst nestedGlyphDescriptor = {\n kind: \"nestedGlyph\",\n // The `+` on a nested span's glyphs. Purely tree-derived and rewritten in place by its own sync;\n // there is no state a user edit can leave half-finished, so it owes no pend or deletion duty.\n ownerPredicate: (node) => $isCharNode(node),\n ownerOf: () => undefined,\n expectedPieces: () => NO_RUN,\n scanPieces: () => NO_PIECES,\n graceSite: () => false,\n settleScope: \"none\",\n deletionPolicy: \"none\",\n byteFormat: { writer: \"kind-owned\", glyphs: \"none\" },\n};\n/** Every registered kind, in the order the pend/settle driver consults them. THREE descriptors\n * declare `ownerPredicate: $isCharNode` — `separator` (the NBSP gap after an opening glyph), `char`\n * (the span's own `|…` attribute run), and `nestedGlyph` (the `+` on a nested span's glyphs) — so a\n * `CharNode` matches all three. `separator` is listed before `char`, so its grace is checked first,\n * preserving the order the per-kind arms ran in. `cat`, `ca`, and `cp` are listed before `milestone` so their\n * loose glyphs are claimed by their own descriptors first — the milestone loose-piece test\n * accepts ANY opening glyph and only rejects it deeper in its chain walk. `nestedGlyph` never acts in the\n * settle loops at all: its `settleScope` is `\"none\"`, so those loops skip it outright — its `+` is\n * purely tree-derived and rewritten in place by its own sync, with no state a user edit can leave\n * half-finished. */\nexport const displayRunDescriptors = [\n separatorDescriptor,\n charDescriptor,\n verseDescriptor(\"va\"),\n verseDescriptor(\"vp\"),\n catDescriptor,\n chapterDescriptor(\"ca\"),\n chapterDescriptor(\"cp\"),\n milestoneDescriptor,\n optbreakDescriptor,\n opaqueUnknownDescriptor,\n nestedGlyphDescriptor,\n];\nconst byKind = new Map(displayRunDescriptors.map((descriptor) => [descriptor.kind, descriptor]));\n/** The descriptor for `kind`. Throws for an unregistered kind — a kind is only nameable once its\n * descriptor exists, so a miss is a wiring bug, never a runtime condition to handle. */\nexport function displayRunDescriptor(kind) {\n const descriptor = byKind.get(kind);\n if (!descriptor)\n throw new Error(`No display-run descriptor registered for kind \"${kind}\"`);\n return descriptor;\n}\n","/**\n * The ONE walk from a display-run piece back to its owner, for every kind.\n *\n * A piece can be a live node (an edit inside a run dirties the piece or its wrapper, never the\n * leaf owner, whose own transform would then not fire) or a node read from the PREVIOUS editor\n * state (a destroyed piece, which still has its tree position there). The walk is identical in\n * both cases — it reads only tree position — so one function serves the live re-sync path and the\n * destruction-pend path alike.\n *\n * The chain classification is keyed on MARKER IDENTITY, not on \"is this a glyph\": only pieces of\n * the same kind's run may sit between a piece and its owner. Anything else — a char span's own\n * opener riding beside a verse, a note glyph — ends the walk with no owner, so a deletion in\n * unrelated content can never pend a nearby verse or milestone.\n */\nimport { displayRunDescriptors } from \"./displayRunRegistry.js\";\n/**\n * The owner whose run `piece` belongs to, and that run's kind — or `undefined` when `piece` is not\n * part of any registered display run. Descriptors are consulted in registry order and the first\n * match wins; each kind's `ownerOf` recognizes only its own pieces, so at most one can match.\n */\nexport function $ownerOfRunPiece(piece) {\n for (const descriptor of displayRunDescriptors) {\n const owner = descriptor.ownerOf(piece);\n if (owner)\n return { owner, kind: descriptor.kind };\n }\n return undefined;\n}\n/**\n * True when `node` is a piece — a run glyph or an attribute value — of a display run whose kind\n * implements an owner walk (currently `va`/`vp`, `milestone`, `char`, and `optbreak`; see each\n * descriptor's `ownerOf` in displayRunRegistry.ts). A kind with no owner walk (`separator`,\n * `opaqueUnknown`, `nestedGlyph` — their `ownerOf` always returns `undefined`) never reports true\n * here, regardless of what `node` is. Engine-owned presentation, never content, for the kinds it\n * does cover: it must not enter OT content ops or the editor→USJ conversion.\n *\n * Keyed on the piece's KIND (via {@link $ownerOfRunPiece}) rather than on tree shape, so both the\n * wrapped shape the adaptor builds and the loose shape a mid-edit commit, an undo stack, or a\n * collab-materialized bare owner can leave behind are recognized by the same rule — WHEN the\n * piece is directly adjacent to (or one wrapper-hop from) its owner, which is what each `ownerOf`\n * walk requires. It is therefore NOT a full ancestor check: a wrapped piece separated from its\n * owner by an intervening node, or nested more than one level below its wrapper, reports false\n * here even though it is still presentation — callers that also need that shape covered pair this\n * with an ancestry check (see `editor-delta.adaptor.ts`'s glyph gate).\n */\nexport function $isDisplayRunPiece(node) {\n return $ownerOfRunPiece(node) !== undefined;\n}\n","/**\n * Annotations held ON a display-byte node (a marker glyph, an attribute run's text, a verse, a note\n * caller, a chapter glyph, a read-only glyph decorator). Such a node is never moved into a\n * `TypedMarkNode` or split by one: display runs are found by position and read as single nodes,\n * so the node keeps its place and carries the annotation as state instead.\n */\nimport { createState } from \"lexical\";\nfunction isDisplayAnnotation(value) {\n if (typeof value !== \"object\" || value === null)\n return false;\n const { type, id, start, end, undisplayed } = value;\n return (typeof type === \"string\" &&\n typeof id === \"string\" &&\n Number.isInteger(start) &&\n Number.isInteger(end) &&\n (undisplayed === undefined || typeof undisplayed === \"boolean\"));\n}\nexport const displayAnnotationsState = createState(\"displayAnnotations\", {\n parse: (value) => {\n if (typeof value !== \"object\" || value === null)\n return undefined;\n const { basis, annotations } = value;\n if (typeof basis !== \"string\" || !Array.isArray(annotations))\n return undefined;\n if (!annotations.every(isDisplayAnnotation))\n return undefined;\n return { basis, annotations };\n },\n});\n/**\n * Each byte of `before` matched to its counterpart in `after` (its index there), or `undefined` for a\n * byte `after` no longer has: a longest-common-subsequence alignment, after the common prefix and\n * suffix are matched one to one. Ties go to the earliest match. So a byte typed right beside an\n * identical one may be read as either of the two; nothing else is ambiguous. Carrier texts are short\n * (a glyph, a number, an attribute list), and the trimmed middle is what the quadratic table is\n * built for.\n */\nexport function alignCharacters(before, after) {\n const matched = new Array(before.length).fill(undefined);\n let head = 0;\n while (head < before.length && head < after.length && before[head] === after[head]) {\n matched[head] = head;\n head++;\n }\n let tail = 0;\n while (tail < before.length - head &&\n tail < after.length - head &&\n before[before.length - 1 - tail] === after[after.length - 1 - tail]) {\n matched[before.length - 1 - tail] = after.length - 1 - tail;\n tail++;\n }\n const a = before.slice(head, before.length - tail);\n const b = after.slice(head, after.length - tail);\n // lcs[i][j]: the longest common subsequence of a[i..] and b[j..].\n const lcs = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));\n for (let i = a.length - 1; i >= 0; i--)\n for (let j = b.length - 1; j >= 0; j--)\n lcs[i][j] = a[i] === b[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1]);\n let i = 0;\n let j = 0;\n while (i < a.length && j < b.length) {\n if (a[i] === b[j]) {\n matched[head + i] = head + j;\n i++;\n j++;\n }\n else if (lcs[i + 1][j] >= lcs[i][j + 1])\n i++;\n else\n j++;\n }\n return matched;\n}\n/** `[start, end)` through `alignment` (from {@link alignCharacters}). See {@link mapRangeThroughEdit}. */\nexport function mapRangeThroughAlignment(alignment, start, end) {\n let first;\n let last;\n for (let index = start; index < end; index++) {\n const to = alignment[index];\n if (to === undefined)\n continue;\n first ??= to;\n last = to;\n }\n return first === undefined || last === undefined ? undefined : [first, last + 1];\n}\n/**\n * Where the range `[start, end)` of `before` lands in `after`: from its first byte `after` still has\n * to just past its last. Only matched bytes bound the result. So a byte typed strictly inside the\n * range is inside it, a byte typed at either edge stays outside it (as text typed beside a mark\n * does), and a re-spelling keeps the bytes both spellings share. With no byte left, the range is\n * `undefined` — dropped, never moved onto other bytes.\n */\nexport function mapRangeThroughEdit(before, after, start, end) {\n return mapRangeThroughAlignment(alignCharacters(before, after), start, end);\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/cv/c.html */\nimport { $applyNodeReplacement, DecoratorNode, isHTMLElement, } from \"lexical\";\nimport { CHAPTER_CLASS_NAME } from \"./node-constants.js\";\nimport { getVisibleOpenMarkerText } from \"./markerText.utils.js\";\nexport const IMMUTABLE_CHAPTER_VERSION = 1;\nconst CHAPTER_MARKER = \"c\";\nconst IMMUTABLE_CHAPTER_TAG_NAME = \"span\";\nexport class ImmutableChapterNode extends DecoratorNode {\n __marker;\n __number;\n __showMarker;\n __sid;\n __altnumber;\n __pubnumber;\n __unknownAttributes;\n constructor(chapterNumber = \"\", showMarker = false, sid, altnumber, pubnumber, unknownAttributes, key) {\n super(key);\n this.__marker = CHAPTER_MARKER;\n this.__number = chapterNumber;\n this.__showMarker = showMarker;\n this.__sid = sid;\n this.__altnumber = altnumber;\n this.__pubnumber = pubnumber;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"immutable-chapter\";\n }\n static clone(node) {\n const { __number, __showMarker, __sid, __altnumber, __pubnumber, __unknownAttributes, __key } = node;\n return new ImmutableChapterNode(__number, __showMarker, __sid, __altnumber, __pubnumber, __unknownAttributes, __key);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isImmutableChapterElement(node))\n return null;\n return {\n conversion: $convertImmutableChapterElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createImmutableChapterNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setNumber(serializedNode.number)\n .setShowMarker(serializedNode.showMarker)\n .setSid(serializedNode.sid)\n .setAltnumber(serializedNode.altnumber)\n .setPubnumber(serializedNode.pubnumber)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setNumber(chapterNumber) {\n if (this.__number === chapterNumber)\n return this;\n const self = this.getWritable();\n self.__number = chapterNumber;\n return self;\n }\n getNumber() {\n const self = this.getLatest();\n return self.__number;\n }\n setShowMarker(showMarker = false) {\n if (this.__showMarker === showMarker)\n return this;\n const self = this.getWritable();\n self.__showMarker = showMarker;\n return self;\n }\n getShowMarker() {\n const self = this.getLatest();\n return self.__showMarker;\n }\n setSid(sid) {\n if (this.__sid === sid)\n return this;\n const self = this.getWritable();\n self.__sid = sid;\n return self;\n }\n getSid() {\n const self = this.getLatest();\n return self.__sid;\n }\n setAltnumber(altnumber) {\n if (this.__altnumber === altnumber)\n return this;\n const self = this.getWritable();\n self.__altnumber = altnumber;\n return self;\n }\n getAltnumber() {\n const self = this.getLatest();\n return self.__altnumber;\n }\n setPubnumber(pubnumber) {\n if (this.__pubnumber === pubnumber)\n return this;\n const self = this.getWritable();\n self.__pubnumber = pubnumber;\n return self;\n }\n getPubnumber() {\n const self = this.getLatest();\n return self.__pubnumber;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(IMMUTABLE_CHAPTER_TAG_NAME);\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(CHAPTER_CLASS_NAME, `usfm_${this.__marker}`);\n if (this.__showMarker)\n dom.classList.add(\"marker\");\n dom.setAttribute(\"data-number\", this.__number);\n return dom;\n }\n updateDOM() {\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(CHAPTER_CLASS_NAME, `usfm_${this.getMarker()}`);\n element.setAttribute(\"data-number\", this.getNumber());\n }\n return { element };\n }\n /**\n * VISIBLE bytes with STABLE IDENTITY, which is only safe because of where this node lives.\n *\n * `@lexical/react` paints a decorator payload into the node's element through a portal, and\n * Lexical only rebuilds that portal when the payload CHANGES (`reconcileDecorator` bails on\n * `currentDecorators[key] === decorator`, and equal strings always compare equal). So any node\n * whose element is destroyed and re-created while the node itself survives — which is precisely\n * what re-parenting does, since Lexical builds fresh elements for every child of a newly created\n * parent — keeps a portal bound to the OLD, detached element and renders permanently EMPTY.\n *\n * A chapter escapes that only by POSITION: it is a root-level block, and the marker engine's\n * Tier-2 rebuild re-parents preserved nodes only within paragraph-kind blocks, so nothing ever\n * moves a chapter. That invariant is not enforced anywhere. Moving chapter nodes into any\n * rebuilt/re-created container would blank this glyph on screen while the node, the USJ, and the\n * file all stayed correct — a silent rendering loss with no error. If that day comes, render\n * these bytes from `createDOM` instead, the way `ImmutableTypedTextNode` does.\n */\n decorate() {\n return this.getRenderedText();\n }\n /** The text this chapter shows on screen: its whole `\\c N` glyph, or only its number. */\n getRenderedText() {\n return this.getShowMarker()\n ? getVisibleOpenMarkerText(this.getMarker(), this.getNumber())\n : this.getNumber();\n }\n exportJSON() {\n return {\n type: this.getType(),\n marker: this.getMarker(),\n number: this.getNumber(),\n showMarker: this.getShowMarker(),\n sid: this.getSid(),\n altnumber: this.getAltnumber(),\n pubnumber: this.getPubnumber(),\n unknownAttributes: this.getUnknownAttributes(),\n version: IMMUTABLE_CHAPTER_VERSION,\n };\n }\n // Mutation\n isInline() {\n return false;\n }\n isKeyboardSelectable() {\n return false;\n }\n}\nfunction $convertImmutableChapterElement(element) {\n const chapterNumber = element.getAttribute(\"data-number\") ?? \"0\";\n const node = $createImmutableChapterNode(chapterNumber);\n return { node };\n}\nexport function $createImmutableChapterNode(chapterNumber, showMarker, sid, altnumber, pubnumber, unknownAttributes) {\n return $applyNodeReplacement(new ImmutableChapterNode(chapterNumber, showMarker, sid, altnumber, pubnumber, unknownAttributes));\n}\nexport function isImmutableChapterElement(element) {\n if (!element)\n return false;\n return (element.classList.contains(CHAPTER_CLASS_NAME) &&\n element.tagName.toLowerCase() === IMMUTABLE_CHAPTER_TAG_NAME);\n}\nexport function $isImmutableChapterNode(node) {\n return node instanceof ImmutableChapterNode;\n}\nexport function isSerializedImmutableChapterNode(node) {\n return node?.type === ImmutableChapterNode.getType();\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/doc/id.html */\nimport { isValidBookCode } from \"@eten-tech-foundation/scripture-utilities\";\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\nexport const BOOK_MARKER = \"id\";\nexport const BOOK_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const BOOK_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"code\",\n \"content\",\n];\nexport class BookNode extends ElementNode {\n __marker = BOOK_MARKER;\n __code;\n __unknownAttributes;\n constructor(code = \"\", unknownAttributes, key) {\n super(key);\n this.__code = code;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"book\";\n }\n static clone(node) {\n const { __code, __unknownAttributes, __key } = node;\n return new BookNode(__code, __unknownAttributes, __key);\n }\n static importJSON(serializedNode) {\n const { code } = serializedNode;\n return $createBookNode(code).updateFromJSON(serializedNode);\n }\n static isValidBookCode(code) {\n return isValidBookCode(code);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setCode(serializedNode.code)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setCode(code) {\n if (this.__code === code)\n return this;\n const self = this.getWritable();\n self.__code = code;\n return self;\n }\n /**\n * Get the book code (ID).\n * @returns the book code (ID).\n */\n getCode() {\n const self = this.getLatest();\n return self.__code;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n // The `.book` class is targeted by platform gutter-positioning rules in usj-nodes.css\n // alongside `.para` (paragraph-like layout). Changes here that affect the first-child marker\n // node, the data-code attribute, or the element tag may require corresponding CSS updates.\n const dom = document.createElement(\"p\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(this.__type, `usfm_${this.__marker}`);\n dom.setAttribute(\"data-code\", this.__code);\n return dom;\n }\n updateDOM() {\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n code: this.getCode(),\n unknownAttributes: this.getUnknownAttributes(),\n version: BOOK_VERSION,\n };\n }\n}\nexport function $createBookNode(code, unknownAttributes) {\n return $applyNodeReplacement(new BookNode(code, unknownAttributes));\n}\nexport function $isBookNode(node) {\n return node instanceof BookNode;\n}\nexport function isSerializedBookNode(node) {\n return node?.type === BookNode.getType();\n}\n","/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/para/index.html */\nimport { PARA_MARKER_DEFAULT } from \"./node-constants.js\";\nimport { $applyNodeReplacement, ParagraphNode, isHTMLElement, } from \"lexical\";\n/** @see https://docs.usfm.bible/usfm/3.1/para/index.html */\nconst VALID_PARA_MARKERS = [\n // Identification\n \"ide\",\n \"sts\",\n \"rem\",\n \"h\",\n \"toc1\",\n \"toc2\",\n \"toc3\",\n \"toca1\",\n \"toca2\",\n \"toca3\",\n // Introductions\n \"imt\",\n \"imt1\",\n \"imt2\",\n \"imt3\",\n \"imt4\",\n \"is\",\n \"is1\",\n \"is2\",\n \"ip\",\n \"ipi\",\n \"im\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"ib\",\n \"iot\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"iex\",\n \"imte\",\n \"imte1\",\n \"imte2\",\n \"ie\",\n // Titles and Headings\n \"mt\",\n \"mt1\",\n \"mt2\",\n \"mt3\",\n \"mt4\",\n \"mte\",\n \"mte1\",\n \"mte2\",\n \"cl\",\n \"cd\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"ms3\",\n \"mr\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"sr\",\n \"r\",\n \"d\",\n \"sp\",\n \"sd\",\n \"sd1\",\n \"sd2\",\n \"sd3\",\n \"sd4\",\n // Body Paragraphs\n PARA_MARKER_DEFAULT,\n \"m\",\n \"po\",\n \"cls\",\n \"pr\",\n \"pc\",\n \"pm\",\n \"pmo\",\n \"pmc\",\n \"pmr\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"mi\",\n \"lit\",\n \"nb\",\n \"ph\", // Deprecated marker.\n \"ph1\", // Deprecated marker.\n \"ph2\", // Deprecated marker.\n \"ph3\", // Deprecated marker.\n // Poetry\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qr\",\n \"qc\",\n \"qa\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"qd\",\n \"b\",\n // Lists\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n // Breaks - see https://docs.usfm.bible/usfm/3.1/char/breaks/pb.html\n \"pb\",\n];\nexport const PARA_VERSION = 1;\n/** List of known properties of `MarkerObject` */\nexport const PARA_MARKER_OBJECT_PROPS = [\"type\", \"marker\", \"content\"];\nexport class ParaNode extends ParagraphNode {\n __marker;\n __unknownAttributes;\n constructor(marker = PARA_MARKER_DEFAULT, unknownAttributes, key) {\n super(key);\n this.__marker = marker;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return \"para\";\n }\n static clone(node) {\n const { __marker, __unknownAttributes, __key } = node;\n return new ParaNode(__marker, __unknownAttributes, __key);\n }\n static isValidMarker(marker, extraValidMarkers) {\n return (marker !== undefined &&\n (VALID_PARA_MARKERS.includes(marker) ||\n (extraValidMarkers?.includes(marker) ?? false)));\n }\n static importDOM() {\n return {\n p: () => ({\n conversion: $convertParaElement,\n priority: 1,\n }),\n };\n }\n static importJSON(serializedNode) {\n return $createParaNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n // Define the DOM element here\n const dom = document.createElement(\"p\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(this.__type, `usfm_${this.__marker}`);\n return dom;\n }\n updateDOM(prevNode, dom, config) {\n const recreate = super.updateDOM(prevNode, dom, config);\n if (!recreate && prevNode.__marker !== this.__marker) {\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.remove(`usfm_${prevNode.__marker}`);\n dom.classList.add(`usfm_${this.__marker}`);\n }\n return recreate;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(this.getType(), `usfm_${this.getMarker()}`);\n }\n return { element };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n unknownAttributes: this.getUnknownAttributes(),\n version: PARA_VERSION,\n };\n }\n // Mutation\n insertNewAfter(rangeSelection, restoreSelection) {\n const newElement = $createParaNode(this.getMarker());\n newElement.setTextFormat(rangeSelection.format);\n newElement.setTextStyle(rangeSelection.style);\n newElement.setDirection(this.getDirection());\n newElement.setFormat(this.getFormatType());\n newElement.setStyle(this.getTextStyle());\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n}\nfunction $convertParaElement(element) {\n const marker = element.getAttribute(\"data-marker\") ?? undefined;\n const node = $createParaNode(marker);\n if (element.style) {\n node.setFormat(element.style.textAlign);\n const indent = parseInt(element.style.textIndent, 10) / 20;\n if (indent > 0) {\n node.setIndent(indent);\n }\n }\n return { node };\n}\nexport function $createParaNode(marker, unknownAttributes) {\n return $applyNodeReplacement(new ParaNode(marker, unknownAttributes));\n}\nexport function $isParaNode(node) {\n return node instanceof ParaNode;\n}\nexport function isSerializedParaNode(node) {\n return node?.type === ParaNode.getType();\n}\n","/**\n * Standard view's space-run collapse, as it applies to a text node's DISPLAY text. Standard view\n * shows each space of a run of two or more as NBSP, so the run stays visible while typing, and\n * serialization collapses the run back to one space. A data NBSP displays as `~`, so an NBSP in\n * display text is always a space, and `~` never belongs to a run.\n *\n * Serialization and the logical position model both read the collapse from here, so what\n * `getUsj()` emits and the offsets the model reports cannot disagree about which characters a\n * run loses. Callers pass the text AFTER removing a char span's structural separator prefix,\n * which serialization strips before collapsing.\n */\n/** Two or more consecutive display spaces: plain spaces or NBSPs. */\nconst SPACE_RUN = /[ \\u00A0]{2,}/g;\n/** The display spaces a text starts with: plain spaces or NBSPs. */\nconst LEADING_SPACES = /^[ \\u00A0]*/;\n/**\n * Finds the characters the collapse drops: every character of a run after its first.\n *\n * @param displayText - A text node's display text, without a char span's separator prefix.\n * @returns The dropped characters as ascending, non-overlapping `[start, end)` ranges.\n */\nexport function collapsedSpaceRunRanges(displayText) {\n return [...displayText.matchAll(SPACE_RUN)].map((run) => [\n run.index + 1,\n run.index + run[0].length,\n ]);\n}\n/**\n * Collapses each run to its first character. Display NBSPs survive as NBSP; the display→data\n * inversion that follows in serialization turns them back into spaces.\n *\n * @param displayText - A text node's display text, without a char span's separator prefix.\n * @returns The display text with every run collapsed.\n */\nexport function collapseSpaceRuns(displayText) {\n return displayText.replace(SPACE_RUN, (run) => run[0]);\n}\n/**\n * Counts the display spaces `displayText` starts with. Serialization drops them where they follow\n * a marker's separator — at the start of a paragraph's content, and after a verse marker: Paratext\n * 9 skips all whitespace after such a marker, so they are not content (`\\p text` saves as\n * `\\p text`). A displayed data NBSP is `~`, so it is never counted.\n *\n * @param displayText - A text node's display text.\n * @returns How many of its first characters are display spaces.\n */\nexport function leadingDisplaySpaceLength(displayText) {\n return LEADING_SPACES.exec(displayText)?.[0].length ?? 0;\n}\n","export const ZERO_WIDTH_SPACE = \"\\u200B\";\nexport const CARET = \"\\u2038\";\nexport const CURSOR_PLACEHOLDER_CHAR = ZERO_WIDTH_SPACE;\nexport var CursorMovementDirection;\n(function (CursorMovementDirection) {\n CursorMovementDirection[\"LEFT\"] = \"left\";\n CursorMovementDirection[\"RIGHT\"] = \"right\";\n})(CursorMovementDirection || (CursorMovementDirection = {}));\nexport var CharSelectionOffset;\n(function (CharSelectionOffset) {\n CharSelectionOffset[CharSelectionOffset[\"BEFORE\"] = 0] = \"BEFORE\";\n CharSelectionOffset[CharSelectionOffset[\"AFTER\"] = 1] = \"AFTER\";\n})(CharSelectionOffset || (CharSelectionOffset = {}));\n","import { $createTextNode, $isElementNode, $isRootNode, $isTextNode, } from \"lexical\";\nimport { CURSOR_PLACEHOLDER_CHAR } from \"./constants.js\";\nimport { CursorPosition } from \"./CursorSelectionContext.js\";\nexport function $createCursorPlaceholderNode() {\n return $createTextNode(CURSOR_PLACEHOLDER_CHAR);\n}\nexport function $insertCursorPlaceholder(node, position, restoreSelection = false) {\n const cursorPlaceholderNode = $createCursorPlaceholderNode();\n if (position === CursorPosition.Start)\n node.insertBefore(cursorPlaceholderNode, restoreSelection);\n else\n node.insertAfter(cursorPlaceholderNode, restoreSelection);\n return cursorPlaceholderNode;\n}\nexport function $removeCursorPlaceholder(node) {\n const textContent = node.getTextContent();\n node.setTextContent(textContent.replaceAll(CURSOR_PLACEHOLDER_CHAR, \"\"));\n}\n/**\n * Whether `text` is non-empty and made up entirely of placeholder characters. This is a content-only\n * test: the placeholder is a zero-width space, which is also authored text (a Thai/Khmer/Lao line\n * break), so it cannot tell a transient caret host from an authored zero-width-space-only run.\n * Never use it to decide what to leave out of saved, sent or indexed content — that would drop the\n * authored run. Identify a host by its mark instead: `$isCaretHost` for a live node,\n * `isSerializedCaretHost` for a serialized one (both in `nodes/usj/transientCaretHost.utils`).\n *\n * It is right only where treating an authored zero-width space as a host loses nothing: choosing\n * where the caret rests, such as reusing an existing node at a boundary instead of stacking a new\n * host there.\n *\n * @param text - The text content to test.\n * @returns `true` when `text` is non-empty and every character is a cursor placeholder.\n */\nexport function isCursorPlaceholderOnly(text) {\n // Fast path: the common case (no placeholder at all) short-circuits before any allocation, so\n // this stays cheap when called per text node.\n return (text.length > 0 &&\n text.includes(CURSOR_PLACEHOLDER_CHAR) &&\n text.replaceAll(CURSOR_PLACEHOLDER_CHAR, \"\") === \"\");\n}\n/**\n * Whether `node` is a text node holding only cursor placeholder(s) — see {@link isCursorPlaceholderOnly}.\n *\n * @param node - The node to test; may be `null`/`undefined`.\n * @returns `true` when `node` is a `TextNode` whose content is entirely cursor placeholders.\n */\nexport function $isCursorPlaceholderOnlyText(node) {\n return $isTextNode(node) && isCursorPlaceholderOnly(node.getTextContent());\n}\nexport function $getValidAncestor(node, cursor, canHavePlaceholder) {\n const ancestor = node.getParent();\n if (!ancestor || !$isElementNode(ancestor) || !ancestor.isInline()) {\n return { ancestor: null, ancestorSibling: null };\n }\n const ancestorParent = ancestor.getParent();\n if (!ancestorParent || $isRootNode(ancestorParent)) {\n return { ancestor: null, ancestorSibling: null };\n }\n const parentCanHavePlaceholder = canHavePlaceholder(ancestorParent);\n const canHavePlaceholderAsSibling = cursor.isMovingRight\n ? ancestor.canInsertTextAfter()\n : ancestor.canInsertTextBefore();\n const canInsert = parentCanHavePlaceholder && canHavePlaceholderAsSibling;\n const ancestorSibling = cursor.isMovingRight\n ? ancestor.getNextSibling()\n : ancestor.getPreviousSibling();\n if (!ancestorSibling && !canInsert) {\n return $getValidAncestor(ancestor, cursor, canHavePlaceholder);\n }\n if ($isTextNode(ancestorSibling) && !canInsert) {\n return { ancestor: null, ancestorSibling: null };\n }\n return { ancestor, ancestorSibling };\n}\nexport function $findDescendantEligibleForPlaceholder(node, cursor, canHavePlaceholder) {\n if (canHavePlaceholder(node)) {\n return node;\n }\n if ($isElementNode(node)) {\n const child = cursor.isMovingRight ? node.getFirstChild() : node.getLastChild();\n if (child) {\n return $findDescendantEligibleForPlaceholder(child, cursor, canHavePlaceholder);\n }\n }\n return null;\n}\n","/**\n * What a transient caret host IS, as editor state: the identity every consumer that must leave a\n * host out — the USJ serializer, the collab ops stream and its positions, annotation content\n * indexes — reads, rather than recognizing a host by its text. The host's lifecycle (when one is\n * created, moved into, and removed) lives with the guards that need one, in shared-react's\n * `transientCaretHost.ts`.\n *\n * A host is a single zero-width space, and so is authored text: ZWSP marks line-break\n * opportunities in Thai, Khmer and Lao, and a run of it lands in a text node of its own wherever\n * the text around it is split. Content alone cannot tell the two apart, so a host is recognized\n * only by its mark.\n */\nimport { CURSOR_PLACEHOLDER_CHAR } from \"../../plugins/CursorHandler/core/utils/constants.js\";\nimport { $createCursorPlaceholderNode } from \"../../plugins/CursorHandler/core/utils/index.js\";\nimport { $getState, $isTextNode, $setState, createState, NODE_STATE_KEY, } from \"lexical\";\n/**\n * Marks a text node as a caret host from the moment it is created until text lands in it. It is\n * what recognizes a host from the node itself — after an undo brings one back, in every guard\n * instance at once, and in a serialized editor state — rather than by the key one guard instance\n * happens to track. Lexical merges adjacent simple text nodes only when their node states are\n * equivalent, and an unmarked node reads the mark as its default (`false`), so the mark also keeps\n * Lexical from folding text pasted beside the caret into the host — on either side of it. (Its\n * merge check's `__state === null` shortcut never fires for a stateless node, whose `__state` is\n * `undefined`; `transientCaretHost.utils.test.ts` pins both directions.)\n */\nexport const caretHostState = createState(\"isCaretHost\", {\n parse: (value) => value === true,\n});\n/**\n * A new caret host: a single placeholder character, marked as a host.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $createCaretHostNode() {\n return $setState($createCursorPlaceholderNode(), caretHostState, true);\n}\n/**\n * Whether `node` is a caret host nothing has landed in yet: a marked text node holding exactly its\n * own placeholder. A second zero-width space is one the user typed, which makes it content.\n *\n * Read-only: safe in any read.\n */\nexport function $isCaretHost(node) {\n return ($isTextNode(node) &&\n $getState(node, caretHostState) &&\n node.getTextContent() === CURSOR_PLACEHOLDER_CHAR);\n}\n/**\n * Whether `node` carries the caret-host mark — a bare host, or one text has landed in that this\n * update's transforms have not yet turned into content. A transform that must leave a host alone\n * (`TextSpacingPlugin`'s) asks this rather than {@link $isCaretHost}, so its answer does not\n * depend on whether the host's own transform ran first.\n *\n * Read-only: safe in any read.\n */\nexport function $hasCaretHostMark(node) {\n return $isTextNode(node) && $getState(node, caretHostState);\n}\n/**\n * The serialized twin of {@link $isCaretHost}, for consumers that walk `editorState.toJSON()`.\n *\n * @param node - A serialized text node.\n * @returns `true` when `node` is a bare caret host.\n */\nexport function isSerializedCaretHost(node) {\n return (node[NODE_STATE_KEY]?.[caretHostState.key] === true && node.text === CURSOR_PLACEHOLDER_CHAR);\n}\n","/** Utility functions for editor nodes */\nimport { MARKER_OBJECT_PROPS } from \"@eten-tech-foundation/scripture-utilities\";\nimport { $findMatchingParent } from \"@lexical/utils\";\nimport { $createNodeSelection, $createTextNode, $getCommonAncestor, $getEditor, $getSelection, $getState, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isTextNode, $setSelection, $setState, NODE_STATE_KEY, TextNode, } from \"lexical\";\nimport { charIdState, MARKER_TRAILING_SPACE_TEXT_TYPE, textTypeState, } from \"../collab/delta.state.js\";\nimport { $isGutterMarkerNode, $isImmutableTypedTextNode, isSerializedImmutableTypedTextNode, } from \"../features/ImmutableTypedTextNode.js\";\nimport { $isMarkerNode, isSerializedMarkerNode } from \"../features/MarkerNode.js\";\nimport { $isTypedMarkNode } from \"../features/TypedMarkNode.js\";\nimport { $isUnknownNode } from \"../features/UnknownNode.js\";\nimport { $isAttributeRunNode } from \"./AttributeRunNode.js\";\nimport { $isBookNode } from \"./BookNode.js\";\nimport { $isChapterNode, isSerializedChapterNode, } from \"./ChapterNode.js\";\nimport { $isCharNode, CharNode, isSerializedCharNode } from \"./CharNode.js\";\nimport { $isImmutableChapterNode, isSerializedImmutableChapterNode, } from \"./ImmutableChapterNode.js\";\nimport { $isImpliedParaNode, isSerializedImpliedParaNode, } from \"./ImpliedParaNode.js\";\nimport { $isMilestoneNode } from \"./MilestoneNode.js\";\nimport { $isNoteNode } from \"./NoteNode.js\";\nimport { $isParaNode, isSerializedParaNode } from \"./ParaNode.js\";\nimport { $isVerseNode } from \"./VerseNode.js\";\nimport { $noteEditableCallerNode } from \"./attributeDisplay.utils.js\";\nimport { $charSeparatorPrefixLength } from \"./markerSeparators.utils.js\";\nimport { $getLogicalParent, $isContentTransparent, $isSplicedImpliedPara, } from \"./logicalParent.utils.js\";\nimport { closingMarkerText, openingMarkerText, typedCallerRange } from \"./markerText.utils.js\";\nimport { collapsedSpaceRunRanges, leadingDisplaySpaceLength } from \"./spaceRuns.utils.js\";\nimport { EMPTY_CHAR_PLACEHOLDER_TEXT, IMMUTABLE_NOTE_CALLER_NODE_TYPE, NBSP, } from \"./node-constants.js\";\nimport { $isCaretHost } from \"./transientCaretHost.utils.js\";\nexport { $getLogicalParent } from \"./logicalParent.utils.js\";\nexport { closingMarkerText, getEditableCallerText, getVisibleOpenMarkerText, openingMarkerText, typedCallerBytes, typedCallerRange, } from \"./markerText.utils.js\";\n/** RegEx to test for a string only containing digits. */\nconst ONLY_DIGITS_TEST = /^\\d+$/;\n/**\n * Check if the marker is valid and numbered.\n * @param marker - Marker to check.\n * @param numberedMarkers - List of valid numbered markers ('#' removed).\n * @returns true if the marker is a valid numbered marker, false otherwise.\n */\nexport function isValidNumberedMarker(marker, numberedMarkers) {\n if (!marker)\n return false;\n // Starts with a valid numbered marker.\n const numberedMarker = numberedMarkers.find((markerNumbered) => marker.startsWith(markerNumbered));\n if (!numberedMarker)\n return false;\n // Ends with a number.\n const maybeNumber = marker.slice(numberedMarker.length);\n return ONLY_DIGITS_TEST.test(maybeNumber);\n}\n/**\n * Checks if the given node is a SerializedChapterNode or SerializedImmutableChapterNode.\n * @param node - The serialized node to check.\n * @returns `true` if the node is a SerializedChapterNode or SerializedImmutableChapterNode, `false` otherwise.\n */\nexport function isSomeSerializedChapterNode(node) {\n return isSerializedChapterNode(node) || isSerializedImmutableChapterNode(node);\n}\n/**\n * Checks if the given node is a ChapterNode or ImmutableChapterNode.\n * @param node - The node to check.\n * @returns `true` if the node is a ChapterNode or ImmutableChapterNode, `false` otherwise.\n */\nexport function $isSomeChapterNode(node) {\n return $isChapterNode(node) || $isImmutableChapterNode(node);\n}\n/**\n * Finds the chapter node with the given chapter number amongst the nodes.\n * @param nodes - Nodes to look in.\n * @param chapterNum - Chapter number to look for.\n * @returns the chapter node if found, `undefined` otherwise.\n */\nexport function $findChapter(nodes, chapterNum) {\n return nodes.find((node) => $isSomeChapterNode(node) && node.getNumber() === chapterNum.toString());\n}\n/**\n * Finds the next chapter.\n * @param nodes - Nodes to look in.\n * @param isCurrentChapterAtFirstNode - If `true` ignore the first node.\n * @returns the next chapter node if found, `undefined` otherwise.\n */\nexport function $findNextChapter(nodes, isCurrentChapterAtFirstNode = false) {\n return nodes.find((node, index) => (!isCurrentChapterAtFirstNode || index > 0) && $isSomeChapterNode(node));\n}\n/**\n * Finds the nearest previous node by checking the node's previous sibling, then walking up\n * through ancestors and checking their previous siblings. Stops at root.\n * @param node - Node to start from.\n * @returns the nearest previous node, or `undefined` if none exists.\n */\nexport function $findNearestPreviousNode(node) {\n let current = node;\n while (current && current.getParent() !== null) {\n const prev = current.getPreviousSibling();\n if (prev)\n return prev;\n current = current.getParent();\n }\n return undefined;\n}\n/**\n * Find the chapter that this node is in.\n * @param node - Node to find the chapter it's in.\n * @returns the chapter node if found, `undefined` otherwise.\n */\nexport function $findThisChapter(node) {\n if (!node)\n return undefined;\n // is this node a chapter\n if ($isSomeChapterNode(node))\n return node;\n // is the chapter a previous top level sibling\n let previousSibling = node.getTopLevelElement()?.getPreviousSibling();\n while (previousSibling && !$isSomeChapterNode(previousSibling)) {\n previousSibling = previousSibling.getPreviousSibling();\n }\n if (previousSibling && $isSomeChapterNode(previousSibling))\n return previousSibling;\n return undefined;\n}\n/**\n * Traverses up the node tree from startNode (itself included) to find the first ancestor NoteNode.\n * A named convenience over `$findMatchingParent` — the one shared ancestor-walk.\n * @param startNode - The node to start the upward search from.\n * @returns The first ancestor NoteNode found, or `undefined` if none exists before the root.\n */\nexport function $findFirstAncestorNoteNode(startNode) {\n return $findMatchingParent(startNode, $isNoteNode) ?? undefined;\n}\n/**\n * Checks if the node has a `getMarker` method. Excludes React nodes - consider using\n * `$isReactNodeWithMarker` instead.\n * @param node - LexicalNode to check.\n * @returns `true` if the node has a `getMarker` method, `false` otherwise.\n */\nexport function $isNodeWithMarker(node) {\n return ($isBookNode(node) ||\n $isChapterNode(node) ||\n $isCharNode(node) ||\n $isImmutableChapterNode(node) ||\n $isImpliedParaNode(node) ||\n $isMilestoneNode(node) ||\n $isParaNode(node) ||\n $isNoteNode(node) ||\n $isVerseNode(node) ||\n $isUnknownNode(node)\n // ImmutableUnmatchedNode & MarkerNode also have the `getMarker` method but they left out for\n // now until we know we need them.\n );\n}\n/**\n * Get the next node in the document tree.\n * @param selection - The current selection to get the next node from.\n * @returns The next node or null if there is no next node.\n */\nexport function $getNextNode(selection) {\n if (selection.anchor.type === \"element\") {\n const anchorNode = selection.anchor.getNode();\n const offset = selection.anchor.offset;\n if (offset < anchorNode.getChildrenSize())\n return anchorNode.getChildAtIndex(offset);\n }\n const anchorNode = selection.anchor.getNode();\n return anchorNode.getNextSibling() ?? anchorNode.getParent()?.getNextSibling() ?? null;\n}\n/**\n * Get the previous node in the document tree.\n * @param selection - The current selection to get the previous node from.\n * @returns The previous node or null if there is no previous node.\n */\nexport function $getPreviousNode(selection) {\n const offset = selection.anchor.offset;\n if (selection.anchor.type === \"element\" && offset > 0) {\n const anchorNode = selection.anchor.getNode();\n return anchorNode.getChildAtIndex(offset - 1);\n }\n const anchorNode = selection.anchor.getNode();\n return anchorNode.getPreviousSibling() ?? anchorNode.getParent()?.getPreviousSibling() ?? null;\n}\n/**\n * Type guard to check if a node is para-like. Para-like nodes have an OT length of 1 that is\n * counted on its close (rather than its open).\n */\nexport function $isParaLikeNode(node) {\n return $isSomeParaNode(node) || $isBookNode(node);\n}\n/**\n * Checks if the given node is a ParaNode or ImpliedParaNode.\n * @param node - The node to check.\n * @returns `true` if the node is a ParaNode or ImpliedParaNode, `false` otherwise.\n */\nexport function $isSomeParaNode(node) {\n return $isParaNode(node) || $isImpliedParaNode(node);\n}\n/**\n * Checks if the given serialized node is a SerializedParaNode or SerializedImpliedParaNode.\n * @param node - The serialized node to check.\n * @returns `true` if the node is a SerializedParaNode or SerializedImpliedParaNode, `false`\n * otherwise.\n */\nexport function isSomeSerializedParaNode(node) {\n return isSerializedParaNode(node) || isSerializedImpliedParaNode(node);\n}\n/**\n * Check if a node is a descendant of a potential ancestor node.\n *\n * Deliberately NOT delegated to `$findMatchingParent`: this walk excludes the starting node (a\n * node is not its own descendant) and must be able to match the RootNode's key, which\n * `$findMatchingParent` never tests.\n *\n * @param node - The node to check.\n * @param ancestorKey - The key of the potential ancestor node.\n * @returns `true` if the node is a descendant of the ancestor, `false` otherwise.\n */\nexport function $isDescendantOf(node, ancestorKey) {\n let parent = node.getParent();\n while (parent) {\n if (parent.getKey() === ancestorKey)\n return true;\n parent = parent.getParent();\n }\n return false;\n}\n/**\n * Check if the given char attributes are the same as the ones in the CharNode.\n * @param charAttributes - The char attributes to compare.\n * @param charNode - The character node to compare against.\n * @returns `true` if the attributes are the same, `false` otherwise.\n */\nexport function $hasSameCharAttributes(charAttributes, charNode) {\n const charNodeCid = $getState(charNode, charIdState);\n const bothHaveCid = !!(charAttributes.cid && charNodeCid);\n const bothHaveNoCid = !charAttributes.cid && !charNodeCid;\n return (charAttributes.style === charNode.getMarker() &&\n (bothHaveNoCid || (bothHaveCid && charAttributes.cid === charNodeCid)));\n}\n/**\n * Find a common ancestor of a and b and return the common ancestor,\n * or undefined if there is no common ancestor between the two nodes.\n *\n * This function is compatible with the deprecated `LexicalNode.getCommonAncestor` function but\n * uses the new (as of Lexical v0.26.0) NodeCaret APIs.\n *\n * @param a A LexicalNode\n * @param b A LexicalNode\n * @returns The common ancestor between the two nodes or undefined if they have no common ancestor\n */\nexport function $getCommonAncestorCompatible(a, b) {\n const a1 = $isElementNode(a) ? a : a.getParent();\n const b1 = $isElementNode(b) ? b : b.getParent();\n const result = a1 && b1 ? $getCommonAncestor(a1, b1) : undefined;\n return result ? result.commonAncestor : undefined;\n}\n/**\n * Moves the selection to the end of the current range, accounting for backward selections.\n * @param selection - The range selection to move to the end.\n */\nexport function $moveSelectionToEnd(selection) {\n const startEndPoints = selection.getStartEndPoints();\n if (!startEndPoints)\n return undefined;\n const [start, end] = startEndPoints;\n const actualEnd = selection.isBackward() ? start : end;\n selection.focus.set(actualEnd.key, actualEnd.offset, actualEnd.type);\n selection.anchor.set(actualEnd.key, actualEnd.offset, actualEnd.type);\n}\n/**\n * Checks if the given node is a SerializedTextNode.\n * @param node - The node to check.\n * @returns `true` if the node is a SerializedTextNode, `false` otherwise.\n */\nexport function isSerializedTextNode(node) {\n return node?.type === TextNode.getType();\n}\n/**\n * Remove the given node and all the nodes after.\n * @param nodes - Nodes to prune.\n * @param pruneNode - Node to prune and all nodes after.\n */\nexport function removeNodeAndAfter(nodes, pruneNode) {\n if (!pruneNode)\n return;\n const pruneNodeIndex = nodes.findIndex((node) => node === pruneNode);\n // prune node and after\n if (pruneNodeIndex)\n nodes.length = pruneNodeIndex;\n}\n/**\n * Removes all the nodes that proceed the given node.\n * @param nodes - Nodes to prune.\n * @param firstNode - Node to prune before.\n * @returns the nodes from the node and after.\n */\nexport function removeNodesBeforeNode(nodes, firstNode) {\n if (!firstNode)\n return nodes;\n const firstNodeIndex = firstNode.getIndexWithinParent();\n return nodes.splice(firstNodeIndex + 1, nodes.length - firstNodeIndex - 1);\n}\n/**\n * Parse number from marker text.\n * @param marker - Chapter or verse marker.\n * @param text - Text to parse.\n * @param number - Default number to use if none is found.\n * @returns the parsed number or the default value as a string.\n */\nexport function parseNumberFromMarkerText(marker, text, number) {\n const openMarkerText = openingMarkerText(marker);\n if (text?.startsWith(openMarkerText)) {\n // Skip the NBSP/space separator inserted by `getVisibleOpenMarkerText`.\n const rest = text.slice(openMarkerText.length).replace(/^[\\s ]+/, \"\");\n // The number is the whole WORD, valid or not — the same scan Paratext 9's GetNextWord applies\n // and the same one Tier 1 uses to keep the glyph and the node in step\n // (`leadingAttributeGlyphRegexes`). Anything narrower drops displayed bytes on the way to the\n // file: a bridge the user is still typing (`5-`), a typo (`5--`, `5*`), a half-typed segment\n // (`5-Da`) are all on screen and in the node's own number, so a grammar that recognized only\n // well-formed numbers would save something the editor is not showing.\n //\n // The word still ends where the leading-attribute rule says it does, which is what keeps this\n // from swallowing content: whitespace ends it (`\\v 7 5` is verse 7 plus body text `5`) and so\n // does a backslash (`\\v 2\\ Da` is verse 2 plus the literal), because both are the tokenizer's\n // own name-scan terminators.\n const match = /^([^ \\u00A0\\\\]+)/.exec(rest);\n if (match)\n number = match[1];\n }\n return number;\n}\n/** The `textType` NodeState of a serialized node, if any — the serialize-only mirror of the live\n * `$getState(node, textTypeState)`. */\nfunction serializedTextType(node) {\n const state = node[NODE_STATE_KEY];\n if (state && typeof state === \"object\" && \"textType\" in state) {\n const textType = state.textType;\n if (typeof textType === \"string\")\n return textType;\n }\n return undefined;\n}\n/**\n * Recursively extracts text content from a serialized Lexical node and its descendants.\n * Excludes marker nodes (both MarkerNode and ImmutableTypedTextNode with type \"marker\").\n * @param node - The serialized node to process.\n * @returns The concatenated text content.\n */\n// Keep this function in sync with `$getTextContentExcludingMarkers`. The two are deliberately\n// parallel rather than merged: this one walks SERIALIZED nodes (plain objects, `children` arrays),\n// the other walks LIVE nodes (Lexical accessors inside a read) — a shared core would need a\n// node-accessor abstraction that costs more than the ~20 duplicated lines it would save.\nfunction extractTextFromNode(node) {\n // Skip marker nodes - they're structural/formatting elements, not content\n if (isSerializedSynthesizedMarkerNode(node))\n return \"\";\n // The attribute display run (textType \"attribute\") is engine-owned presentation, not content —\n // exclude its bytes (`|gloss`) from note-preview text.\n if (isSerializedTextNode(node) && serializedTextType(node) === \"attribute\")\n return \"\";\n if (isSerializedTextNode(node) && node.text !== NBSP)\n return node.text;\n if (isSerializedCharNode(node)) {\n // If it's an ElementNode, process its children recursively and join their text\n // We join with '' here because spacing is usually handled by spaces within TextNodes\n // or potentially by joining results from the top-level nodes with spaces later.\n return node.children.map((child) => extractTextFromNode(child)).join(\"\");\n }\n // Ignore other node types (e.g., LineBreakNode, custom nodes without text/children)\n return \"\";\n}\n/**\n * Gets the preview text from an array of serialized Lexical nodes,\n * handling nested elements like the modified CharNode.\n * @param childNodes - Child nodes (e.g., from a NoteNode or ParagraphNode).\n * @returns The preview text.\n */\nexport function getPreviewTextFromSerializedNodes(childNodes) {\n const previewText = childNodes\n .map((node) => extractTextFromNode(node))\n .filter((text) => text.length > 0)\n .join(\" \")\n .trim();\n return previewText;\n}\n/**\n * Gets the preview text for a note caller.\n * Excludes marker nodes from the text content.\n * @param childNodes - Child nodes of the NoteNode.\n * @returns the preview text.\n */\nexport function $getNoteCallerPreviewText(childNodes) {\n const parts = [];\n for (const node of childNodes) {\n if (!$isCharNode(node))\n continue;\n const textContent = $getTextContentExcludingMarkers(node);\n if (textContent === EMPTY_CHAR_PLACEHOLDER_TEXT)\n continue;\n if (textContent.length > 0)\n parts.push(textContent);\n }\n return parts.join(\" \").trim();\n}\n/**\n * Recursively gets text content from a node, excluding marker nodes.\n * @param node - The node to extract text from.\n * @returns The text content without markers.\n */\n// Keep this function in sync with `extractTextFromNode`.\nfunction $getTextContentExcludingMarkers(node) {\n // Skip marker nodes\n if ($isMarkerNode(node))\n return \"\";\n if ($isVisibleMarkerNode(node))\n return \"\";\n // The attribute display run (textType \"attribute\") is engine-owned presentation, not content.\n if ($isTextNode(node) && $getState(node, textTypeState) === \"attribute\")\n return \"\";\n // For text nodes, return the text\n if ($isTextNode(node))\n return node.getTextContent();\n // For element nodes, recursively process children\n if ($isElementNode(node)) {\n return node\n .getChildren()\n .map((child) => $getTextContentExcludingMarkers(child))\n .join(\"\");\n }\n return \"\";\n}\n/**\n * Checks whether a node is a visible marker node.\n *\n * Visible marker nodes are immutable typed text nodes whose text type is \"marker\".\n *\n * @param node - The node to check.\n * @returns `true` if the node is an ImmutableTypedTextNode with text type \"marker\".\n */\nexport function $isVisibleMarkerNode(node) {\n return $isImmutableTypedTextNode(node) && node.getTextType() === \"marker\";\n}\n/**\n * True for either flavor of synthesized marker node: a `MarkerNode` (markerMode \"editable\") or an\n * `ImmutableTypedTextNode` with `textType: \"marker\"` (markerMode \"visible\" or gutter views).\n * These are the two node shapes used to render a USFM marker as visible content — a paragraph's\n * marker (e.g. `\\p`, `\\s2`, `\\q1`) as the first child of its `ParaNode`, or a character marker's\n * opening and closing markers inside its `CharNode`.\n *\n * @param node - The node to check.\n * @returns `true` if the node is a `MarkerNode` or a visible marker node.\n */\nexport function $isSynthesizedMarkerNode(node) {\n return $isMarkerNode(node) || $isVisibleMarkerNode(node);\n}\n/**\n * True for the `\\id` line's own prefix glyph, in EVERY marker mode — a synthesized marker node\n * ({@link $isSynthesizedMarkerNode}) that is its `BookNode`'s first child. Unlike\n * `$isBookPrefixNode` (the cursor-guard plugin's own predicate, `shared-react`), this does not\n * exclude the editable-mode `MarkerNode`: it answers \"is this the glyph the prefix shape is made\n * of\", not \"can a caret go here\". Use `$isBookPrefixNode` for the caret question; use this one\n * wherever the prefix needs recognizing regardless of markerMode — e.g. moving a selection\n * endpoint past it, or leaving it out of the content a rebuild re-derives from bytes.\n *\n * Read-only: call inside `editor.read()`, `editor.getEditorState().read(...)`, or an update.\n *\n * @param node - The node to check.\n * @returns `true` if the node is its parent `BookNode`'s first child AND a synthesized marker node.\n */\nexport function $isBookPrefixGlyph(node) {\n if (!node || !$isSynthesizedMarkerNode(node))\n return false;\n const parent = node.getParent();\n return $isBookNode(parent) && node.is(parent.getFirstChild());\n}\n/**\n * The serialized twin of {@link $isSynthesizedMarkerNode}: either flavor of visible marker\n * glyph — a `MarkerNode` (markerMode \"editable\") or a marker-typed `ImmutableTypedTextNode`\n * (markerMode \"visible\" and gutter views) — in a SERIALIZED tree. Kept beside the live predicate\n * so a live and a serialized rebuild of the same region cannot disagree about what the marker\n * prefix is.\n *\n * @param node - The serialized node to check.\n * @returns `true` if the node is a serialized `MarkerNode` or marker-typed `ImmutableTypedTextNode`.\n */\nexport function isSerializedSynthesizedMarkerNode(node) {\n return (isSerializedMarkerNode(node) ||\n (isSerializedImmutableTypedTextNode(node) && node.textType === \"marker\"));\n}\n/**\n * The paragraph marker a selection has selected, if it has one.\n *\n * A paragraph's gutter glyph (see `gutterMarkerState`) is never a caret position, but clicking it\n * selects it: a Lexical `NodeSelection` of the glyph alone, which carries no offsets. This is the\n * one definition every consumer uses to recognize that selection, and it qualifies the same glyph\n * {@link $getSelectableParaMarker} does.\n *\n * Read-only: safe in any read — `editor.getEditorState().read()`, an `editor.update()`, or a\n * command handler.\n *\n * @param selection - The selection to inspect, e.g. `$getSelection()`.\n * @returns the selected glyph, or `undefined` for any other selection — a range, a node selection\n * of some other node, or of more than one node.\n */\nexport function $getSelectedParaMarker(selection) {\n if (!$isNodeSelection(selection))\n return undefined;\n const nodes = selection.getNodes();\n if (nodes.length !== 1)\n return undefined;\n const [node] = nodes;\n const glyph = $getSelectableParaMarker(node.getParent());\n return glyph?.is(node) ? glyph : undefined;\n}\n/**\n * The paragraph whose marker a selection has selected — the parent of\n * {@link $getSelectedParaMarker}'s glyph.\n *\n * Read-only: safe in any read — `editor.getEditorState().read()`, an `editor.update()`, or a\n * command handler.\n *\n * @param selection - The selection to inspect, e.g. `$getSelection()`.\n * @returns the paragraph, or `undefined` when no paragraph marker is selected.\n */\nexport function $getSelectedParaMarkerPara(selection) {\n const para = $getSelectedParaMarker(selection)?.getParent();\n return $isParaNode(para) ? para : undefined;\n}\n/**\n * The marker glyph `node` would offer as a selection target: its leading gutter marker, when\n * `node` is a `ParaNode` that renders one. An implied paragraph has no marker to retag, and a\n * paragraph inside an `UnknownNode` (a sidebar or periph the view hides) is not offered either.\n *\n * Read-only: safe in any read — `editor.getEditorState().read()`, an `editor.update()`, or a\n * command handler.\n *\n * @param node - The node to inspect — typically the parent of a clicked gutter glyph.\n * @returns the paragraph's gutter marker glyph, or `undefined`.\n */\nexport function $getSelectableParaMarker(node) {\n if (!$isParaNode(node))\n return undefined;\n const glyph = node.getFirstChild();\n if (!$isGutterMarkerNode(glyph))\n return undefined;\n return $findMatchingParent(node, $isUnknownNode) ? undefined : glyph;\n}\n/**\n * How many owners (`ParaMarkerSelectionPlugin`, shared-react) are mounted on each editor. A count\n * rather than a set so a remount that registers before the previous instance unregisters (React\n * strict mode, a re-keyed plugin) never leaves the editor looking unowned.\n */\nconst paraMarkerSelectionOwnerCounts = new WeakMap();\n/**\n * Records that `editor` has an owner for a selected paragraph marker — the plugin that handles\n * every key and command reaching it. {@link $selectParaMarker} selects only in an editor that has\n * one, so rich-text's default handling (Backspace deleting the glyph) never sees the selection.\n *\n * @param editor - The editor the owner is mounted on.\n * @returns a function that withdraws this registration.\n */\nexport function registerParaMarkerSelectionOwner(editor) {\n paraMarkerSelectionOwnerCounts.set(editor, (paraMarkerSelectionOwnerCounts.get(editor) ?? 0) + 1);\n return () => {\n const count = (paraMarkerSelectionOwnerCounts.get(editor) ?? 1) - 1;\n if (count > 0)\n paraMarkerSelectionOwnerCounts.set(editor, count);\n else\n paraMarkerSelectionOwnerCounts.delete(editor);\n };\n}\n/**\n * Whether the active editor may select a paragraph marker: it is editable, and an owner is\n * registered ({@link registerParaMarkerSelectionOwner}). A read-only editor never selects one:\n * there is nothing to change the marker to.\n *\n * Read-only, but needs an active editor: call inside `editor.update()` or a command handler (a\n * bare `editorState.read()` has no editor to ask).\n */\nexport function $canSelectParaMarker() {\n const editor = $getEditor();\n return editor.isEditable() && (paraMarkerSelectionOwnerCounts.get(editor) ?? 0) > 0;\n}\n/**\n * Selects a paragraph's gutter marker glyph, replacing the current selection — see\n * {@link $getSelectedParaMarker} for what that selection means. The single gate for creating one:\n * it selects only a glyph {@link $getSelectableParaMarker} offers, in an editor that\n * {@link $canSelectParaMarker}.\n *\n * Mutating: call inside `editor.update()` (a command handler already runs inside one).\n *\n * @param glyph - The paragraph's gutter marker glyph.\n * @returns `true` if the glyph is now selected, `false` if it was refused (nothing changed).\n */\nexport function $selectParaMarker(glyph) {\n if (!$getSelectableParaMarker(glyph.getParent())?.is(glyph) || !$canSelectParaMarker())\n return false;\n const selection = $createNodeSelection();\n selection.add(glyph.getKey());\n $setSelection(selection);\n return true;\n}\n/**\n * Set a `CharNode`'s marker, keeping its content and identity.\n *\n * Use this rather than `CharNode.setMarker` whenever an existing `CharNode`'s marker changes in a\n * rendered editor: it pairs the `setMarker` with the retargeting of the node's synthesized marker\n * children, in the one order that works.\n *\n * Coalescing with an identically-marked adjacent sibling is deliberately not handled here:\n * `$charNodeTransform` (`shared-react`'s `CharNodePlugin.tsx`) already does it, and\n * `CharNodePlugin.test.tsx` proves it for exactly this call. Don't hand-roll it, and don't fight it.\n *\n * The merge is not deferred to a later update: Lexical runs node transforms to fixpoint inside the\n * *same* `editor.update()`, before reconciliation and before any update listener fires, and the node\n * this touches is dirty and therefore transformed. So no committed `EditorState` is ever observable\n * with the un-coalesced pair in it. That matters wherever a caller copies an existing `CharNode`'s\n * cid onto a new sibling and leans on this merge to reunite them — the duplicate cid has no window\n * in which anything can read it.\n *\n * Callers must pre-validate `marker`: passing a footnote or cross-reference marker (e.g. `\"ft\"`,\n * `\"xt\"`) removes the node's closing marker child rather than rewriting it, because\n * `addClosingMarker` never emits one for those families. That is a deliberate contract rather than a\n * guard - see `$retargetSynthesizedMarkers` - and no current caller reaches it, since\n * `EditorRef.replaceCharacterMarker` rejects those markers up front.\n *\n * @param charNode - The `CharNode` to change.\n * @param marker - The character marker to change to. Must not be a footnote or cross-reference\n * marker; see above.\n */\nexport function $setCharNodeMarker(charNode, marker) {\n // Before setMarker, not after. $retargetSynthesizedMarkers's ImmutableTypedTextNode branch\n // (markerMode \"visible\") matches a child's text against the *old* marker's opening/closing form,\n // read via charNode.getMarker() — reversed, that read would already return the new marker, and\n // the stale child would silently go unmatched. Its MarkerNode branch (markerMode \"editable\")\n // doesn't care about this order: MarkerNode.setMarker recomputes text from the new marker it's\n // given plus its own stored __markerSyntax, not from anything read off charNode.\n // Guarded by \"matches marker children against the old marker, not the new one\" in\n // node-utils.test.ts - reverse these two calls and it fails.\n $retargetSynthesizedMarkers(charNode, marker);\n charNode.setMarker(marker);\n}\n/**\n * Point a `CharNode`'s synthesized marker children at a new marker.\n *\n * Under `markerMode: \"editable\"` those children are `MarkerNode`s and under `\"visible\"` they are\n * `ImmutableTypedTextNode`s with `textType: \"marker\"`; both are produced by the USJ editor\n * adaptor's `addOpeningMarker` / `addClosingMarker` and neither is touched by `CharNode.setMarker`,\n * so without this every marker change in those modes leaves the old marker's text on screen.\n *\n * Retargets rather than strips: stripping would leave the changed span looking unmarked, which\n * reads worse than stale. The one exception is the closing marker child when `toMarker` is a\n * note-content marker: `addClosingMarker` never emits a closing marker for those families, so the\n * child is removed rather than rewritten to a form the adaptor would never produce (e.g. `\\ft*`).\n * That is a contract of the function, not a live path — `EditorRef.replaceCharacterMarker` rejects\n * those markers up front.\n *\n * The old marker is read from the node itself rather than taken from a caller-supplied \"from\"\n * marker, which callers may not know when the innermost marker was targeted.\n *\n * A child whose text is neither the opening nor the closing form of the old marker — in either the\n * plain or the nested (`\\\\+nd`) spelling — is left verbatim rather than rewritten by guesswork. This applies to both synthesized child flavors: a\n * `MarkerNode` is a `TextNode` in default (non-token) mode, so a selection anchored inside its\n * visible text can `splitText` it into a fragment whose `__marker` is stale but whose text no\n * longer matches — rewriting that verbatim would re-expand it to the wrong marker.\n *\n * @param charNode - The `CharNode` whose marker is about to change.\n * @param toMarker - The character marker to change to.\n */\nfunction $retargetSynthesizedMarkers(charNode, toMarker) {\n const fromMarker = charNode.getMarker();\n // Both spellings: a nested span's glyphs carry the `+` (`\\\\+nd`), and matching only the plain\n // form left them unmatched, so a marker change inside another span rewrote the node while its\n // glyphs — and the bytes they serialize to — kept the old marker.\n const openingText = openingMarkerText(fromMarker);\n const nestedOpeningText = openingMarkerText(fromMarker, true);\n const closingText = closingMarkerText(fromMarker);\n const nestedClosingText = closingMarkerText(fromMarker, true);\n // Note-content markers are written without a closing marker, so a closing child is removed rather\n // than retargeted to a form `addClosingMarker` would never emit.\n const dropsClosingMarker = CharNode.isNoteContentMarker(toMarker);\n charNode.getChildren().forEach((child) => {\n // Gate on the node type first: only a synthesized marker child is ever a candidate for\n // rewriting or removal here, regardless of what its text happens to contain.\n if (!$isSynthesizedMarkerNode(child))\n return;\n const text = child.getTextContent();\n const isOpening = text === openingText || text === nestedOpeningText;\n const isClosing = !isOpening && (text === closingText || text === nestedClosingText);\n if (!isOpening && !isClosing)\n return;\n if (isClosing && dropsClosingMarker) {\n child.remove();\n return;\n }\n // MarkerNode.setMarker recomputes the node's text for us, nesting included — it re-derives\n // from its own stored nesting rather than from anything read here.\n if ($isMarkerNode(child))\n child.setMarker(toMarker);\n else if ($isVisibleMarkerNode(child)) {\n // A visible glyph stores no nesting, so carry over the nesting its text already showed.\n const nested = text.startsWith(openingMarkerText(\"\", true));\n child.setTextContent(isOpening ? openingMarkerText(toMarker, nested) : closingMarkerText(toMarker, nested));\n }\n });\n}\n/**\n * Remove all known properties of the `markerObject`.\n * @param markerObject - Scripture marker and its contents.\n * @param markerObjectProps - List of known properties to remove. Defaults to `MARKER_OBJECT_PROPS`.\n * @returns all the unknown properties or `undefined` if all are known.\n */\nexport function getUnknownAttributes(markerObject, markerObjectProps = MARKER_OBJECT_PROPS) {\n const attributes = { ...markerObject };\n markerObjectProps.forEach((property) => {\n Reflect.deleteProperty(attributes, property);\n });\n return Object.keys(attributes).length === 0 ? undefined : attributes;\n}\n/**\n * Retrieves the lowercase tag name of the DOM element associated with a LexicalNode.\n * @param node - The LexicalNode for which to find the corresponding DOM element's tag name.\n * @param editor - The LexicalEditor instance used to access the DOM.\n * @returns The lowercase tag name of the DOM element if found, or `undefined` if no corresponding\n * DOM element exists.\n * @deprecated Not used anymore.\n */\nexport function getNodeElementTagName(node, editor) {\n const domElement = editor.getElementByKey(node.getKey());\n return domElement ? domElement.tagName.toLowerCase() : undefined;\n}\n/**\n * Removes properties with undefined values from an object.\n *\n * @param obj - The object to remove undefined properties from.\n * @returns A new object with the same type as the input, but with undefined properties removed.\n *\n * @example\n * const input = { a: 1, b: undefined, c: 'hello' };\n * const result = removeUndefinedProperties(input);\n * // result: { a: 1, c: 'hello' }\n *\n * @remarks\n * This function creates a new object and does not modify the original input object.\n */\nexport function removeUndefinedProperties(obj) {\n return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));\n}\n/**\n * Returns true when the error is Lexical's getNodes() throw (selection on DecoratorNode).\n * Message-based; may break if Lexical changes error text. Prefer pre-checking anchor\n * node type before calling getSelectionStartNode.\n */\nexport function isSelectionStartNodeExpectedError(err) {\n const message = err instanceof Error ? err.message : String(err);\n return (message.includes(\"$caretFromPoint\") &&\n (message.includes(\"does not inherit from ElementNode\") ||\n message.includes(\"does not inherit from TextNode\")));\n}\n/**\n * Get the start node of the selection.\n * For range selections, avoids throws from `getNodes()` when the anchor is on a node type that\n * does not match the anchor type (e.g. DecoratorNode with an element selection), by returning the\n * anchor node or applying `isSelectionStartNodeExpectedError` fallback.\n * @param selection - The selection to get the start node from.\n * @returns The start node of the selection or `undefined` if no selection is provided.\n */\nexport function getSelectionStartNode(selection) {\n if (!$isRangeSelection(selection)) {\n return getSelectionStartNodeInner(selection);\n }\n const anchorNode = selection.anchor.getNode();\n const isAnchorTypeMismatch = anchorNode &&\n ((selection.anchor.type === \"element\" && !$isElementNode(anchorNode)) ||\n (selection.anchor.type === \"text\" && !$isTextNode(anchorNode)));\n if (isAnchorTypeMismatch) {\n return anchorNode ?? undefined;\n }\n try {\n const node = getSelectionStartNodeInner(selection);\n return node ?? anchorNode ?? undefined;\n }\n catch (err) {\n if (isSelectionStartNodeExpectedError(err)) {\n return anchorNode ?? undefined;\n }\n throw err;\n }\n}\n/**\n * Get the next verse number or segment.\n *\n * A verse range increments the end of the range (even if the range includes segments), and a verse\n * segment increments the segment character. This is intentional to simplify the UX.\n * @param verseNum - The current verse number.\n * @param verse - The current verse string, which can be a single verse, a range, or a segment.\n * @returns The next verse number or segment as a string.\n */\nexport function getNextVerse(verseNum, verse) {\n if (!verse)\n return (verseNum + 1).toString();\n const verseParts = verse.split(\"-\");\n if (verseParts.length === 2)\n return parseInt(verseParts[1])\n ? `${parseInt(verseParts[1]) + 1}`\n : `${parseInt(verseParts[0]) + 1}`;\n // Don't increment beyond 'z' or 'Z'.\n const verseSegment = RegExp(/^(\\d+)([a-yA-Y]{1,3})$/).exec(verse);\n if (!verseSegment)\n return (parseInt(verse) + 1).toString();\n const nextSegmentChar = String.fromCharCode(verseSegment[2].charCodeAt(0) + 1);\n return `${verseSegment[1]}${nextSegmentChar}`;\n}\n/**\n * Determines if the verse number is in the given verse range. Verse segments are accounted for.\n * @param verseNum - The current verse number.\n * @param verseRange - The verse range including segments.\n * @returns `true` if the verse number is in the range, `false` otherwise.\n * @example\n * verseRange \"1-2\" - verseNum 1 and 2 are `true`\n * verseRange \"1a-2b\" - verseNum 1 and 2 are `true`\n * verseRange \"1-3\" - verseNum 1, 2, and 3 are `true`\n */\nexport function isVerseInRange(verseNum, verseRange) {\n if (!verseRange)\n return false;\n const verseNumParts = verseRange.split(\"-\").map((v) => parseInt(v));\n if (verseNumParts.length < 1 || verseNumParts.length > 2 || verseNumParts[0] > verseNumParts[1])\n throw new Error(\"isVerseInRange: invalid range\");\n if (verseNumParts.length === 1)\n return verseNum === verseNumParts[0];\n if (verseNumParts.length === 2 && isNaN(verseNumParts[1]))\n return verseNum >= verseNumParts[0];\n if (verseNumParts.length === 2 && isNaN(verseNumParts[0]))\n return verseNum <= verseNumParts[1];\n return verseNum >= verseNumParts[0] && verseNum <= verseNumParts[1];\n}\n/**\n * Checks if the given verse range is a range (i.e. contains a dash).\n * @param verseRange - The verse range to check.\n * @returns `true` if the verse range is a range, `false` otherwise.\n */\nexport function isVerseRange(verseRange) {\n return !!verseRange && verseRange.includes(\"-\");\n}\n/**\n * Parses a (possibly combined/partial) verse marker into its numeric bounds.\n *\n * Unlike {@link isVerseInRange}, this never throws: a marker that isn't numeric yields `NaN` bounds\n * for the caller to reject. Verse numbers come from imported USFM and are not guaranteed to be\n * well-formed.\n *\n * @param verseRange - The verse marker, e.g. `\"5\"`, `\"14-15\"`, `\"3a\"`.\n * @returns the first and last verse numbers the marker covers.\n * @example\n * \"5\" - `{ start: 5, end: 5 }`\n * \"14-15\" - `{ start: 14, end: 15 }`\n * \"1-3a\" - `{ start: 1, end: 3 }`\n * \"3a\" - `{ start: 3, end: 3 }`\n * \"abc\" - `{ start: NaN, end: NaN }`\n */\nexport function parseVerseRange(verseRange) {\n const parts = verseRange.split(\"-\");\n const start = parseInt(parts[0], 10);\n const end = parts.length > 1 ? parseInt(parts[parts.length - 1], 10) : start;\n return { start, end };\n}\nfunction getSelectionStartNodeInner(selection) {\n if (!selection)\n return undefined;\n const nodes = selection.getNodes();\n if (nodes.length > 0) {\n return selection.isBackward() ? nodes[nodes.length - 1] : nodes[0];\n }\n return undefined;\n}\n/**\n * The bytes the user typed into an expanded note's editable caller text, as a local `[start,\n * end)` range of `node` — or `undefined` when `node` is no such caller text, or holds none. Such a\n * text waits as typed while the caret is at it (the marker-edit engine's caller transform), and\n * the editor→USJ conversion reads it as the departure will leave it: the note keeps its caller,\n * and the typed bytes start the note's content. The logical content model reads it the same way,\n * so a position in those bytes is a position in the content.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $typedNoteCallerRange(node) {\n if (!$isTextNode(node))\n return undefined;\n const note = $getLogicalParent(node);\n if (!$isNoteNode(note) || !$noteEditableCallerNode(note)?.is(node))\n return undefined;\n const { start, end } = typedCallerRange(node.getTextContent(), note.getCaller());\n return start < end ? { start, end } : undefined;\n}\n/**\n * Checks whether a node is presentation-only and therefore not part of USJ content:\n * line breaks, marker scaffolding (editable and visible), marker-trailing-space or\n * attribute text (as a plain TextNode or as an opaque block's folded ImmutableTypedTextNode\n * display run, e.g. an UnknownNode's `\\cat` byte display), attribute display-run wrappers,\n * either shape of a note's caller, everything an editable chapter displays, and empty or\n * NBSP-only spacer text (which the editor→USJ conversion drops as well; ideally the USJ→editor\n * conversion would create such spacers as presentation-typed text nodes instead — follow-up\n * work).\n *\n * The answer depends on WHERE the node is attached, not on the node alone: a plain TextNode is\n * presentation when it sits in a note's caller slot or under a chapter, and content anywhere else.\n * So a caller cannot decide from a node's type and state — it has to pass the node as it stands in\n * the tree.\n * @param node - The node to check.\n * @returns `true` if the node must be skipped when computing USJ content indexes.\n */\nexport function $shouldIgnoreNodeForContentIndexes(node) {\n if (!node)\n return false;\n if ($isLineBreakNode(node))\n return true;\n if ($isMarkerNode(node))\n return true;\n if ($isVisibleMarkerNode(node))\n return true;\n // An attribute display run (`\\va`/`\\vp`, `\\ca`/`\\cp`, a milestone's or a note category's) is\n // a wrapper around glyph and attribute-byte pieces that are each presentation-only on their\n // own, so the whole subtree carries no content — which is why the editor→USJ conversion skips\n // it without recursing.\n if ($isAttributeRunNode(node))\n return true;\n // A collapsed note's caller decorator lives in the react layer, which this layer may not\n // import; the registered type name is the contract between them.\n if (node.getType() === IMMUTABLE_NOTE_CALLER_NODE_TYPE)\n return true;\n // ImmutableTypedTextNode's \"attribute\" flavor (an opaque block's folded attribute-byte display\n // run, e.g. an UnknownNode's `\\cat ...\\cat*`) is a DecoratorNode, not a TextNode, so it never\n // reaches the $isTextNode branch below — mirror the \"marker\" flavor handled above by\n // $isVisibleMarkerNode.\n if ($isImmutableTypedTextNode(node) && node.getTextType() === \"attribute\")\n return true;\n const logicalParent = $getLogicalParent(node);\n // A USJ chapter marker carries no content at all, so nothing an editable ChapterNode displays\n // — the `\\c N` glyph text and any `\\ca`/`\\cp` run — occupies a content position.\n if ($isChapterNode(logicalParent))\n return true;\n // An expanded note's editable caller (` + `) is display the conversion drops. Anchored to the\n // caller SLOT — the child right after the note's leading opening glyph(s), the same slot the\n // note-content rebuild reads — so note content that happens to spell the caller is still\n // content. A caller text holding bytes the user typed into it is content too, for exactly those\n // bytes ({@link $typedNoteCallerRange}).\n if ($isTextNode(node) &&\n $isNoteNode(logicalParent) &&\n $noteEditableCallerNode(logicalParent)?.is(node))\n return !$typedNoteCallerRange(node);\n if ($isTextNode(node)) {\n const textType = $getState(node, textTypeState);\n if (textType === MARKER_TRAILING_SPACE_TEXT_TYPE || textType === \"attribute\")\n return true;\n const text = node.getTextContent();\n // \"\" / NBSP are presentation-only; a bare caret host (transientCaretHost.utils.ts) likewise\n // carries no content, so it must not shift annotation content indexes while it rests.\n if (text === \"\" || $isCaretHost(node))\n return true;\n if (text === NBSP)\n return !$isNbspContentAtMark(node);\n }\n return false;\n}\n/**\n * Whether `node`, a text that is exactly one NBSP, is content an annotation mark split off rather\n * than a display spacer. A lone-NBSP text is normally presentation — a char span's separator or\n * spacer, or an empty span's placeholder — but text can contain a no-break space of its own\n * (`Tilde~should`, French `mot~:`, `1~000`), and the wrap splits content text at a range's edges:\n * a range naming just that space makes it a mark of its own, and a range ending or starting right\n * beside it (`end~` over `end`, `a~b` over `a` and over `b`) leaves it a node of its own outside\n * the mark. The wrap moves only named bytes into a mark and leaves a char opener's separator out of\n * it, so a lone NBSP directly inside a mark, or directly beside one, is content unless it sits\n * where a char opener's separator does, or a char span has no other content for it to be part of\n * (the placeholder's shape). The editor→USJ conversion (`editor-usj.adaptor.ts`) keeps exactly\n * these as content, by the same rule on serialized nodes.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isNbspContentAtMark(node) {\n if (node.getTextContent() !== NBSP || $getState(node, textTypeState) !== undefined)\n return false;\n const atMark = $isTypedMarkNode(node.getParent()) ||\n $isTypedMarkNode(node.getPreviousSibling()) ||\n $isTypedMarkNode(node.getNextSibling());\n if (!atMark || $charSeparatorPrefixLength(node) > 0)\n return false;\n const owner = $getLogicalParent(node);\n return !$isCharNode(owner) || $hasOtherCharContent(owner, node);\n}\n/** Whether `char` holds content besides `except`: a text that is more than display, or a nested\n * element (a span, note or milestone). Glyphs, separators and attribute runs do not count. */\nfunction $hasOtherCharContent(char, except) {\n return char.getChildren().some((child) => {\n if (child.is(except))\n return false;\n if ($isTypedMarkNode(child))\n return $hasOtherCharContent(child, except);\n if ($isTextNode(child))\n return (!$isMarkerNode(child) &&\n $getState(child, textTypeState) === undefined &&\n child.getTextContent() !== \"\" &&\n child.getTextContent() !== NBSP &&\n !$isCaretHost(child));\n return $isElementNode(child) && !$isAttributeRunNode(child);\n });\n}\n/**\n * Creates the engine-owned NBSP separator that sits between an editable marker glyph and its\n * content (the `[glyph, separator, ...content]` prefix layout). Token mode so typing at the\n * separator's boundary can never insert INTO it — Lexical routes boundary insertions into a new\n * plain sibling TextNode instead. Without token mode, a fresh empty paragraph (whose caret\n * fallback is the separator's end) absorbed typed text into this node (`asdf`), which the\n * serializer — matching the separator by exact-NBSP text — then leaked into USJ content (`\\p\n * ~asdf` in USFM, and a non-convergent PDP echo loop in the host). The forward adaptor builds the\n * SERIALIZED twin of this node with the same {@link MARKER_TRAILING_SPACE_TEXT_TYPE} tag and\n * token mode.\n *\n * Mutating factory (creates a node): call inside `editor.update()`.\n */\nexport function $createMarkerTrailingSeparator() {\n const separator = $createTextNode(NBSP);\n $setState(separator, textTypeState, MARKER_TRAILING_SPACE_TEXT_TYPE);\n separator.setMode(\"token\");\n return separator;\n}\n/**\n * Prepends the structural NBSP that leads an editable char span's text content (after the opening\n * glyph), if not already present. The prefix separates the glyph from the content so caret\n * placement and Tier-2 fragment building can address the content boundary; the reverse adaptor\n * strips it on serialization. String-building code paths (the forward adaptor,\n * `$createNoteContentChar`, the delta materializer) prepend the same `NBSP` when constructing\n * content text.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $withCharContentNbspPrefix(node) {\n const text = node.getTextContent();\n if (!text.startsWith(NBSP))\n node.setTextContent(NBSP + text);\n}\n/**\n * Whether `node` is the engine-owned marker-trailing NBSP separator (see\n * {@link $createMarkerTrailingSeparator}). Read-only: call inside\n * `editor.getEditorState().read(...)` or an update.\n *\n * Deliberately NOT a `node is TextNode` type predicate: a false result must not narrow the node\n * away from `TextNode` (an untagged plain text node also returns false), which a type predicate's\n * false branch would wrongly do.\n */\nexport function $isMarkerTrailingSeparator(node) {\n return $isTextNode(node) && $getState(node, textTypeState) === MARKER_TRAILING_SPACE_TEXT_TYPE;\n}\n/**\n * Whether `element`'s para-prefix separator is MISSING while the collapsed caret sits at its\n * site — on the prefix glyph, on the element itself (an element point), or at the very start of\n * the node after the glyph. This is where the caret lands when the user deletes the separator,\n * and it is the para-prefix twin of the char opener's caret-boundary rule\n * (markerSeparators.utils.ts): while it holds, healing the byte back would be healing against a\n * user edit, so the heal and the settle both defer to caret departure. One definition, used by\n * both the deletion transform's grace and the departure settle's re-pend, so the two can never\n * disagree about what \"at the site\" means. Read-only: call inside\n * `editor.getEditorState().read(...)` or an update.\n */\nexport function $paraPrefixSeparatorCaretHeld(element) {\n const glyph = element.getFirstChild();\n if (!$isSynthesizedMarkerNode(glyph) || glyph === null)\n return false;\n if ($isMarkerTrailingSeparator(glyph.getNextSibling()))\n return false;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n if (anchorNode.is(glyph) || anchorNode.is(element))\n return true;\n const next = glyph.getNextSibling();\n return next !== null && anchorNode.is(next) && selection.anchor.offset === 0;\n}\n/** The characters of `node` the conversion keeps before any whitespace rule: past its lead, up to\n * the end of any typed caller bytes. */\nfunction $keptRange(node) {\n // A char span's separator NBSP is a prefix of its first content text and the exporter strips\n // it before anything else, so it occupies no USJ offset and never belongs to a space run —\n // see $charSeparatorPrefixLength.\n // A caller text holding typed bytes contributes only those bytes: the caller's own bytes in\n // front of them are its lead, and any behind them are dropped too.\n const typed = $typedNoteCallerRange(node);\n return {\n lead: typed ? typed.start : $charSeparatorPrefixLength(node),\n keptEnd: typed ? typed.end : node.getTextContentSize(),\n };\n}\n/** Whether every character `nodes` keep is a display space. */\nfunction $holdsOnlySpaces(nodes) {\n return nodes.every((node) => {\n const { lead, keptEnd } = $keptRange(node);\n const kept = node.getTextContent().slice(lead, keptEnd);\n return leadingDisplaySpaceLength(kept) === kept.length;\n });\n}\n/** Whether a text right after `node` follows a verse number's separator: a verse with no `\\va` or\n * `\\vp`, whose closing marker the text would follow instead. */\nfunction $endsInVerseNumber(node) {\n return ($isVerseNode(node) && node.getAltnumber() === undefined && node.getPubnumber() === undefined);\n}\n/** Whether the root's implied paragraph `implied` starts its content after a marker's separator:\n * not after a chapter's `\\ca`/`\\cp`, whose closing marker or text the content would follow. */\nfunction $startsAfterSeparator(implied) {\n const previous = implied.getPreviousSibling();\n return (!$isSomeChapterNode(previous) ||\n (previous.getAltnumber() === undefined && previous.getPubnumber() === undefined));\n}\n/**\n * The shape half of {@link $getLogicalContentItems}. Serialization that collapses space runs\n * (Standard view's) also drops the spaces a text starts with right after a marker's separator,\n * which Paratext 9 skips as part of the separator rather than reading as content:\n *\n * - at the start of a paragraph's content — under any paragraph marker, and in the root's implied\n * paragraph after a chapter;\n * - right after a verse number.\n *\n * A text holding nothing but such spaces is no item.\n */\nfunction $getLogicalItemShapes(parent, collapsesSpaceRuns) {\n // A chapter marker has no `content` in USJ: an editable ChapterNode's children are entirely the\n // `\\c N` glyph it displays and the runs that ride after it.\n if ($isChapterNode(parent))\n return [];\n const shapes = [];\n /** Where in `shapes` each paragraph's content starts that starts after a separator. */\n const paragraphStarts = [];\n let run;\n const flushRun = () => {\n if (run) {\n shapes.push({ type: \"text\", nodes: run });\n run = undefined;\n }\n };\n const visit = (node) => {\n if ($shouldIgnoreNodeForContentIndexes(node))\n return;\n if ($isSplicedImpliedPara(node)) {\n // The conversion splices the implied paragraph into the root, so its content starts among\n // the root's items.\n flushRun();\n if ($startsAfterSeparator(node))\n paragraphStarts.push(shapes.length);\n node.getChildren().forEach(visit);\n flushRun();\n return;\n }\n if ($isContentTransparent(node)) {\n // For marks, recursion is defense-in-depth: nested marks only exist transiently before the\n // AnnotationPlugin's nested-element resolver flattens them into siblings.\n node.getChildren().forEach(visit);\n return;\n }\n // Only plain TextNodes (exact \"text\" type) join a coalesced run, mirroring the exporter.\n // TextNode subclasses (e.g. VerseNode) fall through to become standalone items.\n if ($isTextNode(node) && node.getType() === TextNode.getType()) {\n run ??= [];\n run.push(node);\n return;\n }\n flushRun();\n shapes.push({ type: \"element\", node });\n };\n parent.getChildren().forEach(visit);\n flushRun();\n if (!collapsesSpaceRuns)\n return shapes;\n if ($isParaNode(parent))\n paragraphStarts.push(0);\n return shapes.filter((shape, index) => {\n if (shape.type !== \"text\")\n return true;\n const previous = shapes[index - 1];\n const afterSeparator = paragraphStarts.includes(index) ||\n (previous?.type === \"element\" && $endsInVerseNumber(previous.node));\n if (!afterSeparator)\n return true;\n shape.dropsLeadingSpaces = true;\n return !$holdsOnlySpaces(shape.nodes);\n });\n}\n/**\n * Measures a coalesced text run in the exporter's coordinates. Each node is measured on its own,\n * as the exporter converts each node's text before joining it to its neighbors, so a space run\n * split across an annotation's edge does not collapse. The spaces the run starts with, when\n * serialization drops them (see {@link $getLogicalItemShapes}), are dropped across nodes, as the\n * exporter drops them from the joined string.\n */\nfunction $measureTextItem(shape, collapsesSpaceRuns) {\n const segments = [];\n let length = 0;\n let dropsLeadingSpaces = !!shape.dropsLeadingSpaces;\n for (const node of shape.nodes) {\n const { lead, keptEnd } = $keptRange(node);\n const kept = node.getTextContent().slice(lead, keptEnd);\n const leadingSpaces = dropsLeadingSpaces ? leadingDisplaySpaceLength(kept) : 0;\n if (leadingSpaces < kept.length)\n dropsLeadingSpaces = false;\n const runsStart = lead + leadingSpaces;\n const collapsed = collapsesSpaceRuns\n ? collapsedSpaceRunRanges(kept.slice(leadingSpaces)).map(([start, end]) => [start + runsStart, end + runsStart])\n : [];\n if (leadingSpaces > 0)\n collapsed.unshift([lead, runsStart]);\n if (keptEnd < node.getTextContentSize())\n collapsed.push([keptEnd, node.getTextContentSize()]);\n const segmentLength = node.getTextContentSize() -\n lead -\n collapsed.reduce((sum, [start, end]) => sum + end - start, 0);\n segments.push({ node, start: length, lead, collapsed, length: segmentLength });\n length += segmentLength;\n }\n return { type: \"text\", segments, length };\n}\n/** A segment's dropped characters — its lead, then its collapsed runs — as ascending ranges. */\nfunction droppedRanges(segment) {\n return segment.lead > 0 ? [[0, segment.lead], ...segment.collapsed] : segment.collapsed;\n}\n/** The logical offset of local offset `offset` in the segment's node. */\nfunction segmentLogicalOffset(segment, offset) {\n let kept = offset;\n for (const [start, end] of droppedRanges(segment)) {\n if (offset <= start)\n break;\n kept -= Math.min(offset, end) - start;\n }\n return segment.start + kept;\n}\n/** The local offset in the segment's node of the character `contentOffset` into its content. */\nfunction segmentLocalOffset(segment, contentOffset) {\n let local = contentOffset;\n for (const [start, end] of droppedRanges(segment)) {\n if (start > local)\n break;\n local += end - start;\n }\n return local;\n}\n/**\n * Maps a parent element's Lexical children to its logical USJ content items — the items the\n * editor→USJ conversion would export: presentation-only nodes skipped, TypedMarkNodes\n * transparent (children spliced in, recursively), contiguous text coalesced into single items,\n * and the characters the conversion drops (a char span's structural separator NBSP, a collapsed\n * space run's extra characters, and the spaces after a marker's separator — at a paragraph's\n * content start and after a verse number) excluded from its text item's coordinates — a text\n * holding only such spaces is no item. The root's implied paragraph is transparent the same way\n * marks are: the conversion splices its children into the root.\n *\n * Known exclusion: comment-type TypedMarkNodes are treated as transparent like every other\n * mark, even though the exporter still serializes them as milestone items. That milestone\n * serialization is deprecated and pending removal, so the model intentionally ignores it.\n * @param parent - The parent element node.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs (Standard\n * view's whitespace, `hasStandardViewWhitespace` in shared-react), and with them drops the\n * spaces after a marker's separator.\n * @returns the logical content items in document order.\n */\nexport function $getLogicalContentItems(parent, collapsesSpaceRuns) {\n return $getLogicalItemShapes(parent, collapsesSpaceRuns).map((shape) => shape.type === \"element\"\n ? { type: \"element\", node: shape.node }\n : $measureTextItem(shape, collapsesSpaceRuns));\n}\n/**\n * Gets the logical content index of the item containing the child (the child may be nested\n * inside TypedMarkNodes under the parent).\n * @param parent - The logical parent element.\n * @param child - The node to find.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs; see\n * {@link $getLogicalContentItems}.\n * @returns the logical index, or -1 if the child is presentation-only, is text holding only\n * spaces after a marker's separator that the conversion drops whole, or is not found.\n */\nexport function $getLogicalIndexOfChild(parent, child, collapsesSpaceRuns) {\n return $getLogicalItemShapes(parent, collapsesSpaceRuns).findIndex((shape) => shape.type === \"element\" ? shape.node.is(child) : shape.nodes.some((node) => node.is(child)));\n}\n/**\n * Converts a (TextNode, local offset) point to logical USJ text coordinates: the index of the\n * coalesced text item within the logical parent and the cumulative offset within it.\n * @param textNode - The Lexical text node.\n * @param offset - The offset within the text node.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs; see\n * {@link $getLogicalContentItems}.\n * @returns the logical parent, item index, and cumulative offset, or `undefined` if the text\n * node is not part of any logical text item (e.g. presentation-only text). An offset inside a\n * character the conversion drops (the separator lead, or a collapsed run's extra spaces)\n * reports the kept character after it, the nearest position the USJ text can express.\n */\nexport function $getLogicalTextLocation(textNode, offset, collapsesSpaceRuns) {\n const parent = $getLogicalParent(textNode);\n if (!parent)\n return undefined;\n const items = $getLogicalContentItems(parent, collapsesSpaceRuns);\n for (let index = 0; index < items.length; index++) {\n const item = items[index];\n if (item.type !== \"text\")\n continue;\n const segment = item.segments.find((segment) => segment.node.is(textNode));\n if (segment)\n return { parent, index, offset: segmentLogicalOffset(segment, offset) };\n }\n return undefined;\n}\n/**\n * Finds the TextNode and local offset at a cumulative offset within a logical text item.\n * At internal segment boundaries the next segment's start is preferred, so a point at an\n * annotation edge targets the start of the following content rather than the end of the\n * previous piece.\n * @param item - The logical text item.\n * @param offset - The cumulative offset within the item.\n * @returns the text node and local offset — past any characters the conversion drops, so the\n * point sits on the character the USJ offset names — or `undefined` when out of range.\n */\nexport function $getTextNodeAtLogicalOffset(item, offset) {\n if (offset < 0 || offset > item.length)\n return undefined;\n for (const segment of item.segments) {\n if (offset >= segment.start && offset < segment.start + segment.length)\n return [segment.node, segmentLocalOffset(segment, offset - segment.start)];\n }\n // offset === item.length: end of the last segment.\n const lastSegment = item.segments[item.segments.length - 1];\n if (!lastSegment)\n return undefined;\n return [lastSegment.node, segmentLocalOffset(lastSegment, offset - lastSegment.start)];\n}\n/**\n * Converts an element point (parent + child index) to a logical point. Boundaries that fall\n * inside a coalesced text item (e.g. at an annotation edge) become text points; boundaries\n * between logical items become index points. A point on the root's implied paragraph is a\n * boundary among the ROOT's items, since the implied paragraph has none of its own.\n * @param parent - The parent element node of the element point.\n * @param elementOffset - The child index of the element point.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs; see\n * {@link $getLogicalContentItems}.\n * @returns the logical point, in the coordinates of `parent`'s logical parent when `parent` is the\n * root's implied paragraph and of `parent` otherwise.\n */\nexport function $getLogicalPointFromElementPoint(parent, elementOffset, collapsesSpaceRuns) {\n const child = parent.getChildAtIndex(elementOffset);\n if ($isSplicedImpliedPara(parent)) {\n const root = parent.getParentOrThrow();\n // Past the implied paragraph's last child is the boundary in front of whatever follows it.\n if (!child)\n return $getLogicalPointFromElementPoint(root, parent.getIndexWithinParent() + 1, collapsesSpaceRuns);\n if ($shouldIgnoreNodeForContentIndexes(child) ||\n !$logicalItemWithin($getLogicalContentItems(root, collapsesSpaceRuns), child))\n return $getLogicalPointFromElementPoint(parent, elementOffset + 1, collapsesSpaceRuns);\n return $logicalPointBefore(root, child, collapsesSpaceRuns);\n }\n const items = $getLogicalContentItems(parent, collapsesSpaceRuns);\n if (!child)\n return { type: \"index\", index: items.length };\n // Boundary before a presentation-only node: use the boundary before the next content child.\n if ($shouldIgnoreNodeForContentIndexes(child))\n return $getLogicalPointFromElementPoint(parent, elementOffset + 1, collapsesSpaceRuns);\n // A child with no content items of its own — an implied paragraph the conversion splices away,\n // an annotation mark left holding nothing USJ carries, or a text holding only spaces after a\n // marker's separator, which the conversion drops whole. It contributes no item to search for,\n // so the boundary in front of it is the one in front of whatever follows it; falling through\n // would report the END of the parent's content instead.\n if (!$logicalItemWithin(items, child))\n return $getLogicalPointFromElementPoint(parent, elementOffset + 1, collapsesSpaceRuns);\n return $logicalPointBefore(parent, child, collapsesSpaceRuns);\n}\n/**\n * The logical point in front of `node` among its logical parent's items. Annotation marks around\n * `node` are transparent, so a node between two of a mark's children still gets the exact point in\n * front of it; a node in the root's implied paragraph counts among the root's items.\n * @param node - The node to find the point in front of.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs; see\n * {@link $getLogicalContentItems}.\n * @returns the logical parent and the point in its coordinates, or `undefined` for the root and for\n * a node that neither is nor holds any of its logical parent's items (presentation, or a mark\n * holding only presentation), which has no point of its own to be in front of.\n */\nexport function $getLogicalPointBeforeNode(node, collapsesSpaceRuns) {\n const parent = $getLogicalParent(node);\n if (!parent)\n return undefined;\n if (!$logicalItemWithin($getLogicalContentItems(parent, collapsesSpaceRuns), node))\n return undefined;\n return { parent, point: $logicalPointBefore(parent, node, collapsesSpaceRuns) };\n}\n/** Whether any of `items` is `node` or lies inside it. */\nfunction $logicalItemWithin(items, node) {\n return items.some((item) => item.type === \"element\"\n ? item.node.is(node) || $isDescendantOf(item.node, node.getKey())\n : item.segments.some((segment) => segment.node.is(node) || $isDescendantOf(segment.node, node.getKey())));\n}\n/** The logical point in front of `child`, which is `parent`'s logical content or holds some. */\nfunction $logicalPointBefore(parent, child, collapsesSpaceRuns) {\n const items = $getLogicalContentItems(parent, collapsesSpaceRuns);\n for (let index = 0; index < items.length; index++) {\n const item = items[index];\n if (item.type === \"element\") {\n if (item.node.is(child) || $isDescendantOf(item.node, child.getKey()))\n return { type: \"index\", index };\n continue;\n }\n for (const segment of item.segments) {\n if (segment.node.is(child) || $isDescendantOf(segment.node, child.getKey())) {\n return segment.start === 0\n ? { type: \"index\", index }\n : { type: \"text\", index, offset: segment.start };\n }\n }\n }\n return { type: \"index\", index: items.length };\n}\n/**\n * Converts a logical boundary index to the earliest element point at that boundary (the inverse\n * of `$getLogicalPointFromElementPoint` for index points). A boundary among the items of the\n * root's implied paragraph lies inside that paragraph, so the point's element is not always\n * `parent`.\n * @param parent - The parent element node.\n * @param logicalIndex - The logical boundary index (0 = before the first item).\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs; see\n * {@link $getLogicalContentItems}.\n * @returns the element holding the point and the child offset within it.\n */\nexport function $getElementPointFromLogicalIndex(parent, logicalIndex, collapsesSpaceRuns) {\n if (logicalIndex <= 0)\n return [parent, 0];\n const shapes = $getLogicalItemShapes(parent, collapsesSpaceRuns);\n if (shapes.length === 0 || logicalIndex > shapes.length)\n return [parent, parent.getChildrenSize()];\n const previousShape = shapes[logicalIndex - 1];\n const lastNode = previousShape.type === \"element\"\n ? previousShape.node\n : previousShape.nodes[previousShape.nodes.length - 1];\n const topLevelChild = lastNode ? $findChildOfParent(parent, lastNode) : undefined;\n if (!topLevelChild)\n return [parent, parent.getChildrenSize()];\n if ($isSplicedImpliedPara(topLevelChild)) {\n const impliedChild = $findChildOfParent(topLevelChild, lastNode);\n if (impliedChild)\n return [topLevelChild, impliedChild.getIndexWithinParent() + 1];\n }\n return [parent, topLevelChild.getIndexWithinParent() + 1];\n}\n/** Walks up from a descendant to the direct child of the given parent. */\nfunction $findChildOfParent(parent, descendant) {\n let current = descendant;\n while (current) {\n const currentParent = current.getParent();\n if (currentParent?.is(parent))\n return current;\n current = currentParent;\n }\n return undefined;\n}\n","import { INVALID_CLASS_NAME } from \"../usj/node-constants.js\";\nimport { $applyNodeReplacement, TextNode, } from \"lexical\";\nexport const UNMATCHED_TAG_NAME = \"unmatched\";\nexport const IMMUTABLE_UNMATCHED_VERSION = 2;\n/** The displayed bytes for an unmatched marker: `marker` keeps its own trailing `*` (`\"nd*\"`,\n * or `\"*\"` for a bare stray closer), so the glyph is just a backslash prefix away. */\nexport function unmatchedGlyphText(marker) {\n return `\\\\${marker}`;\n}\n/**\n * A marker with no counterpart to pair with — an unmatched closer (`\\nd*` with no open span, PT9\n * `sink.Unmatched`) or a stray `\\*`. Ordinary editable TEXT, not a decorator: under Invariant I\n * the flagged bytes are document bytes that happen to re-tokenize to nothing yet, so they must\n * remain caret-addressable and must flow through a Tier-2 rebuild as bytes — which is exactly how\n * an unmatched closer RE-matches when the document later supplies its opener (the tokenizer's own\n * frame matching consumes it). The `marker` field mirrors the node's rest-state bytes the same\n * way `MarkerNode`'s does: a user edit diverges the text from the state, the divergence pends,\n * and the settle re-tokenizes the displayed bytes.\n *\n * Despite the historical name, only the DEFAULT text mode is immutable-ish: \"token\", which makes\n * the node atomic (caret steps over it whole, deletion removes it whole, no in-place typing) —\n * the right behavior for view modes with no marker-edit engine to settle an in-place edit\n * (visible/hidden marker modes, and collab-materialized nodes). The editable-marker adaptor\n * serializes these nodes with mode \"normal\" so Standard view can edit the bytes in place.\n */\nexport class ImmutableUnmatchedNode extends TextNode {\n __marker;\n constructor(marker = \"\", key) {\n super(unmatchedGlyphText(marker), key);\n this.__marker = marker;\n // Direct assignment, not setMode: the constructor owns the instance, and the writable-node\n // machinery is not available until the node is attached to an update.\n this.__mode = 1; // \"token\"\n }\n static getType() {\n return \"unmatched\";\n }\n static clone(node) {\n const { __marker, __key } = node;\n // Text, format, style, mode, and detail are copied by afterCloneFrom (TextNode), so a\n // mid-edit divergence between the bytes and __marker survives cloning.\n return new ImmutableUnmatchedNode(__marker, __key);\n }\n static importDOM() {\n return {\n [UNMATCHED_TAG_NAME]: (node) => {\n if (!isUnmatchedElement(node))\n return null;\n return {\n conversion: $convertImmutableUnmatchedElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createImmutableUnmatchedNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n // Version-1 serializations (and the collab materializer's embed data) carry only `marker` —\n // none of the TextNode fields — so every text field defaults at runtime even though the\n // serialized type declares them required: bytes derive from the marker, and the mode\n // defaults to the constructor's atomic \"token\".\n const marker = serializedNode.marker ?? \"\";\n const self = super.updateFromJSON({\n ...serializedNode,\n detail: serializedNode.detail ?? 0,\n format: serializedNode.format ?? 0,\n mode: serializedNode.mode ?? \"token\",\n style: serializedNode.style ?? \"\",\n text: serializedNode.text ?? unmatchedGlyphText(marker),\n });\n // Assigned directly rather than via setMarker, which would rewrite the just-applied text to\n // canonical and lose a serialized mid-edit divergence.\n const writable = self.getWritable();\n writable.__marker = marker;\n return writable;\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n self.__text = unmatchedGlyphText(marker);\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n createDOM(config) {\n const dom = super.createDOM(config);\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(INVALID_CLASS_NAME);\n dom.title = unmatchedTitle(this.__marker);\n return dom;\n }\n updateDOM(prevNode, dom, config) {\n // TextNode reconciles the visible text; on element reuse createDOM does not run again, so the\n // marker-derived attribute and title are rewritten by hand — same gap MarkerNode.updateDOM\n // closes for glyphs.\n const isRecreated = super.updateDOM(prevNode, dom, config);\n if (prevNode.__marker !== this.__marker) {\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.title = unmatchedTitle(this.__marker);\n }\n return isRecreated;\n }\n exportDOM() {\n // The dedicated element round-trips through importDOM above, so an HTML copy of the flagged\n // bytes pastes back as the same construct.\n const element = document.createElement(UNMATCHED_TAG_NAME);\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(INVALID_CLASS_NAME);\n element.textContent = this.getTextContent();\n return { element };\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n marker: this.getMarker(),\n version: IMMUTABLE_UNMATCHED_VERSION,\n };\n }\n canInsertTextBefore() {\n // Typing at either edge belongs to the surrounding content, not to the flagged bytes — the\n // same reason a completed closer keeps appended typing outside the glyph.\n return false;\n }\n canInsertTextAfter() {\n return false;\n }\n}\n/** Whether the node's rendered bytes still spell its own state's glyph — at rest, as opposed to\n * mid-edit (pend-shaped). The unmatched counterpart of `$isCanonicalMarkerNode`.\n * Read-only: call inside `editor.getEditorState().read(...)` or an update. */\nexport function $isCanonicalUnmatchedNode(node) {\n return node.getTextContent() === unmatchedGlyphText(node.getMarker());\n}\nfunction unmatchedTitle(marker) {\n return marker.endsWith(\"*\")\n ? `This closing marker has no matching opening marker!`\n : `This opening marker has no matching closing marker!`;\n}\nfunction $convertImmutableUnmatchedElement(element) {\n const marker = element.getAttribute(\"data-marker\") ?? \"\";\n const node = $createImmutableUnmatchedNode(marker);\n return { node };\n}\nexport function $createImmutableUnmatchedNode(marker) {\n return $applyNodeReplacement(new ImmutableUnmatchedNode(marker));\n}\nfunction isUnmatchedElement(node) {\n // `tagName` is upper-cased for HTML-namespace elements, so compare case-insensitively.\n return node?.tagName.toLowerCase() === UNMATCHED_TAG_NAME;\n}\nexport function $isImmutableUnmatchedNode(node) {\n return node instanceof ImmutableUnmatchedNode;\n}\nexport function isSerializedImmutableUnmatchedNode(node) {\n return node?.type === ImmutableUnmatchedNode.getType();\n}\n","/**\n * Reading and writing annotations held on display-byte nodes (\"carriers\"), and the per-editor\n * registration that keeps a display-held annotation's host callbacks. See\n * `displayAnnotations.state.ts` for why a carrier holds state instead of sitting in a mark.\n *\n * Kept apart from `TypedMarkNode.ts` because it reads display-run structure\n * (`attributeDisplay.utils.ts`), which itself imports `TypedMarkNode.ts`.\n */\nimport { textTypeState } from \"../collab/delta.state.js\";\nimport { $chapterGlyphTextNode, $noteEditableCallerNode } from \"../usj/attributeDisplay.utils.js\";\nimport { $isChapterNode } from \"../usj/ChapterNode.js\";\nimport { ImmutableChapterNode } from \"../usj/ImmutableChapterNode.js\";\nimport { IMMUTABLE_NOTE_CALLER_NODE_TYPE, IMMUTABLE_VERSE_NODE_TYPE, ZWSP, } from \"../usj/node-constants.js\";\nimport { $isMarkerTrailingSeparator } from \"../usj/node.utils.js\";\nimport { $isNoteNode } from \"../usj/NoteNode.js\";\nimport { $isVerseNode, VerseNode } from \"../usj/VerseNode.js\";\nimport { displayAnnotationsState, mapRangeThroughAlignment, alignCharacters, } from \"./displayAnnotations.state.js\";\nimport { $isImmutableUnmatchedNode } from \"./ImmutableUnmatchedNode.js\";\nimport { ImmutableTypedTextNode } from \"./ImmutableTypedTextNode.js\";\nimport { $isMarkerNode, MarkerNode } from \"./MarkerNode.js\";\nimport { $isTypedMarkNode } from \"./TypedMarkNode.js\";\nimport { $getEditor, $getState, $isDecoratorNode, $isTextNode, $setState, TextNode } from \"lexical\";\n/** Decorators whose DOM is their display bytes, annotated as a whole node. */\nconst DISPLAY_ANNOTATION_DECORATOR_TYPES = new Set([\n IMMUTABLE_NOTE_CALLER_NODE_TYPE,\n IMMUTABLE_VERSE_NODE_TYPE,\n ImmutableTypedTextNode.getType(),\n // A chapter in the views without editable markers: the same whole-node treatment as a verse.\n ImmutableChapterNode.getType(),\n]);\n/** Whether `node` is the text of an attribute display run — engine-owned display bytes, never\n * annotated content. */\nexport function $isAttributeDisplayRun(node) {\n return $isTextNode(node) && $getState(node, textTypeState) === \"attribute\";\n}\n/**\n * Whether `node` is the text an element owner's attribute display run is anchored after: a note's\n * editable caller (its `\\cat` run follows it) or a chapter's `\\c N` glyph text (its `\\ca` run\n * follows it, and its `\\cp` run follows that). Both runs are found beside the anchor, so an\n * anchor moved into a mark without its run reads as the run being missing, and the sync writes a\n * second one.\n */\nexport function $isElementOwnerRunAnchor(node) {\n if (!$isTextNode(node))\n return false;\n let owner = node.getParent();\n while ($isTypedMarkNode(owner))\n owner = owner.getParent();\n if ($isNoteNode(owner))\n return $noteEditableCallerNode(owner)?.is(node) ?? false;\n if ($isChapterNode(owner))\n return $chapterGlyphTextNode(owner)?.is(node) ?? false;\n return false;\n}\n/**\n * Whether `node` is a display-byte node an annotation is held ON rather than wrapped: a marker\n * glyph, an attribute run's text, a verse, a note's editable caller, a chapter's `\\c N` glyph, an\n * unmatched closer, or a read-only glyph, caller, verse or chapter decorator. Never a separator —\n * the engine-owned whitespace between a marker and its content has no position of its own — and\n * never a milestone or an `AttributeRunNode` wrapper, which spell no bytes themselves (their run\n * pieces do).\n */\nexport function $isDisplayAnnotationCarrier(node) {\n if ($isDecoratorNode(node))\n return DISPLAY_ANNOTATION_DECORATOR_TYPES.has(node.getType());\n if (!$isTextNode(node) || $isMarkerTrailingSeparator(node))\n return false;\n return ($isMarkerNode(node) ||\n $isVerseNode(node) ||\n $isAttributeDisplayRun(node) ||\n $isElementOwnerRunAnchor(node) ||\n // An unmatched closer (`ImmutableUnmatchedNode`) is a `TextNode` subclass, not a decorator, so\n // the decorator-type set above cannot reach it.\n $isImmutableUnmatchedNode(node));\n}\n/**\n * The bytes of carrier `node` an annotation can hold: all of a decorator (`[0, 0]`, the whole\n * node), or a text carrier without the whitespace at its edges — a glyph's own separator (the\n * space in `\\v 3 `, around a caller, after a run opener), which has no position of its own.\n */\nexport function $carrierHoldableRange(node) {\n if (!$isTextNode(node))\n return [0, 0];\n if ($isImmutableUnmatchedNode(node))\n return [0, node.getTextContentSize()];\n const text = node.getTextContent();\n const lead = text.length - text.trimStart().length;\n if (lead === text.length)\n return [lead, lead];\n return [lead, text.trimEnd().length];\n}\nfunction sameAnnotation(a, type, id) {\n return a.type === type && a.id === id;\n}\n/**\n * `held`'s ranges re-measured against `basis`, the carrier's storage text now, through a character\n * alignment, dropping any with no byte left (see `mapRangeThroughEdit`). A whole-decorator hold\n * (`[0, 0]`) stays whole.\n */\nfunction remapped(held, basis) {\n if (held.basis === basis)\n return held.annotations;\n const alignment = alignCharacters(held.basis, basis);\n return held.annotations.flatMap((annotation) => {\n if (annotation.start === annotation.end)\n return [annotation];\n const mapped = mapRangeThroughAlignment(alignment, annotation.start, annotation.end);\n return mapped ? [{ ...annotation, start: mapped[0], end: mapped[1] }] : [];\n });\n}\n/**\n * The text a carrier's stored ranges index: a text's own, or the holdable bytes a decorator stands\n * for ({@link $decoratorHoldableText}). A decorator's holds are kept in its bytes, not in what it\n * renders, so a change only in how it draws them (a hidden caller `-` drawn as `*` while its note\n * is collapsed) never moves or widens one, whatever is written meanwhile.\n */\nfunction $storageText(node) {\n return $isDecoratorNode(node) ? $decoratorHoldableText(node) : node.getTextContent();\n}\n/** The text a carrier's offsets measure as read: a text's own, or what a decorator renders. */\nfunction $carrierText(node) {\n return $isDecoratorNode(node) ? $decoratorRenderedText(node) : node.getTextContent();\n}\n/** `node`'s holds as stored, measured against its current storage text ({@link $storageText}). */\nfunction $storedAnnotations(node) {\n const held = $getState(node, displayAnnotationsState);\n return held ? remapped(held, $storageText(node)) : [];\n}\n/**\n * A decorator's hold of holdable bytes `[start, end)` as it is drawn now: the rendered characters\n * of the bytes it shows; whole (`[0, 0]`) when one of them is drawn without text (a caller CSS\n * draws, a hidden caller drawn as `*`); and, when it shows none of them, the same holdable range\n * marked `undisplayed`.\n */\nfunction $drawnHold(node, annotation) {\n if (annotation.start === annotation.end)\n return annotation;\n let start;\n let end;\n for (let index = annotation.start; index < annotation.end; index++) {\n const offset = bytesReader.renderedOffset(node, index);\n if (offset === \"drawn\")\n return { type: annotation.type, id: annotation.id, start: 0, end: 0 };\n if (offset === undefined)\n continue;\n start = Math.min(start ?? offset, offset);\n end = Math.max(end ?? offset + 1, offset + 1);\n }\n if (start === undefined || end === undefined)\n return { ...annotation, undisplayed: true };\n return { type: annotation.type, id: annotation.id, start, end };\n}\n/**\n * The annotations `node` holds, measured against its CURRENT text — for a decorator, against what\n * it renders now ({@link $drawnHold}). Read-only.\n */\nexport function $displayAnnotationsOf(node) {\n const stored = $storedAnnotations(node);\n if (!$isDecoratorNode(node))\n return stored;\n return stored.map((annotation) => $drawnHold(node, annotation));\n}\n/** Store `annotations` on `node` in the order their bytes come (a whole hold first), so a reader\n * that joins them gets them in document order. */\nfunction $writeAnnotations(node, annotations) {\n const ordered = [...annotations].sort((a, b) => a.start - b.start || a.end - b.end);\n $setState(node, displayAnnotationsState, ordered.length > 0 ? { basis: $storageText(node), annotations: ordered } : undefined);\n}\n/** What a decorator displays without edge whitespace; what it renders, for one whose own text is\n * empty (a chapter number). */\nfunction $displayedHoldableText(decorator) {\n const own = $decoratorDisplayText(decorator).trim();\n if (own)\n return own;\n const rendered = $decoratorRenderedText(decorator);\n const [start, end] = trimmedTextRange(rendered);\n return rendered.slice(start, end);\n}\n/** A decorator stands for what it displays, drawn where its rendered text spells it. */\nconst displayedBytesReader = {\n holdableText: $displayedHoldableText,\n renderedOffset: (decorator, index) => {\n const holdable = $displayedHoldableText(decorator);\n if (index >= holdable.length)\n return undefined;\n const rendered = $decoratorRenderedText(decorator);\n const [lead] = trimmedTextRange(rendered);\n return rendered.slice(lead, lead + holdable.length) === holdable ? lead + index : \"drawn\";\n },\n};\nlet bytesReader = displayedBytesReader;\n/**\n * Set how the bytes a decorator stands for are read and where each is drawn. They depend on display\n * structure this package does not know (a verse's `\\va` tokens, an empty span's attributes), so the\n * package that does sets it once; until then, a decorator stands for what it displays, without edge\n * whitespace. The reader must be a pure function of the node. `undefined` restores that default.\n */\nexport function setDecoratorBytesReader(reader) {\n bytesReader = reader ?? displayedBytesReader;\n}\n/** The holdable bytes `decorator` stands for ({@link setDecoratorBytesReader}). */\nexport function $decoratorHoldableText(decorator) {\n return bytesReader.holdableText(decorator);\n}\n/**\n * Hold `type`/`id` on `node` over `[start, end)`, merged with any range of the same annotation it\n * overlaps or touches. On a decorator, `[start, end)` index the holdable bytes it stands for\n * ({@link $decoratorHoldableText}), shown or not, and `0, 0` holds it whole. Every other hold on\n * the node is kept exactly as stored. Mutating: call inside `editor.update()`.\n */\nexport function $addDisplayAnnotation(node, type, id, start, end) {\n let merged = { type, id, start, end };\n const others = [];\n for (const annotation of $storedAnnotations(node)) {\n if (sameAnnotation(annotation, type, id) &&\n annotation.start <= merged.end &&\n merged.start <= annotation.end)\n merged = {\n ...merged,\n start: Math.min(merged.start, annotation.start),\n end: Math.max(merged.end, annotation.end),\n };\n else\n others.push(annotation);\n }\n $writeAnnotations(node, [...others, merged]);\n}\n/** Drop every range of `type`/`id` from `node`; `true` when there was one. Mutating. */\nexport function $removeDisplayAnnotation(node, type, id) {\n const annotations = $storedAnnotations(node);\n const kept = annotations.filter((annotation) => !sameAnnotation(annotation, type, id));\n if (kept.length === annotations.length)\n return false;\n $writeAnnotations(node, kept);\n return true;\n}\n/** The text a display-byte node shows: its own text, except that a collapsed caller (a decorator\n * whose own text is empty) shows its note's caller. */\nexport function $decoratorDisplayText(node) {\n if (node.getType() !== IMMUTABLE_NOTE_CALLER_NODE_TYPE)\n return node.getTextContent();\n const note = node.getParent();\n return $isNoteNode(note) ? note.getCaller() : \"\";\n}\nfunction hasRenderedText(node) {\n return \"getRenderedText\" in node && typeof node.getRenderedText === \"function\";\n}\n/**\n * The text a display-byte decorator shows on screen — what its element's DOM text reads once\n * rendered. Empty for a decorator whose glyph CSS generates (a collapsed note's `+` caller) and for\n * any other node.\n */\nexport function $decoratorRenderedText(node) {\n if (!$isDecoratorNode(node) || !hasRenderedText(node))\n return \"\";\n const text = node.getRenderedText();\n return typeof text === \"string\" ? text : \"\";\n}\n/** Whitespace, or the zero-width space a verse number is padded with: bytes at the edge of a\n * glyph that name nothing. */\nfunction isEdgeFiller(char) {\n return char === ZWSP || /\\s/u.test(char);\n}\n/** The `[start, end)` of `text` without the whitespace and zero-width spaces at its edges;\n * `[0, 0]` when nothing else is left. */\nexport function trimmedTextRange(text) {\n let start = 0;\n while (start < text.length && isEdgeFiller(text[start]))\n start++;\n if (start === text.length)\n return [0, 0];\n let end = text.length;\n while (end > start && isEdgeFiller(text[end - 1]))\n end--;\n return [start, end];\n}\n/**\n * The bytes `annotation` (as {@link $displayAnnotationsOf} reads it) holds on `node`: its range of\n * the node's text, or of what a decorator renders; for a hold on bytes a decorator does not show,\n * those bytes; for a decorator held whole, the bytes it stands for (a collapsed note's caller, not\n * the `*` or nothing drawn for it), or what it renders when it stands for none.\n */\nexport function $coveredDisplayText(node, annotation) {\n if (annotation.undisplayed)\n return $decoratorHoldableText(node).slice(annotation.start, annotation.end);\n if (annotation.start !== annotation.end)\n return $carrierText(node).slice(annotation.start, annotation.end);\n const holdable = $decoratorHoldableText(node);\n if (holdable)\n return holdable;\n const rendered = $decoratorRenderedText(node);\n const [start, end] = trimmedTextRange(rendered);\n return rendered.slice(start, end);\n}\n/** The ids of `type` whose range on `node` holds the caret offset `offset`. */\nexport function $displayAnnotationIdsAt(node, type, offset) {\n return $displayAnnotationsOf(node)\n .filter((annotation) => annotation.type === type &&\n (annotation.undisplayed ||\n annotation.start === annotation.end ||\n (annotation.start <= offset && offset <= annotation.end)))\n .map((annotation) => annotation.id);\n}\n/**\n * Re-measure `node`'s annotations against its current storage text (a decorator's holdable bytes)\n * and store that text as their basis, so a range follows its bytes through typing, a sync rewrite, a split or\n * a collaborator's renumber, and a range its bytes left stays dropped. Idempotent. The body of the\n * node transform `registerDisplayAnnotationBasis` registers; mutating.\n */\nexport function $syncDisplayAnnotationBasis(node) {\n const held = $getState(node, displayAnnotationsState);\n if (!held || held.basis === $storageText(node))\n return;\n $writeAnnotations(node, remapped(held, $storageText(node)));\n}\nconst registrations = new WeakMap();\n/** A type or id may itself contain the NUL character a delimiter join would use, so the key is\n * JSON, not a joined string. */\nfunction registrationKey(type, id) {\n return JSON.stringify([type, id]);\n}\n/**\n * Record `type`/`id` for the active editor: callbacks given here replace the ones held. Call\n * inside an update or read of the editor.\n */\nexport function $registerDisplayAnnotation(type, id, callbacks) {\n const editor = $getEditor();\n let byKey = registrations.get(editor);\n if (!byKey) {\n byKey = new Map();\n registrations.set(editor, byKey);\n }\n const key = registrationKey(type, id);\n const previous = byKey.get(key);\n const defined = Object.fromEntries(Object.entries(callbacks).filter(([, callback]) => callback !== undefined));\n byKey.set(key, { ...previous, ...defined });\n}\nexport function getDisplayAnnotationRegistration(editor, type, id) {\n return registrations.get(editor)?.get(registrationKey(type, id));\n}\nexport function deleteDisplayAnnotationRegistration(editor, type, id) {\n registrations.get(editor)?.delete(registrationKey(type, id));\n}\n/**\n * Keep every carrier's ranges measured against its current text, so an annotation follows its\n * bytes the way a mark follows its text. `TextNode` covers attribute runs, a note's caller and a\n * chapter's glyph; `MarkerNode` and `VerseNode` register their own transforms, as do the\n * decorator carriers defined here and any in `decoratorKlasses` (those `shared-react` defines).\n * Returns the unregister function.\n *\n * Registering a transform marks every existing node of the class dirty once, so each mount runs\n * one extra pass over them (a decorator's is decorated again); `$syncDisplayAnnotationBasis`\n * reads no state for a node without carrier state and writes nothing, so the pass costs a tree\n * walk and nothing more.\n */\nexport function registerDisplayAnnotationBasis(editor, decoratorKlasses = []) {\n const klasses = [\n TextNode,\n MarkerNode,\n VerseNode,\n ImmutableTypedTextNode,\n ImmutableChapterNode,\n ...decoratorKlasses,\n ];\n const unregisters = klasses\n .filter((klass) => editor.hasNodes([klass]))\n .map((klass) => editor.registerNodeTransform(klass, $syncDisplayAnnotationBasis));\n return () => unregisters.forEach((unregister) => unregister());\n}\n","/**\n * Wrapping a selection in a `TypedMarkNode`, adapted from `$wrapSelectionInMarkNode` in\n * https://github.com/facebook/lexical/blob/92c47217244f9d3c22a59728633fb41a10420724/packages/lexical-mark/src/index.ts\n *\n * Kept apart from `TypedMarkNode.ts` because it reads display-run structure\n * (`attributeDisplay.utils.ts`), which itself imports `TypedMarkNode.ts`.\n */\nimport { $isAttributeRunNode } from \"../usj/AttributeRunNode.js\";\nimport { $charSeparatorPrefixLength } from \"../usj/markerSeparators.utils.js\";\nimport { $isMilestoneNode } from \"../usj/MilestoneNode.js\";\nimport { TYPED_MARK_WRAP_TAG } from \"../usj/node-constants.js\";\nimport { $isMarkerTrailingSeparator } from \"../usj/node.utils.js\";\nimport { $isVerseNode } from \"../usj/VerseNode.js\";\nimport { $addDisplayAnnotation, $carrierHoldableRange, $decoratorHoldableText, $isAttributeDisplayRun, $isDisplayAnnotationCarrier, $isElementOwnerRunAnchor, $registerDisplayAnnotation, } from \"./displayAnnotations.utils.js\";\nimport { $isImmutableUnmatchedNode } from \"./ImmutableUnmatchedNode.js\";\nimport { $isMarkerNode } from \"./MarkerNode.js\";\nimport { $createTypedMarkNode, $isTypedMarkNode, COMMENT_MARK_TYPE, } from \"./TypedMarkNode.js\";\nimport { $addUpdateTag, $isElementNode, $isTextNode } from \"lexical\";\n/**\n * Whether `node` is part of a display owner's unit: the owner's `AttributeRunNode` wrapper(s) and\n * anything inside one, together with what the run is found beside — a verse or milestone the\n * wrapper directly follows (`\\va 3\\va*`, `|who=\"Pilate\"`), or a note's caller or chapter's glyph\n * text ({@link $isElementOwnerRunAnchor}). The run belongs to its owner by position alone, so\n * moving either half into a mark without the other reads as the run having been deleted: the\n * display-run sync then removes a milestone, or writes a second run beside a caller. A verse and an\n * unmatched closer are also `TextNode`s, which the wrap would otherwise split like content.\n */\nfunction $isDisplayOwnerUnit(node) {\n return ($isVerseNode(node) ||\n $isMilestoneNode(node) ||\n $isAttributeRunNode(node) ||\n $isAttributeRunNode(node.getParent()) ||\n $isElementOwnerRunAnchor(node) ||\n $isImmutableUnmatchedNode(node));\n}\nfunction leafSize(node) {\n return $isTextNode(node) ? node.getTextContentSize() : 1;\n}\nfunction $firstLeaf(node) {\n let leaf = node;\n while ($isElementNode(leaf)) {\n const child = leaf.getFirstChild();\n if (!child)\n return leaf;\n leaf = child;\n }\n return leaf;\n}\nfunction $lastLeaf(node) {\n let leaf = node;\n while ($isElementNode(leaf)) {\n const child = leaf.getLastChild();\n if (!child)\n return leaf;\n leaf = child;\n }\n return leaf;\n}\n/**\n * The caret a selection point stands for. An element point `(E, i)` is in front of child `i`'s\n * first leaf, or behind E's last leaf when `i` is past its children — never a text offset.\n */\nfunction $caretOf(point) {\n const node = point.getNode();\n if (!$isElementNode(node))\n return { leaf: node, offset: $isTextNode(node) ? point.offset : Math.min(point.offset, 1) };\n const child = node.getChildAtIndex(point.offset);\n if (child)\n return { leaf: $firstLeaf(child), offset: 0 };\n const last = node.getLastChild();\n if (!last)\n return { leaf: node, offset: 0 };\n const leaf = $lastLeaf(last);\n return { leaf, offset: leafSize(leaf) };\n}\nfunction compareCarets(a, b) {\n if (a.leaf.is(b.leaf))\n return a.offset - b.offset;\n return a.leaf.isBefore(b.leaf) ? -1 : 1;\n}\n/** The `[from, to)` offsets of `leaf` the range from `start` to `end` covers (`from === to`: none). */\nfunction $coveredOffsets(leaf, start, end) {\n const size = leafSize(leaf);\n let from = size;\n if (start.leaf.is(leaf))\n from = start.offset;\n else if (start.leaf.isBefore(leaf))\n from = 0;\n let to = 0;\n if (end.leaf.is(leaf))\n to = end.offset;\n else if (leaf.isBefore(end.leaf))\n to = size;\n return [from, Math.max(from, to)];\n}\n/** The first leaf after `node` in document order, if any. */\nfunction $leafAfter(node) {\n for (let current = node; current; current = current.getParent()) {\n const sibling = current.getNextSibling();\n if (sibling)\n return $firstLeaf(sibling);\n }\n return undefined;\n}\n/**\n * Whether the range covers `element` from in front of its first leaf through behind its last.\n *\n * An element that ends with a separator (a collapsed note's layout does) counts as covered only\n * when the range also goes on past it: moved into a mark, the separator then sits between held\n * bytes. A range that stops at the element's end leaves it in place, since its mark would\n * otherwise end in a separator with nothing held beyond it.\n */\nfunction $coversWhole(element, start, end) {\n const first = $firstLeaf(element);\n const last = $lastLeaf(element);\n if (compareCarets(start, { leaf: first, offset: 0 }) > 0)\n return false;\n if (compareCarets(end, { leaf: last, offset: leafSize(last) }) < 0)\n return false;\n if ($isMarkerTrailingSeparator(last)) {\n const after = $leafAfter(element);\n if (!after || compareCarets(end, { leaf: after, offset: 0 }) <= 0)\n return false;\n }\n return true;\n}\n/**\n * The `[start, end)` bytes of carrier `node` the range from `start` to `end` covers, or\n * `undefined` when it covers none. A decorator is covered only when the range passes over it, and\n * its bytes are the holdable bytes it stands for (`$decoratorHoldableText`): the part `holds`\n * names, or all of them (whole, `[0, 0]`, when it stands for none). A text carrier's covered bytes\n * are clamped to its holdable range ({@link $carrierHoldableRange}), so a glyph's own edge\n * whitespace is never held.\n */\nfunction $coveredCarrierRange(node, start, end, holds) {\n if (!$isDisplayAnnotationCarrier(node))\n return undefined;\n const [from, to] = $coveredOffsets(node, start, end);\n if (to <= from)\n return undefined;\n if (!$isTextNode(node)) {\n const hold = holds?.get(node.getKey());\n if (hold)\n return [hold.start, hold.end];\n return [0, $decoratorHoldableText(node).length];\n }\n const [low, high] = $carrierHoldableRange(node);\n const clamped = [Math.max(from, low), Math.min(to, high)];\n return clamped[1] > clamped[0] ? clamped : undefined;\n}\nexport function $wrapSelectionInTypedMarkNode(selection, type, id, onClick, onRemove, onMouseEnter, onMouseLeave, options = {}) {\n // A collapsed range names no byte, so it holds nothing — not even the node beside it.\n if (selection.isCollapsed())\n return;\n const nodes = selection.getNodes();\n const isBackward = selection.isBackward();\n const [startPoint, endPoint] = isBackward\n ? [selection.focus, selection.anchor]\n : [selection.anchor, selection.focus];\n // Measured before the loop splits anything: `splitText` keeps the original key on the first\n // piece and ordering reads the live tree, so each caret keeps naming the same place.\n const startCaret = $caretOf(startPoint);\n const endCaret = $caretOf(endPoint);\n if (compareCarets(startCaret, endCaret) >= 0)\n return;\n let carrierAnnotated = false;\n const $annotateCarrier = (node) => {\n const covered = $coveredCarrierRange(node, startCaret, endCaret, options.decoratorHolds);\n if (!covered)\n return;\n // Tagged here, at the wrap's first actual mutation, never unconditionally at the top of the\n // function: an update's tags survive only as long as the commit that carries them changes a\n // node (see `CURSOR_CHANGE_TAG` in `node-constants.ts`), so a call that ends up covering no\n // byte must never add this tag, or it rides into the update's own selection-only commit and\n // then onto whatever the user's NEXT edit turns out to be.\n $addUpdateTag(TYPED_MARK_WRAP_TAG);\n $addDisplayAnnotation(node, type, id, covered[0], covered[1]);\n carrierAnnotated = true;\n };\n let currentNodeParent;\n let lastCreatedMarkNode;\n // We only want wrap adjacent text nodes, line break nodes and inline element nodes. For decorator\n // nodes and block element nodes, we step out of their boundary and start again after, if there\n // are more nodes.\n for (const node of nodes) {\n if ($isElementNode(lastCreatedMarkNode) && lastCreatedMarkNode.isParentOf(node)) {\n // If the current node is a child of the last created mark node, there is nothing to do here\n continue;\n }\n if ($isMarkerNode(node) ||\n $isMarkerTrailingSeparator(node) ||\n $isAttributeDisplayRun(node) ||\n $isDisplayOwnerUnit(node)) {\n // A display-byte node — a marker glyph, a separator, an attribute run's text, a display\n // owner or the text its run is anchored after — is never moved into a mark or split by one.\n //\n // A marker glyph is display bytes its construct owns, never annotated content: moving one\n // into a mark takes it out of the construct's own children, which the marker-edit engine\n // reads as the marker having been deleted (a char span or note loses its closer, a note its\n // opener) and settles by dissolving or deleting the construct. So end the current mark at\n // the glyph, and start any later content in a new one. Remember the glyph's parent, though:\n // it is the element the selection is inside, which must not then be wrapped whole.\n //\n // The engine-owned separator after a `\\p`, `\\tr` or `\\tc` glyph, and a collapsed note's\n // layout separators, are display bytes too. Moved into a mark, a separator no longer sits\n // where its glyph expects it, so the glyph reads as missing one and gets a second. (A char\n // span opener's separator is text, not a tagged node: the text case below leaves it out.)\n //\n // An attribute display run (`|grace`, `|who=\"Pilate\"`) is the same kind of bytes and gets\n // the same treatment, never split or moved: a mark over part of it splits its text node,\n // after which the display-run sync no longer recognizes the run and rebuilds it beside the\n // split-off piece — and the next settle reads both into the attribute's value.\n //\n // A display owner (or a run's anchor text) and its run wrapper are one unit: the selection\n // lists the wrapper ELEMENT before its children, so the glyph guard alone never sees it.\n // Neither half is ever moved or split, so the unit stays together outside the mark.\n //\n // The annotation is held ON the node instead (`displayAnnotationsState`), for the bytes the\n // selection covers on it; a separator holds nothing (see `$isDisplayAnnotationCarrier`).\n $annotateCarrier(node);\n currentNodeParent = node.getParent();\n lastCreatedMarkNode = undefined;\n continue;\n }\n let targetNode = null;\n if ($isTextNode(node)) {\n // Case 1: The node is a text node and we can split it\n const [from, to] = $coveredOffsets(node, startCaret, endCaret);\n // A char span opener's separator is the first byte of the text right after the glyph —\n // either the prefix of the span's first content text or, in front of a nested span, a\n // standalone NBSP spacer. That byte is the glyph's display, so the mark starts after it; a\n // spacer holds nothing else and stays out of the mark whole. Only that place qualifies: an\n // NBSP anywhere else in the span is content.\n const startTextOffset = Math.max(from, $charSeparatorPrefixLength(node));\n // A text node the range covers no byte of stays out of the mark: the range starts at its end\n // (a position in front of a verse or a closing glyph names the text before it), ends at its\n // start, or covers only the separator prefix. `splitText` never returns an empty piece, so\n // wrapping here would mark the whole node.\n if (startTextOffset >= to)\n continue;\n // Tagged here, at the split that is about to happen — see the tag's other call site below\n // for why it is never added unconditionally.\n $addUpdateTag(TYPED_MARK_WRAP_TAG);\n const splitNodes = node.splitText(startTextOffset, to);\n // `splitText` drops a cut at either end, so the covered piece is the second when the range\n // starts inside the node and the first otherwise.\n targetNode = splitNodes[startTextOffset > 0 ? 1 : 0];\n }\n else if ($isTypedMarkNode(node)) {\n // Case 2: the node is a mark node and we can ignore it as a target, moving on to its\n // children. Note that when we make a mark inside another mark, it may ultimately be un-nested\n // by a call to `registerNestedElementResolver` somewhere else in the\n // codebase.\n continue;\n }\n else if ($isElementNode(node) && node.isInline()) {\n // Case 3: an inline element moves into the mark whole only when the range covers all of it,\n // opening glyph through closing glyph (its opener's separator goes with it, between held\n // bytes). A range that starts or ends inside it leaves it in place: its listed content text\n // is wrapped piece by piece and its glyphs hold the annotation as carriers, so no byte the\n // range does not name is marked.\n if (!$coversWhole(node, startCaret, endCaret))\n continue;\n targetNode = node;\n }\n if (targetNode !== null) {\n // Now that we have a target node for wrapping with a mark, we can run through special cases.\n if (targetNode && targetNode.is(currentNodeParent)) {\n // The current node is a child of the target node to be wrapped, there is nothing to do\n // here. This is also why a range starting ON an inline element's opening glyph never moves\n // the element whole, even when the range covers it in full: the glyph branch above already\n // set `currentNodeParent` to the element, so this guard is true the moment Case 3 considers\n // the element itself as a target. The whole-element move and this glyph-start case hold the\n // same bytes either way; they are deliberately uneven in mark count, not a gap to close.\n continue;\n }\n // Tagged here too, for Case 3's whole-element move (Case 1 already tagged its own split\n // above; adding the tag again here is a no-op).\n $addUpdateTag(TYPED_MARK_WRAP_TAG);\n const parentNode = targetNode.getParent();\n if (parentNode == null || !parentNode.is(currentNodeParent)) {\n // If the parent node is not the current node's parent node, we can clear the last created\n // mark node.\n lastCreatedMarkNode = undefined;\n }\n currentNodeParent = parentNode;\n if (lastCreatedMarkNode === undefined) {\n lastCreatedMarkNode = $createTypedMarkNode();\n lastCreatedMarkNode.addID(type, id, onClick, onRemove, onMouseEnter, onMouseLeave);\n targetNode.insertBefore(lastCreatedMarkNode);\n }\n // Add the target node to be wrapped in the latest created mark node\n lastCreatedMarkNode.append(targetNode);\n }\n else {\n // A decorator or block element is never wrapped; a display-byte decorator holds the\n // annotation instead.\n $annotateCarrier(node);\n // If we don't have a target node to wrap we can clear our state and continue on with the next\n // node\n currentNodeParent = undefined;\n lastCreatedMarkNode = undefined;\n }\n }\n if (carrierAnnotated)\n $registerDisplayAnnotation(type, id, { onClick, onRemove, onMouseEnter, onMouseLeave });\n // Make selection collapsed at the end for comments.\n if (type === COMMENT_MARK_TYPE && $isElementNode(lastCreatedMarkNode)) {\n if (isBackward)\n lastCreatedMarkNode.selectStart();\n else\n lastCreatedMarkNode.selectEnd();\n }\n}\n","/** Conforms with USJ v3.1 table rows @see https://docs.usfm.bible/usfm/3.1/para/table.html */\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\n/** USJ marker type this node renders; the forward adaptor matches USJ input against it. */\nexport const TABLE_ROW_TYPE = \"table:row\";\nexport const IMMUTABLE_TABLE_ROW_TYPE = \"immutable-table-row\";\nexport const IMMUTABLE_TABLE_ROW_VERSION = 1;\nexport const TABLE_ROW_DEFAULT_MARKER = \"tr\";\n/** List of known properties of `MarkerObject` */\nexport const TABLE_ROW_MARKER_OBJECT_PROPS = [\"type\", \"marker\", \"content\"];\nexport class ImmutableTableRowNode extends ElementNode {\n __marker;\n __unknownAttributes;\n constructor(marker = TABLE_ROW_DEFAULT_MARKER, unknownAttributes, key) {\n super(key);\n this.__marker = marker;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return IMMUTABLE_TABLE_ROW_TYPE;\n }\n static clone(node) {\n return new ImmutableTableRowNode(node.__marker, node.__unknownAttributes, node.__key);\n }\n static importJSON(serializedNode) {\n return $createImmutableTableRowNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker ?? TABLE_ROW_DEFAULT_MARKER)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n return this.getLatest().__marker;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n return this.getLatest().__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(\"tr\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(\"table-row\", `usfm_${this.__marker}`);\n // A first-line indent is meaningful for a `\\tr` rendered as a BLOCK of text and meaningless\n // inside a real table, where it only drags content left. It reaches two places here: the cells\n // (reset by `.table-cell` in usj-nodes.css) and the row's own marker glyph, which — being the\n // only non-cell content of a
— the browser wraps in an ANONYMOUS table cell. That box has\n // no class to target, so a negative indent pulls the glyph clear outside the table.\n //\n // Inline rather than a stylesheet rule because a stylesheet rule cannot reliably win: a project\n // StyleInfo that gives `tr` a firstLineIndent emits `.editor-input.usfm .usfm_tr { text-indent }`\n // (generateUsjCss.ts), injected after the static sheet and at a specificity any reasonable\n // static selector ties at best. Paratext 9 resolves it the same way, stamping\n // `style=\"TEXT-INDENT: 0in\"` on every `
` it emits. Cells need nothing of their own: with the\n // row at zero they inherit zero.\n dom.style.textIndent = \"0\";\n return dom;\n }\n updateDOM(prevNode) {\n return prevNode.__marker !== this.__marker;\n }\n exportJSON() {\n const unknownAttributes = this.getUnknownAttributes();\n return {\n ...super.exportJSON(),\n type: IMMUTABLE_TABLE_ROW_TYPE,\n marker: this.getMarker(),\n ...(unknownAttributes !== undefined && { unknownAttributes }),\n version: IMMUTABLE_TABLE_ROW_VERSION,\n };\n }\n}\nexport function $createImmutableTableRowNode(marker, unknownAttributes) {\n return $applyNodeReplacement(new ImmutableTableRowNode(marker, unknownAttributes));\n}\nexport function $isImmutableTableRowNode(node) {\n return node instanceof ImmutableTableRowNode;\n}\nexport function isSerializedImmutableTableRowNode(node) {\n return node?.type === IMMUTABLE_TABLE_ROW_TYPE;\n}\n","/** Conforms with USJ v3.1 table cells @see https://docs.usfm.bible/usfm/3.1/para/table.html */\nimport { $applyNodeReplacement, ElementNode, } from \"lexical\";\n/** USJ marker type this node renders; the forward adaptor matches USJ input against it. */\nexport const TABLE_CELL_TYPE = \"table:cell\";\nexport const IMMUTABLE_TABLE_CELL_TYPE = \"immutable-table-cell\";\nexport const IMMUTABLE_TABLE_CELL_VERSION = 1;\nexport const TABLE_CELL_DEFAULT_MARKER = \"tc1\";\n/** List of known properties of a table cell `MarkerObject` */\nexport const TABLE_CELL_MARKER_OBJECT_PROPS = [\n \"type\",\n \"marker\",\n \"align\",\n \"colspan\",\n \"content\",\n];\n// USJ `align` is logical (start/center/end), which CSS `text-align` supports natively and mirrors\n// correctly under `dir` (RTL). Pass it straight through, ignoring unrecognized values, rather than\n// mapping to the physical left/right — that would flip alignment in RTL scripts.\nfunction toLogicalTextAlign(align) {\n return align === \"start\" || align === \"center\" || align === \"end\" ? align : undefined;\n}\nexport class ImmutableTableCellNode extends ElementNode {\n __marker;\n __align;\n __colspan;\n __unknownAttributes;\n constructor(marker = TABLE_CELL_DEFAULT_MARKER, align, colspan, unknownAttributes, key) {\n super(key);\n this.__marker = marker;\n this.__align = align;\n this.__colspan = colspan;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return IMMUTABLE_TABLE_CELL_TYPE;\n }\n static clone(node) {\n const { __marker, __align, __colspan, __unknownAttributes, __key } = node;\n return new ImmutableTableCellNode(__marker, __align, __colspan, __unknownAttributes, __key);\n }\n static importJSON(serializedNode) {\n return $createImmutableTableCellNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker ?? TABLE_CELL_DEFAULT_MARKER)\n .setAlign(serializedNode.align)\n .setColspan(serializedNode.colspan)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n return this.getLatest().__marker;\n }\n setAlign(align) {\n if (this.__align === align)\n return this;\n const self = this.getWritable();\n self.__align = align;\n return self;\n }\n getAlign() {\n return this.getLatest().__align;\n }\n setColspan(colspan) {\n if (this.__colspan === colspan)\n return this;\n const self = this.getWritable();\n self.__colspan = colspan;\n return self;\n }\n getColspan() {\n return this.getLatest().__colspan;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n return this.getLatest().__unknownAttributes;\n }\n createDOM() {\n const isHeader = this.__marker.startsWith(\"th\");\n const dom = document.createElement(isHeader ? \"th\" : \"td\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(\"table-cell\", `usfm_${this.__marker}`);\n const textAlign = toLogicalTextAlign(this.__align);\n if (textAlign)\n dom.style.textAlign = textAlign;\n if (this.__colspan)\n dom.setAttribute(\"colspan\", this.__colspan);\n return dom;\n }\n updateDOM(prevNode) {\n // Recreate the DOM element when marker, align, or colspan changes.\n return (prevNode.__marker !== this.__marker ||\n prevNode.__align !== this.__align ||\n prevNode.__colspan !== this.__colspan);\n }\n exportJSON() {\n const align = this.getAlign();\n const colspan = this.getColspan();\n const unknownAttributes = this.getUnknownAttributes();\n return {\n ...super.exportJSON(),\n type: IMMUTABLE_TABLE_CELL_TYPE,\n marker: this.getMarker(),\n ...(align !== undefined && { align }),\n ...(colspan !== undefined && { colspan }),\n ...(unknownAttributes !== undefined && { unknownAttributes }),\n version: IMMUTABLE_TABLE_CELL_VERSION,\n };\n }\n}\nexport function $createImmutableTableCellNode(marker, align, colspan, unknownAttributes) {\n return $applyNodeReplacement(new ImmutableTableCellNode(marker, align, colspan, unknownAttributes));\n}\nexport function $isImmutableTableCellNode(node) {\n return node instanceof ImmutableTableCellNode;\n}\nexport function isSerializedImmutableTableCellNode(node) {\n return node?.type === IMMUTABLE_TABLE_CELL_TYPE;\n}\n","const applyingByEditor = new WeakMap();\n/**\n * Mark `editor` as committing an update applied from `source`, or as not applying one\n * (`undefined`). Set it inside a DISCRETE update and clear it once that commit lands (its\n * `onUpdate`) or the update throws, so it covers exactly that commit's transforms and listeners.\n */\nexport function markApplyingUpdate(editor, source) {\n if (source)\n applyingByEditor.set(editor, source);\n else\n applyingByEditor.delete(editor);\n}\n/** Where the update `editor` is committing was applied from, or `undefined` when it is not\n * committing an applied update (see {@link markApplyingUpdate}). */\nexport function getApplyingUpdateSource(editor) {\n return applyingByEditor.get(editor);\n}\n","/**\n * Caret positions at a content boundary: the single place that owns HOW a boundary between an\n * element's children becomes a Lexical caret position, and WHICH node renders the caret there. A\n * \"boundary\" is the location just before a parent's child at some index — the location the child\n * count itself names being the end of the parent's content.\n *\n * Every path that parks a caret at the start of some content answers this same question, and each\n * one used to answer it by hand: the para-marker prefix cursor guard, the marker-edit prefix\n * injection, verse-start placement, and the `\\fp` visual-line hop. The empty-verse caret guard asks\n * the other half of it — whether a boundary has a host at all — because that is exactly the state it\n * exists to repair.\n *\n * ## The convention\n *\n * - **A boundary is hosted by the text node that FOLLOWS it**, and a text point at that node's\n * offset 0 is the caret position — not the end of whatever text precedes the boundary, and not the\n * element point, even when a text node sits on both sides. The reason is what the caller is doing:\n * it has chosen a boundary because the content AFTER it is where the user's next keystroke\n * belongs, and at these boundaries what precedes is structure — a paragraph's marker glyph, its\n * token-mode separator, a verse marker — that typed text must never merge into.\n * - **The element point is the fallback, and it renders no caret of its own.** Where the following\n * child is a decorator (an immutable verse or chapter number, an immutable marker glyph) or where\n * there is no child at all, the boundary can only be expressed as an element point, and the\n * browser draws nothing at it. That is not a failure of this module — it is the condition\n * `EmptyVerseCaretGuardPlugin` detects with {@link $caretHostAtBoundary} and repairs by\n * materializing a text node to host the caret.\n * - **Hosting is a question about the TREE, not about the view.** A `MarkerNode` is a `TextNode`\n * subclass, so an editable-mode marker glyph hosts a caret exactly as content text does. That is\n * why one implementation serves every marker mode: it never asks which nodes are visible, only\n * which node can carry a text point.\n *\n * ## What this module does NOT own\n *\n * WHICH boundary is the legal one. That rule is genuinely different in each caller, and deliberately\n * different per marker mode, so it is stated at each site rather than merged here:\n *\n * - `$guardCursorAtParaStart` (shared-react) rules that a click may not come to rest before or\n * inside a paragraph's structural prefix, and advances FORWARD past it. It runs in every marker\n * mode — it is what stops a click in the hanging-indent gutter of `\\li`/`\\ili`/poetry from landing\n * before the marker — and its prefix scan therefore enumerates both marker flavors.\n * - `ArrowNavigationPlugin`'s visible-stop canonicalizer picks, among the tree positions sharing one\n * screen location, the outermost and earliest: the end of the nearest PRECEDING visible text — the\n * opposite preference to this module's, and correct there, because what precedes an arrow landing\n * is rendered content the caret just walked over rather than structure. It is also scoped to\n * markerMode \"editable\", where the display runs and glyph text that stack those positions exist at\n * all. Merging the two preferences would be a behavior change in both directions.\n * - `$selectParaContentStart` (platform's marker-edit paths) knows its paragraphs have the fixed\n * editable-mode `[glyph, separator, …content]` shape and names boundary 2 outright, where\n * `$advancePastParaPrefixes` scans for its boundary. Same convention, different way of finding the\n * index — which is precisely the part that is not shareable.\n *\n * Nor the mirror question, the caret position at the END of a node: `$placeCaretAtEnd`\n * (shared-react's structureKeyboard.utils.ts) owns that for the delete/merge paths, and it descends\n * into the node rather than resting at a boundary between children.\n */\nimport { $isTextNode } from \"lexical\";\n/**\n * The text node hosting a caret at the boundary before `parent`'s child at `index`, or `undefined`\n * when nothing there can carry a text point — a decorator child, or a boundary past the last child.\n *\n * Deliberately forward-looking: text preceding the boundary occupies the same screen location at its\n * own end, but it is not what this answers. See the module's convention.\n *\n * Read-only: safe to call from a read or an update. A caller placing a caret directly after a verse\n * marker must handle an EDITABLE next verse marker itself — it is a text node, so it is returned\n * here as the host, which puts the caret in the next verse's marker node (at the same screen\n * location as the end of this verse's marker).\n *\n * @param parent - The element whose children the boundary lies between.\n * @param index - The boundary: the index of the child that follows it.\n */\nexport function $caretHostAtBoundary(parent, index) {\n const child = parent.getChildAtIndex(index);\n return $isTextNode(child) ? child : undefined;\n}\n/**\n * Collapse the caret to the boundary before `parent`'s child at `index`: offset 0 of the text node\n * hosting it, or the element point when nothing hosts it.\n *\n * Mutating: call inside `editor.update()`. Like `$caretHostAtBoundary`, it selects offset 0 of an\n * editable next verse marker when one follows the boundary, so a caller placing a caret directly\n * after a verse marker must handle that case itself.\n *\n * @param parent - The element whose children the boundary lies between.\n * @param index - The boundary: the index of the child that follows it.\n */\nexport function $placeCaretAtBoundary(parent, index) {\n const host = $caretHostAtBoundary(parent, index);\n if (host)\n host.select(0, 0);\n else\n parent.select(index, index);\n}\n","/**\n * Char-span glyph shape: the single place that owns WHETHER a char span carries an opening and a\n * closing glyph, and HOW a fresh span's pair is built. Sibling of nestedGlyphs.utils.ts (the `+` a\n * nested span's glyphs carry), markerSeparators.utils.ts (the NBSP between an opening glyph and its\n * content), and attributeDisplay.utils.ts (the `|name=\"value\"` run) — between them those three own\n * everything about a rendered char glyph EXCEPT whether there is one at all, which is this module.\n *\n * ## The conventions\n *\n * - **Glyphs are markerMode \"editable\" presentation.** A `MarkerNode` exists only there — \"visible\"\n * mode renders `ImmutableTypedTextNode` byte runs instead and \"hidden\" mode renders no glyph at\n * all — so a builder that fabricates one unconditionally puts literal `\\ft ` text (and its\n * separator NBSP) into the content of a document that displays no glyphs, where it is visible in\n * the span's text content and wrong on serialization. Callers that can run outside editable mode\n * pass `renderGlyphs` false. It is a plain boolean rather than `ViewOptions` because that type\n * lives in `shared-react`, which this package must not depend on.\n * - **Closer display keys on the span's STATE, never on its marker family**\n * ({@link $charOwesClosingGlyph}): a span renders a closing glyph iff it does NOT carry\n * `closed=\"false\"`. ParatextData stamps that flag on every genuinely-unclosed span — chiefly\n * footnote/cross-reference content chars (`\\fr`, `\\ft`, `\\xo`, `\\xt`), which the next bare marker\n * closes — so those render closer-less, while an explicitly-closed `\\xt` keeps its `\\xt*`. The\n * same state decides whether a missing closer is deletion damage (`$charNodeDeletionTransform`)\n * and whether an attribute run may exist at all (attributeDisplay.utils.ts).\n * - **A span CONTINUING another reproduces that span's shape**, not the convention's default\n * ({@link $buildContinuationCharSpan}): the PT9 close-and-reopen (`$liftOutOfChar`) and the\n * Ctrl+Space-style split (`$splitCharNodeAt`) both build a right-hand span keeping the source's\n * marker, nesting, and `closed` state, and take its closing glyph from the source's actual\n * CHILDREN ({@link $charHasClosingGlyph}) rather than from that state — the tree is what says\n * which glyphs this document renders, so a mode with no glyphs reopens with none.\n *\n * ## What this module does NOT own\n *\n * Only the shape of a span BUILT here. Keeping an existing span's glyphs honest afterwards belongs\n * to the syncs and the marker-edit engine: `$syncNestedGlyphs` re-derives the `+`,\n * `$syncOpenerSeparators` heals the separator, `$charNodeDeletionTransform` reads a missing\n * opener/closer as deletion damage, and the Tier-1 rename engine retargets a live pair. Nor are\n * these the only glyph MATERIALIZATIONS: the load adaptor's `createChar`/`addOpeningMarker`/\n * `addClosingMarker` build the same shape as SERIALIZED nodes, the collab materializer builds it\n * for \"visible\" mode as `ImmutableTypedTextNode`s, and `CharNode`'s `applyMarkerToDom` writes the\n * marker onto the rendered DOM. Each is a different layer with its own node kinds; this module is\n * the live-`MarkerNode` one, and states the conventions the others follow.\n */\nimport { $createMarkerNode, $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { $insertOwedOpenerSpacer, $isSeparatorPrefixHostText } from \"./markerSeparators.utils.js\";\nimport { $isNestedCharNode } from \"./nestedGlyphs.utils.js\";\nimport { NBSP } from \"./node-constants.js\";\n/**\n * Whether `char` owes a closing glyph — the implicit-close convention read from the span's own\n * state: everything closes except a span explicitly marked `closed=\"false\"`. This is the rule for\n * whether a closer SHOULD exist; {@link $charHasClosingGlyph} is the separate question of whether\n * one actually does.\n */\nexport function $charOwesClosingGlyph(char) {\n return char.getUnknownAttributes()?.closed !== \"false\";\n}\n/**\n * Whether `char` currently renders a closing glyph — a direct-child `MarkerNode` with closing\n * syntax. Outside markerMode \"editable\" a span has no glyph children at all, so this is also the\n * tree's answer to \"does this document display glyphs for this span\".\n *\n * Deliberately marker-AGNOSTIC, unlike `$charClosingGlyph` (attributeDisplay.utils.ts), which\n * requires the glyph to name `char`'s own marker because it must anchor `char`'s own attribute run\n * and the collab-flattened shape parks a nested child span's glyphs among the same children. Here\n * the question is only whether the span was built with a closer to reproduce.\n */\nexport function $charHasClosingGlyph(char) {\n return char\n .getChildren()\n .some((child) => $isMarkerNode(child) && child.getMarkerSyntax() === \"closing\");\n}\n/**\n * The unknown attributes a span continuing `char` must be created with: `closed=\"false\"` when\n * `char` carries the implicit-close convention, otherwise none.\n *\n * `closed` is structural state, not attribute bytes — an implicitly-closed span splits into TWO\n * implicitly-closed spans, and without the flag the continuation's (correct) missing closer reads\n * as deletion damage and gets routed through Tier 2. The DISPLAY attributes (`|name=\"value\"`) are\n * deliberately not copied: they stay on the left half only, since duplicating them would double\n * those bytes on serialization.\n */\nexport function $continuationCharAttributes(char) {\n return $charOwesClosingGlyph(char) ? undefined : { closed: \"false\" };\n}\n/**\n * Fill `span` — a freshly created, not-yet-inserted char span continuing `source` — with `content`\n * and the glyphs that content is owed. The caller creates `span` (with `source`'s marker and\n * {@link $continuationCharAttributes}) and inserts it; this decides its shape:\n *\n * - an opening glyph, first, only when `renderGlyphs` — the document has to display glyphs at all;\n * - the separator NBSP on `content`'s leading text, only when an opening glyph was emitted, since\n * the NBSP is the separator BETWEEN the glyph and the content it opens (markerSeparators.utils.ts);\n * - a closing glyph, last, only when `source` itself renders one ({@link $charHasClosingGlyph});\n * - the `+` on both glyphs when `source` is nested ({@link $isNestedCharNode}) — the continuation\n * becomes `source`'s sibling, so it inherits `source`'s nesting.\n *\n * @param span - The continuation span to fill. Must be empty; must be called inside `editor.update()`.\n * @param source - The span being continued, read for marker, nesting, and closing-glyph shape.\n * @param content - The nodes moving into `span`, in order. May be empty.\n * @param renderGlyphs - Whether this document displays char glyphs (markerMode \"editable\").\n */\nexport function $buildContinuationCharSpan(span, source, content, renderGlyphs) {\n const marker = source.getMarker();\n const nested = $isNestedCharNode(source);\n const hasCloser = $charHasClosingGlyph(source);\n const opener = renderGlyphs ? $createMarkerNode(marker, \"opening\", nested) : undefined;\n if (opener) {\n span.append(opener);\n // Plain-text-first content carries the separator as its prefix — the same host predicate the\n // separator sync uses ($isSeparatorPrefixHostText): TextNode SUBCLASSES (VerseNode,\n // ImmutableUnmatchedNode, MarkerNode) render their own marker bytes and attribute runs are\n // engine-owned canonical output, so splicing an NBSP into either rewrites a glyph or corrupts\n // the run. Everything else takes a standalone NBSP spacer, added once the content is in.\n const [firstContent] = content;\n if ($isSeparatorPrefixHostText(firstContent) && !firstContent.getTextContent().startsWith(NBSP))\n firstContent.setTextContent(NBSP + firstContent.getTextContent());\n }\n span.append(...content);\n if (opener)\n $insertOwedOpenerSpacer(opener, span);\n if (hasCloser)\n span.append($createMarkerNode(marker, \"closing\", nested));\n}\n","/**\n * The character-style STACK: closing every char span open at a point and reopening the ones that\n * still have content after it. Sibling of charGlyphs.utils.ts, which owns the shape of each span\n * this module builds.\n *\n * ## Why one primitive\n *\n * Paratext 9 has no bespoke algorithm for this. Its `StyleApplicator` closes the open character\n * styles before the point and reopens the still-active ones after it, and every operation that\n * interrupts styled text — applying a non-nesting style, an unformatted space, a footnote-paragraph\n * break, a paragraph split — is the same close-and-reopen with a different thing placed in the gap.\n * Reimplemented per caller, that operation came out right in one place and wrong in four.\n *\n * ## Ordering falls out of the loop, not out of ordering code\n *\n * {@link $liftOutOfChar} closes the ONE span holding the node and reopens a continuation after it.\n * {@link $liftOutOfCharStack} iterates that outwards. Each iteration's continuation lands in the\n * next iteration's \"content after the node\" set, so the closers emerge innermost-to-outermost and\n * the openers outermost-to-innermost with no explicit ordering step:\n *\n * ```\n * \\wj \\+nd thing\\+nd*\\wj* -> \\wj \\+nd thi\\+nd*\\wj* \\wj \\+nd ng\\+nd*\\wj*\n * ```\n *\n * PT9 gets the reopen order WRONG for nested styles — its reopen loop walks the style list\n * innermost-first and emits index 0 without the `+`, so a two-deep stack comes back with the\n * markers swapped. That path has no PT9 test coverage. We port the intent, not the code.\n */\nimport { $createMarkerNode, $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { $buildContinuationCharSpan, $charOwesClosingGlyph, $continuationCharAttributes, } from \"./charGlyphs.utils.js\";\nimport { $createCharNode, $isCharNode } from \"./CharNode.js\";\nimport { $charSeparatorPrefixLength, $insertOwedOpenerSpacer, $isSeparatorPrefixHostText, } from \"./markerSeparators.utils.js\";\nimport { $isNestedCharNode } from \"./nestedGlyphs.utils.js\";\nimport { canonicalAttributeText } from \"./attributeDisplay.utils.js\";\nimport { textTypeState } from \"../collab/delta.state.js\";\nimport { defaultMarkerAttribute } from \"../../converters/usfm/usfmFragmentToUsj.js\";\nimport { NBSP } from \"./node-constants.js\";\nimport { $findMatchingParent } from \"@lexical/utils\";\nimport { $createTextNode, $getState, $isElementNode, $isTextNode } from \"lexical\";\n/**\n * The innermost char span a point sits in: the nearest `CharNode` at or above `node`, or\n * `undefined` when the point is not inside one.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $innermostCharAncestor(node) {\n return $findMatchingParent(node, $isCharNode) ?? undefined;\n}\n/**\n * Where a lifted node comes to rest: the nearest non-char ancestor of `node` — the note or\n * paragraph a bare marker would land in. Returns `node`'s own parent when `node` is not inside a\n * char span at all.\n *\n * Deliberately NOT delegated to `$findMatchingParent`: for a root-level char span the resting\n * place is the RootNode itself, which `$findMatchingParent` never yields (it stops before testing\n * the root).\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $charStackContainer(node) {\n let parent = node.getParent();\n while ($isCharNode(parent))\n parent = parent.getParent();\n return parent;\n}\n/**\n * Whether `char` holds no CONTENT — only its own glyphs and the structural NBSP separator those\n * glyphs own (markerSeparators.utils.ts). Such a span serializes to `\\nd \\nd*`: a marker pair\n * around nothing, which is not what the user asked for when a close-and-reopen happened to land at\n * a run's edge. A genuine space is content and does NOT make a span empty — only the NBSP does.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nexport function $isCharContentEmpty(char) {\n // The display run is a rendering of the span's attribute state, not content — a span holding\n // nothing but its own `|name=\"value\"` bytes has had its content taken away and is empty. Only a\n // span that closes explicitly can own a run at all ({@link $ownsDisplayRun}); inside an\n // implicitly-closed one, `attribute`-tagged text is ordinary content.\n const ownsDisplayRun = $ownsDisplayRun(char);\n return char\n .getChildren()\n .every((child) => $isMarkerNode(child) ||\n (ownsDisplayRun && $getState(child, textTypeState) === \"attribute\") ||\n ($isTextNode(child) && child.getTextContent().replaceAll(NBSP, \"\") === \"\"));\n}\n/**\n * Whether `char` can own a display run at all. The run is anchored to the closing glyph, and a\n * `closed=\"false\"` span renders neither (attributeDisplay.utils.ts), so inside one — note content,\n * chiefly — `attribute`-tagged text is not a run but ordinary content.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nfunction $ownsDisplayRun(char) {\n return $charOwesClosingGlyph(char);\n}\n/**\n * Remove `char`, leaving its attribute bytes behind as plain text after `contentEnd` when it has\n * any. Paratext 9 keeps an unwrapped span's attributes as literal bytes, and the span is the only\n * thing that carried them — dropping it silently would delete `|lemma=\"grace\"` from the file.\n * Routed through {@link canonicalAttributeText}, the same one serializer `$unwrapCharNode` uses, so\n * the two paths cannot spell the same attributes differently: a lone default attribute collapses to\n * `|value`, anything else stays `|name=\"value\" …`.\n *\n * Mutating: call inside `editor.update()`.\n */\nfunction $removeCharKeepingAttributeBytes(char, contentEnd) {\n const attributes = char.getUnknownAttributes();\n const bytes = attributes\n ? canonicalAttributeText(attributes, defaultMarkerAttribute(char.getMarker()))\n : \"\";\n if (bytes !== \"\")\n contentEnd.insertAfter($createTextNode(bytes));\n char.remove();\n}\n/**\n * Leave `char` EXPLICITLY closed: drop the `closed=\"false\"` convention it was carrying and, where\n * this document renders glyphs, give it the closing glyph that state now owes. Already-explicit\n * spans are untouched.\n *\n * The state is the load-bearing half — it is what serializes — and the glyph follows it, the same\n * pairing `$charOwesClosingGlyph` reads everywhere else. Leaving one without the other makes the\n * marker-edit engine read the mismatch as deletion damage.\n *\n * Mutating: call inside `editor.update()`.\n */\nfunction $closeCharExplicitly(char, renderGlyphs) {\n if ($charOwesClosingGlyph(char))\n return;\n const attributes = char.getUnknownAttributes();\n if (attributes) {\n const rest = { ...attributes };\n delete rest.closed;\n char.setUnknownAttributes(Object.keys(rest).length > 0 ? rest : undefined);\n }\n if (renderGlyphs)\n char.append($createMarkerNode(char.getMarker(), \"closing\", $isNestedCharNode(char)));\n}\n/**\n * Whether writing `node`'s own opening marker is ITSELF how `char` ends, so there is nothing to\n * close and nothing to reopen.\n *\n * True when both spans close implicitly — the `closed=\"false\"` convention ParatextData stamps on\n * note-content and cross-reference markers (`\\ft`, `\\fq`, `\\fr`, `\\fp`, `\\xt`, …), which are\n * terminated by the next bare marker rather than by an end marker. Putting `\\fq` at a caret inside\n * `\\ft` therefore emits no `\\ft*` and no reopened `\\ft`: the remainder of `\\ft`'s content simply\n * belongs to `\\fq` now.\n *\n * False whenever either side closes explicitly. An explicitly-closed `char` (`\\wj`) must emit its\n * `\\wj*` and reopen afterwards, because the new marker cannot terminate it; and an\n * explicitly-closed `node` (`\\add`) ends at its own `\\add*`, so `char`'s remaining content is not\n * part of it and does need reopening.\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nfunction $endsImplicitly(node, char) {\n return $isCharNode(node) && !$charOwesClosingGlyph(node) && !$charOwesClosingGlyph(char);\n}\n/**\n * Move `content` into `span`, which is a freshly built, still content-less marker taking over the\n * remainder of the span it just ended ({@link $endsImplicitly}). Any placeholder the builder gave\n * `span` is dropped so the moved nodes become its real content, and a leading text run takes the\n * structural separator the opening glyph owes it (markerSeparators.utils.ts) — the same shape\n * {@link $buildContinuationCharSpan} gives a reopened clone.\n *\n * Mutating: call inside `editor.update()`.\n */\nfunction $absorbIntoCharSpan(span, content, renderGlyphs) {\n if ($isCharContentEmpty(span))\n span.getChildren().forEach((child) => {\n if (!$isMarkerNode(child))\n child.remove();\n });\n // Only PLAIN leading text takes the separator as its prefix — the same host predicate the\n // separator sync uses ($isSeparatorPrefixHostText): TextNode subclasses (VerseNode,\n // ImmutableUnmatchedNode) render their own marker bytes and attribute runs are engine-owned\n // canonical output, so splicing an NBSP into either rewrites a glyph or corrupts the run.\n // Everything else gets a standalone spacer once it is in.\n const [first] = content;\n if (renderGlyphs && $isSeparatorPrefixHostText(first) && !first.getTextContent().startsWith(NBSP))\n first.setTextContent(NBSP + first.getTextContent());\n span.append(...content);\n const opener = span.getFirstChild();\n if (renderGlyphs && $isMarkerNode(opener) && opener.getMarkerSyntax() === \"opening\")\n $insertOwedOpenerSpacer(opener, span);\n}\n/**\n * Lift `node` OUT of the char span `char` to `char`'s parent, splitting `char` around it: content\n * before `node` stays in `char` (its \"before\" half), content after `node` moves to a fresh reopened\n * clone inserted after `node`, and `node` itself becomes a sibling of `char`. A half left with no\n * content ({@link $isCharContentEmpty}) is dropped rather than serialized as an empty marker pair.\n * The reopened clone keeps `char`'s marker, closer convention, and nesting (its glyphs carry the\n * `+` when `char` was itself nested).\n *\n * The one shape with no reopened clone is a `node` that ends `char` implicitly\n * ({@link $endsImplicitly}): there the content after `node` moves INTO it instead.\n *\n * An implicitly-closed `char` is left EXPLICITLY closed when `options.closeImplicitSpans` says the\n * gap cannot terminate it — see {@link CharStackLiftOptions}, which also documents `renderGlyphs`.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $liftOutOfChar(node, char, options) {\n const { renderGlyphs, closeImplicitSpans = false } = options;\n // Content strictly after `node`. Two kinds of child stay behind rather than move: `char`'s own\n // closing glyph, which terminates the \"before\" half (the clone gets a fresh one of its own), and\n // its display run — the `|name=\"value\"` bytes are a rendering of `char`'s OWN attribute state,\n // which stays on `char` (`$continuationCharAttributes` deliberately does not copy it, since\n // duplicating it would double those bytes on serialization). Carrying the bytes to the clone\n // left the attributes displayed on a span that does not have them and missing from the span that\n // does — the same content-versus-presentation split `$unwrapCharNode` makes.\n //\n // Only a span that closes EXPLICITLY can own a display run ({@link $ownsDisplayRun}). So inside\n // an implicitly-closed one — note content, chiefly — `attribute`-tagged text is not a run and is\n // ordinary content that must ride along with everything else after the caret.\n const ownsDisplayRun = $ownsDisplayRun(char);\n const after = [];\n for (let sibling = node.getNextSibling(); sibling;) {\n const next = sibling.getNextSibling();\n const isCloser = $isMarkerNode(sibling) && sibling.getMarkerSyntax() === \"closing\";\n const isDisplayRun = ownsDisplayRun && $getState(sibling, textTypeState) === \"attribute\";\n if (!isCloser && !isDisplayRun)\n after.push(sibling);\n sibling = next;\n }\n const endsImplicitly = $endsImplicitly(node, char);\n char.insertAfter(node); // node leaves char, becomes its next sibling\n // Where whatever came out of `char` ends, so a dropped span's attribute bytes land after its\n // former content rather than in front of it.\n let contentEnd = node;\n if (after.length > 0) {\n if (endsImplicitly) {\n $absorbIntoCharSpan(node, after, renderGlyphs);\n }\n else {\n const right = $createCharNode(char.getMarker(), $continuationCharAttributes(char));\n $buildContinuationCharSpan(right, char, after, renderGlyphs);\n node.insertAfter(right);\n if ($isCharContentEmpty(right))\n right.remove();\n else\n contentEnd = right;\n }\n }\n // The gap cannot terminate `char` on its own, so an implicitly-closed one has to be closed for\n // real: `\\ft` runs to the next note marker or `\\f*`, and anything merely placed after its\n // content would re-read as more of that content. Done AFTER the continuation is built, which\n // takes its own closing glyph from `char`'s children — the continuation reopens implicitly, as\n // the span it continues did.\n if (closeImplicitSpans && !endsImplicitly)\n $closeCharExplicitly(char, renderGlyphs);\n if ($isCharContentEmpty(char))\n $removeCharKeepingAttributeBytes(char, contentEnd);\n}\n/**\n * Lift `node` out of EVERY char span enclosing it, closing each on the way out and reopening the\n * ones with content after it — the whole close-and-reopen. `node` comes to rest in the nearest\n * non-char container ({@link $charStackContainer}), carrying with it the content of any span it\n * ended implicitly on the way ({@link $endsImplicitly}).\n *\n * Callers that place something in the gap (an unformatted space, a new non-nesting char span, a\n * paragraph-split marker) insert it at the caret first and lift THAT; the caret point they want\n * afterwards differs per caller, so this function deliberately does not move the selection.\n *\n * @param node - The node to lift. Must already be attached at the point the gap belongs.\n * @param options - How the gap is treated; see {@link CharStackLiftOptions}.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $liftOutOfCharStack(node, options) {\n let parent = node.getParent();\n while ($isCharNode(parent)) {\n $liftOutOfChar(node, parent, options);\n parent = node.getParent();\n }\n}\n/**\n * Put the caret at the START of `node`'s content — immediately after the structural separator the\n * opening glyph owns, and descending through nested spans to the innermost one. This is where\n * typing belongs after a close-and-reopen: the user interrupted the text at that point, so the\n * next keystroke continues the reopened run rather than landing outside it. Offset 0 would sit\n * BEFORE the separator, splicing typed text between the glyph and the space it owns.\n *\n * Mutating (moves the selection): call inside `editor.update()`.\n */\nexport function $selectCharContentStart(node) {\n if ($isTextNode(node) && !$isMarkerNode(node)) {\n const offset = $charSeparatorPrefixLength(node);\n node.select(offset, offset);\n return;\n }\n if ($isElementNode(node)) {\n // A standalone separator spacer in front of more content (a nested span, an annotation mark)\n // is the glyph's, not content: the content starts behind it.\n const content = node.getChildren().filter((child) => !$isMarkerNode(child));\n const first = content.find((child, index) => index === content.length - 1 || !$isTextNode(child) || child.getTextContent() !== NBSP);\n if (first) {\n $selectCharContentStart(first);\n return;\n }\n node.selectEnd(); // defensive: glyphs only, no content to sit in front of\n }\n}\n","/**\n * The shared display-run drivers: ONE self-healing sync transform and ONE caret-held reporter,\n * both parameterized by a {@link DisplayRunDescriptor}. Every engine-owned display kind runs\n * through these, so the four duties (construct, self-heal-with-grace, pend-on-edit/delete,\n * settle-on-departure) cannot diverge per kind.\n *\n * Descriptor INSTANCES live one layer up (displayRun/displayRunRegistry.ts) because they need the\n * converters; taking a descriptor as a parameter keeps these drivers importable from anywhere in\n * `nodes/usj`.\n */\nimport { $createAttributeRunNode } from \"./AttributeRunNode.js\";\nimport { getApplyingUpdateSource } from \"./applyingUpdate.utils.js\";\nimport { $isDescendantOf } from \"./node.utils.js\";\nimport { $isDisplayOwnerPended, $reportDestroyedDisplayOwner, } from \"./pendedDisplayOwners.utils.js\";\nimport { $createMarkerNode } from \"../features/MarkerNode.js\";\nimport { textTypeState } from \"../collab/delta.state.js\";\nimport { $createTextNode, $getEditor, $getNodeByKey, $getSelection, $isRangeSelection, $isTextNode, $setState, } from \"lexical\";\n/** Whether any piece of the run is currently in the tree. */\nfunction runHasPieces(pieces) {\n return Boolean(pieces.opener || pieces.value || pieces.closer || pieces.wrapper);\n}\n/**\n * Whether any of the run's BYTE pieces — opener, value, closer — is currently in the tree. A\n * surviving `AttributeRunNode` wrapper alone does not count: an emptied wrapper is the transient\n * husk `$clearRun` deliberately leaves behind, not displayed bytes. Destruction detection reads\n * THIS predicate, so deleting a wrapped run's visible bytes reports the owner even when the\n * deletion left the husk standing ({@link runHasPieces} would see the husk and call the run\n * alive, and the sync would then resurrect bytes the user just deleted).\n */\nfunction runHasByteContent(pieces) {\n return Boolean(pieces.opener || pieces.value || pieces.closer);\n}\n/**\n * Whether a display kind's canonical value bytes OPEN with the structural whitespace separator\n * that stands between a marker and its value (`\\va` + NBSP + `2`, `\\cat` + NBSP + `People`).\n * Kinds whose value carries no such separator — a char span's `|…` attribute bytes, an optbreak's\n * `//` token — are outside the licence {@link valueDiverges} grants and compare byte-for-byte.\n */\nfunction opensWithSeparator(text) {\n return /^\\s/.test(text);\n}\n/**\n * Whether the run's DISPLAYED value bytes diverge from the ones the owner's own state calls for.\n *\n * Whitespace FLANKING the value is not a divergence for a kind whose canonical bytes carry a\n * separator ({@link opensWithSeparator}). Whitespace between an attribute marker and its value is\n * structural: the writer emits exactly one separator space whatever the screen shows, so those\n * bytes never reach the document — the same licence a trailing space at the end of a paragraph\n * already has. Counting them as divergence made every such run canonicalize a space the user had\n * just typed with the caret sitting right after it: while the caret held the site the run showed\n * `\\va 2 \\va*`, and on departure the settle re-tokenized it back to `\\va 2\\va*`. That is a\n * keystroke accepted and then discarded, which \"no silent no-ops\" forbids.\n *\n * Two neighbouring edits stay divergences, because neither is whitespace the writer would supply:\n * deleting the separator outright (the value no longer opens with whitespace at all), and\n * whitespace typed INSIDE the value, which genuinely respells it (`12` → `1 2`) and must settle\n * onto owner state like any other value edit.\n */\nfunction valueDiverges(actual, expected) {\n if (actual === expected)\n return false;\n if (actual === undefined || expected === undefined)\n return true;\n if (!opensWithSeparator(expected) || !opensWithSeparator(actual))\n return true;\n const value = expected.trim();\n return value === \"\" || actual.trim() !== value;\n}\n/**\n * Whether `pieces` diverge from `expected`.\n *\n * A run that should not exist diverges the moment any piece survives. A run that should exist\n * diverges when its value's bytes differ ({@link valueDiverges}, which excuses the structural\n * whitespace flanking a separator-bearing value), when either glyph of a glyph-bearing kind is\n * missing, or — for a wrapper-written kind — when the pieces are still riding LOOSE: the wrap\n * migration is itself a divergence to heal, and treating it as one here is what lets the caret\n * grace it and the settle finish it, instead of the migration being deferred forever with nothing\n * pending it.\n */\nexport function $runDiverges(descriptor, pieces, expected) {\n if (!expected.wantsRun)\n return runHasPieces(pieces);\n if (valueDiverges(pieces.value?.getTextContent(), expected.valueText))\n return true;\n // A closer-less kind (`closerSyntax: \"none\"` — a chapter's `\\cp`) owes only its opener; every\n // other glyph-bearing kind owes both glyphs.\n if (descriptor.byteFormat.glyphs !== \"none\") {\n if (!pieces.opener)\n return true;\n if (descriptor.byteFormat.closerSyntax !== \"none\" && !pieces.closer)\n return true;\n }\n return descriptor.byteFormat.writer === \"wrapper\" && pieces.wrapper === undefined;\n}\n/**\n * True when `owner`'s run diverges from `$runDiverges` for EXACTLY the wrap-migration reason: the\n * value's bytes already match, both glyphs of a glyph-bearing kind are present, and the ONLY thing\n * missing is the wrapper itself. This is the one slice of `$runDiverges` the marker-edit engine's\n * departure settle may finish by calling `$syncDisplayRun` directly, instead of routing to a Tier-2\n * re-tokenize: every OTHER divergence (a missing/stale value, a missing glyph) means the DISPLAYED\n * bytes have genuinely drifted from `owner`'s own state — deleted or edited content — and only\n * re-tokenizing (which reads the displayed bytes back into state) can settle that without\n * resurrecting what the user just changed. A kind whose `byteFormat.writer` is not `\"wrapper\"`\n * (nothing to migrate) always returns `false`.\n */\nexport function $runNeedsOnlyWrapMigration(descriptor, owner) {\n if (descriptor.byteFormat.writer !== \"wrapper\")\n return false;\n const expected = descriptor.expectedPieces(owner);\n if (!expected.wantsRun)\n return false;\n const pieces = descriptor.scanPieces(owner);\n if (valueDiverges(pieces.value?.getTextContent(), expected.valueText))\n return false;\n if (descriptor.byteFormat.glyphs !== \"none\") {\n if (!pieces.opener)\n return false;\n if (descriptor.byteFormat.closerSyntax !== \"none\" && !pieces.closer)\n return false;\n }\n return pieces.wrapper === undefined;\n}\n/** True when NO piece of `owner`'s run remains — the run was deleted outright, as opposed to a\n * partial mangle that still leaves debris to repair around. */\nexport function $runEntirelyAbsent(descriptor, owner) {\n return !runHasByteContent(descriptor.scanPieces(owner));\n}\n/**\n * True when `owner`'s run diverges from what its state calls for but the collapsed caret holds the\n * run's SITE, so the sync must leave it alone and the marker-edit engine settle it on departure.\n *\n * Two arms are shared by every WRITER-DRIVEN kind: the caret anywhere inside the run's wrapper\n * subtree (an element point can land on the wrapper itself, which no piece-specific arm\n * recognizes), and the caret inside a live value node. Everything else is the descriptor's own\n * `graceSite` — the insertion-point and glyph-debris anchors that differ by tree shape.\n *\n * A `\"kind-owned\"` writer (the separator, the nested glyph) skips both shared arms and `$runDiverges`\n * entirely: its `expectedPieces`/`scanPieces` are deliberately empty, so the shared divergence rule\n * would never see anything to grace. Its `graceSite` is authoritative on its own instead.\n */\nexport function $caretHoldsRunSite(descriptor, owner) {\n if (!owner.isAttached())\n return false;\n // A kind-owned writer keeps its own divergence rule (a separator's missing NBSP is not a run\n // piece at all), so its graceSite is authoritative on its own.\n if (descriptor.byteFormat.writer === \"kind-owned\")\n return descriptor.graceSite(owner, {});\n const expected = descriptor.expectedPieces(owner);\n const pieces = descriptor.scanPieces(owner);\n if (!$runDiverges(descriptor, pieces, expected))\n return false;\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const { wrapper, value } = pieces;\n if (wrapper && (anchorNode.is(wrapper) || $isDescendantOf(anchorNode, wrapper.getKey())))\n return true;\n // A live value node is the mid-edit case: the caret is IN the bytes, so nothing else matters.\n if (value)\n return anchorNode.is(value);\n return descriptor.graceSite(owner, pieces);\n}\n/**\n * Whether `owner`'s run was destroyed by something other than this sync since the last committed\n * state. Gated on `wantsRun` so a call can never react to its own heal-removal: the writer below\n * only removes pieces when the run is NOT wanted, the opposite of this condition.\n *\n * Detecting the destruction from the last-committed state, inside the sync's own decision path,\n * keeps the result independent of which plugin's transforms happen to run first on a shared dirty\n * node — mount order varies across hosts. A collaborator's applied update is excluded\n * ({@link getApplyingUpdateSource}): it clears owner state directly, so the run is already unwanted\n * before this sync next runs.\n */\nfunction $runDestroyedSinceLastCommit(descriptor, owner, expected, pieces) {\n if (!expected.wantsRun)\n return false;\n // Byte pieces only: a deletion that empties the wrapper but leaves the husk standing is still\n // a destroyed run — see runHasByteContent.\n if (runHasByteContent(pieces))\n return false;\n if (getApplyingUpdateSource($getEditor()) === \"remote\")\n return false;\n return $getEditor()\n .getEditorState()\n .read(() => {\n const previous = $getNodeByKey(owner.getKey());\n if (!previous || !descriptor.ownerPredicate(previous))\n return false;\n return runHasByteContent(descriptor.scanPieces(previous));\n });\n}\n/** Remove every surviving piece — the \"no run wanted\" path. An emptied wrapper is left in place:\n * it is a transient husk the marker-edit engine's settle removes, so the removal and the owner's\n * own deletion policy stay in one place. */\nfunction $clearRun(pieces) {\n pieces.opener?.remove();\n pieces.value?.remove();\n pieces.closer?.remove();\n}\nfunction $createValueNode(text) {\n const value = $createTextNode(text);\n $setState(value, textTypeState, \"attribute\");\n return value;\n}\n/** Ensure the run's wrapper exists, healing any loose survivors forward into a freshly created one\n * inserted where the run belongs. This is the one migration path from loose to wrapped. */\nfunction $ensureWrapper(descriptor, owner, pieces) {\n if (pieces.wrapper)\n return pieces.wrapper;\n const { runKind, insertRunAfter } = descriptor.byteFormat;\n const anchor = insertRunAfter?.(owner);\n if (!runKind || !anchor)\n return undefined;\n const created = $createAttributeRunNode(runKind);\n anchor.insertAfter(created);\n if (pieces.opener)\n created.append(pieces.opener);\n if (pieces.value)\n created.append(pieces.value);\n if (pieces.closer)\n created.append(pieces.closer);\n return created;\n}\n/** Build or repair the run AROUND whatever pieces survive, in their fixed order. A found piece\n * already sits in its correct position (the scan reads them in order), so a missing one is\n * inserted into its gap and a leftover is reused in place, never duplicated. */\nfunction $writeRun(descriptor, owner, pieces, expected) {\n const { writer, glyphs, glyphMarker, closerSyntax, insertRunBefore } = descriptor.byteFormat;\n if (writer === \"owner-children\") {\n const anchor = insertRunBefore?.(owner);\n if (!anchor || expected.valueText === undefined)\n return;\n if ($isTextNode(pieces.value))\n pieces.value.setTextContent(expected.valueText);\n else\n anchor.insertBefore($createValueNode(expected.valueText));\n return;\n }\n const wrapper = $ensureWrapper(descriptor, owner, pieces);\n if (!wrapper || glyphs === \"none\" || !glyphMarker || !closerSyntax)\n return;\n const opener = pieces.opener ??\n (() => {\n const created = $createMarkerNode(glyphMarker(owner), \"opening\");\n const first = wrapper.getFirstChild();\n if (first)\n first.insertBefore(created);\n else\n wrapper.append(created);\n return created;\n })();\n let value = pieces.value;\n if (expected.valueText === undefined) {\n value?.remove();\n value = undefined;\n }\n else if ($isTextNode(value)) {\n // The same licence the divergence rule grants: a value the user only padded with structural\n // whitespace is left exactly as typed, even when a missing glyph is what brought the writer here.\n if (valueDiverges(value.getTextContent(), expected.valueText))\n value.setTextContent(expected.valueText);\n }\n else {\n value = $createValueNode(expected.valueText);\n opener.insertAfter(value);\n }\n // A closer-less kind never builds a trailing glyph; its wrapper bounds the value instead.\n if (closerSyntax !== \"none\" && !pieces.closer)\n (value ?? opener).insertAfter($createMarkerNode(closerSyntax === \"selfClosing\" ? \"\" : glyphMarker(owner), closerSyntax));\n}\n/**\n * Heal `owner`'s display run to what its own state calls for: insert a missing run, rewrite a\n * stale one, migrate a loose one into its wrapper, or remove one that is no longer wanted —\n * except while the engine holds the owner pended, while the run was just destroyed by something\n * else (reported so the engine settles it), or while the caret holds the run's site. Idempotent —\n * writes only on change, so the registering transform converges.\n *\n * Kinds whose pieces the driver does not write (`\"kind-owned\"` and `\"read-only\"` byte formats)\n * return immediately: they join the registry for their pend/settle duties only.\n *\n * @param descriptor - The kind's descriptor.\n * @param owner - The owner whose run to sync. Must be called inside `editor.update()`.\n */\nexport function $syncDisplayRun(descriptor, owner) {\n const { writer } = descriptor.byteFormat;\n if (writer === \"kind-owned\" || writer === \"read-only\")\n return;\n // An earlier transform in the same pass may have merged or removed the owner; a detached node\n // has no tree position to derive from.\n if (!owner.isAttached())\n return;\n const expected = descriptor.expectedPieces(owner);\n const pieces = descriptor.scanPieces(owner);\n if (!$runDiverges(descriptor, pieces, expected))\n return;\n if ($isDisplayOwnerPended(owner))\n return;\n if ($runDestroyedSinceLastCommit(descriptor, owner, expected, pieces)) {\n $reportDestroyedDisplayOwner(owner);\n return;\n }\n if ($caretHoldsRunSite(descriptor, owner))\n return;\n if (!expected.wantsRun) {\n $clearRun(pieces);\n return;\n }\n $writeRun(descriptor, owner, pieces, expected);\n}\n/**\n * Sync `owner`'s run for `descriptor`, then pend `owner` while the caret holds the run's site so\n * caret departure settles it. The pairing every registration home needs: the sync leaves a\n * caret-held divergence alone, and without the matching pend nothing would ever settle it — the\n * run would silently resurrect from the owner's still-set state on the next unrelated dirtying.\n *\n * @param descriptor - The kind's descriptor.\n * @param owner - The owner whose run to sync. Must be called inside `editor.update()`.\n * @param pendingKeys - The marker-edit engine's live pending set.\n */\nexport function $syncAndPendDisplayRun(descriptor, owner, pendingKeys) {\n $syncDisplayRun(descriptor, owner);\n if (owner.isAttached() && $caretHoldsRunSite(descriptor, owner))\n pendingKeys.add(owner.getKey());\n}\n","/**\n * Glyph text and document positions: the single place that owns WHICH rendered bytes are display\n * rather than document, and HOW a caret or selection point that names those bytes is re-expressed\n * so an edit never operates on them.\n *\n * ## The property, not a list of node types\n *\n * A glyph text node is a `TextNode` whose rendered text is a PICTURE OF ITS OWN STATE — the\n * document owns none of those bytes. A `MarkerNode`'s `__text` is a cache of (marker, syntax,\n * nested) that only its setters write ({@link $isCanonicalMarkerNode} exists because that cache can\n * drift). A `VerseNode`'s `__text` is a rendering of its `__number`. An attribute display run's\n * text is a rendering of the char span's attributes, and the marker-trailing separator is a\n * rendering of the `[glyph, separator, …content]` layout itself. Membership is decided by that\n * property, and {@link $isGlyphTextNode} is the one place it is decided — a kind wired in\n * separately somewhere else is the recurring defect this module exists to end.\n *\n * ## Two spellings of one place, and why each gesture picks a different one\n *\n * A glyph's bytes are visible, so the caret really can sit between two of them, and the arrow keys\n * really do walk through them one character at a time. Both of a glyph's ENDS, though, name a place\n * on screen that a neighbouring node also names, and nothing the user does can choose between the\n * two spellings. So an edit must pick the spelling under which the glyph is NOT one of its\n * operands, and which spelling that is depends on what the edit does with a point:\n *\n * - **A collapsed caret is an insertion point**, and it names no node as an operand. Its illegal\n * region is a glyph's INTERIOR: a node inserted between two display bytes cuts the picture in\n * half and hands the right-hand half to the document as content — a verse number arriving in the\n * file as text, a closing glyph's tail stranded as literal paragraph bytes. An interior point\n * therefore resolves to the glyph's TRAILING end, the end a caret that has already crossed the\n * glyph's first byte is heading for. Both ends are ordinary positions and are left exactly as\n * they are.\n * - **A range endpoint drags its own node into the range.** Its illegal region is the mirror image:\n * a glyph's ENDS, where the endpoint takes the WHOLE glyph node as a wrap target even when it\n * selects none of its bytes. A glyph is its span's identity, so moving one into another span\n * deletes the span it came from — the marker vanishes from the file while its glyph is still on\n * screen. An endpoint at an end is therefore re-spelled onto the neighbouring node, INWARD, so\n * the glyph falls outside the range. An endpoint strictly inside a glyph is left alone: the user\n * can see exactly which bytes are highlighted, and re-tokenizing them is Invariant I working as\n * intended rather than a divergence.\n *\n * Stated once: express the point so the glyph is not an operand. The two arms differ in spelling\n * because insertion and range membership differ in what naming a node means, not because the\n * exclusion rule differs.\n *\n * ## Agreeing with arrow traversal\n *\n * `ArrowNavigationPlugin` walks glyph text one character at a time, so its idea of where a glyph\n * begins and ends is the same as this module's: the interior is inside, the two ends are the\n * boundary positions, and a caret at an end has crossed the glyph whole. Nothing here calls a\n * position outside a glyph that a press treats as inside it, or the reverse. The spelling agrees\n * too — the trailing end resolved to above is written as (glyph, its length), which is exactly the\n * spelling that plugin's canonicalizer prefers for that screen location (the end of the nearest\n * preceding visible text) over the neighbouring node's offset 0. The one thing this module does\n * NOT do is move the caret for traversal's sake: it re-expresses the point an EDIT acts at.\n *\n * ## What this module does NOT own\n *\n * - WHICH boundary an edit should prefer once the point is legal — `caretBoundaries.utils.ts` owns\n * the content-boundary convention, and `ArrowNavigationPlugin` owns the traversal one.\n * - Which nodes are skipped when counting USJ content indexes\n * (`$shouldIgnoreNodeForContentIndexes`, node.utils.ts). That question is broader: it also skips\n * empty and NBSP-only text and line breaks, which are legal insertion hosts and must stay so.\n * - Whether a glyph's bytes are at rest or mid-edit ({@link $isCanonicalMarkerNode}), and what to do\n * about it — the marker-edit engine owns healing and settling.\n */\nimport { $isImmutableUnmatchedNode } from \"../features/ImmutableUnmatchedNode.js\";\nimport { $isCanonicalMarkerNode, $isMarkerNode } from \"../features/MarkerNode.js\";\nimport { MARKER_TRAILING_SPACE_TEXT_TYPE, textTypeState } from \"../collab/delta.state.js\";\nimport { $isCharNode } from \"./CharNode.js\";\nimport { $isVerseNode } from \"./VerseNode.js\";\nimport { $getSelection, $getState, $isRangeSelection, $isTextNode, } from \"lexical\";\n/**\n * Whether `node`'s rendered text is engine-owned DISPLAY bytes — a picture of the node's own state\n * — rather than document content. See the module doc for why this is one property and not four\n * unrelated node types; anything new whose text is derived from state belongs here, and nowhere\n * else.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isGlyphTextNode(node) {\n if (!$isTextNode(node))\n return false;\n // A marker glyph (`\\add`, `\\add*`, a paragraph's `\\p` prefix) and an editable verse marker\n // (`\\v` + NBSP + number + space) both render their own state as text.\n if ($isMarkerNode(node) || $isVerseNode(node))\n return true;\n // An unmatched-closer glyph (`\\f*` with no opener) is likewise a picture of its own\n // `__marker` state. It is a TextNode subclass, so without this arm the caret is never\n // normalized out of it and an insert can split the glyph (`\\f` + inserted note + a stranded\n // `*`).\n if ($isImmutableUnmatchedNode(node))\n return true;\n // The attribute display run (`|gloss=\"x\"`) renders the span's attributes; the marker-trailing\n // separator renders the prefix layout. Both are tagged rather than typed, so they are read off\n // the tag the engine writes when it builds them.\n const textType = $getState(node, textTypeState);\n return textType === \"attribute\" || textType === MARKER_TRAILING_SPACE_TEXT_TYPE;\n}\n/**\n * Whether a caret point (`node`, `offset`) sits INSIDE marker glyph text — as opposed to at the\n * TRAILING EDGE of a char span's canonical closing glyph, which is genuinely AFTER the span:\n * arrow traversal and clicks park the caret there at the end of a paragraph whose last child is\n * an inline span, and Enter there is a paragraph action (open the Enter menu), not a marker\n * edit. A NON-canonical (pended, mid-edit) closer keeps its trailing edge \"inside\": the caret is\n * there because the user is editing the glyph byte-by-byte, and Enter must keep settling that\n * edit instead of splitting. An OPENING glyph's trailing edge stays \"inside\" too — it is the\n * span's interior (the separator/content follows it). Deliberately scoped to CHAR-parented\n * closers: a display-run wrapper's closer (`\\va*`, `\\cat*`, a milestone's `\\*`) keeps today's\n * swallow — a split at that caret would land inside the `AttributeRunNode`, a path with no\n * close-and-reopen story yet.\n *\n * This asks whether the caret is in a marker the user may be EDITING, which is why an opening\n * glyph's trailing edge counts. It is not the same question as whether the point is a legal\n * document POSITION ({@link $normalizeSelectionOutOfGlyphText}), where both of a glyph's ends are\n * ordinary places to stand. Keeping the two in one module is deliberate: they read the same bytes\n * and the difference between them is the thing that is easy to get wrong.\n *\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isPointInMarkerGlyphText(node, offset) {\n if (!$isMarkerNode(node))\n return false;\n return !(offset === node.getTextContentSize() &&\n node.getMarkerSyntax() !== \"opening\" &&\n $isCanonicalMarkerNode(node) &&\n $isCharNode(node.getParent()));\n}\n/**\n * Whether a range selection's caret end sits inside marker glyph text — the guard\n * `MarkerEditPlugin` and `UsjNodesMenuPlugin` use to swallow Enter presses inside a marker. Read\n * from the FOCUS point (the live cursor end, correct even for a backward range — the project's\n * standing rule for \"the node the caret is in\"); for the common collapsed caret the two points\n * coincide. The trailing edge of a canonical closer does NOT count (see\n * {@link $isPointInMarkerGlyphText}).\n * Read-only: call inside `editor.getEditorState().read(...)` or an update.\n */\nexport function $isSelectionInMarkerNode() {\n const selection = $getSelection();\n if (!$isRangeSelection(selection))\n return false;\n return $isPointInMarkerGlyphText(selection.focus.getNode(), selection.focus.offset);\n}\n/** The glyph text node a point is expressed against, if it is expressed against one. */\nfunction $glyphAtPoint(point) {\n if (point.type !== \"text\")\n return undefined;\n const node = point.getNode();\n return $isTextNode(node) && $isGlyphTextNode(node) ? node : undefined;\n}\n/** The glyph node a point sits strictly between two display bytes of, if it does. */\nfunction $glyphAroundPoint(point) {\n const node = $glyphAtPoint(point);\n if (!node)\n return undefined;\n return point.offset > 0 && point.offset < node.getTextContentSize() ? node : undefined;\n}\n/** The glyph node a point names one of the ENDS of, if it does. */\nfunction $glyphAtPointEnd(point) {\n const node = $glyphAtPoint(point);\n if (!node)\n return undefined;\n return point.offset === 0 || point.offset === node.getTextContentSize() ? node : undefined;\n}\nfunction snapshotPoint(point) {\n return { key: point.key, offset: point.offset, type: point.type };\n}\nfunction restorePoint(point, snapshot) {\n point.set(snapshot.key, snapshot.offset, snapshot.type);\n}\n/**\n * The position a range endpoint naming a glyph's end should move to, so the glyph stops being part\n * of the range — or `undefined` when it should not move.\n *\n * Walks siblings in `direction`, because glyphs sit next to each other (a paragraph's prefix is a\n * glyph followed by its separator) and one step would only move the problem along. The walk is\n * ALL-OR-NOTHING: it must reach a text node that is not itself a glyph, or the endpoint stays put.\n * Landing anywhere else would trade one glyph for another, and the next thing along is often an\n * element — a char span — where stepping in would change which span the range starts in. Deciding\n * span membership is not this module's call.\n */\nfunction $landingPastGlyphs(point, direction) {\n let cursor = $glyphAtPointEnd(point);\n while (cursor) {\n const sibling = direction === \"next\" ? cursor.getNextSibling() : cursor.getPreviousSibling();\n if (!$isTextNode(sibling))\n return undefined;\n if (!$isGlyphTextNode(sibling))\n return { node: sibling, offset: direction === \"next\" ? 0 : sibling.getTextContentSize() };\n cursor = sibling;\n }\n return undefined;\n}\n/** Apply {@link $landingPastGlyphs} to `point`, reporting whether it moved. */\nfunction $stepPointPastGlyphs(point, direction) {\n const landing = $landingPastGlyphs(point, direction);\n if (!landing)\n return false;\n point.set(landing.node.getKey(), landing.offset, \"text\");\n return true;\n}\n/**\n * Re-express `selection` so no glyph is an operand of the edit about to run, and report whether\n * anything moved. The one exclusion point: every gesture that places a node at a caret or acts on a\n * selected range routes through this instead of testing for its own favourite glyph shape.\n *\n * A COLLAPSED selection is an insertion point: a point in a glyph's interior resolves to that\n * glyph's trailing end, and the ends are left alone. A RANGE has its two endpoints stepped inward\n * past any glyph they name an end of, and interior endpoints are left alone. The module doc carries\n * the reasoning for the asymmetry — it is one rule about operands, not two policies.\n *\n * Both range steps are all-or-nothing (see {@link $landingPastGlyphs}), and a trim that would\n * invert or collapse the selection is abandoned whole — that happens when both endpoints name the\n * same glyph, as a selection of exactly one glyph does. Leaving the range as the user made it beats\n * guessing at a position this module cannot justify.\n *\n * Mutating: call inside `editor.update()`, before the edit reads the selection.\n */\nexport function $normalizeSelectionOutOfGlyphText(selection) {\n if (selection.isCollapsed()) {\n const glyph = $glyphAroundPoint(selection.anchor);\n if (!glyph)\n return false;\n const trailingEnd = glyph.getTextContentSize();\n selection.anchor.set(glyph.getKey(), trailingEnd, \"text\");\n selection.focus.set(glyph.getKey(), trailingEnd, \"text\");\n return true;\n }\n const wasBackward = selection.isBackward();\n const start = wasBackward ? selection.focus : selection.anchor;\n const end = wasBackward ? selection.anchor : selection.focus;\n const before = [snapshotPoint(start), snapshotPoint(end)];\n const movedStart = $stepPointPastGlyphs(start, \"next\");\n const movedEnd = $stepPointPastGlyphs(end, \"previous\");\n if (!movedStart && !movedEnd)\n return false;\n if (selection.isCollapsed() || selection.isBackward() !== wasBackward) {\n restorePoint(start, before[0]);\n restorePoint(end, before[1]);\n return false;\n }\n return true;\n}\n","/**\n * A block-level container for one verse, used by the block verse view (`ViewOptions.verseLayout`).\n *\n * A verse is normally an inline milestone marker with no element around its text, so there is no\n * per-verse box for a layout to position. This node is that box: it holds the verse's paragraphs -\n * plural, so poetry keeps its `q1`/`q2` line structure - while still occupying a single row.\n *\n * Read-only. It is produced by the USJ-to-editor adaptor and has no editing surface; it is not\n * round-trippable back to USJ, because a source paragraph spanning several verses is split across\n * their blocks.\n */\nimport { $applyNodeReplacement, createState, ElementNode, } from \"lexical\";\nimport { parseVerseRange } from \"./node.utils.js\";\n/**\n * On a paragraph fragment in the block verse layout: the index, among the root children the\n * grouping started from, of the paragraph it was cut from. Fragments of one paragraph share it; a\n * unit without it is a whole source of its own.\n */\nexport const verseBlockSourceState = createState(\"verseBlockSource\", {\n parse: (value) => (typeof value === \"number\" ? value : undefined),\n});\nexport const VERSE_BLOCK_TYPE = \"verse-block\";\nexport const VERSE_BLOCK_VERSION = 1;\nexport const VERSE_BLOCK_CLASS_NAME = \"verse-block\";\nexport class VerseBlockNode extends ElementNode {\n /** The verse marker verbatim. Authoritative: the range is derived from it, never stored. */\n __number;\n constructor(verseNumber = \"\", key) {\n super(key);\n this.__number = verseNumber;\n }\n static getType() {\n return VERSE_BLOCK_TYPE;\n }\n static clone(node) {\n return new VerseBlockNode(node.__number, node.__key);\n }\n static importJSON(serializedNode) {\n return $createVerseBlockNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super.updateFromJSON(serializedNode).setNumber(serializedNode.number);\n }\n setNumber(verseNumber) {\n if (this.__number === verseNumber)\n return this;\n const self = this.getWritable();\n self.__number = verseNumber;\n return self;\n }\n getNumber() {\n return this.getLatest().__number;\n }\n /** The first and last verse numbers this block covers. A bridge covers more than one. */\n getRange() {\n return parseVerseRange(this.getNumber());\n }\n createDOM() {\n const dom = document.createElement(\"div\");\n dom.classList.add(VERSE_BLOCK_CLASS_NAME);\n setVerseAttributes(dom, this.__number);\n return dom;\n }\n updateDOM(prevNode, dom) {\n if (prevNode.__number !== this.__number)\n setVerseAttributes(dom, this.__number);\n return false;\n }\n // No `exportDOM`/`importDOM`: Lexical's default export already emits `createDOM`'s element, so\n // the HTML flavor of a copied passage carries these wrappers, which an ordinary paste unwraps\n // because there is no import counterpart. Block verse is read-only, so pasting one back in is\n // not a supported flow.\n /**\n * Keeps the wrapper out of the `application/x-lexical-editor` clipboard payload; its paragraphs\n * travel in its place.\n *\n * Every platform editor shares one Lexical namespace, so a payload copied from a block verse\n * editor is accepted when pasted into an ordinary one - which registers no `VerseBlockNode`, so\n * `$parseSerializedNode` would throw on the unknown type and `onError` would rethrow and tear the\n * editor down. `TypedMarkNode` and `UnknownNode` exclude themselves the same way; Lexical's\n * clipboard only ever asks with `\"html\"`.\n */\n excludeFromCopy(destination) {\n return destination !== \"clone\";\n }\n exportJSON() {\n return {\n ...super.exportJSON(),\n type: VERSE_BLOCK_TYPE,\n number: this.getNumber(),\n version: VERSE_BLOCK_VERSION,\n };\n }\n canBeEmpty() {\n return false;\n }\n}\n/**\n * Attributes a layout consumes to place the block on a row; `data-verse-start`/`-end` let a bridge\n * span rows. Deliberately not `data-number`, which the inner verse marker span already uses.\n */\nfunction setVerseAttributes(dom, verseNumber) {\n const { start, end } = parseVerseRange(verseNumber);\n // Imported USFM can carry a reversed bridge like `3-1`, which would hand a layout a negative\n // span. Publish the range only when it describes one, and remove rather than skip the\n // attributes otherwise, so a stale range from a previous number cannot be read as this verse's.\n const isPublishable = !isNaN(start) && !isNaN(end) && start <= end;\n dom.setAttribute(\"data-verse-number\", verseNumber);\n setOrRemoveAttribute(dom, \"data-verse-start\", isPublishable ? start : NaN);\n setOrRemoveAttribute(dom, \"data-verse-end\", isPublishable ? end : NaN);\n}\nfunction setOrRemoveAttribute(dom, name, value) {\n if (isNaN(value))\n dom.removeAttribute(name);\n else\n dom.setAttribute(name, value.toString());\n}\nexport function $createVerseBlockNode(verseNumber) {\n return $applyNodeReplacement(new VerseBlockNode(verseNumber));\n}\nexport function $isVerseBlockNode(node) {\n return node instanceof VerseBlockNode;\n}\nexport function isSerializedVerseBlockNode(node) {\n return node?.type === VERSE_BLOCK_TYPE;\n}\n","import { ImmutableTypedTextNode } from \"../features/ImmutableTypedTextNode.js\";\nimport { ImmutableUnmatchedNode } from \"../features/ImmutableUnmatchedNode.js\";\nimport { MarkerNode } from \"../features/MarkerNode.js\";\nimport { UnknownNode } from \"../features/UnknownNode.js\";\nimport { AttributeRunNode } from \"./AttributeRunNode.js\";\nimport { BookNode } from \"./BookNode.js\";\nimport { ChapterNode } from \"./ChapterNode.js\";\nimport { CharNode } from \"./CharNode.js\";\nimport { ImmutableChapterNode } from \"./ImmutableChapterNode.js\";\nimport { ImmutableTableNode } from \"./ImmutableTableNode.js\";\nimport { ImmutableTableRowNode } from \"./ImmutableTableRowNode.js\";\nimport { ImmutableTableCellNode } from \"./ImmutableTableCellNode.js\";\nimport { $createImpliedParaNode, ImpliedParaNode } from \"./ImpliedParaNode.js\";\nimport { MilestoneNode } from \"./MilestoneNode.js\";\nimport { NoteNode } from \"./NoteNode.js\";\nimport { ParaNode } from \"./ParaNode.js\";\nimport { VerseNode } from \"./VerseNode.js\";\nimport { ParagraphNode } from \"lexical\";\nexport * from \"./applyingUpdate.utils.js\";\nexport * from \"./attributeDisplay.utils.js\";\nexport * from \"./AttributeRunNode.js\";\nexport * from \"./BookNode.js\";\nexport * from \"./caretBoundaries.utils.js\";\nexport * from \"./ChapterNode.js\";\nexport * from \"./charGlyphs.utils.js\";\nexport * from \"./CharNode.js\";\nexport * from \"./charStack.utils.js\";\nexport * from \"./displayRunDescriptor.js\";\nexport * from \"./displayRunSync.utils.js\";\nexport * from \"./glyphPositions.utils.js\";\nexport * from \"./ImmutableChapterNode.js\";\nexport * from \"./ImmutableTableNode.js\";\nexport * from \"./ImmutableTableRowNode.js\";\nexport * from \"./ImmutableTableCellNode.js\";\nexport * from \"./ImpliedParaNode.js\";\nexport * from \"./literalOnlyBlock.utils.js\";\nexport * from \"./markerSeparators.utils.js\";\nexport * from \"./MilestoneNode.js\";\nexport * from \"./nestedGlyphs.utils.js\";\nexport * from \"./node-constants.js\";\nexport * from \"./node.utils.js\";\nexport * from \"./NoteNode.js\";\nexport * from \"./ParaNode.js\";\nexport * from \"./pendedDisplayOwners.utils.js\";\nexport * from \"./spaceRuns.utils.js\";\nexport * from \"./transientCaretHost.utils.js\";\nexport * from \"./VerseBlockNode.js\";\nexport * from \"./VerseNode.js\";\n// `VerseBlockNode` is deliberately absent below: it is registered only by editors using the block\n// verse layout, so every other editor's node registry is unchanged. See `usjBlockVerseNodes`.\n// Safe because the node excludes itself from the clipboard payload, so a passage copied out of a\n// block verse editor cannot reach an editor that has no class for it.\nexport const usjBaseNodes = [\n BookNode,\n ImmutableChapterNode,\n ChapterNode,\n VerseNode,\n CharNode,\n NoteNode,\n MilestoneNode,\n MarkerNode,\n UnknownNode,\n ImmutableTypedTextNode,\n ImmutableUnmatchedNode,\n ParaNode,\n ImpliedParaNode,\n ImmutableTableNode,\n ImmutableTableRowNode,\n ImmutableTableCellNode,\n // The forward adaptor (usj-editor.adaptor.ts, platform) serializes editable-mode verse/milestone\n // display runs as AttributeRunNode wrappers, and this package's own self-healing sync\n // (displayRunSync.utils.ts's shared $syncDisplayRun driver, parameterized by each kind's own\n // descriptor) constructs one whenever it heals a run forward from a loose or missing shape —\n // every USJ-shaped editor needs the class registered, not only shared-react's (a non-react host,\n // e.g. packages/scribe's NoteEditor, builds its editor straight from usjBaseNodes with no\n // react-specific node list).\n AttributeRunNode,\n {\n replace: ParagraphNode,\n with: () => $createImpliedParaNode(),\n withKlass: ImpliedParaNode,\n },\n];\n","/** Generated file using `nx generate markers-data` with 'tools/usfm-markers/src/generators/markers-data/data/usfm.sty' */\n/**\n * Default project `StyleInfo` derived from the bundled `usfm.sty` stylesheet.\n *\n * @public\n */\nexport const defaultStyleInfo = {\n markers: {\n id: {\n marker: \"id\",\n styleType: \"paragraph\",\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\", \"book\"],\n description: \"File identification information (BOOKID, FILENAME, EDITOR, MODIFICATION DATE)\",\n fontSize: 12,\n },\n usfm: {\n marker: \"usfm\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"File markup version information\",\n fontSize: 12,\n },\n ide: {\n marker: \"ide\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"File encoding information\",\n fontSize: 12,\n },\n h: {\n marker: \"h\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Running header text for a book (basic)\",\n fontSize: 12,\n },\n h1: {\n marker: \"h1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Running header text\",\n fontSize: 12,\n },\n h2: {\n marker: \"h2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Running header text, left side of page\",\n fontSize: 12,\n },\n h3: {\n marker: \"h3\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Running header text, right side of page\",\n fontSize: 12,\n },\n toc1: {\n marker: \"toc1\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\", \"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Long table of contents text\",\n fontSize: 12,\n bold: true,\n italic: true,\n color: \"#004000\",\n },\n toc2: {\n marker: \"toc2\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\", \"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Short table of contents text\",\n fontSize: 12,\n italic: true,\n color: \"#004000\",\n },\n toc3: {\n marker: \"toc3\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\", \"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Book Abbreviation\",\n fontSize: 12,\n bold: true,\n italic: true,\n color: \"#800000\",\n },\n toca1: {\n marker: \"toca1\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Alternative language long table of contents text\",\n fontSize: 10,\n italic: true,\n color: \"#808080\",\n },\n toca2: {\n marker: \"toca2\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Alternative language short table of contents text\",\n fontSize: 10,\n italic: true,\n color: \"#808080\",\n },\n toca3: {\n marker: \"toca3\",\n styleType: \"paragraph\",\n occursUnder: [\"h\", \"h1\", \"h2\", \"h3\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Alternative language book Abbreviation\",\n fontSize: 10,\n italic: true,\n color: \"#808080\",\n },\n rem: {\n marker: \"rem\",\n styleType: \"paragraph\",\n occursUnder: [\"id\", \"ide\", \"c\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"Comments and remarks\",\n fontSize: 12,\n color: \"#0000FF\",\n },\n sts: {\n marker: \"sts\",\n styleType: \"paragraph\",\n occursUnder: [\"id\", \"ide\", \"c\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"Status of this file\",\n fontSize: 12,\n color: \"#0000FF\",\n },\n restore: {\n marker: \"restore\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 99,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"Project restore information\",\n fontSize: 12,\n color: \"#0000FF\",\n },\n imt: {\n marker: \"imt\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 5,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction major title, level 1 (if single level) (basic)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n imt1: {\n marker: \"imt1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 5,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction major title, level 1 (if multiple levels)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n imt2: {\n marker: \"imt2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 5,\n textType: \"other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Introduction major title, level 2\",\n fontSize: 13,\n italic: true,\n justification: \"center\",\n spaceBefore: 6,\n spaceAfter: 3,\n },\n imt3: {\n marker: \"imt3\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 5,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"Introduction major title, level 3\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceBefore: 2,\n spaceAfter: 2,\n },\n imt4: {\n marker: \"imt4\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 5,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"Introduction major title, level 4 (usually within parenthesis)\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n spaceBefore: 2,\n spaceAfter: 2,\n },\n imte: {\n marker: \"imte\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 7,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction major title at introduction end, level 1 (if single level)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n imte1: {\n marker: \"imte1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 7,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction major title at introduction end, level 1 (if multiple levels)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n imte2: {\n marker: \"imte2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 7,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Introduction major title at introduction end, level 2\",\n fontSize: 16,\n italic: true,\n justification: \"center\",\n spaceAfter: 2,\n },\n is: {\n marker: \"is\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction section heading, level 1 (if single level) (basic)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n is1: {\n marker: \"is1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction section heading, level 1 (if multiple levels)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n is2: {\n marker: \"is2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Introduction section heading, level 2\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n iot: {\n marker: \"iot\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction outline title (basic)\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n io: {\n marker: \"io\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction outline text, level 1 (if single level)\",\n fontSize: 12,\n leftMargin: 0.5,\n },\n io1: {\n marker: \"io1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Introduction outline text, level 1 (if multiple levels) (basic)\",\n fontSize: 12,\n leftMargin: 0.5,\n },\n io2: {\n marker: \"io2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Introduction outline text, level 2\",\n fontSize: 12,\n leftMargin: 0.75,\n },\n io3: {\n marker: \"io3\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"Introduction outline text, level 3\",\n fontSize: 12,\n leftMargin: 1,\n },\n io4: {\n marker: \"io4\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"Introduction outline text, level 4\",\n fontSize: 12,\n leftMargin: 1.25,\n },\n ior: {\n marker: \"ior\",\n styleType: \"character\",\n endMarker: \"ior*\",\n occursUnder: [\"id\", \"io\", \"io1\", \"io2\", \"io3\", \"io4\", \"NEST\"],\n textType: \"Other\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Introduction references range for outline entry; for marking references separately\",\n fontSize: 12,\n },\n ip: {\n marker: \"ip\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph (basic)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n },\n im: {\n marker: \"im\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph, with no first line indent (may occur after poetry)\",\n fontSize: 12,\n },\n ipi: {\n marker: \"ipi\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph, indented, with first line indent\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n imi: {\n marker: \"imi\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph text, indented, with no first line indent\",\n fontSize: 12,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n ili: {\n marker: \"ili\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A list entry, level 1 (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.5,\n },\n ili1: {\n marker: \"ili1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A list entry, level 1 (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.5,\n },\n ili2: {\n marker: \"ili2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"A list entry, level 2\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.75,\n },\n ipq: {\n marker: \"ipq\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph, quote from the body text\",\n fontSize: 12,\n italic: true,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n imq: {\n marker: \"imq\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph, quote from the body text, with no first line indent\",\n fontSize: 12,\n italic: true,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n ipr: {\n marker: \"ipr\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction prose paragraph, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n ib: {\n marker: \"ib\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Introduction blank line\",\n fontSize: 10,\n },\n iq: {\n marker: \"iq\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_1\"],\n description: \"Introduction poetry text, level 1 (if single level)\",\n fontSize: 12,\n italic: true,\n firstLineIndent: -0.75,\n leftMargin: 1,\n },\n iq1: {\n marker: \"iq1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_1\"],\n description: \"Introduction poetry text, level 1 (if multiple levels)\",\n fontSize: 12,\n italic: true,\n firstLineIndent: -0.75,\n leftMargin: 1,\n },\n iq2: {\n marker: \"iq2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_2\"],\n description: \"Introduction poetry text, level 2\",\n fontSize: 12,\n italic: true,\n firstLineIndent: -0.5,\n leftMargin: 1,\n },\n iq3: {\n marker: \"iq3\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_3\"],\n description: \"Introduction poetry text, level 3\",\n fontSize: 12,\n italic: true,\n firstLineIndent: -0.25,\n leftMargin: 1,\n },\n iex: {\n marker: \"iex\",\n styleType: \"paragraph\",\n occursUnder: [\"id\", \"c\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n spaceBefore: 4,\n spaceAfter: 4,\n },\n iqt: {\n marker: \"iqt\",\n styleType: \"character\",\n endMarker: \"iqt*\",\n occursUnder: [\n \"imt\",\n \"imt1\",\n \"imt2\",\n \"imt3\",\n \"imt4\",\n \"ib\",\n \"ie\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"im\",\n \"imi\",\n \"imq\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"iot\",\n \"ip\",\n \"ipi\",\n \"ipq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"is\",\n \"is1\",\n \"is2\",\n \"imte\",\n \"imte1\",\n \"imte2\",\n \"iex\",\n ],\n textType: \"Other\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For quoted scripture text appearing in the introduction\",\n fontSize: 12,\n italic: true,\n },\n ie: {\n marker: \"ie\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 6,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Introduction ending marker\",\n fontSize: 10,\n },\n c: {\n marker: \"c\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 8,\n textType: \"ChapterNumber\",\n textProperties: [\"chapter\"],\n description: \"Chapter number (necessary for normal Paratext operation)\",\n fontSize: 18,\n bold: true,\n spaceBefore: 8,\n spaceAfter: 4,\n },\n ca: {\n marker: \"ca\",\n styleType: \"character\",\n endMarker: \"ca*\",\n occursUnder: [\"c\"],\n textType: \"Other\",\n description: \"Second (alternate) chapter number (for coding dual versification; useful for places where different traditions of chapter breaks need to be supported in the same translation)\",\n fontSize: 16,\n italic: true,\n color: \"#228B22\",\n },\n cp: {\n marker: \"cp\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Other\",\n textProperties: [\"paragraph\"],\n description: \"Published chapter number (chapter string that should appear in the published text)\",\n fontSize: 18,\n bold: true,\n color: \"#0000FF\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n cl: {\n marker: \"cl\",\n styleType: \"paragraph\",\n occursUnder: [\"id\", \"c\", \"ms\", \"ms1\", \"ms2\", \"ms3\", \"mr\"],\n textType: \"Other\",\n textProperties: [\"paragraph\"],\n description: 'Chapter label used for translations that add a word such as \"Chapter\" before chapter numbers (e.g. Psalms). The subsequent text is the chapter label.',\n fontSize: 18,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n cd: {\n marker: \"cd\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Chapter Description (Publishing option D, e.g. in Russian Bibles)\",\n fontSize: 11,\n spaceBefore: 8,\n spaceAfter: 4,\n },\n v: {\n marker: \"v\",\n styleType: \"character\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"s3\",\n \"d\",\n \"sp\",\n ],\n textType: \"VerseNumber\",\n textProperties: [\"verse\"],\n description: \"A verse number (Necessary for normal paratext operation) (basic)\",\n fontSize: 12,\n superscript: true,\n },\n va: {\n marker: \"va\",\n styleType: \"character\",\n endMarker: \"va*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"s3\",\n \"d\",\n \"sp\",\n ],\n textType: \"Other\",\n description: \"Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)\",\n fontSize: 12,\n superscript: true,\n color: \"#228B22\",\n },\n vp: {\n marker: \"vp\",\n styleType: \"character\",\n endMarker: \"vp*\",\n occursUnder: [\n \"cd\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"s3\",\n \"d\",\n \"sp\",\n ],\n textType: \"Other\",\n description: \"Published verse marker (verse string that should appear in the published text)\",\n fontSize: 12,\n superscript: true,\n color: \"#0000FF\",\n },\n p: {\n marker: \"p\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with first line indent (basic)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n },\n m: {\n marker: \"m\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with no first line indent (may occur after poetry) (basic)\",\n fontSize: 12,\n },\n po: {\n marker: \"po\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Letter opening\",\n fontSize: 12,\n firstLineIndent: 0.125,\n spaceBefore: 4,\n spaceAfter: 4,\n },\n pr: {\n marker: \"pr\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Text refrain (paragraph text, right aligned)\",\n fontSize: 12,\n justification: \"right\",\n },\n cls: {\n marker: \"cls\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Letter Closing\",\n fontSize: 12,\n justification: \"right\",\n },\n pmo: {\n marker: \"pmo\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Embedded text opening\",\n fontSize: 12,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pm: {\n marker: \"pm\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"po\",\n \"psi\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Embedded text paragraph\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pmc: {\n marker: \"pmc\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Embedded text closing\",\n fontSize: 12,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pmr: {\n marker: \"pmr\",\n styleType: \"paragraph\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: 'Embedded text refrain (e.g. Then all the people shall say, \"Amen!\")',\n fontSize: 12,\n justification: \"right\",\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pi: {\n marker: \"pi\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse (basic)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pi1: {\n marker: \"pi1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n pi2: {\n marker: \"pi2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Paragraph text, level 2 indent, with first line indent; often used for discourse\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.5,\n rightMargin: 0.25,\n },\n pi3: {\n marker: \"pi3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"Paragraph text, level 3 indent, with first line indent; often used for discourse\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.75,\n rightMargin: 0.25,\n },\n pc: {\n marker: \"pc\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, centered (for Inscription)\",\n fontSize: 12,\n justification: \"center\",\n },\n mi: {\n marker: \"mi\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, indented, with no first line indent; often used for discourse\",\n fontSize: 12,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n nb: {\n marker: \"nb\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with no break from previous paragraph text (at chapter boundary) (basic)\",\n fontSize: 12,\n },\n q: {\n marker: \"q\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_1\"],\n description: \"Poetry text, level 1 indent (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.5,\n leftMargin: 0.75,\n },\n q1: {\n marker: \"q1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_1\"],\n description: \"Poetry text, level 1 indent (if multiple levels) (basic)\",\n fontSize: 12,\n firstLineIndent: -0.5,\n leftMargin: 0.75,\n },\n q2: {\n marker: \"q2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_2\"],\n description: \"Poetry text, level 2 indent (basic)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.75,\n },\n q3: {\n marker: \"q3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_3\"],\n description: \"Poetry text, level 3 indent\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.75,\n },\n q4: {\n marker: \"q4\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_4\"],\n description: \"Poetry text, level 4 indent\",\n fontSize: 12,\n firstLineIndent: -0.125,\n leftMargin: 0.75,\n },\n qc: {\n marker: \"qc\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, centered\",\n fontSize: 12,\n justification: \"center\",\n },\n qr: {\n marker: \"qr\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, Right Aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n qs: {\n marker: \"qs\",\n styleType: \"character\",\n endMarker: \"qs*\",\n occursUnder: [\"q\", \"q1\", \"q2\", \"q3\", \"q4\", \"qc\", \"qr\", \"qd\", \"NEST\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, Selah\",\n fontSize: 12,\n italic: true,\n },\n qa: {\n marker: \"qa\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, Acrostic marker/heading\",\n fontSize: 12,\n italic: true,\n },\n qac: {\n marker: \"qac\",\n styleType: \"character\",\n endMarker: \"qac*\",\n occursUnder: [\"q\", \"q1\", \"q2\", \"q3\", \"q4\", \"qc\", \"qr\", \"\", \"NEST\"],\n rank: 4,\n textType: \"Other\",\n textProperties: [\"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, Acrostic markup of the first character of a line of acrostic poetry\",\n fontSize: 12,\n italic: true,\n },\n qm: {\n marker: \"qm\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text, embedded, level 1 indent (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.75,\n leftMargin: 1,\n },\n qm1: {\n marker: \"qm1\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_1\"],\n description: \"Poetry text, embedded, level 1 indent (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: -0.75,\n leftMargin: 1,\n },\n qm2: {\n marker: \"qm2\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_2\"],\n description: \"Poetry text, embedded, level 2 indent\",\n fontSize: 12,\n firstLineIndent: -0.5,\n leftMargin: 1,\n },\n qm3: {\n marker: \"qm3\",\n styleType: \"paragraph\",\n occursUnder: [\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"b\",\n ],\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\", \"level_3\"],\n description: \"Poetry text, embedded, level 3 indent\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 1,\n },\n qd: {\n marker: \"qd\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.\",\n fontSize: 12,\n italic: true,\n leftMargin: 0.25,\n },\n b: {\n marker: \"b\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Poetry text stanza break (e.g. stanza break) (basic)\",\n fontSize: 10,\n },\n mt: {\n marker: \"mt\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 3,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"The main title of the book (if single level)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n mt1: {\n marker: \"mt1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 3,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"The main title of the book (if multiple levels) (basic)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 2,\n spaceAfter: 4,\n },\n mt2: {\n marker: \"mt2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 3,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"A secondary title usually occurring before the main title (basic)\",\n fontSize: 16,\n italic: true,\n justification: \"center\",\n spaceAfter: 2,\n },\n mt3: {\n marker: \"mt3\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 3,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"A secondary title occurring after the main title\",\n fontSize: 16,\n bold: true,\n justification: \"center\",\n spaceBefore: 2,\n spaceAfter: 2,\n },\n mt4: {\n marker: \"mt4\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 3,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"A small secondary title sometimes occurring within parentheses\",\n fontSize: 12,\n justification: \"center\",\n spaceBefore: 2,\n spaceAfter: 2,\n },\n mte: {\n marker: \"mte\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 2,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"The main title of the book repeated at the end of the book, level 1 (if single level)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n mte1: {\n marker: \"mte1\",\n styleType: \"paragraph\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"s3\",\n \"d\",\n ],\n rank: 2,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"The main title of the book repeated at the end of the book, level 1 (if multiple levels)\",\n fontSize: 20,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n mte2: {\n marker: \"mte2\",\n styleType: \"paragraph\",\n occursUnder: [\"mte1\"],\n rank: 2,\n textType: \"Title\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"A secondary title occurring before or after the 'ending' main title\",\n fontSize: 16,\n italic: true,\n justification: \"center\",\n spaceAfter: 2,\n },\n ms: {\n marker: \"ms\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A major section division heading, level 1 (if single level) (basic)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 16,\n spaceAfter: 4,\n },\n ms1: {\n marker: \"ms1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A major section division heading, level 1 (if multiple levels)\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 16,\n spaceAfter: 4,\n },\n ms2: {\n marker: \"ms2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A major section division heading, level 2\",\n fontSize: 14,\n bold: true,\n justification: \"center\",\n spaceBefore: 16,\n spaceAfter: 4,\n },\n ms3: {\n marker: \"ms3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A major section division heading, level 3\",\n fontSize: 14,\n italic: true,\n justification: \"center\",\n spaceBefore: 16,\n spaceAfter: 4,\n },\n mr: {\n marker: \"mr\",\n styleType: \"paragraph\",\n occursUnder: [\"ms\", \"ms1\", \"ms2\", \"ms3\"],\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A major section division references range heading (basic)\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n spaceAfter: 4,\n },\n s: {\n marker: \"s\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A section heading, level 1 (if single level) (basic)\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n s1: {\n marker: \"s1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A section heading, level 1 (if multiple levels)\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n s2: {\n marker: \"s2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"A section heading, level 2 (e.g. Proverbs 22-24)\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n s3: {\n marker: \"s3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: 'A section heading, level 3 (e.g. Genesis \"The First Day\")',\n fontSize: 12,\n italic: true,\n justification: \"left\",\n spaceBefore: 6,\n spaceAfter: 3,\n },\n s4: {\n marker: \"s4\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"A section heading, level 4\",\n fontSize: 12,\n italic: true,\n justification: \"left\",\n spaceBefore: 6,\n spaceAfter: 3,\n },\n sr: {\n marker: \"sr\",\n styleType: \"paragraph\",\n occursUnder: [\"s\", \"s1\", \"s2\", \"s3\", \"s4\"],\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A section division references range heading\",\n fontSize: 12,\n bold: true,\n justification: \"center\",\n spaceAfter: 4,\n },\n r: {\n marker: \"r\",\n styleType: \"paragraph\",\n occursUnder: [\"c\", \"s\", \"s1\", \"s2\", \"s3\", \"s4\"],\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Parallel reference(s) (basic)\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n spaceAfter: 4,\n },\n sp: {\n marker: \"sp\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A heading, to identify the speaker (e.g. Job)\",\n fontSize: 12,\n italic: true,\n justification: \"left\",\n spaceBefore: 8,\n spaceAfter: 4,\n },\n d: {\n marker: \"d\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A Hebrew text heading, to provide description (e.g. Psalms)\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n spaceBefore: 4,\n spaceAfter: 4,\n },\n sd: {\n marker: \"sd\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Vertical space used to divide the text into sections, level 1 (if single level)\",\n spaceBefore: 24,\n spaceAfter: 24,\n },\n sd1: {\n marker: \"sd1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"Vertical space used to divide the text into sections, level 1 (if multiple levels)\",\n spaceBefore: 24,\n spaceAfter: 24,\n },\n sd2: {\n marker: \"sd2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"Vertical space used to divide the text into sections, level 2\",\n spaceBefore: 18,\n spaceAfter: 18,\n },\n sd3: {\n marker: \"sd3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"Vertical space used to divide the text into sections, level 3\",\n spaceBefore: 12,\n spaceAfter: 12,\n },\n sd4: {\n marker: \"sd4\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Section\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"Vertical space used to divide the text into sections, level 4\",\n spaceBefore: 8,\n spaceAfter: 8,\n },\n tr: {\n marker: \"tr\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"A new table row\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.5,\n },\n th1: {\n marker: \"th1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 1\",\n fontSize: 12,\n italic: true,\n },\n th2: {\n marker: \"th2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 2\",\n fontSize: 12,\n italic: true,\n },\n th3: {\n marker: \"th3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 3\",\n fontSize: 12,\n italic: true,\n },\n th4: {\n marker: \"th4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 4\",\n fontSize: 12,\n italic: true,\n },\n th5: {\n marker: \"th5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 5\",\n fontSize: 12,\n italic: true,\n },\n th6: {\n marker: \"th6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 6\",\n fontSize: 12,\n italic: true,\n },\n th7: {\n marker: \"th7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 7\",\n fontSize: 12,\n italic: true,\n },\n th8: {\n marker: \"th8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 8\",\n fontSize: 12,\n italic: true,\n },\n th9: {\n marker: \"th9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 9\",\n fontSize: 12,\n italic: true,\n },\n th10: {\n marker: \"th10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 10\",\n fontSize: 12,\n italic: true,\n },\n th11: {\n marker: \"th11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 11\",\n fontSize: 12,\n italic: true,\n },\n th12: {\n marker: \"th12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 12\",\n fontSize: 12,\n italic: true,\n },\n tc1: {\n marker: \"tc1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 1\",\n fontSize: 12,\n },\n tc2: {\n marker: \"tc2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 2\",\n fontSize: 12,\n },\n tc3: {\n marker: \"tc3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 3\",\n fontSize: 12,\n },\n tc4: {\n marker: \"tc4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 4\",\n fontSize: 12,\n },\n tc5: {\n marker: \"tc5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 5\",\n fontSize: 12,\n },\n tc6: {\n marker: \"tc6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 6\",\n fontSize: 12,\n },\n tc7: {\n marker: \"tc7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 7\",\n fontSize: 12,\n },\n tc8: {\n marker: \"tc8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 8\",\n fontSize: 12,\n },\n tc9: {\n marker: \"tc9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 9\",\n fontSize: 12,\n },\n tc10: {\n marker: \"tc10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 10\",\n fontSize: 12,\n },\n tc11: {\n marker: \"tc11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 11\",\n fontSize: 12,\n },\n tc12: {\n marker: \"tc12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 12\",\n fontSize: 12,\n },\n thc1: {\n marker: \"thc1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 1, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc2: {\n marker: \"thc2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 2, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc3: {\n marker: \"thc3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 3, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc4: {\n marker: \"thc4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 4, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc5: {\n marker: \"thc5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 5, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc6: {\n marker: \"thc6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 6, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc7: {\n marker: \"thc7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 7, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc8: {\n marker: \"thc8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 8, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc9: {\n marker: \"thc9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 9, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc10: {\n marker: \"thc10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 10, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc11: {\n marker: \"thc11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 11, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n thc12: {\n marker: \"thc12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 12, center aligned\",\n fontSize: 12,\n italic: true,\n justification: \"center\",\n },\n tcc1: {\n marker: \"tcc1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 1, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc2: {\n marker: \"tcc2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 2, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc3: {\n marker: \"tcc3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 3, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc4: {\n marker: \"tcc4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 4, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc5: {\n marker: \"tcc5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 5, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc6: {\n marker: \"tcc6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 6, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc7: {\n marker: \"tcc7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 7, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc8: {\n marker: \"tcc8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 8, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc9: {\n marker: \"tcc9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 9, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc10: {\n marker: \"tcc10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 10, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc11: {\n marker: \"tcc11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 11, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n tcc12: {\n marker: \"tcc12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 12, center aligned\",\n fontSize: 12,\n justification: \"center\",\n },\n thr1: {\n marker: \"thr1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 1, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr2: {\n marker: \"thr2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 2, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr3: {\n marker: \"thr3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 3, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr4: {\n marker: \"thr4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 4, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr5: {\n marker: \"thr5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 5, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr6: {\n marker: \"thr6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 6, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr7: {\n marker: \"thr7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 7, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr8: {\n marker: \"thr8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 8, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr9: {\n marker: \"thr9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 9, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr10: {\n marker: \"thr10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 10, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr11: {\n marker: \"thr11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 11, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n thr12: {\n marker: \"thr12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table heading, column 12, right aligned\",\n fontSize: 12,\n italic: true,\n justification: \"right\",\n },\n tcr1: {\n marker: \"tcr1\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 1, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr2: {\n marker: \"tcr2\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 2, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr3: {\n marker: \"tcr3\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 3, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr4: {\n marker: \"tcr4\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 4, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr5: {\n marker: \"tcr5\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 5, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr6: {\n marker: \"tcr6\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 6, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr7: {\n marker: \"tcr7\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 7, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr8: {\n marker: \"tcr8\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 8, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr9: {\n marker: \"tcr9\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 9, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr10: {\n marker: \"tcr10\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 10, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr11: {\n marker: \"tcr11\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 11, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n tcr12: {\n marker: \"tcr12\",\n styleType: \"character\",\n occursUnder: [\"tr\"],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A table cell item, column 12, right aligned\",\n fontSize: 12,\n justification: \"right\",\n },\n lh: {\n marker: \"lh\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"List header (introductory remark)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n },\n li: {\n marker: \"li\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A list entry, level 1 (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.5,\n },\n li1: {\n marker: \"li1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"A list entry, level 1 (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.5,\n },\n li2: {\n marker: \"li2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"A list entry, level 2\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.75,\n },\n li3: {\n marker: \"li3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"A list entry, level 3\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 1,\n },\n li4: {\n marker: \"li4\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"A list entry, level 4\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 1.25,\n },\n lf: {\n marker: \"lf\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"List footer (concluding remark)\",\n fontSize: 12,\n },\n lim: {\n marker: \"lim\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"An embedded list entry, level 1 (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.75,\n rightMargin: 0.25,\n },\n lim1: {\n marker: \"lim1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_1\"],\n description: \"An embedded list entry, level 1 (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 0.75,\n rightMargin: 0.25,\n },\n lim2: {\n marker: \"lim2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_2\"],\n description: \"An embedded list entry, level 2\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 1,\n },\n lim3: {\n marker: \"lim3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_3\"],\n description: \"An embedded list item, level 3\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 1.25,\n },\n lim4: {\n marker: \"lim4\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"level_4\"],\n description: \"An embedded list entry, level 4\",\n fontSize: 12,\n firstLineIndent: -0.375,\n leftMargin: 1.5,\n },\n litl: {\n marker: \"litl\",\n styleType: \"character\",\n endMarker: \"litl*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"List entry total text\",\n fontSize: 12,\n italic: true,\n },\n lik: {\n marker: \"lik\",\n styleType: \"character\",\n endMarker: \"lik*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry key text\",\n fontSize: 12,\n italic: true,\n },\n liv: {\n marker: \"liv\",\n styleType: \"character\",\n endMarker: \"liv*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 1 content (if single value)\",\n fontSize: 12,\n },\n liv1: {\n marker: \"liv1\",\n styleType: \"character\",\n endMarker: \"liv1*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 1 content (if multiple values)\",\n fontSize: 12,\n },\n liv2: {\n marker: \"liv2\",\n styleType: \"character\",\n endMarker: \"liv2*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 2 content\",\n fontSize: 12,\n },\n liv3: {\n marker: \"liv3\",\n styleType: \"character\",\n endMarker: \"liv3*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 3 content\",\n fontSize: 12,\n },\n liv4: {\n marker: \"liv4\",\n styleType: \"character\",\n endMarker: \"liv4*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 4 content\",\n fontSize: 12,\n },\n liv5: {\n marker: \"liv5\",\n styleType: \"character\",\n endMarker: \"liv5*\",\n occursUnder: [\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Structured list entry value 5 content\",\n fontSize: 12,\n },\n f: {\n marker: \"f\",\n styleType: \"note\",\n endMarker: \"f*\",\n occursUnder: [\n \"c\",\n \"cp\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"qs\",\n \"sp\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"mt\",\n \"mt1\",\n \"mt2\",\n \"mt3\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"ms3\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n ],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A Footnote text item (basic)\",\n fontSize: 12,\n },\n fe: {\n marker: \"fe\",\n styleType: \"note\",\n endMarker: \"fe*\",\n occursUnder: [\n \"c\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"ms3\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n ],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"An Endnote text item\",\n fontSize: 12,\n },\n fr: {\n marker: \"fr\",\n styleType: \"character\",\n endMarker: \"fr*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"The origin reference for the footnote (basic)\",\n fontSize: 12,\n bold: true,\n },\n ft: {\n marker: \"ft\",\n styleType: \"character\",\n endMarker: \"ft*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Footnote text, Protocanon (basic)\",\n fontSize: 12,\n },\n fk: {\n marker: \"fk\",\n styleType: \"character\",\n endMarker: \"fk*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A footnote keyword (basic)\",\n fontSize: 12,\n bold: true,\n italic: true,\n },\n fq: {\n marker: \"fq\",\n styleType: \"character\",\n endMarker: \"fq*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A footnote scripture quote or alternate rendering (basic)\",\n fontSize: 12,\n italic: true,\n },\n fqa: {\n marker: \"fqa\",\n styleType: \"character\",\n endMarker: \"fqa*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A footnote alternate rendering for a portion of scripture text\",\n fontSize: 12,\n italic: true,\n },\n fl: {\n marker: \"fl\",\n styleType: \"character\",\n endMarker: \"fl*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: 'A footnote label text item, for marking or \"labelling\" the type or alternate translation being provided in the note.',\n fontSize: 12,\n bold: true,\n italic: true,\n },\n fw: {\n marker: \"fw\",\n styleType: \"character\",\n endMarker: \"fw*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.\",\n fontSize: 12,\n },\n fp: {\n marker: \"fp\",\n styleType: \"character\",\n endMarker: \"fp*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A Footnote additional paragraph marker\",\n fontSize: 12,\n },\n fv: {\n marker: \"fv\",\n styleType: \"character\",\n endMarker: \"fv*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A verse number within the footnote text\",\n fontSize: 12,\n superscript: true,\n },\n fdc: {\n marker: \"fdc\",\n styleType: \"character\",\n endMarker: \"fdc*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Footnote text, applies to Deuterocanon only\",\n fontSize: 12,\n },\n fm: {\n marker: \"fm\",\n styleType: \"character\",\n endMarker: \"fm*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n ],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"An additional footnote marker location for a previous footnote\",\n fontSize: 12,\n superscript: true,\n },\n x: {\n marker: \"x\",\n styleType: \"note\",\n endMarker: \"x*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"qs\",\n \"sp\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"mt\",\n \"mt1\",\n \"mt2\",\n \"mt3\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n ],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\", \"crossreference\"],\n description: \"A list of cross references (basic)\",\n fontSize: 12,\n },\n xo: {\n marker: \"xo\",\n styleType: \"character\",\n endMarker: \"xo*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"The cross reference origin reference (basic)\",\n fontSize: 12,\n bold: true,\n },\n xop: {\n marker: \"xop\",\n styleType: \"character\",\n endMarker: \"xop*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Published cross reference origin reference (origin reference that should appear in the published text)\",\n fontSize: 12,\n },\n xt: {\n marker: \"xt\",\n styleType: \"character\",\n endMarker: \"xt*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"ef\",\n \"ex\",\n \"NEST\",\n ],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"The cross reference target reference(s), protocanon only (basic)\",\n fontSize: 12,\n },\n xta: {\n marker: \"xta\",\n styleType: \"character\",\n endMarker: \"xta*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Cross reference target references added text\",\n fontSize: 12,\n },\n xk: {\n marker: \"xk\",\n styleType: \"character\",\n endMarker: \"xk*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A cross reference keyword\",\n fontSize: 12,\n italic: true,\n },\n xq: {\n marker: \"xq\",\n styleType: \"character\",\n endMarker: \"xq*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A cross-reference quotation from the scripture text\",\n fontSize: 12,\n italic: true,\n },\n xot: {\n marker: \"xot\",\n styleType: \"character\",\n endMarker: \"xot*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Cross-reference target reference(s), Old Testament only\",\n fontSize: 12,\n },\n xnt: {\n marker: \"xnt\",\n styleType: \"character\",\n endMarker: \"xnt*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Cross-reference target reference(s), New Testament only\",\n fontSize: 12,\n },\n xdc: {\n marker: \"xdc\",\n styleType: \"character\",\n endMarker: \"xdc*\",\n occursUnder: [\"x\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"Cross-reference target reference(s), Deuterocanon only\",\n fontSize: 12,\n },\n rq: {\n marker: \"rq\",\n styleType: \"character\",\n endMarker: \"rq*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"NEST\",\n ],\n textType: \"Other\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A cross-reference indicating the source text for the preceding quotation.\",\n fontSize: 10,\n italic: true,\n },\n qt: {\n marker: \"qt\",\n styleType: \"character\",\n endMarker: \"qt*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For Old Testament quoted text appearing in the New Testament (basic)\",\n fontSize: 12,\n italic: true,\n },\n nd: {\n marker: \"nd\",\n styleType: \"character\",\n endMarker: \"nd*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For name of deity (basic)\",\n fontSize: 12,\n underline: true,\n },\n tl: {\n marker: \"tl\",\n styleType: \"character\",\n endMarker: \"tl*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"nonvernacular\"],\n description: \"For transliterated words\",\n fontSize: 12,\n italic: true,\n },\n dc: {\n marker: \"dc\",\n styleType: \"character\",\n endMarker: \"dc*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Deuterocanonical/LXX additions or insertions in the Protocanonical text\",\n italic: true,\n },\n bk: {\n marker: \"bk\",\n styleType: \"character\",\n endMarker: \"bk*\",\n occursUnder: [\n \"imt\",\n \"imt1\",\n \"imt2\",\n \"imt3\",\n \"imt4\",\n \"imte\",\n \"imte1\",\n \"imte2\",\n \"is\",\n \"is1\",\n \"is2\",\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For the quoted name of a book\",\n fontSize: 12,\n italic: true,\n },\n sig: {\n marker: \"sig\",\n styleType: \"character\",\n endMarker: \"sig*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For the signature of the author of an Epistle\",\n fontSize: 12,\n italic: true,\n },\n pn: {\n marker: \"pn\",\n styleType: \"character\",\n endMarker: \"pn*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For a proper name\",\n fontSize: 12,\n bold: true,\n underline: true,\n },\n png: {\n marker: \"png\",\n styleType: \"character\",\n endMarker: \"png*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For a geographic proper name\",\n fontSize: 12,\n underline: true,\n },\n addpn: {\n marker: \"addpn\",\n styleType: \"character\",\n endMarker: \"addpn*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For chinese words to be dot underline & underline\",\n fontSize: 12,\n bold: true,\n italic: true,\n underline: true,\n },\n wj: {\n marker: \"wj\",\n styleType: \"character\",\n endMarker: \"wj*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For marking the words of Jesus\",\n fontSize: 12,\n color: \"#FF0000\",\n },\n k: {\n marker: \"k\",\n styleType: \"character\",\n endMarker: \"k*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For a keyword\",\n fontSize: 12,\n bold: true,\n italic: true,\n },\n sls: {\n marker: \"sls\",\n styleType: \"character\",\n endMarker: \"sls*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"To represent where the original text is in a secondary language or from an alternate text source\",\n fontSize: 12,\n italic: true,\n },\n ord: {\n marker: \"ord\",\n styleType: \"character\",\n endMarker: \"ord*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For the text portion of an ordinal number\",\n fontSize: 12,\n superscript: true,\n },\n add: {\n marker: \"add\",\n styleType: \"character\",\n endMarker: \"add*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"cls\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"For a translational addition to the text\",\n bold: true,\n italic: true,\n },\n lit: {\n marker: \"lit\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"For a comment or note inserted for liturgical use\",\n fontSize: 12,\n bold: true,\n justification: \"right\",\n },\n no: {\n marker: \"no\",\n styleType: \"character\",\n endMarker: \"no*\",\n occursUnder: [\n \"is\",\n \"ip\",\n \"ipi\",\n \"im\",\n \"imi\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"imq\",\n \"ipq\",\n \"iex\",\n \"iq\",\n \"iot\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, use normal text\",\n fontSize: 12,\n },\n it: {\n marker: \"it\",\n styleType: \"character\",\n endMarker: \"it*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, use italic text\",\n fontSize: 12,\n italic: true,\n },\n bd: {\n marker: \"bd\",\n styleType: \"character\",\n endMarker: \"bd*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, use bold text\",\n fontSize: 12,\n bold: true,\n },\n bdit: {\n marker: \"bdit\",\n styleType: \"character\",\n endMarker: \"bdit*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, use bold + italic text\",\n fontSize: 12,\n bold: true,\n italic: true,\n },\n em: {\n marker: \"em\",\n styleType: \"character\",\n endMarker: \"em*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, use emphasized text style\",\n fontSize: 12,\n italic: true,\n },\n sc: {\n marker: \"sc\",\n styleType: \"character\",\n endMarker: \"sc*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, for small capitalization text\",\n fontSize: 12,\n smallCaps: true,\n },\n sup: {\n marker: \"sup\",\n styleType: \"character\",\n endMarker: \"sup*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A character style, for superscript text. Typically for use in critical edition footnotes.\",\n fontSize: 12,\n superscript: true,\n },\n pb: {\n marker: \"pb\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"Other\",\n textProperties: [\"publishable\"],\n description: \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n fontSize: 12,\n },\n fig: {\n marker: \"fig\",\n styleType: \"character\",\n endMarker: \"fig*\",\n occursUnder: [\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n ],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Illustration [Columns to span, height, filename, caption text]\",\n fontSize: 12,\n },\n jmp: {\n marker: \"jmp\",\n styleType: \"character\",\n endMarker: \"jmp*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"Other\",\n description: \"For associating linking attributes to a span of text\",\n underline: true,\n color: \"#0000FF\",\n },\n pro: {\n marker: \"pro\",\n styleType: \"character\",\n endMarker: \"pro*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"Other\",\n textProperties: [\"Nonpublishable\"],\n description: \"For indicating pronunciation in CJK texts\",\n fontSize: 10,\n },\n rb: {\n marker: \"rb\",\n styleType: \"character\",\n endMarker: \"rb*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"sp\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"d\",\n \"ip\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Most often used to provide a reading / pronunciation guide in ideographic scripts\",\n },\n w: {\n marker: \"w\",\n styleType: \"character\",\n endMarker: \"w*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A wordlist text item\",\n fontSize: 12,\n },\n wh: {\n marker: \"wh\",\n styleType: \"character\",\n endMarker: \"wh*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A Hebrew wordlist text item\",\n fontSize: 12,\n },\n wg: {\n marker: \"wg\",\n styleType: \"character\",\n endMarker: \"wg*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A Greek Wordlist text item\",\n fontSize: 12,\n },\n wa: {\n marker: \"wa\",\n styleType: \"character\",\n endMarker: \"wa*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"An Aramaic Wordlist text item\",\n fontSize: 12,\n },\n ndx: {\n marker: \"ndx\",\n styleType: \"character\",\n endMarker: \"ndx*\",\n occursUnder: [\n \"ip\",\n \"im\",\n \"ipi\",\n \"imi\",\n \"ipq\",\n \"imq\",\n \"ipr\",\n \"iq\",\n \"iq1\",\n \"iq2\",\n \"iq3\",\n \"ili\",\n \"ili1\",\n \"ili2\",\n \"io\",\n \"io1\",\n \"io2\",\n \"io3\",\n \"io4\",\n \"ms\",\n \"ms1\",\n \"ms2\",\n \"s\",\n \"s1\",\n \"s2\",\n \"s3\",\n \"s4\",\n \"cd\",\n \"sp\",\n \"d\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"pmo\",\n \"pm\",\n \"pmc\",\n \"pmr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"qm\",\n \"qm1\",\n \"qm2\",\n \"qm3\",\n \"tr\",\n \"th1\",\n \"th2\",\n \"th3\",\n \"th4\",\n \"thr1\",\n \"thr2\",\n \"thr3\",\n \"thr4\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"tcr1\",\n \"tcr2\",\n \"tcr3\",\n \"tcr4\",\n \"f\",\n \"fe\",\n \"x\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A subject index text item\",\n fontSize: 12,\n },\n periph: {\n marker: \"periph\",\n styleType: \"paragraph\",\n textType: \"Section\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"vernacular\"],\n description: \"Peripheral content division marker which should be followed by an additional division argument/title.\",\n fontSize: 14,\n bold: true,\n color: \"#FF8000\",\n spaceBefore: 16,\n spaceAfter: 4,\n },\n p1: {\n marker: \"p1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Front or back matter text paragraph, level 1 (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n },\n p2: {\n marker: \"p2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Front or back matter text paragraph, level 2 (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.125,\n },\n k1: {\n marker: \"k1\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Concordance main entry text or keyword, level 1\",\n fontSize: 12,\n },\n k2: {\n marker: \"k2\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Concordance main entry text or keyword, level 2\",\n fontSize: 12,\n },\n xtSee: {\n marker: \"xtSee\",\n styleType: \"character\",\n endMarker: \"xtSee*\",\n occursUnder: [\"p\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Concordance and Names Index markup for an alternate entry target reference.\",\n fontSize: 12,\n italic: true,\n color: \"#0000FF\",\n },\n xtSeeAlso: {\n marker: \"xtSeeAlso\",\n styleType: \"character\",\n endMarker: \"xtSeeAlso*\",\n occursUnder: [\"p\"],\n textType: \"Other\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"Concordance and Names Index markup for an additional entry target reference.\",\n fontSize: 12,\n italic: true,\n color: \"#0000FF\",\n },\n \"qt-s\": {\n marker: \"qt-s\",\n styleType: \"milestone\",\n endMarker: \"qt-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 1 (if single level)\",\n },\n \"qt1-s\": {\n marker: \"qt1-s\",\n styleType: \"milestone\",\n endMarker: \"qt1-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 1 (if multiple levels)\",\n },\n \"qt2-s\": {\n marker: \"qt2-s\",\n styleType: \"milestone\",\n endMarker: \"qt2-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 2\",\n },\n \"qt3-s\": {\n marker: \"qt3-s\",\n styleType: \"milestone\",\n endMarker: \"qt3-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 3\",\n },\n \"qt4-s\": {\n marker: \"qt4-s\",\n styleType: \"milestone\",\n endMarker: \"qt4-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 4\",\n },\n \"qt5-s\": {\n marker: \"qt5-s\",\n styleType: \"milestone\",\n endMarker: \"qt5-e\",\n occursUnder: [\"id\"],\n description: \"Quotation start/end milestone, level 5\",\n },\n \"ts-s\": {\n marker: \"ts-s\",\n styleType: \"milestone\",\n endMarker: \"ts-e\",\n occursUnder: [\"id\"],\n description: \"Translator's section start/end milestone\",\n },\n ph: {\n marker: \"ph\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with level 1 hanging indent (if single level)\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.5,\n },\n ph1: {\n marker: \"ph1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with level 1 hanging indent (if multiple levels)\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.5,\n },\n ph2: {\n marker: \"ph2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with level 2 hanging indent\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.75,\n },\n ph3: {\n marker: \"ph3\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, with level 3 hanging indent\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 1,\n },\n phi: {\n marker: \"phi\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, indented with hanging indent\",\n leftMargin: 1,\n },\n tr1: {\n marker: \"tr1\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"A table Row\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.5,\n },\n tr2: {\n marker: \"tr2\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"A table Row\",\n fontSize: 12,\n firstLineIndent: -0.25,\n leftMargin: 0.75,\n },\n ps: {\n marker: \"ps\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, no break with next paragraph text at chapter boundary\",\n fontSize: 12,\n firstLineIndent: 0.125,\n },\n psi: {\n marker: \"psi\",\n styleType: \"paragraph\",\n occursUnder: [\"c\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Paragraph text, indented, with no break with next paragraph text (at chapter boundary)\",\n fontSize: 12,\n firstLineIndent: 0.125,\n leftMargin: 0.25,\n rightMargin: 0.25,\n },\n fs: {\n marker: \"fs\",\n styleType: \"character\",\n endMarker: \"fs*\",\n occursUnder: [\"f\", \"fe\"],\n textType: \"NoteText\",\n textProperties: [\"publishable\", \"vernacular\", \"note\"],\n description: \"A summary text for the concept/idea/quotation from the scripture translation for which the note is being provided.\",\n fontSize: 12,\n italic: true,\n },\n wr: {\n marker: \"wr\",\n styleType: \"character\",\n endMarker: \"wr*\",\n occursUnder: [\n \"ms\",\n \"s\",\n \"lh\",\n \"li\",\n \"li1\",\n \"li2\",\n \"li3\",\n \"li4\",\n \"lf\",\n \"lim\",\n \"lim1\",\n \"lim2\",\n \"lim3\",\n \"lim4\",\n \"m\",\n \"mi\",\n \"nb\",\n \"p\",\n \"pc\",\n \"ph\",\n \"phi\",\n \"pi\",\n \"pi1\",\n \"pi2\",\n \"pi3\",\n \"pr\",\n \"po\",\n \"q\",\n \"q1\",\n \"q2\",\n \"q3\",\n \"q4\",\n \"qc\",\n \"qr\",\n \"qd\",\n \"tc1\",\n \"tc2\",\n \"tc3\",\n \"tc4\",\n \"f\",\n \"fe\",\n \"NEST\",\n ],\n textType: \"VerseText\",\n textProperties: [\"publishable\", \"vernacular\"],\n description: \"A Wordlist text item\",\n fontSize: 12,\n italic: true,\n },\n pub: {\n marker: \"pub\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Front matter publication data\",\n fontSize: 10,\n },\n toc: {\n marker: \"toc\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Front matter table of contents\",\n fontSize: 10,\n },\n pref: {\n marker: \"pref\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Front matter preface\",\n fontSize: 10,\n },\n intro: {\n marker: \"intro\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Front matter introduction\",\n fontSize: 10,\n },\n conc: {\n marker: \"conc\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Back matter concordance\",\n fontSize: 10,\n },\n glo: {\n marker: \"glo\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Back matter glossary\",\n fontSize: 10,\n },\n idx: {\n marker: \"idx\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Back matter index\",\n fontSize: 10,\n },\n maps: {\n marker: \"maps\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Back matter map index\",\n fontSize: 10,\n },\n cov: {\n marker: \"cov\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Other peripheral materials - cover\",\n fontSize: 10,\n },\n spine: {\n marker: \"spine\",\n styleType: \"paragraph\",\n occursUnder: [\"id\"],\n rank: 4,\n textType: \"VerseText\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\", \"poetic\"],\n description: \"Other peripheral materials - spine\",\n fontSize: 10,\n },\n pubinfo: {\n marker: \"pubinfo\",\n styleType: \"paragraph\",\n occursUnder: [\"id\", \"ide\"],\n textType: \"Other\",\n textProperties: [\"paragraph\", \"nonpublishable\", \"nonvernacular\"],\n description: \"Publication information - Lang,Credit,Version,Copies,Publisher,Id,Logo\",\n fontSize: 12,\n color: \"#0000FF\",\n },\n \"zpa-xb\": {\n marker: \"zpa-xb\",\n styleType: \"character\",\n endMarker: \"zpa-xb*\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Book Ref\",\n fontSize: 12,\n },\n \"zpa-xc\": {\n marker: \"zpa-xc\",\n styleType: \"character\",\n endMarker: \"zpa-xc*\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Chapter Ref\",\n fontSize: 12,\n bold: true,\n },\n \"zpa-xv\": {\n marker: \"zpa-xv\",\n styleType: \"character\",\n endMarker: \"zpa-xv*\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Verse Ref\",\n fontSize: 12,\n },\n \"zpa-d\": {\n marker: \"zpa-d\",\n styleType: \"character\",\n endMarker: \"zpa-d*\",\n occursUnder: [\"id\"],\n rank: 1,\n textType: \"Other\",\n textProperties: [\"paragraph\", \"publishable\", \"vernacular\"],\n description: \"Description\",\n fontSize: 12,\n },\n },\n};\n","/**\n * Project StyleInfo — the host-agnostic shape of a Paratext project's merged\n * stylesheet (usfm.sty + custom.sty).\n *\n * Unit conventions (match usfm.sty as parsed, not PT9's internal ints):\n * - fontSize, spaceBefore, spaceAfter: points\n * - firstLineIndent, leftMargin, rightMargin: inches (PT9 ScrTag stores\n * thousandths of an inch; hosts divide by 1000 when serializing)\n * - color: \"#RRGGBB\", omitted when black (PT9 CSSCreator skips black)\n * - lineSpacing: PT9 quirk — 1 renders as line-height 1.5, 2 as 2, else nothing\n */\nimport getMarker from \"./getMarker.js\";\nimport { CategoryType, MarkerType } from \"./usfmTypes.js\";\nconst STYLE_TYPE_TO_MARKER_TYPE = {\n paragraph: MarkerType.Paragraph,\n character: MarkerType.Character,\n note: MarkerType.Note,\n milestone: MarkerType.Milestone,\n};\n/**\n * StyleInfo-backed replacement for the bundled `getMarker`. With `styleInfo`,\n * the project sheet is authoritative for a marker's existence and\n * classification: markers absent from it return `undefined` (PT9: unknown to\n * the stylesheet), and `usfmMarkersOverwrites` never overrides those fields.\n * `children` (submenu structure) is editor data keyed by marker name, not\n * stylesheet data, so it still comes from the bundled path (table +\n * overwrites) — children-dependent consumers keep working. Without\n * `styleInfo`, the bundled `getMarker` is returned unchanged so non-project\n * consumers keep today's behavior exactly.\n */\nexport function createMarkerLookup(styleInfo) {\n if (!styleInfo)\n return getMarker;\n const cache = new Map();\n return (marker) => {\n if (cache.has(marker))\n return cache.get(marker);\n // Own-property guard: `markers` is a plain object off the wire, so a bare index resolves\n // Object.prototype members (`constructor`, `toString`, …) as if they were stylesheet\n // entries — handing back a Marker built from a Function.\n const entry = Object.hasOwn(styleInfo.markers, marker) ? styleInfo.markers[marker] : undefined;\n const result = entry\n ? {\n // Through `getMarker`, not the raw generated table: `usfmMarkersOverwrites` supplies\n // markers the generated data lacks (`w`, `rb`, `jmp`), and reading the table directly\n // demoted exactly those to Uncategorized whenever a project StyleInfo was active.\n category: getMarker(marker)?.category ?? CategoryType.Uncategorized,\n type: STYLE_TYPE_TO_MARKER_TYPE[entry.styleType] ?? MarkerType.Unknown,\n description: entry.description ?? \"\",\n hasEndMarker: Boolean(entry.endMarker),\n children: getMarker(marker)?.children,\n }\n : undefined;\n cache.set(marker, result);\n return result;\n };\n}\n","import { USJ_TYPE, USJ_VERSION, } from \"@eten-tech-foundation/scripture-utilities\";\nimport { isSerializedImpliedParaNode } from \"../../nodes/usj/ImpliedParaNode.js\";\nexport function createLexicalUsjNode(content, editorAdaptor, viewOptions) {\n const usj = {\n type: USJ_TYPE,\n version: USJ_VERSION,\n content,\n };\n const lexicalSerializedRoot = editorAdaptor.serializeEditorState(usj, viewOptions);\n const lexicalSerializedNode = isSerializedImpliedParaNode(lexicalSerializedRoot.root.children[0])\n ? lexicalSerializedRoot.root.children[0].children[0]\n : lexicalSerializedRoot.root.children[0];\n return lexicalSerializedNode;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\n/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/cv/v.html */\nimport { $applyNodeReplacement, DecoratorNode, isHTMLElement, } from \"lexical\";\nimport { useLexicalNodeSelection } from \"@lexical/react/useLexicalNodeSelection\";\nimport { getVisibleOpenMarkerText, IMMUTABLE_VERSE_NODE_TYPE, isSelectionStartNodeExpectedError, VERSE_CLASS_NAME, ZWSP, } from \"shared\";\nexport const VERSE_MARKER = \"v\";\nexport const IMMUTABLE_VERSE_VERSION = 1;\n/**\n * Class applied to the rendered verse marker while it is in a NodeSelection (e.g. armed for the\n * two-step intentional delete). Themeable by the host app; a default selection-style background\n * ships in the platform stylesheet.\n */\nexport const VERSE_SELECTED_CLASS_NAME = \"verse-selected\";\nexport class ImmutableVerseNode extends DecoratorNode {\n __marker;\n __number;\n __showMarker;\n __sid;\n __altnumber;\n __pubnumber;\n __unknownAttributes;\n constructor(verseNumber = \"\", showMarker = false, sid, altnumber, pubnumber, unknownAttributes, key) {\n super(key);\n this.__marker = VERSE_MARKER;\n this.__number = verseNumber;\n this.__showMarker = showMarker;\n this.__sid = sid;\n this.__altnumber = altnumber;\n this.__pubnumber = pubnumber;\n this.__unknownAttributes = unknownAttributes;\n }\n static getType() {\n return IMMUTABLE_VERSE_NODE_TYPE;\n }\n static clone(node) {\n const { __number, __showMarker, __sid, __altnumber, __pubnumber, __unknownAttributes, __key } = node;\n return new ImmutableVerseNode(__number, __showMarker, __sid, __altnumber, __pubnumber, __unknownAttributes, __key);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isVerseElement(node))\n return null;\n return {\n conversion: $convertImmutableVerseElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createImmutableVerseNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setMarker(serializedNode.marker)\n .setNumber(serializedNode.number)\n .setShowMarker(serializedNode.showMarker)\n .setSid(serializedNode.sid)\n .setAltnumber(serializedNode.altnumber)\n .setPubnumber(serializedNode.pubnumber)\n .setUnknownAttributes(serializedNode.unknownAttributes);\n }\n setMarker(marker) {\n if (this.__marker === marker)\n return this;\n const self = this.getWritable();\n self.__marker = marker;\n return self;\n }\n getMarker() {\n const self = this.getLatest();\n return self.__marker;\n }\n setNumber(verseNumber) {\n if (this.__number === verseNumber)\n return this;\n const self = this.getWritable();\n self.__number = verseNumber;\n return self;\n }\n getNumber() {\n const self = this.getLatest();\n return self.__number;\n }\n setShowMarker(showMarker = false) {\n if (this.__showMarker === showMarker)\n return this;\n const self = this.getWritable();\n self.__showMarker = showMarker;\n return self;\n }\n getShowMarker() {\n const self = this.getLatest();\n return self.__showMarker;\n }\n setSid(sid) {\n if (this.__sid === sid)\n return this;\n const self = this.getWritable();\n self.__sid = sid;\n return self;\n }\n getSid() {\n const self = this.getLatest();\n return self.__sid;\n }\n setAltnumber(altnumber) {\n if (this.__altnumber === altnumber)\n return this;\n const self = this.getWritable();\n self.__altnumber = altnumber;\n return self;\n }\n getAltnumber() {\n const self = this.getLatest();\n return self.__altnumber;\n }\n setPubnumber(pubnumber) {\n if (this.__pubnumber === pubnumber)\n return this;\n const self = this.getWritable();\n self.__pubnumber = pubnumber;\n return self;\n }\n getPubnumber() {\n const self = this.getLatest();\n return self.__pubnumber;\n }\n setUnknownAttributes(unknownAttributes) {\n const self = this.getWritable();\n self.__unknownAttributes = unknownAttributes;\n return self;\n }\n getUnknownAttributes() {\n const self = this.getLatest();\n return self.__unknownAttributes;\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.setAttribute(\"data-marker\", this.__marker);\n dom.classList.add(VERSE_CLASS_NAME, `usfm_${this.__marker}`);\n if (this.__showMarker)\n dom.classList.add(\"marker\");\n dom.setAttribute(\"data-number\", this.__number);\n return dom;\n }\n updateDOM() {\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.setAttribute(\"data-marker\", this.getMarker());\n element.classList.add(VERSE_CLASS_NAME, `usfm_${this.getMarker()}`);\n element.setAttribute(\"data-number\", this.getNumber());\n }\n return { element };\n }\n decorate() {\n return _jsx(VerseDecorator, { nodeKey: this.getKey(), text: this.getRenderedText() });\n }\n /** The text this verse shows on screen: its whole `\\v N` glyph, or only its number. */\n getRenderedText() {\n return this.getShowMarker()\n ? getVisibleOpenMarkerText(this.getMarker(), this.getNumber())\n : // ZWSP added so double click word selection works without including this number.\n ZWSP + this.getNumber() + ZWSP;\n }\n exportJSON() {\n return {\n type: this.getType(),\n marker: this.getMarker(),\n number: this.getNumber(),\n showMarker: this.getShowMarker(),\n sid: this.getSid(),\n altnumber: this.getAltnumber(),\n pubnumber: this.getPubnumber(),\n unknownAttributes: this.getUnknownAttributes(),\n version: IMMUTABLE_VERSE_VERSION,\n };\n }\n isSelected(selection) {\n // The base implementation calls `selection.getNodes()`, which throws when a RangeSelection\n // has an element-type point anchored on this DecoratorNode (the \"cursor on the verse number\"\n // case). Treat that expected throw as \"not selected\", consistent with how\n // `getSelectionStartNode` handles the same selection shape.\n try {\n return super.isSelected(selection);\n }\n catch (err) {\n if (isSelectionStartNodeExpectedError(err))\n return false;\n throw err;\n }\n }\n // Mutation\n isKeyboardSelectable() {\n return false;\n }\n}\n/**\n * Renders the verse marker text and reflects its node-selection state. DecoratorNodes do not get\n * selection styling for free, so this subscribes to the node's selection and toggles\n * {@link VERSE_SELECTED_CLASS_NAME}.\n */\nfunction VerseDecorator({ nodeKey, text }) {\n const [isSelected] = useLexicalNodeSelection(nodeKey);\n // ZWSPs stay inside this span so double-click word selection still excludes the number.\n return _jsx(\"span\", { className: isSelected ? VERSE_SELECTED_CLASS_NAME : undefined, children: text });\n}\nfunction $convertImmutableVerseElement(element) {\n const verseNumber = element.getAttribute(\"data-number\") ?? \"0\";\n const node = $createImmutableVerseNode(verseNumber);\n return { node };\n}\nexport function $createImmutableVerseNode(verseNumber, showMarker, sid, altnumber, pubnumber, unknownAttributes) {\n return $applyNodeReplacement(new ImmutableVerseNode(verseNumber, showMarker, sid, altnumber, pubnumber, unknownAttributes));\n}\nfunction isVerseElement(node) {\n const marker = node?.getAttribute(\"data-marker\") ?? undefined;\n return marker === VERSE_MARKER;\n}\nexport function $isImmutableVerseNode(node) {\n return node instanceof ImmutableVerseNode;\n}\nexport function isSerializedImmutableVerseNode(node) {\n return node?.type === ImmutableVerseNode.getType();\n}\n","import { $isImmutableVerseNode, isSerializedImmutableVerseNode, } from \"./ImmutableVerseNode\";\nimport { $getNodeByKey, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, } from \"lexical\";\nimport { $findNearestPreviousNode, $isNodeWithMarker, $isParaNode, $isSomeChapterNode, $isVerseBlockNode, $isVerseNode, isSerializedVerseNode, isVerseInRange, NBSP, } from \"shared\";\n/**\n * Checks if the given node is a VerseNode or ImmutableVerseNode.\n * @param node - The node to check.\n * @returns `true` if the node is a VerseNode or ImmutableVerseNode, `false` otherwise.\n */\nexport function $isSomeVerseNode(node) {\n return $isVerseNode(node) || $isImmutableVerseNode(node);\n}\n/**\n * Checks if the given node is a SerializedVerseNode or SerializedImmutableVerseNode.\n * @param node - The serialized node to check.\n * @returns `true` if the node is a SerializedVerseNode or SerializedImmutableVerseNode, `false` otherwise.\n */\nexport function isSomeSerializedVerseNode(node) {\n return isSerializedVerseNode(node) || isSerializedImmutableVerseNode(node);\n}\n/**\n * Finds the first paragraph that is not a book or chapter node.\n * @param nodes - Nodes to look in.\n * @returns the first paragraph node.\n */\nexport function $getFirstPara(nodes) {\n return $expandVerseBlocks(nodes).find((node) => $isParaNode(node));\n}\n/**\n * The given nodes with any `VerseBlockNode` replaced by its own paragraphs.\n *\n * In the block verse layout a verse sits two levels below the root - `VerseBlockNode > ParaNode >\n * verse` - so anything searching for verses or paragraphs has to see through the block. Returns\n * the input unchanged when there are no verse blocks, leaving the inline layouts untouched.\n */\nfunction $expandVerseBlocks(nodes) {\n if (!nodes.some($isVerseBlockNode))\n return nodes;\n return nodes.flatMap((node) => ($isVerseBlockNode(node) ? node.getChildren() : node));\n}\n/**\n * The nodes among which a verse marker would sit, for a container that might hold one.\n *\n * For a paragraph that is its own children. For a verse block it is the children of each of its\n * paragraphs, in document order, since the block holds paragraphs and the markers live inside\n * those. Callers can then treat both the same way.\n */\nfunction $getVerseSiblings(node) {\n if (!$isElementNode(node))\n return [];\n if ($isVerseBlockNode(node))\n return node.getChildren().flatMap($getVerseSiblings);\n return node.getChildren();\n}\n/**\n * Find the given verse in the children of the node.\n * @param node - Node with potential verses in children.\n * @param verseNum - Verse number to look for.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findVerseInNode(node, verseNum) {\n const children = $getVerseSiblings(node);\n const verseNode = children.find((child) => $isSomeVerseNode(child) && isVerseInRange(verseNum, child.getNumber()));\n return verseNode;\n}\n/**\n * Finds the verse node with the given verse number amongst the children of nodes.\n * @param nodes - Nodes to look in.\n * @param verseNum - Verse number to look for.\n * @returns the verse node if found, or the first paragraph if verse 0, `undefined` otherwise.\n */\nexport function $findVerseOrPara(nodes, verseNum) {\n return verseNum === 0\n ? $getFirstPara(nodes)\n : nodes\n .map((node) => $findVerseInNode(node, verseNum))\n // remove any undefined results and take the first found\n .filter((verseNode) => verseNode)[0];\n}\n/**\n * Find the next verse in the children of the node.\n * @param node - Node with potential verses in children.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findNextVerseInNode(node) {\n const verseNode = $getVerseSiblings(node).find((child) => $isSomeVerseNode(child));\n return verseNode;\n}\n/**\n * Finds the next verse node amongst the children of nodes.\n * @param nodes - Nodes to look in.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findNextVerse(nodes) {\n return (nodes\n .map((node) => $findNextVerseInNode(node))\n // remove any undefined results and take the first found\n .filter((verseNode) => verseNode)[0]);\n}\n/**\n * Find the previous verse node in a parent's children, walking backward from the given index.\n * @param parent - Element node whose children to search.\n * @param fromIndex - Start index (exclusive); search from fromIndex - 1 down to 0.\n * @returns The verse node if found, `undefined` otherwise.\n */\nexport function $findPreviousVerseInSiblings(parent, fromIndex) {\n if (!$isElementNode(parent) || fromIndex <= 0)\n return;\n const children = parent.getChildren();\n for (let i = fromIndex - 1; i >= 0; i--) {\n const child = children[i];\n if ($isSomeVerseNode(child))\n return child;\n }\n return undefined;\n}\n/**\n * Find the next verse node after `verseNode` in document order, stopping at the next chapter\n * boundary (or the end of the document). Forward counterpart to `$findPreviousVerseInSiblings` /\n * the backward walk in `$findThisVerse`.\n * @param verseNode - The verse node to search forward from.\n * @returns The next verse node, or `undefined` if none exists before the next chapter/document end.\n */\nexport function $findNextVerseAfter(verseNode) {\n const parent = verseNode.getParent();\n if (parent && $isElementNode(parent)) {\n const children = parent.getChildren();\n for (let i = verseNode.getIndexWithinParent() + 1; i < children.length; i++) {\n const child = children[i];\n if ($isSomeVerseNode(child))\n return child;\n }\n }\n let nextPara = parent?.getNextSibling();\n while (nextPara && !$isSomeChapterNode(nextPara)) {\n const verse = $findNextVerseInNode(nextPara);\n if (verse)\n return verse;\n nextPara = nextPara.getNextSibling();\n }\n return undefined;\n}\n/**\n * Find the last verse in the children of the node.\n * @param node - Node with potential verses in children.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findLastVerseInNode(node) {\n return $getVerseSiblings(node).findLast((child) => $isSomeVerseNode(child));\n}\n/**\n * Finds the last verse node amongst the children of nodes.\n * @param nodes - Nodes to look in.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findLastVerse(nodes) {\n const verseNodes = nodes\n .map((node) => $findLastVerseInNode(node))\n // remove any undefined results\n .filter((verseNode) => verseNode);\n if (verseNodes.length <= 0)\n return;\n return verseNodes[verseNodes.length - 1];\n}\n/**\n * Offset just past the verse number within a verse node's own text, for the BCV \"before vs after\"\n * check. Everything up to it is the marker rather than the verse's content, so a caret there\n * belongs to the PRECEDING verse.\n *\n * The number does not always sit at offset 0: in views that render markers as editable text the\n * verse node's text is the whole marker (`\\v 3 `), and a caret at its offset 0 is the position\n * just past whatever ends the previous verse — a note caller, most often, since a note on a\n * verse's last word puts the next verse's marker directly after it.\n *\n * If the text doesn't contain the verse number (e.g. `$createVerseNode(\"1\", \" verse one\")`) or the\n * node is a non-VerseNode (e.g. ImmutableVerseNode, whose whole node is the number), returns 0 —\n * treats all positions as \"after\" and shows the current verse.\n */\nfunction getVerseNumberPrefixLength(verseNode) {\n if (!$isVerseNode(verseNode))\n return 0;\n const verseNumber = verseNode.getNumber();\n if (!verseNumber)\n return 0;\n // Only the marker's own syntax can precede the number, and no digit appears in it, so the first\n // occurrence is the number itself.\n const numberIndex = verseNode.getTextContent().indexOf(verseNumber);\n return numberIndex < 0 ? 0 : numberIndex + verseNumber.length;\n}\n/**\n * Returns true when the selection anchor is positioned before the given verse node in document\n * order. Handles: (1) cursor inside the verse's parent with offset before this verse's index,\n * (2) cursor in the verse's previous sibling.\n */\nfunction $isSelectionBeforeVerseNode(selection, verseNode, anchorNode) {\n if (!anchorNode)\n return false;\n const parent = verseNode.getParent();\n if (anchorNode === parent && $isElementNode(anchorNode)) {\n const verseIndex = verseNode.getIndexWithinParent();\n const anchorOffset = selection.anchor.offset;\n return anchorOffset <= verseIndex;\n }\n if (anchorNode.getNextSibling() === verseNode)\n return true;\n return false;\n}\n/**\n * Returns true when BCV should show the previous verse (cursor is before the verse number).\n * Encapsulates: anchor in parent/previous sibling before verse; anchor in verse node before\n * verse number (TextNode) or on whole node (DecoratorNode).\n */\nfunction $shouldShowPreviousVerseForBcv(verseNode, selection) {\n const anchorNode = selection.anchor.getNode();\n // Anchor not on verse node: check if cursor is before verse (parent offset or previous sibling)\n if (anchorNode !== verseNode) {\n return $isSelectionBeforeVerseNode(selection, verseNode, anchorNode);\n }\n // Anchor on verse node: show previous if cursor is before verse number\n if ($isTextNode(verseNode)) {\n const prefixLength = getVerseNumberPrefixLength(verseNode);\n return selection.anchor.offset < prefixLength;\n }\n // ImmutableVerseNode (DecoratorNode): whole node is verse number; show previous\n return true;\n}\n/** Build result for current verse (no selection or cursor after verse number). */\nfunction currentVerseResult(verseNode) {\n const verse = verseNode.getNumber();\n const selectedVerseNum = Number.parseInt(verse ?? \"0\", 10);\n return {\n verseNum: selectedVerseNum,\n verse: verse != null && selectedVerseNum.toString() !== verse ? verse : undefined,\n };\n}\n/**\n * The verse node before `verseNode` in document order, within its chapter.\n * @param verseNode - The verse node to look before.\n * @returns the previous verse node, or `undefined` when `verseNode` is its chapter's first.\n */\nfunction $findPreviousVerse(verseNode) {\n const previous = $findNearestPreviousNode(verseNode);\n if (!previous || $isSomeChapterNode(previous))\n return undefined;\n if ($isSomeVerseNode(previous))\n return previous;\n return $findLastVerseInNode(previous) ?? $findThisVerse(previous);\n}\n/**\n * Returns the verse number (and optional verse range) for BCV display. When the cursor is\n * before the verse number, returns the verse before it - the actual previous verse node when the\n * chapter has one, so a caret before `\\v 3` after `\\v 1-2` reports `{ verseNum: 1, verse: \"1-2\" }`\n * and one before `\\v 2b` reports `{ verseNum: 2, verse: \"2a\" }`. Only when no earlier verse exists\n * in the chapter is it inferred from the number: e.g. cursor before a lone \"2-3\" → `{ verseNum: 1 }`.\n *\n * Read-only: call inside `editor.update()` or `editor.getEditorState().read()`.\n *\n * @param verseNode - The verse node that contains or precedes the cursor.\n * @param selection - The current editor selection.\n * @returns Effective verse number and optional verse range string for BCV display.\n */\nexport function $getEffectiveVerseForBcv(verseNode, selection) {\n if (!verseNode)\n return { verseNum: 0 };\n // No selection or not range: use verse node as-is\n if (!$isRangeSelection(selection)) {\n return currentVerseResult(verseNode);\n }\n const selectedVerseNum = Number.parseInt(verseNode.getNumber() ?? \"0\", 10);\n const prevNum = selectedVerseNum <= 1 ? 0 : selectedVerseNum - 1;\n // Anchor before verse number: show previous verse\n if ($shouldShowPreviousVerseForBcv(verseNode, selection)) {\n const previousVerse = $findPreviousVerse(verseNode);\n return previousVerse ? currentVerseResult(previousVerse) : { verseNum: prevNum };\n }\n return currentVerseResult(verseNode);\n}\n/**\n * Checks if the node has a `getMarker` method. Includes all React nodes.\n * @param node - LexicalNode to check.\n * @returns `true` if the node has a `getMarker` method, `false` otherwise.\n */\nexport function $isReactNodeWithMarker(node) {\n return $isNodeWithMarker(node) || $isImmutableVerseNode(node);\n}\n/**\n * Add trailing space to a TextNode\n * @param node - Text node to add trailing space to.\n */\nexport function $addTrailingSpace(node) {\n if ($isTextNode(node)) {\n const text = node.getTextContent();\n if (!text.endsWith(\" \") && !text.endsWith(NBSP))\n node.setTextContent(`${text} `);\n }\n}\n/**\n * Removes any leading space from a TextNode. A selection point in that text moves back with\n * it, so a caret at its end is not left past the end of the shortened text.\n *\n * Mutating: call inside `editor.update()` or a node transform.\n * @param node - Text node to remove leading space from.\n */\nexport function $removeLeadingSpace(node) {\n if (!$isTextNode(node))\n return;\n const text = node.getTextContent();\n if (!text.startsWith(\" \"))\n return;\n const trimmed = text.trimStart();\n const removed = text.length - trimmed.length;\n node.setTextContent(trimmed);\n const selection = $getSelection();\n if (!$isRangeSelection(selection))\n return;\n for (const point of [selection.anchor, selection.focus]) {\n if (point.type === \"text\" && point.key === node.getKey())\n point.set(point.key, Math.max(0, point.offset - removed), \"text\");\n }\n}\n/**\n * Checks if the node was created since the previous editor state.\n * @param editor - The lexical editor instance.\n * @param nodeKey - The key of the node.\n * @returns `true` if the node was created, and `false` otherwise.\n */\nexport function wasNodeCreated(editor, nodeKey) {\n return editor.getEditorState().read(() => !$getNodeByKey(nodeKey));\n}\n/**\n * Moves the selection to the start of the next verse's content (after the verse marker).\n * Used for ArrowDown navigation so the cursor lands on a position that ScriptureReferencePlugin\n * can resolve for BCV display.\n * @param selection - The current range selection (must be collapsed).\n * @returns `true` if the selection was moved, `false` if not collapsed or no next verse.\n */\nexport function $selectNextVerse(selection) {\n if (!selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const currentVerse = $resolveVerseNode(anchorNode, selection);\n let nextVerse;\n if (currentVerse) {\n const parent = currentVerse.getParent();\n // When the cursor is on a block (e.g. para) before the first verse in that block,\n // $resolveVerseNode falls back to the first verse in the paragraph. That verse is\n // ahead of the caret — it should be the ArrowDown target, not skipped as \"current\".\n if (parent &&\n $isElementNode(parent) &&\n $isElementNode(anchorNode) &&\n anchorNode === parent &&\n selection.anchor.offset < currentVerse.getIndexWithinParent()) {\n nextVerse = currentVerse;\n }\n if (!nextVerse && parent && $isElementNode(parent)) {\n const children = parent.getChildren();\n const currentIndex = currentVerse.getIndexWithinParent();\n for (let i = currentIndex + 1; i < children.length; i++) {\n const child = children[i];\n if ($isSomeVerseNode(child)) {\n nextVerse = child;\n break;\n }\n }\n }\n if (!nextVerse && parent) {\n let nextPara = $getNextSearchSibling(parent);\n while (nextPara && !$isSomeChapterNode(nextPara)) {\n const verse = $findNextVerseInNode(nextPara);\n if (verse) {\n nextVerse = verse;\n break;\n }\n nextPara = $getNextSearchSibling(nextPara);\n }\n }\n }\n else {\n const topLevel = anchorNode.getTopLevelElement();\n let para = topLevel ?? anchorNode;\n while (para) {\n const verse = $findNextVerseInNode(para);\n if (verse) {\n nextVerse = verse;\n break;\n }\n para = para.getNextSibling();\n if (para && $isSomeChapterNode(para))\n break;\n }\n }\n if (!nextVerse)\n return false;\n nextVerse.selectNext(0, 0);\n return true;\n}\n/**\n * Moves the selection to the start of the previous verse's content (after the verse marker).\n * Used for ArrowUp navigation so the cursor lands on a position that ScriptureReferencePlugin\n * can resolve for BCV display.\n * @param selection - The current range selection (must be collapsed).\n * @returns `true` if the selection was moved, `false` if not collapsed or no previous verse.\n */\nexport function $selectPreviousVerse(selection) {\n if (!selection.isCollapsed())\n return false;\n const anchorNode = selection.anchor.getNode();\n const currentVerse = $resolveVerseNode(anchorNode, selection);\n let prevVerse;\n if (currentVerse) {\n const parent = currentVerse.getParent();\n // When the cursor is in a different (later) paragraph than currentVerse's parent,\n // $resolveVerseNode found the verse via backward traversal across paragraphs.\n // That verse is behind the caret — it should be the ArrowUp target directly.\n const topLevel = anchorNode.getTopLevelElement();\n // Compare the caret's block against the verse's own block. Everywhere but the block verse\n // layout a paragraph is its own top-level element - including inside a table, whose cells are\n // shadow roots - so this is the same test as comparing against the paragraph. In block verse\n // the paragraph's top-level element is its verse block, which is what makes it correct there.\n if (parent && topLevel && topLevel !== parent.getTopLevelElement()) {\n prevVerse = currentVerse;\n }\n if (!prevVerse && parent && $isElementNode(parent)) {\n prevVerse = $findPreviousVerseInSiblings(parent, currentVerse.getIndexWithinParent());\n }\n if (!prevVerse && parent) {\n let prevPara = $getPreviousSearchSibling(parent);\n while (prevPara && !$isSomeChapterNode(prevPara)) {\n const verse = $findLastVerseInNode(prevPara);\n if (verse) {\n prevVerse = verse;\n break;\n }\n prevPara = $getPreviousSearchSibling(prevPara);\n }\n }\n }\n else {\n const topLevel = anchorNode.getTopLevelElement();\n let prevPara = topLevel?.getPreviousSibling() ?? null;\n while (prevPara && !$isSomeChapterNode(prevPara)) {\n const verse = $findLastVerseInNode(prevPara);\n if (verse) {\n prevVerse = verse;\n break;\n }\n prevPara = prevPara.getPreviousSibling();\n }\n }\n if (!prevVerse)\n return false;\n prevVerse.selectNext(0, 0);\n return true;\n}\n/**\n * The next node to search when walking forward looking for a verse.\n *\n * Normally the node's next sibling. In the block verse layout a paragraph's siblings run out at\n * the end of its verse block, so the walk continues from the block's own next sibling rather than\n * stopping inside it. Behaves exactly like `getNextSibling` for a top-level node.\n */\nfunction $getNextSearchSibling(node) {\n const nextSibling = node.getNextSibling();\n if (nextSibling)\n return nextSibling;\n const topLevel = node.getTopLevelElement();\n return topLevel && topLevel !== node ? topLevel.getNextSibling() : null;\n}\n/** Mirror of {@link $getNextSearchSibling} for a backward walk. */\nfunction $getPreviousSearchSibling(node) {\n const previousSibling = node.getPreviousSibling();\n if (previousSibling)\n return previousSibling;\n const topLevel = node.getTopLevelElement();\n return topLevel && topLevel !== node ? topLevel.getPreviousSibling() : null;\n}\n/**\n * Resolves the verse node for the given start node. When the cursor is on an element\n * (e.g. para) rather than inside a verse, looks at the child at offset or walks backward\n * within that element before falling back to $findThisVerse (which may walk to prior paras).\n */\nexport function $resolveVerseNode(startNode, selection) {\n const isCursorOnElement = $isElementNode(startNode) &&\n $isRangeSelection(selection) &&\n selection.anchor.key === startNode.getKey();\n if (isCursorOnElement) {\n const childAtOffset = startNode.getChildAtIndex(selection.anchor.offset);\n if (childAtOffset && $isSomeVerseNode(childAtOffset))\n return childAtOffset;\n const prev = $findPreviousVerseInSiblings(startNode, selection.anchor.offset);\n if (prev)\n return prev;\n const firstVerseInPara = $findNextVerseInNode(startNode);\n if (firstVerseInPara)\n return firstVerseInPara;\n }\n return $findThisVerse(startNode);\n}\n/**\n * Find the verse that this node is in.\n * @param node - Node to find the verse it's in.\n * @returns the verse node if found, `undefined` otherwise.\n */\nexport function $findThisVerse(node) {\n if (!node || $isSomeChapterNode(node))\n return;\n // is this node a verse\n if ($isSomeVerseNode(node))\n return node;\n let previousSiblingOrParent = $findNearestPreviousNode(node);\n while (previousSiblingOrParent) {\n // If this node is a chapter node, stop searching as we've reached the start of this chapter\n if ($isSomeChapterNode(previousSiblingOrParent))\n return;\n // If this node is a verse node, return it\n if ($isSomeVerseNode(previousSiblingOrParent))\n return previousSiblingOrParent;\n // If this node contains a verse node, return that\n const verseNode = $findLastVerseInNode(previousSiblingOrParent);\n if (verseNode)\n return verseNode;\n previousSiblingOrParent = $findNearestPreviousNode(previousSiblingOrParent);\n }\n return undefined;\n}\n","/**\n * Models for the rich-text Operational Transform documents used in Scripture Forge.\n * `OT_???_PROPS` are the properties that can be set on the corresponding Lexical node. The rest go\n * into unknownAttributes.\n */\nexport const OT_PARA_PROPS = [\"style\"];\nexport const OT_BOOK_PROPS = [\"style\", \"code\"];\nexport const OT_CHAR_PROPS = [\"style\", \"cid\"];\nexport const OT_CHAPTER_PROPS = [\n \"style\",\n \"number\",\n \"sid\",\n \"altnumber\",\n \"pubnumber\",\n];\nexport const OT_VERSE_PROPS = [\n \"style\",\n \"number\",\n \"sid\",\n \"altnumber\",\n \"pubnumber\",\n];\nexport const OT_MILESTONE_PROPS = [\n \"style\",\n \"sid\",\n \"eid\",\n \"attributeOrder\",\n];\n// Note that `contents` is not a property of a NoteNode, but we don't want it in unknownAttributes.\nexport const OT_NOTE_PROPS = [\"style\", \"caller\", \"category\", \"contents\"];\nexport const OT_UNKNOWN_PROPS = [\"tag\", \"marker\", \"contents\"];\nexport const validOTEmbedTypes = [\n \"chapter\",\n \"immutable-chapter\",\n \"verse\",\n \"immutable-verse\",\n \"ms\",\n \"note\",\n \"unknown\",\n \"unmatched\",\n];\n","/** Common utilities used for OT Delta realtime collaborative editing. */\nimport { $isSomeVerseNode } from \"../../../nodes/usj/node-react.utils\";\nimport { validOTEmbedTypes } from \"./rich-text-ot.model\";\nimport { $dfsIterator, $findMatchingParent } from \"@lexical/utils\";\nimport { $getNodeByKey, $getState, $isElementNode, $isTextNode, } from \"lexical\";\nimport { $getLogicalParent, $isAttributeRunNode, $isCaretHost, $isCharNode, $isDescendantOf, $isImmutableUnmatchedNode, $isMilestoneNode, $isNoteNode, $isParaLikeNode, $isParaNode, $isDisplayRunPiece, $isSomeChapterNode, $isSynthesizedMarkerNode, $isUnknownNode, $noteEditableCallerNode, EMPTY_CHAR_PLACEHOLDER_TEXT, NODE_ATTRIBUTE_PREFIX, textTypeState, typedCallerBytes, } from \"shared\";\n/** Line Feed character used to close para-like nodes.*/\nexport const LF = \"\\n\";\n/**\n * Get the replace embed operations for a given embed node key.\n *\n * @remarks\n * The returned ops are host-local: they are meant to be fed straight to `$applyUpdate`, so\n * the retain is computed in `\"apply\"` coordinates (see {@link OTCoordinateSystem}) to agree\n * with `$applyUpdate`'s insert/delete traversals.\n *\n * @param embedNodeKey - The key of the embed node to replace.\n * @param insertEmbedOps - The operations to insert the new embed node. Any after the first are\n * inserted right after it, once the old embed is deleted: inserted before that delete, text lands\n * at the old embed's position and is deleted along with it.\n * @returns The replace embed operations, or `undefined` if the node is not found.\n */\nexport function $getReplaceEmbedOps(embedNodeKey, insertEmbedOps) {\n const node = $getNodeByKey(embedNodeKey);\n if (!$isEmbedNode(node))\n return;\n const retain = $getOTPositionOfNode(node, \"apply\");\n if (retain === undefined)\n return;\n const [embedOp, ...following] = insertEmbedOps;\n const ops = [{ retain }, ...(embedOp ? [embedOp] : []), { delete: 1 }, ...following];\n return ops;\n}\n/**\n * Calculate the OT (Operational Transform) position of a given node in the document.\n *\n * @remarks\n * - Text nodes return their start position\n * - Embed nodes (chapter, verse, milestone, note, unmatched) return their position (length 1)\n * - Para-like nodes (ParaNode, BookNode, ImpliedParaNode) return their closing position (length 1)\n * - CharNodes have no OT length contribution\n *\n * @param node - The Lexical node to find the position for.\n * @param coordinates - The OT coordinate system to count in (see {@link OTCoordinateSystem}).\n * Defaults to the legacy `\"delta-doc\"` counting; pass `\"apply\"` for positions consumed by\n * `$applyUpdate`.\n * @returns The OT position of the node, or `undefined` if the node is not found.\n */\nexport function $getOTPositionOfNode(node, coordinates = \"delta-doc\") {\n if (!node)\n return undefined;\n // LAZY traversal, terminated by the early returns below: this runs per keystroke on\n // DeltaOnChangePlugin's fast path, and the eager `$dfs()` array materialized the ENTIRE\n // document each call regardless of where the target sat.\n const dfsNodes = $dfsIterator();\n let currentIndex = 0;\n const openParaLikeNodes = [];\n const openContentEmbeds = [];\n const targetKey = node.getKey();\n let targetParaLikeNode;\n for (const dfsNode of dfsNodes) {\n const currentNode = dfsNode.node;\n // Before processing the current node, check if any previously opened para-like nodes are\n // closing.\n for (let j = openParaLikeNodes.length - 1; j >= 0; j--) {\n if ($isElementNodeClosing(openParaLikeNodes[j], dfsNode)) {\n const closingPara = openParaLikeNodes[j];\n openParaLikeNodes.splice(j, 1);\n currentIndex += 1;\n // If this is the target para-like node closing, return its position\n if (targetParaLikeNode && closingPara.getKey() === targetParaLikeNode.getKey()) {\n return currentIndex - 1; // Return the position we just incremented\n }\n }\n }\n // Check if any open content embed nodes (note/unknown) are closing\n for (let j = openContentEmbeds.length - 1; j >= 0; j--) {\n if ($isElementNodeClosing(openContentEmbeds[j].node, dfsNode)) {\n openContentEmbeds.splice(j, 1);\n }\n }\n const activeContentEmbed = openContentEmbeds[openContentEmbeds.length - 1];\n if (activeContentEmbed) {\n if (currentNode.getKey() === targetKey) {\n return activeContentEmbed.position;\n }\n continue;\n }\n // Check if we've found the target node\n if (currentNode.getKey() === targetKey) {\n // For text nodes, return the start position (an editable verse is an embed, not text —\n // see $isOTTextNode — so it falls to the embed check below)\n if ($isOTTextNode(currentNode))\n return currentIndex;\n // For embed nodes, return their position\n if ($isEmbedNode(currentNode))\n return currentIndex;\n // For para-like nodes, mark it and continue to find its closing position\n if ($isParaLikeNode(currentNode)) {\n targetParaLikeNode = currentNode;\n // Continue processing to find where this para closes\n }\n // For CharNodes or other nodes that don't have OT positions, continue searching\n // (CharNodes don't have their own position, their text content does)\n }\n // Track opening of para-like nodes after checking for target\n if ($isParaLikeNode(currentNode)) {\n if (!openParaLikeNodes.includes(currentNode)) {\n openParaLikeNodes.push(currentNode);\n }\n }\n // Track when we enter an opaque content container (note/unknown always; any element\n // embed such as an editable chapter in \"apply\" coordinates)\n if ($isOpaqueContentNode(currentNode, coordinates)) {\n if (currentNode.getKey() === targetKey)\n return currentIndex;\n openContentEmbeds.push({ node: currentNode, position: currentIndex });\n currentIndex += 1; // Embeds contribute 1 to OT length\n continue; // Skip normal OT contribution calculation for embed contents\n }\n // Calculate OT length contribution of current node\n currentIndex += $getNodeOTContribution(currentNode, coordinates);\n }\n // If we're looking for a para-like node that didn't close, return current position\n if (targetParaLikeNode)\n return currentIndex;\n // Node not found\n return undefined;\n}\n/**\n * Get the key of the inserted node from the OT delta operations.\n * @param ops - The OT delta operations with potential insertion.\n * @param editorState - The current editor state.\n * @param coordinates - The OT coordinate system the retain in `ops` is expressed in (see\n * {@link OTCoordinateSystem}). Use `\"apply\"` when the ops were applied by `$applyUpdate`\n * (the node was placed at the retain in apply coordinates); use the default `\"delta-doc\"`\n * for retains produced by doc-delta diffs (e.g. `DeltaOnChangePlugin` local-edit ops).\n * @returns The key of the inserted node if found, `undefined` otherwise.\n */\nexport function getInsertedNodeKey(ops, editorState, coordinates = \"delta-doc\") {\n if (ops.length < 2 || !isRetainOp(ops[0]) || !isInsertEmbedOp(ops[1]))\n return undefined;\n const retain = ops[0].retain;\n return editorState.read(() => {\n const node = $getNodeFromOTPosition(retain, coordinates);\n return node?.getKey();\n });\n}\n/**\n * Get the Lexical node at a specific OT delta position.\n *\n * @remarks\n * This is the reverse of {@link $getOTPositionOfNode}: both must count in the SAME\n * coordinate system for round trips to resolve to the same node.\n *\n * @param otPosition - The OT delta position in the doc.\n * @param coordinates - The OT coordinate system to count in (see {@link OTCoordinateSystem}).\n * @returns The Lexical node if found, `undefined` otherwise.\n */\nexport function $getNodeFromOTPosition(otPosition, coordinates = \"delta-doc\") {\n // LAZY traversal, terminated by the early returns below — same reasoning as\n // $getOTPositionOfNode: the walk stops at the resolved position instead of first\n // materializing the entire document.\n const dfsNodes = $dfsIterator();\n let currentIndex = 0;\n const openParaLikeNodes = [];\n const openContentEmbeds = [];\n for (const dfsNode of dfsNodes) {\n const currentNode = dfsNode.node;\n // Before processing the current node, check if any previously opened para-like nodes are\n // closing.\n for (let j = openParaLikeNodes.length - 1; j >= 0; j--) {\n if ($isElementNodeClosing(openParaLikeNodes[j], dfsNode)) {\n const closingPara = openParaLikeNodes[j];\n openParaLikeNodes.splice(j, 1);\n // Check if this closing position matches our target\n if (currentIndex === otPosition) {\n return closingPara;\n }\n currentIndex += 1;\n }\n }\n // Check if any open content embed nodes (note/unknown) are closing\n for (let j = openContentEmbeds.length - 1; j >= 0; j--) {\n if ($isElementNodeClosing(openContentEmbeds[j].node, dfsNode)) {\n openContentEmbeds.splice(j, 1);\n }\n }\n const activeContentEmbed = openContentEmbeds[openContentEmbeds.length - 1];\n if (activeContentEmbed) {\n if (activeContentEmbed.position === otPosition) {\n return activeContentEmbed.node;\n }\n continue;\n }\n // Track opening of para-like nodes\n if ($isParaLikeNode(currentNode)) {\n if (!openParaLikeNodes.includes(currentNode)) {\n openParaLikeNodes.push(currentNode);\n }\n }\n // Track when we enter an opaque content container (note/unknown always; any element\n // embed such as an editable chapter in \"apply\" coordinates)\n if ($isOpaqueContentNode(currentNode, coordinates)) {\n if (currentIndex === otPosition) {\n return currentNode;\n }\n openContentEmbeds.push({ node: currentNode, position: currentIndex });\n currentIndex += 1;\n continue;\n }\n // Calculate OT length contribution of current node\n const contribution = $getNodeOTContribution(currentNode, coordinates);\n // For text nodes, check if the position falls within this node's range (an editable verse is\n // an embed, not text — see $isOTTextNode — so it is matched by the embed check below instead)\n if ($isOTTextNode(currentNode) && contribution > 0) {\n if (otPosition >= currentIndex && otPosition < currentIndex + contribution) {\n return currentNode;\n }\n }\n // For embed nodes (contribution === 1), check exact position\n if ($isEmbedNode(currentNode)) {\n if (currentIndex === otPosition) {\n return currentNode;\n }\n }\n currentIndex += contribution;\n }\n // Check if any remaining open para-like nodes close at the final position\n for (const paraNode of openParaLikeNodes) {\n if (currentIndex === otPosition) {\n return paraNode;\n }\n currentIndex += 1;\n }\n // Position not found or out of bounds\n return undefined;\n}\n/**\n * Check if an element node is being closed at this point in the DFS traversal.\n */\nexport function $isElementNodeClosing(node, nextDfsNode) {\n if (!node)\n return false;\n // An element node is closing if the next node in DFS is not a descendant.\n // In DFS, all descendants of a node appear consecutively after the node.\n if (!nextDfsNode) {\n // End of traversal, so this node is closing\n return true;\n }\n // Check if the next node is a descendant of the current node\n return !$isDescendantOf(nextDfsNode.node, node.getKey());\n}\n/**\n * Type guard for a node that contributes its glyph TEXT to OT length — a genuine text node, and\n * NOT an embed that merely subclasses `TextNode`.\n *\n * The only embed that is also a `TextNode` is an editable `VerseNode` (its `__text` IS the\n * `\"\\v 1 \"` glyph). Like every embed it counts as ONE opaque OT unit, so OT-counting traversals\n * must classify it via {@link $isEmbedNode} and never measure or split its glyph text. Use this\n * in place of `$isTextNode` wherever a text branch precedes an embed branch, so an editable\n * verse falls through to the embed branch. See {@link OTCoordinateSystem}.\n */\nexport function $isOTTextNode(node) {\n return $isTextNode(node) && !$isEmbedNode(node);\n}\n/**\n * Type guard to check if a node is an embed. Embeds have an OT length of 1 and are self-contained\n * (no children to process).\n */\nexport function $isEmbedNode(node) {\n return ($isSomeChapterNode(node) ||\n $isSomeVerseNode(node) ||\n $isMilestoneNode(node) ||\n $isNoteNode(node) ||\n $isUnknownNode(node) ||\n $isImmutableUnmatchedNode(node));\n}\n/**\n * Type guard to check if the given insert embed operation is for the specified embed type.\n *\n * @param embedType - The type of embed to check for, e.g. \"note\".\n * @param op - The OT delta operation to check.\n * @returns `true` if the operation is for the specified embed type, `false` otherwise.\n *\n * @public\n */\nexport function isInsertEmbedOpOfType(embedType, op) {\n return op?.insert != null && typeof op.insert === \"object\" && embedType in op.insert;\n}\n/**\n * Type guard to check if the given insert embed operation is for an embed type.\n * @param op - The OT delta operation to check.\n * @returns `true` if the operation is for an embed type, `false` otherwise.\n */\nfunction isInsertEmbedOp(op) {\n if (op.insert == null || typeof op.insert !== \"object\")\n return false;\n const embedType = Object.keys(op.insert)[0];\n return (op.insert != null &&\n typeof op.insert === \"object\" &&\n embedType in op.insert &&\n validOTEmbedTypes.includes(embedType));\n}\n/**\n * Type guard to check if the given operation is a retain operation.\n * @param op - The OT delta operation to check.\n * @returns `true` if it is a retain operation, `false` otherwise.\n */\nfunction isRetainOp(op) {\n return op.retain != null && typeof op.retain === \"number\";\n}\n/**\n * Whether the node is an opaque content container in the given coordinate system: it\n * contributes exactly 1 OT unit and its descendants are skipped.\n *\n * Note and unknown contents are opaque in BOTH systems (their contents ops nest inside the\n * embed insert op in the doc delta). Other element-based embeds with presentation glyph\n * children — an editable `ChapterNode` — are opaque only in `\"apply\"` coordinates:\n * `$applyUpdate`'s traversals never descend into ANY embed, while the doc delta serializes\n * a chapter's glyph text child as a body text op. See {@link OTCoordinateSystem}.\n */\nfunction $isOpaqueContentNode(node, coordinates) {\n if ($isNoteNode(node) || $isUnknownNode(node))\n return true;\n return coordinates === \"apply\" && $isElementNode(node) && $isEmbedNode(node);\n}\n/**\n * True when `node` is a paragraph's own marker-prefix glyph — the `\\p`-style MarkerNode a\n * ParaNode carries as its first child in editable marker mode ($createMarkerPrefix,\n * markerEditDeletion.utils.ts). The ONE definition, shared by this file's own OT-length\n * accounting below and by `editor-delta.adaptor.ts`'s content-ops gate, so the two coordinate\n * systems can never drift apart on what counts as the prefix glyph. The position check (first\n * child of a ParaNode) is load-bearing, since {@link $isSynthesizedMarkerNode} identifies the node\n * SHAPE, which is reused for every other glyph in the tree too (a char span's own opener/closer,\n * a note's glyphs, a milestone's or verse's bare attribute glyph) — only a MarkerNode sitting in\n * the paragraph's own prefix slot is presentation scaffolding.\n */\nexport function $isOwnParaPrefixGlyph(node) {\n const parent = node.getParent();\n return $isSynthesizedMarkerNode(node) && $isParaNode(parent) && parent.getFirstChild() === node;\n}\n/**\n * True when `node` sits inside an `AttributeRunNode` wrapper (a verse's/milestone's display run,\n * when wrapped — see `AttributeRunNode.ts`). The wrapper is pure presentation scaffolding — its\n * children are the SAME run pieces (glyphs, attribute text) that also ride as loose siblings when\n * nothing has wrapped the run — so this is the wrapped-shape counterpart of\n * `$isOwnParaPrefixGlyph` above: an ANCESTRY check rather than a sibling-adjacency one, so it also\n * catches shapes the loose-piece exclusions in `editor-delta.adaptor.ts` can miss by adjacency\n * alone (e.g. a milestone's glyph pair with no attribute text between them, where neither glyph\n * has an attribute-tagged sibling to key off of).\n */\nexport function $hasAttributeRunAncestor(node) {\n // The walk starts at the PARENT deliberately: an AttributeRunNode is not \"inside\" itself.\n const parent = node.getParent();\n return parent !== null && $findMatchingParent(parent, $isAttributeRunNode) !== null;\n}\n/**\n * Mirror of editor-delta.adaptor.ts's empty-char-placeholder skip, in delta-doc coordinates: the\n * lone stand-in text of an otherwise childless char span, which the ops stream never emits.\n */\nfunction $isEmptyCharPlaceholderText(node) {\n const parent = node.getParent();\n return ($isCharNode(parent) &&\n node.getTextContent() === EMPTY_CHAR_PLACEHOLDER_TEXT &&\n parent.getChildrenSize() === 1);\n}\n/**\n * When `node` is an expanded note's editable caller text, the bytes of it that are the note's\n * CONTENT — none for the caller's own spelling, and for a caller that waits as the user left it\n * (deleted, or typed into, while the caret is at it) the bytes typed into it, spelled as the\n * content they settle into — or `undefined` when `node` is no caller text.\n *\n * The same split the editor→USJ conversion makes (`$noteEditableCallerNode` finds the caller\n * text, `typedCallerBytes` its typed bytes), so the ops stream, the delta-doc length it is counted\n * in, and `getUsj()` all read a waiting caller alike.\n */\nexport function $editableNoteCallerContent(node) {\n const note = $getLogicalParent(node);\n if (!$isNoteNode(note) || !$noteEditableCallerNode(note)?.is(node))\n return undefined;\n return typedCallerBytes(node.getTextContent(), note.getCaller());\n}\n/**\n * Whether the single-dirty-leaf fast path (DeltaOnChangePlugin) may emit `node`'s raw text as a\n * content op. ONE authority rather than a re-implemented exclusion list: eligibility derives\n * from the same delta-doc counting the length side uses ({@link $getNodeOTContribution}) — a\n * node whose bytes are presentation (contribution 0: para-prefix glyphs, marker-trailing-space,\n * attribute text and runs, placeholders, caller text, legacy `⍽|`-prefixed attribute text) or an\n * opaque embed (contribution 1 ≠ text size: an editable verse glyph) counts differently from its\n * raw bytes, so an op built from those bytes would be in a different currency than its retain —\n * such an edit must take the full-diff fallback, which applies `$handleTextNodes`' exclusions.\n * `$isDisplayRunPiece` is checked on top because the ops stream excludes a LOOSE display run's\n * glyphs while delta-doc counting deliberately keeps them (the documented asymmetry in\n * editor-delta.adaptor.ts).\n */\nexport function $isFastPathContentText(node) {\n return (!$isDisplayRunPiece(node) &&\n // A caller's typed bytes are respelled as the content they settle into, never sent raw.\n $editableNoteCallerContent(node) === undefined &&\n $getNodeOTContribution(node, \"delta-doc\") === node.getTextContentSize());\n}\n/**\n * Calculate the OT length contribution of a single node.\n *\n * @param coordinates - The OT coordinate system to count in (see {@link OTCoordinateSystem}).\n * A paragraph's own marker-prefix glyph and its NBSP separator are presentation scaffolding\n * that `editor-delta.adaptor.ts`'s `$handleTextNodes` excludes from content ops — but ONLY in\n * `\"delta-doc\"` coordinates, which must agree with that ops stream. `\"apply\"` coordinates are\n * DEFINED as whatever `$applyUpdate`'s own insert/delete/attribute traversals do\n * (delta-apply-update.utils.ts), and none of them skip these nodes — every one counts an OT\n * text node's raw `getTextContentSize()` unconditionally. So `\"apply\"` coordinates must keep\n * counting the prefix and separator too, or a replace-embed retain computed here would\n * disagree with where `$applyUpdate` actually walks to (a note \"replace\" landing one-plus-\n * prefix-length short of the note it meant to delete, deleting the wrong node and leaving the\n * replacement appended instead). If `$applyUpdate`'s traversals are ever taught to skip these\n * nodes too, this exclusion should extend to `\"apply\"` at the same time — not before.\n *\n * The SAME reasoning governs the `$hasAttributeRunAncestor` exclusion below: `$applyUpdate`'s\n * own traversal functions (`$traverseAndApplyAttributesRecursive`, `$traverseAndDelete`,\n * `$insertNodeAtCharacterOffset`) do not special-case `AttributeRunNode` at all — every\n * editable-mode verse/milestone run the adaptor builds rides wrapped in one, so this traversal\n * gap is live on every real document, not a hypothetical one. Each traversal treats a wrapper as\n * an ordinary, un-special-cased `ElementNode` (zero contribution of its own, descend into\n * children) and counts each child's raw text length exactly as it already does for a LOOSE run's\n * pieces — i.e. wrapping changes nothing about what `$applyUpdate` actually does. `\"apply\"`\n * coordinates must therefore keep counting a wrapped piece's text too, matching that (unchanged)\n * traversal; only `\"delta-doc\"` excludes it, mirroring `editor-delta.adaptor.ts`'s existing ops\n * exclusion for the identical bytes.\n */\nexport function $getNodeOTContribution(node, coordinates) {\n // Embeds are checked FIRST: an editable VerseNode is a TextNode subclass but counts as one\n // opaque OT unit (its glyph text is engine-owned display, excluded from content ops), the same\n // as it counts in the doc delta and in `$applyUpdate`'s traversals. See {@link $isOTTextNode}.\n if ($isEmbedNode(node))\n return 1;\n if ($isTextNode(node)) {\n // Read before the guard chain below: its type guards narrow `node` in later `||` operands\n // (a false branch of a `node is TextNode` guard leaves `never`), so member access there\n // does not typecheck even though the value is unchanged.\n const nodeText = node.getTextContent();\n if (coordinates === \"delta-doc\" &&\n // A bare caret host (transientCaretHost.utils.ts) is a transient, collab-invisible node:\n // its insertion is never emitted, so it contributes nothing to DOC-DELTA positions or the\n // local doc would drift one position ahead of every peer while a host rests. In `\"apply\"`\n // coordinates it MUST count, per the rule in the doc comment above: none of\n // `$applyUpdate`'s traversals skip a placeholder (each classifies with `$isOTTextNode`\n // and adds raw `getTextContentSize()`), so excluding it here left a replace-embed retain\n // one short whenever a host rested before the target — a footnote-popover save then\n // deleted the unit BEFORE the note instead of the note itself.\n ($isCaretHost(node) ||\n $isOwnParaPrefixGlyph(node) ||\n $getState(node, textTypeState) === \"marker-trailing-space\" ||\n // An attribute value keyed by its own state, not by ancestry: a CHAR span's run is a direct\n // TextNode child of the span, never wrapped (`displayRunRegistry.ts`'s char descriptor\n // writes \"owner-children\"), so `$hasAttributeRunAncestor` cannot see it. That shape is at\n // rest on every `\\w …|strong=\"…\"\\w*`, and the ops stream already omits those bytes\n // (`isNodeAttributeText` in editor-delta.adaptor.ts), so counting them here would put this\n // side out of step with the op stream on ordinary Scripture.\n $getState(node, textTypeState) === \"attribute\" ||\n $hasAttributeRunAncestor(node) ||\n // The remaining ops-stream exclusions, so this side and $handleTextNodes count the same\n // bytes (docs/standard-view-invariants.md §II — extend the shared list, never fork it):\n // the legacy NBSP-`|` byte-prefixed attribute text the ops stream still honors for\n // pre-state-tag peers and persisted deltas, and the empty-char placeholder. The\n // editable-mode note caller counts only its content bytes, below.\n nodeText.startsWith(NODE_ATTRIBUTE_PREFIX) ||\n $isEmptyCharPlaceholderText(node)))\n return 0;\n const callerContent = coordinates === \"delta-doc\" ? $editableNoteCallerContent(node) : undefined;\n if (callerContent !== undefined)\n return callerContent.length;\n return node.getTextContentSize();\n }\n // CharNodes and other nodes don't contribute to OT length\n return 0;\n}\n","import { $isSomeVerseNode } from \"../../../nodes/usj/node-react.utils\";\nimport { $editableNoteCallerContent, $hasAttributeRunAncestor, $isElementNodeClosing, $isOwnParaPrefixGlyph, LF, } from \"./delta-common.utils\";\nimport { $dfs } from \"@lexical/utils\";\nimport { $getRoot, $getState, $isTextNode } from \"lexical\";\nimport Delta from \"quill-delta\";\nimport { $findFirstAncestorNoteNode, $isBookNode, $isCaretHost, $isCharNode, $isDisplayRunPiece, $isImmutableUnmatchedNode, $isImpliedParaNode, $isMarkerNode, $isMilestoneNode, $isNoteNode, $isParaLikeNode, $isParaNode, $isSomeChapterNode, $isUnknownNode, $isVerseNode, $separatorPrefixLength, BOOK_MARKER, CHAPTER_MARKER, charIdState, EMPTY_CHAR_PLACEHOLDER_TEXT, NBSP, NODE_ATTRIBUTE_PREFIX, segmentState, textTypeState, VERSE_MARKER, } from \"shared\";\nexport function $getTextOp(node, openCharNodes) {\n const op = { insert: node.__text };\n const segment = $getState(node, segmentState);\n if (segment)\n op.attributes = { segment };\n if (openCharNodes && openCharNodes.length > 0) {\n const char = $buildCharAttribute(openCharNodes);\n if (char) {\n op.attributes = {\n ...op.attributes,\n char,\n };\n }\n }\n return op;\n}\nexport function getEditorDelta(editorState) {\n const update = new Delta();\n if (editorState.isEmpty())\n return update;\n editorState.read(() => {\n const root = $getRoot();\n if (!root || root.isEmpty())\n return;\n // check for default empty implied-para node\n const rootChildren = root.getChildren();\n if (rootChildren.length === 1 &&\n $isImpliedParaNode(rootChildren[0]) &&\n (!rootChildren[0].getChildren() || rootChildren[0].getChildrenSize() === 0)) {\n return;\n }\n const ops = $getAllNodeOps();\n for (const op of ops)\n update.push(op);\n });\n return update;\n}\n/**\n * Get the operational transform (OT) delta operations for a specific node or range of nodes.\n * Pass nothing to get all nodes.\n *\n * @param startNode - The node to start the search, if omitted, it will start at the root node.\n * @param endNode - The node to end the search, if omitted, it will find all descendants of the\n * startingNode.\n * @returns An array of DeltaOp objects representing the OT operations for the specified nodes.\n */\nexport function $getParticularNodeOps(startNode, endNode) {\n const ops = [];\n const dfsNodes = $dfs(startNode, endNode);\n const openParaLikeNodes = [];\n const openCharNodes = [];\n const openEmbeds = [];\n const charContentProduced = new Set();\n for (let i = 0; i < dfsNodes.length; i++) {\n const currentNode = dfsNodes[i].node;\n ops.push(...$getNodeOps(currentNode, i, dfsNodes, openParaLikeNodes, openCharNodes, openEmbeds, charContentProduced));\n }\n // Close any remaining open nodes\n for (const openNode of openParaLikeNodes) {\n ops.push(...$getNodeOps(openNode, dfsNodes.length, dfsNodes, openParaLikeNodes, openCharNodes, openEmbeds, charContentProduced));\n }\n return ops;\n}\nfunction $getAllNodeOps() {\n return $getParticularNodeOps();\n}\nfunction $getNodeOps(currentNode, currentIndex, dfsNodes, openParaLikeNodes, openCharNodes, openEmbeds, charContentProduced) {\n if (!currentNode)\n return [];\n const ops = [];\n const nextDfsNode = dfsNodes[currentIndex + 1];\n $handleBlockNodes(currentNode, ops, openParaLikeNodes);\n $handleTextNodes(currentNode, ops, openCharNodes, openEmbeds, charContentProduced);\n $handleCharNodes(currentNode, currentIndex, dfsNodes, openCharNodes, charContentProduced, openEmbeds, ops);\n // is an EmbedNode\n if ($isSomeChapterNode(currentNode))\n ops.push($getChapterOp(currentNode));\n if ($isSomeVerseNode(currentNode))\n ops.push($getVerseOp(currentNode));\n if ($isMilestoneNode(currentNode))\n ops.push($getMilestoneOp(currentNode));\n if ($isImmutableUnmatchedNode(currentNode))\n ops.push($getImmutableUnmatchedOp(currentNode));\n $handleUnknownNodes(currentNode, ops, openEmbeds);\n $handleNoteNodes(currentNode, ops, openEmbeds);\n $closeCompletedEmbeds(nextDfsNode, openEmbeds);\n return ops;\n}\nfunction $handleBlockNodes(currentNode, ops, openParaLikeNodes) {\n if (!currentNode.isInline()) {\n // Handle block nodes\n const openNode = openParaLikeNodes.pop();\n if ($isBookNode(openNode))\n ops.push($getBookOp(openNode));\n else if ($isParaNode(openNode))\n ops.push($getParaOp(openNode));\n else if ($isImpliedParaNode(openNode))\n ops.push({ insert: LF });\n }\n if ($isParaLikeNode(currentNode)) {\n // Track when we open para-like nodes\n if (!openParaLikeNodes.includes(currentNode)) {\n openParaLikeNodes.push(currentNode);\n }\n }\n}\nfunction $handleTextNodes(currentNode, ops, openCharNodes, openEmbeds, charContentProduced) {\n if (!$isTextNode(currentNode))\n return;\n // An editable VerseNode's own `__text` is its marker glyph (`\\v 1 `) — VerseNode extends\n // TextNode so the glyph can sit inline for caret placement, but the glyph is engine-owned\n // display, not content. The verse is already conveyed by its own embed op ($getVerseOp,\n // pushed by the caller once $isSomeVerseNode matches). Skip the glyph here so it never ALSO\n // surfaces as a content text op, which would double-count the verse's length in the OT\n // content stream (once as the embed's implicit 1 unit, once as the leaked glyph bytes) and\n // shift every offset that follows it.\n if ($isVerseNode(currentNode))\n return;\n // An ImmutableUnmatchedNode's bytes are its embed's presentation, the same shape as the\n // editable VerseNode glyph above: the node extends TextNode so the flagged `\\nd*` bytes stay\n // caret-addressable and editable, but the construct is conveyed by its own embed op\n // ($getImmutableUnmatchedOp, pushed by the caller once $isImmutableUnmatchedNode matches).\n // Letting the bytes ALSO flow as a content text op would double-count the embed's OT length\n // (once as the embed's 1 unit, once as the leaked bytes) and shift every offset after it.\n if ($isImmutableUnmatchedNode(currentNode))\n return;\n // Skip a note's first text child: in editable modes this is the note's opening marker glyph\n // (MarkerNode extends TextNode), which shouldn't flow into ops. Caller text, when present as a\n // plain text child (expanded editable mode), is never the first child and is not skipped here.\n const parent = currentNode.getParent();\n if ($isNoteNode(parent) && parent.getFirstChild() === currentNode)\n return;\n // Canonical, glyph-free note ops in editable marker mode: note contents ops carry CONTENT\n // only, the same shape non-editable marker modes produce. Presentation-only nodes that\n // `$applyUpdate` re-synthesizes when materializing the note (`$createWholeNote` /\n // `$createNestedChars`) must not flow into ops, otherwise a round-trip doubles them:\n // - MarkerNode glyphs (char-span openers/closers and the note's own closing glyph);\n // - the expanded editable caller text (presentation of the note's `caller` attribute).\n // A char span's OWN opener/closer glyphs OUTSIDE a note legitimately flow through as literal\n // editable-mode text (the `char` attribute wrapper is layered on top, not a substitute) — only\n // a milestone's or a verse's \\va/\\vp display-run glyphs (presentation that duplicates state the\n // embed op already carries) must never leak, in or out of a note. TWO checks are needed together\n // here, neither a superset of the other:\n // - $hasAttributeRunAncestor walks EVERY ancestor, so it catches a wrapped glyph regardless of\n // how deep it rides or whether the wrapper sits directly after its owner — an intervening\n // node between the owner and its wrapper (a remote insert landing at that boundary, an undo\n // stack, a mid-edit tree) still leaves the wrapper's own contents ancestor-reachable, but the\n // registry's per-kind `ownerOf` walks require exactly that adjacency and give up on the first\n // non-run-piece sibling, so it would miss this shape. (A few lines below, `isNodeAttributeText`\n // applies this same ancestor walk unconditionally to every surviving TextNode, wrapped glyph\n // or not — that independently backstops a wrapped piece even if this arm were removed, but\n // keeping it here too means this gate's OWN stated exclusion holds on its own, rather than by\n // incidental coupling to a check several lines away that could itself change independently.)\n // - $isDisplayRunPiece is keyed on the glyph's KIND (the display-run registry's owner walk), so\n // it catches a run's glyphs riding LOOSE — caret-grace, an undo stack, and a\n // collab-materialized bare owner each leave a run's glyphs loose for at least one commit, and\n // a loose glyph is exactly as much engine-owned display as a wrapped one — a shape\n // $hasAttributeRunAncestor (ancestry into a wrapper) cannot see at all.\n // Being kind-keyed rather than shape-keyed, $isDisplayRunPiece also needs no per-piece exemption\n // for a char span's own opener/closer or its own nested `|…` run: neither is a registered piece\n // of any OTHER owner's run.\n //\n // This union widens only the ops-stream exclusion, restoring the historical contract: the\n // delta-doc length side (`$getNodeOTContribution` in delta-common.utils.ts) deliberately keeps\n // counting a LOOSE run's glyphs (via $hasAttributeRunAncestor alone, unchanged) even though the\n // ops stream now excludes them — that is not a drift to fix by widening the length side to\n // match, it is the same asymmetry the ops stream honored before the earlier loose-glyph\n // exclusion was removed.\n const isInNote = $findFirstAncestorNoteNode(currentNode) !== undefined;\n if ($isMarkerNode(currentNode) &&\n (isInNote ||\n $isOwnParaPrefixGlyph(currentNode) ||\n $hasAttributeRunAncestor(currentNode) ||\n $isDisplayRunPiece(currentNode)))\n return;\n // The para prefix's NBSP separator is presentation scaffolding ($createMarkerPrefix,\n // markerEditDeletion.utils.ts); the apply side re-synthesizes the whole prefix, so its text\n // must never enter content ops.\n if ($getState(currentNode, textTypeState) === \"marker-trailing-space\")\n return;\n let text = currentNode.getTextContent();\n // A bare caret host (transientCaretHost.utils.ts) is collab-invisible: its insertion is never\n // emitted, so it must never appear in a delta op either. Recognized by its mark, not its text: an\n // authored zero-width-space-only run is content and must reach peers.\n if ($isCaretHost(currentNode))\n return;\n // An expanded note's editable caller text is presentation of the note's `caller` attribute, so\n // none of its own bytes are content; only bytes typed into a caller that waits as the user left\n // them are, as the editor→USJ conversion reads them ({@link $editableNoteCallerContent}).\n const callerContent = $editableNoteCallerContent(currentNode);\n if (callerContent !== undefined) {\n if (!callerContent)\n return;\n text = callerContent;\n }\n const previousSibling = currentNode.getPreviousSibling();\n const parentCharNode = $isCharNode(parent) ? parent : undefined;\n // Strip the structural NBSP separator that editable-mode char spans glue onto their\n // content text after the opening glyph (added by the USJ adaptor's `createChar` and\n // re-added by `$applyUpdate`'s `$createNote`); it is display-only, not content. Which bytes\n // count is $separatorPrefixLength's call, so a leading NBSP anywhere else (after a nested closer\n // in `\\ft A\\+nd x\\+nd*~B`) is the author's own `~` and flows into the op on every emit. This\n // path is narrower still: only the span's OWN opener (its first child) qualifies, like the\n // reverse adaptor's `content[0]` strip, so the collab-flattened shape's nested opener keeps\n // emitting what peers already receive.\n if (isInNote && !!parentCharNode && previousSibling === parentCharNode.getFirstChild()) {\n text = text.slice($separatorPrefixLength(currentNode));\n }\n // Char-span attribute display runs (bare `|…`, no NBSP prefix — see usj-editor.adaptor's\n // `addCharAttributes`) carry no NBSP prefix to strip against, so the prefix check alone can't\n // catch them; the textType state tag is the other signal, kept alongside the prefix check for\n // the legacy NBSP-prefixed (milestone) attribute text. The legacy byte arm is LOAD-BEARING for\n // compatibility, not a leftover: deployed peers and persisted OT documents (ScriptureForge\n // shares these collab documents) predate the state-tagged format, and their stored deltas\n // replay through here — without the byte check, that replayed attribute text would leak display\n // bytes into content. Do not retire it while any pre-tag document or peer can reach this\n // editor. Text inside an AttributeRunNode wrapper\n // is excluded regardless of its own textType tag: the wrapper is an engine-owned presentation\n // region (see AttributeRunNode.ts), so anything riding inside it is presentation, not content,\n // whether or not it happens to also carry the \"attribute\" state tag.\n const isNodeAttributeText = text.startsWith(NODE_ATTRIBUTE_PREFIX) ||\n $getState(currentNode, textTypeState) === \"attribute\" ||\n $hasAttributeRunAncestor(currentNode);\n const isPlaceholderText = !!parentCharNode &&\n text === EMPTY_CHAR_PLACEHOLDER_TEXT &&\n parentCharNode.getChildrenSize() === 1;\n const activeEmbed = $getActiveEmbedContext(currentNode, openEmbeds);\n // An embed's `contents` ops are a SELF-CONTAINED SUB-DOCUMENT: they are materialized on the\n // receive side into a freshly built note/unknown, with no surrounding document to inherit from,\n // and read back out by `$getParticularNodeOps(embedNode)`, whose DFS starts AT the embed and so\n // has no ambient char stack at all. `openCharNodes` is the whole walk's stack, so inside an\n // embed it still holds char spans opened OUTSIDE it — spans that are not part of the embed's\n // content and have no representation in the sub-document. Scoping the stack to spans within the\n // embed is what makes this producer agree with `$getParticularNodeOps`; without it a note\n // inserted mid-span (`\\nd asdf\\nd*`) shipped `char: [{nd}, {fr}]` on its own first\n // content op, and the apply side built the enclosing `\\nd` INSIDE the note with a nested\n // `\\+fr` under it. `children` is the embed's entire subtree (`$dfs` from the embed node), not\n // just its direct children, so a span opened at any depth inside the embed is kept.\n const embedScopedCharNodes = activeEmbed\n ? openCharNodes.filter((charNode) => activeEmbed.children.includes(charNode))\n : openCharNodes;\n const textOp = $getTextOp(currentNode, embedScopedCharNodes);\n textOp.insert = text;\n if (activeEmbed) {\n if (!text || text === NBSP || isNodeAttributeText)\n return;\n activeEmbed.contentsOps?.push(textOp);\n }\n else {\n // Attribute display text is presentation-only regardless of WHERE it rides — inside a char\n // span (the original, narrower rule) or, like a milestone's or a verse's \\va/\\vp value, as a\n // plain sibling with no CharNode parent at all.\n const shouldSkipTextOp = isPlaceholderText || isNodeAttributeText;\n if (!shouldSkipTextOp) {\n ops.push(textOp);\n }\n }\n const hasMeaningfulText = text !== \"\" && !isPlaceholderText && !(isNodeAttributeText && !!parentCharNode);\n if (openCharNodes.length > 0 && hasMeaningfulText) {\n for (const charNode of openCharNodes) {\n charContentProduced.add(charNode);\n }\n }\n}\nfunction $handleCharNodes(currentNode, currentIndex, dfsNodes, openCharNodes, charContentProduced, openEmbeds, ops) {\n if ($isCharNode(currentNode) && !openCharNodes.includes(currentNode)) {\n openCharNodes.push(currentNode);\n }\n const nextDfsNode = dfsNodes[currentIndex + 1];\n for (const openCharNode of openCharNodes.toReversed()) {\n if ($isElementNodeClosing(openCharNode, nextDfsNode)) {\n openCharNodes.pop();\n if (!charContentProduced.has(openCharNode)) {\n const emptyCharOp = $getEmptyCharOp(openCharNode);\n const activeEmbed = $getActiveEmbedContext(openCharNode, openEmbeds);\n if (activeEmbed) {\n activeEmbed.contentsOps?.push(emptyCharOp);\n }\n else {\n ops.push(emptyCharOp);\n }\n }\n charContentProduced.delete(openCharNode);\n }\n }\n}\nfunction $handleNoteNodes(currentNode, ops, openEmbeds) {\n if (!$isNoteNode(currentNode))\n return;\n const noteOp = $getNoteOp(currentNode);\n const parentEmbed = $getActiveEmbedContext(currentNode, openEmbeds);\n const embedContext = {\n node: currentNode,\n children: $dfs(currentNode).map((n) => n.node),\n contentsOps: noteOp.insert.note?.contents?.ops,\n };\n openEmbeds.push(embedContext);\n if (parentEmbed?.contentsOps)\n parentEmbed.contentsOps.push(noteOp);\n else\n ops.push(noteOp);\n}\nfunction $handleUnknownNodes(currentNode, ops, openEmbeds) {\n if (!$isUnknownNode(currentNode))\n return;\n const unknownOp = $getUnknownOp(currentNode);\n const parentEmbed = $getActiveEmbedContext(currentNode, openEmbeds);\n const embedContext = {\n node: currentNode,\n children: $dfs(currentNode).map((n) => n.node),\n contentsOps: unknownOp.insert.unknown?.contents?.ops,\n };\n openEmbeds.push(embedContext);\n if (parentEmbed?.contentsOps)\n parentEmbed.contentsOps.push(unknownOp);\n else\n ops.push(unknownOp);\n}\n/**\n * Copies `node`'s unknown attributes onto `payload` — the embed or attribute object it is emitted\n * in — so they reach the peer. The node holds them either way; dropping them here is invisible to\n * every USJ round-trip and loses them only on the wire.\n *\n * Reads node state: call inside `editorState.read()`, as every op builder in this module is.\n */\nfunction $assignUnknownAttributes(payload, node) {\n const unknownAttributes = node.getUnknownAttributes();\n if (unknownAttributes)\n Object.assign(payload, unknownAttributes);\n}\nfunction $getBookOp(currentNode) {\n const book = { style: BOOK_MARKER, code: currentNode.__code };\n $assignUnknownAttributes(book, currentNode);\n return { insert: LF, attributes: { book } };\n}\nfunction $getChapterOp(currentNode) {\n const chapter = { style: CHAPTER_MARKER, number: currentNode.__number };\n if (currentNode.__sid) {\n chapter.sid = currentNode.__sid;\n }\n if (currentNode.__altnumber) {\n chapter.altnumber = currentNode.__altnumber;\n }\n if (currentNode.__pubnumber) {\n chapter.pubnumber = currentNode.__pubnumber;\n }\n $assignUnknownAttributes(chapter, currentNode);\n return { insert: { chapter } };\n}\nexport function $getParaOp(node) {\n const para = { style: node.__marker };\n $assignUnknownAttributes(para, node);\n return { insert: LF, attributes: { para } };\n}\nfunction $getVerseOp(currentNode) {\n const verse = { style: VERSE_MARKER, number: currentNode.__number };\n if (currentNode.__sid) {\n verse.sid = currentNode.__sid;\n }\n if (currentNode.__altnumber) {\n verse.altnumber = currentNode.__altnumber;\n }\n if (currentNode.__pubnumber) {\n verse.pubnumber = currentNode.__pubnumber;\n }\n $assignUnknownAttributes(verse, currentNode);\n return { insert: { verse } };\n}\nfunction $getMilestoneOp(currentNode) {\n const milestone = { style: currentNode.__marker };\n if (currentNode.__sid) {\n milestone.sid = currentNode.__sid;\n }\n if (currentNode.__eid) {\n milestone.eid = currentNode.__eid;\n }\n if (currentNode.__attributeOrder) {\n milestone.attributeOrder = currentNode.__attributeOrder;\n }\n $assignUnknownAttributes(milestone, currentNode);\n return { insert: { milestone } };\n}\nfunction $getImmutableUnmatchedOp(currentNode) {\n return { insert: { unmatched: { marker: currentNode.__marker } } };\n}\nfunction $getNoteOp(currentNode) {\n const note = {\n style: currentNode.__marker,\n caller: currentNode.__caller,\n };\n if (currentNode.__category) {\n note.category = currentNode.__category;\n }\n // Carry unknown attributes (e.g. the unclosed-note `closed=\"false\"`) so the round-trip is\n // lossless — `$applyUpdate`'s `$createNote` already reads them back via\n // `getUnknownAttributes(…, OT_NOTE_PROPS)`, matching how unknown-embed ops behave.\n $assignUnknownAttributes(note, currentNode);\n if (currentNode.getChildrenSize() > 1) {\n note.contents = { ops: [] };\n }\n const op = { insert: { note } };\n const segment = $getState(currentNode, segmentState);\n if (segment) {\n op.attributes = { segment };\n }\n return op;\n}\nfunction $getEmptyCharOp(charNode) {\n const op = { insert: \"\" };\n const char = $buildCharAttribute([charNode]);\n if (char) {\n op.attributes = { char };\n }\n return op;\n}\nfunction $getUnknownOp(currentNode) {\n const unknown = { tag: currentNode.getTag() };\n const marker = currentNode.getMarker();\n if (marker)\n unknown.marker = marker;\n $assignUnknownAttributes(unknown, currentNode);\n if (currentNode.getChildrenSize() > 0)\n unknown.contents = { ops: [] };\n return { insert: { unknown } };\n}\nfunction $getActiveEmbedContext(node, openEmbeds) {\n for (let i = openEmbeds.length - 1; i >= 0; i--) {\n const embed = openEmbeds[i];\n if (embed.children.includes(node))\n return embed;\n }\n return undefined;\n}\nfunction $closeCompletedEmbeds(nextDfsNode, openEmbeds) {\n for (let i = openEmbeds.length - 1; i >= 0; i--) {\n if ($isElementNodeClosing(openEmbeds[i].node, nextDfsNode)) {\n openEmbeds.splice(i, 1);\n }\n }\n}\nfunction $buildCharAttribute(charNodes) {\n if (charNodes.length === 0)\n return undefined;\n const items = charNodes.map($buildCharItem);\n return items.length === 1 ? items[0] : items;\n}\nfunction $buildCharItem(charNode) {\n const charItem = { style: charNode.__marker };\n const cid = $getState(charNode, charIdState);\n if (cid)\n charItem.cid = cid;\n $assignUnknownAttributes(charItem, charNode);\n return charItem;\n}\n","/**\n * The document-order note index, in a module of its own.\n *\n * `ImmutableNoteCallerNode` needs this coordinate, and the rest of the note machinery in\n * `note.utils.ts` needs `ImmutableNoteCallerNode`. Keeping the index here — a leaf that imports\n * neither — is what keeps those two from importing each other: a cycle between them works only for\n * as long as every use stays inside a function body, and the first module-level use (or a CJS\n * evaluation order that puts the caller node first) fails at load with an uninitialized binding.\n */\nimport { $dfsIterator } from \"@lexical/utils\";\nimport { $isNoteNode } from \"shared\";\n/**\n * Document-order index of the note with the given key, or `undefined` when the key is not a note\n * in the document. This is the coordinate a USJ-built notes list (e.g. a host footnotes pane)\n * addresses notes by; hosts should not re-derive it by content comparison.\n *\n * Built on `$dfsIterator` rather than `$dfs`: the search stops at the first match, and the\n * iterator walks the tree lazily instead of materializing every node up front.\n *\n * Must be called inside an editor read or update.\n */\nexport function $getNoteIndex(noteNodeKey) {\n let index = 0;\n for (const { node } of $dfsIterator()) {\n if (!$isNoteNode(node))\n continue;\n if (node.getKey() === noteNodeKey)\n return index;\n index += 1;\n }\n return undefined;\n}\n/**\n * The note at the given document-order index, or `undefined` when the document has no note at\n * that index. The inverse of {@link $getNoteIndex}.\n *\n * Must be called inside an editor read or update.\n */\nexport function $getNoteAtIndex(index) {\n let current = 0;\n for (const { node } of $dfsIterator()) {\n if (!$isNoteNode(node))\n continue;\n if (current === index)\n return node;\n current += 1;\n }\n return undefined;\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\n/** Conforms with USJ v3.1 @see https://docs.usfm.bible/usfm/3.1/note/index.html */\nimport { $getParticularNodeOps } from \"../../plugins/usj/collab/editor-delta.adaptor\";\nimport { $getNoteIndex } from \"./note-index.utils\";\nimport { $applyNodeReplacement, $getNodeByKey, DecoratorNode, isHTMLElement, } from \"lexical\";\nimport { $isNoteNode, GENERATOR_NOTE_CALLER, HIDDEN_NOTE_CALLER, IMMUTABLE_NOTE_CALLER_NODE_TYPE, } from \"shared\";\nexport const IMMUTABLE_NOTE_CALLER_VERSION = 1;\nexport class ImmutableNoteCallerNode extends DecoratorNode {\n __caller;\n __previewText;\n __onClick;\n constructor(caller = GENERATOR_NOTE_CALLER, previewText = \"\", onClick, key) {\n super(key);\n this.__caller = caller;\n this.__previewText = previewText;\n this.__onClick = onClick ?? (() => undefined);\n }\n static getType() {\n return IMMUTABLE_NOTE_CALLER_NODE_TYPE;\n }\n static clone(node) {\n const { __caller, __previewText, __onClick, __key } = node;\n return new ImmutableNoteCallerNode(__caller, __previewText, __onClick, __key);\n }\n static importDOM() {\n return {\n span: (node) => {\n if (!isNoteCallerElement(node))\n return null;\n return {\n conversion: $convertNoteCallerElement,\n priority: 1,\n };\n },\n };\n }\n static importJSON(serializedNode) {\n return $createImmutableNoteCallerNode().updateFromJSON(serializedNode);\n }\n updateFromJSON(serializedNode) {\n return super\n .updateFromJSON(serializedNode)\n .setCaller(serializedNode.caller)\n .setPreviewText(serializedNode.previewText)\n .setOnClick(serializedNode.onClick);\n }\n setCaller(caller) {\n if (this.__caller === caller)\n return this;\n const self = this.getWritable();\n self.__caller = caller;\n return self;\n }\n getCaller() {\n const self = this.getLatest();\n return self.__caller;\n }\n setPreviewText(previewText) {\n if (this.__previewText === previewText)\n return this;\n const self = this.getWritable();\n self.__previewText = previewText;\n return self;\n }\n getPreviewText() {\n const self = this.getLatest();\n return self.__previewText;\n }\n setOnClick(onClick) {\n if (this.__onClick === onClick)\n return this;\n const self = this.getWritable();\n self.__onClick = onClick;\n return self;\n }\n getOnClick() {\n const self = this.getLatest();\n return self.__onClick;\n }\n createDOM() {\n const dom = document.createElement(\"span\");\n dom.classList.add(this.__type);\n dom.setAttribute(\"data-caller\", this.__caller);\n dom.setAttribute(\"data-preview-text\", this.__previewText);\n return dom;\n }\n updateDOM(prevNode) {\n if (prevNode.__caller !== this.__caller)\n return true;\n return false;\n }\n exportDOM(editor) {\n const { element } = super.exportDOM(editor);\n if (element && isHTMLElement(element)) {\n element.classList.add(this.getType());\n element.setAttribute(\"data-caller\", this.getCaller());\n element.setAttribute(\"data-preview-text\", this.getPreviewText());\n }\n return { element };\n }\n decorate(editor) {\n const noteNode = this.getParent();\n if (!noteNode)\n return null;\n const noteNodeKey = noteNode.getKey();\n const noteIsCollapsed = noteNode.getIsCollapsed();\n const callerNodeKey = this.__key;\n const onClick = (event) => this.__onClick?.(event, noteNodeKey, noteIsCollapsed, () => getNoteCaller(editor, noteNodeKey), (caller) => setNoteCaller(editor, noteNodeKey, callerNodeKey, caller), () => getNoteOps(editor, noteNodeKey), () => getNoteIndex(editor, noteNodeKey));\n const callerId = `${this.__caller}_${this.__previewText}}`.replace(/\\s+/g, \"\").substring(0, 25);\n return (_jsx(\"button\", { onClick: onClick, title: this.__previewText, \"data-caller-id\": callerId, children: this.getRenderedText() }));\n }\n /** The text this caller shows on screen; empty when CSS generates the caller instead. */\n getRenderedText() {\n const self = this.getLatest();\n const note = self.getParent();\n const noteIsCollapsed = $isNoteNode(note) && note.getIsCollapsed();\n if (self.__caller === GENERATOR_NOTE_CALLER && noteIsCollapsed)\n // Caller is generated by CSS (footnote or cross-reference sequence, per note marker)\n return \"\";\n // PT9: the hidden caller displays as `*` when collapsed\n if (self.__caller === HIDDEN_NOTE_CALLER && noteIsCollapsed)\n return \"*\";\n return self.__caller;\n }\n exportJSON() {\n return {\n type: this.getType(),\n caller: this.getCaller(),\n previewText: this.getPreviewText(),\n onClick: this.getOnClick(),\n version: IMMUTABLE_NOTE_CALLER_VERSION,\n };\n }\n // Mutation\n isKeyboardSelectable() {\n return false;\n }\n}\nfunction $convertNoteCallerElement(element) {\n const caller = element.getAttribute(\"data-caller\") ?? \"\";\n const previewText = element.getAttribute(\"data-preview-text\") ?? \"\";\n const node = $createImmutableNoteCallerNode(caller, previewText);\n return { node };\n}\nexport function $createImmutableNoteCallerNode(caller, previewText, onClick) {\n return $applyNodeReplacement(new ImmutableNoteCallerNode(caller, previewText, onClick));\n}\nfunction isNoteCallerElement(node) {\n if (!node)\n return false;\n return node.classList.contains(ImmutableNoteCallerNode.getType());\n}\nexport function $isImmutableNoteCallerNode(node) {\n return node instanceof ImmutableNoteCallerNode;\n}\nexport function isSerializedImmutableNoteCallerNode(node) {\n return node?.type === ImmutableNoteCallerNode.getType();\n}\n// `getEditorState().read`, NOT `editor.read`, in this and the two getters below: all three are\n// handed to the caller-click callback as lazy thunks, and `editor.read()` force-flushes any\n// in-flight update when invoked mid-dispatch — the frozen-state hazard the project rule exists\n// to prevent.\nfunction getNoteCaller(editor, noteNodeKey) {\n return editor.getEditorState().read(() => {\n const noteNode = $getNodeByKey(noteNodeKey);\n if (!$isNoteNode(noteNode))\n throw new Error(`getNoteCaller: Note node not found: ${noteNodeKey}`);\n return noteNode.getCaller();\n });\n}\nfunction setNoteCaller(editor, noteNodeKey, callerNodeKey, caller) {\n editor.update(() => {\n const noteNode = $getNodeByKey(noteNodeKey);\n if (!$isNoteNode(noteNode))\n throw new Error(`setNoteCaller: Note node not found: ${noteNodeKey}`);\n noteNode.setCaller(caller);\n const callerNode = $getNodeByKey(callerNodeKey);\n if (!$isImmutableNoteCallerNode(callerNode))\n throw new Error(`setNoteCaller: Caller node not found: ${callerNodeKey}`);\n callerNode.setCaller(caller);\n });\n}\nfunction getNoteOps(editor, noteNodeKey) {\n return editor.getEditorState().read(() => {\n const noteNode = $getNodeByKey(noteNodeKey);\n if (!$isNoteNode(noteNode))\n throw new Error(`getNoteOps: Note node not found: ${noteNodeKey}`);\n return $getParticularNodeOps(noteNode);\n });\n}\n/**\n * The note's document-order index among all of the document's notes — the same order a USJ walk\n * yields them, so it addresses the corresponding entry of a USJ-built notes list (e.g. a footnotes\n * pane). `undefined` when the note is no longer attached.\n */\nfunction getNoteIndex(editor, noteNodeKey) {\n return editor.getEditorState().read(() => $getNoteIndex(noteNodeKey));\n}\n/** Possible note callers to use when caller is '+'. Up to 2 characters are used, e.g. a-zz */\nexport const defaultNoteCallers = [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\",\n];\n/** Default cross-reference caller to use when caller is '+' on a cross-reference note and no\n * `crossRefCallers` option is set. */\nexport const defaultCrossRefCallers = [\"†\"];\n","/**\n * Constant representing the formatted view mode.\n * Used to display content with formatting applied.\n *\n * @public\n */\nexport const FORMATTED_VIEW_MODE = \"formatted\";\n/**\n * Constant representing the unformatted view mode.\n * Used to display content without formatting applied.\n *\n * @public\n */\nexport const UNFORMATTED_VIEW_MODE = \"unformatted\";\n/**\n * Constant representing the paragraph structure view mode.\n * Displays formatted text with visible USFM paragraph markers in a gutter column,\n * styled verse numbers, decorative chapter numbers, and an active-text outline on\n * the focused paragraph section.\n *\n * @public\n */\nexport const PARAGRAPH_STRUCTURE_VIEW_MODE = \"paragraph-structure\";\n/**\n * Constant representing the standard view mode (PT9 \"Standard\" equivalent).\n * Displays formatted text with USFM markers visible inline as editable text and\n * notes collapsed to callers.\n *\n * @public\n */\nexport const STANDARD_VIEW_MODE = \"standard\";\n/**\n * Constant representing the block verse view mode.\n * Displays formatted text with each verse wrapped in a block-level element, so a verse can be\n * placed on a layout row - for example a grid aligning the same verse across several resources.\n * This view is read-only; see `ViewOptions.verseLayout`.\n *\n * @public\n */\nexport const BLOCK_VERSE_VIEW_MODE = \"block-verse\";\n/**\n * Maps view mode keys to their human-readable display names.\n * Used for UI components that need to show view mode options to users.\n *\n * @public\n */\nexport const viewModeToViewNames = {\n [FORMATTED_VIEW_MODE]: \"Formatted\",\n [UNFORMATTED_VIEW_MODE]: \"Unformatted\",\n [PARAGRAPH_STRUCTURE_VIEW_MODE]: \"Paragraph Structure\",\n [STANDARD_VIEW_MODE]: \"Standard\",\n [BLOCK_VERSE_VIEW_MODE]: \"Block Verse\",\n};\n","import { TEXT_SPACING_CLASS_NAME, FORMATTED_FONT_CLASS_NAME, MARKER_MODE_CLASS_NAME_PREFIX, VerseNode, } from \"shared\";\nimport { ImmutableVerseNode } from \"../nodes/usj/ImmutableVerseNode\";\nimport { BLOCK_VERSE_VIEW_MODE, FORMATTED_VIEW_MODE, UNFORMATTED_VIEW_MODE, PARAGRAPH_STRUCTURE_VIEW_MODE, STANDARD_VIEW_MODE, viewModeToViewNames, } from \"./view-mode.model\";\nimport { deepEqual } from \"fast-equals\";\n/**\n * Whether `viewOptions` renders paragraph marker prefixes at all — the single spelling of the\n * `showParaMarkerPrefixes !== false` default. The adaptor (which builds the glyph), the\n * marker-edit transforms (which police or heal it), and the prefix-deletion guard (which reacts\n * to its absence) must all answer this identically: a surface that never builds the prefix must\n * never treat its absence as user intent to change the paragraph.\n *\n * @public\n */\nexport function showParaMarkerPrefix(viewOptions) {\n return viewOptions?.showParaMarkerPrefixes !== false;\n}\nlet defaultViewMode;\nlet defaultViewOptions;\n/**\n * Sets the default view mode and options.\n *\n * @param viewMode - View mode of the editor.\n *\n * @public\n */\nexport function setDefaultView(viewMode) {\n const _viewOptions = getViewOptions(viewMode);\n if (!_viewOptions)\n throw new Error(`Invalid view mode: ${viewMode}`);\n defaultViewMode = viewMode;\n defaultViewOptions = _viewOptions;\n}\nsetDefaultView(FORMATTED_VIEW_MODE);\n/**\n * Gets the default view mode.\n *\n * @returns the default view mode.\n *\n * @public\n */\nexport const getDefaultViewMode = () => defaultViewMode;\n/**\n * Gets the default view options.\n *\n * @returns the default view options.\n *\n * @public\n */\nexport const getDefaultViewOptions = () => defaultViewOptions;\n/**\n * Get view option properties based on the view mode.\n *\n * @param viewMode - View mode of the editor.\n * @returns the view options if the view exists, the default options if the viewMode is undefined,\n * `undefined` otherwise.\n *\n * @public\n */\nexport function getViewOptions(viewMode) {\n let viewOptions;\n switch (viewMode ?? defaultViewMode) {\n case FORMATTED_VIEW_MODE:\n viewOptions = {\n markerMode: \"hidden\",\n noteMode: \"collapsed\",\n hasSpacing: true,\n isFormattedFont: true,\n };\n break;\n case UNFORMATTED_VIEW_MODE:\n viewOptions = {\n markerMode: \"editable\",\n noteMode: \"expanded\",\n hasSpacing: false,\n isFormattedFont: false,\n };\n break;\n case PARAGRAPH_STRUCTURE_VIEW_MODE:\n viewOptions = {\n markerMode: \"hidden\",\n noteMode: \"collapsed\",\n hasSpacing: true,\n isFormattedFont: true,\n hasGutterParaMarkers: true,\n hasActiveTextFocusBox: true,\n };\n break;\n case STANDARD_VIEW_MODE:\n viewOptions = {\n markerMode: \"editable\",\n noteMode: \"collapsed\",\n hasSpacing: true,\n isFormattedFont: true,\n };\n break;\n case BLOCK_VERSE_VIEW_MODE:\n viewOptions = {\n markerMode: \"hidden\",\n noteMode: \"collapsed\",\n hasSpacing: true,\n isFormattedFont: true,\n verseLayout: \"block\",\n };\n break;\n default:\n break;\n }\n return viewOptions;\n}\n/**\n * Convert view options to view mode if the view exists.\n *\n * Inverts {@link getViewOptions} by comparison, so a view option added later cannot be forgotten\n * here and leave two modes indistinguishable. Matching is exact once each unset optional field is\n * filled in with its default, so spelling a default out still matches, but options derived from a\n * mode and then genuinely tweaked describe a view that is no longer that mode and yield\n * `undefined`.\n *\n * @remarks\n * This is narrower than the field-by-field matching it replaced, which tested only `markerMode`,\n * `hasSpacing`, `isFormattedFont`, `hasGutterParaMarkers` and `hasActiveTextFocusBox`. Every other\n * field now counts, `noteMode` included - it has no default to fill in (call sites read `undefined`\n * inconsistently, some as collapsed and some as not), so it is part of what identifies a mode and\n * has to be given. Options built from a mode with `noteMode` changed - say\n * `{ ...getViewOptions(PARAGRAPH_STRUCTURE_VIEW_MODE), noteMode: \"expanded\" }` - used to return the\n * mode they started from and now return `undefined`.\n *\n * @param viewOptions - View options of the editor.\n * @returns the view mode if the view is defined, `undefined` otherwise.\n *\n * @public\n */\nexport function getViewMode(viewOptions) {\n if (!viewOptions)\n return undefined;\n const normalized = canonicalize(viewOptions);\n return Object.keys(viewModeToViewNames).find((viewMode) => deepEqual(canonicalize(getViewOptions(viewMode)), normalized));\n}\n/**\n * Each optional field's documented default, so options that spell a default out compare equal to\n * options that leave it out - they describe the same view, and the comparison counts keys.\n *\n * `noteMode` is absent deliberately: it has no default (call sites read `undefined` inconsistently,\n * some as collapsed and some as not), so it is part of what identifies a mode and has to be given.\n */\nconst optionalViewOptionDefaults = {\n showCharMarkerTitles: true,\n hasGutterParaMarkers: false,\n hasActiveTextFocusBox: false,\n verseLayout: \"inline\",\n};\n/** The options with every unset optional field filled in with its default. */\nfunction canonicalize(viewOptions) {\n if (!viewOptions)\n return viewOptions;\n // Strip the `undefined`-valued keys first - spreading them over the defaults would reinstate the\n // very \"not set\" state the defaults exist to resolve.\n const setOptions = Object.fromEntries(Object.entries(viewOptions).filter(([, value]) => value !== undefined));\n return { ...optionalViewOptionDefaults, ...setOptions };\n}\n/**\n * Whether the standard-view whitespace/display normalization rules apply to these view options.\n *\n * These rules — the display NBSP/`~` mapping at load time, the live display-whitespace transform\n * and clipboard normalization, and the inverse normalization on serialization — are all gated on\n * this ONE predicate, so a document always serializes under the same whitespace regime it was\n * loaded with; no combination of options can apply the display mapping without its inversion.\n *\n * The invariant is the STANDARD view fingerprint with the `noteMode` axis dropped: editable\n * markers in a spacing+formatted view with NEITHER `hasGutterParaMarkers` NOR\n * `hasActiveTextFocusBox`. It is `true` for both collapsed (the named `standard` mode) and\n * expanded notes. It is `false` for the Unformatted view (editable but neither spaced nor\n * formatted, where whitespace is shown literally) and for gutter/focus-box views: those render\n * paragraph markers as immutable typed text — a different whitespace regime with no\n * display-mapped text to invert (their named mode hides markers entirely, so the editable\n * engine's separators never combine with them). Deliberately NOT expressed via\n * {@link getViewMode}: expanded is not the named `standard` mode, and overloading `getViewMode`\n * would break its invertibility contract and the user-facing mode labels. `getViewMode` compares\n * whole option objects against {@link getViewOptions}, so this predicate stays independent of it:\n * it is the one place the whitespace fingerprint — the STANDARD options with the `noteMode` axis\n * dropped — is written down.\n *\n * @param viewOptions - View options of the editor.\n * @returns `true` when standard-view whitespace normalization applies.\n *\n * @public\n */\nexport function hasStandardViewWhitespace(viewOptions) {\n if (!viewOptions)\n return false;\n const { markerMode, hasSpacing, isFormattedFont, hasGutterParaMarkers, hasActiveTextFocusBox } = viewOptions;\n return (markerMode === \"editable\" &&\n hasSpacing &&\n isFormattedFont &&\n !hasGutterParaMarkers &&\n !hasActiveTextFocusBox);\n}\n/**\n * Get the verse node class for the given view options.\n *\n * @param viewOptions - View options of the editor.\n * @returns the verse node class if the view is defined, `undefined` otherwise.\n *\n * @public\n */\nexport function getVerseNodeClass(viewOptions) {\n if (!viewOptions)\n return;\n // Block verse is read-only, so its marker is never the editable `VerseNode`. Today the marker\n // mode below would reach the same answer - block verse hides markers - but dispatching on the\n // layout first keeps that independent of how markers happen to be configured.\n if (isBlockVerseLayout(viewOptions))\n return ImmutableVerseNode;\n return viewOptions.markerMode === \"editable\" ? VerseNode : ImmutableVerseNode;\n}\n/**\n * Whether the view options select the block verse layout.\n *\n * That layout is read-only: its paragraphs are split across verse blocks, so an edit has no\n * correct USJ to go back to. Anything that offers editing - or an affordance that depends on\n * editing, such as comment authoring - should treat it as read-only whatever `isReadonly` says.\n *\n * @param viewOptions - View options of the editor.\n * @returns `true` if verses are laid out as blocks.\n *\n * @public\n */\nexport function isBlockVerseLayout(viewOptions) {\n return viewOptions?.verseLayout === \"block\";\n}\n/**\n * Get the class name list for the given view options.\n *\n * @param viewOptions - View options of the editor.\n * @returns the element class name list based on view options.\n *\n * @public\n */\nexport function getViewClassList(viewOptions) {\n const classList = [];\n const _viewOptions = viewOptions ?? defaultViewOptions;\n if (_viewOptions) {\n classList.push(`${MARKER_MODE_CLASS_NAME_PREFIX}${_viewOptions.markerMode}`);\n if (_viewOptions.hasSpacing)\n classList.push(TEXT_SPACING_CLASS_NAME);\n if (_viewOptions.isFormattedFont)\n classList.push(FORMATTED_FONT_CLASS_NAME);\n }\n return classList;\n}\n","/**\n * Positions in the block verse layout, mapped to and from the USJ it displays.\n *\n * The layout regroups a chapter into one block per verse, cutting a paragraph that spans verses\n * into one fragment per verse (verse-block.utils.ts in platform). Every cut falls immediately\n * before a verse opener, which is always an element content item of its own, so no text run\n * straddles two fragments: a source paragraph's content items are its fragments' items end to\n * end. Mapping a location is therefore rewriting its leading indexes; everything below a unit is\n * unchanged. The layout has no pending edits, so there is no settled translation on top of this.\n */\nimport { indexesFromUsjJsonPath, isUsjTextContentLocation, usjJsonPathFromIndexes, } from \"@eten-tech-foundation/scripture-utilities\";\nimport { $getRoot, $getState, $isElementNode } from \"lexical\";\nimport { $getLogicalContentItems, $isImpliedParaNode, $isVerseBlockNode, $shouldIgnoreNodeForContentIndexes, verseBlockSourceState, } from \"shared\";\n/** The `$.content[…]` prefix of a jsonPath, with any property suffix (`['marker']`) stripped. */\nconst CONTENT_PATH = /^(\\$(?:\\.content\\[\\d+\\])*)(?:\\.|$|\\[)/;\nfunction contentPathOf(jsonPath) {\n return CONTENT_PATH.exec(jsonPath)?.[1] ?? jsonPath;\n}\n/** `location` re-addressed at `indexes`, keeping its subtype, its offsets, and any property\n * suffix — the path is the only part a translation ever changes. */\nfunction withContentIndexes(location, indexes) {\n const suffix = location.jsonPath.slice(contentPathOf(location.jsonPath).length);\n return { ...location, jsonPath: `${usjJsonPathFromIndexes(indexes)}${suffix}` };\n}\n/** Every unit of the block tree, in document order. Call inside a read of that tree. */\nexport function $getBlockUnits(collapsesSpaceRuns) {\n const placed = [];\n let rootIndex = 0;\n for (const child of $getRoot().getChildren()) {\n if ($shouldIgnoreNodeForContentIndexes(child))\n continue;\n if ($isVerseBlockNode(child)) {\n const blockIndex = rootIndex;\n child\n .getChildren()\n .filter((unit) => !$shouldIgnoreNodeForContentIndexes(unit))\n .forEach((unit, index) => placed.push({ node: unit, blockPrefix: [blockIndex, index], blockBase: 0 }));\n rootIndex += 1;\n }\n else if ($isImpliedParaNode(child)) {\n // Content-transparent at the root: its items are root items of the block tree too.\n placed.push({ node: child, blockPrefix: [], blockBase: rootIndex });\n rootIndex += $getLogicalContentItems(child, collapsesSpaceRuns).length;\n }\n else {\n placed.push({ node: child, blockPrefix: [rootIndex], blockBase: 0 });\n rootIndex += 1;\n }\n }\n const units = [];\n let nextTop = 0;\n let sourceTop = 0;\n let itemsInSource = 0;\n let previousSource;\n for (const unit of placed) {\n const count = $isElementNode(unit.node)\n ? $getLogicalContentItems(unit.node, collapsesSpaceRuns).length\n : 0;\n const source = $getState(unit.node, verseBlockSourceState);\n const isImplied = $isImpliedParaNode(unit.node);\n const isSourceStart = source === undefined || source !== previousSource;\n if (isSourceStart) {\n if (units.length > 0)\n units[units.length - 1].isSourceEnd = true;\n sourceTop = nextTop;\n itemsInSource = 0;\n if (!isImplied)\n nextTop += 1;\n }\n units.push({\n ...unit,\n count,\n usjPrefix: isImplied ? [] : [sourceTop],\n usjBase: isImplied ? sourceTop + itemsInSource : itemsInSource,\n isSourceStart,\n isSourceEnd: false,\n });\n if (isImplied)\n nextTop += count;\n itemsInSource += count;\n previousSource = source;\n }\n if (units.length > 0)\n units[units.length - 1].isSourceEnd = true;\n return units;\n}\nfunction startsWith(indexes, prefix) {\n return (indexes.length >= prefix.length && prefix.every((index, depth) => indexes[depth] === index));\n}\n/**\n * The USJ location a block-tree location names, or `undefined` when it names no unit.\n *\n * @param $locateContentStart - The location of the start of a unit's content (the caller's\n * `$getLocationFromNode(unit, 0, …)`), for a unit whose own path has no USJ counterpart.\n */\nexport function $blockToUsj(location, units, $locateContentStart, mayDescend = true) {\n const suffix = location.jsonPath.slice(contentPathOf(location.jsonPath).length);\n let indexes = indexesFromUsjJsonPath(contentPathOf(location.jsonPath));\n // A verse block has no USJ counterpart: naming one names its first unit.\n if (indexes.length === 1 &&\n units.some((unit) => unit.blockPrefix.length === 2 && unit.blockPrefix[0] === indexes[0]))\n indexes = [indexes[0], 0];\n for (const unit of units) {\n if (!startsWith(indexes, unit.blockPrefix))\n continue;\n const rest = indexes.slice(unit.blockPrefix.length);\n if (rest.length === 0) {\n if (unit.blockPrefix.length === 0)\n continue;\n // Only a source's first fragment stands for the paragraph. Any other fragment, and an\n // implied paragraph (which USJ has no object for), starts at its first item.\n if (mayDescend &&\n suffix === \"\" &&\n $isElementNode(unit.node) &&\n (!unit.isSourceStart || $isImpliedParaNode(unit.node)))\n return $blockToUsj($locateContentStart(unit.node), units, $locateContentStart, false);\n return withContentIndexes(location, unit.usjPrefix);\n }\n if (rest[0] < unit.blockBase || rest[0] >= unit.blockBase + unit.count)\n continue;\n return withContentIndexes(location, [\n ...unit.usjPrefix,\n rest[0] - unit.blockBase + unit.usjBase,\n ...rest.slice(1),\n ]);\n }\n return undefined;\n}\n/** The block-tree spelling of `{ \"$\", offset }`: the gap in front of USJ top-level item `offset`. */\nfunction $rootGapToBlock(offset, units, collapsesSpaceRuns) {\n for (const unit of units) {\n if (unit.usjPrefix.length === 0) {\n // An implied paragraph's items are root items of the USJ.\n if (offset < unit.usjBase || offset >= unit.usjBase + unit.count)\n continue;\n const item = offset - unit.usjBase + unit.blockBase;\n return unit.blockPrefix.length === 0\n ? { jsonPath: \"$\", offset: item }\n : { jsonPath: usjJsonPathFromIndexes(unit.blockPrefix), offset: item };\n }\n if (!unit.isSourceStart || unit.usjPrefix[0] !== offset)\n continue;\n const [top, within] = unit.blockPrefix;\n return within === undefined\n ? { jsonPath: \"$\", offset: top }\n : { jsonPath: usjJsonPathFromIndexes([top]), offset: within };\n }\n // Past the last item: the end of the document.\n return { jsonPath: \"$\", offset: $getLogicalContentItems($getRoot(), collapsesSpaceRuns).length };\n}\n/** The block-tree location a USJ location names, or `undefined` when it names nothing. */\nexport function $usjToBlock(location, units, collapsesSpaceRuns) {\n const indexes = indexesFromUsjJsonPath(contentPathOf(location.jsonPath));\n if (indexes.length === 0)\n return isUsjTextContentLocation(location)\n ? $rootGapToBlock(location.offset, units, collapsesSpaceRuns)\n : location;\n for (const unit of units) {\n if (!startsWith(indexes, unit.usjPrefix))\n continue;\n const rest = indexes.slice(unit.usjPrefix.length);\n if (rest.length === 0) {\n if (unit.usjPrefix.length === 0)\n continue;\n // The older `{ container, offset }` spelling: the gap before item `offset` of the paragraph,\n // in whichever fragment holds that item (its end only in the last fragment). An offset past\n // even the last fragment's own count still names the same \"end of container\" position every\n // other out-of-range index there does (mirroring `$contentEndLocation`'s clamp), rather than\n // naming nothing: a comment milestone consumed into the surrounding text run, say, can leave\n // the source's logical item count short of the raw USJ item count that produced the offset.\n if (isUsjTextContentLocation(location)) {\n const item = location.offset - unit.usjBase;\n if (item < 0 || (!unit.isSourceEnd && item >= unit.count))\n continue;\n return {\n ...withContentIndexes(location, unit.blockPrefix),\n offset: Math.min(item, unit.count) + unit.blockBase,\n };\n }\n if (!unit.isSourceStart)\n continue;\n return withContentIndexes(location, unit.blockPrefix);\n }\n if (rest[0] < unit.usjBase || rest[0] >= unit.usjBase + unit.count)\n continue;\n return withContentIndexes(location, [\n ...unit.blockPrefix,\n rest[0] - unit.usjBase + unit.blockBase,\n ...rest.slice(1),\n ]);\n }\n return undefined;\n}\n","import { $isImmutableVerseNode } from \"../../../nodes/usj/ImmutableVerseNode\";\nimport { $isSomeVerseNode } from \"../../../nodes/usj/node-react.utils\";\nimport { hasStandardViewWhitespace } from \"../../../views/view-options.utils\";\nimport { $blockToUsj, $getBlockUnits, $usjToBlock } from \"./blockVerseLocations.utils\";\nimport { getUsjDocumentLocationTypeName, indexesFromUsjJsonPath, isUsjAttributeKeyLocation, isUsjAttributeMarkerLocation, isUsjClosingAttributeMarkerLocation, isUsjClosingMarkerLocation, isUsjMarkerLocation, isUsjPropertyValueLocation, isUsjTextContentLocation, usjJsonPathFromIndexes, } from \"@eten-tech-foundation/scripture-utilities\";\nimport { deepEqual } from \"fast-equals\";\nimport { $createPoint, $createRangeSelection, $getRoot, $getSelection, $getState, $isElementNode, $isRangeSelection, $isRootNode, $isTextNode, } from \"lexical\";\nimport { $chapterGlyphTextNode, $charSeparatorPrefixLength, $decoratorDisplayText, $getLogicalContentItems, $getLogicalIndexOfChild, $getLogicalParent, $getLogicalPointBeforeNode, $getLogicalPointFromElementPoint, $getLogicalTextLocation, $getTextNodeAtLogicalOffset, $isAttributeDisplayRun, $isAttributeRunNode, $isBookNode, $isChapterNode, $isCharNode, $isImmutableChapterNode, $isImmutableTableCellNode, $isImmutableTableRowNode, $isImmutableTypedTextNode, $isImmutableUnmatchedNode, $isImpliedParaNode, $isMarkerNode, $isMilestoneNode, $isNestedCharNode, $isNoteNode, $isParaNode, $isSomeChapterNode, $isTypedMarkNode, $isUnknownNode, $isVerseBlockNode, $isVerseNode, $isVisibleMarkerNode, $noteEditableCallerNode, $ownerOfRunPiece, $shouldIgnoreNodeForContentIndexes, $typedNoteCallerRange, canonicalAttributeText, closingMarkerText, defaultMarkerAttribute, displayRunDescriptor, IMMUTABLE_NOTE_CALLER_NODE_TYPE, milestoneDefaultAttribute, openingMarkerText, textTypeState, unknownDisplayParts, unknownUsjAttributeName, } from \"shared\";\n/**\n * Converts a USJ SelectionRange or AnnotationRange to an editor RangeSelection.\n *\n * This function takes a USJ selection object and creates a corresponding editor RangeSelection.\n * It determines the start and end nodes based on the provided selection range and creates a new\n * RangeSelection with appropriate anchor and focus points.\n *\n * @param selection - The USJ selection range to convert. Can be either a SelectionRange or\n * AnnotationRange.\n * @param viewOptions - The editor's view options, which decide how its text maps to USJ offsets\n * (see {@link $getNodeFromLocation}).\n * @param options - `forAnnotation`: resolve the range an annotation holds rather than a selection.\n * A selection cannot point inside a read-only decorator, so an annotation's end inside one\n * passes over the whole decorator, its start there keeps it unless only the decorator's trailing\n * separator follows, and a range between two of its separators holds nothing; `decoratorHolds`\n * then says which part of it the range names. Without it, each end\n * resolves as a caret at that location does ({@link $getNodeFromLocation}).\n * `decoratorHolds` (with `forAnnotation`): filled, per decorator key, with the part of each\n * read-only decorator an end falls inside of, in the holdable bytes it stands for, for\n * `$wrapSelectionInTypedMarkNode` to hold exactly that part.\n * @returns A new editor RangeSelection object if the conversion is successful, or `undefined` if\n * the required nodes or offsets cannot be found.\n *\n * @remarks\n * - If the 'end' property of the selection is undefined (indicating this is a location rather than\n * a range), it defaults to the 'start' value.\n * - If either the start or end node cannot be found, or if their offsets are undefined, the\n * function returns undefined.\n * - In the block verse layout, `start` and `end` are first restated in that layout's own tree\n * coordinates ({@link $usjToBlock}), since it regroups paragraphs into verse blocks and so does\n * not share the USJ's content indexes; a location naming nothing there returns `undefined` the\n * same way a location naming nothing in the ordinary tree does.\n */\nexport function $getRangeFromUsjSelection(selection, viewOptions, options) {\n let { start } = selection;\n let end = selection.end ?? start;\n // The block verse layout regroups paragraphs into verse blocks, so its tree's indexes are not the\n // USJ's: restate both ends in block-tree coordinates first.\n if ($hasVerseBlocks()) {\n const collapsesSpaceRuns = hasStandardViewWhitespace(viewOptions);\n const units = $getBlockUnits(collapsesSpaceRuns);\n const blockStart = $usjToBlock(start, units, collapsesSpaceRuns);\n const blockEnd = end === start ? blockStart : $usjToBlock(end, units, collapsesSpaceRuns);\n if (!blockStart || !blockEnd)\n return undefined;\n start = blockStart;\n end = blockEnd;\n }\n // Find the start and end nodes with offsets based on the location.\n const forAnnotation = !!options?.forAnnotation;\n const startAt = $getPointFromLocation(start, viewOptions, forAnnotation);\n const endAt = end === start ? startAt : $getPointFromLocation(end, viewOptions, forAnnotation);\n const [startNode, startOffset] = startAt.point;\n const [endNode, endOffset] = endAt.point;\n if (!startNode || !endNode || startOffset === undefined || endOffset === undefined)\n return undefined;\n let startEdge = $normalizeDecoratorPoint(startNode, startOffset);\n let endEdge = $normalizeDecoratorPoint(endNode, endOffset);\n // A range that ends where a closing marker begins ends with the content before it. Standard view\n // can show presentation-only text between the two (the space before a note's `\\f*` when its last\n // char span has no closer of its own), and a range reaching over that text would let typing over\n // the selection delete it — which the marker-edit engine settles by losing the text after the\n // note. A caret there is left alone: it names the closer, and nothing is replaced. Hosts often\n // spell a caret as two equal objects, so a caret is told apart by value here.\n if (isUsjClosingMarkerLocation(end) && end.closingMarkerOffset === 0 && !deepEqual(end, start))\n endEdge = $pointBeforePresentationText(endEdge[0], endEdge[1], hasStandardViewWhitespace(viewOptions));\n if (options?.forAnnotation && end !== start) {\n const startEnd = { edge: startEdge, inside: startAt.insideDecorator };\n const endEnd = { edge: endEdge, inside: endAt.insideDecorator };\n [startEdge, endEdge] = $annotationEdges(startEnd, endEnd);\n if (options.decoratorHolds)\n $collectDecoratorHolds(startEnd, endEnd, options.decoratorHolds);\n }\n // Create selection range.\n const editorSelection = $createRangeSelection();\n editorSelection.anchor = $createPoint(startEdge[0].getKey(), startEdge[1], $getPointType(startEdge[0]));\n editorSelection.focus = $createPoint(endEdge[0].getKey(), endEdge[1], $getPointType(endEdge[0]));\n return editorSelection;\n}\n/**\n * The edges of the selection an annotation's range is wrapped through. A selection cannot point\n * inside a read-only decorator, so an end inside one moves to the decorator's edge, deciding by the\n * bytes it names: the range's first end goes in front of the decorator unless nothing but its\n * trailing separator follows, its last end behind it unless nothing but separators precede, and two\n * ends inside the same decorator with no byte between them name nothing. That only decides whether\n * the selection passes over the decorator; which of its bytes the annotation then holds is the part\n * the range names ({@link $collectDecoratorHolds}). Ends not inside a decorator keep their edges;\n * the range keeps its direction.\n */\nfunction $annotationEdges(start, end) {\n const { inside: startInside } = start;\n const { inside: endInside } = end;\n if (!startInside && !endInside)\n return [start.edge, end.edge];\n const { sameDecorator, reversed } = $rangeEndsOrder(start, end);\n const [first, last] = reversed ? [end, start] : [start, end];\n const firstEdge = first.inside\n ? $edgeBeside(first.inside, first.inside.before >= first.inside.total, first.edge)\n : first.edge;\n if (sameDecorator && startInside?.before === endInside?.before)\n return [firstEdge, firstEdge];\n const lastEdge = last.inside\n ? $edgeBeside(last.inside, last.inside.before > 0, last.edge)\n : last.edge;\n return reversed ? [lastEdge, firstEdge] : [firstEdge, lastEdge];\n}\n/**\n * The part of each read-only decorator an annotation range's end falls inside of, by decorator key\n * — the decorators {@link $annotationEdges} keeps: from the range's first end to the decorator's\n * end, from its start to the range's last end, or between both ends inside one decorator.\n */\nfunction $collectDecoratorHolds(start, end, holds) {\n const { inside: startInside } = start;\n const { inside: endInside } = end;\n if (!startInside && !endInside)\n return;\n const { sameDecorator, reversed } = $rangeEndsOrder(start, end);\n const [first, last] = reversed ? [endInside, startInside] : [startInside, endInside];\n const hold = (inside, from, to) => {\n if (to > from)\n holds.set(inside.decorator.getKey(), { start: from, end: to });\n };\n if (first)\n hold(first, first.before, sameDecorator && last ? last.before : first.total);\n if (last && !sameDecorator)\n hold(last, 0, last.before);\n}\n/**\n * Whether both ends of a range fall inside the same read-only decorator, and whether its `end` comes\n * before its `start` — by their bytes inside that decorator, or else by document order. The order\n * both {@link $annotationEdges} and {@link $collectDecoratorHolds} go by.\n */\nfunction $rangeEndsOrder(start, end) {\n const { inside: startInside } = start;\n const { inside: endInside } = end;\n if (startInside && endInside && startInside.decorator.is(endInside.decorator))\n return { sameDecorator: true, reversed: endInside.before < startInside.before };\n return { sameDecorator: false, reversed: $isBeforeInDocument(end, start) };\n}\n/** The element point in front of the decorator, or behind it when `after`; `fallback` when it has\n * no parent to point in. */\nfunction $edgeBeside(inside, after, fallback) {\n const [parent, index] = $pointBeside(inside.decorator, after);\n return parent && index !== undefined ? [parent, index] : fallback;\n}\n/** Whether `a` comes strictly before `b` in the document. An end inside a decorator counts from the\n * decorator's front, just past an edge that sits there. */\nfunction $isBeforeInDocument(a, b) {\n const $orderPoint = ({ edge, inside }) => {\n const [node, offset] = inside ? $edgeBeside(inside, false, edge) : edge;\n return $createPoint(node.getKey(), offset, $getPointType(node));\n };\n const aPoint = $orderPoint(a);\n const bPoint = $orderPoint(b);\n if (aPoint.isBefore(bPoint))\n return true;\n if (bPoint.isBefore(aPoint))\n return false;\n return !a.inside && !!b.inside;\n}\n/**\n * Retrieves the current USJ selection range from the editor.\n *\n * This function extracts the selection range from the editor's current state. It handles both\n * forward and backward selections, as well as collapsed (single point) selections.\n *\n * @param viewOptions - The editor's view options, which decide how its text maps to USJ offsets\n * (see {@link $getLocationFromNode}).\n * @returns A USJ `SelectionRange` object containing the start and end positions of the selection,\n * or `undefined` if there is no valid range selection, or the caret sits where the block verse\n * layout's regrouping ({@link $blockToUsj}) has nothing in the USJ to name.\n */\nexport function $getUsjSelectionFromEditor(viewOptions) {\n const editorSelection = $getSelection();\n if (!editorSelection || !$isRangeSelection(editorSelection))\n return;\n const units = $hasVerseBlocks()\n ? $getBlockUnits(hasStandardViewWhitespace(viewOptions))\n : undefined;\n const $locate = (node, offset) => {\n const location = $getLocationFromNode(node, offset, viewOptions);\n return units\n ? $blockToUsj(location, units, (unit) => $getLocationFromNode(unit, 0, viewOptions))\n : location;\n };\n const startNode = editorSelection.isBackward()\n ? editorSelection.focus.getNode()\n : editorSelection.anchor.getNode();\n const startOffset = editorSelection.isBackward()\n ? editorSelection.focus.offset\n : editorSelection.anchor.offset;\n const start = $locate(startNode, startOffset);\n if (!start)\n return undefined;\n if (editorSelection.isCollapsed())\n return { start };\n const endNode = editorSelection.isBackward()\n ? editorSelection.anchor.getNode()\n : editorSelection.focus.getNode();\n const endOffset = editorSelection.isBackward()\n ? editorSelection.anchor.offset\n : editorSelection.focus.offset;\n const end = $locate(endNode, endOffset);\n if (!end)\n return undefined;\n return { start, end };\n}\n/** The attribute-marker run each display-run kind carries, `undefined` for a kind that carries\n * none. Exhaustive over the registry, so a newly registered kind has to say which it is. */\nconst ATTRIBUTE_MARKER_RUNS = {\n va: { markerName: \"va\", keyName: \"altnumber\" },\n vp: { markerName: \"vp\", keyName: \"pubnumber\" },\n ca: { markerName: \"ca\", keyName: \"altnumber\" },\n cp: { markerName: \"cp\", keyName: \"pubnumber\" },\n cat: { markerName: \"cat\", keyName: \"category\" },\n char: undefined,\n milestone: undefined,\n optbreak: undefined,\n separator: undefined,\n nestedGlyph: undefined,\n opaqueUnknown: undefined,\n};\n/** The USJ attribute an attribute marker NAME carries, derived from {@link ATTRIBUTE_MARKER_RUNS}\n * so a run's two spellings cannot drift. */\nconst ATTRIBUTE_KEY_BY_MARKER_NAME = new Map(Object.values(ATTRIBUTE_MARKER_RUNS).flatMap((run) => run ? [[run.markerName, run.keyName]] : []));\n/**\n * Whether each display-run kind's pieces carry their owner's display bytes. Exhaustive over the\n * registry, so a newly registered kind has to decide rather than defaulting to carrying none, and\n * declared in the order a scan consults the carrying kinds.\n */\nconst RUN_KIND_CARRIES_BYTES = {\n va: true,\n vp: true,\n ca: true,\n cp: true,\n cat: true,\n milestone: true,\n char: true,\n optbreak: true,\n // A separator and a nested glyph are bytes of the char span they decorate and are addressed\n // through that span's own glyph spans; an opaque unknown renders its bytes as ordinary text.\n separator: false,\n nestedGlyph: false,\n opaqueUnknown: false,\n};\n/** The display-run kinds whose pieces carry their owner's bytes, in the order a scan consults them. */\nconst BYTE_CARRYING_RUN_KINDS = \n// `Object.keys` widens to `string[]`; the mapped type above is what guarantees every key is one.\nObject.keys(RUN_KIND_CARRIES_BYTES).filter((kind) => RUN_KIND_CARRIES_BYTES[kind]);\n/** One `name=\"value\"` pair of a USFM pipe-attribute list. */\nconst ATTRIBUTE_PAIR_REGEX = /([^\\s=\"|]+)=\"([^\"]*)\"/g;\n/** An attribute marker opening a run of display bytes, e.g. the `\\cat ` of `\\cat Missions\\cat*`. */\nconst ATTRIBUTE_MARKER_RUN_REGEX = /^[ \\u00A0]*\\\\([^\\s\\\\*]+)[ \\u00A0]/;\n/** A property path, always in bracket notation — the one spelling that survives an attribute name\n * carrying anything but word characters (`x-custom-attribute-1`), and the spelling\n * `UsjReaderWriter` emits. */\nfunction propertyJsonPath(ownerPath, property) {\n return `${ownerPath}['${property}']`;\n}\n/** The spans of an opening marker glyph: the `\\` (plus a nested span's `+`, which has no location\n * of its own and collapses onto it), then the marker name. */\nfunction markerGlyphSpans(prefixLength) {\n return [\n { start: 0, base: 0, bytes: { kind: \"marker\" } },\n { start: prefixLength, base: 0, bytes: { kind: \"property\", property: \"marker\" } },\n ];\n}\n/** A single span covering a whole closing marker glyph. */\nfunction closingGlyphSpans(keyName) {\n return [\n {\n start: 0,\n base: 0,\n bytes: keyName === undefined\n ? { kind: \"closingMarker\" }\n : { kind: \"closingAttributeMarker\", keyName },\n },\n ];\n}\n/** Which piece of which display run `node` is, or `undefined` when it is not a run piece. */\nfunction $runPieceOf(node) {\n const reference = $ownerOfRunPiece(node);\n if (!reference)\n return undefined;\n const pieces = displayRunDescriptor(reference.kind).scanPieces(reference.owner);\n if (pieces.opener?.is(node))\n return { ...reference, role: \"opener\" };\n if (pieces.value?.is(node))\n return { ...reference, role: \"value\" };\n if (pieces.closer?.is(node))\n return { ...reference, role: \"closer\" };\n return undefined;\n}\n/**\n * The spans of a USFM pipe-attribute list (`|lemma=\"grace\" strong=\"G5485\"`, `|grace`), starting at\n * the byte after the `|`. A key's span reaches through its `=` and opening quote (so those bytes\n * run one and two past the key), and a value's span reaches through its closing quote and the\n * space before the next key (so those run one and two past the value). A list with no\n * `name=\"value\"` pair at all is the bare form a marker's default attribute collapses to.\n * `usjAttributeName` names each key as USJ does, for bytes that spell it under its USFM name (a\n * figure's `src` is its USJ `file`).\n */\nfunction pipeAttributeSpans(text, contentStart, defaultAttributeName, usjAttributeName = (usfmName) => usfmName) {\n const spans = [];\n // `matchAll` rather than repeated `exec`: it iterates a clone, so the shared regex's `lastIndex`\n // stays 0 and a second call cannot start mid-string.\n for (const pair of text.slice(contentStart).matchAll(ATTRIBUTE_PAIR_REGEX)) {\n const name = pair[1];\n const keyName = usjAttributeName(name);\n spans.push({\n start: contentStart + pair.index,\n base: 0,\n bytes: { kind: \"attributeKey\", keyName },\n });\n spans.push({\n // Past the key, its `=`, and its opening quote.\n start: contentStart + pair.index + name.length + 2,\n base: 0,\n bytes: { kind: \"property\", property: keyName },\n });\n }\n if (spans.length > 0)\n return spans;\n if (defaultAttributeName === undefined)\n return [];\n return [\n { start: contentStart, base: 0, bytes: { kind: \"property\", property: defaultAttributeName } },\n ];\n}\n/**\n * The spans of an attribute marker's display run written as ONE string — the shape an opaque block\n * renders (`\\esb \\cat Missions\\cat*`), as opposed to the glyph/value/glyph node triplet an\n * editable owner carries. A leading space counts into the enclosing marker's own name offset space.\n */\nfunction attributeMarkerRunSpans(text, enclosingMarkerLength) {\n const opener = ATTRIBUTE_MARKER_RUN_REGEX.exec(text);\n if (!opener)\n return [];\n const markerName = opener[1];\n const openerStart = opener[0].length - markerName.length - 2;\n const keyName = ATTRIBUTE_KEY_BY_MARKER_NAME.get(markerName) ?? markerName;\n const spans = [];\n if (openerStart > 0)\n spans.push({\n start: 0,\n base: enclosingMarkerLength,\n bytes: { kind: \"property\", property: \"marker\" },\n });\n spans.push({ start: openerStart, base: 0, bytes: { kind: \"attributeMarker\", keyName } });\n spans.push({ start: openerStart + 1, base: 0, bytes: { kind: \"attributeKey\", keyName } });\n spans.push({ start: opener[0].length, base: 0, bytes: { kind: \"property\", property: keyName } });\n const closer = text.lastIndexOf(`\\\\${markerName}*`);\n if (closer > opener[0].length)\n spans.push({ start: closer, base: 0, bytes: { kind: \"closingAttributeMarker\", keyName } });\n return spans;\n}\n/** The USJ node a marker glyph's bytes belong to: the element it sits in (looking through an\n * annotation mark) — except the loose read-only glyphs markerMode \"visible\" renders AFTER a\n * milestone (`\\qt-s`, `\\*`), which are that milestone's. Any other glyph that follows an element is\n * its own parent's (`\\f*` after the note's last `\\ft`, `\\wj*` after a nested `\\+nd*`). Editable\n * mode wraps a milestone's glyphs in a display run, which `$runPieceOf` resolves before this is\n * asked. */\nfunction $glyphOwner(glyph) {\n if ($isVisibleMarkerNode(glyph)) {\n const previous = $getPreviousContentSibling(glyph);\n const text = glyph.getTextContent();\n if ($isMilestoneNode(previous) &&\n (text === \"\\\\*\" || text.startsWith(openingMarkerText(previous.getMarker()))))\n return previous;\n }\n return $getLogicalParent(glyph) ?? glyph;\n}\n/** The spans of an editable `MarkerNode` glyph. */\nfunction $markerGlyphBytes(glyph) {\n const length = glyph.getTextContentSize();\n const piece = $runPieceOf(glyph);\n if (piece && piece.role !== \"value\") {\n const attributeRun = ATTRIBUTE_MARKER_RUNS[piece.kind];\n if (attributeRun) {\n const { keyName } = attributeRun;\n return {\n owner: piece.owner,\n length,\n spans: piece.role === \"closer\"\n ? closingGlyphSpans(keyName)\n : [\n { start: 0, base: 0, bytes: { kind: \"attributeMarker\", keyName } },\n { start: 1, base: 0, bytes: { kind: \"attributeKey\", keyName } },\n ],\n };\n }\n if (piece.kind === \"milestone\")\n return {\n owner: piece.owner,\n length,\n spans: piece.role === \"closer\" ? closingGlyphSpans() : markerGlyphSpans(1),\n };\n }\n const syntax = glyph.getMarkerSyntax();\n return {\n owner: $glyphOwner(glyph),\n length,\n spans: syntax === \"opening\"\n ? // A nested span's `+` rides between the backslash and the marker name, so the name's\n // offsets start one byte later.\n markerGlyphSpans(glyph.getNested() ? 2 : 1)\n : closingGlyphSpans(),\n };\n}\n/** The spans of a read-only glyph (`ImmutableTypedTextNode` with text type \"marker\"). */\nfunction $visibleGlyphBytes(glyph) {\n const text = glyph.getTextContent();\n const length = text.length;\n // An optbreak's whole `//` token is the node's marker location: USJ has nothing to say about the\n // second slash, so it collapses onto the first.\n const piece = $runPieceOf(glyph);\n if (piece?.kind === \"optbreak\")\n return {\n owner: piece.owner,\n length,\n spans: [{ start: 0, base: 0, bytes: { kind: \"marker\" } }],\n };\n const owner = $glyphOwner(glyph);\n // A book's glyph carries its code as well as its marker (`\\id 2SA `).\n if ($isBookNode(owner)) {\n const markerLength = openingMarkerText(owner.getMarker()).length;\n if (text.startsWith(openingMarkerText(owner.getMarker())))\n return {\n owner,\n length,\n spans: [\n ...markerGlyphSpans(1),\n { start: markerLength + 1, base: 0, bytes: { kind: \"property\", property: \"code\" } },\n ],\n };\n }\n // An opaque block's glyphs spell whatever its kind renders, which is not always `*`-terminated\n // (`\\esb` opens and `\\esbe` closes a sidebar), so the bytes themselves decide which glyph it is.\n if ($isUnknownNode(owner)) {\n const parts = unknownDisplayParts(owner.getTag(), owner.getMarker(), owner.getUnknownAttributes());\n if (parts.closing !== \"\" && text === parts.closing)\n return { owner, length, spans: closingGlyphSpans() };\n if (parts.opening !== \"\" && text === parts.opening)\n return { owner, length, spans: markerGlyphSpans(1) };\n }\n return {\n owner,\n length,\n spans: text.endsWith(\"*\")\n ? closingGlyphSpans()\n : markerGlyphSpans(text.startsWith(\"\\\\+\") ? 2 : 1),\n };\n}\n/** The spans of an attribute display run's value node. */\nfunction $attributeRunValueBytes(value) {\n const piece = $runPieceOf(value);\n if (piece?.role !== \"value\")\n return undefined;\n const { owner, kind } = piece;\n const text = value.getTextContent();\n const length = text.length;\n const attributeRun = ATTRIBUTE_MARKER_RUNS[kind];\n if (attributeRun) {\n const { markerName, keyName } = attributeRun;\n return {\n owner,\n length,\n spans: [\n // The separator before the value is the space after the attribute marker, which counts\n // into that marker name's offset space.\n { start: 0, base: markerName.length, bytes: { kind: \"attributeKey\", keyName } },\n { start: 1, base: 0, bytes: { kind: \"property\", property: keyName } },\n ],\n };\n }\n if (kind === \"char\")\n return {\n owner,\n length,\n spans: [\n { start: 0, base: 0, bytes: { kind: \"precedingText\" } },\n ...pipeAttributeSpans(text, 1, $isCharNode(owner) ? defaultMarkerAttribute(owner.getMarker()) : undefined),\n ],\n };\n if (kind === \"milestone\" && $isMilestoneNode(owner))\n return { owner, length, spans: milestoneAttributeSpans(owner.getMarker(), text) };\n return undefined;\n}\n/** The spans of a milestone's attribute display — its marker's separator, then\n * `|sid=\"q1\" who=\"Pilate\"` — the same bytes whether an editable run's value text or markerMode\n * \"visible\"'s read-only decorator spells them. A milestone has no text content of its own, so the\n * separator and the `|` both keep counting into its marker name's offset space. */\nfunction milestoneAttributeSpans(marker, text) {\n return [\n { start: 0, base: marker.length, bytes: { kind: \"property\", property: \"marker\" } },\n ...pipeAttributeSpans(text, 2, milestoneDefaultAttribute(marker)),\n ];\n}\n/** The spans of a read-only attribute display (an `ImmutableTypedTextNode` with text type\n * \"attribute\"): an opaque block's folded run, which spells a whole attribute-marker run or\n * pipe-attribute list, or the attribute list markerMode \"visible\" renders after a milestone. */\nfunction $opaqueAttributeBytes(node) {\n const text = node.getTextContent();\n const length = text.length;\n const owner = node.getParent();\n if (!$isUnknownNode(owner)) {\n // A milestone's loose display follows it the way its loose glyphs do (see `$glyphOwner`).\n const milestone = $getPreviousContentSibling(node);\n return $isMilestoneNode(milestone)\n ? { owner: milestone, length, spans: milestoneAttributeSpans(milestone.getMarker(), text) }\n : undefined;\n }\n const markerRun = attributeMarkerRunSpans(text, (owner.getMarker() ?? \"\").length);\n if (markerRun.length > 0)\n return { owner, length, spans: markerRun };\n if (!text.startsWith(\"|\"))\n return undefined;\n return {\n owner,\n length,\n spans: [\n { start: 0, base: 0, bytes: { kind: \"precedingText\" } },\n // The bytes spell an attribute the way USFM names it, which is not always USJ's name for it.\n ...pipeAttributeSpans(text, 1, undefined, (usfmName) => unknownUsjAttributeName(owner.getTag(), usfmName)),\n ],\n };\n}\n/** The spans of a glyph whose text spells `\\marker` — a verse's own\n * text and a chapter's glyph child. */\nfunction markerAndNumberSpans(marker, text) {\n const openingText = openingMarkerText(marker);\n if (!text.startsWith(openingText))\n return undefined;\n return [\n ...markerGlyphSpans(1),\n { start: openingText.length + 1, base: 0, bytes: { kind: \"property\", property: \"number\" } },\n ];\n}\n/** The USFM display bytes `node` carries, or `undefined` when it carries none. */\nfunction $displayBytesOf(node) {\n if ($isMarkerNode(node))\n return $markerGlyphBytes(node);\n if ($isVisibleMarkerNode(node))\n return $visibleGlyphBytes(node);\n if ($isImmutableTypedTextNode(node) && node.getTextType() === \"attribute\")\n return $opaqueAttributeBytes(node);\n if (node.getType() === IMMUTABLE_NOTE_CALLER_NODE_TYPE) {\n const note = node.getParent();\n if (!$isNoteNode(note))\n return undefined;\n // A collapsed caller renders no glyph bytes of its own; the caller value is what it stands for.\n // The decorator's own text size is 0, so measure the value it stands for: every offset into\n // that value then resolves to the decorator rather than falling back to another carrier.\n return {\n owner: note,\n length: note.getCaller().length,\n spans: [{ start: 0, base: 0, bytes: { kind: \"property\", property: \"caller\" } }],\n };\n }\n if ($isVerseNode(node)) {\n const spans = markerAndNumberSpans(node.getMarker(), node.getTextContent());\n return spans ? { owner: node, length: node.getTextContentSize(), spans } : undefined;\n }\n if (!$isTextNode(node))\n return undefined;\n // An unmatched marker spells `\\` then its marker name, which carries its own `*` (`\\*`, `\\nd*`).\n if ($isImmutableUnmatchedNode(node))\n return { owner: node, length: node.getTextContentSize(), spans: markerGlyphSpans(1) };\n if ($getState(node, textTypeState) === \"attribute\")\n return $attributeRunValueBytes(node);\n const parent = node.getParent();\n if ($isChapterNode(parent) && $chapterGlyphTextNode(parent)?.is(node)) {\n const spans = markerAndNumberSpans(parent.getMarker(), node.getTextContent());\n return spans ? { owner: parent, length: node.getTextContentSize(), spans } : undefined;\n }\n // An annotation mark around the caller is transparent in USJ, so the note is the logical parent.\n const note = $getLogicalParent(node);\n if ($isNoteNode(note) && $noteEditableCallerNode(note)?.is(node)) {\n return {\n owner: note,\n length: node.getTextContentSize(),\n spans: [\n // The caller's leading space is the space after the note's own marker, which counts into\n // that marker name's offset space.\n {\n start: 0,\n base: note.getMarker().length,\n bytes: { kind: \"property\", property: \"marker\" },\n },\n { start: 1, base: 0, bytes: { kind: \"property\", property: \"caller\" } },\n ],\n };\n }\n return undefined;\n}\n/**\n * Whether `node` renders display bytes as a decorator. Such a node holds no text of its own, so\n * the editor can put no caret inside it and the element boundary beside it is the only point that\n * addresses its bytes.\n */\nfunction $isDisplayByteDecorator(node) {\n return ($isVisibleMarkerNode(node) ||\n ($isImmutableTypedTextNode(node) && node.getTextType() === \"attribute\") ||\n node.getType() === IMMUTABLE_NOTE_CALLER_NODE_TYPE);\n}\n/** Every node carrying `owner`'s own display bytes, in the order a location resolves against them\n * — the owner's glyphs first, then the pieces of the display runs that ride on it. */\nfunction $displayByteCarriers(owner) {\n const carriers = [];\n // A verse's text and an unmatched marker's are their own bytes.\n if ($isVerseNode(owner) || $isImmutableUnmatchedNode(owner))\n carriers.push(owner);\n if ($isElementNode(owner)) {\n const chapterGlyph = $isChapterNode(owner) ? $chapterGlyphTextNode(owner) : undefined;\n const noteCaller = $isNoteNode(owner) ? $noteEditableCallerNode(owner) : undefined;\n for (const child of owner.getChildren()) {\n // The caller can sit inside an annotation mark, which is transparent in USJ.\n if (noteCaller && (noteCaller.is(child) || child.isParentOf(noteCaller)))\n carriers.push(noteCaller);\n else if ($isMarkerNode(child) ||\n $isVisibleMarkerNode(child) ||\n ($isImmutableTypedTextNode(child) && child.getTextType() === \"attribute\") ||\n child.getType() === IMMUTABLE_NOTE_CALLER_NODE_TYPE ||\n chapterGlyph?.is(child))\n carriers.push(child);\n }\n }\n // markerMode \"visible\" renders a milestone's glyphs and attribute display as loose read-only\n // siblings after it, up to the next thing that is not one.\n if ($isMilestoneNode(owner))\n for (let next = owner.getNextSibling(); next && $isDisplayByteDecorator(next); next = next.getNextSibling())\n if (!$isVisibleMarkerNode(next) || $glyphOwner(next).is(owner))\n carriers.push(next);\n for (const kind of BYTE_CARRYING_RUN_KINDS) {\n const descriptor = displayRunDescriptor(kind);\n if (!descriptor.ownerPredicate(owner))\n continue;\n const { opener, value, closer } = descriptor.scanPieces(owner);\n if (opener)\n carriers.push(opener);\n if (value)\n carriers.push(value);\n if (closer)\n carriers.push(closer);\n }\n return carriers;\n}\n/** Whether a span's bytes are the ones a location is asking for. */\nfunction isSameByteKind(span, wanted) {\n if (span.kind !== wanted.kind)\n return false;\n if (span.kind === \"property\" && wanted.kind === \"property\")\n return span.property === wanted.property;\n if ((span.kind === \"attributeKey\" ||\n span.kind === \"attributeMarker\" ||\n span.kind === \"closingAttributeMarker\") &&\n \"keyName\" in wanted)\n return span.keyName === wanted.keyName;\n return true;\n}\n/**\n * The location `offset` bytes into `node`'s display text, or `undefined` when `node` carries no\n * display bytes. Snaps LEFT: the offset lands in the last span that starts at or before it, and\n * keeps counting into that span's offset space.\n */\nfunction $locationFromDisplayBytes(node, offset, collapsesSpaceRuns) {\n const bytes = $displayBytesOf(node);\n if (!bytes || bytes.spans.length === 0)\n return undefined;\n const clamped = Math.max(0, Math.min(offset, bytes.length));\n let span = bytes.spans[0];\n for (const candidate of bytes.spans) {\n if (candidate.start > clamped)\n break;\n span = candidate;\n }\n const within = span.base + (clamped - span.start);\n const jsonPath = usjJsonPathFromIndexes($getJsonPathIndexes(bytes.owner, collapsesSpaceRuns));\n switch (span.bytes.kind) {\n case \"marker\":\n return { jsonPath };\n case \"closingMarker\":\n return { jsonPath, closingMarkerOffset: within };\n case \"property\": {\n // Spaces after a verse's number are its separator and, at a line end, the newline USFM\n // writes instead; extra ones typed there are a run USFM normalizes away. None is a byte of\n // the number, so a caret among them is the number's end.\n const { owner } = bytes;\n const number = span.bytes.property === \"number\" && $isVerseNode(owner) ? owner.getNumber() : undefined;\n return {\n jsonPath: propertyJsonPath(jsonPath, span.bytes.property),\n propertyOffset: number === undefined ? within : Math.min(within, number.length),\n };\n }\n case \"attributeKey\":\n return { jsonPath, keyName: span.bytes.keyName, keyOffset: within };\n case \"attributeMarker\":\n return { jsonPath, keyName: span.bytes.keyName };\n case \"closingAttributeMarker\":\n return { jsonPath, keyName: span.bytes.keyName, keyClosingMarkerOffset: within };\n case \"precedingText\":\n return $precedingTextLocation(node, collapsesSpaceRuns);\n }\n}\n/**\n * Whether `node` is text that has no location of its own to report — neither display bytes nor a\n * place in the logical content model — so being asked for one only makes it defer to a neighbor.\n * An empty char span's NBSP placeholder is the shape that matters: `\\w |lemma=\"x\"\\w*` renders as\n * the opening glyph, the placeholder, then the attribute run. Whoever asks such a node must not\n * take its answer, because for the run's own `|` that answer comes straight back to the run, and\n * the two hops then recurse until the stack blows.\n */\nfunction $defersToNeighbor(node, collapsesSpaceRuns) {\n return ($isTextNode(node) &&\n !$displayBytesOf(node) &&\n !$getLogicalTextLocation(node, 0, collapsesSpaceRuns));\n}\n/** Where the byte just before `node` sits — the answer for a byte with no representation of its own\n * (the `|` opening an attribute run), which keeps counting into that byte's offset space: the end\n * of the text before it, or the end of a nested span's closing glyph. Only what comes BEFORE\n * `node` counts, even when text after it joins the same USJ string (the run between them is\n * presentation-only). */\nfunction $precedingTextLocation(node, collapsesSpaceRuns) {\n // An annotation mark around the run is transparent: step out of it to find what precedes.\n let start = node;\n for (let mark = start.getParent(); !start.getPreviousSibling() && $isTypedMarkNode(mark);) {\n start = mark;\n mark = start.getParent();\n }\n // Walk back over text that would only defer to its neighbor — the deferral points forward, at\n // this run, so taking it would cycle. Stepping strictly backwards through siblings terminates.\n let previous = start.getPreviousSibling();\n while (previous && $defersToNeighbor(previous, collapsesSpaceRuns))\n previous = previous.getPreviousSibling();\n if (!previous)\n return undefined;\n const last = $isElementNode(previous) ? previous.getLastDescendant() : previous;\n if (last && ($isTextNode(last) || $isDisplayByteDecorator(last))) {\n // The same deferral one level down (a wrapper whose last descendant is that placeholder).\n // Nothing here can answer, so report no preceding byte rather than following it.\n if ($defersToNeighbor(last, collapsesSpaceRuns))\n return undefined;\n return $locationFromNode(last, last.getTextContentSize(), collapsesSpaceRuns);\n }\n const parent = previous.getParent();\n if (!parent)\n return undefined;\n return $locationFromNode(parent, previous.getIndexWithinParent() + 1, collapsesSpaceRuns);\n}\n/**\n * The node and offset holding `owner`'s `wanted` bytes at `offset` within them, or `undefined`\n * when nothing in the tree carries them. The first carrier whose span covers the offset wins, so\n * a position two nodes can express (the end of `\\ca` and the separator before its value) resolves\n * to the node whose own bytes it is.\n */\nfunction $pointFromDisplayBytes(owner, wanted, offset) {\n for (const carrier of $displayByteCarriers(owner)) {\n const bytes = $displayBytesOf(carrier);\n if (!bytes || !bytes.owner.is(owner))\n continue;\n for (let index = 0; index < bytes.spans.length; index++) {\n const span = bytes.spans[index];\n if (!isSameByteKind(span.bytes, wanted))\n continue;\n const highest = highestSpanOffset(bytes, index);\n if (offset < span.base || offset > highest)\n continue;\n return [carrier, span.start + (offset - span.base)];\n }\n }\n return undefined;\n}\n/** The highest offset span `index` of `bytes` addresses. The last span owns the position at the\n * very end of the text; every other span stops one byte before the next span starts. */\nfunction highestSpanOffset(bytes, index) {\n const span = bytes.spans[index];\n const nextSpan = bytes.spans[index + 1];\n return nextSpan\n ? span.base + (nextSpan.start - span.start) - 1\n : span.base + (bytes.length - span.start);\n}\n/**\n * Finds the live point a USJ location names.\n *\n * @param location - The location, in the coordinates of the USJ the editor serializes to.\n * @param viewOptions - The editor's view options. In Standard view serialization collapses a run of\n * two or more spaces to one, so a text offset past such a run is that much further along in the\n * live text.\n * @returns The node and offset, or `[undefined, undefined]` when nothing in the tree matches.\n */\nexport function $getNodeFromLocation(location, viewOptions) {\n const collapsesSpaceRuns = hasStandardViewWhitespace(viewOptions);\n // Handle UsjTextContentLocation first (most common case)\n if (isUsjTextContentLocation(location)) {\n const jsonPathIndexes = indexesFromUsjJsonPath(location.jsonPath);\n let currentNode = $getRoot();\n for (let i = 0; i < jsonPathIndexes.length; i++) {\n if (!currentNode || !$isElementNode(currentNode))\n return [undefined, undefined];\n const item = $getLogicalContentItems(currentNode, collapsesSpaceRuns)[jsonPathIndexes[i]];\n if (!item)\n return [undefined, undefined];\n if (item.type === \"text\") {\n // Text items are terminal — the path must end here.\n if (i !== jsonPathIndexes.length - 1)\n return [undefined, undefined];\n return ($getTextNodeAtLogicalOffset(item, location.offset) ??\n $documentEndPoint(location, collapsesSpaceRuns) ?? [undefined, undefined]);\n }\n currentNode = item.node;\n }\n // The jsonPath resolved to an ElementNode (e.g. \"$.content[0]\", or \"$\" for the root): the\n // older spelling of the gap in front of that container's content item `offset`. Resolve the\n // location that gap has.\n if (currentNode && $isElementNode(currentNode)) {\n return $getNodeFromLocation($boundaryLocation(currentNode, jsonPathIndexes, location.offset, collapsesSpaceRuns), viewOptions);\n }\n return [undefined, undefined];\n }\n // The document end is spelled one past the last token's own bytes, which a glyph that carries\n // its trailing separator would otherwise take for a byte of its own.\n if (isUsjPropertyValueLocation(location) ||\n isUsjClosingMarkerLocation(location) ||\n isUsjClosingAttributeMarkerLocation(location)) {\n const documentEnd = $documentEndPoint(location, collapsesSpaceRuns);\n if (documentEnd)\n return documentEnd;\n }\n // Handle UsjAttributeKeyLocation and UsjAttributeMarkerLocation BEFORE UsjMarkerLocation\n // because UsjAttributeMarkerLocation has keyName but no offsets, similar to UsjMarkerLocation.\n // Checking for keyName first ensures correct type narrowing.\n if (isUsjAttributeKeyLocation(location) || isUsjAttributeMarkerLocation(location)) {\n const node = $navigateToNode(location.jsonPath, collapsesSpaceRuns);\n if (!node)\n return [undefined, undefined];\n const { keyName } = location;\n const point = isUsjAttributeKeyLocation(location)\n ? $pointFromDisplayBytes(node, { kind: \"attributeKey\", keyName }, location.keyOffset)\n : $pointFromDisplayBytes(node, { kind: \"attributeMarker\", keyName }, 0);\n if (point)\n return point;\n const behindCaller = $behindReadOnlyCaller(node, keyName);\n if (behindCaller)\n return behindCaller;\n const bareValueStart = $bareValueStart(node, keyName);\n if (bareValueStart)\n return bareValueStart;\n // A milestone key no byte displays resolves in front of the milestone, where its values and\n // closer resolve too, so no range across them runs backward.\n if ($isMilestoneNode(node))\n return $pointBeside(node, false);\n return $nearestPointAfterContent(node);\n }\n // Handle UsjClosingAttributeMarkerLocation BEFORE UsjMarkerLocation/UsjClosingMarkerLocation.\n if (isUsjClosingAttributeMarkerLocation(location)) {\n const node = $navigateToNode(location.jsonPath, collapsesSpaceRuns);\n if (!node)\n return [undefined, undefined];\n const point = $pointFromDisplayBytes(node, { kind: \"closingAttributeMarker\", keyName: location.keyName }, location.keyClosingMarkerOffset);\n if (point)\n return point;\n return $behindReadOnlyCaller(node, location.keyName) ?? $nearestPointAfterContent(node);\n }\n // Handle UsjMarkerLocation - position at the beginning of the opening marker\n if (isUsjMarkerLocation(location)) {\n const node = $navigateToNode(location.jsonPath, collapsesSpaceRuns);\n if (!node)\n return [undefined, undefined];\n const point = $pointFromDisplayBytes(node, { kind: \"marker\" }, 0);\n if (point)\n return point;\n // Fallback: no glyph bytes at all (markerMode \"hidden\"), so position at the element's start —\n // or, with no text there to stand in front of, in front of the node itself.\n const firstChild = $isElementNode(node) ? node.getFirstChild() : null;\n if (firstChild && $isTextNode(firstChild))\n return [firstChild, 0];\n return $pointBeside(node, false);\n }\n // Handle UsjClosingMarkerLocation - position within the closing marker\n if (isUsjClosingMarkerLocation(location)) {\n const node = $navigateToNode(location.jsonPath, collapsesSpaceRuns);\n if (!node)\n return [undefined, undefined];\n const point = $pointFromDisplayBytes(node, { kind: \"closingMarker\" }, location.closingMarkerOffset);\n if (point)\n return point;\n // Fallback: no closing glyph. The character after the closer is past the node; anything\n // before it is the end of the node's content.\n const closingLength = $closingMarkerLength(node);\n if (closingLength !== undefined && location.closingMarkerOffset >= closingLength)\n return $pointBeside(node, true);\n // A leaf owner (a milestone) has no content before its closer: in front of the leaf.\n if (!$isElementNode(node))\n return $pointBeside(node, false);\n const lastChild = node.getLastChild();\n if (lastChild && $isTextNode(lastChild))\n return [lastChild, lastChild.getTextContent().length];\n return [node, node.getChildrenSize()];\n }\n // Handle UsjPropertyValueLocation - position within a property value (e.g., marker name)\n if (isUsjPropertyValueLocation(location)) {\n const propertyName = propertyNameOf(location.jsonPath);\n const node = $navigateToNode(location.jsonPath, collapsesSpaceRuns);\n if (!node || propertyName === undefined)\n return [undefined, undefined];\n const wanted = { kind: \"property\", property: propertyName };\n // At the end of a line, USFM has no separator after a verse's number: the newline follows it.\n // The glyph's trailing separator stands for nothing there (the browser does not even draw it),\n // so one past the number is the newline's far side, the start of the next line.\n if (propertyName === \"number\" &&\n $isVerseNode(node) &&\n location.propertyOffset === node.getNumber().length + 1 &&\n $endsInOwnSeparator(node) &&\n $endsItsLine(node)) {\n const nextLine = $nextLineStart(node);\n if (nextLine)\n return nextLine;\n }\n const point = $pointFromDisplayBytes(node, wanted, location.propertyOffset);\n if (point)\n return point;\n // Past the bytes a read-only decorator displays of the value (a collapsed caller shows the\n // caller, not the space after it): the end of those bytes.\n const pastDisplayed = $endOfDecoratorBytes(node, wanted, location.propertyOffset);\n if (pastDisplayed)\n return pastDisplayed;\n const behindCaller = $behindReadOnlyCaller(node, propertyName);\n if (behindCaller)\n return behindCaller;\n if ($isElementNode(node)) {\n // An attribute the view does not display is placed where USFM spells it — after the\n // content — so both ends of a range inside it meet; the marker and the other properties\n // USFM writes first stay at the start.\n if (!PROPERTIES_BEFORE_CONTENT.has(propertyName))\n return $nearestPointAfterContent(node);\n const firstChild = node.getFirstChild();\n if (firstChild && $isTextNode(firstChild))\n return [firstChild, 0];\n return [node, 0];\n }\n // A leaf marker's property (a verse's number): in front of the marker, or past it from the\n // character after the value on.\n const value = $leafPropertyValue(node, propertyName);\n return $pointBeside(node, value !== undefined && location.propertyOffset >= value.length);\n }\n // All UsjDocumentLocation subtypes should be handled above\n throw new Error(`Unsupported UsjDocumentLocation type: ${getUsjDocumentLocationTypeName(location)}. ` +\n \"All UsjDocumentLocation subtypes should be supported: UsjMarkerLocation, \" +\n \"UsjClosingMarkerLocation, UsjTextContentLocation, UsjPropertyValueLocation, \" +\n \"UsjAttributeKeyLocation, UsjAttributeMarkerLocation, and\" +\n `UsjClosingAttributeMarkerLocation. Received: ${JSON.stringify(location)}`);\n}\n/** The property a property-value location's path names (`$.content[0]['marker']` → `marker`). */\nfunction propertyNameOf(jsonPath) {\n const propertyMatch = /\\.(\\w+)$|^\\$\\.(\\w+)$|\\['([^']+)'\\]$/.exec(jsonPath);\n return propertyMatch?.[1] ?? propertyMatch?.[2] ?? propertyMatch?.[3];\n}\n/** The properties USFM spells in front of an element's content; every other property is an\n * attribute, spelled after it. */\nconst PROPERTIES_BEFORE_CONTENT = new Set([\n \"marker\",\n \"code\",\n \"caller\",\n \"category\",\n]);\n/** Where `offset` falls among `text`'s holdable bytes — all but its edge whitespace, the rule a\n * text carrier's holdable range follows. */\nfunction holdableBytePosition(text, offset) {\n const lead = text.length - text.trimStart().length;\n const end = Math.max(lead, text.trimEnd().length);\n return { before: Math.min(Math.max(offset, lead), end) - lead, total: end - lead };\n}\n/**\n * {@link $getNodeFromLocation}'s point, and where the location falls among a read-only decorator's\n * bytes when it names one past the decorator's first: a byte of a glyph, attribute or collapsed\n * caller decorator, measured in the bytes the decorator displays — and, for an annotation\n * (`forAnnotation`), together with the undisplayed bytes it stands for ({@link $standInPosition});\n * or any byte of a verse or chapter decorator other than its marker's backslash, since such a\n * decorator displays its owner whole ({@link $wholeDecoratorPosition}).\n */\nfunction $getPointFromLocation(location, viewOptions, forAnnotation) {\n const point = $getNodeFromLocation(location, viewOptions);\n const [node, offset] = point;\n if (forAnnotation && !isUsjTextContentLocation(location)) {\n const owner = $navigateToNode(location.jsonPath, hasStandardViewWhitespace(viewOptions));\n const standIn = owner && $standInPosition(owner, location);\n if (standIn)\n return standIn.before > 0 ? { point, insideDecorator: standIn } : { point };\n }\n if (node && offset !== undefined && offset > 0 && $isDisplayByteDecorator(node)) {\n const text = $decoratorDisplayText(node);\n return {\n point,\n insideDecorator: { decorator: node, ...holdableBytePosition(text, offset) },\n };\n }\n if (isUsjTextContentLocation(location))\n return { point };\n const owner = $navigateToNode(location.jsonPath, hasStandardViewWhitespace(viewOptions));\n if (!$isImmutableVerseNode(owner) && !$isImmutableChapterNode(owner))\n return { point };\n const insideDecorator = $wholeDecoratorPosition(owner, location);\n return insideDecorator && insideDecorator.before > 0 ? { point, insideDecorator } : { point };\n}\n/**\n * The bytes a read-only decorator stands for, its own displayed bytes first, then the undisplayed\n * bytes USFM spells between it and the next byte the view shows — bytes the caret behind the\n * decorator steps over, so they have no position of their own in the view. Only an empty char\n * span's read-only opening glyph stands for any: the glyph, then the span's attributes as Standard\n * view spells them (`|GEN 1:1`), when no byte the view shows spells them. A note's caller stands\n * for nothing it does not display: an undisplayed category names nothing\n * ({@link $behindReadOnlyCaller}).\n *\n * Only an EMPTY span: with content, the caret behind the glyph reports that content, so the\n * attributes (spelled after it) lie outside the glyph's locations — between the content's end and\n * the closer, where no byte names them and a range inside them holds nothing.\n */\nfunction $emptySpanStandIn(char) {\n const opener = char.getFirstChild();\n if (!opener || !$isVisibleMarkerNode(opener))\n return undefined;\n const openerBytes = $displayBytesOf(opener);\n if (openerBytes?.spans[0]?.bytes.kind !== \"marker\" || !openerBytes.owner.is(char))\n return undefined;\n const isEmpty = char\n .getChildren()\n .every((child) => $isDisplayByteDecorator(child) ||\n ($isTextNode(child) && $shouldIgnoreNodeForContentIndexes(child)));\n if (!isEmpty)\n return undefined;\n const defaultAttribute = defaultMarkerAttribute(char.getMarker());\n const text = canonicalAttributeText(char.getUnknownAttributes() ?? {}, defaultAttribute);\n if (!text)\n return undefined;\n const attributeSpans = pipeAttributeSpans(text, 1, defaultAttribute);\n const isDisplayed = $displayByteCarriers(char).some((carrier) => $displayBytesOf(carrier)?.spans.some((span) => attributeSpans.some((attributeSpan) => isSameByteKind(span.bytes, attributeSpan.bytes))));\n if (isDisplayed)\n return undefined;\n return {\n decorator: opener,\n pieces: [\n { text: opener.getTextContent(), spans: openerBytes.spans },\n {\n text,\n spans: [{ start: 0, base: 0, bytes: { kind: \"precedingText\" } }, ...attributeSpans],\n },\n ],\n };\n}\n/**\n * Where `location` falls among the bytes a read-only decorator of `owner` stands for\n * ({@link $emptySpanStandIn}), counted in holdable bytes — each piece's edge whitespace, like a text\n * carrier's, names nothing. `undefined` when `owner` has no such decorator or the location names\n * none of those bytes.\n */\nfunction $standInPosition(owner, location) {\n const standIn = $isCharNode(owner) ? $emptySpanStandIn(owner) : undefined;\n const named = standIn && wholeDecoratorByteOf(location);\n if (!standIn || !named)\n return undefined;\n let total = 0;\n let before;\n for (const { text, spans } of standIn.pieces) {\n const bytes = { owner, spans, length: text.length };\n if (before === undefined) {\n const index = spans.findIndex((span, i) => isSameByteKind(span.bytes, named.bytes) &&\n named.offset >= span.base &&\n named.offset <= highestSpanOffset(bytes, i));\n if (index >= 0) {\n const at = spans[index].start + (named.offset - spans[index].base);\n before = total + holdableBytePosition(text, at).before;\n }\n }\n total += holdableBytePosition(text, 0).total;\n }\n return before === undefined ? undefined : { decorator: standIn.decorator, before, total };\n}\n/**\n * Where `location` falls among the bytes of `decorator`'s owner, which a verse or chapter decorator\n * displays whole: `\\v 1 \\va 1a\\va* \\vp 1b\\vp*`, `\\c 1 \\ca 2\\ca* \\cp A`. The separators between\n * its tokens are not counted; the space inside `\\v 1` is. `undefined` for a location that names\n * none of those tokens.\n */\nfunction $wholeDecoratorPosition(decorator, location) {\n const named = wholeDecoratorByteOf(location);\n if (!named)\n return undefined;\n const tokens = $wholeDecoratorTokens(decorator);\n const index = tokens.findIndex((token) => isSameByteKind(token.bytes, named.bytes));\n if (index < 0)\n return undefined;\n const total = tokens.reduce((sum, token) => sum + token.length, 0);\n const before = tokens.slice(0, index).reduce((sum, token) => sum + token.length, 0) +\n Math.min(Math.max(named.offset, 0), tokens[index].length);\n return { decorator, before, total };\n}\n/** The bytes `location` names and its offset into them, for a location on a verse or chapter. */\nfunction wholeDecoratorByteOf(location) {\n if (isUsjAttributeKeyLocation(location))\n return {\n bytes: { kind: \"attributeKey\", keyName: location.keyName },\n offset: location.keyOffset,\n };\n if (isUsjAttributeMarkerLocation(location))\n return { bytes: { kind: \"attributeMarker\", keyName: location.keyName }, offset: 0 };\n if (isUsjClosingAttributeMarkerLocation(location))\n return {\n bytes: { kind: \"closingAttributeMarker\", keyName: location.keyName },\n offset: location.keyClosingMarkerOffset,\n };\n if (isUsjMarkerLocation(location))\n return { bytes: { kind: \"marker\" }, offset: 0 };\n if (isUsjPropertyValueLocation(location)) {\n const property = propertyNameOf(location.jsonPath);\n if (property === undefined)\n return undefined;\n return { bytes: { kind: \"property\", property }, offset: location.propertyOffset };\n }\n return undefined;\n}\n/** The tokens a verse or chapter decorator displays, in USFM order, with the bytes each spells\n * and how many. A chapter's `\\cp` is a line of its own, with no closer. */\nfunction $wholeDecoratorTokens(decorator) {\n const token = (bytes, text) => ({ bytes, text, length: text.length });\n const tokens = [\n token({ kind: \"marker\" }, \"\\\\\"),\n // The space after the marker name is inside the glyph Standard view spells, so it counts.\n token({ kind: \"property\", property: \"marker\" }, `${decorator.getMarker()} `),\n token({ kind: \"property\", property: \"number\" }, decorator.getNumber()),\n ];\n const isChapter = $isImmutableChapterNode(decorator);\n const runs = isChapter\n ? [ATTRIBUTE_MARKER_RUNS.ca, ATTRIBUTE_MARKER_RUNS.cp]\n : [ATTRIBUTE_MARKER_RUNS.va, ATTRIBUTE_MARKER_RUNS.vp];\n for (const run of runs) {\n if (!run)\n continue;\n const { markerName, keyName } = run;\n const value = keyName === \"altnumber\" ? decorator.getAltnumber() : decorator.getPubnumber();\n if (value === undefined)\n continue;\n tokens.push(token({ kind: \"attributeMarker\", keyName }, \"\\\\\"), token({ kind: \"attributeKey\", keyName }, markerName), token({ kind: \"property\", property: keyName }, value));\n if (!(isChapter && keyName === \"pubnumber\"))\n tokens.push(token({ kind: \"closingAttributeMarker\", keyName }, closingMarkerText(markerName)));\n }\n return tokens;\n}\n/**\n * The holdable bytes read-only `decorator` stands for, in the order positions inside it count them\n * ({@link DecoratorBytePosition}): a verse's or chapter's tokens, an empty span's opening glyph and\n * then its attributes, or the bytes any other decorator displays — each without its edge\n * whitespace.\n */\nexport function $readDecoratorHoldableText(decorator) {\n if ($isImmutableVerseNode(decorator) || $isImmutableChapterNode(decorator))\n return $wholeDecoratorTokens(decorator)\n .map(({ text }) => text)\n .join(\"\");\n const owner = decorator.getParent();\n const standIn = $isCharNode(owner) ? $emptySpanStandIn(owner) : undefined;\n if (standIn?.decorator.is(decorator))\n return standIn.pieces.map(({ text }) => text.trim()).join(\"\");\n return $decoratorDisplayText(decorator).trim();\n}\n/**\n * The caret a point on read-only display bytes stands for. Those bytes render as decorator nodes,\n * which hold no text of their own — Lexical throws on a text point whose node is not a `TextNode`\n * — so every offset inside them becomes an element boundary beside them: in front of the node for\n * a point within its bytes, and after it for a point at their very end.\n *\n * Interior bytes therefore collapse onto the boundary in front of the node: a read-only glyph is\n * addressable as a whole, never byte by byte. {@link $getLocationFromNode} reports what those\n * boundaries stand for, so the surviving positions still name the bytes rather than the element.\n * The one exception is the separator an opening glyph ends in (`\\b `): it is the character after\n * the marker name, where the marker's content starts, so it is the boundary after the glyph.\n */\nfunction $normalizeDecoratorPoint(node, offset) {\n if (!$isDisplayByteDecorator(node))\n return [node, offset];\n const parent = node.getParent();\n if (!parent || !$isElementNode(parent))\n return [node, offset];\n const indexWithinParent = node.getIndexWithinParent();\n if (indexWithinParent < 0)\n return [node, offset];\n const size = node.getTextContentSize();\n const isPastEnd = (offset >= size && offset > 0) ||\n (offset === size - 1 && TRAILING_SEPARATOR_REGEX.test(node.getTextContent()));\n return [parent, isPastEnd ? indexWithinParent + 1 : indexWithinParent];\n}\n/** A glyph's trailing separator: the space (or NBSP) after its marker name. */\nconst TRAILING_SEPARATOR_REGEX = /[ \\u00A0]$/;\n/**\n * `[node, offset]` moved back over any presentation-only text directly in front of it — text that\n * is neither USJ content nor display bytes of its own — to the end of whatever precedes that text.\n * Unchanged when there is none, or when the point is not at the front of its node.\n */\nfunction $pointBeforePresentationText(node, offset, collapsesSpaceRuns) {\n let previous;\n if ($isElementNode(node))\n previous = offset > 0 ? node.getChildAtIndex(offset - 1) : null;\n else if (offset === 0)\n previous = node.getPreviousSibling();\n else\n return [node, offset];\n let skipped = false;\n while ($isTextNode(previous) &&\n !$displayBytesOf(previous) &&\n !$getLogicalTextLocation(previous, 0, collapsesSpaceRuns)) {\n previous = previous.getPreviousSibling();\n skipped = true;\n }\n if (!skipped)\n return [node, offset];\n // A read-only glyph before the skipped text is addressed by the boundary right after it.\n const parent = previous?.getParent();\n if (previous && parent && $isDisplayByteDecorator(previous))\n return [parent, previous.getIndexWithinParent() + 1];\n const last = $isElementNode(previous) ? previous.getLastDescendant() : previous;\n return $isTextNode(last) ? [last, last.getTextContentSize()] : [node, offset];\n}\nfunction $getPointType(node) {\n return $isElementNode(node) ? \"element\" : \"text\";\n}\n/**\n * Navigates to a node using jsonPath indexes.\n * @param jsonPath - The jsonPath string to navigate.\n * @param collapsesSpaceRuns - Whether serialization collapses space runs; see\n * `$getLogicalContentItems`.\n * @returns The node at the path, or undefined if not found.\n */\nfunction $navigateToNode(jsonPath, collapsesSpaceRuns) {\n // Extract just the content path portion (strip property suffix if present)\n const contentPathMatch = new RegExp(/^(\\$(?:\\.content\\[\\d+\\])*)(?:\\.|$|\\[)/).exec(jsonPath);\n const contentPath = contentPathMatch ? contentPathMatch[1] : jsonPath;\n const jsonPathIndexes = indexesFromUsjJsonPath(contentPath);\n let currentNode = $getRoot();\n for (const index of jsonPathIndexes) {\n if (!currentNode || !$isElementNode(currentNode))\n return undefined;\n const item = $getLogicalContentItems(currentNode, collapsesSpaceRuns)[index];\n currentNode = item?.type === \"element\" ? item.node : undefined;\n }\n return currentNode;\n}\n/**\n * Gets the location from a Lexical node and offset, emitting the `UsjDocumentLocation` subtype\n * that names what those bytes are.\n *\n * A point inside displayed USFM bytes — a marker glyph, an attribute display run, the optbreak\n * token, a chapter's or verse's own glyph text, a note's caller — names the byte it sits on\n * ({@link $locationFromDisplayBytes}); everything else is a point in USJ content, reported as a\n * `UsjTextContentLocation` in coalesced-USJ coordinates.\n *\n * @param node - The Lexical node.\n * @param offset - The offset within the node's text content.\n * @param viewOptions - The editor's view options. In Standard view serialization collapses a run of\n * two or more spaces to one, so a text offset past such a run reports that many fewer characters,\n * and a point inside the run reports the character after the space it keeps.\n * @returns The appropriate UsjDocumentLocation subtype.\n */\nexport function $getLocationFromNode(node, offset, viewOptions) {\n return $locationFromNode(node, offset, hasStandardViewWhitespace(viewOptions));\n}\n/** {@link $getLocationFromNode} with the view's whitespace decision already made. */\nfunction $locationFromNode(node, offset, collapsesSpaceRuns) {\n // Past the front of the bytes typed into a waiting note caller text is in those bytes, which\n // are the note's content (`$typedNoteCallerRange`): the content's location, not the caller's.\n const typedCaller = $isTextNode(node) ? $typedNoteCallerRange(node) : undefined;\n if ($isTextNode(node) && typedCaller && offset > typedCaller.start) {\n const typed = $getLogicalTextLocation(node, offset, collapsesSpaceRuns);\n if (typed)\n return {\n jsonPath: usjJsonPathFromIndexes([\n ...$getJsonPathIndexes(typed.parent, collapsesSpaceRuns),\n typed.index,\n ]),\n offset: typed.offset,\n };\n }\n // Behind a glyph's own trailing separator the next byte is the first one after the glyph, and a\n // separator has no position of its own: the caret names that byte (the same answer the\n // paragraph separator gives, below).\n if ($isTextNode(node) &&\n offset > 0 &&\n offset === node.getTextContentSize() &&\n $endsInOwnSeparator(node)) {\n const after = $locationOfFirstByteAfter(node, collapsesSpaceRuns);\n if (after)\n return after;\n }\n // Standard view renders USFM bytes as real nodes, so a point inside one of them is a point in\n // those bytes rather than in content.\n const displayLocation = $locationFromDisplayBytes(node, offset, collapsesSpaceRuns);\n if (displayLocation)\n return displayLocation;\n if ($isTypedMarkNode(node)) {\n // An element point on the annotation wrapper: convert to the equivalent point as if the\n // mark did not exist.\n const childrenSize = node.getChildrenSize();\n const childAtOffset = node.getChildAtIndex(Math.min(offset, childrenSize - 1));\n if ($isTextNode(childAtOffset)) {\n const localOffset = offset >= childrenSize ? childAtOffset.getTextContentSize() : 0;\n return $locationFromNode(childAtOffset, localOffset, collapsesSpaceRuns);\n }\n // A boundary between two of the mark's children is the point in front of the child it names\n // (a verse the mark spans, a char span), exactly as if the mark were not there.\n if (childAtOffset && offset > 0 && offset < childrenSize) {\n const inFront = $locationInFrontOfMarkChild(node, offset, collapsesSpaceRuns);\n if (inFront)\n return inFront;\n }\n // An edge of a mark whose child there is not text (e.g. a CharNode wrapped in the mark), an\n // interior point with no content from there to the mark's end, or an empty mark (childAtOffset\n // is null): anchor on the mark's parent at the mark's own position instead of falling through\n // to treat the mark itself as the logical parent, which would drop the mark's content index.\n // The mark contributes no content of its own, so the boundary before/after it is the boundary\n // before/after its own position in its parent — which, for a mark inside the root's implied\n // paragraph, is itself a boundary among the root's items. Any point past the mark's front is\n // after it.\n const parent = node.getParent();\n if (parent) {\n const markIndex = node.getIndexWithinParent();\n const elementOffset = offset > 0 ? markIndex + 1 : markIndex;\n return $locationFromNode(parent, elementOffset, collapsesSpaceRuns);\n }\n }\n // Element selection - offset is a child index, convert to a logical point.\n if ($isElementNode(node)) {\n const childAtOffset = node.getChildAtIndex(offset);\n // A boundary in front of displayed USFM bytes is at their first byte, so it reports what those\n // bytes are rather than a content boundary. For read-only bytes it is the only point that\n // addresses them at all.\n const front = childAtOffset && $frontDisplayByteNode(childAtOffset);\n if (front) {\n const byteLocation = $locationFromDisplayBytes(front, 0, collapsesSpaceRuns);\n if (byteLocation)\n return byteLocation;\n }\n if (childAtOffset && $isDisplayByteDecorator(childAtOffset))\n return {\n jsonPath: usjJsonPathFromIndexes($getJsonPathIndexes(node, collapsesSpaceRuns)),\n };\n // Past the container's own closing glyph is past the container.\n const previous = offset > 0 ? node.getChildAtIndex(offset - 1) : null;\n if (!childAtOffset && previous && $isClosingGlyphOf(previous, node))\n return $locationBeside(node, true, collapsesSpaceRuns);\n // An element that holds only display — a chapter's glyph and runs, an attribute display run —\n // has no content gaps of its own: a point in it is beside the element itself.\n if ($isSomeChapterNode(node) || $shouldIgnoreNodeForContentIndexes(node))\n return $locationBeside(node, offset > 0, collapsesSpaceRuns);\n // The root's implied paragraph is spliced into the root, so a point in it is among the root's\n // items.\n const container = $isImpliedParaNode(node) && $isRootNode(node.getParent()) ? node.getParentOrThrow() : node;\n return $locationFromLogicalPoint(container, $getLogicalPointFromElementPoint(node, offset, collapsesSpaceRuns), collapsesSpaceRuns);\n }\n // Regular text node - UsjTextContentLocation in coalesced-USJ coordinates.\n if ($isTextNode(node)) {\n // A caret in front of the separator the span's text starts with is the end of the opener's\n // name — the answer the same caret gives once the separator is its own node.\n if (offset < $charSeparatorPrefixLength(node)) {\n const previousGlyph = node.getPreviousSibling();\n if ($isMarkerNode(previousGlyph))\n return $locationFromNode(previousGlyph, previousGlyph.getTextContentSize(), collapsesSpaceRuns);\n }\n const logicalTextLocation = $getLogicalTextLocation(node, offset, collapsesSpaceRuns);\n if (logicalTextLocation) {\n return {\n jsonPath: usjJsonPathFromIndexes([\n ...$getJsonPathIndexes(logicalTextLocation.parent, collapsesSpaceRuns),\n logicalTextLocation.index,\n ]),\n offset: logicalTextLocation.offset,\n };\n }\n // Presentation-only text (the space Standard view shows after a paragraph's `\\p` glyph, where\n // a caret at the paragraph's content start sits) is no USJ content of its own: a point in it\n // is the point beside it — the start of the text after it, or the end of the bytes before it.\n const isAfter = offset > 0;\n let neighbor = isAfter ? node.getNextSibling() : node.getPreviousSibling();\n // An annotation mark is transparent: the text beside it is its first or last leaf.\n while ($isTypedMarkNode(neighbor))\n neighbor = isAfter ? neighbor.getFirstChild() : neighbor.getLastChild();\n if ($isTextNode(neighbor) &&\n ($displayBytesOf(neighbor) || $getLogicalTextLocation(neighbor, 0, collapsesSpaceRuns)))\n return $locationFromNode(neighbor, isAfter ? 0 : neighbor.getTextContentSize(), collapsesSpaceRuns);\n }\n // Anything else — presentation text with nothing beside it to defer to, a decorator the model\n // counts as one item — is the gap in front of it, or after it for a point past its start.\n return $locationBeside(node, offset > 0, collapsesSpaceRuns);\n}\n/** Whether `node` is editable glyph text ending in its own trailing separator: a verse's `\\v 1 `,\n * or an expanded note's ` + ` caller. A chapter's glyph is not one: only its own runs follow it. */\nfunction $endsInOwnSeparator(node) {\n if (!TRAILING_SEPARATOR_REGEX.test(node.getTextContent()))\n return false;\n if ($isVerseNode(node))\n return true;\n // An annotation mark around the caller is transparent in USJ, so the note is the logical parent.\n const note = $getLogicalParent(node);\n return $isNoteNode(note) && !!$noteEditableCallerNode(note)?.is(node);\n}\n/**\n * The location of the first byte after `node`: in front of the first leaf of whatever follows it,\n * looking through annotation marks, so a `\\va` run or a char span answers with its own first byte.\n * With nothing after `node` in its parent, that byte is the parent's content end (a paragraph's\n * newline, the last paragraph's included). `undefined` when what follows answers with the end of\n * whatever precedes it — this node.\n */\nfunction $locationOfFirstByteAfter(node, collapsesSpaceRuns) {\n let current = node;\n for (let mark = current.getParent(); !current.getNextSibling() && $isTypedMarkNode(mark); mark = current.getParent())\n current = mark;\n const next = current.getNextSibling();\n if (!next) {\n const parent = current.getParent();\n if (!parent)\n return undefined;\n return $locationFromNode(parent, parent.getChildrenSize(), collapsesSpaceRuns);\n }\n const leaf = $isElementNode(next) ? (next.getFirstDescendant() ?? next) : next;\n if ($defersToNeighbor(leaf, collapsesSpaceRuns) ||\n $displayBytesOf(leaf)?.spans[0]?.bytes.kind === \"precedingText\")\n return undefined;\n return $locationFromNode(leaf, 0, collapsesSpaceRuns);\n}\n/**\n * Where the line after `node`'s starts — in front of the next block's first byte, as its marker\n * location resolves — or `undefined` when `node`'s line is the document's last.\n */\nfunction $nextLineStart(node) {\n let line = node.getParent();\n while (line && !$endsLine(line))\n line = line.getParent();\n const next = line?.getNextSibling();\n if (!next)\n return undefined;\n const point = $pointFromDisplayBytes(next, { kind: \"marker\" }, 0);\n if (point)\n return point;\n const firstChild = $isElementNode(next) ? next.getFirstChild() : null;\n if (firstChild && $isTextNode(firstChild))\n return [firstChild, 0];\n return $pointBeside(next, false);\n}\n/** Whether nothing follows `node` in its line, looking through annotation marks. */\nfunction $endsItsLine(node) {\n let current = node;\n for (let mark = current.getParent(); !current.getNextSibling() && $isTypedMarkNode(mark); mark = current.getParent())\n current = mark;\n return !current.getNextSibling();\n}\n/** The node carrying the first display byte at `child`'s front: `child` itself, or the first piece\n * of an attribute display run's wrapper (`\\va 1a\\va*`), whose element point would otherwise skip\n * the run as non-content. `undefined` when no display byte starts there. */\nfunction $frontDisplayByteNode(child) {\n if ($displayBytesOf(child))\n return child;\n if (!$isAttributeRunNode(child))\n return undefined;\n const first = child.getFirstDescendant();\n return first && $displayBytesOf(first) ? first : undefined;\n}\n/**\n * The location in front of `mark`'s child at `offset`, a child with siblings on both sides, or\n * `undefined` when nothing from that child onward in the mark is logical content (the mark's back\n * edge then answers).\n */\nfunction $locationInFrontOfMarkChild(mark, offset, collapsesSpaceRuns) {\n for (let index = offset; index < mark.getChildrenSize(); index++) {\n const child = mark.getChildAtIndex(index);\n if (!child)\n return undefined;\n // Displayed USFM bytes answer with their first byte, as they do in front of any element point.\n const front = $frontDisplayByteNode(child);\n if (front)\n return $locationFromDisplayBytes(front, 0, collapsesSpaceRuns);\n if ($isTextNode(child) && $getLogicalTextLocation(child, 0, collapsesSpaceRuns))\n return $locationFromNode(child, 0, collapsesSpaceRuns);\n // Presentation-only children — including a nested mark holding nothing but presentation —\n // hold no position of their own: the boundary is in front of what follows them.\n if ($isTextNode(child) || $shouldIgnoreNodeForContentIndexes(child))\n continue;\n const logical = $getLogicalPointBeforeNode(child, collapsesSpaceRuns);\n if (logical)\n return $locationFromLogicalPoint(logical.parent, logical.point, collapsesSpaceRuns);\n }\n return undefined;\n}\n/**\n * The location of a logical point among `container`'s items: a text point inside a coalesced USJ\n * text item (e.g. at an annotation edge) keeps its offset, and an index point is the gap in front\n * of that item ({@link $boundaryLocation}).\n */\nfunction $locationFromLogicalPoint(container, point, collapsesSpaceRuns) {\n const containerIndexes = $getJsonPathIndexes(container, collapsesSpaceRuns);\n if (point.type === \"text\")\n return {\n jsonPath: usjJsonPathFromIndexes([...containerIndexes, point.index]),\n offset: point.offset,\n };\n return $boundaryLocation(container, containerIndexes, point.index, collapsesSpaceRuns);\n}\n/** Whether `glyph` is `owner`'s own closing marker glyph. */\nfunction $isClosingGlyphOf(glyph, owner) {\n const bytes = $displayBytesOf(glyph);\n return !!bytes && bytes.owner.is(owner) && bytes.spans[0]?.bytes.kind === \"closingMarker\";\n}\n/** The location of the gap in front of `node` in its parent, or after it when `after`. */\nfunction $locationBeside(node, after, collapsesSpaceRuns) {\n const parent = node.getParent();\n if (!parent)\n return { jsonPath: usjJsonPathFromIndexes($getJsonPathIndexes(node, collapsesSpaceRuns)) };\n const index = node.getIndexWithinParent() + (after ? 1 : 0);\n if ($isTypedMarkNode(parent)) {\n // A mark is transparent, so a gap at its edge is the gap beside the mark itself, and a gap\n // between its children is in front of the content that follows. Asking the mark for its own\n // element point instead would hand a point at its front straight back to the child that asked\n // — presentation text opening a mark defers to the gap in front of itself — and never return.\n if (index > 0 && index < parent.getChildrenSize()) {\n const inFront = $locationInFrontOfMarkChild(parent, index, collapsesSpaceRuns);\n if (inFront)\n return inFront;\n }\n return $locationBeside(parent, index > 0, collapsesSpaceRuns);\n }\n return $locationFromNode(parent, index, collapsesSpaceRuns);\n}\n// ---------------------------------------------------------------------------\n// Content gaps\n// ---------------------------------------------------------------------------\n/**\n * The location of the gap in front of `container`'s logical content item `index`, or of the end of\n * its content when `index` is past its last item.\n *\n * USJ gives `offset` a meaning only on text, so a gap is never a container plus an index: every\n * USFM position has exactly one canonical location, and a gap is the USFM position right after it.\n * In front of a marker object that is the marker's own location (at its backslash); in front of\n * text, the text's first character; at the end of a container, see {@link $contentEndLocation}.\n * The one allowed alias is the end of a text run in front of a marker or closer, which a caret held\n * there reports as the text's `offset: length` instead.\n *\n * @param container - The logical parent the index counts in (the root for the root's implied\n * paragraph).\n * @param containerIndexes - `container`'s own content path.\n */\nfunction $boundaryLocation(container, containerIndexes, index, collapsesSpaceRuns) {\n const items = $getLogicalContentItems(container, collapsesSpaceRuns);\n const item = items[index];\n if (!item)\n return $contentEndLocation(container, containerIndexes, items, collapsesSpaceRuns);\n const jsonPath = usjJsonPathFromIndexes([...containerIndexes, index]);\n return item.type === \"text\"\n ? { jsonPath, offset: 0 }\n : { jsonPath };\n}\n/**\n * The location of the end of `container`'s content — the USFM position after its last item:\n *\n * - The root's is the end of the document, one past the final newline, spelled on the last token\n * ({@link $afterLastTokenLocation} plus one).\n * - A span with a closing marker ends where that closer starts (`closingMarkerOffset: 0`), unless\n * it ends in text, whose end names the same position.\n * - A paragraph-like line ends at its newline, which has no location of its own and so is the\n * character after the line's last token.\n * - A span with no closer (note content that ParatextData leaves unclosed, a table cell) ends\n * where whatever follows it in its parent starts.\n */\nfunction $contentEndLocation(container, containerIndexes, items, collapsesSpaceRuns) {\n if ($isRootNode(container))\n return $afterLastTokenLocation(container, containerIndexes, 1, collapsesSpaceRuns);\n if ($closingMarkerLength(container) !== undefined) {\n const lastIndex = items.length - 1;\n const last = items[lastIndex];\n if (last?.type === \"text\")\n return {\n jsonPath: usjJsonPathFromIndexes([...containerIndexes, lastIndex]),\n offset: last.length,\n };\n return {\n jsonPath: usjJsonPathFromIndexes(containerIndexes),\n closingMarkerOffset: 0,\n };\n }\n const parent = $getLogicalParent(container);\n const indexInParent = containerIndexes[containerIndexes.length - 1];\n if ($endsLine(container) || !parent || indexInParent === undefined)\n return $afterLastTokenLocation(container, containerIndexes, 0, collapsesSpaceRuns);\n return $boundaryLocation(parent, containerIndexes.slice(0, -1), indexInParent + 1, collapsesSpaceRuns);\n}\n/**\n * The character after `node`'s last token, addressed on that token at its length, plus `extra`:\n * text `offset: length`, a closing marker's `closingMarkerOffset: `, and for a\n * marker with no content the last of its opening's own tokens — `['marker']` at the marker\n * name's length for an empty paragraph, a verse's or chapter's number, or its last attribute\n * marker. `extra` is 1 for the end of the document, which is one past the final newline.\n */\nfunction $afterLastTokenLocation(node, indexes, extra, collapsesSpaceRuns) {\n const jsonPath = usjJsonPathFromIndexes(indexes);\n const closingLength = $closingMarkerLength(node);\n if (closingLength !== undefined)\n return {\n jsonPath,\n closingMarkerOffset: closingLength + extra,\n };\n if ($isElementNode(node)) {\n const items = $getLogicalContentItems(node, collapsesSpaceRuns);\n const lastIndex = items.length - 1;\n const last = items[lastIndex];\n const lastPath = [...indexes, lastIndex];\n if (last?.type === \"text\")\n return { jsonPath: usjJsonPathFromIndexes(lastPath), offset: last.length + extra };\n if (last)\n return $afterLastTokenLocation(last.node, lastPath, extra, collapsesSpaceRuns);\n }\n const property = (name, value) => ({\n jsonPath: propertyJsonPath(jsonPath, name),\n propertyOffset: value.length + extra,\n });\n // A number's attribute markers follow it, `\\va`…`\\va*` before `\\vp`…`\\vp*`, and a chapter's\n // `\\cp` line has no closer.\n const closingAttribute = (keyName, markerName) => ({\n jsonPath,\n keyName,\n keyClosingMarkerOffset: closingMarkerText(markerName).length + extra,\n });\n if ($isSomeVerseNode(node)) {\n if (node.getPubnumber() !== undefined)\n return closingAttribute(\"pubnumber\", \"vp\");\n if (node.getAltnumber() !== undefined)\n return closingAttribute(\"altnumber\", \"va\");\n return property(\"number\", node.getNumber());\n }\n if ($isSomeChapterNode(node)) {\n const pubnumber = node.getPubnumber();\n if (pubnumber !== undefined)\n return property(\"pubnumber\", pubnumber);\n if (node.getAltnumber() !== undefined)\n return closingAttribute(\"altnumber\", \"ca\");\n return property(\"number\", node.getNumber());\n }\n if ($isBookNode(node))\n return property(\"code\", node.getCode());\n if ($isNoteNode(node))\n return property(\"caller\", node.getCaller());\n const marker = $isUnknownNode(node) ? node.getMarker() : $markerOf(node);\n // A marker-less object (the document root, a table, an optbreak) has no token to count past,\n // so the character after it can only be named as the object itself. A nameless paragraph's\n // marker is the empty name, which its `\\` still spells: the place after it is `['marker']` at 0.\n if (marker === undefined)\n return { jsonPath };\n return property(\"marker\", marker);\n}\n/** The length of `node`'s USFM closing marker, or `undefined` when it has none: a span\n * ParatextData left unclosed (`closed=\"false\"`) and a paragraph-like marker do not. */\nfunction $closingMarkerLength(node) {\n if ($isCharNode(node))\n return node.getUnknownAttributes()?.closed === \"false\"\n ? undefined\n : closingMarkerText(node.getMarker(), $isNestedCharNode(node)).length;\n if ($isNoteNode(node))\n return node.getUnknownAttributes()?.closed === \"false\"\n ? undefined\n : closingMarkerText(node.getMarker()).length;\n if ($isMilestoneNode(node))\n return closingMarkerText(\"\").length;\n if ($isUnknownNode(node)) {\n const { closing } = unknownDisplayParts(node.getTag(), node.getMarker(), node.getUnknownAttributes());\n return closing === \"\" ? undefined : closing.length;\n }\n return undefined;\n}\n/** Whether `node`'s content runs to the end of a USFM line, so a newline follows it. A verse\n * block's children are root-level lines of the USJ the block layout regroups. */\nfunction $endsLine(node) {\n const parent = $getLogicalParent(node);\n return ($isParaNode(node) ||\n $isImpliedParaNode(node) ||\n $isBookNode(node) ||\n $isImmutableTableRowNode(node) ||\n ($isUnknownNode(node) && node.getTag() === \"table:row\") ||\n $isRootNode(parent) ||\n $isVerseBlockNode(parent));\n}\n/** `node`'s marker, when it has one. */\nfunction $markerOf(node) {\n if ($isParaNode(node) ||\n $isCharNode(node) ||\n $isMilestoneNode(node) ||\n $isImmutableTableRowNode(node) ||\n $isImmutableTableCellNode(node))\n return node.getMarker();\n return undefined;\n}\n/**\n * The closest point to bytes the current view does not render at all: the end of the node's\n * content, since USFM attribute bytes come after it. The answer for markerMode \"visible\" and\n * \"hidden\", where attribute markers and their values have no nodes of their own, and for an\n * attribute an editable view's run does not spell.\n */\nfunction $nearestPointAfterContent(node) {\n if ($isElementNode(node)) {\n // USFM spells attributes after the content and before the closer, so bytes the view does not\n // display sit in front of the closer and the run, not behind them.\n const lastChild = node.getLastChild();\n let content = lastChild;\n while (content && $isAttributeDisplayOrCloserOf(content, node))\n content = content.getPreviousSibling();\n if (content !== lastChild) {\n // An empty span's placeholder is no content: the content ends in front of it.\n if ($isTextNode(content) && !$displayBytesOf(content))\n return [\n content,\n $shouldIgnoreNodeForContentIndexes(content) ? 0 : content.getTextContentSize(),\n ];\n return [node, content ? content.getIndexWithinParent() + 1 : 0];\n }\n // An empty span's placeholder is no content either: the content ends in front of it.\n if (lastChild && $isTextNode(lastChild))\n return [\n lastChild,\n !$displayBytesOf(lastChild) && $shouldIgnoreNodeForContentIndexes(lastChild)\n ? 0\n : lastChild.getTextContentSize(),\n ];\n }\n // A decorator (e.g. ImmutableChapterNode) or an element with no children: the start of what\n // follows it is the nearest point there is.\n const nextSibling = node.getNextSibling();\n if (nextSibling && $isElementNode(nextSibling))\n return [nextSibling, 0];\n return $pointBeside(node, true);\n}\n/** Whether `child` is `owner`'s closing glyph or attribute display: bytes USFM spells after the\n * content. */\nfunction $isAttributeDisplayOrCloserOf(child, owner) {\n return ($isAttributeDisplayRun(child) ||\n $isAttributeRunNode(child) ||\n ($isImmutableTypedTextNode(child) && child.getTextType() === \"attribute\") ||\n $isClosingGlyphOf(child, owner));\n}\n/**\n * Where a key no byte spells sits in an editable view's bare default-attribute run (`|grace` for\n * `lemma=\"grace\"`): USFM would spell `lemma=\"` right after the `|`, which is the value's start in\n * the run. `undefined` when `owner` has no such run for `keyName`.\n */\nfunction $bareValueStart(owner, keyName) {\n for (const carrier of $displayByteCarriers(owner)) {\n const bytes = $displayBytesOf(carrier);\n if (!bytes?.owner.is(owner))\n continue;\n const { spans } = bytes;\n if (spans.some((span) => isSameByteKind(span.bytes, { kind: \"attributeKey\", keyName })))\n return undefined;\n const value = spans.find((span) => isSameByteKind(span.bytes, { kind: \"property\", property: keyName }));\n if (value && carrier.getTextContent()[value.start - 1] === \"|\")\n return [carrier, value.start];\n }\n return undefined;\n}\n/** The end of the bytes a read-only decorator displays of `owner`'s `wanted` bytes when `offset` is\n * past them, or `undefined` when no decorator displays them or `offset` is not past them. */\nfunction $endOfDecoratorBytes(owner, wanted, offset) {\n for (const carrier of $displayByteCarriers(owner)) {\n if (!$isDisplayByteDecorator(carrier))\n continue;\n const bytes = $displayBytesOf(carrier);\n if (!bytes?.owner.is(owner))\n continue;\n const index = bytes.spans.findIndex((span) => isSameByteKind(span.bytes, wanted));\n if (index < 0)\n continue;\n return offset > highestSpanOffset(bytes, index)\n ? [carrier, bytes.spans[index + 1]?.start ?? bytes.length]\n : undefined;\n }\n return undefined;\n}\n/**\n * Where a location on a note's category resolves when no byte the view shows spells it: behind the\n * note's read-only caller, the closest position to its left, since USFM spells the category\n * between the caller and the content (`\\f + \\cat People\\cat* \\ft …`). The category has no\n * position of its own there and names nothing an annotation can hold — Paratext 9 never anchors an\n * annotation to it either. `undefined` for any other key, or a note with no caller decorator.\n */\nfunction $behindReadOnlyCaller(owner, keyName) {\n if (!$isNoteNode(owner) || keyName !== ATTRIBUTE_MARKER_RUNS.cat?.keyName)\n return undefined;\n const caller = owner\n .getChildren()\n .find((child) => child.getType() === IMMUTABLE_NOTE_CALLER_NODE_TYPE);\n if (!caller)\n return undefined;\n const [parent, index] = $pointBeside(caller, true);\n return parent && index !== undefined ? [parent, index] : undefined;\n}\n/** The element point in front of `node` in its parent, or after it when `after`. */\nfunction $pointBeside(node, after) {\n const parent = node.getParent();\n if (!parent)\n return [undefined, undefined];\n return [parent, node.getIndexWithinParent() + (after ? 1 : 0)];\n}\n/** The value of a leaf marker's property, for the leaves that carry one on screen. */\nfunction $leafPropertyValue(node, property) {\n if ($isSomeVerseNode(node) || $isSomeChapterNode(node)) {\n if (property === \"number\")\n return node.getNumber();\n if (property === \"altnumber\")\n return node.getAltnumber();\n if (property === \"pubnumber\")\n return node.getPubnumber();\n if (property === \"marker\")\n return node.getMarker();\n }\n if ($isMilestoneNode(node) && property === \"marker\")\n return node.getMarker();\n return undefined;\n}\n/**\n * The document-end point when `location` is the end of the document — one past the final newline,\n * spelled on the last token (see {@link $contentEndLocation}) — and `undefined` otherwise. The\n * point is the end of the last line, where End puts the caret, so text typed there joins that\n * block instead of falling outside every paragraph.\n */\nfunction $documentEndPoint(location, collapsesSpaceRuns) {\n const root = $getRoot();\n const end = $afterLastTokenLocation(root, [], 1, collapsesSpaceRuns);\n if (locationKey(end) !== locationKey(location))\n return undefined;\n const lastBlock = root.getLastChild();\n if (!$isElementNode(lastBlock))\n return [root, root.getChildrenSize()];\n const lastDescendant = lastBlock.getLastDescendant();\n // A verse glyph's trailing separator stands for no byte at a line end, and the browser does not\n // draw it, so the caret goes in front of it, where End puts it.\n if ($isVerseNode(lastDescendant) && $endsInOwnSeparator(lastDescendant))\n return [lastDescendant, lastDescendant.getTextContentSize() - 1];\n if ($isTextNode(lastDescendant))\n return [lastDescendant, lastDescendant.getTextContentSize()];\n if ($isElementNode(lastDescendant))\n return [lastDescendant, lastDescendant.getChildrenSize()];\n const container = lastDescendant?.getParent() ?? lastBlock;\n return [container, container.getChildrenSize()];\n}\n/** A location's fields in a fixed order, so two spellings of one location compare equal. */\nfunction locationKey(location) {\n return JSON.stringify(Object.entries(location).sort(([a], [b]) => a.localeCompare(b)));\n}\nfunction $getPreviousContentSibling(child) {\n let sibling = child.getPreviousSibling();\n while (sibling) {\n if (!$shouldIgnoreNodeForContentIndexes(sibling))\n return sibling;\n sibling = sibling.getPreviousSibling();\n }\n return undefined;\n}\n/**\n * Gets the jsonPath indexes from a node by traversing up to the root using logical\n * (annotation-transparent) content indexes — the path every location's `jsonPath` is built from,\n * and the answer for a node that is not itself a position (the first node of a region, a note a\n * path has to be prefixed with).\n * @param node - The node to get the path for.\n * @param collapsesSpaceRuns - Whether this editor's serialization collapses space runs, and with\n * them drops a paragraph's leading spaces — which can remove a paragraph's first item, so the\n * items after it are indexed one lower; see `$getLogicalContentItems`.\n * @returns An array of indexes representing the path from root to node.\n */\nexport function $getJsonPathIndexes(node, collapsesSpaceRuns) {\n const jsonPathIndexes = [];\n let current = node;\n while (current) {\n const parent = $getLogicalParent(current);\n if (!parent)\n break;\n const index = $getLogicalIndexOfChild(parent, current, collapsesSpaceRuns);\n if (index >= 0)\n jsonPathIndexes.unshift(index);\n current = parent;\n }\n return jsonPathIndexes;\n}\n/**\n * Whether the document uses the block verse layout.\n *\n * USJ locations are indexes into the source USJ's content. That layout regroups verses into\n * blocks, splitting any paragraph that spans verses into one fragment per verse, so the editor's\n * content indexes no longer line up with the USJ's on their own - every position that crosses this\n * boundary is translated through `blockVerseLocations.utils` first ({@link $blockToUsj},\n * {@link $usjToBlock}).\n */\nfunction $hasVerseBlocks() {\n // Both callers run on every selection change, so this walks siblings and exits at the first\n // block rather than calling `getChildren()`, which would build an array of every root child.\n //\n // The layout is known from `ViewOptions.verseLayout`, and an editor registers `VerseBlockNode`\n // only for that layout, so `editor.hasNodes([VerseBlockNode])` looks like a cheaper answer. It\n // is not available here: `$getEditor()` needs an active *editor*, and these functions are\n // called from `editorState.read()` as well, which establishes only an active editor state.\n // Reading the layout instead would mean threading `ViewOptions` through every caller.\n for (let child = $getRoot().getFirstChild(); child; child = child.getNextSibling()) {\n if ($isVerseBlockNode(child))\n return true;\n }\n return false;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { $getEditor, $getNearestNodeFromDOMNode, $getNodeByKey, $getSelection, $isRangeSelection, $isTextNode, CLICK_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, $isRootNode, isDOMNode, PASTE_COMMAND, REMOVE_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, } from \"lexical\";\nimport { $findMatchingParent, mergeRegister } from \"@lexical/utils\";\nimport { useEffect } from \"react\";\nimport { $caretHostAtBoundary, $getNextNode, $getPreviousNode, $getSelectedParaMarkerPara, $isBookNode, $isGutterMarkerNode, $isImmutableTypedTextNode, $isParaLikeNode, $isSomeParaNode, $isSynthesizedMarkerNode, $isVisibleMarkerNode, $placeCaretAtBoundary, BookNode, NBSP, } from \"shared\";\nimport { $isImmutableVerseNode, $isSomeVerseNode } from \"../../nodes/usj\";\n/**\n * Whether `node` is the `\\id` line's own immutable `\\id GEN ` prefix — the book's first child,\n * and (per docs/standard-view-invariants.md) the one glyph in the line the caret can never enter.\n * Identity-based (the book's actual first child), not just \"any visible marker glyph\": a\n * paragraph's own marker prefix is the SAME node shape but takes the opposite, intentional path —\n * deleting it is a real marker-deletion gesture (`$paraMarkerDeletionTransform`,\n * markerEditDeletion.utils.ts), never something to refuse.\n *\n * Deliberately excludes the editable-mode `MarkerNode` prefix: that flavor is a `TextNode`, so it\n * hosts a caret, and this predicate exists to answer \"can a caret go here\" — the editable prefix's\n * answer is yes, unlike every other mode's. For the mode-independent question — \"is this the `\\id`\n * line's prefix glyph, whatever mode is rendering it\" — use `$isBookPrefixGlyph` (`shared`) instead.\n */\nexport function $isBookPrefixNode(node) {\n return ($isImmutableTypedTextNode(node) &&\n $isBookNode(node.getParent()) &&\n node.is(node.getParent()?.getFirstChild()));\n}\n/**\n * The point just past `book`'s own immutable prefix — the boundary any selection endpoint that has\n * landed ON or BEFORE the prefix should be clamped to. Follows the same hosting convention\n * `$placeCaretAtBoundary` does (a TEXT point at the following content's own start, or the ELEMENT\n * point when nothing hosts one yet), expressed as plain point pieces so a caller can move ONE\n * endpoint of an existing selection without collapsing the other — `$placeCaretAtBoundary` itself\n * replaces the whole active selection, which is only safe for a genuinely collapsed correction.\n */\nfunction $pointJustPastBookPrefix(book) {\n const host = $caretHostAtBoundary(book, 1);\n return host\n ? { key: host.getKey(), offset: 0, type: \"text\" }\n : { key: book.getKey(), offset: 1, type: \"element\" };\n}\n/**\n * For a NON-collapsed selection whose span includes the book's own prefix, moves whichever of\n * anchor/focus is EARLIER in document order to the boundary just past it, so the range that\n * survives covers only real content.\n *\n * Delete, paste-over and cut all resolve to the same two primitives against this selection —\n * `RangeSelection.removeText()`/`insertText()` — and every one of them would otherwise consume the\n * prefix decorator along with whatever the user meant to replace, the same loss a collapsed caret's\n * `deleteCharacter` causes at the boundary (see {@link $shouldRefuseBookPrefixDeletion}). Narrowing\n * the selection BEFORE any of those run is the one fix that covers all of them.\n *\n * Mutating: call inside `editor.update()` (a command listener already runs inside one).\n *\n * @param selection - The selection to narrow in place.\n * @returns `true` if the selection touched the prefix and was narrowed, `false` if it did not.\n */\nexport function $narrowSelectionPastBookPrefix(selection) {\n if (selection.isCollapsed())\n return false;\n // Cheap pre-filter before the `getNodes()` walk below, which visits every node the selection\n // spans: the prefix is the very first thing in the document (the book's own first child, and\n // the book is always the document's first block), so it can only be in the span at all when the\n // EARLIER endpoint is at or before it — an element point on the root itself at offset 0, or\n // anywhere inside the book (its own element point included: a node's top-level element is\n // itself when the node already IS one). `getTopLevelElement()` returns `null` for the root node,\n // so the root case needs its own check rather than falling out of the same call.\n const point = selection.isBackward() ? selection.focus : selection.anchor;\n const pointNode = point.getNode();\n const mayReachPrefix = ($isRootNode(pointNode) && point.offset === 0) || $isBookNode(pointNode.getTopLevelElement());\n if (!mayReachPrefix)\n return false;\n const prefixNode = selection.getNodes().find($isBookPrefixNode);\n if (!prefixNode)\n return false;\n const book = prefixNode.getParent();\n if (!$isBookNode(book))\n return false;\n const target = $pointJustPastBookPrefix(book);\n point.set(target.key, target.offset, target.type);\n return true;\n}\n/**\n * Whether the current selection's `DELETE_CHARACTER_COMMAND` (the command both Backspace and\n * Delete fall through to) — and, by the same registration, `DELETE_WORD_COMMAND` and\n * `DELETE_LINE_COMMAND` — should be refused outright: a COLLAPSED caret sitting right at the\n * boundary the prefix occupies, where the command's own default handling\n * (`RangeSelection.deleteCharacter`) removes the adjacent DecoratorNode regardless of\n * `isKeyboardSelectable()` (`ImmutableTypedTextNode.ts`).\n *\n * `$getPreviousNode`/`$getNextNode` resolve a TEXT point's neighbor from its containing node's\n * sibling alone, ignoring the offset within it — meaningful only once the caret is actually AT\n * that text's boundary (offset 0 backward, or its own length forward). An ELEMENT point is\n * already offset-correct inside both helpers, so only the TEXT case needs the extra check.\n *\n * A NON-collapsed delete is a different failure mode: it removes every node the selection SPANS,\n * not only the two it is anchored on, so a range starting at an element point before the prefix\n * (e.g. `(book, 0)`) and ending in the content consumes the prefix along the way despite neither\n * endpoint resolving to it directly. Rather than refuse that outright — a silent no-op, against the\n * \"a keystroke either changes the document or is visibly refused\" rule\n * (docs/standard-view-invariants.md) — this narrows the selection past the prefix\n * ({@link $narrowSelectionPastBookPrefix}) and returns `false`, so the delete that follows removes\n * only the content the selection actually covers. Refusal is reserved for the one case narrowing\n * cannot fix: nothing left to delete once the prefix is excluded.\n *\n * Exported for direct unit testing, the same convention {@link $guardCursorAtParaStart} follows —\n * production callers reach it through {@link ParaMarkerPrefixCursorGuardPlugin}'s own registration.\n */\nexport function $shouldRefuseBookPrefixDeletion(isBackward) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection))\n return false;\n if (selection.isCollapsed()) {\n const { anchor } = selection;\n if (anchor.type === \"text\") {\n const node = anchor.getNode();\n const atBoundary = isBackward\n ? anchor.offset === 0\n : $isTextNode(node) && anchor.offset === node.getTextContentSize();\n if (!atBoundary)\n return false;\n }\n const target = isBackward ? $getPreviousNode(selection) : $getNextNode(selection);\n return $isBookPrefixNode(target);\n }\n return $narrowSelectionPastBookPrefix(selection) && selection.isCollapsed();\n}\n/**\n * `DELETE_LINE_COMMAND`'s own fix for the case {@link $shouldRefuseBookPrefixDeletion} does not\n * catch: a COLLAPSED caret already past the boundary, mid-content, on the `\\id` line. Lexical's own\n * `RangeSelection.deleteLine` extends the selection to the DOM's own visual line boundary before\n * removing it (`modify('extend', isBackward, 'lineboundary')`), and that extension steps the far\n * endpoint past an adjacent inline, non-isolated decorator\n * (`$modifySelectionAroundDecoratorsAndBlocks`'s trailing 'decorators' pass, run only for\n * `'lineboundary'`) — landing it AT or BEFORE the prefix whenever the visual line boundary sits\n * right past the glyph: the whole line for a short `\\id` line, or a wrapped line's own start for a\n * long one. Left alone, the deletion that follows removes the prefix along with the content.\n *\n * Runs the same extension Lexical would, then clamps whichever endpoint moved onto or past the\n * prefix back to just past it, so the delete that follows only ever touches real content. Falls\n * back to Lexical's own collapsed-selection handling (`deleteCharacter`) when the extension finds\n * nothing to extend into, refusing instead if THAT would touch the prefix.\n *\n * `DELETE_WORD_COMMAND` needs no equivalent: `modify` with 'word' granularity never runs the\n * trailing 'decorators' pass (gated on `granularity === 'lineboundary'` alone), so a genuinely\n * mid-content collapsed caret cannot reach this stepping through it — only the boundary case\n * {@link $shouldRefuseBookPrefixDeletion} already refuses.\n *\n * @param isBackward - `true` for Cmd+Backspace, `false` for the forward line delete.\n */\nfunction $clampLineDeletionPastBookPrefix(isBackward) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const book = $findMatchingParent(selection.anchor.getNode(), $isBookNode);\n if (!book || !$isBookPrefixNode(book.getFirstChild()))\n return false;\n selection.modify(\"extend\", isBackward, \"lineboundary\");\n if (selection.isCollapsed()) {\n // Nothing to extend into: fall back to exactly what Lexical's own deleteLine would have done,\n // refusing only if that fallback would itself remove the prefix.\n if ($shouldRefuseBookPrefixDeletion(isBackward))\n return true;\n selection.deleteCharacter(isBackward);\n return true;\n }\n if (selection.getNodes().some($isBookPrefixNode)) {\n const target = $pointJustPastBookPrefix(book);\n selection.focus.set(target.key, target.offset, target.type);\n }\n if (!selection.isCollapsed())\n selection.removeText();\n return true;\n}\n/**\n * Narrows the current selection past the book's own prefix ({@link $narrowSelectionPastBookPrefix})\n * before `CONTROLLED_TEXT_INSERTION_COMMAND`, `PASTE_COMMAND`, `CUT_COMMAND` or `REMOVE_TEXT_COMMAND`\n * runs — each of those resolves to `RangeSelection.insertText()`/`removeText()` against whatever\n * selection is current, and a selection spanning the prefix loses it the same way an un-narrowed\n * delete would. `REMOVE_TEXT_COMMAND` is the one of the four with no dedicated key binding: Lexical\n * routes drag-move deletion (`deleteByDrag`) and composition-driven deletes (an IME replacing a\n * selected range) through it rather than `DELETE_CHARACTER_COMMAND`. Always returns `false`: this\n * never claims the command, only corrects the selection those commands' own handlers (registered\n * lower) go on to read.\n */\nfunction $narrowSelectionBeforeCommand() {\n const selection = $getSelection();\n if ($isRangeSelection(selection))\n $narrowSelectionPastBookPrefix(selection);\n return false;\n}\n/**\n * Moves a COLLAPSED caret that has come to rest in front of the book's own prefix — the element\n * point `(book, 0)` — to just past it.\n *\n * The browser puts the caret there for any keyboard move to the start of the `\\id` line (Home,\n * Ctrl+Home, ArrowUp from the line below): the prefix is a `contenteditable=\"false\"` island, so the\n * line's visual start is the boundary before it. Left there, typed text becomes the book's first\n * child and renders in front of `\\id GEN `, while the save — which never writes the glyph as its own\n * node — puts it after the book code. A click reaching the same point is corrected by\n * {@link $guardCursorAtParaStart}; this covers every other way of arriving.\n *\n * A non-collapsed selection is left alone: Shift+Home legitimately extends to the line's start, and\n * every command that would remove or replace its span already narrows it past the prefix first\n * ({@link $narrowSelectionPastBookPrefix}).\n *\n * Mutating: call inside `editor.update()` (a command listener already runs inside one).\n *\n * @returns `true` if the caret was moved, `false` if it was not in front of the prefix.\n */\nfunction $guardCaretBeforeBookPrefix() {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || !selection.isCollapsed())\n return false;\n const { anchor } = selection;\n if (anchor.type !== \"element\" || anchor.offset !== 0)\n return false;\n const book = anchor.getNode();\n if (!$isBookNode(book) || !$isBookPrefixNode(book.getFirstChild()))\n return false;\n $placeCaretAtBoundary(book, 1);\n return true;\n}\n/**\n * Keeps the book's own prefix the book's first child, by moving anything that has landed in front\n * of it to directly after it — in order, so the line reads exactly as the save will write it: the\n * serializer drops the glyph wherever it sits, so the content before it and after it are written\n * as one run following the book code.\n *\n * {@link $guardCaretBeforeBookPrefix} keeps a user's caret from resting there, but not every\n * insertion goes through a selection change first (a drop, a programmatic `select(0, 0)`), and\n * everything else that reads the line — the deletion guards here, the arrow-key rules, the line's\n * settle — finds the prefix as the book's first child.\n *\n * The prefix is recognized by its shape and marker text rather than its position, since its\n * position is exactly what is wrong. A book built without one (a markerMode that shows no markers)\n * has nothing to reorder.\n *\n * Registered as a `BookNode` transform, so it runs in the same update that made the change.\n */\nfunction $keepBookPrefixFirst(book) {\n const children = book.getChildren();\n const markerText = `\\\\${book.getMarker()}`;\n const prefixIndex = children.findIndex((child) => $isVisibleMarkerNode(child) && child.getTextContent().startsWith(markerText));\n if (prefixIndex <= 0)\n return;\n let insertionPoint = children[prefixIndex];\n for (const node of children.slice(0, prefixIndex)) {\n insertionPoint.insertAfter(node);\n insertionPoint = node;\n }\n}\n/**\n * Keeps the cursor out of the places a paragraph's structural prefix occupies but no caret may\n * rest in. WHICH marker is caret territory is decided one node at a time, never per view — see\n * `gutterMarkerState` (shared). A click that selects a paragraph's gutter marker never reaches this\n * plugin: `ParaMarkerSelectionPlugin` claims it first. See\n * {@link registerParaMarkerPrefixCursorGuard} for the click policy.\n *\n * Also refuses `DELETE_CHARACTER_COMMAND` (the command both Backspace and Delete fall through to),\n * `DELETE_WORD_COMMAND` (Ctrl/Alt+Backspace) and `DELETE_LINE_COMMAND` (Cmd+Backspace) whenever a\n * COLLAPSED caret sitting right at the prefix's own boundary would remove it. A collapsed word/line\n * delete that finds nothing left to extend into falls back to `RangeSelection.deleteCharacter`, and\n * Lexical's default `deleteCharacter` removes an adjacent `DecoratorNode` outright regardless of\n * `isKeyboardSelectable()` (ImmutableTypedTextNode.ts) — so without refusing all three, any of\n * these keystrokes at the very start of the line's content deletes the `\\id GEN ` glyph from the\n * screen while the file — which never stored the glyph as its own node — is left unchanged, until\n * the next reload silently brings it back.\n *\n * A COLLAPSED caret already past that boundary, mid-content, gets its own fix for\n * `DELETE_LINE_COMMAND` specifically ({@link $clampLineDeletionPastBookPrefix}): Cmd+Backspace\n * extends to the visual line boundary before deleting, which can step onto or past the prefix the\n * same way.\n *\n * A NON-collapsed selection spanning the prefix — Ctrl+A's selection normalizes to an anchor right\n * before it — is narrowed past it rather than refused, for `DELETE_CHARACTER_COMMAND`,\n * `DELETE_WORD_COMMAND`, `DELETE_LINE_COMMAND` (all three via\n * {@link $shouldRefuseBookPrefixDeletion}'s own non-collapsed branch), and — since typing over such\n * a selection, pasting/cutting it away, drag-moving it, or replacing it mid-composition is the same\n * removal, just through `RangeSelection.insertText()`/`removeText()` instead of a delete command —\n * `CONTROLLED_TEXT_INSERTION_COMMAND`, `PASTE_COMMAND`, `CUT_COMMAND` and `REMOVE_TEXT_COMMAND` too,\n * each narrowed by {@link $narrowSelectionBeforeCommand} ahead of every other handler registered for\n * them.\n *\n * A collapsed caret that a keyboard move leaves in FRONT of the book's prefix (Home) is moved past\n * it on `SELECTION_CHANGE_COMMAND` ({@link $guardCaretBeforeBookPrefix}), and anything that still\n * lands there is moved after the prefix by a `BookNode` transform ({@link $keepBookPrefixFirst}).\n */\nexport function ParaMarkerPrefixCursorGuardPlugin() {\n const [editor] = useLexicalComposerContext();\n useEffect(() => registerParaMarkerPrefixCursorGuard(editor), [editor]);\n useEffect(() => {\n return mergeRegister(editor.registerCommand(DELETE_CHARACTER_COMMAND, $shouldRefuseBookPrefixDeletion, COMMAND_PRIORITY_HIGH), editor.registerCommand(DELETE_WORD_COMMAND, $shouldRefuseBookPrefixDeletion, COMMAND_PRIORITY_HIGH), editor.registerCommand(DELETE_LINE_COMMAND, $shouldRefuseBookPrefixDeletion, COMMAND_PRIORITY_HIGH), \n // Below the boundary refusal above (which still runs first and can refuse outright), and\n // above Lexical's own default DELETE_LINE_COMMAND handling (COMMAND_PRIORITY_EDITOR) — the\n // default is exactly what this replaces for a book line, so it must never run for one.\n editor.registerCommand(DELETE_LINE_COMMAND, $clampLineDeletionPastBookPrefix, COMMAND_PRIORITY_NORMAL), \n // CRITICAL: other handlers for these commands (StructureKeyboardPlugin's CUT_COMMAND/\n // PASTE_COMMAND, OpaqueBlockGuardPlugin's CUT_COMMAND) are registered at HIGH or CRITICAL\n // too, so this must match the top priority to have any guarantee of running before them —\n // CRITICAL-tier order among plugins otherwise follows mount order, which this plugin does\n // not control. Always returns `false` (never claims the command), so running before or after\n // another CRITICAL handler that also returns `false` changes nothing either way; it only\n // matters relative to a handler that would itself remove the prefix.\n editor.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND, $narrowSelectionBeforeCommand, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(PASTE_COMMAND, $narrowSelectionBeforeCommand, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CUT_COMMAND, $narrowSelectionBeforeCommand, COMMAND_PRIORITY_CRITICAL), \n // REMOVE_TEXT_COMMAND is how drag-move deletion and composition-driven deletes reach a\n // non-collapsed selection — neither goes through DELETE_CHARACTER_COMMAND — so it needs the\n // same narrowing the other three selection-replacing commands get above.\n editor.registerCommand(REMOVE_TEXT_COMMAND, $narrowSelectionBeforeCommand, COMMAND_PRIORITY_CRITICAL));\n }, [editor]);\n useEffect(() => {\n return mergeRegister(\n // Below `DecoratorBoundarySelectionPlugin` (CRITICAL), which can itself produce `(book, 0)`\n // when it snaps a caret that landed inside the prefix glyph to the glyph's leading edge; above\n // the listeners that report the caret's position (e.g. `OnSelectionChangePlugin`, LOW), so\n // they only ever see the corrected one. Never claims the command.\n editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {\n $guardCaretBeforeBookPrefix();\n return false;\n }, COMMAND_PRIORITY_HIGH), editor.registerNodeTransform(BookNode, $keepBookPrefixFirst));\n }, [editor]);\n return null;\n}\n/**\n * Registers the click policy on `editor`. Exported so tests register exactly what the plugin does.\n *\n * A click ON a gutter glyph is answered at LOW, ahead of rich-text's EDITOR-priority handler, which\n * would otherwise clear a selected marker and claim the click before the caret moves. Every other\n * click is judged at EDITOR priority, from where the selection came to rest. Both correct the\n * caret inside the click's own update, so other listeners (e.g. `OnSelectionChangePlugin`) never\n * see the intermediate prefix position.\n *\n * @param editor - The editor to guard.\n * @returns a function that unregisters both listeners.\n */\nexport function registerParaMarkerPrefixCursorGuard(editor) {\n return mergeRegister(editor.registerCommand(CLICK_COMMAND, $guardGutterMarkerClick, COMMAND_PRIORITY_LOW), editor.registerCommand(CLICK_COMMAND, (event) => {\n $guardCursorOnClick(event);\n return false;\n }, COMMAND_PRIORITY_EDITOR));\n}\n/**\n * The LOW-priority half of the click policy, for a click ON a gutter glyph. Mutating: runs inside\n * the click's update.\n *\n * @returns always `false`, so the rest of the click chain runs as before.\n */\nfunction $guardGutterMarkerClick(event) {\n $guardCursorAtGutterMarker(event.target);\n return false;\n}\n/**\n * The EDITOR-priority half of the click policy, for every click not on a gutter glyph. Mutating:\n * runs inside the click's update.\n *\n * @param event - The click that Lexical dispatched through `CLICK_COMMAND`.\n */\nexport function $guardCursorOnClick(event) {\n const target = event.target;\n if (isDOMNode(target) && $isGutterMarkerNode($getNearestNodeFromDOMNode(target)))\n return;\n const selection = $getSelection();\n if ($isRangeSelection(selection))\n $guardCursorAtParaStart(selection);\n}\n/**\n * The boundary index of `para`'s first content position: how many structural prefix children\n * lead it — the para-marker prefix (`MarkerNode` or `ImmutableTypedTextNode`) with its trailing\n * NBSP, then any leading verse nodes (`VerseNode` or `ImmutableVerseNode`). `0` when nothing\n * leads the content.\n *\n * Read-only: safe in any read — `editor.getEditorState().read()`, an `editor.update()`, or a\n * command handler.\n *\n * Accepts a `BookNode` too: the `\\id` line's own immutable `\\id GEN ` prefix is the same shape as\n * a paragraph's marker prefix, just with no leading verse ever preceding it.\n *\n * @param para - The paragraph (or `\\id` line) to measure.\n */\nexport function $paraContentStartIndex(para) {\n let child = para.getFirstChild();\n let index = 0;\n while (child !== null) {\n if ($isSynthesizedMarkerNode(child)) {\n index++;\n child = child.getNextSibling();\n // In editable mode the para-marker prefix is followed by a NBSP TextNode (marker-trailing-space).\n if ($isTextNode(child) && child.getTextContent() === NBSP) {\n index++;\n child = child.getNextSibling();\n }\n }\n else if ($isSomeVerseNode(child)) {\n index++;\n child = child.getNextSibling();\n }\n else {\n break;\n }\n }\n return index;\n}\n/**\n * Advances the cursor past all structural prefix nodes at the start of `para` (see\n * {@link $paraContentStartIndex}), placing it at the content boundary just past them under the\n * shared convention for a boundary's caret position (`$placeCaretAtBoundary`): the start of the\n * first content `TextNode` that follows, or an element point at that boundary when no `TextNode`\n * hosts it yet.\n *\n * Also called directly when programmatically navigating to a verse whose paragraph has a\n * non-text first child (e.g. in `ScriptureReferencePlugin`), and to leave a selected paragraph\n * marker for its content (`$collapseParaMarkerSelection`).\n *\n * Mutating: call inside `editor.update()`.\n *\n * @returns `false` (and moves nothing) when `para` has no structural prefix.\n */\nexport function $advancePastParaPrefixes(para) {\n const index = $paraContentStartIndex(para);\n if (index === 0)\n return false;\n $placeCaretAtBoundary(para, index);\n return true;\n}\n/**\n * Collapses the caret to `para`'s first content position ({@link $advancePastParaPrefixes}), or to\n * its start when nothing leads its content.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $placeCaretAtParaContentStart(para) {\n if (!$advancePastParaPrefixes(para))\n para.selectStart();\n}\n/**\n * Answers a click that landed ON a gutter marker glyph, which is never a caret position: the\n * cursor moves to the first place past it that is one — past a paragraph's whole structural prefix\n * (its glyph and any leading verse, see {@link $advancePastParaPrefixes}), or just past the glyph\n * for any other owner (a book's `\\id` line, a table cell).\n *\n * Takes the click's DOM TARGET rather than the selection because a click on a gutter marker leaves\n * no selection to inspect: the glyph is a decorator, which Lexical renders `contenteditable=\"false\"`,\n * so the browser's caret lands inside a node Lexical cannot resolve and the editor's selection is\n * left null.\n *\n * Scoped to the GUTTER flavor by {@link $isGutterMarkerNode}, not to the node class: markerMode\n * \"visible\" renders the same class of node INLINE among the words, and this rule has no opinion\n * about that glyph.\n *\n * Mutating: call inside `editor.update()` (the click's update, via {@link $guardGutterMarkerClick}).\n *\n * @param target - The click's `event.target`.\n * @returns `true` if the cursor moved, and `false` if the click was not on a gutter marker.\n */\nexport function $guardCursorAtGutterMarker(target) {\n if (!isDOMNode(target))\n return false;\n const glyph = $getNearestNodeFromDOMNode(target);\n if (!$isGutterMarkerNode(glyph))\n return false;\n const owner = glyph.getParent();\n if (!owner)\n return false;\n if ($isSomeParaNode(owner) && $advancePastParaPrefixes(owner))\n return true;\n $placeCaretAtBoundary(owner, glyph.getIndexWithinParent() + 1);\n return true;\n}\n/**\n * Collapses a selected paragraph marker to a caret at its paragraph's content start — the position\n * the rest of the editor treats a marker selection as. Call before running an edit written for a\n * caret, so it acts on the paragraph's text rather than on the glyph.\n *\n * A marker selection a remote edit orphaned (its paragraph removed) is repaired the same way the\n * next key would repair it, through {@link REPAIR_PARA_MARKER_SELECTION_COMMAND}. With the\n * paragraph and both its neighbours gone the repair leaves no selection at all, which reports\n * `false`.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @returns `true` if a marker was selected and is now a caret, `false` otherwise.\n */\nexport function $collapseParaMarkerSelection() {\n if ($getEditor().dispatchCommand(REPAIR_PARA_MARKER_SELECTION_COMMAND, undefined))\n return $isRangeSelection($getSelection());\n const para = $getSelectedParaMarkerPara($getSelection());\n if (!para)\n return false;\n $placeCaretAtParaContentStart(para);\n return true;\n}\n/**\n * Asks `ParaMarkerSelectionPlugin` to collapse a marker selection whose paragraph a remote edit\n * removed. Handlers return `true` if they repaired one. Dispatched from inside an update.\n */\nexport const REPAIR_PARA_MARKER_SELECTION_COMMAND = createCommand(\"REPAIR_PARA_MARKER_SELECTION_COMMAND\");\n/**\n * The node a selected paragraph marker counts as selecting for location purposes (which verse,\n * which chapter): the first child of its paragraph's content, or its leading verse when it has no\n * content yet, or the paragraph itself when it holds only its glyph. Never the glyph: it is no\n * position.\n *\n * Read-only: safe in any read — `editor.getEditorState().read()`, an `editor.update()`, or a\n * command handler.\n *\n * @param selection - The selection to inspect, e.g. `$getSelection()`.\n * @returns the node, or `undefined` when no paragraph marker is selected.\n */\nexport function $getParaMarkerSelectionLocationNode(selection) {\n const para = $getSelectedParaMarkerPara(selection);\n if (!para)\n return undefined;\n const index = $paraContentStartIndex(para);\n const lastPrefix = para.getChildAtIndex(index - 1);\n return (para.getChildAtIndex(index) ??\n ($isGutterMarkerNode(lastPrefix) ? undefined : lastPrefix) ??\n para);\n}\n/**\n * Corrects the cursor when it lands at the very start of a paragraph, before a structural prefix\n * that renders no caret of its own: an immutable marker glyph (the gutter aid, or markerMode\n * \"visible\"'s inline glyph) or an `ImmutableVerseNode`. This happens when the user clicks in the\n * hanging-indent gutter of any marker that sets a negative `text-indent` (e.g. `\\li`, `\\li1`,\n * `\\li2`, `\\ili`, `\\ili1`, `\\ili2`, and poetry markers), which resolves to an element-typed anchor\n * at offset 0 of the `ParaNode`.\n *\n * The cursor is advanced past all structural prefix nodes (marker glyph, trailing NBSP, and leading\n * verse nodes) to the first content `TextNode`, or to the element offset just after all those\n * structural nodes when no content `TextNode` follows yet.\n *\n * An EDITABLE marker glyph (`MarkerNode`, markerMode \"editable\") is deliberately not corrected: it\n * is a `TextNode`, so it hosts a caret, and the user clicks into it on purpose to edit the marker.\n * Hauling that click to the content would both fight the intent and make a position the arrow keys\n * can reach unreachable by mouse. So the question this asks is about the NODE at the paragraph's\n * start — can it hold the caret? — never about which view is on screen.\n *\n * Also corrects a `BookNode`'s `\\id` line the same way: its immutable `\\id GEN ` prefix hosts no\n * caret either, and the line has no paragraph arm to fall back on.\n *\n * Returns `true` if the selection was corrected, `false` if no correction was needed.\n *\n * Exported only for direct unit testing; production callers reach it through\n * {@link $guardCursorOnClick}.\n */\nexport function $guardCursorAtParaStart(selection) {\n if (!selection.isCollapsed())\n return false;\n const { anchor } = selection;\n if (anchor.type !== \"element\" || anchor.offset !== 0)\n return false;\n const para = $getNodeByKey(anchor.key);\n if (!$isParaLikeNode(para))\n return false;\n const first = para.getFirstChild();\n if (!$isVisibleMarkerNode(first) && !$isImmutableVerseNode(first))\n return false;\n return $advancePastParaPrefixes(para);\n}\n","import { $getRangeFromUsjSelection } from \"../../plugins/usj/annotation/selection.utils\";\nimport { $advancePastParaPrefixes } from \"../../plugins/usj/ParaMarkerPrefixCursorGuardPlugin\";\nimport { $createImmutableNoteCallerNode, $isImmutableNoteCallerNode, } from \"./ImmutableNoteCallerNode\";\nimport { $isImmutableVerseNode } from \"./ImmutableVerseNode\";\nimport { $isSomeVerseNode } from \"./node-react.utils\";\nimport { $dfs, $findMatchingParent } from \"@lexical/utils\";\nimport { $createRangeSelection, $createTextNode, $getCharacterOffsets, $getEditor, $getNodeByKey, $getSelection, $getState, $isElementNode, $isRangeSelection, $isRootNode, $isTextNode, $setSelection, $setState, SELECTION_CHANGE_COMMAND, } from \"lexical\";\nimport { $createCharNode, $createImmutableTypedTextNode, $createMarkerNode, $createMarkerTrailingSeparator, $createNoteNode, $getNoteCallerPreviewText, $isAttributeRunNode, $isChapterNode, $isCharNode, $isGlyphTextNode, $isImmutableTypedTextNode, $isImmutableUnmatchedNode, $isMarkerNode, $isNoteNode, $isSomeParaNode, $isVisibleMarkerNode, $moveSelectionToEnd, $normalizeSelectionOutOfGlyphText, $noteCategoryRunPieces, $noteEditableCallerNode, $separatorPrefixLength, $shouldIgnoreNodeForContentIndexes, closingMarkerText, EMPTY_CHAR_PLACEHOLDER_TEXT, getEditableCallerText, NBSP, NoteNode, openingMarkerText, segmentState, textTypeState, } from \"shared\";\n// Lives in a leaf module so this file and `ImmutableNoteCallerNode` do not import each other (see\n// `note-index.utils`). Re-exported so it reaches the `nodes/usj` barrel, which exports this file\n// and not the leaf; imported here too since `$getNoteByKeyOrIndex` below builds on it.\nimport { $getNoteAtIndex } from \"./note-index.utils\";\nexport { $getNoteAtIndex, $getNoteIndex } from \"./note-index.utils\";\n/**\n * Find all ImmutableNoteCallerNodes in the given nodes tree.\n * @param nodes - Lexical node array to look in.\n * @returns an array of all ImmutableNoteCallerNodes in the tree.\n */\nexport function $findImmutableNoteCallerNodes(nodes) {\n const immutableNoteCallerNodes = [];\n function $traverse(node) {\n if ($isImmutableNoteCallerNode(node))\n immutableNoteCallerNodes.push(node);\n if (!$isElementNode(node))\n return;\n const children = node.getChildren();\n children.forEach($traverse);\n }\n nodes.forEach($traverse);\n return immutableNoteCallerNodes;\n}\n/**\n * The caller a freshly inserted note gets when nothing explicit is given, matching Paratext 9's\n * `DefaultCallerMapper`/`UsfmSnippetInserter.GetFallbackCaller` exactly: a project-level default\n * caller exists ONLY for the two markers this editor exposes a setting for — `f`\n * (`defaultFootnoteCaller`) and `x` (`defaultCrossRefCaller`). Paratext 9 also has project\n * settings for `ef` and `ex`, under their own separate settings this editor does not model; every\n * marker without a project setting here — `fe`, `ef`, `efe`, `ex`, and any custom note marker —\n * falls back to Paratext 9's hardcoded per-marker default instead: `+` for a marker starting with\n * `f`, `-` for everything else. Reusing the footnote/cross-reference project setting for those\n * markers (e.g. giving `fe` the project's `f` caller) would be a default the project never\n * actually configured.\n *\n * Read-only.\n */\nfunction $defaultCallerForMarker(marker, nodeOptions) {\n if (marker === \"f\")\n return nodeOptions.defaultFootnoteCaller ?? \"+\";\n if (marker === \"x\")\n return nodeOptions.defaultCrossRefCaller ?? \"-\";\n return marker.startsWith(\"f\") ? \"+\" : \"-\";\n}\n/**\n * Inserts a note at the specified selection, e.g. footnote, cross-reference, endnote.\n * @param marker - The marker type for the note.\n * @param caller - Optional note caller to override the default for the given marker.\n * @param selectionRange - Optional selection range where the note should be inserted. By default it will\n * use the current selection in the editor.\n * @param scriptureReference - Scripture reference for the note.\n * @param viewOptions - The current editor view options.\n * @param nodeOptions - The current editor node options.\n * @param logger - Logger instance.\n * @returns The inserted note node, or `undefined` if insertion failed. A selection inside a\n * chapter's `\\c N` line is refused (and logged): a chapter line has no content to hold a note,\n * so the note would be dropped from the saved document.\n * @throws Will throw an error if the marker is not a valid note marker.\n *\n * Mutating: call inside `editor.update()`.\n */\nexport function $insertNote(marker, caller, selectionRange, scriptureReference, viewOptions, nodeOptions, logger) {\n if (!NoteNode.isValidMarker(marker))\n throw new Error(`$insertNote: Invalid note marker '${marker}'`);\n const selection = selectionRange\n ? $getRangeFromUsjSelection(selectionRange, viewOptions)\n : $getSelection();\n if (!$isRangeSelection(selection))\n return undefined;\n if ($isSelectionInChapterLine(selection)) {\n logger?.warn(\"$insertNote: a note cannot be inserted in a chapter line\");\n return undefined;\n }\n const children = $createNoteChildren(selection, marker, scriptureReference, viewOptions, nodeOptions, logger);\n if (children === undefined)\n return undefined;\n const resolvedCaller = caller ?? $defaultCallerForMarker(marker, nodeOptions);\n const noteNode = $createWholeNote(marker, resolvedCaller, children, viewOptions, nodeOptions, undefined, undefined);\n $insertNoteWithSelect(noteNode, selection, viewOptions);\n return noteNode;\n}\n/**\n * Whether notes BUILD collapsed under the given note mode: only `\"expanded\"` builds expanded\n * notes; `\"collapsed\"`, `\"expandInline\"`, and an unset mode all build collapsed ones (under\n * `expandInline` the NoteNodePlugin expands a note only while the caret is adjacent).\n *\n * This is the ONE predicate for constructing a note's collapsed flag and child layout — used at\n * document load (the platform adaptor's `createNote`) and at insert time (`$createWholeNote`,\n * `$insertNoteWithSelect`) so a freshly inserted note is indistinguishable from a loaded one.\n * When the two ever disagree, the flag and the layout drift apart (e.g. a collapsed-layout note\n * flagged expanded). Note: this governs CONSTRUCTION only — `$selectNote` intentionally uses a\n * different rule for expanding an existing note on selection.\n *\n * @param noteMode - The note display mode from the editor view options.\n * @returns `true` when notes are built collapsed under this mode.\n */\nexport function isCollapsedNoteMode(noteMode) {\n return noteMode !== \"expanded\";\n}\n/**\n * The closing marker glyph a collapsed caret sits immediately before, when that glyph closes the\n * char span the caret is in — otherwise `undefined`.\n *\n * This is the one insertion point where Lexical's `selection.insertNodes()` SPLITS the enclosing\n * char span rather than inserting into it, because the caret is at a child boundary with nothing\n * but the closer beyond it. The split leaves a second span holding nothing but the orphaned\n * closing glyph, which the standard-view marker-edit engine reads as a span whose opener was\n * deleted and dissolves — taking the closer's bytes with it. A caret in the MIDDLE of the span's\n * text, or outside the span entirely, does not split it and needs none of this.\n *\n * Both spellings of the same boundary are recognized: the caret at the end of the span's content\n * text (a click at the end of the word) and the caret at offset 0 of the closing glyph itself\n * (an arrow-left back off the closer).\n *\n * Read-only: safe inside `editor.update()` or either read form.\n */\nfunction $closingGlyphAfterCaret(selection) {\n if (!selection.isCollapsed())\n return undefined;\n const { anchor } = selection;\n if (anchor.type !== \"text\")\n return undefined;\n const node = anchor.getNode();\n if (!$isTextNode(node) || !$isCharNode(node.getParent()))\n return undefined;\n // MarkerNode extends TextNode, so the caret may be parked in the closing glyph itself.\n if ($isMarkerNode(node))\n return anchor.offset === 0 && node.getMarkerSyntax() === \"closing\" ? node : undefined;\n if (anchor.offset !== node.getTextContentSize())\n return undefined;\n const next = node.getNextSibling();\n return $isMarkerNode(next) && next.getMarkerSyntax() === \"closing\" ? next : undefined;\n}\n/** Whether either end of `selection` sits in a chapter's `\\c N` line. Read-only. */\nfunction $isSelectionInChapterLine(selection) {\n return [selection.anchor, selection.focus].some((point) => {\n const node = point.getNode();\n return $isChapterNode(node) || $isChapterNode(node.getParent());\n });\n}\n/**\n * The paragraph a collapsed `selection` names the very start of, if any: offset 0 of the\n * paragraph's own opening marker glyph (Standard view), or an element point on the root in front of\n * the paragraph (Formatted view). Read-only.\n */\nfunction $paragraphStartedByCaret(selection) {\n if (!selection.isCollapsed())\n return undefined;\n const { anchor } = selection;\n const node = anchor.getNode();\n if (anchor.type === \"text\") {\n if (anchor.offset !== 0 || !$isMarkerNode(node))\n return undefined;\n const para = node.getParent();\n return $isSomeParaNode(para) && para.getFirstChild()?.is(node) ? para : undefined;\n }\n if (!$isRootNode(node))\n return undefined;\n const child = node.getChildAtIndex(anchor.offset);\n return $isSomeParaNode(child) ? child : undefined;\n}\n/**\n * Insert note node at the given selection, and select the note content if expanded.\n *\n * Whether the note lands collapsed is `isCollapsedNoteMode` — the same predicate that governs\n * both the child structure and the collapsed flag when notes are built at document load — so a\n * freshly inserted note matches a loaded one.\n *\n * A caret at the very start of a paragraph moves to the paragraph's content start first, so the note\n * lands inside that paragraph rather than joining it to the previous one. A selection in a chapter\n * line inserts nothing.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param noteNode - The note node to insert.\n * @param selection - The selection where to insert the note.\n * @param viewOptions - The current editor view options.\n */\nexport function $insertNoteWithSelect(noteNode, selection, viewOptions) {\n if ($isSelectionInChapterLine(selection))\n return;\n const isCollapsed = isCollapsedNoteMode(viewOptions?.noteMode);\n noteNode.setIsCollapsed(isCollapsed);\n if (!selection.isCollapsed())\n $moveSelectionToEnd(selection);\n // The caret may be parked between two of a glyph's display bytes — inside `\\v 5 `, inside a\n // closing `\\add*`. Those bytes are a picture of the node's own state, so a note dropped between\n // them would cut the picture in half and hand the right-hand half to the document as content\n // (the reported verse number arriving in the file twice). One place decides where such a point\n // really is; here it resolves to the glyph's trailing end, the ordinary position just past it.\n $normalizeSelectionOutOfGlyphText(selection);\n const startedPara = $paragraphStartedByCaret(selection);\n if (startedPara && $advancePastParaPrefixes(startedPara)) {\n const advanced = $getSelection();\n if ($isRangeSelection(advanced))\n selection = advanced;\n }\n // `selection` may be a detached range built from a caller-supplied location rather than the\n // editor's own live selection (`$getRangeFromUsjSelection`). Lexical's `insertNodes` reaches for\n // `$getSelection()` partway through its own split/removal machinery\n // (`$removeTextAndSplitBlock`), so without this the note would land wherever the live caret is\n // instead of where `selection` points.\n $setSelection(selection);\n // At a char span's content end, place the note explicitly rather than letting `insertNodes`\n // split the span there and strand its closing glyph (see `$closingGlyphAfterCaret`). The\n // resulting shape — note inside the span, ahead of the closer — is what re-tokenizing the\n // displayed bytes gives, and what a mid-content caret already produced.\n const closingGlyph = $closingGlyphAfterCaret(selection);\n if (closingGlyph) {\n closingGlyph.insertBefore(noteNode);\n noteNode.selectNext(0, 0); // caret past the note, where `insertNodes` leaves it\n }\n else {\n selection.insertNodes([noteNode]);\n }\n if (!isCollapsed) {\n const lastCharChild = noteNode.getChildren().reverse().find($isCharNode);\n lastCharChild?.selectEnd();\n }\n}\n/**\n * Build a single note-content char span matching the reverse adaptor's `createChar` output for\n * the active `markerMode`. In editable markerMode a char span MUST begin with its opening\n * MarkerNode glyph and carry a structural NBSP content prefix; otherwise the standard-view\n * marker-edit engine's `$charNodeDeletionTransform` treats it as \"opener deleted\" and\n * unwraps it back to plain text in the same commit — which was silently emptying freshly\n * inserted footnotes. `content === \"\"` yields the lone-NBSP empty-char placeholder (matching\n * `createChar`, which prepends the NBSP prefix only to real content, then adds the placeholder).\n */\nfunction $createNoteContentChar(marker, content, viewOptions) {\n const char = $createCharNode(marker);\n // Note-content chars are built without their own closing markers, i.e. they are implicitly\n // closed — exactly what ParatextData records as closed=\"false\" (near universal on \\fr/\\ft/\n // \\xo/\\xt). Carrying the flag from creation keeps these nodes signature-identical to what\n // Tier-2 re-tokenization produces (the rebuild's fixed-point refusal depends on that) and\n // round-trips the correct USJ shape.\n char.setUnknownAttributes({ closed: \"false\" });\n const isEditable = viewOptions?.markerMode === \"editable\";\n if (isEditable)\n char.append($createMarkerNode(marker));\n // Visible marker mode shows a bare opening glyph inside the span, matching `createChar` in\n // the load adaptor (implicitly-closed note-content chars get no closer there either).\n else if (viewOptions?.markerMode === \"visible\")\n char.append($createImmutableTypedTextNode(\"marker\", openingMarkerText(marker)));\n const text = content === \"\" ? EMPTY_CHAR_PLACEHOLDER_TEXT : isEditable ? NBSP + content : content;\n char.append($createTextNode(text));\n return char;\n}\nexport function $createNoteChildren(selection, marker, scriptureReference, viewOptions, nodeOptions, logger) {\n const children = [];\n const { chapterNum, verseNum, verse } = scriptureReference ?? {};\n const chapterVerseSeparator = nodeOptions.chapterVerseSeparator ?? \":\";\n const verseRangeSeparator = nodeOptions.verseRangeSeparator ?? \"-\";\n // `verse` (e.g. \"16-18\") is only populated for a verse bridge; replace the raw \"-\" bridge\n // separator with the project's configured verseRangeSeparator (PT9 `GetFormattedVerse`). Passed as\n // a REPLACER FUNCTION, not a replacement string, so a separator containing `$` is inserted\n // literally instead of being read as a `$&`/`$1` substitution pattern.\n const referenceText = chapterNum !== undefined && verseNum !== undefined\n ? `${chapterNum}${chapterVerseSeparator}${(verse ?? `${verseNum}`).replace(/-/g, () => verseRangeSeparator)} `\n : undefined;\n switch (marker) {\n case \"f\":\n case \"fe\":\n case \"ef\":\n case \"efe\":\n if (referenceText !== undefined) {\n children.push($createNoteContentChar(\"fr\", referenceText, viewOptions));\n }\n if (!selection.isCollapsed()) {\n const quotation = $stripSelectionToQuotation(selection);\n if (quotation.length > 0) {\n children.push($createNoteContentChar(\"fq\", quotation, viewOptions));\n }\n }\n children.push($createNoteContentChar(\"ft\", \"\", viewOptions));\n break;\n case \"x\":\n case \"ex\":\n if (referenceText !== undefined) {\n children.push($createNoteContentChar(\"xo\", referenceText, viewOptions));\n }\n if (!selection.isCollapsed()) {\n const quotation = $stripSelectionToQuotation(selection);\n if (quotation.length > 0) {\n children.push($createNoteContentChar(\"xq\", quotation, viewOptions));\n }\n }\n children.push($createNoteContentChar(\"xt\", \"\", viewOptions));\n break;\n default:\n logger?.warn(`$createNoteChildren: Unsupported note marker '${marker}'`);\n return undefined;\n }\n return children;\n}\n/**\n * Creates a note node including children with the given parameters.\n * @param marker - The marker for the note.\n * @param caller - The caller for the note.\n * @param contentNodes - The content nodes for the note.\n * @param viewOptions - The view options for the note.\n * @param nodeOptions - The node options for the note.\n * @param segment - The segment for the note.\n * @param closed - The source `closed` attribute (`\"false\"` for an unterminated note). Unclosed\n * notes render expanded inline (PT9 `opennote`) regardless of `noteMode`. `undefined` (the\n * default for freshly inserted notes) behaves as closed.\n * @returns The created note node.\n */\n// Keep this function updated with logic from\n// `packages/platform/src/editor/adaptors/usj-editor.adaptor.ts` > `createNote`\nexport function $createWholeNote(marker, caller, contentNodes, viewOptions, nodeOptions, segment, closed) {\n // Unclosed notes (closed=\"false\") render expanded inline (PT9 `opennote`); only closed\n // notes honor noteMode collapse.\n const isUnclosed = closed === \"false\";\n const isCollapsed = isUnclosed ? false : isCollapsedNoteMode(viewOptions?.noteMode);\n const note = $createNoteNode(marker, caller, isCollapsed);\n if (segment)\n $setState(note, segmentState, () => segment);\n // The note's shell — its opening glyph and its caller — is atomic when the host governs those\n // two through its own UI (see ViewOptions.isNoteShellEditable). Mirrors the load path\n // (`createNote`, usj-editor.adaptor): an INSERTED note must be shaped like a reloaded one.\n const isShellAtomic = viewOptions?.isNoteShellEditable === false;\n let openingMarkerNode;\n let closingMarkerNode;\n if (viewOptions?.markerMode === \"editable\") {\n openingMarkerNode = $createMarkerNode(marker);\n if (isShellAtomic)\n openingMarkerNode.setMode(\"token\");\n // An unclosed note has no closer to display.\n if (!isUnclosed) {\n closingMarkerNode = $createMarkerNode(marker, \"closing\");\n if (isShellAtomic)\n closingMarkerNode.setMode(\"token\");\n }\n }\n else if (viewOptions?.markerMode === \"visible\") {\n // Same glyph text shapes as the load path (`createNote`): opening glyph with a plain\n // trailing space, closer bare. Glyphs are presentation-only (never serialized), so a\n // reloaded note shows the load path's shape — an inserted note must look identical.\n openingMarkerNode = $createImmutableTypedTextNode(\"marker\", openingMarkerText(marker) + \" \");\n if (!isUnclosed)\n closingMarkerNode = $createImmutableTypedTextNode(\"marker\", closingMarkerText(marker));\n }\n let callerNode;\n if (openingMarkerNode)\n note.append(openingMarkerNode);\n // Expanded layout whenever the note is expanded (either noteMode expanded OR unclosed).\n // Unlike the load path (`createNote`, usj-editor.adaptor), no `\\cat` category run is built\n // here: this constructs NEW notes, which never carry a category at insert time — there is no\n // category input on the insert path. A category acquired later heals its run through the\n // shared display-run sync.\n if (viewOptions?.markerMode === \"editable\" && !isCollapsed) {\n // An empty caller keeps its slot: the two separators Paratext 9 leaves where a deleted caller\n // was (`\\f \\fr …`), as the load path (`createNote`) builds it. Unmergeable, or Lexical folds\n // content text that starts right after it into the caller on the first edit, and the caller\n // then saves as content.\n callerNode = $createTextNode(getEditableCallerText(note.__caller)).toggleUnmergeable();\n if (isShellAtomic)\n callerNode.setMode(\"token\");\n note.append(callerNode, ...contentNodes);\n }\n else {\n // The engine-owned NBSP separators of a collapsed note's layout, in the same tagged token\n // shape as the para-marker prefix separator (and as the load path's `createNote` builds\n // them): a bare NBSP TextNode merged into adjacent plain content on the first normalization\n // pass, after which serialization's exact-NBSP drop could no longer see the separator and\n // one display byte leaked into USJ as a data space.\n const $createSpaceNodeFn = () => $createMarkerTrailingSeparator();\n const spacedContentNodes = contentNodes.flatMap($addSpaceNodes($createSpaceNodeFn));\n if (caller === \"\")\n note.append(...spacedContentNodes);\n else {\n const previewText = $getNoteCallerPreviewText(contentNodes);\n let onClick = () => undefined;\n if (nodeOptions?.noteCallerOnClick) {\n onClick = nodeOptions.noteCallerOnClick;\n }\n callerNode = $createImmutableNoteCallerNode(note.__caller, previewText, onClick);\n note.append(callerNode, $createSpaceNodeFn(), ...spacedContentNodes);\n }\n }\n if (closingMarkerNode)\n note.append(closingMarkerNode);\n return note;\n}\n/**\n * Gets the note using the editor key or at the specified note index.\n * @param noteKeyOrIndex - The note key or index, e.g. 1 would select the second note in the editor.\n * @returns The note at the specified index, or `undefined` if not found.\n */\nexport function $getNoteByKeyOrIndex(noteKeyOrIndex) {\n if (typeof noteKeyOrIndex === \"string\") {\n const node = $getNodeByKey(noteKeyOrIndex);\n if (!$isNoteNode(node))\n return;\n return node;\n }\n return $getNoteAtIndex(noteKeyOrIndex);\n}\n/**\n * Selects the given note node, expanding or collapsing it based on the current view options.\n *\n * Deliberately NOT `isCollapsedNoteMode` (nor its inverse): that predicate is for CONSTRUCTING\n * notes, where `expandInline` builds collapsed. Here the user is navigating INTO the note, so\n * `expandInline` must expand it (the caret is about to be adjacent — the same condition under\n * which the NoteNodePlugin keeps it open); only an always-`\"collapsed\"` mode keeps it closed.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param noteNode - The note node to select.\n * @param viewOptions - The current editor view options.\n */\nexport function $selectNote(noteNode, viewOptions) {\n const isCollapsed = viewOptions?.noteMode === \"collapsed\";\n noteNode.setIsCollapsed(isCollapsed);\n if (isCollapsed) {\n const nodeBefore = noteNode.getPreviousSibling();\n if ($isImmutableVerseNode(nodeBefore) || !nodeBefore) {\n const parent = noteNode.getParent();\n if (parent) {\n const nodeIndex = noteNode.getIndexWithinParent();\n parent.select(nodeIndex, nodeIndex);\n }\n }\n else\n nodeBefore.selectEnd();\n }\n else {\n const children = noteNode.getChildren();\n const lastCharChild = children.slice().reverse().find($isCharNode);\n if (lastCharChild)\n $selectCharContentEnd(lastCharChild);\n else {\n // An expanded note with no content run at all (`\\f + \\f*`) holds nothing to select the end\n // of, and leaving the caret where it was puts it OUTSIDE the note the user asked to be in -\n // so the next keystroke lands in the surrounding text. Land it at the child slot content\n // would occupy: just before the closing glyph, or at the end when there is none. The glyph\n // is a marker node under `markerMode: \"editable\"` and display-only text under `\"visible\"`.\n const closingIndex = $closingGlyphIndex(noteNode);\n const at = closingIndex === -1 ? children.length : closingIndex;\n noteNode.select(at, at);\n }\n }\n}\n/**\n * Index of `element`'s own closing glyph among its children: a marker node under\n * `markerMode: \"editable\"`, display-only text under `\"visible\"`.\n *\n * Only the LAST child can be the element's own closer. A closing glyph earlier in the children is\n * not a boundary the content ends at: it can be a nested span's, where that span's glyphs sit\n * among the run's own children (the flattened nested shape collaborative input can carry).\n * @param element - The note or char span whose closer to find.\n * @returns The closer's index, or `-1` when the element does not end in one (implicitly closed,\n * markers hidden, or content after an inner closer).\n */\nfunction $closingGlyphIndex(element) {\n const lastIndex = element.getChildrenSize() - 1;\n const last = element.getLastChild();\n const isCloser = ($isMarkerNode(last) && last.getMarkerSyntax() === \"closing\") ||\n ($isVisibleMarkerNode(last) &&\n last.getTextContent() === closingMarkerText(element.getMarker()));\n return isCloser ? lastIndex : -1;\n}\n/**\n * Puts the caret at the end of a char span's CONTENT: ahead of its closing glyph when the span is\n * explicitly closed (`\\ft a\\ft*`), where text typed extends the run rather than landing after it.\n * @param charNode - The char span.\n */\nfunction $selectCharContentEnd(charNode) {\n const closingIndex = $closingGlyphIndex(charNode);\n if (closingIndex === -1) {\n charNode.selectEnd();\n return;\n }\n const beforeCloser = charNode.getChildAtIndex(closingIndex - 1);\n if ($isTextNode(beforeCloser) && !$shouldIgnoreNodeForContentIndexes(beforeCloser))\n beforeCloser.selectEnd();\n else\n charNode.select(closingIndex, closingIndex);\n}\n/**\n * Puts the caret immediately AFTER `noteNode`, where PT9 leaves it once the user is done with a\n * note: in a collapsed note the note renders as its caller alone, so this is the position just\n * past the caller.\n *\n * The mirror of {@link $selectNote}'s collapsed branch, which lands just BEFORE the note.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param noteNode - The note node to put the caret after.\n * @param options - `isContentChange`: set it when the calling update also changes the document\n * (closing a note, say). The caret then still goes past the note but its move is not announced\n * (see {@link $selectElementPoint}), since the repair that announcement triggers tags the whole\n * commit as a caret move and `onUsjChange` would skip the change with it. Unannounced, the point\n * gets no caret host, so a browser that reads it back from the end of a char span resolves it to\n * the end of the note's closing glyph. The editable-marker views move text typed there out after\n * the note as it is typed, so it still lands past the note.\n */\nexport function $selectAfterNote(noteNode, { isContentChange = false } = {}) {\n const nodeAfter = noteNode.getNextSibling();\n // Landing in the following text rather than on the parent's element offset gives the caret a\n // text position to type into, the same reason $selectNote prefers `selectEnd()` on the node\n // before over the parent-offset branch.\n //\n // A glyph text node is not that text: its bytes are a picture of its own state (a verse number,\n // a marker's syntax), so offset 0 is a position INSIDE the picture, which the next keystroke\n // splits - the very thing $normalizeSelectionOutOfGlyphText exists to prevent. A note that ends\n // a verse is followed by exactly such a node, so it takes the parent-offset branch instead.\n if ($isTextNode(nodeAfter) && !$isGlyphTextNode(nodeAfter)) {\n nodeAfter.select(0, 0);\n return;\n }\n const parent = noteNode.getParent();\n if (!parent)\n return;\n const indexAfter = noteNode.getIndexWithinParent() + 1;\n // A paragraph's own `select` names the slot past the note; only a char span (which cannot be\n // empty) descends into the note instead, so only there is the explicit element point needed.\n if (parent.canBeEmpty())\n parent.select(indexAfter, indexAfter);\n else\n $selectElementPoint(parent, indexAfter, { announce: !isContentChange });\n}\n/**\n * Puts a collapsed caret at child slot `offset` of `element`, and keeps it at that slot when the\n * slot sits just past a collapsed note.\n *\n * `ElementNode.select` on an element that cannot be empty - a char span - descends into the child\n * at its edge rather than naming the slot itself. At the end of a span that a collapsed note ends\n * (an unclosed `\\wj`, whose missing closer leaves the note its last child), that child is the\n * note, and the descent comes to rest inside the note's hidden closing glyph: an invisible caret\n * whose next keystroke edits the note body.\n *\n * The slot past the note is where the caret belongs, and `TrailingNoteCaretGuardPlugin` gives it a\n * caret host to render in when it hears of the move on `SELECTION_CHANGE_COMMAND`. The move is\n * announced here, inside this update, because the browser's own report of it comes too late for an\n * inline span: the element point is written out to the DOM and read back, and reading a position at\n * the end of an inline element resolves it into that element's last text - the same hidden glyph.\n * The guard's repair tags its whole commit as a caret move, which `onUsjChange` skips, so an\n * update that also changes the document passes `announce: false`: the caret still lands past the\n * note, but without the announcement the guard does not give it a host there.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param element - The element to place the caret in.\n * @param offset - The child slot to place it at.\n * @param options - `announce` (default `true`): whether to dispatch `SELECTION_CHANGE_COMMAND`.\n */\nexport function $selectElementPoint(element, offset, { announce = true } = {}) {\n const childBefore = element.getChildAtIndex(offset - 1);\n if (!$isNoteNode(childBefore) || childBefore.getIsCollapsed() !== true) {\n element.select(offset, offset);\n return;\n }\n const selection = $createRangeSelection();\n selection.anchor.set(element.getKey(), offset, \"element\");\n selection.focus.set(element.getKey(), offset, \"element\");\n $setSelection(selection);\n if (announce)\n $getEditor().dispatchCommand(SELECTION_CHANGE_COMMAND, undefined);\n}\n/**\n * Puts the caret at `utf16Offset` within a note's own text, counting the note's CONTENT only and\n * skipping every display artifact the view adds around it: marker glyphs (editable and visible),\n * attribute display runs, engine-owned NBSP spacers, an opening glyph's NBSP separator prefix,\n * and - in an expanded editable note - the caller text node. That makes the offset origin the\n * note's USJ text, so a host that captured a position over its OWN rendering of the same note\n * (a footnotes pane row, say) resolves against the same characters no matter which\n * `ViewOptions.markerMode` this editor renders in.\n *\n * Text the source wrote directly inside the note rather than inside a `\\ft`-style run counts too,\n * as it does in the note's USJ.\n *\n * With `glyph`, the caret goes inside the marker glyph that position names instead (see\n * {@link NoteGlyphCaret}): a run's opening or closing glyph, a nested span's, or an unmatched\n * marker - never the note's own opening glyph, caller, or closing glyph. The start of a glyph that\n * follows text the user can type in (content, or the caller) is that text's end, where typing\n * extends it rather than rewriting the glyph. A glyph position the note does not have falls back to\n * the content offset.\n *\n * Offsets past the end of the note's text clamp to the end.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param noteNode - The note node whose text to place the caret in.\n * @param utf16Offset - Offset into the note's content text, in UTF-16 code units.\n * @param glyph - The marker glyph at that offset to put the caret in, if any.\n * @returns `true` when a caret was placed, `false` when the note holds no content text to place\n * one in (the caller should fall back to {@link $selectNote}).\n */\nexport function $selectNoteTextOffset(noteNode, utf16Offset, glyph) {\n const caller = $noteEditableCallerNode(noteNode);\n const stops = $noteTextStops(noteNode, caller);\n if (glyph && $selectGlyphStop(stops, utf16Offset, glyph, $isTypingTextBefore(noteNode, caller)))\n return true;\n let remaining = Math.max(utf16Offset, 0);\n let lastDataNode;\n for (const { node, isGlyph, dataStart } of stops) {\n if (isGlyph)\n continue;\n const dataLength = node.getTextContentSize() - dataStart;\n // Strictly `<`: an offset that lands exactly on a run boundary belongs to the run it starts,\n // not to the one it ends. The two are the same caret on screen but not the same place to type\n // - the end of `\\fr`'s text extends the reference run, while the start of `\\ft`'s extends the\n // note text the user clicked into. The final position is reached by the clamp below instead.\n if (remaining < dataLength) {\n const at = dataStart + remaining;\n node.select(at, at);\n return true;\n }\n remaining -= dataLength;\n lastDataNode = node;\n }\n if (!lastDataNode)\n return false;\n const end = lastDataNode.getTextContentSize();\n lastDataNode.select(end, end);\n return true;\n}\n/**\n * The note's content text and its runs' marker glyphs, in document order. Excluded: the note's own\n * opening glyph, caller, and closing glyph (its shell, which a note editor governs through its own\n * controls), the `\\cat` category run and every other attribute display run, and the view's NBSP\n * spacers.\n */\nfunction $noteTextStops(noteNode, caller) {\n const stops = [];\n for (const { node } of $dfs(noteNode)) {\n if (!$isTextNode(node) || $findMatchingParent(node, $isAttributeRunNode))\n continue;\n if ($isNoteContentText(node, caller))\n stops.push({ node, isGlyph: false, dataStart: $separatorPrefixLength(node) });\n else if ($isNoteRunGlyph(node, noteNode))\n stops.push({ node, isGlyph: true, dataStart: 0 });\n }\n return stops;\n}\n/** Whether `node` is a marker glyph of one of the note's runs, or an unmatched marker in it. */\nfunction $isNoteRunGlyph(node, noteNode) {\n if ($isImmutableUnmatchedNode(node))\n return true;\n // The note's own opening and closing glyphs are its children; a run's are its span's.\n return $isMarkerNode(node) && !noteNode.is(node.getParent());\n}\n/**\n * Text the user can type into that `node` directly follows, if any: note content, or the caller\n * (the shell's end, where typing goes into the note's content). Its end is the same place on screen\n * as the glyph's start.\n */\nfunction $isTypingTextBefore(noteNode, caller) {\n return (node) => {\n let cursor = node;\n while (!cursor.getPreviousSibling()) {\n const parent = cursor.getParent();\n if (!parent || parent.is(noteNode))\n return undefined;\n cursor = parent;\n }\n const before = cursor.getPreviousSibling();\n const last = $isElementNode(before) ? before.getLastDescendant() : before;\n if (!$isTextNode(last))\n return undefined;\n if (caller?.is(last) || $isNoteContentText(last, caller))\n return last;\n return undefined;\n };\n}\n/**\n * Put the caret in the glyph `glyph` names at content offset `utf16Offset` among `stops`.\n * @returns Whether that glyph exists and got the caret.\n */\nfunction $selectGlyphStop(stops, utf16Offset, glyph, typingTextBefore) {\n let contentOffset = 0;\n let glyphIndex = 0;\n for (const { node, isGlyph, dataStart } of stops) {\n if (!isGlyph) {\n const dataLength = node.getTextContentSize() - dataStart;\n contentOffset += dataLength;\n if (dataLength > 0)\n glyphIndex = 0;\n if (contentOffset > utf16Offset)\n return false;\n continue;\n }\n if (contentOffset === utf16Offset && glyphIndex === glyph.index) {\n $selectInGlyph(node, glyph.offset, typingTextBefore);\n return true;\n }\n glyphIndex += 1;\n }\n return false;\n}\n/** Put the caret `offset` characters into `glyphNode` (see {@link $selectNoteTextOffset}). */\nfunction $selectInGlyph(glyphNode, offset, typingTextBefore) {\n const size = glyphNode.getTextContentSize();\n // An atomic glyph (an unmatched marker outside an editable marker mode) takes no caret inside.\n const at = glyphNode.isToken() ? size : Math.min(Math.max(offset, 0), size);\n const before = at === 0 ? typingTextBefore(glyphNode) : undefined;\n if (before) {\n const end = before.getTextContentSize();\n before.select(end, end);\n }\n else\n glyphNode.select(at, at);\n}\n/**\n * Puts the caret at `utf16Offset` within a note's `\\cat` category value - the category a\n * study-Bible note carries as a field rather than as content, which an expanded editable note shows\n * as its own run right after the caller. The value's display separator is skipped, so offset 0 is\n * the start of the category itself. Offsets past the end clamp to the end.\n *\n * With `glyph`, the caret goes inside the run's `\\cat` or `\\cat*` glyph instead, addressed as\n * {@link $selectNoteTextOffset} addresses a run's glyphs: `\\cat` sits at value offset 0 and\n * `\\cat*` at the value's end.\n *\n * Mutating: call inside `editor.update()`.\n *\n * @param noteNode - The note whose category to place the caret in.\n * @param utf16Offset - Offset into the category value, in UTF-16 code units.\n * @param glyph - The category run's glyph at that offset to put the caret in, if any.\n * @returns `true` when a caret was placed, `false` when the note shows no category run.\n */\nexport function $selectNoteCategoryOffset(noteNode, utf16Offset, glyph) {\n const { opener, value, closer } = $noteCategoryRunPieces(noteNode);\n if (!value)\n return false;\n const start = $categoryValueStart(value);\n if (glyph) {\n const stops = [];\n if (opener)\n stops.push({ node: opener, isGlyph: true, dataStart: 0 });\n stops.push({ node: value, isGlyph: false, dataStart: start });\n if (closer)\n stops.push({ node: closer, isGlyph: true, dataStart: 0 });\n const caller = $noteEditableCallerNode(noteNode);\n if ($selectGlyphStop(stops, utf16Offset, glyph, $isTypingTextBefore(noteNode, caller)))\n return true;\n }\n const at = Math.min(start + Math.max(utf16Offset, 0), value.getTextContentSize());\n value.select(at, at);\n return true;\n}\n/** Where a category value's own text starts, past the NBSP display separator it leads with. */\nfunction $categoryValueStart(value) {\n return value.getTextContent().startsWith(NBSP) ? NBSP.length : 0;\n}\n/**\n * Whether `node`, somewhere inside a note, is text of the note's CONTENT rather than display the\n * view adds around it (see {@link $selectNoteTextOffset} for the list).\n * @param node - A node inside the note.\n * @param caller - The note's editable caller text node, if it has one.\n */\nfunction $isNoteContentText(node, caller) {\n if (!$isTextNode(node))\n return false;\n if ($shouldIgnoreNodeForContentIndexes(node))\n return false;\n // A glyph's bytes are a picture of its own state (an unmatched closer, say), never content.\n if ($isGlyphTextNode(node))\n return false;\n // An expanded editable note spells its caller out as plain text ahead of the content.\n return !caller || !node.is(caller);\n}\n/**\n * Where an expanded note with no content takes the text a user types into it: the child index just\n * before its closing glyph, or its end when it has none. What is typed there is the note's content,\n * written directly in the note (`\\f + text\\f*`) with no run marker added.\n *\n * Read-only: call inside `editor.update()` or `editor.getEditorState().read()`.\n *\n * @param noteNode - The note.\n * @returns The child index, or `undefined` when the note is collapsed or already has content.\n */\nexport function $emptyNoteContentSlot(noteNode) {\n if (noteNode.getIsCollapsed() !== false)\n return undefined;\n if (noteNode.getChildren().some($isCharNode))\n return undefined;\n const caller = $noteEditableCallerNode(noteNode);\n for (const { node } of $dfs(noteNode))\n if ($isNoteContentText(node, caller))\n return undefined;\n const closingIndex = $closingGlyphIndex(noteNode);\n return closingIndex === -1 ? noteNode.getChildrenSize() : closingIndex;\n}\n/** Add the given space node after each child node */\nfunction $addSpaceNodes($createSpaceNodeFn) {\n return (node) => {\n if ($isImmutableTypedTextNode(node))\n return [node];\n return [node, $createSpaceNodeFn()];\n };\n}\n/**\n * Returns `true` when `node` is inside a NoteNode (i.e. an existing footnote/cross-reference\n * embedded in the selected body text) — its entire content, markers included, must be dropped.\n * `selection.getNodes()` flattens a NoteNode's descendants into the returned list alongside the\n * note itself, so skipping just the NoteNode entry is not enough; every descendant must also be\n * excluded by walking its ancestor chain.\n */\nfunction $isInsideNote(node) {\n // The walk starts at the PARENT deliberately: the NoteNode entry itself is handled by the\n // caller, and a note is not \"inside\" itself.\n const parent = node.getParent();\n return parent !== null && $findMatchingParent(parent, $isNoteNode) !== null;\n}\n/**\n * TS port of PT9 `RemoveMarkersAndFootnotes(text, isFootnote=true)`\n * (`UsfmSnippetInserter.cs:444-489`): builds a footnote/cross-reference quotation (`\\fq`/`\\xq`)\n * from a selection over body text — plain text only, with USFM markers and any nested\n * notes stripped, and embedded verse numbers converted to `\\+fv \\+fv*`.\n *\n * Endpoint handling: Lexical's `RangeSelection.getNodes()` returns whole boundary nodes even for\n * a partial selection, so the first/last selected plain TextNode is sliced to the\n * anchor/focus offset here — reusing Lexical's own `$getCharacterOffsets` (which normalizes\n * \"element\"-type points, e.g. a whole-paragraph `select(0, childrenSize)`, to real character\n * offsets) and the same anchor/focus-order slicing Lexical's `RangeSelection.getTextContent()`\n * uses internally, rather than raw `.offset` values (a raw element-point offset is a child\n * index, not a character offset, and slicing with it truncates the last node's text).\n *\n * @param selection - The selection to build the quotation from.\n * @returns The stripped, trimmed quotation text.\n */\nexport function $stripSelectionToQuotation(selection) {\n if (!$isRangeSelection(selection))\n return \"\";\n const nodes = selection.getNodes();\n if (nodes.length === 0)\n return \"\";\n const firstNode = nodes[0];\n const lastNode = nodes[nodes.length - 1];\n const isBefore = selection.anchor.isBefore(selection.focus);\n const [anchorOffset, focusOffset] = $getCharacterOffsets(selection);\n let result = \"\";\n for (const node of nodes) {\n if ($isNoteNode(node) || $isImmutableNoteCallerNode(node) || $isInsideNote(node))\n continue;\n if ($isMarkerNode(node))\n continue;\n // A stray closer's glyph bytes (`\\nd*`) are display text, not quotation content.\n // ImmutableUnmatchedNode is a TextNode subclass, so without this skip it falls through to\n // the TextNode branch below and its bytes land verbatim in the quotation.\n if ($isImmutableUnmatchedNode(node))\n continue;\n // Attribute display text is display too: a char span's `|lemma=\"…\"` run, a verse's `\\va`\n // value, and a milestone's attribute run are engine-owned bytes, not Scripture — without\n // this skip they land verbatim in the inserted note's quotation and reach the file as note\n // content.\n if ($getState(node, textTypeState) === \"attribute\")\n continue;\n // Check verse nodes before TextNode, via the union: in editable markerMode a VerseNode IS a\n // TextNode subclass, so a TextNode-first check would emit its raw glyph text instead of\n // `\\+fv` — and in visible/hidden marker mode the verse is an ImmutableVerseNode (a\n // DecoratorNode), which a bare $isVerseNode check misses entirely, silently dropping the\n // verse number from the quotation.\n if ($isSomeVerseNode(node)) {\n result += `\\\\+fv ${node.getNumber()}\\\\+fv*`;\n continue;\n }\n if ($isTextNode(node)) {\n let text = node.getTextContent();\n if (node === firstNode && node === lastNode) {\n text =\n anchorOffset < focusOffset\n ? text.slice(anchorOffset, focusOffset)\n : text.slice(focusOffset, anchorOffset);\n }\n else if (node === firstNode) {\n text = isBefore ? text.slice(anchorOffset) : text.slice(focusOffset);\n }\n else if (node === lastNode) {\n text = isBefore ? text.slice(0, focusOffset) : text.slice(0, anchorOffset);\n }\n result += text;\n }\n }\n // Collapse ASCII whitespace runs only (line joins and indentation from the source paragraph).\n // NBSP, ZWSP, and the other Unicode spaces are authored content that Paratext preserves, so\n // folding them into a plain space here would quietly rewrite the quoted text.\n return result.replace(/[ \\t\\r\\n\\f\\v]+/g, \" \").trim();\n}\n","import { ImmutableNoteCallerNode } from \"./ImmutableNoteCallerNode\";\nimport { ImmutableVerseNode } from \"./ImmutableVerseNode\";\nimport { usjBaseNodes, VerseBlockNode } from \"shared\";\nexport * from \"./ImmutableNoteCallerNode\";\nexport * from \"./ImmutableVerseNode\";\nexport * from \"./node-react.utils\";\nexport * from \"./note.utils\";\nexport * from \"./usj-node-options.model\";\n// AttributeRunNode rides in via usjBaseNodes (shared) — every USJ-shaped editor needs it, not only\n// a react host, since the shared self-healing syncs construct one directly.\nexport const usjReactNodes = [\n ImmutableNoteCallerNode,\n ImmutableVerseNode,\n ...usjBaseNodes,\n];\n/**\n * Nodes for the block verse layout (`ViewOptions.verseLayout`). Register these instead of\n * {@link usjReactNodes} when that layout is active, so every other editor's node registry is\n * unchanged.\n *\n * A Lexical editor's node types are fixed when it is created, so an editor registered with\n * `usjReactNodes` cannot be switched to the block verse layout - it has to be recreated.\n */\nexport const usjBlockVerseNodes = [\n VerseBlockNode,\n ...usjReactNodes,\n];\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { forwardRef } from \"react\";\nexport const FloatingBox = forwardRef((props, ref) => {\n const { coords, children, style, ...extraProps } = props;\n const shouldShow = coords !== undefined;\n return (_jsx(\"div\", { ref: ref, className: \"floating-box\", \"aria-hidden\": !shouldShow, style: {\n ...style,\n position: \"absolute\",\n zIndex: 1000,\n top: coords?.y,\n left: coords?.x,\n visibility: shouldShow ? \"visible\" : \"hidden\",\n opacity: shouldShow ? 1 : 0,\n }, ...extraProps, children: children }));\n});\n","import { useState, useCallback, useRef, useEffect } from \"react\";\nimport { autoUpdate, computePosition, shift, flip } from \"@floating-ui/dom\";\nexport function useFloatingPosition() {\n const [coords, setCoords] = useState(undefined);\n const [placement, setPlacement] = useState();\n const cleanupRef = useRef(null);\n const updatePosition = useCallback((domRange, anchorElement) => {\n if (cleanupRef.current) {\n cleanupRef.current();\n }\n const referenceElement = domRange.commonAncestorContainer.nodeType === domRange.commonAncestorContainer.TEXT_NODE\n ? domRange\n : domRange.commonAncestorContainer;\n cleanupRef.current = autoUpdate(referenceElement, anchorElement, () => {\n computePosition(referenceElement, anchorElement, {\n placement: \"bottom-start\",\n middleware: [shift(), flip()],\n })\n .then((pos) => {\n setPlacement(pos.placement);\n setCoords((prevCoords) => prevCoords?.x === pos.x && prevCoords?.y === pos.y\n ? prevCoords\n : { x: pos.x, y: pos.y });\n })\n .catch(() => {\n setCoords(undefined);\n });\n });\n }, []);\n const cleanup = useCallback(() => {\n if (cleanupRef.current) {\n setCoords(undefined);\n cleanupRef.current();\n cleanupRef.current = null;\n }\n }, []);\n useEffect(() => {\n return cleanup;\n }, [cleanup]);\n return { coords, placement, updatePosition, cleanup };\n}\n","import { useEffect } from \"react\";\nimport { useFloatingPosition } from \"./useFloatingPosition\";\nexport default function useCursorCoords({ isOpen, floatingBoxRef, }) {\n const { coords, updatePosition, cleanup, placement } = useFloatingPosition();\n useEffect(() => {\n if (!isOpen || !floatingBoxRef.current) {\n cleanup();\n return undefined;\n }\n const domRange = window.getSelection()?.getRangeAt(0);\n if (!domRange) {\n cleanup();\n return undefined;\n }\n updatePosition(domRange, floatingBoxRef.current);\n return cleanup;\n }, [cleanup, isOpen, floatingBoxRef, updatePosition]);\n return { coords, placement };\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { memo, useMemo, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { FloatingBox } from \"./FloatingBox\";\nimport useCursorCoords from \"./useCursorCoords\";\nconst MemoizedFloatingBox = memo(FloatingBox);\n/**\n * FloatingBoxAtCursor component is responsible for rendering a floating menu\n * at the cursor position when the isOpen prop is true\n */\nexport default function FloatingBoxAtCursor({ isOpen = false, children }) {\n const floatingBoxRef = useRef(null);\n const { coords, placement } = useCursorCoords({ isOpen, floatingBoxRef });\n const renderChildren = useMemo(() => (coords ? (typeof children === \"function\" ? children : () => children) : () => null), [children, coords]);\n return createPortal(_jsx(MemoizedFloatingBox, { ref: floatingBoxRef, coords: coords, style: coords ? undefined : { display: \"none\" }, children: renderChildren({ isOpen, placement }) }), \n // Read at render rather than at module scope: this module sits in the import graph of the\n // package's utility entry points, so touching `document` on load throws for any consumer that\n // imports one of them outside a DOM environment (a Node-environment unit test, SSR).\n document.body);\n}\n","import { createContext, useContext } from \"react\";\nconst MenuContext = createContext(undefined);\nexport function useMenuContext() {\n const context = useContext(MenuContext);\n if (!context) {\n throw new Error(\"useMenuContext must be used within a MenuProvider\");\n }\n return context;\n}\nexport { MenuContext };\n","import { useState, useCallback, useMemo } from \"react\";\nexport function useMenuCore(initialMenuItems, onSelectOption) {\n const [activeIndex, setActiveIndex] = useState(0);\n const [selectedIndex, setSelectedIndex] = useState(-1);\n const menuItems = useMemo(() => initialMenuItems ?? [], [initialMenuItems]);\n const state = {\n menuItems,\n activeIndex,\n selectedIndex,\n onSelectOption: onSelectOption ?? (() => undefined),\n };\n const moveUp = useCallback(() => {\n setActiveIndex((prev) => {\n const optionsCount = menuItems.length;\n return optionsCount ? (prev - 1 + optionsCount) % optionsCount : 0;\n });\n }, [menuItems.length]);\n const moveDown = useCallback(() => {\n setActiveIndex((prev) => {\n const optionsCount = menuItems.length;\n return optionsCount ? (prev + 1) % optionsCount : 0;\n });\n }, [menuItems.length]);\n const select = useCallback(() => {\n const optionsCount = menuItems.length;\n if (activeIndex >= 0 && activeIndex < optionsCount) {\n const selectedOption = menuItems[activeIndex];\n onSelectOption?.(selectedOption);\n setSelectedIndex(activeIndex);\n }\n }, [activeIndex, menuItems, onSelectOption]);\n return {\n state,\n moveUp,\n moveDown,\n select,\n setActiveIndex,\n setSelectedIndex,\n };\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { MenuContext } from \"./MenuContext\";\nimport { useMenuCore } from \"./useMenuCore\";\nexport function MenuRoot({ children, menuItems, onSelectOption, ...divProps }) {\n const menuContext = useMenuCore(menuItems, onSelectOption);\n return (_jsx(MenuContext.Provider, { value: menuContext, children: _jsx(\"div\", { ...divProps, children: children }) }));\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { forwardRef, useCallback } from \"react\";\nimport { useMenuContext } from \"./MenuContext\";\nexport const MenuOption = forwardRef(({ index, children, onMouseEnter, onClick, ...props }, ref) => {\n const { state: { activeIndex }, setActiveIndex, setSelectedIndex, select, } = useMenuContext();\n const handleClick = useCallback((event) => {\n select();\n setSelectedIndex(-1);\n onClick?.(event);\n }, [onClick, select, setSelectedIndex]);\n const handleMouseEnter = useCallback((event) => {\n setActiveIndex(index);\n onMouseEnter?.(event);\n }, [index, setActiveIndex, onMouseEnter]);\n return (_jsx(\"button\", { ref: ref, role: \"menuitem\", ...props, onClick: handleClick, onMouseEnter: handleMouseEnter, \"aria-selected\": index !== undefined && activeIndex === index ? \"true\" : undefined, tabIndex: -1, children: children }));\n});\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { Children, cloneElement, isValidElement, useEffect, useMemo, useRef, } from \"react\";\nimport { useMenuContext } from \"./MenuContext\";\nimport { MenuOption } from \"./Option\";\nexport function MenuOptions({ children, autoIndex = true, ...divProps }) {\n const menuRef = useRef(null);\n const { state: { activeIndex, menuItems }, } = useMenuContext();\n const renderChildren = useMemo(() => (menuItems ? (typeof children === \"function\" ? children : () => children) : () => null), [children, menuItems]);\n const mappedChildren = useMemo(() => {\n const children = renderChildren(menuItems);\n if (!autoIndex)\n return children;\n return Children.map(children, (child, index) => {\n if (isValidElement(child) &&\n child.type === MenuOption &&\n child.props.index === undefined) {\n return cloneElement(child, { index });\n }\n return child;\n });\n }, [renderChildren, autoIndex, menuItems]);\n useEffect(() => {\n if (menuRef.current) {\n const menuElement = menuRef.current;\n const selectedElement = menuElement.children[activeIndex];\n if (selectedElement) {\n const menuRect = menuElement.getBoundingClientRect();\n const selectedRect = selectedElement.getBoundingClientRect();\n if (selectedRect.bottom > menuRect.bottom) {\n menuElement.scrollTop += selectedRect.bottom - menuRect.bottom;\n }\n else if (selectedRect.top < menuRect.top) {\n menuElement.scrollTop -= menuRect.top - selectedRect.top;\n }\n }\n }\n }, [activeIndex]);\n return (_jsx(\"div\", { ref: menuRef, role: \"menu\", ...divProps, children: mappedChildren }));\n}\n","// Default filter function\nconst defaultFilter = (item, query, filterBy) => {\n return getSafeValue(item, filterBy).toLowerCase().includes(query.toLowerCase());\n};\n// Helper function to get the first string key of an object\nconst getFirstStringKey = (obj) => {\n return Object.keys(obj).find((key) => typeof obj[key] === \"string\") || \"\";\n};\n// Helper function to safely get a string value from an item\nconst getSafeValue = (item, key) => {\n const value = item[key];\n return typeof value === \"string\" ? value : String(value);\n};\n/**\n * Filters `items` by `query` and ranks the matches exact-first — THE ranking behind the editor's\n * marker palettes (`NodeSelectionMenu` filters with `filterBy: \"name\"`, the marker code): exact\n * match, then prefix matches, then containment matches (nearest occurrence first), with ties\n * keeping the caller's item order (stable sort). Hosts rendering their own palette UI over the\n * editor's marker items should reuse this rather than reimplementing the ordering.\n *\n * @public\n */\nexport function filterAndRankItems(options) {\n const { query, items, filterBy, filter, sortBy, sortingOptions } = options;\n const { caseSensitive = false, priorityOrder = [\"exact\", \"startsWith\", \"contains\"] } = sortingOptions || {};\n const compareQuery = caseSensitive ? query : query.toLowerCase();\n let actualFilterBy;\n let actualFilter;\n if (filter) {\n actualFilter = filter;\n actualFilterBy = items.length > 0 ? getFirstStringKey(items[0]) : \"\";\n }\n else {\n actualFilterBy = filterBy || (items.length > 0 ? getFirstStringKey(items[0]) : \"\");\n actualFilter = (item, query) => defaultFilter(item, query, actualFilterBy);\n }\n const actualSortBy = sortBy || actualFilterBy;\n // Create a Map to cache lowercase versions of sortBy values\n const sortByCache = new Map();\n return items\n .filter((item) => {\n try {\n return actualFilter(item, query);\n }\n catch (error) {\n console.warn(`Error filtering item:`, item, error);\n return false;\n }\n })\n .sort((a, b) => {\n const getTextLower = (item) => {\n if (!sortByCache.has(item)) {\n sortByCache.set(item, getSafeValue(item, actualSortBy).toLowerCase());\n }\n return sortByCache.get(item) ?? \"\";\n };\n const textA = caseSensitive ? getSafeValue(a, actualSortBy) : getTextLower(a);\n const textB = caseSensitive ? getSafeValue(b, actualSortBy) : getTextLower(b);\n for (const priority of priorityOrder) {\n switch (priority) {\n case \"exact\":\n if (textA === compareQuery && textB !== compareQuery)\n return -1;\n if (textB === compareQuery && textA !== compareQuery)\n return 1;\n break;\n case \"startsWith\":\n if (textA.startsWith(compareQuery) && !textB.startsWith(compareQuery))\n return -1;\n if (textB.startsWith(compareQuery) && !textA.startsWith(compareQuery))\n return 1;\n break;\n case \"contains\": {\n const indexA = textA.indexOf(compareQuery);\n const indexB = textB.indexOf(compareQuery);\n if (indexA !== -1 && indexB === -1)\n return -1;\n if (indexB !== -1 && indexA === -1)\n return 1;\n if (indexA !== -1 && indexB !== -1)\n return indexA - indexB;\n break;\n }\n }\n }\n return textA.localeCompare(textB);\n });\n}\n","import { MenuRoot } from \"./Root\";\nimport { MenuOptions } from \"./Options\";\nimport { MenuOption } from \"./Option\";\nexport { filterAndRankItems } from \"./filterAndRankItems\";\nexport default {\n Root: MenuRoot,\n Options: MenuOptions,\n Option: MenuOption,\n};\n","import { useMemo } from \"react\";\nimport { filterAndRankItems } from \"./filterAndRankItems\";\nexport function useFilteredItems(props) {\n const { query, items, filterBy, filter, sortBy, sortingOptions } = props;\n const filteredItems = useMemo(() => {\n return filterAndRankItems({\n query,\n items,\n filterBy,\n filter,\n sortBy,\n sortingOptions,\n });\n }, [query, items, filterBy, filter, sortBy, sortingOptions]);\n return filteredItems;\n}\n","import { useMemo } from \"react\";\nimport { useMenuContext } from \"./MenuContext\";\nexport function useMenuActions() {\n const { moveUp, moveDown, select } = useMenuContext();\n return useMemo(() => ({\n moveUp,\n moveDown,\n select,\n }), [moveUp, moveDown, select]);\n}\n","import { useEffect } from \"react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useMenuActions } from \"./useMenuActions\";\nimport { COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND } from \"lexical\";\nexport const useLexicalMenuNavigation = () => {\n const menu = useMenuActions();\n const [editor] = useLexicalComposerContext();\n useEffect(() => {\n const handleEvent = (event) => {\n const actions = {\n ArrowDown: () => menu?.moveDown(),\n ArrowUp: () => menu?.moveUp(),\n Enter: () => menu?.select(),\n Tab: () => menu?.select(),\n };\n const action = actions[event.key];\n if (action) {\n action();\n event.preventDefault();\n event.stopPropagation();\n return true;\n }\n return false;\n };\n return editor.registerCommand(KEY_DOWN_COMMAND, handleEvent, COMMAND_PRIORITY_HIGH);\n }, [editor, menu]);\n};\n","import { useLexicalMenuNavigation } from \"./Menu/useLexicalMenuNavigation\";\nexport default function LexicalMenuNavigation() {\n useLexicalMenuNavigation();\n return null;\n}\n","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useEffect, useState } from \"react\";\nimport Menu from \"./Menu\";\nimport { useFilteredItems } from \"./Menu/useFilteredItems\";\nimport { COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport LexicalMenuNavigation from \"./LexicalMenuNavigation\";\n/**\n * Keys that are a modifier's OWN keydown rather than input. A modifier fires its own keydown\n * before the chord (or the shifted character) it is part of arrives, so the menu must sit still\n * for it: closing here would end the menu mid-chord, e.g. on the Shift of a `\\+w` nested marker.\n */\nconst MODIFIER_KEYS = [\"Shift\", \"Control\", \"Alt\", \"Meta\"];\nexport function NodeSelectionMenu(props) {\n const { options, onSelectOption, onClose, inverse, query: controlledQuery, menuOpenKey, onFilterChange, passthroughKeys, } = props;\n const [editor] = useLexicalComposerContext();\n const isControlled = controlledQuery !== undefined;\n const [query, setQuery] = useState(\"\");\n const localQuery = isControlled ? (controlledQuery ?? \"\") : query;\n const filteredOptions = useFilteredItems({ query: localQuery, items: options, filterBy: \"name\" });\n const handleOptionSelection = (option) => {\n onClose?.();\n if (onSelectOption)\n onSelectOption(option);\n else\n option.action(editor);\n };\n useEffect(() => {\n onFilterChange?.(localQuery, filteredOptions);\n }, [onFilterChange, localQuery, filteredOptions]);\n useEffect(() => {\n return editor.registerCommand(KEY_DOWN_COMMAND, (event) => {\n if (isControlled)\n return false;\n if (passthroughKeys?.includes(event.key))\n return false;\n if (MODIFIER_KEYS.includes(event.key))\n return false;\n if ((event.ctrlKey || event.metaKey || event.altKey) &&\n !event.getModifierState(\"AltGraph\")) {\n // A real chord (Ctrl+Z, Ctrl+C, Cmd+V, Ctrl+A, …) is never query input: ingesting it\n // would append its letter to the filter, and claiming it would leave undo, copy, paste\n // and select-all dead for as long as the menu is open. Close the menu — the marker it\n // was offering is not what the user is reaching for — and let the chord through\n // unclaimed, to whatever handles it. Shift is deliberately absent from the check: a\n // shifted character is still a character, and capitalized markers filter with it —\n // and so is AltGr, which Windows/Linux layouts dispatch as Ctrl+Alt: `@` on a German\n // layout or `ł` on Polish is ordinary character input, not a command chord.\n onClose?.();\n return false;\n }\n const actions = {\n Escape: () => onClose?.(),\n Backspace: () => {\n if (localQuery.length === 0) {\n onClose?.();\n }\n else {\n setQuery((prev) => prev.slice(0, -1));\n }\n },\n };\n const action = actions[event.key];\n if (action) {\n event.stopPropagation();\n event.preventDefault();\n action();\n return true;\n }\n else if (event.key.length === 1) {\n event.stopPropagation();\n event.preventDefault();\n if (event.key !== menuOpenKey)\n setQuery((prev) => prev + event.key);\n return true;\n }\n return false;\n }, COMMAND_PRIORITY_HIGH);\n }, [editor, isControlled, localQuery, menuOpenKey, onClose, passthroughKeys]);\n return (_jsxs(Menu.Root, { className: `autocomplete-menu-container ${inverse ? \"inverse\" : \"\"}`, menuItems: filteredOptions, onSelectOption: (item) => handleOptionSelection(item), children: [!isControlled && _jsx(\"input\", { value: localQuery, type: \"text\", disabled: true }), _jsx(LexicalMenuNavigation, {}), _jsx(Menu.Options, { className: \"autocomplete-menu-options\", autoIndex: false, children: (options) => {\n const mappedOptions = options.map((option, index) => (_jsxs(Menu.Option, { index: index, children: [_jsx(\"span\", { className: \"label\", children: option.label ?? option.name }), _jsx(\"span\", { className: \"description\", children: option.description })] }, option.name)));\n return mappedOptions;\n } })] }));\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { $getSelection, $isRangeSelection } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport FloatingBoxAtCursor from \"../FloatingBox/FloatingBoxAtCursor\";\nimport { NodeSelectionMenu } from \"./NodeSelectionMenu\";\nexport * from \"./Menu\";\nexport * from \"./LexicalMenuNavigation\";\nexport * from \"./NodeSelectionMenu\";\nexport default function NodesMenu({ trigger, items }) {\n const [editor] = useLexicalComposerContext();\n const [isOpen, setIsOpen] = useState(false);\n const handleKeyDown = useCallback((e) => {\n if (e.key === \"Escape\" && isOpen) {\n setIsOpen(false);\n editor.focus();\n }\n else if (e.key === trigger && !isOpen) {\n e.preventDefault();\n setIsOpen(true);\n }\n }, [editor, trigger, isOpen]);\n useEffect(() => {\n return editor.registerRootListener((root) => {\n if (!root)\n return;\n root.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n root.removeEventListener(\"keydown\", handleKeyDown);\n };\n });\n }, [editor, handleKeyDown]);\n // Close the menu when the selection changes\n useEffect(() => {\n return editor.registerUpdateListener(({ prevEditorState, editorState }) => {\n const prevSelection = prevEditorState.read(() => {\n const selection = $getSelection();\n if (!$isRangeSelection(selection))\n return;\n return selection;\n });\n editorState.read(() => {\n const selection = $getSelection();\n if (!$isRangeSelection(selection) || prevSelection?.is(selection))\n return;\n setIsOpen(false);\n });\n });\n }, [editor]);\n return (items && (_jsx(FloatingBoxAtCursor, { isOpen: isOpen, children: ({ placement }) => (_jsx(NodeSelectionMenu, { options: items, onClose: () => setIsOpen(false), inverse: placement === \"top-start\", menuOpenKey: trigger })) })));\n}\n","import { useMemo } from \"react\";\nimport { getMarker } from \"shared\";\n// getMarker() takes a marker string and gets its data from a usfm markers map object that is merged with overwrites that fit the PERF editor context.\n// getMarkerAction() returns a function to generate a LexicalNode and insert it in the editor, this lexical node is a custom node made for the PERF editor\n// NOTE: You can create your own typeahead plugin by creating your own getMarker() and getMarkerAction() functions adapted to your editor needs.\nexport default function useUsfmMarkersForMenu({ scriptureReference, contextMarker, getMarkerAction, }) {\n const markersMenuItems = useMemo(() => {\n if (!contextMarker || !scriptureReference)\n return;\n const marker = getMarker(contextMarker);\n if (!marker?.children)\n return;\n return Object.values(marker.children).flatMap((markers) => markers.map((marker) => {\n const markerData = getMarker(marker);\n const { action } = getMarkerAction(marker, markerData);\n return {\n name: marker,\n label: marker,\n description: markerData?.description ?? \"\",\n action: (editor) => {\n action({ editor, reference: scriptureReference });\n },\n };\n }));\n }, [contextMarker, getMarkerAction, scriptureReference]);\n return { markersMenuItems };\n}\n","/**\n * Where each holdable byte of a read-only decorator is drawn. A decorator's holds are kept in the\n * holdable bytes it stands for (`$readDecoratorHoldableText` in `selection.utils.ts`): its own\n * displayed bytes first, then any it stands for but does not show. Reading a hold maps it onto the\n * text the decorator renders now, so painting covers exactly those characters.\n */\nimport { $isImmutableVerseNode } from \"../../../nodes/usj/ImmutableVerseNode\";\nimport { $decoratorDisplayText, $decoratorRenderedText, $isImmutableChapterNode } from \"shared\";\n/**\n * Where holdable byte `index` of `decorator` renders: an offset into its rendered text,\n * `\"drawn\"` when it is shown but not as text (a caller CSS draws, a hidden caller shown as `*`), or\n * `undefined` when the decorator does not show it.\n */\nexport function $renderedOffsetOf(decorator, index) {\n const rendered = $decoratorRenderedText(decorator);\n if ($isImmutableVerseNode(decorator) || $isImmutableChapterNode(decorator)) {\n // `\\`, then the marker name with its space, then the number, then `\\va`/`\\vp`/`\\ca`/`\\cp`.\n const markerLength = 1 + decorator.getMarker().length + 1;\n const number = decorator.getNumber();\n if (decorator.getShowMarker())\n return index < markerLength + number.length ? index : undefined;\n if (index < markerLength || index >= markerLength + number.length)\n return undefined;\n const at = rendered.indexOf(number);\n return at < 0 ? \"drawn\" : at + index - markerLength;\n }\n const own = $decoratorDisplayText(decorator);\n const lead = own.length - own.trimStart().length;\n const holdable = own.trim().length;\n if (index >= holdable)\n return undefined;\n return own === rendered ? lead + index : \"drawn\";\n}\n","/**\n * Painting part of a display-byte node's text, which no element can do without restructuring the\n * DOM Lexical owns: CSS Custom Highlights (`CSS.highlights`), one per distinct set of annotation\n * class names, styled by the editor itself from the host's own class rules.\n *\n * Hosts style annotations by class (`.editor-typed-mark-external-`, `.annotationId-`,\n * compound and state rules included). A hidden probe element carrying a class set, beside one\n * carrying none, shows which properties those rules set; the ones a highlight can paint are copied\n * into a `::highlight()` rule. A bottom border becomes an underline, the closest a highlight can\n * draw. Every other property (other borders, radius, padding, margin, opacity, fonts, cursor) and\n * `:hover` rules apply only where an element is painted whole. The probes are measured again\n * whenever a stylesheet in `` or the page's theme attributes change.\n */\n/** The page's highlight API, or `undefined` where the browser has none (painting then falls back\n * to whole elements). */\nexport function getHighlightApi() {\n if (typeof CSS === \"undefined\" || typeof Highlight === \"undefined\")\n return undefined;\n if (!(\"highlights\" in CSS))\n return undefined;\n const registry = CSS.highlights;\n return { registry, create: () => new Highlight() };\n}\n/** Each live highlight name's class names, for reading what a registered highlight paints. */\nconst classNamesByHighlight = new Map();\n/** The annotation class names the editor highlight called `name` paints with, if it is one. */\nexport function annotationHighlightClassNames(name) {\n return classNamesByHighlight.get(name);\n}\n/** The properties a `::highlight()` rule can paint besides a text decoration, read in this order. */\nconst HIGHLIGHT_PROPERTIES = [\"background-color\", \"color\", \"text-shadow\"];\n/** A text decoration's longhands, read in this order. */\nconst DECORATION_PROPERTIES = [\n \"text-decoration-line\",\n \"text-decoration-style\",\n \"text-decoration-color\",\n \"text-decoration-thickness\",\n];\nconst DECORATION_STYLES = new Set([\"solid\", \"double\", \"dotted\", \"dashed\", \"wavy\"]);\n/**\n * The `::highlight()` declarations for what `probe`'s classes set beyond `baseline`: only the\n * properties that differ, so an inherited color is never copied over a glyph's own.\n *\n * A decoration counts only when it draws a line: `text-decoration-color` follows `currentcolor`,\n * so a rule that sets only `color` changes it too, and that alone must not stand in for the\n * underline a bottom border becomes.\n */\nexport function highlightDeclarations(probe, baseline) {\n const view = probe.ownerDocument.defaultView;\n if (!view)\n return [];\n const styled = view.getComputedStyle(probe);\n const plain = view.getComputedStyle(baseline);\n const changed = (property) => {\n const value = styled.getPropertyValue(property);\n return value && value !== plain.getPropertyValue(property) ? value : undefined;\n };\n const declarations = [];\n for (const property of HIGHLIGHT_PROPERTIES) {\n const value = changed(property);\n if (value)\n declarations.push(`${property}: ${value}`);\n }\n const line = styled.getPropertyValue(\"text-decoration-line\");\n let decorated = false;\n if (line) {\n if (line !== \"none\" && changed(\"text-decoration-line\")) {\n decorated = true;\n for (const property of DECORATION_PROPERTIES) {\n const value = changed(property);\n if (value)\n declarations.push(`${property}: ${value}`);\n }\n }\n }\n else {\n // Some engines report a decoration only through its shorthand, whose first word is its line.\n const shorthand = changed(\"text-decoration\");\n if (shorthand && !/^none\\b/.test(shorthand)) {\n decorated = true;\n declarations.push(`text-decoration: ${shorthand}`);\n }\n }\n const borderStyle = changed(\"border-bottom-style\");\n if (!decorated && borderStyle && borderStyle !== \"none\") {\n declarations.push(\"text-decoration-line: underline\", `text-decoration-style: ${DECORATION_STYLES.has(borderStyle) ? borderStyle : \"solid\"}`);\n const color = styled.getPropertyValue(\"border-bottom-color\");\n if (color)\n declarations.push(`text-decoration-color: ${color}`);\n const width = styled.getPropertyValue(\"border-bottom-width\");\n if (width)\n declarations.push(`text-decoration-thickness: ${width}`);\n }\n return declarations;\n}\n/**\n * Set apart this copy of the module's highlight names from any other copy's: the highlight\n * registry and the page are shared, and two bundles, or a module a hot reload loads again, each\n * count painters from 0.\n */\nconst MODULE_TOKEN = Math.random().toString(36).slice(2, 10);\nlet nextPainterId = 0;\n/** Partial-text painting for one editor: highlight registration, ranges per leaf, and the\n * translated stylesheet. */\nexport class AnnotationHighlighter {\n api;\n probeParent;\n prefix = `editor-annotation-${MODULE_TOKEN}-${nextPainterId++}`;\n byClassSet = new Map();\n byLeaf = new Map();\n nextName = 0;\n style;\n probes;\n observer;\n renderQueued = false;\n disposed = false;\n /** Each class set's declarations as last measured; cleared when a stylesheet changes. */\n measured = new Map();\n /** What the page's style rules name; cleared when a stylesheet changes. */\n rules;\n /** How many rules each of the page's stylesheets held when `rules` was read. */\n ruleCounts;\n constructor(api, \n /** Where the probes go: beside the editable content, so rules scoped to the editor's\n * container still match them. */\n probeParent) {\n this.api = api;\n this.probeParent = probeParent;\n }\n /** The pieces painted on leaf `key`. */\n leafHighlights(key) {\n return this.byLeaf.get(key) ?? [];\n }\n /** The leaves with painted pieces. */\n leafKeys() {\n return [...this.byLeaf.keys()];\n }\n /**\n * Replace leaf `key`'s painted pieces. The new pieces are added before the old ones are let go,\n * so a class set the leaf keeps using keeps its highlight, name and priority, and the stylesheet\n * is not rewritten.\n */\n setLeaf(key, pieces) {\n const previous = this.byLeaf.get(key) ?? [];\n for (const piece of pieces)\n this.use(piece.classNames).highlight.add(piece.range);\n if (pieces.length > 0)\n this.byLeaf.set(key, pieces);\n else\n this.byLeaf.delete(key);\n this.release(previous, pieces);\n }\n clearLeaf(key) {\n const previous = this.byLeaf.get(key) ?? [];\n this.byLeaf.delete(key);\n this.release(previous, []);\n }\n /** Let go of `pieces`, keeping a range in its class set's highlight while one of `kept` still\n * paints it with that class set; a class set no piece uses any more is unregistered. */\n release(pieces, kept) {\n for (const piece of pieces) {\n const key = classSetKey(piece.classNames);\n const entry = this.byClassSet.get(key);\n if (!entry)\n continue;\n const isKept = kept.some((other) => other.range === piece.range && classSetKey(other.classNames) === key);\n if (!isKept)\n entry.highlight.delete(piece.range);\n if (--entry.uses > 0)\n continue;\n this.api.registry.delete(entry.name);\n classNamesByHighlight.delete(entry.name);\n this.byClassSet.delete(key);\n this.queueRender();\n }\n }\n dispose() {\n for (const key of [...this.byLeaf.keys()])\n this.clearLeaf(key);\n this.disposed = true;\n this.observer?.disconnect();\n this.style?.remove();\n this.probes?.remove();\n }\n use(classNames) {\n const key = classSetKey(classNames);\n let entry = this.byClassSet.get(key);\n if (!entry) {\n const name = `${this.prefix}-${this.nextName++}`;\n const highlight = this.api.create();\n // Later class sets paint above earlier ones, as rules later in a stylesheet would win.\n highlight.priority = this.nextName;\n entry = { name, classNames, highlight, uses: 0 };\n this.byClassSet.set(key, entry);\n this.api.registry.set(name, highlight);\n classNamesByHighlight.set(name, classNames);\n this.queueRender();\n }\n entry.uses++;\n return entry;\n }\n queueRender() {\n if (this.renderQueued)\n return;\n this.renderQueued = true;\n queueMicrotask(() => {\n this.renderQueued = false;\n this.render();\n });\n }\n /** Measure each class set not yet measured and write the stylesheet, when it changed. */\n render() {\n const parent = this.probeParent();\n if (!parent || this.disposed)\n return;\n const document = parent.ownerDocument;\n this.observe(document);\n if (!this.probes?.isConnected || this.probes.parentElement !== parent) {\n this.probes?.remove();\n this.probes = document.createElement(\"div\");\n this.probes.setAttribute(\"aria-hidden\", \"true\");\n this.probes.setAttribute(\"data-editor-annotation-probes\", \"\");\n this.probes.style.cssText =\n \"position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none\";\n parent.append(this.probes);\n }\n const probes = this.probes;\n probes.replaceChildren();\n const baseline = document.createElement(\"span\");\n probes.append(baseline);\n // Every probe goes in before any is read, so the page recalculates styles once, not once per\n // class set.\n const unmeasured = [];\n for (const [key, { classNames }] of this.byClassSet) {\n if (this.measured.has(key))\n continue;\n // A class set no rule names styles nothing: no need to measure it.\n if (!this.isNamedByRule(document, classNames)) {\n this.measured.set(key, []);\n continue;\n }\n const probe = document.createElement(\"span\");\n probe.className = classNames.join(\" \");\n unmeasured.push([key, probe]);\n }\n probes.append(...unmeasured.map(([, probe]) => probe));\n for (const [key, probe] of unmeasured)\n this.measured.set(key, highlightDeclarations(probe, baseline));\n const rules = [];\n for (const [key, { name }] of this.byClassSet) {\n const declarations = this.measured.get(key) ?? [];\n if (declarations.length > 0)\n rules.push(`::highlight(${name}) { ${declarations.join(\"; \")}; }`);\n }\n for (const key of this.measured.keys())\n if (!this.byClassSet.has(key))\n this.measured.delete(key);\n probes.replaceChildren();\n const text = rules.join(\"\\n\");\n if (!this.style?.isConnected) {\n this.style = document.createElement(\"style\");\n this.style.setAttribute(HIGHLIGHT_STYLESHEET_ATTRIBUTE, this.prefix);\n document.head.append(this.style);\n }\n if (this.style.textContent !== text)\n this.style.textContent = text;\n }\n /**\n * Whether any style rule's selector names one of `classNames`. Errs toward yes: a substring match\n * counts, and every class set counts while any rule cannot be read.\n */\n isNamedByRule(document, classNames) {\n if (!this.rules) {\n this.rules = scanRules(pageStylesheets(document));\n this.ruleCounts = ruleCountsOf(document);\n }\n const { selectors, unreadable } = this.rules;\n return (unreadable ||\n classNames.some((name) => selectors.includes(name) || selectors.includes(name.replace(/[^\\w-]/g, \"\\\\$&\"))));\n }\n /**\n * Measure again if a stylesheet's rule count changed since the rules were last read: `insertRule`,\n * `deleteRule` and adopting a stylesheet change no DOM, so no observer sees them. Only each\n * stylesheet's top-level count is compared, which keeps this cheap enough to call on every\n * commit; a rule inserted inside a group rule is seen at the next stylesheet change.\n */\n noticeStylesheetChanges() {\n if (this.disposed || this.ruleCounts === undefined)\n return;\n const document = this.probeParent()?.ownerDocument;\n if (!document || ruleCountsOf(document) === this.ruleCounts)\n return;\n this.forgetStyles();\n }\n forgetStyles() {\n this.measured.clear();\n this.rules = undefined;\n this.ruleCounts = undefined;\n this.queueRender();\n }\n /** Measure again when a stylesheet or the page's theme changes; never for an editor highlight\n * stylesheet (this painter's or another editor's), which only styles highlights. */\n observe(document) {\n if (this.observer)\n return;\n const view = document.defaultView;\n if (!view)\n return;\n this.observer = new view.MutationObserver((records) => {\n const isHighlightStylesheetChange = (record) => {\n if (isInHighlightStylesheet(record.target))\n return true;\n const moved = [...record.addedNodes, ...record.removedNodes];\n return moved.length > 0 && moved.every(isInHighlightStylesheet);\n };\n if (records.every(isHighlightStylesheetChange))\n return;\n this.forgetStyles();\n });\n this.observer.observe(document.head, { childList: true, characterData: true, subtree: true });\n const themed = { attributes: true, attributeFilter: [\"class\", \"style\", \"data-theme\"] };\n this.observer.observe(document.documentElement, themed);\n if (document.body)\n this.observer.observe(document.body, themed);\n }\n}\n/** The attribute on every editor highlight stylesheet, whose value is its painter's prefix. */\nconst HIGHLIGHT_STYLESHEET_ATTRIBUTE = \"data-editor-annotation-highlights\";\n/** Whether `node` is, or is inside, an editor highlight stylesheet. */\nfunction isInHighlightStylesheet(node) {\n for (let current = node; current; current = current.parentNode)\n if (isElement(current) && current.hasAttribute(HIGHLIGHT_STYLESHEET_ATTRIBUTE))\n return true;\n return false;\n}\nfunction isElement(node) {\n return node.nodeType === node.ELEMENT_NODE;\n}\n/** The page's stylesheets: its `]/g, (ch) => {\n if (ch === \"\\n\") return \"\\\\a \";\n if (ch === \"\\r\") return \"\\\\d \";\n if (ch === \"\\f\") return \"\\\\c \";\n if (ch === \"<\") return \"\\\\3C \";\n if (ch === \">\") return \"\\\\3E \";\n return `\\\\${ch}`;\n });\n}\n\n/**\n * Escape a marker for safe use inside the `.usfm_` class selector. `CSS.escape` is the\n * correct tool and is present in the renderer (and every modern browser); the jsdom test env\n * lacks it, so fall back to an equivalent per-character escape. The marker always follows\n * `usfm_`, so it is never at identifier start — the leading-digit case never applies.\n */\nfunction escapeCssIdentifier(value: string): string {\n if (typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\") return CSS.escape(value);\n return value.replace(/[^\\w-]/g, (ch) => `\\\\${ch}`);\n}\n\n/**\n * Characters permitted in a color value — hex (`#0a3`), functional (`rgb(0 0 0 / 50%)`), and named\n * colors. Excludes every declaration/selector/comment breakout character (`;{}:\"'*<>` and `\\`), so\n * a value that passes cannot escape `color: `. Anything else is dropped with a warning.\n */\nconst SAFE_COLOR_REGEX = /^[#\\w().,%/\\s-]+$/;\n\n/**\n * Presence gate for numeric stylesheet fields: emit iff the serializer delivered a value —\n * INCLUDING an explicit 0. PT9's ScrTag cannot distinguish \"unset\" from \"explicitly 0\" (both are\n * the int 0, so CSSCreator.cs gates on `!= 0`/`> 0`), but this wire can: an explicit stylesheet 0\n * (e.g. `\\FirstLineIndent 0`) must EMIT `text-indent: 0` so it overrides the static base sheet's\n * declaration for the marker, while an absent field must emit nothing so the base sheet applies.\n * The wire type says `number | undefined`, but the value crosses a JSON boundary where a host-side\n * null survives parsing, so null is treated as absent too.\n */\nfunction hasValue(value: number | undefined): value is number {\n return value !== undefined && value !== null;\n}\n\n/**\n * `text-align` for each stylesheet justification. A closed table, so only these four values can\n * ever reach the emitted CSS; anything else the wire delivers is dropped rather than interpolated.\n */\nconst JUSTIFICATION_TO_TEXT_ALIGN: Readonly<{ [justification: string]: string | undefined }> = {\n left: \"left\",\n right: \"right\",\n center: \"center\",\n both: \"justify\",\n};\n\n/** Justifications that swap sides in a right-to-left project; the rest are direction-neutral. */\nconst MIRRORED_JUSTIFICATION: Readonly<{ [justification: string]: string | undefined }> = {\n left: \"right\",\n right: \"left\",\n};\n\n/**\n * Appended after every font this sheet names, so a project whose font is unavailable falls back to\n * the Scripture text chain instead of the user agent's default. A bare `font-family: \"\"`\n * would not: the emitted rule outranks the static `.usfm.formatted-font` chain, so there would be\n * nothing left behind it to catch. `usj-nodes.css` defines the property on `.usfm`, which keeps one\n * copy of the chain; the literal `serif` is what remains where that stylesheet is not loaded.\n */\nconst FONT_FALLBACK = \"var(--usj-font-fallback, serif)\";\n\n/**\n * A `font-family` declaration for a stylesheet-declared font, with the fallback chain behind it.\n *\n * `projectDefaultFont` goes between the two for a marker font, so a marker whose own font is\n * unavailable lands on the font the rest of the project's text is already using rather than\n * skipping straight to the Scripture chain — which, in a project whose default font is not Latin,\n * is a visible typeface break mid-verse. Omit it for the base rule, whose font IS that default.\n */\nfunction fontFamilyDeclaration(fontName: string, projectDefaultFont?: string): string {\n const families = [fontName];\n if (projectDefaultFont && projectDefaultFont !== fontName) families.push(projectDefaultFont);\n const names = families.map((family) => `\"${escapeCssString(family)}\"`).join(\", \");\n return `font-family: ${names}, ${FONT_FALLBACK}`;\n}\n\n/** The scope prefix used when none is supplied — see {@link UsjCssOptions.containerSelector}. */\nconst DEFAULT_CONTAINER_SELECTOR = \".editor-input.usfm\";\n\n/**\n * Characters permitted in the container selector — type/class/id/attribute selectors, pseudo-\n * classes, and the combinators. Excludes every rule/comment/element breakout character (`;{}<\\` and\n * `/`), so a value that passes cannot close the rule it prefixes, start a comment, or end a\n * `]/g, (ch) => {\n if (ch === \"\\n\") return \"\\\\a \";\n if (ch === \"\\r\") return \"\\\\d \";\n if (ch === \"\\f\") return \"\\\\c \";\n if (ch === \"<\") return \"\\\\3C \";\n if (ch === \">\") return \"\\\\3E \";\n return `\\\\${ch}`;\n });\n}\n\n/**\n * Escape a marker for safe use inside the `.usfm_` class selector. `CSS.escape` is the\n * correct tool and is present in the renderer (and every modern browser); the jsdom test env\n * lacks it, so fall back to an equivalent per-character escape. The marker always follows\n * `usfm_`, so it is never at identifier start — the leading-digit case never applies.\n */\nfunction escapeCssIdentifier(value: string): string {\n if (typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\") return CSS.escape(value);\n return value.replace(/[^\\w-]/g, (ch) => `\\\\${ch}`);\n}\n\n/**\n * Characters permitted in a color value — hex (`#0a3`), functional (`rgb(0 0 0 / 50%)`), and named\n * colors. Excludes every declaration/selector/comment breakout character (`;{}:\"'*<>` and `\\`), so\n * a value that passes cannot escape `color: `. Anything else is dropped with a warning.\n */\nconst SAFE_COLOR_REGEX = /^[#\\w().,%/\\s-]+$/;\n\n/**\n * Presence gate for numeric stylesheet fields: emit iff the serializer delivered a value —\n * INCLUDING an explicit 0. PT9's ScrTag cannot distinguish \"unset\" from \"explicitly 0\" (both are\n * the int 0, so CSSCreator.cs gates on `!= 0`/`> 0`), but this wire can: an explicit stylesheet 0\n * (e.g. `\\FirstLineIndent 0`) must EMIT `text-indent: 0` so it overrides the static base sheet's\n * declaration for the marker, while an absent field must emit nothing so the base sheet applies.\n * The wire type says `number | undefined`, but the value crosses a JSON boundary where a host-side\n * null survives parsing, so null is treated as absent too.\n */\nfunction hasValue(value: number | undefined): value is number {\n return value !== undefined && value !== null;\n}\n\n/**\n * `text-align` for each stylesheet justification. A closed table, so only these four values can\n * ever reach the emitted CSS; anything else the wire delivers is dropped rather than interpolated.\n */\nconst JUSTIFICATION_TO_TEXT_ALIGN: Readonly<{ [justification: string]: string | undefined }> = {\n left: \"left\",\n right: \"right\",\n center: \"center\",\n both: \"justify\",\n};\n\n/** Justifications that swap sides in a right-to-left project; the rest are direction-neutral. */\nconst MIRRORED_JUSTIFICATION: Readonly<{ [justification: string]: string | undefined }> = {\n left: \"right\",\n right: \"left\",\n};\n\n/**\n * Appended after every font this sheet names, so a project whose font is unavailable falls back to\n * the Scripture text chain instead of the user agent's default. A bare `font-family: \"\"`\n * would not: the emitted rule outranks the static `.usfm.formatted-font` chain, so there would be\n * nothing left behind it to catch. `usj-nodes.css` defines the property on `.usfm`, which keeps one\n * copy of the chain; the literal `serif` is what remains where that stylesheet is not loaded.\n */\nconst FONT_FALLBACK = \"var(--usj-font-fallback, serif)\";\n\n/**\n * A `font-family` declaration for a stylesheet-declared font, with the fallback chain behind it.\n *\n * `projectDefaultFont` goes between the two for a marker font, so a marker whose own font is\n * unavailable lands on the font the rest of the project's text is already using rather than\n * skipping straight to the Scripture chain — which, in a project whose default font is not Latin,\n * is a visible typeface break mid-verse. Omit it for the base rule, whose font IS that default.\n */\nfunction fontFamilyDeclaration(fontName: string, projectDefaultFont?: string): string {\n const families = [fontName];\n if (projectDefaultFont && projectDefaultFont !== fontName) families.push(projectDefaultFont);\n const names = families.map((family) => `\"${escapeCssString(family)}\"`).join(\", \");\n return `font-family: ${names}, ${FONT_FALLBACK}`;\n}\n\n/** The scope prefix used when none is supplied — see {@link UsjCssOptions.containerSelector}. */\nconst DEFAULT_CONTAINER_SELECTOR = \".editor-input.usfm\";\n\n/**\n * Characters permitted in the container selector — type/class/id/attribute selectors, pseudo-\n * classes, and the combinators. Excludes every rule/comment/element breakout character (`;{}<\\` and\n * `/`), so a value that passes cannot close the rule it prefixes, start a comment, or end a\n * `