diff --git a/lib/platform-bible-utils/dist/index.cjs b/lib/platform-bible-utils/dist/index.cjs index 6a240ae4608..51df11e0e83 100644 --- a/lib/platform-bible-utils/dist/index.cjs +++ b/lib/platform-bible-utils/dist/index.cjs @@ -19,7 +19,7 @@ A theme type indicates the kind of theme (e.g. light, dark). Some UI elements us ${Object.entries(r.cssVariables).map(([e,t])=>` --${e}: ${t};`).join(` `)} } -`}function Go(r,e,t){const n=e==null?void 0:e.dataset.themeId;n&&this.document.body.classList.remove(n),this.document.body.classList.add(r.id),e&&this.document.head.removeChild(e);const s=this.document.createElement("style");return s.id=`${Sn}${t?`-${t}`:""}`,s.dataset.themeId=r.id,s.textContent=xn(r),this.document.head.appendChild(s),s}function kn(r){return Object.freeze(r),r==null||Object.getOwnPropertyNames(r).forEach(function(t){r[t]!==null&&(typeof r[t]=="object"||typeof r[t]=="function")&&!Object.isFrozen(r[t])&&kn(r[t])}),r}const _t=kn({version:"3.0.7",schemaRepo:"https://github.com/ubsicap/usx.git",schemaCommit:"6c490bb5675d281b0fa01876fe67f6e3fd50a4ce",markersMapVersion:"1.0.0",usfmToolsCommit:"b3475856e2b7c0f19739d247ae3f3c13cba66215",markers:{add:{type:"char",description:"For a translational addition to the text"},addpn:{type:"char",description:"For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)"},b:{type:"para",description:"Poetry text stanza break (e.g. stanza break)"},bd:{type:"char",description:"A character style, use bold text"},bdit:{type:"char",description:"A character style, use bold + italic text"},bk:{type:"char",description:"For the quoted name of a book"},c:{type:"chapter",leadingAttributes:["number"],attributeMarkers:["ca","cp"]},ca:{type:"char",attributeMarkerAttributeName:"altnumber",isAttributeMarkerFor:["c"],hasStructuralSpaceAfterCloseAttributeMarker:!0,description:"Second (alternate) chapter number"},cat:{type:"char",attributeMarkerAttributeName:"category",isAttributeMarkerFor:["ef","efe","esb","ex","f","fe","x"],description:"Note category (study Bible)"},cd:{type:"para",description:"Chapter Description (Publishing option D, e.g. in Russian Bibles)"},cl:{type:"para",description:'Chapter label used for translations that add a word such as "Chapter"'},cls:{type:"para",description:"Closure of an Epistle"},cp:{type:"para",description:"Published chapter number",attributeMarkerAttributeName:"pubnumber",isAttributeMarkerFor:["c"]},d:{type:"para",description:"A Hebrew text heading, to provide description (e.g. Psalms)"},dc:{type:"char",description:"Deuterocanonical/LXX additions or insertions in the Protocanonical text"},ef:{type:"note",description:"Study note",leadingAttributes:["caller"],attributeMarkers:["cat"]},efe:{type:"note",description:"Extended study endnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},efm:{type:"char",description:"Reference to caller of previous footnote in a study Bible"},em:{type:"char",description:"A character style, use emphasized text style"},esb:{type:"sidebar",independentClosingMarkers:["esbe"],attributeMarkers:["cat"]},esbe:{type:"sidebar",isIndependentClosingMarkerFor:["esb"]},ex:{type:"note",description:"Extended cross reference",leadingAttributes:["caller"],attributeMarkers:["cat"]},f:{type:"note",description:"Footnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},fdc:{type:"char",description:"Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)",isClosingMarkerOptional:!0},fe:{type:"note",description:"Endnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},fig:{type:"figure"},fk:{type:"char",description:"A footnote keyword",isClosingMarkerOptional:!0},fl:{type:"char",description:'A footnote label text item, for marking or "labelling" the type or alternate translation being provided in the note.',isClosingMarkerOptional:!0},fm:{type:"char",description:"Reference to caller of previous footnote"},fp:{type:"char",description:"A Footnote additional paragraph marker",isClosingMarkerOptional:!0},fq:{type:"char",description:"A footnote scripture quote or alternate rendering",isClosingMarkerOptional:!0},fqa:{type:"char",description:"A footnote alternate rendering for a portion of scripture text",isClosingMarkerOptional:!0},fr:{type:"char",description:"The origin reference for the footnote",isClosingMarkerOptional:!0},ft:{type:"char",description:"Footnote text, Protocanon",isClosingMarkerOptional:!0},fv:{type:"char",description:"A verse number within the footnote text"},fw:{type:"char",description:"A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.",isClosingMarkerOptional:!0},h:{type:"para",description:"Running header text for a book"},h1:{type:"para",description:"Running header text (DEPRECATED)"},h2:{type:"para",description:"Running header text, left side of page (DEPRECATED)"},h3:{type:"para",description:"Running header text, right side of page (DEPRECATED)"},ib:{type:"para",description:"Introduction blank line"},id:{type:"book",leadingAttributes:["code"]},ide:{type:"para",description:"File encoding information"},ie:{type:"para",description:"Introduction ending marker"},iex:{type:"para",description:"Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)"},ili:{type:"para",description:"A list entry, level 1 (if single level)"},ili1:{type:"para",description:"A list entry, level 1 (if multiple levels)"},ili2:{type:"para",description:"A list entry, level 2"},im:{type:"para",description:"Introduction prose paragraph, with no first line indent (may occur after poetry)"},imi:{type:"para",description:"Introduction prose paragraph text, indented, with no first line indent"},imq:{type:"para",description:"Introduction prose paragraph, quote from the body text, with no first line indent"},imt:{type:"para",description:`Introduction major title, level 1 (if single level) +`}function Go(r,e,t){const n=e==null?void 0:e.dataset.themeId;n&&this.document.body.classList.remove(n),this.document.body.classList.add(r.id),e&&this.document.head.removeChild(e);const s=this.document.createElement("style");return s.id=`${Sn}${t?`-${t}`:""}`,s.dataset.themeId=r.id,s.textContent=xn(r),this.document.head.appendChild(s),s}function kn(r){return Object.freeze(r),r==null||Object.getOwnPropertyNames(r).forEach(function(t){r[t]!==null&&(typeof r[t]=="object"||typeof r[t]=="function")&&!Object.isFrozen(r[t])&&kn(r[t])}),r}const _t=kn({version:"3.0.7",schemaRepo:"https://github.com/ubsicap/usx.git",schemaCommit:"6c490bb5675d281b0fa01876fe67f6e3fd50a4ce",markersMapVersion:"1.0.0",usfmToolsCommit:"6c7bb8d75eda47893296a635c1e6e0b67165ac7f",markers:{add:{type:"char",description:"For a translational addition to the text"},addpn:{type:"char",description:"For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)"},b:{type:"para",description:"Poetry text stanza break (e.g. stanza break)"},bd:{type:"char",description:"A character style, use bold text"},bdit:{type:"char",description:"A character style, use bold + italic text"},bk:{type:"char",description:"For the quoted name of a book"},c:{type:"chapter",leadingAttributes:["number"],attributeMarkers:["ca","cp"]},ca:{type:"char",attributeMarkerAttributeName:"altnumber",isAttributeMarkerFor:["c"],hasStructuralSpaceAfterCloseAttributeMarker:!0,description:"Second (alternate) chapter number"},cat:{type:"char",attributeMarkerAttributeName:"category",isAttributeMarkerFor:["ef","efe","esb","ex","f","fe","x"],description:"Note category (study Bible)"},cd:{type:"para",description:"Chapter Description (Publishing option D, e.g. in Russian Bibles)"},cl:{type:"para",description:'Chapter label used for translations that add a word such as "Chapter"'},cls:{type:"para",description:"Closure of an Epistle"},cp:{type:"para",description:"Published chapter number",attributeMarkerAttributeName:"pubnumber",isAttributeMarkerFor:["c"]},d:{type:"para",description:"A Hebrew text heading, to provide description (e.g. Psalms)"},dc:{type:"char",description:"Deuterocanonical/LXX additions or insertions in the Protocanonical text"},ef:{type:"note",description:"Study note",leadingAttributes:["caller"],attributeMarkers:["cat"]},efe:{type:"note",description:"Extended study endnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},efm:{type:"char",description:"Reference to caller of previous footnote in a study Bible"},em:{type:"char",description:"A character style, use emphasized text style"},esb:{type:"sidebar",independentClosingMarkers:["esbe"],attributeMarkers:["cat"]},esbe:{type:"sidebar",isIndependentClosingMarkerFor:["esb"]},ex:{type:"note",description:"Extended cross reference",leadingAttributes:["caller"],attributeMarkers:["cat"]},f:{type:"note",description:"Footnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},fdc:{type:"char",description:"Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)",isClosingMarkerOptional:!0},fe:{type:"note",description:"Endnote",leadingAttributes:["caller"],attributeMarkers:["cat"]},fig:{type:"figure"},fk:{type:"char",description:"A footnote keyword",isClosingMarkerOptional:!0},fl:{type:"char",description:'A footnote label text item, for marking or "labelling" the type or alternate translation being provided in the note.',isClosingMarkerOptional:!0},fm:{type:"char",description:"Reference to caller of previous footnote"},fp:{type:"char",description:"A Footnote additional paragraph marker",isClosingMarkerOptional:!0},fq:{type:"char",description:"A footnote scripture quote or alternate rendering",isClosingMarkerOptional:!0},fqa:{type:"char",description:"A footnote alternate rendering for a portion of scripture text",isClosingMarkerOptional:!0},fr:{type:"char",description:"The origin reference for the footnote",isClosingMarkerOptional:!0},ft:{type:"char",description:"Footnote text, Protocanon",isClosingMarkerOptional:!0},fv:{type:"char",description:"A verse number within the footnote text"},fw:{type:"char",description:"A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.",isClosingMarkerOptional:!0},h:{type:"para",description:"Running header text for a book"},h1:{type:"para",description:"Running header text (DEPRECATED)"},h2:{type:"para",description:"Running header text, left side of page (DEPRECATED)"},h3:{type:"para",description:"Running header text, right side of page (DEPRECATED)"},ib:{type:"para",description:"Introduction blank line"},id:{type:"book",leadingAttributes:["code"]},ide:{type:"para",description:"File encoding information"},ie:{type:"para",description:"Introduction ending marker"},iex:{type:"para",description:"Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)"},ili:{type:"para",description:"A list entry, level 1 (if single level)"},ili1:{type:"para",description:"A list entry, level 1 (if multiple levels)"},ili2:{type:"para",description:"A list entry, level 2"},im:{type:"para",description:"Introduction prose paragraph, with no first line indent (may occur after poetry)"},imi:{type:"para",description:"Introduction prose paragraph text, indented, with no first line indent"},imq:{type:"para",description:"Introduction prose paragraph, quote from the body text, with no first line indent"},imt:{type:"para",description:`Introduction major title, level 1 (if single level) Introduction major title, level 1 - (if single level)`},imt1:{type:"para",description:"Introduction major title, level 1 (if multiple levels)"},imt2:{type:"para",description:"Introduction major title, level 2"},imt3:{type:"para",description:"Introduction major title, level 3"},imt4:{type:"para",description:"Introduction major title, level 4 (usually within parenthesis)"},imte:{type:"para",description:"Introduction major title at introduction end, level 1 (if single level)"},imte1:{type:"para",description:"Introduction major title at introduction end, level 1 (if multiple levels)"},imte2:{type:"para",description:"Introduction major title at introduction end, level 2"},io:{type:"para",description:"Introduction outline text, level 1 (if single level)"},io1:{type:"para",description:"Introduction outline text, level 1 (if multiple levels)"},io2:{type:"para",description:"Introduction outline text, level 2"},io3:{type:"para",description:"Introduction outline text, level 3"},io4:{type:"para",description:"Introduction outline text, level 4"},ior:{type:"char",description:"Introduction references range for outline entry; for marking references separately"},iot:{type:"para",description:"Introduction outline title"},ip:{type:"para",description:`Introduction prose paragraph Division or Section introductory paragraph (study Bible)`},ipi:{type:"para",description:"Introduction prose paragraph, indented, with first line indent"},ipq:{type:"para",description:"Introduction prose paragraph, quote from the body text"},ipr:{type:"para",description:"Introduction prose paragraph, right aligned"},iq:{type:"para",description:"Introduction poetry text, level 1 (if single level)"},iq1:{type:"para",description:"Introduction poetry text, level 1 (if multiple levels)"},iq2:{type:"para",description:"Introduction poetry text, level 2"},iq3:{type:"para",description:"Introduction poetry text, level 3"},iqt:{type:"char"},is:{type:"para",description:"Introduction section heading, level 1 (if single level)"},is1:{type:"para",description:"Introduction section heading, level 1 (if multiple levels)"},is2:{type:"para",description:"Introduction section heading, level 2"},it:{type:"char",description:"A character style, use italic text"},jmp:{type:"char",defaultAttribute:"link-href",description:"For associating linking attributes to a span of text"},k:{type:"char",description:"For a keyword"},k1:{type:"para",description:"Concordance main entry text or keyword, level 1"},k2:{type:"para",description:"Concordance main entry text or keyword, level 2"},lf:{type:"para",description:"List footer (introductory remark)"},lh:{type:"para",description:"List header (introductory remark)"},li:{type:"para",description:"A list entry, level 1 (if single level)"},li1:{type:"para",description:"A list entry, level 1 (if multiple levels)"},li2:{type:"para",description:"A list entry, level 2"},li3:{type:"para",description:"A list entry, level 3"},li4:{type:"para",description:"A list entry, level 4"},lik:{type:"char",description:"Structured list entry key text"},lim:{type:"para",description:"An embedded list entry, level 1 (if single level)"},lim1:{type:"para",description:"An embedded list entry, level 1 (if multiple levels)"},lim2:{type:"para",description:"An embedded list entry, level 2"},lim3:{type:"para",description:"An embedded list entry, level 3"},lim4:{type:"para",description:"An embedded list entry, level 4"},lit:{type:"para",description:"For a comment or note inserted for liturgical use"},litl:{type:"char",description:"List entry total text"},liv:{type:"char",description:"Structured list entry value 1 content (if single value)"},liv1:{type:"char",description:"Structured list entrt value 1 content (if multiple values)"},liv2:{type:"char",description:"Structured list entry value 2 content"},liv3:{type:"char",description:"Structured list entry value 3 content"},liv4:{type:"char",description:"Structured list entry value 4 content"},liv5:{type:"char",description:"Structured list entry value 5 content"},m:{type:"para",description:"Paragraph text, with no first line indent (may occur after poetry) aka: Paragraph Continuation"},mi:{type:"para",description:"Paragraph text, indented, with no first line indent; often used for discourse"},mr:{type:"para",description:"A major section division references range heading"},ms:{type:"para",description:"A major section division heading, level 1 (if single level)"},ms1:{type:"para",description:"A major section division heading, level 1 (if multiple levels)"},ms2:{type:"para",description:"A major section division heading, level 2"},ms3:{type:"para",description:"A major section division heading, level 3"},mt:{type:"para",description:"The main title of the book (if single level)"},mt1:{type:"para",description:"The main title of the book (if multiple levels)"},mt2:{type:"para",description:"A secondary title usually occurring before the main title"},mt3:{type:"para",description:"A tertiary title occurring after the main title"},mt4:{type:"para",description:`Introduction major title, level 1 (if single level) A small secondary title sometimes occuring within parentheses`},mte:{type:"para",description:"The main title of the book repeated at the end of the book, level 1 (if single level)"},mte1:{type:"para",description:"The main title of the book repeat /ed at the end of the book, level 1 (if multiple levels)"},mte2:{type:"para",description:"A secondary title occurring before or after the 'ending' main title"},nb:{type:"para",description:"Paragraph text, with no break from previous paragraph text (at chapter boundary)"},nd:{type:"char",description:"For name of deity"},ndx:{type:"char",description:"A subject index text item"},no:{type:"char",description:"A character style, use normal text"},optbreak:{type:"optbreak"},ord:{type:"char",description:"For the text portion of an ordinal number"},p:{type:"para",description:`Paragraph text, with first line indent diff --git a/lib/platform-bible-utils/dist/index.cjs.map b/lib/platform-bible-utils/dist/index.cjs.map index 20331ed3cf2..c9dbf5c4516 100644 --- a/lib/platform-bible-utils/dist/index.cjs.map +++ b/lib/platform-bible-utils/dist/index.cjs.map @@ -1 +1 @@ -{"version":3,"file":"index.cjs","sources":["../src/promises/async-variable.ts","../src/intl/intl-collator.ts","../src/intl/intl-date-time-format.ts","../src/events/platform-event-emitter.model.ts","../src/util.ts","../src/document-combiner.ts","../src/event-rolling-time-counter.ts","../src/promises/mutex.ts","../src/promises/mutex-map.ts","../src/non-validating-document-combiner.ts","../src/intl/intl-number-format.ts","../src/promises/promise-chaining-map.ts","../src/sorted-number-map.ts","../src/sorted-set.ts","../src/lifetime-management/unsubscriber-async-list.ts","../src/platform-error.ts","../../../node_modules/@sillsdev/scripture/dist/index.es.js","../node_modules/@xmldom/xmldom/lib/conventions.js","../node_modules/@xmldom/xmldom/lib/errors.js","../node_modules/@xmldom/xmldom/lib/grammar.js","../node_modules/@xmldom/xmldom/lib/dom.js","../node_modules/@xmldom/xmldom/lib/entities.js","../node_modules/@xmldom/xmldom/lib/sax.js","../node_modules/@xmldom/xmldom/lib/dom-parser.js","../node_modules/@xmldom/xmldom/lib/index.js","../node_modules/@eten-tech-foundation/scripture-utilities/dist/index.js","../../../node_modules/char-regex/index.js","../../../node_modules/stringz/dist/index.js","../src/array-util.ts","../src/string-util.ts","../src/scripture/scripture-util.ts","../src/lifetime-management/unsubscriber.ts","../src/scripture/usj-reader-writer.model.ts","../src/scripture/footnote-util.ts","../src/pane-utils.ts","../../../node_modules/fast-equals/dist/esm/index.mjs","../src/equality-checking.ts","../src/subset-checking.ts","../src/serialization.ts","../src/intl/intl-util.ts","../src/number-utils.ts","../src/date-time-format-util.ts","../src/keyboard-util.ts","../src/extension-contributions/settings.model.ts","../src/extension-contributions/localized-strings.model.ts","../src/extension-contributions/menus.model.ts","../src/extension-contributions/theme.model.ts","../src/extension-contributions/theme.util.ts","../src/scripture/markers-maps/markers-map-3.0.model.ts","../src/scripture/usj-reader-writer.ts"],"sourcesContent":["/** This class provides a convenient way for one task to wait on a variable that another task sets. */\nexport class AsyncVariable {\n private static verboseLoggingEnabled: boolean = false;\n private readonly variableName: string;\n private readonly promiseToValue: Promise;\n private timeoutId: ReturnType | undefined;\n private timeoutOccurred: boolean;\n private resolver: ((value: T) => void) | undefined;\n private rejecter: ((reason: string | undefined) => void) | undefined;\n\n /**\n * Creates an instance of the class\n *\n * @param variableName Name to use when logging about this variable\n * @param rejectIfNotSettledWithinMS Milliseconds to wait before verifying if the promise was\n * settled (resolved or rejected); will reject if it has not settled by that time. Use -1 if you\n * do not want a timeout at all. Defaults to 10000 ms\n */\n constructor(variableName: string, rejectIfNotSettledWithinMS: number = 10000) {\n this.variableName = variableName;\n this.timeoutOccurred = false;\n this.promiseToValue = new Promise((resolve, reject) => {\n this.resolver = resolve;\n this.rejecter = reject;\n });\n if (rejectIfNotSettledWithinMS > 0) {\n this.timeoutId = setTimeout(() => {\n if (this.rejecter) {\n this.rejecter(`Timeout reached when waiting for ${this.variableName} to settle`);\n this.timeoutOccurred = true;\n this.complete();\n }\n }, rejectIfNotSettledWithinMS);\n }\n Object.seal(this);\n }\n\n /**\n * Get this variable's promise to a value. This always returns the same promise even after the\n * value has been resolved or rejected.\n *\n * @returns The promise for the value to be set\n */\n get promise(): Promise {\n return this.promiseToValue;\n }\n\n /**\n * A simple way to see if this variable's promise was resolved or rejected already\n *\n * @returns Whether the variable was already resolved or rejected\n */\n get hasSettled(): boolean {\n return Object.isFrozen(this);\n }\n\n /**\n * Can use to determine if a rejection occurred due to a timeout\n *\n * @returns Whether the variable timed out while waiting for a value to resolve\n */\n get hasTimedOut(): boolean {\n return this.timeoutOccurred;\n }\n\n /**\n * Allows enabling more verbose logging when async variables resolve and reject\n *\n * @param enabled Whether to enable verbose logging\n */\n static setVerboseLogging(enabled: boolean): void {\n this.verboseLoggingEnabled = enabled;\n }\n\n /**\n * Resolve this variable's promise to the given value\n *\n * @param value This variable's promise will resolve to this value\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n resolveToValue(value: T, throwIfAlreadySettled: boolean = false): void {\n if (this.resolver) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being resolved now`);\n this.resolver(value);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent resolution of ${this.variableName}`);\n }\n }\n\n /**\n * Reject this variable's promise for the value with the given reason\n *\n * @param reason This variable's promise will be rejected with this reason\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n rejectWithReason(reason: string, throwIfAlreadySettled: boolean = false): void {\n if (this.rejecter) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being rejected now with reason: ${reason}`);\n this.rejecter(reason);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent rejection of ${this.variableName}`);\n }\n }\n\n /** Prevent any further updates to this variable */\n private complete(): void {\n this.resolver = undefined;\n this.rejecter = undefined;\n if (this.timeoutId !== undefined) {\n clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n Object.freeze(this);\n }\n}\n\nexport default AsyncVariable;\n","/** Enables language-sensitive string comparison. Wraps Intl.Collator */\nexport class Collator {\n private collator: Intl.Collator;\n\n constructor(locales?: string | string[], options?: Intl.CollatorOptions) {\n this.collator = new Intl.Collator(locales, options);\n }\n\n /**\n * Compares two strings according to the sort order of this Collator object\n *\n * @param string1 String to compare\n * @param string2 String to compare\n * @returns A number indicating how string1 and string2 compare to each other according to the\n * sort order of this Collator object. Negative value if string1 comes before string2. Positive\n * value if string1 comes after string2. 0 if they are considered equal.\n */\n compare(string1: string, string2: string): number {\n return this.collator.compare(string1, string2);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and collation options computed\n * during initialization of this collator object.\n *\n * @returns ResolvedCollatorOptions object\n */\n resolvedOptions(): Intl.ResolvedCollatorOptions {\n return this.collator.resolvedOptions();\n }\n}\n\nexport default Collator;\n","/** Enables language-sensitive data and time formatting. Wraps Intl.DateTimeFormat */\nexport class DateTimeFormat {\n private dateTimeFormatter: Intl.DateTimeFormat;\n\n constructor(locales?: string | string[], options?: Intl.DateTimeFormatOptions) {\n this.dateTimeFormatter = new Intl.DateTimeFormat(locales, options);\n }\n\n /**\n * Formats a date according to the locale and formatting option for this DateTimeFormat object\n *\n * @param date The date to format\n * @returns String representing the given date formatted according to the locale and formatting\n * options of this DateTimeFormat object\n */\n format(date: Date): string {\n return this.dateTimeFormatter.format(date);\n }\n\n /**\n * Formats a date range in the most concise way based on the locales and options provided when\n * instantiating this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns String representing the given date range formatted according to the locale and\n * formatting options of this DateTimeFormat object\n */\n formatRange(startDate: Date, endDate: Date): string {\n return this.dateTimeFormatter.formatRange(startDate, endDate);\n }\n\n /**\n * Returns an array of locale-specific tokens representing each part of the formatted date range\n * produced by this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns Array of DateTimeRangeFormatPart objects\n */\n formatRangeToParts(startDate: Date, endDate: Date): Intl.DateTimeRangeFormatPart[] {\n return this.dateTimeFormatter.formatRangeToParts(startDate, endDate);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this DateTimeFormat object\n *\n * @param date The date to format\n * @returns Array of DateTimeFormatPart objects\n */\n formatToParts(date: Date): Intl.DateTimeFormatPart[] {\n return this.dateTimeFormatter.formatToParts(date);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and date and time formatting options\n * computed during initialization of this DateTimeFormat object\n *\n * @returns ResolvedDateTimeFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n return this.dateTimeFormatter.resolvedOptions();\n }\n}\n\nexport default DateTimeFormat;\n","/** Interfaces, classes, and functions related to events and event emitters */\n\nimport { Dispose } from '../lifetime-management/disposal.model';\nimport { PlatformEvent, PlatformEventHandler } from './platform-event';\n\n/**\n * Event manager - accepts subscriptions to an event and runs the subscription callbacks when the\n * event is emitted Use eventEmitter.event(callback) to subscribe to the event. Use\n * eventEmitter.emit(event) to run the subscriptions. Generally, this EventEmitter should be\n * private, and its event should be public. That way, the emitter is not publicized, but anyone can\n * subscribe to the event.\n */\nexport class PlatformEventEmitter implements Dispose {\n /**\n * Subscribes a function to run when this event is emitted.\n *\n * @param callback Function to run with the event when it is emitted\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n subscribe = this.event;\n\n /** All callback functions that will run when this event is emitted. Lazy loaded */\n private subscriptions?: PlatformEventHandler[];\n /** Event for listeners to subscribe to. Lazy loaded */\n private lazyEvent?: PlatformEvent;\n /** Whether this emitter has been disposed */\n private isDisposed = false;\n\n /**\n * Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.\n * Use like `const unsubscriber = event(callback)`\n *\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n get event(): PlatformEvent {\n this.assertNotDisposed();\n\n if (!this.lazyEvent) {\n this.lazyEvent = (callback) => {\n if (!callback || typeof callback !== 'function')\n throw new Error(`Event handler callback must be a function!`);\n\n // Initialize this.subscriptions if it does not exist\n if (!this.subscriptions) this.subscriptions = [];\n\n this.subscriptions.push(callback);\n\n return () => {\n if (!this.subscriptions) return false; // Did not find any subscribed callbacks\n\n const callbackIndex = this.subscriptions.indexOf(callback);\n\n if (callbackIndex < 0) return false; // Did not find this callback in the subscriptions\n\n // Remove the callback\n this.subscriptions.splice(callbackIndex, 1);\n\n return true;\n };\n };\n }\n return this.lazyEvent;\n }\n\n /** Disposes of this event, preparing it to release from memory */\n dispose = () => {\n return this.disposeFn();\n };\n\n /**\n * Runs the subscriptions for the event\n *\n * @param event Event data to provide to subscribed callbacks\n */\n emit = (event: T) => {\n // Do not do anything other than emitFn here. This emit is just binding `this` to emitFn\n this.emitFn(event);\n };\n\n /**\n * Function that runs the subscriptions for the event. Added here so children can override emit\n * and still call the base functionality. See NetworkEventEmitter.emit for example\n */\n protected emitFn(event: T) {\n this.assertNotDisposed();\n\n // Clone the subscriptions array before iterating over the callbacks so the callback index\n // doesn't get messed up if someone subscribes or unsubscribes inside one of the callbacks\n const emitCallbacks = [...(this.subscriptions ?? [])];\n emitCallbacks.forEach((callback) => callback(event));\n }\n\n /** Check to make sure this emitter is not disposed. Throw if it is */\n protected assertNotDisposed() {\n if (this.isDisposed) throw new Error('Emitter is disposed');\n }\n\n /**\n * Disposes of this event, preparing it to release from memory. Added here so children can\n * override emit and still call the base functionality.\n */\n protected disposeFn() {\n this.assertNotDisposed();\n\n this.isDisposed = true;\n this.subscriptions = undefined;\n this.lazyEvent = undefined;\n return Promise.resolve(true);\n }\n}\n\nexport default PlatformEventEmitter;\n","/** Collection of functions, objects, and types that are used as helpers in other services. */\n\n// Thanks to blubberdiblub at https://stackoverflow.com/a/68141099/217579\nexport function newGuid(): string {\n return '00-0-4-1-000'.replace(/[^-]/g, (s) =>\n // @ts-expect-error ts(2363) this works fine\n // eslint-disable-next-line no-bitwise\n (((Math.random() + ~~s) * 0x10000) >> s).toString(16).padStart(4, '0'),\n );\n}\n\n// thanks to DRAX at https://stackoverflow.com/a/9436948\n/**\n * Determine whether the object is a string\n *\n * @param o Object to determine if it is a string\n * @returns True if the object is a string; false otherwise\n */\nexport function isString(o: unknown): o is string {\n return typeof o === 'string' || o instanceof String;\n}\n\n/**\n * If deepClone isn't used when copying properties between objects, you may be left with dangling\n * references between the source and target of property copying operations.\n *\n * @param obj Object to clone\n * @returns Duplicate copy of `obj` without any references back to the original one\n */\nexport function deepClone(obj: T): T {\n // Assert the return type matches what is expected\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\n/**\n * Get a function that reduces calls to the function passed in\n *\n * @template T - A function type that takes any arguments and returns void. This is the type of the\n * function being debounced.\n * @param fn The function to debounce\n * @param delay How much delay in milliseconds after the most recent call to the debounced function\n * to call the function\n * @returns Function that, when called, only calls the function passed in at maximum every delay ms\n */\n// We don't know the parameter types since this function can be anything and can return anything\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce any>(\n fn: TFunc,\n delay = 300,\n): (...args: Parameters) => Promise> {\n let timeout: ReturnType;\n let promise: Promise> | undefined;\n let promiseResolve: (value: ReturnType | PromiseLike>) => void;\n let promiseReject: (reason?: unknown) => void;\n\n return (...args) => {\n clearTimeout(timeout);\n if (!promise)\n promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n timeout = setTimeout(async () => {\n try {\n promiseResolve(await fn(...args));\n } catch (e) {\n promiseReject(e);\n } finally {\n promise = undefined;\n }\n }, delay);\n\n return promise;\n };\n}\n\n/**\n * Groups each item in the array of items into a map according to the keySelector\n *\n * There are two overloads:\n *\n * - `groupBy(items, keySelector)` – groups the original items using the key returned by\n * `keySelector`.\n * - `groupBy(items, keySelector, valueSelector)` – groups transformed values using the key returned\n * by `keySelector` and the value returned by `valueSelector`.\n *\n * If `valueSelector` is not provided, the original item is used in the resulting groups.\n *\n * @param items - Array of items to group by.\n * @param keySelector - Function to run on each item to get the key for the group to which it\n * belongs. The first argument is the item, and the second argument is the index of the item in\n * the original array.\n * @param valueSelector - Optional function to run on each item to get the value to store in the\n * group. The first argument is the item, the second argument is the key for the group to which\n * this item belongs, and the third argument is the index of the item in the original array.\n * @returns Map of keys to groups of values corresponding to each item.\n */\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector: (item: T, key: K, index: number) => V,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector?: (item: T, key: K, index: number) => V,\n): Map> {\n const map = new Map>();\n items.forEach((item, index) => {\n const key = keySelector(item, index);\n const group = map.get(key);\n const value = valueSelector ? valueSelector(item, key, index) : item;\n if (group) group.push(value);\n else map.set(key, [value]);\n });\n return map;\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\ntype ErrorWithMessage = {\n message: string;\n};\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return (\n typeof error === 'object' &&\n // We're potentially dealing with objects we didn't create, so they might contain `null`\n // eslint-disable-next-line no-null/no-null\n error !== null &&\n 'message' in error &&\n // Type assert `error` to check it's `message`.\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n typeof (error as Record).message === 'string'\n );\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error from the object (useful for getting an error in a catch block)\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n // fallback in case there's an error stringifying the maybeError\n // like with circular references for example.\n return new Error(String(maybeError));\n }\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error message from the object (useful for getting error message in a catch\n * block)\n *\n * @example `try {...} catch (e) { logger.info(getErrorMessage(e)) }`\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\n/** Asynchronously waits for the specified number of milliseconds. (wraps setTimeout in a promise) */\nexport function wait(ms: number) {\n // eslint-disable-next-line no-promise-executor-return\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Runs the specified function and will timeout if it takes longer than the specified wait time\n *\n * @param fn The function to run\n * @param maxWaitTimeInMS The maximum amount of time to wait for the function to resolve\n * @returns Promise that resolves to the resolved value of the function or undefined if it ran\n * longer than the specified wait time\n */\nexport function waitForDuration(fn: () => Promise, maxWaitTimeInMS: number) {\n const timeout = wait(maxWaitTimeInMS).then(() => undefined);\n return Promise.any([timeout, fn()]);\n}\n\n/**\n * Get all functions on an object and its prototype chain (so we don't miss any class methods or any\n * object methods). Note that the functions on the final item in the prototype chain (i.e., Object)\n * are skipped to avoid including functions like `__defineGetter__`, `__defineSetter__`, `toString`,\n * etc.\n *\n * @param obj Object whose functions to get\n * @param _objId Optional ID of the object to use for debug logging\n * @returns Array of all function names on an object\n */\n// Note: lodash has something that MIGHT do the same thing as this. Investigate for https://github.com/paranext/paranext-core/issues/134\nexport function getAllObjectFunctionNames(\n obj: { [property: string]: unknown },\n // Leaving it here for debugging\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _objId: string = 'obj',\n): Set {\n const objectFunctionNames = new Set();\n\n // Get all function properties directly defined on the object\n Object.getOwnPropertyNames(obj).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId} due to error: ${error}`);\n }\n });\n\n // Walk up the prototype chain and get additional function properties, skipping the functions\n // provided by the final (Object) prototype\n let objectPrototype = Object.getPrototypeOf(obj);\n while (objectPrototype && Object.getPrototypeOf(objectPrototype)) {\n Object.getOwnPropertyNames(objectPrototype).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId}'s prototype due to error: ${error}`);\n }\n });\n objectPrototype = Object.getPrototypeOf(objectPrototype);\n }\n\n return objectFunctionNames;\n}\n\n/**\n * Creates a synchronous proxy for an asynchronous object. The proxy allows calling methods on an\n * object that is asynchronously fetched using a provided asynchronous function.\n *\n * @param getObject - A function that returns a promise resolving to the object whose asynchronous\n * methods to call.\n * @param objectToProxy - An optional object that is the object that is proxied. If a property is\n * accessed that does exist on this object, it will be returned. If a property is accessed that\n * does not exist on this object, it will be considered to be an asynchronous method called on the\n * object returned from getObject.\n * @returns A synchronous proxy for the asynchronous object.\n */\nexport function createSyncProxyForAsyncObject(\n getObject: (args?: unknown[]) => Promise,\n objectToProxy: Partial = {},\n): T {\n // objectToProxy will have only the synchronously accessed properties of T on it, and this proxy\n // makes the async methods that do not exist yet available synchronously so we have all of T\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return new Proxy(objectToProxy as T, {\n get(target, prop) {\n // We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // @ts-expect-error 7053\n if (prop in target) return target[prop];\n return async (...args: unknown[]) => {\n // 7053: We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // 2556: The args here are the parameters for the method specified\n // @ts-expect-error 7053 2556\n return (await getObject())[prop](...args);\n };\n },\n });\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that Paratext is blocking internet access.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates Paratext is blocking internet access, `false` otherwise\n */\nexport function isErrorMessageAboutParatextBlockingInternetAccess(errorMessage: unknown): boolean {\n // Copied from ParatextData/InternetAccess.cs, not a localized string\n const paratextExceptionMessage =\n 'Bug in Paratext caused attempted access to Internet. Request has been blocked.';\n\n if (isString(errorMessage)) return errorMessage.includes(paratextExceptionMessage);\n return getErrorMessage(errorMessage).includes(paratextExceptionMessage);\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that an authorization failure occurred regarding registry credentials.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates an auth failure, `false` otherwise\n */\nexport function isErrorMessageAboutRegistryAuthFailure(errorMessage: unknown): boolean {\n // Copied from ParatextProjectSendReceiveService.cs, not a localized string\n const paratextExceptionMessage1 = '401 Unauthorized error while getting shared projects.';\n // Copied from DblDownloadableDataProvider.cs, not a localized string\n const paratextExceptionMessage2 =\n 'User registration is not valid. Cannot retrieve resources from DBL.';\n\n const errorString = isString(errorMessage) ? errorMessage : getErrorMessage(errorMessage);\n return (\n errorString.includes(paratextExceptionMessage1) ||\n errorString.includes(paratextExceptionMessage2)\n );\n}\n\n/** Within type T, recursively change all properties to be optional */\nexport type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T;\n\n/** Within type T, recursively change properties that were of type A to be of type B */\nexport type ReplaceType = T extends A\n ? B\n : T extends object\n ? { [K in keyof T]: ReplaceType }\n : T;\n\n/**\n * Converts a string type from camelCase to kebab-case. Note this simply inserts hyphens before\n * uppercase letters and converts them to lowercase. It does not handle special cases like acronyms\n * or symbols. It can result in multiple hyphens in a row, leading hyphens, or trailing hyphens.\n *\n * By using this as the type for a string parameter or string property, you can enforce (somewhat)\n * at compile time that the string is in kebab-case format assuming it is provided as a string\n * literal.\n *\n * @example\n *\n * ```typescript\n * type Kebab1 = KebabCase<'backgroundColor'>; // 'background-color'\n * type Kebab2 = KebabCase<'HTMLParser'>; // '-h-t-m-l-parser'\n * type Kebab3 = KebabCase<'simpletest'>; // 'simpletest'\n * type Kebab4 = KebabCase<'My$Value'>; // '-my$-value'\n * ```\n */\nexport type KebabCase = T extends `${infer First}${infer Rest}`\n ? `${First extends Lowercase ? First : `-${Lowercase}`}${KebabCase}`\n : T;\n\n// Thanks to jcalz at https://stackoverflow.com/a/50375286\n/**\n * Converts a union type to an intersection type (`|` to `&`).\n *\n * Note: this utility type is for use on object types. It may fail on other types.\n *\n * @example\n *\n * ```typescript\n * type TypeOne = { one: string };\n * type TypeTwo = { two: number };\n * type TypeThree = { three: string };\n *\n * type TypeNums = { one: TypeOne; two: TypeTwo; three: TypeThree };\n * const numNames = ['one', 'two'] as const;\n * type TypeNumNames = typeof numNames;\n *\n * // Same as `TypeOne | TypeTwo`\n * // `{ one: string } | { two: number }`\n * type TypeOneTwoUnion = TypeNums[TypeNumNames[number]];\n *\n * // Same as `TypeOne & TypeTwo`\n * // `{ one: string; two: number }`\n * type TypeOneTwoIntersection = UnionToIntersection;\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (\n x: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Force VSCode to expand all the properties of a type by using this type. Useful for making complex\n * types more readable in hover tooltips.\n *\n * @example\n *\n * ```ts\n * type MyType = Prettify;\n * ```\n */\nexport type Prettify = {\n [K in keyof T]: T[K];\n} & {};\n","import { PlatformEventEmitter } from './events/platform-event-emitter.model';\nimport { deepClone } from './util';\n\ntype JsonObjectLike = { [key: string]: unknown };\ntype JsonArrayLike = unknown[];\n\nexport type JsonDocumentLike = JsonObjectLike | JsonArrayLike;\n\n/**\n * Options for DocumentCombiner objects\n *\n * - `copyDocuments`: If true, this instance will perform a deep copy of all provided documents before\n * composing the output. If false, then changes made to provided documents after they are\n * contributed will be reflected in the next time output is composed.\n * - `ignoreDuplicateProperties`: If true, then duplicate properties are skipped if they are seen in\n * contributed documents. If false, then throw when duplicate properties are seen in contributed\n * documents.\n */\nexport type DocumentCombinerOptions = {\n copyDocuments: boolean;\n ignoreDuplicateProperties: boolean;\n};\n\n/**\n * Base class for any code that wants to compose JSON documents (primarily in the form of JS objects\n * or arrays) together into a single output document.\n */\nexport class DocumentCombiner {\n protected baseDocument: JsonDocumentLike;\n protected readonly contributions = new Map();\n protected latestOutput: JsonDocumentLike | undefined;\n protected readonly options: DocumentCombinerOptions;\n private readonly onDidRebuildEmitter = new PlatformEventEmitter();\n /** Event that emits to announce that the document has been rebuilt and the output has been updated */\n // Need `onDidRebuildEmitter` to be instantiated before this line\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly onDidRebuild = this.onDidRebuildEmitter.subscribe;\n\n /**\n * Create a DocumentCombiner instance\n *\n * @param baseDocument This is the first document that will be used when composing the output\n * @param options Options used by this object when combining documents\n */\n protected constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n // Setting baseDocument redundantly because TS doesn't understand that updateBaseDocument does it\n this.baseDocument = baseDocument;\n this.options = options;\n this.updateBaseDocument(baseDocument);\n }\n\n /**\n * Update the starting document for composition process\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n * @returns Recalculated output document given the new starting state and existing other documents\n */\n updateBaseDocument(baseDocument: JsonDocumentLike): JsonDocumentLike | undefined {\n this.validateBaseDocument(baseDocument);\n this.baseDocument = this.options.copyDocuments ? deepClone(baseDocument) : baseDocument;\n this.baseDocument = this.transformBaseDocumentAfterValidation(this.baseDocument);\n return this.rebuild();\n }\n\n /**\n * Add or update one of the contribution documents for the composition process\n *\n * Note: the order in which contribution documents are added can be considered indeterminate as it\n * depends on the order in which `Map.forEach` iterates over the contributions. However, the order\n * matters when merging two arrays into one. Also, when `options.ignoreDuplicateProperties` is is\n * `true`, the order also matters when adding the same property to an object that is already\n * provided previously. Please let us know if you have trouble because of indeterminate\n * contribution ordering.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n * @returns Recalculated output document given the new or updated contribution and existing other\n * documents\n */\n addOrUpdateContribution(\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike | undefined {\n this.validateContribution(documentName, document);\n const previousDocumentVersion = this.contributions.get(documentName);\n let documentToSet = this.options.copyDocuments && !!document ? deepClone(document) : document;\n documentToSet = this.transformContributionAfterValidation(documentName, documentToSet);\n this.contributions.set(documentName, documentToSet);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after adding/updating the contribution, put it back how it was\n if (previousDocumentVersion) this.contributions.set(documentName, previousDocumentVersion);\n else this.contributions.delete(documentName);\n throw new Error(`Error when setting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete one of the contribution documents for the composition process\n *\n * @param documentName Name of the contributed document to delete\n * @returns Recalculated output document given the remaining other documents\n */\n deleteContribution(documentName: string): JsonDocumentLike | undefined {\n const document = this.contributions.get(documentName);\n if (!document) throw new Error(`${documentName} does not exist`);\n this.contributions.delete(documentName);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting the contribution, put it back and rethrow\n this.contributions.set(documentName, document);\n throw new Error(`Error when deleting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete all present contribution documents for the composition process and return to the base\n * document\n *\n * @returns Recalculated output document consisting only of the base document\n */\n deleteAllContributions(): JsonDocumentLike | undefined {\n if (this.contributions.size <= 0) return this.latestOutput;\n\n // Save out all contributions\n const contributions = [...this.contributions.entries()];\n\n // Delete all contributions\n contributions.forEach(([contributionName]) => this.contributions.delete(contributionName));\n\n // Rebuild with no contributions\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting all contributions, put them back and rethrow\n contributions.forEach(([contributionName, document]) =>\n this.contributions.set(contributionName, document),\n );\n throw new Error(`Error when deleting all contributions: ${error}`);\n }\n }\n\n /**\n * Run the document composition process given the starting document and all contributions. Throws\n * if the output document fails to validate properly.\n *\n * @returns Recalculated output document given the starting and contributed documents\n */\n rebuild(): JsonDocumentLike | undefined {\n // The starting document is the output if there are no other contributions\n if (this.contributions.size === 0) {\n let potentialOutput = deepClone(this.baseDocument);\n potentialOutput = this.transformFinalOutputBeforeValidation(potentialOutput);\n this.validateOutput(potentialOutput);\n this.latestOutput = potentialOutput;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n // Compose the output by validating each document one at a time to pinpoint errors better\n let outputIteration = this.baseDocument;\n this.contributions.forEach((contribution: JsonDocumentLike) => {\n outputIteration = mergeObjects(\n outputIteration,\n contribution,\n this.options.ignoreDuplicateProperties,\n );\n this.validateOutput(outputIteration);\n });\n outputIteration = this.transformFinalOutputBeforeValidation(outputIteration);\n this.validateOutput(outputIteration);\n this.latestOutput = outputIteration;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n /**\n * Transform the starting document that is given to the combiner. This transformation occurs after\n * validating the base document and before combining any contributions.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the `baseDocument` passed in.\n *\n * @param baseDocument Initial input document. Already validated via `validateBaseDocument`\n * @returns Transformed base document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformBaseDocumentAfterValidation(baseDocument: JsonDocumentLike): JsonDocumentLike {\n return baseDocument;\n }\n\n /**\n * Transform the contributed document associated with `documentName`. This transformation occurs\n * after validating the contributed document and before combining with other documents.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the contributed `document` passed in.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine. Already validated via\n * `validateContribution`\n * @returns Transformed contributed document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformContributionAfterValidation(\n // @ts-expect-error this parameter is unused but may be used in child classes\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike {\n return document;\n }\n\n /**\n * Throw an error if the provided document is not a valid starting document.\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateBaseDocument(baseDocument: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided document is not a valid contribution document.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateContribution(documentName: string, document: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided output is not valid.\n *\n * @param output Output document that could potentially be returned to callers\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateOutput(output: JsonDocumentLike): void {}\n\n /**\n * Transform the document that is the composition of the base document and all contribution\n * documents. This is the last step that will be run prior to validation via `validateOutput`\n * before `this.latestOutput` is updated to the new output.\n *\n * @param finalOutput Final output document that could potentially be returned to callers. \"Final\"\n * means no further contribution documents will be merged.\n */\n // no-op intended to be overridden by child classes. Can't be static\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformFinalOutputBeforeValidation(finalOutput: JsonDocumentLike): JsonDocumentLike {\n return finalOutput;\n }\n}\n\n// #region Helper functions\n\n/**\n * Determines if the input values are objects but not arrays\n *\n * @param values Objects to check\n * @returns True if all the values are objects but not arrays\n */\nfunction areNonArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Determines if the input values are arrays\n *\n * @param value Objects to check\n * @returns True if the values are arrays\n */\nfunction areArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || !Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Deep clone and recursively merge the properties of one object (copyFrom) into another\n * (startingPoint). Throws if copyFrom would overwrite values already existing in startingPoint.\n *\n * Does not modify the objects passed in.\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjects(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n const retVal = deepClone(startingPoint);\n\n if (!copyFrom) return retVal;\n\n return mergeObjectsInternal(retVal, deepClone(copyFrom), ignoreDuplicateProperties);\n}\n\n/**\n * Recursively merge the properties of one object (copyFrom) into another (startingPoint). Throws if\n * copyFrom would overwrite values already existing in startingPoint.\n *\n * WARNING: Modifies the argument objects in some way. Recommended to use `mergeObjects`\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjectsInternal(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n if (!copyFrom) return startingPoint;\n\n if (areNonArrayObjects(startingPoint, copyFrom)) {\n // Merge properties since they are both objects\n\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n const startingPointObj = startingPoint as JsonObjectLike;\n const copyFromObj = copyFrom as JsonObjectLike;\n /* eslint-enable no-type-assertion/no-type-assertion */\n Object.keys(copyFromObj).forEach((key: string | number) => {\n if (Object.hasOwn(startingPointObj, key)) {\n if (areNonArrayObjects(startingPointObj[key], copyFromObj[key])) {\n startingPointObj[key] = mergeObjectsInternal(\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] as JsonObjectLike,\n copyFromObj[key] as JsonObjectLike,\n ignoreDuplicateProperties,\n /* eslint-enable no-type-assertion/no-type-assertion */\n );\n } else if (areArrayObjects(startingPointObj[key], copyFromObj[key])) {\n // Concat the arrays since they are both arrays\n\n // We know these are arrays from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] = (startingPointObj[key] as JsonArrayLike).concat(\n copyFromObj[key] as JsonArrayLike,\n );\n /* eslint-enable no-type-assertion/no-type-assertion */\n } else if (!ignoreDuplicateProperties)\n throw new Error(`Cannot merge objects: key \"${key}\" already exists in the target object`);\n // Note that the first non-object non-array value that gets placed in a property stays.\n // New values do not override existing ones\n } else {\n startingPointObj[key] = copyFromObj[key];\n }\n });\n } else if (areArrayObjects(startingPoint, copyFrom)) {\n // Concat the arrays since they are both arrays\n\n // Push the contents of copyFrom into startingPoint since it is a const and was already deep cloned\n // We know these are objects from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n (startingPoint as JsonArrayLike).push(...(copyFrom as JsonArrayLike));\n /* eslint-enable no-type-assertion/no-type-assertion */\n }\n\n // Note that nothing happens if `startingPoint` is not an object or an array or if `startingPoint`\n // and `copyFrom` are not both object or both arrays. Should we throw? Should we push `copyFrom`'s\n // values into the array? Other? Maybe one day we can add some options to decide what to do in\n // this situation, but YAGNI for now\n\n return startingPoint;\n}\n\n// #endregion\n\nexport default DocumentCombiner;\n","/** Class that tracks how long it has taken the last N events to occur */\nexport class EventRollingTimeCounter {\n /** The ring buffer to store times */\n private readonly ringBuffer: number[];\n /** The size of the ring buffer */\n private readonly bufferSize: number;\n /** The next location where a time will be written */\n private writerIndex: number;\n /** The location where the first time in the buffer will be read */\n private readerIndex: number;\n /** The most recent difference in time between the newest and oldest events */\n private lastTimeDifference: number;\n /** How many instances in total have been recorded */\n private totalInstanceCount: number;\n\n /**\n * Create a new instance of the InstanceTimeCounter class\n *\n * @param bufferSize - Maximum number of instances to track\n */\n constructor(bufferSize: number) {\n this.bufferSize = bufferSize;\n this.ringBuffer = new Array(bufferSize).fill(0);\n this.writerIndex = 0;\n this.readerIndex = 0;\n this.lastTimeDifference = 0;\n this.totalInstanceCount = 0;\n }\n\n /** Get the total number of instances that have been recorded */\n get totalInstances(): number {\n return this.totalInstanceCount;\n }\n\n /** Add a new time measurement for an instance of an event */\n recordInstance(): void {\n this.totalInstanceCount += 1;\n const currentTime = performance.now();\n this.lastTimeDifference = currentTime - this.ringBuffer[this.readerIndex];\n\n this.ringBuffer[this.writerIndex] = currentTime;\n this.writerIndex += 1;\n if (this.writerIndex >= this.bufferSize) this.writerIndex %= this.bufferSize;\n if (this.writerIndex === this.readerIndex) {\n this.readerIndex += 1;\n if (this.readerIndex >= this.bufferSize) this.readerIndex %= this.bufferSize;\n }\n }\n\n /**\n * Check if the time between the last N events is less than the provided threshold\n *\n * @param minRollingTimeMs - Minimum time that must have passed when the last N events occurred\n * @returns - True if the threshold is violated, false otherwise\n */\n hasViolatedThreshold(minRollingTimeMs: number): boolean {\n return this.totalInstanceCount >= this.bufferSize && this.lastTimeDifference < minRollingTimeMs;\n }\n}\n","import { Mutex as AsyncMutex } from 'async-mutex';\n\n// Extending Mutex from async-mutex so we can add JSDoc\n\n/**\n * Class that allows calling asynchronous functions multiple times at once while only running one at\n * a time.\n *\n * @example\n *\n * ```typescript\n * const mutex = new Mutex();\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n * ```\n *\n * See [`async-mutex`](https://www.npmjs.com/package/async-mutex) for more information.\n */\nexport class Mutex extends AsyncMutex {}\n\nexport default Mutex;\n","import { Mutex } from './mutex';\n\n/** Map of {@link Mutex}es that automatically (lazily) generates a new {@link Mutex} for any new key */\nexport class MutexMap {\n private mutexesByID = new Map();\n\n /**\n * Retrieves the {@link Mutex} associated with the given ID. If no Mutex exists for the provided\n * ID, a new Mutex is created, stored, and returned.\n *\n * @param mutexID Unique identifier for the desired Mutex\n * @returns The Mutex associated with the provided ID\n */\n get(mutexID: string): Mutex {\n let retVal = this.mutexesByID.get(mutexID);\n if (retVal) return retVal;\n\n retVal = new Mutex();\n this.mutexesByID.set(mutexID, retVal);\n return retVal;\n }\n}\n\nexport default MutexMap;\n","import { DocumentCombiner, DocumentCombinerOptions, JsonDocumentLike } from './document-combiner';\n\nexport class NonValidatingDocumentCombiner extends DocumentCombiner {\n // Making the protected base constructor public\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n super(baseDocument, options);\n }\n\n get output(): JsonDocumentLike | undefined {\n return this.latestOutput;\n }\n}\n\nexport default NonValidatingDocumentCombiner;\n","/** Enables language-sensitive number formatting. Wraps Intl.NumberFormat */\nexport class NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n\n constructor(locales?: string | string[], options?: Intl.NumberFormatOptions) {\n this.numberFormatter = new Intl.NumberFormat(locales, options);\n }\n\n /**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @param value Number or BigInt to format\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\n format(value: number | bigint): string {\n return this.numberFormatter.format(value);\n }\n\n /**\n * Formats a range of numbers according to the locale and formatting options of this NumberFormat\n * object\n *\n * @param startRange Number or bigint representing the start of the range\n * @param endRange Number or bigint representing the end of the range\n * @returns String representing the given range of numbers formatted according to the locale and\n * formatting options of this NumberFormat object\n */\n formatRange(startRange: number | bigint, endRange: number | bigint): string {\n return this.numberFormatter.formatRange(startRange, endRange);\n }\n\n /**\n * Returns an array of objects containing the locale-specific tokens from which it is possible to\n * build custom strings while preserving the locale-specific parts.\n *\n * @param startRange Number or bigint representing start of the range\n * @param endRange Number or bigint representing end of the range\n * @returns Array of NumberRangeFormatPart objects containing the formatted range of numbers in\n * parts\n */\n formatRangeToParts(\n startRange: number | bigint,\n endRange: number | bigint,\n ): Intl.NumberRangeFormatPart[] {\n return this.numberFormatter.formatRangeToParts(startRange, endRange);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this NumberFormat object\n *\n * @param value Number or bigint to format\n * @returns Array of NumberFormatPart objects containing the formatted number in parts\n */\n formatToParts(value: number | bigint): Intl.NumberFormatPart[] {\n return this.numberFormatter.formatToParts(value);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and number formatting options\n * computed during initialization of this NumberFormat object\n *\n * @returns ResolvedNumberFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n return this.numberFormatter.resolvedOptions();\n }\n}\n\nexport default NumberFormat;\n","const defaultPromise = Promise.resolve();\n\n/**\n * Class that allows you to chain promises for a given key. This is useful when:\n *\n * 1. You need to run promises from synchronous code and don't need to look at the results.\n * 2. The promises to run, or at least precisely when to run them, are not known in advance.\n * 3. The promises need to be run sequentially, waiting for the previous one to finish.\n *\n * An example of when this can be helpful is inside of React components. Component code is mostly\n * synchronous, but you may need to run some asynchronous code. You can't use `await` inside of\n * React component code in many situations, so you can use this class to chain promises together.\n *\n * When promises are added to the map with a key, they will run in the order they were added to the\n * map for that key. If a promise rejects, a warning will be logged and the chain will continue. If\n * a promise is added while another promise in the map for that key is running, the new promise will\n * be chained to the existing one.\n */\nexport class PromiseChainingMap {\n private readonly map = new Map>();\n private readonly logger: { warn: (message: string) => void };\n\n /**\n * Creates a new PromiseChainingMap\n *\n * @param logger Object with a `warn` method that will be called when a promise rejects. This\n * defaults to `console`.\n */\n constructor(logger: { warn: (message: string) => void } = console) {\n this.logger = logger;\n }\n\n /**\n * Adds a promise function to the map for a given key. If a promise is already running for the\n * key, the new promise will be chained to the existing one. Once all promises for a key have\n * settled, the map will be cleared for that key.\n *\n * @param key Unique key to identify a distinct promise chain\n * @param promiseFunction Function that returns a promise to add to the chain\n */\n addPromiseFunction(key: TKey, promiseFunction: () => Promise): void {\n const currentPromise = this.map.get(key);\n this.map.set(key, currentPromise ? currentPromise.then(promiseFunction) : promiseFunction());\n this.cleanupPromiseChain(key);\n }\n\n /**\n * Gets the current promise chain for the given key. This is mostly useful for testing. Normally\n * you should just call {@link addPromiseFunction} and let the map handle the rest.\n *\n * @param key Unique key to identify a distinct promise chain\n * @returns The current promise chain for the key\n */\n get(key: TKey): Promise | undefined {\n return this.map.get(key);\n }\n\n /**\n * Configures a promise chain to be removed from the map for the given key after all the promises\n * have settled\n *\n * @param key Unique key to identify a distinct promise chain\n */\n private cleanupPromiseChain(key: TKey): void {\n const currentPromise = this.map.get(key);\n if (!currentPromise) return;\n\n const promiseHolder: { promise: Promise } = { promise: defaultPromise };\n const newPromise = currentPromise\n .catch((e) => this.logger.warn(`Error in promise for ${key}: ${e.message}`))\n .finally(() => {\n if (this.map.get(key) === promiseHolder.promise) this.map.delete(key);\n });\n promiseHolder.promise = newPromise;\n this.map.set(key, newPromise);\n }\n}\n\nexport default PromiseChainingMap;\n","/**\n * A map-like data structure that maintains numeric keys in sorted order and provides efficient\n * operations for finding the closest key-value pair less than or equal to a target.\n *\n * This class combines the benefits of a Map (O(1) key-value lookups) with sorted key access (O(log\n * n) binary search operations). It's particularly useful when you need to frequently find the\n * \"closest\" entry to a given numeric key.\n *\n * @example\n *\n * ```typescript\n * const versionMap = new SortedNumberMap();\n * versionMap.set(100, 'Version 1.0.0');\n * versionMap.set(150, 'Version 1.5.0');\n * versionMap.set(200, 'Version 2.0.0');\n *\n * // Find the highest version <= 175\n * const result = versionMap.findClosestLessThanOrEqual(175);\n * console.log(result); // { key: 150, value: 'Version 1.5.0' }\n * ```\n *\n * @template T The type of values stored in the map\n */\nexport class SortedNumberMap {\n private map = new Map();\n private sortedKeys: number[] = [];\n\n /**\n * Returns an iterable of keys in the map sorted in ascending order.\n *\n * Time complexity: internal detail to JavaScript engine. Reasonable expectation:\n *\n * - Executing this method to return an iterator: O(1)\n * - Iterating over the returned iterator: O(n)\n *\n * Note that iterating over the keys this way negates the benefits of using this class over a\n * using a {@link Map}. To access individual keys more quickly, use\n * {@link SortedNumberMap.findClosestLessThanOrEqual} or {@link SortedNumberMap.get}.\n *\n * TSDoc adapted from {@link Map.keys}\n */\n keys() {\n return this.sortedKeys.values();\n }\n\n /**\n * Returns a specified element from the Map object. If the value that is associated to the\n * provided key is an object, then you will get a reference to that object and any change made to\n * that object will effectively modify it inside the Map.\n *\n * Time complexity: O(1)\n *\n * @returns Returns the element associated with the specified key. If no element is associated\n * with the specified key, returns `undefined`.\n *\n * TSDoc adapted from {@link Map.get}\n */\n get(key: number) {\n return this.map.get(key);\n }\n\n /**\n * Sets a key-value pair in the map. If the key already exists, its value is updated. If the key\n * is new, it's inserted in the correct sorted position.\n *\n * Time complexity: O(log n) for new keys (due to binary search and array insertion), O(1) for\n * existing keys.\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(5, 'five');\n * map.set(15, 'fifteen');\n * // Keys are automatically maintained in sorted order: [5, 10, 15]\n * ```\n *\n * @param key - The numeric key to set\n * @param value - The value to associate with the key\n */\n set(key: number, value: T): void {\n if (!this.map.has(key)) {\n // Insert key in sorted position\n const insertIndex = this.binarySearchInsertIndex(key);\n this.sortedKeys.splice(insertIndex, 0, key);\n }\n this.map.set(key, value);\n }\n\n /**\n * Finds the key-value pair with the largest key that is less than or equal to the target.\n *\n * This method uses binary search to efficiently locate the closest match. If no key is less than\n * or equal to the target, it returns undefined.\n *\n * Time complexity: O(log n)\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(20, 'twenty');\n * map.set(30, 'thirty');\n *\n * // Exact match\n * map.findClosestLessThanOrEqual(20); // { key: 20, value: 'twenty' }\n *\n * // Closest less than\n * map.findClosestLessThanOrEqual(25); // { key: 20, value: 'twenty' }\n *\n * // No match (target too small)\n * map.findClosestLessThanOrEqual(5); // undefined\n * ```\n *\n * @param target - The number to search for\n * @returns The key-value pair with the largest key ≤ target, or undefined if none exists\n */\n findClosestLessThanOrEqual(target: number): { key: number; value: T } | undefined {\n const index = this.binarySearchLessThanOrEqual(target);\n if (index === -1) return undefined;\n\n const key = this.sortedKeys[index];\n const value = this.map.get(key);\n if (value === undefined) return undefined;\n return { key, value };\n }\n\n private binarySearchLessThanOrEqual(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length - 1;\n let result = -1;\n\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] <= target) {\n result = mid;\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return result;\n }\n\n private binarySearchInsertIndex(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return left;\n }\n}\n","/**\n * A collection of unique items that are automatically maintained in sorted order, similar to C#'s\n * SortedSet.\n *\n * @template T The type of elements in the set\n */\nexport class SortedSet {\n /** Internal storage for the sorted items */\n private readonly items: T[] = [];\n\n /**\n * Creates a new sorted set\n *\n * @param compareFn - Function used to determine the order of elements. Returns negative when a <\n * b, zero when a = b, positive when a > b\n */\n constructor(private readonly compareFn: (a: T, b: T) => number) {}\n\n /** Gets the number of elements in the set */\n get size(): number {\n return this.items.length;\n }\n\n /** Returns whether the set is empty */\n get isEmpty(): boolean {\n return this.items.length === 0;\n }\n\n /**\n * Inserts an item into the set if it's not already present\n *\n * @param item - The item to insert\n * @returns True if the item was added; false if an equal item already exists\n */\n insert(item: T): boolean {\n // Find where this item should be inserted\n const index = this.findInsertionIndex(item);\n\n // Check if an equal item exists at the found position\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) {\n // Item already exists\n return false;\n }\n\n // Insert the item at the correct position to maintain sort order\n this.items.splice(index, 0, item);\n return true;\n }\n\n /**\n * Removes an item from the set\n *\n * @param item - The item to remove\n * @returns True if the item was removed; false if it wasn't found\n */\n remove(item: T): boolean {\n const index = this.findIndex(item);\n if (index < 0) return false;\n\n this.items.splice(index, 1);\n return true;\n }\n\n /**\n * Checks if an item exists in the set\n *\n * @param item - The item to check\n * @returns True if the item exists; false otherwise\n */\n has(item: T): boolean {\n return this.findIndex(item) >= 0;\n }\n\n /** Returns all items in the set as an array, in sorted order */\n toArray(): T[] {\n return [...this.items];\n }\n\n /** Returns the index of an item in the set, or -1 if not found */\n findIndex(item: T): number {\n const index = this.findInsertionIndex(item);\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) return index;\n return -1;\n }\n\n /**\n * Returns the element at the specified index in the sorted order\n *\n * @param index - The zero-based index of the element to get\n * @returns The element at the specified index, or undefined if the index is out of range\n */\n at(index: number): T | undefined {\n if (index < 0 || index >= this.items.length) return undefined;\n return this.items[index];\n }\n\n /** Iterates through each item in the sorted set */\n forEach(callback: (item: T, index: number, set: SortedSet) => void): void {\n this.items.forEach((item, index) => callback(item, index, this));\n }\n\n /** Returns an iterator for the set's items */\n [Symbol.iterator](): Iterator {\n let index = 0;\n return {\n next: (): IteratorResult => {\n if (index < this.items.length) {\n index += 1;\n return { value: this.items[index - 1], done: false };\n }\n return { value: undefined as unknown, done: true };\n },\n };\n }\n\n /** Clears all items from the set */\n clear(): void {\n this.items.length = 0;\n }\n\n /**\n * Uses binary search to find the position where an item should be inserted to maintain the sorted\n * order\n */\n private findInsertionIndex(item: T): number {\n let low = 0;\n let high = this.items.length;\n\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n const comparison = this.compareFn(this.items[mid], item);\n\n if (comparison < 0) {\n // Current item is less than the one we're looking for\n low = mid + 1;\n } else {\n // Current item is greater than or equal to the one we're looking for\n high = mid;\n }\n }\n\n return low;\n }\n}\n","import { Dispose } from './disposal.model';\nimport { Unsubscriber, UnsubscriberAsync } from './unsubscriber';\n\n/** Simple collection for UnsubscriberAsync objects that also provides an easy way to run them. */\nexport class UnsubscriberAsyncList {\n readonly unsubscribers = new Set();\n\n constructor(private name = 'Anonymous') {}\n\n /**\n * Add unsubscribers to the list. Note that duplicates are not added twice.\n *\n * @param unsubscribers - Objects that were returned from a registration process.\n */\n add(...unsubscribers: (UnsubscriberAsync | Unsubscriber | Dispose)[]) {\n unsubscribers.forEach((unsubscriber) => {\n if ('dispose' in unsubscriber)\n this.unsubscribers.add(unsubscriber.dispose.bind(unsubscriber));\n else this.unsubscribers.add(unsubscriber);\n });\n }\n\n /**\n * Run all unsubscribers added to this list and then clear the list.\n *\n * @returns `true` if all unsubscribers succeeded, `false` otherwise.\n */\n async runAllUnsubscribers(): Promise {\n const unsubs = [...this.unsubscribers].map((unsubscriber) => unsubscriber());\n const results = await Promise.all(unsubs);\n this.unsubscribers.clear();\n return results.every((unsubscriberSucceeded, index) => {\n if (!unsubscriberSucceeded)\n console.error(`UnsubscriberAsyncList ${this.name}: Unsubscriber at index ${index} failed!`);\n\n return unsubscriberSucceeded;\n });\n }\n}\n\nexport default UnsubscriberAsyncList;\n","import { isString } from './util';\n\n/** The version of the PlatformError type */\nexport const PLATFORM_ERROR_VERSION = 1;\n\n/**\n * PlatformError is an error type with stronger typing of properties than `Error`. It is used to\n * represent errors that are returned by the platform.\n *\n * You can create a new PlatformError object using {@link newPlatformError}. You can check if a value\n * is a PlatformError object using {@link isPlatformError}.\n */\nexport type PlatformError = {\n /**\n * The underlying cause of the error, if any. Normally this will be copied from an `Error object\n * passed to {@link newPlatformError}. If a non-Error object is passed to {@link newPlatformError},\n * it will be stored here.\n */\n cause?: unknown;\n /**\n * A descriptive message explaining the error. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}. If a string is passed to {@link newPlatformError}, it will be\n * stored here.\n */\n message: string;\n /** The version of the PlatformError type. */\n platformErrorVersion: number;\n /**\n * The stack trace of the error, if available. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}.\n */\n stack?: string;\n};\n\n/**\n * Creates a new PlatformError object. If no argument is provided, a PlatformError object with an\n * empty `message` is returned.\n *\n * @param error The error message as a string, an Error object, or a value to assign to the `cause`\n * property of the returned PlatformError object\n * @returns A new PlatformError object\n */\nexport function newPlatformError(error?: unknown): PlatformError {\n if (!error) return { message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (isString(error)) return { message: error, platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n const platformError: PlatformError = {\n message: error.message,\n platformErrorVersion: PLATFORM_ERROR_VERSION,\n };\n Object.defineProperties(platformError, Object.getOwnPropertyDescriptors(error));\n Object.defineProperty(platformError, 'message', { enumerable: true });\n if ('stack' in error && isString(error.stack)) {\n // stack is generated lazily, and it seems this is causing some troubles with copying it into\n // another object via property descriptors as of Node 22.14.0 (no problems in 20.18.0).\n // So we shall set the value directly on the object\n Object.defineProperty(platformError, 'stack', { value: error.stack, enumerable: true });\n }\n if ('cause' in platformError)\n Object.defineProperty(platformError, 'cause', { enumerable: true });\n return platformError;\n }\n return { cause: error, message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n}\n\n/**\n * Checks if the provided value is a PlatformError object.\n *\n * @param error The value to check\n * @returns `true` if the value is a PlatformError object, otherwise `false`\n */\nexport function isPlatformError(error: unknown): error is PlatformError {\n return !!error && typeof error === 'object' && 'platformErrorVersion' in error;\n}\n","var P = Object.defineProperty;\nvar R = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;\nvar n = (t, e, s) => R(t, typeof e != \"symbol\" ? e + \"\" : e, s);\nclass _ {\n constructor() {\n n(this, \"books\");\n n(this, \"firstSelectedBookNum\");\n n(this, \"lastSelectedBookNum\");\n n(this, \"count\");\n n(this, \"selectedBookNumbers\");\n n(this, \"selectedBookIds\");\n }\n}\nconst N = [\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n // 10\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n // 20\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n // 30\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n \"MAT\",\n // 40\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n // 50\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n // 60\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n // 70\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n // 80\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"JSA\",\n // actual variant text for JOS, now in LXA text\n \"JDB\",\n // actual variant text for JDG, now in LXA text\n \"TBS\",\n // actual variant text for TOB, now in LXA text\n \"SST\",\n // actual variant text for SUS, now in LXA text // 90\n \"DNT\",\n // actual variant text for DAN, now in LXA text\n \"BLT\",\n // actual variant text for BEL, now in LXA text\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n // 100\n \"BAK\",\n \"OTH\",\n \"3ES\",\n // Used previously but really should be 2ES\n \"EZA\",\n // Used to be called 4ES, but not actually in any known project\n \"5EZ\",\n // Used to be called 5ES, but not actually in any known project\n \"6EZ\",\n // Used to be called 6ES, but not actually in any known project\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n // 110\n \"NDX\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n // 120\n \"REP\",\n \"4BA\",\n \"LAO\"\n], B = [\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\"\n], O = [\n \"Genesis\",\n \"Exodus\",\n \"Leviticus\",\n \"Numbers\",\n \"Deuteronomy\",\n \"Joshua\",\n \"Judges\",\n \"Ruth\",\n \"1 Samuel\",\n \"2 Samuel\",\n \"1 Kings\",\n \"2 Kings\",\n \"1 Chronicles\",\n \"2 Chronicles\",\n \"Ezra\",\n \"Nehemiah\",\n \"Esther (Hebrew)\",\n \"Job\",\n \"Psalms\",\n \"Proverbs\",\n \"Ecclesiastes\",\n \"Song of Songs\",\n \"Isaiah\",\n \"Jeremiah\",\n \"Lamentations\",\n \"Ezekiel\",\n \"Daniel (Hebrew)\",\n \"Hosea\",\n \"Joel\",\n \"Amos\",\n \"Obadiah\",\n \"Jonah\",\n \"Micah\",\n \"Nahum\",\n \"Habakkuk\",\n \"Zephaniah\",\n \"Haggai\",\n \"Zechariah\",\n \"Malachi\",\n \"Matthew\",\n \"Mark\",\n \"Luke\",\n \"John\",\n \"Acts\",\n \"Romans\",\n \"1 Corinthians\",\n \"2 Corinthians\",\n \"Galatians\",\n \"Ephesians\",\n \"Philippians\",\n \"Colossians\",\n \"1 Thessalonians\",\n \"2 Thessalonians\",\n \"1 Timothy\",\n \"2 Timothy\",\n \"Titus\",\n \"Philemon\",\n \"Hebrews\",\n \"James\",\n \"1 Peter\",\n \"2 Peter\",\n \"1 John\",\n \"2 John\",\n \"3 John\",\n \"Jude\",\n \"Revelation\",\n \"Tobit\",\n \"Judith\",\n \"Esther Greek\",\n \"Wisdom of Solomon\",\n \"Sirach (Ecclesiasticus)\",\n \"Baruch\",\n \"Letter of Jeremiah\",\n \"Song of 3 Young Men\",\n \"Susanna\",\n \"Bel and the Dragon\",\n \"1 Maccabees\",\n \"2 Maccabees\",\n \"3 Maccabees\",\n \"4 Maccabees\",\n \"1 Esdras (Greek)\",\n \"2 Esdras (Latin)\",\n \"Prayer of Manasseh\",\n \"Psalm 151\",\n \"Odes\",\n \"Psalms of Solomon\",\n // WARNING, if you change the spelling of the *obsolete* tag be sure to update\n // IsObsolete routine\n \"Joshua A. *obsolete*\",\n \"Judges B. *obsolete*\",\n \"Tobit S. *obsolete*\",\n \"Susanna Th. *obsolete*\",\n \"Daniel Th. *obsolete*\",\n \"Bel Th. *obsolete*\",\n \"Extra A\",\n \"Extra B\",\n \"Extra C\",\n \"Extra D\",\n \"Extra E\",\n \"Extra F\",\n \"Extra G\",\n \"Front Matter\",\n \"Back Matter\",\n \"Other Matter\",\n \"3 Ezra *obsolete*\",\n \"Apocalypse of Ezra\",\n \"5 Ezra (Latin Prologue)\",\n \"6 Ezra (Latin Epilogue)\",\n \"Introduction\",\n \"Concordance \",\n \"Glossary \",\n \"Topical Index\",\n \"Names Index\",\n \"Daniel Greek\",\n \"Psalms 152-155\",\n \"2 Baruch (Apocalypse)\",\n \"Letter of Baruch\",\n \"Jubilees\",\n \"Enoch\",\n \"1 Meqabyan\",\n \"2 Meqabyan\",\n \"3 Meqabyan\",\n \"Reproof (Proverbs 25-31)\",\n \"4 Baruch (Rest of Baruch)\",\n \"Laodiceans\"\n], S = K();\nfunction g(t, e = !0) {\n return e && (t = t.toUpperCase()), t in S ? S[t] : 0;\n}\nfunction k(t) {\n return g(t) > 0;\n}\nfunction x(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return e >= 40 && e <= 66;\n}\nfunction T(t) {\n return (typeof t == \"string\" ? g(t) : t) <= 39;\n}\nfunction X(t) {\n return t <= 66;\n}\nfunction V(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return w(e) && !X(e);\n}\nfunction* L() {\n for (let t = 1; t <= N.length; t++) yield t;\n}\nconst G = 1, A = N.length;\nfunction H() {\n return [\"XXA\", \"XXB\", \"XXC\", \"XXD\", \"XXE\", \"XXF\", \"XXG\"];\n}\nfunction C(t, e = \"***\") {\n const s = t - 1;\n return s < 0 || s >= N.length ? e : N[s];\n}\nfunction I(t) {\n return t <= 0 || t > A ? \"******\" : O[t - 1];\n}\nfunction y(t) {\n return I(g(t));\n}\nfunction w(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && !B.includes(e);\n}\nfunction q(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && B.includes(e);\n}\nfunction U(t) {\n return O[t - 1].includes(\"*obsolete*\");\n}\nfunction K() {\n const t = {};\n for (let e = 0; e < N.length; e++)\n t[N[e]] = e + 1;\n return t;\n}\nconst m = {\n allBookIds: N,\n nonCanonicalIds: B,\n bookIdToNumber: g,\n isBookIdValid: k,\n isBookNT: x,\n isBookOT: T,\n isBookOTNT: X,\n isBookDC: V,\n allBookNumbers: L,\n firstBook: G,\n lastBook: A,\n extraBooks: H,\n bookNumberToId: C,\n bookNumberToEnglishName: I,\n bookIdToEnglishName: y,\n isCanonical: w,\n isExtraMaterial: q,\n isObsolete: U\n};\nvar l = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = \"Unknown\", t[t.Original = 1] = \"Original\", t[t.Septuagint = 2] = \"Septuagint\", t[t.Vulgate = 3] = \"Vulgate\", t[t.English = 4] = \"English\", t[t.RussianProtestant = 5] = \"RussianProtestant\", t[t.RussianOrthodox = 6] = \"RussianOrthodox\", t))(l || {});\nconst h = class h {\n // private versInfo: Versification;\n constructor(e) {\n n(this, \"name\");\n n(this, \"fullPath\");\n n(this, \"isPresent\");\n n(this, \"hasVerseSegments\");\n n(this, \"isCustomized\");\n n(this, \"baseVersification\");\n n(this, \"scriptureBooks\");\n n(this, \"_type\");\n if (e == null)\n throw new Error(\"Argument undefined\");\n typeof e == \"string\" ? (this.name = e, this._type = l[e]) : (this._type = e, this.name = l[e]);\n }\n get type() {\n return this._type;\n }\n equals(e) {\n return !e.type || !this.type ? !1 : e.type === this.type;\n }\n};\nn(h, \"Original\", new h(l.Original)), n(h, \"Septuagint\", new h(l.Septuagint)), n(h, \"Vulgate\", new h(l.Vulgate)), n(h, \"English\", new h(l.English)), n(h, \"RussianProtestant\", new h(l.RussianProtestant)), n(h, \"RussianOrthodox\", new h(l.RussianOrthodox));\nlet c = h;\nfunction E(t, e) {\n const s = e[0];\n for (let r = 1; r < e.length; r++)\n t = t.split(e[r]).join(s);\n return t.split(s);\n}\nvar D = /* @__PURE__ */ ((t) => (t[t.Valid = 0] = \"Valid\", t[t.UnknownVersification = 1] = \"UnknownVersification\", t[t.OutOfRange = 2] = \"OutOfRange\", t[t.VerseOutOfOrder = 3] = \"VerseOutOfOrder\", t[t.VerseRepeated = 4] = \"VerseRepeated\", t))(D || {});\nconst i = class i {\n constructor(e, s, r, a) {\n /** Not yet implemented. */\n n(this, \"firstChapter\");\n /** Not yet implemented. */\n n(this, \"lastChapter\");\n /** Not yet implemented. */\n n(this, \"lastVerse\");\n /** Not yet implemented. */\n n(this, \"hasSegmentsDefined\");\n /** Not yet implemented. */\n n(this, \"text\");\n /** Not yet implemented. */\n n(this, \"BBBCCCVVVS\");\n /** Not yet implemented. */\n n(this, \"longHashCode\");\n /** The versification of the reference. */\n n(this, \"versification\");\n n(this, \"rtlMark\", \"‏\");\n n(this, \"_bookNum\", 0);\n n(this, \"_chapterNum\", 0);\n n(this, \"_verseNum\", 0);\n n(this, \"_verse\");\n if (r == null && a == null)\n if (e != null && typeof e == \"string\") {\n const o = e, u = s != null && s instanceof c ? s : void 0;\n this.setEmpty(u), this.parse(o);\n } else if (e != null && typeof e == \"number\") {\n const o = s != null && s instanceof c ? s : void 0;\n this.setEmpty(o), this._verseNum = e % i.chapterDigitShifter, this._chapterNum = Math.floor(\n e % i.bookDigitShifter / i.chapterDigitShifter\n ), this._bookNum = Math.floor(e / i.bookDigitShifter);\n } else if (s == null)\n if (e != null && e instanceof i) {\n const o = e;\n this._bookNum = o.bookNum, this._chapterNum = o.chapterNum, this._verseNum = o.verseNum, this._verse = o.verse, this.versification = o.versification;\n } else {\n if (e == null) return;\n const o = e instanceof c ? e : i.defaultVersification;\n this.setEmpty(o);\n }\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else if (e != null && s != null && r != null)\n if (typeof e == \"string\" && typeof s == \"string\" && typeof r == \"string\")\n this.setEmpty(a), this.updateInternal(e, s, r);\n else if (typeof e == \"number\" && typeof s == \"number\" && typeof r == \"number\")\n this._bookNum = e, this._chapterNum = s, this._verseNum = r, this.versification = a ?? i.defaultVersification;\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else\n throw new Error(\"VerseRef constructor not supported.\");\n }\n /**\n * Determines if the verse string is in a valid format (does not consider versification).\n */\n static isVerseParseable(e) {\n return e.length > 0 && \"0123456789\".includes(e[0]) && !e.endsWith(this.verseRangeSeparator) && !e.endsWith(this.verseSequenceIndicator);\n }\n /**\n * Tries to parse the specified string into a verse reference.\n * @param str - The string to attempt to parse.\n * @returns success: `true` if the specified string was successfully parsed, `false` otherwise.\n * @returns verseRef: The result of the parse if successful, or empty VerseRef if it failed\n */\n static tryParse(e) {\n let s;\n try {\n return s = new i(e), { success: !0, verseRef: s };\n } catch (r) {\n if (r instanceof v)\n return s = new i(), { success: !1, verseRef: s };\n throw r;\n }\n }\n /**\n * Gets the reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n * @param bookNum - Book number (this is 1-based, not an index).\n * @param chapterNum - Chapter number.\n * @param verseNum - Verse number.\n * @returns The reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n */\n static getBBBCCCVVV(e, s, r) {\n return e % i.bcvMaxValue * i.bookDigitShifter + (s >= 0 ? s % i.bcvMaxValue * i.chapterDigitShifter : 0) + (r >= 0 ? r % i.bcvMaxValue : 0);\n }\n /**\n * Deserializes a serialized VerseRef.\n * @param serializedVerseRef - Serialized VerseRef to create from.\n * @returns the deserialized VerseRef.\n */\n static fromJSON(e) {\n const { book: s, chapterNum: r, verseNum: a, verse: o, versificationStr: u } = e, f = o || a.toString();\n let d;\n return u && (d = new c(u)), s ? new i(s, r.toString(), f, d) : new i();\n }\n /**\n * Parses a verse string and gets the leading numeric portion as a number.\n * @param verseStr - verse string to parse\n * @returns true if the entire string could be parsed as a single, simple verse number (1-999);\n * false if the verse string represented a verse bridge, contained segment letters, or was invalid\n */\n static tryGetVerseNum(e) {\n let s;\n if (!e)\n return s = -1, { success: !0, vNum: s };\n s = 0;\n let r;\n for (let a = 0; a < e.length; a++) {\n if (r = e[a], r < \"0\" || r > \"9\")\n return a === 0 && (s = -1), { success: !1, vNum: s };\n if (s = s * 10 + +r - 0, s > i.bcvMaxValue)\n return s = -1, { success: !1, vNum: s };\n }\n return { success: !0, vNum: s };\n }\n /**\n * Checks to see if a VerseRef hasn't been set - all values are the default.\n */\n get isDefault() {\n return this.bookNum === 0 && this.chapterNum === 0 && this.verseNum === 0 && this.versification == null;\n }\n /**\n * Gets whether the verse contains multiple verses.\n */\n get hasMultiple() {\n return this._verse != null && (this._verse.includes(i.verseRangeSeparator) || this._verse.includes(i.verseSequenceIndicator));\n }\n /**\n * Gets or sets the book of the reference. Book is the 3-letter abbreviation in capital letters,\n * e.g. `'MAT'`.\n */\n get book() {\n return m.bookNumberToId(this.bookNum, \"\");\n }\n set book(e) {\n this.bookNum = m.bookIdToNumber(e);\n }\n /**\n * Gets or sets the chapter of the reference,. e.g. `'3'`.\n */\n get chapter() {\n return this.isDefault || this._chapterNum < 0 ? \"\" : this._chapterNum.toString();\n }\n set chapter(e) {\n const s = +e;\n this._chapterNum = Number.isInteger(s) ? s : -1;\n }\n /**\n * Gets or sets the verse of the reference, including range, segments, and sequences, e.g. `'4'`,\n * or `'4b-5a, 7'`.\n */\n get verse() {\n return this._verse != null ? this._verse : this.isDefault || this._verseNum < 0 ? \"\" : this._verseNum.toString();\n }\n set verse(e) {\n const { success: s, vNum: r } = i.tryGetVerseNum(e);\n this._verse = s ? void 0 : e.replace(this.rtlMark, \"\"), this._verseNum = r, !(this._verseNum >= 0) && ({ vNum: this._verseNum } = i.tryGetVerseNum(this._verse));\n }\n /**\n * Get or set Book based on book number, e.g. `42`.\n */\n get bookNum() {\n return this._bookNum;\n }\n set bookNum(e) {\n if (e <= 0 || e > m.lastBook)\n throw new v(\n \"BookNum must be greater than zero and less than or equal to last book\"\n );\n this._bookNum = e;\n }\n /**\n * Gets or sets the chapter number, e.g. `3`. `-1` if not valid.\n */\n get chapterNum() {\n return this._chapterNum;\n }\n set chapterNum(e) {\n this.chapterNum = e;\n }\n /**\n * Gets or sets verse start number, e.g. `4`. `-1` if not valid.\n */\n get verseNum() {\n return this._verseNum;\n }\n set verseNum(e) {\n this._verseNum = e;\n }\n /**\n * String representing the versification (should ONLY be used for serialization/deserialization).\n *\n * @remarks This is for backwards compatibility when ScrVers was an enumeration.\n */\n get versificationStr() {\n var e;\n return (e = this.versification) == null ? void 0 : e.name;\n }\n set versificationStr(e) {\n this.versification = this.versification != null ? new c(e) : void 0;\n }\n /**\n * Determines if the reference is valid.\n */\n get valid() {\n return this.validStatus === 0;\n }\n /**\n * Get the valid status for this reference.\n */\n get validStatus() {\n return this.validateVerse(i.verseRangeSeparators, i.verseSequenceIndicators);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits and the verse is 0.\n */\n get BBBCCC() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, 0);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits. If verse is not null\n * (i.e., this reference represents a complex reference with verse\n * segments or bridge) this cannot be used for an exact comparison.\n */\n get BBBCCCVVV() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, this._verseNum);\n }\n /**\n * Gets whether the verse is defined as an excluded verse in the versification.\n * Does not handle verse ranges.\n */\n // eslint-disable-next-line @typescript-eslint/class-literal-property-style\n get isExcluded() {\n return !1;\n }\n /**\n * Parses the reference in the specified string.\n * Optionally versification can follow reference as in GEN 3:11/4\n * Throw an exception if\n * - invalid book name\n * - chapter number is missing or not a number\n * - verse number is missing or does not start with a number\n * - versification is invalid\n * @param verseStr - string to parse e.g. 'MAT 3:11'\n */\n parse(e) {\n if (e = e.replace(this.rtlMark, \"\"), e.includes(\"/\")) {\n const o = e.split(\"/\");\n if (e = o[0], o.length > 1)\n try {\n const u = +o[1].trim();\n this.versification = new c(l[u]);\n } catch {\n throw new v(\"Invalid reference : \" + e);\n }\n }\n const s = e.trim().split(\" \");\n if (s.length !== 2)\n throw new v(\"Invalid reference : \" + e);\n const r = s[1].split(\":\"), a = +r[0];\n if (r.length !== 2 || m.bookIdToNumber(s[0]) === 0 || !Number.isInteger(a) || a < 0 || !i.isVerseParseable(r[1]))\n throw new v(\"Invalid reference : \" + e);\n this.updateInternal(s[0], r[0], r[1]);\n }\n /**\n * Simplifies this verse ref so that it has no bridging of verses or\n * verse segments like `'1a'`.\n */\n simplify() {\n this._verse = void 0;\n }\n /**\n * Makes a clone of the reference.\n *\n * @returns The cloned VerseRef.\n */\n clone() {\n return new i(this);\n }\n toString() {\n const e = this.book;\n return e === \"\" ? \"\" : `${e} ${this.chapter}:${this.verse}`;\n }\n toJSON() {\n let e = this.verse;\n (e === \"\" || e === this.verseNum.toString()) && (e = void 0);\n const s = {\n book: this.book,\n chapterNum: this.chapterNum,\n verseNum: this.verseNum,\n verse: e,\n versificationStr: this.versificationStr\n };\n return e || delete s.verse, s;\n }\n /**\n * Compares this `VerseRef` with supplied one.\n * @param verseRef - object to compare this one to.\n * @returns `true` if this `VerseRef` is equal to the supplied one, `false` otherwise.\n */\n equals(e) {\n return e instanceof i ? e._bookNum === this._bookNum && e._chapterNum === this._chapterNum && e._verseNum === this._verseNum && e.verse === this.verse && (e.versification == null && this.versification == null || e.versification != null && this.versification != null && e.versification.equals(this.versification)) : !1;\n }\n /**\n * Enumerate all individual verses contained in a VerseRef.\n * Verse ranges are indicated by \"-\" and consecutive verses by \",\"s.\n * Examples:\n * GEN 1:2 returns GEN 1:2\n * GEN 1:1a-3b,5 returns GEN 1:1a, GEN 1:2, GEN 1:3b, GEN 1:5\n * GEN 1:2a-2c returns //! ??????\n *\n * @param specifiedVersesOnly - if set to true return only verses that are\n * explicitly specified only, not verses within a range. Defaults to `false`.\n * @param verseRangeSeparators - Verse range separators.\n * Defaults to `VerseRef.verseRangeSeparators`.\n * @param verseSequenceSeparators - Verse sequence separators.\n * Defaults to `VerseRef.verseSequenceIndicators`.\n * @returns An array of all single verse references in this VerseRef.\n */\n allVerses(e = !1, s = i.verseRangeSeparators, r = i.verseSequenceIndicators) {\n if (this._verse == null || this.chapterNum <= 0)\n return [this.clone()];\n const a = [], o = E(this._verse, r);\n for (const u of o.map((f) => E(f, s))) {\n const f = this.clone();\n f.verse = u[0];\n const d = f.verseNum;\n if (a.push(f), u.length > 1) {\n const b = this.clone();\n if (b.verse = u[1], !e)\n for (let p = d + 1; p < b.verseNum; p++) {\n const J = new i(\n this._bookNum,\n this._chapterNum,\n p,\n this.versification\n );\n this.isExcluded || a.push(J);\n }\n a.push(b);\n }\n }\n return a;\n }\n /**\n * Validates a verse number using the supplied separators rather than the defaults.\n */\n validateVerse(e, s) {\n if (!this.verse)\n return this.internalValid;\n let r = 0;\n for (const a of this.allVerses(!0, e, s)) {\n const o = a.internalValid;\n if (o !== 0)\n return o;\n const u = a.BBBCCCVVV;\n if (r > u)\n return 3;\n if (r === u)\n return 4;\n r = u;\n }\n return 0;\n }\n /**\n * Gets whether a single verse reference is valid.\n */\n get internalValid() {\n return this.versification == null ? 1 : this._bookNum <= 0 || this._bookNum > m.lastBook ? 2 : (m.isCanonical(this._bookNum), 0);\n }\n setEmpty(e = i.defaultVersification) {\n this._bookNum = 0, this._chapterNum = -1, this._verse = void 0, this.versification = e;\n }\n updateInternal(e, s, r) {\n this.bookNum = m.bookIdToNumber(e), this.chapter = s, this.verse = r;\n }\n};\nn(i, \"defaultVersification\", c.English), n(i, \"verseRangeSeparator\", \"-\"), n(i, \"verseSequenceIndicator\", \",\"), n(i, \"verseRangeSeparators\", [i.verseRangeSeparator]), n(i, \"verseSequenceIndicators\", [i.verseSequenceIndicator]), n(i, \"chapterDigitShifter\", 1e3), n(i, \"bookDigitShifter\", i.chapterDigitShifter * i.chapterDigitShifter), n(i, \"bcvMaxValue\", i.chapterDigitShifter - 1), /**\n * The valid status of the VerseRef.\n */\nn(i, \"ValidStatusType\", D);\nlet M = i;\nclass v extends Error {\n}\nexport {\n _ as BookSet,\n m as Canon,\n c as ScrVers,\n l as ScrVersType,\n M as VerseRef,\n v as VerseRefException\n};\n//# sourceMappingURL=index.es.js.map\n","'use strict';\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties,\n * including NodeList.\n *\n * @param {T[] | { length: number; [number]: T }} list\n * @param {function (item: T, index: number, list:T[]):boolean} predicate\n * @param {Partial>?} ac\n * Allows injecting a custom implementation in tests (`Array.prototype` by default).\n * @returns {T | undefined}\n * @template {unknown} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (hasOwn(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * If `Object.getOwnPropertyDescriptors` is available,\n * a new object with all properties of object but without any prototype is created and returned\n * after freezing it.\n *\n * @param {T} object\n * The object to freeze.\n * @param {Pick} [oc=Object]\n * `Object` by default,\n * allows to inject custom object constructor for tests.\n * @returns {Readonly}\n * @template {Object} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n * @prettierignore\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object;\n\t}\n\tif (oc && typeof oc.getOwnPropertyDescriptors === 'function') {\n\t\tobject = oc.create(null, oc.getOwnPropertyDescriptors(object));\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;\n}\n\n/**\n * Implementation for `Object.hasOwn` but ES5 compatible.\n *\n * @param {any} object\n * @param {string | number} key\n * @returns {boolean}\n */\nfunction hasOwn(object, key) {\n\treturn Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Since xmldom can not rely on `Object.assign`,\n * it uses/provides a simplified version that is sufficient for its needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n * @returns {Object}\n * The target with the merged/overridden properties.\n * @throws {TypeError}\n * If target is not an object.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object');\n\t}\n\tfor (var key in source) {\n\t\tif (hasOwn(source, key)) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * A number of attributes are boolean attributes.\n * The presence of a boolean attribute on an element represents the `true` value,\n * and the absence of the attribute represents the `false` value.\n *\n * If the attribute is present, its value must either be the empty string, or a value that is\n * an ASCII case-insensitive match for the attribute's canonical name,\n * with no leading or trailing whitespace.\n *\n * Note: The values `\"true\"` and `\"false\"` are not allowed on boolean attributes.\n * To represent a `false` value, the attribute has to be omitted altogether.\n *\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nvar HTML_BOOLEAN_ATTRIBUTES = freeze({\n\tallowfullscreen: true,\n\tasync: true,\n\tautofocus: true,\n\tautoplay: true,\n\tchecked: true,\n\tcontrols: true,\n\tdefault: true,\n\tdefer: true,\n\tdisabled: true,\n\tformnovalidate: true,\n\thidden: true,\n\tismap: true,\n\titemscope: true,\n\tloop: true,\n\tmultiple: true,\n\tmuted: true,\n\tnomodule: true,\n\tnovalidate: true,\n\topen: true,\n\tplaysinline: true,\n\treadonly: true,\n\trequired: true,\n\treversed: true,\n\tselected: true,\n});\n\n/**\n * Check if `name` is matching one of the HTML boolean attribute names.\n * This method doesn't check if such attributes are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} name\n * @returns {boolean}\n * @see {@link HTML_BOOLEAN_ATTRIBUTES}\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nfunction isHTMLBooleanAttribute(name) {\n\treturn hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());\n}\n\n/**\n * Void elements only have a start tag; end tags must not be specified for void elements.\n * These elements should be written as self-closing like this: ``.\n * This should not be confused with optional tags that HTML allows to omit the end tag for\n * (like `li`, `tr` and others), which can have content after them,\n * so they can not be written as self-closing.\n * xmldom does not have any logic for optional end tags cases,\n * and will report them as a warning.\n * Content that would go into the unopened element,\n * will instead be added as a sibling text node.\n *\n * @type {Readonly<{\n * \tarea: boolean;\n * \tcol: boolean;\n * \timg: boolean;\n * \twbr: boolean;\n * \tlink: boolean;\n * \thr: boolean;\n * \tsource: boolean;\n * \tbr: boolean;\n * \tinput: boolean;\n * \tparam: boolean;\n * \tmeta: boolean;\n * \tembed: boolean;\n * \ttrack: boolean;\n * \tbase: boolean;\n * }>}\n * @see https://html.spec.whatwg.org/#void-elements\n * @see https://html.spec.whatwg.org/#optional-tags\n */\nvar HTML_VOID_ELEMENTS = freeze({\n\tarea: true,\n\tbase: true,\n\tbr: true,\n\tcol: true,\n\tembed: true,\n\thr: true,\n\timg: true,\n\tinput: true,\n\tlink: true,\n\tmeta: true,\n\tparam: true,\n\tsource: true,\n\ttrack: true,\n\twbr: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML void element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link HTML_VOID_ELEMENTS}\n * @see https://html.spec.whatwg.org/#void-elements\n */\nfunction isHTMLVoidElement(tagName) {\n\treturn hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());\n}\n\n/**\n * Tag names that are raw text elements according to HTML spec.\n * The value denotes whether they are escapable or not.\n *\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link isHTMLRawTextElement}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nvar HTML_RAW_TEXT_ELEMENTS = freeze({\n\tscript: false,\n\tstyle: false,\n\ttextarea: true,\n\ttitle: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Check if `tagName` is matching one of the HTML escapable raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLEscapableRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'text/html'}\n * @see https://www.iana.org/assignments/media-types/text/html\n * @see https://en.wikipedia.org/wiki/HTML\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n */\nfunction isHTMLMimeType(mimeType) {\n\treturn mimeType === MIME_TYPE.HTML;\n}\n/**\n * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the\n * HTML namespace is provided as the default.\n *\n * @param {string} mimeType\n * @returns {boolean}\n * @see https://dom.spec.whatwg.org/#dom-document-createelement\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n */\nfunction hasDefaultHTMLNamespace(mimeType) {\n\treturn isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02\n * MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype\n * WHATWG HTML Spec\n * @see {@link DOMParser.prototype.parseFromString}\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n\t * WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType\n\t * registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/xml`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType\n\t * registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n});\n/**\n * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n * MimeType\n */\n/**\n * @type {MimeType[]}\n * @private\n * Basically `Object.values`, which is not available in ES5.\n */\nvar _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {\n\treturn MIME_TYPE[key];\n});\n\n/**\n * Only returns true if `mimeType` is one of the allowed values for\n * `DOMParser.parseFromString`.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n *\n */\nfunction isValidMimeType(mimeType) {\n\treturn _MIME_TYPES.indexOf(mimeType) > -1;\n}\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace.\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n});\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;\nexports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;\nexports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;\nexports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;\nexports.hasOwn = hasOwn;\nexports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;\nexports.isHTMLRawTextElement = isHTMLRawTextElement;\nexports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;\nexports.isHTMLMimeType = isHTMLMimeType;\nexports.isHTMLVoidElement = isHTMLVoidElement;\nexports.isValidMimeType = isValidMimeType;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","'use strict';\n\nvar conventions = require('./conventions');\n\nfunction extendError(constructor, writableName) {\n\tconstructor.prototype = Object.create(Error.prototype, {\n\t\tconstructor: { value: constructor },\n\t\tname: { value: constructor.name, enumerable: true, writable: writableName },\n\t});\n}\n\nvar DOMExceptionName = conventions.freeze({\n\t/**\n\t * the default value as defined by the spec\n\t */\n\tError: 'Error',\n\t/**\n\t * @deprecated\n\t * Use RangeError instead.\n\t */\n\tIndexSizeError: 'IndexSizeError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tDomstringSizeError: 'DomstringSizeError',\n\tHierarchyRequestError: 'HierarchyRequestError',\n\tWrongDocumentError: 'WrongDocumentError',\n\tInvalidCharacterError: 'InvalidCharacterError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tNoDataAllowedError: 'NoDataAllowedError',\n\tNoModificationAllowedError: 'NoModificationAllowedError',\n\tNotFoundError: 'NotFoundError',\n\tNotSupportedError: 'NotSupportedError',\n\tInUseAttributeError: 'InUseAttributeError',\n\tInvalidStateError: 'InvalidStateError',\n\tSyntaxError: 'SyntaxError',\n\tInvalidModificationError: 'InvalidModificationError',\n\tNamespaceError: 'NamespaceError',\n\t/**\n\t * @deprecated\n\t * Use TypeError for invalid arguments,\n\t * \"NotSupportedError\" DOMException for unsupported operations,\n\t * and \"NotAllowedError\" DOMException for denied requests instead.\n\t */\n\tInvalidAccessError: 'InvalidAccessError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tValidationError: 'ValidationError',\n\t/**\n\t * @deprecated\n\t * Use TypeError instead.\n\t */\n\tTypeMismatchError: 'TypeMismatchError',\n\tSecurityError: 'SecurityError',\n\tNetworkError: 'NetworkError',\n\tAbortError: 'AbortError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tURLMismatchError: 'URLMismatchError',\n\tQuotaExceededError: 'QuotaExceededError',\n\tTimeoutError: 'TimeoutError',\n\tInvalidNodeTypeError: 'InvalidNodeTypeError',\n\tDataCloneError: 'DataCloneError',\n\tEncodingError: 'EncodingError',\n\tNotReadableError: 'NotReadableError',\n\tUnknownError: 'UnknownError',\n\tConstraintError: 'ConstraintError',\n\tDataError: 'DataError',\n\tTransactionInactiveError: 'TransactionInactiveError',\n\tReadOnlyError: 'ReadOnlyError',\n\tVersionError: 'VersionError',\n\tOperationError: 'OperationError',\n\tNotAllowedError: 'NotAllowedError',\n\tOptOutError: 'OptOutError',\n});\nvar DOMExceptionNames = Object.keys(DOMExceptionName);\n\nfunction isValidDomExceptionCode(value) {\n\treturn typeof value === 'number' && value >= 1 && value <= 25;\n}\nfunction endsWithError(value) {\n\treturn typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;\n}\n/**\n * DOM operations only raise exceptions in \"exceptional\" circumstances, i.e., when an operation\n * is impossible to perform (either for logical reasons, because data is lost, or because the\n * implementation has become unstable). In general, DOM methods return specific error values in\n * ordinary processing situations, such as out-of-bound errors when using NodeList.\n *\n * Implementations should raise other exceptions under other circumstances. For example,\n * implementations should raise an implementation-dependent exception if a null argument is\n * passed when null was not expected.\n *\n * This implementation supports the following usages:\n * 1. according to the living standard (both arguments are optional):\n * ```\n * new DOMException(\"message (can be empty)\", DOMExceptionNames.HierarchyRequestError)\n * ```\n * 2. according to previous xmldom implementation (only the first argument is required):\n * ```\n * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, \"optional message\")\n * ```\n * both result in the proper name being set.\n *\n * @class DOMException\n * @param {number | string} messageOrCode\n * The reason why an operation is not acceptable.\n * If it is a number, it is used to determine the `name`, see\n * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}\n * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]\n * The `name` to use for the error.\n * If `messageOrCode` is a number, this arguments is used as the `message` instead.\n * @augments Error\n * @see https://webidl.spec.whatwg.org/#idl-DOMException\n * @see https://webidl.spec.whatwg.org/#dfn-error-names-table\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(messageOrCode, nameOrMessage) {\n\t// support old way of passing arguments: first argument is a valid number\n\tif (isValidDomExceptionCode(messageOrCode)) {\n\t\tthis.name = DOMExceptionNames[messageOrCode];\n\t\tthis.message = nameOrMessage || '';\n\t} else {\n\t\tthis.message = messageOrCode;\n\t\tthis.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;\n\t}\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n}\nextendError(DOMException, true);\nObject.defineProperties(DOMException.prototype, {\n\tcode: {\n\t\tenumerable: true,\n\t\tget: function () {\n\t\t\tvar code = DOMExceptionNames.indexOf(this.name);\n\t\t\tif (isValidDomExceptionCode(code)) return code;\n\t\t\treturn 0;\n\t\t},\n\t},\n});\n\nvar ExceptionCode = {\n\tINDEX_SIZE_ERR: 1,\n\tDOMSTRING_SIZE_ERR: 2,\n\tHIERARCHY_REQUEST_ERR: 3,\n\tWRONG_DOCUMENT_ERR: 4,\n\tINVALID_CHARACTER_ERR: 5,\n\tNO_DATA_ALLOWED_ERR: 6,\n\tNO_MODIFICATION_ALLOWED_ERR: 7,\n\tNOT_FOUND_ERR: 8,\n\tNOT_SUPPORTED_ERR: 9,\n\tINUSE_ATTRIBUTE_ERR: 10,\n\tINVALID_STATE_ERR: 11,\n\tSYNTAX_ERR: 12,\n\tINVALID_MODIFICATION_ERR: 13,\n\tNAMESPACE_ERR: 14,\n\tINVALID_ACCESS_ERR: 15,\n\tVALIDATION_ERR: 16,\n\tTYPE_MISMATCH_ERR: 17,\n\tSECURITY_ERR: 18,\n\tNETWORK_ERR: 19,\n\tABORT_ERR: 20,\n\tURL_MISMATCH_ERR: 21,\n\tQUOTA_EXCEEDED_ERR: 22,\n\tTIMEOUT_ERR: 23,\n\tINVALID_NODE_TYPE_ERR: 24,\n\tDATA_CLONE_ERR: 25,\n};\n\nvar entries = Object.entries(ExceptionCode);\nfor (var i = 0; i < entries.length; i++) {\n\tvar key = entries[i][0];\n\tDOMException[key] = entries[i][1];\n}\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @class\n * @param {string} message\n * @param {any} [locator]\n */\nfunction ParseError(message, locator) {\n\tthis.message = message;\n\tthis.locator = locator;\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nextendError(ParseError);\n\nexports.DOMException = DOMException;\nexports.DOMExceptionName = DOMExceptionName;\nexports.ExceptionCode = ExceptionCode;\nexports.ParseError = ParseError;\n","'use strict';\n\n/**\n * Detects relevant unicode support for regular expressions in the runtime.\n * Should the runtime not accepts the flag `u` or unicode ranges,\n * character classes without unicode handling will be used.\n *\n * @param {typeof RegExp} [RegExpImpl=RegExp]\n * For testing: the RegExp class.\n * @returns {boolean}\n * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags\n */\nfunction detectUnicodeSupport(RegExpImpl) {\n\ttry {\n\t\tif (typeof RegExpImpl !== 'function') {\n\t\t\tRegExpImpl = RegExp;\n\t\t}\n\t\t// eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape\n\t\tvar match = new RegExpImpl('\\u{1d306}', 'u').exec('𝌆');\n\t\treturn !!match && match[0].length === 2;\n\t} catch (error) {}\n\treturn false;\n}\nvar UNICODE_SUPPORT = detectUnicodeSupport();\n\n/**\n * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.\n *\n * @param {RegExp} regexp\n */\nfunction chars(regexp) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error(regexp + ' can not be used with chars');\n\t}\n\treturn regexp.source.slice(1, regexp.source.lastIndexOf(']'));\n}\n\n/**\n * Creates a new character list regular expression,\n * by removing `search` from the source of `regexp`.\n *\n * @param {RegExp} regexp\n * @param {string} search\n * The character(s) to remove.\n * @returns {RegExp}\n */\nfunction chars_without(regexp, search) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error('/' + regexp.source + '/ can not be used with chars_without');\n\t}\n\tif (!search || typeof search !== 'string') {\n\t\tthrow new Error(JSON.stringify(search) + ' is not a valid search');\n\t}\n\tif (regexp.source.indexOf(search) === -1) {\n\t\tthrow new Error('\"' + search + '\" is not is /' + regexp.source + '/');\n\t}\n\tif (search === '-' && regexp.source.indexOf(search) !== 1) {\n\t\tthrow new Error('\"' + search + '\" is not at the first postion of /' + regexp.source + '/');\n\t}\n\treturn new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');\n}\n\n/**\n * Combines and Regular expressions correctly by using `RegExp.source`.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction reg(args) {\n\tvar self = this;\n\treturn new RegExp(\n\t\tArray.prototype.slice\n\t\t\t.call(arguments)\n\t\t\t.map(function (part) {\n\t\t\t\tvar isStr = typeof part === 'string';\n\t\t\t\tif (isStr && self === undefined && part === '|') {\n\t\t\t\t\tthrow new Error('use regg instead of reg to wrap expressions with `|`!');\n\t\t\t\t}\n\t\t\t\treturn isStr ? part : part.source;\n\t\t\t})\n\t\t\t.join(''),\n\t\tUNICODE_SUPPORT ? 'mu' : 'm'\n\t);\n}\n\n/**\n * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction regg(args) {\n\tif (arguments.length === 0) {\n\t\tthrow new Error('no parameters provided');\n\t}\n\treturn reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));\n}\n\n// /**\n// * Append ^ to the beginning of the expression.\n// * @param {...(RegExp | string)[]} args\n// * @returns {RegExp}\n// */\n// function reg_start(args) {\n// \tif (arguments.length === 0) {\n// \t\tthrow new Error('no parameters provided');\n// \t}\n// \treturn reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));\n// }\n\n// https://www.w3.org/TR/xml/#document\n// `[1] document ::= prolog element Misc*`\n// https://www.w3.org/TR/xml11/#NT-document\n// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`\n\n/**\n * A character usually appearing in wrongly converted strings.\n *\n * @type {string}\n * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character\n * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings\n * @see https://www.unicode.org/faq/utf_bom.html#BOM\n * @readonly\n */\nvar UNICODE_REPLACEMENT_CHARACTER = '\\uFFFD';\n// https://www.w3.org/TR/xml/#NT-Char\n// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-Char\n// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-RestrictedChar\n// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`\n// https://www.w3.org/TR/xml11/#charsets\nvar Char = /[-\\x09\\x0A\\x0D\\x20-\\x2C\\x2E-\\uD7FF\\uE000-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tChar = reg('[', chars(Char), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\n\nvar _SChar = /[\\x20\\x09\\x0D\\x0A]/;\nvar SChar_s = chars(_SChar);\n// https://www.w3.org/TR/xml11/#NT-S\n// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`\nvar S = reg(_SChar, '+');\n// optional whitespace described as `S?` in the grammar,\n// simplified to 0-n occurrences of the character class\n// instead of 0-1 occurrences of a non-capturing group around S\nvar S_OPT = reg(_SChar, '*');\n\n// https://www.w3.org/TR/xml11/#NT-NameStartChar\n// `[4] NameStartChar ::= \":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`\nvar NameStartChar =\n\t/[:_a-zA-Z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02FF\\u0370-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tNameStartChar = reg('[', chars(NameStartChar), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\nvar NameStartChar_s = chars(NameStartChar);\n\n// https://www.w3.org/TR/xml11/#NT-NameChar\n// `[4a] NameChar ::= NameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`\nvar NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\\xB7]/), chars(/[\\u0300-\\u036F\\u203F-\\u2040]/), ']');\n// https://www.w3.org/TR/xml11/#NT-Name\n// `[5] Name ::= NameStartChar (NameChar)*`\nvar Name = reg(NameStartChar, NameChar, '*');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Names\n`[6] Names ::= Name (#x20 Name)*`\n*/\n\n// https://www.w3.org/TR/xml11/#NT-Nmtoken\n// `[7] Nmtoken ::= (NameChar)+`\nvar Nmtoken = reg(NameChar, '+');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Nmtokens\n`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`\nvar Nmtokens = reg(Nmtoken, regg(/\\x20/, Nmtoken), '*');\n*/\n\n// https://www.w3.org/TR/xml11/#NT-EntityRef\n// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\nvar EntityRef = reg('&', Name, ';');\n// https://www.w3.org/TR/xml11/#NT-CharRef\n// `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\nvar CharRef = regg(/&#[0-9]+;|&#x[0-9a-fA-F]+;/);\n\n/*\nhttps://www.w3.org/TR/xml11/#NT-Reference\n- `[67] Reference ::= EntityRef | CharRef`\n- `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\n- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\n*/\nvar Reference = regg(EntityRef, '|', CharRef);\n\n// https://www.w3.org/TR/xml11/#NT-PEReference\n// `[69] PEReference ::= '%' Name ';'`\n// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]\nvar PEReference = reg('%', Name, ';');\n\n// https://www.w3.org/TR/xml11/#NT-EntityValue\n// `[9] EntityValue ::= '\"' ([^%&\"] | PEReference | Reference)* '\"' | \"'\" ([^%&'] | PEReference | Reference)* \"'\"`\nvar EntityValue = regg(\n\treg('\"', regg(/[^%&\"]/, '|', PEReference, '|', Reference), '*', '\"'),\n\t'|',\n\treg(\"'\", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', \"'\")\n);\n\n// https://www.w3.org/TR/xml11/#NT-AttValue\n// `[10] AttValue ::= '\"' ([^<&\"] | Reference)* '\"' | \"'\" ([^<&'] | Reference)* \"'\"`\nvar AttValue = regg('\"', regg(/[^<&\"]/, '|', Reference), '*', '\"', '|', \"'\", regg(/[^<&']/, '|', Reference), '*', \"'\");\n\n// https://www.w3.org/TR/xml-names/#ns-decl\n// https://www.w3.org/TR/xml-names/#ns-qualnames\n// NameStartChar without \":\"\nvar NCNameStartChar = chars_without(NameStartChar, ':');\n// https://www.w3.org/TR/xml-names/#orphans\n// `[5] NCNameChar ::= NameChar - ':'`\n// An XML NameChar, minus the \":\"\nvar NCNameChar = chars_without(NameChar, ':');\n// https://www.w3.org/TR/xml-names/#NT-NCName\n// `[4] NCName ::= Name - (Char* ':' Char*)`\n// An XML Name, minus the \":\"\nvar NCName = reg(NCNameStartChar, NCNameChar, '*');\n\n/**\nhttps://www.w3.org/TR/xml-names/#ns-qualnames\n\n```\n[7] QName ::= PrefixedName | UnprefixedName\n\t\t\t\t === (NCName ':' NCName) | NCName\n\t\t\t\t === NCName (':' NCName)?\n[8] PrefixedName ::= Prefix ':' LocalPart\n\t\t\t\t\t\t\t\t === NCName ':' NCName\n[9] UnprefixedName ::= LocalPart\n\t\t\t\t\t\t\t\t\t === NCName\n[10] Prefix ::= NCName\n[11] LocalPart ::= NCName\n```\n*/\nvar QName = reg(NCName, regg(':', NCName), '?');\nvar QName_exact = reg('^', QName, '$');\nvar QName_group = reg('(', QName, ')');\n\n// https://www.w3.org/TR/xml11/#NT-SystemLiteral\n// `[11] SystemLiteral ::= ('\"' [^\"]* '\"') | (\"'\" [^']* \"'\")`\nvar SystemLiteral = regg(/\"[^\"]*\"|'[^']*'/);\n\n/*\n https://www.w3.org/TR/xml11/#NT-PI\n ```\n [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))\n [16] PI ::= '' Char*)))? '?>'\n ```\n target /xml/i is not excluded!\n*/\nvar PI = reg(/^<\\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\\?>/);\n\n// https://www.w3.org/TR/xml11/#NT-PubidChar\n// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`\nvar PubidChar = /[\\x20\\x0D\\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;\n\n// https://www.w3.org/TR/xml11/#NT-PubidLiteral\n// `[12] PubidLiteral ::= '\"' PubidChar* '\"' | \"'\" (PubidChar - \"'\")* \"'\"`\nvar PubidLiteral = regg('\"', PubidChar, '*\"', '|', \"'\", chars_without(PubidChar, \"'\"), \"*'\");\n\n// https://www.w3.org/TR/xml11/#NT-CharData\n// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`\n\nvar COMMENT_START = '';\n// https://www.w3.org/TR/xml11/#NT-Comment\n// `[15] Comment ::= ''`\nvar Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);\n\nvar PCDATA = '#PCDATA';\n// https://www.w3.org/TR/xml11/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// https://www.w3.org/TR/xml-names/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]\nvar Mixed = regg(\n\treg(/\\(/, S_OPT, PCDATA, regg(S_OPT, /\\|/, S_OPT, QName), '*', S_OPT, /\\)\\*/),\n\t'|',\n\treg(/\\(/, S_OPT, PCDATA, S_OPT, /\\)/)\n);\n\nvar _children_quantity = /[?*+]?/;\n/*\n `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]\n `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');\n ```\n [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?\n === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?\n !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?\n ```\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.\nhttps://github.com/xmldom/xmldom/security/code-scanning/91\nvar choice = regg(/\\(/, S_OPT, cp, regg(S_OPT, /\\|/, S_OPT, cp), '+', S_OPT, /\\)/);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.\nhttps://github.com/xmldom/xmldom/security/code-scanning/92\nvar seq = regg(/\\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\\)/);\n*/\n\n// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`\n// simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\nvar children = reg(/\\([^>]+\\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);\n\n// https://www.w3.org/TR/xml11/#NT-contentspec\n// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`\nvar contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);\n\nvar ELEMENTDECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-elementdecl\n// `[17] elementdecl ::= ''`\n// because of https://www.w3.org/TR/xml11/#NT-PEReference\n// since xmldom is not supporting replacements of PEReferences in the DTD\n// this also supports PEReference in the possible places\nvar elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');\n\n// https://www.w3.org/TR/xml11/#NT-NotationType\n// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`\n// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]\nvar NotationType = reg('NOTATION', S, /\\(/, S_OPT, Name, regg(S_OPT, /\\|/, S_OPT, Name), '*', S_OPT, /\\)/);\n// https://www.w3.org/TR/xml11/#NT-Enumeration\n// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`\n// [VC: Enumeration] [VC: No Duplicate Tokens]\nvar Enumeration = reg(/\\(/, S_OPT, Nmtoken, regg(S_OPT, /\\|/, S_OPT, Nmtoken), '*', S_OPT, /\\)/);\n\n// https://www.w3.org/TR/xml11/#NT-EnumeratedType\n// `[57] EnumeratedType ::= NotationType | Enumeration`\nvar EnumeratedType = regg(NotationType, '|', Enumeration);\n\n/*\n```\n[55] StringType ::= 'CDATA'\n[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]\n | 'IDREF' [VC: IDREF]\n | 'IDREFS' [VC: IDREF]\n\t | 'ENTITY' [VC: Entity Name]\n\t | 'ENTITIES' [VC: Entity Name]\n\t | 'NMTOKEN' [VC: Name Token]\n\t | 'NMTOKENS' [VC: Name Token]\n [54] AttType ::= StringType | TokenizedType | EnumeratedType\n```*/\nvar AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);\n\n// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`\n// [WFC: No < in Attribute Values] [WFC: No External Entity References]\n// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]\nvar DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));\n\n// https://www.w3.org/TR/xml11/#NT-AttDef\n// [53] AttDef ::= S Name S AttType S DefaultDecl\n// https://www.w3.org/TR/xml-names/#NT-AttDef\n// [1] NSAttName ::= PrefixedAttName | DefaultAttName\n// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]\n// [3] DefaultAttName ::= 'xmlns'\n// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl\n// \t\t\t\t\t\t === S Name S AttType S DefaultDecl\n// xmldom is not distinguishing between QName and NSAttName on this level\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttDef = regg(S, Name, S, AttType, S, DefaultDecl);\n\nvar ATTLIST_DECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-AttlistDecl\n// `[20] AttlistDecl ::= ''`\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');\n\n// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat\nvar ABOUT_LEGACY_COMPAT = 'about:legacy-compat';\nvar ABOUT_LEGACY_COMPAT_SystemLiteral = regg('\"' + ABOUT_LEGACY_COMPAT + '\"', '|', \"'\" + ABOUT_LEGACY_COMPAT + \"'\");\nvar SYSTEM = 'SYSTEM';\nvar PUBLIC = 'PUBLIC';\n// https://www.w3.org/TR/xml11/#NT-ExternalID\n// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`\nvar ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));\nvar ExternalID_match = reg(\n\t'^',\n\tregg(\n\t\tregg(SYSTEM, S, '(?', SystemLiteral, ')'),\n\t\t'|',\n\t\tregg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')\n\t)\n);\n\n// https://www.w3.org/TR/xml11/#NT-NDataDecl\n// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]\nvar NDataDecl = regg(S, 'NDATA', S, Name);\n\n// https://www.w3.org/TR/xml11/#NT-EntityDef\n// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`\nvar EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));\n\nvar ENTITY_DECL_START = ''`\nvar GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-PEDef\n// `[74] PEDef ::= EntityValue | ExternalID`\nvar PEDef = regg(EntityValue, '|', ExternalID);\n// https://www.w3.org/TR/xml11/#NT-PEDecl\n// `[72] PEDecl ::= ''`\nvar PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-EntityDecl\n// `[70] EntityDecl ::= GEDecl | PEDecl`\nvar EntityDecl = regg(GEDecl, '|', PEDecl);\n\n// https://www.w3.org/TR/xml11/#NT-PublicID\n// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`\nvar PublicID = reg(PUBLIC, S, PubidLiteral);\n// https://www.w3.org/TR/xml11/#NT-NotationDecl\n// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]\nvar NotationDecl = reg('');\n\n// https://www.w3.org/TR/xml11/#NT-Eq\n// `[25] Eq ::= S? '=' S?`\nvar Eq = reg(S_OPT, '=', S_OPT);\n// https://www.w3.org/TR/xml/#NT-VersionNum\n// `[26] VersionNum ::= '1.' [0-9]+`\n// https://www.w3.org/TR/xml11/#NT-VersionNum\n// `[26] VersionNum ::= '1.1'`\nvar VersionNum = /1[.]\\d+/;\n// https://www.w3.org/TR/xml11/#NT-VersionInfo\n// `[24] VersionInfo ::= S 'version' Eq (\"'\" VersionNum \"'\" | '\"' VersionNum '\"')`\nvar VersionInfo = reg(S, 'version', Eq, regg(\"'\", VersionNum, \"'\", '|', '\"', VersionNum, '\"'));\n// https://www.w3.org/TR/xml11/#NT-EncName\n// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`\nvar EncName = /[A-Za-z][-A-Za-z0-9._]*/;\n// https://www.w3.org/TR/xml11/#NT-EncDecl\n// `[80] EncodingDecl ::= S 'encoding' Eq ('\"' EncName '\"' | \"'\" EncName \"'\" )`\nvar EncodingDecl = regg(S, 'encoding', Eq, regg('\"', EncName, '\"', '|', \"'\", EncName, \"'\"));\n// https://www.w3.org/TR/xml11/#NT-SDDecl\n// `[32] SDDecl ::= S 'standalone' Eq ((\"'\" ('yes' | 'no') \"'\") | ('\"' ('yes' | 'no') '\"'))`\nvar SDDecl = regg(S, 'standalone', Eq, regg(\"'\", regg('yes', '|', 'no'), \"'\", '|', '\"', regg('yes', '|', 'no'), '\"'));\n// https://www.w3.org/TR/xml11/#NT-XMLDecl\n// [23] XMLDecl ::= ''\nvar XMLDecl = reg(/^<\\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\\?>/);\n\n/*\n https://www.w3.org/TR/xml/#NT-markupdecl\n https://www.w3.org/TR/xml11/#NT-markupdecl\n `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`\n var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);\n*/\n/*\n https://www.w3.org/TR/xml-names/#NT-doctypedecl\n`[28a] DeclSep ::= PEReference | S`\n https://www.w3.org/TR/xml11/#NT-intSubset\n```\n [28b] intSubset ::= (markupdecl | DeclSep)*\n === (markupdecl | PEReference | S)*\n```\n [WFC: PE Between Declarations]\n var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');\n*/\nvar DOCTYPE_DECL_START = ''`\n https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl\n `[16] doctypedecl ::= ''`\n var doctypedecl = reg('');\n*/\n\nvar CDATA_START = '';\nvar CDStart = //;\nvar CData = reg(Char, '*?', CDEnd);\n/*\n https://www.w3.org/TR/xml/#dt-cdsection\n `[18] \tCDSect\t ::= \tCDStart CData CDEnd`\n `[19] \tCDStart\t ::= \t'' Char*))`\n `[21] \tCDEnd\t ::= \t']]>'`\n*/\nvar CDSect = reg(CDStart, CData);\n\n// unit tested\nexports.chars = chars;\nexports.chars_without = chars_without;\nexports.detectUnicodeSupport = detectUnicodeSupport;\nexports.reg = reg;\nexports.regg = regg;\nexports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;\nexports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;\nexports.AttlistDecl = AttlistDecl;\nexports.CDATA_START = CDATA_START;\nexports.CDATA_END = CDATA_END;\nexports.CDSect = CDSect;\nexports.Char = Char;\nexports.Comment = Comment;\nexports.COMMENT_START = COMMENT_START;\nexports.COMMENT_END = COMMENT_END;\nexports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;\nexports.elementdecl = elementdecl;\nexports.EntityDecl = EntityDecl;\nexports.EntityValue = EntityValue;\nexports.ExternalID = ExternalID;\nexports.ExternalID_match = ExternalID_match;\nexports.Name = Name;\nexports.NotationDecl = NotationDecl;\nexports.Reference = Reference;\nexports.PEReference = PEReference;\nexports.PI = PI;\nexports.PUBLIC = PUBLIC;\nexports.PubidLiteral = PubidLiteral;\nexports.QName = QName;\nexports.QName_exact = QName_exact;\nexports.QName_group = QName_group;\nexports.S = S;\nexports.SChar_s = SChar_s;\nexports.S_OPT = S_OPT;\nexports.SYSTEM = SYSTEM;\nexports.SystemLiteral = SystemLiteral;\nexports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;\nexports.UNICODE_SUPPORT = UNICODE_SUPPORT;\nexports.XMLDecl = XMLDecl;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar find = conventions.find;\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar hasOwn = conventions.hasOwn;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar isHTMLVoidElement = conventions.isHTMLVoidElement;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * Private DOM Constructor symbol\n *\n * Internal symbol used for construction of all classes whose constructors should be private.\n * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,\n * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`\n * so the constructor can't be used from outside the module.\n */\nvar PDC = Symbol();\n\nvar errors = require('./errors');\nvar DOMException = errors.DOMException;\nvar DOMExceptionName = errors.DOMExceptionName;\n\nvar g = require('./grammar');\n\n/**\n * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)\n * and throws an Illegal constructor exception when the symbols don't match.\n * This ensures that the constructor remains private and can't be used outside this module.\n */\nfunction checkSymbol(symbol) {\n\tif (symbol !== PDC) {\n\t\tthrow new TypeError('Illegal constructor');\n\t}\n}\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty.\n *\n * @param {string} input\n * The string to be checked.\n * @returns {boolean}\n * Returns `true` if the input string is not empty, `false` otherwise.\n */\nfunction notEmptyString(input) {\n\treturn input !== '';\n}\n/**\n * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,\n * U+0020 SPACE).\n * It follows the definition from the infra specification from WHATWG.\n *\n * @param {string} input\n * The string to be split.\n * @returns {string[]}\n * An array of the split strings. The array can be empty if the input string is empty or only\n * contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}\n * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : [];\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * The current record object to which the element will be added as a key.\n * The object's keys are string types and values are either boolean or undefined.\n * @param {string} element\n * The string to be added as a key to the current record.\n * @returns {Record}\n * The updated record object after the addition of the new element.\n */\nfunction orderedSetReducer(current, element) {\n\tif (!hasOwn(current, element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * Converts a string into an ordered set by splitting the input on ASCII whitespace and\n * ensuring uniqueness of elements.\n * This follows the definition of an ordered set from the infra specification by WHATWG.\n *\n * @param {string} input\n * The input string to be transformed into an ordered set.\n * @returns {string[]}\n * An array of unique strings obtained from the input, preserving the original order.\n * The array can be empty if the input string is empty or only contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#ordered-set}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}));\n}\n\n/**\n * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.\n * This function is used in environments where `Array.prototype.includes` may not be available.\n *\n * @param {any[]} list\n * The array in which to search for the element.\n * @returns {function(any): boolean}\n * A function that accepts an element and returns a boolean indicating whether the element is\n * included in the provided list.\n */\nfunction arrayIncludes(list) {\n\treturn function (element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t};\n}\n\n/**\n * Validates a qualified name based on the criteria provided in the DOM specification by\n * WHATWG.\n *\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @throws {DOMException}\n * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an\n * invalid character.\n * @see {@link https://dom.spec.whatwg.org/#validate}\n */\nfunction validateQualifiedName(qualifiedName) {\n\tif (!g.QName_exact.test(qualifiedName)) {\n\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name \"' + qualifiedName + '\"');\n\t}\n}\n\n/**\n * Validates a qualified name and the namespace associated with it,\n * based on the criteria provided in the DOM specification by WHATWG.\n *\n * @param {string | null} namespace\n * The namespace to be validated. It can be a string or null.\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @returns {[namespace: string | null, prefix: string | null, localName: string]}\n * Returns a tuple with the namespace,\n * prefix and local name of the qualified name.\n * @throws {DOMException}\n * Throws a DOMException if the qualified name or the namespace is not valid.\n * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}\n */\nfunction validateAndExtract(namespace, qualifiedName) {\n\tvalidateQualifiedName(qualifiedName);\n\tnamespace = namespace || null;\n\t/**\n\t * @type {string | null}\n\t */\n\tvar prefix = null;\n\tvar localName = qualifiedName;\n\tif (qualifiedName.indexOf(':') >= 0) {\n\t\tvar splitResult = qualifiedName.split(':');\n\t\tprefix = splitResult[0];\n\t\tlocalName = splitResult[1];\n\t}\n\tif (prefix !== null && namespace === null) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');\n\t}\n\tif (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is \"xml\" and namespace is not the XML namespace');\n\t}\n\tif ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'either qualifiedName or prefix is \"xmlns\" and namespace is not the XMLNS namespace'\n\t\t);\n\t}\n\tif (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'namespace is the XMLNS namespace and neither qualifiedName nor prefix is \"xmlns\"'\n\t\t);\n\t}\n\treturn [namespace, prefix, localName];\n}\n\n/**\n * Copies properties from one object to another.\n * It only copies the object's own (not inherited) properties.\n *\n * @param {Object} src\n * The source object from which properties are copied.\n * @param {Object} dest\n * The destination object to which properties are copied.\n */\nfunction copy(src, dest) {\n\tfor (var p in src) {\n\t\tif (hasOwn(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n * Extends a class with the properties and methods of a super class.\n * It uses a form of prototypal inheritance, and establishes the `constructor` property\n * correctly(?).\n *\n * It is not clear to the current maintainers if this implementation is making sense,\n * since it creates an intermediate prototype function,\n * which all properties of `Super` are copied onto using `_copy`.\n *\n * @param {Object} Class\n * The class that is to be extended.\n * @param {Object} Super\n * The super class from which properties and methods are inherited.\n * @private\n */\nfunction _extends(Class, Super) {\n\tvar pt = Class.prototype;\n\tif (!(pt instanceof Super)) {\n\t\tfunction t() {}\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt, t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif (pt.constructor != Class) {\n\t\tif (typeof Class != 'function') {\n\t\t\tconsole.error('unknown Class:' + Class);\n\t\t}\n\t\tpt.constructor = Class;\n\t}\n}\n\nvar NodeType = {};\nvar ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);\nvar ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);\nvar TEXT_NODE = (NodeType.TEXT_NODE = 3);\nvar CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);\nvar ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);\nvar ENTITY_NODE = (NodeType.ENTITY_NODE = 6);\nvar PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);\nvar COMMENT_NODE = (NodeType.COMMENT_NODE = 8);\nvar DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);\nvar DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);\nvar DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);\nvar NOTATION_NODE = (NodeType.NOTATION_NODE = 12);\n\nvar DocumentPosition = conventions.freeze({\n\tDOCUMENT_POSITION_DISCONNECTED: 1,\n\tDOCUMENT_POSITION_PRECEDING: 2,\n\tDOCUMENT_POSITION_FOLLOWING: 4,\n\tDOCUMENT_POSITION_CONTAINS: 8,\n\tDOCUMENT_POSITION_CONTAINED_BY: 16,\n\tDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,\n});\n\n//helper functions for compareDocumentPosition\n/**\n * Finds the common ancestor in two parent chains.\n *\n * @param {Node[]} a\n * The first parent chain.\n * @param {Node[]} b\n * The second parent chain.\n * @returns {Node}\n * The common ancestor node if it exists. If there is no common ancestor, the function will\n * return `null`.\n */\nfunction commonAncestor(a, b) {\n\tif (b.length < a.length) return commonAncestor(b, a);\n\tvar c = null;\n\tfor (var n in a) {\n\t\tif (a[n] !== b[n]) return c;\n\t\tc = a[n];\n\t}\n\treturn c;\n}\n\n/**\n * Assigns a unique identifier to a document to ensure consistency while comparing unrelated\n * nodes.\n *\n * @param {Document} doc\n * The document to which a unique identifier is to be assigned.\n * @returns {string}\n * The unique identifier of the document. If the document already had a unique identifier, the\n * function will return the existing one.\n */\nfunction docGUID(doc) {\n\tif (!doc.guid) doc.guid = Math.random();\n\treturn doc.guid;\n}\n//-- end of helper functions\n\n/**\n * The NodeList interface provides the abstraction of an ordered collection of nodes,\n * without defining or constraining how this collection is implemented.\n * NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n * You can also access the items of the NodeList with a `for...of` loop.\n *\n * @class NodeList\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * @constructs NodeList\n */\nfunction NodeList() {}\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1\n\t * inclusive.\n\t *\n\t * @type {number}\n\t */\n\tlength: 0,\n\t/**\n\t * Returns the item at `index`. If index is greater than or equal to the number of nodes in\n\t * the list, this returns null.\n\t *\n\t * @param index\n\t * Unsigned long Index into the collection.\n\t * @returns {Node | null}\n\t * The node at position `index` in the NodeList,\n\t * or null if that is not a valid index.\n\t */\n\titem: function (index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\t/**\n\t * Returns a string representation of the NodeList.\n\t *\n\t * @param {unknown} nodeFilter\n\t * __A filter function? Not implemented according to the spec?__.\n\t * @returns {string}\n\t * A string representation of the NodeList.\n\t */\n\ttoString: function (nodeFilter) {\n\t\tfor (var buf = [], i = 0; i < this.length; i++) {\n\t\t\tserializeToString(this[i], buf, nodeFilter);\n\t\t}\n\t\treturn buf.join('');\n\t},\n\t/**\n\t * Filters the NodeList based on a predicate.\n\t *\n\t * @param {function(Node): boolean} predicate\n\t * - A predicate function to filter the NodeList.\n\t * @returns {Node[]}\n\t * An array of nodes that satisfy the predicate.\n\t * @private\n\t */\n\tfilter: function (predicate) {\n\t\treturn Array.prototype.filter.call(this, predicate);\n\t},\n\t/**\n\t * Returns the first index at which a given node can be found in the NodeList, or -1 if it is\n\t * not present.\n\t *\n\t * @param {Node} item\n\t * - The Node item to locate in the NodeList.\n\t * @returns {number}\n\t * The first index of the node in the NodeList; -1 if not found.\n\t * @private\n\t */\n\tindexOf: function (item) {\n\t\treturn Array.prototype.indexOf.call(this, item);\n\t},\n};\nNodeList.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Represents a live collection of nodes that is automatically updated when its associated\n * document changes.\n *\n * @class LiveNodeList\n * @param {Node} node\n * The associated node.\n * @param {function} refresh\n * The function to refresh the live node list.\n * @augments NodeList\n * @constructs LiveNodeList\n */\nfunction LiveNodeList(node, refresh) {\n\tthis._node = node;\n\tthis._refresh = refresh;\n\t_updateLiveList(this);\n}\n/**\n * Updates the live node list.\n *\n * @param {LiveNodeList} list\n * The live node list to update.\n * @private\n */\nfunction _updateLiveList(list) {\n\tvar inc = list._node._inc || list._node.ownerDocument._inc;\n\tif (list._inc !== inc) {\n\t\tvar ls = list._refresh(list._node);\n\t\t__set__(list, 'length', ls.length);\n\t\tif (!list.$$length || ls.length < list.$$length) {\n\t\t\tfor (var i = ls.length; i in list; i++) {\n\t\t\t\tif (hasOwn(list, i)) {\n\t\t\t\t\tdelete list[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcopy(ls, list);\n\t\tlist._inc = inc;\n\t}\n}\n/**\n * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid\n * index.\n *\n * @param {number} i\n * Index into the collection.\n * @returns {Node | null}\n * The node at position `index` in the LiveNodeList, or null if that is not a valid index.\n */\nLiveNodeList.prototype.item = function (i) {\n\t_updateLiveList(this);\n\treturn this[i] || null;\n};\n\n_extends(LiveNodeList, NodeList);\n\n/**\n * Objects implementing the NamedNodeMap interface are used to represent collections of nodes\n * that can be accessed by name.\n * Note that NamedNodeMap does not inherit from NodeList;\n * NamedNodeMaps are not maintained in any particular order.\n * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal\n * index,\n * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,\n * and does not imply that the DOM specifies an order to these Nodes.\n * NamedNodeMap objects in the DOM are live.\n * used for attributes or DocumentType entities\n *\n * This implementation only supports property indices, but does not support named properties,\n * as specified in the living standard.\n *\n * @class NamedNodeMap\n * @see https://dom.spec.whatwg.org/#interface-namednodemap\n * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names\n * @constructs NamedNodeMap\n */\nfunction NamedNodeMap() {}\n/**\n * Returns the index of a node within the list.\n *\n * @param {Array} list\n * The list of nodes.\n * @param {Node} node\n * The node to find.\n * @returns {number}\n * The index of the node within the list, or -1 if not found.\n * @private\n */\nfunction _findNodeIndex(list, node) {\n\tvar i = 0;\n\twhile (i < list.length) {\n\t\tif (list[i] === node) {\n\t\t\treturn i;\n\t\t}\n\t\ti++;\n\t}\n}\n/**\n * Adds a new attribute to the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which will become the owner of the new attribute.\n * @param {NamedNodeMap} list\n * The list to which the new attribute will be added.\n * @param {Attr} newAttr\n * The new attribute to be added.\n * @param {Attr} oldAttr\n * The old attribute to be replaced, or null if no attribute is to be replaced.\n * @returns {void}\n * @private\n */\nfunction _addNamedNode(el, list, newAttr, oldAttr) {\n\tif (oldAttr) {\n\t\tlist[_findNodeIndex(list, oldAttr)] = newAttr;\n\t} else {\n\t\tlist[list.length] = newAttr;\n\t\tlist.length++;\n\t}\n\tif (el) {\n\t\tnewAttr.ownerElement = el;\n\t\tvar doc = el.ownerDocument;\n\t\tif (doc) {\n\t\t\toldAttr && _onRemoveAttribute(doc, el, oldAttr);\n\t\t\t_onAddAttribute(doc, el, newAttr);\n\t\t}\n\t}\n}\n/**\n * Removes an attribute from the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which is the current owner of the attribute.\n * @param {NamedNodeMap} list\n * The list from which the attribute will be removed.\n * @param {Attr} attr\n * The attribute to be removed.\n * @returns {void}\n * @private\n */\nfunction _removeNamedNode(el, list, attr) {\n\t//console.log('remove attr:'+attr)\n\tvar i = _findNodeIndex(list, attr);\n\tif (i >= 0) {\n\t\tvar lastIndex = list.length - 1;\n\t\twhile (i <= lastIndex) {\n\t\t\tlist[i] = list[++i];\n\t\t}\n\t\tlist.length = lastIndex;\n\t\tif (el) {\n\t\t\tvar doc = el.ownerDocument;\n\t\t\tif (doc) {\n\t\t\t\t_onRemoveAttribute(doc, el, attr);\n\t\t\t}\n\t\t\tattr.ownerElement = null;\n\t\t}\n\t}\n}\nNamedNodeMap.prototype = {\n\tlength: 0,\n\titem: NodeList.prototype.item,\n\n\t/**\n\t * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and\n\t * document.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given local name, or null if no such attribute exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name\n\t */\n\tgetNamedItem: function (localName) {\n\t\tif (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {\n\t\t\tlocalName = localName.toLowerCase();\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar attr = this[i];\n\t\t\tif (attr.nodeName === localName) {\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n\n\t/**\n\t * Set an attribute.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another\n\t * element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItem: function (attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif (el && el !== this._ownerElement) {\n\t\t\tthrow new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);\n\t\tif (oldAttr === attr) {\n\t\t\treturn attr;\n\t\t}\n\t\t_addNamedNode(this._ownerElement, this, attr, oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/**\n\t * Set an attribute, replacing an existing attribute with the same local name and namespace\n\t * URI if one exists.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * Throws a DOMException with the name \"InUseAttributeError\" if the attribute is already an\n\t * attribute of another element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItemNS: function (attr) {\n\t\treturn this.setNamedItem(attr);\n\t},\n\n\t/**\n\t * Removes an attribute specified by the local name.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name\n\t */\n\tremoveNamedItem: function (localName) {\n\t\tvar attr = this.getNamedItem(localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Removes an attribute specified by the namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute to be removed.\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local\n\t * name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace\n\t */\n\tremoveNamedItemNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getNamedItemNS(namespaceURI, localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Get an attribute by namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute.\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given namespace URI and local name, or null if no such attribute\n\t * exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace\n\t */\n\tgetNamedItemNS: function (namespaceURI, localName) {\n\t\tif (!namespaceURI) {\n\t\t\tnamespaceURI = null;\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar node = this[i];\n\t\t\tif (node.localName === localName && node.namespaceURI === namespaceURI) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n};\nNamedNodeMap.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * The DOMImplementation interface provides a number of methods for performing operations that\n * are independent of any particular instance of the document object model.\n *\n * The DOMImplementation interface represents an object providing methods which are not\n * dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * **The individual methods describe the differences compared to the specs**.\n *\n * @class DOMImplementation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core\n * (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n * @constructs DOMImplementation\n */\nfunction DOMImplementation() {}\n\nDOMImplementation.prototype = {\n\t/**\n\t * Test if the DOM implementation implements a specific feature and version, as specified in\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.\n\t *\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given\n\t * feature is supported. The different implementations fairly diverged in what kind of\n\t * features were reported. The latest version of the spec settled to force this method to\n\t * always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated\n\t * It is deprecated and modern browsers return true in all cases.\n\t * @function DOMImplementation#hasFeature\n\t * @param {string} feature\n\t * The name of the feature to test.\n\t * @param {string} [version]\n\t * This is the version number of the feature to test.\n\t * @returns {boolean}\n\t * Always returns true.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core\n\t */\n\thasFeature: function (feature, version) {\n\t\treturn true;\n\t},\n\t/**\n\t * Creates a DOM Document object of the specified type with its document element. Note that\n\t * based on the {@link DocumentType}\n\t * given to create the document, the implementation may instantiate specialized\n\t * {@link Document} objects that support additional features than the \"Core\", such as \"HTML\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.\n\t * On the other hand, setting the {@link DocumentType} after the document was created makes\n\t * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,\n\t * such as createHTMLDocument\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},\n\t * can be used to obtain specific types of {@link Document} objects.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document`\n\t * instance (with it's `type` set to `'xml'`).\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @function DOMImplementation.createDocument\n\t * @param {string | null} namespaceURI\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}\n\t * of the document element to create or null.\n\t * @param {string | null} qualifiedName\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}\n\t * of the document element to be created or null.\n\t * @param {DocumentType | null} [doctype=null]\n\t * The type of document to be created or null. When doctype is not null, its\n\t * {@link Node#ownerDocument} attribute is set to the document being created. Default is\n\t * `null`\n\t * @returns {Document}\n\t * A new {@link Document} object with its document element. If the NamespaceURI,\n\t * qualifiedName, and doctype are null, the returned {@link Document} is empty with no\n\t * document element.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a\n\t * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI\n\t * is different from null, or if the qualifiedName has a prefix that is \"xml\" and the\n\t * namespaceURI is different from \"{@link http://www.w3.org/XML/1998/namespace}\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},\n\t * or if the DOM implementation does not support the \"XML\" feature but a non-null namespace\n\t * URI was provided, since namespaces were defined by XML.\n\t * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document\n\t * or was created from a different implementation.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see {@link #createHTMLDocument}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 2 Core (initial)\n\t */\n\tcreateDocument: function (namespaceURI, qualifiedName, doctype) {\n\t\tvar contentType = MIME_TYPE.XML_APPLICATION;\n\t\tif (namespaceURI === NAMESPACE.HTML) {\n\t\t\tcontentType = MIME_TYPE.XML_XHTML_APPLICATION;\n\t\t} else if (namespaceURI === NAMESPACE.SVG) {\n\t\t\tcontentType = MIME_TYPE.XML_SVG_IMAGE;\n\t\t}\n\t\tvar doc = new Document(PDC, { contentType: contentType });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype) {\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName) {\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Creates an empty DocumentType node. Entity declarations and notations are not made\n\t * available. Entity reference expansions and default attribute additions do not occur.\n\t *\n\t * **This behavior is slightly different from the one in the specs**:\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - `publicId` and `systemId` contain the raw data including any possible quotes,\n\t * so they can always be serialized back to the original value\n\t * - `internalSubset` contains the raw string between `[` and `]` if present,\n\t * but is not parsed or validated in any form.\n\t *\n\t * @function DOMImplementation#createDocumentType\n\t * @param {string} qualifiedName\n\t * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified\n\t * name} of the document type to be created.\n\t * @param {string} [publicId]\n\t * The external subset public identifier.\n\t * @param {string} [systemId]\n\t * The external subset system identifier.\n\t * @param {string} [internalSubset]\n\t * the internal subset or an empty string if it is not present\n\t * @returns {DocumentType}\n\t * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType\n\t * MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living\n\t * Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM\n\t * Level 2 Core\n\t * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset\n\t * @prettierignore\n\t */\n\tcreateDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {\n\t\tvalidateQualifiedName(qualifiedName);\n\t\tvar node = new DocumentType(PDC);\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\t\tnode.internalSubset = internalSubset || '';\n\t\tnode.childNodes = new NodeList();\n\n\t\treturn node;\n\t},\n\t/**\n\t * Returns an HTML document, that might already have a basic DOM structure.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are\n\t * omitted)\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @param {string | false} [title]\n\t * A string containing the title to give the new HTML document.\n\t * @returns {Document}\n\t * The HTML document.\n\t * @since WHATWG Living Standard.\n\t * @see {@link #createDocument}\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n\t * @see https://dom.spec.whatwg.org/#html-document\n\t */\n\tcreateHTMLDocument: function (title) {\n\t\tvar doc = new Document(PDC, { contentType: MIME_TYPE.HTML });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tif (title !== false) {\n\t\t\tdoc.doctype = this.createDocumentType('html');\n\t\t\tdoc.doctype.ownerDocument = doc;\n\t\t\tdoc.appendChild(doc.doctype);\n\t\t\tvar htmlNode = doc.createElement('html');\n\t\t\tdoc.appendChild(htmlNode);\n\t\t\tvar headNode = doc.createElement('head');\n\t\t\thtmlNode.appendChild(headNode);\n\t\t\tif (typeof title === 'string') {\n\t\t\t\tvar titleNode = doc.createElement('title');\n\t\t\t\ttitleNode.appendChild(doc.createTextNode(title));\n\t\t\t\theadNode.appendChild(titleNode);\n\t\t\t}\n\t\t\thtmlNode.appendChild(doc.createElement('body'));\n\t\t}\n\t\treturn doc;\n\t},\n};\n\n/**\n * The DOM Node interface is an abstract base class upon which many other DOM API objects are\n * based, thus letting those object types to be used similarly and often interchangeably. As an\n * abstract class, there is no such thing as a plain Node object. All objects that implement\n * Node functionality are based on one of its subclasses. Most notable are Document, Element,\n * and DocumentFragment.\n *\n * In addition, every kind of DOM node is represented by an interface based on Node. These\n * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are\n * all based on), and DocumentType.\n *\n * In some cases, a particular feature of the base Node interface may not apply to one of its\n * child interfaces; in that case, the inheriting node may return null or throw an exception,\n * depending on circumstances. For example, attempting to add children to a node type that\n * cannot have children will throw an exception.\n *\n * **This behavior is slightly different from the in the specs**:\n * - unimplemented interfaces: `EventTarget`\n *\n * @class\n * @abstract\n * @param {Symbol} symbol\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n * @see https://dom.spec.whatwg.org/#node\n * @prettierignore\n */\nfunction Node(symbol) {\n\tcheckSymbol(symbol);\n}\n\nNode.prototype = {\n\t/**\n\t * The first child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tfirstChild: null,\n\t/**\n\t * The last child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tlastChild: null,\n\t/**\n\t * The previous sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tpreviousSibling: null,\n\t/**\n\t * The next sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tnextSibling: null,\n\t/**\n\t * The parent node of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tparentNode: null,\n\t/**\n\t * The parent element of this node.\n\t *\n\t * @type {Element | null}\n\t */\n\tget parentElement() {\n\t\treturn this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;\n\t},\n\t/**\n\t * The child nodes of this node.\n\t *\n\t * @type {NodeList}\n\t */\n\tchildNodes: null,\n\t/**\n\t * The document object associated with this node.\n\t *\n\t * @type {Document | null}\n\t */\n\townerDocument: null,\n\t/**\n\t * The value of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnodeValue: null,\n\t/**\n\t * The namespace URI of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnamespaceURI: null,\n\t/**\n\t * The prefix of the namespace for this node.\n\t *\n\t * @type {string | null}\n\t */\n\tprefix: null,\n\t/**\n\t * The local part of the qualified name of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tlocalName: null,\n\t/**\n\t * The baseURI is currently always `about:blank`,\n\t * since that's what happens when you create a document from scratch.\n\t *\n\t * @type {'about:blank'}\n\t */\n\tbaseURI: 'about:blank',\n\t/**\n\t * Is true if this node is part of a document.\n\t *\n\t * @type {boolean}\n\t */\n\tget isConnected() {\n\t\tvar rootNode = this.getRootNode();\n\t\treturn rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;\n\t},\n\t/**\n\t * Checks whether `other` is an inclusive descendant of this node.\n\t *\n\t * @param {Node | null | undefined} other\n\t * The node to check.\n\t * @returns {boolean}\n\t * True if `other` is an inclusive descendant of this node; false otherwise.\n\t * @see https://dom.spec.whatwg.org/#dom-node-contains\n\t */\n\tcontains: function (other) {\n\t\tif (!other) return false;\n\t\tvar parent = other;\n\t\tdo {\n\t\t\tif (this === parent) return true;\n\t\t\tparent = other.parentNode;\n\t\t} while (parent);\n\t\treturn false;\n\t},\n\t/**\n\t * @typedef GetRootNodeOptions\n\t * @property {boolean} [composed=false]\n\t */\n\t/**\n\t * Searches for the root node of this node.\n\t *\n\t * **This behavior is slightly different from the in the specs**:\n\t * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.\n\t *\n\t * @param {GetRootNodeOptions} [options]\n\t * @returns {Node}\n\t * Root node.\n\t * @see https://dom.spec.whatwg.org/#dom-node-getrootnode\n\t * @see https://dom.spec.whatwg.org/#concept-shadow-including-root\n\t */\n\tgetRootNode: function (options) {\n\t\tvar parent = this;\n\t\tdo {\n\t\t\tif (!parent.parentNode) {\n\t\t\t\treturn parent;\n\t\t\t}\n\t\t\tparent = parent.parentNode;\n\t\t} while (parent);\n\t},\n\t/**\n\t * Checks whether the given node is equal to this node.\n\t *\n\t * @param {Node} [otherNode]\n\t * @see https://dom.spec.whatwg.org/#concept-node-equals\n\t */\n\tisEqualNode: function (otherNode) {\n\t\tif (!otherNode) return false;\n\n\t\tif (this.nodeType !== otherNode.nodeType) return false;\n\n\t\tswitch (this.nodeType) {\n\t\t\tcase this.DOCUMENT_TYPE_NODE:\n\t\t\t\tif (this.name !== otherNode.name) return false;\n\t\t\t\tif (this.publicId !== otherNode.publicId) return false;\n\t\t\t\tif (this.systemId !== otherNode.systemId) return false;\n\t\t\t\tbreak;\n\t\t\tcase this.ELEMENT_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.prefix !== otherNode.prefix) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.attributes.length !== otherNode.attributes.length) return false;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attr = this.attributes.item(i);\n\t\t\t\t\tif (!attr.isEqualNode(otherNode.getAttributeNodeNS(attr.namespaceURI, attr.localName))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.ATTRIBUTE_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.value !== otherNode.value) return false;\n\n\t\t\t\tbreak;\n\t\t\tcase this.PROCESSING_INSTRUCTION_NODE:\n\t\t\t\tif (this.target !== otherNode.target || this.data !== otherNode.data) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.TEXT_NODE:\n\t\t\tcase this.COMMENT_NODE:\n\t\t\t\tif (this.data !== otherNode.data) return false;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (this.childNodes.length !== otherNode.childNodes.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < this.childNodes.length; i++) {\n\t\t\tif (!this.childNodes[i].isEqualNode(otherNode.childNodes[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n\t/**\n\t * Checks whether or not the given node is this node.\n\t *\n\t * @param {Node} [otherNode]\n\t */\n\tisSameNode: function (otherNode) {\n\t\treturn this === otherNode;\n\t},\n\t/**\n\t * Inserts a node before a reference node as a child of this node.\n\t *\n\t * @param {Node} newChild\n\t * The new child node to be inserted.\n\t * @param {Node | null} refChild\n\t * The reference node before which newChild will be inserted.\n\t * @returns {Node}\n\t * The new child node successfully inserted.\n\t * @throws {DOMException}\n\t * Throws a DOMException if inserting the node would result in a DOM tree that is not\n\t * well-formed, or if `child` is provided but is not a child of `parent`.\n\t * See {@link _insertBefore} for more details.\n\t * @since Modified in DOM L2\n\t */\n\tinsertBefore: function (newChild, refChild) {\n\t\treturn _insertBefore(this, newChild, refChild);\n\t},\n\t/**\n\t * Replaces an old child node with a new child node within this node.\n\t *\n\t * @param {Node} newChild\n\t * The new node that is to replace the old node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @param {Node} oldChild\n\t * The existing child node to be replaced.\n\t * @returns {Node}\n\t * Returns the replaced child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if replacing the node would result in a DOM tree that is not\n\t * well-formed, or if `oldChild` is not a child of `this`.\n\t * This can also occur if the pre-replacement validity assertion fails.\n\t * See {@link _insertBefore}, {@link Node.removeChild}, and\n\t * {@link assertPreReplacementValidityInDocument} for more details.\n\t * @see https://dom.spec.whatwg.org/#concept-node-replace\n\t */\n\treplaceChild: function (newChild, oldChild) {\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\t/**\n\t * Removes an existing child node from this node.\n\t *\n\t * @param {Node} oldChild\n\t * The child node to be removed.\n\t * @returns {Node}\n\t * Returns the removed child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if `oldChild` is not a child of `this`.\n\t * See {@link _removeChild} for more details.\n\t */\n\tremoveChild: function (oldChild) {\n\t\treturn _removeChild(this, oldChild);\n\t},\n\t/**\n\t * Appends a child node to this node.\n\t *\n\t * @param {Node} newChild\n\t * The child node to be appended to this node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @returns {Node}\n\t * Returns the appended child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if appending the node would result in a DOM tree that is not\n\t * well-formed, or if `newChild` is not a valid Node.\n\t * See {@link insertBefore} for more details.\n\t */\n\tappendChild: function (newChild) {\n\t\treturn this.insertBefore(newChild, null);\n\t},\n\t/**\n\t * Determines whether this node has any child nodes.\n\t *\n\t * @returns {boolean}\n\t * Returns true if this node has any child nodes, and false otherwise.\n\t */\n\thasChildNodes: function () {\n\t\treturn this.firstChild != null;\n\t},\n\t/**\n\t * Creates a copy of the calling node.\n\t *\n\t * @param {boolean} deep\n\t * If true, the contents of the node are recursively copied.\n\t * If false, only the node itself (and its attributes, if it is an element) are copied.\n\t * @returns {Node}\n\t * Returns the newly created copy of the node.\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within {@link Element#setAttributeNode} or\n\t * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their\n\t * specific constraints.\n\t * @see {@link cloneNode}\n\t */\n\tcloneNode: function (deep) {\n\t\treturn cloneNode(this.ownerDocument || this, this, deep);\n\t},\n\t/**\n\t * Puts the specified node and all of its subtree into a \"normalized\" form. In a normalized\n\t * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.\n\t *\n\t * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`\n\t * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text\n\t * nodes.\n\t *\n\t * This method operates recursively, so it also normalizes any and all descendent nodes within\n\t * the subtree.\n\t *\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within removeChild or appendData (which are\n\t * potentially invoked in this method) do not meet their specific constraints.\n\t * @since Modified in DOM Level 2\n\t * @see {@link Node.removeChild}\n\t * @see {@link CharacterData.appendData}\n\t */\n\tnormalize: function () {\n\t\tvar child = this.firstChild;\n\t\twhile (child) {\n\t\t\tvar next = child.nextSibling;\n\t\t\tif (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t} else {\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n\t/**\n\t * Checks whether the DOM implementation implements a specific feature and its version.\n\t *\n\t * @deprecated\n\t * Since `DOMImplementation.hasFeature` is deprecated and always returns true.\n\t * @param {string} feature\n\t * The package name of the feature to test. This is the same name that can be passed to the\n\t * method `hasFeature` on `DOMImplementation`.\n\t * @param {string} version\n\t * This is the version number of the package name to test.\n\t * @returns {boolean}\n\t * Returns true in all cases in the current implementation.\n\t * @since Introduced in DOM Level 2\n\t * @see {@link DOMImplementation.hasFeature}\n\t */\n\tisSupported: function (feature, version) {\n\t\treturn this.ownerDocument.implementation.hasFeature(feature, version);\n\t},\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI for which to find the associated prefix.\n\t * @returns {string | null}\n\t * The associated prefix, if found; otherwise, null.\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t * @prettierignore\n\t */\n\tlookupPrefix: function (namespaceURI) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tfor (var n in map) {\n\t\t\t\t\tif (hasOwn(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * This function is used to look up the namespace URI associated with the given prefix,\n\t * starting from this node.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} prefix\n\t * The prefix for which to find the associated namespace URI.\n\t * @returns {string | null}\n\t * The associated namespace URI, if found; otherwise, null.\n\t * @since DOM Level 3\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI\n\t * @prettierignore\n\t */\n\tlookupNamespaceURI: function (prefix) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tif (hasOwn(map, prefix)) {\n\t\t\t\t\treturn map[prefix];\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * Determines whether the given namespace URI is the default namespace.\n\t *\n\t * The function works by looking up the prefix associated with the given namespace URI. If no\n\t * prefix is found (i.e., the namespace URI is not registered in the namespace map of this\n\t * node or any of its ancestors), it returns `true`, implying the namespace URI is considered\n\t * the default.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI to be checked.\n\t * @returns {boolean}\n\t * Returns true if the given namespace URI is the default namespace, false otherwise.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace\n\t * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace\n\t * @prettierignore\n\t */\n\tisDefaultNamespace: function (namespaceURI) {\n\t\tvar prefix = this.lookupPrefix(namespaceURI);\n\t\treturn prefix == null;\n\t},\n\t/**\n\t * Compares the reference node with a node with regard to their position in the document and\n\t * according to the document order.\n\t *\n\t * @param {Node} other\n\t * The node to compare the reference node to.\n\t * @returns {number}\n\t * Returns how the node is positioned relatively to the reference node according to the\n\t * bitmask. 0 if reference node and given node are the same.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare\n\t * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition\n\t */\n\tcompareDocumentPosition: function (other) {\n\t\tif (this === other) return 0;\n\t\tvar node1 = other;\n\t\tvar node2 = this;\n\t\tvar attr1 = null;\n\t\tvar attr2 = null;\n\t\tif (node1 instanceof Attr) {\n\t\t\tattr1 = node1;\n\t\t\tnode1 = attr1.ownerElement;\n\t\t}\n\t\tif (node2 instanceof Attr) {\n\t\t\tattr2 = node2;\n\t\t\tnode2 = attr2.ownerElement;\n\t\t\tif (attr1 && node1 && node2 === node1) {\n\t\t\t\tfor (var i = 0, attr; (attr = node2.attributes[i]); i++) {\n\t\t\t\t\tif (attr === attr1)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t\t\tif (attr === attr2)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {\n\t\t\treturn (\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_DISCONNECTED +\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +\n\t\t\t\t(docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)\n\t\t\t\t\t? DocumentPosition.DOCUMENT_POSITION_FOLLOWING\n\t\t\t\t\t: DocumentPosition.DOCUMENT_POSITION_PRECEDING)\n\t\t\t);\n\t\t}\n\t\tif (attr2 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\tif (attr1 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t}\n\n\t\tvar chain1 = [];\n\t\tvar ancestor1 = node1.parentNode;\n\t\twhile (ancestor1) {\n\t\t\tif (!attr2 && ancestor1 === node2) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t}\n\t\t\tchain1.push(ancestor1);\n\t\t\tancestor1 = ancestor1.parentNode;\n\t\t}\n\t\tchain1.reverse();\n\n\t\tvar chain2 = [];\n\t\tvar ancestor2 = node2.parentNode;\n\t\twhile (ancestor2) {\n\t\t\tif (!attr1 && ancestor2 === node1) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t}\n\t\t\tchain2.push(ancestor2);\n\t\t\tancestor2 = ancestor2.parentNode;\n\t\t}\n\t\tchain2.reverse();\n\n\t\tvar ca = commonAncestor(chain1, chain2);\n\t\tfor (var n in ca.childNodes) {\n\t\t\tvar child = ca.childNodes[n];\n\t\t\tif (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\tif (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\treturn 0;\n\t},\n};\n\n/**\n * Encodes special XML characters to their corresponding entities.\n *\n * @param {string} c\n * The character to be encoded.\n * @returns {string}\n * The encoded character.\n * @private\n */\nfunction _xmlEncoder(c) {\n\treturn (\n\t\t(c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '\"' && '"') || '&#' + c.charCodeAt() + ';'\n\t);\n}\n\ncopy(NodeType, Node);\ncopy(NodeType, Node.prototype);\ncopy(DocumentPosition, Node);\ncopy(DocumentPosition, Node.prototype);\n\n/**\n * @param callback\n * Return true for continue,false for break.\n * @returns\n * boolean true: break visit;\n */\nfunction _visitNode(node, callback) {\n\tif (callback(node)) {\n\t\treturn true;\n\t}\n\tif ((node = node.firstChild)) {\n\t\tdo {\n\t\t\tif (_visitNode(node, callback)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} while ((node = node.nextSibling));\n\t}\n}\n\n/**\n * @typedef DocumentOptions\n * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]\n */\n/**\n * The Document interface describes the common properties and methods for any kind of document.\n *\n * It should usually be created using `new DOMImplementation().createDocument(...)`\n * or `new DOMImplementation().createHTMLDocument(...)`.\n *\n * The constructor is considered a private API and offers to initially set the `contentType`\n * property via it's options parameter.\n *\n * @class\n * @param {Symbol} symbol\n * @param {DocumentOptions} [options]\n * @augments Node\n * @private\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document\n * @see https://dom.spec.whatwg.org/#interface-document\n */\nfunction Document(symbol, options) {\n\tcheckSymbol(symbol);\n\n\tvar opt = options || {};\n\tthis.ownerDocument = this;\n\t/**\n\t * The mime type of the document is determined at creation time and can not be modified.\n\t *\n\t * @type {string}\n\t * @see https://dom.spec.whatwg.org/#concept-document-content-type\n\t * @see {@link DOMImplementation}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;\n\t/**\n\t * @type {'html' | 'xml'}\n\t * @see https://dom.spec.whatwg.org/#concept-document-type\n\t * @see {@link DOMImplementation}\n\t * @readonly\n\t */\n\tthis.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';\n}\n\n/**\n * Updates the namespace mapping of an element when a new attribute is added.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element to which the attribute is being added.\n * @param {Attr} newAttr\n * The new attribute being added.\n * @private\n */\nfunction _onAddAttribute(doc, el, newAttr) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;\n\t}\n}\n\n/**\n * Updates the namespace mapping of an element when an attribute is removed.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element from which the attribute is being removed.\n * @param {Attr} newAttr\n * The attribute being removed.\n * @param {boolean} remove\n * Indicates whether the attribute is to be removed.\n * @private\n */\nfunction _onRemoveAttribute(doc, el, newAttr, remove) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix ? newAttr.localName : ''];\n\t}\n}\n\n/**\n * Updates `parent.childNodes`, adjusting the indexed items and its `length`.\n * If `newChild` is provided and has no nextSibling, it will be appended.\n * Otherwise, it's assumed that an item has been removed or inserted,\n * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.\n *\n * @param {Document} doc\n * The parent document of `el`.\n * @param {Node} parent\n * The parent node whose childNodes list needs to be updated.\n * @param {Node} [newChild]\n * The new child node to be appended. If not provided, the function assumes a node has been\n * removed.\n * @private\n */\nfunction _onUpdateChild(doc, parent, newChild) {\n\tif (doc && doc._inc) {\n\t\tdoc._inc++;\n\t\tvar childNodes = parent.childNodes;\n\t\t// assumes nextSibling and previousSibling were already configured upfront\n\t\tif (newChild && !newChild.nextSibling) {\n\t\t\t// if an item has been appended, we only need to update the last index and the length\n\t\t\tchildNodes[childNodes.length++] = newChild;\n\t\t} else {\n\t\t\t// otherwise we need to reindex all items,\n\t\t\t// which can take a while when processing nodes with a lot of children\n\t\t\tvar child = parent.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile (child) {\n\t\t\t\tchildNodes[i++] = child;\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\tchildNodes.length = i;\n\t\t\tdelete childNodes[childNodes.length];\n\t\t}\n\t}\n}\n\n/**\n * Removes the connections between `parentNode` and `child`\n * and any existing `child.previousSibling` or `child.nextSibling`.\n *\n * @param {Node} parentNode\n * The parent node from which the child node is to be removed.\n * @param {Node} child\n * The child node to be removed from the parentNode.\n * @returns {Node}\n * Returns the child node that was removed.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.\n * @private\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n */\nfunction _removeChild(parentNode, child) {\n\tif (parentNode !== child.parentNode) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, \"child's parent is not parent\");\n\t}\n\tvar oldPreviousSibling = child.previousSibling;\n\tvar oldNextSibling = child.nextSibling;\n\tif (oldPreviousSibling) {\n\t\toldPreviousSibling.nextSibling = oldNextSibling;\n\t} else {\n\t\tparentNode.firstChild = oldNextSibling;\n\t}\n\tif (oldNextSibling) {\n\t\toldNextSibling.previousSibling = oldPreviousSibling;\n\t} else {\n\t\tparentNode.lastChild = oldPreviousSibling;\n\t}\n\t_onUpdateChild(parentNode.ownerDocument, parentNode);\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.CDATA_SECTION_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_TYPE_NODE ||\n\t\t\tnode.nodeType === Node.ELEMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||\n\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Asserts pre-insertion validity of a node into a parent before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Node} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | null} child\n * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,\n * DocumentFragment, or Element node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive\n * ancestor of `parent`. (Currently not implemented)\n * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not\n * `parent`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,\n * DocumentType, Element, or CharacterData node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is\n * a document, or if `node` is a doctype and `parent` is not a document.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.HIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * Asserts pre-insertion validity of a node into a document before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * The node that should become the `nextSibling` of `node`. If undefined, no sibling is\n * considered.\n * @returns {Node}\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than\n * one element child or has a Text node child.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one\n * element child and either `parent` has an element child, `child` is a doctype, or `child` is\n * non-null and a doctype is following `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an\n * element child, `child` is a doctype, or `child` is non-null and a doctype is following\n * `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a\n * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null\n * and `parent` has an element child.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws {DOMException}\n * For several node combinations that would create a DOM that is not well-formed.\n * @throws {DOMException}\n * If `child` is provided but is not a child of `parent`.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * Inserts a node into a parent node before a child node.\n *\n * @param {Node} parent\n * The parent node to insert the node into.\n * @param {Node} node\n * The node to insert into the parent.\n * @param {Node | null} child\n * The node that should become the next sibling of the node.\n * If null, the function inserts the node at the end of the children of the parent node.\n * @param {Function} [_inDocumentAssertion]\n * An optional function to check pre-insertion validity if parent is a document node.\n * Defaults to {@link assertPreInsertionValidityInDocument}\n * @returns {Node}\n * Returns the inserted node.\n * @throws {DOMException}\n * Throws a DOMException if inserting the node would result in a DOM tree that is not\n * well-formed. See {@link assertPreInsertionValidity1to5},\n * {@link assertPreInsertionValidityInDocument}.\n * @throws {DOMException}\n * Throws a DOMException if child is provided but is not a child of the parent. See\n * {@link Node.removeChild}\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif (cp) {\n\t\tcp.removeChild(node); //remove and update\n\t}\n\tif (node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t} else {\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\tif (pre) {\n\t\tpre.nextSibling = newFirst;\n\t} else {\n\t\tparent.firstChild = newFirst;\n\t}\n\tif (child == null) {\n\t\tparent.lastChild = newLast;\n\t} else {\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo {\n\t\tnewFirst.parentNode = parent;\n\t} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));\n\t_onUpdateChild(parent.ownerDocument || parent, parent, node);\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\n\treturn node;\n}\n\nDocument.prototype = {\n\t/**\n\t * The implementation that created this document.\n\t *\n\t * @type DOMImplementation\n\t * @readonly\n\t */\n\timplementation: null,\n\tnodeName: '#document',\n\tnodeType: DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @type DocumentType\n\t * @readonly\n\t */\n\tdoctype: null,\n\tdocumentElement: null,\n\t_inc: 1,\n\n\tinsertBefore: function (newChild, refChild) {\n\t\t//raises\n\t\tif (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child, refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild: function (oldChild) {\n\t\tvar removed = _removeChild(this, oldChild);\n\t\tif (removed === this.documentElement) {\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn removed;\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode: function (importedNode, deep) {\n\t\treturn importNode(this, importedNode, deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById: function (id) {\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement, function (node) {\n\t\t\tif (node.nodeType == ELEMENT_NODE) {\n\t\t\t\tif (node.getAttribute('id') == id) {\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * Creates a new `Element` that is owned by this `Document`.\n\t * In HTML Documents `localName` is the lower cased `tagName`,\n\t * otherwise no transformation is being applied.\n\t * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t * - There is no interface `HTMLElement`, it is always an `Element`.\n\t * - There is no support for a second argument to indicate using custom elements.\n\t *\n\t * @param {string} tagName\n\t * @returns {Element}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement\n\t * @see https://dom.spec.whatwg.org/#dom-document-createelement\n\t * @see https://dom.spec.whatwg.org/#concept-create-element\n\t */\n\tcreateElement: function (tagName) {\n\t\tvar node = new Element(PDC);\n\t\tnode.ownerDocument = this;\n\t\tif (this.type === 'html') {\n\t\t\ttagName = tagName.toLowerCase();\n\t\t}\n\t\tif (hasDefaultHTMLNamespace(this.contentType)) {\n\t\t\tnode.namespaceURI = NAMESPACE.HTML;\n\t\t}\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t/**\n\t * @returns {DocumentFragment}\n\t */\n\tcreateDocumentFragment: function () {\n\t\tvar node = new DocumentFragment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Text}\n\t */\n\tcreateTextNode: function (data) {\n\t\tvar node = new Text(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Comment}\n\t */\n\tcreateComment: function (data) {\n\t\tvar node = new Comment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {CDATASection}\n\t */\n\tcreateCDATASection: function (data) {\n\t\tvar node = new CDATASection(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} target\n\t * @param {string} data\n\t * @returns {ProcessingInstruction}\n\t */\n\tcreateProcessingInstruction: function (target, data) {\n\t\tvar node = new ProcessingInstruction(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an `Attr` node that is owned by this document.\n\t * In HTML Documents `localName` is the lower cased `name`,\n\t * otherwise no transformation is being applied.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t *\n\t * @param {string} name\n\t * @returns {Attr}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute\n\t * @see https://dom.spec.whatwg.org/#dom-document-createattribute\n\t */\n\tcreateAttribute: function (name) {\n\t\tif (!g.QName_exact.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this._createAttribute(name);\n\t},\n\t_createAttribute: function (name) {\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.name = name;\n\t\tnode.nodeName = name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an EntityReference object.\n\t * The current implementation does not fill the `childNodes` with those of the corresponding\n\t * `Entity`\n\t *\n\t * @deprecated\n\t * In DOM Level 4.\n\t * @param {string} name\n\t * The name of the entity to reference. No namespace well-formedness checks are performed.\n\t * @returns {EntityReference}\n\t * @throws {DOMException}\n\t * With code `INVALID_CHARACTER_ERR` when `name` is not valid.\n\t * @throws {DOMException}\n\t * with code `NOT_SUPPORTED_ERR` when the document is of type `html`\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE\n\t */\n\tcreateEntityReference: function (name) {\n\t\tif (!g.Name.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tthrow new DOMException('document is an html document', DOMExceptionName.NotSupportedError);\n\t\t}\n\n\t\tvar node = new EntityReference(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Element}\n\t */\n\tcreateElementNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Element(PDC);\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Attr}\n\t */\n\tcreateAttributeNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.specified = true;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\treturn node;\n\t},\n};\n_extends(Document, Node);\n\nfunction Element(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis._nsMap = Object.create(null);\n}\nElement.prototype = {\n\tnodeType: ELEMENT_NODE,\n\t/**\n\t * The attributes of this element.\n\t *\n\t * @type {NamedNodeMap | null}\n\t */\n\tattributes: null,\n\tgetQualifiedName: function () {\n\t\treturn this.prefix ? this.prefix + ':' + this.localName : this.localName;\n\t},\n\t_isInHTMLDocumentAndNamespace: function () {\n\t\treturn this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;\n\t},\n\t/**\n\t * Implementaton of Level2 Core function hasAttributes.\n\t *\n\t * @returns {boolean}\n\t * True if attribute list is not empty.\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs\n\t */\n\thasAttributes: function () {\n\t\treturn !!(this.attributes && this.attributes.length);\n\t},\n\thasAttribute: function (name) {\n\t\treturn !!this.getAttributeNode(name);\n\t},\n\t/**\n\t * Returns element’s first attribute whose qualified name is `name`, and `null`\n\t * if there is no such attribute.\n\t *\n\t * @param {string} name\n\t * @returns {string | null}\n\t */\n\tgetAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr ? attr.value : null;\n\t},\n\tgetAttributeNode: function (name) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\t/**\n\t * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.\n\t *\n\t * @param {string} name\n\t * @param {string} value\n\t */\n\tsetAttribute: function (name, value) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\tvar attr = this.getAttributeNode(name);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument._createAttribute(name);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tremoveAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\tsetAttributeNode: function (newAttr) {\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS: function (newAttr) {\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode: function (oldAttr) {\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS: function (namespaceURI, localName) {\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS: function (namespaceURI, localName) {\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName) != null;\n\t},\n\t/**\n\t * Returns element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName`,\n\t * or `null` if there is no such attribute.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} localName\n\t * @returns {string | null}\n\t */\n\tgetAttributeNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr ? attr.value : null;\n\t},\n\t/**\n\t * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName` to value.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {string} value\n\t * @see https://dom.spec.whatwg.org/#dom-element-setattributens\n\t */\n\tsetAttributeNS: function (namespaceURI, qualifiedName, value) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar localName = validated[2];\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tgetAttributeNodeNS: function (namespaceURI, localName) {\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classNames` is an empty string or only contains HTML white space\n\t * characters.\n\t *\n\t * Warning: This returns a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames\n\t * Is a string representing the class name(s) to match; multiple class names are separated by\n\t * (ASCII-)whitespace.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function (classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames);\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base, function (node) {\n\t\t\t\t\tif (node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class');\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames);\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of elements with the given qualifiedName.\n\t * Searching for all descendants can be done by passing `*` as `qualifiedName`.\n\t *\n\t * All descendants of the specified element are searched, but not the element itself.\n\t * The returned list is live, which means it updates itself with the DOM tree automatically.\n\t * Therefore, there is no need to call `Element.getElementsByTagName()`\n\t * with the same element and arguments repeatedly if the DOM changes in between calls.\n\t *\n\t * When called on an HTML element in an HTML document,\n\t * `getElementsByTagName` lower-cases the argument before searching for it.\n\t * This is undesirable when trying to match camel-cased SVG elements (such as\n\t * ``) in an HTML document.\n\t * Instead, use `Element.getElementsByTagNameNS()`,\n\t * which preserves the capitalization of the tag name.\n\t *\n\t * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,\n\t * except that it only searches for elements that are descendants of the specified element.\n\t *\n\t * @param {string} qualifiedName\n\t * @returns {LiveNodeList}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname\n\t */\n\tgetElementsByTagName: function (qualifiedName) {\n\t\tvar isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';\n\t\tvar lowerQualifiedName = qualifiedName.toLowerCase();\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (node === base || node.nodeType !== ELEMENT_NODE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (qualifiedName === '*') {\n\t\t\t\t\tls.push(node);\n\t\t\t\t} else {\n\t\t\t\t\tvar nodeQualifiedName = node.getQualifiedName();\n\t\t\t\t\tvar matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;\n\t\t\t\t\tif (nodeQualifiedName === matchingQName) {\n\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS: function (namespaceURI, localName) {\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== base &&\n\t\t\t\t\tnode.nodeType === ELEMENT_NODE &&\n\t\t\t\t\t(namespaceURI === '*' || node.namespaceURI === namespaceURI) &&\n\t\t\t\t\t(localName === '*' || node.localName == localName)\n\t\t\t\t) {\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n};\nDocument.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n_extends(Element, Node);\nfunction Attr(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis.namespaceURI = null;\n\tthis.prefix = null;\n\tthis.ownerElement = null;\n}\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr, Node);\n\nfunction CharacterData(symbol) {\n\tcheckSymbol(symbol);\n}\nCharacterData.prototype = {\n\tdata: '',\n\tsubstringData: function (offset, count) {\n\t\treturn this.data.substring(offset, offset + count);\n\t},\n\tappendData: function (text) {\n\t\ttext = this.data + text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function (offset, text) {\n\t\tthis.replaceData(offset, 0, text);\n\t},\n\tdeleteData: function (offset, count) {\n\t\tthis.replaceData(offset, count, '');\n\t},\n\treplaceData: function (offset, count, text) {\n\t\tvar start = this.data.substring(0, offset);\n\t\tvar end = this.data.substring(offset + count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n};\n_extends(CharacterData, Node);\nfunction Text(symbol) {\n\tcheckSymbol(symbol);\n}\nText.prototype = {\n\tnodeName: '#text',\n\tnodeType: TEXT_NODE,\n\tsplitText: function (offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif (this.parentNode) {\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t},\n};\n_extends(Text, CharacterData);\nfunction Comment(symbol) {\n\tcheckSymbol(symbol);\n}\nComment.prototype = {\n\tnodeName: '#comment',\n\tnodeType: COMMENT_NODE,\n};\n_extends(Comment, CharacterData);\n\nfunction CDATASection(symbol) {\n\tcheckSymbol(symbol);\n}\nCDATASection.prototype = {\n\tnodeName: '#cdata-section',\n\tnodeType: CDATA_SECTION_NODE,\n};\n_extends(CDATASection, Text);\n\nfunction DocumentType(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType, Node);\n\nfunction Notation(symbol) {\n\tcheckSymbol(symbol);\n}\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation, Node);\n\nfunction Entity(symbol) {\n\tcheckSymbol(symbol);\n}\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity, Node);\n\nfunction EntityReference(symbol) {\n\tcheckSymbol(symbol);\n}\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference, Node);\n\nfunction DocumentFragment(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentFragment.prototype.nodeName = '#document-fragment';\nDocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment, Node);\n\nfunction ProcessingInstruction(symbol) {\n\tcheckSymbol(symbol);\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction, CharacterData);\nfunction XMLSerializer() {}\nXMLSerializer.prototype.serializeToString = function (node, nodeFilter) {\n\treturn nodeSerializeToString.call(node, nodeFilter);\n};\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(nodeFilter) {\n\tvar buf = [];\n\tvar refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif (uri && prefix == null) {\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif (prefix == null) {\n\t\t\tvar visibleNamespaces = [\n\t\t\t\t{ namespace: uri, prefix: null },\n\t\t\t\t//{namespace:uri,prefix:''}\n\t\t\t];\n\t\t}\n\t}\n\tserializeToString(this, buf, nodeFilter, visibleNamespaces);\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length;\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Literal whitespace other than space that appear in attribute values are serialized as\n * their entity references, so they will be preserved.\n * (In contrast to whitespace literals in the input which are normalized to spaces).\n *\n * Well-formed constraint: No < in Attribute Values:\n * > The replacement text of any entity referred to directly or indirectly\n * > in an attribute value must not contain a <.\n *\n * @see https://www.w3.org/TR/xml11/#CleanAttrVals\n * @see https://www.w3.org/TR/xml11/#NT-AttValue\n * @see https://www.w3.org/TR/xml11/#AVNormalize\n * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes\n * @prettierignore\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<>&\"\\t\\n\\r]/g, _xmlEncoder), '\"');\n}\n\nfunction serializeToString(node, buf, nodeFilter, visibleNamespaces) {\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\tvar doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;\n\tvar isHTML = doc.type === 'html';\n\n\tif (nodeFilter) {\n\t\tnode = nodeFilter(node);\n\t\tif (node) {\n\t\t\tif (typeof node == 'string') {\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tvar attrs = node.attributes;\n\t\t\tvar len = attrs.length;\n\t\t\tvar child = node.firstChild;\n\t\t\tvar nodeName = node.tagName;\n\n\t\t\tvar prefixedNodeName = nodeName;\n\t\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\t\tvar defaultNS;\n\t\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\t\tdefaultNS = attrs.item(ai).value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultNS) {\n\t\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tdefaultNS = namespace.namespace;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuf.push('<', prefixedNodeName);\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\t// add namespaces for attributes\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (attr.prefix == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({\n\t\t\t\t\t\tprefix: attr.localName,\n\t\t\t\t\t\tnamespace: attr.value,\n\t\t\t\t\t});\n\t\t\t\t} else if (attr.nodeName == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({ prefix: '', namespace: attr.value });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {\n\t\t\t\t\tvar prefix = attr.prefix || '';\n\t\t\t\t\tvar uri = attr.namespaceURI;\n\t\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t\t}\n\t\t\t\tserializeToString(attr, buf, nodeFilter, visibleNamespaces);\n\t\t\t}\n\n\t\t\t// add namespace for current node\n\t\t\tif (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {\n\t\t\t\tvar prefix = node.prefix || '';\n\t\t\t\tvar uri = node.namespaceURI;\n\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t}\n\t\t\t// in XML elements can be closed when they have no children\n\t\t\tvar canCloseTag = !child;\n\t\t\tif (canCloseTag && (isHTML || node.namespaceURI === NAMESPACE.HTML)) {\n\t\t\t\t// in HTML (doc or ns) only void elements can be closed right away\n\t\t\t\tcanCloseTag = isHTMLVoidElement(nodeName);\n\t\t\t}\n\t\t\tif (canCloseTag) {\n\t\t\t\tbuf.push('/>');\n\t\t\t} else {\n\t\t\t\tbuf.push('>');\n\t\t\t\t//if is cdata child node\n\t\t\t\tif (isHTML && isHTMLRawTextElement(nodeName)) {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tif (child.data) {\n\t\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuf.push('');\n\t\t\t}\n\t\t\t// remove added visible namespaces\n\t\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\t\treturn;\n\t\tcase DOCUMENT_NODE:\n\t\tcase DOCUMENT_FRAGMENT_NODE:\n\t\t\tvar child = node.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\treturn;\n\t\tcase ATTRIBUTE_NODE:\n\t\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\t\tcase TEXT_NODE:\n\t\t\t/*\n\t\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t\t * except when used as markup delimiters, or within a comment, a processing instruction,\n\t\t\t * or a CDATA section.\n\t\t\t * If they are needed elsewhere, they must be escaped using either numeric character\n\t\t\t * references or the strings `&` and `<` respectively.\n\t\t\t * The right angle bracket (>) may be represented using the string \" > \",\n\t\t\t * and must, for compatibility, be escaped using either `>`,\n\t\t\t * or a character reference when it appears in the string `]]>` in content,\n\t\t\t * when that string is not marking the end of a CDATA section.\n\t\t\t *\n\t\t\t * In the content of elements, character data is any string of characters which does not\n\t\t\t * contain the start-delimiter of any markup and does not include the CDATA-section-close\n\t\t\t * delimiter, `]]>`.\n\t\t\t *\n\t\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t\t * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node\n\t\t\t */\n\t\t\treturn buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));\n\t\tcase CDATA_SECTION_NODE:\n\t\t\treturn buf.push(g.CDATA_START, node.data, g.CDATA_END);\n\t\tcase COMMENT_NODE:\n\t\t\treturn buf.push(g.COMMENT_START, node.data, g.COMMENT_END);\n\t\tcase DOCUMENT_TYPE_NODE:\n\t\t\tvar pubid = node.publicId;\n\t\t\tvar sysid = node.systemId;\n\t\t\tbuf.push(g.DOCTYPE_DECL_START, ' ', node.name);\n\t\t\tif (pubid) {\n\t\t\t\tbuf.push(' ', g.PUBLIC, ' ', pubid);\n\t\t\t\tif (sysid && sysid !== '.') {\n\t\t\t\t\tbuf.push(' ', sysid);\n\t\t\t\t}\n\t\t\t} else if (sysid && sysid !== '.') {\n\t\t\t\tbuf.push(' ', g.SYSTEM, ' ', sysid);\n\t\t\t}\n\t\t\tif (node.internalSubset) {\n\t\t\t\tbuf.push(' [', node.internalSubset, ']');\n\t\t\t}\n\t\t\tbuf.push('>');\n\t\t\treturn;\n\t\tcase PROCESSING_INSTRUCTION_NODE:\n\t\t\treturn buf.push('');\n\t\tcase ENTITY_REFERENCE_NODE:\n\t\t\treturn buf.push('&', node.nodeName, ';');\n\t\t//case ENTITY_NODE:\n\t\t//case NOTATION_NODE:\n\t\tdefault:\n\t\t\tbuf.push('??', node.nodeName);\n\t}\n}\nfunction importNode(doc, node, deep) {\n\tvar node2;\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tnode2 = node.cloneNode(false);\n\t\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see {@link XML_ENTITIES}\n * @see {@link DOMParser.parseFromString}\n * @see {@link DOMImplementation.prototype.createHTMLDocument}\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)\n * Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML\n * Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML\n * Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated\n * Use `HTML_ENTITIES` instead.\n * @see {@link HTML_ENTITIES}\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar g = require('./grammar');\nvar errors = require('./errors');\n\nvar isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar hasOwn = conventions.hasOwn;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\nvar DOMException = errors.DOMException;\n\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0; //tag name offerring\nvar S_ATTR = 1; //attr name offerring\nvar S_ATTR_SPACE = 2; //attr name end and space offer\nvar S_EQ = 3; //=space?\nvar S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)\nvar S_ATTR_END = 5; //attr value end and no space(quot end)\nvar S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7; //closed el\n\nfunction XMLReader() {}\n\nXMLReader.prototype = {\n\tparse: function (source, defaultNSMap, entityMap) {\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap, (defaultNSMap = Object.create(null)));\n\t\tparse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t},\n};\n\n/**\n * Detecting everything that might be a reference,\n * including those without ending `;`, since those are allowed in HTML.\n * The entityReplacer takes care of verifying and transforming each occurrence,\n * and reports to the errorHandler on those that are not OK,\n * depending on the context.\n */\nvar ENTITY_REG = /&#?\\w+;?/g;\n\nfunction parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {\n\tvar isHTML = isHTMLMimeType(domBuilder.mimeType);\n\tif (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {\n\t\terrorHandler.warning('Unicode replacement character detected, source encoding issues?');\n\t}\n\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10),\n\t\t\t\tsurrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\n\tfunction entityReplacer(a) {\n\t\tvar complete = a[a.length - 1] === ';' ? a : a + ';';\n\t\tif (!isHTML && complete !== a) {\n\t\t\terrorHandler.error('EntityRef: expecting ;');\n\t\t\treturn a;\n\t\t}\n\t\tvar match = g.Reference.exec(complete);\n\t\tif (!match || match[0].length !== complete.length) {\n\t\t\terrorHandler.error('entity not matching Reference production: ' + a);\n\t\t\treturn a;\n\t\t}\n\t\tvar k = complete.slice(1, -1);\n\t\tif (hasOwn(entityMap, k)) {\n\t\t\treturn entityMap[k];\n\t\t} else if (k.charAt(0) === '#') {\n\t\t\treturn fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));\n\t\t} else {\n\t\t\terrorHandler.error('entity not found:' + a);\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tfunction appendText(end) {\n\t\t//has some bugs\n\t\tif (end > start) {\n\t\t\tvar xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);\n\t\t\tlocator && position(start);\n\t\t\tdomBuilder.characters(xt, 0, end - start);\n\t\t\tstart = end;\n\t\t}\n\t}\n\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /\\r\\n?|\\n|$/g;\n\tvar locator = domBuilder.locator;\n\n\tfunction position(p, m) {\n\t\twhile (p >= lineEnd && (m = linePattern.exec(source))) {\n\t\t\tlineStart = lineEnd;\n\t\t\tlineEnd = m.index + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t}\n\t\tlocator.columnNumber = p - lineStart + 1;\n\t}\n\n\tvar parseStack = [{ currentNSMap: defaultNSMapCopy }];\n\tvar unclosedTags = [];\n\tvar start = 0;\n\twhile (true) {\n\t\ttry {\n\t\t\tvar tagStart = source.indexOf('<', start);\n\t\t\tif (tagStart < 0) {\n\t\t\t\tif (!isHTML && unclosedTags.length > 0) {\n\t\t\t\t\treturn errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));\n\t\t\t\t}\n\t\t\t\tif (!source.substring(start).match(/^\\s*$/)) {\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t\t\t\t\tvar text = doc.createTextNode(source.substring(start));\n\t\t\t\t\tif (doc.documentElement) {\n\t\t\t\t\t\treturn errorHandler.error('Extra content at the end of the document');\n\t\t\t\t\t}\n\t\t\t\t\tdoc.appendChild(text);\n\t\t\t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (tagStart > start) {\n\t\t\t\tvar fromSource = source.substring(start, tagStart);\n\t\t\t\tif (!isHTML && unclosedTags.length === 0) {\n\t\t\t\t\tfromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');\n\t\t\t\t\tfromSource && errorHandler.error(\"Unexpected content outside root element: '\" + fromSource + \"'\");\n\t\t\t\t}\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch (source.charAt(tagStart + 1)) {\n\t\t\t\tcase '/':\n\t\t\t\t\tvar end = source.indexOf('>', tagStart + 2);\n\t\t\t\t\tvar tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);\n\t\t\t\t\tif (!tagNameRaw) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name missing');\n\t\t\t\t\t}\n\t\t\t\t\tvar tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);\n\t\t\t\t\tif (!tagNameMatch) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name contains invalid characters: \"' + tagNameRaw + '\"');\n\t\t\t\t\t}\n\t\t\t\t\tif (!domBuilder.currentElement && !domBuilder.doc.documentElement) {\n\t\t\t\t\t\t// not enough information to provide a helpful error message,\n\t\t\t\t\t\t// but parsing will throw since there is no root element\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar currentTagName =\n\t\t\t\t\t\tunclosedTags[unclosedTags.length - 1] ||\n\t\t\t\t\t\tdomBuilder.currentElement.tagName ||\n\t\t\t\t\t\tdomBuilder.doc.documentElement.tagName ||\n\t\t\t\t\t\t'';\n\t\t\t\t\tif (currentTagName !== tagNameMatch[1]) {\n\t\t\t\t\t\tvar tagNameLower = tagNameMatch[1].toLowerCase();\n\t\t\t\t\t\tif (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('Opening and ending tag mismatch: \"' + currentTagName + '\" != \"' + tagNameRaw + '\"');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvar config = parseStack.pop();\n\t\t\t\t\tunclosedTags.pop();\n\t\t\t\t\tvar localNSMap = config.localNSMap;\n\t\t\t\t\tdomBuilder.endElement(config.uri, config.localName, currentTagName);\n\t\t\t\t\tif (localNSMap) {\n\t\t\t\t\t\tfor (var prefix in localNSMap) {\n\t\t\t\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tend++;\n\t\t\t\t\tbreak;\n\t\t\t\t// end element\n\t\t\t\tcase '?': // \n\t\t\t\t\tlocator && position(tagStart);\n\t\t\t\t\tend = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);\n\t\t\t\t\tbreak;\n\t\t\t\tcase '!': // start) {\n\t\t\tstart = end;\n\t\t} else {\n\t\t\t//Possible sax fallback here, risk of positional error\n\t\t\tappendText(Math.max(tagStart, start) + 1);\n\t\t}\n\t}\n}\n\nfunction copyLocator(f, t) {\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @returns\n * end of the elementStartPart(end of elementEndPart for selfClosed el)\n * @see {@link #appendElement}\n */\nfunction parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (hasOwn(el.attributeNames, qname)) {\n\t\t\treturn errorHandler.fatalError('Attribute ' + qname + ' redefined');\n\t\t}\n\t\tif (!isHTML && value.indexOf('<') >= 0) {\n\t\t\treturn errorHandler.fatalError(\"Unescaped '<' not allowed in attributes values\");\n\t\t}\n\t\tel.addValue(\n\t\t\tqname,\n\t\t\t// @see https://www.w3.org/TR/xml/#AVNormalize\n\t\t\t// since the xmldom sax parser does not \"interpret\" DTD the following is not implemented:\n\t\t\t// - recursive replacement of (DTD) entity references\n\t\t\t// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA\n\t\t\tvalue.replace(/[\\t\\n\\r]/g, ' ').replace(ENTITY_REG, entityReplacer),\n\t\t\tstartIndex\n\t\t);\n\t}\n\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG; //status\n\twhile (true) {\n\t\tvar c = source.charAt(p);\n\t\tswitch (c) {\n\t\t\tcase '=':\n\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t//attrName\n\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else if (s === S_ATTR_SPACE) {\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\tcase '\"':\n\t\t\t\tif (\n\t\t\t\t\ts === S_EQ ||\n\t\t\t\t\ts === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t) {\n\t\t\t\t\t//equal\n\t\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"');\n\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t}\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\tp = source.indexOf(c, start);\n\t\t\t\t\tif (p > 0) {\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\taddAttribute(attrName, value, start - 1);\n\t\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\t\tthrow new Error(\"attribute value no end '\" + c + \"' match\");\n\t\t\t\t\t}\n\t\t\t\t} else if (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed start quot(' + c + ')!!');\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: no equal before\n\t\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '/':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\ts = S_TAG_CLOSE;\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t//case S_EQ:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"attribute invalid close char('/')\"); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '': //end document\n\t\t\t\terrorHandler.error('unexpected end of input');\n\t\t\t\tif (s == S_TAG) {\n\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\tcase '>':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\tbreak; //normal\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE: //Compatible state\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\tif (value.slice(-1) === '/') {\n\t\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\t\tvalue = value.slice(0, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tif (s === S_ATTR_SPACE) {\n\t\t\t\t\t\t\tvalue = attrName;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed value!! \"' + value + '\" instead!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(value, value, start);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('AttValue: \\' or \" expected');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\t\tcase '\\u0080':\n\t\t\t\tc = ' ';\n\t\t\tdefault:\n\t\t\t\tif (c <= ' ') {\n\t\t\t\t\t//space\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\t\tel.setTagName(source.slice(start, p)); //tagName\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\t\t\tvar value = source.slice(start, p);\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t\t\t//case S_EQ:\n\t\t\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t\t\t//\tvoid();break;\n\t\t\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t\t//ignore warning\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//not space\n\t\t\t\t\t//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n\t\t\t\t\t//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed value!! \"' + attrName + '\" instead2!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\terrorHandler.warning('attribute space is required\"' + attrName + '\"!!');\n\t\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t} //end outer switch\n\t\tp++;\n\t}\n}\n\n/**\n * @returns\n * `true` if a new namespace has been defined.\n */\nfunction appendElement(el, domBuilder, currentNSMap) {\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\tvar i = el.length;\n\twhile (i--) {\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif (nsp > 0) {\n\t\t\tvar prefix = (a.prefix = qName.slice(0, nsp));\n\t\t\tvar localName = qName.slice(nsp + 1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName;\n\t\t} else {\n\t\t\tlocalName = qName;\n\t\t\tprefix = null;\n\t\t\tnsPrefix = qName === 'xmlns' && '';\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif (nsPrefix !== false) {\n\t\t\t//hack!!\n\t\t\tif (localNSMap == null) {\n\t\t\t\tlocalNSMap = Object.create(null);\n\t\t\t\t_copy(currentNSMap, (currentNSMap = Object.create(null)));\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS;\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value);\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile (i--) {\n\t\ta = el[i];\n\t\tif (a.prefix) {\n\t\t\t//no prefix attribute has no namespace\n\t\t\tif (a.prefix === 'xml') {\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}\n\t\t\tif (a.prefix !== 'xmlns') {\n\t\t\t\ta.uri = currentNSMap[a.prefix];\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif (nsp > 0) {\n\t\tprefix = el.prefix = tagName.slice(0, nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp + 1);\n\t} else {\n\t\tprefix = null; //important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = (el.uri = currentNSMap[prefix || '']);\n\tdomBuilder.startElement(ns, localName, tagName, el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif (el.closed) {\n\t\tdomBuilder.endElement(ns, localName, tagName);\n\t\tif (localNSMap) {\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\n\nfunction parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {\n\t// https://html.spec.whatwg.org/#raw-text-elements\n\t// https://html.spec.whatwg.org/#escapable-raw-text-elements\n\t// https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements\n\t// TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions\n\tvar isEscapableRaw = isHTMLEscapableRawTextElement(tagName);\n\tif (isEscapableRaw || isHTMLRawTextElement(tagName)) {\n\t\tvar elEndStart = source.indexOf('', elStartEnd);\n\t\tvar text = source.substring(elStartEnd + 1, elEndStart);\n\n\t\tif (isEscapableRaw) {\n\t\t\ttext = text.replace(ENTITY_REG, entityReplacer);\n\t\t}\n\t\tdomBuilder.characters(text, 0, text.length);\n\t\treturn elEndStart;\n\t}\n\treturn elStartEnd + 1;\n}\n\nfunction _copy(source, target) {\n\tfor (var n in source) {\n\t\tif (hasOwn(source, n)) {\n\t\t\ttarget[n] = source[n];\n\t\t}\n\t}\n}\n\n/**\n * @typedef ParseUtils\n * @property {function(relativeIndex: number?): string | undefined} char\n * Provides look ahead access to a singe character relative to the current index.\n * @property {function(): number} getIndex\n * Provides read-only access to the current index.\n * @property {function(reg: RegExp): string | null} getMatch\n * Applies the provided regular expression enforcing that it starts at the current index and\n * returns the complete matching string,\n * and moves the current index by the length of the matching string.\n * @property {function(): string} getSource\n * Provides read-only access to the complete source.\n * @property {function(places: number?): void} skip\n * moves the current index by places (defaults to 1)\n * @property {function(): number} skipBlanks\n * Moves the current index by the amount of white space that directly follows the current index\n * and returns the amount of whitespace chars skipped (0..n),\n * or -1 if the end of the source was reached.\n * @property {function(): string} substringFromIndex\n * creates a substring from the current index to the end of `source`\n * @property {function(compareWith: string): boolean} substringStartsWith\n * Checks if `source` contains `compareWith`, starting from the current index.\n * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive\n * Checks if `source` contains `compareWith`, starting from the current index,\n * comparing the upper case of both sides.\n * @see {@link parseUtils}\n */\n\n/**\n * A temporary scope for parsing and look ahead operations in `source`,\n * starting from index `start`.\n *\n * Some operations move the current index by a number of positions,\n * after which `getIndex` returns the new index.\n *\n * @param {string} source\n * @param {number} start\n * @returns {ParseUtils}\n */\nfunction parseUtils(source, start) {\n\tvar index = start;\n\n\tfunction char(n) {\n\t\tn = n || 0;\n\t\treturn source.charAt(index + n);\n\t}\n\n\tfunction skip(n) {\n\t\tn = n || 1;\n\t\tindex += n;\n\t}\n\n\tfunction skipBlanks() {\n\t\tvar blanks = 0;\n\t\twhile (index < source.length) {\n\t\t\tvar c = char();\n\t\t\tif (c !== ' ' && c !== '\\n' && c !== '\\t' && c !== '\\r') {\n\t\t\t\treturn blanks;\n\t\t\t}\n\t\t\tblanks++;\n\t\t\tskip();\n\t\t}\n\t\treturn -1;\n\t}\n\tfunction substringFromIndex() {\n\t\treturn source.substring(index);\n\t}\n\tfunction substringStartsWith(text) {\n\t\treturn source.substring(index, index + text.length) === text;\n\t}\n\tfunction substringStartsWithCaseInsensitive(text) {\n\t\treturn source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();\n\t}\n\n\tfunction getMatch(args) {\n\t\tvar expr = g.reg('^', args);\n\t\tvar match = expr.exec(substringFromIndex());\n\t\tif (match) {\n\t\t\tskip(match[0].length);\n\t\t\treturn match[0];\n\t\t}\n\t\treturn null;\n\t}\n\treturn {\n\t\tchar: char,\n\t\tgetIndex: function () {\n\t\t\treturn index;\n\t\t},\n\t\tgetMatch: getMatch,\n\t\tgetSource: function () {\n\t\t\treturn source;\n\t\t},\n\t\tskip: skip,\n\t\tskipBlanks: skipBlanks,\n\t\tsubstringFromIndex: substringFromIndex,\n\t\tsubstringStartsWith: substringStartsWith,\n\t\tsubstringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,\n\t};\n}\n\n/**\n * @param {ParseUtils} p\n * @param {DOMHandler} errorHandler\n * @returns {string}\n */\nfunction parseDoctypeInternalSubset(p, errorHandler) {\n\t/**\n\t * @param {ParseUtils} p\n\t * @param {DOMHandler} errorHandler\n\t * @returns {string}\n\t */\n\tfunction parsePI(p, errorHandler) {\n\t\tvar match = g.PI.exec(p.substringFromIndex());\n\t\tif (!match) {\n\t\t\treturn errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());\n\t\t}\n\t\tif (match[1].toLowerCase() === 'xml') {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()\n\t\t\t);\n\t\t}\n\t\tp.skip(match[0].length);\n\t\treturn match[0];\n\t}\n\t// Parse internal subset\n\tvar source = p.getSource();\n\tif (p.char() === '[') {\n\t\tp.skip(1);\n\t\tvar intSubsetStart = p.getIndex();\n\t\twhile (p.getIndex() < source.length) {\n\t\t\tp.skipBlanks();\n\t\t\tif (p.char() === ']') {\n\t\t\t\tvar internalSubset = source.substring(intSubsetStart, p.getIndex());\n\t\t\t\tp.skip(1);\n\t\t\t\treturn internalSubset;\n\t\t\t}\n\t\t\tvar current = null;\n\t\t\t// Only in external subset\n\t\t\t// if (char() === '<' && char(1) === '!' && char(2) === '[') {\n\t\t\t// \tparseConditionalSections(p, errorHandler);\n\t\t\t// } else\n\t\t\tif (p.char() === '<' && p.char(1) === '!') {\n\t\t\t\tswitch (p.char(2)) {\n\t\t\t\t\tcase 'E': // ELEMENT | ENTITY\n\t\t\t\t\t\tif (p.char(3) === 'L') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.elementdecl);\n\t\t\t\t\t\t} else if (p.char(3) === 'N') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.EntityDecl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'A': // ATTRIBUTE\n\t\t\t\t\t\tcurrent = p.getMatch(g.AttlistDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'N': // NOTATION\n\t\t\t\t\t\tcurrent = p.getMatch(g.NotationDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-': // COMMENT\n\t\t\t\t\t\tcurrent = p.getMatch(g.Comment);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (p.char() === '<' && p.char(1) === '?') {\n\t\t\t\tcurrent = parsePI(p, errorHandler);\n\t\t\t} else if (p.char() === '%') {\n\t\t\t\tcurrent = p.getMatch(g.PEReference);\n\t\t\t} else {\n\t\t\t\treturn errorHandler.fatalError('Error detected in Markup declaration');\n\t\t\t}\n\t\t\tif (!current) {\n\t\t\t\treturn errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());\n\t\t\t}\n\t\t}\n\t\treturn errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');\n\t}\n}\n\n/**\n * Called when the parser encounters an element starting with '') {\n\t\t\t\treturn errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());\n\t\t\t}\n\t\t\tp.skip(1);\n\t\t\tdomBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);\n\t\t\tdomBuilder.endDTD();\n\t\t\treturn p.getIndex();\n\t\t}\n\t\tdefault:\n\t\t\treturn errorHandler.fatalError('Not well-formed XML starting with \" 0) {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'\n\t\t\t);\n\t\t}\n\t\tif (!g.XMLDecl.test(source.substring(start))) {\n\t\t\treturn errorHandler.fatalError('xml declaration is not well-formed');\n\t\t}\n\t}\n\tdomBuilder.processingInstruction(match[1], match[2]);\n\treturn start + match[0].length;\n}\n\nfunction ElementAttributes() {\n\tthis.attributeNames = Object.create(null);\n}\n\nElementAttributes.prototype = {\n\tsetTagName: function (tagName) {\n\t\tif (!g.QName_exact.test(tagName)) {\n\t\t\tthrow new Error('invalid tagName:' + tagName);\n\t\t}\n\t\tthis.tagName = tagName;\n\t},\n\taddValue: function (qName, value, offset) {\n\t\tif (!g.QName_exact.test(qName)) {\n\t\t\tthrow new Error('invalid attribute:' + qName);\n\t\t}\n\t\tthis.attributeNames[qName] = this.length;\n\t\tthis[this.length++] = { qName: qName, value: value, offset: offset };\n\t},\n\tlength: 0,\n\tgetLocalName: function (i) {\n\t\treturn this[i].localName;\n\t},\n\tgetLocator: function (i) {\n\t\treturn this[i].locator;\n\t},\n\tgetQName: function (i) {\n\t\treturn this[i].qName;\n\t},\n\tgetURI: function (i) {\n\t\treturn this[i].uri;\n\t},\n\tgetValue: function (i) {\n\t\treturn this[i].value;\n\t},\n\t//\t,getIndex:function(uri, localName)){\n\t//\t\tif(localName){\n\t//\n\t//\t\t}else{\n\t//\t\t\tvar qName = uri\n\t//\t\t}\n\t//\t},\n\t//\tgetValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},\n\t//\tgetType:function(uri,localName){}\n\t//\tgetType:function(i){},\n};\n\nexports.XMLReader = XMLReader;\nexports.parseUtils = parseUtils;\nexports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar dom = require('./dom');\nvar errors = require('./errors');\nvar entities = require('./entities');\nvar sax = require('./sax');\n\nvar DOMImplementation = dom.DOMImplementation;\n\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isValidMimeType = conventions.isValidMimeType;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\n\nvar XMLReader = sax.XMLReader;\n\n/**\n * Normalizes line ending according to ,\n * including some Unicode \"newline\" characters:\n *\n * > XML parsed entities are often stored in computer files which,\n * > for editing convenience, are organized into lines.\n * > These lines are typically separated by some combination\n * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).\n * >\n * > To simplify the tasks of applications, the XML processor must behave\n * > as if it normalized all line breaks in external parsed entities (including the document entity)\n * > on input, before parsing, by translating the following to a single #xA character:\n * >\n * > 1. the two-character sequence #xD #xA,\n * > 2. the two-character sequence #xD #x85,\n * > 3. the single character #x85,\n * > 4. the single character #x2028,\n * > 5. the single character #x2029,\n * > 6. any #xD character that is not immediately followed by #xA or #x85.\n *\n * @param {string} input\n * @returns {string}\n * @prettierignore\n */\nfunction normalizeLineEndings(input) {\n\treturn input.replace(/\\r[\\n\\u0085]/g, '\\n').replace(/[\\r\\u0085\\u2028\\u2029]/g, '\\n');\n}\n\n/**\n * @typedef Locator\n * @property {number} [columnNumber]\n * @property {number} [lineNumber]\n */\n\n/**\n * @typedef DOMParserOptions\n * @property {typeof assign} [assign]\n * The method to use instead of `conventions.assign`, which is used to copy values from\n * `options` before they are used for parsing.\n * @property {typeof DOMHandler} [domHandler]\n * For internal testing: The class for creating an instance for handling events from the SAX\n * parser.\n * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n * be broken.*****.\n * @property {Function} [errorHandler]\n * DEPRECATED! use `onError` instead.\n * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n * [onError]\n * A function invoked for every error that occurs during parsing.\n *\n * If it is not provided, all errors are reported to `console.error`\n * and only `fatalError`s are thrown as a `ParseError`,\n * which prevents any further processing.\n * If the provided method throws, a `ParserError` is thrown,\n * which prevents any further processing.\n *\n * Be aware that many `warning`s are considered an error that prevents further processing in\n * most implementations.\n * @property {boolean} [locator=true]\n * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`\n * attribute describing their location in the XML string.\n * Default is true.\n * @property {(string) => string} [normalizeLineEndings]\n * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,\n * which normalizes line endings according to ,\n * including some Unicode \"newline\" characters.\n * @property {Object} [xmlns]\n * The XML namespaces that should be assumed when parsing.\n * The default namespace can be provided by the key that is the empty string.\n * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n * the default namespace that will be used,\n * will be overridden according to the specification.\n * @see {@link normalizeLineEndings}\n */\n\n/**\n * The DOMParser interface provides the ability to parse XML or HTML source code from a string\n * into a DOM `Document`.\n *\n * ***xmldom is different from the spec in that it allows an `options` parameter,\n * to control the behavior***.\n *\n * @class\n * @param {DOMParserOptions} [options]\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization\n */\nfunction DOMParser(options) {\n\toptions = options || {};\n\tif (options.locator === undefined) {\n\t\toptions.locator = true;\n\t}\n\n\t/**\n\t * The method to use instead of `conventions.assign`, which is used to copy values from\n\t * `options`\n\t * before they are used for parsing.\n\t *\n\t * @type {conventions.assign}\n\t * @private\n\t * @see {@link conventions.assign}\n\t * @readonly\n\t */\n\tthis.assign = options.assign || conventions.assign;\n\n\t/**\n\t * For internal testing: The class for creating an instance for handling events from the SAX\n\t * parser.\n\t * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n\t * be broken*****.\n\t *\n\t * @type {typeof DOMHandler}\n\t * @private\n\t * @readonly\n\t */\n\tthis.domHandler = options.domHandler || DOMHandler;\n\n\t/**\n\t * A function that is invoked for every error that occurs during parsing.\n\t *\n\t * If it is not provided, all errors are reported to `console.error`\n\t * and only `fatalError`s are thrown as a `ParseError`,\n\t * which prevents any further processing.\n\t * If the provided method throws, a `ParserError` is thrown,\n\t * which prevents any further processing.\n\t *\n\t * Be aware that many `warning`s are considered an error that prevents further processing in\n\t * most implementations.\n\t *\n\t * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n\t * @see {@link onErrorStopParsing}\n\t * @see {@link onWarningStopParsing}\n\t */\n\tthis.onError = options.onError || options.errorHandler;\n\tif (options.errorHandler && typeof options.errorHandler !== 'function') {\n\t\tthrow new TypeError('errorHandler object is no longer supported, switch to onError!');\n\t} else if (options.errorHandler) {\n\t\toptions.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);\n\t}\n\n\t/**\n\t * used to replace line endings before parsing, defaults to `normalizeLineEndings`\n\t *\n\t * @type {(string) => string}\n\t * @readonly\n\t */\n\tthis.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;\n\n\t/**\n\t * Configures if the nodes created during parsing will have a `lineNumber` and a\n\t * `columnNumber`\n\t * attribute describing their location in the XML string.\n\t * Default is true.\n\t *\n\t * @type {boolean}\n\t * @readonly\n\t */\n\tthis.locator = !!options.locator;\n\n\t/**\n\t * The default namespace can be provided by the key that is the empty string.\n\t * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n\t * the default namespace that will be used,\n\t * will be overridden according to the specification.\n\t *\n\t * @type {Readonly}\n\t * @readonly\n\t */\n\tthis.xmlns = this.assign(Object.create(null), options.xmlns);\n}\n\n/**\n * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`\n * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,\n * otherwise an XML `Document` is created.\n *\n * __It behaves different from the description in the living standard__:\n * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.\n * - Any unexpected input is reported to `onError` with either a `warning`,\n * `error` or `fatalError` level.\n * - Any `fatalError` throws a `ParseError` which prevents further processing.\n * - Any error thrown by `onError` is converted to a `ParseError` which prevents further\n * processing - If no `Document` was created during parsing it is reported as a `fatalError`.\n * *****Warning: By configuring a faulty DOMHandler implementation,\n * the specified behavior can completely be broken*****.\n *\n * @param {string} source\n * The XML mime type only allows string input!\n * @param {string} [mimeType='application/xml']\n * the mimeType or contentType of the document to be created determines the `type` of document\n * created (XML or HTML)\n * @returns {Document}\n * The `Document` node.\n * @throws {ParseError}\n * for any `fatalError` or anything that is thrown by `onError`\n * @throws {TypeError}\n * for any invalid `mimeType`\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev\n */\nDOMParser.prototype.parseFromString = function (source, mimeType) {\n\tif (!isValidMimeType(mimeType)) {\n\t\tthrow new TypeError('DOMParser.parseFromString: the provided mimeType \"' + mimeType + '\" is not valid.');\n\t}\n\tvar defaultNSMap = this.assign(Object.create(null), this.xmlns);\n\tvar entityMap = entities.XML_ENTITIES;\n\tvar defaultNamespace = defaultNSMap[''] || null;\n\tif (hasDefaultHTMLNamespace(mimeType)) {\n\t\tentityMap = entities.HTML_ENTITIES;\n\t\tdefaultNamespace = NAMESPACE.HTML;\n\t} else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {\n\t\tdefaultNamespace = NAMESPACE.SVG;\n\t}\n\tdefaultNSMap[''] = defaultNamespace;\n\tdefaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;\n\n\tvar domBuilder = new this.domHandler({\n\t\tmimeType: mimeType,\n\t\tdefaultNamespace: defaultNamespace,\n\t\tonError: this.onError,\n\t});\n\tvar locator = this.locator ? {} : undefined;\n\tif (this.locator) {\n\t\tdomBuilder.setDocumentLocator(locator);\n\t}\n\n\tvar sax = new XMLReader();\n\tsax.errorHandler = domBuilder;\n\tsax.domBuilder = domBuilder;\n\tvar isXml = !conventions.isHTMLMimeType(mimeType);\n\tif (isXml && typeof source !== 'string') {\n\t\tsax.errorHandler.fatalError('source is not a string');\n\t}\n\tsax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);\n\tif (!domBuilder.doc.documentElement) {\n\t\tsax.errorHandler.fatalError('missing root element');\n\t}\n\treturn domBuilder.doc;\n};\n\n/**\n * @typedef DOMHandlerOptions\n * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]\n * @property {string | null} [defaultNamespace=null]\n */\n/**\n * The class that is used to handle events from the SAX parser to create the related DOM\n * elements.\n *\n * Some methods are only implemented as an empty function,\n * since they are (at least currently) not relevant for xmldom.\n *\n * @class\n * @param {DOMHandlerOptions} [options]\n * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html\n */\nfunction DOMHandler(options) {\n\tvar opt = options || {};\n\t/**\n\t * The mime type is used to determine if the DOM handler will create an XML or HTML document.\n\t * Only if it is set to `text/html` it will create an HTML document.\n\t * It defaults to MIME_TYPE.XML_APPLICATION.\n\t *\n\t * @type {string}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;\n\n\t/**\n\t * The namespace to use to create an XML document.\n\t * For the following reasons this is required:\n\t * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,\n\t * since at that point there is no way for the parser to know what the default namespace from\n\t * the document will be.\n\t * - When creating using `DOMImplementation.createDocument` it is required to pass a\n\t * namespace,\n\t * to determine the correct `Document.contentType`, which should match `this.mimeType`.\n\t * - When parsing an XML document with the `application/xhtml+xml` mimeType,\n\t * the HTML namespace needs to be the default namespace.\n\t *\n\t * @type {string | null}\n\t * @private\n\t * @readonly\n\t */\n\tthis.defaultNamespace = opt.defaultNamespace || null;\n\n\t/**\n\t * @type {boolean}\n\t * @private\n\t */\n\tthis.cdata = false;\n\n\t/**\n\t * The last `Element` that was created by `startElement`.\n\t * `endElement` sets it to the `currentElement.parentNode`.\n\t *\n\t * Note: The sax parser currently sets it to white space text nodes between tags.\n\t *\n\t * @type {Element | Node | undefined}\n\t * @private\n\t */\n\tthis.currentElement = undefined;\n\n\t/**\n\t * The Document that is created as part of `startDocument`,\n\t * and returned by `DOMParser.parseFromString`.\n\t *\n\t * @type {Document | undefined}\n\t * @readonly\n\t */\n\tthis.doc = undefined;\n\n\t/**\n\t * The locator is stored as part of setDocumentLocator.\n\t * It is controlled and mutated by the SAX parser to store the current parsing position.\n\t * It is used by DOMHandler to set `columnNumber` and `lineNumber`\n\t * on the DOM nodes.\n\t *\n\t * @type {Readonly | undefined}\n\t * @private\n\t * @readonly (the\n\t * sax parser currently sometimes set's it)\n\t */\n\tthis.locator = undefined;\n\t/**\n\t * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}\n\t * @readonly\n\t */\n\tthis.onError = opt.onError;\n}\n\nfunction position(locator, node) {\n\tnode.lineNumber = locator.lineNumber;\n\tnode.columnNumber = locator.columnNumber;\n}\n\nDOMHandler.prototype = {\n\t/**\n\t * Either creates an XML or an HTML document and stores it under `this.doc`.\n\t * If it is an XML document, `this.defaultNamespace` is used to create it,\n\t * and it will not contain any `childNodes`.\n\t * If it is an HTML document, it will be created without any `childNodes`.\n\t *\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html\n\t */\n\tstartDocument: function () {\n\t\tvar impl = new DOMImplementation();\n\t\tthis.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');\n\t},\n\tstartElement: function (namespaceURI, localName, qName, attrs) {\n\t\tvar doc = this.doc;\n\t\tvar el = doc.createElementNS(namespaceURI, qName || localName);\n\t\tvar len = attrs.length;\n\t\tappendElement(this, el);\n\t\tthis.currentElement = el;\n\n\t\tthis.locator && position(this.locator, el);\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tvar namespaceURI = attrs.getURI(i);\n\t\t\tvar value = attrs.getValue(i);\n\t\t\tvar qName = attrs.getQName(i);\n\t\t\tvar attr = doc.createAttributeNS(namespaceURI, qName);\n\t\t\tthis.locator && position(attrs.getLocator(i), attr);\n\t\t\tattr.value = attr.nodeValue = value;\n\t\t\tel.setAttributeNode(attr);\n\t\t}\n\t},\n\tendElement: function (namespaceURI, localName, qName) {\n\t\tthis.currentElement = this.currentElement.parentNode;\n\t},\n\tstartPrefixMapping: function (prefix, uri) {},\n\tendPrefixMapping: function (prefix) {},\n\tprocessingInstruction: function (target, data) {\n\t\tvar ins = this.doc.createProcessingInstruction(target, data);\n\t\tthis.locator && position(this.locator, ins);\n\t\tappendElement(this, ins);\n\t},\n\tignorableWhitespace: function (ch, start, length) {},\n\tcharacters: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\t//console.log(chars)\n\t\tif (chars) {\n\t\t\tif (this.cdata) {\n\t\t\t\tvar charNode = this.doc.createCDATASection(chars);\n\t\t\t} else {\n\t\t\t\tvar charNode = this.doc.createTextNode(chars);\n\t\t\t}\n\t\t\tif (this.currentElement) {\n\t\t\t\tthis.currentElement.appendChild(charNode);\n\t\t\t} else if (/^\\s*$/.test(chars)) {\n\t\t\t\tthis.doc.appendChild(charNode);\n\t\t\t\t//process xml\n\t\t\t}\n\t\t\tthis.locator && position(this.locator, charNode);\n\t\t}\n\t},\n\tskippedEntity: function (name) {},\n\tendDocument: function () {\n\t\tthis.doc.normalize();\n\t},\n\t/**\n\t * Stores the locator to be able to set the `columnNumber` and `lineNumber`\n\t * on the created DOM nodes.\n\t *\n\t * @param {Locator} locator\n\t */\n\tsetDocumentLocator: function (locator) {\n\t\tif (locator) {\n\t\t\tlocator.lineNumber = 0;\n\t\t}\n\t\tthis.locator = locator;\n\t},\n\t//LexicalHandler\n\tcomment: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\tvar comm = this.doc.createComment(chars);\n\t\tthis.locator && position(this.locator, comm);\n\t\tappendElement(this, comm);\n\t},\n\n\tstartCDATA: function () {\n\t\t//used in characters() methods\n\t\tthis.cdata = true;\n\t},\n\tendCDATA: function () {\n\t\tthis.cdata = false;\n\t},\n\n\tstartDTD: function (name, publicId, systemId, internalSubset) {\n\t\tvar impl = this.doc.implementation;\n\t\tif (impl && impl.createDocumentType) {\n\t\t\tvar dt = impl.createDocumentType(name, publicId, systemId, internalSubset);\n\t\t\tthis.locator && position(this.locator, dt);\n\t\t\tappendElement(this, dt);\n\t\t\tthis.doc.doctype = dt;\n\t\t}\n\t},\n\treportError: function (level, message) {\n\t\tif (typeof this.onError === 'function') {\n\t\t\ttry {\n\t\t\t\tthis.onError(level, message, this);\n\t\t\t} catch (e) {\n\t\t\t\tthrow new ParseError('Reporting ' + level + ' \"' + message + '\" caused ' + e, this.locator);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error('[xmldom ' + level + ']\\t' + message, _locator(this.locator));\n\t\t}\n\t},\n\t/**\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html\n\t */\n\twarning: function (message) {\n\t\tthis.reportError('warning', message);\n\t},\n\terror: function (message) {\n\t\tthis.reportError('error', message);\n\t},\n\t/**\n\t * This function reports a fatal error and throws a ParseError.\n\t *\n\t * @param {string} message\n\t * - The message to be used for reporting and throwing the error.\n\t * @returns {never}\n\t * This function always throws an error and never returns a value.\n\t * @throws {ParseError}\n\t * Always throws a ParseError with the provided message.\n\t */\n\tfatalError: function (message) {\n\t\tthis.reportError('fatalError', message);\n\t\tthrow new ParseError(message, this.locator);\n\t},\n};\n\nfunction _locator(l) {\n\tif (l) {\n\t\treturn '\\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';\n\t}\n}\n\nfunction _toString(chars, start, length) {\n\tif (typeof chars == 'string') {\n\t\treturn chars.substr(start, length);\n\t} else {\n\t\t//java sax connect width xmldom on rhino(what about: \"? && !(chars instanceof String)\")\n\t\tif (chars.length >= start + length || start) {\n\t\t\treturn new java.lang.String(chars, start, length) + '';\n\t\t}\n\t\treturn chars;\n\t}\n}\n\n/*\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html\n * used method of org.xml.sax.ext.LexicalHandler:\n * #comment(chars, start, length)\n * #startCDATA()\n * #endCDATA()\n * #startDTD(name, publicId, systemId)\n *\n *\n * IGNORED method of org.xml.sax.ext.LexicalHandler:\n * #endDTD()\n * #startEntity(name)\n * #endEntity(name)\n *\n *\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html\n * IGNORED method of org.xml.sax.ext.DeclHandler\n * \t#attributeDecl(eName, aName, type, mode, value)\n * #elementDecl(name, model)\n * #externalEntityDecl(name, publicId, systemId)\n * #internalEntityDecl(name, value)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html\n * IGNORED method of org.xml.sax.EntityResolver2\n * #resolveEntity(String name,String publicId,String baseURI,String systemId)\n * #resolveEntity(publicId, systemId)\n * #getExternalSubset(name, baseURI)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html\n * IGNORED method of org.xml.sax.DTDHandler\n * #notationDecl(name, publicId, systemId) {};\n * #unparsedEntityDecl(name, publicId, systemId, notationName) {};\n */\n'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(\n\t/\\w+/g,\n\tfunction (key) {\n\t\tDOMHandler.prototype[key] = function () {\n\t\t\treturn null;\n\t\t};\n\t}\n);\n\n/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */\nfunction appendElement(handler, node) {\n\tif (!handler.currentElement) {\n\t\thandler.doc.appendChild(node);\n\t} else {\n\t\thandler.currentElement.appendChild(node);\n\t}\n}\n\n/**\n * A method that prevents any further parsing when an `error`\n * with level `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onWarningStopParsing}\n */\nfunction onErrorStopParsing(level) {\n\tif (level === 'error') throw 'onErrorStopParsing';\n}\n\n/**\n * A method that prevents any further parsing when any `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onErrorStopParsing}\n */\nfunction onWarningStopParsing() {\n\tthrow 'onWarningStopParsing';\n}\n\nexports.__DOMHandler = DOMHandler;\nexports.DOMParser = DOMParser;\nexports.normalizeLineEndings = normalizeLineEndings;\nexports.onErrorStopParsing = onErrorStopParsing;\nexports.onWarningStopParsing = onWarningStopParsing;\n","'use strict';\nvar conventions = require('./conventions');\nexports.assign = conventions.assign;\nexports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nexports.isHTMLMimeType = conventions.isHTMLMimeType;\nexports.isValidMimeType = conventions.isValidMimeType;\nexports.MIME_TYPE = conventions.MIME_TYPE;\nexports.NAMESPACE = conventions.NAMESPACE;\n\nvar errors = require('./errors');\nexports.DOMException = errors.DOMException;\nexports.DOMExceptionName = errors.DOMExceptionName;\nexports.ExceptionCode = errors.ExceptionCode;\nexports.ParseError = errors.ParseError;\n\nvar dom = require('./dom');\nexports.Attr = dom.Attr;\nexports.CDATASection = dom.CDATASection;\nexports.CharacterData = dom.CharacterData;\nexports.Comment = dom.Comment;\nexports.Document = dom.Document;\nexports.DocumentFragment = dom.DocumentFragment;\nexports.DocumentType = dom.DocumentType;\nexports.DOMImplementation = dom.DOMImplementation;\nexports.Element = dom.Element;\nexports.Entity = dom.Entity;\nexports.EntityReference = dom.EntityReference;\nexports.LiveNodeList = dom.LiveNodeList;\nexports.NamedNodeMap = dom.NamedNodeMap;\nexports.Node = dom.Node;\nexports.NodeList = dom.NodeList;\nexports.Notation = dom.Notation;\nexports.ProcessingInstruction = dom.ProcessingInstruction;\nexports.Text = dom.Text;\nexports.XMLSerializer = dom.XMLSerializer;\n\nvar domParser = require('./dom-parser');\nexports.DOMParser = domParser.DOMParser;\nexports.normalizeLineEndings = domParser.normalizeLineEndings;\nexports.onErrorStopParsing = domParser.onErrorStopParsing;\nexports.onWarningStopParsing = domParser.onWarningStopParsing;\n","import { DOMParser as g, DOMImplementation as J } from \"@xmldom/xmldom\";\nconst p = \"USJ\", O = \"3.1\", _ = Object.freeze({ type: p, version: O, content: [] }), B = [\n \"type\",\n \"marker\",\n \"content\",\n \"sid\",\n \"eid\",\n \"number\",\n \"code\",\n \"altnumber\",\n \"pubnumber\",\n \"caller\",\n \"align\",\n \"category\"\n];\nfunction H(e) {\n return M.includes(e);\n}\nconst M = [\n // Old Testament\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n // New Testament\n \"MAT\",\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n // Deuterocanon\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"EZA\",\n \"5EZ\",\n \"6EZ\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n \"REP\",\n \"4BA\",\n \"LAO\",\n // Non scripture\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\",\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\"\n], f = \"usx\", N = \"3.1\", I = `<${f} version=\"${N}\" />`;\nfunction V(e) {\n const n = new g().parseFromString(e, \"text/xml\");\n return m(n.documentElement);\n}\nfunction m(e) {\n const [t] = e ? b(e) : [{ content: [] }];\n return t.type = p, t.version = O, t;\n}\nfunction b(e) {\n const t = {};\n let n = e.tagName, o, s, c = \"append\";\n if ([\"row\", \"cell\"].includes(n) && (n = \"table:\" + n), e.attributes)\n for (const r of Array.from(e.attributes))\n t[r.name] = r.value;\n t.style && (o = t.style, delete t.style), t.vid && delete t.vid, t.status && delete t.status;\n let i = { type: n };\n o && (i.marker = o), i = { ...i, ...t }, e.firstChild && e.firstChild.nodeType === e.firstChild.TEXT_NODE && e.firstChild.nodeValue && E(e.firstChild.nodeValue) !== \"\" && (s = e.firstChild.nodeValue);\n const l = Array.from(e.childNodes);\n i.content = [], s && i.content.push(s);\n for (const r of l) {\n if (r.tagName === void 0)\n continue;\n const [u, S] = b(r);\n switch (S) {\n case \"append\":\n i.content.push(u);\n break;\n case \"merge\":\n i.content = i.content.concat(u);\n break;\n }\n r.nextSibling && r.nextSibling.nodeType === r.nextSibling.TEXT_NODE && r.nextSibling.nodeValue && (E(r.nextSibling.nodeValue) !== \"\" || r.nextSibling.nodeValue === \" \") && i.content.push(r.nextSibling.nodeValue);\n }\n return i.content.length === 0 && i.type !== f && delete i.content, \"eid\" in i && [\"verse\", \"chapter\"].includes(n) && (c = \"ignore\"), [i, c];\n}\nfunction E(e) {\n return e.replace(/(^[ \\t\\n\\r\\f\\v]+)|([ \\t\\n\\r\\f\\v]+$)/g, \"\");\n}\nlet d, a;\nfunction C(e) {\n const t = new J().createDocument(\"\", f);\n return t.documentElement && (t.documentElement.setAttribute(\"version\", N), y(e, t)), t.toString();\n}\nfunction y(e, t) {\n if (t.documentElement) {\n for (const [n, o] of e.content.entries()) {\n const s = n === e.content.length - 1;\n v(o, t.documentElement, t, s);\n }\n return t.documentElement ?? void 0;\n }\n}\nfunction v(e, t, n, o) {\n let s, c, i;\n if (typeof e == \"string\") s = n.createTextNode(e);\n else if (c = e.type.replace(\"table:\", \"\"), s = n.createElement(c), X(s, e), e.content)\n for (const [r, u] of e.content.entries()) {\n const S = r === e.content.length - 1;\n v(u, s, n, S);\n }\n a && (c === \"verse\" || t.tagName === \"para\" && o) && (i = T(n, a), a = void 0), c === \"verse\" && typeof e != \"string\" && e.sid !== void 0 && (a = e.sid), d && (c === \"chapter\" || c === \"para\" && o) && (i = h(n, d), d = void 0), c === \"chapter\" && typeof e != \"string\" && e.sid !== void 0 && (d = e.sid);\n const l = t.nodeName === f && (i == null ? void 0 : i.tagName) === \"verse\";\n i && (!o || l) && t.appendChild(i), t.appendChild(s), i && o && !l && t.appendChild(i), o && t.nodeName === f && (a && t.appendChild(T(n, a)), d && t.appendChild(h(n, d)), a = void 0, d = void 0);\n}\nfunction X(e, t) {\n t.marker && (t.type === \"unmatched\" ? e.setAttribute(\"marker\", t.marker) : e.setAttribute(\"style\", t.marker));\n for (const [n, o] of Object.entries(t))\n o && ![\"type\", \"marker\", \"content\"].includes(n) && e.setAttribute(n, o);\n}\nfunction T(e, t) {\n const n = e.createElement(\"verse\");\n return n.setAttribute(\"eid\", t), n;\n}\nfunction h(e, t) {\n const n = e.createElement(\"chapter\");\n return n.setAttribute(\"eid\", t), n;\n}\nconst A = \"$\", P = \".content[\";\nfunction D(e) {\n const t = e.split(P);\n if (t.shift() !== A)\n throw new Error(`indexesFromJsonPath: jsonPath didn't start with '${A}'`);\n return t.map((o) => parseInt(o, 10));\n}\nfunction U(e) {\n return e.reduce((t, n) => `${t}${P}${n}]`, A);\n}\nexport {\n _ as EMPTY_USJ,\n I as EMPTY_USX,\n B as MARKER_OBJECT_PROPS,\n p as USJ_TYPE,\n O as USJ_VERSION,\n f as USX_TYPE,\n N as USX_VERSION,\n M as VALID_BOOK_CODES,\n D as indexesFromUsjJsonPath,\n H as isValidBookCode,\n U as usjJsonPathFromIndexes,\n C as usjToUsxString,\n V as usxStringToUsj\n};\n//# sourceMappingURL=index.js.map\n","\"use strict\"\r\n\r\n// Based on: https://github.com/lodash/lodash/blob/6018350ac10d5ce6a5b7db625140b82aeab804df/.internal/unicodeSize.js\r\n\r\nmodule.exports = () => {\r\n\t// Used to compose unicode character classes.\r\n\tconst astralRange = \"\\\\ud800-\\\\udfff\"\r\n\tconst comboMarksRange = \"\\\\u0300-\\\\u036f\"\r\n\tconst comboHalfMarksRange = \"\\\\ufe20-\\\\ufe2f\"\r\n\tconst comboSymbolsRange = \"\\\\u20d0-\\\\u20ff\"\r\n\tconst comboMarksExtendedRange = \"\\\\u1ab0-\\\\u1aff\"\r\n\tconst comboMarksSupplementRange = \"\\\\u1dc0-\\\\u1dff\"\r\n\tconst comboRange = comboMarksRange + comboHalfMarksRange + comboSymbolsRange + comboMarksExtendedRange + comboMarksSupplementRange\r\n\tconst varRange = \"\\\\ufe0e\\\\ufe0f\"\r\n\tconst familyRange = \"\\\\uD83D\\\\uDC69\\\\uD83C\\\\uDFFB\\\\u200D\\\\uD83C\\\\uDF93\"\r\n\r\n\t// Used to compose unicode capture groups.\r\n\tconst astral = `[${astralRange}]`\r\n\tconst combo = `[${comboRange}]`\r\n\tconst fitz = \"\\\\ud83c[\\\\udffb-\\\\udfff]\"\r\n\tconst modifier = `(?:${combo}|${fitz})`\r\n\tconst nonAstral = `[^${astralRange}]`\r\n\tconst regional = \"(?:\\\\uD83C[\\\\uDDE6-\\\\uDDFF]){2}\"\r\n\tconst surrogatePair = \"[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]\"\r\n\tconst zwj = \"\\\\u200d\"\r\n\tconst blackFlag = \"(?:\\\\ud83c\\\\udff4\\\\udb40\\\\udc67\\\\udb40\\\\udc62\\\\udb40(?:\\\\udc65|\\\\udc73|\\\\udc77)\\\\udb40(?:\\\\udc6e|\\\\udc63|\\\\udc6c)\\\\udb40(?:\\\\udc67|\\\\udc74|\\\\udc73)\\\\udb40\\\\udc7f)\"\r\n\tconst family = `[${familyRange}]`\r\n\r\n\t// Used to compose unicode regexes.\r\n\tconst optModifier = `${modifier}?`\r\n\tconst optVar = `[${varRange}]?`\r\n\tconst optJoin = `(?:${zwj}(?:${[nonAstral, regional, surrogatePair].join(\"|\")})${optVar + optModifier})*`\r\n\tconst seq = optVar + optModifier + optJoin\r\n\tconst nonAstralCombo = `${nonAstral}${combo}?`\r\n\tconst symbol = `(?:${[nonAstralCombo, combo, regional, surrogatePair, astral, family].join(\"|\")})`\r\n\r\n\t// Used to match [String symbols](https://mathiasbynens.be/notes/javascript-unicode).\r\n\treturn new RegExp(`${blackFlag}|${fitz}(?=${fitz})|${symbol + seq}`, \"g\")\r\n}\r\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// @ts-ignore\nvar char_regex_1 = __importDefault(require(\"char-regex\"));\n/**\n * Converts a string to an array of string chars\n * @param {string} str The string to turn into array\n * @returns {string[]}\n */\nfunction toArray(str) {\n if (typeof str !== 'string') {\n throw new Error('A string is expected as input');\n }\n return str.match(char_regex_1.default()) || [];\n}\nexports.toArray = toArray;\n/**\n * Returns the length of a string\n *\n * @export\n * @param {string} str\n * @returns {number}\n */\nfunction length(str) {\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var match = str.match(char_regex_1.default());\n return match === null ? 0 : match.length;\n}\nexports.length = length;\n/**\n * Returns a substring by providing start and end position\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} end End position\n * @returns {string}\n */\nfunction substring(str, begin, end) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n // Even though negative numbers work here, theyre not in the spec\n if (typeof begin !== 'number' || begin < 0) {\n begin = 0;\n }\n if (typeof end === 'number' && end < 0) {\n end = 0;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substring = substring;\n/**\n * Returns a substring by providing start position and length\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} len Desired length\n * @returns {string}\n */\nfunction substr(str, begin, len) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var strLength = length(str);\n // Fix type\n if (typeof begin !== 'number') {\n begin = parseInt(begin, 10);\n }\n // Return zero-length string if got oversize number.\n if (begin >= strLength) {\n return '';\n }\n // Calculating postive version of negative value.\n if (begin < 0) {\n begin += strLength;\n }\n var end;\n if (typeof len === 'undefined') {\n end = strLength;\n }\n else {\n // Fix type\n if (typeof len !== 'number') {\n len = parseInt(len, 10);\n }\n end = len >= 0 ? len + begin : begin;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substr = substr;\n/**\n * Enforces a string to be a certain length by\n * adding or removing characters\n *\n * @export\n * @param {string} str\n * @param {number} [limit=16] Limit\n * @param {string} [padString='#'] The Pad String\n * @param {string} [padPosition='right'] The Pad Position\n * @returns {string}\n */\nfunction limit(str, limit, padString, padPosition) {\n if (limit === void 0) { limit = 16; }\n if (padString === void 0) { padString = '#'; }\n if (padPosition === void 0) { padPosition = 'right'; }\n // Input should be a string, limit should be a number\n if (typeof str !== 'string' || typeof limit !== 'number') {\n throw new Error('Invalid arguments specified');\n }\n // Pad position should be either left or right\n if (['left', 'right'].indexOf(padPosition) === -1) {\n throw new Error('Pad position should be either left or right');\n }\n // Pad string can be anything, we convert it to string\n if (typeof padString !== 'string') {\n padString = String(padString);\n }\n // Calculate string length considering astral code points\n var strLength = length(str);\n if (strLength > limit) {\n return substring(str, 0, limit);\n }\n else if (strLength < limit) {\n var padRepeats = padString.repeat(limit - strLength);\n return padPosition === 'left' ? padRepeats + str : str + padRepeats;\n }\n return str;\n}\nexports.limit = limit;\n/**\n * Returns the index of the first occurrence of a given string\n *\n * @export\n * @param {string} str\n * @param {string} [searchStr] the string to search\n * @param {number} [pos] starting position\n * @returns {number}\n */\nfunction indexOf(str, searchStr, pos) {\n if (pos === void 0) { pos = 0; }\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n if (str === '') {\n if (searchStr === '') {\n return 0;\n }\n return -1;\n }\n // fix type\n pos = Number(pos);\n pos = isNaN(pos) ? 0 : pos;\n searchStr = String(searchStr);\n var strArr = toArray(str);\n if (pos >= strArr.length) {\n if (searchStr === '') {\n return strArr.length;\n }\n return -1;\n }\n if (searchStr === '') {\n return pos;\n }\n var searchArr = toArray(searchStr);\n var finded = false;\n var index;\n for (index = pos; index < strArr.length; index += 1) {\n var searchIndex = 0;\n while (searchIndex < searchArr.length &&\n searchArr[searchIndex] === strArr[index + searchIndex]) {\n searchIndex += 1;\n }\n if (searchIndex === searchArr.length &&\n searchArr[searchIndex - 1] === strArr[index + searchIndex - 1]) {\n finded = true;\n break;\n }\n }\n return finded ? index : -1;\n}\nexports.indexOf = indexOf;\n","/**\n * Ensures that the given input is returned as an array.\n *\n * This function takes a value that might be a single item, an array, or `undefined` and returns it\n * as an array:\n *\n * - If the input is `undefined`, an empty array is returned.\n * - If the input is already an array, it is returned as-is.\n * - If the input is a single item, it is wrapped in an array.\n *\n * @typeParam T - The type of the elements in the array.\n * @param maybeArray - The value that may be a single item, an array, or `undefined`.\n * @returns An array containing the input value(s). If the input is `undefined`, an empty array is\n * returned.\n */\nexport function ensureArray(maybeArray: T | T[] | undefined): T[] {\n if (!maybeArray) return [];\n\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\nexport default ensureArray;\n","import { LocalizeKey } from 'extension-contributions/menus.model';\nimport {\n indexOf as stringzIndexOf,\n length as stringzLength,\n limit as stringzLimit,\n substr as stringzSubstr,\n substring as stringzSubstring,\n toArray as stringzToArray,\n} from 'stringz';\nimport { ensureArray } from './array-util';\nimport { isString } from './util';\n\n/**\n * This function mirrors the `at` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Finds the Unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the character to be returned in range of -length(string) to\n * length(string)\n * @returns New string consisting of the Unicode code point located at the specified offset,\n * undefined if index is out of bounds\n */\nexport function at(string: string, index: number): string | undefined {\n if (index > stringLength(string) || index < -stringLength(string)) return undefined;\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `charAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a new string consisting of the single unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns New string consisting of the Unicode code point located at the specified offset, empty\n * string if index is out of bounds\n */\nexport function charAt(string: string, index: number): string {\n if (index < 0 || index > stringLength(string) - 1) return '';\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `codePointAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a non-negative integer that is the Unicode code point value of the character starting at\n * the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns Non-negative integer representing the code point value of the character at the given\n * index, or undefined if there is no element at that position\n */\nexport function codePointAt(string: string, index: number): number | undefined {\n if (index < 0 || index > stringLength(string) - 1) return undefined;\n return substr(string, index, 1).codePointAt(0);\n}\n\n/**\n * This function mirrors the `endsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether a string ends with the characters of this string.\n *\n * @param string String to search through\n * @param searchString Characters to search for at the end of the string\n * @param endPosition End position where searchString is expected to be found. Default is\n * `length(string)`\n * @returns True if it ends with searchString, false if it does not\n */\nexport function endsWith(\n string: string,\n searchString: string,\n endPosition: number = stringLength(string),\n): boolean {\n const lastIndexOfSearchString = lastIndexOf(string, searchString);\n if (lastIndexOfSearchString === -1) return false;\n if (lastIndexOfSearchString + stringLength(searchString) !== endPosition) return false;\n return true;\n}\n\n/**\n * Get the index of the closest closing curly brace in a string.\n *\n * Note: when escaped, gets the index of the curly brace, not the backslash before it.\n *\n * @param str String to search\n * @param index Index at which to start searching. Inclusive of this index\n * @param escaped Whether to search for an escaped or an unescaped closing curly brace\n * @returns Index of closest closing curly brace or -1 if not found\n */\nfunction indexOfClosestClosingCurlyBrace(str: string, index: number, escaped: boolean) {\n if (index < 0) return -1;\n if (escaped) {\n if (charAt(str, index) === '}' && charAt(str, index - 1) === '\\\\') return index;\n const closeCurlyBraceIndex = indexOf(str, '\\\\}', index);\n return closeCurlyBraceIndex >= 0 ? closeCurlyBraceIndex + 1 : closeCurlyBraceIndex;\n }\n\n let i = index;\n const strLength = stringLength(str);\n while (i < strLength) {\n i = indexOf(str, '}', i);\n\n if (i === -1 || charAt(str, i - 1) !== '\\\\') break;\n\n // Didn't find an un-escaped close brace, so keep looking\n i += 1;\n }\n\n return i >= strLength ? -1 : i;\n}\n\n/**\n * Formats a string into an array of objects (adjacent strings are concatenated in one array entry),\n * replacing `{replacer key}` with the value in the `replacers` at that replacer key (or multiple\n * replacer values if there are multiple in the string). Will also remove \\ before curly braces if\n * curly braces are escaped with a backslash in order to preserve the curly braces. E.g. 'Hi, this\n * is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * Note: React elements can be used as replacer values.\n *\n * @example\n *\n * ```tsx\n *

\n * {formatReplacementStringToArray('Hi {other}! I am {name}.', {\n * other: 'Billy',\n * name: Jim,\n * })}\n *

\n * ```\n *\n * @example\n *\n * ```typescript\n * formatReplacementStringToArray(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carInfo} car. My favorite food is {food}.',\n * { name: ['Bill'], carInfo: { year: 2015, color: 'blue' } }\n * );\n *\n * =>\n *\n * ['Hi, this is ', ['Bill'], '! I like {curly braces}! I have a ', { year: 2015, color: 'blue' }, ' car. My favorite food is food.']\n * ```\n *\n * @param str String to format and break out into an array of objects\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. If the replacer value is a string,\n * it will be concatenated into existing strings in the array. Otherwise, the replacer value will\n * be added as a new entry in the array\n * @returns Array of formatted strings and replaced objects\n */\nexport function formatReplacementStringToArray(\n str: string,\n replacers: { [key: string | number]: T } | object,\n): (string | T)[] {\n /** The compiled list of contents with replacers replaced appropriately */\n const contents: (string | T)[] = [];\n\n // current index in the string as we go through it\n let i = 0;\n // first index of characters to include in the next plain string added to the content\n let nextIntermediateStartIndex = 0;\n\n /**\n * Adds some content to the array of contents that is being built and also add the intermediate\n * string between the last added content and this added content\n *\n * @param newContent Content to add\n * @param newContentIndex Position in string where newContent starts\n * @param newContentLength Length in the string of the representation of this newContent\n */\n function addToContents(\n newContent: string | T,\n newContentIndex: number,\n newContentLength: number,\n ) {\n // Get the string content between the last new content and this new content\n const intermediateContent = substring(str, nextIntermediateStartIndex, newContentIndex);\n\n // If the last item in contents is a string, pull it out and add intermediateContent to\n // it. Otherwise stick with just intermediateContent\n const baseSubstring =\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${intermediateContent}`\n : intermediateContent;\n\n if (isString(newContent)) {\n // If the new content is a string, add it all together\n contents.push(`${baseSubstring}${newContent}`);\n } else {\n // New content is not a string. Add the base string if it exists (don't add an\n // empty string between added contents), then add the new content separately\n if (baseSubstring) contents.push(baseSubstring);\n contents.push(newContent);\n }\n\n // Set the intermediate start index to right after the new content so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = newContentIndex + newContentLength;\n }\n\n const strLength = stringLength(str);\n while (i < strLength) {\n switch (charAt(str, i)) {\n case '{':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped open curly brace. Try to match and replace\n const closeCurlyBraceIndex = indexOfClosestClosingCurlyBrace(str, i, false);\n if (closeCurlyBraceIndex >= 0) {\n // We have matching open and close indices. Try to replace the contents\n const replacerKey = substring(str, i + 1, closeCurlyBraceIndex);\n\n // Replace with the replacer or just remove the curly braces\n const replacerContent =\n replacerKey in replacers\n ? // Just checked that the key is in the object\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n replacers[replacerKey as keyof typeof replacers]\n : replacerKey;\n\n addToContents(replacerContent, i, closeCurlyBraceIndex + 1 - i);\n\n // Put our index at the closing brace to keep processing the string after it\n i = closeCurlyBraceIndex;\n // Set the intermediate start index to right after our closing curly brace so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = closeCurlyBraceIndex + 1;\n } else {\n // This is an unexpected un-escaped open curly brace with no matching closing curly\n // brace. Just ignore, I guess\n }\n } else {\n // This character is an escaped open curly brace. Add the curly brace but skip over the\n // escape backslash\n addToContents('{', i - 1, 2);\n }\n break;\n case '}':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped closing curly brace with no matching open curly\n // brace. Just ignore, I guess\n } else {\n // This character is an escaped closing curly brace. Add the curly brace but skip over\n // the escape backslash\n addToContents('}', i - 1, 2);\n }\n break;\n default:\n // No need to do anything with other characters at this point\n break;\n }\n\n i += 1;\n }\n\n // Now we are through the whole string and need to add the string content after all replacers if\n // there is anything left\n if (nextIntermediateStartIndex < strLength) {\n // Get the string content between the last new content and this new content\n const endContent = substring(str, nextIntermediateStartIndex);\n\n // If the last item in contents is a string, pull it out and add endContent to\n // it. Then put it in the contents array\n contents.push(\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${endContent}`\n : endContent,\n );\n }\n\n return contents;\n}\n\n/**\n * Formats a string, replacing `{replacer key}` with the value in the `replacers` at that replacer\n * key (or multiple replacer values if there are multiple in the string). Will also remove \\ before\n * curly braces if curly braces are escaped with a backslash in order to preserve the curly braces.\n * E.g. 'Hi, this is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly\n * braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * @example\n *\n * ```typescript\n * formatReplacementString(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carColor} car. My favorite food is {food}.',\n * { name: 'Bill', carColor: 'blue' }\n * );\n *\n * =>\n *\n * 'Hi, this is Bill! I like {curly braces}! I have a blue car. My favorite food is food.'\n * ```\n *\n * @param str String to format\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. Will be coerced to strings using\n * `${replacerValue}`\n * @returns Formatted string\n */\nexport function formatReplacementString(\n str: string,\n replacers: { [key: string | number]: string | unknown } | object,\n): string {\n return formatReplacementStringToArray(str, replacers)\n .map((content) => `${content}`)\n .join('');\n}\n\n/**\n * This function mirrors the `includes` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Performs a case-sensitive search to determine if searchString is found in string.\n *\n * @param string String to search through\n * @param searchString String to search for\n * @param position Position within the string to start searching for searchString. Default is `0`\n * @returns True if search string is found, false if it is not\n */\nexport function includes(string: string, searchString: string, position: number = 0): boolean {\n const partialString = substring(string, position);\n const indexOfSearchString = indexOf(partialString, searchString);\n if (indexOfSearchString === -1) return false;\n return true;\n}\n\n/**\n * This function mirrors the `indexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the index of the first occurrence of a given string.\n *\n * @param string String to search through\n * @param searchString The string to search for\n * @param position Start of searching. Default is `0`\n * @returns Index of the first occurrence of a given string\n */\nexport function indexOf(\n string: string,\n searchString: string,\n position: number | undefined = 0,\n): number {\n return stringzIndexOf(string, searchString, position);\n}\n\n/**\n * This function mirrors the `lastIndexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Searches this string and returns the index of the last occurrence of the specified substring.\n *\n * @param string String to search through\n * @param searchString Substring to search for\n * @param position The index at which to begin searching. If omitted, the search begins at the end\n * of the string. Default is `undefined`\n * @returns Index of the last occurrence of searchString found, or -1 if not found.\n */\nexport function lastIndexOf(string: string, searchString: string, position?: number): number {\n let validatedPosition = position === undefined ? stringLength(string) : position;\n\n if (validatedPosition < 0) {\n validatedPosition = 0;\n } else if (validatedPosition >= stringLength(string)) {\n validatedPosition = stringLength(string) - 1;\n }\n\n for (let index = validatedPosition; index >= 0; index--) {\n if (substr(string, index, stringLength(searchString)) === searchString) {\n return index;\n }\n }\n\n return -1;\n}\n\n/**\n * This function mirrors the `length` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes. Since `length` appears to be a\n * reserved keyword, the function was renamed to `stringLength`\n *\n * Returns the length of a string.\n *\n * @param string String to return the length for\n * @returns Number that is length of the starting string\n */\nexport function stringLength(string: string): number {\n return stringzLength(string);\n}\n\n/**\n * This function mirrors the `normalize` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the Unicode Normalization Form of this string.\n *\n * @param string The starting string\n * @param form Form specifying the Unicode Normalization Form. Default is `'NFC'`\n * @returns A string containing the Unicode Normalization Form of the given string.\n */\nexport function normalize(string: string, form: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | 'none'): string {\n const upperCaseForm = form.toUpperCase();\n if (upperCaseForm === 'NONE') {\n return string;\n }\n return string.normalize(upperCaseForm);\n}\n\n/**\n * Compares two strings using an ordinal comparison approach based on the specified collation\n * options. This function uses the built-in `localeCompare` method with the 'en' locale and the\n * provided collation options to compare the strings.\n *\n * @param string1 The first string to compare.\n * @param string2 The second string to compare.\n * @param options Optional. The collation options used for comparison.\n * @returns A number indicating the result of the comparison: - Negative value if string1 precedes\n * string2 in sorting order. - Zero if string1 and string2 are equivalent in sorting order. -\n * Positive value if string1 follows string2 in sorting order.\n */\nexport function ordinalCompare(\n string1: string,\n string2: string,\n options?: Intl.CollatorOptions,\n): number {\n return string1.localeCompare(string2, 'en', options);\n}\n\n/**\n * This function mirrors the `padEnd` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the end of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within targetLength, it will be truncated. Default is `\" \"`\n * @returns String with appropriate padding at the end\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padEnd(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'right');\n}\n\n/**\n * This function mirrors the `padStart` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the start of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within the targetLength, it will be truncated from the end. Default is `\" \"`\n * @returns String with of specified targetLength with padString applied from the start\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padStart(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'left');\n}\n\n// This is a helper function that performs a correction on the slice index to make sure it\n// cannot go out of bounds\nfunction correctSliceIndex(length: number, index: number) {\n if (index > length) return length;\n if (index < -length) return 0;\n if (index < 0) return index + length;\n return index;\n}\n\n/**\n * This function mirrors the `slice` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Extracts a section of this string and returns it as a new string, without modifying the original\n * string.\n *\n * @param string The starting string\n * @param indexStart The index of the first character to include in the returned substring.\n * @param indexEnd The index of the first character to exclude from the returned substring.\n * @returns A new string containing the extracted section of the string.\n */\nexport function slice(string: string, indexStart: number, indexEnd?: number): string {\n const length: number = stringLength(string);\n if (\n indexStart > length ||\n (indexEnd &&\n ((indexStart > indexEnd &&\n !(indexStart >= 0 && indexStart < length && indexEnd < 0 && indexEnd > -length)) ||\n indexEnd < -length))\n )\n return '';\n\n const newStart = correctSliceIndex(length, indexStart);\n const newEnd = indexEnd ? correctSliceIndex(length, indexEnd) : undefined;\n\n return substring(string, newStart, newEnd);\n}\n\n/**\n * This function mirrors the `split` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Takes a pattern and divides the string into an ordered list of substrings by searching for the\n * pattern, puts these substrings into an array, and returns the array.\n *\n * @param string The string to split\n * @param separator The pattern describing where each split should occur\n * @param splitLimit Limit on the number of substrings to be included in the array. Splits the\n * string at each occurrence of specified separator, but stops when limit entries have been placed\n * in the array.\n * @returns An array of strings, split at each point where separator occurs in the starting string.\n * Returns undefined if separator is not found in string.\n */\nexport function split(string: string, separator: string | RegExp, splitLimit?: number): string[] {\n const result: string[] = [];\n\n if (splitLimit !== undefined && splitLimit <= 0) {\n return [string];\n }\n\n if (separator === '') return toArray(string).slice(0, splitLimit);\n\n let regexSeparator = separator;\n if (\n typeof separator === 'string' ||\n (separator instanceof RegExp && !includes(separator.flags, 'g'))\n ) {\n regexSeparator = new RegExp(separator, 'g');\n }\n\n const matches: RegExpMatchArray | null = string.match(regexSeparator);\n\n let currentIndex = 0;\n\n if (!matches) return [string];\n\n for (let index = 0; index < (splitLimit ? splitLimit - 1 : matches.length); index++) {\n const matchIndex = indexOf(string, matches[index], currentIndex);\n const matchLength = stringLength(matches[index]);\n\n result.push(substring(string, currentIndex, matchIndex));\n currentIndex = matchIndex + matchLength;\n\n if (splitLimit !== undefined && result.length === splitLimit) {\n break;\n }\n }\n\n result.push(substring(string, currentIndex));\n\n return result;\n}\n\n/**\n * This function mirrors the `startsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether the string begins with the characters of a specified string, returning true or\n * false as appropriate.\n *\n * @param string String to search through\n * @param searchString The characters to be searched for at the start of this string.\n * @param position The start position at which searchString is expected to be found (the index of\n * searchString's first character). Default is `0`\n * @returns True if the given characters are found at the beginning of the string, including when\n * searchString is an empty string; otherwise, false.\n */\nexport function startsWith(string: string, searchString: string, position: number = 0): boolean {\n const indexOfSearchString = indexOf(string, searchString, position);\n if (indexOfSearchString !== position) return false;\n return true;\n}\n\n/**\n * This function mirrors the `substr` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and length. This function is not exported because it is\n * considered deprecated, however it is still useful as a local helper function.\n *\n * @param string String to be divided\n * @param begin Start position. Default is `Start of string`\n * @param len Length of result. Default is `String length minus start parameter`. Default is `String\n * length minus start parameter`\n * @returns Substring from starting string\n */\nfunction substr(\n string: string,\n begin: number = 0,\n len: number = stringLength(string) - begin,\n): string {\n return stringzSubstr(string, begin, len);\n}\n\n/**\n * This function mirrors the `substring` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and end position.\n *\n * @param string String to be divided\n * @param begin Start position\n * @param end End position. Default is `End of string`\n * @returns Substring from starting string\n */\nexport function substring(\n string: string,\n begin: number,\n end: number = stringLength(string),\n): string {\n return stringzSubstring(string, begin, end);\n}\n\n/**\n * This function mirrors the `toArray` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Converts a string to an array of string characters.\n *\n * @param string String to convert to array\n * @returns An array of characters from the starting string\n */\nexport function toArray(string: string): string[] {\n return stringzToArray(string);\n}\n\n/** Determine whether the string is a `LocalizeKey` meant to be localized in Platform.Bible. */\nexport function isLocalizeKey(str: string): str is LocalizeKey {\n return startsWith(str, '%') && endsWith(str, '%');\n}\n\n/**\n * Escape RegExp special characters.\n *\n * You can also use this to escape a string that is inserted into the middle of a regex, for\n * example, into a character class.\n *\n * All credit to [`escape-string-regexp`](https://www.npmjs.com/package/escape-string-regexp) - this\n * function is simply copied directly from there to allow a common js export\n *\n * @example\n *\n * import escapeStringRegexp from 'platform-bible-utils';\n *\n * const escapedString = escapeStringRegexp('How much $ for a 🦄?');\n * //=> 'How much \\\\$ for a 🦄\\\\?'\n *\n * new RegExp(escapedString);\n */\nexport function escapeStringRegexp(string: string): string {\n if (typeof string !== 'string') {\n throw new TypeError('Expected a string');\n }\n\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions, ensuring that\n * the result is always an array.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - If the input is an array containing nested arrays, it converts each string in the nested arrays\n * into `RegExp` objects.\n * - Ensures that the result is always an array of `RegExp` objects or arrays of `RegExp` objects.\n *\n * @param stringStringMaybeArray - The value to be transformed, which can be a single string, an\n * array of strings or arrays of strings, or `undefined`.\n * @returns An array of `RegExp` objects or arrays of `RegExp` objects. If the input is `undefined`,\n * an empty array is returned.\n */\nexport function transformAndEnsureRegExpRegExpArray(\n stringStringMaybeArray: string | (string | string[])[] | undefined,\n): (RegExp | RegExp[])[] {\n if (!stringStringMaybeArray) return [];\n\n const stringStringArray = ensureArray(stringStringMaybeArray);\n\n const regExpRegExpArray = stringStringArray.map((stringMaybeStringArray: string | string[]) =>\n Array.isArray(stringMaybeStringArray)\n ? stringMaybeStringArray.map((str) => new RegExp(str))\n : new RegExp(stringMaybeStringArray),\n );\n\n return regExpRegExpArray;\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - Ensures that the result is always an array of `RegExp` objects.\n *\n * @param stringMaybeArray - The value to be transformed, which can be a single string, an array of\n * strings, or `undefined`.\n * @returns An array of `RegExp` objects. If the input is `undefined`, an empty array is returned.\n */\nexport function transformAndEnsureRegExpArray(\n stringMaybeArray: string | string[] | undefined,\n): RegExp[] {\n if (!stringMaybeArray) return [];\n\n const stringArray = ensureArray(stringMaybeArray);\n\n const regExpArray = stringArray.map((str: string) => new RegExp(str));\n\n return regExpArray;\n}\n\nconst whiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/;\n/**\n * Determines whether a string contains one or more white space characters and no other characters.\n *\n * This implementation uses [dotnet's `Char.IsWhiteSpace` definition of white\n * space](https://learn.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=net-9.0):\n *\n * ```ts\n * /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: This differs from\n * [`/\\s/.test(ch)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes#:~:text=Matches%20a%20single%20white%20space%20character%2C%20including%20space)\n * (usually considered the determiner of what is white space in JavaScript) in that it does not\n * include ZWNBSP (U+FEFF) but rather includes NEXT LINE (U+0085)\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more white space characters and no other\n * characters, `false` otherwise\n */\nexport function isWhiteSpace(ch: string) {\n return whiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts PascalCase or camelCase string to kebab-case. To detect upper- and lower-case\n * characters, uses `.toUpperCase` and `.toLowerCase` to be locale-independent.\n *\n * Current implementation supports only UTF-16.\n *\n * Thanks to ChatGPT https://chatgpt.com/share/67c8aa44-e054-800c-8068-e1e6630081f7\n */\nexport function toKebabCase(input: string): string {\n let result = '';\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n const isUpper = char === char.toUpperCase() && char !== char.toLowerCase();\n\n if (isUpper) {\n if (i > 0) {\n const prevChar = input[i - 1];\n const isPrevUpper =\n prevChar === prevChar.toUpperCase() && prevChar !== prevChar.toLowerCase();\n\n // If previous is not uppercase, always insert dash.\n if (!isPrevUpper) {\n result += '-';\n } else if (i + 1 < input.length) {\n // Deal with initialisms and acronyms as if they are whole words (\"APIFinder\" -> \"api-finder\")\n // Previous was uppercase; insert dash only if the next character exists and is lowercase.\n const nextChar = input[i + 1];\n const isNextLower =\n nextChar === nextChar.toLowerCase() && nextChar !== nextChar.toUpperCase();\n if (isNextLower) {\n result += '-';\n }\n }\n }\n result += char.toLowerCase();\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n/** This is an internal-only export for testing purposes and should not be used in development */\nexport const testingStringUtils = {\n indexOfClosestClosingCurlyBrace,\n};\n","import { Canon, SerializedVerseRef, VerseRef } from '@sillsdev/scripture';\nimport {\n MarkerContent,\n MarkerObject,\n Usj,\n USJ_TYPE,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { BookInfo, ScrollGroupId } from './scripture.model';\nimport { at, isWhiteSpace, slice, split, startsWith } from '../string-util';\nimport { LocalizeKey } from '../extension-contributions/menus.model';\nimport { isString } from '../util';\n\n/**\n * All marker types that seem to be block-level according to `UsxFragmenter.AppendStartUsfm`. And\n * the `type` for USJ documents' top-level object because that is effectively a block\n *\n * Note: This \"block-level\" means the marker is in its own paragraph (a [CSS\n * Block](https://developer.mozilla.org/en-US/docs/Glossary/Block/CSS)) as opposed to being\n * in-line.\n */\nconst BLOCK_MARKER_TYPES = ['chapter', 'book', 'para', 'row', 'sidebar', USJ_TYPE];\n\nconst ZWSP = '\\u200B';\n\nconst scrBookData: BookInfo[] = [\n { shortName: 'ERR', fullNames: ['ERROR'], chapters: -1 },\n { shortName: 'GEN', fullNames: ['Genesis'], chapters: 50 },\n { shortName: 'EXO', fullNames: ['Exodus'], chapters: 40 },\n { shortName: 'LEV', fullNames: ['Leviticus'], chapters: 27 },\n { shortName: 'NUM', fullNames: ['Numbers'], chapters: 36 },\n { shortName: 'DEU', fullNames: ['Deuteronomy'], chapters: 34 },\n { shortName: 'JOS', fullNames: ['Joshua'], chapters: 24 },\n { shortName: 'JDG', fullNames: ['Judges'], chapters: 21 },\n { shortName: 'RUT', fullNames: ['Ruth'], chapters: 4 },\n { shortName: '1SA', fullNames: ['1 Samuel'], chapters: 31 },\n { shortName: '2SA', fullNames: ['2 Samuel'], chapters: 24 },\n { shortName: '1KI', fullNames: ['1 Kings'], chapters: 22 },\n { shortName: '2KI', fullNames: ['2 Kings'], chapters: 25 },\n { shortName: '1CH', fullNames: ['1 Chronicles'], chapters: 29 },\n { shortName: '2CH', fullNames: ['2 Chronicles'], chapters: 36 },\n { shortName: 'EZR', fullNames: ['Ezra'], chapters: 10 },\n { shortName: 'NEH', fullNames: ['Nehemiah'], chapters: 13 },\n { shortName: 'EST', fullNames: ['Esther'], chapters: 10 },\n { shortName: 'JOB', fullNames: ['Job'], chapters: 42 },\n { shortName: 'PSA', fullNames: ['Psalm', 'Psalms'], chapters: 150 },\n { shortName: 'PRO', fullNames: ['Proverbs'], chapters: 31 },\n { shortName: 'ECC', fullNames: ['Ecclesiastes'], chapters: 12 },\n { shortName: 'SNG', fullNames: ['Song of Solomon', 'Song of Songs'], chapters: 8 },\n { shortName: 'ISA', fullNames: ['Isaiah'], chapters: 66 },\n { shortName: 'JER', fullNames: ['Jeremiah'], chapters: 52 },\n { shortName: 'LAM', fullNames: ['Lamentations'], chapters: 5 },\n { shortName: 'EZK', fullNames: ['Ezekiel'], chapters: 48 },\n { shortName: 'DAN', fullNames: ['Daniel'], chapters: 12 },\n { shortName: 'HOS', fullNames: ['Hosea'], chapters: 14 },\n { shortName: 'JOL', fullNames: ['Joel'], chapters: 3 },\n { shortName: 'AMO', fullNames: ['Amos'], chapters: 9 },\n { shortName: 'OBA', fullNames: ['Obadiah'], chapters: 1 },\n { shortName: 'JON', fullNames: ['Jonah'], chapters: 4 },\n { shortName: 'MIC', fullNames: ['Micah'], chapters: 7 },\n { shortName: 'NAM', fullNames: ['Nahum'], chapters: 3 },\n { shortName: 'HAB', fullNames: ['Habakkuk'], chapters: 3 },\n { shortName: 'ZEP', fullNames: ['Zephaniah'], chapters: 3 },\n { shortName: 'HAG', fullNames: ['Haggai'], chapters: 2 },\n { shortName: 'ZEC', fullNames: ['Zechariah'], chapters: 14 },\n { shortName: 'MAL', fullNames: ['Malachi'], chapters: 4 },\n { shortName: 'MAT', fullNames: ['Matthew'], chapters: 28 },\n { shortName: 'MRK', fullNames: ['Mark'], chapters: 16 },\n { shortName: 'LUK', fullNames: ['Luke'], chapters: 24 },\n { shortName: 'JHN', fullNames: ['John'], chapters: 21 },\n { shortName: 'ACT', fullNames: ['Acts'], chapters: 28 },\n { shortName: 'ROM', fullNames: ['Romans'], chapters: 16 },\n { shortName: '1CO', fullNames: ['1 Corinthians'], chapters: 16 },\n { shortName: '2CO', fullNames: ['2 Corinthians'], chapters: 13 },\n { shortName: 'GAL', fullNames: ['Galatians'], chapters: 6 },\n { shortName: 'EPH', fullNames: ['Ephesians'], chapters: 6 },\n { shortName: 'PHP', fullNames: ['Philippians'], chapters: 4 },\n { shortName: 'COL', fullNames: ['Colossians'], chapters: 4 },\n { shortName: '1TH', fullNames: ['1 Thessalonians'], chapters: 5 },\n { shortName: '2TH', fullNames: ['2 Thessalonians'], chapters: 3 },\n { shortName: '1TI', fullNames: ['1 Timothy'], chapters: 6 },\n { shortName: '2TI', fullNames: ['2 Timothy'], chapters: 4 },\n { shortName: 'TIT', fullNames: ['Titus'], chapters: 3 },\n { shortName: 'PHM', fullNames: ['Philemon'], chapters: 1 },\n { shortName: 'HEB', fullNames: ['Hebrews'], chapters: 13 },\n { shortName: 'JAS', fullNames: ['James'], chapters: 5 },\n { shortName: '1PE', fullNames: ['1 Peter'], chapters: 5 },\n { shortName: '2PE', fullNames: ['2 Peter'], chapters: 3 },\n { shortName: '1JN', fullNames: ['1 John'], chapters: 5 },\n { shortName: '2JN', fullNames: ['2 John'], chapters: 1 },\n { shortName: '3JN', fullNames: ['3 John'], chapters: 1 },\n { shortName: 'JUD', fullNames: ['Jude'], chapters: 1 },\n { shortName: 'REV', fullNames: ['Revelation'], chapters: 22 },\n];\n\n/** The first book number */\nexport const FIRST_SCR_BOOK_NUM = 1;\n/** The last book number */\nexport const LAST_SCR_BOOK_NUM = scrBookData.length - 1;\n/** The first chapter number */\nexport const FIRST_SCR_CHAPTER_NUM = 1;\n/** The first verse number */\nexport const FIRST_SCR_VERSE_NUM = 1;\n\n/** The default Scripture reference, representing the first chapter and verse of the first book. */\nexport const defaultScrRef: SerializedVerseRef = {\n book: 'GEN',\n chapterNum: 1,\n verseNum: 1,\n};\n\n/**\n * Retrieves the number of chapters for a given book number.\n *\n * @param bookNum The number representing the book.\n * @returns The number of chapters in the book, or -1 if the book number is invalid.\n */\nexport const getChaptersForBook = (bookNum: number): number => {\n return scrBookData[bookNum]?.chapters ?? -1;\n};\n\n/**\n * Adjusts the book of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose book is to be adjusted.\n * @param offset The number of books to offset the current book by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted book. The chapter and verse numbers are\n * reset to 1. If the resulting book number exceeds the bounds of available books, it is clamped\n * to the nearest valid book.\n */\nexport const offsetBook = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n book: Canon.bookNumberToId(\n Math.max(\n FIRST_SCR_BOOK_NUM,\n Math.min(Canon.bookIdToNumber(scrRef.book) + offset, LAST_SCR_BOOK_NUM),\n ),\n ),\n chapterNum: 1,\n verseNum: 1,\n});\n\n/**\n * Adjusts the chapter of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose chapter is to be adjusted.\n * @param offset The number of chapters to offset the current chapter by. Positive values move\n * forward, negative values move backward.\n * @returns A new Scripture reference with the adjusted chapter. The verse number is reset to 1. The\n * chapter number is clamped to stay within valid bounds for the book.\n */\nexport const offsetChapter = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n chapterNum: Math.min(\n Math.max(FIRST_SCR_CHAPTER_NUM, scrRef.chapterNum + offset),\n getChaptersForBook(Canon.bookIdToNumber(scrRef.book)),\n ),\n verseNum: 1,\n});\n\n/**\n * Adjusts the verse of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose verse is to be adjusted.\n * @param offset The number of verses to offset the current verse by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted verse. The verse number is clamped to stay\n * within valid bounds for the chapter.\n */\nexport const offsetVerse = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n verseNum: Math.max(FIRST_SCR_VERSE_NUM, scrRef.verseNum + offset),\n});\n\n/**\n * https://github.com/ubsicap/Paratext/blob/master/ParatextData/SILScriptureExtensions.cs#L72\n *\n * Convert book number to a localized Id (a short description of the book). This should be used\n * whenever a book ID (short code) is shown to the user. It is primarily needed for people who do\n * not read Roman script well and need to have books identified in a alternate script (e.g. Chinese\n * or Russian)\n *\n * @param bookNumber\n * @param localizationLanguage In BCP 47 format\n * @param getLocalizedString Function that provides the localized versions of the book ids and names\n * asynchronously.\n * @returns\n */\nexport async function getLocalizedIdFromBookNumber(\n bookNumber: number,\n localizationLanguage: string,\n getLocalizedString: (item: {\n localizeKey: string;\n languagesToSearch?: string[];\n }) => Promise,\n) {\n const id = Canon.bookNumberToId(bookNumber);\n\n if (!startsWith(Intl.getCanonicalLocales(localizationLanguage)[0], 'zh'))\n return getLocalizedString({\n localizeKey: `LocalizedId.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n\n // For Chinese the normal book name is already fairly short.\n const bookName = await getLocalizedString({\n localizeKey: `Book.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n const parts = split(bookName, '-');\n // some entries had a second name inside ideographic parenthesis\n const parts2 = split(parts[0], '\\xff08');\n const retVal = parts2[0].trim();\n return retVal;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer, without considering the\n * verse.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCC(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum).BBBCCC;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCCVVV(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum)\n .BBBCCCVVV;\n}\n\n/**\n * Compares two Scripture references canonically.\n *\n * @param scrRef1 The first Scripture reference to compare.\n * @param scrRef2 The second Scripture reference to compare.\n * @returns A number indicating the result of the comparison: - Negative value if scrRef1 precedes\n * scrRef2 in sorting order. - Zero if scrRef1 and scrRef2 are equivalent in sorting order. -\n * Positive value if scrRef1 follows scrRef2 in sorting order.\n */\nexport function compareScrRefs(scrRef1: SerializedVerseRef, scrRef2: SerializedVerseRef): number {\n // TODO: consider edge cases for invalid references (current implementation should suffice for\n // all but the most extreme cases)\n return scrRefToBBBCCCVVV(scrRef1) - scrRefToBBBCCCVVV(scrRef2);\n}\n\n/** Get the localized string key for a given scroll group Id (or no scroll group if `undefined`) */\nexport function getLocalizeKeyForScrollGroupId(\n scrollGroupId: ScrollGroupId | undefined | 'undefined',\n): LocalizeKey {\n return `%scrollGroup_${scrollGroupId}%`;\n}\n\n/**\n * Gets a list of localized string keys for provided scroll group Ids. Uses\n * {@link getLocalizeKeyForScrollGroupId} internally\n *\n * @example\n *\n * ```typescript\n * getLocalizeKeysForScrollGroupIds([undefined, 0, 1, 2, 3, 4]);\n * // Gives localized string keys for the provided scroll group ids in an array\n * ```\n *\n * @param scrollGroupIds Scroll group ids to include\n * @returns List of localized string keys for scroll group Ids\n */\nexport function getLocalizeKeysForScrollGroupIds(scrollGroupIds: (ScrollGroupId | undefined)[]) {\n return scrollGroupIds.map((scrollGroupId) => getLocalizeKeyForScrollGroupId(scrollGroupId));\n}\n\n/**\n * Formats a Scripture reference.\n *\n * @param scrRef The Scripture reference to format.\n * @param optionOrLocalizedBookName Either 'id' (the default) to format using the \"standard\" (as\n * defined by SIL/UBS) 3-letter book ID, 'English' to format using the English book name spelled\n * out, or some other string (e.g., a localized book name, vernacular abbreviation, FCBH book id,\n * etc.) to use.\n * @param chapterVerseSeparator The character used to separate the chapter number from the verse\n * number. Default is a colon (:). Note: More than one character is allowed.\n * @param bookChapterSeparator The character used to separate the book from the chapter number.\n * Default is a single space. Note: More than one character is allowed.\n * @returns The formatted reference.\n */\nexport function formatScrRef(\n scrRef: SerializedVerseRef,\n optionOrLocalizedBookName?: 'id' | 'English' | string,\n chapterVerseSeparator?: string,\n bookChapterSeparator?: string,\n): string {\n let book: string;\n switch (optionOrLocalizedBookName ?? 'id') {\n case 'English':\n book = Canon.bookIdToEnglishName(scrRef.book);\n break;\n case 'id':\n book = scrRef.book;\n break;\n default:\n // We already dealt with undefined about in the switch, but TS is getting confused.\n book = optionOrLocalizedBookName ?? '';\n break;\n }\n return `${book}${bookChapterSeparator ?? ' '}${scrRef.chapterNum}${chapterVerseSeparator ?? ':'}${scrRef.verseNum}`;\n}\n\n/**\n * Represents the major sections of the Bible and extra materials. Used for grouping and filtering\n * books in the book selector.\n */\nexport enum Section {\n /** Old Testament books (Genesis through Malachi) */\n OT = 'OT',\n /** New Testament books (Matthew through Revelation) */\n NT = 'NT',\n /** Deuterocanonical books (e.g. Tobit, Judith, 1-2 Maccabees) */\n DC = 'DC',\n /** Additional materials not part of the biblical canon (e.g. XXA, XXB etc.) */\n Extra = 'Extra',\n}\n\n/**\n * Determines which section a book belongs to based on its ID\n *\n * @param bookId The ID of the book (e.g., 'GEN', 'MAT')\n * @returns The section (OT, NT, DC, or Extra) that the book belongs to\n * @throws Error if the book ID is not recognized or cannot be categorized\n */\nexport const getSectionForBook = (bookId: string): Section => {\n if (Canon.isBookOT(bookId)) return Section.OT;\n if (Canon.isBookNT(bookId)) return Section.NT;\n if (Canon.isBookDC(bookId)) return Section.DC;\n if (Canon.isExtraMaterial(bookId)) return Section.Extra;\n\n throw new Error(`Unknown section for book: ${bookId}`);\n};\n\n// #region white space functions\n\nconst nonSemanticWhiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u200B\\u0085]+$/;\n/**\n * Determines whether a string contains one or more \"non-meaningful\" white space characters\n * according to `ParatextData.dll` and no other characters.\n *\n * \"Non-meaningful\" white space according to `ParatextData.dll` is white space (according to\n * {@link isWhiteSpace}) other than IDEOGRAPHIC SPACE (U+3000) and also includes ZWSP (U+200B)\n *\n * This function is a direct translation of `UsfmToken.IsNonSemanticWhiteSpace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more \"non-meaningful\" white space characters and\n * no other characters, `false` otherwise\n */\nfunction isNonSemanticWhiteSpace(ch: string) {\n return nonSemanticWhiteSpaceRegex.test(ch);\n}\n\n// Note Zero-width joiner is at the start because eslint thinks we're trying to test for joined\n// characters if it's in the middle. https://eslint.org/docs/latest/rules/no-misleading-character-class\nconst invisibleCharOrWhiteSpaceRegex =\n /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/;\n/**\n * Determines whether a string contains one or more Paratext-9-selectable invisible characters or\n * white space characters and no other characters.\n *\n * Paratext-9-selectable invisible characters or white space characters are characters listed in\n * [Paratext 9's \"Whitespace and invisible characters\n * drop-down\"](https://paratext.myjetbrains.com/youtrack/issue/PTX-23623) that the user can insert\n * into the text:\n *\n * ```ts\n * // Zero-width joiner, em space, en space, space, no-break space, narrow no-break space,\n * // thin space, hair space, ideographic space, zero-width space, zero-width non-joiner,\n * // word joiner, left-to-right mark, right-to-left mark\n * /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: more white space characters are supported in Paratext 9 but are not listed in this\n * dropdown. See {@link isWhiteSpace} for more information.\n *\n * This function is a direct translation of `CharExtensions.IsInvisibleCharOrWhitespace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more Paratext-9-selectable invisible characters\n * or white space characters and no other characters, `false` otherwise\n */\nfunction isParatextSelectableInvisibleCharOrWhiteSpace(ch: string) {\n return invisibleCharOrWhiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts all control characters, carriage returns, and tabs into spaces and then strips duplicate\n * spaces.\n *\n * This is mainly intended for use with individual Scripture strings in USFM, USX, USJ, etc. format.\n * It is not intended to implement the [USFM white space definition or reduction\n * rules](https://docs.usfm.bible/usfm/3.1/whitespace.html) but strictly follows Paratext 9's white\n * space rules. It is generally best suited to normalizing spaces within a Scripture marker as it\n * removes all newlines.\n *\n * This function is a direct translation of `UsfmToken.RegularizeSpaces` from `ParatextData.dll`\n */\nexport function normalizeScriptureSpaces(str: string): string {\n let result = '';\n let lastCharWasSpace = false;\n // Initialized to placeholder previous character\n let prevCh = '\\0';\n for (let i = 0; i < str.length; i += 1) {\n const ch = str[i];\n // Control characters, CR/LF, and TAB become spaces\n if (ch.charCodeAt(0) < 32) {\n if (!lastCharWasSpace) result += ' ';\n lastCharWasSpace = true;\n } else if (\n !lastCharWasSpace &&\n ch === ZWSP &&\n i + 1 < str.length &&\n isNonSemanticWhiteSpace(str[i + 1])\n ) {\n // ZWSP is redundant if followed by a space\n } else if (isNonSemanticWhiteSpace(ch)) {\n // Keep other kinds of spaces\n if (!lastCharWasSpace) result += ch;\n lastCharWasSpace = true;\n } else if (isParatextSelectableInvisibleCharOrWhiteSpace(ch) && prevCh === ch) {\n // If the char is a whitespace or invisible char that has not already been handled and is a\n // duplicate, remove the duplicate\n } else {\n result += ch;\n lastCharWasSpace = false;\n }\n\n prevCh = ch;\n }\n\n return result;\n}\n\n/**\n * Determines whether the array of marker contents is \"empty\" meaning it is undefined, is an empty\n * array, or has just `undefined` or `''` in it\n *\n * Paratext passed up \"\\va \\va*\" which had no content array coming in translated to USJ, but the\n * editor put a content array with an empty string. So this will help them be considered equal.\n */\nfunction isUsjContentEmpty(content: MarkerContent[] | undefined) {\n if (!content) return true;\n if (content.length === 0) return true;\n return content.length === 1 && (content[0] === undefined || content[0] === '');\n}\n\n/**\n * Determines if the content object is the final child of a parent that is a block-level marker.\n *\n * We do not need to walk up the ancestors to the _closest_ block marker because spaces are\n * preserved at the end of in-line markers even at the end of a paragraph. We just need to know if\n * the parent is a block marker because space at the end of a block marker is not preserved.\n *\n * @param contentObject USJ document or marker to check\n * @param parent Parent object of `contentObject`. If `contentObject` is a USJ document, this should\n * be `undefined`.\n * @returns `true` if `contentObject` is the final child of the closest block-level marker; `false`\n * otherwise\n */\nfunction isAtEndOfBlockMarker(\n contentObject: MarkerContent | Usj,\n parent: MarkerObject | Usj | undefined,\n) {\n if (!parent) return false;\n // If the parent is not a block-level marker, the content object is not at the end of a block-level marker\n if (!BLOCK_MARKER_TYPES.includes(parent.type)) return false;\n\n if (!parent.content)\n throw new Error(\n `Parent ${JSON.stringify(parent)} of ${JSON.stringify(contentObject)} does not have a content array! This should not happen!`,\n );\n // If the content object is not the last in its parent, it is not at the end of a block-level marker\n if (contentObject !== parent.content[parent.content.length - 1]) return false;\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n *\n * @param a First USJ document or marker to compare\n * @param aParent Parent object of `a`. If `a` is a USJ document, this should be `undefined`.\n * @param b Second USJ document or marker to compare\n * @param bParent Parent object of `b`. If `b` is a USJ document, this should be `undefined`.\n */\nfunction areUsjContentsEqualExceptWhitespaceInternal(\n a: MarkerContent | Usj | undefined,\n aParent: MarkerObject | Usj | undefined,\n b: MarkerContent | Usj | undefined,\n bParent: MarkerObject | Usj | undefined,\n) {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aIsString = isString(a);\n const bIsString = isString(b);\n if (aIsString && bIsString) {\n const aNormalized = normalizeScriptureSpaces(a);\n const bNormalized = normalizeScriptureSpaces(b);\n // Check to see if their regularized forms are equal. If so, they're equal. If not, they may still\n // be equal if they are at the end of a block-level marker and the only difference is space at the end.\n // If at the end of a block-level marker with space at the end, take off the final space and compare again\n if (aNormalized !== bNormalized) {\n // If neither ends in whitespace, they are not equal\n if (!isWhiteSpace(at(aNormalized, -1) ?? '') && !isWhiteSpace(at(bNormalized, -1) ?? ''))\n return false;\n\n // If either is not at the end of a block-level marker, they are not equal\n if (!isAtEndOfBlockMarker(a, aParent)) return false;\n if (!isAtEndOfBlockMarker(b, bParent)) return false;\n\n // Trim the end of each string\n let aTrimmed = aNormalized;\n while (isWhiteSpace(at(aTrimmed, -1) ?? '')) aTrimmed = slice(aTrimmed, 0, -1);\n let bTrimmed = bNormalized;\n while (isWhiteSpace(at(bTrimmed, -1) ?? '')) bTrimmed = slice(bTrimmed, 0, -1);\n // If they are not equal after trimming, they are not equal\n if (aTrimmed !== bTrimmed) return false;\n }\n } else if (!aIsString && !bIsString) {\n // We have determined they are not strings, so they must be objects with various simple properties and possibly a `content` array\n const aObject: MarkerObject | Usj = a;\n const bObject: MarkerObject | Usj = b;\n // Check if all properties are present and equal. We will check `content` separately\n // Seems Object.keys doesn't support proper key typing? Asserting to the key types\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const aKeys = Object.keys(aObject).filter(\n (key) => key !== 'content',\n ) as (keyof typeof aObject)[];\n if (aKeys.length !== Object.keys(bObject).filter((key) => key !== 'content').length)\n return false;\n if (aKeys.some((key) => !(key in bObject) || aObject[key] !== bObject[key])) return false;\n\n // Check that both `content`s are equal\n const isAContentEmpty = isUsjContentEmpty(aObject.content);\n const isBContentEmpty = isUsjContentEmpty(bObject.content);\n // If one is empty and the other is not, they are not equal\n if (isAContentEmpty !== isBContentEmpty) return false;\n // If both are empty, they are equal. If neither is empty, do more testing\n if (!isAContentEmpty && !isBContentEmpty) {\n // Although TypeScript doesn't realize `!isUsjContentEmpty(a)` means a is an array, we know\n // they are both arrays, so we can access the content with a bang.\n /* eslint-disable no-type-assertion/no-type-assertion */\n let aContent: MarkerContent[] = aObject.content!;\n let bContent: MarkerContent[] = bObject.content!;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const aLast = aContent[aContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(aObject.type) && isString(aLast) && isWhiteSpace(aLast))\n aContent = aContent.slice(0, -1);\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const bLast = bContent[bContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(bObject.type) && isString(bLast) && isWhiteSpace(bLast))\n bContent = bContent.slice(0, -1);\n\n if (aContent.length !== bContent.length) return false;\n for (let i = 0; i < aContent.length; i += 1) {\n if (\n !areUsjContentsEqualExceptWhitespaceInternal(aContent[i], aObject, bContent[i], bObject)\n )\n return false;\n }\n }\n } else {\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n */\nexport function areUsjContentsEqualExceptWhitespace(a: Usj | undefined, b: Usj | undefined) {\n return areUsjContentsEqualExceptWhitespaceInternal(a, undefined, b, undefined);\n}\n\n// #endregion\n","/** Function to run to dispose of something. Returns true if successfully unsubscribed */\nexport type Unsubscriber = () => boolean;\n\n/**\n * Returns an Unsubscriber function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers All unsubscribers to aggregate into one unsubscriber\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscribers = (unsubscribers: Unsubscriber[]): Unsubscriber => {\n return (...args) => {\n // Run the unsubscriber for each handler\n const unsubs = unsubscribers.map((unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return unsubs.every((success) => success);\n };\n};\n\n/**\n * Function to run to dispose of something that runs asynchronously. The promise resolves to true if\n * successfully unsubscribed\n */\nexport type UnsubscriberAsync = () => Promise;\n\n/**\n * Returns an UnsubscriberAsync function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers - All unsubscribers to aggregate into one unsubscriber.\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscriberAsyncs = (\n unsubscribers: (UnsubscriberAsync | Unsubscriber)[],\n): UnsubscriberAsync => {\n return async (...args) => {\n // Run the unsubscriber for each handler\n const unsubPromises = unsubscribers.map(async (unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return (await Promise.all(unsubPromises)).every((success) => success);\n };\n};\n","import {\n Usj,\n type MarkerContent,\n type MarkerObject,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { MarkersMap } from './markers-maps/markers-map-3.0.model';\n\n/** USJ content node type for a book */\nexport const BOOK_TYPE = 'book';\n\n/** USJ content node type for a chapter */\nexport const CHAPTER_TYPE = 'chapter';\n\n/** USJ content node type for a verse */\nexport const VERSE_TYPE = 'verse';\n\n/** 3-character code that indicates there is no known book */\nexport const NO_BOOK_ID = '***';\n\n/**\n * Represents a book, chapter, verse, and offset\n *\n * @deprecated 23 October 2025. Use {@link UsfmVerseLocation} or {@link UsfmVerseRefVerseLocation}\n * instead.\n */\nexport type VerseRefOffset = {\n verseRef: SerializedVerseRef;\n offset: number;\n};\n\n// #region Serializable USFM locations\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. If only a verse ref is provided, the offset is assumed to be 0.\n *\n * The USJ representation of the positions represented by this type are {@link UsjLocation}. Both are\n * absolute verse reference locations.\n *\n * {@link UsjDocumentLocation} also represents positions of this type, but those locations are\n * relative to a specific USJ document rather than being absolute verse reference locations like\n * this type. The closest equivalent concept in USFM to {@link UsjDocumentLocation} is a string\n * character index in a USFM document; such an index is relative to a specific USFM document rather\n * than indicating an absolute position in a Scripture text.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsfmScrRefVerseLocation} for details.\n */\nexport type UsfmVerseLocation =\n | UsfmVerseRefVerseLocation\n | SerializedVerseRef\n | UsfmScrRefVerseLocation;\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM\n */\nexport type UsfmVerseRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n verseRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. This uses `scrRef` instead of `verseRef` for backwards compatibility.\n *\n * @deprecated 13 November 2025. Use {@link UsfmVerseLocation} instead.\n */\nexport type UsfmScrRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n scrRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n// #endregion Serializable USFM locations\n\n// #region Serializable absolute USJ locations\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from either the start of the book or the chapter\n * depending on the type of location used.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the following USJ documents:\n *\n * - {@link UsjBookLocation} - a USJ document that contains the entire specified book. The first\n * content entry of the top-level `USJ` marker is the `id` marker of the book.\n * - {@link UsjChapterLocation} - a USJ document that contains only the specified chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjLocation =\n | UsjChapterLocation\n | UsjBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the book specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains the entire specified book. The first content entry of the top-level `USJ` marker is the\n * `id` marker of the book.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjBookLocation =\n | UsjVerseRefBookLocation\n | UsjFlatBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the chapter specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains only the specified chapter in the specified book. If the chapter number is 1, the first\n * content entry of the top-level `USJ` marker is the `id` marker of the book because the intro\n * content before chapter 1 is part of chapter 1. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsjFlatTextChapterLocation} for details. Also note that {@link UsjFlatTextChapterLocation}\n * can only be a marker- or text-based location and will _not_ follow the generic type specified as\n * `TDocumentLocation`.\n */\nexport type UsjChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> =\n | UsjVerseRefChapterLocation\n | UsjFlatChapterLocation\n | UsjFlatTextChapterLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified in the verse ref. The rest of the verse ref\n * is meaningless and can be disregarded.\n */\nexport type UsjVerseRefBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (see\n * {@link UsjVerseRefChapterLocation})\n */\n granularity: 'book';\n /** USJ document location specifying where in the book the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the chapter specified in the verse ref. The rest of the verse\n * ref is meaningless and can be disregarded.\n */\nexport type UsjVerseRefChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which chapter in which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (can alternatively be 'book';\n * {@link UsjVerseRefBookLocation})\n */\n granularity?: 'chapter';\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified.\n */\nexport type UsjFlatBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID, chapter number, and location in USJ space that point to a specific location in USJ.\n * The location in USJ space starts from the start of the chapter specified.\n */\nexport type UsjFlatChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = UsjFlatBookLocation & {\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n};\n\n/**\n * A book ID, chapter number, and text location or beginning of marker location in USJ space that\n * point to a specific location in USJ. The location in USJ space starts from the start of the\n * chapter specified. This can only represent the beginning of a marker or a location in the USJ\n * document's text content.\n *\n * @deprecated 13 November 2025. This type of location is not generic enough to support all\n * positions we need to be able to represent in USJ space. Use other forms of\n * {@link UsjChapterLocation} instead.\n */\nexport type UsjFlatTextChapterLocation = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n} & ((UsjMarkerLocation & { offset?: undefined }) | UsjTextContentLocation);\n\n// #endregion Serializable absolute USJ locations\n\n// #region Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * JSON path to a {@link MarkerObject}, {@link Usj}, or text content string in the current USJ\n * document.\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type ContentJsonPath =\n | ''\n | `$`\n | `$.content[${number}]`\n | `$.content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]`;\n\n/**\n * JSON path to the `marker` or an attribute on a {@link MarkerObject} or {@link Usj} in the current\n * USJ document. Note that it seems you must use `['bracket notation']` rather than `.dot` notation\n * if there are symbols other than underscore in the property name\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type PropertyJsonPath =\n | ''\n | `$.${string}`\n | `$['${string}']`\n | `$.content[${number}].${string}`\n | `$.content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]['${string}']`;\n\n/**\n * A JSONPath query to a {@link MarkerContent}, {@link Usj}, or property within a USJ document and\n * additional information that point to a specific location in that USJ document.\n *\n * This type does not include a verse reference because the JSONPath is relative to a specific USJ\n * document; that USJ document may have a book, a chapter, or something else in it. Use\n * {@link UsjLocation} to specify which USJ document this location is relative to, making the\n * location an absolute verse reference location. The closest equivalent concept in USFM to this\n * relative document location is a string character index in a USFM document; such an index is\n * relative to a specific USFM document rather than indicating an absolute position in a Scripture\n * text.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types:\n *\n * - The second slash in `optbreak`'s USFM representation `//` (literally not representable)\n * - Nested marker prefix on opening markers like `+` for character markers (literally not\n * representable)\n * - The bar `|` that indicates the start of closing marker attributes (no official representation)\n * - The equals sign for closing marker attributes (no official representation)\n * - The quotes around closing marker attribute values (no official representation)\n * - The space between closing marker attributes (no official representation)\n *\n * Also note that the following types do not specify a concrete location that is actually in the USJ\n * document but represent a USFM location relative to the most similar thing in USJ that there is:\n *\n * - {@link UsjClosingMarkerLocation} - there are no distinct closing objects in JSON; there is a\n * common syntax for closing every object, but it is only one character and is on every single\n * object as opposed to USFM closing markers which are multiple characters long and are only\n * sometimes present.\n * - {@link UsjAttributeKeyLocation} - when the attribute whose key is being pointed to is an attribute\n * marker in USFM, the `keyOffset` does not apply to the USJ attribute name (e.g. `altnumber`) but\n * to the USFM attribute marker name (e.g. `ca`).\n * - {@link UsjAttributeMarkerLocation} - attribute markers are just properties in JSON; they do not\n * have their own object such that they would have an opening that can be pointed to in the JSON\n * like they have their own opening in USFM.\n * - {@link UsjClosingAttributeMarkerLocation} - attribute markers are just properties in JSON, plus\n * they are in the same situation as {@link UsjClosingMarkerLocation} as detailed above.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n */\nexport type UsjDocumentLocation =\n | UsjMarkerLocation\n | UsjClosingMarkerLocation\n | UsjTextContentLocation\n | UsjPropertyValueLocation\n | UsjAttributeKeyLocation\n | UsjAttributeMarkerLocation\n | UsjClosingAttributeMarkerLocation;\n\n/**\n * A JSONPath query to a {@link MarkerObject} or {@link Usj} node. Indicates the very beginning of\n * that marker (at the backslash in USFM).\n */\nexport type UsjMarkerLocation = {\n /** JSON path to the marker object the location is pointing to. */\n jsonPath: ContentJsonPath;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of a\n * {@link MarkerObject} or {@link Usj} node.\n */\nexport type UsjClosingMarkerLocation = {\n /**\n * JSON path to the marker object whose closing marker the location is pointing to. The offset\n * applies to the closing marker representation of that marker (for example, `\\nd*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation.\n */\n closingMarkerOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a text content string in a {@link MarkerObject.content}\n * array.\n */\nexport type UsjTextContentLocation = {\n /**\n * JSON path to the text content string the location is pointing to. The offset applies to this\n * text string.\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the text content string where this location is pointing. The location is\n * at this offset within the text content string.\n */\n offset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a property (`marker` or an attribute) value string in a\n * {@link MarkerObject} or {@link Usj}. The property cannot be `type` because `type`'s value has no\n * representation in USFM.\n *\n * To represent a location in an attribute's key, use {@link UsjAttributeKeyLocation}.\n */\nexport type UsjPropertyValueLocation = {\n /**\n * JSON path to the property the location is pointing to. The offset applies to this property's\n * value string.\n */\n jsonPath: PropertyJsonPath;\n /**\n * The character index in the property's value string where this location is pointing. The\n * location is at this offset within the property's value string.\n */\n propertyOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in an attribute key string in a {@link MarkerObject} or\n * {@link Usj}. The property cannot be `type` or `marker` because these properties' keys have no\n * representation in USFM. The property also cannot be any special attribute whose key doesn't have\n * a text representation in USFM like default attribute, leading attribute, text content attribute\n *\n * To represent a location in an attribute's value, use {@link UsjPropertyValueLocation}.\n */\nexport type UsjAttributeKeyLocation = {\n /**\n * JSON path to the marker whose attribute key the location is pointing to. The offset applies to\n * this attribute's key string unless the attribute is an attribute marker in USFM.\n */\n jsonPath: ContentJsonPath;\n /** Attribute name on the marker object whose key this location is pointing to. */\n keyName: string;\n /**\n * The character index in the attribute's key string where this location is pointing.\n *\n * If the attribute is an attribute marker in USFM, the location is at this offset within the\n * marker name for this attribute marker (for example, `c`'s `altnumber` attribute has attribute\n * marker `ca`, so its `keyOffset` applies to `ca`).\n *\n * If the attribute is not an attribute marker in USFM, the location is at this offset within the\n * attribute's key string.\n */\n keyOffset: number;\n};\n\n/**\n * A JSONPath query to an attribute marker derived from an attribute on a {@link MarkerObject} or\n * {@link Usj}. Indicates the very beginning of that marker (at the backslash in USFM).\n */\nexport type UsjAttributeMarkerLocation = {\n /** JSON path to the marker whose attribute marker the location is pointing to. */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of an attribute marker\n * derived from an attribute on a {@link MarkerObject} or {@link Usj}.\n */\nexport type UsjClosingAttributeMarkerLocation = {\n /**\n * JSON path to the marker whose attribute marker's closing marker the location is pointing to.\n * The offset applies to the closing marker representation of that attribute marker (for example,\n * `\\ca*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation of the attribute marker.\n */\n keyClosingMarkerOffset: number;\n};\n\n// #endregion Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * Node in a USJ object (including the top-level Usj object) and its location in the document. You\n * must make sure you only add `node`s that correspond to the appropriate type of\n * `UsjDocumentLocation` (e.g. if `documentLocation` is a {@link UsjTextContentLocation}, `node` must\n * be a text content string)\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjNodeAndDocumentLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n node: TDocumentLocation extends UsjTextContentLocation ? string : MarkerObject | Usj;\n documentLocation: TDocumentLocation;\n};\n\n/** Result of a search for text within a USJ object */\nexport type UsjSearchResult = {\n /**\n * Beginning location in the USJ document of the search result. The text is inclusive of this\n * location, meaning this is the location of the first character of the found text\n */\n start: UsjNodeAndDocumentLocation;\n /**\n * Ending location in the USJ document of the search result. The text is exclusive of this\n * location, meaning this is the location right after the last character of the found text\n */\n end: UsjNodeAndDocumentLocation;\n /**\n * The matching Scripture text (not USFM string) that was found between the start and end\n * locations\n */\n text: string;\n};\n\n/**\n * Set of options to provide to `UsjReaderWriter`'s constructor to customize how the reading and\n * writing works\n */\nexport type UsjReaderWriterOptions = {\n /**\n * A map of all USFM/USX/USJ markers and some information about them. Used for translating between\n * the formats\n *\n * Defaults to trying to use a built-in markers map that matches the version of the USJ passed in.\n *\n * Currently supported built-in USFM versions:\n *\n * - 3.0/3.0.x\n */\n markersMap?: MarkersMap;\n /**\n * Whether the transformations should preserve invisible characters as in Paratext 9\n * (`ScrText.Settings.AllowInvisibleChars`).\n *\n * Defaults to `false`\n */\n shouldAllowInvisibleCharacters?: boolean;\n};\n\n/** Utilities for reading from and writing to `Usj` objects */\nexport interface IUsjReaderWriter {\n /**\n * Return a copy of text following a given starting point\n *\n * @param start Point where text extraction will start\n * @param desiredLength Length of text to extract from this USJ data\n */\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string;\n /**\n * Return a copy of text between two points\n *\n * @param start Point where text extraction will start\n * @param end Point where text extraction will end\n * @param maxLength Maximum length of string to return (defaults to 100)\n * @returns Text between the two points, capped at length `maxLength`\n */\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number,\n ): string;\n /**\n * Given a starting point, find the next location in this USJ data that matches the given text\n *\n * @param start Point where the search for `text` will start\n * @param text Text to find. Note you can use an empty string to find the closest text in or after\n * the `start` point.\n * @param maxTextLengthToSearch Maximum length of text to search before stopping (default is 1000)\n * @returns Object containing the USJ node where `text` begins (it might be split across nodes),\n * offset within that node that indicates where `text` begins, and a JSONPath string that\n * indicates the location of the of USJ node within `usj`. Note that if the USJ node returned is\n * an object, it is the same object that is within this USJ data. So if you change it, you are\n * changing this USJ data.\n */\n findNextLocationOfMatchingText(\n start: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number,\n ): UsjNodeAndDocumentLocation | undefined;\n /** Find the first value matching the given JSONPath query within this USJ data */\n findSingleValue(jsonPathQuery: string): T | undefined;\n /** Find the parent of the first value matching the given JSONPath query within this USJ data */\n findParent(jsonPathQuery: string): T | undefined;\n /**\n * Convert a JSONPath query into a SerializedVerseRef and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Convert a JSONPath query into a USJ node, JSONPath, and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @returns USJ node, JSONPath, and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n */\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation;\n /** Build a JSONPath query that uniquely identifies the given node with this USJ data. */\n nodeToJsonPath(node: MarkerObject): ContentJsonPath;\n /**\n * Determine the location in the USFM representation of this data that corresponds to the location\n * of a node somewhere within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USFM location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Determine the location in the USJ document that corresponds to the location of a node somewhere\n * within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USJ location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @returns Node, JSONPath, and offset info representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n */\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation;\n /**\n * Remove all nodes from this USJ data that match a given search function.\n *\n * @param searchFunction Function that returns `true` if the given node should be removed\n * @returns Number of nodes removed\n */\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number;\n /**\n * Search for matches of a regular expression within this USJ's text data\n *\n * @param regex Regular expression to search for. Specify the global flag to find all matches.\n * @returns Array of `UsjSearchResult` objects that match the given regular expression\n */\n search(regex: RegExp): UsjSearchResult[];\n /** Transforms the USJ document into USFM */\n toUsfm(): string;\n /**\n * Get the index in the USFM representation of this data relative to the start of the document\n * that corresponds to the absolute verse location in USFM space passed in\n *\n * @param usfmVerseLocation The location in USFM space relative to a verse to get the index for\n * @returns Index in the USFM representation of this data relative to the start of the document\n */\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number;\n /**\n * Get the node + offset and JSONPath query within this USJ data of the first encountered string\n * after the provided USFM location for a specific verse in a USJ document.\n *\n * Note: this may return a node that is in a subsequent verse or even chapter depending on how\n * much content the USJ data contains. It simply looks through the rest of the USJ data for the\n * first text node and returns that.\n *\n * @param usfmVerseLocation Indicates the location in USFM space (book, chapter, verse, character\n * offset) to find the next text for\n * @returns Object containing the first USJ text node after `verseRef`, and a JSONPath string that\n * indicates the location of the USJ text node within this USJ data.\n * @throws Error if there is no text after `usfmVerseLocation`\n * @throws Error if `usfmVerseLocation` does not point to a valid location in this USJ data\n */\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a location in USJ space within this USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ location within the USJ document indicated by\n * `usfmVerseLocation`.\n */\n usfmVerseLocationToUsjDocumentLocation(usfmVerseLocation: UsfmVerseLocation): UsjDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a node and location in USJ space within this\n * USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ node and location within the USJ document indicated by\n * `usfmVerseLocation`. Note that if the USJ node returned is an object, it is the same object\n * that is within this USJ data. So if you change it, you are changing this USJ data.\n */\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Inform this UsjReaderWriter that the underlying USJ object changed. This is needed to clear\n * caches used when querying.\n */\n usjChanged(): void;\n /**\n * Convert a location in USJ space within this USJ data into a location in USFM space.\n *\n * @param usjLocation Location in USJ space - a jsonPath and other information about where the\n * location is\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Location in USFM space that is equivalent to the USJ location specified\n * @throws If not able to find the location in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n}\n","import { MarkerObject, MarkerContent } from '@eten-tech-foundation/scripture-utilities';\n\n/** Gets the default caller sequence to use to generate callers for textual notes. */\nexport function getDefaultCallerSequence(): string[] {\n return Array.from({ length: 26 }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i));\n}\n\n/**\n * Gets a caller to be displayed for a textual note. This is primarily useful as a helper function\n * in {@link getFormatCallerFunction} , but it might be useful in stories, UI preview code, etc.\n *\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n * @param n Zero-based index into the caller list.\n */\nexport function getNthCaller(n: number, callers?: string[]): string {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n return callerList[n % callerList.length];\n}\n\n/**\n * Gets a function that provides a (stable) caller based on a given sequence of textual notes.\n *\n * @param footnotes Sequence of footnotes, cross-references, and/or end-notes.\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n */\nexport function getFormatCallerFunction(footnotes: MarkerObject[], callers: string[] | undefined) {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n // Precompute a stable sequence for '+' callers\n const plusSequenceMap = (() => {\n const map = new Map();\n let autoCallerCounter = 0;\n footnotes.forEach((fn, idx) => {\n if (fn.caller === '+') {\n map.set(idx, getNthCaller(autoCallerCounter, callerList));\n autoCallerCounter += 1;\n }\n });\n return map;\n })();\n\n return (caller: string | undefined, index: number): string | undefined => {\n if (caller === '+') {\n const formattedCaller = plusSequenceMap.get(index);\n if (!formattedCaller) {\n console.warn(`Caller index ${index} out of range for '+' callers`);\n return '?'; // Out of range'\n }\n return formattedCaller;\n }\n if (caller === '-') return undefined;\n return caller;\n };\n}\n\n/**\n * Extract footnotes from an array of `MarkerContent` objects.\n *\n * @param contents - An array of `MarkerContent` objects\n * @returns An array of MarkerObjects representing all textual notes found in the contents.\n */\nexport function extractFootnotesFromUsjContent(contents?: MarkerContent[]): MarkerObject[] {\n const footnotes: MarkerObject[] = [];\n if (!contents || contents.length === 0) return footnotes;\n\n function traverse(item: MarkerContent) {\n if (typeof item === 'string') return; // plain text node, ignore\n\n // item is a MarkerObject\n if (item.type === 'note') {\n footnotes.push(item);\n } else if (Array.isArray(item.content) && item.content.length > 0) {\n item.content.forEach(traverse);\n }\n }\n\n contents.forEach(traverse);\n return footnotes;\n}\n","/** Options for calculating resizable pane size limits. */\nexport type PaneSizeLimitsOptions = {\n /**\n * The thickness of the splitter between the two panes, in pixels.\n *\n * @default 4\n */\n splitterThicknessPx?: number;\n /**\n * Minimum size (height or width) of the secondary pane (the pane whose size is to be\n * constrained), in pixels. Ensures the secondary pane never shrinks below this size, if\n * possible.\n *\n * @default 20\n */\n secondaryPaneMinSizePx?: number;\n /**\n * Minimum size (height or width) of the main pane (the other pane), in pixels. Ensures the main\n * pane always has some visible content.\n *\n * @default 60\n */\n mainPaneMinSizePx?: number;\n /**\n * Absolute minimum percentage of the total available that the secondary pane can occupy. Used to\n * avoid the pane collapsing completely (e.g., if the available height or width is less than the\n * combined minimums).\n *\n * @default 3\n */\n absoluteMinPercent?: number;\n /**\n * Absolute maximum percentage of the total available that the secondary pane can occupy. Can be\n * used to keep the \"main\" pane from being overwhelmed by the size of the secondary pane.\n *\n * @default 90\n */\n absoluteMaxPercent?: number;\n};\n\n/**\n * Calculates the minimum and maximum size (as percentages) for a resizable pane in a two-pane\n * layout based on the total available height or width and optional constraints.\n *\n * The returned percentages indicate the allowable range for the secondary pane (the one whose size\n * limits are being computed). When applied, they ensure that pane never shrinks below its minimum\n * or grows beyond its maximum, leaving adequate space for both panes.\n *\n * @param availablePx - Total height or width available for both panes, in pixels.\n * @param options - Optional parameters for customizing pane size constraints.\n * @returns An object containing the minimum and maximum percentages the secondary pane can occupy:\n * `{ minPercent, maxPercent }`.\n */\nexport function getPaneSizeLimits(\n availablePx: number,\n options: PaneSizeLimitsOptions = {},\n): { minPercent: number; maxPercent: number } {\n const {\n splitterThicknessPx = 4,\n secondaryPaneMinSizePx = 20,\n mainPaneMinSizePx = 60,\n absoluteMinPercent = 3,\n absoluteMaxPercent = 90,\n } = options;\n\n const usableHeightPx = availablePx - splitterThicknessPx;\n\n let minPercent: number;\n let maxPercent: number;\n\n if (usableHeightPx < secondaryPaneMinSizePx + mainPaneMinSizePx) {\n minPercent = absoluteMinPercent;\n maxPercent = absoluteMaxPercent;\n } else {\n maxPercent = Math.min(\n Math.floor(((usableHeightPx - mainPaneMinSizePx) / usableHeightPx) * 100),\n absoluteMaxPercent,\n );\n\n minPercent = Math.min(\n Math.max(Math.ceil((secondaryPaneMinSizePx / usableHeightPx) * 100), absoluteMinPercent),\n maxPercent,\n );\n }\n\n return { minPercent, maxPercent };\n}\n","var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n/**\n * Combine two comparators into a single comparators.\n */\nfunction combineComparators(comparatorA, comparatorB) {\n return function isEqual(a, b, state) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nfunction createIsCircular(areItemsEqual) {\n return function isCircular(a, b, state) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n var cache = state.cache;\n var cachedA = cache.get(a);\n var cachedB = cache.get(b);\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n cache.set(a, b);\n cache.set(b, a);\n var result = areItemsEqual(a, b, state);\n cache.delete(a);\n cache.delete(b);\n return result;\n };\n}\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nfunction getStrictProperties(object) {\n return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));\n}\n/**\n * Whether the object contains the property passed as an own property.\n */\nvar hasOwn = Object.hasOwn ||\n (function (object, property) {\n return hasOwnProperty.call(object, property);\n });\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nfunction sameValueZeroEqual(a, b) {\n return a === b || (!a && !b && a !== a && b !== b);\n}\n\nvar PREACT_VNODE = '__v';\nvar PREACT_OWNER = '__o';\nvar REACT_OWNER = '_owner';\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys = Object.keys;\n/**\n * Whether the arrays are equal in value.\n */\nfunction areArraysEqual(a, b, state) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the dates passed are equal in value.\n */\nfunction areDatesEqual(a, b) {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n/**\n * Whether the errors passed are equal in value.\n */\nfunction areErrorsEqual(a, b) {\n return (a.name === b.name &&\n a.message === b.message &&\n a.cause === b.cause &&\n a.stack === b.stack);\n}\n/**\n * Whether the functions passed are equal in value.\n */\nfunction areFunctionsEqual(a, b) {\n return a === b;\n}\n/**\n * Whether the `Map`s are equal in value.\n */\nfunction areMapsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.entries();\n var aResult;\n var bResult;\n var index = 0;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.entries();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (matchedIndices[matchIndex]) {\n matchIndex++;\n continue;\n }\n var aEntry = aResult.value;\n var bEntry = bResult.value;\n if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) &&\n state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n index++;\n }\n return true;\n}\n/**\n * Whether the numbers are equal in value.\n */\nvar areNumbersEqual = sameValueZeroEqual;\n/**\n * Whether the objects are equal in value.\n */\nfunction areObjectsEqual(a, b, state) {\n var properties = keys(a);\n var index = properties.length;\n if (keys(b).length !== index) {\n return false;\n }\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n if (!isPropertyEqual(a, b, state, properties[index])) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nfunction areObjectsEqualStrict(a, b, state) {\n var properties = getStrictProperties(a);\n var index = properties.length;\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n var property;\n var descriptorA;\n var descriptorB;\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index];\n if (!isPropertyEqual(a, b, state, property)) {\n return false;\n }\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n if ((descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nfunction arePrimitiveWrappersEqual(a, b) {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n/**\n * Whether the regexps passed are equal in value.\n */\nfunction areRegExpsEqual(a, b) {\n return a.source === b.source && a.flags === b.flags;\n}\n/**\n * Whether the `Set`s are equal in value.\n */\nfunction areSetsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.values();\n var aResult;\n var bResult;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.values();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (!matchedIndices[matchIndex] &&\n state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the TypedArray instances are equal in value.\n */\nfunction areTypedArraysEqual(a, b) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the URL instances are equal in value.\n */\nfunction areUrlsEqual(a, b) {\n return (a.hostname === b.hostname &&\n a.pathname === b.pathname &&\n a.protocol === b.protocol &&\n a.port === b.port &&\n a.hash === b.hash &&\n a.username === b.username &&\n a.password === b.password);\n}\nfunction isPropertyEqual(a, b, state, property) {\n if ((property === REACT_OWNER ||\n property === PREACT_OWNER ||\n property === PREACT_VNODE) &&\n (a.$$typeof || b.$$typeof)) {\n return true;\n }\n return (hasOwn(b, property) &&\n state.equals(a[property], b[property], property, property, a, b, state));\n}\n\nvar ARGUMENTS_TAG = '[object Arguments]';\nvar BOOLEAN_TAG = '[object Boolean]';\nvar DATE_TAG = '[object Date]';\nvar ERROR_TAG = '[object Error]';\nvar MAP_TAG = '[object Map]';\nvar NUMBER_TAG = '[object Number]';\nvar OBJECT_TAG = '[object Object]';\nvar REG_EXP_TAG = '[object RegExp]';\nvar SET_TAG = '[object Set]';\nvar STRING_TAG = '[object String]';\nvar URL_TAG = '[object URL]';\nvar isArray = Array.isArray;\nvar isTypedArray = typeof ArrayBuffer === 'function' && ArrayBuffer.isView\n ? ArrayBuffer.isView\n : null;\nvar assign = Object.assign;\nvar getTag = Object.prototype.toString.call.bind(Object.prototype.toString);\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nfunction createEqualityComparator(_a) {\n var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areErrorsEqual = _a.areErrorsEqual, areFunctionsEqual = _a.areFunctionsEqual, areMapsEqual = _a.areMapsEqual, areNumbersEqual = _a.areNumbersEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual, areUrlsEqual = _a.areUrlsEqual;\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a, b, state) {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n // If either of the items are nullish and fail the strictly equal check\n // above, then they must be unequal.\n if (a == null || b == null) {\n return false;\n }\n var type = typeof a;\n if (type !== typeof b) {\n return false;\n }\n if (type !== 'object') {\n if (type === 'number') {\n return areNumbersEqual(a, b, state);\n }\n if (type === 'function') {\n return areFunctionsEqual(a, b, state);\n }\n // If a primitive value that is not strictly equal, it must be unequal.\n return false;\n }\n var constructor = a.constructor;\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n // Constructors should match, otherwise there is potential for false positives\n // between class and subclass or custom object and POJO.\n if (constructor !== b.constructor) {\n return false;\n }\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid capturing the string tag.\n if (constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing\n // the string tag or doing an `instanceof` check.\n if (isArray(a)) {\n return areArraysEqual(a, b, state);\n }\n // `isTypedArray()` works on all possible TypedArray classes, so we can avoid\n // capturing the string tag or comparing against all possible constructors.\n if (isTypedArray != null && isTypedArray(a)) {\n return areTypedArraysEqual(a, b, state);\n }\n // Try to fast-path equality checks for other complex object types in the\n // same realm to avoid capturing the string tag. Strict equality is used\n // instead of `instanceof` because it is more performant for the common\n // use-case. If someone is subclassing a native class, it will be handled\n // with the string tag comparison.\n if (constructor === Date) {\n return areDatesEqual(a, b, state);\n }\n if (constructor === RegExp) {\n return areRegExpsEqual(a, b, state);\n }\n if (constructor === Map) {\n return areMapsEqual(a, b, state);\n }\n if (constructor === Set) {\n return areSetsEqual(a, b, state);\n }\n // Since this is a custom object, capture the string tag to determing its type.\n // This is reasonably performant in modern environments like v8 and SpiderMonkey.\n var tag = getTag(a);\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n // For RegExp, the properties are not enumerable, and therefore will give false positives if\n // tested like a standard object.\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is custom `Promise`-like class instances. These should\n // be treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state));\n }\n // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === URL_TAG) {\n return areUrlsEqual(a, b, state);\n }\n // If an error tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === ERROR_TAG) {\n return areErrorsEqual(a, b, state);\n }\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n/**\n * Create the configuration object used for building comparators.\n */\nfunction createEqualityComparatorConfig(_a) {\n var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;\n var config = {\n areArraysEqual: strict\n ? areObjectsEqualStrict\n : areArraysEqual,\n areDatesEqual: areDatesEqual,\n areErrorsEqual: areErrorsEqual,\n areFunctionsEqual: areFunctionsEqual,\n areMapsEqual: strict\n ? combineComparators(areMapsEqual, areObjectsEqualStrict)\n : areMapsEqual,\n areNumbersEqual: areNumbersEqual,\n areObjectsEqual: strict\n ? areObjectsEqualStrict\n : areObjectsEqual,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,\n areRegExpsEqual: areRegExpsEqual,\n areSetsEqual: strict\n ? combineComparators(areSetsEqual, areObjectsEqualStrict)\n : areSetsEqual,\n areTypedArraysEqual: strict\n ? areObjectsEqualStrict\n : areTypedArraysEqual,\n areUrlsEqual: areUrlsEqual,\n };\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n if (circular) {\n var areArraysEqual$1 = createIsCircular(config.areArraysEqual);\n var areMapsEqual$1 = createIsCircular(config.areMapsEqual);\n var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);\n var areSetsEqual$1 = createIsCircular(config.areSetsEqual);\n config = assign({}, config, {\n areArraysEqual: areArraysEqual$1,\n areMapsEqual: areMapsEqual$1,\n areObjectsEqual: areObjectsEqual$1,\n areSetsEqual: areSetsEqual$1,\n });\n }\n return config;\n}\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nfunction createInternalEqualityComparator(compare) {\n return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {\n return compare(a, b, state);\n };\n}\n/**\n * Create the `isEqual` function used by the consuming application.\n */\nfunction createIsEqual(_a) {\n var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;\n if (createState) {\n return function isEqual(a, b) {\n var _a = createState(), _b = _a.cache, cache = _b === void 0 ? circular ? new WeakMap() : undefined : _b, meta = _a.meta;\n return comparator(a, b, {\n cache: cache,\n equals: equals,\n meta: meta,\n strict: strict,\n });\n };\n }\n if (circular) {\n return function isEqual(a, b) {\n return comparator(a, b, {\n cache: new WeakMap(),\n equals: equals,\n meta: undefined,\n strict: strict,\n });\n };\n }\n var state = {\n cache: undefined,\n equals: equals,\n meta: undefined,\n strict: strict,\n };\n return function isEqual(a, b) {\n return comparator(a, b, state);\n };\n}\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nvar deepEqual = createCustomEqual();\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nvar strictDeepEqual = createCustomEqual({ strict: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nvar circularDeepEqual = createCustomEqual({ circular: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nvar shallowEqual = createCustomEqual({\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nvar strictShallowEqual = createCustomEqual({\n strict: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nvar circularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n strict: true,\n});\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nfunction createCustomEqual(options) {\n if (options === void 0) { options = {}; }\n var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;\n var config = createEqualityComparatorConfig(options);\n var comparator = createEqualityComparator(config);\n var equals = createCustomInternalComparator\n ? createCustomInternalComparator(comparator)\n : createInternalEqualityComparator(comparator);\n return createIsEqual({ circular: circular, comparator: comparator, createState: createState, equals: equals, strict: strict });\n}\n\nexport { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };\n//# sourceMappingURL=index.mjs.map\n","// There is a circular version https://www.npmjs.com/package/fast-equals#circulardeepequal that I\n// think allows comparing React refs (which have circular references in particular places that this\n// library would ignore). Maybe we can change to that version sometime if needed.\nimport { deepEqual as isEqualDeep } from 'fast-equals';\n\n/**\n * Check that two objects are deeply equal, comparing members of each object and such\n *\n * @param a The first object to compare\n * @param b The second object to compare\n *\n * WARNING: Objects like arrays from different iframes have different constructor function\n * references even if they do the same thing, so this deep equality comparison fails objects that\n * look the same but have different constructors because different constructors could produce\n * false positives in [a few specific\n * situations](https://github.com/planttheidea/fast-equals/blob/a41afc0a240ad5a472e47b53791e9be017f52281/src/comparator.ts#L96).\n * This means that two objects like arrays from different iframes that look the same will fail\n * this check. Please use some other means to check deep equality in those situations.\n *\n * Note: This deep equality check considers `undefined` values on keys of objects NOT to be equal to\n * not specifying the key at all. For example, `{ stuff: 3, things: undefined }` and `{ stuff: 3\n * }` are not considered equal in this case\n *\n * - For more information and examples, see [this\n * CodeSandbox](https://codesandbox.io/s/deepequallibrarycomparison-4g4kk4?file=/src/index.mjs).\n *\n * @returns True if a and b are deeply equal; false otherwise\n */\nexport function deepEqual(a: unknown, b: unknown) {\n return isEqualDeep(a, b);\n}\n\nexport default deepEqual;\n","import { deepEqual } from './equality-checking';\n\n/**\n * Check if one object is a subset of the other object. \"Subset\" means that all properties of one\n * object are present in the other object, and if they are present that all values of those\n * properties are deeply equal. Sub-objects are also checked to be subsets of the corresponding\n * sub-object in the other object.\n *\n * @example ObjB is a subset of objA given these objects:\n *\n * ```ts\n * objA = { name: 'Alice', age: 30, address: { city: 'Seattle', state: 'Washington' } };\n * objB = { name: 'Alice', address: { city: 'Seattle' } };\n * ```\n *\n * It is important to note that only arrays of primitives (i.e., booleans, numbers, strings) are\n * supported. In particular, objects in arrays will not be checked for deep equality. Also, presence\n * in an array is all this checks, not the number of times that an item appears in an array. `[1,\n * 1]` is a subset of `[1]`.\n *\n * @param objectWithAllProperties Object to be checked if it is a superset of\n * `objectWithPartialProperties`\n * @param objectWithPartialProperties Object to be checked if it is a subset of\n * `objectWithAllProperties`\n * @returns True if `objectWithAllProperties` contains all the properties of\n * `objectWithPartialProperties` and all values of those properties are deeply equal\n */\nexport function isSubset(\n objectWithAllProperties: unknown,\n objectWithPartialProperties: unknown,\n): boolean {\n if (typeof objectWithAllProperties !== typeof objectWithPartialProperties) return false;\n\n // For this function we're saying that all falsy things of the same type are equal to each other\n if (!objectWithAllProperties && !objectWithPartialProperties) return true;\n\n if (Array.isArray(objectWithAllProperties)) {\n // We know these are arrays from the line above\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialArray = objectWithPartialProperties as Array;\n const allArray = objectWithAllProperties as Array;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n if (partialArray.length === 0) return true;\n\n // This only works with arrays of primitives.\n // If someone cares about checking arrays of objects this needs updating.\n return partialArray.every((item) => allArray.includes(item));\n }\n\n if (typeof objectWithAllProperties !== 'object')\n return deepEqual(objectWithAllProperties, objectWithPartialProperties);\n\n // We know these are objects that potentially have properties because of the earlier checks\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialObj = objectWithPartialProperties as Record;\n const allObj = objectWithAllProperties as Record;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n let retVal = true;\n Object.keys(partialObj).forEach((key) => {\n if (!retVal) return;\n if (!Object.hasOwn(allObj, key)) retVal = false;\n else if (!isSubset(allObj[key], partialObj[key])) retVal = false;\n });\n return retVal;\n}\n\nexport default isSubset;\n","/**\n * Converts a JavaScript value to a JSON string, changing `undefined` properties in the JavaScript\n * object to `null` properties in the JSON string.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer A function that transforms the results. Note that all `undefined` values returned\n * by the replacer will be further transformed into `null` in the JSON string.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON\n * text to make it easier to read. See the `space` parameter of `JSON.stringify` for more\n * details.\n */\nexport function serialize(\n value: unknown,\n replacer?: (this: unknown, key: string, value: unknown) => unknown,\n space?: string | number,\n): string {\n const undefinedReplacer = (replacerKey: string, replacerValue: unknown) => {\n let newValue = replacerValue;\n if (replacer) newValue = replacer(replacerKey, newValue);\n // All `undefined` values become `null` on the way from JS objects into JSON strings\n // eslint-disable-next-line no-null/no-null\n if (newValue === undefined) newValue = null;\n return newValue;\n };\n return JSON.stringify(value, undefinedReplacer, space);\n}\n\n/**\n * Converts a JSON string into a value, converting all `null` properties from JSON into `undefined`\n * in the returned JavaScript value/object.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A valid JSON string.\n * @param reviver A function that transforms the results. This function is called for each member of\n * the object. If a member contains nested objects, the nested objects are transformed before the\n * parent object is. Note that `null` values are converted into `undefined` values after the\n * reviver has run.\n */\nexport function deserialize(\n value: string,\n reviver?: (this: unknown, key: string, value: unknown) => unknown,\n // Need to use `any` instead of `unknown` here to match the signature of JSON.parse\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // Helper function to replace `null` with `undefined` on a per property basis. This can't be done\n // with our own reviver because `JSON.parse` removes `undefined` properties from the return value.\n function replaceNull(obj: Record): Record {\n Object.keys(obj).forEach((key: string | number) => {\n // We only want to replace `null`, not other falsy values\n // eslint-disable-next-line no-null/no-null\n if (obj[key] === null) obj[key] = undefined;\n // If the property is an object, recursively call the helper function on it\n else if (typeof obj[key] === 'object')\n // Since the object came from a string, we know the keys will not be symbols\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n obj[key] = replaceNull(obj[key] as Record);\n });\n return obj;\n }\n\n const parsedObject = JSON.parse(value, reviver);\n // Explicitly convert the value 'null' that isn't stored as a property on an object to 'undefined'\n // eslint-disable-next-line no-null/no-null\n if (parsedObject === null) return undefined;\n if (typeof parsedObject === 'object') return replaceNull(parsedObject);\n return parsedObject;\n}\n\n/**\n * Check to see if the value is serializable without losing information\n *\n * @param value Value to test\n * @returns True if serializable; false otherwise\n *\n * Note: the values `undefined` and `null` are serializable (on their own or in an array), but\n * `null` values get transformed into `undefined` when serializing/deserializing.\n *\n * WARNING: This is inefficient right now as it stringifies, parses, stringifies, and === the value.\n * Please only use this if you need to\n *\n * DISCLAIMER: this does not successfully detect that values are not serializable in some cases:\n *\n * - Losses of removed properties like functions and `Map`s\n * - Class instances (not deserializable into class instances without special code)\n *\n * We intend to improve this in the future if it becomes important to do so. See [`JSON.stringify`\n * documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)\n * for more information.\n */\nexport function isSerializable(value: unknown): boolean {\n try {\n const serializedValue = serialize(value);\n return serializedValue === serialize(deserialize(serializedValue));\n } catch (e) {\n return false;\n }\n}\n\n/**\n * HTML Encodes the provided string. Thanks to ChatGPT\n *\n * @param str String to HTML encode\n * @returns HTML-encoded string\n */\nexport const htmlEncode = (str: string): string =>\n str\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n","import { DateTimeFormat } from './intl-date-time-format';\n\n/**\n * Retrieves the current locale of the user's environment.\n *\n * @returns A string representing the current locale. If the locale cannot be determined, the\n * function returns an empty string.\n */\nexport function getCurrentLocale(): string {\n // Use navigator when available\n if (typeof navigator !== 'undefined' && navigator.languages) {\n const rawLocale = navigator.languages[0];\n // According to the MDN page for navigator.languages it should always return a valid BCP 47 tag.\n // However, some environments (e.g., certain Linux distros) may use the 'POSIX locale format'.\n // This code removes a (potential) trailing \"@posix\" so we will always return a valid BCP 47 tag\n // You can find the MDN page for navigator.languages here:\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n // You can learn more about the 'POSIX locale format' here:\n // https://learn.microsoft.com/en-us/globalization/locale/other-locale-names\n return rawLocale.replace(/@posix$/i, '');\n }\n // For Node.js\n return new DateTimeFormat().resolvedOptions().locale;\n}\n\nexport default getCurrentLocale;\n","import { NumberFormat } from './intl/intl-number-format';\n\n/**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @example FormatBytes(1024) => \"1 KB\"\n *\n * @example FormatBytes(1024, 0) => \"1 KB\"\n *\n * @param fileSize Number to format\n * @param decimals Number of decimal places to round to\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\nexport function formatBytes(fileSize: number, decimals: number = 2): string {\n if (fileSize === 0) return '0 Bytes';\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(fileSize) / Math.log(1024));\n const sizeToUse = sizes[i];\n const formattingFileSize = new NumberFormat('en', {\n style: 'decimal',\n maximumFractionDigits: decimals,\n minimumFractionDigits: 0,\n }).format(fileSize / 1024 ** i);\n return `${formattingFileSize} ${sizeToUse}`;\n}\n\nexport default formatBytes;\n","const MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60;\nconst SECONDS_PER_DAY = SECONDS_PER_HOUR * 24;\n\n/**\n * Get a localized string representation of the time between two dates\n *\n * @example\n *\n * `since` = 3 Aug 2024 8:00 AM\n *\n * `to` = 5 Aug 2024 8:000 AM\n *\n * Returns: \"two days ago\"\n *\n * @param since \"Destination\" time. time against which to get the time span.\n * @param to \"Starting\" time. Time span will be formatted relative to `to`. Defaults to `new Date()`\n * @returns Time span in words from `to` to `since`\n */\nexport function formatTimeSpan(\n relativeTimeFormatter: Intl.RelativeTimeFormat,\n since: Date,\n to = new Date(),\n) {\n const spanSeconds = Math.floor((since.getTime() - to.getTime()) / MILLISECONDS_PER_SECOND);\n\n const totalDays = Math.round(spanSeconds / SECONDS_PER_DAY);\n if (Math.abs(totalDays) >= 1) return relativeTimeFormatter.format(totalDays, 'day');\n\n const totalHours = Math.round(spanSeconds / SECONDS_PER_HOUR);\n if (Math.abs(totalHours) >= 1) return relativeTimeFormatter.format(totalHours, 'hour');\n\n const totalMinutes = Math.round(spanSeconds / SECONDS_PER_MINUTE);\n if (Math.abs(totalMinutes) >= 1) return relativeTimeFormatter.format(totalMinutes, 'minute');\n\n return relativeTimeFormatter.format(spanSeconds, 'second');\n}\n\n/**\n * Formats a date relative to today, showing \"Today\" or \"Yesterday\" when applicable, otherwise\n * returns the date in the specified format\n *\n * @param date The date to format\n * @param todayString The string to display when the date is today\n * @param yesterdayString The string to display when the date is yesterday\n * @param locale The locale to use for date formatting (defaults to user's locale)\n * @param options The Intl.DateTimeFormatOptions to use for date formatting when not\n * today/yesterday. Defaults to `{ year: 'numeric', month: 'short', day: 'numeric' }` which\n * produces formats like \"Nov 9, 2025\"\n */\nexport function formatRelativeDate(\n date: Date,\n todayString: string,\n yesterdayString: string,\n locale?: string,\n options: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n): string {\n const today = new Date();\n const yesterday = new Date(today);\n yesterday.setDate(yesterday.getDate() - 1);\n\n const isToday =\n date.getDate() === today.getDate() &&\n date.getMonth() === today.getMonth() &&\n date.getFullYear() === today.getFullYear();\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n if (isToday) {\n return todayString;\n }\n if (isYesterday) {\n return yesterdayString;\n }\n\n return date.toLocaleString(locale, options);\n}\n","/**\n * Modifier keys that don't constitute typed input\n *\n * Sourced from\n * https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys\n */\nexport const MODIFIER_KEYS = new Set([\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta',\n 'NumLock',\n 'ScrollLock',\n 'Shift',\n 'Super',\n 'Symbol',\n 'SymbolLock',\n]);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey, ReferencedItem } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the settings it provides */\nexport type SettingsContribution = SettingsGroup | SettingsGroup[];\n/** A description of an extension's setting entry */\nexport type Setting = ExtensionControlledSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledSetting = SettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a setting entry */\nexport type SettingBase = StateBase & {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the setting name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the setting */\n description?: LocalizeKey;\n /**\n * Boolean that controls whether a setting should be hidden or not. If hidden, the setting will\n * not show up in the settings dialog in `paranext-core`, and thus will not be configurable by the\n * user unless an extension provides a way to interact with the setting.\n */\n isHidden?: boolean;\n};\n/** The data an extension provides to inform Platform.Bible of the project settings it provides */\nexport type ProjectSettingsContribution = ProjectSettingsGroup | ProjectSettingsGroup[];\n/** A description of an extension's setting entry */\nexport type ProjectSetting = ExtensionControlledProjectSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledProjectSetting = ProjectSettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a project setting entry */\nexport type ProjectSettingBase = SettingBase & ModifierProject;\n/** A description of an extension's user state entry */\nexport type UserState = ExtensionControlledState;\n/** State definition that is validated by the extension. */\nexport type ExtensionControlledState = StateBase & ModifierExtensionControlled;\n/** Group of related settings definitions */\nexport interface SettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the group */\n description?: LocalizeKey;\n properties: SettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface SettingProperties {\n [k: ReferencedItem]: Setting;\n}\n/** Base information needed to describe a state entry */\nexport interface StateBase {\n [k: string]: unknown;\n /** Default value for the state/setting */\n default: unknown;\n /**\n * A state/setting ID whose value to set to this state/setting's starting value the first time\n * this state/setting is loaded\n */\n derivesFrom?: ReferencedItem;\n}\n/**\n * Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the\n * extension provides the component and the validator for the state/setting, so the state/setting is\n * controlled by the extension.\n */\nexport interface ModifierExtensionControlled {\n [k: string]: unknown;\n platformType?: undefined;\n type?: undefined;\n}\n/** Group of related settings definitions */\nexport interface ProjectSettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the project settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the project settings dialog to describe the group */\n description?: LocalizeKey;\n properties: ProjectSettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface ProjectSettingProperties {\n [k: ReferencedItem]: ProjectSetting;\n}\n\n// Note: we removed the index signature on ModifierProject to avoid having it on\n// `ProjectMetadataFilterOptions`. Unfortunately adding \"additionalProperties\": false on the json\n// schema messes up validation. Please remove the index signature again in the future if you\n// regenerate types\n/**\n * Defines a set of optional properties that can be used to filter projects based on their\n * `projectInterface` and Project Data Provider Factory Ids.\n */\nexport interface ModifierProject {\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should be included.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to pass):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to all `ProjectInterfaces`, so all projects that do not match\n * `excludeProjectInterfaces` will be included\n *\n * @example\n *\n * ```typescript\n * includeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed on projects whose `projectInterface`s fulfill at least one\n * of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n includeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should absolutely not be included even if they match with\n * `includeProjectInterfaces`.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to exclude the project):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition and exclude the project\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition and exclude the project\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will\n * be included\n *\n * @example\n *\n * ```typescript\n * excludeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed and exclude projects whose `projectInterface`s fulfill at\n * least one of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n excludeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should be included.\n *\n * Defaults to all Project Data Provider Factory Ids, so all projects that do not match\n * `excludePdpFactoryIds` will be included\n */\n includePdpFactoryIds?: undefined | string | string[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should absolutely not be included even if they match\n * with `includeProjectInterfaces`.\n *\n * Defaults to none, so all projects that match `includePdpFactoryIds` will be included\n */\n excludePdpFactoryIds?: undefined | string | string[];\n}\n\n/** The data an extension provides to inform Platform.Bible of the user state it provides */\nexport interface UserStateContribution {\n [k: ReferencedItem]: UserState;\n}\n/** The data an extension provides to inform Platform.Bible of the project state it provides */\nexport interface ProjectStateContribution {\n [k: ReferencedItem]: UserState;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\nconst settingsDefs = {\n projectSettingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n },\n projectSettingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the project settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description:\n 'localizeKey that displays in the project settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/projectSettingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n projectSettingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/projectSetting',\n },\n },\n additionalProperties: false,\n },\n projectSetting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledProjectSetting',\n },\n ],\n },\n extensionControlledProjectSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/projectSettingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n projectSettingBase: {\n description: 'Base information needed to describe a project setting entry',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierProject',\n },\n ],\n },\n modifierProject: {\n description: 'Modifies setting type to be project setting',\n type: 'object',\n properties: {\n includeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should be included.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to pass):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to all `ProjectInterfaces`, so all projects that do not match `excludeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nincludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed on projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n excludeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to exclude the project):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition and exclude the project\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition and exclude the project\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nexcludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed and exclude projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n includePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should be included.\\n\\nDefaults to all Project Data Provider Factory Ids, so all projects that do not match `excludePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n excludePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nDefaults to none, so all projects that match `includePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n },\n settingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n },\n settingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/settingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n settingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w-]+\\\\.[\\\\w-]+$': {\n $ref: '#/$defs/setting',\n },\n },\n additionalProperties: false,\n },\n setting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledSetting',\n },\n ],\n },\n extensionControlledSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n settingBase: {\n description: 'Base information needed to describe a setting entry',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the setting name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the setting',\n $ref: '#/$defs/localizeKey',\n },\n isHidden: {\n description: `Boolean that controls whether a setting should be hidden or not. If hidden\n , the setting will not show up in the settings dialog in \\`paranext-core\\`, and thus\n will not be configurable by the user unless an extension provides a way to interact with\n the setting.`,\n type: 'boolean',\n },\n },\n required: ['label'],\n },\n ],\n },\n projectStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the user state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateProperties: {\n description: 'Object whose keys are state IDs and whose values are state objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/userState',\n },\n },\n additionalProperties: false,\n },\n userState: {\n description: \"A description of an extension's user state entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledState',\n },\n ],\n },\n extensionControlledState: {\n description: 'State definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n modifierExtensionControlled: {\n description:\n 'Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the extension provides the component and the validator for the state/setting, so the state/setting is controlled by the extension.',\n not: {\n anyOf: [\n {\n type: 'object',\n required: ['platformType'],\n },\n {\n type: 'object',\n required: ['type'],\n },\n ],\n },\n },\n stateBase: {\n description: 'Base information needed to describe a state entry',\n type: 'object',\n properties: {\n default: {\n description: 'default value for the state/setting',\n type: 'any',\n },\n derivesFrom: {\n description:\n \"a state/setting ID whose value to set to this state/setting's starting value the first time this state/setting is loaded\",\n $ref: '#/$defs/id',\n },\n },\n required: ['default'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n id: {\n description: '',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n tsType: 'Id',\n },\n};\n\n/**\n * Json-schema-to-typescript has some added stuff that isn't actually compatible with JSON schema,\n * so we remove them here\n *\n * @param defs The `$defs` property of a JSON schema (will be modified in place)\n */\n// JSON schema types are weird, so we'll just be careful\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function removeJsonToTypeScriptTypesStuff(defs: any) {\n if (!defs) return;\n\n // JSON schema types are weird, so we'll just be careful\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.values(defs).forEach((def: any) => {\n if (!def.type) return;\n\n if ('tsType' in def) delete def.tsType;\n\n if (def.type === 'any') {\n delete def.type;\n return;\n }\n\n if (def.type === 'object') {\n removeJsonToTypeScriptTypesStuff(def.properties);\n }\n });\n}\n\nremoveJsonToTypeScriptTypesStuff(settingsDefs);\n\n/** JSON schema object that aligns with the ProjectSettingsContribution type */\nexport const projectSettingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Project Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(projectSettingsDocumentSchema);\n\n/** JSON schema object that aligns with the {@link SettingsContribution} type */\nexport const settingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(settingsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey } from './menus.model';\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\n\n/** Localized string value associated with this key */\nexport type LocalizedStringValue = string;\n/**\n * Date in YYYY-MM-DD format\n *\n * Use regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$` to test.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\nexport type DateYYYYMMDD = `${number}-${number}-${number}`;\n\n/** The data an extension provides to inform Platform.Bible of the localized strings it provides. */\nexport interface LocalizedStringDataContribution {\n [k: string]: unknown;\n metadata?: StringsMetadata;\n localizedStrings?: {\n [k: string]: LanguageStrings;\n };\n}\n/**\n * Map whose keys are localized string keys and whose values provide additional non-locale-specific\n * information about the localized string key\n */\nexport interface StringsMetadata {\n [k: LocalizeKey]: StringMetadata;\n}\n/** Additional non-locale-specific information about a localized string key */\nexport interface StringMetadata {\n [k: string]: unknown;\n /**\n * Localized string key from which to get this value if one does not exist in the specified\n * language. If a new key/value pair needs to be made to replace an existing one, this could help\n * smooth over the transition if the meanings are close enough\n *\n * You can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a\n * backslash `\\`.\n */\n fallbackKey?: LocalizeKey;\n /**\n * Additional information provided by developers in English to help the translator to know how to\n * translate this localized string accurately\n */\n notes?: string;\n /**\n * If this property is filled, the localized string is deprecated. Contains information about the\n * deprecation.\n */\n deprecationInfo?: LocalizedStringDeprecationInfo;\n}\n/**\n * Contains information about the deprecation of a localized string key, including the date of\n * deprecation and the reason.\n */\nexport interface LocalizedStringDeprecationInfo {\n [k: string]: unknown;\n /**\n * Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\n *\n * Tested against regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\n date: DateYYYYMMDD;\n /**\n * Should contain the reason for deprecation and what to use instead in what contexts.\n *\n * @example Reworded to clarify the meaning. Use %my_key_2% instead.\n */\n message: string;\n}\n/**\n * Map whose keys are localized string keys and whose values provide information about how to\n * localize strings for the localized string key\n */\nexport interface LanguageStrings {\n [k: LocalizeKey]: LocalizedStringValue;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n\nconst localizedStringsDefs = {\n languageStrings: {\n description:\n 'Map whose keys are localized string keys and whose values provide information about how to localize strings for the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/localizedStringValue',\n },\n },\n additionalProperties: false,\n },\n localizedStringValue: {\n description: 'Localized string value associated with this key',\n type: 'string',\n },\n stringsMetadata: {\n description:\n 'Map whose keys are localized string keys and whose values provide additional non-locale-specific information about the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/stringMetadata',\n },\n },\n additionalProperties: false,\n },\n stringMetadata: {\n description: 'Additional non-locale-specific information about a localized string key',\n type: 'object',\n properties: {\n fallbackKey: {\n description:\n 'Localized string key from which to get this value if one does not exist in the specified language. If a new key/value pair needs to be made to replace an existing one, this could help smooth over the transition if the meanings are close enough.\\nYou can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a backslash `\\\\`.',\n type: 'string',\n pattern: \"^%[\\\\w\\\\-\\\\.;&,' (){}#:/\\\\\\\\?%⋮|[\\\\]“”‘’!~*\\u00A0+=•`…\\u200B↑↓]+%$\",\n tsType: 'LocalizeKey',\n },\n notes: {\n description:\n 'Additional information provided by developers in English to help the translator to know how to translate this localized string accurately',\n type: 'string',\n },\n deprecationInfo: {\n description:\n 'If this property is filled, the localized string is deprecated. Contains information about the deprecation.',\n $ref: '#/$defs/localizedStringDeprecationInfo',\n },\n },\n },\n localizedStringDeprecationInfo: {\n description:\n 'Date of deprecation, the reason for deprecation, and what to use instead in what contexts',\n type: 'object',\n properties: {\n date: {\n description:\n 'Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\\n\\nTested against regex `^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\\n\\nThanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.',\n type: 'string',\n pattern: '^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$',\n tsType: 'DateYYYYMMDD',\n },\n message: {\n description:\n 'Should contain the reason for deprecation and what to use instead in what contexts.\\n\\n@example Reworded to clarify the meaning. Use %my_key_2% instead.',\n type: 'string',\n },\n },\n required: ['date', 'message'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(localizedStringsDefs);\n\n/** JSON schema object that aligns with the LocalizedStringDataContribution type */\nexport const localizedStringsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Localized String Data Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the localized strings it provides.',\n type: 'object',\n properties: {\n metadata: {\n $ref: '#/$defs/stringsMetadata',\n },\n localizedStrings: {\n type: 'object',\n additionalProperties: {\n $ref: '#/$defs/languageStrings',\n },\n },\n },\n $defs: localizedStringsDefs,\n};\n\nObject.freeze(localizedStringsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { ReplaceType } from '../util';\n\n/** Identifier for a string that will be localized in a menu based on the user's UI language */\nexport type LocalizeKey = `%${string}%`;\n\n/** Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command) */\nexport type ReferencedItem = `${string}.${string}`;\n\nexport type OrderedItem = {\n /** Relative order of this item compared to other items in the same parent/scope (sorted ascending) */\n order: number;\n};\n\nexport type OrderedExtensibleContainer = OrderedItem & {\n /** Determines whether other items can be added to this after it has been defined */\n isExtensible?: boolean;\n};\n\n/** Group of menu items that belongs in a column */\nexport type MenuGroupDetailsInColumn = OrderedExtensibleContainer & {\n /** ID of column in which this group resides */\n column: ReferencedItem;\n};\n\n/** Group of menu items that belongs in a submenu */\nexport type MenuGroupDetailsInSubMenu = OrderedExtensibleContainer & {\n /** ID of menu item hosting the submenu in which this group resides */\n menuItem: ReferencedItem;\n};\n\n/** Column that includes header text in a menu */\nexport type MenuColumnWithHeader = OrderedExtensibleContainer & {\n /** Key that represents the text of the header text of the column */\n label: LocalizeKey;\n};\n\nexport type MenuItemBase = OrderedItem & {\n /** Menu group to which this menu item belongs */\n group: ReferencedItem;\n /** Key that represents the text of this menu item to display */\n label: LocalizeKey;\n /** Key that represents words the platform should reference when users are searching for menu items */\n searchTerms?: LocalizeKey;\n /** Key that represents the text to display if a mouse pointer hovers over the menu item */\n tooltip?: LocalizeKey;\n /** Additional information provided by developers to help people who perform localization */\n localizeNotes: string;\n};\n\n/** Menu item that hosts a submenu */\nexport type MenuItemContainingSubmenu = MenuItemBase & {\n /** ID for this menu item that holds a submenu */\n id: ReferencedItem;\n};\n\n/** Menu item that runs a command */\nexport type MenuItemContainingCommand = MenuItemBase & {\n /** Name of the PAPI command to run when this menu item is selected. */\n command: ReferencedItem;\n /**\n * Uri path to the icon to display after the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathAfter?: string;\n /**\n * Uri path to the icon to display before the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathBefore?: string;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single context menu/submenu.\n * Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInSingleColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: OrderedExtensibleContainer | MenuGroupDetailsInSubMenu;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single menu/submenu within a\n * multi-column menu. Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInMultiColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: MenuGroupDetailsInColumn | MenuGroupDetailsInSubMenu;\n};\n\n/** Group of columns that can be combined with other columns to form a multi-column menu */\nexport type ColumnsWithHeaders = {\n /** Named column of a menu */\n [property: ReferencedItem]: MenuColumnWithHeader;\n /** Defines whether columns can be added to this multi-column menu */\n isExtensible?: boolean;\n};\n\n/** Menu that contains a column without a header */\nexport type SingleColumnMenu = {\n /** Groups that belong in this menu */\n groups: GroupsInSingleColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menu that contains multiple columns with headers */\nexport type MultiColumnMenu = {\n /** Columns that belong in this menu */\n columns: ColumnsWithHeaders;\n /** Groups that belong in this menu */\n groups: GroupsInMultiColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menus for one single web view */\nexport type WebViewMenu = {\n /** Indicates whether the platform default menus should be included for this webview */\n includeDefaults: boolean | undefined;\n /** Menu that opens when you click on the top left corner of a tab */\n topMenu: MultiColumnMenu | undefined;\n /** Menu that opens when you right click on the main body/area of a tab */\n contextMenu: SingleColumnMenu | undefined;\n};\n\n/** Menus for all web views */\nexport type WebViewMenus = {\n /** Named web view */\n [property: ReferencedItem]: WebViewMenu;\n};\n\n/** Platform.Bible menus before they are localized */\nexport type PlatformMenus = {\n /** Top level menu for the application */\n mainMenu: MultiColumnMenu;\n /** Menus that apply per web view in the application */\n webViewMenus: WebViewMenus;\n /** Default context menu for web views that don't specify their own */\n defaultWebViewContextMenu: SingleColumnMenu;\n /** Default top menu for web views that don't specify their own */\n defaultWebViewTopMenu: MultiColumnMenu;\n};\n\n/**\n * Type that converts any menu type before it is localized to what it is after it is localized. This\n * can be applied to any menu type as needed.\n */\nexport type Localized = ReplaceType, ReferencedItem, string>;\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n/** JSON schema object that aligns with the PlatformMenus type */\nexport const menuDocumentSchema = {\n title: 'Platform.Bible menus',\n type: 'object',\n properties: {\n mainMenu: {\n description: 'Top level menu for the application',\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewTopMenu: {\n description: \"Default top menu for web views that don't specify their own\",\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewContextMenu: {\n description: \"Default context menu for web views that don't specify their own\",\n $ref: '#/$defs/singleColumnMenu',\n },\n webViewMenus: {\n description: 'Menus that apply per web view in the application',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/menusForOneWebView',\n },\n },\n additionalProperties: false,\n },\n },\n required: ['mainMenu', 'defaultWebViewTopMenu', 'defaultWebViewContextMenu', 'webViewMenus'],\n additionalProperties: false,\n $defs: {\n localizeKey: {\n description:\n \"Identifier for a string that will be localized in a menu based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n },\n referencedItem: {\n description:\n 'Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command)',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n },\n columnsWithHeaders: {\n description:\n 'Group of columns that can be combined with other columns to form a multi-column menu',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single column with a header string',\n type: 'object',\n properties: {\n label: {\n description: 'Header text for this this column in the UI',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n order: {\n description:\n 'Relative order of this column compared to other columns (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu groups to this column',\n type: 'boolean',\n },\n },\n required: ['label', 'order'],\n additionalProperties: false,\n },\n },\n properties: {\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add columns to this multi-column menu',\n type: 'boolean',\n },\n },\n },\n menuGroups: {\n description:\n 'Group of menu items that can be combined with other groups to form a single menu/submenu. Groups are separated using a line within the menu/submenu.',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single group that contains menu items',\n type: 'object',\n oneOf: [\n {\n properties: {\n column: {\n description:\n 'Column where this group belongs, not required for single column menus',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['order'],\n additionalProperties: false,\n },\n {\n properties: {\n menuItem: {\n description: 'Menu item that anchors the submenu where this group belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['menuItem', 'order'],\n additionalProperties: false,\n },\n ],\n },\n },\n additionalProperties: false,\n },\n menuItem: {\n description:\n 'Single item in a menu that can be clicked on to take an action or can be the parent of a submenu',\n type: 'object',\n oneOf: [\n {\n properties: {\n id: {\n description: 'ID for this menu item that holds a submenu',\n $ref: '#/$defs/referencedItem',\n },\n },\n required: ['id'],\n },\n {\n properties: {\n command: {\n description: 'Name of the PAPI command to run when this menu item is selected.',\n $ref: '#/$defs/referencedItem',\n },\n iconPathBefore: {\n description:\n 'Uri path to the icon to display before the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n iconPathAfter: {\n description:\n 'Uri path to the icon to display after the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n },\n required: ['command'],\n },\n ],\n properties: {\n label: {\n description: 'Key that represents the text of this menu item to display',\n $ref: '#/$defs/localizeKey',\n },\n tooltip: {\n description:\n 'Key that represents the text to display if a mouse pointer hovers over the menu item',\n $ref: '#/$defs/localizeKey',\n },\n searchTerms: {\n description:\n 'Key that represents additional words the platform should reference when users are searching for menu items',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n group: {\n description: 'Group to which this menu item belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this menu item compared to other menu items in the same group (sorted ascending)',\n type: 'number',\n },\n },\n required: ['label', 'group', 'order'],\n unevaluatedProperties: false,\n },\n groupsAndItems: {\n description: 'Core schema for a column',\n type: 'object',\n properties: {\n groups: {\n description: 'Groups that belong in this menu',\n $ref: '#/$defs/menuGroups',\n },\n items: {\n description: 'List of menu items that belong in this menu',\n type: 'array',\n items: { $ref: '#/$defs/menuItem' },\n uniqueItems: true,\n },\n },\n required: ['groups', 'items'],\n },\n singleColumnMenu: {\n description: 'Menu that contains a column without a header',\n type: 'object',\n allOf: [{ $ref: '#/$defs/groupsAndItems' }],\n unevaluatedProperties: false,\n },\n multiColumnMenu: {\n description: 'Menu that can contain multiple columns with headers',\n type: 'object',\n allOf: [\n { $ref: '#/$defs/groupsAndItems' },\n {\n properties: {\n columns: {\n description: 'Columns that belong in this menu',\n $ref: '#/$defs/columnsWithHeaders',\n },\n },\n required: ['columns'],\n },\n ],\n unevaluatedProperties: false,\n },\n menusForOneWebView: {\n description: 'Set of menus that are associated with a single tab',\n type: 'object',\n properties: {\n includeDefaults: {\n description:\n 'Indicates whether the platform default menus should be included for this webview',\n type: 'boolean',\n },\n topMenu: {\n description: 'Menu that opens when you click on the top left corner of a tab',\n $ref: '#/$defs/multiColumnMenu',\n },\n contextMenu: {\n description: 'Menu that opens when you right click on the main body/area of a tab',\n $ref: '#/$defs/singleColumnMenu',\n },\n },\n additionalProperties: false,\n },\n },\n};\n\nObject.freeze(menuDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\nimport { LocalizeKey } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the themes it provides. */\nexport type ThemeContribution = ThemeFamiliesById;\n\n/** Object whose keys are theme family ids and whose values are {@link ThemeFamily}. */\nexport interface ThemeFamiliesById {\n [themeFamilyId: string]: ThemeFamily | undefined;\n}\n\n/**\n * A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\n *\n * A theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type\n * to determine how to look. Colors not present in the theme will fall back to the built-in colors\n * for this type.\n */\nexport interface ThemeFamily {\n [themeType: string]: ThemeDefinition | undefined;\n light?: ThemeDefinition;\n dark?: ThemeDefinition;\n}\n\n/**\n * The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark)\n * and belongs to a theme family. An extension can provide multiple themes with\n * {@link ThemeContribution}.\n */\nexport interface ThemeDefinition {\n [k: string]: unknown;\n /** LocalizeKey that is the display name for the theme */\n label: LocalizeKey;\n /**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\n cssVariables: ThemeCssVariables;\n}\n/**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\nexport interface ThemeCssVariables {\n [variableName: string]: string | undefined;\n background?: string;\n foreground?: string;\n card?: string;\n 'card-foreground'?: string;\n popover?: string;\n 'popover-foreground'?: string;\n primary?: string;\n 'primary-foreground'?: string;\n secondary?: string;\n 'secondary-foreground'?: string;\n muted?: string;\n 'muted-foreground'?: string;\n accent?: string;\n 'accent-foreground'?: string;\n destructive?: string;\n 'destructive-foreground'?: string;\n border?: string;\n input?: string;\n ring?: string;\n 'sidebar-background'?: string;\n 'sidebar-foreground'?: string;\n 'sidebar-primary'?: string;\n 'sidebar-primary-foreground'?: string;\n 'sidebar-accent'?: string;\n 'sidebar-accent-foreground'?: string;\n 'sidebar-border'?: string;\n 'sidebar-ring'?: string;\n radius?: string;\n}\n\nconst themeDefs = {\n themeCssVariables: {\n description:\n \"Theme colors and other CSS variable properties that adjust the looks of the application. These are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like `tw-bg-primary`\\n\\nSee the wiki's [Matching Application Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme) section for more information.\",\n type: 'object',\n properties: {\n background: { type: 'string' },\n foreground: { type: 'string' },\n card: { type: 'string' },\n 'card-foreground': { type: 'string' },\n popover: { type: 'string' },\n 'popover-foreground': { type: 'string' },\n primary: { type: 'string' },\n 'primary-foreground': { type: 'string' },\n secondary: { type: 'string' },\n 'secondary-foreground': { type: 'string' },\n muted: { type: 'string' },\n 'muted-foreground': { type: 'string' },\n accent: { type: 'string' },\n 'accent-foreground': { type: 'string' },\n destructive: { type: 'string' },\n 'destructive-foreground': { type: 'string' },\n border: { type: 'string' },\n input: { type: 'string' },\n ring: { type: 'string' },\n 'sidebar-background': { type: 'string' },\n 'sidebar-foreground': { type: 'string' },\n 'sidebar-primary': { type: 'string' },\n 'sidebar-primary-foreground': { type: 'string' },\n 'sidebar-accent': { type: 'string' },\n 'sidebar-accent-foreground': { type: 'string' },\n 'sidebar-border': { type: 'string' },\n 'sidebar-ring': { type: 'string' },\n radius: { type: 'string' },\n },\n additionalProperties: { anyOf: [{ type: 'string' }, { type: 'null' }] },\n },\n themeDefinition: {\n description:\n 'The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark) and belongs to a theme family. An extension can provide multiple themes with {@link ThemeContribution}.',\n type: 'object',\n properties: {\n label: {\n description: 'LocalizeKey that is the display name for the theme',\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n cssVariables: {\n $ref: '#/$defs/themeCssVariables',\n },\n },\n required: ['label', 'cssVariables'],\n },\n themeFamily: {\n description:\n 'A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\\n\\nA theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to look. Colors not present in the theme will fall back to the built-in colors for this type.',\n type: 'object',\n properties: {\n light: {\n $ref: '#/$defs/themeDefinition',\n },\n dark: {\n $ref: '#/$defs/themeDefinition',\n },\n },\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeDefinition',\n },\n { type: 'null' },\n ],\n },\n },\n themeFamiliesById: {\n description: 'Object whose keys are theme family ids and whose values are {@link ThemeFamily}.',\n type: 'object',\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeFamily',\n },\n { type: 'null' },\n ],\n },\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(themeDefs);\n\n// JSON schema object for ThemeContribution\nexport const themeDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Theme Contribution',\n description: 'The data an extension provides to inform Platform.Bible of the themes it provides.',\n anyOf: [\n {\n $ref: '#/$defs/themeFamiliesById',\n },\n ],\n $defs: themeDefs,\n};\n\nObject.freeze(themeDocumentSchema);\n","import { ReplaceType } from '../util';\nimport { ThemeDefinition, ThemeFamiliesById, ThemeFamily } from './theme.model';\n\n/**\n * {@link ThemeDefinition} with some additional properties derived from the {@link ThemeFamiliesById}\n * it comes from to help with managing the theme\n */\nexport type ThemeDefinitionExpanded = ThemeDefinition & {\n /**\n * Unique identifier for the {@link ThemeFamily} this theme is in.\n *\n * This is derived from the key of the {@link ThemeFamiliesById} this theme is in\n */\n themeFamilyId: string;\n /**\n * The kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to\n * look. Colors not present in the theme will fall back to the built-in colors for this type.\n *\n * This is derived from the key of the {@link ThemeFamily} this theme is in\n */\n type: string;\n /**\n * Unique identifier for this theme.\n *\n * This is derived by combining the theme family and type\n */\n id: string;\n};\n\n/**\n * Replaces {@link ThemeDefinition} with {@link ThemeDefinitionExpanded} recursively in the provided\n * type. Modifies the type to what is used in the theme service.\n */\nexport type ExpandThemeDefinition = ReplaceType;\n\n/**\n * {@link ThemeFamily} with all {@link ThemeDefinition} replaced by {@link ThemeDefinitionExpanded}.\n * This is used in the theme service\n */\nexport type ThemeFamilyExpanded = ExpandThemeDefinition;\n\n/**\n * {@link ThemeFamiliesById} with all {@link ThemeDefinition} replaced by\n * {@link ThemeDefinitionExpanded}. This is used in the theme service\n */\nexport type ThemeFamiliesByIdExpanded = ExpandThemeDefinition;\n\n/** ID for the style element the theme styles should go into */\nexport const THEME_STYLE_ELEMENT_ID = 'theme-styles';\n\nfunction getThemeId(themeFamilyId: string, type: string) {\n return `${themeFamilyId ? `${themeFamilyId}-` : ''}${type}`;\n}\n\n/**\n * Add the derived properties in {@link ThemeDefinitionExpanded} to {@link ThemeDefinition}s in the\n * given {@link ThemeFamiliesById} and fill in any missing `cssVariables` in the theme definitions\n * with those from the default themes.\n *\n * Does not modify the input object.\n *\n * @param themeFamiliesById Theme families to expand with the additional derived properties\n * @param defaultThemeFamily If provided, themes from this family are used to fill in missing\n * `cssVariables` in the theme definitions to make sure each theme definition has all necessary\n * `cssVariables`\n * @returns The expanded theme families\n */\nexport function expandThemeContribution(\n themeFamiliesById: ThemeFamiliesById,\n defaultThemeFamily: ThemeFamily | undefined,\n): ThemeFamiliesByIdExpanded {\n const themeFamiliesByIdExpanded: ThemeFamiliesByIdExpanded = Object.fromEntries(\n Object.entries(themeFamiliesById)\n .map(([themeFamilyId, themeFamily]) => [\n themeFamilyId,\n themeFamily\n ? Object.fromEntries(\n Object.entries(themeFamily)\n .map(([type, themeDefinition]): [string, ThemeDefinitionExpanded | undefined] => [\n type,\n themeDefinition\n ? {\n ...themeDefinition,\n // Add the derived properties\n themeFamilyId,\n type,\n id: getThemeId(themeFamilyId, type),\n cssVariables: {\n // Fill in the default css variables\n ...defaultThemeFamily?.[type]?.cssVariables,\n ...themeDefinition.cssVariables,\n },\n }\n : undefined,\n ])\n .filter(([, themeDefinition]) => !!themeDefinition),\n )\n : undefined,\n ])\n .filter(([, themeFamily]) => !!themeFamily),\n );\n return themeFamiliesByIdExpanded;\n}\n\n/** Gets the CSS stylesheet that should be applied for the given theme */\nexport function getStylesheetForTheme(theme: ThemeDefinitionExpanded): string {\n return `\n.${theme.id} {\n${Object.entries(theme.cssVariables)\n .map(([variableName, value]) => ` --${variableName}: ${value};`)\n .join('\\n')}\n}\n`;\n}\n\n/**\n * Applies a CSS stylesheet for the provided theme to the current window\n *\n * WARNING: THIS MUST BE BOUND TO `window` IN ORDER TO USE!\n *\n * ```ts\n * applyThemeStylesheet.bind(window)()`\n * ```\n *\n * @param theme Theme to apply\n * @param previousStyleElement Previous style element if applicable\n * @param styleElementIdSuffix Suffix to apply to the ID of the new style element. Will be\n * {@link THEME_STYLE_ELEMENT_ID} with a dash and the suffix added to it\n * @returns\n */\n// Must use `this` so it works across iframes\nexport function applyThemeStylesheet(\n this: Window,\n theme: ThemeDefinitionExpanded,\n previousStyleElement?: HTMLStyleElement,\n styleElementIdSuffix?: string,\n): HTMLStyleElement {\n // Set the class on the body\n const previousThemeId = previousStyleElement?.dataset.themeId;\n if (previousThemeId) this.document.body.classList.remove(previousThemeId);\n this.document.body.classList.add(theme.id);\n\n // Set up the stylesheet element\n if (previousStyleElement) this.document.head.removeChild(previousStyleElement);\n const themeStyleElement = this.document.createElement('style');\n themeStyleElement.id = `${THEME_STYLE_ELEMENT_ID}${styleElementIdSuffix ? `-${styleElementIdSuffix}` : ''}`;\n themeStyleElement.dataset.themeId = theme.id;\n themeStyleElement.textContent = getStylesheetForTheme(theme);\n this.document.head.appendChild(themeStyleElement);\n return themeStyleElement;\n}\n","/**\n * Information about a USFM marker that is just an attribute in USX/USJ. See {@link MarkerInfo} for\n * other kinds of markers.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker instead in USX/USJ.\n *\n * @example `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for\n * `v`. `cat` is an attribute marker for `f`, `esb`, and more.\n *\n * Following is an example of using the `ca` and `cp` attribute markers in USFM:\n *\n * ```usfm\n * \\c 1 \\ca 2\\ca*\n * \\cp A\n * \\s1 This is a section header\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * This is a section header\n * ```\n */\nexport type AttributeMarkerInfo = NormalMarkerInfo & {\n /**\n * List of normal marker names for which this marker is an attribute marker.\n *\n * @example `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']`\n * for both `ca` and `cp`.\n */\n isAttributeMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an attribute marker.\n *\n * @example Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`.\n * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isAttributeMarkerForRegExp?: string[];\n /**\n * The name of the USX/USJ attribute this attribute marker represents.\n *\n * @example `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the\n * `c` marker in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca`\n * marker.\n */\n attributeMarkerAttributeName: string;\n /**\n * Whether there should be a structural space after the normal closing marker in output USFM if\n * this marker is an attribute marker. If this marker is not an attribute marker, it should not\n * have a structural space after the normal closing marker.\n *\n * This field should be ignored if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `true`\n * because this space is only supposed to be added in contexts in which the space here is\n * structural. Otherwise we would be mistakenly adding content to the USFM.\n *\n * Note that, if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `false` (which is the\n * case according to spec), horizontal spaces after attribute markers are always considered\n * structural; this property only indicates whether there should be a space after the attribute\n * marker when outputting USFM as opposed to parsing it.\n *\n * If not present or `undefined`, defaults to `false`.\n *\n * @example According to specification, the `va` and `vp` attribute markers have a space after\n * their normal closing markers:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp 10 vp\\vp* Some verse text\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n *\n * However, when the `vp` marker is not an attribute marker, such as when it has markers in its\n * contents, there should not be a structural space after the normal closing marker, and any space\n * should be considered content:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp \\+wj 10 vp\\+wj*\\vp* Some verse text.\n * ```\n *\n * The verse text in this example is \" Some verse text\" including a space at the start.\n *\n * @example The `cat` attribute marker does not have a structural space after its normal closing\n * marker:\n *\n * ```usfm\n * \\f + \\cat category here\\cat*\\fr 1:2 \\ft Some footnote text\\f*\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n */\n hasStructuralSpaceAfterCloseAttributeMarker?: boolean;\n};\n\n/**\n * Information about a regular USFM/USX/USJ marker. See {@link MarkerInfo} for other kinds of\n * markers.\n */\nexport type NormalMarkerInfo = {\n /**\n * Which marker type the marker is. Determines how the marker is structured in the data such as\n * what kind of mandatory whitespace is around the marker in USFM. See {@link MarkerTypeInfoBase}\n * for information.\n */\n type: string;\n /** Explanation of the meaning of this marker */\n description?: string;\n /**\n * Which attribute can be provided without specifying the attribute name in USFM.\n *\n * A marker can have a default attribute only if it has zero or one non-optional attributes.\n *\n * An attribute can be provided with default syntax in the USFM only if it is the only attribute\n * provided for the marker.\n *\n * @example A marker with a default attribute:\n *\n * ```usfm\n * \\w stuff|thisIsTheLemmaDefaultAttribute\\w*\n * ```\n *\n * @example A marker with multiple attributes (cannot use default attribute syntax):\n *\n * ```usfm\n * \\w stuff|lemma=\"thisIsTheLemma\" strong=\"H1234,G1234\"\\w*\n * ```\n */\n defaultAttribute?: string;\n /**\n * The name of the text content attribute that is present on this marker if this marker has text\n * content in USFM.\n *\n * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual\n * text content of the marker.\n *\n * @example `alt` is a text content attribute on the `periph` marker. This value would be `alt`\n * for the `periph` marker.\n *\n * Following is an example of a `periph` marker in USFM:\n *\n * ```usfm\n * \\periph Example Peripheral|id=\"x-example\"\n * \\p Some contents of the example peripheral\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * Some contents of the example peripheral\n * \n * ```\n */\n textContentAttribute?: string;\n /**\n * List of leading attributes that must be present on this marker. This list is ordered by the\n * order in which the attributes should appear.\n *\n * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker\n * and separated only by a space.\n *\n * @example `code` is a leading attribute on the `id` marker. This value would be `['code']` for\n * the `id` marker.\n *\n * Following is an example of an `id` marker in USFM:\n *\n * ```usfm\n * \\id MAT 41MATEX.SFM, Example Translation, September 2025\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * 41MATEX.SFM, Example Translation, September 2025\n * ```\n */\n leadingAttributes?: string[];\n /**\n * List of attribute markers that may be present on this marker. This list is ordered by the order\n * in which the markers should appear.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker in USX/USJ.\n *\n * Note: the attribute names for attribute markers may be different than the marker names. See\n * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information.\n *\n * @example `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for\n * `c`.\n */\n attributeMarkers?: string[];\n /**\n * Whether the normal closing marker for this marker is considered optional in USFM, meaning in\n * some cases that the normal closing marker would be expected not to be present.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `true`, this marker\n * may or may not be expected to have a normal closing marker actually present in USFM depending\n * on the value of this property.\n *\n * - If this is `true`, the normal closing marker for this marker in USFM may be expected to be\n * present or absent depending on the value of\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}. If\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `true`, this marker is expected to\n * have the normal closing marker actually present in USFM just like markers for which this\n * property is `false`. If {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `false`,\n * this marker is expected not to have the normal closing marker actually present in USFM. The\n * `closed` attribute should be present if the presence of a normal closing marker for this\n * marker in USFM does not match the presence implied by\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}.\n * - If this is `false`, the normal closing marker for this marker in USFM is expected to always be\n * present. If the normal closing marker is absent in USFM, the USX/USJ for this marker should\n * have the attribute `closed` set to `false`.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `false`, this\n * property is unused; markers of that type do not have a normal closing marker.\n *\n * If not present or `undefined`, defaults to `false`\n */\n isClosingMarkerOptional?: boolean;\n /**\n * List of independent closing marker names for this marker in USFM if it has any. If this is\n * defined, this marker does not have a normal closing marker but rather is closed by a completely\n * separate marker in USFM. All contents between this marker and the independent closing marker\n * are contents of this marker. In USX and USJ, this marker is closed normally like any other\n * object because USX and USJ have clear hierarchical structure.\n *\n * Note that independent closing markers do not have a `*` at the end because they are not normal\n * closing marker for but rather are completely separate markers that close the corresponding\n * opening marker.\n *\n * @example `esb` (a sidebar) is closed by the independent closing marker `esbe`.\n * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a\n * sidebar:\n *\n * ```usfm\n * \\esb\n * \\p This paragraph is in a \\bd sidebar\\bd*.\n * \\p The sidebar can contain multiple paragraphs.\n * \\esbe\n * ```\n */\n independentClosingMarkers?: string[];\n /**\n * List of marker names for which this marker is an independent closing marker. See\n * {@link NormalMarkerInfo.independentClosingMarker} for more information on independent closing\n * markers and their syntax.\n *\n * @example `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor`\n * would be `['esb']` for `esbe`.\n */\n isIndependentClosingMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an independent closing\n * marker. See {@link NormalMarkerInfo.independentClosingMarker} for more information on\n * independent closing markers and their syntax.\n *\n * @example Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp\n * `/test/`. `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isIndependentClosingMarkerForRegExp?: string[];\n /**\n * Marker to use when operating on the USFM representation of this marker. For example, when\n * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used\n * instead of the marker info for the marker as listed in USX or USJ.\n *\n * @example When the `usx` marker is output to USFM, it should be transformed to the `usfm`\n * marker.\n */\n markerUsfm?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker when\n * transforming from USFM to USX or USJ. These instructions are an explanation of what needs to be\n * done to this marker to properly transform it to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker that is essential for proper translation between formats.\n *\n * @example `w` is a `char`-type marker, so it shares the characteristics of the `char`\n * {@link MarkerTypeInfo} with other `char`-type markers and has its own set of characteristics.\n * `w`'s `MarkerInfo` is as follows:\n *\n * ```json\n * {\n * \"type\": \"char\",\n * \"defaultAttribute\": \"lemma\"\n * }\n * ```\n */\nexport type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo;\n\n/**\n * Information about a USFM/USX/USJ marker type that has a closing marker. See {@link MarkerTypeInfo}\n * for other kinds of marker types.\n *\n * If the marker type has a closing marker but the closing marker is not present in the USFM for a\n * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to\n * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`.\n *\n * @example `char` marker types such as `nd` markers have closing markers, but `para` markers such\n * as `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type CloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable: true;\n /**\n * Whether the closing marker for markers of this type is \"empty\" in USFM, meaning the marker name\n * is absent from the closing marker. This also means that there should not be a structural space\n * between the opening and the closing markers in USFM if there are no attributes listed on the\n * marker.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker:\n *\n * ```usfm\n * \\qt1-s\\*\n * ...\n * \\qt1-e\\*\n * ```\n *\n * The closing marker for `qt1-s` is `\\*` as opposed to the closing marker for `nd` which is\n * `\\nd*`.\n *\n * Note that there is still a structural space after the opening marker if there are attributes\n * present:\n *\n * ```usfm\n * \\qt1-s |Someone\\*\n * ...\n * \\qt1-e\\*\n * ```\n */\n isClosingMarkerEmpty?: boolean;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that does not have a closing marker. See\n * {@link MarkerTypeInfo} for other kinds of marker types.\n *\n * @example `char` marker types such as `nd` markers have closing markers, but `para` marker types\n * such as `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type NonCloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable?: false;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is common to all marker types. See\n * {@link MarkerTypeInfo} for various kinds of marker types.\n */\nexport type MarkerTypeInfoBase = {\n /** Explanation of the meaning of this marker type */\n description?: string;\n /**\n * Whether markers of this type should have a `style` attribute in USX/USJ.\n *\n * If this is `false`, it also means the marker type is the same as the marker name.\n *\n * If not present or `undefined`, defaults to `true`.\n */\n hasStyleAttribute?: boolean;\n /**\n * List of attributes that should not be output to USFM on markers of this type.\n *\n * This is used for attributes that are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example The `sid` attribute on the `verse` type marker is not present in USFM because it is\n * derived metadata in USX/USJ and is not present in USFM.\n */\n skipOutputAttributeToUsfm?: string[];\n /**\n * List of attributes indicating whether to skip outputting this marker to USFM. If any of the\n * listed attributes is present on the marker, skip outputting this marker when converting to\n * USFM. Only skip outputting the opening and closing marker representations, though; the content\n * inside the marker (if present) should not be skipped.\n *\n * This is used for certain markers that sometimes are normal markers but sometimes are derived\n * metadata and are not present in USFM. These derived metadata markers are identified by whether\n * they have specific attributes on them.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the\n * end of the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the\n * `verse` marker does not have the `style=\"v\"` attribute in this situation, so this list of\n * attributes is on the marker type.\n *\n * Following is an example of a derived metadata `verse` marker in USX:\n *\n * ```xml\n * \n * \n * This is verse 21.\n * \n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\p\n * \\v 21 This is verse 21.\n * ```\n *\n * @example Generated `ref`s should be skipped but have content inside the marker that should not\n * be skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have\n * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived\n * metadata have the `gen` attribute set to `\"true\"` and can be removed if `gen=\"true\"` is\n * present.\n *\n * Following is an example of a generated `ref` in USX:\n *\n * ```xml\n * \n * 2Sam 1:1; 2Sam 1:2-3.\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\xt 2Sam 1:1; 2Sam 1:2-3.\\xt*\n * ```\n */\n skipOutputMarkerToUsfmIfAttributeIsPresent?: string[];\n /**\n * Whether to always skip outputting this marker when converting to USFM. Only skip outputting the\n * opening and closing marker representations, though; the content inside the marker (if present)\n * should not be skipped.\n *\n * This is used for marker types that have no representation in USFM in a given version, likely\n * meaning they are derived metadata and are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ\n * and is not preserved when transforming from USX/USJ to USFM.\n *\n * Following is an example of a derived metadata `table` marker in USX:\n *\n * ```xml\n * \n * \n * \n * Header 1\n * Header 2 space after \n * Header 3-4 centered\n * Header 5 right\n * \n * \n * Row 1 cell 1\n * Row 1 cell 2 space after \n * Row 1 cell 3 centered\n * Row 1 cell 4-5 right\n * \n * \n * Row 2 cell 1-4 right\n * Row 2 cell 5\n * \n *
\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\tr \\th1 Header 1\\th2 Header 2 space after \\thc3-4 Header 3-4 centered\\thr5 Header 5 right\n * \\tr \\tc1 Row 1 cell 1\\tc2 Row 1 cell 2 space after \\thc3 Row 1 cell 3 centered\\thr4-5 Row 1 cell 4-5 right\n * \\tr \\tcr1-4 Row 2 cell 1-4 right\\tc5 Row 2 cell 5\n * ```\n */\n skipOutputMarkerToUsfm?: boolean;\n /**\n * Whether markers of this type should have a newline before them in USFM.\n *\n * Note that the newline is never strictly necessary, and it is not usually present if the very\n * first marker in the file (or in examples such as the following example) should have a newline.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example `para` marker types such as `p` should have a newline, but `char` marker types such as\n * `nd` markers should not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\n hasNewlineBefore?: boolean;\n /**\n * Marker type to use when operating on the USFM representation of markers of this type. For\n * example, when outputting to USFM, the marker type listed here in `markerTypeUsfm` should be\n * used instead of the marker's type as listed in USX or USJ.\n */\n markerTypeUsfm?: string;\n /**\n * Marker type to use when operating on the USX representation of markers of this type. For\n * example, when outputting to USX, the marker type listed here in `markerTypeUsx` should be used\n * instead of the marker's type as listed in USFM or USJ.\n */\n markerTypeUsx?: string;\n /**\n * Marker type to use when operating on the USJ representation of markers of this type. For\n * example, when outputting to USJ, the marker type listed here in `markerTypeUsj` should be used\n * instead of the marker's type as listed in USFM or USX.\n */\n markerTypeUsj?: string;\n /**\n * Prefix to add to the opening and closing marker before the marker name if a marker of this type\n * occurs within another marker of this type when outputting to USFM.\n *\n * @example In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is\n * an example of `nd` inside `wj` (both are `char`-type markers) in USFM:\n *\n * ```usfm\n * \\p \\wj This is \\+nd nested\\+nd*!\\wj*\n * ```\n */\n nestedPrefix?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming to USFM. These instructions are an explanation of what needs to be done to\n * markers of this type to properly transform the marker to USFM.\n *\n * This property is generally only included when it is exceptionally difficult to output a marker\n * properly to USFM; the markers map attempts to use this property as little as possible, favoring\n * encoding information in other properties for more automatic transformation instead.\n */\n outputToUsfmInstructions?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming from USFM to USX or USJ. These instructions are an explanation of what needs\n * to be done to markers of this type to properly transform the marker to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is essential for proper translation between\n * formats.\n *\n * @example `char` is a marker type, which means markers like `w` whose marker type is `char` share\n * some characteristics, and each marker also has its own set of characteristics which are presented\n * with type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows:\n *\n * ```json\n * {\n * \"isCloseable\": true,\n * \"nestedPrefix\": \"+\"\n * }\n * ```\n */\nexport type MarkerTypeInfo = CloseableMarkerTypeInfo | NonCloseableMarkerTypeInfo;\n\n/** A map of all USFM/USX/USJ markers and some information about them */\nexport type MarkersMap = {\n /** Which version of USFM/USX/USJ this map represents */\n version: string;\n /** Which repository this map came from. */\n schemaRepo: string;\n /**\n * Which commit this map came from. This is necessary because the schema file seems to be\n * distributed multiple times in one release version. As such, this specifies the exact version of\n * the schema file.\n */\n schemaCommit: string;\n /**\n * Which version of the markers map types this markers map conforms to. Follows [Semantic\n * versioning](https://semver.org/); the same major version contains no breaking changes.\n */\n markersMapVersion: `1.${number}.${number}${string}`;\n /**\n * Which tag or commit in the `https://github.com/paranext/usfm-tools` repo this map is generated\n * from.\n *\n * Contains the output from `git tag --points-at HEAD` or `git rev-parse HEAD`\n *\n * Will also have a `+` at the end if there were working changes outside the `src/test-data`\n * folder when this was generated.\n */\n usfmToolsCommit: string;\n /**\n * Whether any whitespace after attribute markers and before the next content is not just\n * structural but should actually be considered part of the content of the marker.\n *\n * Structural whitespace is whitespace in the USFM that is required as part of the USFM syntax and\n * usually acts as a delimiter between markers and other things. Content whitespace is whitespace\n * in USFM that is part of the actual Scripture text or the \"content\" of the marker.\n *\n * According to specification, whitespace after attribute markers is not content but is just\n * structural.\n *\n * According to Paratext 9.4, whitespace after attribute markers is content and is not just\n * structural.\n *\n * This setting determines which interpretation to use when converting from USFM to USX/USJ.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n isSpaceAfterAttributeMarkersContent?: boolean;\n /**\n * Whether markers with optional closing markers (see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}) should still be explicitly closed in USFM.\n * That is, whether markers with optional closing markers still need the `closed` attribute set to\n * `\"false\"` in USX/USJ if the closing marker is not present in USFM.\n *\n * In other words, this setting determines whether markers with optional closing markers should\n * still be expected to be explicitly closed (meaning the closing marker is present in USFM) when\n * transforming USX/USJ to USFM unless otherwise indicated by the `closed` attribute.\n *\n * If this is `true` (matches Paratext 9.4), markers with optional closing markers are treated\n * like markers whose normal closing marker is not optional in that they are expected to be\n * explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they should have `closed=\"false\"`\n * - If they are explicitly closed in USFM, they do not need `closed=\"true\"`\n *\n * If this is `false` (matches specification), markers with optional closing markers are expected\n * _not_ to be explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they do not need `closed=\"false\"`\n * - If they are explicitly closed in USFM, they should have `closed=\"true\"`\n *\n * - Disclaimer: It is not clear that `closed=\"true\"` should be present in this case according to\n * `usx.rng`; it seems `usx.rng` indicates that optional closing markers should never be\n * output to USFM. It is possible that `usx.rng` considers this to be a case where\n * preserving the exact USFM is not important.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n shouldOptionalClosingMarkersBePresent?: boolean;\n /**\n * Map whose keys are the marker names and whose values are information about that marker\n *\n * If you find the marker name in this map, you do not need to search the `markersRegExp` map.\n */\n markers: Record;\n /**\n * Map whose keys are string representations of `RegExp` patterns to match against marker names\n * (using the\n * [test](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) and whose values are information about that marker\n *\n * You do not need to search this map if you found the marker name in the `markers` map.\n */\n markersRegExp: Record;\n /** Map whose keys are the marker types and whose values are information about that marker type */\n markerTypes: Record;\n};\n\n// This function should safely freeze anything, but TypeScript doesn't understand.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction deepFreeze(o: any) {\n Object.freeze(o);\n // Don't want to crash out on null\n // eslint-disable-next-line no-null/no-null\n if (o === undefined || o === null) {\n return o;\n }\n\n Object.getOwnPropertyNames(o).forEach(function freezeProperty(prop) {\n if (\n // Need to make sure to avoid null, which is an object type\n // eslint-disable-next-line no-null/no-null\n o[prop] !== null &&\n (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&\n !Object.isFrozen(o[prop])\n ) {\n deepFreeze(o[prop]);\n }\n });\n\n return o;\n}\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file\n */\nexport const USFM_MARKERS_MAP: MarkersMap = deepFreeze({\n version: '3.0.7',\n schemaRepo: 'https://github.com/ubsicap/usx.git',\n schemaCommit: '6c490bb5675d281b0fa01876fe67f6e3fd50a4ce',\n markersMapVersion: '1.0.0',\n usfmToolsCommit: 'b3475856e2b7c0f19739d247ae3f3c13cba66215',\n markers: {\n add: {\n type: 'char',\n description: 'For a translational addition to the text',\n },\n addpn: {\n type: 'char',\n description:\n 'For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)',\n },\n b: {\n type: 'para',\n description: 'Poetry text stanza break (e.g. stanza break)',\n },\n bd: {\n type: 'char',\n description: 'A character style, use bold text',\n },\n bdit: {\n type: 'char',\n description: 'A character style, use bold + italic text',\n },\n bk: {\n type: 'char',\n description: 'For the quoted name of a book',\n },\n c: {\n type: 'chapter',\n leadingAttributes: ['number'],\n attributeMarkers: ['ca', 'cp'],\n },\n ca: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['c'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description: 'Second (alternate) chapter number',\n },\n cat: {\n type: 'char',\n attributeMarkerAttributeName: 'category',\n isAttributeMarkerFor: ['ef', 'efe', 'esb', 'ex', 'f', 'fe', 'x'],\n description: 'Note category (study Bible)',\n },\n cd: {\n type: 'para',\n description: 'Chapter Description (Publishing option D, e.g. in Russian Bibles)',\n },\n cl: {\n type: 'para',\n description: 'Chapter label used for translations that add a word such as \"Chapter\"',\n },\n cls: {\n type: 'para',\n description: 'Closure of an Epistle',\n },\n cp: {\n type: 'para',\n description: 'Published chapter number',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['c'],\n },\n d: {\n type: 'para',\n description: 'A Hebrew text heading, to provide description (e.g. Psalms)',\n },\n dc: {\n type: 'char',\n description: 'Deuterocanonical/LXX additions or insertions in the Protocanonical text',\n },\n ef: {\n type: 'note',\n description: 'Study note',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efe: {\n type: 'note',\n description: 'Extended study endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efm: {\n type: 'char',\n description: 'Reference to caller of previous footnote in a study Bible',\n },\n em: {\n type: 'char',\n description: 'A character style, use emphasized text style',\n },\n esb: {\n type: 'sidebar',\n independentClosingMarkers: ['esbe'],\n attributeMarkers: ['cat'],\n },\n esbe: {\n type: 'sidebar',\n isIndependentClosingMarkerFor: ['esb'],\n },\n ex: {\n type: 'note',\n description: 'Extended cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n f: {\n type: 'note',\n description: 'Footnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fdc: {\n type: 'char',\n description: 'Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n fe: {\n type: 'note',\n description: 'Endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fig: {\n type: 'figure',\n },\n fk: {\n type: 'char',\n description: 'A footnote keyword',\n isClosingMarkerOptional: true,\n },\n fl: {\n type: 'char',\n description:\n 'A footnote label text item, for marking or \"labelling\" the type or alternate translation being provided in the note.',\n isClosingMarkerOptional: true,\n },\n fm: {\n type: 'char',\n description: 'Reference to caller of previous footnote',\n },\n fp: {\n type: 'char',\n description: 'A Footnote additional paragraph marker',\n isClosingMarkerOptional: true,\n },\n fq: {\n type: 'char',\n description: 'A footnote scripture quote or alternate rendering',\n isClosingMarkerOptional: true,\n },\n fqa: {\n type: 'char',\n description: 'A footnote alternate rendering for a portion of scripture text',\n isClosingMarkerOptional: true,\n },\n fr: {\n type: 'char',\n description: 'The origin reference for the footnote',\n isClosingMarkerOptional: true,\n },\n ft: {\n type: 'char',\n description: 'Footnote text, Protocanon',\n isClosingMarkerOptional: true,\n },\n fv: {\n type: 'char',\n description: 'A verse number within the footnote text',\n },\n fw: {\n type: 'char',\n description:\n 'A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.',\n isClosingMarkerOptional: true,\n },\n h: {\n type: 'para',\n description: 'Running header text for a book',\n },\n h1: {\n type: 'para',\n description: 'Running header text (DEPRECATED)',\n },\n h2: {\n type: 'para',\n description: 'Running header text, left side of page (DEPRECATED)',\n },\n h3: {\n type: 'para',\n description: 'Running header text, right side of page (DEPRECATED)',\n },\n ib: {\n type: 'para',\n description: 'Introduction blank line',\n },\n id: {\n type: 'book',\n leadingAttributes: ['code'],\n },\n ide: {\n type: 'para',\n description: 'File encoding information',\n },\n ie: {\n type: 'para',\n description: 'Introduction ending marker',\n },\n iex: {\n type: 'para',\n description:\n 'Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)',\n },\n ili: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n ili1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n ili2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n im: {\n type: 'para',\n description:\n 'Introduction prose paragraph, with no first line indent (may occur after poetry)',\n },\n imi: {\n type: 'para',\n description: 'Introduction prose paragraph text, indented, with no first line indent',\n },\n imq: {\n type: 'para',\n description:\n 'Introduction prose paragraph, quote from the body text, with no first line indent',\n },\n imt: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nIntroduction major title, level 1 - (if single level)',\n },\n imt1: {\n type: 'para',\n description: 'Introduction major title, level 1 (if multiple levels)',\n },\n imt2: {\n type: 'para',\n description: 'Introduction major title, level 2',\n },\n imt3: {\n type: 'para',\n description: 'Introduction major title, level 3',\n },\n imt4: {\n type: 'para',\n description: 'Introduction major title, level 4 (usually within parenthesis)',\n },\n imte: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if single level)',\n },\n imte1: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if multiple levels)',\n },\n imte2: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 2',\n },\n io: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if single level)',\n },\n io1: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if multiple levels)',\n },\n io2: {\n type: 'para',\n description: 'Introduction outline text, level 2',\n },\n io3: {\n type: 'para',\n description: 'Introduction outline text, level 3',\n },\n io4: {\n type: 'para',\n description: 'Introduction outline text, level 4',\n },\n ior: {\n type: 'char',\n description:\n 'Introduction references range for outline entry; for marking references separately',\n },\n iot: {\n type: 'para',\n description: 'Introduction outline title',\n },\n ip: {\n type: 'para',\n description:\n 'Introduction prose paragraph\\nDivision or Section introductory paragraph (study Bible)',\n },\n ipi: {\n type: 'para',\n description: 'Introduction prose paragraph, indented, with first line indent',\n },\n ipq: {\n type: 'para',\n description: 'Introduction prose paragraph, quote from the body text',\n },\n ipr: {\n type: 'para',\n description: 'Introduction prose paragraph, right aligned',\n },\n iq: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if single level)',\n },\n iq1: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if multiple levels)',\n },\n iq2: {\n type: 'para',\n description: 'Introduction poetry text, level 2',\n },\n iq3: {\n type: 'para',\n description: 'Introduction poetry text, level 3',\n },\n iqt: {\n type: 'char',\n },\n is: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if single level)',\n },\n is1: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if multiple levels)',\n },\n is2: {\n type: 'para',\n description: 'Introduction section heading, level 2',\n },\n it: {\n type: 'char',\n description: 'A character style, use italic text',\n },\n jmp: {\n type: 'char',\n defaultAttribute: 'link-href',\n description: 'For associating linking attributes to a span of text',\n },\n k: {\n type: 'char',\n description: 'For a keyword',\n },\n k1: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 1',\n },\n k2: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 2',\n },\n lf: {\n type: 'para',\n description: 'List footer (introductory remark)',\n },\n lh: {\n type: 'para',\n description: 'List header (introductory remark)',\n },\n li: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n li1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n li2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n li3: {\n type: 'para',\n description: 'A list entry, level 3',\n },\n li4: {\n type: 'para',\n description: 'A list entry, level 4',\n },\n lik: {\n type: 'char',\n description: 'Structured list entry key text',\n },\n lim: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if single level)',\n },\n lim1: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if multiple levels)',\n },\n lim2: {\n type: 'para',\n description: 'An embedded list entry, level 2',\n },\n lim3: {\n type: 'para',\n description: 'An embedded list entry, level 3',\n },\n lim4: {\n type: 'para',\n description: 'An embedded list entry, level 4',\n },\n lit: {\n type: 'para',\n description: 'For a comment or note inserted for liturgical use',\n },\n litl: {\n type: 'char',\n description: 'List entry total text',\n },\n liv: {\n type: 'char',\n description: 'Structured list entry value 1 content (if single value)',\n },\n liv1: {\n type: 'char',\n description: 'Structured list entrt value 1 content (if multiple values)',\n },\n liv2: {\n type: 'char',\n description: 'Structured list entry value 2 content',\n },\n liv3: {\n type: 'char',\n description: 'Structured list entry value 3 content',\n },\n liv4: {\n type: 'char',\n description: 'Structured list entry value 4 content',\n },\n liv5: {\n type: 'char',\n description: 'Structured list entry value 5 content',\n },\n m: {\n type: 'para',\n description:\n 'Paragraph text, with no first line indent (may occur after poetry) aka: Paragraph Continuation',\n },\n mi: {\n type: 'para',\n description: 'Paragraph text, indented, with no first line indent; often used for discourse',\n },\n mr: {\n type: 'para',\n description: 'A major section division references range heading',\n },\n ms: {\n type: 'para',\n description: 'A major section division heading, level 1 (if single level)',\n },\n ms1: {\n type: 'para',\n description: 'A major section division heading, level 1 (if multiple levels)',\n },\n ms2: {\n type: 'para',\n description: 'A major section division heading, level 2',\n },\n ms3: {\n type: 'para',\n description: 'A major section division heading, level 3',\n },\n mt: {\n type: 'para',\n description: 'The main title of the book (if single level)',\n },\n mt1: {\n type: 'para',\n description: 'The main title of the book (if multiple levels)',\n },\n mt2: {\n type: 'para',\n description: 'A secondary title usually occurring before the main title',\n },\n mt3: {\n type: 'para',\n description: 'A tertiary title occurring after the main title',\n },\n mt4: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nA small secondary title sometimes occuring within parentheses',\n },\n mte: {\n type: 'para',\n description:\n 'The main title of the book repeated at the end of the book, level 1 (if single level)',\n },\n mte1: {\n type: 'para',\n description:\n 'The main title of the book repeat /ed at the end of the book, level 1 (if multiple levels)',\n },\n mte2: {\n type: 'para',\n description: \"A secondary title occurring before or after the 'ending' main title\",\n },\n nb: {\n type: 'para',\n description:\n 'Paragraph text, with no break from previous paragraph text (at chapter boundary)',\n },\n nd: {\n type: 'char',\n description: 'For name of deity',\n },\n ndx: {\n type: 'char',\n description: 'A subject index text item',\n },\n no: {\n type: 'char',\n description: 'A character style, use normal text',\n },\n optbreak: {\n type: 'optbreak',\n },\n ord: {\n type: 'char',\n description: 'For the text portion of an ordinal number',\n },\n p: {\n type: 'para',\n description:\n 'Paragraph text, with first line indent\\nFront or back matter text paragraph, level 1',\n },\n p1: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 1 (if multiple levels)',\n },\n p2: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 2 (if multiple levels)',\n },\n pb: {\n type: 'para',\n description:\n \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n },\n pc: {\n type: 'para',\n description: 'Inscription (paragraph text centered)',\n },\n periph: {\n type: 'periph',\n textContentAttribute: 'alt',\n },\n ph: {\n type: 'para',\n description:\n 'Paragraph text, with level 1 hanging indent (if single level) (DEPRECATED - use para@style li#)',\n },\n ph1: {\n type: 'para',\n description: 'Paragraph text, with level 1 hanging indent (if multiple levels)',\n },\n ph2: {\n type: 'para',\n description: 'Paragraph text, with level 2 hanging indent',\n },\n ph3: {\n type: 'para',\n description: 'Paragraph text, with level 3 hanging indent',\n },\n pi: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse',\n },\n pi1: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse',\n },\n pi2: {\n type: 'para',\n description:\n 'Paragraph text, level 2 indent, with first line indent; often used for discourse',\n },\n pi3: {\n type: 'para',\n description:\n 'Paragraph text, level 3 indent, with first line indent; often used for discourse',\n },\n pm: {\n type: 'para',\n description: 'Embedded text paragraph',\n },\n pmc: {\n type: 'para',\n description: 'Embedded text closing',\n },\n pmo: {\n type: 'para',\n description: 'Embedded text opening',\n },\n pmr: {\n type: 'para',\n description: 'Embedded text refrain',\n },\n pn: {\n type: 'char',\n description: 'For a proper name',\n },\n png: {\n type: 'char',\n description: 'For a geographic proper name',\n },\n po: {\n type: 'para',\n description: 'Letter opening',\n },\n pr: {\n type: 'para',\n description: 'Text refrain (paragraph right-aligned)',\n },\n pro: {\n type: 'char',\n description: 'For indicating pronunciation in CJK texts (DEPRECATED - used char@style rb)',\n },\n q: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if single level)',\n },\n q1: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if multiple levels)',\n },\n q2: {\n type: 'para',\n description: 'Poetry text, level 2 indent',\n },\n q3: {\n type: 'para',\n description: 'Poetry text, level 3 indent',\n },\n q4: {\n type: 'para',\n description: 'Poetry text, level 4 indent',\n },\n qa: {\n type: 'para',\n description: 'Poetry text, Acrostic marker/heading',\n },\n qac: {\n type: 'char',\n description:\n 'Poetry text, Acrostic markup of the first character of a line of acrostic poetry',\n },\n qc: {\n type: 'para',\n description: 'Poetry text, centered',\n },\n qd: {\n type: 'para',\n description:\n 'A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.',\n },\n qm: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if single level)',\n },\n qm1: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if multiple levels)',\n },\n qm2: {\n type: 'para',\n description: 'Poetry text, embedded, level 2 indent',\n },\n qm3: {\n type: 'para',\n description: 'Poetry text, embedded, level 3 indent',\n },\n qr: {\n type: 'para',\n description: 'Poetry text, Right Aligned',\n },\n qs: {\n type: 'char',\n description: 'Poetry text, Selah',\n },\n qt: {\n type: 'char',\n description: 'For Old Testament quoted text appearing in the New Testament',\n },\n 'qt-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt1-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt1-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt2-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt2-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt3-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt3-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt4-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt4-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt5-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt5-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n r: {\n type: 'para',\n description: 'Parallel reference(s)',\n },\n rb: {\n type: 'char',\n defaultAttribute: 'gloss',\n },\n ref: {\n type: 'ref',\n defaultAttribute: 'loc',\n },\n rem: {\n type: 'para',\n description: 'Remark',\n },\n restore: {\n type: 'para',\n description: 'Comment about when text was restored',\n },\n rq: {\n type: 'char',\n description: 'A cross-reference indicating the source text for the preceding quotation.',\n },\n s: {\n type: 'para',\n description: 'A section heading, level 1 (if single level)',\n },\n s1: {\n type: 'para',\n description: 'A section heading, level 1 (if multiple levels)',\n },\n s2: {\n type: 'para',\n description: 'A section heading, level 2 (e.g. Proverbs 22-24)',\n },\n s3: {\n type: 'para',\n description: 'A section heading, level 3 (e.g. Genesis \"The First Day\")',\n },\n s4: {\n type: 'para',\n description: 'A section heading, level 4',\n },\n sc: {\n type: 'char',\n description: 'A character style, for small capitalization text',\n },\n sd: {\n type: 'para',\n description:\n 'Vertical space used to divide the text into sections, level 1 (if single level)',\n },\n sd1: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 1 (if multiple levels)',\n },\n sd2: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 2',\n },\n sd3: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 3',\n },\n sd4: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 4',\n },\n sig: {\n type: 'char',\n description: 'For the signature of the author of an Epistle',\n },\n sls: {\n type: 'char',\n description:\n 'To represent where the original text is in a secondary language or from an alternate text source',\n },\n sp: {\n type: 'para',\n description: 'A heading, to identify the speaker (e.g. Job)',\n },\n sr: {\n type: 'para',\n description: 'A section division references range heading',\n },\n sts: {\n type: 'para',\n description: 'Status\\nRemark',\n },\n sup: {\n type: 'char',\n description:\n 'A character style, for superscript text. Typically for use in critical edition footnotes.',\n },\n 't-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 't-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n table: {\n type: 'table',\n },\n tl: {\n type: 'char',\n description: 'For transliterated words',\n },\n toc1: {\n type: 'para',\n description: 'Long table of contents text',\n },\n toc2: {\n type: 'para',\n description: 'Short table of contents text',\n },\n toc3: {\n type: 'para',\n description: 'Book Abbreviation',\n },\n toca1: {\n type: 'para',\n description: 'Alternative language long table of contents text',\n },\n toca2: {\n type: 'para',\n description: 'Alternative language short table of contents text',\n },\n toca3: {\n type: 'para',\n description: 'Alternative language book Abbreviation',\n },\n tr: {\n type: 'row',\n description: 'Table row',\n },\n ts: {\n type: 'ms',\n description:\n \"Translator's chunk (to identify chunks of text suitable for translating at one time)\",\n },\n 'ts-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'ts-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n usfm: {\n type: 'para',\n textContentAttribute: 'version',\n parseUsfmInstructions:\n \"If this marker is directly after the first id marker, this marker's version attribute should determine the version attribute of the usx or USJ marker at the top of the USX or USJ document, then this marker should be removed.\",\n },\n USJ: {\n type: 'USJ',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n usx: {\n type: 'usx',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n v: {\n type: 'verse',\n leadingAttributes: ['number'],\n attributeMarkers: ['va', 'vp'],\n },\n va: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description:\n 'Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)',\n },\n vp: {\n type: 'char',\n description:\n 'Published verse marker - this is a verse marking that would be used in the published text',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n },\n w: {\n type: 'char',\n defaultAttribute: 'lemma',\n },\n wa: {\n type: 'char',\n description: 'An Aramaic wordlist text item',\n },\n wg: {\n type: 'char',\n description: 'A Greek Wordlist text item',\n },\n wh: {\n type: 'char',\n description: 'A Hebrew wordlist text item',\n },\n wj: {\n type: 'char',\n description: 'For marking the words of Jesus',\n },\n x: {\n type: 'note',\n description: 'Cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n xdc: {\n type: 'char',\n description:\n 'Cross-reference target reference(s), Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n xk: {\n type: 'char',\n description: 'A cross reference keyword',\n isClosingMarkerOptional: true,\n },\n xnt: {\n type: 'char',\n description: 'Cross-reference target reference(s), New Testament only',\n isClosingMarkerOptional: true,\n },\n xo: {\n type: 'char',\n description: 'The cross reference origin reference',\n isClosingMarkerOptional: true,\n },\n xop: {\n type: 'char',\n description:\n 'Published cross reference origin text (origin reference that should appear in the published text)',\n isClosingMarkerOptional: true,\n },\n xot: {\n type: 'char',\n description: 'Cross-reference target reference(s), Old Testament only',\n isClosingMarkerOptional: true,\n },\n xq: {\n type: 'char',\n description: 'A cross-reference quotation from the scripture text',\n isClosingMarkerOptional: true,\n },\n xt: {\n type: 'char',\n defaultAttribute: 'link-href',\n description:\n 'A target reference(s)\\nA cross reference target reference(s)\\nThe cross reference target reference(s), protocanon only',\n isClosingMarkerOptional: true,\n },\n xta: {\n type: 'char',\n description: 'Cross reference target references added text',\n isClosingMarkerOptional: true,\n },\n },\n markersRegExp: {\n '[Zz].+': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 'qt[1-5]?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 't[hc][rc]?\\\\d+': {\n type: 'cell',\n },\n 'ts?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n },\n markerTypes: {\n book: {},\n cell: {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n },\n chapter: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n char: {\n isCloseable: true,\n nestedPrefix: '+',\n },\n figure: {\n isCloseable: true,\n outputToUsfmInstructions: 'The USX/USJ file attribute needs its name changed to src in USFM',\n parseUsfmInstructions: 'The USFM src attribute needs its name changed to file in USX/USJ',\n },\n ms: {\n isCloseable: true,\n isClosingMarkerEmpty: true,\n },\n note: {\n isCloseable: true,\n },\n optbreak: {\n hasStyleAttribute: false,\n },\n para: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['vid'],\n },\n periph: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n },\n ref: {\n isCloseable: true,\n hasStyleAttribute: false,\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['gen'],\n skipOutputMarkerToUsfm: true,\n },\n row: {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n },\n sidebar: {\n hasNewlineBefore: true,\n },\n table: {\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['vid'],\n skipOutputMarkerToUsfm: true,\n },\n 'table:cell': {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n markerTypeUsfm: 'cell',\n markerTypeUsx: 'cell',\n },\n 'table:row': {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n markerTypeUsfm: 'row',\n markerTypeUsx: 'row',\n },\n unmatched: {\n description:\n 'Paratext uses this type for closing markers that it cannot find opening markers for. They are treated like char markers but have no contents, no closing markers, and no space after the marker.',\n outputToUsfmInstructions:\n 'Do not output a structural space after the opening marker for markers with unmatched type.',\n parseUsfmInstructions:\n 'If a closing marker occurs but does not seem to have a matching opening marker, create an unmatched-type marker. There is no structural space after the unmatched-type marker; its end is determined by the asterisk at the end of the marker.',\n },\n USJ: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n usx: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n verse: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n },\n});\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file and adjusted to reflect the way Paratext 9.4 handles USFM.\n */\nexport const USFM_MARKERS_MAP_PARATEXT: MarkersMap = Object.freeze({\n ...USFM_MARKERS_MAP,\n isSpaceAfterAttributeMarkersContent: true,\n shouldOptionalClosingMarkersBePresent: true,\n});\n","// This was disabled so class functions that are similar in purpose can be grouped together\n/* eslint-disable @typescript-eslint/member-ordering */\nimport {\n USJ_TYPE,\n type MarkerContent,\n type MarkerObject,\n type Usj,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { JSONPath } from 'jsonpath-plus';\nimport { deepEqual } from '../equality-checking';\nimport { SortedNumberMap } from '../sorted-number-map';\nimport { isString } from '../util';\nimport { extractFootnotesFromUsjContent } from './footnote-util';\nimport {\n AttributeMarkerInfo,\n MarkerInfo,\n MarkersMap,\n MarkerTypeInfo,\n USFM_MARKERS_MAP as USFM_MARKERS_MAP_3_0,\n} from './markers-maps/markers-map-3.0.model';\nimport {\n BOOK_TYPE,\n CHAPTER_TYPE,\n ContentJsonPath,\n IUsjReaderWriter,\n NO_BOOK_ID,\n PropertyJsonPath,\n UsfmVerseLocation,\n UsfmVerseRefVerseLocation,\n UsjAttributeKeyLocation,\n UsjAttributeMarkerLocation,\n UsjBookLocation,\n UsjChapterLocation,\n UsjClosingAttributeMarkerLocation,\n UsjClosingMarkerLocation,\n UsjDocumentLocation,\n UsjMarkerLocation,\n UsjNodeAndDocumentLocation,\n UsjPropertyValueLocation,\n UsjReaderWriterOptions,\n UsjSearchResult,\n UsjTextContentLocation,\n UsjVerseRefBookLocation,\n UsjVerseRefChapterLocation,\n VERSE_TYPE,\n} from './usj-reader-writer.model';\n\nconst NODE_TYPES_NOT_CONTAINING_VERSE_TEXT = ['figure', 'note', 'sidebar', 'table'];\nObject.freeze(NODE_TYPES_NOT_CONTAINING_VERSE_TEXT);\n\n/** RegExp that matches all NBSP characters in a string. Used to convert NBSP in USJ to ~ in USFM */\nconst TEXT_CONTENT_NBSP_REGEXP = /\\u00A0/g;\n\n/**\n * RegExp that matches a USX/USJ table marker to get the number out of it. Used to figure out the\n * USFM cell range for table markers with `colspan` attribute in USX/USJ\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the number portion of the marker (the starting column of this cell)\n */\nconst TABLE_MARKER_NUMBER_REGEXP = /\\w+(\\d+)/;\n\n/**\n * RegExp that matches a USFM/USX/USJ verse number (optionally a span) to get the starting verse\n * number and optionally an ending verse number out of it.\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the starting number portion of the verse number\n * - 2: the ending number portion of the verse number if one exists\n *\n * Example:\n *\n * ```usfm\n * \\v 15-16\n * ```\n *\n * We would match this RegExp against `\"15-16\"`\n *\n * Match 1 would be `\"15\"`, and match 2 would be `\"16\"`\n */\nconst VERSE_MARKER_NUMBER_SPAN_REGEXP = /(\\d+)-?(\\d+)?/;\n\n/**\n * Map of USJ content arrays and objects inside content arrays to the content array owner\n *\n * Note that `USJ` markers may have parents if they are unexpectedly present within the contents of\n * the USJ document. We can tell which `USJ` marker is the top-level marker by receiving `undefined`\n * when looking up the `USJ` marker.\n */\ntype UsjParentMap = Map;\n\n/** Fragment indicating a marker closed */\ntype UsjClosingMarkerFragment = { isClosingMarker: true; forMarker: MarkerObject | Usj };\n/** Fragment indicating the value for an attribute */\ntype UsjAttributeValueFragment = { attributeValueForKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the key for an attribute */\ntype UsjAttributeKeyFragment = { attributeKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the opening of an attribute marker */\ntype UsjAttributeMarkerFragment = { attributeMarker: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the closing of an attribute marker */\ntype UsjAttributeMarkerClosingMarkerFragment = {\n attributeMarkerClosingMarker: string;\n forMarker: MarkerObject | Usj;\n};\n\n/**\n * A piece of Scripture data in a USJ document. This could be any of the following:\n *\n * 1. A marker or content string in a USJ document\n *\n * - `Usj`\n * - `MarkerContent`\n * 2. A JavaScript object representation of some part of a marker that isn't actually a JavaScript\n * object\n *\n * - `UsjClosingMarker`\n * - `UsjAttributeValue`\n * - `UsjAttributeKey` except when the attribute whose key is being pointed to is an attribute marker\n * in USFM, in which case this fragment is type 3 below. This fragment represents the USFM\n * attribute marker name in USFM (e.g. `ca`), not the attribute key name (e.g. `altnumber`)\n * 3. Part of a marker as it appears in USFM but that doesn't have a direct equivalence in USJ\n *\n * - `UsjAttributeKey` when pointing to an attribute marker. See fragment type 2 above.\n * - `UsjAttributeMarker`\n * - `UsjAttributeMarkerClosingMarker`\n *\n * This is somewhat similar to `UsfmToken` in `ParatextData.dll`, but there are many differences.\n * `UsfmToken` is a class with many methods and divides Scripture data based on the USFM contents.\n * `UsjFragment`, however, is just a union of object types (and `string`) that indicates the\n * division of Scripture data primarily by USJ contents.\n *\n * This is not the same as or similar to `IFragment` in `ParatextData.dll`. `IFragment` is a bit\n * more similar to {@link UsjFragmentInfo}.\n *\n * If you think of a better name for this, feel free to replace it.\n */\ntype UsjFragment =\n | Usj\n | MarkerContent\n | UsjClosingMarkerFragment\n | UsjAttributeValueFragment\n | UsjAttributeKeyFragment\n | UsjAttributeMarkerFragment\n | UsjAttributeMarkerClosingMarkerFragment;\n\n/**\n * Information about a fragment including its position in the USFM representation. Built while\n * determining the USFM representation of the USJ document\n */\ntype UsjFragmentInfoMinimal = {\n fragment: UsjFragment;\n indexInUsfm: number;\n};\n\n/**\n * A snippet of USFM along with information about what fragments of the marker are where in that\n * USFM snippet\n */\ntype UsfmSnippetAndUsjFragmentsInfo = {\n usfm: string;\n /** USFM position info about the fragments that are represented in this USFM string */\n fragmentsInfo: UsjFragmentInfoMinimal[];\n};\n\n/**\n * Information about a fragment that includes its position in the USFM and the USJ representation.\n * Transformed from {@link UsjFragmentInfoMinimal} in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} while sorting the fragments into the\n * right places after finishing determining the USFM representation.\n *\n * This is somewhat similar to `IFragment` in `ParatextData.dll` in that both contain information\n * that connects some position in USFM to some position in USX (`IFragment`) or USJ\n * (`UsjFragmentInfo`).\n */\ntype UsjFragmentInfo = UsjFragmentInfoMinimal & {\n /**\n * The node this fragment is on and the document location of the start of this fragment (any\n * offset property will be 0)\n */\n nodeAndDocumentLocation: UsjNodeAndDocumentLocation;\n};\n\n/** Fragments at each index in the USFM string */\ntype FragmentsByIndexInUsfm = SortedNumberMap;\n\n/**\n * Array of fragments that have the JSONPath (content or property) that is the key\n *\n * The JSONPath must be \"normalized\" as generated by UsjReaderWriter.convertWorkingStackToJsonPath\n * and UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath. Otherwise, your JSONPath will not\n * match the keys in this map.\n */\ntype FragmentsByJsonPath = Map;\n\n/**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. Used for taking an index based on the start of a verse and\n * determining the index in the whole USFM document to look up in {@link FragmentsByIndexInUsfm}.\n *\n * Notes:\n *\n * - All indices before a book id are associated with the first book id present. If there is not a\n * book id present in the USJ data, everything will be in book {@link NO_BOOK_ID}.\n * - All indices before a chapter number are associated with the first chapter number present. If\n * there is not a chapter number present in the USJ data, everything will be in chapter 0.\n * - Any indices that occur before a verse number will be in verse 0.\n * - The start of a book is at the book name, chapter 1 (or 0 if no chapter numbers), verse 0. The\n * start of a chapter is at the book name, chapter number, verse 0.\n * - There are no verse ranges in this object. Only the starting verse in any range that is found in\n * the USFM is added to this map (in {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}), so\n * we should always look up verse ranges with the starting verse in the range (in\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}). Presumably, if someone is trying to find the\n * index in USFM of a verse that isn't standalone but is in the middle of a range, they are likely\n * going to run into less obvious trouble with index in USFM calculations.\n *\n * TODO: Should we do something else to support verse ranges? Depending on how we want to support\n * them, we can do different things:\n *\n * - If we just want to support getting the first verse in a range (`SerializedVerseRef.verseNum`), we\n * don't need to change anything as this is how it works currently.\n * - If we want to support getting the verse range exactly as it appears in the text and _not_ from\n * the first verse in the range, we could change the index signature `[verseNum: number]` to be\n * accessible by `string | number` and put the `SerializedVerseRef.verse` range text as the key\n * instead of `verseNum` when it is defined and looked up (in at least\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} and\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}; maybe other places as well).\n * - If we want to support getting any verse in a range, we could add the same index in USFM for all\n * the verses within a verse range `SerializedVerseRef.verse` (in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}).\n *\n * In any case, once we come to a clear decision on what we want to do, we should probably document\n * it in the TSDoc for {@link UsjReaderWriter}.\n */\ntype IndicesInUsfmByVerseRef = {\n [book: string]:\n | {\n [chapterNum: number]:\n | {\n [verseNum: number]: number | undefined;\n }\n | undefined;\n }\n | undefined;\n};\n\n/**\n * Represents information about where a USJ node resides in the `content` array of its parent.\n * `parent` is a reference to the node's parent, and `index` represents the numeric index inside of\n * `parent`'s content array.\n */\ntype StackItem = { parent: MarkerObject | Usj; index: number };\n\n/**\n * Stack of levels inside a USJ tree relative to a specific node. The top of the stack should always\n * be the root Usj object.\n */\ntype WorkingStack = StackItem[];\n\n/**\n * Represents USJ formatted scripture with helpful utilities for working with it. Some notable\n * features:\n *\n * - Find Scripture text in the USJ document\n *\n * - `extractText`\n * - `extractTextBetweenPoints`\n * - `findNextLocationOfMatchingText`\n * - `search`\n * - `usfmVerseLocationToNextTextLocation`\n * - Edit the USJ document: `removeContentNodes`\n * - Transform USJ to USFM: `toUsfm`\n * - Transform USJ document locations to USFM locations and vice versa\n *\n * - `usfmVerseLocationToUsjDocumentLocation`\n * - `usjDocumentLocationToUsfmVerseRefVerseLocation`\n * - Use the version of USFM you need by passing in a custom markers map to the constructor if the\n * version in your USJ document is not supported by default:\n * {@link UsjReaderWriterOptions.markersMap}\n *\n * Notes:\n *\n * - \"node\" is a term used in the methods in this class that usually means an object or content string\n * somewhere in the USj document, either {@link Usj} or {@link MarkerContent}. However, in specific\n * situations, it may refer only to {@link MarkerObject} or {@link MarkerContent}. The TypeScript\n * types indicate when this is the case.\n * - See {@link UsfmVerseLocation} and {@link UsjDocumentLocation} for information about transforming\n * USFM locations and USJ locations including what kinds of USFM locations are and are not\n * representable in USJ locations, which USJ locations actually correspond to something in USJ,\n * etc.\n * - It is best to reuse the same `UsjReaderWriter` for the same USJ document as long as possible\n * because there is a significant amount of processing and caching done internally to facilitate\n * various operations. Note that, if the USJ document added to `UsjReaderWriter` changes, you must\n * run `usjChanged` to clear the internal caches and receive accurate results from future method\n * calls\n */\nexport class UsjReaderWriter implements IUsjReaderWriter {\n private readonly usj: Usj;\n private readonly markersMap: MarkersMap;\n private readonly shouldAllowInvisibleCharacters: boolean;\n\n // Cached properties\n private parentMapInternal: UsjParentMap | undefined;\n private fragmentsByIndexInUsfmInternal: FragmentsByIndexInUsfm | undefined;\n private fragmentsByJsonPathInternal: FragmentsByJsonPath | undefined;\n private indicesInUsfmByVerseRefInternal: IndicesInUsfmByVerseRef | undefined;\n private usfmInternal: string | undefined;\n\n constructor(usj: Usj, options?: UsjReaderWriterOptions) {\n this.usj = usj;\n\n const { markersMap: providedMarkersMap, shouldAllowInvisibleCharacters } = options ?? {};\n\n // If they passed in a markers map, use it\n if (providedMarkersMap) {\n this.markersMap = providedMarkersMap;\n\n // Warn if the passed in markers map is not compatible\n if (!UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, this.markersMap.version))\n console.warn(\n `Warning: USJ provided has version ${\n this.usj.version\n }, but provided markers map has version ${\n this.markersMap.version\n }. This may cause unexpected issues when transforming between formats.`,\n );\n }\n // They didn't pass in a markers map, so try to use a built-in markers map matching the USJ version\n else if (\n UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, USFM_MARKERS_MAP_3_0.version)\n )\n this.markersMap = USFM_MARKERS_MAP_3_0;\n else\n throw new Error(\n 'USJ version is not 3.0 or 3.0.x! Not equipped to handle yet without passing in a markers map',\n );\n\n if (!this.markersMap.markersMapVersion.startsWith('1.'))\n throw new Error(\n `Incompatible markers map version: ${\n this.markersMap.markersMapVersion\n }. This class only supports version 1.x.y`,\n );\n\n this.shouldAllowInvisibleCharacters = shouldAllowInvisibleCharacters ?? false;\n }\n\n // If new variables are created to speed up queries, they should be reset here\n usjChanged(): void {\n this.parentMapInternal = undefined;\n this.fragmentsByIndexInUsfmInternal = undefined;\n this.fragmentsByJsonPathInternal = undefined;\n this.indicesInUsfmByVerseRefInternal = undefined;\n this.usfmInternal = undefined;\n }\n\n private static areUsjVersionsCompatible(versionA: string, versionB: string) {\n if (versionA === '3.0' || versionA.startsWith('3.0.'))\n return versionB === '3.0' || versionB.startsWith('3.0.');\n return versionA === versionB;\n }\n\n // #region Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n findSingleValue(jsonPathQuery: string): T | undefined {\n const wrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n if (wrappedResults === undefined || wrappedResults.length === 0) return undefined;\n if (!Array.isArray(wrappedResults[0])) return wrappedResults[0];\n\n // There is no way to tell the difference between a query that returns a single result that is an\n // array and a query that returns multiple results wrapped in an array when `wrap` is false.\n // However, if `wrap` is true then a single result that is an array will be a different array\n // object than the array object within `usj`. So we need to run with `wrap` as true and false to\n // get the original array object back for a query that returns a single array.\n const unwrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: false });\n if (unwrappedResults.length === 1 && Array.isArray(unwrappedResults[0]))\n // I have no idea why eslint is mad about casting from `any` to `T`, but it doesn't like it\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return unwrappedResults[0] as T;\n return unwrappedResults;\n }\n\n findParent(jsonPathQuery: string): T | undefined {\n // Note that \"resultType: 'parent'\" does not work for queries\n // The \"jsonpath-plus\" package allows putting a carat at the end of a query to get a parent\n return this.findSingleValue(`${jsonPathQuery}^`);\n }\n\n // #endregion Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n // #region marker helper methods\n\n /**\n * Determine if the passed in marker is the top-level USJ marker.\n *\n * Note that USJ markers that are not the top-level USJ markers technically should not occur, but\n * they can occur. We should treat them like any other marker. They conform to\n * {@link MarkerObject}, so it's not hard to do.\n *\n * @param marker Marker to test if it is USJ marker\n * @returns `true` if it is a USJ marker; false otherwise\n */\n static isTopLevelUsjMarker(\n marker: Usj | MarkerContent,\n workingStack: WorkingStack,\n ): marker is Usj {\n return typeof marker === 'object' && marker.type === USJ_TYPE && workingStack.length === 0;\n }\n\n /**\n * Determine if a fragment is a marker, not a text content string or some kind of position\n * fragment that isn't actually a marker e.g. closing marker fragment\n */\n private static isFragmentAMarker(fragment: UsjFragment): fragment is MarkerObject | Usj {\n return !isString(fragment) && !('forMarker' in fragment);\n }\n\n // #endregion marker helper methods\n\n // #region Parent Maps\n\n private static createParentMapInternal(\n obj: MarkerObject,\n parent: MarkerObject | Usj,\n parentMap: UsjParentMap,\n ): void {\n parentMap.set(obj, parent);\n // USJ queries may return pointers to content arrays, not just objects\n if (obj.content) parentMap.set(obj.content, obj);\n obj.content?.forEach((child) => {\n if (typeof child === 'object') UsjReaderWriter.createParentMapInternal(child, obj, parentMap);\n });\n }\n\n /** Viewing a Usj object as a tree, build a map to walk up the tree */\n private createUsjParentMap(): UsjParentMap {\n const parentMap = new Map();\n if (this.usj.content) parentMap.set(this.usj.content, this.usj);\n this.usj.content.forEach((content) => {\n if (typeof content === 'object')\n UsjReaderWriter.createParentMapInternal(content, this.usj, parentMap);\n });\n return parentMap;\n }\n\n /** Create the parent map if it doesn't already exist and return it */\n private get parentMap(): UsjParentMap {\n if (this.parentMapInternal) return this.parentMapInternal;\n this.parentMapInternal = this.createUsjParentMap();\n return this.parentMapInternal;\n }\n\n // #endregion Parent Maps\n\n // #region Working Stacks\n\n /**\n * Checks if two stack items are equal using shallow equivalence, testing the stack item\n * properties for [strict\n * equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)\n *\n * Note that this requires the parent of the two stack items to have reference equality\n */\n private static areStackItemsShallowEqual(a: StackItem, b: StackItem): boolean {\n return a.index === b.index && a.parent === b.parent;\n }\n\n /** Return the working stack applicable to the given node */\n private createWorkingStack(node: MarkerObject | Usj): WorkingStack {\n // Represents levels in the USJ node tree that are above the current node (i.e., ancestors)\n // Levels in the tree are represented as a stack, so the last item in the stack is node's parent\n const workingStack: WorkingStack = [];\n\n // Grab a reference so we don't keep checking if it exists\n const { parentMap } = this;\n\n // `node` might be in the middle of the USJ tree, so build up the stack before walking the tree\n let tempNode: MarkerObject | Usj = node;\n let tempParent = parentMap.get(tempNode);\n while (tempParent !== undefined) {\n if (!tempParent.content)\n throw new Error('Invalid parentMap: all parents should have content');\n\n if (\n // Referencing tempNode and tempParent is OK in the loop since 'let' is used instead of 'var'\n // eslint-disable-next-line no-loop-func\n !tempParent.content.find((tempChild, index) => {\n if (tempChild !== tempNode) return false;\n if (!tempParent) throw new Error('undefined \"tempParent\" should not be possible');\n workingStack.unshift({ parent: tempParent, index });\n return true;\n })\n )\n throw new Error(`Unable to find correct parent node of ${JSON.stringify(tempNode)}`);\n\n tempNode = tempParent;\n tempParent = parentMap.get(tempParent);\n }\n\n return workingStack;\n }\n\n /**\n * Transform a JSONPath array (`JSONPath.toPathArray`) to a \"normalized\" JSONPath. We can use this\n * JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static jsonPathArrayToJsonPath(pathArray: string[]): string {\n return pathArray.reduce((pathAcc, pathEntry) => {\n if (pathEntry === 'content') return `${pathAcc}.${pathEntry}`;\n if (!Number.isNaN(parseInt(pathEntry, 10))) return `${pathAcc}[${pathEntry}]`;\n return `${pathAcc}['${pathEntry}']`;\n });\n }\n\n /** \"Normalize\" the JSONPath passed in so we can use it for lookups in {@link FragmentsByJsonPath} */\n private static normalizeJsonPath(jsonPath: string): string {\n // Convert to path array and back to standardize property access syntax\n const pathArray = JSONPath.toPathArray(jsonPath);\n return UsjReaderWriter.jsonPathArrayToJsonPath(pathArray);\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack. We can use this JSONPath\n * for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackToJsonPath(stack: WorkingStack): ContentJsonPath {\n let jsonPath = '$';\n stack.forEach((stackLevel) => {\n jsonPath = `${jsonPath}.content[${stackLevel.index}]`;\n });\n // The JSONPath string construction above conforms to the ContentJsonPath type\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return jsonPath as ContentJsonPath;\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack and property. We can use\n * this JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackAndPropertyToJsonPath(\n stack: WorkingStack,\n property: string,\n ): PropertyJsonPath {\n // Adding this property makes it conform to PropertyJsonPath. Always using bracket notation\n // because it works in more cases than dot notation does\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return `${UsjReaderWriter.convertWorkingStackToJsonPath(stack)}['${property}']` as PropertyJsonPath;\n }\n\n private convertJsonPathToWorkingStack(\n jsonPath: ContentJsonPath | PropertyJsonPath,\n ): WorkingStack {\n const retVal: WorkingStack = [];\n\n // If the JSONPath is pointing to the top marker, there are no content levels\n if (jsonPath === '$') return retVal;\n\n const levels = jsonPath.match(/content\\[(\\d+)\\]/g);\n if (!levels) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n\n let onNode: Usj | MarkerObject = this.usj;\n\n levels.forEach((level, onLevel) => {\n const indexString = /(\\d+)/.exec(level);\n if (!indexString) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n const index = parseInt(indexString[0], 10);\n retVal.push({ parent: onNode, index });\n if (onLevel + 1 < levels.length) {\n if (typeof onNode === 'string' || !onNode.content)\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(onNode)}`);\n const nextNode = onNode.content[index];\n if (typeof nextNode === 'string')\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(nextNode)}`);\n onNode = nextNode;\n }\n });\n\n return retVal;\n }\n\n // #endregion Working Stacks\n\n // #region Walk the node tree\n\n /**\n * Extract textual notes (aka, \"footnotes\") from a full USJ object.\n *\n * @returns An array of MarkerObjects representing all textual notes found in the USJ content.\n */\n findAllNotes(): MarkerObject[] {\n return extractFootnotesFromUsjContent(this.usj?.content);\n\n // Note that the following could be used instead of the above call to\n // extractFootnotesFromUsjContent, and that function could be removed. However, this is about\n // 100x slower than the custom traversal in extractFootnotesFromUsjContent.\n // return this.findAll('$.content..[?(@.type==\"note\")]');\n // This would depend on implementing findAll in this class:\n // findAll(jsonPathQuery: string): T[] {\n // const results = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n // return Array.isArray(results) ? results as T[] : [];\n // }\n }\n\n /**\n * Look through the USJ document for a node or the closing of a node matching some condition. This\n * will run `searchFunction` for `node`, all nodes encountered in `node.contents` (recursively),\n * when `node` closes, and all nodes after `node`\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes and representations of the closing of nodes will be\n * passed into to determine if they are the correct node or representation of the closing of a\n * node. Stops searching and returns the node/close if this function returns `true`\n * @returns Node or representation of the closing of a node matching condition tested by the\n * search function\n */\n private static findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNodeOrClose: MarkerContent | Usj | UsjClosingMarkerFragment,\n workingStack: WorkingStack,\n ) => boolean,\n ) {\n let nextNode: MarkerContent | Usj | undefined = node;\n\n const topNode = workingStack.length === 0 ? node : workingStack[0].parent;\n // If the top node is a marker as we would expect, we need to check if `node` is under a\n // skipped-type node and skip past all that skipped stuff if so. If the top node is a `string`,\n // don't need to worry about this since we should just be searching against that one string\n if (!isString(topNode)) {\n // Determine if we are in a skipped-type node and skip to the next node after it if so\n // If the top node is skipped, return `undefined` because everything is skipped\n if (skipTypes.includes(topNode.type)) return undefined;\n\n // Find the highest (lowest index) stack item level that is skipped so we can go to its next\n // sibling\n let highestSkippedNode: MarkerContent | undefined;\n workingStack.some((stackItem) => {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const stackNode = stackItem.parent.content![stackItem.index];\n if (!isString(stackNode) && skipTypes.includes(stackNode.type)) {\n highestSkippedNode = stackNode;\n return true;\n }\n\n return false;\n });\n\n // Set nextNode to the highest skipped node so it will skip and go to the next sibling in the\n // following code\n if (highestSkippedNode) nextNode = highestSkippedNode;\n }\n\n // Walk the nodes in a depth-first, left-to-right manner until the search function returns true\n while (nextNode !== undefined) {\n const skipNextNode = typeof nextNode === 'object' && skipTypes.includes(nextNode.type);\n\n // If we found the node we're looking for, we're done\n if (!skipNextNode && searchFunction(nextNode, workingStack)) return nextNode;\n\n // Look at the node's children\n if (!skipNextNode && typeof nextNode === 'object' && (nextNode.content?.length ?? 0) > 0) {\n workingStack.push({ parent: nextNode, index: 0 });\n // Same as `nextNode = nextNode.content[0];` without triggering 2 different eslint errors\n [nextNode] = nextNode.content;\n } else {\n if (!skipNextNode) {\n // The node has no children, so check the closing marker for this node\n const nextNodeClosingMarker: UsjClosingMarkerFragment | undefined =\n typeof nextNode === 'object'\n ? { isClosingMarker: true, forMarker: nextNode }\n : undefined;\n if (nextNodeClosingMarker && searchFunction(nextNodeClosingMarker, workingStack))\n return nextNodeClosingMarker;\n }\n\n // Then look at the next sibling, or the parent's next sibling, or the parent's closing\n // marker, etc. up the stack\n nextNode = undefined;\n while (workingStack.length > 0) {\n const nextLevel = workingStack.pop();\n if (nextLevel) {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if (nextLevel.index + 1 < nextLevel.parent.content!.length) {\n // Check the next sibling\n nextLevel.index += 1;\n workingStack.push(nextLevel);\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n nextNode = nextLevel.parent.content![nextLevel.index];\n break;\n } else {\n // There is no next sibling, so check the closing marker for the parent before we\n // continue to look at the parent's next sibling and etc.\n const parentClosingMarker: UsjClosingMarkerFragment = {\n isClosingMarker: true,\n forMarker: nextLevel.parent,\n };\n if (searchFunction(parentClosingMarker, workingStack)) return parentClosingMarker;\n }\n }\n }\n }\n }\n\n // We've looked everywhere, so there must not be an appropriate node anywhere\n return undefined;\n }\n\n /**\n * Look through the USJ document for a node matching some condition\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes will be passed into to determine if they are the\n * correct node. Stops searching and returns the node if this function returns `true`\n * @returns Node matching condition tested by the search function\n */\n private static findNextMatchingNodeUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNode: MarkerContent | Usj,\n workingStack: WorkingStack,\n ) => boolean,\n ): MarkerContent | undefined {\n // We are filtering out closing markers in our search function\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const result = this.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node,\n workingStack,\n skipTypes,\n (potentiallyMatchingNodeOrClose, currentWorkingStack) => {\n if (\n typeof potentiallyMatchingNodeOrClose === 'object' &&\n 'isClosingMarker' in potentiallyMatchingNodeOrClose\n )\n // Skip closing markers\n return false;\n\n // Just search normal markers and text as appropriate for this method\n return searchFunction(potentiallyMatchingNodeOrClose, currentWorkingStack);\n },\n ) as MarkerContent | undefined;\n\n return result;\n }\n\n // #endregion Walk the node tree\n\n // #region Node -> JSONPath\n\n nodeToJsonPath(node: MarkerObject): ContentJsonPath {\n return UsjReaderWriter.convertWorkingStackToJsonPath(this.createWorkingStack(node));\n }\n\n // #endregion Node -> JSONPath\n\n // #region USJ node -> SerializedVerseRef + offset in USFM\n\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { documentLocation: usjLocation } = this.nodeToUsjNodeAndDocumentLocation(\n node,\n nodeParent,\n );\n\n // Find the UsjFragmentInfo at this location\n return this.usjDocumentLocationToUsfmVerseRefVerseLocation(usjLocation, bookIdIfNotFound);\n }\n\n // #endregion USJ node -> SerializedVerseRef + offset in USFM\n\n // #region USJ node -> USJ location\n\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation {\n // Get working stack to the node\n let workingStack: WorkingStack;\n\n if (isString(node)) {\n // If the node is a string, we need to get the working stack from the parent and add the last\n // level for the string node\n if (nodeParent === undefined)\n throw new Error(`If \"node\" is a string, then \"nodeParent\" cannot be undefined`);\n\n // Get the real parent\n const realParent = Array.isArray(nodeParent) ? this.parentMap.get(nodeParent) : nodeParent;\n if (realParent === undefined)\n throw new Error(`Cannot find parent for ${JSON.stringify(nodeParent)}`);\n\n // Get the working stack to the parent\n workingStack = this.createWorkingStack(realParent);\n\n // Add the stack item for the string node\n const nodeIndexInParent = realParent.content?.indexOf(node);\n if (nodeIndexInParent === undefined || nodeIndexInParent < 0)\n throw new Error(`Could not find index of node in parent for creating working stack`);\n workingStack.push({ parent: realParent, index: nodeIndexInParent });\n } else {\n // The node is not a string, so it's easy to get the working stack\n workingStack = this.createWorkingStack(node);\n }\n\n // Get the UsjDocumentLocation for this node so we can find the fragment at that location\n const usjLocation = UsjReaderWriter.convertNodeToUsjDocumentLocation(node, workingStack);\n\n return {\n node,\n documentLocation: usjLocation,\n };\n }\n\n // #endregion USJ node -> USJ location\n\n // #region JSONPath > USJ location\n\n /**\n * Finds the node associated with the JSONPath provided, and also gets the parent of the node if\n * the node is a string. This is helpful so you can find a real object that is actually somewhere\n * in the USJ document from the JSONPath\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered.\n * @returns First node found at the JSONPath and the parent of that node _if_ the node is a\n * string. Note that the object returned is the actual object in the USJ document.\n */\n private jsonPathToNodeAndParentIfString(jsonPathQuery: string): {\n node: MarkerContent | Usj;\n parent: MarkerObject | Usj | MarkerContent[] | undefined;\n } {\n // Find the node this JSONPath is pointing to\n const target: MarkerContent | Usj | undefined = this.findSingleValue(jsonPathQuery);\n if (!target) throw new Error(`No result found for JSONPath query: ${jsonPathQuery}`);\n\n // Find the parent of this node if it is a string so we can know where it is\n const parent: MarkerObject | Usj | MarkerContent[] | undefined = isString(target)\n ? this.findParent(jsonPathQuery)\n : undefined;\n if (!parent && isString(target))\n throw new Error(`Could not determine parent for ${jsonPathQuery}`);\n\n return {\n node: target,\n parent,\n };\n }\n\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usjNodeAndDocumentLocation = this.nodeToUsjNodeAndDocumentLocation(node, parent);\n\n return usjNodeAndDocumentLocation;\n }\n\n // #endregion JSONPath > USJ location\n\n // #region JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usfmVerseLocation = this.nodeToUsfmVerseRefVerseLocation(node, parent, bookIdIfNotFound);\n\n return usfmVerseLocation;\n }\n\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n // Find the fragment with the matching UsjDocumentLocation except offset\n const fragmentInfo = this.findFragmentInfoAtUsjDocumentLocation(usjLocation);\n if (fragmentInfo === undefined)\n throw new Error(\n `Could not find fragment info at USJ document location while transforming to USFM verse location: ${JSON.stringify(\n usjLocation,\n )}`,\n );\n\n const verseRef = this.getVerseRefForIndexInUsfm(fragmentInfo.indexInUsfm, bookIdIfNotFound);\n\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n return {\n verseRef,\n // Final USFM verse offset is the fragment's location relative to the verse plus whatever\n // offset is in the USJ location\n offset:\n fragmentInfo.indexInUsfm -\n verseIndexInUsfm +\n UsjReaderWriter.getOffsetInUsjDocumentLocation(usjLocation),\n };\n }\n\n // #endregion JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n // #region Handling VerseRefs\n\n /**\n * Gets the book ID in the internal USJ document data corresponding to the book ID passed in.\n *\n * @param bookId The book ID to look up data in the USJ document for\n * @returns If there isn't a book ID in the USJ document, {@link NO_BOOK_ID} will be returned\n * @throws If the requested book is not found in the USJ data and there are other books\n * @throws If there is no USJ content in the document whatsoever\n */\n private getEffectiveBookId(bookId: string): string {\n const availableBookIds = Object.keys(this.indicesInUsfmByVerseRef);\n const noBookIdsFound =\n availableBookIds.length === 0 ||\n (availableBookIds.length === 1 && availableBookIds[0] === NO_BOOK_ID);\n const effectiveBookId = noBookIdsFound ? NO_BOOK_ID : bookId;\n const bookIndices = this.indicesInUsfmByVerseRef[effectiveBookId];\n if (!bookIndices)\n throw new Error(\n `Book ID ${bookId} not found in USJ! ${noBookIdsFound ? `There seems to be no USJ content because there is no content in ${NO_BOOK_ID} either` : `Book IDs in USJ: ${JSON.stringify(availableBookIds)}`}`,\n );\n\n return effectiveBookId;\n }\n\n /**\n * Gets the index in USFM of the start of the verse (the backslash on the verse marker or the\n * beginning of the chapter if verse 0 is provided)\n */\n private getIndexInUsfmForVerseRef(verseRef: SerializedVerseRef): number {\n // Make sure the requested book ID is in the USJ content\n const bookId = this.getEffectiveBookId(verseRef.book);\n // `getEffectiveBookId` guaranteed bookIndices is defined\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const bookIndices = this.indicesInUsfmByVerseRef[bookId]!;\n\n // Make sure the requested chapter number is in the USJ content\n const chapterIndices = bookIndices[verseRef.chapterNum];\n if (!chapterIndices) throw new Error(`Could not find ${bookId} chapter ${verseRef.chapterNum}`);\n\n // Make sure the requested verse number is in the USJ content\n // Only look for the verse number even if it is the starting number in a requested verse range\n // because you are likely going to run into less obvious trouble if you get the index in USFM of\n // the wrong verse in a range\n const verseIndexInUsfm = chapterIndices[verseRef.verseNum];\n if (verseIndexInUsfm === undefined)\n throw new Error(`Verse ${verseRef.verseNum} not found in ${bookId} ${verseRef.chapterNum}`);\n\n return verseIndexInUsfm;\n }\n\n /**\n * Gets the verse ref that the provided index in USFM is in (including verse range if applicable).\n * Finds the closest verse ref before the index in USFM.\n *\n * @param indexInUsfm The index in USFM from the beginning of this document\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Closest verse reference before or at the index in USFM\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n private getVerseRefForIndexInUsfm(\n indexInUsfm: number,\n bookIdIfNotFound?: string,\n ): SerializedVerseRef {\n // ENHANCE: This could be sped up and simplified significantly by storing a sorted number map of\n // verse refs by index in USFM like so:\n /**\n * Index in the USFM representation of the USJ document of where the start of each verse ref is\n * (the backslash on the verse marker)\n */\n // type VerseRefsByIndexInUsfm = SortedNumberMap;\n\n const bookEntries = Object.entries(this.indicesInUsfmByVerseRef);\n let bookIndex = 0;\n let lastVerseRef: SerializedVerseRef | undefined;\n let didFindVerseRef = false;\n\n // Loop through all the books looking for the right book\n while (!didFindVerseRef && bookIndex < bookEntries.length) {\n const [bookId, chapterIndices] = bookEntries[bookIndex];\n\n if (chapterIndices) {\n const chapterEntries = Object.entries(chapterIndices);\n let chapterIndex = 0;\n // Loop through all the chapters looking for the right chapter\n while (!didFindVerseRef && chapterIndex < chapterEntries.length) {\n const [chapterNumString, verseIndices] = chapterEntries[chapterIndex];\n if (verseIndices) {\n const verseEntries = Object.entries(verseIndices);\n let verseIndex = 0;\n // Loop through all the verses looking for the right verse\n while (!didFindVerseRef && verseIndex < verseEntries.length) {\n const [verseNumString, verseIndexInUsfm] = verseEntries[verseIndex];\n\n if (verseIndexInUsfm !== undefined) {\n // If the verse ref index in USFM is past the index in USFM to find for the first time,\n // this is the verse ref after this index in USFM. Return the last one\n if (indexInUsfm < verseIndexInUsfm) {\n if (!lastVerseRef)\n // Somehow the index to find is less than the very first known index. Maybe that\n // means it's negative? Either way, it doesn't make sense\n throw new Error(\n `Could not find verse ref for index in USFM ${\n indexInUsfm\n } less than the first known index ${verseIndexInUsfm}`,\n );\n\n // We know the last verse ref, which was the final verse ref before this index.\n // Return that last verse ref\n didFindVerseRef = true;\n break;\n }\n // This verse ref is not past the index in USFM to find, so record this current verse\n // ref to return later if we determine this is the right verse ref\n lastVerseRef = {\n book: bookId,\n chapterNum: parseInt(chapterNumString, 10),\n verseNum: parseInt(verseNumString, 10),\n };\n // If the verse ref index is the same as the index to find, go ahead and return the\n // current verse ref. No need to look at the next index\n if (indexInUsfm === verseIndexInUsfm) {\n didFindVerseRef = true;\n break;\n }\n }\n\n verseIndex += 1;\n }\n }\n\n chapterIndex += 1;\n }\n }\n\n bookIndex += 1;\n }\n\n if (!lastVerseRef)\n throw new Error(`Did not find any verse refs while looking for index in USFM ${indexInUsfm}`);\n\n if (lastVerseRef.book === NO_BOOK_ID) {\n // Deal with no book ID\n if (!bookIdIfNotFound)\n throw new Error(\n `Could not find book ID and no book ID provided when finding USFM verse ref for index in USFM ${\n indexInUsfm\n }`,\n );\n\n lastVerseRef.book = bookIdIfNotFound;\n }\n\n // If `didFindVerseRef` is `false`, the index in USFM to find is greater than all known indices\n // in USFM. That means it's in the very last verse ref. That's fine; no need to do anything\n // special.\n\n // Add the verse range if the verse marker for this location's verse is a range\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(lastVerseRef);\n const verseFragmentInfo = this.fragmentsByIndexInUsfm.get(verseIndexInUsfm);\n if (\n verseFragmentInfo &&\n UsjReaderWriter.isFragmentAMarker(verseFragmentInfo.fragment) &&\n verseFragmentInfo.fragment.type === VERSE_TYPE &&\n verseFragmentInfo.fragment.number &&\n verseFragmentInfo.fragment.number !== `${lastVerseRef.verseNum}`\n )\n lastVerseRef.verse = verseFragmentInfo.fragment.number;\n\n return lastVerseRef;\n }\n\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n if (verseRefOffset < 0) throw new Error('offset must be >= 0');\n\n // Find the index in the whole USFM of this verse\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n // Add the verse offset to the verse index to get the USFM location's index in the USFM\n // representation of this USJ document\n const usfmVerseLocationIndexInUsfm = verseIndexInUsfm + verseRefOffset;\n\n return usfmVerseLocationIndexInUsfm;\n }\n\n // #endregion Handling VerseRefs\n\n // #region transforming location types to different types\n\n /**\n * Transforms a USFM verse-based location into a single standardized format of USFM verse-based\n * location for ease of accessing the location's properties\n *\n * @param usfmVerseLocation USFM verse-based location in one of multiple forms\n * @returns USFM verse-based location in one particular form. Also ensures `offset` is defined\n * (defaults to 0 as described in {@link UsfmVerseLocation})\n */\n static usfmVerseLocationToUsfmVerseRefVerseLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsfmVerseRefVerseLocation & { offset: number } {\n if ('verseRef' in usfmVerseLocation) {\n // UsfmVerseRefVerseLocation\n return {\n verseRef: usfmVerseLocation.verseRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n if ('scrRef' in usfmVerseLocation) {\n // Old deprecated form UsfmScrRefVerseLocation\n return {\n verseRef: usfmVerseLocation.scrRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n // SerializedVerseRef\n return {\n verseRef: usfmVerseLocation,\n offset: 0,\n };\n }\n\n /**\n * Transforms a USJ chapter-based location into a single standardized format of USJ chapter-based\n * location for ease of accessing the location's properties\n *\n * @param usjChapterLocation USJ chapter-based location in one of multiple forms\n * @returns USJ chapter-based location in one particular form.\n * @throws If erroneously received a {@link UsjBookLocation}, not a {@link UsjChapterLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjChapterLocationToUsjVerseRefChapterLocation(\n usjChapterLocation: UsjChapterLocation,\n ): UsjVerseRefChapterLocation {\n // Old deprecated UsjFlatTextChapterLocation\n if ('jsonPath' in usjChapterLocation) {\n if (usjChapterLocation.offset !== undefined)\n // with UsjTextContentLocation (has offset). Unfortunately, TypeScript really doesn't like\n // having this and the following type returned via the same object even though they're very\n // similar because of the required presence/absence of `offset` in each of the returned\n // types. Just breaking them out into separate returns.\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n offset: usjChapterLocation.offset,\n },\n };\n // with UsjMarkerLocation (does not have offset)\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n },\n };\n }\n\n // UsjVerseRefChapterLocation\n if ('verseRef' in usjChapterLocation) {\n if (\n // Make sure we are receiving a chapter location, not a book location\n usjChapterLocation.granularity !== undefined &&\n usjChapterLocation.granularity !== 'chapter'\n )\n throw new Error(\n 'Received UsjVerseRefBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return usjChapterLocation;\n }\n\n // UsjFlatChapterLocation\n // Make sure we are receiving a chapter location, not a book location\n if (usjChapterLocation.chapterNum === undefined)\n throw new Error(\n 'Received UsjFlatBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: usjChapterLocation.documentLocation,\n };\n }\n\n /**\n * Transforms a USJ book-based location into a single standardized format of USJ book-based\n * location for ease of accessing the location's properties\n *\n * @param usjBookLocation USJ book-based location in one of multiple forms\n * @returns USJ book-based location in one particular form.\n * @throws If erroneously received a {@link UsjChapterLocation}, not a {@link UsjBookLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjBookLocationToUsjVerseRefBookLocation(\n usjBookLocation: UsjBookLocation,\n ): UsjVerseRefBookLocation {\n // UsjVerseRefBookLocation\n if ('verseRef' in usjBookLocation) {\n if (\n // Make sure we are receiving a book location, not a chapter location\n usjBookLocation.granularity !== 'book'\n )\n throw new Error(\n 'Received UsjVerseRefChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return usjBookLocation;\n }\n\n // UsjFlatBookLocation\n // Make sure we are receiving a book location, not a chapter location\n if ('chapterNum' in usjBookLocation)\n throw new Error(\n 'Received UsjFlatChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return {\n verseRef: {\n book: usjBookLocation.book,\n chapterNum: 1,\n verseNum: 0,\n },\n granularity: 'book',\n documentLocation: usjBookLocation.documentLocation,\n };\n }\n\n // #endregion transforming location types to different types\n\n // #region USFM location -> USJ location\n\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n // Get the USFM location's index in the USFM representation of this USJ document\n const usfmVerseLocationIndexInUsfm = this.usfmVerseLocationToIndexInUsfm(usfmVerseLocation);\n\n // Find the fragment info at this USFM location\n const { value: fragmentInfo } = this.fragmentsByIndexInUsfm.findClosestLessThanOrEqual(\n usfmVerseLocationIndexInUsfm,\n ) ?? {\n value: undefined,\n };\n if (!fragmentInfo)\n throw new Error(\n `Somehow, did not find anything at index in verse ${verseRefOffset} or below in ${verseRef.book} ${verseRef.chapterNum}:${verseRef.verseNum}. Not sure how this would happen.`,\n );\n\n // Get the offset within the fragment where the USFM location is pointing\n const usjOffset = usfmVerseLocationIndexInUsfm - fragmentInfo.indexInUsfm;\n\n // Add the offset to the fragment's UsjDocumentLocation and return it\n return {\n ...fragmentInfo.nodeAndDocumentLocation,\n documentLocation: UsjReaderWriter.moveUsjDocumentLocationToNewOffset(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n usjOffset,\n ),\n };\n }\n\n usfmVerseLocationToUsjDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation | SerializedVerseRef,\n ): UsjDocumentLocation {\n return this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation).documentLocation;\n }\n\n // #endregion USFM location -> USJ location\n\n // #region UsjDocumentLocation utilities\n\n /**\n * Determine if the USJ document location is pointing to a text content location instead of some\n * location related to a marker object\n *\n * @param usjDocumentLocation USJ document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocation: UsjDocumentLocation,\n ): usjDocumentLocation is UsjTextContentLocation;\n /**\n * Determine if the USJ document location in this node and document location is pointing to a text\n * content location instead of some location related to a marker object\n *\n * @param usjNodeAndDocumentLocation USJ node and document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjNodeAndDocumentLocation: UsjNodeAndDocumentLocation,\n ): usjNodeAndDocumentLocation is UsjNodeAndDocumentLocation;\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocationMaybeNode: UsjDocumentLocation | UsjNodeAndDocumentLocation,\n ): boolean {\n let documentLocation = usjDocumentLocationMaybeNode;\n if ('node' in usjDocumentLocationMaybeNode) {\n // If it's a UsjNodeAndDocumentLocation, the node must be a string\n if (!isString(usjDocumentLocationMaybeNode.node)) return false;\n\n documentLocation = usjDocumentLocationMaybeNode.documentLocation;\n }\n\n // Text content representation in USJDocumentLocation requires offset and nothing else has offset\n return 'offset' in documentLocation;\n }\n\n // #endregion UsjDocumentLocation utilities\n\n // #region Search for text from a certain point\n\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n // Get the location of the verse marker\n const verseLocation = this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation);\n\n // Find the first string after the verse marker\n const firstStringLocationAfterVerseMarker = this.findNextLocationOfMatchingText(\n verseLocation,\n '',\n );\n\n if (!firstStringLocationAfterVerseMarker)\n throw new Error(\n `Could not find next text location after verse ${JSON.stringify(usfmVerseLocation)} at location ${\n verseLocation.documentLocation.jsonPath\n }`,\n );\n\n return firstStringLocationAfterVerseMarker;\n }\n\n findNextLocationOfMatchingText(\n startingPoint: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number = 1000,\n ): UsjNodeAndDocumentLocation | undefined {\n let textScanned = '';\n let lengthScanned = 0;\n let lengthTrimmed = 0;\n let foundStartingAtOffset = -1;\n const workingStackForStartingPoint = this.convertJsonPathToWorkingStack(\n startingPoint.documentLocation.jsonPath,\n );\n // Get the starting point stack item so we can offset our staring search point by the offset.\n // But if we started at the top USJ marker, the starting point isn't text, so we don't need to\n // worry about offsetting as there is no offset.\n // Cloning because the working stack items are modified during search\n const startingPointStackItem =\n workingStackForStartingPoint.length > 0\n ? {\n ...workingStackForStartingPoint[workingStackForStartingPoint.length - 1],\n }\n : undefined;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n workingStackForStartingPoint,\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n let nodeTextToSearch = node;\n\n const currentStackItem = workingStack[workingStack.length - 1];\n\n // If the node is the starting point, then we need to start scanning from the offset.\n // Otherwise look from the start of the string\n if (\n startingPointStackItem &&\n UsjReaderWriter.areStackItemsShallowEqual(currentStackItem, startingPointStackItem)\n ) {\n if (!('offset' in startingPoint.documentLocation))\n throw new Error(\n `Somehow 'offset' was not in text content string document location. This should not happen. ${JSON.stringify(startingPoint.documentLocation)}`,\n );\n nodeTextToSearch = node.substring(startingPoint.documentLocation.offset);\n // We're skipping the offset characters in the first node, so we need to adjust the final\n // foundStartingAtOffset to account for that\n lengthTrimmed += startingPoint.documentLocation.offset;\n }\n\n lengthScanned += nodeTextToSearch.length;\n textScanned = `${textScanned}${nodeTextToSearch}`;\n const textIndex = textScanned.indexOf(text);\n if (textIndex < 0) {\n // Keep the string we're keeping around from going too large\n lengthTrimmed += textScanned.length;\n if (textScanned.length > text.length)\n textScanned = textScanned.substring(textScanned.length - text.length);\n lengthTrimmed -= textScanned.length;\n\n // Stop looking if we haven't found it after scanning a lot of text\n return lengthScanned > maxTextLengthToSearch;\n }\n\n // We found it!\n foundStartingAtOffset = lengthTrimmed + textIndex;\n return true;\n },\n );\n\n // We never found what we wanted\n if (foundStartingAtOffset < 0) return undefined;\n\n // The text might have been split between nodes, so we have to go through it one more time\n lengthScanned = 0;\n let finalOffset = 0;\n let finalStack: WorkingStack = [];\n const finalNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, stack) => {\n if (typeof node !== 'string') return false;\n\n lengthScanned += node.length;\n if (lengthScanned < foundStartingAtOffset + 1) return false;\n\n finalOffset = foundStartingAtOffset - lengthScanned + node.length;\n finalStack = stack;\n return true;\n },\n );\n if (!finalNode) throw new Error('Internal error: inconsistent search results');\n if (!isString(finalNode))\n throw new Error(\n `Somehow found non-string node while searching for strings: ${JSON.stringify(finalNode)}`,\n );\n\n return {\n node: finalNode,\n documentLocation: {\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(finalStack),\n offset: finalOffset,\n },\n };\n }\n\n search(regex: RegExp): UsjSearchResult[] {\n const retVal: UsjSearchResult[] = [];\n if (this.usj.content.length === 0) return retVal;\n\n // Start searching from the first node in the USJ content tree\n const startingPoint: UsjNodeAndDocumentLocation = {\n node: this.usj,\n documentLocation: {\n jsonPath: `$`,\n },\n };\n\n // This will hold all of the text content from the USJ, so we can search it all at once\n const textChunks: string[] = [];\n // This will map the index of each text chunk in the full text, so we can find the location\n const fullTextIndexMap = new SortedNumberMap<\n UsjNodeAndDocumentLocation\n >();\n\n // Variables to track our current position while walking through the USJ content tree\n let currentIndex = 0;\n let nextNode: MarkerContent | Usj | undefined = startingPoint.node;\n while (nextNode !== undefined) {\n nextNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n [],\n // We need to use variables from outside the function to keep track of our current position\n // eslint-disable-next-line no-loop-func\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n textChunks.push(node);\n fullTextIndexMap.set(currentIndex, {\n node,\n documentLocation: {\n offset: 0,\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(workingStack),\n },\n });\n currentIndex += node.length;\n return false;\n },\n );\n }\n\n // Connect all the text chunks together so we can search them all at once. Note that there are\n // no spaces between the text chunks. If we need spaces inserted between verses, chapters, etc.\n // then we should adjust how we walk through the tree to insert extra spaces at the right times.\n const fullText = textChunks.join('');\n\n // Lean on regular expressions to do the heavy lifting of finding matches\n let match: RegExpExecArray | null = regex.exec(fullText);\n while (match) {\n // If the match is empty, then we don't want to include it in the results\n if (match[0].length > 0) {\n if (match.index < 0 || match.index >= fullText.length)\n throw new Error(`Match index out of bounds: ${match.index}`);\n\n const startingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(match.index);\n if (!startingNodeEntry)\n throw new Error(`Internal error: no starting node found for index ${match.index}`);\n const start: UsjNodeAndDocumentLocation = {\n node: startingNodeEntry.value.node,\n documentLocation: {\n jsonPath: startingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index - startingNodeEntry.key,\n },\n };\n\n // Have to find the node containing the last character in the match so we don't go past the\n // ending text node and to the next text node that may be multiple markers past the end text\n // node. Then do NOT subtract one from the index in the offset since the ending location is\n // exclusive, meaning the last character in the match is the character before the ending\n // location.\n const endingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(\n match.index + match[0].length - 1,\n );\n if (!endingNodeEntry)\n throw new Error(`Internal error: no ending node found for index ${match.index}`);\n const end: UsjNodeAndDocumentLocation = {\n node: endingNodeEntry.value.node,\n documentLocation: {\n jsonPath: endingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index + match[0].length - endingNodeEntry.key,\n },\n };\n\n retVal.push({ text: match[0], start, end });\n }\n\n // If the regex is not global, then running `exec` again will return the same match\n if (!regex.global) break;\n match = regex.exec(fullText);\n }\n\n return retVal;\n }\n\n // #endregion Search for text from a certain point\n\n // #region Extract text from a node + JSONPath + offset\n\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string {\n let retVal = '';\n let offsetRemaining = 'offset' in start.documentLocation ? start.documentLocation.offset : 0;\n let lengthRecorded = 0;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node) => {\n if (typeof node !== 'string') return false;\n if (offsetRemaining >= node.length) {\n offsetRemaining -= node.length;\n return false;\n }\n let remainingNode = node;\n if (offsetRemaining > 0) {\n remainingNode = remainingNode.substring(offsetRemaining);\n offsetRemaining = 0;\n }\n if (lengthRecorded + remainingNode.length < desiredLength) {\n lengthRecorded += remainingNode.length;\n retVal = `${retVal}${remainingNode}`;\n return false;\n }\n const lengthToCopy = desiredLength - lengthRecorded;\n retVal = `${retVal}${remainingNode.substring(0, lengthToCopy - 1)}`;\n return true;\n },\n );\n return retVal;\n }\n\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number = 100,\n ): string {\n let retVal = '';\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, currentStack) => {\n // `node` and `end.node` are both `MarkerContent` which might be strings or objects\n if (node === end.node) {\n // If both objects are the same, then we definitely found `end`\n if (typeof node === 'object') return true;\n\n // If both strings are the same, we need to verify that we're at the same place in `usj`\n if (\n end.documentLocation.jsonPath ===\n UsjReaderWriter.convertWorkingStackToJsonPath(currentStack)\n )\n return true;\n }\n if (typeof node !== 'string') return false;\n retVal = `${retVal}${node}`;\n if (retVal.length > maxLength) retVal = retVal.substring(0, maxLength);\n return retVal.length >= maxLength;\n },\n );\n return retVal;\n }\n\n // #endregion Extract text from a node + JSONPath + offset\n\n // #region Edit this USJ data\n\n private static removeContentNodesFromArray(\n contentArray: MarkerContent[],\n searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean,\n ) {\n let removedCount = 0;\n for (let i = contentArray.length - 1; i >= 0; i--) {\n const node = contentArray[i];\n if (searchFunction(node)) {\n contentArray.splice(i, 1);\n removedCount += 1;\n } else if (typeof node !== 'string' && node.content)\n removedCount += this.removeContentNodesFromArray(node.content, searchFunction);\n }\n return removedCount;\n }\n\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number {\n const retVal = UsjReaderWriter.removeContentNodesFromArray(this.usj.content, searchFunction);\n this.usjChanged();\n return retVal;\n }\n\n // #endregion Edit this USJ data\n\n // #region transform USJ to USFM\n\n /**\n * Get `MarkerInfo` by marker name\n *\n * @param markerName Name of the marker for which to get `MarkerInfo`\n * @returns `MarkerInfo` for the marker by name if the marker is in the markers map. `undefined`\n * if the marker is not in the markers map. If you have the marker type, you can build a fake\n * `MarkerInfo` for an unknown marker by making an object with just the type. If not, might be\n * best to throw an error since there probably isn't enough information available to do anything\n * with that marker.\n */\n private getMarkerInfo(markerName: string): MarkerInfo | undefined {\n // Try to get by exact marker name first\n let markerInfo = this.markersMap.markers[markerName];\n\n // If not found by exact name, try to match the RegExp marker names\n if (!markerInfo)\n [, markerInfo] =\n Object.entries(this.markersMap.markersRegExp).find(([markerRegExp]) =>\n new RegExp(markerRegExp).test(markerName),\n ) ?? [];\n\n // Return the marker info we found or `undefined` if we didn't find one\n return markerInfo;\n }\n\n /**\n * Gathers various pieces of information about a marker that are helpful for transforming the\n * marker to USFM\n *\n * WARNING: this only has the ability to return the info for the marker to be used in USFM. If you\n * need to use info for the marker in USX or USJ, this method needs to be modified.\n *\n * @param marker A USJ marker (can be USJ type) or a string which is the marker name\n * @param scriptureFormat The Scripture format to get the marker information for. For example, if\n * you are using this marker info to transform the marker into USFM, this should be `usfm`.\n * Defaults to `usfm`\n * @returns Various pieces of info about the marker\n */\n private getInfoForMarker(\n marker: MarkerObject | Usj | string,\n scriptureFormat: 'usfm' = 'usfm',\n ): {\n /**\n * Marker name on the original marker itself as opposed to the marker name in this Scripture\n * format\n */\n markerNameOriginal: string;\n /**\n * Name of the marker in this Scripture format. For example, In USFM format, the `usx` marker's\n * name is `usfm`\n */\n markerName: string;\n /** Marker info corresponding to `markerName`, not `markerNameOriginal` */\n markerInfo: MarkerInfo;\n /**\n * This marker's type in this Scripture format. For example, In USFM format, the `table:cell`\n * type is `cell`\n */\n markerType: string;\n /** Marker info corresponding to `markerType`, not the marker's original `type` */\n markerTypeInfo: MarkerTypeInfo;\n /**\n * Array of tuples containing the USFM name of an attribute marker that may be present on this\n * marker and the marker info for that attribute marker\n *\n * This is like the returned value from `Object.entries`. However, the order of these is\n * important in some cases, so it cannot simply be an object.\n */\n attributeMarkerInfoEntries: [\n attributeMarkerName: string,\n attributeMarkerInfo: AttributeMarkerInfo,\n ][];\n } {\n if (scriptureFormat !== 'usfm')\n throw new Error(\n 'Scripture formats beside usfm are not supported for getting info for markers',\n );\n\n const markerNameOriginal = isString(marker)\n ? marker\n : // Usj type has no `marker` property, but the Usj marker isn't really different than any other\n // marker with no `marker` property. It is appropriate to treat them the same to get the name\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n ((marker as MarkerObject).marker ?? marker.type);\n\n // If we don't have marker info for the marker or the marker type doesn't match the type in the\n // marker info, this marker is considered unknown. Do some special handling.\n let markerIsUnknown = false;\n\n let markerInfo = this.getMarkerInfo(markerNameOriginal);\n const markerTypeFromFirstMarkerInfo = markerInfo?.type ?? (isString(marker) ? '' : marker.type);\n let markerName = markerNameOriginal;\n\n // Get the actual marker name and info in this format if it is different\n if (markerInfo?.markerUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerName = markerInfo.markerUsfm;\n markerInfo = this.getMarkerInfo(markerName);\n }\n\n // Didn't find the marker, so create `MarkerInfo` with the marker type if possible\n if (!markerInfo) {\n if (isString(marker))\n throw new Error(`Unknown marker ${markerNameOriginal} and no marker type provided`);\n\n markerInfo = { type: marker.type };\n markerIsUnknown = true;\n\n console.warn(\n `Unknown marker ${markerNameOriginal}. Creating MarkerInfo to use: ${JSON.stringify(markerInfo)}`,\n );\n }\n\n // Get the marker type\n let markerType = markerInfo.type;\n let markerTypeInfo = this.markersMap.markerTypes[markerType];\n\n // Get the actual marker type and type info in this format if it is different\n if (markerTypeInfo?.markerTypeUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerType = markerTypeInfo.markerTypeUsfm;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n }\n\n // If the actual marker's type is not one of the expected types, something is wrong. Use the\n // actual marker's type\n if (\n !isString(marker) &&\n marker.type !== markerTypeFromFirstMarkerInfo &&\n (!markerTypeInfo ||\n (marker.type !== markerTypeInfo.markerTypeUsfm &&\n marker.type !== markerTypeInfo.markerTypeUsx &&\n marker.type !== markerTypeInfo.markerTypeUsj))\n ) {\n console.warn(\n `Warning: Mismatching marker type in the USJ content ${marker.type} vs marker type in the marker info ${markerInfo.type} for marker ${markerNameOriginal}. Using the type from the USJ content.`,\n );\n markerType = marker.type;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n markerIsUnknown = true;\n }\n\n // Couldn't find the marker type info\n // Note: In this case, Paratext just ignores the marker and prints the marker's content. This\n // really shouldn't happen, though. I had to manually change a marker type in USX and then import\n // it to Paratext to see this behavior. If you hit this, something is already going terribly wrong.\n if (!markerTypeInfo) {\n throw new Error(\n `Unknown marker type ${markerType} on marker ${markerNameOriginal}! Cannot proceed.`,\n );\n }\n\n if (markerIsUnknown && markerType === 'para')\n // Special case: If the marker type is para and it is unknown, do not add a newline before\n // the marker to match Paratext 9.4. We'll just do the same for spec for now since spec\n // seems to be silent regarding what to do about unknown markers\n markerTypeInfo = { ...markerTypeInfo, hasNewlineBefore: false };\n\n // Figure out attribute marker attribute names\n const attributeMarkerInfoEntries: [string, AttributeMarkerInfo][] = [];\n if (markerInfo.attributeMarkers) {\n markerInfo.attributeMarkers.forEach((attributeMarkerName) => {\n // Note: we are not attempting to get the appropriate marker for the relevant Scripture\n // representation aka we are not using `markerUsfm` for example. There are no attribute\n // markers that have alternate representations and are not likely to be any ever. If that\n // changes, this may cause bugs.\n const attributeMarkerInfo = this.getMarkerInfo(attributeMarkerName);\n\n // Markers map lists an attribute marker that doesn't exist. Just skip this attribute\n if (!attributeMarkerInfo) return;\n\n // Markers map lists an attribute marker that doesn't seem to be an attribute marker.\n // Just skip this attribute\n if (!('attributeMarkerAttributeName' in attributeMarkerInfo)) return;\n\n attributeMarkerInfoEntries.push([attributeMarkerName, attributeMarkerInfo]);\n });\n }\n\n // According to `cell`'s `outputToUsfmInstructions`, cell-type markers with `colspan` need to be\n // cell range marker in USFM, so let's figure that out now\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n if (scriptureFormat === 'usfm' && markerType === 'cell' && markerWithAnyAttributes.colspan) {\n // Get the number of columns that this cell spans\n const columnsSpanned = parseInt(markerWithAnyAttributes.colspan, 10);\n\n const tableMarkerMatches = TABLE_MARKER_NUMBER_REGEXP.exec(markerNameOriginal);\n\n if (tableMarkerMatches?.[1]) {\n // Get the starting cell column number\n const startingColumn = parseInt(tableMarkerMatches[1], 10);\n if (!Number.isNaN(startingColumn) && !Number.isNaN(columnsSpanned)) {\n // Create cell range marker like `tc1-3`\n markerName = `${markerNameOriginal}-${startingColumn + columnsSpanned - 1}`;\n // Set `colspan` so it is not output to USFM since it was just incorporated properly\n markerTypeInfo = {\n ...markerTypeInfo,\n skipOutputAttributeToUsfm: [\n ...(markerTypeInfo.skipOutputAttributeToUsfm ?? []),\n 'colspan',\n ],\n };\n }\n }\n }\n\n return {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n };\n }\n\n /** Converts the text content of a marker to its equivalent in USFM */\n private textContentToUsfm(textContent: string): UsfmSnippetAndUsjFragmentsInfo {\n // Special case: NBSP should be replaced with ~ in USFM if invisible characters are not allowed\n return {\n usfm: this.shouldAllowInvisibleCharacters\n ? textContent\n : textContent.replace(TEXT_CONTENT_NBSP_REGEXP, '~'),\n fragmentsInfo: [{ fragment: textContent, indexInUsfm: 0 }],\n };\n }\n\n /**\n * Merge an independent array of fragment info into an existing array of fragment info, offsetting\n * the indices of the new fragments so their locations start from the end of the string\n */\n private static mergeFragmentsInfoIntoExistingArray(\n newFragmentsInfo: UsjFragmentInfoMinimal[],\n existingFragmentsInfo: UsjFragmentInfoMinimal[],\n existingUsfmLength: number,\n ) {\n newFragmentsInfo.forEach((fragmentInfo) => {\n const fragmentIndex = existingUsfmLength + fragmentInfo.indexInUsfm;\n existingFragmentsInfo.push({\n ...fragmentInfo,\n indexInUsfm: fragmentIndex,\n });\n });\n }\n\n /**\n * Transforms the provided USJ marker into its opening marker representation in USFM\n *\n * Includes a newline before the marker if applicable. Generally also includes a space at the end.\n *\n * Opening markers generally look like the following:\n *\n * ```text\n * \\markerName leadingAttributes textContentAttribute attributeMarkers\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come before the contents of the\n * marker in USFM\n */\n private openingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { markerName, markerInfo, markerType, markerTypeInfo, attributeMarkerInfoEntries } =\n this.getInfoForMarker(marker);\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // Add newline before the marker if there's supposed to be one\n if (markerTypeInfo.hasNewlineBefore) usfm += `\\n`;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n // Add the marker name\n // Fragment representing the very beginning of the marker is the marker itself\n fragmentsInfo.push({ fragment: marker, indexInUsfm: usfm.length });\n // Special case: `optbreak` - transform to `//`\n usfm += markerType === 'optbreak' ? '//' : `\\\\${markerPrefix}`;\n\n if (markerType !== 'optbreak') {\n // Fragment representing the marker name is the `marker` property\n fragmentsInfo.push({\n fragment: { attributeValueForKey: 'marker', forMarker: marker },\n indexInUsfm: usfm.length,\n });\n\n // According to `unmatched`'s `outputToUsfmInstructions`, no space after the marker name\n // because it is basically a closing marker\n usfm += `${markerName}${markerType === 'unmatched' ? '' : ' '}`;\n }\n\n // Add leading attributes in listed order\n if (markerInfo.leadingAttributes) {\n markerInfo.leadingAttributes.forEach((attributeName) => {\n const attributeValue = markerWithAnyAttributes[attributeName];\n\n if (!attributeValue) return;\n\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeValue} `;\n });\n }\n\n // Add text content attribute\n if (\n markerInfo.textContentAttribute &&\n markerWithAnyAttributes[markerInfo.textContentAttribute]\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.textContentAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[markerInfo.textContentAttribute]} `;\n }\n\n // Add attribute markers in listed order\n if (markerInfo.attributeMarkers) {\n attributeMarkerInfoEntries.forEach(([attributeMarkerName, attributeMarkerInfo]) => {\n const attributeValue =\n markerWithAnyAttributes[attributeMarkerInfo.attributeMarkerAttributeName];\n\n if (!attributeValue) return;\n\n // Create a marker that represents this attribute marker so we can make the USFM\n const attributeMarker: MarkerObject = {\n type: attributeMarkerInfo.type,\n marker: attributeMarkerName,\n content: [attributeValue],\n };\n\n // Add the attribute marker USFM to the document\n\n // Collect opening and closing attribute marker fragments so we can modify them before adding\n // them to the main fragments\n const attributeMarkerFragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Caveat: it's not technically always true that this marker is the parent of the attribute\n // markers, but there is currently no known case where it matters because there are no\n // attribute markers that have the same marker type as the marker on which they are\n // attributes. It likely will never matter as this is a very strange concept and it seems\n // the USFM committee doesn't want to create more attribute markers.\n usfm = this.addMarkerUsfmToString(\n usfm,\n attributeMarker,\n marker,\n attributeMarkerFragmentsInfo,\n );\n const { usfm: textContentUsfm } = this.textContentToUsfm(attributeValue);\n fragmentsInfo.push({\n fragment: {\n attributeValueForKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n indexInUsfm: usfm.length,\n });\n usfm += textContentUsfm;\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: attributeMarker,\n },\n marker,\n attributeMarkerFragmentsInfo,\n );\n\n // Transform the opening fragments to attribute marker fragments and add them to the main\n // fragments\n attributeMarkerFragmentsInfo.forEach((fragmentInfo) => {\n // There should never be such a thing as text content in the opening/closing of an attribute\n // marker or an attribute key for an attribute marker\n if (isString(fragmentInfo.fragment) || 'attributeKey' in fragmentInfo.fragment)\n throw new Error(\n `Attribute marker opening or closing markers generated a text content fragment or an attribute key fragment! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n\n if (UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment)) {\n // Opening marker. Need to point to the original marker and indicate this is the opening\n // marker for its attribute marker\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n\n return;\n }\n\n if ('attributeValueForKey' in fragmentInfo.fragment) {\n // There should never be an attribute value for an attribute marker other than the marker name\n if (fragmentInfo.fragment.attributeValueForKey !== 'marker')\n throw new Error(\n `Attribute marker opening or closing markers generated an attribute value fragment for a key that was not marker! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n // Marker representation of the attribute marker. Change to attribute key for attribute\n // marker attribute name.\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n return;\n }\n\n if ('isClosingMarker' in fragmentInfo.fragment) {\n // Closing marker. Need to point to the original marker and indicate this is the closing\n // marker for its attribute marker\n\n // Need to remove isClosingMarker but will not use it again. This was the easiest way to\n // delete it without TypeScript going berserk\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars\n const { isClosingMarker: _, ...partialClosingFragment } = fragmentInfo.fragment;\n\n const fragment: UsjAttributeMarkerClosingMarkerFragment = {\n ...partialClosingFragment,\n forMarker: marker,\n attributeMarkerClosingMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n };\n\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment,\n });\n\n return;\n }\n\n // That should have been all of them, so not sure what other fragment this could be\n throw new Error(\n `Attribute marker opening or closing markers generated an unrecognized fragment: ${JSON.stringify(fragmentInfo)}`,\n );\n });\n\n if (\n !this.markersMap.isSpaceAfterAttributeMarkersContent &&\n attributeMarkerInfo.hasStructuralSpaceAfterCloseAttributeMarker\n )\n // Add the optional structural space after the attribute marker according to spec\n usfm += ' ';\n });\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Transforms the provided USJ marker into its closing marker representation in USFM\n *\n * Closing markers do not include the attributes listed as part of the opening markers (leading\n * attributes, text content attributes, and attribute markers). They only include other kinds of\n * attributes including the default attribute if present.\n *\n * Closing markers with only the default attribute present generally look like the following:\n *\n * ```text\n * |defaultAttribute\\markerName*\n * ```\n *\n * Closing markers with at least one non-default attribute present generally look like the\n * following:\n *\n * ```text\n * |attributeName=\"AttributeValue\" attributeName=\"AttributeValue\"\\markerName*\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come after the contents of the\n * marker in USFM\n */\n private closingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n const {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n } = this.getInfoForMarker(marker);\n\n // Gather attributes that are not listed as part of the opening marker and not skipped in USFM\n const closingMarkerAttributeNames = Object.keys(marker).filter((attributeName) => {\n // Special case: skip properties that are not attributes\n if (attributeName === 'type') return false;\n if (attributeName === 'marker') return false;\n if (attributeName === 'content') return false;\n if (attributeName === 'closed') return false;\n\n // Skip attributes that are supposed to be skipped when outputting to USFM\n if (markerTypeInfo.skipOutputAttributeToUsfm?.includes(attributeName)) return false;\n\n // Not a leadingAttribute\n if (markerInfo.leadingAttributes?.includes(attributeName)) return false;\n\n // Not a textContentAttribute\n if (markerInfo.textContentAttribute === attributeName) return false;\n\n // Not an attributeMarker\n if (\n attributeMarkerInfoEntries.some(\n ([, attributeMarkerInfo]) =>\n attributeMarkerInfo.attributeMarkerAttributeName === attributeName,\n )\n )\n return false;\n\n // There are no other attributes that go on the opening marker, so this must go on the closing\n // marker\n return true;\n });\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // We don't have examples of markers that have both normal closing markers and independent\n // closing markers, so just throw an error if we encounter this situation\n if (\n markerTypeInfo.isCloseable &&\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0\n )\n throw new Error(\n `Marker ${\n markerName\n } is intended to have a normal closing marker and independent closing markers. As of writing this code, there is no known syntax for this situation in USFM. Cannot proceed.`,\n );\n\n // Determine if the marker is supposed to have an explicit closing marker\n let hasExplicitClosingMarker = true;\n // If the closing marker is specified as not present, it should not be present no matter what\n if (markerWithAnyAttributes.closed === 'false') hasExplicitClosingMarker = false;\n else if (\n markerInfo.isClosingMarkerOptional &&\n !this.markersMap.shouldOptionalClosingMarkersBePresent &&\n markerWithAnyAttributes.closed !== 'true'\n ) {\n // If the closing marker is optional, if optional closing markers should be left out, and\n // if it is not specified as closed, then it should not have a closing marker\n hasExplicitClosingMarker = false;\n }\n\n // If this marker has an independent closing marker, create that\n if (\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0 &&\n hasExplicitClosingMarker\n ) {\n // Create a marker that represents this independent closing marker so we can make the USFM\n const independentClosingMarker: MarkerObject = {\n type: markerType,\n marker: markerInfo.independentClosingMarkers[0],\n // Put all the closing marker attributes on here since we don't really have a better place\n // to put them and might as well\n ...Object.fromEntries(\n closingMarkerAttributeNames.map((attributeName) => [\n attributeName,\n markerWithAnyAttributes[attributeName],\n ]),\n ),\n };\n\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { usfm: openingMarkerUsfm, fragmentsInfo: openingFragmentsInfo } =\n this.openingMarkerToUsfm(independentClosingMarker, isInsideMarkerWithSameType);\n // Fragment for independent closing marker is just the normal closing fragment. So find the\n // opening fragment, change it to closing fragment, and add it to the fragments for this\n // marker. Need to get the opening marker so we have the right indexInUsfm (might be 1 if\n // the marker has a newline before it, for example)\n const openingFragmentInfo = openingFragmentsInfo.find((fragmentInfo) => {\n return UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment);\n });\n if (!openingFragmentInfo)\n throw new Error(\n `Could not find opening fragment info for independent closing marker ${JSON.stringify(\n independentClosingMarker,\n )}. Fragments info generated: ${JSON.stringify(openingFragmentsInfo)}`,\n );\n fragmentsInfo.push({\n ...openingFragmentInfo,\n fragment: { isClosingMarker: true, forMarker: marker },\n });\n usfm += openingMarkerUsfm;\n // Only add the independent closing marker if it does not have the same name as the marker we\n // are closing so we don't get in an infinite loop\n if (markerNameOriginal !== independentClosingMarker.marker)\n // ENHANCE: If we ever have a situation where closing marker attributes get on a marker\n // with an independent closing marker, let's add fragments for the attributes here. Though\n // I think this may be something the USFM committee intends to avoid doing based on the\n // proposal to add attributes at the opening marker\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: independentClosingMarker,\n },\n isInsideMarkerWithSameType,\n );\n\n return { usfm, fragmentsInfo };\n }\n\n // This marker doesn't have an independent closing marker, so create a normal closing marker\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Add attributes to the closing marker USFM\n if (closingMarkerAttributeNames.length > 0) {\n // Add the bar before closing attributes\n usfm += '|';\n\n // Default attribute syntax if it is the only attribute present\n if (\n closingMarkerAttributeNames.length === 1 &&\n closingMarkerAttributeNames[0] === markerInfo.defaultAttribute\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.defaultAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += markerWithAnyAttributes[markerInfo.defaultAttribute];\n } else {\n // List all attributes with key and value\n closingMarkerAttributeNames.forEach((attributeName, index) => {\n // According to `figure`'s `outputToUsfmInstructions`, figure's file attribute is src in USFM\n const attributeNameUsfm =\n markerType === 'figure' && attributeName === 'file' ? 'src' : attributeName;\n // Add to the accumulated usfm (starting with a bar): a space if this is after the first\n // attribute, then the attribute name, then =, then \"the attribute value\"\n if (index > 0) usfm += ' ';\n fragmentsInfo.push({\n fragment: { attributeKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeNameUsfm}=\"`;\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[attributeName]}\"`;\n });\n }\n }\n\n // Add the normal closing marker\n if (markerTypeInfo.isCloseable && hasExplicitClosingMarker) {\n const closingMarkerName = markerTypeInfo.isClosingMarkerEmpty ? '' : markerName;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n fragmentsInfo.push({\n fragment: { isClosingMarker: true, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `\\\\${markerPrefix}${closingMarkerName}*`;\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Determines whether this marker and all its content should be skipped entirely when outputting\n * to USFM\n *\n * @param marker Marker to check\n * @returns `true` if this marker should be skipped; `false` otherwise\n */\n private shouldSkipOutputMarkerToUsfm(marker: MarkerObject | Usj) {\n const { markerTypeInfo } = this.getInfoForMarker(marker);\n\n if (markerTypeInfo.skipOutputMarkerToUsfm) return true;\n\n if (\n markerTypeInfo.skipOutputMarkerToUsfmIfAttributeIsPresent?.some(\n (attributeName) => attributeName in marker,\n )\n )\n return true;\n\n return false;\n }\n\n /** Removes one space at the end of the string if present */\n private static removeEndSpace(value: string) {\n // TODO: should this use the surrogate-aware functions?\n if (value.at(-1) !== ' ') return value;\n return value.slice(0, -1);\n }\n\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param markerParent Parent of the marker being added. Used to determine if this marker is\n * nested within another marker of the same type\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | Usj | UsjClosingMarkerFragment,\n markerParent: MarkerObject | Usj | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n isInsideMarkerWithSameType: boolean,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n markerParentOrIsInsideMarkerWithSameType: MarkerObject | Usj | boolean | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string {\n let usfmOutput = usfm;\n\n // Build up the marker's usfm and fragment info separately first because we may modify it before\n // adding it to the full usfm\n let markerUsfmOutput;\n let markerFragmentsInfo: UsjFragmentInfoMinimal[];\n\n const { markerNameOriginal, markerType, markerTypeInfo } = this.getInfoForMarker(\n 'isClosingMarker' in marker ? marker.forMarker : marker,\n );\n\n // Determine if this marker is a direct child of another marker of the same type\n let isParentSameType = false;\n if (typeof markerParentOrIsInsideMarkerWithSameType === 'boolean')\n isParentSameType = markerParentOrIsInsideMarkerWithSameType;\n else if (markerParentOrIsInsideMarkerWithSameType) {\n const { markerType: parentMarkerType } = this.getInfoForMarker(\n markerParentOrIsInsideMarkerWithSameType,\n );\n if (parentMarkerType === markerType) {\n isParentSameType = true;\n }\n }\n\n if ('isClosingMarker' in marker) {\n const { usfm: closingUsfm, fragmentsInfo: closingFragmentsInfo } = this.closingMarkerToUsfm(\n marker.forMarker,\n isParentSameType,\n );\n markerFragmentsInfo = closingFragmentsInfo;\n markerUsfmOutput = closingUsfm;\n\n // If the closing marker is supposed to be empty, there was nothing in the marker content, and\n // there are no closing marker attributes present, we need to remove the structural space after\n // the opening marker\n if (\n markerTypeInfo.isCloseable &&\n markerTypeInfo.isClosingMarkerEmpty &&\n // No contents\n (!marker.forMarker.content || marker.forMarker.content.length === 0) &&\n // No closing marker attributes\n !markerUsfmOutput.startsWith('|')\n ) {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n } else {\n const { usfm: openingUsfm, fragmentsInfo: openingFragmentsInfo } = this.openingMarkerToUsfm(\n marker,\n isParentSameType,\n );\n markerFragmentsInfo = openingFragmentsInfo;\n markerUsfmOutput = openingUsfm;\n }\n\n if (markerUsfmOutput.startsWith('\\n')) {\n if (usfmOutput.length === 0) {\n // If the USFM is empty, don't add a newline at the start\n markerFragmentsInfo = markerFragmentsInfo.map((fragmentInfo) => ({\n ...fragmentInfo,\n indexInUsfm: fragmentInfo.indexInUsfm - 1,\n }));\n markerUsfmOutput = markerUsfmOutput.substring(1);\n } else {\n // If there's supposed to be a newline before the marker, it should eat the last space if\n // there is one (that last space gets turned into the newline in this format)\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n }\n\n // Special case: `ca` after chapter marker needs a newline and space before in Paratext USFM for\n // some reason\n // Note that there is not a newline and space before `ca` after importing from USX in Paratext,\n // so maybe we should just remove the newline and space in the PDP\n if (this.markersMap.isSpaceAfterAttributeMarkersContent && markerNameOriginal === 'ca') {\n // Find the last marker in the current USFM output\n const lastMarkerBackslashIndex = usfmOutput.lastIndexOf('\\\\');\n if (lastMarkerBackslashIndex >= 0) {\n // We just want to know if it's a chapter marker, so we can just get two characters, c and space\n const lastMarker = usfm.substring(\n lastMarkerBackslashIndex + 1,\n lastMarkerBackslashIndex + 3,\n );\n if (lastMarker === 'c ') {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n usfmOutput += '\\n ';\n }\n }\n }\n\n // Add the marker fragments and USFM into the existing fragments and USFM\n if (fragmentsInfo)\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n markerFragmentsInfo,\n fragmentsInfo,\n usfmOutput.length,\n );\n usfmOutput += markerUsfmOutput;\n\n return usfmOutput;\n }\n\n toUsfm() {\n // See calculateUsfmProperties method for implementation\n return this.usfm;\n }\n\n // #endregion transform USJ to USFM\n\n // #region fragment utilities\n\n /**\n * Returns a new {@link UsjDocumentLocation} based on the one passed in but with the offset\n * provided. If the location passed in does not have an offset property, a shallow clone of the\n * location will be returned with no changes.\n */\n private static moveUsjDocumentLocationToNewOffset(\n usjLocation: UsjDocumentLocation,\n usjOffset: number,\n ): UsjDocumentLocation {\n const newLocation = { ...usjLocation };\n\n // UsjTextContentLocation\n if ('offset' in newLocation) newLocation.offset = usjOffset;\n // UsjClosingMarkerLocation\n else if ('closingMarkerOffset' in newLocation) newLocation.closingMarkerOffset = usjOffset;\n // UsjPropertyValueLocation\n else if ('propertyOffset' in newLocation) newLocation.propertyOffset = usjOffset;\n // UsjAttributeKeyLocation\n else if ('keyOffset' in newLocation) newLocation.keyOffset = usjOffset;\n // UsjClosingAttributeMarkerLocation\n else if ('keyClosingMarkerOffset' in newLocation)\n newLocation.keyClosingMarkerOffset = usjOffset;\n // No offset; no change:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return newLocation;\n }\n\n /**\n * Returns the offset of whatever kind that is found in the UsjDocumentLocation. Returns 0 if the\n * location passed in does not have an offset property.\n */\n private static getOffsetInUsjDocumentLocation(usjLocation: UsjDocumentLocation): number {\n // UsjTextContentLocation\n if ('offset' in usjLocation) return usjLocation.offset;\n // UsjClosingMarkerLocation\n if ('closingMarkerOffset' in usjLocation) return usjLocation.closingMarkerOffset;\n // UsjPropertyValueLocation\n if ('propertyOffset' in usjLocation) return usjLocation.propertyOffset;\n // UsjAttributeKeyLocation\n if ('keyOffset' in usjLocation) return usjLocation.keyOffset;\n // UsjClosingAttributeMarkerLocation\n if ('keyClosingMarkerOffset' in usjLocation) return usjLocation.keyClosingMarkerOffset;\n // No offset:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return 0;\n }\n\n /**\n * Compares two UsjDocumentLocations to determine if they are pointing to the same location\n *\n * @param a The first location to compare\n * @param b The second location to compare\n * @param ignoreJsonPath If `true`, the JSONPath properties of the locations will be ignored in\n * the comparison. This is useful if you have already determined that the JSONPaths are the\n * same\n */\n private static areUsjDocumentLocationsEqual(\n a: UsjDocumentLocation,\n b: UsjDocumentLocation,\n ignoreJsonPath = false,\n ) {\n const { jsonPath: aJsonPath, ...restOfA } = a;\n const { jsonPath: bJsonPath, ...restOfB } = b;\n\n // Determine if the two JSONPaths are equivalent even if they use different property syntax\n if (\n !ignoreJsonPath &&\n !deepEqual(JSONPath.toPathArray(aJsonPath), JSONPath.toPathArray(bJsonPath))\n )\n return false;\n\n // Determine if the rest of the location information is the same\n return deepEqual(restOfA, restOfB);\n }\n\n /** Find the fragment info corresponding to the specified USJ Document location. */\n private findFragmentInfoAtUsjDocumentLocation(\n usjLocation: UsjDocumentLocation,\n ): UsjFragmentInfo | undefined {\n // Set offset to 0 because all the fragments' locations are at offset 0\n const zeroedUsjLocation = UsjReaderWriter.moveUsjDocumentLocationToNewOffset(usjLocation, 0);\n\n let fragmentInfoAtLocation: UsjFragmentInfo | undefined;\n const allFragmentsInfoAtJsonPath = this.fragmentsByJsonPath.get(\n UsjReaderWriter.normalizeJsonPath(usjLocation.jsonPath),\n );\n\n // Couldn't find any fragment info at this JSONPath\n if (!allFragmentsInfoAtJsonPath) return undefined;\n\n // Look in the fragments at this JSONPath to find one that matches the full location\n allFragmentsInfoAtJsonPath.find((fragmentInfo) => {\n if (\n !UsjReaderWriter.areUsjDocumentLocationsEqual(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n zeroedUsjLocation,\n // We already compared the JSONPaths by looking in the map for this JSONPath\n true,\n )\n )\n return false;\n\n fragmentInfoAtLocation = fragmentInfo;\n return true;\n });\n\n return fragmentInfoAtLocation;\n }\n\n /**\n * Transform a node and its working stack into the {@link UsjDocumentLocation} corresponding to it.\n *\n * @param node Marker or string to convert\n * @param workingStack Working stack pointing to the node\n * @param locationOffset If applicable, this is the offset that will be put on the\n * {@link UsjDocumentLocation}. If not present, offset on the {@link UsjDocumentLocation} will be\n * `0`. Not all subtypes of {@link UsjDocumentLocation}s have offsets, so this is not used in all\n * situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertNodeToUsjDocumentLocation(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n locationOffset = 0,\n ): UsjTextContentLocation | UsjMarkerLocation {\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n if (isString(node)) {\n // If the node is a text content string, location is the jsonPath and the offset in that\n // string\n const documentLocation: UsjTextContentLocation = { jsonPath, offset: locationOffset };\n return documentLocation;\n }\n\n // The node is a marker itself, so location is just the marker jsonPath. We don't currently\n // provide a way to represent an offset within the opening marker.\n const documentLocation: UsjMarkerLocation = { jsonPath };\n return documentLocation;\n }\n\n /**\n * Transform a fragment and its working stack into the {@link UsjNodeAndDocumentLocation}\n * corresponding to it.\n *\n * @param fragment Fragment to convert\n * @param workingStack Working stack pointing to the marker or string the fragment is in\n * @param offsetWithinFragment If applicable, this is the offset within the fragment that the\n * location is pointing to, which is offset that will be put on the {@link UsjDocumentLocation}.\n * If not present, offset on the {@link UsjDocumentLocation} will be `0` because fragments don't\n * have their own offsets into the contents. Not all {@link UsjDocumentLocation}s have offsets,\n * so this is not used in all situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertFragmentToUsjNodeAndDocumentLocation(\n fragment: UsjFragment,\n workingStack: WorkingStack,\n offsetWithinFragment = 0,\n ): UsjNodeAndDocumentLocation {\n // Return the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n\n // Check if the fragment itself is the target, meaning the fragment is the node in the USJ\n // document (`string`, `MarkerObject`, and `Usj`)\n if (isString(fragment) || UsjReaderWriter.isFragmentAMarker(fragment)) {\n // The fragment/node itself is the target. Get document location for this node\n const documentLocation: UsjTextContentLocation | UsjMarkerLocation =\n UsjReaderWriter.convertNodeToUsjDocumentLocation(\n fragment,\n workingStack,\n offsetWithinFragment,\n );\n return {\n node: fragment,\n documentLocation,\n };\n }\n\n // Check if the target is a closing marker\n if ('isClosingMarker' in fragment) {\n // Get JsonPath to the marker this is a closing marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and an offset within the closing marker\n const documentLocation: UsjClosingMarkerLocation = {\n jsonPath,\n closingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is a property value (`marker` or an attribute)\n if ('attributeValueForKey' in fragment) {\n // Get JsonPath to the indicated property on the marker this is a property for\n const jsonPath = UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath(\n workingStack,\n fragment.attributeValueForKey,\n );\n\n // Location is the jsonPath to the property on the marker and the offset within the property\n // value\n const documentLocation: UsjPropertyValueLocation = {\n jsonPath,\n propertyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute key\n if ('attributeKey' in fragment) {\n // Get JsonPath to the marker this is an attribute key for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker, the key, and the offset within that key\n const documentLocation: UsjAttributeKeyLocation = {\n jsonPath,\n keyName: fragment.attributeKey,\n keyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker\n if ('attributeMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker. We don't\n // currently provide a way to represent an offset within the opening marker.\n const documentLocation: UsjAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarker,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker closing marker\n if ('attributeMarkerClosingMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker\n const documentLocation: UsjClosingAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarkerClosingMarker,\n keyClosingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n throw new Error(\n `Could not transform unrecognized fragment to UsjNodeAndDocumentLocation: ${JSON.stringify(\n fragment,\n )} at working stack ${JSON.stringify(JSON.stringify(fragment))}`,\n );\n }\n\n /**\n * Fill out fragments info from a minimal fragments info array and move them into the final\n * fragments map\n *\n * @param fragmentsInfo Minimal fragments info array to fill out and put into maps. ALL CONTENTS\n * OF THIS ARRAY ARE REMOVED IN THIS METHOD\n * @param workingStack Current working stack\n * @param position Object containing properties describing where in the USFM document these\n * fragments are. If this method encounters a verse range, only the starting verse number is\n * used (hence this is not a {@link SerializedVerseRef}). PROPERTIES ON THIS OBJECT ARE MODIFIED\n * IN THIS METHOD\n * @param fragmentsByIndexInUsfm Map to add fragment information to by index in USFM\n * @param fragmentsByJsonPath Map to add fragment information to by JSONPath\n * @param indicesInUsfmByVerseRef Map to add verse start locations to. If this method encounters a\n * verse range, only the starting verse number is used. See {@link IndicesInUsfmByVerseRef} for\n * potential adjustments to handle verse ranges differently when we know better what we ought to\n * do.\n */\n private static transferFragmentsInfoArrayToMaps(\n fragmentsInfo: UsjFragmentInfoMinimal[],\n workingStack: WorkingStack,\n position: {\n bookId: string;\n chapterNum: number;\n verseNum: number;\n },\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm,\n fragmentsByJsonPath: FragmentsByJsonPath,\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef,\n ): void {\n // Add the extra information to each fragment to make it complete\n const fullFragmentsInfo = fragmentsInfo.map((fragmentInfo) => {\n // Adjust current verse ref if we find start of book, chapter, or verse marker\n if (typeof fragmentInfo.fragment === 'object' && 'type' in fragmentInfo.fragment) {\n const marker = fragmentInfo.fragment;\n\n if (marker.type === BOOK_TYPE && marker.code) {\n // Found book marker. Update current verse ref to new book\n position.bookId = marker.code;\n position.chapterNum = 0;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered book id, move them to the first\n // encountered book id\n if (indicesInUsfmByVerseRef[NO_BOOK_ID]) {\n indicesInUsfmByVerseRef[position.bookId] = indicesInUsfmByVerseRef[NO_BOOK_ID];\n delete indicesInUsfmByVerseRef[NO_BOOK_ID];\n }\n } else if (marker.type === CHAPTER_TYPE && marker.number) {\n // Found chapter marker. Try to update chapter\n const nextChapterNum = parseInt(marker.number, 10);\n\n if (Number.isNaN(nextChapterNum)) {\n console.warn(\n `Found ${CHAPTER_TYPE} type marker with number ${\n marker.number\n }, but could not parse chapter number from it. Continuing using previous chapter number ${\n position.chapterNum\n }`,\n );\n } else {\n // Update current verse ref to new chapter\n position.chapterNum = nextChapterNum;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered chapter number, move them to\n // the first encountered chapter number\n const currentBookFragments = indicesInUsfmByVerseRef[position.bookId];\n if (currentBookFragments?.[0]) {\n // Not array destructuring because it's really hard to read here\n // eslint-disable-next-line prefer-destructuring\n currentBookFragments[position.chapterNum] = currentBookFragments[0];\n delete currentBookFragments[0];\n }\n }\n } else if (marker.type === VERSE_TYPE && marker.number) {\n // Found verse marker. Try to update verse\n const nextVerseNumString = VERSE_MARKER_NUMBER_SPAN_REGEXP.exec(marker.number)?.[1];\n\n if (!nextVerseNumString) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not find starting verse number in it. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else {\n const nextVerseNum = parseInt(nextVerseNumString, 10);\n\n if (Number.isNaN(nextVerseNum)) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not parse starting verse number from ${nextVerseNumString}. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else if (\n indicesInUsfmByVerseRef[position.bookId]?.[position.chapterNum]?.[nextVerseNum]\n ) {\n console.warn(`Found ${VERSE_TYPE} marker with existing number ${nextVerseNum} after\n current ${VERSE_TYPE} number ${\n position.verseNum\n }! Not updating verse start index. All positions in this duplicate verse will be based on the current ${\n VERSE_TYPE\n } marker, not the new duplicate marker.`);\n } else {\n if (nextVerseNum < position.verseNum)\n console.debug(\n `Found ${VERSE_TYPE} marker with number ${nextVerseNum} lower than current ${\n VERSE_TYPE\n } number ${position.verseNum}. Verses are out of order. There may be some issues.`,\n );\n\n // Update current verse ref to new verse\n position.verseNum = nextVerseNum;\n }\n }\n }\n }\n\n // Fill out the rest of the fragment info\n const fullFragmentInfo: UsjFragmentInfo = {\n ...fragmentInfo,\n // Determine the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n nodeAndDocumentLocation: UsjReaderWriter.convertFragmentToUsjNodeAndDocumentLocation(\n fragmentInfo.fragment,\n workingStack,\n ),\n };\n\n return fullFragmentInfo;\n });\n\n // Add staged fragments to final fragments maps\n fullFragmentsInfo.forEach((fragmentInfo) => {\n // Put the fragment info in the map by index in USFM\n fragmentsByIndexInUsfm.set(fragmentInfo.indexInUsfm, fragmentInfo);\n\n // Put the fragment info in the map by JSONPath. Note this JSONPath is generated using\n // UsjReaderWriter.convertWorkingStackToJsonPath and\n // UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath, so it is \"normalized\".\n // Must use \"normalized\" JSONPath when looking up fragments by JSONPath.\n const fragmentJsonPath = fragmentInfo.nodeAndDocumentLocation.documentLocation.jsonPath;\n const fragmentsAtJsonPath = fragmentsByJsonPath.get(fragmentJsonPath);\n if (fragmentsAtJsonPath) fragmentsAtJsonPath.push(fragmentInfo);\n else fragmentsByJsonPath.set(fragmentJsonPath, [fragmentInfo]);\n\n // Put the fragment's index in USFM in the map by verse reference\n // We are ensuring the properties are defined all the way through before use, so allow the\n // bang operator. This would be way more verbose without bang operator.\n /* eslint-disable no-type-assertion/no-type-assertion */\n if (!indicesInUsfmByVerseRef[position.bookId]) indicesInUsfmByVerseRef[position.bookId] = {};\n if (!indicesInUsfmByVerseRef[position.bookId]![position.chapterNum])\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum] = {};\n if (\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] ===\n undefined\n )\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] =\n fragmentInfo.indexInUsfm;\n /* eslint-enable no-type-assertion/no-type-assertion */\n });\n\n // Remove all elements from fragmentsInfo\n fragmentsInfo.splice(0);\n }\n\n // #endregion fragment utilities\n\n // #region USFM-related cached properties\n\n /**\n * Generates USFM representation of the USJ document passed in and returns it along with\n * information about how various locations in USFM and USJ map to each other\n */\n private calculateUsfmProperties(): {\n usfm: string;\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm;\n fragmentsByJsonPath: FragmentsByJsonPath;\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef;\n } {\n // Build the USFM up from the USJ content\n let usfm = '';\n // Build the fragments maps as we go\n const fragmentsByIndexInUsfm = new SortedNumberMap();\n const fragmentsByJsonPath = new Map();\n const indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef = {};\n\n // Temporary staging array to put fragments in before loading them into the map\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Keep track of current verse reference numbers as we go through the content so we can put\n // fragments in the right place\n const currentPosition = {\n bookId: NO_BOOK_ID,\n chapterNum: 0,\n verseNum: 0,\n };\n /** Move the fragments info that are in `fragmentsInfo` into the final fragments map */\n function transferFragmentsInfo(workingStack: WorkingStack) {\n UsjReaderWriter.transferFragmentsInfoArrayToMaps(\n fragmentsInfo,\n workingStack,\n currentPosition,\n fragmentsByIndexInUsfm,\n fragmentsByJsonPath,\n indicesInUsfmByVerseRef,\n );\n }\n\n // According to `USJ`'s `outputToUsfmInstructions`, need to move the top-level `USJ` marker after\n // `id` closes in USFM even though it is before it in USJ\n let topLevelUsjMarker: Usj | undefined;\n // The marker objects we're currently skipping ordered as a stack (last entry is the deepest\n // marker we are skipping and therefore will be the next to close). If this has entries, it\n // means we are walking through contents of marker objects whose opening marker we already skipped\n // and whose closing marker we should also skip outputting to USFM\n const markersToSkipOutput: (MarkerObject | Usj)[] = [];\n\n UsjReaderWriter.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n this.usj,\n // Working stack is empty since the top-level object doesn't have any parents\n [],\n // Don't skip anything\n [],\n (nodeOrClosingFragment, workingStack) => {\n if (typeof nodeOrClosingFragment !== 'object') {\n // Add the text contents USFM representation\n const { usfm: textContentUsfm, fragmentsInfo: textContentFragmentsInfo } =\n this.textContentToUsfm(nodeOrClosingFragment);\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n textContentFragmentsInfo,\n fragmentsInfo,\n usfm.length,\n );\n transferFragmentsInfo(workingStack);\n usfm += textContentUsfm;\n return false;\n }\n\n // Determine this marker's parent\n let markerParent: MarkerObject | Usj | undefined;\n if (workingStack.length > 0) {\n markerParent = workingStack[workingStack.length - 1].parent;\n }\n\n if ('isClosingMarker' in nodeOrClosingFragment) {\n // If we are supposed to skip this marker in USFM, skip its closing marker\n if (\n markersToSkipOutput.length > 0 &&\n markersToSkipOutput[markersToSkipOutput.length - 1] === nodeOrClosingFragment.forMarker\n ) {\n // Indicate the skipped marker has now closed by removing it from the stack\n markersToSkipOutput.pop();\n return false;\n }\n\n // Add the closing marker USFM representation\n usfm = this.addMarkerUsfmToString(\n usfm,\n nodeOrClosingFragment,\n markerParent,\n fragmentsInfo,\n );\n transferFragmentsInfo(workingStack);\n\n // If this is closing the `id` marker (the only marker whose type is `book`), add the\n // top-level USJ opening marker after it\n if (nodeOrClosingFragment.forMarker.type === 'book' && topLevelUsjMarker) {\n usfm = this.addMarkerUsfmToString(usfm, topLevelUsjMarker, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n topLevelUsjMarker = undefined;\n }\n\n return false;\n }\n\n // If we are supposed to skip this marker in USFM, skip its opening marker\n if (this.shouldSkipOutputMarkerToUsfm(nodeOrClosingFragment)) {\n markersToSkipOutput.push(nodeOrClosingFragment);\n return false;\n }\n\n // If this is the USJ marker at the start of the doc, save it until after `id` marker closes\n if (\n UsjReaderWriter.isTopLevelUsjMarker(nodeOrClosingFragment, workingStack) &&\n !topLevelUsjMarker\n ) {\n // The USJ types aren't set up to know about 3.0 right now, but we should handle it anyway\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if ((nodeOrClosingFragment.version as string) !== '3.0') {\n // Don't output the USJ marker if it is 3.0 (3.0 is assumed and should not appear in\n // the USFM)\n topLevelUsjMarker = nodeOrClosingFragment;\n }\n return false;\n }\n\n // Add the opening marker USFM representation\n usfm = this.addMarkerUsfmToString(usfm, nodeOrClosingFragment, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n\n // Keep going through the whole document\n return false;\n },\n );\n\n // Always add newline at the end of the file; likely replaces a space\n usfm = `${UsjReaderWriter.removeEndSpace(usfm)}\\n`;\n\n return { usfm, fragmentsByIndexInUsfm, fragmentsByJsonPath, indicesInUsfmByVerseRef };\n }\n\n /** The USFM representation of the USJ document passed in */\n private get usfm(): string {\n if (this.usfmInternal !== undefined) return this.usfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.usfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByIndexInUsfm(): FragmentsByIndexInUsfm {\n if (this.fragmentsByIndexInUsfmInternal) return this.fragmentsByIndexInUsfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByIndexInUsfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByJsonPath(): FragmentsByJsonPath {\n if (this.fragmentsByJsonPathInternal) return this.fragmentsByJsonPathInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByJsonPathInternal;\n }\n\n /**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. See {@link IndicesInUsfmByVerseRef} for more information.\n */\n private get indicesInUsfmByVerseRef(): IndicesInUsfmByVerseRef {\n if (this.indicesInUsfmByVerseRefInternal) return this.indicesInUsfmByVerseRefInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.indicesInUsfmByVerseRefInternal;\n }\n\n // #endregion USFM-related cached properties\n}\n\nexport default UsjReaderWriter;\n"],"names":["_AsyncVariable","variableName","rejectIfNotSettledWithinMS","__publicField","resolve","reject","enabled","value","throwIfAlreadySettled","reason","AsyncVariable","Collator","locales","options","string1","string2","DateTimeFormat","date","startDate","endDate","PlatformEventEmitter","event","callback","callbackIndex","newGuid","s","isString","o","deepClone","obj","debounce","fn","delay","timeout","promise","promiseResolve","promiseReject","args","e","groupBy","items","keySelector","valueSelector","map","item","index","key","group","isErrorWithMessage","error","toErrorWithMessage","maybeError","getErrorMessage","wait","ms","waitForDuration","maxWaitTimeInMS","getAllObjectFunctionNames","_objId","objectFunctionNames","property","objectPrototype","createSyncProxyForAsyncObject","getObject","objectToProxy","target","prop","isErrorMessageAboutParatextBlockingInternetAccess","errorMessage","paratextExceptionMessage","isErrorMessageAboutRegistryAuthFailure","paratextExceptionMessage1","paratextExceptionMessage2","errorString","DocumentCombiner","baseDocument","documentName","document","previousDocumentVersion","documentToSet","contributions","contributionName","potentialOutput","outputIteration","contribution","mergeObjects","output","finalOutput","areNonArrayObjects","values","allMatch","areArrayObjects","startingPoint","copyFrom","ignoreDuplicateProperties","retVal","mergeObjectsInternal","startingPointObj","copyFromObj","EventRollingTimeCounter","bufferSize","currentTime","minRollingTimeMs","Mutex","AsyncMutex","MutexMap","mutexID","NonValidatingDocumentCombiner","NumberFormat","startRange","endRange","defaultPromise","PromiseChainingMap","logger","promiseFunction","currentPromise","promiseHolder","newPromise","SortedNumberMap","insertIndex","left","right","result","mid","SortedSet","compareFn","low","high","UnsubscriberAsyncList","name","unsubscribers","unsubscriber","unsubs","results","unsubscriberSucceeded","PLATFORM_ERROR_VERSION","newPlatformError","platformError","isPlatformError","P","R","t","n","N","B","O","S","K","g","k","x","T","X","V","w","L","G","A","H","C","I","y","q","U","m","l","h","c","E","r","D","i","a","u","v","f","d","b","p","J","M","find","list","predicate","ac","hasOwn","freeze","object","oc","assign","source","HTML_BOOLEAN_ATTRIBUTES","isHTMLBooleanAttribute","HTML_VOID_ELEMENTS","isHTMLVoidElement","tagName","HTML_RAW_TEXT_ELEMENTS","isHTMLRawTextElement","isHTMLEscapableRawTextElement","isHTMLMimeType","mimeType","MIME_TYPE","hasDefaultHTMLNamespace","_MIME_TYPES","isValidMimeType","NAMESPACE","conventions","require$$0","extendError","constructor","writableName","DOMExceptionName","DOMExceptionNames","isValidDomExceptionCode","endsWithError","DOMException","messageOrCode","nameOrMessage","code","ExceptionCode","entries","ParseError","message","locator","errors","detectUnicodeSupport","RegExpImpl","match","UNICODE_SUPPORT","chars","regexp","chars_without","search","reg","self","part","isStr","regg","UNICODE_REPLACEMENT_CHARACTER","Char","_SChar","SChar_s","S_OPT","NameStartChar","NameStartChar_s","NameChar","Name","Nmtoken","EntityRef","CharRef","Reference","PEReference","EntityValue","AttValue","NCNameStartChar","NCNameChar","NCName","QName","QName_exact","QName_group","SystemLiteral","PI","PubidChar","PubidLiteral","COMMENT_START","COMMENT_END","Comment","PCDATA","Mixed","_children_quantity","children","contentspec","ELEMENTDECL_START","elementdecl","NotationType","Enumeration","EnumeratedType","AttType","DefaultDecl","AttDef","ATTLIST_DECL_START","AttlistDecl","ABOUT_LEGACY_COMPAT","ABOUT_LEGACY_COMPAT_SystemLiteral","SYSTEM","PUBLIC","ExternalID","ExternalID_match","NDataDecl","EntityDef","ENTITY_DECL_START","GEDecl","PEDef","PEDecl","EntityDecl","PublicID","NotationDecl","Eq","VersionNum","VersionInfo","EncName","EncodingDecl","SDDecl","XMLDecl","DOCTYPE_DECL_START","CDATA_START","CDATA_END","CDStart","CDEnd","CData","CDSect","grammar","PDC","require$$1","require$$2","checkSymbol","symbol","notEmptyString","input","splitOnASCIIWhitespace","orderedSetReducer","current","element","toOrderedSet","arrayIncludes","validateQualifiedName","qualifiedName","validateAndExtract","namespace","prefix","localName","splitResult","copy","src","dest","_extends","Class","Super","pt","NodeType","ELEMENT_NODE","ATTRIBUTE_NODE","TEXT_NODE","CDATA_SECTION_NODE","ENTITY_REFERENCE_NODE","ENTITY_NODE","PROCESSING_INSTRUCTION_NODE","COMMENT_NODE","DOCUMENT_NODE","DOCUMENT_TYPE_NODE","DOCUMENT_FRAGMENT_NODE","NOTATION_NODE","DocumentPosition","commonAncestor","docGUID","doc","NodeList","nodeFilter","buf","serializeToString","me","LiveNodeList","node","refresh","_updateLiveList","inc","ls","__set__","NamedNodeMap","_findNodeIndex","_addNamedNode","el","newAttr","oldAttr","_onRemoveAttribute","_onAddAttribute","_removeNamedNode","attr","lastIndex","namespaceURI","DOMImplementation","feature","version","doctype","contentType","Document","root","publicId","systemId","internalSubset","DocumentType","title","htmlNode","headNode","titleNode","Node","rootNode","other","parent","otherNode","newChild","refChild","_insertBefore","oldChild","assertPreReplacementValidityInDocument","_removeChild","deep","cloneNode","child","next","node1","node2","attr1","attr2","Attr","chain1","ancestor1","chain2","ancestor2","ca","_xmlEncoder","_visitNode","opt","ns","remove","_onUpdateChild","childNodes","parentNode","oldPreviousSibling","oldNextSibling","hasValidParentNodeType","hasInsertableNodeType","isDocTypeNode","isElementNode","isTextNode","isElementInsertionPossible","parentChildNodes","docTypeNode","isElementReplacementPossible","hasElementChildThatIsNotChild","assertPreInsertionValidity1to5","assertPreInsertionValidityInDocument","nodeChildNodes","nodeChildElements","parentElementChild","_inDocumentAssertion","cp","newFirst","newLast","pre","removed","importedNode","importNode","id","rtv","Element","attrs","DocumentFragment","data","Text","CDATASection","ProcessingInstruction","EntityReference","validated","old","classNames","classNamesSet","base","nodeClassNames","matches","nodeClassNamesSet","isHTMLDocument","lowerQualifiedName","nodeQualifiedName","matchingQName","CharacterData","offset","count","text","start","end","newText","newNode","Notation","Entity","XMLSerializer","nodeSerializeToString","refNode","uri","visibleNamespaces","needNamespaceDefine","isHTML","addSerializedAttribute","len","nodeName","prefixedNodeName","defaultNS","ai","nsi","canCloseTag","pubid","sysid","attrs2","getTextContent","dom","exports","S_TAG","S_ATTR","S_ATTR_SPACE","S_EQ","S_ATTR_NOQUOT_VALUE","S_ATTR_END","S_TAG_SPACE","S_TAG_CLOSE","XMLReader","defaultNSMap","entityMap","domBuilder","_copy","parse","ENTITY_REG","defaultNSMapCopy","errorHandler","fixedFromCharCode","surrogate1","surrogate2","entityReplacer","complete","appendText","xt","position","lineStart","lineEnd","linePattern","parseStack","unclosedTags","tagStart","fromSource","tagNameRaw","tagNameMatch","currentTagName","tagNameLower","config","localNSMap","parseProcessingInstruction","parseDoctypeCommentOrCData","ElementAttributes","currentNSMap","parseElementStartPart","locator2","copyLocator","appendElement","parseHtmlSpecialContent","addAttribute","qname","startIndex","attrName","qName","nsp","nsPrefix","elStartEnd","isEscapableRaw","elEndStart","parseUtils","char","skip","skipBlanks","blanks","substringFromIndex","substringStartsWith","substringStartsWithCaseInsensitive","getMatch","expr","parseDoctypeInternalSubset","parsePI","intSubsetStart","comment","cdata","sax","entities","require$$3","require$$4","normalizeLineEndings","DOMParser","DOMHandler","defaultNamespace","isXml","impl","ins","ch","length","_toString","charNode","comm","dt","level","_locator","handler","onErrorStopParsing","onWarningStopParsing","domParser","lib","charRegex","astralRange","comboRange","varRange","familyRange","astral","combo","fitz","modifier","nonAstral","regional","surrogatePair","zwj","blackFlag","family","optModifier","optVar","optJoin","seq","__importDefault","this","mod","dist","char_regex_1","toArray","str","substring","begin","substr","strLength","limit","padString","padPosition","padRepeats","indexOf","searchStr","pos","strArr","searchArr","finded","searchIndex","ensureArray","maybeArray","at","string","stringLength","charAt","codePointAt","endsWith","searchString","endPosition","lastIndexOfSearchString","lastIndexOf","indexOfClosestClosingCurlyBrace","escaped","closeCurlyBraceIndex","formatReplacementStringToArray","replacers","contents","nextIntermediateStartIndex","addToContents","newContent","newContentIndex","newContentLength","intermediateContent","baseSubstring","replacerKey","replacerContent","endContent","formatReplacementString","content","includes","partialString","stringzIndexOf","validatedPosition","stringzLength","normalize","form","upperCaseForm","ordinalCompare","padEnd","targetLength","stringzLimit","padStart","correctSliceIndex","slice","indexStart","indexEnd","newStart","newEnd","split","separator","splitLimit","regexSeparator","currentIndex","matchIndex","matchLength","startsWith","stringzSubstr","stringzSubstring","stringzToArray","isLocalizeKey","escapeStringRegexp","transformAndEnsureRegExpRegExpArray","stringStringMaybeArray","stringMaybeStringArray","transformAndEnsureRegExpArray","stringMaybeArray","whiteSpaceRegex","isWhiteSpace","toKebabCase","prevChar","nextChar","BLOCK_MARKER_TYPES","USJ_TYPE","ZWSP","scrBookData","FIRST_SCR_BOOK_NUM","LAST_SCR_BOOK_NUM","FIRST_SCR_CHAPTER_NUM","FIRST_SCR_VERSE_NUM","defaultScrRef","getChaptersForBook","bookNum","_a","offsetBook","scrRef","Canon","offsetChapter","offsetVerse","getLocalizedIdFromBookNumber","bookNumber","localizationLanguage","getLocalizedString","bookName","parts","scrRefToBBBCCC","VerseRef","scrRefToBBBCCCVVV","compareScrRefs","scrRef1","scrRef2","getLocalizeKeyForScrollGroupId","scrollGroupId","getLocalizeKeysForScrollGroupIds","scrollGroupIds","formatScrRef","optionOrLocalizedBookName","chapterVerseSeparator","bookChapterSeparator","book","Section","getSectionForBook","bookId","nonSemanticWhiteSpaceRegex","isNonSemanticWhiteSpace","invisibleCharOrWhiteSpaceRegex","isParatextSelectableInvisibleCharOrWhiteSpace","normalizeScriptureSpaces","lastCharWasSpace","prevCh","isUsjContentEmpty","isAtEndOfBlockMarker","contentObject","areUsjContentsEqualExceptWhitespaceInternal","aParent","bParent","aIsString","bIsString","aNormalized","bNormalized","aTrimmed","bTrimmed","aObject","bObject","aKeys","isAContentEmpty","isBContentEmpty","aContent","bContent","aLast","bLast","areUsjContentsEqualExceptWhitespace","aggregateUnsubscribers","success","aggregateUnsubscriberAsyncs","unsubPromises","BOOK_TYPE","CHAPTER_TYPE","VERSE_TYPE","NO_BOOK_ID","getDefaultCallerSequence","_","getNthCaller","callers","callerList","getFormatCallerFunction","footnotes","plusSequenceMap","autoCallerCounter","idx","caller","formattedCaller","extractFootnotesFromUsjContent","traverse","getPaneSizeLimits","availablePx","splitterThicknessPx","secondaryPaneMinSizePx","mainPaneMinSizePx","absoluteMinPercent","absoluteMaxPercent","usableHeightPx","minPercent","maxPercent","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","combineComparators","comparatorA","comparatorB","state","createIsCircular","areItemsEqual","cache","cachedA","cachedB","getStrictProperties","sameValueZeroEqual","PREACT_VNODE","PREACT_OWNER","REACT_OWNER","getOwnPropertyDescriptor","keys","areArraysEqual","areDatesEqual","areErrorsEqual","areFunctionsEqual","areMapsEqual","size","matchedIndices","aIterable","aResult","bResult","bIterable","hasMatch","aEntry","bEntry","areNumbersEqual","areObjectsEqual","properties","isPropertyEqual","areObjectsEqualStrict","descriptorA","descriptorB","arePrimitiveWrappersEqual","areRegExpsEqual","areSetsEqual","areTypedArraysEqual","areUrlsEqual","ARGUMENTS_TAG","BOOLEAN_TAG","DATE_TAG","ERROR_TAG","MAP_TAG","NUMBER_TAG","OBJECT_TAG","REG_EXP_TAG","SET_TAG","STRING_TAG","URL_TAG","isArray","isTypedArray","getTag","createEqualityComparator","type","tag","createEqualityComparatorConfig","circular","createCustomConfig","strict","areArraysEqual$1","areMapsEqual$1","areObjectsEqual$1","areSetsEqual$1","createInternalEqualityComparator","compare","_indexOrKeyA","_indexOrKeyB","_parentA","_parentB","createIsEqual","comparator","createState","equals","_b","meta","deepEqual","createCustomEqual","createCustomInternalComparator","isEqualDeep","isSubset","objectWithAllProperties","objectWithPartialProperties","partialArray","allArray","partialObj","allObj","serialize","replacer","space","replacerValue","newValue","deserialize","reviver","replaceNull","parsedObject","isSerializable","serializedValue","htmlEncode","getCurrentLocale","formatBytes","fileSize","decimals","sizes","sizeToUse","MILLISECONDS_PER_SECOND","SECONDS_PER_MINUTE","SECONDS_PER_HOUR","SECONDS_PER_DAY","formatTimeSpan","relativeTimeFormatter","since","to","spanSeconds","totalDays","totalHours","totalMinutes","formatRelativeDate","todayString","yesterdayString","locale","today","yesterday","isToday","isYesterday","MODIFIER_KEYS","settingsDefs","removeJsonToTypeScriptTypesStuff","defs","def","projectSettingsDocumentSchema","settingsDocumentSchema","localizedStringsDefs","localizedStringsDocumentSchema","menuDocumentSchema","themeDefs","themeDocumentSchema","THEME_STYLE_ELEMENT_ID","getThemeId","themeFamilyId","expandThemeContribution","themeFamiliesById","defaultThemeFamily","themeFamily","themeDefinition","getStylesheetForTheme","theme","applyThemeStylesheet","previousStyleElement","styleElementIdSuffix","previousThemeId","themeStyleElement","deepFreeze","USFM_MARKERS_MAP","USFM_MARKERS_MAP_PARATEXT","NODE_TYPES_NOT_CONTAINING_VERSE_TEXT","TEXT_CONTENT_NBSP_REGEXP","TABLE_MARKER_NUMBER_REGEXP","VERSE_MARKER_NUMBER_SPAN_REGEXP","UsjReaderWriter","usj","providedMarkersMap","shouldAllowInvisibleCharacters","USFM_MARKERS_MAP_3_0","versionA","versionB","jsonPathQuery","wrappedResults","JSONPath","unwrappedResults","marker","workingStack","fragment","parentMap","tempNode","tempParent","tempChild","pathArray","pathAcc","pathEntry","jsonPath","stack","stackLevel","levels","onNode","onLevel","indexString","nextNode","skipTypes","searchFunction","topNode","highestSkippedNode","stackItem","stackNode","skipNextNode","nextNodeClosingMarker","nextLevel","parentClosingMarker","potentiallyMatchingNodeOrClose","currentWorkingStack","nodeParent","bookIdIfNotFound","usjLocation","realParent","nodeIndexInParent","fragmentInfo","verseRef","verseIndexInUsfm","availableBookIds","noBookIdsFound","effectiveBookId","chapterIndices","indexInUsfm","bookEntries","bookIndex","lastVerseRef","didFindVerseRef","chapterEntries","chapterIndex","chapterNumString","verseIndices","verseEntries","verseIndex","verseNumString","verseFragmentInfo","usfmVerseLocation","verseRefOffset","usjChapterLocation","usjBookLocation","usfmVerseLocationIndexInUsfm","usjOffset","usjDocumentLocationMaybeNode","documentLocation","verseLocation","firstStringLocationAfterVerseMarker","maxTextLengthToSearch","textScanned","lengthScanned","lengthTrimmed","foundStartingAtOffset","workingStackForStartingPoint","startingPointStackItem","nodeTextToSearch","currentStackItem","textIndex","finalOffset","finalStack","finalNode","regex","textChunks","fullTextIndexMap","fullText","startingNodeEntry","endingNodeEntry","desiredLength","offsetRemaining","lengthRecorded","remainingNode","lengthToCopy","maxLength","currentStack","contentArray","removedCount","markerName","markerInfo","markerRegExp","scriptureFormat","markerNameOriginal","markerIsUnknown","markerTypeFromFirstMarkerInfo","markerType","markerTypeInfo","attributeMarkerInfoEntries","attributeMarkerName","attributeMarkerInfo","markerWithAnyAttributes","columnsSpanned","tableMarkerMatches","startingColumn","textContent","newFragmentsInfo","existingFragmentsInfo","existingUsfmLength","fragmentIndex","isInsideMarkerWithSameType","usfm","fragmentsInfo","markerPrefix","attributeName","attributeValue","attributeMarker","attributeMarkerFragmentsInfo","textContentUsfm","partialClosingFragment","closingMarkerAttributeNames","hasExplicitClosingMarker","independentClosingMarker","openingMarkerUsfm","openingFragmentsInfo","openingFragmentInfo","attributeNameUsfm","closingMarkerName","markerParentOrIsInsideMarkerWithSameType","usfmOutput","markerUsfmOutput","markerFragmentsInfo","isParentSameType","parentMarkerType","closingUsfm","closingFragmentsInfo","openingUsfm","lastMarkerBackslashIndex","newLocation","ignoreJsonPath","aJsonPath","restOfA","bJsonPath","restOfB","zeroedUsjLocation","fragmentInfoAtLocation","allFragmentsInfoAtJsonPath","locationOffset","offsetWithinFragment","fragmentsByIndexInUsfm","fragmentsByJsonPath","indicesInUsfmByVerseRef","nextChapterNum","currentBookFragments","nextVerseNumString","nextVerseNum","_c","fragmentJsonPath","fragmentsAtJsonPath","currentPosition","transferFragmentsInfo","topLevelUsjMarker","markersToSkipOutput","nodeOrClosingFragment","textContentFragmentsInfo","markerParent"],"mappings":"oTACaA,GAAN,MAAMA,EAAiB,CAiB5B,YAAYC,EAAsBC,EAAqC,IAAO,CAf7DC,EAAA,qBACAA,EAAA,uBACTA,EAAA,kBACAA,EAAA,wBACAA,EAAA,iBACAA,EAAA,iBAWN,KAAK,aAAeF,EACpB,KAAK,gBAAkB,GACvB,KAAK,eAAiB,IAAI,QAAW,CAACG,EAASC,IAAW,CACxD,KAAK,SAAWD,EAChB,KAAK,SAAWC,CAAA,CACjB,EACGH,EAA6B,IAC1B,KAAA,UAAY,WAAW,IAAM,CAC5B,KAAK,WACP,KAAK,SAAS,oCAAoC,KAAK,YAAY,YAAY,EAC/E,KAAK,gBAAkB,GACvB,KAAK,SAAS,IAEfA,CAA0B,GAE/B,OAAO,KAAK,IAAI,CAAA,CASlB,IAAI,SAAsB,CACxB,OAAO,KAAK,cAAA,CAQd,IAAI,YAAsB,CACjB,OAAA,OAAO,SAAS,IAAI,CAAA,CAQ7B,IAAI,aAAuB,CACzB,OAAO,KAAK,eAAA,CAQd,OAAO,kBAAkBI,EAAwB,CAC/C,KAAK,sBAAwBA,CAAA,CAU/B,eAAeC,EAAUC,EAAiC,GAAa,CACrE,GAAI,KAAK,SACHR,GAAc,uBAChB,QAAQ,MAAM,GAAG,KAAK,YAAY,wBAAwB,EAC5D,KAAK,SAASO,CAAK,EACnB,KAAK,SAAS,MACT,CACL,GAAIC,EAA6B,MAAA,MAAM,GAAG,KAAK,YAAY,sB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A,MAEA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MAEA,MAEA,MAEA,MAEA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,KACF,EAAGC,GAAI,CACL,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,KACF,EAAGC,GAAI,CACL,UACA,SACA,YACA,UACA,cACA,SACA,SACA,OACA,WACA,WACA,UACA,UACA,eACA,eACA,OACA,WACA,kBACA,MACA,SACA,WACA,eACA,gBACA,SACA,WACA,eACA,UACA,kBACA,QACA,OACA,OACA,UACA,QACA,QACA,QACA,WACA,YACA,SACA,YACA,UACA,UACA,OACA,OACA,OACA,OACA,SACA,gBACA,gBACA,YACA,YACA,cACA,aACA,kBACA,kBACA,YACA,YACA,QACA,WACA,UACA,QACA,UACA,UACA,SACA,SACA,SACA,OACA,aACA,QACA,SACA,eACA,oBACA,0BACA,SACA,qBACA,sBACA,UACA,qBACA,cACA,cACA,cACA,cACA,mBACA,mBACA,qBACA,YACA,OACA,oBAGA,uBACA,uBACA,sBACA,yBACA,wBACA,qBACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,eACA,cACA,eACA,oBACA,qBACA,0BACA,0BACA,eACA,eACA,YACA,gBACA,cACA,eACA,iBACA,wBACA,mBACA,WACA,QACA,aACA,aACA,aACA,2BACA,4BACA,YACF,EAAGC,GAAIC,GAAG,EACV,SAASC,GAAEP,EAAG,EAAI,GAAI,CACpB,OAAO,IAAMA,EAAIA,EAAE,YAAa,GAAGA,KAAKK,GAAIA,GAAEL,CAAC,EAAI,CACrD,CACA,SAASQ,GAAER,EAAG,CACZ,OAAOO,GAAEP,CAAC,EAAI,CAChB,CACA,SAASS,GAAET,EAAG,CACZ,MAAM,EAAI,OAAOA,GAAK,SAAWO,GAAEP,CAAC,EAAIA,EACxC,OAAO,GAAK,IAAM,GAAK,EACz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F,CAAC,ECoLKC,GAAe,CACnB,4BAA6B,CAC3B,YACE,8FACF,MAAO,CACL,CACE,KAAM,8BACR,EACA,CACE,KAAM,QACN,MAAO,CACL,KAAM,8BAAA,CACR,CACF,CAEJ,EACA,qBAAsB,CACpB,YAAa,wCACb,KAAM,SACN,WAAY,CACV,MAAO,CACL,YAAa,6EACb,KAAM,qBACR,EACA,YAAa,CACX,YACE,iFACF,KAAM,qBACR,EACA,WAAY,CACV,KAAM,kCAAA,CAEV,EACA,SAAU,CAAC,QAAS,YAAY,CAClC,EACA,yBAA0B,CACxB,YAAa,0EACb,KAAM,SACN,kBAAmB,CACjB,0BAA2B,CACzB,KAAM,wBAAA,CAEV,EACA,qBAAsB,EACxB,EACA,eAAgB,CACd,YAAa,gDACb,MAAO,CACL,CACE,KAAM,2CAAA,CACR,CAEJ,EACA,kCAAmC,CACjC,YAAa,yDACb,MAAO,CACL,CACE,KAAM,4BACR,EACA,CACE,KAAM,qCAAA,CACR,CAEJ,EACA,mBAAoB,CAClB,YAAa,8DACb,MAAO,CACL,CACE,KAAM,qBACR,EACA,CACE,KAAM,yBAAA,CACR,CAEJ,EACA,gBAAiB,CACf,YAAa,8CACb,KAAM,SACN,WAAY,CACV,yBAA0B,CACxB,YACE,+3CACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CACL,MAAO,CACL,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CACF,CACF,CACF,CAEJ,EACA,yBAA0B,CACxB,YACE,igDACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CACL,MAAO,CACL,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CACF,CACF,CACF,CAEJ,EACA,qBAAsB,CACpB,YACE,ybACF,MAAO,CACL,CACE,KA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sB,EACxB,EACA,SAAU,CACR,YACE,mGACF,KAAM,SACN,MAAO,CACL,CACE,WAAY,CACV,GAAI,CACF,YAAa,6CACb,KAAM,wBAAA,CAEV,EACA,SAAU,CAAC,IAAI,CACjB,EACA,CACE,WAAY,CACV,QAAS,CACP,YAAa,mEACb,KAAM,wBACR,EACA,eAAgB,CACd,YACE,0GACF,KAAM,QACR,EACA,cAAe,CACb,YACE,yGACF,KAAM,QAAA,CAEV,EACA,SAAU,CAAC,SAAS,CAAA,CAExB,EACA,WAAY,CACV,MAAO,CACL,YAAa,4DACb,KAAM,qBACR,EACA,QAAS,CACP,YACE,uFACF,KAAM,qBACR,EACA,YAAa,CACX,YACE,6GACF,KAAM,qBACR,EACA,cAAe,CACb,YACE,wFACF,KAAM,QACR,EACA,MAAO,CACL,YAAa,wCACb,KAAM,wBACR,EACA,MAAO,CACL,YACE,qGACF,KAAM,QAAA,CAEV,EACA,SAAU,CAAC,QAAS,QAAS,OAAO,EACpC,sBAAuB,EACzB,EACA,eAAgB,CACd,YAAa,2BACb,KAAM,SACN,WAAY,CACV,OAAQ,CACN,YAAa,kCACb,KAAM,oBACR,EACA,MAAO,CACL,YAAa,8CACb,KAAM,QACN,MAAO,CAAE,KAAM,kBAAmB,EAClC,YAAa,EAAA,CAEjB,EACA,SAAU,CAAC,SAAU,OAAO,CAC9B,EACA,iBAAkB,CAChB,YAAa,+CACb,KAAM,SACN,MAAO,CAAC,CAAE,KAAM,yBAA0B,EAC1C,sBAAuB,EACzB,EACA,gBAAiB,CACf,YAAa,sDACb,KAAM,SACN,MAAO,CACL,CAAE,KAAM,wBAAyB,EACjC,CACE,WAAY,CACV,QAAS,CACP,YAAa,mCACb,KAAM,4BAAA,CAEV,EACA,SAAU,CAAC,SAAS,CAAA,CAExB,EACA,sBAAuB,EACzB,EACA,mBAAoB,CAClB,YAAa,qDACb,KAAM,SACN,WAAY,CACV,gBAAiB,CACf,YACE,mFACF,KAAM,SACR,EACA,QAAS,CACP,YAAa,i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,YAAa,4BACf,EACA,IAAK,CACH,KAAM,OACN,YACE,mGACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,yCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,4CACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YACE,kFACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,wEACf,EACA,IAAK,CACH,KAAM,OACN,YACE,mFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE;AAAA,sDACJ,EACA,KAAM,CACJ,KAAM,OACN,YAAa,wDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,mCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,mCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,gEACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,yEACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,4EACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,uDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,sDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YACE,oFACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YACE;AAAA,yDACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,gEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,wDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,qDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,wDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mCACf,EACA,IAAK,CACH,KAAM,MACR,EACA,GAAI,CACF,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,iBAAkB,YAClB,YAAa,sDACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,eACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,yCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,gCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,sDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,yDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,4DACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,EAAG,CACD,KAAM,OACN,YACE,gGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,+EACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,gEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,8CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,iDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,iDACf,EACA,IAAK,CACH,KAAM,OACN,YACE;AAAA,8DACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,uFACJ,EACA,KAAM,CACJ,KAAM,OACN,YACE,4FACJ,EACA,KAAM,CACJ,KAAM,OACN,YAAa,qEACf,EACA,GAAI,CACF,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,mBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oCACf,EACA,SAAU,CACR,KAAM,UACR,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,EAAG,CACD,KAAM,OACN,YACE;AAAA,6CACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,mEACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mEACf,EACA,GAAI,CACF,KAAM,OACN,YACE,uGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,uCACf,EACA,OAAQ,CACN,KAAM,SACN,qBAAsB,KACxB,EACA,GAAI,CACF,KAAM,OACN,YACE,iGACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,kEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,GAAI,CACF,KAAM,OACN,YACE,oGACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,uGACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,yBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,8BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,gBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,wCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6EACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,+CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,sCACf,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YACE,0FACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,8DACf,EACA,OAAQ,CACN,KAAM,KACN,iBAAkB,KACpB,EACA,OAAQ,CACN,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,EAAG,CACD,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,iBAAkB,OACpB,EACA,IAAK,CACH,KAAM,MACN,iBAAkB,KACpB,EACA,IAAK,CACH,KAAM,OACN,YAAa,QACf,EACA,QAAS,CACP,KAAM,OACN,YAAa,sCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,2EACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,8CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,2DACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YACE,iFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,iHACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,+CACf,EACA,IAAK,CACH,KAAM,OACN,YACE,kGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,+CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa;AAAA,OACf,EACA,IAAK,CACH,KAAM,OACN,YACE,2FACJ,EACA,MAAO,CACL,KAAM,KACN,iBAAkB,KACpB,EACA,MAAO,CACL,KAAM,KACN,iBAAkB,KACpB,EACA,MAAO,CACL,KA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AId,IAAY,qBAA2C,CACjD,OAAA,KAAK,4BAAoC,KAAK,6BAEjD,CACC,KAAM,KAAK,aACX,uBAAwB,KAAK,+BAC7B,oBAAqB,KAAK,4BAC1B,wBAAyB,KAAK,+BAAA,EAC5B,KAAK,wBAAwB,EAE1B,KAAK,4BAAA,CAOd,IAAY,yBAAmD,CACzD,OAAA,KAAK,gCAAwC,KAAK,iCAErD,CACC,KAAM,KAAK,aACX,uBAAwB,KAAK,+BAC7B,oBAAqB,KAAK,4BAC1B,wBAAyB,KAAK,+BAAA,EAC5B,KAAK,wBAAwB,EAE1B,KAAK,gCAAA,CAIhB","x_google_ignoreList":[16,17,18,19,20,21,22,23,24,25,26,27,35]} \ No newline at end of file +{"version":3,"file":"index.cjs","sources":["../src/promises/async-variable.ts","../src/intl/intl-collator.ts","../src/intl/intl-date-time-format.ts","../src/events/platform-event-emitter.model.ts","../src/util.ts","../src/document-combiner.ts","../src/event-rolling-time-counter.ts","../src/promises/mutex.ts","../src/promises/mutex-map.ts","../src/non-validating-document-combiner.ts","../src/intl/intl-number-format.ts","../src/promises/promise-chaining-map.ts","../src/sorted-number-map.ts","../src/sorted-set.ts","../src/lifetime-management/unsubscriber-async-list.ts","../src/platform-error.ts","../../../node_modules/@sillsdev/scripture/dist/index.es.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/conventions.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/errors.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/grammar.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/dom.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/entities.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/sax.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/dom-parser.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/index.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/dist/index.js","../../../node_modules/char-regex/index.js","../../../node_modules/stringz/dist/index.js","../src/array-util.ts","../src/string-util.ts","../src/scripture/scripture-util.ts","../src/lifetime-management/unsubscriber.ts","../src/scripture/usj-reader-writer.model.ts","../src/scripture/footnote-util.ts","../src/pane-utils.ts","../../../node_modules/fast-equals/dist/esm/index.mjs","../src/equality-checking.ts","../src/subset-checking.ts","../src/serialization.ts","../src/intl/intl-util.ts","../src/number-utils.ts","../src/date-time-format-util.ts","../src/keyboard-util.ts","../src/extension-contributions/settings.model.ts","../src/extension-contributions/localized-strings.model.ts","../src/extension-contributions/menus.model.ts","../src/extension-contributions/theme.model.ts","../src/extension-contributions/theme.util.ts","../src/scripture/markers-maps/markers-map-3.0.model.ts","../src/scripture/usj-reader-writer.ts"],"sourcesContent":["/** This class provides a convenient way for one task to wait on a variable that another task sets. */\nexport class AsyncVariable {\n private static verboseLoggingEnabled: boolean = false;\n private readonly variableName: string;\n private readonly promiseToValue: Promise;\n private timeoutId: ReturnType | undefined;\n private timeoutOccurred: boolean;\n private resolver: ((value: T) => void) | undefined;\n private rejecter: ((reason: string | undefined) => void) | undefined;\n\n /**\n * Creates an instance of the class\n *\n * @param variableName Name to use when logging about this variable\n * @param rejectIfNotSettledWithinMS Milliseconds to wait before verifying if the promise was\n * settled (resolved or rejected); will reject if it has not settled by that time. Use -1 if you\n * do not want a timeout at all. Defaults to 10000 ms\n */\n constructor(variableName: string, rejectIfNotSettledWithinMS: number = 10000) {\n this.variableName = variableName;\n this.timeoutOccurred = false;\n this.promiseToValue = new Promise((resolve, reject) => {\n this.resolver = resolve;\n this.rejecter = reject;\n });\n if (rejectIfNotSettledWithinMS > 0) {\n this.timeoutId = setTimeout(() => {\n if (this.rejecter) {\n this.rejecter(`Timeout reached when waiting for ${this.variableName} to settle`);\n this.timeoutOccurred = true;\n this.complete();\n }\n }, rejectIfNotSettledWithinMS);\n }\n Object.seal(this);\n }\n\n /**\n * Get this variable's promise to a value. This always returns the same promise even after the\n * value has been resolved or rejected.\n *\n * @returns The promise for the value to be set\n */\n get promise(): Promise {\n return this.promiseToValue;\n }\n\n /**\n * A simple way to see if this variable's promise was resolved or rejected already\n *\n * @returns Whether the variable was already resolved or rejected\n */\n get hasSettled(): boolean {\n return Object.isFrozen(this);\n }\n\n /**\n * Can use to determine if a rejection occurred due to a timeout\n *\n * @returns Whether the variable timed out while waiting for a value to resolve\n */\n get hasTimedOut(): boolean {\n return this.timeoutOccurred;\n }\n\n /**\n * Allows enabling more verbose logging when async variables resolve and reject\n *\n * @param enabled Whether to enable verbose logging\n */\n static setVerboseLogging(enabled: boolean): void {\n this.verboseLoggingEnabled = enabled;\n }\n\n /**\n * Resolve this variable's promise to the given value\n *\n * @param value This variable's promise will resolve to this value\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n resolveToValue(value: T, throwIfAlreadySettled: boolean = false): void {\n if (this.resolver) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being resolved now`);\n this.resolver(value);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent resolution of ${this.variableName}`);\n }\n }\n\n /**\n * Reject this variable's promise for the value with the given reason\n *\n * @param reason This variable's promise will be rejected with this reason\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n rejectWithReason(reason: string, throwIfAlreadySettled: boolean = false): void {\n if (this.rejecter) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being rejected now with reason: ${reason}`);\n this.rejecter(reason);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent rejection of ${this.variableName}`);\n }\n }\n\n /** Prevent any further updates to this variable */\n private complete(): void {\n this.resolver = undefined;\n this.rejecter = undefined;\n if (this.timeoutId !== undefined) {\n clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n Object.freeze(this);\n }\n}\n\nexport default AsyncVariable;\n","/** Enables language-sensitive string comparison. Wraps Intl.Collator */\nexport class Collator {\n private collator: Intl.Collator;\n\n constructor(locales?: string | string[], options?: Intl.CollatorOptions) {\n this.collator = new Intl.Collator(locales, options);\n }\n\n /**\n * Compares two strings according to the sort order of this Collator object\n *\n * @param string1 String to compare\n * @param string2 String to compare\n * @returns A number indicating how string1 and string2 compare to each other according to the\n * sort order of this Collator object. Negative value if string1 comes before string2. Positive\n * value if string1 comes after string2. 0 if they are considered equal.\n */\n compare(string1: string, string2: string): number {\n return this.collator.compare(string1, string2);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and collation options computed\n * during initialization of this collator object.\n *\n * @returns ResolvedCollatorOptions object\n */\n resolvedOptions(): Intl.ResolvedCollatorOptions {\n return this.collator.resolvedOptions();\n }\n}\n\nexport default Collator;\n","/** Enables language-sensitive data and time formatting. Wraps Intl.DateTimeFormat */\nexport class DateTimeFormat {\n private dateTimeFormatter: Intl.DateTimeFormat;\n\n constructor(locales?: string | string[], options?: Intl.DateTimeFormatOptions) {\n this.dateTimeFormatter = new Intl.DateTimeFormat(locales, options);\n }\n\n /**\n * Formats a date according to the locale and formatting option for this DateTimeFormat object\n *\n * @param date The date to format\n * @returns String representing the given date formatted according to the locale and formatting\n * options of this DateTimeFormat object\n */\n format(date: Date): string {\n return this.dateTimeFormatter.format(date);\n }\n\n /**\n * Formats a date range in the most concise way based on the locales and options provided when\n * instantiating this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns String representing the given date range formatted according to the locale and\n * formatting options of this DateTimeFormat object\n */\n formatRange(startDate: Date, endDate: Date): string {\n return this.dateTimeFormatter.formatRange(startDate, endDate);\n }\n\n /**\n * Returns an array of locale-specific tokens representing each part of the formatted date range\n * produced by this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns Array of DateTimeRangeFormatPart objects\n */\n formatRangeToParts(startDate: Date, endDate: Date): Intl.DateTimeRangeFormatPart[] {\n return this.dateTimeFormatter.formatRangeToParts(startDate, endDate);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this DateTimeFormat object\n *\n * @param date The date to format\n * @returns Array of DateTimeFormatPart objects\n */\n formatToParts(date: Date): Intl.DateTimeFormatPart[] {\n return this.dateTimeFormatter.formatToParts(date);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and date and time formatting options\n * computed during initialization of this DateTimeFormat object\n *\n * @returns ResolvedDateTimeFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n return this.dateTimeFormatter.resolvedOptions();\n }\n}\n\nexport default DateTimeFormat;\n","/** Interfaces, classes, and functions related to events and event emitters */\n\nimport { Dispose } from '../lifetime-management/disposal.model';\nimport { PlatformEvent, PlatformEventHandler } from './platform-event';\n\n/**\n * Event manager - accepts subscriptions to an event and runs the subscription callbacks when the\n * event is emitted Use eventEmitter.event(callback) to subscribe to the event. Use\n * eventEmitter.emit(event) to run the subscriptions. Generally, this EventEmitter should be\n * private, and its event should be public. That way, the emitter is not publicized, but anyone can\n * subscribe to the event.\n */\nexport class PlatformEventEmitter implements Dispose {\n /**\n * Subscribes a function to run when this event is emitted.\n *\n * @param callback Function to run with the event when it is emitted\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n subscribe = this.event;\n\n /** All callback functions that will run when this event is emitted. Lazy loaded */\n private subscriptions?: PlatformEventHandler[];\n /** Event for listeners to subscribe to. Lazy loaded */\n private lazyEvent?: PlatformEvent;\n /** Whether this emitter has been disposed */\n private isDisposed = false;\n\n /**\n * Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.\n * Use like `const unsubscriber = event(callback)`\n *\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n get event(): PlatformEvent {\n this.assertNotDisposed();\n\n if (!this.lazyEvent) {\n this.lazyEvent = (callback) => {\n if (!callback || typeof callback !== 'function')\n throw new Error(`Event handler callback must be a function!`);\n\n // Initialize this.subscriptions if it does not exist\n if (!this.subscriptions) this.subscriptions = [];\n\n this.subscriptions.push(callback);\n\n return () => {\n if (!this.subscriptions) return false; // Did not find any subscribed callbacks\n\n const callbackIndex = this.subscriptions.indexOf(callback);\n\n if (callbackIndex < 0) return false; // Did not find this callback in the subscriptions\n\n // Remove the callback\n this.subscriptions.splice(callbackIndex, 1);\n\n return true;\n };\n };\n }\n return this.lazyEvent;\n }\n\n /** Disposes of this event, preparing it to release from memory */\n dispose = () => {\n return this.disposeFn();\n };\n\n /**\n * Runs the subscriptions for the event\n *\n * @param event Event data to provide to subscribed callbacks\n */\n emit = (event: T) => {\n // Do not do anything other than emitFn here. This emit is just binding `this` to emitFn\n this.emitFn(event);\n };\n\n /**\n * Function that runs the subscriptions for the event. Added here so children can override emit\n * and still call the base functionality. See NetworkEventEmitter.emit for example\n */\n protected emitFn(event: T) {\n this.assertNotDisposed();\n\n // Clone the subscriptions array before iterating over the callbacks so the callback index\n // doesn't get messed up if someone subscribes or unsubscribes inside one of the callbacks\n const emitCallbacks = [...(this.subscriptions ?? [])];\n emitCallbacks.forEach((callback) => callback(event));\n }\n\n /** Check to make sure this emitter is not disposed. Throw if it is */\n protected assertNotDisposed() {\n if (this.isDisposed) throw new Error('Emitter is disposed');\n }\n\n /**\n * Disposes of this event, preparing it to release from memory. Added here so children can\n * override emit and still call the base functionality.\n */\n protected disposeFn() {\n this.assertNotDisposed();\n\n this.isDisposed = true;\n this.subscriptions = undefined;\n this.lazyEvent = undefined;\n return Promise.resolve(true);\n }\n}\n\nexport default PlatformEventEmitter;\n","/** Collection of functions, objects, and types that are used as helpers in other services. */\n\n// Thanks to blubberdiblub at https://stackoverflow.com/a/68141099/217579\nexport function newGuid(): string {\n return '00-0-4-1-000'.replace(/[^-]/g, (s) =>\n // @ts-expect-error ts(2363) this works fine\n // eslint-disable-next-line no-bitwise\n (((Math.random() + ~~s) * 0x10000) >> s).toString(16).padStart(4, '0'),\n );\n}\n\n// thanks to DRAX at https://stackoverflow.com/a/9436948\n/**\n * Determine whether the object is a string\n *\n * @param o Object to determine if it is a string\n * @returns True if the object is a string; false otherwise\n */\nexport function isString(o: unknown): o is string {\n return typeof o === 'string' || o instanceof String;\n}\n\n/**\n * If deepClone isn't used when copying properties between objects, you may be left with dangling\n * references between the source and target of property copying operations.\n *\n * @param obj Object to clone\n * @returns Duplicate copy of `obj` without any references back to the original one\n */\nexport function deepClone(obj: T): T {\n // Assert the return type matches what is expected\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\n/**\n * Get a function that reduces calls to the function passed in\n *\n * @template T - A function type that takes any arguments and returns void. This is the type of the\n * function being debounced.\n * @param fn The function to debounce\n * @param delay How much delay in milliseconds after the most recent call to the debounced function\n * to call the function\n * @returns Function that, when called, only calls the function passed in at maximum every delay ms\n */\n// We don't know the parameter types since this function can be anything and can return anything\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce any>(\n fn: TFunc,\n delay = 300,\n): (...args: Parameters) => Promise> {\n let timeout: ReturnType;\n let promise: Promise> | undefined;\n let promiseResolve: (value: ReturnType | PromiseLike>) => void;\n let promiseReject: (reason?: unknown) => void;\n\n return (...args) => {\n clearTimeout(timeout);\n if (!promise)\n promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n timeout = setTimeout(async () => {\n try {\n promiseResolve(await fn(...args));\n } catch (e) {\n promiseReject(e);\n } finally {\n promise = undefined;\n }\n }, delay);\n\n return promise;\n };\n}\n\n/**\n * Groups each item in the array of items into a map according to the keySelector\n *\n * There are two overloads:\n *\n * - `groupBy(items, keySelector)` – groups the original items using the key returned by\n * `keySelector`.\n * - `groupBy(items, keySelector, valueSelector)` – groups transformed values using the key returned\n * by `keySelector` and the value returned by `valueSelector`.\n *\n * If `valueSelector` is not provided, the original item is used in the resulting groups.\n *\n * @param items - Array of items to group by.\n * @param keySelector - Function to run on each item to get the key for the group to which it\n * belongs. The first argument is the item, and the second argument is the index of the item in\n * the original array.\n * @param valueSelector - Optional function to run on each item to get the value to store in the\n * group. The first argument is the item, the second argument is the key for the group to which\n * this item belongs, and the third argument is the index of the item in the original array.\n * @returns Map of keys to groups of values corresponding to each item.\n */\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector: (item: T, key: K, index: number) => V,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector?: (item: T, key: K, index: number) => V,\n): Map> {\n const map = new Map>();\n items.forEach((item, index) => {\n const key = keySelector(item, index);\n const group = map.get(key);\n const value = valueSelector ? valueSelector(item, key, index) : item;\n if (group) group.push(value);\n else map.set(key, [value]);\n });\n return map;\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\ntype ErrorWithMessage = {\n message: string;\n};\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return (\n typeof error === 'object' &&\n // We're potentially dealing with objects we didn't create, so they might contain `null`\n // eslint-disable-next-line no-null/no-null\n error !== null &&\n 'message' in error &&\n // Type assert `error` to check it's `message`.\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n typeof (error as Record).message === 'string'\n );\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error from the object (useful for getting an error in a catch block)\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n // fallback in case there's an error stringifying the maybeError\n // like with circular references for example.\n return new Error(String(maybeError));\n }\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error message from the object (useful for getting error message in a catch\n * block)\n *\n * @example `try {...} catch (e) { logger.info(getErrorMessage(e)) }`\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\n/** Asynchronously waits for the specified number of milliseconds. (wraps setTimeout in a promise) */\nexport function wait(ms: number) {\n // eslint-disable-next-line no-promise-executor-return\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Runs the specified function and will timeout if it takes longer than the specified wait time\n *\n * @param fn The function to run\n * @param maxWaitTimeInMS The maximum amount of time to wait for the function to resolve\n * @returns Promise that resolves to the resolved value of the function or undefined if it ran\n * longer than the specified wait time\n */\nexport function waitForDuration(fn: () => Promise, maxWaitTimeInMS: number) {\n const timeout = wait(maxWaitTimeInMS).then(() => undefined);\n return Promise.any([timeout, fn()]);\n}\n\n/**\n * Get all functions on an object and its prototype chain (so we don't miss any class methods or any\n * object methods). Note that the functions on the final item in the prototype chain (i.e., Object)\n * are skipped to avoid including functions like `__defineGetter__`, `__defineSetter__`, `toString`,\n * etc.\n *\n * @param obj Object whose functions to get\n * @param _objId Optional ID of the object to use for debug logging\n * @returns Array of all function names on an object\n */\n// Note: lodash has something that MIGHT do the same thing as this. Investigate for https://github.com/paranext/paranext-core/issues/134\nexport function getAllObjectFunctionNames(\n obj: { [property: string]: unknown },\n // Leaving it here for debugging\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _objId: string = 'obj',\n): Set {\n const objectFunctionNames = new Set();\n\n // Get all function properties directly defined on the object\n Object.getOwnPropertyNames(obj).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId} due to error: ${error}`);\n }\n });\n\n // Walk up the prototype chain and get additional function properties, skipping the functions\n // provided by the final (Object) prototype\n let objectPrototype = Object.getPrototypeOf(obj);\n while (objectPrototype && Object.getPrototypeOf(objectPrototype)) {\n Object.getOwnPropertyNames(objectPrototype).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId}'s prototype due to error: ${error}`);\n }\n });\n objectPrototype = Object.getPrototypeOf(objectPrototype);\n }\n\n return objectFunctionNames;\n}\n\n/**\n * Creates a synchronous proxy for an asynchronous object. The proxy allows calling methods on an\n * object that is asynchronously fetched using a provided asynchronous function.\n *\n * @param getObject - A function that returns a promise resolving to the object whose asynchronous\n * methods to call.\n * @param objectToProxy - An optional object that is the object that is proxied. If a property is\n * accessed that does exist on this object, it will be returned. If a property is accessed that\n * does not exist on this object, it will be considered to be an asynchronous method called on the\n * object returned from getObject.\n * @returns A synchronous proxy for the asynchronous object.\n */\nexport function createSyncProxyForAsyncObject(\n getObject: (args?: unknown[]) => Promise,\n objectToProxy: Partial = {},\n): T {\n // objectToProxy will have only the synchronously accessed properties of T on it, and this proxy\n // makes the async methods that do not exist yet available synchronously so we have all of T\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return new Proxy(objectToProxy as T, {\n get(target, prop) {\n // We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // @ts-expect-error 7053\n if (prop in target) return target[prop];\n return async (...args: unknown[]) => {\n // 7053: We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // 2556: The args here are the parameters for the method specified\n // @ts-expect-error 7053 2556\n return (await getObject())[prop](...args);\n };\n },\n });\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that Paratext is blocking internet access.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates Paratext is blocking internet access, `false` otherwise\n */\nexport function isErrorMessageAboutParatextBlockingInternetAccess(errorMessage: unknown): boolean {\n // Copied from ParatextData/InternetAccess.cs, not a localized string\n const paratextExceptionMessage =\n 'Bug in Paratext caused attempted access to Internet. Request has been blocked.';\n\n if (isString(errorMessage)) return errorMessage.includes(paratextExceptionMessage);\n return getErrorMessage(errorMessage).includes(paratextExceptionMessage);\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that an authorization failure occurred regarding registry credentials.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates an auth failure, `false` otherwise\n */\nexport function isErrorMessageAboutRegistryAuthFailure(errorMessage: unknown): boolean {\n // Copied from ParatextProjectSendReceiveService.cs, not a localized string\n const paratextExceptionMessage1 = '401 Unauthorized error while getting shared projects.';\n // Copied from DblDownloadableDataProvider.cs, not a localized string\n const paratextExceptionMessage2 =\n 'User registration is not valid. Cannot retrieve resources from DBL.';\n\n const errorString = isString(errorMessage) ? errorMessage : getErrorMessage(errorMessage);\n return (\n errorString.includes(paratextExceptionMessage1) ||\n errorString.includes(paratextExceptionMessage2)\n );\n}\n\n/** Within type T, recursively change all properties to be optional */\nexport type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T;\n\n/** Within type T, recursively change properties that were of type A to be of type B */\nexport type ReplaceType = T extends A\n ? B\n : T extends object\n ? { [K in keyof T]: ReplaceType }\n : T;\n\n/**\n * Converts a string type from camelCase to kebab-case. Note this simply inserts hyphens before\n * uppercase letters and converts them to lowercase. It does not handle special cases like acronyms\n * or symbols. It can result in multiple hyphens in a row, leading hyphens, or trailing hyphens.\n *\n * By using this as the type for a string parameter or string property, you can enforce (somewhat)\n * at compile time that the string is in kebab-case format assuming it is provided as a string\n * literal.\n *\n * @example\n *\n * ```typescript\n * type Kebab1 = KebabCase<'backgroundColor'>; // 'background-color'\n * type Kebab2 = KebabCase<'HTMLParser'>; // '-h-t-m-l-parser'\n * type Kebab3 = KebabCase<'simpletest'>; // 'simpletest'\n * type Kebab4 = KebabCase<'My$Value'>; // '-my$-value'\n * ```\n */\nexport type KebabCase = T extends `${infer First}${infer Rest}`\n ? `${First extends Lowercase ? First : `-${Lowercase}`}${KebabCase}`\n : T;\n\n// Thanks to jcalz at https://stackoverflow.com/a/50375286\n/**\n * Converts a union type to an intersection type (`|` to `&`).\n *\n * Note: this utility type is for use on object types. It may fail on other types.\n *\n * @example\n *\n * ```typescript\n * type TypeOne = { one: string };\n * type TypeTwo = { two: number };\n * type TypeThree = { three: string };\n *\n * type TypeNums = { one: TypeOne; two: TypeTwo; three: TypeThree };\n * const numNames = ['one', 'two'] as const;\n * type TypeNumNames = typeof numNames;\n *\n * // Same as `TypeOne | TypeTwo`\n * // `{ one: string } | { two: number }`\n * type TypeOneTwoUnion = TypeNums[TypeNumNames[number]];\n *\n * // Same as `TypeOne & TypeTwo`\n * // `{ one: string; two: number }`\n * type TypeOneTwoIntersection = UnionToIntersection;\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (\n x: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Force VSCode to expand all the properties of a type by using this type. Useful for making complex\n * types more readable in hover tooltips.\n *\n * @example\n *\n * ```ts\n * type MyType = Prettify;\n * ```\n */\nexport type Prettify = {\n [K in keyof T]: T[K];\n} & {};\n","import { PlatformEventEmitter } from './events/platform-event-emitter.model';\nimport { deepClone } from './util';\n\ntype JsonObjectLike = { [key: string]: unknown };\ntype JsonArrayLike = unknown[];\n\nexport type JsonDocumentLike = JsonObjectLike | JsonArrayLike;\n\n/**\n * Options for DocumentCombiner objects\n *\n * - `copyDocuments`: If true, this instance will perform a deep copy of all provided documents before\n * composing the output. If false, then changes made to provided documents after they are\n * contributed will be reflected in the next time output is composed.\n * - `ignoreDuplicateProperties`: If true, then duplicate properties are skipped if they are seen in\n * contributed documents. If false, then throw when duplicate properties are seen in contributed\n * documents.\n */\nexport type DocumentCombinerOptions = {\n copyDocuments: boolean;\n ignoreDuplicateProperties: boolean;\n};\n\n/**\n * Base class for any code that wants to compose JSON documents (primarily in the form of JS objects\n * or arrays) together into a single output document.\n */\nexport class DocumentCombiner {\n protected baseDocument: JsonDocumentLike;\n protected readonly contributions = new Map();\n protected latestOutput: JsonDocumentLike | undefined;\n protected readonly options: DocumentCombinerOptions;\n private readonly onDidRebuildEmitter = new PlatformEventEmitter();\n /** Event that emits to announce that the document has been rebuilt and the output has been updated */\n // Need `onDidRebuildEmitter` to be instantiated before this line\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly onDidRebuild = this.onDidRebuildEmitter.subscribe;\n\n /**\n * Create a DocumentCombiner instance\n *\n * @param baseDocument This is the first document that will be used when composing the output\n * @param options Options used by this object when combining documents\n */\n protected constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n // Setting baseDocument redundantly because TS doesn't understand that updateBaseDocument does it\n this.baseDocument = baseDocument;\n this.options = options;\n this.updateBaseDocument(baseDocument);\n }\n\n /**\n * Update the starting document for composition process\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n * @returns Recalculated output document given the new starting state and existing other documents\n */\n updateBaseDocument(baseDocument: JsonDocumentLike): JsonDocumentLike | undefined {\n this.validateBaseDocument(baseDocument);\n this.baseDocument = this.options.copyDocuments ? deepClone(baseDocument) : baseDocument;\n this.baseDocument = this.transformBaseDocumentAfterValidation(this.baseDocument);\n return this.rebuild();\n }\n\n /**\n * Add or update one of the contribution documents for the composition process\n *\n * Note: the order in which contribution documents are added can be considered indeterminate as it\n * depends on the order in which `Map.forEach` iterates over the contributions. However, the order\n * matters when merging two arrays into one. Also, when `options.ignoreDuplicateProperties` is is\n * `true`, the order also matters when adding the same property to an object that is already\n * provided previously. Please let us know if you have trouble because of indeterminate\n * contribution ordering.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n * @returns Recalculated output document given the new or updated contribution and existing other\n * documents\n */\n addOrUpdateContribution(\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike | undefined {\n this.validateContribution(documentName, document);\n const previousDocumentVersion = this.contributions.get(documentName);\n let documentToSet = this.options.copyDocuments && !!document ? deepClone(document) : document;\n documentToSet = this.transformContributionAfterValidation(documentName, documentToSet);\n this.contributions.set(documentName, documentToSet);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after adding/updating the contribution, put it back how it was\n if (previousDocumentVersion) this.contributions.set(documentName, previousDocumentVersion);\n else this.contributions.delete(documentName);\n throw new Error(`Error when setting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete one of the contribution documents for the composition process\n *\n * @param documentName Name of the contributed document to delete\n * @returns Recalculated output document given the remaining other documents\n */\n deleteContribution(documentName: string): JsonDocumentLike | undefined {\n const document = this.contributions.get(documentName);\n if (!document) throw new Error(`${documentName} does not exist`);\n this.contributions.delete(documentName);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting the contribution, put it back and rethrow\n this.contributions.set(documentName, document);\n throw new Error(`Error when deleting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete all present contribution documents for the composition process and return to the base\n * document\n *\n * @returns Recalculated output document consisting only of the base document\n */\n deleteAllContributions(): JsonDocumentLike | undefined {\n if (this.contributions.size <= 0) return this.latestOutput;\n\n // Save out all contributions\n const contributions = [...this.contributions.entries()];\n\n // Delete all contributions\n contributions.forEach(([contributionName]) => this.contributions.delete(contributionName));\n\n // Rebuild with no contributions\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting all contributions, put them back and rethrow\n contributions.forEach(([contributionName, document]) =>\n this.contributions.set(contributionName, document),\n );\n throw new Error(`Error when deleting all contributions: ${error}`);\n }\n }\n\n /**\n * Run the document composition process given the starting document and all contributions. Throws\n * if the output document fails to validate properly.\n *\n * @returns Recalculated output document given the starting and contributed documents\n */\n rebuild(): JsonDocumentLike | undefined {\n // The starting document is the output if there are no other contributions\n if (this.contributions.size === 0) {\n let potentialOutput = deepClone(this.baseDocument);\n potentialOutput = this.transformFinalOutputBeforeValidation(potentialOutput);\n this.validateOutput(potentialOutput);\n this.latestOutput = potentialOutput;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n // Compose the output by validating each document one at a time to pinpoint errors better\n let outputIteration = this.baseDocument;\n this.contributions.forEach((contribution: JsonDocumentLike) => {\n outputIteration = mergeObjects(\n outputIteration,\n contribution,\n this.options.ignoreDuplicateProperties,\n );\n this.validateOutput(outputIteration);\n });\n outputIteration = this.transformFinalOutputBeforeValidation(outputIteration);\n this.validateOutput(outputIteration);\n this.latestOutput = outputIteration;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n /**\n * Transform the starting document that is given to the combiner. This transformation occurs after\n * validating the base document and before combining any contributions.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the `baseDocument` passed in.\n *\n * @param baseDocument Initial input document. Already validated via `validateBaseDocument`\n * @returns Transformed base document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformBaseDocumentAfterValidation(baseDocument: JsonDocumentLike): JsonDocumentLike {\n return baseDocument;\n }\n\n /**\n * Transform the contributed document associated with `documentName`. This transformation occurs\n * after validating the contributed document and before combining with other documents.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the contributed `document` passed in.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine. Already validated via\n * `validateContribution`\n * @returns Transformed contributed document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformContributionAfterValidation(\n // @ts-expect-error this parameter is unused but may be used in child classes\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike {\n return document;\n }\n\n /**\n * Throw an error if the provided document is not a valid starting document.\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateBaseDocument(baseDocument: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided document is not a valid contribution document.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateContribution(documentName: string, document: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided output is not valid.\n *\n * @param output Output document that could potentially be returned to callers\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateOutput(output: JsonDocumentLike): void {}\n\n /**\n * Transform the document that is the composition of the base document and all contribution\n * documents. This is the last step that will be run prior to validation via `validateOutput`\n * before `this.latestOutput` is updated to the new output.\n *\n * @param finalOutput Final output document that could potentially be returned to callers. \"Final\"\n * means no further contribution documents will be merged.\n */\n // no-op intended to be overridden by child classes. Can't be static\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformFinalOutputBeforeValidation(finalOutput: JsonDocumentLike): JsonDocumentLike {\n return finalOutput;\n }\n}\n\n// #region Helper functions\n\n/**\n * Determines if the input values are objects but not arrays\n *\n * @param values Objects to check\n * @returns True if all the values are objects but not arrays\n */\nfunction areNonArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Determines if the input values are arrays\n *\n * @param value Objects to check\n * @returns True if the values are arrays\n */\nfunction areArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || !Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Deep clone and recursively merge the properties of one object (copyFrom) into another\n * (startingPoint). Throws if copyFrom would overwrite values already existing in startingPoint.\n *\n * Does not modify the objects passed in.\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjects(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n const retVal = deepClone(startingPoint);\n\n if (!copyFrom) return retVal;\n\n return mergeObjectsInternal(retVal, deepClone(copyFrom), ignoreDuplicateProperties);\n}\n\n/**\n * Recursively merge the properties of one object (copyFrom) into another (startingPoint). Throws if\n * copyFrom would overwrite values already existing in startingPoint.\n *\n * WARNING: Modifies the argument objects in some way. Recommended to use `mergeObjects`\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjectsInternal(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n if (!copyFrom) return startingPoint;\n\n if (areNonArrayObjects(startingPoint, copyFrom)) {\n // Merge properties since they are both objects\n\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n const startingPointObj = startingPoint as JsonObjectLike;\n const copyFromObj = copyFrom as JsonObjectLike;\n /* eslint-enable no-type-assertion/no-type-assertion */\n Object.keys(copyFromObj).forEach((key: string | number) => {\n if (Object.hasOwn(startingPointObj, key)) {\n if (areNonArrayObjects(startingPointObj[key], copyFromObj[key])) {\n startingPointObj[key] = mergeObjectsInternal(\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] as JsonObjectLike,\n copyFromObj[key] as JsonObjectLike,\n ignoreDuplicateProperties,\n /* eslint-enable no-type-assertion/no-type-assertion */\n );\n } else if (areArrayObjects(startingPointObj[key], copyFromObj[key])) {\n // Concat the arrays since they are both arrays\n\n // We know these are arrays from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] = (startingPointObj[key] as JsonArrayLike).concat(\n copyFromObj[key] as JsonArrayLike,\n );\n /* eslint-enable no-type-assertion/no-type-assertion */\n } else if (!ignoreDuplicateProperties)\n throw new Error(`Cannot merge objects: key \"${key}\" already exists in the target object`);\n // Note that the first non-object non-array value that gets placed in a property stays.\n // New values do not override existing ones\n } else {\n startingPointObj[key] = copyFromObj[key];\n }\n });\n } else if (areArrayObjects(startingPoint, copyFrom)) {\n // Concat the arrays since they are both arrays\n\n // Push the contents of copyFrom into startingPoint since it is a const and was already deep cloned\n // We know these are objects from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n (startingPoint as JsonArrayLike).push(...(copyFrom as JsonArrayLike));\n /* eslint-enable no-type-assertion/no-type-assertion */\n }\n\n // Note that nothing happens if `startingPoint` is not an object or an array or if `startingPoint`\n // and `copyFrom` are not both object or both arrays. Should we throw? Should we push `copyFrom`'s\n // values into the array? Other? Maybe one day we can add some options to decide what to do in\n // this situation, but YAGNI for now\n\n return startingPoint;\n}\n\n// #endregion\n\nexport default DocumentCombiner;\n","/** Class that tracks how long it has taken the last N events to occur */\nexport class EventRollingTimeCounter {\n /** The ring buffer to store times */\n private readonly ringBuffer: number[];\n /** The size of the ring buffer */\n private readonly bufferSize: number;\n /** The next location where a time will be written */\n private writerIndex: number;\n /** The location where the first time in the buffer will be read */\n private readerIndex: number;\n /** The most recent difference in time between the newest and oldest events */\n private lastTimeDifference: number;\n /** How many instances in total have been recorded */\n private totalInstanceCount: number;\n\n /**\n * Create a new instance of the InstanceTimeCounter class\n *\n * @param bufferSize - Maximum number of instances to track\n */\n constructor(bufferSize: number) {\n this.bufferSize = bufferSize;\n this.ringBuffer = new Array(bufferSize).fill(0);\n this.writerIndex = 0;\n this.readerIndex = 0;\n this.lastTimeDifference = 0;\n this.totalInstanceCount = 0;\n }\n\n /** Get the total number of instances that have been recorded */\n get totalInstances(): number {\n return this.totalInstanceCount;\n }\n\n /** Add a new time measurement for an instance of an event */\n recordInstance(): void {\n this.totalInstanceCount += 1;\n const currentTime = performance.now();\n this.lastTimeDifference = currentTime - this.ringBuffer[this.readerIndex];\n\n this.ringBuffer[this.writerIndex] = currentTime;\n this.writerIndex += 1;\n if (this.writerIndex >= this.bufferSize) this.writerIndex %= this.bufferSize;\n if (this.writerIndex === this.readerIndex) {\n this.readerIndex += 1;\n if (this.readerIndex >= this.bufferSize) this.readerIndex %= this.bufferSize;\n }\n }\n\n /**\n * Check if the time between the last N events is less than the provided threshold\n *\n * @param minRollingTimeMs - Minimum time that must have passed when the last N events occurred\n * @returns - True if the threshold is violated, false otherwise\n */\n hasViolatedThreshold(minRollingTimeMs: number): boolean {\n return this.totalInstanceCount >= this.bufferSize && this.lastTimeDifference < minRollingTimeMs;\n }\n}\n","import { Mutex as AsyncMutex } from 'async-mutex';\n\n// Extending Mutex from async-mutex so we can add JSDoc\n\n/**\n * Class that allows calling asynchronous functions multiple times at once while only running one at\n * a time.\n *\n * @example\n *\n * ```typescript\n * const mutex = new Mutex();\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n * ```\n *\n * See [`async-mutex`](https://www.npmjs.com/package/async-mutex) for more information.\n */\nexport class Mutex extends AsyncMutex {}\n\nexport default Mutex;\n","import { Mutex } from './mutex';\n\n/** Map of {@link Mutex}es that automatically (lazily) generates a new {@link Mutex} for any new key */\nexport class MutexMap {\n private mutexesByID = new Map();\n\n /**\n * Retrieves the {@link Mutex} associated with the given ID. If no Mutex exists for the provided\n * ID, a new Mutex is created, stored, and returned.\n *\n * @param mutexID Unique identifier for the desired Mutex\n * @returns The Mutex associated with the provided ID\n */\n get(mutexID: string): Mutex {\n let retVal = this.mutexesByID.get(mutexID);\n if (retVal) return retVal;\n\n retVal = new Mutex();\n this.mutexesByID.set(mutexID, retVal);\n return retVal;\n }\n}\n\nexport default MutexMap;\n","import { DocumentCombiner, DocumentCombinerOptions, JsonDocumentLike } from './document-combiner';\n\nexport class NonValidatingDocumentCombiner extends DocumentCombiner {\n // Making the protected base constructor public\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n super(baseDocument, options);\n }\n\n get output(): JsonDocumentLike | undefined {\n return this.latestOutput;\n }\n}\n\nexport default NonValidatingDocumentCombiner;\n","/** Enables language-sensitive number formatting. Wraps Intl.NumberFormat */\nexport class NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n\n constructor(locales?: string | string[], options?: Intl.NumberFormatOptions) {\n this.numberFormatter = new Intl.NumberFormat(locales, options);\n }\n\n /**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @param value Number or BigInt to format\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\n format(value: number | bigint): string {\n return this.numberFormatter.format(value);\n }\n\n /**\n * Formats a range of numbers according to the locale and formatting options of this NumberFormat\n * object\n *\n * @param startRange Number or bigint representing the start of the range\n * @param endRange Number or bigint representing the end of the range\n * @returns String representing the given range of numbers formatted according to the locale and\n * formatting options of this NumberFormat object\n */\n formatRange(startRange: number | bigint, endRange: number | bigint): string {\n return this.numberFormatter.formatRange(startRange, endRange);\n }\n\n /**\n * Returns an array of objects containing the locale-specific tokens from which it is possible to\n * build custom strings while preserving the locale-specific parts.\n *\n * @param startRange Number or bigint representing start of the range\n * @param endRange Number or bigint representing end of the range\n * @returns Array of NumberRangeFormatPart objects containing the formatted range of numbers in\n * parts\n */\n formatRangeToParts(\n startRange: number | bigint,\n endRange: number | bigint,\n ): Intl.NumberRangeFormatPart[] {\n return this.numberFormatter.formatRangeToParts(startRange, endRange);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this NumberFormat object\n *\n * @param value Number or bigint to format\n * @returns Array of NumberFormatPart objects containing the formatted number in parts\n */\n formatToParts(value: number | bigint): Intl.NumberFormatPart[] {\n return this.numberFormatter.formatToParts(value);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and number formatting options\n * computed during initialization of this NumberFormat object\n *\n * @returns ResolvedNumberFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n return this.numberFormatter.resolvedOptions();\n }\n}\n\nexport default NumberFormat;\n","const defaultPromise = Promise.resolve();\n\n/**\n * Class that allows you to chain promises for a given key. This is useful when:\n *\n * 1. You need to run promises from synchronous code and don't need to look at the results.\n * 2. The promises to run, or at least precisely when to run them, are not known in advance.\n * 3. The promises need to be run sequentially, waiting for the previous one to finish.\n *\n * An example of when this can be helpful is inside of React components. Component code is mostly\n * synchronous, but you may need to run some asynchronous code. You can't use `await` inside of\n * React component code in many situations, so you can use this class to chain promises together.\n *\n * When promises are added to the map with a key, they will run in the order they were added to the\n * map for that key. If a promise rejects, a warning will be logged and the chain will continue. If\n * a promise is added while another promise in the map for that key is running, the new promise will\n * be chained to the existing one.\n */\nexport class PromiseChainingMap {\n private readonly map = new Map>();\n private readonly logger: { warn: (message: string) => void };\n\n /**\n * Creates a new PromiseChainingMap\n *\n * @param logger Object with a `warn` method that will be called when a promise rejects. This\n * defaults to `console`.\n */\n constructor(logger: { warn: (message: string) => void } = console) {\n this.logger = logger;\n }\n\n /**\n * Adds a promise function to the map for a given key. If a promise is already running for the\n * key, the new promise will be chained to the existing one. Once all promises for a key have\n * settled, the map will be cleared for that key.\n *\n * @param key Unique key to identify a distinct promise chain\n * @param promiseFunction Function that returns a promise to add to the chain\n */\n addPromiseFunction(key: TKey, promiseFunction: () => Promise): void {\n const currentPromise = this.map.get(key);\n this.map.set(key, currentPromise ? currentPromise.then(promiseFunction) : promiseFunction());\n this.cleanupPromiseChain(key);\n }\n\n /**\n * Gets the current promise chain for the given key. This is mostly useful for testing. Normally\n * you should just call {@link addPromiseFunction} and let the map handle the rest.\n *\n * @param key Unique key to identify a distinct promise chain\n * @returns The current promise chain for the key\n */\n get(key: TKey): Promise | undefined {\n return this.map.get(key);\n }\n\n /**\n * Configures a promise chain to be removed from the map for the given key after all the promises\n * have settled\n *\n * @param key Unique key to identify a distinct promise chain\n */\n private cleanupPromiseChain(key: TKey): void {\n const currentPromise = this.map.get(key);\n if (!currentPromise) return;\n\n const promiseHolder: { promise: Promise } = { promise: defaultPromise };\n const newPromise = currentPromise\n .catch((e) => this.logger.warn(`Error in promise for ${key}: ${e.message}`))\n .finally(() => {\n if (this.map.get(key) === promiseHolder.promise) this.map.delete(key);\n });\n promiseHolder.promise = newPromise;\n this.map.set(key, newPromise);\n }\n}\n\nexport default PromiseChainingMap;\n","/**\n * A map-like data structure that maintains numeric keys in sorted order and provides efficient\n * operations for finding the closest key-value pair less than or equal to a target.\n *\n * This class combines the benefits of a Map (O(1) key-value lookups) with sorted key access (O(log\n * n) binary search operations). It's particularly useful when you need to frequently find the\n * \"closest\" entry to a given numeric key.\n *\n * @example\n *\n * ```typescript\n * const versionMap = new SortedNumberMap();\n * versionMap.set(100, 'Version 1.0.0');\n * versionMap.set(150, 'Version 1.5.0');\n * versionMap.set(200, 'Version 2.0.0');\n *\n * // Find the highest version <= 175\n * const result = versionMap.findClosestLessThanOrEqual(175);\n * console.log(result); // { key: 150, value: 'Version 1.5.0' }\n * ```\n *\n * @template T The type of values stored in the map\n */\nexport class SortedNumberMap {\n private map = new Map();\n private sortedKeys: number[] = [];\n\n /**\n * Returns an iterable of keys in the map sorted in ascending order.\n *\n * Time complexity: internal detail to JavaScript engine. Reasonable expectation:\n *\n * - Executing this method to return an iterator: O(1)\n * - Iterating over the returned iterator: O(n)\n *\n * Note that iterating over the keys this way negates the benefits of using this class over a\n * using a {@link Map}. To access individual keys more quickly, use\n * {@link SortedNumberMap.findClosestLessThanOrEqual} or {@link SortedNumberMap.get}.\n *\n * TSDoc adapted from {@link Map.keys}\n */\n keys() {\n return this.sortedKeys.values();\n }\n\n /**\n * Returns a specified element from the Map object. If the value that is associated to the\n * provided key is an object, then you will get a reference to that object and any change made to\n * that object will effectively modify it inside the Map.\n *\n * Time complexity: O(1)\n *\n * @returns Returns the element associated with the specified key. If no element is associated\n * with the specified key, returns `undefined`.\n *\n * TSDoc adapted from {@link Map.get}\n */\n get(key: number) {\n return this.map.get(key);\n }\n\n /**\n * Sets a key-value pair in the map. If the key already exists, its value is updated. If the key\n * is new, it's inserted in the correct sorted position.\n *\n * Time complexity: O(log n) for new keys (due to binary search and array insertion), O(1) for\n * existing keys.\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(5, 'five');\n * map.set(15, 'fifteen');\n * // Keys are automatically maintained in sorted order: [5, 10, 15]\n * ```\n *\n * @param key - The numeric key to set\n * @param value - The value to associate with the key\n */\n set(key: number, value: T): void {\n if (!this.map.has(key)) {\n // Insert key in sorted position\n const insertIndex = this.binarySearchInsertIndex(key);\n this.sortedKeys.splice(insertIndex, 0, key);\n }\n this.map.set(key, value);\n }\n\n /**\n * Finds the key-value pair with the largest key that is less than or equal to the target.\n *\n * This method uses binary search to efficiently locate the closest match. If no key is less than\n * or equal to the target, it returns undefined.\n *\n * Time complexity: O(log n)\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(20, 'twenty');\n * map.set(30, 'thirty');\n *\n * // Exact match\n * map.findClosestLessThanOrEqual(20); // { key: 20, value: 'twenty' }\n *\n * // Closest less than\n * map.findClosestLessThanOrEqual(25); // { key: 20, value: 'twenty' }\n *\n * // No match (target too small)\n * map.findClosestLessThanOrEqual(5); // undefined\n * ```\n *\n * @param target - The number to search for\n * @returns The key-value pair with the largest key ≤ target, or undefined if none exists\n */\n findClosestLessThanOrEqual(target: number): { key: number; value: T } | undefined {\n const index = this.binarySearchLessThanOrEqual(target);\n if (index === -1) return undefined;\n\n const key = this.sortedKeys[index];\n const value = this.map.get(key);\n if (value === undefined) return undefined;\n return { key, value };\n }\n\n private binarySearchLessThanOrEqual(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length - 1;\n let result = -1;\n\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] <= target) {\n result = mid;\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return result;\n }\n\n private binarySearchInsertIndex(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return left;\n }\n}\n","/**\n * A collection of unique items that are automatically maintained in sorted order, similar to C#'s\n * SortedSet.\n *\n * @template T The type of elements in the set\n */\nexport class SortedSet {\n /** Internal storage for the sorted items */\n private readonly items: T[] = [];\n\n /**\n * Creates a new sorted set\n *\n * @param compareFn - Function used to determine the order of elements. Returns negative when a <\n * b, zero when a = b, positive when a > b\n */\n constructor(private readonly compareFn: (a: T, b: T) => number) {}\n\n /** Gets the number of elements in the set */\n get size(): number {\n return this.items.length;\n }\n\n /** Returns whether the set is empty */\n get isEmpty(): boolean {\n return this.items.length === 0;\n }\n\n /**\n * Inserts an item into the set if it's not already present\n *\n * @param item - The item to insert\n * @returns True if the item was added; false if an equal item already exists\n */\n insert(item: T): boolean {\n // Find where this item should be inserted\n const index = this.findInsertionIndex(item);\n\n // Check if an equal item exists at the found position\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) {\n // Item already exists\n return false;\n }\n\n // Insert the item at the correct position to maintain sort order\n this.items.splice(index, 0, item);\n return true;\n }\n\n /**\n * Removes an item from the set\n *\n * @param item - The item to remove\n * @returns True if the item was removed; false if it wasn't found\n */\n remove(item: T): boolean {\n const index = this.findIndex(item);\n if (index < 0) return false;\n\n this.items.splice(index, 1);\n return true;\n }\n\n /**\n * Checks if an item exists in the set\n *\n * @param item - The item to check\n * @returns True if the item exists; false otherwise\n */\n has(item: T): boolean {\n return this.findIndex(item) >= 0;\n }\n\n /** Returns all items in the set as an array, in sorted order */\n toArray(): T[] {\n return [...this.items];\n }\n\n /** Returns the index of an item in the set, or -1 if not found */\n findIndex(item: T): number {\n const index = this.findInsertionIndex(item);\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) return index;\n return -1;\n }\n\n /**\n * Returns the element at the specified index in the sorted order\n *\n * @param index - The zero-based index of the element to get\n * @returns The element at the specified index, or undefined if the index is out of range\n */\n at(index: number): T | undefined {\n if (index < 0 || index >= this.items.length) return undefined;\n return this.items[index];\n }\n\n /** Iterates through each item in the sorted set */\n forEach(callback: (item: T, index: number, set: SortedSet) => void): void {\n this.items.forEach((item, index) => callback(item, index, this));\n }\n\n /** Returns an iterator for the set's items */\n [Symbol.iterator](): Iterator {\n let index = 0;\n return {\n next: (): IteratorResult => {\n if (index < this.items.length) {\n index += 1;\n return { value: this.items[index - 1], done: false };\n }\n return { value: undefined as unknown, done: true };\n },\n };\n }\n\n /** Clears all items from the set */\n clear(): void {\n this.items.length = 0;\n }\n\n /**\n * Uses binary search to find the position where an item should be inserted to maintain the sorted\n * order\n */\n private findInsertionIndex(item: T): number {\n let low = 0;\n let high = this.items.length;\n\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n const comparison = this.compareFn(this.items[mid], item);\n\n if (comparison < 0) {\n // Current item is less than the one we're looking for\n low = mid + 1;\n } else {\n // Current item is greater than or equal to the one we're looking for\n high = mid;\n }\n }\n\n return low;\n }\n}\n","import { Dispose } from './disposal.model';\nimport { Unsubscriber, UnsubscriberAsync } from './unsubscriber';\n\n/** Simple collection for UnsubscriberAsync objects that also provides an easy way to run them. */\nexport class UnsubscriberAsyncList {\n readonly unsubscribers = new Set();\n\n constructor(private name = 'Anonymous') {}\n\n /**\n * Add unsubscribers to the list. Note that duplicates are not added twice.\n *\n * @param unsubscribers - Objects that were returned from a registration process.\n */\n add(...unsubscribers: (UnsubscriberAsync | Unsubscriber | Dispose)[]) {\n unsubscribers.forEach((unsubscriber) => {\n if ('dispose' in unsubscriber)\n this.unsubscribers.add(unsubscriber.dispose.bind(unsubscriber));\n else this.unsubscribers.add(unsubscriber);\n });\n }\n\n /**\n * Run all unsubscribers added to this list and then clear the list.\n *\n * @returns `true` if all unsubscribers succeeded, `false` otherwise.\n */\n async runAllUnsubscribers(): Promise {\n const unsubs = [...this.unsubscribers].map((unsubscriber) => unsubscriber());\n const results = await Promise.all(unsubs);\n this.unsubscribers.clear();\n return results.every((unsubscriberSucceeded, index) => {\n if (!unsubscriberSucceeded)\n console.error(`UnsubscriberAsyncList ${this.name}: Unsubscriber at index ${index} failed!`);\n\n return unsubscriberSucceeded;\n });\n }\n}\n\nexport default UnsubscriberAsyncList;\n","import { isString } from './util';\n\n/** The version of the PlatformError type */\nexport const PLATFORM_ERROR_VERSION = 1;\n\n/**\n * PlatformError is an error type with stronger typing of properties than `Error`. It is used to\n * represent errors that are returned by the platform.\n *\n * You can create a new PlatformError object using {@link newPlatformError}. You can check if a value\n * is a PlatformError object using {@link isPlatformError}.\n */\nexport type PlatformError = {\n /**\n * The underlying cause of the error, if any. Normally this will be copied from an `Error object\n * passed to {@link newPlatformError}. If a non-Error object is passed to {@link newPlatformError},\n * it will be stored here.\n */\n cause?: unknown;\n /**\n * A descriptive message explaining the error. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}. If a string is passed to {@link newPlatformError}, it will be\n * stored here.\n */\n message: string;\n /** The version of the PlatformError type. */\n platformErrorVersion: number;\n /**\n * The stack trace of the error, if available. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}.\n */\n stack?: string;\n};\n\n/**\n * Creates a new PlatformError object. If no argument is provided, a PlatformError object with an\n * empty `message` is returned.\n *\n * @param error The error message as a string, an Error object, or a value to assign to the `cause`\n * property of the returned PlatformError object\n * @returns A new PlatformError object\n */\nexport function newPlatformError(error?: unknown): PlatformError {\n if (!error) return { message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (isString(error)) return { message: error, platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n const platformError: PlatformError = {\n message: error.message,\n platformErrorVersion: PLATFORM_ERROR_VERSION,\n };\n Object.defineProperties(platformError, Object.getOwnPropertyDescriptors(error));\n Object.defineProperty(platformError, 'message', { enumerable: true });\n if ('stack' in error && isString(error.stack)) {\n // stack is generated lazily, and it seems this is causing some troubles with copying it into\n // another object via property descriptors as of Node 22.14.0 (no problems in 20.18.0).\n // So we shall set the value directly on the object\n Object.defineProperty(platformError, 'stack', { value: error.stack, enumerable: true });\n }\n if ('cause' in platformError)\n Object.defineProperty(platformError, 'cause', { enumerable: true });\n return platformError;\n }\n return { cause: error, message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n}\n\n/**\n * Checks if the provided value is a PlatformError object.\n *\n * @param error The value to check\n * @returns `true` if the value is a PlatformError object, otherwise `false`\n */\nexport function isPlatformError(error: unknown): error is PlatformError {\n return !!error && typeof error === 'object' && 'platformErrorVersion' in error;\n}\n","var P = Object.defineProperty;\nvar R = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;\nvar n = (t, e, s) => R(t, typeof e != \"symbol\" ? e + \"\" : e, s);\nclass _ {\n constructor() {\n n(this, \"books\");\n n(this, \"firstSelectedBookNum\");\n n(this, \"lastSelectedBookNum\");\n n(this, \"count\");\n n(this, \"selectedBookNumbers\");\n n(this, \"selectedBookIds\");\n }\n}\nconst N = [\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n // 10\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n // 20\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n // 30\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n \"MAT\",\n // 40\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n // 50\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n // 60\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n // 70\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n // 80\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"JSA\",\n // actual variant text for JOS, now in LXA text\n \"JDB\",\n // actual variant text for JDG, now in LXA text\n \"TBS\",\n // actual variant text for TOB, now in LXA text\n \"SST\",\n // actual variant text for SUS, now in LXA text // 90\n \"DNT\",\n // actual variant text for DAN, now in LXA text\n \"BLT\",\n // actual variant text for BEL, now in LXA text\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n // 100\n \"BAK\",\n \"OTH\",\n \"3ES\",\n // Used previously but really should be 2ES\n \"EZA\",\n // Used to be called 4ES, but not actually in any known project\n \"5EZ\",\n // Used to be called 5ES, but not actually in any known project\n \"6EZ\",\n // Used to be called 6ES, but not actually in any known project\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n // 110\n \"NDX\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n // 120\n \"REP\",\n \"4BA\",\n \"LAO\"\n], B = [\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\"\n], O = [\n \"Genesis\",\n \"Exodus\",\n \"Leviticus\",\n \"Numbers\",\n \"Deuteronomy\",\n \"Joshua\",\n \"Judges\",\n \"Ruth\",\n \"1 Samuel\",\n \"2 Samuel\",\n \"1 Kings\",\n \"2 Kings\",\n \"1 Chronicles\",\n \"2 Chronicles\",\n \"Ezra\",\n \"Nehemiah\",\n \"Esther (Hebrew)\",\n \"Job\",\n \"Psalms\",\n \"Proverbs\",\n \"Ecclesiastes\",\n \"Song of Songs\",\n \"Isaiah\",\n \"Jeremiah\",\n \"Lamentations\",\n \"Ezekiel\",\n \"Daniel (Hebrew)\",\n \"Hosea\",\n \"Joel\",\n \"Amos\",\n \"Obadiah\",\n \"Jonah\",\n \"Micah\",\n \"Nahum\",\n \"Habakkuk\",\n \"Zephaniah\",\n \"Haggai\",\n \"Zechariah\",\n \"Malachi\",\n \"Matthew\",\n \"Mark\",\n \"Luke\",\n \"John\",\n \"Acts\",\n \"Romans\",\n \"1 Corinthians\",\n \"2 Corinthians\",\n \"Galatians\",\n \"Ephesians\",\n \"Philippians\",\n \"Colossians\",\n \"1 Thessalonians\",\n \"2 Thessalonians\",\n \"1 Timothy\",\n \"2 Timothy\",\n \"Titus\",\n \"Philemon\",\n \"Hebrews\",\n \"James\",\n \"1 Peter\",\n \"2 Peter\",\n \"1 John\",\n \"2 John\",\n \"3 John\",\n \"Jude\",\n \"Revelation\",\n \"Tobit\",\n \"Judith\",\n \"Esther Greek\",\n \"Wisdom of Solomon\",\n \"Sirach (Ecclesiasticus)\",\n \"Baruch\",\n \"Letter of Jeremiah\",\n \"Song of 3 Young Men\",\n \"Susanna\",\n \"Bel and the Dragon\",\n \"1 Maccabees\",\n \"2 Maccabees\",\n \"3 Maccabees\",\n \"4 Maccabees\",\n \"1 Esdras (Greek)\",\n \"2 Esdras (Latin)\",\n \"Prayer of Manasseh\",\n \"Psalm 151\",\n \"Odes\",\n \"Psalms of Solomon\",\n // WARNING, if you change the spelling of the *obsolete* tag be sure to update\n // IsObsolete routine\n \"Joshua A. *obsolete*\",\n \"Judges B. *obsolete*\",\n \"Tobit S. *obsolete*\",\n \"Susanna Th. *obsolete*\",\n \"Daniel Th. *obsolete*\",\n \"Bel Th. *obsolete*\",\n \"Extra A\",\n \"Extra B\",\n \"Extra C\",\n \"Extra D\",\n \"Extra E\",\n \"Extra F\",\n \"Extra G\",\n \"Front Matter\",\n \"Back Matter\",\n \"Other Matter\",\n \"3 Ezra *obsolete*\",\n \"Apocalypse of Ezra\",\n \"5 Ezra (Latin Prologue)\",\n \"6 Ezra (Latin Epilogue)\",\n \"Introduction\",\n \"Concordance \",\n \"Glossary \",\n \"Topical Index\",\n \"Names Index\",\n \"Daniel Greek\",\n \"Psalms 152-155\",\n \"2 Baruch (Apocalypse)\",\n \"Letter of Baruch\",\n \"Jubilees\",\n \"Enoch\",\n \"1 Meqabyan\",\n \"2 Meqabyan\",\n \"3 Meqabyan\",\n \"Reproof (Proverbs 25-31)\",\n \"4 Baruch (Rest of Baruch)\",\n \"Laodiceans\"\n], S = K();\nfunction g(t, e = !0) {\n return e && (t = t.toUpperCase()), t in S ? S[t] : 0;\n}\nfunction k(t) {\n return g(t) > 0;\n}\nfunction x(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return e >= 40 && e <= 66;\n}\nfunction T(t) {\n return (typeof t == \"string\" ? g(t) : t) <= 39;\n}\nfunction X(t) {\n return t <= 66;\n}\nfunction V(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return w(e) && !X(e);\n}\nfunction* L() {\n for (let t = 1; t <= N.length; t++) yield t;\n}\nconst G = 1, A = N.length;\nfunction H() {\n return [\"XXA\", \"XXB\", \"XXC\", \"XXD\", \"XXE\", \"XXF\", \"XXG\"];\n}\nfunction C(t, e = \"***\") {\n const s = t - 1;\n return s < 0 || s >= N.length ? e : N[s];\n}\nfunction I(t) {\n return t <= 0 || t > A ? \"******\" : O[t - 1];\n}\nfunction y(t) {\n return I(g(t));\n}\nfunction w(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && !B.includes(e);\n}\nfunction q(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && B.includes(e);\n}\nfunction U(t) {\n return O[t - 1].includes(\"*obsolete*\");\n}\nfunction K() {\n const t = {};\n for (let e = 0; e < N.length; e++)\n t[N[e]] = e + 1;\n return t;\n}\nconst m = {\n allBookIds: N,\n nonCanonicalIds: B,\n bookIdToNumber: g,\n isBookIdValid: k,\n isBookNT: x,\n isBookOT: T,\n isBookOTNT: X,\n isBookDC: V,\n allBookNumbers: L,\n firstBook: G,\n lastBook: A,\n extraBooks: H,\n bookNumberToId: C,\n bookNumberToEnglishName: I,\n bookIdToEnglishName: y,\n isCanonical: w,\n isExtraMaterial: q,\n isObsolete: U\n};\nvar l = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = \"Unknown\", t[t.Original = 1] = \"Original\", t[t.Septuagint = 2] = \"Septuagint\", t[t.Vulgate = 3] = \"Vulgate\", t[t.English = 4] = \"English\", t[t.RussianProtestant = 5] = \"RussianProtestant\", t[t.RussianOrthodox = 6] = \"RussianOrthodox\", t))(l || {});\nconst h = class h {\n // private versInfo: Versification;\n constructor(e) {\n n(this, \"name\");\n n(this, \"fullPath\");\n n(this, \"isPresent\");\n n(this, \"hasVerseSegments\");\n n(this, \"isCustomized\");\n n(this, \"baseVersification\");\n n(this, \"scriptureBooks\");\n n(this, \"_type\");\n if (e == null)\n throw new Error(\"Argument undefined\");\n typeof e == \"string\" ? (this.name = e, this._type = l[e]) : (this._type = e, this.name = l[e]);\n }\n get type() {\n return this._type;\n }\n equals(e) {\n return !e.type || !this.type ? !1 : e.type === this.type;\n }\n};\nn(h, \"Original\", new h(l.Original)), n(h, \"Septuagint\", new h(l.Septuagint)), n(h, \"Vulgate\", new h(l.Vulgate)), n(h, \"English\", new h(l.English)), n(h, \"RussianProtestant\", new h(l.RussianProtestant)), n(h, \"RussianOrthodox\", new h(l.RussianOrthodox));\nlet c = h;\nfunction E(t, e) {\n const s = e[0];\n for (let r = 1; r < e.length; r++)\n t = t.split(e[r]).join(s);\n return t.split(s);\n}\nvar D = /* @__PURE__ */ ((t) => (t[t.Valid = 0] = \"Valid\", t[t.UnknownVersification = 1] = \"UnknownVersification\", t[t.OutOfRange = 2] = \"OutOfRange\", t[t.VerseOutOfOrder = 3] = \"VerseOutOfOrder\", t[t.VerseRepeated = 4] = \"VerseRepeated\", t))(D || {});\nconst i = class i {\n constructor(e, s, r, a) {\n /** Not yet implemented. */\n n(this, \"firstChapter\");\n /** Not yet implemented. */\n n(this, \"lastChapter\");\n /** Not yet implemented. */\n n(this, \"lastVerse\");\n /** Not yet implemented. */\n n(this, \"hasSegmentsDefined\");\n /** Not yet implemented. */\n n(this, \"text\");\n /** Not yet implemented. */\n n(this, \"BBBCCCVVVS\");\n /** Not yet implemented. */\n n(this, \"longHashCode\");\n /** The versification of the reference. */\n n(this, \"versification\");\n n(this, \"rtlMark\", \"‏\");\n n(this, \"_bookNum\", 0);\n n(this, \"_chapterNum\", 0);\n n(this, \"_verseNum\", 0);\n n(this, \"_verse\");\n if (r == null && a == null)\n if (e != null && typeof e == \"string\") {\n const o = e, u = s != null && s instanceof c ? s : void 0;\n this.setEmpty(u), this.parse(o);\n } else if (e != null && typeof e == \"number\") {\n const o = s != null && s instanceof c ? s : void 0;\n this.setEmpty(o), this._verseNum = e % i.chapterDigitShifter, this._chapterNum = Math.floor(\n e % i.bookDigitShifter / i.chapterDigitShifter\n ), this._bookNum = Math.floor(e / i.bookDigitShifter);\n } else if (s == null)\n if (e != null && e instanceof i) {\n const o = e;\n this._bookNum = o.bookNum, this._chapterNum = o.chapterNum, this._verseNum = o.verseNum, this._verse = o.verse, this.versification = o.versification;\n } else {\n if (e == null) return;\n const o = e instanceof c ? e : i.defaultVersification;\n this.setEmpty(o);\n }\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else if (e != null && s != null && r != null)\n if (typeof e == \"string\" && typeof s == \"string\" && typeof r == \"string\")\n this.setEmpty(a), this.updateInternal(e, s, r);\n else if (typeof e == \"number\" && typeof s == \"number\" && typeof r == \"number\")\n this._bookNum = e, this._chapterNum = s, this._verseNum = r, this.versification = a ?? i.defaultVersification;\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else\n throw new Error(\"VerseRef constructor not supported.\");\n }\n /**\n * Determines if the verse string is in a valid format (does not consider versification).\n */\n static isVerseParseable(e) {\n return e.length > 0 && \"0123456789\".includes(e[0]) && !e.endsWith(this.verseRangeSeparator) && !e.endsWith(this.verseSequenceIndicator);\n }\n /**\n * Tries to parse the specified string into a verse reference.\n * @param str - The string to attempt to parse.\n * @returns success: `true` if the specified string was successfully parsed, `false` otherwise.\n * @returns verseRef: The result of the parse if successful, or empty VerseRef if it failed\n */\n static tryParse(e) {\n let s;\n try {\n return s = new i(e), { success: !0, verseRef: s };\n } catch (r) {\n if (r instanceof v)\n return s = new i(), { success: !1, verseRef: s };\n throw r;\n }\n }\n /**\n * Gets the reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n * @param bookNum - Book number (this is 1-based, not an index).\n * @param chapterNum - Chapter number.\n * @param verseNum - Verse number.\n * @returns The reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n */\n static getBBBCCCVVV(e, s, r) {\n return e % i.bcvMaxValue * i.bookDigitShifter + (s >= 0 ? s % i.bcvMaxValue * i.chapterDigitShifter : 0) + (r >= 0 ? r % i.bcvMaxValue : 0);\n }\n /**\n * Deserializes a serialized VerseRef.\n * @param serializedVerseRef - Serialized VerseRef to create from.\n * @returns the deserialized VerseRef.\n */\n static fromJSON(e) {\n const { book: s, chapterNum: r, verseNum: a, verse: o, versificationStr: u } = e, f = o || a.toString();\n let d;\n return u && (d = new c(u)), s ? new i(s, r.toString(), f, d) : new i();\n }\n /**\n * Parses a verse string and gets the leading numeric portion as a number.\n * @param verseStr - verse string to parse\n * @returns true if the entire string could be parsed as a single, simple verse number (1-999);\n * false if the verse string represented a verse bridge, contained segment letters, or was invalid\n */\n static tryGetVerseNum(e) {\n let s;\n if (!e)\n return s = -1, { success: !0, vNum: s };\n s = 0;\n let r;\n for (let a = 0; a < e.length; a++) {\n if (r = e[a], r < \"0\" || r > \"9\")\n return a === 0 && (s = -1), { success: !1, vNum: s };\n if (s = s * 10 + +r - 0, s > i.bcvMaxValue)\n return s = -1, { success: !1, vNum: s };\n }\n return { success: !0, vNum: s };\n }\n /**\n * Checks to see if a VerseRef hasn't been set - all values are the default.\n */\n get isDefault() {\n return this.bookNum === 0 && this.chapterNum === 0 && this.verseNum === 0 && this.versification == null;\n }\n /**\n * Gets whether the verse contains multiple verses.\n */\n get hasMultiple() {\n return this._verse != null && (this._verse.includes(i.verseRangeSeparator) || this._verse.includes(i.verseSequenceIndicator));\n }\n /**\n * Gets or sets the book of the reference. Book is the 3-letter abbreviation in capital letters,\n * e.g. `'MAT'`.\n */\n get book() {\n return m.bookNumberToId(this.bookNum, \"\");\n }\n set book(e) {\n this.bookNum = m.bookIdToNumber(e);\n }\n /**\n * Gets or sets the chapter of the reference,. e.g. `'3'`.\n */\n get chapter() {\n return this.isDefault || this._chapterNum < 0 ? \"\" : this._chapterNum.toString();\n }\n set chapter(e) {\n const s = +e;\n this._chapterNum = Number.isInteger(s) ? s : -1;\n }\n /**\n * Gets or sets the verse of the reference, including range, segments, and sequences, e.g. `'4'`,\n * or `'4b-5a, 7'`.\n */\n get verse() {\n return this._verse != null ? this._verse : this.isDefault || this._verseNum < 0 ? \"\" : this._verseNum.toString();\n }\n set verse(e) {\n const { success: s, vNum: r } = i.tryGetVerseNum(e);\n this._verse = s ? void 0 : e.replace(this.rtlMark, \"\"), this._verseNum = r, !(this._verseNum >= 0) && ({ vNum: this._verseNum } = i.tryGetVerseNum(this._verse));\n }\n /**\n * Get or set Book based on book number, e.g. `42`.\n */\n get bookNum() {\n return this._bookNum;\n }\n set bookNum(e) {\n if (e <= 0 || e > m.lastBook)\n throw new v(\n \"BookNum must be greater than zero and less than or equal to last book\"\n );\n this._bookNum = e;\n }\n /**\n * Gets or sets the chapter number, e.g. `3`. `-1` if not valid.\n */\n get chapterNum() {\n return this._chapterNum;\n }\n set chapterNum(e) {\n this.chapterNum = e;\n }\n /**\n * Gets or sets verse start number, e.g. `4`. `-1` if not valid.\n */\n get verseNum() {\n return this._verseNum;\n }\n set verseNum(e) {\n this._verseNum = e;\n }\n /**\n * String representing the versification (should ONLY be used for serialization/deserialization).\n *\n * @remarks This is for backwards compatibility when ScrVers was an enumeration.\n */\n get versificationStr() {\n var e;\n return (e = this.versification) == null ? void 0 : e.name;\n }\n set versificationStr(e) {\n this.versification = this.versification != null ? new c(e) : void 0;\n }\n /**\n * Determines if the reference is valid.\n */\n get valid() {\n return this.validStatus === 0;\n }\n /**\n * Get the valid status for this reference.\n */\n get validStatus() {\n return this.validateVerse(i.verseRangeSeparators, i.verseSequenceIndicators);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits and the verse is 0.\n */\n get BBBCCC() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, 0);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits. If verse is not null\n * (i.e., this reference represents a complex reference with verse\n * segments or bridge) this cannot be used for an exact comparison.\n */\n get BBBCCCVVV() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, this._verseNum);\n }\n /**\n * Gets whether the verse is defined as an excluded verse in the versification.\n * Does not handle verse ranges.\n */\n // eslint-disable-next-line @typescript-eslint/class-literal-property-style\n get isExcluded() {\n return !1;\n }\n /**\n * Parses the reference in the specified string.\n * Optionally versification can follow reference as in GEN 3:11/4\n * Throw an exception if\n * - invalid book name\n * - chapter number is missing or not a number\n * - verse number is missing or does not start with a number\n * - versification is invalid\n * @param verseStr - string to parse e.g. 'MAT 3:11'\n */\n parse(e) {\n if (e = e.replace(this.rtlMark, \"\"), e.includes(\"/\")) {\n const o = e.split(\"/\");\n if (e = o[0], o.length > 1)\n try {\n const u = +o[1].trim();\n this.versification = new c(l[u]);\n } catch {\n throw new v(\"Invalid reference : \" + e);\n }\n }\n const s = e.trim().split(\" \");\n if (s.length !== 2)\n throw new v(\"Invalid reference : \" + e);\n const r = s[1].split(\":\"), a = +r[0];\n if (r.length !== 2 || m.bookIdToNumber(s[0]) === 0 || !Number.isInteger(a) || a < 0 || !i.isVerseParseable(r[1]))\n throw new v(\"Invalid reference : \" + e);\n this.updateInternal(s[0], r[0], r[1]);\n }\n /**\n * Simplifies this verse ref so that it has no bridging of verses or\n * verse segments like `'1a'`.\n */\n simplify() {\n this._verse = void 0;\n }\n /**\n * Makes a clone of the reference.\n *\n * @returns The cloned VerseRef.\n */\n clone() {\n return new i(this);\n }\n toString() {\n const e = this.book;\n return e === \"\" ? \"\" : `${e} ${this.chapter}:${this.verse}`;\n }\n toJSON() {\n let e = this.verse;\n (e === \"\" || e === this.verseNum.toString()) && (e = void 0);\n const s = {\n book: this.book,\n chapterNum: this.chapterNum,\n verseNum: this.verseNum,\n verse: e,\n versificationStr: this.versificationStr\n };\n return e || delete s.verse, s;\n }\n /**\n * Compares this `VerseRef` with supplied one.\n * @param verseRef - object to compare this one to.\n * @returns `true` if this `VerseRef` is equal to the supplied one, `false` otherwise.\n */\n equals(e) {\n return e instanceof i ? e._bookNum === this._bookNum && e._chapterNum === this._chapterNum && e._verseNum === this._verseNum && e.verse === this.verse && (e.versification == null && this.versification == null || e.versification != null && this.versification != null && e.versification.equals(this.versification)) : !1;\n }\n /**\n * Enumerate all individual verses contained in a VerseRef.\n * Verse ranges are indicated by \"-\" and consecutive verses by \",\"s.\n * Examples:\n * GEN 1:2 returns GEN 1:2\n * GEN 1:1a-3b,5 returns GEN 1:1a, GEN 1:2, GEN 1:3b, GEN 1:5\n * GEN 1:2a-2c returns //! ??????\n *\n * @param specifiedVersesOnly - if set to true return only verses that are\n * explicitly specified only, not verses within a range. Defaults to `false`.\n * @param verseRangeSeparators - Verse range separators.\n * Defaults to `VerseRef.verseRangeSeparators`.\n * @param verseSequenceSeparators - Verse sequence separators.\n * Defaults to `VerseRef.verseSequenceIndicators`.\n * @returns An array of all single verse references in this VerseRef.\n */\n allVerses(e = !1, s = i.verseRangeSeparators, r = i.verseSequenceIndicators) {\n if (this._verse == null || this.chapterNum <= 0)\n return [this.clone()];\n const a = [], o = E(this._verse, r);\n for (const u of o.map((f) => E(f, s))) {\n const f = this.clone();\n f.verse = u[0];\n const d = f.verseNum;\n if (a.push(f), u.length > 1) {\n const b = this.clone();\n if (b.verse = u[1], !e)\n for (let p = d + 1; p < b.verseNum; p++) {\n const J = new i(\n this._bookNum,\n this._chapterNum,\n p,\n this.versification\n );\n this.isExcluded || a.push(J);\n }\n a.push(b);\n }\n }\n return a;\n }\n /**\n * Validates a verse number using the supplied separators rather than the defaults.\n */\n validateVerse(e, s) {\n if (!this.verse)\n return this.internalValid;\n let r = 0;\n for (const a of this.allVerses(!0, e, s)) {\n const o = a.internalValid;\n if (o !== 0)\n return o;\n const u = a.BBBCCCVVV;\n if (r > u)\n return 3;\n if (r === u)\n return 4;\n r = u;\n }\n return 0;\n }\n /**\n * Gets whether a single verse reference is valid.\n */\n get internalValid() {\n return this.versification == null ? 1 : this._bookNum <= 0 || this._bookNum > m.lastBook ? 2 : (m.isCanonical(this._bookNum), 0);\n }\n setEmpty(e = i.defaultVersification) {\n this._bookNum = 0, this._chapterNum = -1, this._verse = void 0, this.versification = e;\n }\n updateInternal(e, s, r) {\n this.bookNum = m.bookIdToNumber(e), this.chapter = s, this.verse = r;\n }\n};\nn(i, \"defaultVersification\", c.English), n(i, \"verseRangeSeparator\", \"-\"), n(i, \"verseSequenceIndicator\", \",\"), n(i, \"verseRangeSeparators\", [i.verseRangeSeparator]), n(i, \"verseSequenceIndicators\", [i.verseSequenceIndicator]), n(i, \"chapterDigitShifter\", 1e3), n(i, \"bookDigitShifter\", i.chapterDigitShifter * i.chapterDigitShifter), n(i, \"bcvMaxValue\", i.chapterDigitShifter - 1), /**\n * The valid status of the VerseRef.\n */\nn(i, \"ValidStatusType\", D);\nlet M = i;\nclass v extends Error {\n}\nexport {\n _ as BookSet,\n m as Canon,\n c as ScrVers,\n l as ScrVersType,\n M as VerseRef,\n v as VerseRefException\n};\n//# sourceMappingURL=index.es.js.map\n","'use strict';\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties,\n * including NodeList.\n *\n * @param {T[] | { length: number; [number]: T }} list\n * @param {function (item: T, index: number, list:T[]):boolean} predicate\n * @param {Partial>?} ac\n * Allows injecting a custom implementation in tests (`Array.prototype` by default).\n * @returns {T | undefined}\n * @template {unknown} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (hasOwn(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * If `Object.getOwnPropertyDescriptors` is available,\n * a new object with all properties of object but without any prototype is created and returned\n * after freezing it.\n *\n * @param {T} object\n * The object to freeze.\n * @param {Pick} [oc=Object]\n * `Object` by default,\n * allows to inject custom object constructor for tests.\n * @returns {Readonly}\n * @template {Object} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n * @prettierignore\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object;\n\t}\n\tif (oc && typeof oc.getOwnPropertyDescriptors === 'function') {\n\t\tobject = oc.create(null, oc.getOwnPropertyDescriptors(object));\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;\n}\n\n/**\n * Implementation for `Object.hasOwn` but ES5 compatible.\n *\n * @param {any} object\n * @param {string | number} key\n * @returns {boolean}\n */\nfunction hasOwn(object, key) {\n\treturn Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Since xmldom can not rely on `Object.assign`,\n * it uses/provides a simplified version that is sufficient for its needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n * @returns {Object}\n * The target with the merged/overridden properties.\n * @throws {TypeError}\n * If target is not an object.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object');\n\t}\n\tfor (var key in source) {\n\t\tif (hasOwn(source, key)) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * A number of attributes are boolean attributes.\n * The presence of a boolean attribute on an element represents the `true` value,\n * and the absence of the attribute represents the `false` value.\n *\n * If the attribute is present, its value must either be the empty string, or a value that is\n * an ASCII case-insensitive match for the attribute's canonical name,\n * with no leading or trailing whitespace.\n *\n * Note: The values `\"true\"` and `\"false\"` are not allowed on boolean attributes.\n * To represent a `false` value, the attribute has to be omitted altogether.\n *\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nvar HTML_BOOLEAN_ATTRIBUTES = freeze({\n\tallowfullscreen: true,\n\tasync: true,\n\tautofocus: true,\n\tautoplay: true,\n\tchecked: true,\n\tcontrols: true,\n\tdefault: true,\n\tdefer: true,\n\tdisabled: true,\n\tformnovalidate: true,\n\thidden: true,\n\tismap: true,\n\titemscope: true,\n\tloop: true,\n\tmultiple: true,\n\tmuted: true,\n\tnomodule: true,\n\tnovalidate: true,\n\topen: true,\n\tplaysinline: true,\n\treadonly: true,\n\trequired: true,\n\treversed: true,\n\tselected: true,\n});\n\n/**\n * Check if `name` is matching one of the HTML boolean attribute names.\n * This method doesn't check if such attributes are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} name\n * @returns {boolean}\n * @see {@link HTML_BOOLEAN_ATTRIBUTES}\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nfunction isHTMLBooleanAttribute(name) {\n\treturn hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());\n}\n\n/**\n * Void elements only have a start tag; end tags must not be specified for void elements.\n * These elements should be written as self-closing like this: ``.\n * This should not be confused with optional tags that HTML allows to omit the end tag for\n * (like `li`, `tr` and others), which can have content after them,\n * so they can not be written as self-closing.\n * xmldom does not have any logic for optional end tags cases,\n * and will report them as a warning.\n * Content that would go into the unopened element,\n * will instead be added as a sibling text node.\n *\n * @type {Readonly<{\n * \tarea: boolean;\n * \tcol: boolean;\n * \timg: boolean;\n * \twbr: boolean;\n * \tlink: boolean;\n * \thr: boolean;\n * \tsource: boolean;\n * \tbr: boolean;\n * \tinput: boolean;\n * \tparam: boolean;\n * \tmeta: boolean;\n * \tembed: boolean;\n * \ttrack: boolean;\n * \tbase: boolean;\n * }>}\n * @see https://html.spec.whatwg.org/#void-elements\n * @see https://html.spec.whatwg.org/#optional-tags\n */\nvar HTML_VOID_ELEMENTS = freeze({\n\tarea: true,\n\tbase: true,\n\tbr: true,\n\tcol: true,\n\tembed: true,\n\thr: true,\n\timg: true,\n\tinput: true,\n\tlink: true,\n\tmeta: true,\n\tparam: true,\n\tsource: true,\n\ttrack: true,\n\twbr: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML void element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link HTML_VOID_ELEMENTS}\n * @see https://html.spec.whatwg.org/#void-elements\n */\nfunction isHTMLVoidElement(tagName) {\n\treturn hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());\n}\n\n/**\n * Tag names that are raw text elements according to HTML spec.\n * The value denotes whether they are escapable or not.\n *\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link isHTMLRawTextElement}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nvar HTML_RAW_TEXT_ELEMENTS = freeze({\n\tscript: false,\n\tstyle: false,\n\ttextarea: true,\n\ttitle: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Check if `tagName` is matching one of the HTML escapable raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLEscapableRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'text/html'}\n * @see https://www.iana.org/assignments/media-types/text/html\n * @see https://en.wikipedia.org/wiki/HTML\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n */\nfunction isHTMLMimeType(mimeType) {\n\treturn mimeType === MIME_TYPE.HTML;\n}\n/**\n * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the\n * HTML namespace is provided as the default.\n *\n * @param {string} mimeType\n * @returns {boolean}\n * @see https://dom.spec.whatwg.org/#dom-document-createelement\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n */\nfunction hasDefaultHTMLNamespace(mimeType) {\n\treturn isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02\n * MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype\n * WHATWG HTML Spec\n * @see {@link DOMParser.prototype.parseFromString}\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n\t * WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType\n\t * registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/xml`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType\n\t * registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n});\n/**\n * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n * MimeType\n */\n/**\n * @type {MimeType[]}\n * @private\n * Basically `Object.values`, which is not available in ES5.\n */\nvar _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {\n\treturn MIME_TYPE[key];\n});\n\n/**\n * Only returns true if `mimeType` is one of the allowed values for\n * `DOMParser.parseFromString`.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n *\n */\nfunction isValidMimeType(mimeType) {\n\treturn _MIME_TYPES.indexOf(mimeType) > -1;\n}\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace.\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n});\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;\nexports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;\nexports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;\nexports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;\nexports.hasOwn = hasOwn;\nexports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;\nexports.isHTMLRawTextElement = isHTMLRawTextElement;\nexports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;\nexports.isHTMLMimeType = isHTMLMimeType;\nexports.isHTMLVoidElement = isHTMLVoidElement;\nexports.isValidMimeType = isValidMimeType;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","'use strict';\n\nvar conventions = require('./conventions');\n\nfunction extendError(constructor, writableName) {\n\tconstructor.prototype = Object.create(Error.prototype, {\n\t\tconstructor: { value: constructor },\n\t\tname: { value: constructor.name, enumerable: true, writable: writableName },\n\t});\n}\n\nvar DOMExceptionName = conventions.freeze({\n\t/**\n\t * the default value as defined by the spec\n\t */\n\tError: 'Error',\n\t/**\n\t * @deprecated\n\t * Use RangeError instead.\n\t */\n\tIndexSizeError: 'IndexSizeError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tDomstringSizeError: 'DomstringSizeError',\n\tHierarchyRequestError: 'HierarchyRequestError',\n\tWrongDocumentError: 'WrongDocumentError',\n\tInvalidCharacterError: 'InvalidCharacterError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tNoDataAllowedError: 'NoDataAllowedError',\n\tNoModificationAllowedError: 'NoModificationAllowedError',\n\tNotFoundError: 'NotFoundError',\n\tNotSupportedError: 'NotSupportedError',\n\tInUseAttributeError: 'InUseAttributeError',\n\tInvalidStateError: 'InvalidStateError',\n\tSyntaxError: 'SyntaxError',\n\tInvalidModificationError: 'InvalidModificationError',\n\tNamespaceError: 'NamespaceError',\n\t/**\n\t * @deprecated\n\t * Use TypeError for invalid arguments,\n\t * \"NotSupportedError\" DOMException for unsupported operations,\n\t * and \"NotAllowedError\" DOMException for denied requests instead.\n\t */\n\tInvalidAccessError: 'InvalidAccessError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tValidationError: 'ValidationError',\n\t/**\n\t * @deprecated\n\t * Use TypeError instead.\n\t */\n\tTypeMismatchError: 'TypeMismatchError',\n\tSecurityError: 'SecurityError',\n\tNetworkError: 'NetworkError',\n\tAbortError: 'AbortError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tURLMismatchError: 'URLMismatchError',\n\tQuotaExceededError: 'QuotaExceededError',\n\tTimeoutError: 'TimeoutError',\n\tInvalidNodeTypeError: 'InvalidNodeTypeError',\n\tDataCloneError: 'DataCloneError',\n\tEncodingError: 'EncodingError',\n\tNotReadableError: 'NotReadableError',\n\tUnknownError: 'UnknownError',\n\tConstraintError: 'ConstraintError',\n\tDataError: 'DataError',\n\tTransactionInactiveError: 'TransactionInactiveError',\n\tReadOnlyError: 'ReadOnlyError',\n\tVersionError: 'VersionError',\n\tOperationError: 'OperationError',\n\tNotAllowedError: 'NotAllowedError',\n\tOptOutError: 'OptOutError',\n});\nvar DOMExceptionNames = Object.keys(DOMExceptionName);\n\nfunction isValidDomExceptionCode(value) {\n\treturn typeof value === 'number' && value >= 1 && value <= 25;\n}\nfunction endsWithError(value) {\n\treturn typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;\n}\n/**\n * DOM operations only raise exceptions in \"exceptional\" circumstances, i.e., when an operation\n * is impossible to perform (either for logical reasons, because data is lost, or because the\n * implementation has become unstable). In general, DOM methods return specific error values in\n * ordinary processing situations, such as out-of-bound errors when using NodeList.\n *\n * Implementations should raise other exceptions under other circumstances. For example,\n * implementations should raise an implementation-dependent exception if a null argument is\n * passed when null was not expected.\n *\n * This implementation supports the following usages:\n * 1. according to the living standard (both arguments are optional):\n * ```\n * new DOMException(\"message (can be empty)\", DOMExceptionNames.HierarchyRequestError)\n * ```\n * 2. according to previous xmldom implementation (only the first argument is required):\n * ```\n * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, \"optional message\")\n * ```\n * both result in the proper name being set.\n *\n * @class DOMException\n * @param {number | string} messageOrCode\n * The reason why an operation is not acceptable.\n * If it is a number, it is used to determine the `name`, see\n * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}\n * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]\n * The `name` to use for the error.\n * If `messageOrCode` is a number, this arguments is used as the `message` instead.\n * @augments Error\n * @see https://webidl.spec.whatwg.org/#idl-DOMException\n * @see https://webidl.spec.whatwg.org/#dfn-error-names-table\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(messageOrCode, nameOrMessage) {\n\t// support old way of passing arguments: first argument is a valid number\n\tif (isValidDomExceptionCode(messageOrCode)) {\n\t\tthis.name = DOMExceptionNames[messageOrCode];\n\t\tthis.message = nameOrMessage || '';\n\t} else {\n\t\tthis.message = messageOrCode;\n\t\tthis.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;\n\t}\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n}\nextendError(DOMException, true);\nObject.defineProperties(DOMException.prototype, {\n\tcode: {\n\t\tenumerable: true,\n\t\tget: function () {\n\t\t\tvar code = DOMExceptionNames.indexOf(this.name);\n\t\t\tif (isValidDomExceptionCode(code)) return code;\n\t\t\treturn 0;\n\t\t},\n\t},\n});\n\nvar ExceptionCode = {\n\tINDEX_SIZE_ERR: 1,\n\tDOMSTRING_SIZE_ERR: 2,\n\tHIERARCHY_REQUEST_ERR: 3,\n\tWRONG_DOCUMENT_ERR: 4,\n\tINVALID_CHARACTER_ERR: 5,\n\tNO_DATA_ALLOWED_ERR: 6,\n\tNO_MODIFICATION_ALLOWED_ERR: 7,\n\tNOT_FOUND_ERR: 8,\n\tNOT_SUPPORTED_ERR: 9,\n\tINUSE_ATTRIBUTE_ERR: 10,\n\tINVALID_STATE_ERR: 11,\n\tSYNTAX_ERR: 12,\n\tINVALID_MODIFICATION_ERR: 13,\n\tNAMESPACE_ERR: 14,\n\tINVALID_ACCESS_ERR: 15,\n\tVALIDATION_ERR: 16,\n\tTYPE_MISMATCH_ERR: 17,\n\tSECURITY_ERR: 18,\n\tNETWORK_ERR: 19,\n\tABORT_ERR: 20,\n\tURL_MISMATCH_ERR: 21,\n\tQUOTA_EXCEEDED_ERR: 22,\n\tTIMEOUT_ERR: 23,\n\tINVALID_NODE_TYPE_ERR: 24,\n\tDATA_CLONE_ERR: 25,\n};\n\nvar entries = Object.entries(ExceptionCode);\nfor (var i = 0; i < entries.length; i++) {\n\tvar key = entries[i][0];\n\tDOMException[key] = entries[i][1];\n}\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @class\n * @param {string} message\n * @param {any} [locator]\n */\nfunction ParseError(message, locator) {\n\tthis.message = message;\n\tthis.locator = locator;\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nextendError(ParseError);\n\nexports.DOMException = DOMException;\nexports.DOMExceptionName = DOMExceptionName;\nexports.ExceptionCode = ExceptionCode;\nexports.ParseError = ParseError;\n","'use strict';\n\n/**\n * Detects relevant unicode support for regular expressions in the runtime.\n * Should the runtime not accepts the flag `u` or unicode ranges,\n * character classes without unicode handling will be used.\n *\n * @param {typeof RegExp} [RegExpImpl=RegExp]\n * For testing: the RegExp class.\n * @returns {boolean}\n * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags\n */\nfunction detectUnicodeSupport(RegExpImpl) {\n\ttry {\n\t\tif (typeof RegExpImpl !== 'function') {\n\t\t\tRegExpImpl = RegExp;\n\t\t}\n\t\t// eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape\n\t\tvar match = new RegExpImpl('\\u{1d306}', 'u').exec('𝌆');\n\t\treturn !!match && match[0].length === 2;\n\t} catch (error) {}\n\treturn false;\n}\nvar UNICODE_SUPPORT = detectUnicodeSupport();\n\n/**\n * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.\n *\n * @param {RegExp} regexp\n */\nfunction chars(regexp) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error(regexp + ' can not be used with chars');\n\t}\n\treturn regexp.source.slice(1, regexp.source.lastIndexOf(']'));\n}\n\n/**\n * Creates a new character list regular expression,\n * by removing `search` from the source of `regexp`.\n *\n * @param {RegExp} regexp\n * @param {string} search\n * The character(s) to remove.\n * @returns {RegExp}\n */\nfunction chars_without(regexp, search) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error('/' + regexp.source + '/ can not be used with chars_without');\n\t}\n\tif (!search || typeof search !== 'string') {\n\t\tthrow new Error(JSON.stringify(search) + ' is not a valid search');\n\t}\n\tif (regexp.source.indexOf(search) === -1) {\n\t\tthrow new Error('\"' + search + '\" is not is /' + regexp.source + '/');\n\t}\n\tif (search === '-' && regexp.source.indexOf(search) !== 1) {\n\t\tthrow new Error('\"' + search + '\" is not at the first postion of /' + regexp.source + '/');\n\t}\n\treturn new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');\n}\n\n/**\n * Combines and Regular expressions correctly by using `RegExp.source`.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction reg(args) {\n\tvar self = this;\n\treturn new RegExp(\n\t\tArray.prototype.slice\n\t\t\t.call(arguments)\n\t\t\t.map(function (part) {\n\t\t\t\tvar isStr = typeof part === 'string';\n\t\t\t\tif (isStr && self === undefined && part === '|') {\n\t\t\t\t\tthrow new Error('use regg instead of reg to wrap expressions with `|`!');\n\t\t\t\t}\n\t\t\t\treturn isStr ? part : part.source;\n\t\t\t})\n\t\t\t.join(''),\n\t\tUNICODE_SUPPORT ? 'mu' : 'm'\n\t);\n}\n\n/**\n * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction regg(args) {\n\tif (arguments.length === 0) {\n\t\tthrow new Error('no parameters provided');\n\t}\n\treturn reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));\n}\n\n// /**\n// * Append ^ to the beginning of the expression.\n// * @param {...(RegExp | string)[]} args\n// * @returns {RegExp}\n// */\n// function reg_start(args) {\n// \tif (arguments.length === 0) {\n// \t\tthrow new Error('no parameters provided');\n// \t}\n// \treturn reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));\n// }\n\n// https://www.w3.org/TR/xml/#document\n// `[1] document ::= prolog element Misc*`\n// https://www.w3.org/TR/xml11/#NT-document\n// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`\n\n/**\n * A character usually appearing in wrongly converted strings.\n *\n * @type {string}\n * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character\n * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings\n * @see https://www.unicode.org/faq/utf_bom.html#BOM\n * @readonly\n */\nvar UNICODE_REPLACEMENT_CHARACTER = '\\uFFFD';\n// https://www.w3.org/TR/xml/#NT-Char\n// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-Char\n// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-RestrictedChar\n// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`\n// https://www.w3.org/TR/xml11/#charsets\nvar Char = /[-\\x09\\x0A\\x0D\\x20-\\x2C\\x2E-\\uD7FF\\uE000-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tChar = reg('[', chars(Char), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\n\nvar _SChar = /[\\x20\\x09\\x0D\\x0A]/;\nvar SChar_s = chars(_SChar);\n// https://www.w3.org/TR/xml11/#NT-S\n// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`\nvar S = reg(_SChar, '+');\n// optional whitespace described as `S?` in the grammar,\n// simplified to 0-n occurrences of the character class\n// instead of 0-1 occurrences of a non-capturing group around S\nvar S_OPT = reg(_SChar, '*');\n\n// https://www.w3.org/TR/xml11/#NT-NameStartChar\n// `[4] NameStartChar ::= \":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`\nvar NameStartChar =\n\t/[:_a-zA-Z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02FF\\u0370-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tNameStartChar = reg('[', chars(NameStartChar), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\nvar NameStartChar_s = chars(NameStartChar);\n\n// https://www.w3.org/TR/xml11/#NT-NameChar\n// `[4a] NameChar ::= NameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`\nvar NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\\xB7]/), chars(/[\\u0300-\\u036F\\u203F-\\u2040]/), ']');\n// https://www.w3.org/TR/xml11/#NT-Name\n// `[5] Name ::= NameStartChar (NameChar)*`\nvar Name = reg(NameStartChar, NameChar, '*');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Names\n`[6] Names ::= Name (#x20 Name)*`\n*/\n\n// https://www.w3.org/TR/xml11/#NT-Nmtoken\n// `[7] Nmtoken ::= (NameChar)+`\nvar Nmtoken = reg(NameChar, '+');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Nmtokens\n`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`\nvar Nmtokens = reg(Nmtoken, regg(/\\x20/, Nmtoken), '*');\n*/\n\n// https://www.w3.org/TR/xml11/#NT-EntityRef\n// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\nvar EntityRef = reg('&', Name, ';');\n// https://www.w3.org/TR/xml11/#NT-CharRef\n// `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\nvar CharRef = regg(/&#[0-9]+;|&#x[0-9a-fA-F]+;/);\n\n/*\nhttps://www.w3.org/TR/xml11/#NT-Reference\n- `[67] Reference ::= EntityRef | CharRef`\n- `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\n- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\n*/\nvar Reference = regg(EntityRef, '|', CharRef);\n\n// https://www.w3.org/TR/xml11/#NT-PEReference\n// `[69] PEReference ::= '%' Name ';'`\n// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]\nvar PEReference = reg('%', Name, ';');\n\n// https://www.w3.org/TR/xml11/#NT-EntityValue\n// `[9] EntityValue ::= '\"' ([^%&\"] | PEReference | Reference)* '\"' | \"'\" ([^%&'] | PEReference | Reference)* \"'\"`\nvar EntityValue = regg(\n\treg('\"', regg(/[^%&\"]/, '|', PEReference, '|', Reference), '*', '\"'),\n\t'|',\n\treg(\"'\", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', \"'\")\n);\n\n// https://www.w3.org/TR/xml11/#NT-AttValue\n// `[10] AttValue ::= '\"' ([^<&\"] | Reference)* '\"' | \"'\" ([^<&'] | Reference)* \"'\"`\nvar AttValue = regg('\"', regg(/[^<&\"]/, '|', Reference), '*', '\"', '|', \"'\", regg(/[^<&']/, '|', Reference), '*', \"'\");\n\n// https://www.w3.org/TR/xml-names/#ns-decl\n// https://www.w3.org/TR/xml-names/#ns-qualnames\n// NameStartChar without \":\"\nvar NCNameStartChar = chars_without(NameStartChar, ':');\n// https://www.w3.org/TR/xml-names/#orphans\n// `[5] NCNameChar ::= NameChar - ':'`\n// An XML NameChar, minus the \":\"\nvar NCNameChar = chars_without(NameChar, ':');\n// https://www.w3.org/TR/xml-names/#NT-NCName\n// `[4] NCName ::= Name - (Char* ':' Char*)`\n// An XML Name, minus the \":\"\nvar NCName = reg(NCNameStartChar, NCNameChar, '*');\n\n/**\nhttps://www.w3.org/TR/xml-names/#ns-qualnames\n\n```\n[7] QName ::= PrefixedName | UnprefixedName\n\t\t\t\t === (NCName ':' NCName) | NCName\n\t\t\t\t === NCName (':' NCName)?\n[8] PrefixedName ::= Prefix ':' LocalPart\n\t\t\t\t\t\t\t\t === NCName ':' NCName\n[9] UnprefixedName ::= LocalPart\n\t\t\t\t\t\t\t\t\t === NCName\n[10] Prefix ::= NCName\n[11] LocalPart ::= NCName\n```\n*/\nvar QName = reg(NCName, regg(':', NCName), '?');\nvar QName_exact = reg('^', QName, '$');\nvar QName_group = reg('(', QName, ')');\n\n// https://www.w3.org/TR/xml11/#NT-SystemLiteral\n// `[11] SystemLiteral ::= ('\"' [^\"]* '\"') | (\"'\" [^']* \"'\")`\nvar SystemLiteral = regg(/\"[^\"]*\"|'[^']*'/);\n\n/*\n https://www.w3.org/TR/xml11/#NT-PI\n ```\n [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))\n [16] PI ::= '' Char*)))? '?>'\n ```\n target /xml/i is not excluded!\n*/\nvar PI = reg(/^<\\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\\?>/);\n\n// https://www.w3.org/TR/xml11/#NT-PubidChar\n// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`\nvar PubidChar = /[\\x20\\x0D\\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;\n\n// https://www.w3.org/TR/xml11/#NT-PubidLiteral\n// `[12] PubidLiteral ::= '\"' PubidChar* '\"' | \"'\" (PubidChar - \"'\")* \"'\"`\nvar PubidLiteral = regg('\"', PubidChar, '*\"', '|', \"'\", chars_without(PubidChar, \"'\"), \"*'\");\n\n// https://www.w3.org/TR/xml11/#NT-CharData\n// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`\n\nvar COMMENT_START = '';\n// https://www.w3.org/TR/xml11/#NT-Comment\n// `[15] Comment ::= ''`\nvar Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);\n\nvar PCDATA = '#PCDATA';\n// https://www.w3.org/TR/xml11/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// https://www.w3.org/TR/xml-names/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]\nvar Mixed = regg(\n\treg(/\\(/, S_OPT, PCDATA, regg(S_OPT, /\\|/, S_OPT, QName), '*', S_OPT, /\\)\\*/),\n\t'|',\n\treg(/\\(/, S_OPT, PCDATA, S_OPT, /\\)/)\n);\n\nvar _children_quantity = /[?*+]?/;\n/*\n `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]\n `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');\n ```\n [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?\n === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?\n !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?\n ```\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.\nhttps://github.com/xmldom/xmldom/security/code-scanning/91\nvar choice = regg(/\\(/, S_OPT, cp, regg(S_OPT, /\\|/, S_OPT, cp), '+', S_OPT, /\\)/);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.\nhttps://github.com/xmldom/xmldom/security/code-scanning/92\nvar seq = regg(/\\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\\)/);\n*/\n\n// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`\n// simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\nvar children = reg(/\\([^>]+\\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);\n\n// https://www.w3.org/TR/xml11/#NT-contentspec\n// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`\nvar contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);\n\nvar ELEMENTDECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-elementdecl\n// `[17] elementdecl ::= ''`\n// because of https://www.w3.org/TR/xml11/#NT-PEReference\n// since xmldom is not supporting replacements of PEReferences in the DTD\n// this also supports PEReference in the possible places\nvar elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');\n\n// https://www.w3.org/TR/xml11/#NT-NotationType\n// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`\n// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]\nvar NotationType = reg('NOTATION', S, /\\(/, S_OPT, Name, regg(S_OPT, /\\|/, S_OPT, Name), '*', S_OPT, /\\)/);\n// https://www.w3.org/TR/xml11/#NT-Enumeration\n// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`\n// [VC: Enumeration] [VC: No Duplicate Tokens]\nvar Enumeration = reg(/\\(/, S_OPT, Nmtoken, regg(S_OPT, /\\|/, S_OPT, Nmtoken), '*', S_OPT, /\\)/);\n\n// https://www.w3.org/TR/xml11/#NT-EnumeratedType\n// `[57] EnumeratedType ::= NotationType | Enumeration`\nvar EnumeratedType = regg(NotationType, '|', Enumeration);\n\n/*\n```\n[55] StringType ::= 'CDATA'\n[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]\n | 'IDREF' [VC: IDREF]\n | 'IDREFS' [VC: IDREF]\n\t | 'ENTITY' [VC: Entity Name]\n\t | 'ENTITIES' [VC: Entity Name]\n\t | 'NMTOKEN' [VC: Name Token]\n\t | 'NMTOKENS' [VC: Name Token]\n [54] AttType ::= StringType | TokenizedType | EnumeratedType\n```*/\nvar AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);\n\n// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`\n// [WFC: No < in Attribute Values] [WFC: No External Entity References]\n// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]\nvar DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));\n\n// https://www.w3.org/TR/xml11/#NT-AttDef\n// [53] AttDef ::= S Name S AttType S DefaultDecl\n// https://www.w3.org/TR/xml-names/#NT-AttDef\n// [1] NSAttName ::= PrefixedAttName | DefaultAttName\n// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]\n// [3] DefaultAttName ::= 'xmlns'\n// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl\n// \t\t\t\t\t\t === S Name S AttType S DefaultDecl\n// xmldom is not distinguishing between QName and NSAttName on this level\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttDef = regg(S, Name, S, AttType, S, DefaultDecl);\n\nvar ATTLIST_DECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-AttlistDecl\n// `[20] AttlistDecl ::= ''`\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');\n\n// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat\nvar ABOUT_LEGACY_COMPAT = 'about:legacy-compat';\nvar ABOUT_LEGACY_COMPAT_SystemLiteral = regg('\"' + ABOUT_LEGACY_COMPAT + '\"', '|', \"'\" + ABOUT_LEGACY_COMPAT + \"'\");\nvar SYSTEM = 'SYSTEM';\nvar PUBLIC = 'PUBLIC';\n// https://www.w3.org/TR/xml11/#NT-ExternalID\n// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`\nvar ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));\nvar ExternalID_match = reg(\n\t'^',\n\tregg(\n\t\tregg(SYSTEM, S, '(?', SystemLiteral, ')'),\n\t\t'|',\n\t\tregg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')\n\t)\n);\n\n// https://www.w3.org/TR/xml11/#NT-NDataDecl\n// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]\nvar NDataDecl = regg(S, 'NDATA', S, Name);\n\n// https://www.w3.org/TR/xml11/#NT-EntityDef\n// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`\nvar EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));\n\nvar ENTITY_DECL_START = ''`\nvar GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-PEDef\n// `[74] PEDef ::= EntityValue | ExternalID`\nvar PEDef = regg(EntityValue, '|', ExternalID);\n// https://www.w3.org/TR/xml11/#NT-PEDecl\n// `[72] PEDecl ::= ''`\nvar PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-EntityDecl\n// `[70] EntityDecl ::= GEDecl | PEDecl`\nvar EntityDecl = regg(GEDecl, '|', PEDecl);\n\n// https://www.w3.org/TR/xml11/#NT-PublicID\n// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`\nvar PublicID = reg(PUBLIC, S, PubidLiteral);\n// https://www.w3.org/TR/xml11/#NT-NotationDecl\n// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]\nvar NotationDecl = reg('');\n\n// https://www.w3.org/TR/xml11/#NT-Eq\n// `[25] Eq ::= S? '=' S?`\nvar Eq = reg(S_OPT, '=', S_OPT);\n// https://www.w3.org/TR/xml/#NT-VersionNum\n// `[26] VersionNum ::= '1.' [0-9]+`\n// https://www.w3.org/TR/xml11/#NT-VersionNum\n// `[26] VersionNum ::= '1.1'`\nvar VersionNum = /1[.]\\d+/;\n// https://www.w3.org/TR/xml11/#NT-VersionInfo\n// `[24] VersionInfo ::= S 'version' Eq (\"'\" VersionNum \"'\" | '\"' VersionNum '\"')`\nvar VersionInfo = reg(S, 'version', Eq, regg(\"'\", VersionNum, \"'\", '|', '\"', VersionNum, '\"'));\n// https://www.w3.org/TR/xml11/#NT-EncName\n// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`\nvar EncName = /[A-Za-z][-A-Za-z0-9._]*/;\n// https://www.w3.org/TR/xml11/#NT-EncDecl\n// `[80] EncodingDecl ::= S 'encoding' Eq ('\"' EncName '\"' | \"'\" EncName \"'\" )`\nvar EncodingDecl = regg(S, 'encoding', Eq, regg('\"', EncName, '\"', '|', \"'\", EncName, \"'\"));\n// https://www.w3.org/TR/xml11/#NT-SDDecl\n// `[32] SDDecl ::= S 'standalone' Eq ((\"'\" ('yes' | 'no') \"'\") | ('\"' ('yes' | 'no') '\"'))`\nvar SDDecl = regg(S, 'standalone', Eq, regg(\"'\", regg('yes', '|', 'no'), \"'\", '|', '\"', regg('yes', '|', 'no'), '\"'));\n// https://www.w3.org/TR/xml11/#NT-XMLDecl\n// [23] XMLDecl ::= ''\nvar XMLDecl = reg(/^<\\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\\?>/);\n\n/*\n https://www.w3.org/TR/xml/#NT-markupdecl\n https://www.w3.org/TR/xml11/#NT-markupdecl\n `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`\n var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);\n*/\n/*\n https://www.w3.org/TR/xml-names/#NT-doctypedecl\n`[28a] DeclSep ::= PEReference | S`\n https://www.w3.org/TR/xml11/#NT-intSubset\n```\n [28b] intSubset ::= (markupdecl | DeclSep)*\n === (markupdecl | PEReference | S)*\n```\n [WFC: PE Between Declarations]\n var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');\n*/\nvar DOCTYPE_DECL_START = ''`\n https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl\n `[16] doctypedecl ::= ''`\n var doctypedecl = reg('');\n*/\n\nvar CDATA_START = '';\nvar CDStart = //;\nvar CData = reg(Char, '*?', CDEnd);\n/*\n https://www.w3.org/TR/xml/#dt-cdsection\n `[18] \tCDSect\t ::= \tCDStart CData CDEnd`\n `[19] \tCDStart\t ::= \t'' Char*))`\n `[21] \tCDEnd\t ::= \t']]>'`\n*/\nvar CDSect = reg(CDStart, CData);\n\n// unit tested\nexports.chars = chars;\nexports.chars_without = chars_without;\nexports.detectUnicodeSupport = detectUnicodeSupport;\nexports.reg = reg;\nexports.regg = regg;\nexports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;\nexports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;\nexports.AttlistDecl = AttlistDecl;\nexports.CDATA_START = CDATA_START;\nexports.CDATA_END = CDATA_END;\nexports.CDSect = CDSect;\nexports.Char = Char;\nexports.Comment = Comment;\nexports.COMMENT_START = COMMENT_START;\nexports.COMMENT_END = COMMENT_END;\nexports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;\nexports.elementdecl = elementdecl;\nexports.EntityDecl = EntityDecl;\nexports.EntityValue = EntityValue;\nexports.ExternalID = ExternalID;\nexports.ExternalID_match = ExternalID_match;\nexports.Name = Name;\nexports.NotationDecl = NotationDecl;\nexports.Reference = Reference;\nexports.PEReference = PEReference;\nexports.PI = PI;\nexports.PUBLIC = PUBLIC;\nexports.PubidLiteral = PubidLiteral;\nexports.QName = QName;\nexports.QName_exact = QName_exact;\nexports.QName_group = QName_group;\nexports.S = S;\nexports.SChar_s = SChar_s;\nexports.S_OPT = S_OPT;\nexports.SYSTEM = SYSTEM;\nexports.SystemLiteral = SystemLiteral;\nexports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;\nexports.UNICODE_SUPPORT = UNICODE_SUPPORT;\nexports.XMLDecl = XMLDecl;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar find = conventions.find;\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar hasOwn = conventions.hasOwn;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar isHTMLVoidElement = conventions.isHTMLVoidElement;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * Private DOM Constructor symbol\n *\n * Internal symbol used for construction of all classes whose constructors should be private.\n * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,\n * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`\n * so the constructor can't be used from outside the module.\n */\nvar PDC = Symbol();\n\nvar errors = require('./errors');\nvar DOMException = errors.DOMException;\nvar DOMExceptionName = errors.DOMExceptionName;\n\nvar g = require('./grammar');\n\n/**\n * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)\n * and throws an Illegal constructor exception when the symbols don't match.\n * This ensures that the constructor remains private and can't be used outside this module.\n */\nfunction checkSymbol(symbol) {\n\tif (symbol !== PDC) {\n\t\tthrow new TypeError('Illegal constructor');\n\t}\n}\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty.\n *\n * @param {string} input\n * The string to be checked.\n * @returns {boolean}\n * Returns `true` if the input string is not empty, `false` otherwise.\n */\nfunction notEmptyString(input) {\n\treturn input !== '';\n}\n/**\n * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,\n * U+0020 SPACE).\n * It follows the definition from the infra specification from WHATWG.\n *\n * @param {string} input\n * The string to be split.\n * @returns {string[]}\n * An array of the split strings. The array can be empty if the input string is empty or only\n * contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}\n * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : [];\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * The current record object to which the element will be added as a key.\n * The object's keys are string types and values are either boolean or undefined.\n * @param {string} element\n * The string to be added as a key to the current record.\n * @returns {Record}\n * The updated record object after the addition of the new element.\n */\nfunction orderedSetReducer(current, element) {\n\tif (!hasOwn(current, element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * Converts a string into an ordered set by splitting the input on ASCII whitespace and\n * ensuring uniqueness of elements.\n * This follows the definition of an ordered set from the infra specification by WHATWG.\n *\n * @param {string} input\n * The input string to be transformed into an ordered set.\n * @returns {string[]}\n * An array of unique strings obtained from the input, preserving the original order.\n * The array can be empty if the input string is empty or only contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#ordered-set}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}));\n}\n\n/**\n * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.\n * This function is used in environments where `Array.prototype.includes` may not be available.\n *\n * @param {any[]} list\n * The array in which to search for the element.\n * @returns {function(any): boolean}\n * A function that accepts an element and returns a boolean indicating whether the element is\n * included in the provided list.\n */\nfunction arrayIncludes(list) {\n\treturn function (element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t};\n}\n\n/**\n * Validates a qualified name based on the criteria provided in the DOM specification by\n * WHATWG.\n *\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @throws {DOMException}\n * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an\n * invalid character.\n * @see {@link https://dom.spec.whatwg.org/#validate}\n */\nfunction validateQualifiedName(qualifiedName) {\n\tif (!g.QName_exact.test(qualifiedName)) {\n\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name \"' + qualifiedName + '\"');\n\t}\n}\n\n/**\n * Validates a qualified name and the namespace associated with it,\n * based on the criteria provided in the DOM specification by WHATWG.\n *\n * @param {string | null} namespace\n * The namespace to be validated. It can be a string or null.\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @returns {[namespace: string | null, prefix: string | null, localName: string]}\n * Returns a tuple with the namespace,\n * prefix and local name of the qualified name.\n * @throws {DOMException}\n * Throws a DOMException if the qualified name or the namespace is not valid.\n * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}\n */\nfunction validateAndExtract(namespace, qualifiedName) {\n\tvalidateQualifiedName(qualifiedName);\n\tnamespace = namespace || null;\n\t/**\n\t * @type {string | null}\n\t */\n\tvar prefix = null;\n\tvar localName = qualifiedName;\n\tif (qualifiedName.indexOf(':') >= 0) {\n\t\tvar splitResult = qualifiedName.split(':');\n\t\tprefix = splitResult[0];\n\t\tlocalName = splitResult[1];\n\t}\n\tif (prefix !== null && namespace === null) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');\n\t}\n\tif (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is \"xml\" and namespace is not the XML namespace');\n\t}\n\tif ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'either qualifiedName or prefix is \"xmlns\" and namespace is not the XMLNS namespace'\n\t\t);\n\t}\n\tif (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'namespace is the XMLNS namespace and neither qualifiedName nor prefix is \"xmlns\"'\n\t\t);\n\t}\n\treturn [namespace, prefix, localName];\n}\n\n/**\n * Copies properties from one object to another.\n * It only copies the object's own (not inherited) properties.\n *\n * @param {Object} src\n * The source object from which properties are copied.\n * @param {Object} dest\n * The destination object to which properties are copied.\n */\nfunction copy(src, dest) {\n\tfor (var p in src) {\n\t\tif (hasOwn(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n * Extends a class with the properties and methods of a super class.\n * It uses a form of prototypal inheritance, and establishes the `constructor` property\n * correctly(?).\n *\n * It is not clear to the current maintainers if this implementation is making sense,\n * since it creates an intermediate prototype function,\n * which all properties of `Super` are copied onto using `_copy`.\n *\n * @param {Object} Class\n * The class that is to be extended.\n * @param {Object} Super\n * The super class from which properties and methods are inherited.\n * @private\n */\nfunction _extends(Class, Super) {\n\tvar pt = Class.prototype;\n\tif (!(pt instanceof Super)) {\n\t\tfunction t() {}\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt, t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif (pt.constructor != Class) {\n\t\tif (typeof Class != 'function') {\n\t\t\tconsole.error('unknown Class:' + Class);\n\t\t}\n\t\tpt.constructor = Class;\n\t}\n}\n\nvar NodeType = {};\nvar ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);\nvar ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);\nvar TEXT_NODE = (NodeType.TEXT_NODE = 3);\nvar CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);\nvar ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);\nvar ENTITY_NODE = (NodeType.ENTITY_NODE = 6);\nvar PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);\nvar COMMENT_NODE = (NodeType.COMMENT_NODE = 8);\nvar DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);\nvar DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);\nvar DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);\nvar NOTATION_NODE = (NodeType.NOTATION_NODE = 12);\n\nvar DocumentPosition = conventions.freeze({\n\tDOCUMENT_POSITION_DISCONNECTED: 1,\n\tDOCUMENT_POSITION_PRECEDING: 2,\n\tDOCUMENT_POSITION_FOLLOWING: 4,\n\tDOCUMENT_POSITION_CONTAINS: 8,\n\tDOCUMENT_POSITION_CONTAINED_BY: 16,\n\tDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,\n});\n\n//helper functions for compareDocumentPosition\n/**\n * Finds the common ancestor in two parent chains.\n *\n * @param {Node[]} a\n * The first parent chain.\n * @param {Node[]} b\n * The second parent chain.\n * @returns {Node}\n * The common ancestor node if it exists. If there is no common ancestor, the function will\n * return `null`.\n */\nfunction commonAncestor(a, b) {\n\tif (b.length < a.length) return commonAncestor(b, a);\n\tvar c = null;\n\tfor (var n in a) {\n\t\tif (a[n] !== b[n]) return c;\n\t\tc = a[n];\n\t}\n\treturn c;\n}\n\n/**\n * Assigns a unique identifier to a document to ensure consistency while comparing unrelated\n * nodes.\n *\n * @param {Document} doc\n * The document to which a unique identifier is to be assigned.\n * @returns {string}\n * The unique identifier of the document. If the document already had a unique identifier, the\n * function will return the existing one.\n */\nfunction docGUID(doc) {\n\tif (!doc.guid) doc.guid = Math.random();\n\treturn doc.guid;\n}\n//-- end of helper functions\n\n/**\n * The NodeList interface provides the abstraction of an ordered collection of nodes,\n * without defining or constraining how this collection is implemented.\n * NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n * You can also access the items of the NodeList with a `for...of` loop.\n *\n * @class NodeList\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * @constructs NodeList\n */\nfunction NodeList() {}\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1\n\t * inclusive.\n\t *\n\t * @type {number}\n\t */\n\tlength: 0,\n\t/**\n\t * Returns the item at `index`. If index is greater than or equal to the number of nodes in\n\t * the list, this returns null.\n\t *\n\t * @param index\n\t * Unsigned long Index into the collection.\n\t * @returns {Node | null}\n\t * The node at position `index` in the NodeList,\n\t * or null if that is not a valid index.\n\t */\n\titem: function (index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\t/**\n\t * Returns a string representation of the NodeList.\n\t *\n\t * @param {unknown} nodeFilter\n\t * __A filter function? Not implemented according to the spec?__.\n\t * @returns {string}\n\t * A string representation of the NodeList.\n\t */\n\ttoString: function (nodeFilter) {\n\t\tfor (var buf = [], i = 0; i < this.length; i++) {\n\t\t\tserializeToString(this[i], buf, nodeFilter);\n\t\t}\n\t\treturn buf.join('');\n\t},\n\t/**\n\t * Filters the NodeList based on a predicate.\n\t *\n\t * @param {function(Node): boolean} predicate\n\t * - A predicate function to filter the NodeList.\n\t * @returns {Node[]}\n\t * An array of nodes that satisfy the predicate.\n\t * @private\n\t */\n\tfilter: function (predicate) {\n\t\treturn Array.prototype.filter.call(this, predicate);\n\t},\n\t/**\n\t * Returns the first index at which a given node can be found in the NodeList, or -1 if it is\n\t * not present.\n\t *\n\t * @param {Node} item\n\t * - The Node item to locate in the NodeList.\n\t * @returns {number}\n\t * The first index of the node in the NodeList; -1 if not found.\n\t * @private\n\t */\n\tindexOf: function (item) {\n\t\treturn Array.prototype.indexOf.call(this, item);\n\t},\n};\nNodeList.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Represents a live collection of nodes that is automatically updated when its associated\n * document changes.\n *\n * @class LiveNodeList\n * @param {Node} node\n * The associated node.\n * @param {function} refresh\n * The function to refresh the live node list.\n * @augments NodeList\n * @constructs LiveNodeList\n */\nfunction LiveNodeList(node, refresh) {\n\tthis._node = node;\n\tthis._refresh = refresh;\n\t_updateLiveList(this);\n}\n/**\n * Updates the live node list.\n *\n * @param {LiveNodeList} list\n * The live node list to update.\n * @private\n */\nfunction _updateLiveList(list) {\n\tvar inc = list._node._inc || list._node.ownerDocument._inc;\n\tif (list._inc !== inc) {\n\t\tvar ls = list._refresh(list._node);\n\t\t__set__(list, 'length', ls.length);\n\t\tif (!list.$$length || ls.length < list.$$length) {\n\t\t\tfor (var i = ls.length; i in list; i++) {\n\t\t\t\tif (hasOwn(list, i)) {\n\t\t\t\t\tdelete list[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcopy(ls, list);\n\t\tlist._inc = inc;\n\t}\n}\n/**\n * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid\n * index.\n *\n * @param {number} i\n * Index into the collection.\n * @returns {Node | null}\n * The node at position `index` in the LiveNodeList, or null if that is not a valid index.\n */\nLiveNodeList.prototype.item = function (i) {\n\t_updateLiveList(this);\n\treturn this[i] || null;\n};\n\n_extends(LiveNodeList, NodeList);\n\n/**\n * Objects implementing the NamedNodeMap interface are used to represent collections of nodes\n * that can be accessed by name.\n * Note that NamedNodeMap does not inherit from NodeList;\n * NamedNodeMaps are not maintained in any particular order.\n * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal\n * index,\n * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,\n * and does not imply that the DOM specifies an order to these Nodes.\n * NamedNodeMap objects in the DOM are live.\n * used for attributes or DocumentType entities\n *\n * This implementation only supports property indices, but does not support named properties,\n * as specified in the living standard.\n *\n * @class NamedNodeMap\n * @see https://dom.spec.whatwg.org/#interface-namednodemap\n * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names\n * @constructs NamedNodeMap\n */\nfunction NamedNodeMap() {}\n/**\n * Returns the index of a node within the list.\n *\n * @param {Array} list\n * The list of nodes.\n * @param {Node} node\n * The node to find.\n * @returns {number}\n * The index of the node within the list, or -1 if not found.\n * @private\n */\nfunction _findNodeIndex(list, node) {\n\tvar i = 0;\n\twhile (i < list.length) {\n\t\tif (list[i] === node) {\n\t\t\treturn i;\n\t\t}\n\t\ti++;\n\t}\n}\n/**\n * Adds a new attribute to the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which will become the owner of the new attribute.\n * @param {NamedNodeMap} list\n * The list to which the new attribute will be added.\n * @param {Attr} newAttr\n * The new attribute to be added.\n * @param {Attr} oldAttr\n * The old attribute to be replaced, or null if no attribute is to be replaced.\n * @returns {void}\n * @private\n */\nfunction _addNamedNode(el, list, newAttr, oldAttr) {\n\tif (oldAttr) {\n\t\tlist[_findNodeIndex(list, oldAttr)] = newAttr;\n\t} else {\n\t\tlist[list.length] = newAttr;\n\t\tlist.length++;\n\t}\n\tif (el) {\n\t\tnewAttr.ownerElement = el;\n\t\tvar doc = el.ownerDocument;\n\t\tif (doc) {\n\t\t\toldAttr && _onRemoveAttribute(doc, el, oldAttr);\n\t\t\t_onAddAttribute(doc, el, newAttr);\n\t\t}\n\t}\n}\n/**\n * Removes an attribute from the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which is the current owner of the attribute.\n * @param {NamedNodeMap} list\n * The list from which the attribute will be removed.\n * @param {Attr} attr\n * The attribute to be removed.\n * @returns {void}\n * @private\n */\nfunction _removeNamedNode(el, list, attr) {\n\t//console.log('remove attr:'+attr)\n\tvar i = _findNodeIndex(list, attr);\n\tif (i >= 0) {\n\t\tvar lastIndex = list.length - 1;\n\t\twhile (i <= lastIndex) {\n\t\t\tlist[i] = list[++i];\n\t\t}\n\t\tlist.length = lastIndex;\n\t\tif (el) {\n\t\t\tvar doc = el.ownerDocument;\n\t\t\tif (doc) {\n\t\t\t\t_onRemoveAttribute(doc, el, attr);\n\t\t\t}\n\t\t\tattr.ownerElement = null;\n\t\t}\n\t}\n}\nNamedNodeMap.prototype = {\n\tlength: 0,\n\titem: NodeList.prototype.item,\n\n\t/**\n\t * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and\n\t * document.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given local name, or null if no such attribute exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name\n\t */\n\tgetNamedItem: function (localName) {\n\t\tif (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {\n\t\t\tlocalName = localName.toLowerCase();\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar attr = this[i];\n\t\t\tif (attr.nodeName === localName) {\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n\n\t/**\n\t * Set an attribute.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another\n\t * element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItem: function (attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif (el && el !== this._ownerElement) {\n\t\t\tthrow new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);\n\t\tif (oldAttr === attr) {\n\t\t\treturn attr;\n\t\t}\n\t\t_addNamedNode(this._ownerElement, this, attr, oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/**\n\t * Set an attribute, replacing an existing attribute with the same local name and namespace\n\t * URI if one exists.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * Throws a DOMException with the name \"InUseAttributeError\" if the attribute is already an\n\t * attribute of another element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItemNS: function (attr) {\n\t\treturn this.setNamedItem(attr);\n\t},\n\n\t/**\n\t * Removes an attribute specified by the local name.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name\n\t */\n\tremoveNamedItem: function (localName) {\n\t\tvar attr = this.getNamedItem(localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Removes an attribute specified by the namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute to be removed.\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local\n\t * name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace\n\t */\n\tremoveNamedItemNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getNamedItemNS(namespaceURI, localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Get an attribute by namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute.\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given namespace URI and local name, or null if no such attribute\n\t * exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace\n\t */\n\tgetNamedItemNS: function (namespaceURI, localName) {\n\t\tif (!namespaceURI) {\n\t\t\tnamespaceURI = null;\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar node = this[i];\n\t\t\tif (node.localName === localName && node.namespaceURI === namespaceURI) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n};\nNamedNodeMap.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * The DOMImplementation interface provides a number of methods for performing operations that\n * are independent of any particular instance of the document object model.\n *\n * The DOMImplementation interface represents an object providing methods which are not\n * dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * **The individual methods describe the differences compared to the specs**.\n *\n * @class DOMImplementation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core\n * (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n * @constructs DOMImplementation\n */\nfunction DOMImplementation() {}\n\nDOMImplementation.prototype = {\n\t/**\n\t * Test if the DOM implementation implements a specific feature and version, as specified in\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.\n\t *\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given\n\t * feature is supported. The different implementations fairly diverged in what kind of\n\t * features were reported. The latest version of the spec settled to force this method to\n\t * always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated\n\t * It is deprecated and modern browsers return true in all cases.\n\t * @function DOMImplementation#hasFeature\n\t * @param {string} feature\n\t * The name of the feature to test.\n\t * @param {string} [version]\n\t * This is the version number of the feature to test.\n\t * @returns {boolean}\n\t * Always returns true.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core\n\t */\n\thasFeature: function (feature, version) {\n\t\treturn true;\n\t},\n\t/**\n\t * Creates a DOM Document object of the specified type with its document element. Note that\n\t * based on the {@link DocumentType}\n\t * given to create the document, the implementation may instantiate specialized\n\t * {@link Document} objects that support additional features than the \"Core\", such as \"HTML\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.\n\t * On the other hand, setting the {@link DocumentType} after the document was created makes\n\t * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,\n\t * such as createHTMLDocument\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},\n\t * can be used to obtain specific types of {@link Document} objects.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document`\n\t * instance (with it's `type` set to `'xml'`).\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @function DOMImplementation.createDocument\n\t * @param {string | null} namespaceURI\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}\n\t * of the document element to create or null.\n\t * @param {string | null} qualifiedName\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}\n\t * of the document element to be created or null.\n\t * @param {DocumentType | null} [doctype=null]\n\t * The type of document to be created or null. When doctype is not null, its\n\t * {@link Node#ownerDocument} attribute is set to the document being created. Default is\n\t * `null`\n\t * @returns {Document}\n\t * A new {@link Document} object with its document element. If the NamespaceURI,\n\t * qualifiedName, and doctype are null, the returned {@link Document} is empty with no\n\t * document element.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a\n\t * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI\n\t * is different from null, or if the qualifiedName has a prefix that is \"xml\" and the\n\t * namespaceURI is different from \"{@link http://www.w3.org/XML/1998/namespace}\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},\n\t * or if the DOM implementation does not support the \"XML\" feature but a non-null namespace\n\t * URI was provided, since namespaces were defined by XML.\n\t * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document\n\t * or was created from a different implementation.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see {@link #createHTMLDocument}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 2 Core (initial)\n\t */\n\tcreateDocument: function (namespaceURI, qualifiedName, doctype) {\n\t\tvar contentType = MIME_TYPE.XML_APPLICATION;\n\t\tif (namespaceURI === NAMESPACE.HTML) {\n\t\t\tcontentType = MIME_TYPE.XML_XHTML_APPLICATION;\n\t\t} else if (namespaceURI === NAMESPACE.SVG) {\n\t\t\tcontentType = MIME_TYPE.XML_SVG_IMAGE;\n\t\t}\n\t\tvar doc = new Document(PDC, { contentType: contentType });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype) {\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName) {\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Creates an empty DocumentType node. Entity declarations and notations are not made\n\t * available. Entity reference expansions and default attribute additions do not occur.\n\t *\n\t * **This behavior is slightly different from the one in the specs**:\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - `publicId` and `systemId` contain the raw data including any possible quotes,\n\t * so they can always be serialized back to the original value\n\t * - `internalSubset` contains the raw string between `[` and `]` if present,\n\t * but is not parsed or validated in any form.\n\t *\n\t * @function DOMImplementation#createDocumentType\n\t * @param {string} qualifiedName\n\t * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified\n\t * name} of the document type to be created.\n\t * @param {string} [publicId]\n\t * The external subset public identifier.\n\t * @param {string} [systemId]\n\t * The external subset system identifier.\n\t * @param {string} [internalSubset]\n\t * the internal subset or an empty string if it is not present\n\t * @returns {DocumentType}\n\t * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType\n\t * MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living\n\t * Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM\n\t * Level 2 Core\n\t * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset\n\t * @prettierignore\n\t */\n\tcreateDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {\n\t\tvalidateQualifiedName(qualifiedName);\n\t\tvar node = new DocumentType(PDC);\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\t\tnode.internalSubset = internalSubset || '';\n\t\tnode.childNodes = new NodeList();\n\n\t\treturn node;\n\t},\n\t/**\n\t * Returns an HTML document, that might already have a basic DOM structure.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are\n\t * omitted)\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @param {string | false} [title]\n\t * A string containing the title to give the new HTML document.\n\t * @returns {Document}\n\t * The HTML document.\n\t * @since WHATWG Living Standard.\n\t * @see {@link #createDocument}\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n\t * @see https://dom.spec.whatwg.org/#html-document\n\t */\n\tcreateHTMLDocument: function (title) {\n\t\tvar doc = new Document(PDC, { contentType: MIME_TYPE.HTML });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tif (title !== false) {\n\t\t\tdoc.doctype = this.createDocumentType('html');\n\t\t\tdoc.doctype.ownerDocument = doc;\n\t\t\tdoc.appendChild(doc.doctype);\n\t\t\tvar htmlNode = doc.createElement('html');\n\t\t\tdoc.appendChild(htmlNode);\n\t\t\tvar headNode = doc.createElement('head');\n\t\t\thtmlNode.appendChild(headNode);\n\t\t\tif (typeof title === 'string') {\n\t\t\t\tvar titleNode = doc.createElement('title');\n\t\t\t\ttitleNode.appendChild(doc.createTextNode(title));\n\t\t\t\theadNode.appendChild(titleNode);\n\t\t\t}\n\t\t\thtmlNode.appendChild(doc.createElement('body'));\n\t\t}\n\t\treturn doc;\n\t},\n};\n\n/**\n * The DOM Node interface is an abstract base class upon which many other DOM API objects are\n * based, thus letting those object types to be used similarly and often interchangeably. As an\n * abstract class, there is no such thing as a plain Node object. All objects that implement\n * Node functionality are based on one of its subclasses. Most notable are Document, Element,\n * and DocumentFragment.\n *\n * In addition, every kind of DOM node is represented by an interface based on Node. These\n * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are\n * all based on), and DocumentType.\n *\n * In some cases, a particular feature of the base Node interface may not apply to one of its\n * child interfaces; in that case, the inheriting node may return null or throw an exception,\n * depending on circumstances. For example, attempting to add children to a node type that\n * cannot have children will throw an exception.\n *\n * **This behavior is slightly different from the in the specs**:\n * - unimplemented interfaces: `EventTarget`\n *\n * @class\n * @abstract\n * @param {Symbol} symbol\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n * @see https://dom.spec.whatwg.org/#node\n * @prettierignore\n */\nfunction Node(symbol) {\n\tcheckSymbol(symbol);\n}\n\nNode.prototype = {\n\t/**\n\t * The first child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tfirstChild: null,\n\t/**\n\t * The last child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tlastChild: null,\n\t/**\n\t * The previous sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tpreviousSibling: null,\n\t/**\n\t * The next sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tnextSibling: null,\n\t/**\n\t * The parent node of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tparentNode: null,\n\t/**\n\t * The parent element of this node.\n\t *\n\t * @type {Element | null}\n\t */\n\tget parentElement() {\n\t\treturn this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;\n\t},\n\t/**\n\t * The child nodes of this node.\n\t *\n\t * @type {NodeList}\n\t */\n\tchildNodes: null,\n\t/**\n\t * The document object associated with this node.\n\t *\n\t * @type {Document | null}\n\t */\n\townerDocument: null,\n\t/**\n\t * The value of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnodeValue: null,\n\t/**\n\t * The namespace URI of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnamespaceURI: null,\n\t/**\n\t * The prefix of the namespace for this node.\n\t *\n\t * @type {string | null}\n\t */\n\tprefix: null,\n\t/**\n\t * The local part of the qualified name of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tlocalName: null,\n\t/**\n\t * The baseURI is currently always `about:blank`,\n\t * since that's what happens when you create a document from scratch.\n\t *\n\t * @type {'about:blank'}\n\t */\n\tbaseURI: 'about:blank',\n\t/**\n\t * Is true if this node is part of a document.\n\t *\n\t * @type {boolean}\n\t */\n\tget isConnected() {\n\t\tvar rootNode = this.getRootNode();\n\t\treturn rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;\n\t},\n\t/**\n\t * Checks whether `other` is an inclusive descendant of this node.\n\t *\n\t * @param {Node | null | undefined} other\n\t * The node to check.\n\t * @returns {boolean}\n\t * True if `other` is an inclusive descendant of this node; false otherwise.\n\t * @see https://dom.spec.whatwg.org/#dom-node-contains\n\t */\n\tcontains: function (other) {\n\t\tif (!other) return false;\n\t\tvar parent = other;\n\t\tdo {\n\t\t\tif (this === parent) return true;\n\t\t\tparent = other.parentNode;\n\t\t} while (parent);\n\t\treturn false;\n\t},\n\t/**\n\t * @typedef GetRootNodeOptions\n\t * @property {boolean} [composed=false]\n\t */\n\t/**\n\t * Searches for the root node of this node.\n\t *\n\t * **This behavior is slightly different from the in the specs**:\n\t * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.\n\t *\n\t * @param {GetRootNodeOptions} [options]\n\t * @returns {Node}\n\t * Root node.\n\t * @see https://dom.spec.whatwg.org/#dom-node-getrootnode\n\t * @see https://dom.spec.whatwg.org/#concept-shadow-including-root\n\t */\n\tgetRootNode: function (options) {\n\t\tvar parent = this;\n\t\tdo {\n\t\t\tif (!parent.parentNode) {\n\t\t\t\treturn parent;\n\t\t\t}\n\t\t\tparent = parent.parentNode;\n\t\t} while (parent);\n\t},\n\t/**\n\t * Checks whether the given node is equal to this node.\n\t *\n\t * @param {Node} [otherNode]\n\t * @see https://dom.spec.whatwg.org/#concept-node-equals\n\t */\n\tisEqualNode: function (otherNode) {\n\t\tif (!otherNode) return false;\n\n\t\tif (this.nodeType !== otherNode.nodeType) return false;\n\n\t\tswitch (this.nodeType) {\n\t\t\tcase this.DOCUMENT_TYPE_NODE:\n\t\t\t\tif (this.name !== otherNode.name) return false;\n\t\t\t\tif (this.publicId !== otherNode.publicId) return false;\n\t\t\t\tif (this.systemId !== otherNode.systemId) return false;\n\t\t\t\tbreak;\n\t\t\tcase this.ELEMENT_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.prefix !== otherNode.prefix) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.attributes.length !== otherNode.attributes.length) return false;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attr = this.attributes.item(i);\n\t\t\t\t\tif (!attr.isEqualNode(otherNode.getAttributeNodeNS(attr.namespaceURI, attr.localName))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.ATTRIBUTE_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.value !== otherNode.value) return false;\n\n\t\t\t\tbreak;\n\t\t\tcase this.PROCESSING_INSTRUCTION_NODE:\n\t\t\t\tif (this.target !== otherNode.target || this.data !== otherNode.data) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.TEXT_NODE:\n\t\t\tcase this.COMMENT_NODE:\n\t\t\t\tif (this.data !== otherNode.data) return false;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (this.childNodes.length !== otherNode.childNodes.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < this.childNodes.length; i++) {\n\t\t\tif (!this.childNodes[i].isEqualNode(otherNode.childNodes[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n\t/**\n\t * Checks whether or not the given node is this node.\n\t *\n\t * @param {Node} [otherNode]\n\t */\n\tisSameNode: function (otherNode) {\n\t\treturn this === otherNode;\n\t},\n\t/**\n\t * Inserts a node before a reference node as a child of this node.\n\t *\n\t * @param {Node} newChild\n\t * The new child node to be inserted.\n\t * @param {Node | null} refChild\n\t * The reference node before which newChild will be inserted.\n\t * @returns {Node}\n\t * The new child node successfully inserted.\n\t * @throws {DOMException}\n\t * Throws a DOMException if inserting the node would result in a DOM tree that is not\n\t * well-formed, or if `child` is provided but is not a child of `parent`.\n\t * See {@link _insertBefore} for more details.\n\t * @since Modified in DOM L2\n\t */\n\tinsertBefore: function (newChild, refChild) {\n\t\treturn _insertBefore(this, newChild, refChild);\n\t},\n\t/**\n\t * Replaces an old child node with a new child node within this node.\n\t *\n\t * @param {Node} newChild\n\t * The new node that is to replace the old node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @param {Node} oldChild\n\t * The existing child node to be replaced.\n\t * @returns {Node}\n\t * Returns the replaced child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if replacing the node would result in a DOM tree that is not\n\t * well-formed, or if `oldChild` is not a child of `this`.\n\t * This can also occur if the pre-replacement validity assertion fails.\n\t * See {@link _insertBefore}, {@link Node.removeChild}, and\n\t * {@link assertPreReplacementValidityInDocument} for more details.\n\t * @see https://dom.spec.whatwg.org/#concept-node-replace\n\t */\n\treplaceChild: function (newChild, oldChild) {\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\t/**\n\t * Removes an existing child node from this node.\n\t *\n\t * @param {Node} oldChild\n\t * The child node to be removed.\n\t * @returns {Node}\n\t * Returns the removed child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if `oldChild` is not a child of `this`.\n\t * See {@link _removeChild} for more details.\n\t */\n\tremoveChild: function (oldChild) {\n\t\treturn _removeChild(this, oldChild);\n\t},\n\t/**\n\t * Appends a child node to this node.\n\t *\n\t * @param {Node} newChild\n\t * The child node to be appended to this node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @returns {Node}\n\t * Returns the appended child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if appending the node would result in a DOM tree that is not\n\t * well-formed, or if `newChild` is not a valid Node.\n\t * See {@link insertBefore} for more details.\n\t */\n\tappendChild: function (newChild) {\n\t\treturn this.insertBefore(newChild, null);\n\t},\n\t/**\n\t * Determines whether this node has any child nodes.\n\t *\n\t * @returns {boolean}\n\t * Returns true if this node has any child nodes, and false otherwise.\n\t */\n\thasChildNodes: function () {\n\t\treturn this.firstChild != null;\n\t},\n\t/**\n\t * Creates a copy of the calling node.\n\t *\n\t * @param {boolean} deep\n\t * If true, the contents of the node are recursively copied.\n\t * If false, only the node itself (and its attributes, if it is an element) are copied.\n\t * @returns {Node}\n\t * Returns the newly created copy of the node.\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within {@link Element#setAttributeNode} or\n\t * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their\n\t * specific constraints.\n\t * @see {@link cloneNode}\n\t */\n\tcloneNode: function (deep) {\n\t\treturn cloneNode(this.ownerDocument || this, this, deep);\n\t},\n\t/**\n\t * Puts the specified node and all of its subtree into a \"normalized\" form. In a normalized\n\t * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.\n\t *\n\t * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`\n\t * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text\n\t * nodes.\n\t *\n\t * This method operates recursively, so it also normalizes any and all descendent nodes within\n\t * the subtree.\n\t *\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within removeChild or appendData (which are\n\t * potentially invoked in this method) do not meet their specific constraints.\n\t * @since Modified in DOM Level 2\n\t * @see {@link Node.removeChild}\n\t * @see {@link CharacterData.appendData}\n\t */\n\tnormalize: function () {\n\t\tvar child = this.firstChild;\n\t\twhile (child) {\n\t\t\tvar next = child.nextSibling;\n\t\t\tif (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t} else {\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n\t/**\n\t * Checks whether the DOM implementation implements a specific feature and its version.\n\t *\n\t * @deprecated\n\t * Since `DOMImplementation.hasFeature` is deprecated and always returns true.\n\t * @param {string} feature\n\t * The package name of the feature to test. This is the same name that can be passed to the\n\t * method `hasFeature` on `DOMImplementation`.\n\t * @param {string} version\n\t * This is the version number of the package name to test.\n\t * @returns {boolean}\n\t * Returns true in all cases in the current implementation.\n\t * @since Introduced in DOM Level 2\n\t * @see {@link DOMImplementation.hasFeature}\n\t */\n\tisSupported: function (feature, version) {\n\t\treturn this.ownerDocument.implementation.hasFeature(feature, version);\n\t},\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI for which to find the associated prefix.\n\t * @returns {string | null}\n\t * The associated prefix, if found; otherwise, null.\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t * @prettierignore\n\t */\n\tlookupPrefix: function (namespaceURI) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tfor (var n in map) {\n\t\t\t\t\tif (hasOwn(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * This function is used to look up the namespace URI associated with the given prefix,\n\t * starting from this node.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} prefix\n\t * The prefix for which to find the associated namespace URI.\n\t * @returns {string | null}\n\t * The associated namespace URI, if found; otherwise, null.\n\t * @since DOM Level 3\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI\n\t * @prettierignore\n\t */\n\tlookupNamespaceURI: function (prefix) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tif (hasOwn(map, prefix)) {\n\t\t\t\t\treturn map[prefix];\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * Determines whether the given namespace URI is the default namespace.\n\t *\n\t * The function works by looking up the prefix associated with the given namespace URI. If no\n\t * prefix is found (i.e., the namespace URI is not registered in the namespace map of this\n\t * node or any of its ancestors), it returns `true`, implying the namespace URI is considered\n\t * the default.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI to be checked.\n\t * @returns {boolean}\n\t * Returns true if the given namespace URI is the default namespace, false otherwise.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace\n\t * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace\n\t * @prettierignore\n\t */\n\tisDefaultNamespace: function (namespaceURI) {\n\t\tvar prefix = this.lookupPrefix(namespaceURI);\n\t\treturn prefix == null;\n\t},\n\t/**\n\t * Compares the reference node with a node with regard to their position in the document and\n\t * according to the document order.\n\t *\n\t * @param {Node} other\n\t * The node to compare the reference node to.\n\t * @returns {number}\n\t * Returns how the node is positioned relatively to the reference node according to the\n\t * bitmask. 0 if reference node and given node are the same.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare\n\t * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition\n\t */\n\tcompareDocumentPosition: function (other) {\n\t\tif (this === other) return 0;\n\t\tvar node1 = other;\n\t\tvar node2 = this;\n\t\tvar attr1 = null;\n\t\tvar attr2 = null;\n\t\tif (node1 instanceof Attr) {\n\t\t\tattr1 = node1;\n\t\t\tnode1 = attr1.ownerElement;\n\t\t}\n\t\tif (node2 instanceof Attr) {\n\t\t\tattr2 = node2;\n\t\t\tnode2 = attr2.ownerElement;\n\t\t\tif (attr1 && node1 && node2 === node1) {\n\t\t\t\tfor (var i = 0, attr; (attr = node2.attributes[i]); i++) {\n\t\t\t\t\tif (attr === attr1)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t\t\tif (attr === attr2)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {\n\t\t\treturn (\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_DISCONNECTED +\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +\n\t\t\t\t(docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)\n\t\t\t\t\t? DocumentPosition.DOCUMENT_POSITION_FOLLOWING\n\t\t\t\t\t: DocumentPosition.DOCUMENT_POSITION_PRECEDING)\n\t\t\t);\n\t\t}\n\t\tif (attr2 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\tif (attr1 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t}\n\n\t\tvar chain1 = [];\n\t\tvar ancestor1 = node1.parentNode;\n\t\twhile (ancestor1) {\n\t\t\tif (!attr2 && ancestor1 === node2) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t}\n\t\t\tchain1.push(ancestor1);\n\t\t\tancestor1 = ancestor1.parentNode;\n\t\t}\n\t\tchain1.reverse();\n\n\t\tvar chain2 = [];\n\t\tvar ancestor2 = node2.parentNode;\n\t\twhile (ancestor2) {\n\t\t\tif (!attr1 && ancestor2 === node1) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t}\n\t\t\tchain2.push(ancestor2);\n\t\t\tancestor2 = ancestor2.parentNode;\n\t\t}\n\t\tchain2.reverse();\n\n\t\tvar ca = commonAncestor(chain1, chain2);\n\t\tfor (var n in ca.childNodes) {\n\t\t\tvar child = ca.childNodes[n];\n\t\t\tif (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\tif (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\treturn 0;\n\t},\n};\n\n/**\n * Encodes special XML characters to their corresponding entities.\n *\n * @param {string} c\n * The character to be encoded.\n * @returns {string}\n * The encoded character.\n * @private\n */\nfunction _xmlEncoder(c) {\n\treturn (\n\t\t(c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '\"' && '"') || '&#' + c.charCodeAt() + ';'\n\t);\n}\n\ncopy(NodeType, Node);\ncopy(NodeType, Node.prototype);\ncopy(DocumentPosition, Node);\ncopy(DocumentPosition, Node.prototype);\n\n/**\n * @param callback\n * Return true for continue,false for break.\n * @returns\n * boolean true: break visit;\n */\nfunction _visitNode(node, callback) {\n\tif (callback(node)) {\n\t\treturn true;\n\t}\n\tif ((node = node.firstChild)) {\n\t\tdo {\n\t\t\tif (_visitNode(node, callback)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} while ((node = node.nextSibling));\n\t}\n}\n\n/**\n * @typedef DocumentOptions\n * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]\n */\n/**\n * The Document interface describes the common properties and methods for any kind of document.\n *\n * It should usually be created using `new DOMImplementation().createDocument(...)`\n * or `new DOMImplementation().createHTMLDocument(...)`.\n *\n * The constructor is considered a private API and offers to initially set the `contentType`\n * property via it's options parameter.\n *\n * @class\n * @param {Symbol} symbol\n * @param {DocumentOptions} [options]\n * @augments Node\n * @private\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document\n * @see https://dom.spec.whatwg.org/#interface-document\n */\nfunction Document(symbol, options) {\n\tcheckSymbol(symbol);\n\n\tvar opt = options || {};\n\tthis.ownerDocument = this;\n\t/**\n\t * The mime type of the document is determined at creation time and can not be modified.\n\t *\n\t * @type {string}\n\t * @see https://dom.spec.whatwg.org/#concept-document-content-type\n\t * @see {@link DOMImplementation}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;\n\t/**\n\t * @type {'html' | 'xml'}\n\t * @see https://dom.spec.whatwg.org/#concept-document-type\n\t * @see {@link DOMImplementation}\n\t * @readonly\n\t */\n\tthis.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';\n}\n\n/**\n * Updates the namespace mapping of an element when a new attribute is added.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element to which the attribute is being added.\n * @param {Attr} newAttr\n * The new attribute being added.\n * @private\n */\nfunction _onAddAttribute(doc, el, newAttr) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;\n\t}\n}\n\n/**\n * Updates the namespace mapping of an element when an attribute is removed.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element from which the attribute is being removed.\n * @param {Attr} newAttr\n * The attribute being removed.\n * @param {boolean} remove\n * Indicates whether the attribute is to be removed.\n * @private\n */\nfunction _onRemoveAttribute(doc, el, newAttr, remove) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix ? newAttr.localName : ''];\n\t}\n}\n\n/**\n * Updates `parent.childNodes`, adjusting the indexed items and its `length`.\n * If `newChild` is provided and has no nextSibling, it will be appended.\n * Otherwise, it's assumed that an item has been removed or inserted,\n * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.\n *\n * @param {Document} doc\n * The parent document of `el`.\n * @param {Node} parent\n * The parent node whose childNodes list needs to be updated.\n * @param {Node} [newChild]\n * The new child node to be appended. If not provided, the function assumes a node has been\n * removed.\n * @private\n */\nfunction _onUpdateChild(doc, parent, newChild) {\n\tif (doc && doc._inc) {\n\t\tdoc._inc++;\n\t\tvar childNodes = parent.childNodes;\n\t\t// assumes nextSibling and previousSibling were already configured upfront\n\t\tif (newChild && !newChild.nextSibling) {\n\t\t\t// if an item has been appended, we only need to update the last index and the length\n\t\t\tchildNodes[childNodes.length++] = newChild;\n\t\t} else {\n\t\t\t// otherwise we need to reindex all items,\n\t\t\t// which can take a while when processing nodes with a lot of children\n\t\t\tvar child = parent.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile (child) {\n\t\t\t\tchildNodes[i++] = child;\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\tchildNodes.length = i;\n\t\t\tdelete childNodes[childNodes.length];\n\t\t}\n\t}\n}\n\n/**\n * Removes the connections between `parentNode` and `child`\n * and any existing `child.previousSibling` or `child.nextSibling`.\n *\n * @param {Node} parentNode\n * The parent node from which the child node is to be removed.\n * @param {Node} child\n * The child node to be removed from the parentNode.\n * @returns {Node}\n * Returns the child node that was removed.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.\n * @private\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n */\nfunction _removeChild(parentNode, child) {\n\tif (parentNode !== child.parentNode) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, \"child's parent is not parent\");\n\t}\n\tvar oldPreviousSibling = child.previousSibling;\n\tvar oldNextSibling = child.nextSibling;\n\tif (oldPreviousSibling) {\n\t\toldPreviousSibling.nextSibling = oldNextSibling;\n\t} else {\n\t\tparentNode.firstChild = oldNextSibling;\n\t}\n\tif (oldNextSibling) {\n\t\toldNextSibling.previousSibling = oldPreviousSibling;\n\t} else {\n\t\tparentNode.lastChild = oldPreviousSibling;\n\t}\n\t_onUpdateChild(parentNode.ownerDocument, parentNode);\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.CDATA_SECTION_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_TYPE_NODE ||\n\t\t\tnode.nodeType === Node.ELEMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||\n\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Asserts pre-insertion validity of a node into a parent before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Node} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | null} child\n * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,\n * DocumentFragment, or Element node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive\n * ancestor of `parent`. (Currently not implemented)\n * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not\n * `parent`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,\n * DocumentType, Element, or CharacterData node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is\n * a document, or if `node` is a doctype and `parent` is not a document.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.HIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * Asserts pre-insertion validity of a node into a document before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * The node that should become the `nextSibling` of `node`. If undefined, no sibling is\n * considered.\n * @returns {Node}\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than\n * one element child or has a Text node child.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one\n * element child and either `parent` has an element child, `child` is a doctype, or `child` is\n * non-null and a doctype is following `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an\n * element child, `child` is a doctype, or `child` is non-null and a doctype is following\n * `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a\n * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null\n * and `parent` has an element child.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws {DOMException}\n * For several node combinations that would create a DOM that is not well-formed.\n * @throws {DOMException}\n * If `child` is provided but is not a child of `parent`.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * Inserts a node into a parent node before a child node.\n *\n * @param {Node} parent\n * The parent node to insert the node into.\n * @param {Node} node\n * The node to insert into the parent.\n * @param {Node | null} child\n * The node that should become the next sibling of the node.\n * If null, the function inserts the node at the end of the children of the parent node.\n * @param {Function} [_inDocumentAssertion]\n * An optional function to check pre-insertion validity if parent is a document node.\n * Defaults to {@link assertPreInsertionValidityInDocument}\n * @returns {Node}\n * Returns the inserted node.\n * @throws {DOMException}\n * Throws a DOMException if inserting the node would result in a DOM tree that is not\n * well-formed. See {@link assertPreInsertionValidity1to5},\n * {@link assertPreInsertionValidityInDocument}.\n * @throws {DOMException}\n * Throws a DOMException if child is provided but is not a child of the parent. See\n * {@link Node.removeChild}\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif (cp) {\n\t\tcp.removeChild(node); //remove and update\n\t}\n\tif (node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t} else {\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\tif (pre) {\n\t\tpre.nextSibling = newFirst;\n\t} else {\n\t\tparent.firstChild = newFirst;\n\t}\n\tif (child == null) {\n\t\tparent.lastChild = newLast;\n\t} else {\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo {\n\t\tnewFirst.parentNode = parent;\n\t} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));\n\t_onUpdateChild(parent.ownerDocument || parent, parent, node);\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\n\treturn node;\n}\n\nDocument.prototype = {\n\t/**\n\t * The implementation that created this document.\n\t *\n\t * @type DOMImplementation\n\t * @readonly\n\t */\n\timplementation: null,\n\tnodeName: '#document',\n\tnodeType: DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @type DocumentType\n\t * @readonly\n\t */\n\tdoctype: null,\n\tdocumentElement: null,\n\t_inc: 1,\n\n\tinsertBefore: function (newChild, refChild) {\n\t\t//raises\n\t\tif (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child, refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild: function (oldChild) {\n\t\tvar removed = _removeChild(this, oldChild);\n\t\tif (removed === this.documentElement) {\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn removed;\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode: function (importedNode, deep) {\n\t\treturn importNode(this, importedNode, deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById: function (id) {\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement, function (node) {\n\t\t\tif (node.nodeType == ELEMENT_NODE) {\n\t\t\t\tif (node.getAttribute('id') == id) {\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * Creates a new `Element` that is owned by this `Document`.\n\t * In HTML Documents `localName` is the lower cased `tagName`,\n\t * otherwise no transformation is being applied.\n\t * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t * - There is no interface `HTMLElement`, it is always an `Element`.\n\t * - There is no support for a second argument to indicate using custom elements.\n\t *\n\t * @param {string} tagName\n\t * @returns {Element}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement\n\t * @see https://dom.spec.whatwg.org/#dom-document-createelement\n\t * @see https://dom.spec.whatwg.org/#concept-create-element\n\t */\n\tcreateElement: function (tagName) {\n\t\tvar node = new Element(PDC);\n\t\tnode.ownerDocument = this;\n\t\tif (this.type === 'html') {\n\t\t\ttagName = tagName.toLowerCase();\n\t\t}\n\t\tif (hasDefaultHTMLNamespace(this.contentType)) {\n\t\t\tnode.namespaceURI = NAMESPACE.HTML;\n\t\t}\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t/**\n\t * @returns {DocumentFragment}\n\t */\n\tcreateDocumentFragment: function () {\n\t\tvar node = new DocumentFragment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Text}\n\t */\n\tcreateTextNode: function (data) {\n\t\tvar node = new Text(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Comment}\n\t */\n\tcreateComment: function (data) {\n\t\tvar node = new Comment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {CDATASection}\n\t */\n\tcreateCDATASection: function (data) {\n\t\tvar node = new CDATASection(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} target\n\t * @param {string} data\n\t * @returns {ProcessingInstruction}\n\t */\n\tcreateProcessingInstruction: function (target, data) {\n\t\tvar node = new ProcessingInstruction(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an `Attr` node that is owned by this document.\n\t * In HTML Documents `localName` is the lower cased `name`,\n\t * otherwise no transformation is being applied.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t *\n\t * @param {string} name\n\t * @returns {Attr}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute\n\t * @see https://dom.spec.whatwg.org/#dom-document-createattribute\n\t */\n\tcreateAttribute: function (name) {\n\t\tif (!g.QName_exact.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this._createAttribute(name);\n\t},\n\t_createAttribute: function (name) {\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.name = name;\n\t\tnode.nodeName = name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an EntityReference object.\n\t * The current implementation does not fill the `childNodes` with those of the corresponding\n\t * `Entity`\n\t *\n\t * @deprecated\n\t * In DOM Level 4.\n\t * @param {string} name\n\t * The name of the entity to reference. No namespace well-formedness checks are performed.\n\t * @returns {EntityReference}\n\t * @throws {DOMException}\n\t * With code `INVALID_CHARACTER_ERR` when `name` is not valid.\n\t * @throws {DOMException}\n\t * with code `NOT_SUPPORTED_ERR` when the document is of type `html`\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE\n\t */\n\tcreateEntityReference: function (name) {\n\t\tif (!g.Name.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tthrow new DOMException('document is an html document', DOMExceptionName.NotSupportedError);\n\t\t}\n\n\t\tvar node = new EntityReference(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Element}\n\t */\n\tcreateElementNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Element(PDC);\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Attr}\n\t */\n\tcreateAttributeNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.specified = true;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\treturn node;\n\t},\n};\n_extends(Document, Node);\n\nfunction Element(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis._nsMap = Object.create(null);\n}\nElement.prototype = {\n\tnodeType: ELEMENT_NODE,\n\t/**\n\t * The attributes of this element.\n\t *\n\t * @type {NamedNodeMap | null}\n\t */\n\tattributes: null,\n\tgetQualifiedName: function () {\n\t\treturn this.prefix ? this.prefix + ':' + this.localName : this.localName;\n\t},\n\t_isInHTMLDocumentAndNamespace: function () {\n\t\treturn this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;\n\t},\n\t/**\n\t * Implementaton of Level2 Core function hasAttributes.\n\t *\n\t * @returns {boolean}\n\t * True if attribute list is not empty.\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs\n\t */\n\thasAttributes: function () {\n\t\treturn !!(this.attributes && this.attributes.length);\n\t},\n\thasAttribute: function (name) {\n\t\treturn !!this.getAttributeNode(name);\n\t},\n\t/**\n\t * Returns element’s first attribute whose qualified name is `name`, and `null`\n\t * if there is no such attribute.\n\t *\n\t * @param {string} name\n\t * @returns {string | null}\n\t */\n\tgetAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr ? attr.value : null;\n\t},\n\tgetAttributeNode: function (name) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\t/**\n\t * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.\n\t *\n\t * @param {string} name\n\t * @param {string} value\n\t */\n\tsetAttribute: function (name, value) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\tvar attr = this.getAttributeNode(name);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument._createAttribute(name);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tremoveAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\tsetAttributeNode: function (newAttr) {\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS: function (newAttr) {\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode: function (oldAttr) {\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS: function (namespaceURI, localName) {\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS: function (namespaceURI, localName) {\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName) != null;\n\t},\n\t/**\n\t * Returns element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName`,\n\t * or `null` if there is no such attribute.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} localName\n\t * @returns {string | null}\n\t */\n\tgetAttributeNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr ? attr.value : null;\n\t},\n\t/**\n\t * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName` to value.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {string} value\n\t * @see https://dom.spec.whatwg.org/#dom-element-setattributens\n\t */\n\tsetAttributeNS: function (namespaceURI, qualifiedName, value) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar localName = validated[2];\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tgetAttributeNodeNS: function (namespaceURI, localName) {\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classNames` is an empty string or only contains HTML white space\n\t * characters.\n\t *\n\t * Warning: This returns a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames\n\t * Is a string representing the class name(s) to match; multiple class names are separated by\n\t * (ASCII-)whitespace.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function (classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames);\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base, function (node) {\n\t\t\t\t\tif (node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class');\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames);\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of elements with the given qualifiedName.\n\t * Searching for all descendants can be done by passing `*` as `qualifiedName`.\n\t *\n\t * All descendants of the specified element are searched, but not the element itself.\n\t * The returned list is live, which means it updates itself with the DOM tree automatically.\n\t * Therefore, there is no need to call `Element.getElementsByTagName()`\n\t * with the same element and arguments repeatedly if the DOM changes in between calls.\n\t *\n\t * When called on an HTML element in an HTML document,\n\t * `getElementsByTagName` lower-cases the argument before searching for it.\n\t * This is undesirable when trying to match camel-cased SVG elements (such as\n\t * ``) in an HTML document.\n\t * Instead, use `Element.getElementsByTagNameNS()`,\n\t * which preserves the capitalization of the tag name.\n\t *\n\t * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,\n\t * except that it only searches for elements that are descendants of the specified element.\n\t *\n\t * @param {string} qualifiedName\n\t * @returns {LiveNodeList}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname\n\t */\n\tgetElementsByTagName: function (qualifiedName) {\n\t\tvar isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';\n\t\tvar lowerQualifiedName = qualifiedName.toLowerCase();\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (node === base || node.nodeType !== ELEMENT_NODE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (qualifiedName === '*') {\n\t\t\t\t\tls.push(node);\n\t\t\t\t} else {\n\t\t\t\t\tvar nodeQualifiedName = node.getQualifiedName();\n\t\t\t\t\tvar matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;\n\t\t\t\t\tif (nodeQualifiedName === matchingQName) {\n\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS: function (namespaceURI, localName) {\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== base &&\n\t\t\t\t\tnode.nodeType === ELEMENT_NODE &&\n\t\t\t\t\t(namespaceURI === '*' || node.namespaceURI === namespaceURI) &&\n\t\t\t\t\t(localName === '*' || node.localName == localName)\n\t\t\t\t) {\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n};\nDocument.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n_extends(Element, Node);\nfunction Attr(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis.namespaceURI = null;\n\tthis.prefix = null;\n\tthis.ownerElement = null;\n}\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr, Node);\n\nfunction CharacterData(symbol) {\n\tcheckSymbol(symbol);\n}\nCharacterData.prototype = {\n\tdata: '',\n\tsubstringData: function (offset, count) {\n\t\treturn this.data.substring(offset, offset + count);\n\t},\n\tappendData: function (text) {\n\t\ttext = this.data + text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function (offset, text) {\n\t\tthis.replaceData(offset, 0, text);\n\t},\n\tdeleteData: function (offset, count) {\n\t\tthis.replaceData(offset, count, '');\n\t},\n\treplaceData: function (offset, count, text) {\n\t\tvar start = this.data.substring(0, offset);\n\t\tvar end = this.data.substring(offset + count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n};\n_extends(CharacterData, Node);\nfunction Text(symbol) {\n\tcheckSymbol(symbol);\n}\nText.prototype = {\n\tnodeName: '#text',\n\tnodeType: TEXT_NODE,\n\tsplitText: function (offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif (this.parentNode) {\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t},\n};\n_extends(Text, CharacterData);\nfunction Comment(symbol) {\n\tcheckSymbol(symbol);\n}\nComment.prototype = {\n\tnodeName: '#comment',\n\tnodeType: COMMENT_NODE,\n};\n_extends(Comment, CharacterData);\n\nfunction CDATASection(symbol) {\n\tcheckSymbol(symbol);\n}\nCDATASection.prototype = {\n\tnodeName: '#cdata-section',\n\tnodeType: CDATA_SECTION_NODE,\n};\n_extends(CDATASection, Text);\n\nfunction DocumentType(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType, Node);\n\nfunction Notation(symbol) {\n\tcheckSymbol(symbol);\n}\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation, Node);\n\nfunction Entity(symbol) {\n\tcheckSymbol(symbol);\n}\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity, Node);\n\nfunction EntityReference(symbol) {\n\tcheckSymbol(symbol);\n}\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference, Node);\n\nfunction DocumentFragment(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentFragment.prototype.nodeName = '#document-fragment';\nDocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment, Node);\n\nfunction ProcessingInstruction(symbol) {\n\tcheckSymbol(symbol);\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction, CharacterData);\nfunction XMLSerializer() {}\nXMLSerializer.prototype.serializeToString = function (node, nodeFilter) {\n\treturn nodeSerializeToString.call(node, nodeFilter);\n};\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(nodeFilter) {\n\tvar buf = [];\n\tvar refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif (uri && prefix == null) {\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif (prefix == null) {\n\t\t\tvar visibleNamespaces = [\n\t\t\t\t{ namespace: uri, prefix: null },\n\t\t\t\t//{namespace:uri,prefix:''}\n\t\t\t];\n\t\t}\n\t}\n\tserializeToString(this, buf, nodeFilter, visibleNamespaces);\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length;\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Literal whitespace other than space that appear in attribute values are serialized as\n * their entity references, so they will be preserved.\n * (In contrast to whitespace literals in the input which are normalized to spaces).\n *\n * Well-formed constraint: No < in Attribute Values:\n * > The replacement text of any entity referred to directly or indirectly\n * > in an attribute value must not contain a <.\n *\n * @see https://www.w3.org/TR/xml11/#CleanAttrVals\n * @see https://www.w3.org/TR/xml11/#NT-AttValue\n * @see https://www.w3.org/TR/xml11/#AVNormalize\n * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes\n * @prettierignore\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<>&\"\\t\\n\\r]/g, _xmlEncoder), '\"');\n}\n\nfunction serializeToString(node, buf, nodeFilter, visibleNamespaces) {\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\tvar doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;\n\tvar isHTML = doc.type === 'html';\n\n\tif (nodeFilter) {\n\t\tnode = nodeFilter(node);\n\t\tif (node) {\n\t\t\tif (typeof node == 'string') {\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tvar attrs = node.attributes;\n\t\t\tvar len = attrs.length;\n\t\t\tvar child = node.firstChild;\n\t\t\tvar nodeName = node.tagName;\n\n\t\t\tvar prefixedNodeName = nodeName;\n\t\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\t\tvar defaultNS;\n\t\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\t\tdefaultNS = attrs.item(ai).value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultNS) {\n\t\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tdefaultNS = namespace.namespace;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuf.push('<', prefixedNodeName);\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\t// add namespaces for attributes\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (attr.prefix == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({\n\t\t\t\t\t\tprefix: attr.localName,\n\t\t\t\t\t\tnamespace: attr.value,\n\t\t\t\t\t});\n\t\t\t\t} else if (attr.nodeName == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({ prefix: '', namespace: attr.value });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {\n\t\t\t\t\tvar prefix = attr.prefix || '';\n\t\t\t\t\tvar uri = attr.namespaceURI;\n\t\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t\t}\n\t\t\t\tserializeToString(attr, buf, nodeFilter, visibleNamespaces);\n\t\t\t}\n\n\t\t\t// add namespace for current node\n\t\t\tif (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {\n\t\t\t\tvar prefix = node.prefix || '';\n\t\t\t\tvar uri = node.namespaceURI;\n\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t}\n\t\t\t// in XML elements can be closed when they have no children\n\t\t\tvar canCloseTag = !child;\n\t\t\tif (canCloseTag && (isHTML || node.namespaceURI === NAMESPACE.HTML)) {\n\t\t\t\t// in HTML (doc or ns) only void elements can be closed right away\n\t\t\t\tcanCloseTag = isHTMLVoidElement(nodeName);\n\t\t\t}\n\t\t\tif (canCloseTag) {\n\t\t\t\tbuf.push('/>');\n\t\t\t} else {\n\t\t\t\tbuf.push('>');\n\t\t\t\t//if is cdata child node\n\t\t\t\tif (isHTML && isHTMLRawTextElement(nodeName)) {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tif (child.data) {\n\t\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuf.push('');\n\t\t\t}\n\t\t\t// remove added visible namespaces\n\t\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\t\treturn;\n\t\tcase DOCUMENT_NODE:\n\t\tcase DOCUMENT_FRAGMENT_NODE:\n\t\t\tvar child = node.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\treturn;\n\t\tcase ATTRIBUTE_NODE:\n\t\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\t\tcase TEXT_NODE:\n\t\t\t/*\n\t\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t\t * except when used as markup delimiters, or within a comment, a processing instruction,\n\t\t\t * or a CDATA section.\n\t\t\t * If they are needed elsewhere, they must be escaped using either numeric character\n\t\t\t * references or the strings `&` and `<` respectively.\n\t\t\t * The right angle bracket (>) may be represented using the string \" > \",\n\t\t\t * and must, for compatibility, be escaped using either `>`,\n\t\t\t * or a character reference when it appears in the string `]]>` in content,\n\t\t\t * when that string is not marking the end of a CDATA section.\n\t\t\t *\n\t\t\t * In the content of elements, character data is any string of characters which does not\n\t\t\t * contain the start-delimiter of any markup and does not include the CDATA-section-close\n\t\t\t * delimiter, `]]>`.\n\t\t\t *\n\t\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t\t * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node\n\t\t\t */\n\t\t\treturn buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));\n\t\tcase CDATA_SECTION_NODE:\n\t\t\treturn buf.push(g.CDATA_START, node.data, g.CDATA_END);\n\t\tcase COMMENT_NODE:\n\t\t\treturn buf.push(g.COMMENT_START, node.data, g.COMMENT_END);\n\t\tcase DOCUMENT_TYPE_NODE:\n\t\t\tvar pubid = node.publicId;\n\t\t\tvar sysid = node.systemId;\n\t\t\tbuf.push(g.DOCTYPE_DECL_START, ' ', node.name);\n\t\t\tif (pubid) {\n\t\t\t\tbuf.push(' ', g.PUBLIC, ' ', pubid);\n\t\t\t\tif (sysid && sysid !== '.') {\n\t\t\t\t\tbuf.push(' ', sysid);\n\t\t\t\t}\n\t\t\t} else if (sysid && sysid !== '.') {\n\t\t\t\tbuf.push(' ', g.SYSTEM, ' ', sysid);\n\t\t\t}\n\t\t\tif (node.internalSubset) {\n\t\t\t\tbuf.push(' [', node.internalSubset, ']');\n\t\t\t}\n\t\t\tbuf.push('>');\n\t\t\treturn;\n\t\tcase PROCESSING_INSTRUCTION_NODE:\n\t\t\treturn buf.push('');\n\t\tcase ENTITY_REFERENCE_NODE:\n\t\t\treturn buf.push('&', node.nodeName, ';');\n\t\t//case ENTITY_NODE:\n\t\t//case NOTATION_NODE:\n\t\tdefault:\n\t\t\tbuf.push('??', node.nodeName);\n\t}\n}\nfunction importNode(doc, node, deep) {\n\tvar node2;\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tnode2 = node.cloneNode(false);\n\t\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see {@link XML_ENTITIES}\n * @see {@link DOMParser.parseFromString}\n * @see {@link DOMImplementation.prototype.createHTMLDocument}\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)\n * Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML\n * Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML\n * Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated\n * Use `HTML_ENTITIES` instead.\n * @see {@link HTML_ENTITIES}\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar g = require('./grammar');\nvar errors = require('./errors');\n\nvar isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar hasOwn = conventions.hasOwn;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\nvar DOMException = errors.DOMException;\n\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0; //tag name offerring\nvar S_ATTR = 1; //attr name offerring\nvar S_ATTR_SPACE = 2; //attr name end and space offer\nvar S_EQ = 3; //=space?\nvar S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)\nvar S_ATTR_END = 5; //attr value end and no space(quot end)\nvar S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7; //closed el\n\nfunction XMLReader() {}\n\nXMLReader.prototype = {\n\tparse: function (source, defaultNSMap, entityMap) {\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap, (defaultNSMap = Object.create(null)));\n\t\tparse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t},\n};\n\n/**\n * Detecting everything that might be a reference,\n * including those without ending `;`, since those are allowed in HTML.\n * The entityReplacer takes care of verifying and transforming each occurrence,\n * and reports to the errorHandler on those that are not OK,\n * depending on the context.\n */\nvar ENTITY_REG = /&#?\\w+;?/g;\n\nfunction parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {\n\tvar isHTML = isHTMLMimeType(domBuilder.mimeType);\n\tif (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {\n\t\terrorHandler.warning('Unicode replacement character detected, source encoding issues?');\n\t}\n\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10),\n\t\t\t\tsurrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\n\tfunction entityReplacer(a) {\n\t\tvar complete = a[a.length - 1] === ';' ? a : a + ';';\n\t\tif (!isHTML && complete !== a) {\n\t\t\terrorHandler.error('EntityRef: expecting ;');\n\t\t\treturn a;\n\t\t}\n\t\tvar match = g.Reference.exec(complete);\n\t\tif (!match || match[0].length !== complete.length) {\n\t\t\terrorHandler.error('entity not matching Reference production: ' + a);\n\t\t\treturn a;\n\t\t}\n\t\tvar k = complete.slice(1, -1);\n\t\tif (hasOwn(entityMap, k)) {\n\t\t\treturn entityMap[k];\n\t\t} else if (k.charAt(0) === '#') {\n\t\t\treturn fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));\n\t\t} else {\n\t\t\terrorHandler.error('entity not found:' + a);\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tfunction appendText(end) {\n\t\t//has some bugs\n\t\tif (end > start) {\n\t\t\tvar xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);\n\t\t\tlocator && position(start);\n\t\t\tdomBuilder.characters(xt, 0, end - start);\n\t\t\tstart = end;\n\t\t}\n\t}\n\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /\\r\\n?|\\n|$/g;\n\tvar locator = domBuilder.locator;\n\n\tfunction position(p, m) {\n\t\twhile (p >= lineEnd && (m = linePattern.exec(source))) {\n\t\t\tlineStart = lineEnd;\n\t\t\tlineEnd = m.index + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t}\n\t\tlocator.columnNumber = p - lineStart + 1;\n\t}\n\n\tvar parseStack = [{ currentNSMap: defaultNSMapCopy }];\n\tvar unclosedTags = [];\n\tvar start = 0;\n\twhile (true) {\n\t\ttry {\n\t\t\tvar tagStart = source.indexOf('<', start);\n\t\t\tif (tagStart < 0) {\n\t\t\t\tif (!isHTML && unclosedTags.length > 0) {\n\t\t\t\t\treturn errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));\n\t\t\t\t}\n\t\t\t\tif (!source.substring(start).match(/^\\s*$/)) {\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t\t\t\t\tvar text = doc.createTextNode(source.substring(start));\n\t\t\t\t\tif (doc.documentElement) {\n\t\t\t\t\t\treturn errorHandler.error('Extra content at the end of the document');\n\t\t\t\t\t}\n\t\t\t\t\tdoc.appendChild(text);\n\t\t\t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (tagStart > start) {\n\t\t\t\tvar fromSource = source.substring(start, tagStart);\n\t\t\t\tif (!isHTML && unclosedTags.length === 0) {\n\t\t\t\t\tfromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');\n\t\t\t\t\tfromSource && errorHandler.error(\"Unexpected content outside root element: '\" + fromSource + \"'\");\n\t\t\t\t}\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch (source.charAt(tagStart + 1)) {\n\t\t\t\tcase '/':\n\t\t\t\t\tvar end = source.indexOf('>', tagStart + 2);\n\t\t\t\t\tvar tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);\n\t\t\t\t\tif (!tagNameRaw) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name missing');\n\t\t\t\t\t}\n\t\t\t\t\tvar tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);\n\t\t\t\t\tif (!tagNameMatch) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name contains invalid characters: \"' + tagNameRaw + '\"');\n\t\t\t\t\t}\n\t\t\t\t\tif (!domBuilder.currentElement && !domBuilder.doc.documentElement) {\n\t\t\t\t\t\t// not enough information to provide a helpful error message,\n\t\t\t\t\t\t// but parsing will throw since there is no root element\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar currentTagName =\n\t\t\t\t\t\tunclosedTags[unclosedTags.length - 1] ||\n\t\t\t\t\t\tdomBuilder.currentElement.tagName ||\n\t\t\t\t\t\tdomBuilder.doc.documentElement.tagName ||\n\t\t\t\t\t\t'';\n\t\t\t\t\tif (currentTagName !== tagNameMatch[1]) {\n\t\t\t\t\t\tvar tagNameLower = tagNameMatch[1].toLowerCase();\n\t\t\t\t\t\tif (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('Opening and ending tag mismatch: \"' + currentTagName + '\" != \"' + tagNameRaw + '\"');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvar config = parseStack.pop();\n\t\t\t\t\tunclosedTags.pop();\n\t\t\t\t\tvar localNSMap = config.localNSMap;\n\t\t\t\t\tdomBuilder.endElement(config.uri, config.localName, currentTagName);\n\t\t\t\t\tif (localNSMap) {\n\t\t\t\t\t\tfor (var prefix in localNSMap) {\n\t\t\t\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tend++;\n\t\t\t\t\tbreak;\n\t\t\t\t// end element\n\t\t\t\tcase '?': // \n\t\t\t\t\tlocator && position(tagStart);\n\t\t\t\t\tend = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);\n\t\t\t\t\tbreak;\n\t\t\t\tcase '!': // start) {\n\t\t\tstart = end;\n\t\t} else {\n\t\t\t//Possible sax fallback here, risk of positional error\n\t\t\tappendText(Math.max(tagStart, start) + 1);\n\t\t}\n\t}\n}\n\nfunction copyLocator(f, t) {\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @returns\n * end of the elementStartPart(end of elementEndPart for selfClosed el)\n * @see {@link #appendElement}\n */\nfunction parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (hasOwn(el.attributeNames, qname)) {\n\t\t\treturn errorHandler.fatalError('Attribute ' + qname + ' redefined');\n\t\t}\n\t\tif (!isHTML && value.indexOf('<') >= 0) {\n\t\t\treturn errorHandler.fatalError(\"Unescaped '<' not allowed in attributes values\");\n\t\t}\n\t\tel.addValue(\n\t\t\tqname,\n\t\t\t// @see https://www.w3.org/TR/xml/#AVNormalize\n\t\t\t// since the xmldom sax parser does not \"interpret\" DTD the following is not implemented:\n\t\t\t// - recursive replacement of (DTD) entity references\n\t\t\t// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA\n\t\t\tvalue.replace(/[\\t\\n\\r]/g, ' ').replace(ENTITY_REG, entityReplacer),\n\t\t\tstartIndex\n\t\t);\n\t}\n\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG; //status\n\twhile (true) {\n\t\tvar c = source.charAt(p);\n\t\tswitch (c) {\n\t\t\tcase '=':\n\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t//attrName\n\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else if (s === S_ATTR_SPACE) {\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\tcase '\"':\n\t\t\t\tif (\n\t\t\t\t\ts === S_EQ ||\n\t\t\t\t\ts === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t) {\n\t\t\t\t\t//equal\n\t\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"');\n\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t}\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\tp = source.indexOf(c, start);\n\t\t\t\t\tif (p > 0) {\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\taddAttribute(attrName, value, start - 1);\n\t\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\t\tthrow new Error(\"attribute value no end '\" + c + \"' match\");\n\t\t\t\t\t}\n\t\t\t\t} else if (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed start quot(' + c + ')!!');\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: no equal before\n\t\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '/':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\ts = S_TAG_CLOSE;\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t//case S_EQ:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"attribute invalid close char('/')\"); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '': //end document\n\t\t\t\terrorHandler.error('unexpected end of input');\n\t\t\t\tif (s == S_TAG) {\n\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\tcase '>':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\tbreak; //normal\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE: //Compatible state\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\tif (value.slice(-1) === '/') {\n\t\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\t\tvalue = value.slice(0, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tif (s === S_ATTR_SPACE) {\n\t\t\t\t\t\t\tvalue = attrName;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed value!! \"' + value + '\" instead!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(value, value, start);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('AttValue: \\' or \" expected');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\t\tcase '\\u0080':\n\t\t\t\tc = ' ';\n\t\t\tdefault:\n\t\t\t\tif (c <= ' ') {\n\t\t\t\t\t//space\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\t\tel.setTagName(source.slice(start, p)); //tagName\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\t\t\tvar value = source.slice(start, p);\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t\t\t//case S_EQ:\n\t\t\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t\t\t//\tvoid();break;\n\t\t\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t\t//ignore warning\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//not space\n\t\t\t\t\t//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n\t\t\t\t\t//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed value!! \"' + attrName + '\" instead2!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\terrorHandler.warning('attribute space is required\"' + attrName + '\"!!');\n\t\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t} //end outer switch\n\t\tp++;\n\t}\n}\n\n/**\n * @returns\n * `true` if a new namespace has been defined.\n */\nfunction appendElement(el, domBuilder, currentNSMap) {\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\tvar i = el.length;\n\twhile (i--) {\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif (nsp > 0) {\n\t\t\tvar prefix = (a.prefix = qName.slice(0, nsp));\n\t\t\tvar localName = qName.slice(nsp + 1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName;\n\t\t} else {\n\t\t\tlocalName = qName;\n\t\t\tprefix = null;\n\t\t\tnsPrefix = qName === 'xmlns' && '';\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif (nsPrefix !== false) {\n\t\t\t//hack!!\n\t\t\tif (localNSMap == null) {\n\t\t\t\tlocalNSMap = Object.create(null);\n\t\t\t\t_copy(currentNSMap, (currentNSMap = Object.create(null)));\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS;\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value);\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile (i--) {\n\t\ta = el[i];\n\t\tif (a.prefix) {\n\t\t\t//no prefix attribute has no namespace\n\t\t\tif (a.prefix === 'xml') {\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}\n\t\t\tif (a.prefix !== 'xmlns') {\n\t\t\t\ta.uri = currentNSMap[a.prefix];\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif (nsp > 0) {\n\t\tprefix = el.prefix = tagName.slice(0, nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp + 1);\n\t} else {\n\t\tprefix = null; //important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = (el.uri = currentNSMap[prefix || '']);\n\tdomBuilder.startElement(ns, localName, tagName, el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif (el.closed) {\n\t\tdomBuilder.endElement(ns, localName, tagName);\n\t\tif (localNSMap) {\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\n\nfunction parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {\n\t// https://html.spec.whatwg.org/#raw-text-elements\n\t// https://html.spec.whatwg.org/#escapable-raw-text-elements\n\t// https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements\n\t// TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions\n\tvar isEscapableRaw = isHTMLEscapableRawTextElement(tagName);\n\tif (isEscapableRaw || isHTMLRawTextElement(tagName)) {\n\t\tvar elEndStart = source.indexOf('', elStartEnd);\n\t\tvar text = source.substring(elStartEnd + 1, elEndStart);\n\n\t\tif (isEscapableRaw) {\n\t\t\ttext = text.replace(ENTITY_REG, entityReplacer);\n\t\t}\n\t\tdomBuilder.characters(text, 0, text.length);\n\t\treturn elEndStart;\n\t}\n\treturn elStartEnd + 1;\n}\n\nfunction _copy(source, target) {\n\tfor (var n in source) {\n\t\tif (hasOwn(source, n)) {\n\t\t\ttarget[n] = source[n];\n\t\t}\n\t}\n}\n\n/**\n * @typedef ParseUtils\n * @property {function(relativeIndex: number?): string | undefined} char\n * Provides look ahead access to a singe character relative to the current index.\n * @property {function(): number} getIndex\n * Provides read-only access to the current index.\n * @property {function(reg: RegExp): string | null} getMatch\n * Applies the provided regular expression enforcing that it starts at the current index and\n * returns the complete matching string,\n * and moves the current index by the length of the matching string.\n * @property {function(): string} getSource\n * Provides read-only access to the complete source.\n * @property {function(places: number?): void} skip\n * moves the current index by places (defaults to 1)\n * @property {function(): number} skipBlanks\n * Moves the current index by the amount of white space that directly follows the current index\n * and returns the amount of whitespace chars skipped (0..n),\n * or -1 if the end of the source was reached.\n * @property {function(): string} substringFromIndex\n * creates a substring from the current index to the end of `source`\n * @property {function(compareWith: string): boolean} substringStartsWith\n * Checks if `source` contains `compareWith`, starting from the current index.\n * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive\n * Checks if `source` contains `compareWith`, starting from the current index,\n * comparing the upper case of both sides.\n * @see {@link parseUtils}\n */\n\n/**\n * A temporary scope for parsing and look ahead operations in `source`,\n * starting from index `start`.\n *\n * Some operations move the current index by a number of positions,\n * after which `getIndex` returns the new index.\n *\n * @param {string} source\n * @param {number} start\n * @returns {ParseUtils}\n */\nfunction parseUtils(source, start) {\n\tvar index = start;\n\n\tfunction char(n) {\n\t\tn = n || 0;\n\t\treturn source.charAt(index + n);\n\t}\n\n\tfunction skip(n) {\n\t\tn = n || 1;\n\t\tindex += n;\n\t}\n\n\tfunction skipBlanks() {\n\t\tvar blanks = 0;\n\t\twhile (index < source.length) {\n\t\t\tvar c = char();\n\t\t\tif (c !== ' ' && c !== '\\n' && c !== '\\t' && c !== '\\r') {\n\t\t\t\treturn blanks;\n\t\t\t}\n\t\t\tblanks++;\n\t\t\tskip();\n\t\t}\n\t\treturn -1;\n\t}\n\tfunction substringFromIndex() {\n\t\treturn source.substring(index);\n\t}\n\tfunction substringStartsWith(text) {\n\t\treturn source.substring(index, index + text.length) === text;\n\t}\n\tfunction substringStartsWithCaseInsensitive(text) {\n\t\treturn source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();\n\t}\n\n\tfunction getMatch(args) {\n\t\tvar expr = g.reg('^', args);\n\t\tvar match = expr.exec(substringFromIndex());\n\t\tif (match) {\n\t\t\tskip(match[0].length);\n\t\t\treturn match[0];\n\t\t}\n\t\treturn null;\n\t}\n\treturn {\n\t\tchar: char,\n\t\tgetIndex: function () {\n\t\t\treturn index;\n\t\t},\n\t\tgetMatch: getMatch,\n\t\tgetSource: function () {\n\t\t\treturn source;\n\t\t},\n\t\tskip: skip,\n\t\tskipBlanks: skipBlanks,\n\t\tsubstringFromIndex: substringFromIndex,\n\t\tsubstringStartsWith: substringStartsWith,\n\t\tsubstringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,\n\t};\n}\n\n/**\n * @param {ParseUtils} p\n * @param {DOMHandler} errorHandler\n * @returns {string}\n */\nfunction parseDoctypeInternalSubset(p, errorHandler) {\n\t/**\n\t * @param {ParseUtils} p\n\t * @param {DOMHandler} errorHandler\n\t * @returns {string}\n\t */\n\tfunction parsePI(p, errorHandler) {\n\t\tvar match = g.PI.exec(p.substringFromIndex());\n\t\tif (!match) {\n\t\t\treturn errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());\n\t\t}\n\t\tif (match[1].toLowerCase() === 'xml') {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()\n\t\t\t);\n\t\t}\n\t\tp.skip(match[0].length);\n\t\treturn match[0];\n\t}\n\t// Parse internal subset\n\tvar source = p.getSource();\n\tif (p.char() === '[') {\n\t\tp.skip(1);\n\t\tvar intSubsetStart = p.getIndex();\n\t\twhile (p.getIndex() < source.length) {\n\t\t\tp.skipBlanks();\n\t\t\tif (p.char() === ']') {\n\t\t\t\tvar internalSubset = source.substring(intSubsetStart, p.getIndex());\n\t\t\t\tp.skip(1);\n\t\t\t\treturn internalSubset;\n\t\t\t}\n\t\t\tvar current = null;\n\t\t\t// Only in external subset\n\t\t\t// if (char() === '<' && char(1) === '!' && char(2) === '[') {\n\t\t\t// \tparseConditionalSections(p, errorHandler);\n\t\t\t// } else\n\t\t\tif (p.char() === '<' && p.char(1) === '!') {\n\t\t\t\tswitch (p.char(2)) {\n\t\t\t\t\tcase 'E': // ELEMENT | ENTITY\n\t\t\t\t\t\tif (p.char(3) === 'L') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.elementdecl);\n\t\t\t\t\t\t} else if (p.char(3) === 'N') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.EntityDecl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'A': // ATTRIBUTE\n\t\t\t\t\t\tcurrent = p.getMatch(g.AttlistDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'N': // NOTATION\n\t\t\t\t\t\tcurrent = p.getMatch(g.NotationDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-': // COMMENT\n\t\t\t\t\t\tcurrent = p.getMatch(g.Comment);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (p.char() === '<' && p.char(1) === '?') {\n\t\t\t\tcurrent = parsePI(p, errorHandler);\n\t\t\t} else if (p.char() === '%') {\n\t\t\t\tcurrent = p.getMatch(g.PEReference);\n\t\t\t} else {\n\t\t\t\treturn errorHandler.fatalError('Error detected in Markup declaration');\n\t\t\t}\n\t\t\tif (!current) {\n\t\t\t\treturn errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());\n\t\t\t}\n\t\t}\n\t\treturn errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');\n\t}\n}\n\n/**\n * Called when the parser encounters an element starting with '') {\n\t\t\t\treturn errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());\n\t\t\t}\n\t\t\tp.skip(1);\n\t\t\tdomBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);\n\t\t\tdomBuilder.endDTD();\n\t\t\treturn p.getIndex();\n\t\t}\n\t\tdefault:\n\t\t\treturn errorHandler.fatalError('Not well-formed XML starting with \" 0) {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'\n\t\t\t);\n\t\t}\n\t\tif (!g.XMLDecl.test(source.substring(start))) {\n\t\t\treturn errorHandler.fatalError('xml declaration is not well-formed');\n\t\t}\n\t}\n\tdomBuilder.processingInstruction(match[1], match[2]);\n\treturn start + match[0].length;\n}\n\nfunction ElementAttributes() {\n\tthis.attributeNames = Object.create(null);\n}\n\nElementAttributes.prototype = {\n\tsetTagName: function (tagName) {\n\t\tif (!g.QName_exact.test(tagName)) {\n\t\t\tthrow new Error('invalid tagName:' + tagName);\n\t\t}\n\t\tthis.tagName = tagName;\n\t},\n\taddValue: function (qName, value, offset) {\n\t\tif (!g.QName_exact.test(qName)) {\n\t\t\tthrow new Error('invalid attribute:' + qName);\n\t\t}\n\t\tthis.attributeNames[qName] = this.length;\n\t\tthis[this.length++] = { qName: qName, value: value, offset: offset };\n\t},\n\tlength: 0,\n\tgetLocalName: function (i) {\n\t\treturn this[i].localName;\n\t},\n\tgetLocator: function (i) {\n\t\treturn this[i].locator;\n\t},\n\tgetQName: function (i) {\n\t\treturn this[i].qName;\n\t},\n\tgetURI: function (i) {\n\t\treturn this[i].uri;\n\t},\n\tgetValue: function (i) {\n\t\treturn this[i].value;\n\t},\n\t//\t,getIndex:function(uri, localName)){\n\t//\t\tif(localName){\n\t//\n\t//\t\t}else{\n\t//\t\t\tvar qName = uri\n\t//\t\t}\n\t//\t},\n\t//\tgetValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},\n\t//\tgetType:function(uri,localName){}\n\t//\tgetType:function(i){},\n};\n\nexports.XMLReader = XMLReader;\nexports.parseUtils = parseUtils;\nexports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar dom = require('./dom');\nvar errors = require('./errors');\nvar entities = require('./entities');\nvar sax = require('./sax');\n\nvar DOMImplementation = dom.DOMImplementation;\n\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isValidMimeType = conventions.isValidMimeType;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\n\nvar XMLReader = sax.XMLReader;\n\n/**\n * Normalizes line ending according to ,\n * including some Unicode \"newline\" characters:\n *\n * > XML parsed entities are often stored in computer files which,\n * > for editing convenience, are organized into lines.\n * > These lines are typically separated by some combination\n * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).\n * >\n * > To simplify the tasks of applications, the XML processor must behave\n * > as if it normalized all line breaks in external parsed entities (including the document entity)\n * > on input, before parsing, by translating the following to a single #xA character:\n * >\n * > 1. the two-character sequence #xD #xA,\n * > 2. the two-character sequence #xD #x85,\n * > 3. the single character #x85,\n * > 4. the single character #x2028,\n * > 5. the single character #x2029,\n * > 6. any #xD character that is not immediately followed by #xA or #x85.\n *\n * @param {string} input\n * @returns {string}\n * @prettierignore\n */\nfunction normalizeLineEndings(input) {\n\treturn input.replace(/\\r[\\n\\u0085]/g, '\\n').replace(/[\\r\\u0085\\u2028\\u2029]/g, '\\n');\n}\n\n/**\n * @typedef Locator\n * @property {number} [columnNumber]\n * @property {number} [lineNumber]\n */\n\n/**\n * @typedef DOMParserOptions\n * @property {typeof assign} [assign]\n * The method to use instead of `conventions.assign`, which is used to copy values from\n * `options` before they are used for parsing.\n * @property {typeof DOMHandler} [domHandler]\n * For internal testing: The class for creating an instance for handling events from the SAX\n * parser.\n * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n * be broken.*****.\n * @property {Function} [errorHandler]\n * DEPRECATED! use `onError` instead.\n * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n * [onError]\n * A function invoked for every error that occurs during parsing.\n *\n * If it is not provided, all errors are reported to `console.error`\n * and only `fatalError`s are thrown as a `ParseError`,\n * which prevents any further processing.\n * If the provided method throws, a `ParserError` is thrown,\n * which prevents any further processing.\n *\n * Be aware that many `warning`s are considered an error that prevents further processing in\n * most implementations.\n * @property {boolean} [locator=true]\n * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`\n * attribute describing their location in the XML string.\n * Default is true.\n * @property {(string) => string} [normalizeLineEndings]\n * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,\n * which normalizes line endings according to ,\n * including some Unicode \"newline\" characters.\n * @property {Object} [xmlns]\n * The XML namespaces that should be assumed when parsing.\n * The default namespace can be provided by the key that is the empty string.\n * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n * the default namespace that will be used,\n * will be overridden according to the specification.\n * @see {@link normalizeLineEndings}\n */\n\n/**\n * The DOMParser interface provides the ability to parse XML or HTML source code from a string\n * into a DOM `Document`.\n *\n * ***xmldom is different from the spec in that it allows an `options` parameter,\n * to control the behavior***.\n *\n * @class\n * @param {DOMParserOptions} [options]\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization\n */\nfunction DOMParser(options) {\n\toptions = options || {};\n\tif (options.locator === undefined) {\n\t\toptions.locator = true;\n\t}\n\n\t/**\n\t * The method to use instead of `conventions.assign`, which is used to copy values from\n\t * `options`\n\t * before they are used for parsing.\n\t *\n\t * @type {conventions.assign}\n\t * @private\n\t * @see {@link conventions.assign}\n\t * @readonly\n\t */\n\tthis.assign = options.assign || conventions.assign;\n\n\t/**\n\t * For internal testing: The class for creating an instance for handling events from the SAX\n\t * parser.\n\t * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n\t * be broken*****.\n\t *\n\t * @type {typeof DOMHandler}\n\t * @private\n\t * @readonly\n\t */\n\tthis.domHandler = options.domHandler || DOMHandler;\n\n\t/**\n\t * A function that is invoked for every error that occurs during parsing.\n\t *\n\t * If it is not provided, all errors are reported to `console.error`\n\t * and only `fatalError`s are thrown as a `ParseError`,\n\t * which prevents any further processing.\n\t * If the provided method throws, a `ParserError` is thrown,\n\t * which prevents any further processing.\n\t *\n\t * Be aware that many `warning`s are considered an error that prevents further processing in\n\t * most implementations.\n\t *\n\t * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n\t * @see {@link onErrorStopParsing}\n\t * @see {@link onWarningStopParsing}\n\t */\n\tthis.onError = options.onError || options.errorHandler;\n\tif (options.errorHandler && typeof options.errorHandler !== 'function') {\n\t\tthrow new TypeError('errorHandler object is no longer supported, switch to onError!');\n\t} else if (options.errorHandler) {\n\t\toptions.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);\n\t}\n\n\t/**\n\t * used to replace line endings before parsing, defaults to `normalizeLineEndings`\n\t *\n\t * @type {(string) => string}\n\t * @readonly\n\t */\n\tthis.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;\n\n\t/**\n\t * Configures if the nodes created during parsing will have a `lineNumber` and a\n\t * `columnNumber`\n\t * attribute describing their location in the XML string.\n\t * Default is true.\n\t *\n\t * @type {boolean}\n\t * @readonly\n\t */\n\tthis.locator = !!options.locator;\n\n\t/**\n\t * The default namespace can be provided by the key that is the empty string.\n\t * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n\t * the default namespace that will be used,\n\t * will be overridden according to the specification.\n\t *\n\t * @type {Readonly}\n\t * @readonly\n\t */\n\tthis.xmlns = this.assign(Object.create(null), options.xmlns);\n}\n\n/**\n * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`\n * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,\n * otherwise an XML `Document` is created.\n *\n * __It behaves different from the description in the living standard__:\n * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.\n * - Any unexpected input is reported to `onError` with either a `warning`,\n * `error` or `fatalError` level.\n * - Any `fatalError` throws a `ParseError` which prevents further processing.\n * - Any error thrown by `onError` is converted to a `ParseError` which prevents further\n * processing - If no `Document` was created during parsing it is reported as a `fatalError`.\n * *****Warning: By configuring a faulty DOMHandler implementation,\n * the specified behavior can completely be broken*****.\n *\n * @param {string} source\n * The XML mime type only allows string input!\n * @param {string} [mimeType='application/xml']\n * the mimeType or contentType of the document to be created determines the `type` of document\n * created (XML or HTML)\n * @returns {Document}\n * The `Document` node.\n * @throws {ParseError}\n * for any `fatalError` or anything that is thrown by `onError`\n * @throws {TypeError}\n * for any invalid `mimeType`\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev\n */\nDOMParser.prototype.parseFromString = function (source, mimeType) {\n\tif (!isValidMimeType(mimeType)) {\n\t\tthrow new TypeError('DOMParser.parseFromString: the provided mimeType \"' + mimeType + '\" is not valid.');\n\t}\n\tvar defaultNSMap = this.assign(Object.create(null), this.xmlns);\n\tvar entityMap = entities.XML_ENTITIES;\n\tvar defaultNamespace = defaultNSMap[''] || null;\n\tif (hasDefaultHTMLNamespace(mimeType)) {\n\t\tentityMap = entities.HTML_ENTITIES;\n\t\tdefaultNamespace = NAMESPACE.HTML;\n\t} else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {\n\t\tdefaultNamespace = NAMESPACE.SVG;\n\t}\n\tdefaultNSMap[''] = defaultNamespace;\n\tdefaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;\n\n\tvar domBuilder = new this.domHandler({\n\t\tmimeType: mimeType,\n\t\tdefaultNamespace: defaultNamespace,\n\t\tonError: this.onError,\n\t});\n\tvar locator = this.locator ? {} : undefined;\n\tif (this.locator) {\n\t\tdomBuilder.setDocumentLocator(locator);\n\t}\n\n\tvar sax = new XMLReader();\n\tsax.errorHandler = domBuilder;\n\tsax.domBuilder = domBuilder;\n\tvar isXml = !conventions.isHTMLMimeType(mimeType);\n\tif (isXml && typeof source !== 'string') {\n\t\tsax.errorHandler.fatalError('source is not a string');\n\t}\n\tsax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);\n\tif (!domBuilder.doc.documentElement) {\n\t\tsax.errorHandler.fatalError('missing root element');\n\t}\n\treturn domBuilder.doc;\n};\n\n/**\n * @typedef DOMHandlerOptions\n * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]\n * @property {string | null} [defaultNamespace=null]\n */\n/**\n * The class that is used to handle events from the SAX parser to create the related DOM\n * elements.\n *\n * Some methods are only implemented as an empty function,\n * since they are (at least currently) not relevant for xmldom.\n *\n * @class\n * @param {DOMHandlerOptions} [options]\n * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html\n */\nfunction DOMHandler(options) {\n\tvar opt = options || {};\n\t/**\n\t * The mime type is used to determine if the DOM handler will create an XML or HTML document.\n\t * Only if it is set to `text/html` it will create an HTML document.\n\t * It defaults to MIME_TYPE.XML_APPLICATION.\n\t *\n\t * @type {string}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;\n\n\t/**\n\t * The namespace to use to create an XML document.\n\t * For the following reasons this is required:\n\t * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,\n\t * since at that point there is no way for the parser to know what the default namespace from\n\t * the document will be.\n\t * - When creating using `DOMImplementation.createDocument` it is required to pass a\n\t * namespace,\n\t * to determine the correct `Document.contentType`, which should match `this.mimeType`.\n\t * - When parsing an XML document with the `application/xhtml+xml` mimeType,\n\t * the HTML namespace needs to be the default namespace.\n\t *\n\t * @type {string | null}\n\t * @private\n\t * @readonly\n\t */\n\tthis.defaultNamespace = opt.defaultNamespace || null;\n\n\t/**\n\t * @type {boolean}\n\t * @private\n\t */\n\tthis.cdata = false;\n\n\t/**\n\t * The last `Element` that was created by `startElement`.\n\t * `endElement` sets it to the `currentElement.parentNode`.\n\t *\n\t * Note: The sax parser currently sets it to white space text nodes between tags.\n\t *\n\t * @type {Element | Node | undefined}\n\t * @private\n\t */\n\tthis.currentElement = undefined;\n\n\t/**\n\t * The Document that is created as part of `startDocument`,\n\t * and returned by `DOMParser.parseFromString`.\n\t *\n\t * @type {Document | undefined}\n\t * @readonly\n\t */\n\tthis.doc = undefined;\n\n\t/**\n\t * The locator is stored as part of setDocumentLocator.\n\t * It is controlled and mutated by the SAX parser to store the current parsing position.\n\t * It is used by DOMHandler to set `columnNumber` and `lineNumber`\n\t * on the DOM nodes.\n\t *\n\t * @type {Readonly | undefined}\n\t * @private\n\t * @readonly (the\n\t * sax parser currently sometimes set's it)\n\t */\n\tthis.locator = undefined;\n\t/**\n\t * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}\n\t * @readonly\n\t */\n\tthis.onError = opt.onError;\n}\n\nfunction position(locator, node) {\n\tnode.lineNumber = locator.lineNumber;\n\tnode.columnNumber = locator.columnNumber;\n}\n\nDOMHandler.prototype = {\n\t/**\n\t * Either creates an XML or an HTML document and stores it under `this.doc`.\n\t * If it is an XML document, `this.defaultNamespace` is used to create it,\n\t * and it will not contain any `childNodes`.\n\t * If it is an HTML document, it will be created without any `childNodes`.\n\t *\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html\n\t */\n\tstartDocument: function () {\n\t\tvar impl = new DOMImplementation();\n\t\tthis.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');\n\t},\n\tstartElement: function (namespaceURI, localName, qName, attrs) {\n\t\tvar doc = this.doc;\n\t\tvar el = doc.createElementNS(namespaceURI, qName || localName);\n\t\tvar len = attrs.length;\n\t\tappendElement(this, el);\n\t\tthis.currentElement = el;\n\n\t\tthis.locator && position(this.locator, el);\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tvar namespaceURI = attrs.getURI(i);\n\t\t\tvar value = attrs.getValue(i);\n\t\t\tvar qName = attrs.getQName(i);\n\t\t\tvar attr = doc.createAttributeNS(namespaceURI, qName);\n\t\t\tthis.locator && position(attrs.getLocator(i), attr);\n\t\t\tattr.value = attr.nodeValue = value;\n\t\t\tel.setAttributeNode(attr);\n\t\t}\n\t},\n\tendElement: function (namespaceURI, localName, qName) {\n\t\tthis.currentElement = this.currentElement.parentNode;\n\t},\n\tstartPrefixMapping: function (prefix, uri) {},\n\tendPrefixMapping: function (prefix) {},\n\tprocessingInstruction: function (target, data) {\n\t\tvar ins = this.doc.createProcessingInstruction(target, data);\n\t\tthis.locator && position(this.locator, ins);\n\t\tappendElement(this, ins);\n\t},\n\tignorableWhitespace: function (ch, start, length) {},\n\tcharacters: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\t//console.log(chars)\n\t\tif (chars) {\n\t\t\tif (this.cdata) {\n\t\t\t\tvar charNode = this.doc.createCDATASection(chars);\n\t\t\t} else {\n\t\t\t\tvar charNode = this.doc.createTextNode(chars);\n\t\t\t}\n\t\t\tif (this.currentElement) {\n\t\t\t\tthis.currentElement.appendChild(charNode);\n\t\t\t} else if (/^\\s*$/.test(chars)) {\n\t\t\t\tthis.doc.appendChild(charNode);\n\t\t\t\t//process xml\n\t\t\t}\n\t\t\tthis.locator && position(this.locator, charNode);\n\t\t}\n\t},\n\tskippedEntity: function (name) {},\n\tendDocument: function () {\n\t\tthis.doc.normalize();\n\t},\n\t/**\n\t * Stores the locator to be able to set the `columnNumber` and `lineNumber`\n\t * on the created DOM nodes.\n\t *\n\t * @param {Locator} locator\n\t */\n\tsetDocumentLocator: function (locator) {\n\t\tif (locator) {\n\t\t\tlocator.lineNumber = 0;\n\t\t}\n\t\tthis.locator = locator;\n\t},\n\t//LexicalHandler\n\tcomment: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\tvar comm = this.doc.createComment(chars);\n\t\tthis.locator && position(this.locator, comm);\n\t\tappendElement(this, comm);\n\t},\n\n\tstartCDATA: function () {\n\t\t//used in characters() methods\n\t\tthis.cdata = true;\n\t},\n\tendCDATA: function () {\n\t\tthis.cdata = false;\n\t},\n\n\tstartDTD: function (name, publicId, systemId, internalSubset) {\n\t\tvar impl = this.doc.implementation;\n\t\tif (impl && impl.createDocumentType) {\n\t\t\tvar dt = impl.createDocumentType(name, publicId, systemId, internalSubset);\n\t\t\tthis.locator && position(this.locator, dt);\n\t\t\tappendElement(this, dt);\n\t\t\tthis.doc.doctype = dt;\n\t\t}\n\t},\n\treportError: function (level, message) {\n\t\tif (typeof this.onError === 'function') {\n\t\t\ttry {\n\t\t\t\tthis.onError(level, message, this);\n\t\t\t} catch (e) {\n\t\t\t\tthrow new ParseError('Reporting ' + level + ' \"' + message + '\" caused ' + e, this.locator);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error('[xmldom ' + level + ']\\t' + message, _locator(this.locator));\n\t\t}\n\t},\n\t/**\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html\n\t */\n\twarning: function (message) {\n\t\tthis.reportError('warning', message);\n\t},\n\terror: function (message) {\n\t\tthis.reportError('error', message);\n\t},\n\t/**\n\t * This function reports a fatal error and throws a ParseError.\n\t *\n\t * @param {string} message\n\t * - The message to be used for reporting and throwing the error.\n\t * @returns {never}\n\t * This function always throws an error and never returns a value.\n\t * @throws {ParseError}\n\t * Always throws a ParseError with the provided message.\n\t */\n\tfatalError: function (message) {\n\t\tthis.reportError('fatalError', message);\n\t\tthrow new ParseError(message, this.locator);\n\t},\n};\n\nfunction _locator(l) {\n\tif (l) {\n\t\treturn '\\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';\n\t}\n}\n\nfunction _toString(chars, start, length) {\n\tif (typeof chars == 'string') {\n\t\treturn chars.substr(start, length);\n\t} else {\n\t\t//java sax connect width xmldom on rhino(what about: \"? && !(chars instanceof String)\")\n\t\tif (chars.length >= start + length || start) {\n\t\t\treturn new java.lang.String(chars, start, length) + '';\n\t\t}\n\t\treturn chars;\n\t}\n}\n\n/*\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html\n * used method of org.xml.sax.ext.LexicalHandler:\n * #comment(chars, start, length)\n * #startCDATA()\n * #endCDATA()\n * #startDTD(name, publicId, systemId)\n *\n *\n * IGNORED method of org.xml.sax.ext.LexicalHandler:\n * #endDTD()\n * #startEntity(name)\n * #endEntity(name)\n *\n *\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html\n * IGNORED method of org.xml.sax.ext.DeclHandler\n * \t#attributeDecl(eName, aName, type, mode, value)\n * #elementDecl(name, model)\n * #externalEntityDecl(name, publicId, systemId)\n * #internalEntityDecl(name, value)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html\n * IGNORED method of org.xml.sax.EntityResolver2\n * #resolveEntity(String name,String publicId,String baseURI,String systemId)\n * #resolveEntity(publicId, systemId)\n * #getExternalSubset(name, baseURI)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html\n * IGNORED method of org.xml.sax.DTDHandler\n * #notationDecl(name, publicId, systemId) {};\n * #unparsedEntityDecl(name, publicId, systemId, notationName) {};\n */\n'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(\n\t/\\w+/g,\n\tfunction (key) {\n\t\tDOMHandler.prototype[key] = function () {\n\t\t\treturn null;\n\t\t};\n\t}\n);\n\n/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */\nfunction appendElement(handler, node) {\n\tif (!handler.currentElement) {\n\t\thandler.doc.appendChild(node);\n\t} else {\n\t\thandler.currentElement.appendChild(node);\n\t}\n}\n\n/**\n * A method that prevents any further parsing when an `error`\n * with level `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onWarningStopParsing}\n */\nfunction onErrorStopParsing(level) {\n\tif (level === 'error') throw 'onErrorStopParsing';\n}\n\n/**\n * A method that prevents any further parsing when any `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onErrorStopParsing}\n */\nfunction onWarningStopParsing() {\n\tthrow 'onWarningStopParsing';\n}\n\nexports.__DOMHandler = DOMHandler;\nexports.DOMParser = DOMParser;\nexports.normalizeLineEndings = normalizeLineEndings;\nexports.onErrorStopParsing = onErrorStopParsing;\nexports.onWarningStopParsing = onWarningStopParsing;\n","'use strict';\nvar conventions = require('./conventions');\nexports.assign = conventions.assign;\nexports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nexports.isHTMLMimeType = conventions.isHTMLMimeType;\nexports.isValidMimeType = conventions.isValidMimeType;\nexports.MIME_TYPE = conventions.MIME_TYPE;\nexports.NAMESPACE = conventions.NAMESPACE;\n\nvar errors = require('./errors');\nexports.DOMException = errors.DOMException;\nexports.DOMExceptionName = errors.DOMExceptionName;\nexports.ExceptionCode = errors.ExceptionCode;\nexports.ParseError = errors.ParseError;\n\nvar dom = require('./dom');\nexports.Attr = dom.Attr;\nexports.CDATASection = dom.CDATASection;\nexports.CharacterData = dom.CharacterData;\nexports.Comment = dom.Comment;\nexports.Document = dom.Document;\nexports.DocumentFragment = dom.DocumentFragment;\nexports.DocumentType = dom.DocumentType;\nexports.DOMImplementation = dom.DOMImplementation;\nexports.Element = dom.Element;\nexports.Entity = dom.Entity;\nexports.EntityReference = dom.EntityReference;\nexports.LiveNodeList = dom.LiveNodeList;\nexports.NamedNodeMap = dom.NamedNodeMap;\nexports.Node = dom.Node;\nexports.NodeList = dom.NodeList;\nexports.Notation = dom.Notation;\nexports.ProcessingInstruction = dom.ProcessingInstruction;\nexports.Text = dom.Text;\nexports.XMLSerializer = dom.XMLSerializer;\n\nvar domParser = require('./dom-parser');\nexports.DOMParser = domParser.DOMParser;\nexports.normalizeLineEndings = domParser.normalizeLineEndings;\nexports.onErrorStopParsing = domParser.onErrorStopParsing;\nexports.onWarningStopParsing = domParser.onWarningStopParsing;\n","import { DOMParser as g, DOMImplementation as J } from \"@xmldom/xmldom\";\nconst p = \"USJ\", O = \"3.1\", _ = Object.freeze({ type: p, version: O, content: [] }), B = [\n \"type\",\n \"marker\",\n \"content\",\n \"sid\",\n \"eid\",\n \"number\",\n \"code\",\n \"altnumber\",\n \"pubnumber\",\n \"caller\",\n \"align\",\n \"category\"\n];\nfunction H(e) {\n return M.includes(e);\n}\nconst M = [\n // Old Testament\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n // New Testament\n \"MAT\",\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n // Deuterocanon\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"EZA\",\n \"5EZ\",\n \"6EZ\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n \"REP\",\n \"4BA\",\n \"LAO\",\n // Non scripture\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\",\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\"\n], f = \"usx\", N = \"3.1\", I = `<${f} version=\"${N}\" />`;\nfunction V(e) {\n const n = new g().parseFromString(e, \"text/xml\");\n return m(n.documentElement);\n}\nfunction m(e) {\n const [t] = e ? b(e) : [{ content: [] }];\n return t.type = p, t.version = O, t;\n}\nfunction b(e) {\n const t = {};\n let n = e.tagName, o, s, c = \"append\";\n if ([\"row\", \"cell\"].includes(n) && (n = \"table:\" + n), e.attributes)\n for (const r of Array.from(e.attributes))\n t[r.name] = r.value;\n t.style && (o = t.style, delete t.style), t.vid && delete t.vid, t.status && delete t.status;\n let i = { type: n };\n o && (i.marker = o), i = { ...i, ...t }, e.firstChild && e.firstChild.nodeType === e.firstChild.TEXT_NODE && e.firstChild.nodeValue && E(e.firstChild.nodeValue) !== \"\" && (s = e.firstChild.nodeValue);\n const l = Array.from(e.childNodes);\n i.content = [], s && i.content.push(s);\n for (const r of l) {\n if (r.tagName === void 0)\n continue;\n const [u, S] = b(r);\n switch (S) {\n case \"append\":\n i.content.push(u);\n break;\n case \"merge\":\n i.content = i.content.concat(u);\n break;\n }\n r.nextSibling && r.nextSibling.nodeType === r.nextSibling.TEXT_NODE && r.nextSibling.nodeValue && (E(r.nextSibling.nodeValue) !== \"\" || r.nextSibling.nodeValue === \" \") && i.content.push(r.nextSibling.nodeValue);\n }\n return i.content.length === 0 && i.type !== f && delete i.content, \"eid\" in i && [\"verse\", \"chapter\"].includes(n) && (c = \"ignore\"), [i, c];\n}\nfunction E(e) {\n return e.replace(/(^[ \\t\\n\\r\\f\\v]+)|([ \\t\\n\\r\\f\\v]+$)/g, \"\");\n}\nlet d, a;\nfunction C(e) {\n const t = new J().createDocument(\"\", f);\n return t.documentElement && (t.documentElement.setAttribute(\"version\", N), y(e, t)), t.toString();\n}\nfunction y(e, t) {\n if (t.documentElement) {\n for (const [n, o] of e.content.entries()) {\n const s = n === e.content.length - 1;\n v(o, t.documentElement, t, s);\n }\n return t.documentElement ?? void 0;\n }\n}\nfunction v(e, t, n, o) {\n let s, c, i;\n if (typeof e == \"string\") s = n.createTextNode(e);\n else if (c = e.type.replace(\"table:\", \"\"), s = n.createElement(c), X(s, e), e.content)\n for (const [r, u] of e.content.entries()) {\n const S = r === e.content.length - 1;\n v(u, s, n, S);\n }\n a && (c === \"verse\" || t.tagName === \"para\" && o) && (i = T(n, a), a = void 0), c === \"verse\" && typeof e != \"string\" && e.sid !== void 0 && (a = e.sid), d && (c === \"chapter\" || c === \"para\" && o) && (i = h(n, d), d = void 0), c === \"chapter\" && typeof e != \"string\" && e.sid !== void 0 && (d = e.sid);\n const l = t.nodeName === f && (i == null ? void 0 : i.tagName) === \"verse\";\n i && (!o || l) && t.appendChild(i), t.appendChild(s), i && o && !l && t.appendChild(i), o && t.nodeName === f && (a && t.appendChild(T(n, a)), d && t.appendChild(h(n, d)), a = void 0, d = void 0);\n}\nfunction X(e, t) {\n t.marker && (t.type === \"unmatched\" ? e.setAttribute(\"marker\", t.marker) : e.setAttribute(\"style\", t.marker));\n for (const [n, o] of Object.entries(t))\n o && ![\"type\", \"marker\", \"content\"].includes(n) && e.setAttribute(n, o);\n}\nfunction T(e, t) {\n const n = e.createElement(\"verse\");\n return n.setAttribute(\"eid\", t), n;\n}\nfunction h(e, t) {\n const n = e.createElement(\"chapter\");\n return n.setAttribute(\"eid\", t), n;\n}\nconst A = \"$\", P = \".content[\";\nfunction D(e) {\n const t = e.split(P);\n if (t.shift() !== A)\n throw new Error(`indexesFromJsonPath: jsonPath didn't start with '${A}'`);\n return t.map((o) => parseInt(o, 10));\n}\nfunction U(e) {\n return e.reduce((t, n) => `${t}${P}${n}]`, A);\n}\nexport {\n _ as EMPTY_USJ,\n I as EMPTY_USX,\n B as MARKER_OBJECT_PROPS,\n p as USJ_TYPE,\n O as USJ_VERSION,\n f as USX_TYPE,\n N as USX_VERSION,\n M as VALID_BOOK_CODES,\n D as indexesFromUsjJsonPath,\n H as isValidBookCode,\n U as usjJsonPathFromIndexes,\n C as usjToUsxString,\n V as usxStringToUsj\n};\n//# sourceMappingURL=index.js.map\n","\"use strict\"\r\n\r\n// Based on: https://github.com/lodash/lodash/blob/6018350ac10d5ce6a5b7db625140b82aeab804df/.internal/unicodeSize.js\r\n\r\nmodule.exports = () => {\r\n\t// Used to compose unicode character classes.\r\n\tconst astralRange = \"\\\\ud800-\\\\udfff\"\r\n\tconst comboMarksRange = \"\\\\u0300-\\\\u036f\"\r\n\tconst comboHalfMarksRange = \"\\\\ufe20-\\\\ufe2f\"\r\n\tconst comboSymbolsRange = \"\\\\u20d0-\\\\u20ff\"\r\n\tconst comboMarksExtendedRange = \"\\\\u1ab0-\\\\u1aff\"\r\n\tconst comboMarksSupplementRange = \"\\\\u1dc0-\\\\u1dff\"\r\n\tconst comboRange = comboMarksRange + comboHalfMarksRange + comboSymbolsRange + comboMarksExtendedRange + comboMarksSupplementRange\r\n\tconst varRange = \"\\\\ufe0e\\\\ufe0f\"\r\n\tconst familyRange = \"\\\\uD83D\\\\uDC69\\\\uD83C\\\\uDFFB\\\\u200D\\\\uD83C\\\\uDF93\"\r\n\r\n\t// Used to compose unicode capture groups.\r\n\tconst astral = `[${astralRange}]`\r\n\tconst combo = `[${comboRange}]`\r\n\tconst fitz = \"\\\\ud83c[\\\\udffb-\\\\udfff]\"\r\n\tconst modifier = `(?:${combo}|${fitz})`\r\n\tconst nonAstral = `[^${astralRange}]`\r\n\tconst regional = \"(?:\\\\uD83C[\\\\uDDE6-\\\\uDDFF]){2}\"\r\n\tconst surrogatePair = \"[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]\"\r\n\tconst zwj = \"\\\\u200d\"\r\n\tconst blackFlag = \"(?:\\\\ud83c\\\\udff4\\\\udb40\\\\udc67\\\\udb40\\\\udc62\\\\udb40(?:\\\\udc65|\\\\udc73|\\\\udc77)\\\\udb40(?:\\\\udc6e|\\\\udc63|\\\\udc6c)\\\\udb40(?:\\\\udc67|\\\\udc74|\\\\udc73)\\\\udb40\\\\udc7f)\"\r\n\tconst family = `[${familyRange}]`\r\n\r\n\t// Used to compose unicode regexes.\r\n\tconst optModifier = `${modifier}?`\r\n\tconst optVar = `[${varRange}]?`\r\n\tconst optJoin = `(?:${zwj}(?:${[nonAstral, regional, surrogatePair].join(\"|\")})${optVar + optModifier})*`\r\n\tconst seq = optVar + optModifier + optJoin\r\n\tconst nonAstralCombo = `${nonAstral}${combo}?`\r\n\tconst symbol = `(?:${[nonAstralCombo, combo, regional, surrogatePair, astral, family].join(\"|\")})`\r\n\r\n\t// Used to match [String symbols](https://mathiasbynens.be/notes/javascript-unicode).\r\n\treturn new RegExp(`${blackFlag}|${fitz}(?=${fitz})|${symbol + seq}`, \"g\")\r\n}\r\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// @ts-ignore\nvar char_regex_1 = __importDefault(require(\"char-regex\"));\n/**\n * Converts a string to an array of string chars\n * @param {string} str The string to turn into array\n * @returns {string[]}\n */\nfunction toArray(str) {\n if (typeof str !== 'string') {\n throw new Error('A string is expected as input');\n }\n return str.match(char_regex_1.default()) || [];\n}\nexports.toArray = toArray;\n/**\n * Returns the length of a string\n *\n * @export\n * @param {string} str\n * @returns {number}\n */\nfunction length(str) {\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var match = str.match(char_regex_1.default());\n return match === null ? 0 : match.length;\n}\nexports.length = length;\n/**\n * Returns a substring by providing start and end position\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} end End position\n * @returns {string}\n */\nfunction substring(str, begin, end) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n // Even though negative numbers work here, theyre not in the spec\n if (typeof begin !== 'number' || begin < 0) {\n begin = 0;\n }\n if (typeof end === 'number' && end < 0) {\n end = 0;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substring = substring;\n/**\n * Returns a substring by providing start position and length\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} len Desired length\n * @returns {string}\n */\nfunction substr(str, begin, len) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var strLength = length(str);\n // Fix type\n if (typeof begin !== 'number') {\n begin = parseInt(begin, 10);\n }\n // Return zero-length string if got oversize number.\n if (begin >= strLength) {\n return '';\n }\n // Calculating postive version of negative value.\n if (begin < 0) {\n begin += strLength;\n }\n var end;\n if (typeof len === 'undefined') {\n end = strLength;\n }\n else {\n // Fix type\n if (typeof len !== 'number') {\n len = parseInt(len, 10);\n }\n end = len >= 0 ? len + begin : begin;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substr = substr;\n/**\n * Enforces a string to be a certain length by\n * adding or removing characters\n *\n * @export\n * @param {string} str\n * @param {number} [limit=16] Limit\n * @param {string} [padString='#'] The Pad String\n * @param {string} [padPosition='right'] The Pad Position\n * @returns {string}\n */\nfunction limit(str, limit, padString, padPosition) {\n if (limit === void 0) { limit = 16; }\n if (padString === void 0) { padString = '#'; }\n if (padPosition === void 0) { padPosition = 'right'; }\n // Input should be a string, limit should be a number\n if (typeof str !== 'string' || typeof limit !== 'number') {\n throw new Error('Invalid arguments specified');\n }\n // Pad position should be either left or right\n if (['left', 'right'].indexOf(padPosition) === -1) {\n throw new Error('Pad position should be either left or right');\n }\n // Pad string can be anything, we convert it to string\n if (typeof padString !== 'string') {\n padString = String(padString);\n }\n // Calculate string length considering astral code points\n var strLength = length(str);\n if (strLength > limit) {\n return substring(str, 0, limit);\n }\n else if (strLength < limit) {\n var padRepeats = padString.repeat(limit - strLength);\n return padPosition === 'left' ? padRepeats + str : str + padRepeats;\n }\n return str;\n}\nexports.limit = limit;\n/**\n * Returns the index of the first occurrence of a given string\n *\n * @export\n * @param {string} str\n * @param {string} [searchStr] the string to search\n * @param {number} [pos] starting position\n * @returns {number}\n */\nfunction indexOf(str, searchStr, pos) {\n if (pos === void 0) { pos = 0; }\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n if (str === '') {\n if (searchStr === '') {\n return 0;\n }\n return -1;\n }\n // fix type\n pos = Number(pos);\n pos = isNaN(pos) ? 0 : pos;\n searchStr = String(searchStr);\n var strArr = toArray(str);\n if (pos >= strArr.length) {\n if (searchStr === '') {\n return strArr.length;\n }\n return -1;\n }\n if (searchStr === '') {\n return pos;\n }\n var searchArr = toArray(searchStr);\n var finded = false;\n var index;\n for (index = pos; index < strArr.length; index += 1) {\n var searchIndex = 0;\n while (searchIndex < searchArr.length &&\n searchArr[searchIndex] === strArr[index + searchIndex]) {\n searchIndex += 1;\n }\n if (searchIndex === searchArr.length &&\n searchArr[searchIndex - 1] === strArr[index + searchIndex - 1]) {\n finded = true;\n break;\n }\n }\n return finded ? index : -1;\n}\nexports.indexOf = indexOf;\n","/**\n * Ensures that the given input is returned as an array.\n *\n * This function takes a value that might be a single item, an array, or `undefined` and returns it\n * as an array:\n *\n * - If the input is `undefined`, an empty array is returned.\n * - If the input is already an array, it is returned as-is.\n * - If the input is a single item, it is wrapped in an array.\n *\n * @typeParam T - The type of the elements in the array.\n * @param maybeArray - The value that may be a single item, an array, or `undefined`.\n * @returns An array containing the input value(s). If the input is `undefined`, an empty array is\n * returned.\n */\nexport function ensureArray(maybeArray: T | T[] | undefined): T[] {\n if (!maybeArray) return [];\n\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\nexport default ensureArray;\n","import { LocalizeKey } from 'extension-contributions/menus.model';\nimport {\n indexOf as stringzIndexOf,\n length as stringzLength,\n limit as stringzLimit,\n substr as stringzSubstr,\n substring as stringzSubstring,\n toArray as stringzToArray,\n} from 'stringz';\nimport { ensureArray } from './array-util';\nimport { isString } from './util';\n\n/**\n * This function mirrors the `at` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Finds the Unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the character to be returned in range of -length(string) to\n * length(string)\n * @returns New string consisting of the Unicode code point located at the specified offset,\n * undefined if index is out of bounds\n */\nexport function at(string: string, index: number): string | undefined {\n if (index > stringLength(string) || index < -stringLength(string)) return undefined;\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `charAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a new string consisting of the single unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns New string consisting of the Unicode code point located at the specified offset, empty\n * string if index is out of bounds\n */\nexport function charAt(string: string, index: number): string {\n if (index < 0 || index > stringLength(string) - 1) return '';\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `codePointAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a non-negative integer that is the Unicode code point value of the character starting at\n * the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns Non-negative integer representing the code point value of the character at the given\n * index, or undefined if there is no element at that position\n */\nexport function codePointAt(string: string, index: number): number | undefined {\n if (index < 0 || index > stringLength(string) - 1) return undefined;\n return substr(string, index, 1).codePointAt(0);\n}\n\n/**\n * This function mirrors the `endsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether a string ends with the characters of this string.\n *\n * @param string String to search through\n * @param searchString Characters to search for at the end of the string\n * @param endPosition End position where searchString is expected to be found. Default is\n * `length(string)`\n * @returns True if it ends with searchString, false if it does not\n */\nexport function endsWith(\n string: string,\n searchString: string,\n endPosition: number = stringLength(string),\n): boolean {\n const lastIndexOfSearchString = lastIndexOf(string, searchString);\n if (lastIndexOfSearchString === -1) return false;\n if (lastIndexOfSearchString + stringLength(searchString) !== endPosition) return false;\n return true;\n}\n\n/**\n * Get the index of the closest closing curly brace in a string.\n *\n * Note: when escaped, gets the index of the curly brace, not the backslash before it.\n *\n * @param str String to search\n * @param index Index at which to start searching. Inclusive of this index\n * @param escaped Whether to search for an escaped or an unescaped closing curly brace\n * @returns Index of closest closing curly brace or -1 if not found\n */\nfunction indexOfClosestClosingCurlyBrace(str: string, index: number, escaped: boolean) {\n if (index < 0) return -1;\n if (escaped) {\n if (charAt(str, index) === '}' && charAt(str, index - 1) === '\\\\') return index;\n const closeCurlyBraceIndex = indexOf(str, '\\\\}', index);\n return closeCurlyBraceIndex >= 0 ? closeCurlyBraceIndex + 1 : closeCurlyBraceIndex;\n }\n\n let i = index;\n const strLength = stringLength(str);\n while (i < strLength) {\n i = indexOf(str, '}', i);\n\n if (i === -1 || charAt(str, i - 1) !== '\\\\') break;\n\n // Didn't find an un-escaped close brace, so keep looking\n i += 1;\n }\n\n return i >= strLength ? -1 : i;\n}\n\n/**\n * Formats a string into an array of objects (adjacent strings are concatenated in one array entry),\n * replacing `{replacer key}` with the value in the `replacers` at that replacer key (or multiple\n * replacer values if there are multiple in the string). Will also remove \\ before curly braces if\n * curly braces are escaped with a backslash in order to preserve the curly braces. E.g. 'Hi, this\n * is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * Note: React elements can be used as replacer values.\n *\n * @example\n *\n * ```tsx\n *

\n * {formatReplacementStringToArray('Hi {other}! I am {name}.', {\n * other: 'Billy',\n * name: Jim,\n * })}\n *

\n * ```\n *\n * @example\n *\n * ```typescript\n * formatReplacementStringToArray(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carInfo} car. My favorite food is {food}.',\n * { name: ['Bill'], carInfo: { year: 2015, color: 'blue' } }\n * );\n *\n * =>\n *\n * ['Hi, this is ', ['Bill'], '! I like {curly braces}! I have a ', { year: 2015, color: 'blue' }, ' car. My favorite food is food.']\n * ```\n *\n * @param str String to format and break out into an array of objects\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. If the replacer value is a string,\n * it will be concatenated into existing strings in the array. Otherwise, the replacer value will\n * be added as a new entry in the array\n * @returns Array of formatted strings and replaced objects\n */\nexport function formatReplacementStringToArray(\n str: string,\n replacers: { [key: string | number]: T } | object,\n): (string | T)[] {\n /** The compiled list of contents with replacers replaced appropriately */\n const contents: (string | T)[] = [];\n\n // current index in the string as we go through it\n let i = 0;\n // first index of characters to include in the next plain string added to the content\n let nextIntermediateStartIndex = 0;\n\n /**\n * Adds some content to the array of contents that is being built and also add the intermediate\n * string between the last added content and this added content\n *\n * @param newContent Content to add\n * @param newContentIndex Position in string where newContent starts\n * @param newContentLength Length in the string of the representation of this newContent\n */\n function addToContents(\n newContent: string | T,\n newContentIndex: number,\n newContentLength: number,\n ) {\n // Get the string content between the last new content and this new content\n const intermediateContent = substring(str, nextIntermediateStartIndex, newContentIndex);\n\n // If the last item in contents is a string, pull it out and add intermediateContent to\n // it. Otherwise stick with just intermediateContent\n const baseSubstring =\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${intermediateContent}`\n : intermediateContent;\n\n if (isString(newContent)) {\n // If the new content is a string, add it all together\n contents.push(`${baseSubstring}${newContent}`);\n } else {\n // New content is not a string. Add the base string if it exists (don't add an\n // empty string between added contents), then add the new content separately\n if (baseSubstring) contents.push(baseSubstring);\n contents.push(newContent);\n }\n\n // Set the intermediate start index to right after the new content so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = newContentIndex + newContentLength;\n }\n\n const strLength = stringLength(str);\n while (i < strLength) {\n switch (charAt(str, i)) {\n case '{':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped open curly brace. Try to match and replace\n const closeCurlyBraceIndex = indexOfClosestClosingCurlyBrace(str, i, false);\n if (closeCurlyBraceIndex >= 0) {\n // We have matching open and close indices. Try to replace the contents\n const replacerKey = substring(str, i + 1, closeCurlyBraceIndex);\n\n // Replace with the replacer or just remove the curly braces\n const replacerContent =\n replacerKey in replacers\n ? // Just checked that the key is in the object\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n replacers[replacerKey as keyof typeof replacers]\n : replacerKey;\n\n addToContents(replacerContent, i, closeCurlyBraceIndex + 1 - i);\n\n // Put our index at the closing brace to keep processing the string after it\n i = closeCurlyBraceIndex;\n // Set the intermediate start index to right after our closing curly brace so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = closeCurlyBraceIndex + 1;\n } else {\n // This is an unexpected un-escaped open curly brace with no matching closing curly\n // brace. Just ignore, I guess\n }\n } else {\n // This character is an escaped open curly brace. Add the curly brace but skip over the\n // escape backslash\n addToContents('{', i - 1, 2);\n }\n break;\n case '}':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped closing curly brace with no matching open curly\n // brace. Just ignore, I guess\n } else {\n // This character is an escaped closing curly brace. Add the curly brace but skip over\n // the escape backslash\n addToContents('}', i - 1, 2);\n }\n break;\n default:\n // No need to do anything with other characters at this point\n break;\n }\n\n i += 1;\n }\n\n // Now we are through the whole string and need to add the string content after all replacers if\n // there is anything left\n if (nextIntermediateStartIndex < strLength) {\n // Get the string content between the last new content and this new content\n const endContent = substring(str, nextIntermediateStartIndex);\n\n // If the last item in contents is a string, pull it out and add endContent to\n // it. Then put it in the contents array\n contents.push(\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${endContent}`\n : endContent,\n );\n }\n\n return contents;\n}\n\n/**\n * Formats a string, replacing `{replacer key}` with the value in the `replacers` at that replacer\n * key (or multiple replacer values if there are multiple in the string). Will also remove \\ before\n * curly braces if curly braces are escaped with a backslash in order to preserve the curly braces.\n * E.g. 'Hi, this is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly\n * braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * @example\n *\n * ```typescript\n * formatReplacementString(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carColor} car. My favorite food is {food}.',\n * { name: 'Bill', carColor: 'blue' }\n * );\n *\n * =>\n *\n * 'Hi, this is Bill! I like {curly braces}! I have a blue car. My favorite food is food.'\n * ```\n *\n * @param str String to format\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. Will be coerced to strings using\n * `${replacerValue}`\n * @returns Formatted string\n */\nexport function formatReplacementString(\n str: string,\n replacers: { [key: string | number]: string | unknown } | object,\n): string {\n return formatReplacementStringToArray(str, replacers)\n .map((content) => `${content}`)\n .join('');\n}\n\n/**\n * This function mirrors the `includes` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Performs a case-sensitive search to determine if searchString is found in string.\n *\n * @param string String to search through\n * @param searchString String to search for\n * @param position Position within the string to start searching for searchString. Default is `0`\n * @returns True if search string is found, false if it is not\n */\nexport function includes(string: string, searchString: string, position: number = 0): boolean {\n const partialString = substring(string, position);\n const indexOfSearchString = indexOf(partialString, searchString);\n if (indexOfSearchString === -1) return false;\n return true;\n}\n\n/**\n * This function mirrors the `indexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the index of the first occurrence of a given string.\n *\n * @param string String to search through\n * @param searchString The string to search for\n * @param position Start of searching. Default is `0`\n * @returns Index of the first occurrence of a given string\n */\nexport function indexOf(\n string: string,\n searchString: string,\n position: number | undefined = 0,\n): number {\n return stringzIndexOf(string, searchString, position);\n}\n\n/**\n * This function mirrors the `lastIndexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Searches this string and returns the index of the last occurrence of the specified substring.\n *\n * @param string String to search through\n * @param searchString Substring to search for\n * @param position The index at which to begin searching. If omitted, the search begins at the end\n * of the string. Default is `undefined`\n * @returns Index of the last occurrence of searchString found, or -1 if not found.\n */\nexport function lastIndexOf(string: string, searchString: string, position?: number): number {\n let validatedPosition = position === undefined ? stringLength(string) : position;\n\n if (validatedPosition < 0) {\n validatedPosition = 0;\n } else if (validatedPosition >= stringLength(string)) {\n validatedPosition = stringLength(string) - 1;\n }\n\n for (let index = validatedPosition; index >= 0; index--) {\n if (substr(string, index, stringLength(searchString)) === searchString) {\n return index;\n }\n }\n\n return -1;\n}\n\n/**\n * This function mirrors the `length` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes. Since `length` appears to be a\n * reserved keyword, the function was renamed to `stringLength`\n *\n * Returns the length of a string.\n *\n * @param string String to return the length for\n * @returns Number that is length of the starting string\n */\nexport function stringLength(string: string): number {\n return stringzLength(string);\n}\n\n/**\n * This function mirrors the `normalize` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the Unicode Normalization Form of this string.\n *\n * @param string The starting string\n * @param form Form specifying the Unicode Normalization Form. Default is `'NFC'`\n * @returns A string containing the Unicode Normalization Form of the given string.\n */\nexport function normalize(string: string, form: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | 'none'): string {\n const upperCaseForm = form.toUpperCase();\n if (upperCaseForm === 'NONE') {\n return string;\n }\n return string.normalize(upperCaseForm);\n}\n\n/**\n * Compares two strings using an ordinal comparison approach based on the specified collation\n * options. This function uses the built-in `localeCompare` method with the 'en' locale and the\n * provided collation options to compare the strings.\n *\n * @param string1 The first string to compare.\n * @param string2 The second string to compare.\n * @param options Optional. The collation options used for comparison.\n * @returns A number indicating the result of the comparison: - Negative value if string1 precedes\n * string2 in sorting order. - Zero if string1 and string2 are equivalent in sorting order. -\n * Positive value if string1 follows string2 in sorting order.\n */\nexport function ordinalCompare(\n string1: string,\n string2: string,\n options?: Intl.CollatorOptions,\n): number {\n return string1.localeCompare(string2, 'en', options);\n}\n\n/**\n * This function mirrors the `padEnd` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the end of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within targetLength, it will be truncated. Default is `\" \"`\n * @returns String with appropriate padding at the end\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padEnd(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'right');\n}\n\n/**\n * This function mirrors the `padStart` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the start of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within the targetLength, it will be truncated from the end. Default is `\" \"`\n * @returns String with of specified targetLength with padString applied from the start\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padStart(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'left');\n}\n\n// This is a helper function that performs a correction on the slice index to make sure it\n// cannot go out of bounds\nfunction correctSliceIndex(length: number, index: number) {\n if (index > length) return length;\n if (index < -length) return 0;\n if (index < 0) return index + length;\n return index;\n}\n\n/**\n * This function mirrors the `slice` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Extracts a section of this string and returns it as a new string, without modifying the original\n * string.\n *\n * @param string The starting string\n * @param indexStart The index of the first character to include in the returned substring.\n * @param indexEnd The index of the first character to exclude from the returned substring.\n * @returns A new string containing the extracted section of the string.\n */\nexport function slice(string: string, indexStart: number, indexEnd?: number): string {\n const length: number = stringLength(string);\n if (\n indexStart > length ||\n (indexEnd &&\n ((indexStart > indexEnd &&\n !(indexStart >= 0 && indexStart < length && indexEnd < 0 && indexEnd > -length)) ||\n indexEnd < -length))\n )\n return '';\n\n const newStart = correctSliceIndex(length, indexStart);\n const newEnd = indexEnd ? correctSliceIndex(length, indexEnd) : undefined;\n\n return substring(string, newStart, newEnd);\n}\n\n/**\n * This function mirrors the `split` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Takes a pattern and divides the string into an ordered list of substrings by searching for the\n * pattern, puts these substrings into an array, and returns the array.\n *\n * @param string The string to split\n * @param separator The pattern describing where each split should occur\n * @param splitLimit Limit on the number of substrings to be included in the array. Splits the\n * string at each occurrence of specified separator, but stops when limit entries have been placed\n * in the array.\n * @returns An array of strings, split at each point where separator occurs in the starting string.\n * Returns undefined if separator is not found in string.\n */\nexport function split(string: string, separator: string | RegExp, splitLimit?: number): string[] {\n const result: string[] = [];\n\n if (splitLimit !== undefined && splitLimit <= 0) {\n return [string];\n }\n\n if (separator === '') return toArray(string).slice(0, splitLimit);\n\n let regexSeparator = separator;\n if (\n typeof separator === 'string' ||\n (separator instanceof RegExp && !includes(separator.flags, 'g'))\n ) {\n regexSeparator = new RegExp(separator, 'g');\n }\n\n const matches: RegExpMatchArray | null = string.match(regexSeparator);\n\n let currentIndex = 0;\n\n if (!matches) return [string];\n\n for (let index = 0; index < (splitLimit ? splitLimit - 1 : matches.length); index++) {\n const matchIndex = indexOf(string, matches[index], currentIndex);\n const matchLength = stringLength(matches[index]);\n\n result.push(substring(string, currentIndex, matchIndex));\n currentIndex = matchIndex + matchLength;\n\n if (splitLimit !== undefined && result.length === splitLimit) {\n break;\n }\n }\n\n result.push(substring(string, currentIndex));\n\n return result;\n}\n\n/**\n * This function mirrors the `startsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether the string begins with the characters of a specified string, returning true or\n * false as appropriate.\n *\n * @param string String to search through\n * @param searchString The characters to be searched for at the start of this string.\n * @param position The start position at which searchString is expected to be found (the index of\n * searchString's first character). Default is `0`\n * @returns True if the given characters are found at the beginning of the string, including when\n * searchString is an empty string; otherwise, false.\n */\nexport function startsWith(string: string, searchString: string, position: number = 0): boolean {\n const indexOfSearchString = indexOf(string, searchString, position);\n if (indexOfSearchString !== position) return false;\n return true;\n}\n\n/**\n * This function mirrors the `substr` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and length. This function is not exported because it is\n * considered deprecated, however it is still useful as a local helper function.\n *\n * @param string String to be divided\n * @param begin Start position. Default is `Start of string`\n * @param len Length of result. Default is `String length minus start parameter`. Default is `String\n * length minus start parameter`\n * @returns Substring from starting string\n */\nfunction substr(\n string: string,\n begin: number = 0,\n len: number = stringLength(string) - begin,\n): string {\n return stringzSubstr(string, begin, len);\n}\n\n/**\n * This function mirrors the `substring` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and end position.\n *\n * @param string String to be divided\n * @param begin Start position\n * @param end End position. Default is `End of string`\n * @returns Substring from starting string\n */\nexport function substring(\n string: string,\n begin: number,\n end: number = stringLength(string),\n): string {\n return stringzSubstring(string, begin, end);\n}\n\n/**\n * This function mirrors the `toArray` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Converts a string to an array of string characters.\n *\n * @param string String to convert to array\n * @returns An array of characters from the starting string\n */\nexport function toArray(string: string): string[] {\n return stringzToArray(string);\n}\n\n/** Determine whether the string is a `LocalizeKey` meant to be localized in Platform.Bible. */\nexport function isLocalizeKey(str: string): str is LocalizeKey {\n return startsWith(str, '%') && endsWith(str, '%');\n}\n\n/**\n * Escape RegExp special characters.\n *\n * You can also use this to escape a string that is inserted into the middle of a regex, for\n * example, into a character class.\n *\n * All credit to [`escape-string-regexp`](https://www.npmjs.com/package/escape-string-regexp) - this\n * function is simply copied directly from there to allow a common js export\n *\n * @example\n *\n * import escapeStringRegexp from 'platform-bible-utils';\n *\n * const escapedString = escapeStringRegexp('How much $ for a 🦄?');\n * //=> 'How much \\\\$ for a 🦄\\\\?'\n *\n * new RegExp(escapedString);\n */\nexport function escapeStringRegexp(string: string): string {\n if (typeof string !== 'string') {\n throw new TypeError('Expected a string');\n }\n\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions, ensuring that\n * the result is always an array.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - If the input is an array containing nested arrays, it converts each string in the nested arrays\n * into `RegExp` objects.\n * - Ensures that the result is always an array of `RegExp` objects or arrays of `RegExp` objects.\n *\n * @param stringStringMaybeArray - The value to be transformed, which can be a single string, an\n * array of strings or arrays of strings, or `undefined`.\n * @returns An array of `RegExp` objects or arrays of `RegExp` objects. If the input is `undefined`,\n * an empty array is returned.\n */\nexport function transformAndEnsureRegExpRegExpArray(\n stringStringMaybeArray: string | (string | string[])[] | undefined,\n): (RegExp | RegExp[])[] {\n if (!stringStringMaybeArray) return [];\n\n const stringStringArray = ensureArray(stringStringMaybeArray);\n\n const regExpRegExpArray = stringStringArray.map((stringMaybeStringArray: string | string[]) =>\n Array.isArray(stringMaybeStringArray)\n ? stringMaybeStringArray.map((str) => new RegExp(str))\n : new RegExp(stringMaybeStringArray),\n );\n\n return regExpRegExpArray;\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - Ensures that the result is always an array of `RegExp` objects.\n *\n * @param stringMaybeArray - The value to be transformed, which can be a single string, an array of\n * strings, or `undefined`.\n * @returns An array of `RegExp` objects. If the input is `undefined`, an empty array is returned.\n */\nexport function transformAndEnsureRegExpArray(\n stringMaybeArray: string | string[] | undefined,\n): RegExp[] {\n if (!stringMaybeArray) return [];\n\n const stringArray = ensureArray(stringMaybeArray);\n\n const regExpArray = stringArray.map((str: string) => new RegExp(str));\n\n return regExpArray;\n}\n\nconst whiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/;\n/**\n * Determines whether a string contains one or more white space characters and no other characters.\n *\n * This implementation uses [dotnet's `Char.IsWhiteSpace` definition of white\n * space](https://learn.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=net-9.0):\n *\n * ```ts\n * /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: This differs from\n * [`/\\s/.test(ch)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes#:~:text=Matches%20a%20single%20white%20space%20character%2C%20including%20space)\n * (usually considered the determiner of what is white space in JavaScript) in that it does not\n * include ZWNBSP (U+FEFF) but rather includes NEXT LINE (U+0085)\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more white space characters and no other\n * characters, `false` otherwise\n */\nexport function isWhiteSpace(ch: string) {\n return whiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts PascalCase or camelCase string to kebab-case. To detect upper- and lower-case\n * characters, uses `.toUpperCase` and `.toLowerCase` to be locale-independent.\n *\n * Current implementation supports only UTF-16.\n *\n * Thanks to ChatGPT https://chatgpt.com/share/67c8aa44-e054-800c-8068-e1e6630081f7\n */\nexport function toKebabCase(input: string): string {\n let result = '';\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n const isUpper = char === char.toUpperCase() && char !== char.toLowerCase();\n\n if (isUpper) {\n if (i > 0) {\n const prevChar = input[i - 1];\n const isPrevUpper =\n prevChar === prevChar.toUpperCase() && prevChar !== prevChar.toLowerCase();\n\n // If previous is not uppercase, always insert dash.\n if (!isPrevUpper) {\n result += '-';\n } else if (i + 1 < input.length) {\n // Deal with initialisms and acronyms as if they are whole words (\"APIFinder\" -> \"api-finder\")\n // Previous was uppercase; insert dash only if the next character exists and is lowercase.\n const nextChar = input[i + 1];\n const isNextLower =\n nextChar === nextChar.toLowerCase() && nextChar !== nextChar.toUpperCase();\n if (isNextLower) {\n result += '-';\n }\n }\n }\n result += char.toLowerCase();\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n/** This is an internal-only export for testing purposes and should not be used in development */\nexport const testingStringUtils = {\n indexOfClosestClosingCurlyBrace,\n};\n","import { Canon, SerializedVerseRef, VerseRef } from '@sillsdev/scripture';\nimport {\n MarkerContent,\n MarkerObject,\n Usj,\n USJ_TYPE,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { BookInfo, ScrollGroupId } from './scripture.model';\nimport { at, isWhiteSpace, slice, split, startsWith } from '../string-util';\nimport { LocalizeKey } from '../extension-contributions/menus.model';\nimport { isString } from '../util';\n\n/**\n * All marker types that seem to be block-level according to `UsxFragmenter.AppendStartUsfm`. And\n * the `type` for USJ documents' top-level object because that is effectively a block\n *\n * Note: This \"block-level\" means the marker is in its own paragraph (a [CSS\n * Block](https://developer.mozilla.org/en-US/docs/Glossary/Block/CSS)) as opposed to being\n * in-line.\n */\nconst BLOCK_MARKER_TYPES = ['chapter', 'book', 'para', 'row', 'sidebar', USJ_TYPE];\n\nconst ZWSP = '\\u200B';\n\nconst scrBookData: BookInfo[] = [\n { shortName: 'ERR', fullNames: ['ERROR'], chapters: -1 },\n { shortName: 'GEN', fullNames: ['Genesis'], chapters: 50 },\n { shortName: 'EXO', fullNames: ['Exodus'], chapters: 40 },\n { shortName: 'LEV', fullNames: ['Leviticus'], chapters: 27 },\n { shortName: 'NUM', fullNames: ['Numbers'], chapters: 36 },\n { shortName: 'DEU', fullNames: ['Deuteronomy'], chapters: 34 },\n { shortName: 'JOS', fullNames: ['Joshua'], chapters: 24 },\n { shortName: 'JDG', fullNames: ['Judges'], chapters: 21 },\n { shortName: 'RUT', fullNames: ['Ruth'], chapters: 4 },\n { shortName: '1SA', fullNames: ['1 Samuel'], chapters: 31 },\n { shortName: '2SA', fullNames: ['2 Samuel'], chapters: 24 },\n { shortName: '1KI', fullNames: ['1 Kings'], chapters: 22 },\n { shortName: '2KI', fullNames: ['2 Kings'], chapters: 25 },\n { shortName: '1CH', fullNames: ['1 Chronicles'], chapters: 29 },\n { shortName: '2CH', fullNames: ['2 Chronicles'], chapters: 36 },\n { shortName: 'EZR', fullNames: ['Ezra'], chapters: 10 },\n { shortName: 'NEH', fullNames: ['Nehemiah'], chapters: 13 },\n { shortName: 'EST', fullNames: ['Esther'], chapters: 10 },\n { shortName: 'JOB', fullNames: ['Job'], chapters: 42 },\n { shortName: 'PSA', fullNames: ['Psalm', 'Psalms'], chapters: 150 },\n { shortName: 'PRO', fullNames: ['Proverbs'], chapters: 31 },\n { shortName: 'ECC', fullNames: ['Ecclesiastes'], chapters: 12 },\n { shortName: 'SNG', fullNames: ['Song of Solomon', 'Song of Songs'], chapters: 8 },\n { shortName: 'ISA', fullNames: ['Isaiah'], chapters: 66 },\n { shortName: 'JER', fullNames: ['Jeremiah'], chapters: 52 },\n { shortName: 'LAM', fullNames: ['Lamentations'], chapters: 5 },\n { shortName: 'EZK', fullNames: ['Ezekiel'], chapters: 48 },\n { shortName: 'DAN', fullNames: ['Daniel'], chapters: 12 },\n { shortName: 'HOS', fullNames: ['Hosea'], chapters: 14 },\n { shortName: 'JOL', fullNames: ['Joel'], chapters: 3 },\n { shortName: 'AMO', fullNames: ['Amos'], chapters: 9 },\n { shortName: 'OBA', fullNames: ['Obadiah'], chapters: 1 },\n { shortName: 'JON', fullNames: ['Jonah'], chapters: 4 },\n { shortName: 'MIC', fullNames: ['Micah'], chapters: 7 },\n { shortName: 'NAM', fullNames: ['Nahum'], chapters: 3 },\n { shortName: 'HAB', fullNames: ['Habakkuk'], chapters: 3 },\n { shortName: 'ZEP', fullNames: ['Zephaniah'], chapters: 3 },\n { shortName: 'HAG', fullNames: ['Haggai'], chapters: 2 },\n { shortName: 'ZEC', fullNames: ['Zechariah'], chapters: 14 },\n { shortName: 'MAL', fullNames: ['Malachi'], chapters: 4 },\n { shortName: 'MAT', fullNames: ['Matthew'], chapters: 28 },\n { shortName: 'MRK', fullNames: ['Mark'], chapters: 16 },\n { shortName: 'LUK', fullNames: ['Luke'], chapters: 24 },\n { shortName: 'JHN', fullNames: ['John'], chapters: 21 },\n { shortName: 'ACT', fullNames: ['Acts'], chapters: 28 },\n { shortName: 'ROM', fullNames: ['Romans'], chapters: 16 },\n { shortName: '1CO', fullNames: ['1 Corinthians'], chapters: 16 },\n { shortName: '2CO', fullNames: ['2 Corinthians'], chapters: 13 },\n { shortName: 'GAL', fullNames: ['Galatians'], chapters: 6 },\n { shortName: 'EPH', fullNames: ['Ephesians'], chapters: 6 },\n { shortName: 'PHP', fullNames: ['Philippians'], chapters: 4 },\n { shortName: 'COL', fullNames: ['Colossians'], chapters: 4 },\n { shortName: '1TH', fullNames: ['1 Thessalonians'], chapters: 5 },\n { shortName: '2TH', fullNames: ['2 Thessalonians'], chapters: 3 },\n { shortName: '1TI', fullNames: ['1 Timothy'], chapters: 6 },\n { shortName: '2TI', fullNames: ['2 Timothy'], chapters: 4 },\n { shortName: 'TIT', fullNames: ['Titus'], chapters: 3 },\n { shortName: 'PHM', fullNames: ['Philemon'], chapters: 1 },\n { shortName: 'HEB', fullNames: ['Hebrews'], chapters: 13 },\n { shortName: 'JAS', fullNames: ['James'], chapters: 5 },\n { shortName: '1PE', fullNames: ['1 Peter'], chapters: 5 },\n { shortName: '2PE', fullNames: ['2 Peter'], chapters: 3 },\n { shortName: '1JN', fullNames: ['1 John'], chapters: 5 },\n { shortName: '2JN', fullNames: ['2 John'], chapters: 1 },\n { shortName: '3JN', fullNames: ['3 John'], chapters: 1 },\n { shortName: 'JUD', fullNames: ['Jude'], chapters: 1 },\n { shortName: 'REV', fullNames: ['Revelation'], chapters: 22 },\n];\n\n/** The first book number */\nexport const FIRST_SCR_BOOK_NUM = 1;\n/** The last book number */\nexport const LAST_SCR_BOOK_NUM = scrBookData.length - 1;\n/** The first chapter number */\nexport const FIRST_SCR_CHAPTER_NUM = 1;\n/** The first verse number */\nexport const FIRST_SCR_VERSE_NUM = 1;\n\n/** The default Scripture reference, representing the first chapter and verse of the first book. */\nexport const defaultScrRef: SerializedVerseRef = {\n book: 'GEN',\n chapterNum: 1,\n verseNum: 1,\n};\n\n/**\n * Retrieves the number of chapters for a given book number.\n *\n * @param bookNum The number representing the book.\n * @returns The number of chapters in the book, or -1 if the book number is invalid.\n */\nexport const getChaptersForBook = (bookNum: number): number => {\n return scrBookData[bookNum]?.chapters ?? -1;\n};\n\n/**\n * Adjusts the book of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose book is to be adjusted.\n * @param offset The number of books to offset the current book by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted book. The chapter and verse numbers are\n * reset to 1. If the resulting book number exceeds the bounds of available books, it is clamped\n * to the nearest valid book.\n */\nexport const offsetBook = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n book: Canon.bookNumberToId(\n Math.max(\n FIRST_SCR_BOOK_NUM,\n Math.min(Canon.bookIdToNumber(scrRef.book) + offset, LAST_SCR_BOOK_NUM),\n ),\n ),\n chapterNum: 1,\n verseNum: 1,\n});\n\n/**\n * Adjusts the chapter of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose chapter is to be adjusted.\n * @param offset The number of chapters to offset the current chapter by. Positive values move\n * forward, negative values move backward.\n * @returns A new Scripture reference with the adjusted chapter. The verse number is reset to 1. The\n * chapter number is clamped to stay within valid bounds for the book.\n */\nexport const offsetChapter = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n chapterNum: Math.min(\n Math.max(FIRST_SCR_CHAPTER_NUM, scrRef.chapterNum + offset),\n getChaptersForBook(Canon.bookIdToNumber(scrRef.book)),\n ),\n verseNum: 1,\n});\n\n/**\n * Adjusts the verse of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose verse is to be adjusted.\n * @param offset The number of verses to offset the current verse by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted verse. The verse number is clamped to stay\n * within valid bounds for the chapter.\n */\nexport const offsetVerse = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n verseNum: Math.max(FIRST_SCR_VERSE_NUM, scrRef.verseNum + offset),\n});\n\n/**\n * https://github.com/ubsicap/Paratext/blob/master/ParatextData/SILScriptureExtensions.cs#L72\n *\n * Convert book number to a localized Id (a short description of the book). This should be used\n * whenever a book ID (short code) is shown to the user. It is primarily needed for people who do\n * not read Roman script well and need to have books identified in a alternate script (e.g. Chinese\n * or Russian)\n *\n * @param bookNumber\n * @param localizationLanguage In BCP 47 format\n * @param getLocalizedString Function that provides the localized versions of the book ids and names\n * asynchronously.\n * @returns\n */\nexport async function getLocalizedIdFromBookNumber(\n bookNumber: number,\n localizationLanguage: string,\n getLocalizedString: (item: {\n localizeKey: string;\n languagesToSearch?: string[];\n }) => Promise,\n) {\n const id = Canon.bookNumberToId(bookNumber);\n\n if (!startsWith(Intl.getCanonicalLocales(localizationLanguage)[0], 'zh'))\n return getLocalizedString({\n localizeKey: `LocalizedId.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n\n // For Chinese the normal book name is already fairly short.\n const bookName = await getLocalizedString({\n localizeKey: `Book.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n const parts = split(bookName, '-');\n // some entries had a second name inside ideographic parenthesis\n const parts2 = split(parts[0], '\\xff08');\n const retVal = parts2[0].trim();\n return retVal;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer, without considering the\n * verse.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCC(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum).BBBCCC;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCCVVV(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum)\n .BBBCCCVVV;\n}\n\n/**\n * Compares two Scripture references canonically.\n *\n * @param scrRef1 The first Scripture reference to compare.\n * @param scrRef2 The second Scripture reference to compare.\n * @returns A number indicating the result of the comparison: - Negative value if scrRef1 precedes\n * scrRef2 in sorting order. - Zero if scrRef1 and scrRef2 are equivalent in sorting order. -\n * Positive value if scrRef1 follows scrRef2 in sorting order.\n */\nexport function compareScrRefs(scrRef1: SerializedVerseRef, scrRef2: SerializedVerseRef): number {\n // TODO: consider edge cases for invalid references (current implementation should suffice for\n // all but the most extreme cases)\n return scrRefToBBBCCCVVV(scrRef1) - scrRefToBBBCCCVVV(scrRef2);\n}\n\n/** Get the localized string key for a given scroll group Id (or no scroll group if `undefined`) */\nexport function getLocalizeKeyForScrollGroupId(\n scrollGroupId: ScrollGroupId | undefined | 'undefined',\n): LocalizeKey {\n return `%scrollGroup_${scrollGroupId}%`;\n}\n\n/**\n * Gets a list of localized string keys for provided scroll group Ids. Uses\n * {@link getLocalizeKeyForScrollGroupId} internally\n *\n * @example\n *\n * ```typescript\n * getLocalizeKeysForScrollGroupIds([undefined, 0, 1, 2, 3, 4]);\n * // Gives localized string keys for the provided scroll group ids in an array\n * ```\n *\n * @param scrollGroupIds Scroll group ids to include\n * @returns List of localized string keys for scroll group Ids\n */\nexport function getLocalizeKeysForScrollGroupIds(scrollGroupIds: (ScrollGroupId | undefined)[]) {\n return scrollGroupIds.map((scrollGroupId) => getLocalizeKeyForScrollGroupId(scrollGroupId));\n}\n\n/**\n * Formats a Scripture reference.\n *\n * @param scrRef The Scripture reference to format.\n * @param optionOrLocalizedBookName Either 'id' (the default) to format using the \"standard\" (as\n * defined by SIL/UBS) 3-letter book ID, 'English' to format using the English book name spelled\n * out, or some other string (e.g., a localized book name, vernacular abbreviation, FCBH book id,\n * etc.) to use.\n * @param chapterVerseSeparator The character used to separate the chapter number from the verse\n * number. Default is a colon (:). Note: More than one character is allowed.\n * @param bookChapterSeparator The character used to separate the book from the chapter number.\n * Default is a single space. Note: More than one character is allowed.\n * @returns The formatted reference.\n */\nexport function formatScrRef(\n scrRef: SerializedVerseRef,\n optionOrLocalizedBookName?: 'id' | 'English' | string,\n chapterVerseSeparator?: string,\n bookChapterSeparator?: string,\n): string {\n let book: string;\n switch (optionOrLocalizedBookName ?? 'id') {\n case 'English':\n book = Canon.bookIdToEnglishName(scrRef.book);\n break;\n case 'id':\n book = scrRef.book;\n break;\n default:\n // We already dealt with undefined about in the switch, but TS is getting confused.\n book = optionOrLocalizedBookName ?? '';\n break;\n }\n return `${book}${bookChapterSeparator ?? ' '}${scrRef.chapterNum}${chapterVerseSeparator ?? ':'}${scrRef.verseNum}`;\n}\n\n/**\n * Represents the major sections of the Bible and extra materials. Used for grouping and filtering\n * books in the book selector.\n */\nexport enum Section {\n /** Old Testament books (Genesis through Malachi) */\n OT = 'OT',\n /** New Testament books (Matthew through Revelation) */\n NT = 'NT',\n /** Deuterocanonical books (e.g. Tobit, Judith, 1-2 Maccabees) */\n DC = 'DC',\n /** Additional materials not part of the biblical canon (e.g. XXA, XXB etc.) */\n Extra = 'Extra',\n}\n\n/**\n * Determines which section a book belongs to based on its ID\n *\n * @param bookId The ID of the book (e.g., 'GEN', 'MAT')\n * @returns The section (OT, NT, DC, or Extra) that the book belongs to\n * @throws Error if the book ID is not recognized or cannot be categorized\n */\nexport const getSectionForBook = (bookId: string): Section => {\n if (Canon.isBookOT(bookId)) return Section.OT;\n if (Canon.isBookNT(bookId)) return Section.NT;\n if (Canon.isBookDC(bookId)) return Section.DC;\n if (Canon.isExtraMaterial(bookId)) return Section.Extra;\n\n throw new Error(`Unknown section for book: ${bookId}`);\n};\n\n// #region white space functions\n\nconst nonSemanticWhiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u200B\\u0085]+$/;\n/**\n * Determines whether a string contains one or more \"non-meaningful\" white space characters\n * according to `ParatextData.dll` and no other characters.\n *\n * \"Non-meaningful\" white space according to `ParatextData.dll` is white space (according to\n * {@link isWhiteSpace}) other than IDEOGRAPHIC SPACE (U+3000) and also includes ZWSP (U+200B)\n *\n * This function is a direct translation of `UsfmToken.IsNonSemanticWhiteSpace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more \"non-meaningful\" white space characters and\n * no other characters, `false` otherwise\n */\nfunction isNonSemanticWhiteSpace(ch: string) {\n return nonSemanticWhiteSpaceRegex.test(ch);\n}\n\n// Note Zero-width joiner is at the start because eslint thinks we're trying to test for joined\n// characters if it's in the middle. https://eslint.org/docs/latest/rules/no-misleading-character-class\nconst invisibleCharOrWhiteSpaceRegex =\n /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/;\n/**\n * Determines whether a string contains one or more Paratext-9-selectable invisible characters or\n * white space characters and no other characters.\n *\n * Paratext-9-selectable invisible characters or white space characters are characters listed in\n * [Paratext 9's \"Whitespace and invisible characters\n * drop-down\"](https://paratext.myjetbrains.com/youtrack/issue/PTX-23623) that the user can insert\n * into the text:\n *\n * ```ts\n * // Zero-width joiner, em space, en space, space, no-break space, narrow no-break space,\n * // thin space, hair space, ideographic space, zero-width space, zero-width non-joiner,\n * // word joiner, left-to-right mark, right-to-left mark\n * /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: more white space characters are supported in Paratext 9 but are not listed in this\n * dropdown. See {@link isWhiteSpace} for more information.\n *\n * This function is a direct translation of `CharExtensions.IsInvisibleCharOrWhitespace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more Paratext-9-selectable invisible characters\n * or white space characters and no other characters, `false` otherwise\n */\nfunction isParatextSelectableInvisibleCharOrWhiteSpace(ch: string) {\n return invisibleCharOrWhiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts all control characters, carriage returns, and tabs into spaces and then strips duplicate\n * spaces.\n *\n * This is mainly intended for use with individual Scripture strings in USFM, USX, USJ, etc. format.\n * It is not intended to implement the [USFM white space definition or reduction\n * rules](https://docs.usfm.bible/usfm/3.1/whitespace.html) but strictly follows Paratext 9's white\n * space rules. It is generally best suited to normalizing spaces within a Scripture marker as it\n * removes all newlines.\n *\n * This function is a direct translation of `UsfmToken.RegularizeSpaces` from `ParatextData.dll`\n */\nexport function normalizeScriptureSpaces(str: string): string {\n let result = '';\n let lastCharWasSpace = false;\n // Initialized to placeholder previous character\n let prevCh = '\\0';\n for (let i = 0; i < str.length; i += 1) {\n const ch = str[i];\n // Control characters, CR/LF, and TAB become spaces\n if (ch.charCodeAt(0) < 32) {\n if (!lastCharWasSpace) result += ' ';\n lastCharWasSpace = true;\n } else if (\n !lastCharWasSpace &&\n ch === ZWSP &&\n i + 1 < str.length &&\n isNonSemanticWhiteSpace(str[i + 1])\n ) {\n // ZWSP is redundant if followed by a space\n } else if (isNonSemanticWhiteSpace(ch)) {\n // Keep other kinds of spaces\n if (!lastCharWasSpace) result += ch;\n lastCharWasSpace = true;\n } else if (isParatextSelectableInvisibleCharOrWhiteSpace(ch) && prevCh === ch) {\n // If the char is a whitespace or invisible char that has not already been handled and is a\n // duplicate, remove the duplicate\n } else {\n result += ch;\n lastCharWasSpace = false;\n }\n\n prevCh = ch;\n }\n\n return result;\n}\n\n/**\n * Determines whether the array of marker contents is \"empty\" meaning it is undefined, is an empty\n * array, or has just `undefined` or `''` in it\n *\n * Paratext passed up \"\\va \\va*\" which had no content array coming in translated to USJ, but the\n * editor put a content array with an empty string. So this will help them be considered equal.\n */\nfunction isUsjContentEmpty(content: MarkerContent[] | undefined) {\n if (!content) return true;\n if (content.length === 0) return true;\n return content.length === 1 && (content[0] === undefined || content[0] === '');\n}\n\n/**\n * Determines if the content object is the final child of a parent that is a block-level marker.\n *\n * We do not need to walk up the ancestors to the _closest_ block marker because spaces are\n * preserved at the end of in-line markers even at the end of a paragraph. We just need to know if\n * the parent is a block marker because space at the end of a block marker is not preserved.\n *\n * @param contentObject USJ document or marker to check\n * @param parent Parent object of `contentObject`. If `contentObject` is a USJ document, this should\n * be `undefined`.\n * @returns `true` if `contentObject` is the final child of the closest block-level marker; `false`\n * otherwise\n */\nfunction isAtEndOfBlockMarker(\n contentObject: MarkerContent | Usj,\n parent: MarkerObject | Usj | undefined,\n) {\n if (!parent) return false;\n // If the parent is not a block-level marker, the content object is not at the end of a block-level marker\n if (!BLOCK_MARKER_TYPES.includes(parent.type)) return false;\n\n if (!parent.content)\n throw new Error(\n `Parent ${JSON.stringify(parent)} of ${JSON.stringify(contentObject)} does not have a content array! This should not happen!`,\n );\n // If the content object is not the last in its parent, it is not at the end of a block-level marker\n if (contentObject !== parent.content[parent.content.length - 1]) return false;\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n *\n * @param a First USJ document or marker to compare\n * @param aParent Parent object of `a`. If `a` is a USJ document, this should be `undefined`.\n * @param b Second USJ document or marker to compare\n * @param bParent Parent object of `b`. If `b` is a USJ document, this should be `undefined`.\n */\nfunction areUsjContentsEqualExceptWhitespaceInternal(\n a: MarkerContent | Usj | undefined,\n aParent: MarkerObject | Usj | undefined,\n b: MarkerContent | Usj | undefined,\n bParent: MarkerObject | Usj | undefined,\n) {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aIsString = isString(a);\n const bIsString = isString(b);\n if (aIsString && bIsString) {\n const aNormalized = normalizeScriptureSpaces(a);\n const bNormalized = normalizeScriptureSpaces(b);\n // Check to see if their regularized forms are equal. If so, they're equal. If not, they may still\n // be equal if they are at the end of a block-level marker and the only difference is space at the end.\n // If at the end of a block-level marker with space at the end, take off the final space and compare again\n if (aNormalized !== bNormalized) {\n // If neither ends in whitespace, they are not equal\n if (!isWhiteSpace(at(aNormalized, -1) ?? '') && !isWhiteSpace(at(bNormalized, -1) ?? ''))\n return false;\n\n // If either is not at the end of a block-level marker, they are not equal\n if (!isAtEndOfBlockMarker(a, aParent)) return false;\n if (!isAtEndOfBlockMarker(b, bParent)) return false;\n\n // Trim the end of each string\n let aTrimmed = aNormalized;\n while (isWhiteSpace(at(aTrimmed, -1) ?? '')) aTrimmed = slice(aTrimmed, 0, -1);\n let bTrimmed = bNormalized;\n while (isWhiteSpace(at(bTrimmed, -1) ?? '')) bTrimmed = slice(bTrimmed, 0, -1);\n // If they are not equal after trimming, they are not equal\n if (aTrimmed !== bTrimmed) return false;\n }\n } else if (!aIsString && !bIsString) {\n // We have determined they are not strings, so they must be objects with various simple properties and possibly a `content` array\n const aObject: MarkerObject | Usj = a;\n const bObject: MarkerObject | Usj = b;\n // Check if all properties are present and equal. We will check `content` separately\n // Seems Object.keys doesn't support proper key typing? Asserting to the key types\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const aKeys = Object.keys(aObject).filter(\n (key) => key !== 'content',\n ) as (keyof typeof aObject)[];\n if (aKeys.length !== Object.keys(bObject).filter((key) => key !== 'content').length)\n return false;\n if (aKeys.some((key) => !(key in bObject) || aObject[key] !== bObject[key])) return false;\n\n // Check that both `content`s are equal\n const isAContentEmpty = isUsjContentEmpty(aObject.content);\n const isBContentEmpty = isUsjContentEmpty(bObject.content);\n // If one is empty and the other is not, they are not equal\n if (isAContentEmpty !== isBContentEmpty) return false;\n // If both are empty, they are equal. If neither is empty, do more testing\n if (!isAContentEmpty && !isBContentEmpty) {\n // Although TypeScript doesn't realize `!isUsjContentEmpty(a)` means a is an array, we know\n // they are both arrays, so we can access the content with a bang.\n /* eslint-disable no-type-assertion/no-type-assertion */\n let aContent: MarkerContent[] = aObject.content!;\n let bContent: MarkerContent[] = bObject.content!;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const aLast = aContent[aContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(aObject.type) && isString(aLast) && isWhiteSpace(aLast))\n aContent = aContent.slice(0, -1);\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const bLast = bContent[bContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(bObject.type) && isString(bLast) && isWhiteSpace(bLast))\n bContent = bContent.slice(0, -1);\n\n if (aContent.length !== bContent.length) return false;\n for (let i = 0; i < aContent.length; i += 1) {\n if (\n !areUsjContentsEqualExceptWhitespaceInternal(aContent[i], aObject, bContent[i], bObject)\n )\n return false;\n }\n }\n } else {\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n */\nexport function areUsjContentsEqualExceptWhitespace(a: Usj | undefined, b: Usj | undefined) {\n return areUsjContentsEqualExceptWhitespaceInternal(a, undefined, b, undefined);\n}\n\n// #endregion\n","/** Function to run to dispose of something. Returns true if successfully unsubscribed */\nexport type Unsubscriber = () => boolean;\n\n/**\n * Returns an Unsubscriber function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers All unsubscribers to aggregate into one unsubscriber\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscribers = (unsubscribers: Unsubscriber[]): Unsubscriber => {\n return (...args) => {\n // Run the unsubscriber for each handler\n const unsubs = unsubscribers.map((unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return unsubs.every((success) => success);\n };\n};\n\n/**\n * Function to run to dispose of something that runs asynchronously. The promise resolves to true if\n * successfully unsubscribed\n */\nexport type UnsubscriberAsync = () => Promise;\n\n/**\n * Returns an UnsubscriberAsync function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers - All unsubscribers to aggregate into one unsubscriber.\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscriberAsyncs = (\n unsubscribers: (UnsubscriberAsync | Unsubscriber)[],\n): UnsubscriberAsync => {\n return async (...args) => {\n // Run the unsubscriber for each handler\n const unsubPromises = unsubscribers.map(async (unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return (await Promise.all(unsubPromises)).every((success) => success);\n };\n};\n","import {\n Usj,\n type MarkerContent,\n type MarkerObject,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { MarkersMap } from './markers-maps/markers-map-3.0.model';\n\n/** USJ content node type for a book */\nexport const BOOK_TYPE = 'book';\n\n/** USJ content node type for a chapter */\nexport const CHAPTER_TYPE = 'chapter';\n\n/** USJ content node type for a verse */\nexport const VERSE_TYPE = 'verse';\n\n/** 3-character code that indicates there is no known book */\nexport const NO_BOOK_ID = '***';\n\n/**\n * Represents a book, chapter, verse, and offset\n *\n * @deprecated 23 October 2025. Use {@link UsfmVerseLocation} or {@link UsfmVerseRefVerseLocation}\n * instead.\n */\nexport type VerseRefOffset = {\n verseRef: SerializedVerseRef;\n offset: number;\n};\n\n// #region Serializable USFM locations\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. If only a verse ref is provided, the offset is assumed to be 0.\n *\n * The USJ representation of the positions represented by this type are {@link UsjLocation}. Both are\n * absolute verse reference locations.\n *\n * {@link UsjDocumentLocation} also represents positions of this type, but those locations are\n * relative to a specific USJ document rather than being absolute verse reference locations like\n * this type. The closest equivalent concept in USFM to {@link UsjDocumentLocation} is a string\n * character index in a USFM document; such an index is relative to a specific USFM document rather\n * than indicating an absolute position in a Scripture text.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsfmScrRefVerseLocation} for details.\n */\nexport type UsfmVerseLocation =\n | UsfmVerseRefVerseLocation\n | SerializedVerseRef\n | UsfmScrRefVerseLocation;\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM\n */\nexport type UsfmVerseRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n verseRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. This uses `scrRef` instead of `verseRef` for backwards compatibility.\n *\n * @deprecated 13 November 2025. Use {@link UsfmVerseLocation} instead.\n */\nexport type UsfmScrRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n scrRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n// #endregion Serializable USFM locations\n\n// #region Serializable absolute USJ locations\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from either the start of the book or the chapter\n * depending on the type of location used.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the following USJ documents:\n *\n * - {@link UsjBookLocation} - a USJ document that contains the entire specified book. The first\n * content entry of the top-level `USJ` marker is the `id` marker of the book.\n * - {@link UsjChapterLocation} - a USJ document that contains only the specified chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjLocation =\n | UsjChapterLocation\n | UsjBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the book specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains the entire specified book. The first content entry of the top-level `USJ` marker is the\n * `id` marker of the book.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjBookLocation =\n | UsjVerseRefBookLocation\n | UsjFlatBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the chapter specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains only the specified chapter in the specified book. If the chapter number is 1, the first\n * content entry of the top-level `USJ` marker is the `id` marker of the book because the intro\n * content before chapter 1 is part of chapter 1. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsjFlatTextChapterLocation} for details. Also note that {@link UsjFlatTextChapterLocation}\n * can only be a marker- or text-based location and will _not_ follow the generic type specified as\n * `TDocumentLocation`.\n */\nexport type UsjChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> =\n | UsjVerseRefChapterLocation\n | UsjFlatChapterLocation\n | UsjFlatTextChapterLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified in the verse ref. The rest of the verse ref\n * is meaningless and can be disregarded.\n */\nexport type UsjVerseRefBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * Defaults to 'chapter' (see {@link UsjVerseRefChapterLocation})\n */\n granularity: 'book';\n /** USJ document location specifying where in the book the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the chapter specified in the verse ref. The rest of the verse\n * ref is meaningless and can be disregarded.\n */\nexport type UsjVerseRefChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which chapter in which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * Defaults to 'chapter' (can alternatively be 'book'; {@link UsjVerseRefBookLocation})\n */\n granularity?: 'chapter';\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified.\n */\nexport type UsjFlatBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID, chapter number, and location in USJ space that point to a specific location in USJ.\n * The location in USJ space starts from the start of the chapter specified.\n */\nexport type UsjFlatChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = UsjFlatBookLocation & {\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n};\n\n/**\n * A book ID, chapter number, and text location or beginning of marker location in USJ space that\n * point to a specific location in USJ. The location in USJ space starts from the start of the\n * chapter specified. This can only represent the beginning of a marker or a location in the USJ\n * document's text content.\n *\n * @deprecated 13 November 2025. This type of location is not generic enough to support all\n * positions we need to be able to represent in USJ space. Use other forms of\n * {@link UsjChapterLocation} instead.\n */\nexport type UsjFlatTextChapterLocation = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n} & ((UsjMarkerLocation & { offset?: undefined }) | UsjTextContentLocation);\n\n// #endregion Serializable absolute USJ locations\n\n// #region Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * JSON path to a {@link MarkerObject}, {@link Usj}, or text content string in the current USJ\n * document.\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type ContentJsonPath =\n | ''\n | `$`\n | `$.content[${number}]`\n | `$.content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]`;\n\n/**\n * JSON path to the `marker` or an attribute on a {@link MarkerObject} or {@link Usj} in the current\n * USJ document. Note that it seems you must use `['bracket notation']` rather than `.dot` notation\n * if there are symbols other than underscore in the property name\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type PropertyJsonPath =\n | ''\n | `$.${string}`\n | `$['${string}']`\n | `$.content[${number}].${string}`\n | `$.content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]['${string}']`;\n\n/**\n * A JSONPath query to a {@link MarkerContent}, {@link Usj}, or property within a USJ document and\n * additional information that point to a specific location in that USJ document.\n *\n * This type does not include a verse reference because the JSONPath is relative to a specific USJ\n * document; that USJ document may have a book, a chapter, or something else in it. Use\n * {@link UsjLocation} to specify which USJ document this location is relative to, making the\n * location an absolute verse reference location. The closest equivalent concept in USFM to this\n * relative document location is a string character index in a USFM document; such an index is\n * relative to a specific USFM document rather than indicating an absolute position in a Scripture\n * text.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types:\n *\n * - The second slash in `optbreak`'s USFM representation `//` (literally not representable)\n * - Nested marker prefix on opening markers like `+` for character markers (literally not\n * representable)\n * - The bar `|` that indicates the start of closing marker attributes (no official representation)\n * - The equals sign for closing marker attributes (no official representation)\n * - The quotes around closing marker attribute values (no official representation)\n * - The space between closing marker attributes (no official representation)\n *\n * Also note that the following types do not specify a concrete location that is actually in the USJ\n * document but represent a USFM location relative to the most similar thing in USJ that there is:\n *\n * - {@link UsjClosingMarkerLocation} - there are no distinct closing objects in JSON; there is a\n * common syntax for closing every object, but it is only one character and is on every single\n * object as opposed to USFM closing markers which are multiple characters long and are only\n * sometimes present.\n * - {@link UsjAttributeKeyLocation} - when the attribute whose key is being pointed to is an attribute\n * marker in USFM, the `keyOffset` does not apply to the USJ attribute name (e.g. `altnumber`) but\n * to the USFM attribute marker name (e.g. `ca`).\n * - {@link UsjAttributeMarkerLocation} - attribute markers are just properties in JSON; they do not\n * have their own object such that they would have an opening that can be pointed to in the JSON\n * like they have their own opening in USFM.\n * - {@link UsjClosingAttributeMarkerLocation} - attribute markers are just properties in JSON, plus\n * they are in the same situation as {@link UsjClosingMarkerLocation} as detailed above.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n */\nexport type UsjDocumentLocation =\n | UsjMarkerLocation\n | UsjClosingMarkerLocation\n | UsjTextContentLocation\n | UsjPropertyValueLocation\n | UsjAttributeKeyLocation\n | UsjAttributeMarkerLocation\n | UsjClosingAttributeMarkerLocation;\n\n/**\n * A JSONPath query to a {@link MarkerObject} or {@link Usj} node. Indicates the very beginning of\n * that marker (at the backslash in USFM).\n */\nexport type UsjMarkerLocation = {\n /** JSON path to the marker object the location is pointing to. */\n jsonPath: ContentJsonPath;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of a\n * {@link MarkerObject} or {@link Usj} node.\n */\nexport type UsjClosingMarkerLocation = {\n /**\n * JSON path to the marker object whose closing marker the location is pointing to. The offset\n * applies to the closing marker representation of that marker (for example, `\\nd*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation.\n */\n closingMarkerOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a text content string in a {@link MarkerObject.content}\n * array.\n */\nexport type UsjTextContentLocation = {\n /**\n * JSON path to the text content string the location is pointing to. The offset applies to this\n * text string.\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the text content string where this location is pointing. The location is\n * at this offset within the text content string.\n */\n offset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a property (`marker` or an attribute) value string in a\n * {@link MarkerObject} or {@link Usj}. The property cannot be `type` because `type`'s value has no\n * representation in USFM.\n *\n * To represent a location in an attribute's key, use {@link UsjAttributeKeyLocation}.\n */\nexport type UsjPropertyValueLocation = {\n /**\n * JSON path to the property the location is pointing to. The offset applies to this property's\n * value string.\n */\n jsonPath: PropertyJsonPath;\n /**\n * The character index in the property's value string where this location is pointing. The\n * location is at this offset within the property's value string.\n */\n propertyOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in an attribute key string in a {@link MarkerObject} or\n * {@link Usj}. The property cannot be `type` or `marker` because these properties' keys have no\n * representation in USFM. The property also cannot be any special attribute whose key doesn't have\n * a text representation in USFM like default attribute, leading attribute, text content attribute\n *\n * To represent a location in an attribute's value, use {@link UsjPropertyValueLocation}.\n */\nexport type UsjAttributeKeyLocation = {\n /**\n * JSON path to the marker whose attribute key the location is pointing to. The offset applies to\n * this attribute's key string unless the attribute is an attribute marker in USFM.\n */\n jsonPath: ContentJsonPath;\n /** Attribute name on the marker object whose key this location is pointing to. */\n keyName: string;\n /**\n * The character index in the attribute's key string where this location is pointing.\n *\n * If the attribute is an attribute marker in USFM, the location is at this offset within the\n * marker name for this attribute marker (for example, `c`'s `altnumber` attribute has attribute\n * marker `ca`, so its `keyOffset` applies to `ca`).\n *\n * If the attribute is not an attribute marker in USFM, the location is at this offset within the\n * attribute's key string.\n */\n keyOffset: number;\n};\n\n/**\n * A JSONPath query to an attribute marker derived from an attribute on a {@link MarkerObject} or\n * {@link Usj}. Indicates the very beginning of that marker (at the backslash in USFM).\n */\nexport type UsjAttributeMarkerLocation = {\n /** JSON path to the marker whose attribute marker the location is pointing to. */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of an attribute marker\n * derived from an attribute on a {@link MarkerObject} or {@link Usj}.\n */\nexport type UsjClosingAttributeMarkerLocation = {\n /**\n * JSON path to the marker whose attribute marker's closing marker the location is pointing to.\n * The offset applies to the closing marker representation of that attribute marker (for example,\n * `\\ca*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation of the attribute marker.\n */\n keyClosingMarkerOffset: number;\n};\n\n// #endregion Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * Node in a USJ object (including the top-level Usj object) and its location in the document. You\n * must make sure you only add `node`s that correspond to the appropriate type of\n * `UsjDocumentLocation` (e.g. if `documentLocation` is a {@link UsjTextContentLocation}, `node` must\n * be a text content string)\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjNodeAndDocumentLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n node: TDocumentLocation extends UsjTextContentLocation ? string : MarkerObject | Usj;\n documentLocation: TDocumentLocation;\n};\n\n/** Result of a search for text within a USJ object */\nexport type UsjSearchResult = {\n /**\n * Beginning location in the USJ document of the search result. The text is inclusive of this\n * location, meaning this is the location of the first character of the found text\n */\n start: UsjNodeAndDocumentLocation;\n /**\n * Ending location in the USJ document of the search result. The text is exclusive of this\n * location, meaning this is the location right after the last character of the found text\n */\n end: UsjNodeAndDocumentLocation;\n /**\n * The matching Scripture text (not USFM string) that was found between the start and end\n * locations\n */\n text: string;\n};\n\n/**\n * Set of options to provide to `UsjReaderWriter`'s constructor to customize how the reading and\n * writing works\n */\nexport type UsjReaderWriterOptions = {\n /**\n * A map of all USFM/USX/USJ markers and some information about them. Used for translating between\n * the formats\n *\n * Defaults to trying to use a built-in markers map that matches the version of the USJ passed in.\n *\n * Currently supported built-in USFM versions:\n *\n * - 3.0/3.0.x\n */\n markersMap?: MarkersMap;\n /**\n * Whether the transformations should preserve invisible characters as in Paratext 9\n * (`ScrText.Settings.AllowInvisibleChars`).\n *\n * Defaults to `false`\n */\n shouldAllowInvisibleCharacters?: boolean;\n};\n\n/** Utilities for reading from and writing to `Usj` objects */\nexport interface IUsjReaderWriter {\n /**\n * Return a copy of text following a given starting point\n *\n * @param start Point where text extraction will start\n * @param desiredLength Length of text to extract from this USJ data\n */\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string;\n /**\n * Return a copy of text between two points\n *\n * @param start Point where text extraction will start\n * @param end Point where text extraction will end\n * @param maxLength Maximum length of string to return (defaults to 100)\n * @returns Text between the two points, capped at length `maxLength`\n */\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number,\n ): string;\n /**\n * Given a starting point, find the next location in this USJ data that matches the given text\n *\n * @param start Point where the search for `text` will start\n * @param text Text to find. Note you can use an empty string to find the closest text in or after\n * the `start` point.\n * @param maxTextLengthToSearch Maximum length of text to search before stopping (default is 1000)\n * @returns Object containing the USJ node where `text` begins (it might be split across nodes),\n * offset within that node that indicates where `text` begins, and a JSONPath string that\n * indicates the location of the of USJ node within `usj`. Note that if the USJ node returned is\n * an object, it is the same object that is within this USJ data. So if you change it, you are\n * changing this USJ data.\n */\n findNextLocationOfMatchingText(\n start: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number,\n ): UsjNodeAndDocumentLocation | undefined;\n /** Find the first value matching the given JSONPath query within this USJ data */\n findSingleValue(jsonPathQuery: string): T | undefined;\n /** Find the parent of the first value matching the given JSONPath query within this USJ data */\n findParent(jsonPathQuery: string): T | undefined;\n /**\n * Convert a JSONPath query into a SerializedVerseRef and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Convert a JSONPath query into a USJ node, JSONPath, and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @returns USJ node, JSONPath, and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n */\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation;\n /** Build a JSONPath query that uniquely identifies the given node with this USJ data. */\n nodeToJsonPath(node: MarkerObject): ContentJsonPath;\n /**\n * Determine the location in the USFM representation of this data that corresponds to the location\n * of a node somewhere within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USFM location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Determine the location in the USJ document that corresponds to the location of a node somewhere\n * within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USJ location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @returns Node, JSONPath, and offset info representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n */\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation;\n /**\n * Remove all nodes from this USJ data that match a given search function.\n *\n * @param searchFunction Function that returns `true` if the given node should be removed\n * @returns Number of nodes removed\n */\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number;\n /**\n * Search for matches of a regular expression within this USJ's text data\n *\n * @param regex Regular expression to search for. Specify the global flag to find all matches.\n * @returns Array of `UsjSearchResult` objects that match the given regular expression\n */\n search(regex: RegExp): UsjSearchResult[];\n /** Transforms the USJ document into USFM */\n toUsfm(): string;\n /**\n * Get the index in the USFM representation of this data relative to the start of the document\n * that corresponds to the absolute verse location in USFM space passed in\n *\n * @param usfmVerseLocation The location in USFM space relative to a verse to get the index for\n * @returns Index in the USFM representation of this data relative to the start of the document\n */\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number;\n /**\n * Get the node + offset and JSONPath query within this USJ data of the first encountered string\n * after the provided USFM location for a specific verse in a USJ document.\n *\n * Note: this may return a node that is in a subsequent verse or even chapter depending on how\n * much content the USJ data contains. It simply looks through the rest of the USJ data for the\n * first text node and returns that.\n *\n * @param usfmVerseLocation Indicates the location in USFM space (book, chapter, verse, character\n * offset) to find the next text for\n * @returns Object containing the first USJ text node after `verseRef`, and a JSONPath string that\n * indicates the location of the USJ text node within this USJ data.\n * @throws Error if there is no text after `usfmVerseLocation`\n * @throws Error if `usfmVerseLocation` does not point to a valid location in this USJ data\n */\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a location in USJ space within this USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ location within the USJ document indicated by\n * `usfmVerseLocation`.\n */\n usfmVerseLocationToUsjDocumentLocation(usfmVerseLocation: UsfmVerseLocation): UsjDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a node and location in USJ space within this\n * USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ node and location within the USJ document indicated by\n * `usfmVerseLocation`. Note that if the USJ node returned is an object, it is the same object\n * that is within this USJ data. So if you change it, you are changing this USJ data.\n */\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Inform this UsjReaderWriter that the underlying USJ object changed. This is needed to clear\n * caches used when querying.\n */\n usjChanged(): void;\n /**\n * Convert a location in USJ space within this USJ data into a location in USFM space.\n *\n * @param usjLocation Location in USJ space - a jsonPath and other information about where the\n * location is\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Location in USFM space that is equivalent to the USJ location specified\n * @throws If not able to find the location in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n}\n","import { MarkerObject, MarkerContent } from '@eten-tech-foundation/scripture-utilities';\n\n/** Gets the default caller sequence to use to generate callers for textual notes. */\nexport function getDefaultCallerSequence(): string[] {\n return Array.from({ length: 26 }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i));\n}\n\n/**\n * Gets a caller to be displayed for a textual note. This is primarily useful as a helper function\n * in {@link getFormatCallerFunction} , but it might be useful in stories, UI preview code, etc.\n *\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n * @param n Zero-based index into the caller list.\n */\nexport function getNthCaller(n: number, callers?: string[]): string {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n return callerList[n % callerList.length];\n}\n\n/**\n * Gets a function that provides a (stable) caller based on a given sequence of textual notes.\n *\n * @param footnotes Sequence of footnotes, cross-references, and/or end-notes.\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n */\nexport function getFormatCallerFunction(footnotes: MarkerObject[], callers: string[] | undefined) {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n // Precompute a stable sequence for '+' callers\n const plusSequenceMap = (() => {\n const map = new Map();\n let autoCallerCounter = 0;\n footnotes.forEach((fn, idx) => {\n if (fn.caller === '+') {\n map.set(idx, getNthCaller(autoCallerCounter, callerList));\n autoCallerCounter += 1;\n }\n });\n return map;\n })();\n\n return (caller: string | undefined, index: number): string | undefined => {\n if (caller === '+') {\n const formattedCaller = plusSequenceMap.get(index);\n if (!formattedCaller) {\n console.warn(`Caller index ${index} out of range for '+' callers`);\n return '?'; // Out of range'\n }\n return formattedCaller;\n }\n if (caller === '-') return undefined;\n return caller;\n };\n}\n\n/**\n * Extract footnotes from an array of `MarkerContent` objects.\n *\n * @param contents - An array of `MarkerContent` objects\n * @returns An array of MarkerObjects representing all textual notes found in the contents.\n */\nexport function extractFootnotesFromUsjContent(contents?: MarkerContent[]): MarkerObject[] {\n const footnotes: MarkerObject[] = [];\n if (!contents || contents.length === 0) return footnotes;\n\n function traverse(item: MarkerContent) {\n if (typeof item === 'string') return; // plain text node, ignore\n\n // item is a MarkerObject\n if (item.type === 'note') {\n footnotes.push(item);\n } else if (Array.isArray(item.content) && item.content.length > 0) {\n item.content.forEach(traverse);\n }\n }\n\n contents.forEach(traverse);\n return footnotes;\n}\n","/** Options for calculating resizable pane size limits. */\nexport type PaneSizeLimitsOptions = {\n /**\n * The thickness of the splitter between the two panes, in pixels.\n *\n * @default 4\n */\n splitterThicknessPx?: number;\n /**\n * Minimum size (height or width) of the secondary pane (the pane whose size is to be\n * constrained), in pixels. Ensures the secondary pane never shrinks below this size, if\n * possible.\n *\n * @default 20\n */\n secondaryPaneMinSizePx?: number;\n /**\n * Minimum size (height or width) of the main pane (the other pane), in pixels. Ensures the main\n * pane always has some visible content.\n *\n * @default 60\n */\n mainPaneMinSizePx?: number;\n /**\n * Absolute minimum percentage of the total available that the secondary pane can occupy. Used to\n * avoid the pane collapsing completely (e.g., if the available height or width is less than the\n * combined minimums).\n *\n * @default 3\n */\n absoluteMinPercent?: number;\n /**\n * Absolute maximum percentage of the total available that the secondary pane can occupy. Can be\n * used to keep the \"main\" pane from being overwhelmed by the size of the secondary pane.\n *\n * @default 90\n */\n absoluteMaxPercent?: number;\n};\n\n/**\n * Calculates the minimum and maximum size (as percentages) for a resizable pane in a two-pane\n * layout based on the total available height or width and optional constraints.\n *\n * The returned percentages indicate the allowable range for the secondary pane (the one whose size\n * limits are being computed). When applied, they ensure that pane never shrinks below its minimum\n * or grows beyond its maximum, leaving adequate space for both panes.\n *\n * @param availablePx - Total height or width available for both panes, in pixels.\n * @param options - Optional parameters for customizing pane size constraints.\n * @returns An object containing the minimum and maximum percentages the secondary pane can occupy:\n * `{ minPercent, maxPercent }`.\n */\nexport function getPaneSizeLimits(\n availablePx: number,\n options: PaneSizeLimitsOptions = {},\n): { minPercent: number; maxPercent: number } {\n const {\n splitterThicknessPx = 4,\n secondaryPaneMinSizePx = 20,\n mainPaneMinSizePx = 60,\n absoluteMinPercent = 3,\n absoluteMaxPercent = 90,\n } = options;\n\n const usableHeightPx = availablePx - splitterThicknessPx;\n\n let minPercent: number;\n let maxPercent: number;\n\n if (usableHeightPx < secondaryPaneMinSizePx + mainPaneMinSizePx) {\n minPercent = absoluteMinPercent;\n maxPercent = absoluteMaxPercent;\n } else {\n maxPercent = Math.min(\n Math.floor(((usableHeightPx - mainPaneMinSizePx) / usableHeightPx) * 100),\n absoluteMaxPercent,\n );\n\n minPercent = Math.min(\n Math.max(Math.ceil((secondaryPaneMinSizePx / usableHeightPx) * 100), absoluteMinPercent),\n maxPercent,\n );\n }\n\n return { minPercent, maxPercent };\n}\n","var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n/**\n * Combine two comparators into a single comparators.\n */\nfunction combineComparators(comparatorA, comparatorB) {\n return function isEqual(a, b, state) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nfunction createIsCircular(areItemsEqual) {\n return function isCircular(a, b, state) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n var cache = state.cache;\n var cachedA = cache.get(a);\n var cachedB = cache.get(b);\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n cache.set(a, b);\n cache.set(b, a);\n var result = areItemsEqual(a, b, state);\n cache.delete(a);\n cache.delete(b);\n return result;\n };\n}\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nfunction getStrictProperties(object) {\n return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));\n}\n/**\n * Whether the object contains the property passed as an own property.\n */\nvar hasOwn = Object.hasOwn ||\n (function (object, property) {\n return hasOwnProperty.call(object, property);\n });\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nfunction sameValueZeroEqual(a, b) {\n return a === b || (!a && !b && a !== a && b !== b);\n}\n\nvar PREACT_VNODE = '__v';\nvar PREACT_OWNER = '__o';\nvar REACT_OWNER = '_owner';\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys = Object.keys;\n/**\n * Whether the arrays are equal in value.\n */\nfunction areArraysEqual(a, b, state) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the dates passed are equal in value.\n */\nfunction areDatesEqual(a, b) {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n/**\n * Whether the errors passed are equal in value.\n */\nfunction areErrorsEqual(a, b) {\n return (a.name === b.name &&\n a.message === b.message &&\n a.cause === b.cause &&\n a.stack === b.stack);\n}\n/**\n * Whether the functions passed are equal in value.\n */\nfunction areFunctionsEqual(a, b) {\n return a === b;\n}\n/**\n * Whether the `Map`s are equal in value.\n */\nfunction areMapsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.entries();\n var aResult;\n var bResult;\n var index = 0;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.entries();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (matchedIndices[matchIndex]) {\n matchIndex++;\n continue;\n }\n var aEntry = aResult.value;\n var bEntry = bResult.value;\n if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) &&\n state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n index++;\n }\n return true;\n}\n/**\n * Whether the numbers are equal in value.\n */\nvar areNumbersEqual = sameValueZeroEqual;\n/**\n * Whether the objects are equal in value.\n */\nfunction areObjectsEqual(a, b, state) {\n var properties = keys(a);\n var index = properties.length;\n if (keys(b).length !== index) {\n return false;\n }\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n if (!isPropertyEqual(a, b, state, properties[index])) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nfunction areObjectsEqualStrict(a, b, state) {\n var properties = getStrictProperties(a);\n var index = properties.length;\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n var property;\n var descriptorA;\n var descriptorB;\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index];\n if (!isPropertyEqual(a, b, state, property)) {\n return false;\n }\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n if ((descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nfunction arePrimitiveWrappersEqual(a, b) {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n/**\n * Whether the regexps passed are equal in value.\n */\nfunction areRegExpsEqual(a, b) {\n return a.source === b.source && a.flags === b.flags;\n}\n/**\n * Whether the `Set`s are equal in value.\n */\nfunction areSetsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.values();\n var aResult;\n var bResult;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.values();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (!matchedIndices[matchIndex] &&\n state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the TypedArray instances are equal in value.\n */\nfunction areTypedArraysEqual(a, b) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the URL instances are equal in value.\n */\nfunction areUrlsEqual(a, b) {\n return (a.hostname === b.hostname &&\n a.pathname === b.pathname &&\n a.protocol === b.protocol &&\n a.port === b.port &&\n a.hash === b.hash &&\n a.username === b.username &&\n a.password === b.password);\n}\nfunction isPropertyEqual(a, b, state, property) {\n if ((property === REACT_OWNER ||\n property === PREACT_OWNER ||\n property === PREACT_VNODE) &&\n (a.$$typeof || b.$$typeof)) {\n return true;\n }\n return (hasOwn(b, property) &&\n state.equals(a[property], b[property], property, property, a, b, state));\n}\n\nvar ARGUMENTS_TAG = '[object Arguments]';\nvar BOOLEAN_TAG = '[object Boolean]';\nvar DATE_TAG = '[object Date]';\nvar ERROR_TAG = '[object Error]';\nvar MAP_TAG = '[object Map]';\nvar NUMBER_TAG = '[object Number]';\nvar OBJECT_TAG = '[object Object]';\nvar REG_EXP_TAG = '[object RegExp]';\nvar SET_TAG = '[object Set]';\nvar STRING_TAG = '[object String]';\nvar URL_TAG = '[object URL]';\nvar isArray = Array.isArray;\nvar isTypedArray = typeof ArrayBuffer === 'function' && ArrayBuffer.isView\n ? ArrayBuffer.isView\n : null;\nvar assign = Object.assign;\nvar getTag = Object.prototype.toString.call.bind(Object.prototype.toString);\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nfunction createEqualityComparator(_a) {\n var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areErrorsEqual = _a.areErrorsEqual, areFunctionsEqual = _a.areFunctionsEqual, areMapsEqual = _a.areMapsEqual, areNumbersEqual = _a.areNumbersEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual, areUrlsEqual = _a.areUrlsEqual;\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a, b, state) {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n // If either of the items are nullish and fail the strictly equal check\n // above, then they must be unequal.\n if (a == null || b == null) {\n return false;\n }\n var type = typeof a;\n if (type !== typeof b) {\n return false;\n }\n if (type !== 'object') {\n if (type === 'number') {\n return areNumbersEqual(a, b, state);\n }\n if (type === 'function') {\n return areFunctionsEqual(a, b, state);\n }\n // If a primitive value that is not strictly equal, it must be unequal.\n return false;\n }\n var constructor = a.constructor;\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n // Constructors should match, otherwise there is potential for false positives\n // between class and subclass or custom object and POJO.\n if (constructor !== b.constructor) {\n return false;\n }\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid capturing the string tag.\n if (constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing\n // the string tag or doing an `instanceof` check.\n if (isArray(a)) {\n return areArraysEqual(a, b, state);\n }\n // `isTypedArray()` works on all possible TypedArray classes, so we can avoid\n // capturing the string tag or comparing against all possible constructors.\n if (isTypedArray != null && isTypedArray(a)) {\n return areTypedArraysEqual(a, b, state);\n }\n // Try to fast-path equality checks for other complex object types in the\n // same realm to avoid capturing the string tag. Strict equality is used\n // instead of `instanceof` because it is more performant for the common\n // use-case. If someone is subclassing a native class, it will be handled\n // with the string tag comparison.\n if (constructor === Date) {\n return areDatesEqual(a, b, state);\n }\n if (constructor === RegExp) {\n return areRegExpsEqual(a, b, state);\n }\n if (constructor === Map) {\n return areMapsEqual(a, b, state);\n }\n if (constructor === Set) {\n return areSetsEqual(a, b, state);\n }\n // Since this is a custom object, capture the string tag to determing its type.\n // This is reasonably performant in modern environments like v8 and SpiderMonkey.\n var tag = getTag(a);\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n // For RegExp, the properties are not enumerable, and therefore will give false positives if\n // tested like a standard object.\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is custom `Promise`-like class instances. These should\n // be treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state));\n }\n // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === URL_TAG) {\n return areUrlsEqual(a, b, state);\n }\n // If an error tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === ERROR_TAG) {\n return areErrorsEqual(a, b, state);\n }\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n/**\n * Create the configuration object used for building comparators.\n */\nfunction createEqualityComparatorConfig(_a) {\n var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;\n var config = {\n areArraysEqual: strict\n ? areObjectsEqualStrict\n : areArraysEqual,\n areDatesEqual: areDatesEqual,\n areErrorsEqual: areErrorsEqual,\n areFunctionsEqual: areFunctionsEqual,\n areMapsEqual: strict\n ? combineComparators(areMapsEqual, areObjectsEqualStrict)\n : areMapsEqual,\n areNumbersEqual: areNumbersEqual,\n areObjectsEqual: strict\n ? areObjectsEqualStrict\n : areObjectsEqual,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,\n areRegExpsEqual: areRegExpsEqual,\n areSetsEqual: strict\n ? combineComparators(areSetsEqual, areObjectsEqualStrict)\n : areSetsEqual,\n areTypedArraysEqual: strict\n ? areObjectsEqualStrict\n : areTypedArraysEqual,\n areUrlsEqual: areUrlsEqual,\n };\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n if (circular) {\n var areArraysEqual$1 = createIsCircular(config.areArraysEqual);\n var areMapsEqual$1 = createIsCircular(config.areMapsEqual);\n var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);\n var areSetsEqual$1 = createIsCircular(config.areSetsEqual);\n config = assign({}, config, {\n areArraysEqual: areArraysEqual$1,\n areMapsEqual: areMapsEqual$1,\n areObjectsEqual: areObjectsEqual$1,\n areSetsEqual: areSetsEqual$1,\n });\n }\n return config;\n}\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nfunction createInternalEqualityComparator(compare) {\n return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {\n return compare(a, b, state);\n };\n}\n/**\n * Create the `isEqual` function used by the consuming application.\n */\nfunction createIsEqual(_a) {\n var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;\n if (createState) {\n return function isEqual(a, b) {\n var _a = createState(), _b = _a.cache, cache = _b === void 0 ? circular ? new WeakMap() : undefined : _b, meta = _a.meta;\n return comparator(a, b, {\n cache: cache,\n equals: equals,\n meta: meta,\n strict: strict,\n });\n };\n }\n if (circular) {\n return function isEqual(a, b) {\n return comparator(a, b, {\n cache: new WeakMap(),\n equals: equals,\n meta: undefined,\n strict: strict,\n });\n };\n }\n var state = {\n cache: undefined,\n equals: equals,\n meta: undefined,\n strict: strict,\n };\n return function isEqual(a, b) {\n return comparator(a, b, state);\n };\n}\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nvar deepEqual = createCustomEqual();\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nvar strictDeepEqual = createCustomEqual({ strict: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nvar circularDeepEqual = createCustomEqual({ circular: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nvar shallowEqual = createCustomEqual({\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nvar strictShallowEqual = createCustomEqual({\n strict: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nvar circularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n strict: true,\n});\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nfunction createCustomEqual(options) {\n if (options === void 0) { options = {}; }\n var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;\n var config = createEqualityComparatorConfig(options);\n var comparator = createEqualityComparator(config);\n var equals = createCustomInternalComparator\n ? createCustomInternalComparator(comparator)\n : createInternalEqualityComparator(comparator);\n return createIsEqual({ circular: circular, comparator: comparator, createState: createState, equals: equals, strict: strict });\n}\n\nexport { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };\n//# sourceMappingURL=index.mjs.map\n","// There is a circular version https://www.npmjs.com/package/fast-equals#circulardeepequal that I\n// think allows comparing React refs (which have circular references in particular places that this\n// library would ignore). Maybe we can change to that version sometime if needed.\nimport { deepEqual as isEqualDeep } from 'fast-equals';\n\n/**\n * Check that two objects are deeply equal, comparing members of each object and such\n *\n * @param a The first object to compare\n * @param b The second object to compare\n *\n * WARNING: Objects like arrays from different iframes have different constructor function\n * references even if they do the same thing, so this deep equality comparison fails objects that\n * look the same but have different constructors because different constructors could produce\n * false positives in [a few specific\n * situations](https://github.com/planttheidea/fast-equals/blob/a41afc0a240ad5a472e47b53791e9be017f52281/src/comparator.ts#L96).\n * This means that two objects like arrays from different iframes that look the same will fail\n * this check. Please use some other means to check deep equality in those situations.\n *\n * Note: This deep equality check considers `undefined` values on keys of objects NOT to be equal to\n * not specifying the key at all. For example, `{ stuff: 3, things: undefined }` and `{ stuff: 3\n * }` are not considered equal in this case\n *\n * - For more information and examples, see [this\n * CodeSandbox](https://codesandbox.io/s/deepequallibrarycomparison-4g4kk4?file=/src/index.mjs).\n *\n * @returns True if a and b are deeply equal; false otherwise\n */\nexport function deepEqual(a: unknown, b: unknown) {\n return isEqualDeep(a, b);\n}\n\nexport default deepEqual;\n","import { deepEqual } from './equality-checking';\n\n/**\n * Check if one object is a subset of the other object. \"Subset\" means that all properties of one\n * object are present in the other object, and if they are present that all values of those\n * properties are deeply equal. Sub-objects are also checked to be subsets of the corresponding\n * sub-object in the other object.\n *\n * @example ObjB is a subset of objA given these objects:\n *\n * ```ts\n * objA = { name: 'Alice', age: 30, address: { city: 'Seattle', state: 'Washington' } };\n * objB = { name: 'Alice', address: { city: 'Seattle' } };\n * ```\n *\n * It is important to note that only arrays of primitives (i.e., booleans, numbers, strings) are\n * supported. In particular, objects in arrays will not be checked for deep equality. Also, presence\n * in an array is all this checks, not the number of times that an item appears in an array. `[1,\n * 1]` is a subset of `[1]`.\n *\n * @param objectWithAllProperties Object to be checked if it is a superset of\n * `objectWithPartialProperties`\n * @param objectWithPartialProperties Object to be checked if it is a subset of\n * `objectWithAllProperties`\n * @returns True if `objectWithAllProperties` contains all the properties of\n * `objectWithPartialProperties` and all values of those properties are deeply equal\n */\nexport function isSubset(\n objectWithAllProperties: unknown,\n objectWithPartialProperties: unknown,\n): boolean {\n if (typeof objectWithAllProperties !== typeof objectWithPartialProperties) return false;\n\n // For this function we're saying that all falsy things of the same type are equal to each other\n if (!objectWithAllProperties && !objectWithPartialProperties) return true;\n\n if (Array.isArray(objectWithAllProperties)) {\n // We know these are arrays from the line above\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialArray = objectWithPartialProperties as Array;\n const allArray = objectWithAllProperties as Array;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n if (partialArray.length === 0) return true;\n\n // This only works with arrays of primitives.\n // If someone cares about checking arrays of objects this needs updating.\n return partialArray.every((item) => allArray.includes(item));\n }\n\n if (typeof objectWithAllProperties !== 'object')\n return deepEqual(objectWithAllProperties, objectWithPartialProperties);\n\n // We know these are objects that potentially have properties because of the earlier checks\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialObj = objectWithPartialProperties as Record;\n const allObj = objectWithAllProperties as Record;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n let retVal = true;\n Object.keys(partialObj).forEach((key) => {\n if (!retVal) return;\n if (!Object.hasOwn(allObj, key)) retVal = false;\n else if (!isSubset(allObj[key], partialObj[key])) retVal = false;\n });\n return retVal;\n}\n\nexport default isSubset;\n","/**\n * Converts a JavaScript value to a JSON string, changing `undefined` properties in the JavaScript\n * object to `null` properties in the JSON string.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer A function that transforms the results. Note that all `undefined` values returned\n * by the replacer will be further transformed into `null` in the JSON string.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON\n * text to make it easier to read. See the `space` parameter of `JSON.stringify` for more\n * details.\n */\nexport function serialize(\n value: unknown,\n replacer?: (this: unknown, key: string, value: unknown) => unknown,\n space?: string | number,\n): string {\n const undefinedReplacer = (replacerKey: string, replacerValue: unknown) => {\n let newValue = replacerValue;\n if (replacer) newValue = replacer(replacerKey, newValue);\n // All `undefined` values become `null` on the way from JS objects into JSON strings\n // eslint-disable-next-line no-null/no-null\n if (newValue === undefined) newValue = null;\n return newValue;\n };\n return JSON.stringify(value, undefinedReplacer, space);\n}\n\n/**\n * Converts a JSON string into a value, converting all `null` properties from JSON into `undefined`\n * in the returned JavaScript value/object.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A valid JSON string.\n * @param reviver A function that transforms the results. This function is called for each member of\n * the object. If a member contains nested objects, the nested objects are transformed before the\n * parent object is. Note that `null` values are converted into `undefined` values after the\n * reviver has run.\n */\nexport function deserialize(\n value: string,\n reviver?: (this: unknown, key: string, value: unknown) => unknown,\n // Need to use `any` instead of `unknown` here to match the signature of JSON.parse\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // Helper function to replace `null` with `undefined` on a per property basis. This can't be done\n // with our own reviver because `JSON.parse` removes `undefined` properties from the return value.\n function replaceNull(obj: Record): Record {\n Object.keys(obj).forEach((key: string | number) => {\n // We only want to replace `null`, not other falsy values\n // eslint-disable-next-line no-null/no-null\n if (obj[key] === null) obj[key] = undefined;\n // If the property is an object, recursively call the helper function on it\n else if (typeof obj[key] === 'object')\n // Since the object came from a string, we know the keys will not be symbols\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n obj[key] = replaceNull(obj[key] as Record);\n });\n return obj;\n }\n\n const parsedObject = JSON.parse(value, reviver);\n // Explicitly convert the value 'null' that isn't stored as a property on an object to 'undefined'\n // eslint-disable-next-line no-null/no-null\n if (parsedObject === null) return undefined;\n if (typeof parsedObject === 'object') return replaceNull(parsedObject);\n return parsedObject;\n}\n\n/**\n * Check to see if the value is serializable without losing information\n *\n * @param value Value to test\n * @returns True if serializable; false otherwise\n *\n * Note: the values `undefined` and `null` are serializable (on their own or in an array), but\n * `null` values get transformed into `undefined` when serializing/deserializing.\n *\n * WARNING: This is inefficient right now as it stringifies, parses, stringifies, and === the value.\n * Please only use this if you need to\n *\n * DISCLAIMER: this does not successfully detect that values are not serializable in some cases:\n *\n * - Losses of removed properties like functions and `Map`s\n * - Class instances (not deserializable into class instances without special code)\n *\n * We intend to improve this in the future if it becomes important to do so. See [`JSON.stringify`\n * documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)\n * for more information.\n */\nexport function isSerializable(value: unknown): boolean {\n try {\n const serializedValue = serialize(value);\n return serializedValue === serialize(deserialize(serializedValue));\n } catch (e) {\n return false;\n }\n}\n\n/**\n * HTML Encodes the provided string. Thanks to ChatGPT\n *\n * @param str String to HTML encode\n * @returns HTML-encoded string\n */\nexport const htmlEncode = (str: string): string =>\n str\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n","import { DateTimeFormat } from './intl-date-time-format';\n\n/**\n * Retrieves the current locale of the user's environment.\n *\n * @returns A string representing the current locale. If the locale cannot be determined, the\n * function returns an empty string.\n */\nexport function getCurrentLocale(): string {\n // Use navigator when available\n if (typeof navigator !== 'undefined' && navigator.languages) {\n const rawLocale = navigator.languages[0];\n // According to the MDN page for navigator.languages it should always return a valid BCP 47 tag.\n // However, some environments (e.g., certain Linux distros) may use the 'POSIX locale format'.\n // This code removes a (potential) trailing \"@posix\" so we will always return a valid BCP 47 tag\n // You can find the MDN page for navigator.languages here:\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n // You can learn more about the 'POSIX locale format' here:\n // https://learn.microsoft.com/en-us/globalization/locale/other-locale-names\n return rawLocale.replace(/@posix$/i, '');\n }\n // For Node.js\n return new DateTimeFormat().resolvedOptions().locale;\n}\n\nexport default getCurrentLocale;\n","import { NumberFormat } from './intl/intl-number-format';\n\n/**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @example FormatBytes(1024) => \"1 KB\"\n *\n * @example FormatBytes(1024, 0) => \"1 KB\"\n *\n * @param fileSize Number to format\n * @param decimals Number of decimal places to round to\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\nexport function formatBytes(fileSize: number, decimals: number = 2): string {\n if (fileSize === 0) return '0 Bytes';\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(fileSize) / Math.log(1024));\n const sizeToUse = sizes[i];\n const formattingFileSize = new NumberFormat('en', {\n style: 'decimal',\n maximumFractionDigits: decimals,\n minimumFractionDigits: 0,\n }).format(fileSize / 1024 ** i);\n return `${formattingFileSize} ${sizeToUse}`;\n}\n\nexport default formatBytes;\n","const MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60;\nconst SECONDS_PER_DAY = SECONDS_PER_HOUR * 24;\n\n/**\n * Get a localized string representation of the time between two dates\n *\n * @example\n *\n * `since` = 3 Aug 2024 8:00 AM\n *\n * `to` = 5 Aug 2024 8:000 AM\n *\n * Returns: \"two days ago\"\n *\n * @param since \"Destination\" time. time against which to get the time span.\n * @param to \"Starting\" time. Time span will be formatted relative to `to`. Defaults to `new Date()`\n * @returns Time span in words from `to` to `since`\n */\nexport function formatTimeSpan(\n relativeTimeFormatter: Intl.RelativeTimeFormat,\n since: Date,\n to = new Date(),\n) {\n const spanSeconds = Math.floor((since.getTime() - to.getTime()) / MILLISECONDS_PER_SECOND);\n\n const totalDays = Math.round(spanSeconds / SECONDS_PER_DAY);\n if (Math.abs(totalDays) >= 1) return relativeTimeFormatter.format(totalDays, 'day');\n\n const totalHours = Math.round(spanSeconds / SECONDS_PER_HOUR);\n if (Math.abs(totalHours) >= 1) return relativeTimeFormatter.format(totalHours, 'hour');\n\n const totalMinutes = Math.round(spanSeconds / SECONDS_PER_MINUTE);\n if (Math.abs(totalMinutes) >= 1) return relativeTimeFormatter.format(totalMinutes, 'minute');\n\n return relativeTimeFormatter.format(spanSeconds, 'second');\n}\n\n/**\n * Formats a date relative to today, showing \"Today\" or \"Yesterday\" when applicable, otherwise\n * returns the date in the specified format\n *\n * @param date The date to format\n * @param todayString The string to display when the date is today\n * @param yesterdayString The string to display when the date is yesterday\n * @param locale The locale to use for date formatting (defaults to user's locale)\n * @param options The Intl.DateTimeFormatOptions to use for date formatting when not\n * today/yesterday. Defaults to `{ year: 'numeric', month: 'short', day: 'numeric' }` which\n * produces formats like \"Nov 9, 2025\"\n */\nexport function formatRelativeDate(\n date: Date,\n todayString: string,\n yesterdayString: string,\n locale?: string,\n options: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n): string {\n const today = new Date();\n const yesterday = new Date(today);\n yesterday.setDate(yesterday.getDate() - 1);\n\n const isToday =\n date.getDate() === today.getDate() &&\n date.getMonth() === today.getMonth() &&\n date.getFullYear() === today.getFullYear();\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n if (isToday) {\n return todayString;\n }\n if (isYesterday) {\n return yesterdayString;\n }\n\n return date.toLocaleString(locale, options);\n}\n","/**\n * Modifier keys that don't constitute typed input\n *\n * Sourced from\n * https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys\n */\nexport const MODIFIER_KEYS = new Set([\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta',\n 'NumLock',\n 'ScrollLock',\n 'Shift',\n 'Super',\n 'Symbol',\n 'SymbolLock',\n]);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey, ReferencedItem } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the settings it provides */\nexport type SettingsContribution = SettingsGroup | SettingsGroup[];\n/** A description of an extension's setting entry */\nexport type Setting = ExtensionControlledSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledSetting = SettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a setting entry */\nexport type SettingBase = StateBase & {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the setting name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the setting */\n description?: LocalizeKey;\n /**\n * Boolean that controls whether a setting should be hidden or not. If hidden, the setting will\n * not show up in the settings dialog in `paranext-core`, and thus will not be configurable by the\n * user unless an extension provides a way to interact with the setting.\n */\n isHidden?: boolean;\n};\n/** The data an extension provides to inform Platform.Bible of the project settings it provides */\nexport type ProjectSettingsContribution = ProjectSettingsGroup | ProjectSettingsGroup[];\n/** A description of an extension's setting entry */\nexport type ProjectSetting = ExtensionControlledProjectSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledProjectSetting = ProjectSettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a project setting entry */\nexport type ProjectSettingBase = SettingBase & ModifierProject;\n/** A description of an extension's user state entry */\nexport type UserState = ExtensionControlledState;\n/** State definition that is validated by the extension. */\nexport type ExtensionControlledState = StateBase & ModifierExtensionControlled;\n/** Group of related settings definitions */\nexport interface SettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the group */\n description?: LocalizeKey;\n properties: SettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface SettingProperties {\n [k: ReferencedItem]: Setting;\n}\n/** Base information needed to describe a state entry */\nexport interface StateBase {\n [k: string]: unknown;\n /** Default value for the state/setting */\n default: unknown;\n /**\n * A state/setting ID whose value to set to this state/setting's starting value the first time\n * this state/setting is loaded\n */\n derivesFrom?: ReferencedItem;\n}\n/**\n * Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the\n * extension provides the component and the validator for the state/setting, so the state/setting is\n * controlled by the extension.\n */\nexport interface ModifierExtensionControlled {\n [k: string]: unknown;\n platformType?: undefined;\n type?: undefined;\n}\n/** Group of related settings definitions */\nexport interface ProjectSettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the project settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the project settings dialog to describe the group */\n description?: LocalizeKey;\n properties: ProjectSettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface ProjectSettingProperties {\n [k: ReferencedItem]: ProjectSetting;\n}\n\n// Note: we removed the index signature on ModifierProject to avoid having it on\n// `ProjectMetadataFilterOptions`. Unfortunately adding \"additionalProperties\": false on the json\n// schema messes up validation. Please remove the index signature again in the future if you\n// regenerate types\n/**\n * Defines a set of optional properties that can be used to filter projects based on their\n * `projectInterface` and Project Data Provider Factory Ids.\n */\nexport interface ModifierProject {\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should be included.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to pass):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to all `ProjectInterfaces`, so all projects that do not match\n * `excludeProjectInterfaces` will be included\n *\n * @example\n *\n * ```typescript\n * includeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed on projects whose `projectInterface`s fulfill at least one\n * of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n includeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should absolutely not be included even if they match with\n * `includeProjectInterfaces`.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to exclude the project):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition and exclude the project\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition and exclude the project\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will\n * be included\n *\n * @example\n *\n * ```typescript\n * excludeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed and exclude projects whose `projectInterface`s fulfill at\n * least one of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n excludeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should be included.\n *\n * Defaults to all Project Data Provider Factory Ids, so all projects that do not match\n * `excludePdpFactoryIds` will be included\n */\n includePdpFactoryIds?: undefined | string | string[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should absolutely not be included even if they match\n * with `includeProjectInterfaces`.\n *\n * Defaults to none, so all projects that match `includePdpFactoryIds` will be included\n */\n excludePdpFactoryIds?: undefined | string | string[];\n}\n\n/** The data an extension provides to inform Platform.Bible of the user state it provides */\nexport interface UserStateContribution {\n [k: ReferencedItem]: UserState;\n}\n/** The data an extension provides to inform Platform.Bible of the project state it provides */\nexport interface ProjectStateContribution {\n [k: ReferencedItem]: UserState;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\nconst settingsDefs = {\n projectSettingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n },\n projectSettingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the project settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description:\n 'localizeKey that displays in the project settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/projectSettingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n projectSettingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/projectSetting',\n },\n },\n additionalProperties: false,\n },\n projectSetting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledProjectSetting',\n },\n ],\n },\n extensionControlledProjectSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/projectSettingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n projectSettingBase: {\n description: 'Base information needed to describe a project setting entry',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierProject',\n },\n ],\n },\n modifierProject: {\n description: 'Modifies setting type to be project setting',\n type: 'object',\n properties: {\n includeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should be included.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to pass):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to all `ProjectInterfaces`, so all projects that do not match `excludeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nincludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed on projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n excludeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to exclude the project):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition and exclude the project\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition and exclude the project\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nexcludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed and exclude projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n includePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should be included.\\n\\nDefaults to all Project Data Provider Factory Ids, so all projects that do not match `excludePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n excludePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nDefaults to none, so all projects that match `includePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n },\n settingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n },\n settingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/settingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n settingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w-]+\\\\.[\\\\w-]+$': {\n $ref: '#/$defs/setting',\n },\n },\n additionalProperties: false,\n },\n setting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledSetting',\n },\n ],\n },\n extensionControlledSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n settingBase: {\n description: 'Base information needed to describe a setting entry',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the setting name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the setting',\n $ref: '#/$defs/localizeKey',\n },\n isHidden: {\n description: `Boolean that controls whether a setting should be hidden or not. If hidden\n , the setting will not show up in the settings dialog in \\`paranext-core\\`, and thus\n will not be configurable by the user unless an extension provides a way to interact with\n the setting.`,\n type: 'boolean',\n },\n },\n required: ['label'],\n },\n ],\n },\n projectStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the user state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateProperties: {\n description: 'Object whose keys are state IDs and whose values are state objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/userState',\n },\n },\n additionalProperties: false,\n },\n userState: {\n description: \"A description of an extension's user state entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledState',\n },\n ],\n },\n extensionControlledState: {\n description: 'State definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n modifierExtensionControlled: {\n description:\n 'Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the extension provides the component and the validator for the state/setting, so the state/setting is controlled by the extension.',\n not: {\n anyOf: [\n {\n type: 'object',\n required: ['platformType'],\n },\n {\n type: 'object',\n required: ['type'],\n },\n ],\n },\n },\n stateBase: {\n description: 'Base information needed to describe a state entry',\n type: 'object',\n properties: {\n default: {\n description: 'default value for the state/setting',\n type: 'any',\n },\n derivesFrom: {\n description:\n \"a state/setting ID whose value to set to this state/setting's starting value the first time this state/setting is loaded\",\n $ref: '#/$defs/id',\n },\n },\n required: ['default'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n id: {\n description: '',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n tsType: 'Id',\n },\n};\n\n/**\n * Json-schema-to-typescript has some added stuff that isn't actually compatible with JSON schema,\n * so we remove them here\n *\n * @param defs The `$defs` property of a JSON schema (will be modified in place)\n */\n// JSON schema types are weird, so we'll just be careful\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function removeJsonToTypeScriptTypesStuff(defs: any) {\n if (!defs) return;\n\n // JSON schema types are weird, so we'll just be careful\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.values(defs).forEach((def: any) => {\n if (!def.type) return;\n\n if ('tsType' in def) delete def.tsType;\n\n if (def.type === 'any') {\n delete def.type;\n return;\n }\n\n if (def.type === 'object') {\n removeJsonToTypeScriptTypesStuff(def.properties);\n }\n });\n}\n\nremoveJsonToTypeScriptTypesStuff(settingsDefs);\n\n/** JSON schema object that aligns with the ProjectSettingsContribution type */\nexport const projectSettingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Project Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(projectSettingsDocumentSchema);\n\n/** JSON schema object that aligns with the {@link SettingsContribution} type */\nexport const settingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(settingsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey } from './menus.model';\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\n\n/** Localized string value associated with this key */\nexport type LocalizedStringValue = string;\n/**\n * Date in YYYY-MM-DD format\n *\n * Use regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$` to test.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\nexport type DateYYYYMMDD = `${number}-${number}-${number}`;\n\n/** The data an extension provides to inform Platform.Bible of the localized strings it provides. */\nexport interface LocalizedStringDataContribution {\n [k: string]: unknown;\n metadata?: StringsMetadata;\n localizedStrings?: {\n [k: string]: LanguageStrings;\n };\n}\n/**\n * Map whose keys are localized string keys and whose values provide additional non-locale-specific\n * information about the localized string key\n */\nexport interface StringsMetadata {\n [k: LocalizeKey]: StringMetadata;\n}\n/** Additional non-locale-specific information about a localized string key */\nexport interface StringMetadata {\n [k: string]: unknown;\n /**\n * Localized string key from which to get this value if one does not exist in the specified\n * language. If a new key/value pair needs to be made to replace an existing one, this could help\n * smooth over the transition if the meanings are close enough\n *\n * You can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a\n * backslash `\\`.\n */\n fallbackKey?: LocalizeKey;\n /**\n * Additional information provided by developers in English to help the translator to know how to\n * translate this localized string accurately\n */\n notes?: string;\n /**\n * If this property is filled, the localized string is deprecated. Contains information about the\n * deprecation.\n */\n deprecationInfo?: LocalizedStringDeprecationInfo;\n}\n/**\n * Contains information about the deprecation of a localized string key, including the date of\n * deprecation and the reason.\n */\nexport interface LocalizedStringDeprecationInfo {\n [k: string]: unknown;\n /**\n * Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\n *\n * Tested against regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\n date: DateYYYYMMDD;\n /**\n * Should contain the reason for deprecation and what to use instead in what contexts.\n *\n * @example Reworded to clarify the meaning. Use %my_key_2% instead.\n */\n message: string;\n}\n/**\n * Map whose keys are localized string keys and whose values provide information about how to\n * localize strings for the localized string key\n */\nexport interface LanguageStrings {\n [k: LocalizeKey]: LocalizedStringValue;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n\nconst localizedStringsDefs = {\n languageStrings: {\n description:\n 'Map whose keys are localized string keys and whose values provide information about how to localize strings for the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/localizedStringValue',\n },\n },\n additionalProperties: false,\n },\n localizedStringValue: {\n description: 'Localized string value associated with this key',\n type: 'string',\n },\n stringsMetadata: {\n description:\n 'Map whose keys are localized string keys and whose values provide additional non-locale-specific information about the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/stringMetadata',\n },\n },\n additionalProperties: false,\n },\n stringMetadata: {\n description: 'Additional non-locale-specific information about a localized string key',\n type: 'object',\n properties: {\n fallbackKey: {\n description:\n 'Localized string key from which to get this value if one does not exist in the specified language. If a new key/value pair needs to be made to replace an existing one, this could help smooth over the transition if the meanings are close enough.\\nYou can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a backslash `\\\\`.',\n type: 'string',\n pattern: \"^%[\\\\w\\\\-\\\\.;&,' (){}#:/\\\\\\\\?%⋮|[\\\\]“”‘’!~*\\u00A0+=•`…\\u200B↑↓]+%$\",\n tsType: 'LocalizeKey',\n },\n notes: {\n description:\n 'Additional information provided by developers in English to help the translator to know how to translate this localized string accurately',\n type: 'string',\n },\n deprecationInfo: {\n description:\n 'If this property is filled, the localized string is deprecated. Contains information about the deprecation.',\n $ref: '#/$defs/localizedStringDeprecationInfo',\n },\n },\n },\n localizedStringDeprecationInfo: {\n description:\n 'Date of deprecation, the reason for deprecation, and what to use instead in what contexts',\n type: 'object',\n properties: {\n date: {\n description:\n 'Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\\n\\nTested against regex `^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\\n\\nThanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.',\n type: 'string',\n pattern: '^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$',\n tsType: 'DateYYYYMMDD',\n },\n message: {\n description:\n 'Should contain the reason for deprecation and what to use instead in what contexts.\\n\\n@example Reworded to clarify the meaning. Use %my_key_2% instead.',\n type: 'string',\n },\n },\n required: ['date', 'message'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(localizedStringsDefs);\n\n/** JSON schema object that aligns with the LocalizedStringDataContribution type */\nexport const localizedStringsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Localized String Data Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the localized strings it provides.',\n type: 'object',\n properties: {\n metadata: {\n $ref: '#/$defs/stringsMetadata',\n },\n localizedStrings: {\n type: 'object',\n additionalProperties: {\n $ref: '#/$defs/languageStrings',\n },\n },\n },\n $defs: localizedStringsDefs,\n};\n\nObject.freeze(localizedStringsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { ReplaceType } from '../util';\n\n/** Identifier for a string that will be localized in a menu based on the user's UI language */\nexport type LocalizeKey = `%${string}%`;\n\n/** Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command) */\nexport type ReferencedItem = `${string}.${string}`;\n\nexport type OrderedItem = {\n /** Relative order of this item compared to other items in the same parent/scope (sorted ascending) */\n order: number;\n};\n\nexport type OrderedExtensibleContainer = OrderedItem & {\n /** Determines whether other items can be added to this after it has been defined */\n isExtensible?: boolean;\n};\n\n/** Group of menu items that belongs in a column */\nexport type MenuGroupDetailsInColumn = OrderedExtensibleContainer & {\n /** ID of column in which this group resides */\n column: ReferencedItem;\n};\n\n/** Group of menu items that belongs in a submenu */\nexport type MenuGroupDetailsInSubMenu = OrderedExtensibleContainer & {\n /** ID of menu item hosting the submenu in which this group resides */\n menuItem: ReferencedItem;\n};\n\n/** Column that includes header text in a menu */\nexport type MenuColumnWithHeader = OrderedExtensibleContainer & {\n /** Key that represents the text of the header text of the column */\n label: LocalizeKey;\n};\n\nexport type MenuItemBase = OrderedItem & {\n /** Menu group to which this menu item belongs */\n group: ReferencedItem;\n /** Key that represents the text of this menu item to display */\n label: LocalizeKey;\n /** Key that represents words the platform should reference when users are searching for menu items */\n searchTerms?: LocalizeKey;\n /** Key that represents the text to display if a mouse pointer hovers over the menu item */\n tooltip?: LocalizeKey;\n /** Additional information provided by developers to help people who perform localization */\n localizeNotes: string;\n};\n\n/** Menu item that hosts a submenu */\nexport type MenuItemContainingSubmenu = MenuItemBase & {\n /** ID for this menu item that holds a submenu */\n id: ReferencedItem;\n};\n\n/** Menu item that runs a command */\nexport type MenuItemContainingCommand = MenuItemBase & {\n /** Name of the PAPI command to run when this menu item is selected. */\n command: ReferencedItem;\n /**\n * Uri path to the icon to display after the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathAfter?: string;\n /**\n * Uri path to the icon to display before the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathBefore?: string;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single context menu/submenu.\n * Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInSingleColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: OrderedExtensibleContainer | MenuGroupDetailsInSubMenu;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single menu/submenu within a\n * multi-column menu. Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInMultiColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: MenuGroupDetailsInColumn | MenuGroupDetailsInSubMenu;\n};\n\n/** Group of columns that can be combined with other columns to form a multi-column menu */\nexport type ColumnsWithHeaders = {\n /** Named column of a menu */\n [property: ReferencedItem]: MenuColumnWithHeader;\n /** Defines whether columns can be added to this multi-column menu */\n isExtensible?: boolean;\n};\n\n/** Menu that contains a column without a header */\nexport type SingleColumnMenu = {\n /** Groups that belong in this menu */\n groups: GroupsInSingleColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menu that contains multiple columns with headers */\nexport type MultiColumnMenu = {\n /** Columns that belong in this menu */\n columns: ColumnsWithHeaders;\n /** Groups that belong in this menu */\n groups: GroupsInMultiColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menus for one single web view */\nexport type WebViewMenu = {\n /** Indicates whether the platform default menus should be included for this webview */\n includeDefaults: boolean | undefined;\n /** Menu that opens when you click on the top left corner of a tab */\n topMenu: MultiColumnMenu | undefined;\n /** Menu that opens when you right click on the main body/area of a tab */\n contextMenu: SingleColumnMenu | undefined;\n};\n\n/** Menus for all web views */\nexport type WebViewMenus = {\n /** Named web view */\n [property: ReferencedItem]: WebViewMenu;\n};\n\n/** Platform.Bible menus before they are localized */\nexport type PlatformMenus = {\n /** Top level menu for the application */\n mainMenu: MultiColumnMenu;\n /** Menus that apply per web view in the application */\n webViewMenus: WebViewMenus;\n /** Default context menu for web views that don't specify their own */\n defaultWebViewContextMenu: SingleColumnMenu;\n /** Default top menu for web views that don't specify their own */\n defaultWebViewTopMenu: MultiColumnMenu;\n};\n\n/**\n * Type that converts any menu type before it is localized to what it is after it is localized. This\n * can be applied to any menu type as needed.\n */\nexport type Localized = ReplaceType, ReferencedItem, string>;\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n/** JSON schema object that aligns with the PlatformMenus type */\nexport const menuDocumentSchema = {\n title: 'Platform.Bible menus',\n type: 'object',\n properties: {\n mainMenu: {\n description: 'Top level menu for the application',\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewTopMenu: {\n description: \"Default top menu for web views that don't specify their own\",\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewContextMenu: {\n description: \"Default context menu for web views that don't specify their own\",\n $ref: '#/$defs/singleColumnMenu',\n },\n webViewMenus: {\n description: 'Menus that apply per web view in the application',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/menusForOneWebView',\n },\n },\n additionalProperties: false,\n },\n },\n required: ['mainMenu', 'defaultWebViewTopMenu', 'defaultWebViewContextMenu', 'webViewMenus'],\n additionalProperties: false,\n $defs: {\n localizeKey: {\n description:\n \"Identifier for a string that will be localized in a menu based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n },\n referencedItem: {\n description:\n 'Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command)',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n },\n columnsWithHeaders: {\n description:\n 'Group of columns that can be combined with other columns to form a multi-column menu',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single column with a header string',\n type: 'object',\n properties: {\n label: {\n description: 'Header text for this this column in the UI',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n order: {\n description:\n 'Relative order of this column compared to other columns (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu groups to this column',\n type: 'boolean',\n },\n },\n required: ['label', 'order'],\n additionalProperties: false,\n },\n },\n properties: {\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add columns to this multi-column menu',\n type: 'boolean',\n },\n },\n },\n menuGroups: {\n description:\n 'Group of menu items that can be combined with other groups to form a single menu/submenu. Groups are separated using a line within the menu/submenu.',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single group that contains menu items',\n type: 'object',\n oneOf: [\n {\n properties: {\n column: {\n description:\n 'Column where this group belongs, not required for single column menus',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['order'],\n additionalProperties: false,\n },\n {\n properties: {\n menuItem: {\n description: 'Menu item that anchors the submenu where this group belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['menuItem', 'order'],\n additionalProperties: false,\n },\n ],\n },\n },\n additionalProperties: false,\n },\n menuItem: {\n description:\n 'Single item in a menu that can be clicked on to take an action or can be the parent of a submenu',\n type: 'object',\n oneOf: [\n {\n properties: {\n id: {\n description: 'ID for this menu item that holds a submenu',\n $ref: '#/$defs/referencedItem',\n },\n },\n required: ['id'],\n },\n {\n properties: {\n command: {\n description: 'Name of the PAPI command to run when this menu item is selected.',\n $ref: '#/$defs/referencedItem',\n },\n iconPathBefore: {\n description:\n 'Uri path to the icon to display before the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n iconPathAfter: {\n description:\n 'Uri path to the icon to display after the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n },\n required: ['command'],\n },\n ],\n properties: {\n label: {\n description: 'Key that represents the text of this menu item to display',\n $ref: '#/$defs/localizeKey',\n },\n tooltip: {\n description:\n 'Key that represents the text to display if a mouse pointer hovers over the menu item',\n $ref: '#/$defs/localizeKey',\n },\n searchTerms: {\n description:\n 'Key that represents additional words the platform should reference when users are searching for menu items',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n group: {\n description: 'Group to which this menu item belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this menu item compared to other menu items in the same group (sorted ascending)',\n type: 'number',\n },\n },\n required: ['label', 'group', 'order'],\n unevaluatedProperties: false,\n },\n groupsAndItems: {\n description: 'Core schema for a column',\n type: 'object',\n properties: {\n groups: {\n description: 'Groups that belong in this menu',\n $ref: '#/$defs/menuGroups',\n },\n items: {\n description: 'List of menu items that belong in this menu',\n type: 'array',\n items: { $ref: '#/$defs/menuItem' },\n uniqueItems: true,\n },\n },\n required: ['groups', 'items'],\n },\n singleColumnMenu: {\n description: 'Menu that contains a column without a header',\n type: 'object',\n allOf: [{ $ref: '#/$defs/groupsAndItems' }],\n unevaluatedProperties: false,\n },\n multiColumnMenu: {\n description: 'Menu that can contain multiple columns with headers',\n type: 'object',\n allOf: [\n { $ref: '#/$defs/groupsAndItems' },\n {\n properties: {\n columns: {\n description: 'Columns that belong in this menu',\n $ref: '#/$defs/columnsWithHeaders',\n },\n },\n required: ['columns'],\n },\n ],\n unevaluatedProperties: false,\n },\n menusForOneWebView: {\n description: 'Set of menus that are associated with a single tab',\n type: 'object',\n properties: {\n includeDefaults: {\n description:\n 'Indicates whether the platform default menus should be included for this webview',\n type: 'boolean',\n },\n topMenu: {\n description: 'Menu that opens when you click on the top left corner of a tab',\n $ref: '#/$defs/multiColumnMenu',\n },\n contextMenu: {\n description: 'Menu that opens when you right click on the main body/area of a tab',\n $ref: '#/$defs/singleColumnMenu',\n },\n },\n additionalProperties: false,\n },\n },\n};\n\nObject.freeze(menuDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\nimport { LocalizeKey } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the themes it provides. */\nexport type ThemeContribution = ThemeFamiliesById;\n\n/** Object whose keys are theme family ids and whose values are {@link ThemeFamily}. */\nexport interface ThemeFamiliesById {\n [themeFamilyId: string]: ThemeFamily | undefined;\n}\n\n/**\n * A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\n *\n * A theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type\n * to determine how to look. Colors not present in the theme will fall back to the built-in colors\n * for this type.\n */\nexport interface ThemeFamily {\n [themeType: string]: ThemeDefinition | undefined;\n light?: ThemeDefinition;\n dark?: ThemeDefinition;\n}\n\n/**\n * The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark)\n * and belongs to a theme family. An extension can provide multiple themes with\n * {@link ThemeContribution}.\n */\nexport interface ThemeDefinition {\n [k: string]: unknown;\n /** LocalizeKey that is the display name for the theme */\n label: LocalizeKey;\n /**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\n cssVariables: ThemeCssVariables;\n}\n/**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\nexport interface ThemeCssVariables {\n [variableName: string]: string | undefined;\n background?: string;\n foreground?: string;\n card?: string;\n 'card-foreground'?: string;\n popover?: string;\n 'popover-foreground'?: string;\n primary?: string;\n 'primary-foreground'?: string;\n secondary?: string;\n 'secondary-foreground'?: string;\n muted?: string;\n 'muted-foreground'?: string;\n accent?: string;\n 'accent-foreground'?: string;\n destructive?: string;\n 'destructive-foreground'?: string;\n border?: string;\n input?: string;\n ring?: string;\n 'sidebar-background'?: string;\n 'sidebar-foreground'?: string;\n 'sidebar-primary'?: string;\n 'sidebar-primary-foreground'?: string;\n 'sidebar-accent'?: string;\n 'sidebar-accent-foreground'?: string;\n 'sidebar-border'?: string;\n 'sidebar-ring'?: string;\n radius?: string;\n}\n\nconst themeDefs = {\n themeCssVariables: {\n description:\n \"Theme colors and other CSS variable properties that adjust the looks of the application. These are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like `tw-bg-primary`\\n\\nSee the wiki's [Matching Application Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme) section for more information.\",\n type: 'object',\n properties: {\n background: { type: 'string' },\n foreground: { type: 'string' },\n card: { type: 'string' },\n 'card-foreground': { type: 'string' },\n popover: { type: 'string' },\n 'popover-foreground': { type: 'string' },\n primary: { type: 'string' },\n 'primary-foreground': { type: 'string' },\n secondary: { type: 'string' },\n 'secondary-foreground': { type: 'string' },\n muted: { type: 'string' },\n 'muted-foreground': { type: 'string' },\n accent: { type: 'string' },\n 'accent-foreground': { type: 'string' },\n destructive: { type: 'string' },\n 'destructive-foreground': { type: 'string' },\n border: { type: 'string' },\n input: { type: 'string' },\n ring: { type: 'string' },\n 'sidebar-background': { type: 'string' },\n 'sidebar-foreground': { type: 'string' },\n 'sidebar-primary': { type: 'string' },\n 'sidebar-primary-foreground': { type: 'string' },\n 'sidebar-accent': { type: 'string' },\n 'sidebar-accent-foreground': { type: 'string' },\n 'sidebar-border': { type: 'string' },\n 'sidebar-ring': { type: 'string' },\n radius: { type: 'string' },\n },\n additionalProperties: { anyOf: [{ type: 'string' }, { type: 'null' }] },\n },\n themeDefinition: {\n description:\n 'The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark) and belongs to a theme family. An extension can provide multiple themes with {@link ThemeContribution}.',\n type: 'object',\n properties: {\n label: {\n description: 'LocalizeKey that is the display name for the theme',\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n cssVariables: {\n $ref: '#/$defs/themeCssVariables',\n },\n },\n required: ['label', 'cssVariables'],\n },\n themeFamily: {\n description:\n 'A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\\n\\nA theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to look. Colors not present in the theme will fall back to the built-in colors for this type.',\n type: 'object',\n properties: {\n light: {\n $ref: '#/$defs/themeDefinition',\n },\n dark: {\n $ref: '#/$defs/themeDefinition',\n },\n },\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeDefinition',\n },\n { type: 'null' },\n ],\n },\n },\n themeFamiliesById: {\n description: 'Object whose keys are theme family ids and whose values are {@link ThemeFamily}.',\n type: 'object',\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeFamily',\n },\n { type: 'null' },\n ],\n },\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(themeDefs);\n\n// JSON schema object for ThemeContribution\nexport const themeDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Theme Contribution',\n description: 'The data an extension provides to inform Platform.Bible of the themes it provides.',\n anyOf: [\n {\n $ref: '#/$defs/themeFamiliesById',\n },\n ],\n $defs: themeDefs,\n};\n\nObject.freeze(themeDocumentSchema);\n","import { ReplaceType } from '../util';\nimport { ThemeDefinition, ThemeFamiliesById, ThemeFamily } from './theme.model';\n\n/**\n * {@link ThemeDefinition} with some additional properties derived from the {@link ThemeFamiliesById}\n * it comes from to help with managing the theme\n */\nexport type ThemeDefinitionExpanded = ThemeDefinition & {\n /**\n * Unique identifier for the {@link ThemeFamily} this theme is in.\n *\n * This is derived from the key of the {@link ThemeFamiliesById} this theme is in\n */\n themeFamilyId: string;\n /**\n * The kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to\n * look. Colors not present in the theme will fall back to the built-in colors for this type.\n *\n * This is derived from the key of the {@link ThemeFamily} this theme is in\n */\n type: string;\n /**\n * Unique identifier for this theme.\n *\n * This is derived by combining the theme family and type\n */\n id: string;\n};\n\n/**\n * Replaces {@link ThemeDefinition} with {@link ThemeDefinitionExpanded} recursively in the provided\n * type. Modifies the type to what is used in the theme service.\n */\nexport type ExpandThemeDefinition = ReplaceType;\n\n/**\n * {@link ThemeFamily} with all {@link ThemeDefinition} replaced by {@link ThemeDefinitionExpanded}.\n * This is used in the theme service\n */\nexport type ThemeFamilyExpanded = ExpandThemeDefinition;\n\n/**\n * {@link ThemeFamiliesById} with all {@link ThemeDefinition} replaced by\n * {@link ThemeDefinitionExpanded}. This is used in the theme service\n */\nexport type ThemeFamiliesByIdExpanded = ExpandThemeDefinition;\n\n/** ID for the style element the theme styles should go into */\nexport const THEME_STYLE_ELEMENT_ID = 'theme-styles';\n\nfunction getThemeId(themeFamilyId: string, type: string) {\n return `${themeFamilyId ? `${themeFamilyId}-` : ''}${type}`;\n}\n\n/**\n * Add the derived properties in {@link ThemeDefinitionExpanded} to {@link ThemeDefinition}s in the\n * given {@link ThemeFamiliesById} and fill in any missing `cssVariables` in the theme definitions\n * with those from the default themes.\n *\n * Does not modify the input object.\n *\n * @param themeFamiliesById Theme families to expand with the additional derived properties\n * @param defaultThemeFamily If provided, themes from this family are used to fill in missing\n * `cssVariables` in the theme definitions to make sure each theme definition has all necessary\n * `cssVariables`\n * @returns The expanded theme families\n */\nexport function expandThemeContribution(\n themeFamiliesById: ThemeFamiliesById,\n defaultThemeFamily: ThemeFamily | undefined,\n): ThemeFamiliesByIdExpanded {\n const themeFamiliesByIdExpanded: ThemeFamiliesByIdExpanded = Object.fromEntries(\n Object.entries(themeFamiliesById)\n .map(([themeFamilyId, themeFamily]) => [\n themeFamilyId,\n themeFamily\n ? Object.fromEntries(\n Object.entries(themeFamily)\n .map(([type, themeDefinition]): [string, ThemeDefinitionExpanded | undefined] => [\n type,\n themeDefinition\n ? {\n ...themeDefinition,\n // Add the derived properties\n themeFamilyId,\n type,\n id: getThemeId(themeFamilyId, type),\n cssVariables: {\n // Fill in the default css variables\n ...defaultThemeFamily?.[type]?.cssVariables,\n ...themeDefinition.cssVariables,\n },\n }\n : undefined,\n ])\n .filter(([, themeDefinition]) => !!themeDefinition),\n )\n : undefined,\n ])\n .filter(([, themeFamily]) => !!themeFamily),\n );\n return themeFamiliesByIdExpanded;\n}\n\n/** Gets the CSS stylesheet that should be applied for the given theme */\nexport function getStylesheetForTheme(theme: ThemeDefinitionExpanded): string {\n return `\n.${theme.id} {\n${Object.entries(theme.cssVariables)\n .map(([variableName, value]) => ` --${variableName}: ${value};`)\n .join('\\n')}\n}\n`;\n}\n\n/**\n * Applies a CSS stylesheet for the provided theme to the current window\n *\n * WARNING: THIS MUST BE BOUND TO `window` IN ORDER TO USE!\n *\n * ```ts\n * applyThemeStylesheet.bind(window)()`\n * ```\n *\n * @param theme Theme to apply\n * @param previousStyleElement Previous style element if applicable\n * @param styleElementIdSuffix Suffix to apply to the ID of the new style element. Will be\n * {@link THEME_STYLE_ELEMENT_ID} with a dash and the suffix added to it\n * @returns\n */\n// Must use `this` so it works across iframes\nexport function applyThemeStylesheet(\n this: Window,\n theme: ThemeDefinitionExpanded,\n previousStyleElement?: HTMLStyleElement,\n styleElementIdSuffix?: string,\n): HTMLStyleElement {\n // Set the class on the body\n const previousThemeId = previousStyleElement?.dataset.themeId;\n if (previousThemeId) this.document.body.classList.remove(previousThemeId);\n this.document.body.classList.add(theme.id);\n\n // Set up the stylesheet element\n if (previousStyleElement) this.document.head.removeChild(previousStyleElement);\n const themeStyleElement = this.document.createElement('style');\n themeStyleElement.id = `${THEME_STYLE_ELEMENT_ID}${styleElementIdSuffix ? `-${styleElementIdSuffix}` : ''}`;\n themeStyleElement.dataset.themeId = theme.id;\n themeStyleElement.textContent = getStylesheetForTheme(theme);\n this.document.head.appendChild(themeStyleElement);\n return themeStyleElement;\n}\n","/**\n * Information about a USFM marker that is just an attribute in USX/USJ. See {@link MarkerInfo} for\n * other kinds of markers.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker instead in USX/USJ.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for `v`. `cat`\n * is an attribute marker for `f`, `esb`, and more.\n *\n * Following is an example of using the `ca` and `cp` attribute markers in USFM:\n *\n * ```usfm\n * \\c 1 \\ca 2\\ca*\n * \\cp A\n * \\s1 This is a section header\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * This is a section header\n * ```\n */\nexport type AttributeMarkerInfo = NormalMarkerInfo & {\n /**\n * List of normal marker names for which this marker is an attribute marker.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` for both\n * `ca` and `cp`.\n */\n isAttributeMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an attribute marker.\n *\n * @example\n *\n * Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`.\n * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isAttributeMarkerForRegExp?: string[];\n /**\n * The name of the USX/USJ attribute this attribute marker represents.\n *\n * @example\n *\n * `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the `c` marker\n * in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` marker.\n */\n attributeMarkerAttributeName: string;\n /**\n * Whether there should be a structural space after the normal closing marker in output USFM if\n * this marker is an attribute marker. If this marker is not an attribute marker, it should not\n * have a structural space after the normal closing marker.\n *\n * This field should be ignored if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `true`\n * because this space is only supposed to be added in contexts in which the space here is\n * structural. Otherwise we would be mistakenly adding content to the USFM.\n *\n * Note that, if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `false` (which is the\n * case according to spec), horizontal spaces after attribute markers are always considered\n * structural; this property only indicates whether there should be a space after the attribute\n * marker when outputting USFM as opposed to parsing it.\n *\n * If not present or `undefined`, defaults to `false`.\n *\n * @example\n *\n * According to specification, the `va` and `vp` attribute markers have a space after their normal\n * closing markers:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp 10 vp\\vp* Some verse text\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n *\n * However, when the `vp` marker is not an attribute marker, such as when it has markers in its\n * contents, there should not be a structural space after the normal closing marker, and any space\n * should be considered content:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp \\+wj 10 vp\\+wj*\\vp* Some verse text.\n * ```\n *\n * The verse text in this example is \" Some verse text\" including a space at the start.\n *\n * @example\n *\n * The `cat` attribute marker does not have a structural space after its normal closing marker:\n *\n * ```usfm\n * \\f + \\cat category here\\cat*\\fr 1:2 \\ft Some footnote text\\f*\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n */\n hasStructuralSpaceAfterCloseAttributeMarker?: boolean;\n};\n\n/**\n * Information about a regular USFM/USX/USJ marker. See {@link MarkerInfo} for other kinds of\n * markers.\n */\nexport type NormalMarkerInfo = {\n /**\n * Which marker type the marker is. Determines how the marker is structured in the data such as\n * what kind of mandatory whitespace is around the marker in USFM. See {@link MarkerTypeInfoBase}\n * for information.\n */\n type: string;\n /** Explanation of the meaning of this marker */\n description?: string;\n /**\n * Which attribute can be provided without specifying the attribute name in USFM.\n *\n * A marker can have a default attribute only if it has zero or one non-optional attributes.\n *\n * An attribute can be provided with default syntax in the USFM only if it is the only attribute\n * provided for the marker.\n *\n * @example\n *\n * A marker with a default attribute:\n *\n * ```usfm\n * \\w stuff|thisIsTheLemmaDefaultAttribute\\w*\n * ```\n *\n * @example\n *\n * A marker with multiple attributes (cannot use default attribute syntax):\n *\n * ```usfm\n * \\w stuff|lemma=\"thisIsTheLemma\" strong=\"H1234,G1234\"\\w*\n * ```\n */\n defaultAttribute?: string;\n /**\n * The name of the text content attribute that is present on this marker if this marker has text\n * content in USFM.\n *\n * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual\n * text content of the marker.\n *\n * @example\n *\n * `alt` is a text content attribute on the `periph` marker. This value would be `alt` for the\n * `periph` marker.\n *\n * Following is an example of a `periph` marker in USFM:\n *\n * ```usfm\n * \\periph Example Peripheral|id=\"x-example\"\n * \\p Some contents of the example peripheral\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * Some contents of the example peripheral\n * \n * ```\n */\n textContentAttribute?: string;\n /**\n * List of leading attributes that must be present on this marker. This list is ordered by the\n * order in which the attributes should appear.\n *\n * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker\n * and separated only by a space.\n *\n * @example\n *\n * `code` is a leading attribute on the `id` marker. This value would be `['code']` for the `id`\n * marker.\n *\n * Following is an example of an `id` marker in USFM:\n *\n * ```usfm\n * \\id MAT 41MATEX.SFM, Example Translation, September 2025\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * 41MATEX.SFM, Example Translation, September 2025\n * ```\n */\n leadingAttributes?: string[];\n /**\n * List of attribute markers that may be present on this marker. This list is ordered by the order\n * in which the markers should appear.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker in USX/USJ.\n *\n * Note: the attribute names for attribute markers may be different than the marker names. See\n * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for `c`.\n */\n attributeMarkers?: string[];\n /**\n * Whether the normal closing marker for this marker is considered optional in USFM, meaning in\n * some cases that the normal closing marker would be expected not to be present.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `true`, this marker\n * may or may not be expected to have a normal closing marker actually present in USFM depending\n * on the value of this property.\n *\n * - If this is `true`, the normal closing marker for this marker in USFM may be expected to be\n * present or absent depending on the value of\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}. If\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `true`, this marker is expected to\n * have the normal closing marker actually present in USFM just like markers for which this\n * property is `false`. If {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `false`,\n * this marker is expected not to have the normal closing marker actually present in USFM. The\n * `closed` attribute should be present if the presence of a normal closing marker for this\n * marker in USFM does not match the presence implied by\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}.\n * - If this is `false`, the normal closing marker for this marker in USFM is expected to always be\n * present. If the normal closing marker is absent in USFM, the USX/USJ for this marker should\n * have the attribute `closed` set to `false`.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `false`, this\n * property is unused; markers of that type do not have a normal closing marker.\n *\n * If not present or `undefined`, defaults to `false`\n */\n isClosingMarkerOptional?: boolean;\n /**\n * List of independent closing marker names for this marker in USFM if it has any. If this is\n * defined, this marker does not have a normal closing marker but rather is closed by a completely\n * separate marker in USFM. All contents between this marker and the independent closing marker\n * are contents of this marker. In USX and USJ, this marker is closed normally like any other\n * object because USX and USJ have clear hierarchical structure.\n *\n * Note that independent closing markers do not have a `*` at the end because they are not normal\n * closing marker for but rather are completely separate markers that close the corresponding\n * opening marker.\n *\n * @example\n *\n * `esb` (a sidebar) is closed by the independent closing marker `esbe`.\n * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a\n * sidebar:\n *\n * ```usfm\n * \\esb\n * \\p This paragraph is in a \\bd sidebar\\bd*.\n * \\p The sidebar can contain multiple paragraphs.\n * \\esbe\n * ```\n */\n independentClosingMarkers?: string[];\n /**\n * List of marker names for which this marker is an independent closing marker. See\n * {@link NormalMarkerInfo.independentClosingMarkers} for more information on independent closing\n * markers and their syntax.\n *\n * @example\n *\n * `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` would be\n * `['esb']` for `esbe`.\n */\n isIndependentClosingMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an independent closing\n * marker. See {@link NormalMarkerInfo.independentClosingMarkers} for more information on\n * independent closing markers and their syntax.\n *\n * @example\n *\n * Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp `/test/`.\n * `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isIndependentClosingMarkerForRegExp?: string[];\n /**\n * Marker to use when operating on the USFM representation of this marker. For example, when\n * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used\n * instead of the marker info for the marker as listed in USX or USJ.\n *\n * @example\n *\n * When the `usx` marker is output to USFM, it should be transformed to the `usfm` marker.\n */\n markerUsfm?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker when\n * transforming from USFM to USX or USJ. These instructions are an explanation of what needs to be\n * done to this marker to properly transform it to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker that is essential for proper translation between formats.\n *\n * @example\n *\n * `w` is a `char`-type marker, so it shares the characteristics of the `char` {@link MarkerTypeInfo}\n * with other `char`-type markers and has its own set of characteristics. `w`'s `MarkerInfo` is as\n * follows:\n *\n * ```json\n * {\n * \"type\": \"char\",\n * \"defaultAttribute\": \"lemma\"\n * }\n * ```\n */\nexport type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo;\n\n/**\n * Information about a USFM/USX/USJ marker type that has a closing marker. See {@link MarkerTypeInfo}\n * for other kinds of marker types.\n *\n * If the marker type has a closing marker but the closing marker is not present in the USFM for a\n * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to\n * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`.\n *\n * @example\n *\n * `char` marker types such as `nd` markers have closing markers, but `para` markers such as `p` do\n * not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type CloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable: true;\n /**\n * Whether the closing marker for markers of this type is \"empty\" in USFM, meaning the marker name\n * is absent from the closing marker. This also means that there should not be a structural space\n * between the opening and the closing markers in USFM if there are no attributes listed on the\n * marker.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker:\n *\n * ```usfm\n * \\qt1-s\\*\n * ...\n * \\qt1-e\\*\n * ```\n *\n * The closing marker for `qt1-s` is `\\*` as opposed to the closing marker for `nd` which is\n * `\\nd*`.\n *\n * Note that there is still a structural space after the opening marker if there are attributes\n * present:\n *\n * ```usfm\n * \\qt1-s |Someone\\*\n * ...\n * \\qt1-e\\*\n * ```\n */\n isClosingMarkerEmpty?: boolean;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that does not have a closing marker. See\n * {@link MarkerTypeInfo} for other kinds of marker types.\n *\n * @example\n *\n * `char` marker types such as `nd` markers have closing markers, but `para` marker types such as\n * `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type NonCloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable?: false;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is common to all marker types. See\n * {@link MarkerTypeInfo} for various kinds of marker types.\n */\nexport type MarkerTypeInfoBase = {\n /** Explanation of the meaning of this marker type */\n description?: string;\n /**\n * Whether markers of this type should have a `style` attribute in USX/USJ.\n *\n * If this is `false`, it also means the marker type is the same as the marker name.\n *\n * If not present or `undefined`, defaults to `true`.\n */\n hasStyleAttribute?: boolean;\n /**\n * List of attributes that should not be output to USFM on markers of this type.\n *\n * This is used for attributes that are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example\n *\n * The `sid` attribute on the `verse` type marker is not present in USFM because it is derived\n * metadata in USX/USJ and is not present in USFM.\n */\n skipOutputAttributeToUsfm?: string[];\n /**\n * List of attributes indicating whether to skip outputting this marker to USFM. If any of the\n * listed attributes is present on the marker, skip outputting this marker when converting to\n * USFM. Only skip outputting the opening and closing marker representations, though; the content\n * inside the marker (if present) should not be skipped.\n *\n * This is used for certain markers that sometimes are normal markers but sometimes are derived\n * metadata and are not present in USFM. These derived metadata markers are identified by whether\n * they have specific attributes on them.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example\n *\n * If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the end of\n * the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the `verse`\n * marker does not have the `style=\"v\"` attribute in this situation, so this list of attributes is\n * on the marker type.\n *\n * Following is an example of a derived metadata `verse` marker in USX:\n *\n * ```xml\n * \n * \n * This is verse 21.\n * \n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\p\n * \\v 21 This is verse 21.\n * ```\n *\n * @example\n *\n * Generated `ref`s should be skipped but have content inside the marker that should not be\n * skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have\n * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived\n * metadata have the `gen` attribute set to `\"true\"` and can be removed if `gen=\"true\"` is\n * present.\n *\n * Following is an example of a generated `ref` in USX:\n *\n * ```xml\n * \n * 2Sam 1:1; 2Sam 1:2-3.\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\xt 2Sam 1:1; 2Sam 1:2-3.\\xt*\n * ```\n */\n skipOutputMarkerToUsfmIfAttributeIsPresent?: string[];\n /**\n * Whether to always skip outputting this marker when converting to USFM. Only skip outputting the\n * opening and closing marker representations, though; the content inside the marker (if present)\n * should not be skipped.\n *\n * This is used for marker types that have no representation in USFM in a given version, likely\n * meaning they are derived metadata and are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ and is\n * not preserved when transforming from USX/USJ to USFM.\n *\n * Following is an example of a derived metadata `table` marker in USX:\n *\n * ```xml\n * \n * \n * \n * Header 1\n * Header 2 space after \n * Header 3-4 centered\n * Header 5 right\n * \n * \n * Row 1 cell 1\n * Row 1 cell 2 space after \n * Row 1 cell 3 centered\n * Row 1 cell 4-5 right\n * \n * \n * Row 2 cell 1-4 right\n * Row 2 cell 5\n * \n *
\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\tr \\th1 Header 1\\th2 Header 2 space after \\thc3-4 Header 3-4 centered\\thr5 Header 5 right\n * \\tr \\tc1 Row 1 cell 1\\tc2 Row 1 cell 2 space after \\thc3 Row 1 cell 3 centered\\thr4-5 Row 1 cell 4-5 right\n * \\tr \\tcr1-4 Row 2 cell 1-4 right\\tc5 Row 2 cell 5\n * ```\n */\n skipOutputMarkerToUsfm?: boolean;\n /**\n * Whether markers of this type should have a newline before them in USFM.\n *\n * Note that the newline is never strictly necessary, and it is not usually present if the very\n * first marker in the file (or in examples such as the following example) should have a newline.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * `para` marker types such as `p` should have a newline, but `char` marker types such as `nd`\n * markers should not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\n hasNewlineBefore?: boolean;\n /**\n * Marker type to use when operating on the USFM representation of markers of this type. For\n * example, when outputting to USFM, the marker type listed here in `markerTypeUsfm` should be\n * used instead of the marker's type as listed in USX or USJ.\n */\n markerTypeUsfm?: string;\n /**\n * Marker type to use when operating on the USX representation of markers of this type. For\n * example, when outputting to USX, the marker type listed here in `markerTypeUsx` should be used\n * instead of the marker's type as listed in USFM or USJ.\n */\n markerTypeUsx?: string;\n /**\n * Marker type to use when operating on the USJ representation of markers of this type. For\n * example, when outputting to USJ, the marker type listed here in `markerTypeUsj` should be used\n * instead of the marker's type as listed in USFM or USX.\n */\n markerTypeUsj?: string;\n /**\n * Prefix to add to the opening and closing marker before the marker name if a marker of this type\n * occurs within another marker of this type when outputting to USFM.\n *\n * @example\n *\n * In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is an\n * example of `nd` inside `wj` (both are `char`-type markers) in USFM:\n *\n * ```usfm\n * \\p \\wj This is \\+nd nested\\+nd*!\\wj*\n * ```\n */\n nestedPrefix?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming to USFM. These instructions are an explanation of what needs to be done to\n * markers of this type to properly transform the marker to USFM.\n *\n * This property is generally only included when it is exceptionally difficult to output a marker\n * properly to USFM; the markers map attempts to use this property as little as possible, favoring\n * encoding information in other properties for more automatic transformation instead.\n */\n outputToUsfmInstructions?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming from USFM to USX or USJ. These instructions are an explanation of what needs\n * to be done to markers of this type to properly transform the marker to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is essential for proper translation between\n * formats.\n *\n * @example\n *\n * `char` is a marker type, which means markers like `w` whose marker type is `char` share some\n * characteristics, and each marker also has its own set of characteristics which are presented with\n * type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows:\n *\n * ```json\n * {\n * \"isCloseable\": true,\n * \"nestedPrefix\": \"+\"\n * }\n * ```\n */\nexport type MarkerTypeInfo = CloseableMarkerTypeInfo | NonCloseableMarkerTypeInfo;\n\n/** A map of all USFM/USX/USJ markers and some information about them */\nexport type MarkersMap = {\n /** Which version of USFM/USX/USJ this map represents */\n version: string;\n /** Which repository this map came from. */\n schemaRepo: string;\n /**\n * Which commit this map came from. This is necessary because the schema file seems to be\n * distributed multiple times in one release version. As such, this specifies the exact version of\n * the schema file.\n */\n schemaCommit: string;\n /**\n * Which version of the markers map types this markers map conforms to. Follows [Semantic\n * versioning](https://semver.org/); the same major version contains no breaking changes.\n */\n markersMapVersion: `1.${number}.${number}${string}`;\n /**\n * Which tag or commit in the `https://github.com/paranext/usfm-tools` repo this map is generated\n * from.\n *\n * Contains the output from `git tag --points-at HEAD` or `git rev-parse HEAD`\n *\n * Will also have a `+` at the end if there were working changes outside the `src/test-data`\n * folder when this was generated.\n */\n usfmToolsCommit: string;\n /**\n * Whether any whitespace after attribute markers and before the next content is not just\n * structural but should actually be considered part of the content of the marker.\n *\n * Structural whitespace is whitespace in the USFM that is required as part of the USFM syntax and\n * usually acts as a delimiter between markers and other things. Content whitespace is whitespace\n * in USFM that is part of the actual Scripture text or the \"content\" of the marker.\n *\n * According to specification, whitespace after attribute markers is not content but is just\n * structural.\n *\n * According to Paratext 9.4, whitespace after attribute markers is content and is not just\n * structural.\n *\n * This setting determines which interpretation to use when converting from USFM to USX/USJ.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n isSpaceAfterAttributeMarkersContent?: boolean;\n /**\n * Whether markers with optional closing markers (see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}) should still be explicitly closed in USFM.\n * That is, whether markers with optional closing markers still need the `closed` attribute set to\n * `\"false\"` in USX/USJ if the closing marker is not present in USFM.\n *\n * In other words, this setting determines whether markers with optional closing markers should\n * still be expected to be explicitly closed (meaning the closing marker is present in USFM) when\n * transforming USX/USJ to USFM unless otherwise indicated by the `closed` attribute.\n *\n * If this is `true` (matches Paratext 9.4), markers with optional closing markers are treated\n * like markers whose normal closing marker is not optional in that they are expected to be\n * explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they should have `closed=\"false\"`\n * - If they are explicitly closed in USFM, they do not need `closed=\"true\"`\n *\n * If this is `false` (matches specification), markers with optional closing markers are expected\n * _not_ to be explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they do not need `closed=\"false\"`\n * - If they are explicitly closed in USFM, they should have `closed=\"true\"`\n *\n * - Disclaimer: It is not clear that `closed=\"true\"` should be present in this case according to\n * `usx.rng`; it seems `usx.rng` indicates that optional closing markers should never be\n * output to USFM. It is possible that `usx.rng` considers this to be a case where\n * preserving the exact USFM is not important.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n shouldOptionalClosingMarkersBePresent?: boolean;\n /**\n * Map whose keys are the marker names and whose values are information about that marker\n *\n * If you find the marker name in this map, you do not need to search the `markersRegExp` map.\n */\n markers: Record;\n /**\n * Map whose keys are string representations of `RegExp` patterns to match against marker names\n * (using the\n * [test](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) and whose values are information about that marker\n *\n * You do not need to search this map if you found the marker name in the `markers` map.\n */\n markersRegExp: Record;\n /** Map whose keys are the marker types and whose values are information about that marker type */\n markerTypes: Record;\n};\n\n// This function should safely freeze anything, but TypeScript doesn't understand.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction deepFreeze(o: any) {\n Object.freeze(o);\n // Don't want to crash out on null\n // eslint-disable-next-line no-null/no-null\n if (o === undefined || o === null) {\n return o;\n }\n\n Object.getOwnPropertyNames(o).forEach(function freezeProperty(prop) {\n if (\n // Need to make sure to avoid null, which is an object type\n // eslint-disable-next-line no-null/no-null\n o[prop] !== null &&\n (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&\n !Object.isFrozen(o[prop])\n ) {\n deepFreeze(o[prop]);\n }\n });\n\n return o;\n}\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file\n */\nexport const USFM_MARKERS_MAP: MarkersMap = deepFreeze({\n version: '3.0.7',\n schemaRepo: 'https://github.com/ubsicap/usx.git',\n schemaCommit: '6c490bb5675d281b0fa01876fe67f6e3fd50a4ce',\n markersMapVersion: '1.0.0',\n usfmToolsCommit: '6c7bb8d75eda47893296a635c1e6e0b67165ac7f',\n markers: {\n add: {\n type: 'char',\n description: 'For a translational addition to the text',\n },\n addpn: {\n type: 'char',\n description:\n 'For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)',\n },\n b: {\n type: 'para',\n description: 'Poetry text stanza break (e.g. stanza break)',\n },\n bd: {\n type: 'char',\n description: 'A character style, use bold text',\n },\n bdit: {\n type: 'char',\n description: 'A character style, use bold + italic text',\n },\n bk: {\n type: 'char',\n description: 'For the quoted name of a book',\n },\n c: {\n type: 'chapter',\n leadingAttributes: ['number'],\n attributeMarkers: ['ca', 'cp'],\n },\n ca: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['c'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description: 'Second (alternate) chapter number',\n },\n cat: {\n type: 'char',\n attributeMarkerAttributeName: 'category',\n isAttributeMarkerFor: ['ef', 'efe', 'esb', 'ex', 'f', 'fe', 'x'],\n description: 'Note category (study Bible)',\n },\n cd: {\n type: 'para',\n description: 'Chapter Description (Publishing option D, e.g. in Russian Bibles)',\n },\n cl: {\n type: 'para',\n description: 'Chapter label used for translations that add a word such as \"Chapter\"',\n },\n cls: {\n type: 'para',\n description: 'Closure of an Epistle',\n },\n cp: {\n type: 'para',\n description: 'Published chapter number',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['c'],\n },\n d: {\n type: 'para',\n description: 'A Hebrew text heading, to provide description (e.g. Psalms)',\n },\n dc: {\n type: 'char',\n description: 'Deuterocanonical/LXX additions or insertions in the Protocanonical text',\n },\n ef: {\n type: 'note',\n description: 'Study note',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efe: {\n type: 'note',\n description: 'Extended study endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efm: {\n type: 'char',\n description: 'Reference to caller of previous footnote in a study Bible',\n },\n em: {\n type: 'char',\n description: 'A character style, use emphasized text style',\n },\n esb: {\n type: 'sidebar',\n independentClosingMarkers: ['esbe'],\n attributeMarkers: ['cat'],\n },\n esbe: {\n type: 'sidebar',\n isIndependentClosingMarkerFor: ['esb'],\n },\n ex: {\n type: 'note',\n description: 'Extended cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n f: {\n type: 'note',\n description: 'Footnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fdc: {\n type: 'char',\n description: 'Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n fe: {\n type: 'note',\n description: 'Endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fig: {\n type: 'figure',\n },\n fk: {\n type: 'char',\n description: 'A footnote keyword',\n isClosingMarkerOptional: true,\n },\n fl: {\n type: 'char',\n description:\n 'A footnote label text item, for marking or \"labelling\" the type or alternate translation being provided in the note.',\n isClosingMarkerOptional: true,\n },\n fm: {\n type: 'char',\n description: 'Reference to caller of previous footnote',\n },\n fp: {\n type: 'char',\n description: 'A Footnote additional paragraph marker',\n isClosingMarkerOptional: true,\n },\n fq: {\n type: 'char',\n description: 'A footnote scripture quote or alternate rendering',\n isClosingMarkerOptional: true,\n },\n fqa: {\n type: 'char',\n description: 'A footnote alternate rendering for a portion of scripture text',\n isClosingMarkerOptional: true,\n },\n fr: {\n type: 'char',\n description: 'The origin reference for the footnote',\n isClosingMarkerOptional: true,\n },\n ft: {\n type: 'char',\n description: 'Footnote text, Protocanon',\n isClosingMarkerOptional: true,\n },\n fv: {\n type: 'char',\n description: 'A verse number within the footnote text',\n },\n fw: {\n type: 'char',\n description:\n 'A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.',\n isClosingMarkerOptional: true,\n },\n h: {\n type: 'para',\n description: 'Running header text for a book',\n },\n h1: {\n type: 'para',\n description: 'Running header text (DEPRECATED)',\n },\n h2: {\n type: 'para',\n description: 'Running header text, left side of page (DEPRECATED)',\n },\n h3: {\n type: 'para',\n description: 'Running header text, right side of page (DEPRECATED)',\n },\n ib: {\n type: 'para',\n description: 'Introduction blank line',\n },\n id: {\n type: 'book',\n leadingAttributes: ['code'],\n },\n ide: {\n type: 'para',\n description: 'File encoding information',\n },\n ie: {\n type: 'para',\n description: 'Introduction ending marker',\n },\n iex: {\n type: 'para',\n description:\n 'Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)',\n },\n ili: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n ili1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n ili2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n im: {\n type: 'para',\n description:\n 'Introduction prose paragraph, with no first line indent (may occur after poetry)',\n },\n imi: {\n type: 'para',\n description: 'Introduction prose paragraph text, indented, with no first line indent',\n },\n imq: {\n type: 'para',\n description:\n 'Introduction prose paragraph, quote from the body text, with no first line indent',\n },\n imt: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nIntroduction major title, level 1 - (if single level)',\n },\n imt1: {\n type: 'para',\n description: 'Introduction major title, level 1 (if multiple levels)',\n },\n imt2: {\n type: 'para',\n description: 'Introduction major title, level 2',\n },\n imt3: {\n type: 'para',\n description: 'Introduction major title, level 3',\n },\n imt4: {\n type: 'para',\n description: 'Introduction major title, level 4 (usually within parenthesis)',\n },\n imte: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if single level)',\n },\n imte1: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if multiple levels)',\n },\n imte2: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 2',\n },\n io: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if single level)',\n },\n io1: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if multiple levels)',\n },\n io2: {\n type: 'para',\n description: 'Introduction outline text, level 2',\n },\n io3: {\n type: 'para',\n description: 'Introduction outline text, level 3',\n },\n io4: {\n type: 'para',\n description: 'Introduction outline text, level 4',\n },\n ior: {\n type: 'char',\n description:\n 'Introduction references range for outline entry; for marking references separately',\n },\n iot: {\n type: 'para',\n description: 'Introduction outline title',\n },\n ip: {\n type: 'para',\n description:\n 'Introduction prose paragraph\\nDivision or Section introductory paragraph (study Bible)',\n },\n ipi: {\n type: 'para',\n description: 'Introduction prose paragraph, indented, with first line indent',\n },\n ipq: {\n type: 'para',\n description: 'Introduction prose paragraph, quote from the body text',\n },\n ipr: {\n type: 'para',\n description: 'Introduction prose paragraph, right aligned',\n },\n iq: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if single level)',\n },\n iq1: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if multiple levels)',\n },\n iq2: {\n type: 'para',\n description: 'Introduction poetry text, level 2',\n },\n iq3: {\n type: 'para',\n description: 'Introduction poetry text, level 3',\n },\n iqt: {\n type: 'char',\n },\n is: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if single level)',\n },\n is1: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if multiple levels)',\n },\n is2: {\n type: 'para',\n description: 'Introduction section heading, level 2',\n },\n it: {\n type: 'char',\n description: 'A character style, use italic text',\n },\n jmp: {\n type: 'char',\n defaultAttribute: 'link-href',\n description: 'For associating linking attributes to a span of text',\n },\n k: {\n type: 'char',\n description: 'For a keyword',\n },\n k1: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 1',\n },\n k2: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 2',\n },\n lf: {\n type: 'para',\n description: 'List footer (introductory remark)',\n },\n lh: {\n type: 'para',\n description: 'List header (introductory remark)',\n },\n li: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n li1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n li2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n li3: {\n type: 'para',\n description: 'A list entry, level 3',\n },\n li4: {\n type: 'para',\n description: 'A list entry, level 4',\n },\n lik: {\n type: 'char',\n description: 'Structured list entry key text',\n },\n lim: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if single level)',\n },\n lim1: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if multiple levels)',\n },\n lim2: {\n type: 'para',\n description: 'An embedded list entry, level 2',\n },\n lim3: {\n type: 'para',\n description: 'An embedded list entry, level 3',\n },\n lim4: {\n type: 'para',\n description: 'An embedded list entry, level 4',\n },\n lit: {\n type: 'para',\n description: 'For a comment or note inserted for liturgical use',\n },\n litl: {\n type: 'char',\n description: 'List entry total text',\n },\n liv: {\n type: 'char',\n description: 'Structured list entry value 1 content (if single value)',\n },\n liv1: {\n type: 'char',\n description: 'Structured list entrt value 1 content (if multiple values)',\n },\n liv2: {\n type: 'char',\n description: 'Structured list entry value 2 content',\n },\n liv3: {\n type: 'char',\n description: 'Structured list entry value 3 content',\n },\n liv4: {\n type: 'char',\n description: 'Structured list entry value 4 content',\n },\n liv5: {\n type: 'char',\n description: 'Structured list entry value 5 content',\n },\n m: {\n type: 'para',\n description:\n 'Paragraph text, with no first line indent (may occur after poetry) aka: Paragraph Continuation',\n },\n mi: {\n type: 'para',\n description: 'Paragraph text, indented, with no first line indent; often used for discourse',\n },\n mr: {\n type: 'para',\n description: 'A major section division references range heading',\n },\n ms: {\n type: 'para',\n description: 'A major section division heading, level 1 (if single level)',\n },\n ms1: {\n type: 'para',\n description: 'A major section division heading, level 1 (if multiple levels)',\n },\n ms2: {\n type: 'para',\n description: 'A major section division heading, level 2',\n },\n ms3: {\n type: 'para',\n description: 'A major section division heading, level 3',\n },\n mt: {\n type: 'para',\n description: 'The main title of the book (if single level)',\n },\n mt1: {\n type: 'para',\n description: 'The main title of the book (if multiple levels)',\n },\n mt2: {\n type: 'para',\n description: 'A secondary title usually occurring before the main title',\n },\n mt3: {\n type: 'para',\n description: 'A tertiary title occurring after the main title',\n },\n mt4: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nA small secondary title sometimes occuring within parentheses',\n },\n mte: {\n type: 'para',\n description:\n 'The main title of the book repeated at the end of the book, level 1 (if single level)',\n },\n mte1: {\n type: 'para',\n description:\n 'The main title of the book repeat /ed at the end of the book, level 1 (if multiple levels)',\n },\n mte2: {\n type: 'para',\n description: \"A secondary title occurring before or after the 'ending' main title\",\n },\n nb: {\n type: 'para',\n description:\n 'Paragraph text, with no break from previous paragraph text (at chapter boundary)',\n },\n nd: {\n type: 'char',\n description: 'For name of deity',\n },\n ndx: {\n type: 'char',\n description: 'A subject index text item',\n },\n no: {\n type: 'char',\n description: 'A character style, use normal text',\n },\n optbreak: {\n type: 'optbreak',\n },\n ord: {\n type: 'char',\n description: 'For the text portion of an ordinal number',\n },\n p: {\n type: 'para',\n description:\n 'Paragraph text, with first line indent\\nFront or back matter text paragraph, level 1',\n },\n p1: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 1 (if multiple levels)',\n },\n p2: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 2 (if multiple levels)',\n },\n pb: {\n type: 'para',\n description:\n \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n },\n pc: {\n type: 'para',\n description: 'Inscription (paragraph text centered)',\n },\n periph: {\n type: 'periph',\n textContentAttribute: 'alt',\n },\n ph: {\n type: 'para',\n description:\n 'Paragraph text, with level 1 hanging indent (if single level) (DEPRECATED - use para@style li#)',\n },\n ph1: {\n type: 'para',\n description: 'Paragraph text, with level 1 hanging indent (if multiple levels)',\n },\n ph2: {\n type: 'para',\n description: 'Paragraph text, with level 2 hanging indent',\n },\n ph3: {\n type: 'para',\n description: 'Paragraph text, with level 3 hanging indent',\n },\n pi: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse',\n },\n pi1: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse',\n },\n pi2: {\n type: 'para',\n description:\n 'Paragraph text, level 2 indent, with first line indent; often used for discourse',\n },\n pi3: {\n type: 'para',\n description:\n 'Paragraph text, level 3 indent, with first line indent; often used for discourse',\n },\n pm: {\n type: 'para',\n description: 'Embedded text paragraph',\n },\n pmc: {\n type: 'para',\n description: 'Embedded text closing',\n },\n pmo: {\n type: 'para',\n description: 'Embedded text opening',\n },\n pmr: {\n type: 'para',\n description: 'Embedded text refrain',\n },\n pn: {\n type: 'char',\n description: 'For a proper name',\n },\n png: {\n type: 'char',\n description: 'For a geographic proper name',\n },\n po: {\n type: 'para',\n description: 'Letter opening',\n },\n pr: {\n type: 'para',\n description: 'Text refrain (paragraph right-aligned)',\n },\n pro: {\n type: 'char',\n description: 'For indicating pronunciation in CJK texts (DEPRECATED - used char@style rb)',\n },\n q: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if single level)',\n },\n q1: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if multiple levels)',\n },\n q2: {\n type: 'para',\n description: 'Poetry text, level 2 indent',\n },\n q3: {\n type: 'para',\n description: 'Poetry text, level 3 indent',\n },\n q4: {\n type: 'para',\n description: 'Poetry text, level 4 indent',\n },\n qa: {\n type: 'para',\n description: 'Poetry text, Acrostic marker/heading',\n },\n qac: {\n type: 'char',\n description:\n 'Poetry text, Acrostic markup of the first character of a line of acrostic poetry',\n },\n qc: {\n type: 'para',\n description: 'Poetry text, centered',\n },\n qd: {\n type: 'para',\n description:\n 'A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.',\n },\n qm: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if single level)',\n },\n qm1: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if multiple levels)',\n },\n qm2: {\n type: 'para',\n description: 'Poetry text, embedded, level 2 indent',\n },\n qm3: {\n type: 'para',\n description: 'Poetry text, embedded, level 3 indent',\n },\n qr: {\n type: 'para',\n description: 'Poetry text, Right Aligned',\n },\n qs: {\n type: 'char',\n description: 'Poetry text, Selah',\n },\n qt: {\n type: 'char',\n description: 'For Old Testament quoted text appearing in the New Testament',\n },\n 'qt-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt1-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt1-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt2-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt2-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt3-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt3-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt4-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt4-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt5-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt5-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n r: {\n type: 'para',\n description: 'Parallel reference(s)',\n },\n rb: {\n type: 'char',\n defaultAttribute: 'gloss',\n },\n ref: {\n type: 'ref',\n defaultAttribute: 'loc',\n },\n rem: {\n type: 'para',\n description: 'Remark',\n },\n restore: {\n type: 'para',\n description: 'Comment about when text was restored',\n },\n rq: {\n type: 'char',\n description: 'A cross-reference indicating the source text for the preceding quotation.',\n },\n s: {\n type: 'para',\n description: 'A section heading, level 1 (if single level)',\n },\n s1: {\n type: 'para',\n description: 'A section heading, level 1 (if multiple levels)',\n },\n s2: {\n type: 'para',\n description: 'A section heading, level 2 (e.g. Proverbs 22-24)',\n },\n s3: {\n type: 'para',\n description: 'A section heading, level 3 (e.g. Genesis \"The First Day\")',\n },\n s4: {\n type: 'para',\n description: 'A section heading, level 4',\n },\n sc: {\n type: 'char',\n description: 'A character style, for small capitalization text',\n },\n sd: {\n type: 'para',\n description:\n 'Vertical space used to divide the text into sections, level 1 (if single level)',\n },\n sd1: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 1 (if multiple levels)',\n },\n sd2: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 2',\n },\n sd3: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 3',\n },\n sd4: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 4',\n },\n sig: {\n type: 'char',\n description: 'For the signature of the author of an Epistle',\n },\n sls: {\n type: 'char',\n description:\n 'To represent where the original text is in a secondary language or from an alternate text source',\n },\n sp: {\n type: 'para',\n description: 'A heading, to identify the speaker (e.g. Job)',\n },\n sr: {\n type: 'para',\n description: 'A section division references range heading',\n },\n sts: {\n type: 'para',\n description: 'Status\\nRemark',\n },\n sup: {\n type: 'char',\n description:\n 'A character style, for superscript text. Typically for use in critical edition footnotes.',\n },\n 't-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 't-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n table: {\n type: 'table',\n },\n tl: {\n type: 'char',\n description: 'For transliterated words',\n },\n toc1: {\n type: 'para',\n description: 'Long table of contents text',\n },\n toc2: {\n type: 'para',\n description: 'Short table of contents text',\n },\n toc3: {\n type: 'para',\n description: 'Book Abbreviation',\n },\n toca1: {\n type: 'para',\n description: 'Alternative language long table of contents text',\n },\n toca2: {\n type: 'para',\n description: 'Alternative language short table of contents text',\n },\n toca3: {\n type: 'para',\n description: 'Alternative language book Abbreviation',\n },\n tr: {\n type: 'row',\n description: 'Table row',\n },\n ts: {\n type: 'ms',\n description:\n \"Translator's chunk (to identify chunks of text suitable for translating at one time)\",\n },\n 'ts-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'ts-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n usfm: {\n type: 'para',\n textContentAttribute: 'version',\n parseUsfmInstructions:\n \"If this marker is directly after the first id marker, this marker's version attribute should determine the version attribute of the usx or USJ marker at the top of the USX or USJ document, then this marker should be removed.\",\n },\n USJ: {\n type: 'USJ',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n usx: {\n type: 'usx',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n v: {\n type: 'verse',\n leadingAttributes: ['number'],\n attributeMarkers: ['va', 'vp'],\n },\n va: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description:\n 'Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)',\n },\n vp: {\n type: 'char',\n description:\n 'Published verse marker - this is a verse marking that would be used in the published text',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n },\n w: {\n type: 'char',\n defaultAttribute: 'lemma',\n },\n wa: {\n type: 'char',\n description: 'An Aramaic wordlist text item',\n },\n wg: {\n type: 'char',\n description: 'A Greek Wordlist text item',\n },\n wh: {\n type: 'char',\n description: 'A Hebrew wordlist text item',\n },\n wj: {\n type: 'char',\n description: 'For marking the words of Jesus',\n },\n x: {\n type: 'note',\n description: 'Cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n xdc: {\n type: 'char',\n description:\n 'Cross-reference target reference(s), Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n xk: {\n type: 'char',\n description: 'A cross reference keyword',\n isClosingMarkerOptional: true,\n },\n xnt: {\n type: 'char',\n description: 'Cross-reference target reference(s), New Testament only',\n isClosingMarkerOptional: true,\n },\n xo: {\n type: 'char',\n description: 'The cross reference origin reference',\n isClosingMarkerOptional: true,\n },\n xop: {\n type: 'char',\n description:\n 'Published cross reference origin text (origin reference that should appear in the published text)',\n isClosingMarkerOptional: true,\n },\n xot: {\n type: 'char',\n description: 'Cross-reference target reference(s), Old Testament only',\n isClosingMarkerOptional: true,\n },\n xq: {\n type: 'char',\n description: 'A cross-reference quotation from the scripture text',\n isClosingMarkerOptional: true,\n },\n xt: {\n type: 'char',\n defaultAttribute: 'link-href',\n description:\n 'A target reference(s)\\nA cross reference target reference(s)\\nThe cross reference target reference(s), protocanon only',\n isClosingMarkerOptional: true,\n },\n xta: {\n type: 'char',\n description: 'Cross reference target references added text',\n isClosingMarkerOptional: true,\n },\n },\n markersRegExp: {\n '[Zz].+': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 'qt[1-5]?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 't[hc][rc]?\\\\d+': {\n type: 'cell',\n },\n 'ts?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n },\n markerTypes: {\n book: {},\n cell: {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n },\n chapter: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n char: {\n isCloseable: true,\n nestedPrefix: '+',\n },\n figure: {\n isCloseable: true,\n outputToUsfmInstructions: 'The USX/USJ file attribute needs its name changed to src in USFM',\n parseUsfmInstructions: 'The USFM src attribute needs its name changed to file in USX/USJ',\n },\n ms: {\n isCloseable: true,\n isClosingMarkerEmpty: true,\n },\n note: {\n isCloseable: true,\n },\n optbreak: {\n hasStyleAttribute: false,\n },\n para: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['vid'],\n },\n periph: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n },\n ref: {\n isCloseable: true,\n hasStyleAttribute: false,\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['gen'],\n skipOutputMarkerToUsfm: true,\n },\n row: {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n },\n sidebar: {\n hasNewlineBefore: true,\n },\n table: {\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['vid'],\n skipOutputMarkerToUsfm: true,\n },\n 'table:cell': {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n markerTypeUsfm: 'cell',\n markerTypeUsx: 'cell',\n },\n 'table:row': {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n markerTypeUsfm: 'row',\n markerTypeUsx: 'row',\n },\n unmatched: {\n description:\n 'Paratext uses this type for closing markers that it cannot find opening markers for. They are treated like char markers but have no contents, no closing markers, and no space after the marker.',\n outputToUsfmInstructions:\n 'Do not output a structural space after the opening marker for markers with unmatched type.',\n parseUsfmInstructions:\n 'If a closing marker occurs but does not seem to have a matching opening marker, create an unmatched-type marker. There is no structural space after the unmatched-type marker; its end is determined by the asterisk at the end of the marker.',\n },\n USJ: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n usx: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n verse: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n },\n});\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file and adjusted to reflect the way Paratext 9.4 handles USFM.\n */\nexport const USFM_MARKERS_MAP_PARATEXT: MarkersMap = Object.freeze({\n ...USFM_MARKERS_MAP,\n isSpaceAfterAttributeMarkersContent: true,\n shouldOptionalClosingMarkersBePresent: true,\n});\n","// This was disabled so class functions that are similar in purpose can be grouped together\n/* eslint-disable @typescript-eslint/member-ordering */\nimport {\n USJ_TYPE,\n type MarkerContent,\n type MarkerObject,\n type Usj,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { JSONPath } from 'jsonpath-plus';\nimport { deepEqual } from '../equality-checking';\nimport { SortedNumberMap } from '../sorted-number-map';\nimport { isString } from '../util';\nimport { extractFootnotesFromUsjContent } from './footnote-util';\nimport {\n AttributeMarkerInfo,\n MarkerInfo,\n MarkersMap,\n MarkerTypeInfo,\n USFM_MARKERS_MAP as USFM_MARKERS_MAP_3_0,\n} from './markers-maps/markers-map-3.0.model';\nimport {\n BOOK_TYPE,\n CHAPTER_TYPE,\n ContentJsonPath,\n IUsjReaderWriter,\n NO_BOOK_ID,\n PropertyJsonPath,\n UsfmVerseLocation,\n UsfmVerseRefVerseLocation,\n UsjAttributeKeyLocation,\n UsjAttributeMarkerLocation,\n UsjBookLocation,\n UsjChapterLocation,\n UsjClosingAttributeMarkerLocation,\n UsjClosingMarkerLocation,\n UsjDocumentLocation,\n UsjMarkerLocation,\n UsjNodeAndDocumentLocation,\n UsjPropertyValueLocation,\n UsjReaderWriterOptions,\n UsjSearchResult,\n UsjTextContentLocation,\n UsjVerseRefBookLocation,\n UsjVerseRefChapterLocation,\n VERSE_TYPE,\n} from './usj-reader-writer.model';\n\nconst NODE_TYPES_NOT_CONTAINING_VERSE_TEXT = ['figure', 'note', 'sidebar', 'table'];\nObject.freeze(NODE_TYPES_NOT_CONTAINING_VERSE_TEXT);\n\n/** RegExp that matches all NBSP characters in a string. Used to convert NBSP in USJ to ~ in USFM */\nconst TEXT_CONTENT_NBSP_REGEXP = /\\u00A0/g;\n\n/**\n * RegExp that matches a USX/USJ table marker to get the number out of it. Used to figure out the\n * USFM cell range for table markers with `colspan` attribute in USX/USJ\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the number portion of the marker (the starting column of this cell)\n */\nconst TABLE_MARKER_NUMBER_REGEXP = /\\w+(\\d+)/;\n\n/**\n * RegExp that matches a USFM/USX/USJ verse number (optionally a span) to get the starting verse\n * number and optionally an ending verse number out of it.\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the starting number portion of the verse number\n * - 2: the ending number portion of the verse number if one exists\n *\n * Example:\n *\n * ```usfm\n * \\v 15-16\n * ```\n *\n * We would match this RegExp against `\"15-16\"`\n *\n * Match 1 would be `\"15\"`, and match 2 would be `\"16\"`\n */\nconst VERSE_MARKER_NUMBER_SPAN_REGEXP = /(\\d+)-?(\\d+)?/;\n\n/**\n * Map of USJ content arrays and objects inside content arrays to the content array owner\n *\n * Note that `USJ` markers may have parents if they are unexpectedly present within the contents of\n * the USJ document. We can tell which `USJ` marker is the top-level marker by receiving `undefined`\n * when looking up the `USJ` marker.\n */\ntype UsjParentMap = Map;\n\n/** Fragment indicating a marker closed */\ntype UsjClosingMarkerFragment = { isClosingMarker: true; forMarker: MarkerObject | Usj };\n/** Fragment indicating the value for an attribute */\ntype UsjAttributeValueFragment = { attributeValueForKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the key for an attribute */\ntype UsjAttributeKeyFragment = { attributeKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the opening of an attribute marker */\ntype UsjAttributeMarkerFragment = { attributeMarker: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the closing of an attribute marker */\ntype UsjAttributeMarkerClosingMarkerFragment = {\n attributeMarkerClosingMarker: string;\n forMarker: MarkerObject | Usj;\n};\n\n/**\n * A piece of Scripture data in a USJ document. This could be any of the following:\n *\n * 1. A marker or content string in a USJ document\n *\n * - `Usj`\n * - `MarkerContent`\n * 2. A JavaScript object representation of some part of a marker that isn't actually a JavaScript\n * object\n *\n * - `UsjClosingMarker`\n * - `UsjAttributeValue`\n * - `UsjAttributeKey` except when the attribute whose key is being pointed to is an attribute marker\n * in USFM, in which case this fragment is type 3 below. This fragment represents the USFM\n * attribute marker name in USFM (e.g. `ca`), not the attribute key name (e.g. `altnumber`)\n * 3. Part of a marker as it appears in USFM but that doesn't have a direct equivalence in USJ\n *\n * - `UsjAttributeKey` when pointing to an attribute marker. See fragment type 2 above.\n * - `UsjAttributeMarker`\n * - `UsjAttributeMarkerClosingMarker`\n *\n * This is somewhat similar to `UsfmToken` in `ParatextData.dll`, but there are many differences.\n * `UsfmToken` is a class with many methods and divides Scripture data based on the USFM contents.\n * `UsjFragment`, however, is just a union of object types (and `string`) that indicates the\n * division of Scripture data primarily by USJ contents.\n *\n * This is not the same as or similar to `IFragment` in `ParatextData.dll`. `IFragment` is a bit\n * more similar to {@link UsjFragmentInfo}.\n *\n * If you think of a better name for this, feel free to replace it.\n */\ntype UsjFragment =\n | Usj\n | MarkerContent\n | UsjClosingMarkerFragment\n | UsjAttributeValueFragment\n | UsjAttributeKeyFragment\n | UsjAttributeMarkerFragment\n | UsjAttributeMarkerClosingMarkerFragment;\n\n/**\n * Information about a fragment including its position in the USFM representation. Built while\n * determining the USFM representation of the USJ document\n */\ntype UsjFragmentInfoMinimal = {\n fragment: UsjFragment;\n indexInUsfm: number;\n};\n\n/**\n * A snippet of USFM along with information about what fragments of the marker are where in that\n * USFM snippet\n */\ntype UsfmSnippetAndUsjFragmentsInfo = {\n usfm: string;\n /** USFM position info about the fragments that are represented in this USFM string */\n fragmentsInfo: UsjFragmentInfoMinimal[];\n};\n\n/**\n * Information about a fragment that includes its position in the USFM and the USJ representation.\n * Transformed from {@link UsjFragmentInfoMinimal} in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} while sorting the fragments into the\n * right places after finishing determining the USFM representation.\n *\n * This is somewhat similar to `IFragment` in `ParatextData.dll` in that both contain information\n * that connects some position in USFM to some position in USX (`IFragment`) or USJ\n * (`UsjFragmentInfo`).\n */\ntype UsjFragmentInfo = UsjFragmentInfoMinimal & {\n /**\n * The node this fragment is on and the document location of the start of this fragment (any\n * offset property will be 0)\n */\n nodeAndDocumentLocation: UsjNodeAndDocumentLocation;\n};\n\n/** Fragments at each index in the USFM string */\ntype FragmentsByIndexInUsfm = SortedNumberMap;\n\n/**\n * Array of fragments that have the JSONPath (content or property) that is the key\n *\n * The JSONPath must be \"normalized\" as generated by UsjReaderWriter.convertWorkingStackToJsonPath\n * and UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath. Otherwise, your JSONPath will not\n * match the keys in this map.\n */\ntype FragmentsByJsonPath = Map;\n\n/**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. Used for taking an index based on the start of a verse and\n * determining the index in the whole USFM document to look up in {@link FragmentsByIndexInUsfm}.\n *\n * Notes:\n *\n * - All indices before a book id are associated with the first book id present. If there is not a\n * book id present in the USJ data, everything will be in book {@link NO_BOOK_ID}.\n * - All indices before a chapter number are associated with the first chapter number present. If\n * there is not a chapter number present in the USJ data, everything will be in chapter 0.\n * - Any indices that occur before a verse number will be in verse 0.\n * - The start of a book is at the book name, chapter 1 (or 0 if no chapter numbers), verse 0. The\n * start of a chapter is at the book name, chapter number, verse 0.\n * - There are no verse ranges in this object. Only the starting verse in any range that is found in\n * the USFM is added to this map (in {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}), so\n * we should always look up verse ranges with the starting verse in the range (in\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}). Presumably, if someone is trying to find the\n * index in USFM of a verse that isn't standalone but is in the middle of a range, they are likely\n * going to run into less obvious trouble with index in USFM calculations.\n *\n * TODO: Should we do something else to support verse ranges? Depending on how we want to support\n * them, we can do different things:\n *\n * - If we just want to support getting the first verse in a range (`SerializedVerseRef.verseNum`), we\n * don't need to change anything as this is how it works currently.\n * - If we want to support getting the verse range exactly as it appears in the text and _not_ from\n * the first verse in the range, we could change the index signature `[verseNum: number]` to be\n * accessible by `string | number` and put the `SerializedVerseRef.verse` range text as the key\n * instead of `verseNum` when it is defined and looked up (in at least\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} and\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}; maybe other places as well).\n * - If we want to support getting any verse in a range, we could add the same index in USFM for all\n * the verses within a verse range `SerializedVerseRef.verse` (in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}).\n *\n * In any case, once we come to a clear decision on what we want to do, we should probably document\n * it in the TSDoc for {@link UsjReaderWriter}.\n */\ntype IndicesInUsfmByVerseRef = {\n [book: string]:\n | {\n [chapterNum: number]:\n | {\n [verseNum: number]: number | undefined;\n }\n | undefined;\n }\n | undefined;\n};\n\n/**\n * Represents information about where a USJ node resides in the `content` array of its parent.\n * `parent` is a reference to the node's parent, and `index` represents the numeric index inside of\n * `parent`'s content array.\n */\ntype StackItem = { parent: MarkerObject | Usj; index: number };\n\n/**\n * Stack of levels inside a USJ tree relative to a specific node. The top of the stack should always\n * be the root Usj object.\n */\ntype WorkingStack = StackItem[];\n\n/**\n * Represents USJ formatted scripture with helpful utilities for working with it. Some notable\n * features:\n *\n * - Find Scripture text in the USJ document\n *\n * - `extractText`\n * - `extractTextBetweenPoints`\n * - `findNextLocationOfMatchingText`\n * - `search`\n * - `usfmVerseLocationToNextTextLocation`\n * - Edit the USJ document: `removeContentNodes`\n * - Transform USJ to USFM: `toUsfm`\n * - Transform USJ document locations to USFM locations and vice versa\n *\n * - `usfmVerseLocationToUsjDocumentLocation`\n * - `usjDocumentLocationToUsfmVerseRefVerseLocation`\n * - Use the version of USFM you need by passing in a custom markers map to the constructor if the\n * version in your USJ document is not supported by default:\n * {@link UsjReaderWriterOptions.markersMap}\n *\n * Notes:\n *\n * - \"node\" is a term used in the methods in this class that usually means an object or content string\n * somewhere in the USj document, either {@link Usj} or {@link MarkerContent}. However, in specific\n * situations, it may refer only to {@link MarkerObject} or {@link MarkerContent}. The TypeScript\n * types indicate when this is the case.\n * - See {@link UsfmVerseLocation} and {@link UsjDocumentLocation} for information about transforming\n * USFM locations and USJ locations including what kinds of USFM locations are and are not\n * representable in USJ locations, which USJ locations actually correspond to something in USJ,\n * etc.\n * - It is best to reuse the same `UsjReaderWriter` for the same USJ document as long as possible\n * because there is a significant amount of processing and caching done internally to facilitate\n * various operations. Note that, if the USJ document added to `UsjReaderWriter` changes, you must\n * run `usjChanged` to clear the internal caches and receive accurate results from future method\n * calls\n */\nexport class UsjReaderWriter implements IUsjReaderWriter {\n private readonly usj: Usj;\n private readonly markersMap: MarkersMap;\n private readonly shouldAllowInvisibleCharacters: boolean;\n\n // Cached properties\n private parentMapInternal: UsjParentMap | undefined;\n private fragmentsByIndexInUsfmInternal: FragmentsByIndexInUsfm | undefined;\n private fragmentsByJsonPathInternal: FragmentsByJsonPath | undefined;\n private indicesInUsfmByVerseRefInternal: IndicesInUsfmByVerseRef | undefined;\n private usfmInternal: string | undefined;\n\n constructor(usj: Usj, options?: UsjReaderWriterOptions) {\n this.usj = usj;\n\n const { markersMap: providedMarkersMap, shouldAllowInvisibleCharacters } = options ?? {};\n\n // If they passed in a markers map, use it\n if (providedMarkersMap) {\n this.markersMap = providedMarkersMap;\n\n // Warn if the passed in markers map is not compatible\n if (!UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, this.markersMap.version))\n console.warn(\n `Warning: USJ provided has version ${\n this.usj.version\n }, but provided markers map has version ${\n this.markersMap.version\n }. This may cause unexpected issues when transforming between formats.`,\n );\n }\n // They didn't pass in a markers map, so try to use a built-in markers map matching the USJ version\n else if (\n UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, USFM_MARKERS_MAP_3_0.version)\n )\n this.markersMap = USFM_MARKERS_MAP_3_0;\n else\n throw new Error(\n 'USJ version is not 3.0 or 3.0.x! Not equipped to handle yet without passing in a markers map',\n );\n\n if (!this.markersMap.markersMapVersion.startsWith('1.'))\n throw new Error(\n `Incompatible markers map version: ${\n this.markersMap.markersMapVersion\n }. This class only supports version 1.x.y`,\n );\n\n this.shouldAllowInvisibleCharacters = shouldAllowInvisibleCharacters ?? false;\n }\n\n // If new variables are created to speed up queries, they should be reset here\n usjChanged(): void {\n this.parentMapInternal = undefined;\n this.fragmentsByIndexInUsfmInternal = undefined;\n this.fragmentsByJsonPathInternal = undefined;\n this.indicesInUsfmByVerseRefInternal = undefined;\n this.usfmInternal = undefined;\n }\n\n private static areUsjVersionsCompatible(versionA: string, versionB: string) {\n if (versionA === '3.0' || versionA.startsWith('3.0.'))\n return versionB === '3.0' || versionB.startsWith('3.0.');\n return versionA === versionB;\n }\n\n // #region Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n findSingleValue(jsonPathQuery: string): T | undefined {\n const wrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n if (wrappedResults === undefined || wrappedResults.length === 0) return undefined;\n if (!Array.isArray(wrappedResults[0])) return wrappedResults[0];\n\n // There is no way to tell the difference between a query that returns a single result that is an\n // array and a query that returns multiple results wrapped in an array when `wrap` is false.\n // However, if `wrap` is true then a single result that is an array will be a different array\n // object than the array object within `usj`. So we need to run with `wrap` as true and false to\n // get the original array object back for a query that returns a single array.\n const unwrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: false });\n if (unwrappedResults.length === 1 && Array.isArray(unwrappedResults[0]))\n // I have no idea why eslint is mad about casting from `any` to `T`, but it doesn't like it\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return unwrappedResults[0] as T;\n return unwrappedResults;\n }\n\n findParent(jsonPathQuery: string): T | undefined {\n // Note that \"resultType: 'parent'\" does not work for queries\n // The \"jsonpath-plus\" package allows putting a carat at the end of a query to get a parent\n return this.findSingleValue(`${jsonPathQuery}^`);\n }\n\n // #endregion Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n // #region marker helper methods\n\n /**\n * Determine if the passed in marker is the top-level USJ marker.\n *\n * Note that USJ markers that are not the top-level USJ markers technically should not occur, but\n * they can occur. We should treat them like any other marker. They conform to\n * {@link MarkerObject}, so it's not hard to do.\n *\n * @param marker Marker to test if it is USJ marker\n * @returns `true` if it is a USJ marker; false otherwise\n */\n static isTopLevelUsjMarker(\n marker: Usj | MarkerContent,\n workingStack: WorkingStack,\n ): marker is Usj {\n return typeof marker === 'object' && marker.type === USJ_TYPE && workingStack.length === 0;\n }\n\n /**\n * Determine if a fragment is a marker, not a text content string or some kind of position\n * fragment that isn't actually a marker e.g. closing marker fragment\n */\n private static isFragmentAMarker(fragment: UsjFragment): fragment is MarkerObject | Usj {\n return !isString(fragment) && !('forMarker' in fragment);\n }\n\n // #endregion marker helper methods\n\n // #region Parent Maps\n\n private static createParentMapInternal(\n obj: MarkerObject,\n parent: MarkerObject | Usj,\n parentMap: UsjParentMap,\n ): void {\n parentMap.set(obj, parent);\n // USJ queries may return pointers to content arrays, not just objects\n if (obj.content) parentMap.set(obj.content, obj);\n obj.content?.forEach((child) => {\n if (typeof child === 'object') UsjReaderWriter.createParentMapInternal(child, obj, parentMap);\n });\n }\n\n /** Viewing a Usj object as a tree, build a map to walk up the tree */\n private createUsjParentMap(): UsjParentMap {\n const parentMap = new Map();\n if (this.usj.content) parentMap.set(this.usj.content, this.usj);\n this.usj.content.forEach((content) => {\n if (typeof content === 'object')\n UsjReaderWriter.createParentMapInternal(content, this.usj, parentMap);\n });\n return parentMap;\n }\n\n /** Create the parent map if it doesn't already exist and return it */\n private get parentMap(): UsjParentMap {\n if (this.parentMapInternal) return this.parentMapInternal;\n this.parentMapInternal = this.createUsjParentMap();\n return this.parentMapInternal;\n }\n\n // #endregion Parent Maps\n\n // #region Working Stacks\n\n /**\n * Checks if two stack items are equal using shallow equivalence, testing the stack item\n * properties for [strict\n * equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)\n *\n * Note that this requires the parent of the two stack items to have reference equality\n */\n private static areStackItemsShallowEqual(a: StackItem, b: StackItem): boolean {\n return a.index === b.index && a.parent === b.parent;\n }\n\n /** Return the working stack applicable to the given node */\n private createWorkingStack(node: MarkerObject | Usj): WorkingStack {\n // Represents levels in the USJ node tree that are above the current node (i.e., ancestors)\n // Levels in the tree are represented as a stack, so the last item in the stack is node's parent\n const workingStack: WorkingStack = [];\n\n // Grab a reference so we don't keep checking if it exists\n const { parentMap } = this;\n\n // `node` might be in the middle of the USJ tree, so build up the stack before walking the tree\n let tempNode: MarkerObject | Usj = node;\n let tempParent = parentMap.get(tempNode);\n while (tempParent !== undefined) {\n if (!tempParent.content)\n throw new Error('Invalid parentMap: all parents should have content');\n\n if (\n // Referencing tempNode and tempParent is OK in the loop since 'let' is used instead of 'var'\n // eslint-disable-next-line no-loop-func\n !tempParent.content.find((tempChild, index) => {\n if (tempChild !== tempNode) return false;\n if (!tempParent) throw new Error('undefined \"tempParent\" should not be possible');\n workingStack.unshift({ parent: tempParent, index });\n return true;\n })\n )\n throw new Error(`Unable to find correct parent node of ${JSON.stringify(tempNode)}`);\n\n tempNode = tempParent;\n tempParent = parentMap.get(tempParent);\n }\n\n return workingStack;\n }\n\n /**\n * Transform a JSONPath array (`JSONPath.toPathArray`) to a \"normalized\" JSONPath. We can use this\n * JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static jsonPathArrayToJsonPath(pathArray: string[]): string {\n return pathArray.reduce((pathAcc, pathEntry) => {\n if (pathEntry === 'content') return `${pathAcc}.${pathEntry}`;\n if (!Number.isNaN(parseInt(pathEntry, 10))) return `${pathAcc}[${pathEntry}]`;\n return `${pathAcc}['${pathEntry}']`;\n });\n }\n\n /** \"Normalize\" the JSONPath passed in so we can use it for lookups in {@link FragmentsByJsonPath} */\n private static normalizeJsonPath(jsonPath: string): string {\n // Convert to path array and back to standardize property access syntax\n const pathArray = JSONPath.toPathArray(jsonPath);\n return UsjReaderWriter.jsonPathArrayToJsonPath(pathArray);\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack. We can use this JSONPath\n * for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackToJsonPath(stack: WorkingStack): ContentJsonPath {\n let jsonPath = '$';\n stack.forEach((stackLevel) => {\n jsonPath = `${jsonPath}.content[${stackLevel.index}]`;\n });\n // The JSONPath string construction above conforms to the ContentJsonPath type\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return jsonPath as ContentJsonPath;\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack and property. We can use\n * this JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackAndPropertyToJsonPath(\n stack: WorkingStack,\n property: string,\n ): PropertyJsonPath {\n // Adding this property makes it conform to PropertyJsonPath. Always using bracket notation\n // because it works in more cases than dot notation does\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return `${UsjReaderWriter.convertWorkingStackToJsonPath(stack)}['${property}']` as PropertyJsonPath;\n }\n\n private convertJsonPathToWorkingStack(\n jsonPath: ContentJsonPath | PropertyJsonPath,\n ): WorkingStack {\n const retVal: WorkingStack = [];\n\n // If the JSONPath is pointing to the top marker, there are no content levels\n if (jsonPath === '$') return retVal;\n\n const levels = jsonPath.match(/content\\[(\\d+)\\]/g);\n if (!levels) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n\n let onNode: Usj | MarkerObject = this.usj;\n\n levels.forEach((level, onLevel) => {\n const indexString = /(\\d+)/.exec(level);\n if (!indexString) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n const index = parseInt(indexString[0], 10);\n retVal.push({ parent: onNode, index });\n if (onLevel + 1 < levels.length) {\n if (typeof onNode === 'string' || !onNode.content)\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(onNode)}`);\n const nextNode = onNode.content[index];\n if (typeof nextNode === 'string')\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(nextNode)}`);\n onNode = nextNode;\n }\n });\n\n return retVal;\n }\n\n // #endregion Working Stacks\n\n // #region Walk the node tree\n\n /**\n * Extract textual notes (aka, \"footnotes\") from a full USJ object.\n *\n * @returns An array of MarkerObjects representing all textual notes found in the USJ content.\n */\n findAllNotes(): MarkerObject[] {\n return extractFootnotesFromUsjContent(this.usj?.content);\n\n // Note that the following could be used instead of the above call to\n // extractFootnotesFromUsjContent, and that function could be removed. However, this is about\n // 100x slower than the custom traversal in extractFootnotesFromUsjContent.\n // return this.findAll('$.content..[?(@.type==\"note\")]');\n // This would depend on implementing findAll in this class:\n // findAll(jsonPathQuery: string): T[] {\n // const results = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n // return Array.isArray(results) ? results as T[] : [];\n // }\n }\n\n /**\n * Look through the USJ document for a node or the closing of a node matching some condition. This\n * will run `searchFunction` for `node`, all nodes encountered in `node.contents` (recursively),\n * when `node` closes, and all nodes after `node`\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes and representations of the closing of nodes will be\n * passed into to determine if they are the correct node or representation of the closing of a\n * node. Stops searching and returns the node/close if this function returns `true`\n * @returns Node or representation of the closing of a node matching condition tested by the\n * search function\n */\n private static findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNodeOrClose: MarkerContent | Usj | UsjClosingMarkerFragment,\n workingStack: WorkingStack,\n ) => boolean,\n ) {\n let nextNode: MarkerContent | Usj | undefined = node;\n\n const topNode = workingStack.length === 0 ? node : workingStack[0].parent;\n // If the top node is a marker as we would expect, we need to check if `node` is under a\n // skipped-type node and skip past all that skipped stuff if so. If the top node is a `string`,\n // don't need to worry about this since we should just be searching against that one string\n if (!isString(topNode)) {\n // Determine if we are in a skipped-type node and skip to the next node after it if so\n // If the top node is skipped, return `undefined` because everything is skipped\n if (skipTypes.includes(topNode.type)) return undefined;\n\n // Find the highest (lowest index) stack item level that is skipped so we can go to its next\n // sibling\n let highestSkippedNode: MarkerContent | undefined;\n workingStack.some((stackItem) => {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const stackNode = stackItem.parent.content![stackItem.index];\n if (!isString(stackNode) && skipTypes.includes(stackNode.type)) {\n highestSkippedNode = stackNode;\n return true;\n }\n\n return false;\n });\n\n // Set nextNode to the highest skipped node so it will skip and go to the next sibling in the\n // following code\n if (highestSkippedNode) nextNode = highestSkippedNode;\n }\n\n // Walk the nodes in a depth-first, left-to-right manner until the search function returns true\n while (nextNode !== undefined) {\n const skipNextNode = typeof nextNode === 'object' && skipTypes.includes(nextNode.type);\n\n // If we found the node we're looking for, we're done\n if (!skipNextNode && searchFunction(nextNode, workingStack)) return nextNode;\n\n // Look at the node's children\n if (!skipNextNode && typeof nextNode === 'object' && (nextNode.content?.length ?? 0) > 0) {\n workingStack.push({ parent: nextNode, index: 0 });\n // Same as `nextNode = nextNode.content[0];` without triggering 2 different eslint errors\n [nextNode] = nextNode.content;\n } else {\n if (!skipNextNode) {\n // The node has no children, so check the closing marker for this node\n const nextNodeClosingMarker: UsjClosingMarkerFragment | undefined =\n typeof nextNode === 'object'\n ? { isClosingMarker: true, forMarker: nextNode }\n : undefined;\n if (nextNodeClosingMarker && searchFunction(nextNodeClosingMarker, workingStack))\n return nextNodeClosingMarker;\n }\n\n // Then look at the next sibling, or the parent's next sibling, or the parent's closing\n // marker, etc. up the stack\n nextNode = undefined;\n while (workingStack.length > 0) {\n const nextLevel = workingStack.pop();\n if (nextLevel) {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if (nextLevel.index + 1 < nextLevel.parent.content!.length) {\n // Check the next sibling\n nextLevel.index += 1;\n workingStack.push(nextLevel);\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n nextNode = nextLevel.parent.content![nextLevel.index];\n break;\n } else {\n // There is no next sibling, so check the closing marker for the parent before we\n // continue to look at the parent's next sibling and etc.\n const parentClosingMarker: UsjClosingMarkerFragment = {\n isClosingMarker: true,\n forMarker: nextLevel.parent,\n };\n if (searchFunction(parentClosingMarker, workingStack)) return parentClosingMarker;\n }\n }\n }\n }\n }\n\n // We've looked everywhere, so there must not be an appropriate node anywhere\n return undefined;\n }\n\n /**\n * Look through the USJ document for a node matching some condition\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes will be passed into to determine if they are the\n * correct node. Stops searching and returns the node if this function returns `true`\n * @returns Node matching condition tested by the search function\n */\n private static findNextMatchingNodeUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNode: MarkerContent | Usj,\n workingStack: WorkingStack,\n ) => boolean,\n ): MarkerContent | undefined {\n // We are filtering out closing markers in our search function\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const result = this.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node,\n workingStack,\n skipTypes,\n (potentiallyMatchingNodeOrClose, currentWorkingStack) => {\n if (\n typeof potentiallyMatchingNodeOrClose === 'object' &&\n 'isClosingMarker' in potentiallyMatchingNodeOrClose\n )\n // Skip closing markers\n return false;\n\n // Just search normal markers and text as appropriate for this method\n return searchFunction(potentiallyMatchingNodeOrClose, currentWorkingStack);\n },\n ) as MarkerContent | undefined;\n\n return result;\n }\n\n // #endregion Walk the node tree\n\n // #region Node -> JSONPath\n\n nodeToJsonPath(node: MarkerObject): ContentJsonPath {\n return UsjReaderWriter.convertWorkingStackToJsonPath(this.createWorkingStack(node));\n }\n\n // #endregion Node -> JSONPath\n\n // #region USJ node -> SerializedVerseRef + offset in USFM\n\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { documentLocation: usjLocation } = this.nodeToUsjNodeAndDocumentLocation(\n node,\n nodeParent,\n );\n\n // Find the UsjFragmentInfo at this location\n return this.usjDocumentLocationToUsfmVerseRefVerseLocation(usjLocation, bookIdIfNotFound);\n }\n\n // #endregion USJ node -> SerializedVerseRef + offset in USFM\n\n // #region USJ node -> USJ location\n\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation {\n // Get working stack to the node\n let workingStack: WorkingStack;\n\n if (isString(node)) {\n // If the node is a string, we need to get the working stack from the parent and add the last\n // level for the string node\n if (nodeParent === undefined)\n throw new Error(`If \"node\" is a string, then \"nodeParent\" cannot be undefined`);\n\n // Get the real parent\n const realParent = Array.isArray(nodeParent) ? this.parentMap.get(nodeParent) : nodeParent;\n if (realParent === undefined)\n throw new Error(`Cannot find parent for ${JSON.stringify(nodeParent)}`);\n\n // Get the working stack to the parent\n workingStack = this.createWorkingStack(realParent);\n\n // Add the stack item for the string node\n const nodeIndexInParent = realParent.content?.indexOf(node);\n if (nodeIndexInParent === undefined || nodeIndexInParent < 0)\n throw new Error(`Could not find index of node in parent for creating working stack`);\n workingStack.push({ parent: realParent, index: nodeIndexInParent });\n } else {\n // The node is not a string, so it's easy to get the working stack\n workingStack = this.createWorkingStack(node);\n }\n\n // Get the UsjDocumentLocation for this node so we can find the fragment at that location\n const usjLocation = UsjReaderWriter.convertNodeToUsjDocumentLocation(node, workingStack);\n\n return {\n node,\n documentLocation: usjLocation,\n };\n }\n\n // #endregion USJ node -> USJ location\n\n // #region JSONPath > USJ location\n\n /**\n * Finds the node associated with the JSONPath provided, and also gets the parent of the node if\n * the node is a string. This is helpful so you can find a real object that is actually somewhere\n * in the USJ document from the JSONPath\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered.\n * @returns First node found at the JSONPath and the parent of that node _if_ the node is a\n * string. Note that the object returned is the actual object in the USJ document.\n */\n private jsonPathToNodeAndParentIfString(jsonPathQuery: string): {\n node: MarkerContent | Usj;\n parent: MarkerObject | Usj | MarkerContent[] | undefined;\n } {\n // Find the node this JSONPath is pointing to\n const target: MarkerContent | Usj | undefined = this.findSingleValue(jsonPathQuery);\n if (!target) throw new Error(`No result found for JSONPath query: ${jsonPathQuery}`);\n\n // Find the parent of this node if it is a string so we can know where it is\n const parent: MarkerObject | Usj | MarkerContent[] | undefined = isString(target)\n ? this.findParent(jsonPathQuery)\n : undefined;\n if (!parent && isString(target))\n throw new Error(`Could not determine parent for ${jsonPathQuery}`);\n\n return {\n node: target,\n parent,\n };\n }\n\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usjNodeAndDocumentLocation = this.nodeToUsjNodeAndDocumentLocation(node, parent);\n\n return usjNodeAndDocumentLocation;\n }\n\n // #endregion JSONPath > USJ location\n\n // #region JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usfmVerseLocation = this.nodeToUsfmVerseRefVerseLocation(node, parent, bookIdIfNotFound);\n\n return usfmVerseLocation;\n }\n\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n // Find the fragment with the matching UsjDocumentLocation except offset\n const fragmentInfo = this.findFragmentInfoAtUsjDocumentLocation(usjLocation);\n if (fragmentInfo === undefined)\n throw new Error(\n `Could not find fragment info at USJ document location while transforming to USFM verse location: ${JSON.stringify(\n usjLocation,\n )}`,\n );\n\n const verseRef = this.getVerseRefForIndexInUsfm(fragmentInfo.indexInUsfm, bookIdIfNotFound);\n\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n return {\n verseRef,\n // Final USFM verse offset is the fragment's location relative to the verse plus whatever\n // offset is in the USJ location\n offset:\n fragmentInfo.indexInUsfm -\n verseIndexInUsfm +\n UsjReaderWriter.getOffsetInUsjDocumentLocation(usjLocation),\n };\n }\n\n // #endregion JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n // #region Handling VerseRefs\n\n /**\n * Gets the book ID in the internal USJ document data corresponding to the book ID passed in.\n *\n * @param bookId The book ID to look up data in the USJ document for\n * @returns If there isn't a book ID in the USJ document, {@link NO_BOOK_ID} will be returned\n * @throws If the requested book is not found in the USJ data and there are other books\n * @throws If there is no USJ content in the document whatsoever\n */\n private getEffectiveBookId(bookId: string): string {\n const availableBookIds = Object.keys(this.indicesInUsfmByVerseRef);\n const noBookIdsFound =\n availableBookIds.length === 0 ||\n (availableBookIds.length === 1 && availableBookIds[0] === NO_BOOK_ID);\n const effectiveBookId = noBookIdsFound ? NO_BOOK_ID : bookId;\n const bookIndices = this.indicesInUsfmByVerseRef[effectiveBookId];\n if (!bookIndices)\n throw new Error(\n `Book ID ${bookId} not found in USJ! ${noBookIdsFound ? `There seems to be no USJ content because there is no content in ${NO_BOOK_ID} either` : `Book IDs in USJ: ${JSON.stringify(availableBookIds)}`}`,\n );\n\n return effectiveBookId;\n }\n\n /**\n * Gets the index in USFM of the start of the verse (the backslash on the verse marker or the\n * beginning of the chapter if verse 0 is provided)\n */\n private getIndexInUsfmForVerseRef(verseRef: SerializedVerseRef): number {\n // Make sure the requested book ID is in the USJ content\n const bookId = this.getEffectiveBookId(verseRef.book);\n // `getEffectiveBookId` guaranteed bookIndices is defined\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const bookIndices = this.indicesInUsfmByVerseRef[bookId]!;\n\n // Make sure the requested chapter number is in the USJ content\n const chapterIndices = bookIndices[verseRef.chapterNum];\n if (!chapterIndices) throw new Error(`Could not find ${bookId} chapter ${verseRef.chapterNum}`);\n\n // Make sure the requested verse number is in the USJ content\n // Only look for the verse number even if it is the starting number in a requested verse range\n // because you are likely going to run into less obvious trouble if you get the index in USFM of\n // the wrong verse in a range\n const verseIndexInUsfm = chapterIndices[verseRef.verseNum];\n if (verseIndexInUsfm === undefined)\n throw new Error(`Verse ${verseRef.verseNum} not found in ${bookId} ${verseRef.chapterNum}`);\n\n return verseIndexInUsfm;\n }\n\n /**\n * Gets the verse ref that the provided index in USFM is in (including verse range if applicable).\n * Finds the closest verse ref before the index in USFM.\n *\n * @param indexInUsfm The index in USFM from the beginning of this document\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Closest verse reference before or at the index in USFM\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n private getVerseRefForIndexInUsfm(\n indexInUsfm: number,\n bookIdIfNotFound?: string,\n ): SerializedVerseRef {\n // ENHANCE: This could be sped up and simplified significantly by storing a sorted number map of\n // verse refs by index in USFM like so:\n /**\n * Index in the USFM representation of the USJ document of where the start of each verse ref is\n * (the backslash on the verse marker)\n */\n // type VerseRefsByIndexInUsfm = SortedNumberMap;\n\n const bookEntries = Object.entries(this.indicesInUsfmByVerseRef);\n let bookIndex = 0;\n let lastVerseRef: SerializedVerseRef | undefined;\n let didFindVerseRef = false;\n\n // Loop through all the books looking for the right book\n while (!didFindVerseRef && bookIndex < bookEntries.length) {\n const [bookId, chapterIndices] = bookEntries[bookIndex];\n\n if (chapterIndices) {\n const chapterEntries = Object.entries(chapterIndices);\n let chapterIndex = 0;\n // Loop through all the chapters looking for the right chapter\n while (!didFindVerseRef && chapterIndex < chapterEntries.length) {\n const [chapterNumString, verseIndices] = chapterEntries[chapterIndex];\n if (verseIndices) {\n const verseEntries = Object.entries(verseIndices);\n let verseIndex = 0;\n // Loop through all the verses looking for the right verse\n while (!didFindVerseRef && verseIndex < verseEntries.length) {\n const [verseNumString, verseIndexInUsfm] = verseEntries[verseIndex];\n\n if (verseIndexInUsfm !== undefined) {\n // If the verse ref index in USFM is past the index in USFM to find for the first time,\n // this is the verse ref after this index in USFM. Return the last one\n if (indexInUsfm < verseIndexInUsfm) {\n if (!lastVerseRef)\n // Somehow the index to find is less than the very first known index. Maybe that\n // means it's negative? Either way, it doesn't make sense\n throw new Error(\n `Could not find verse ref for index in USFM ${\n indexInUsfm\n } less than the first known index ${verseIndexInUsfm}`,\n );\n\n // We know the last verse ref, which was the final verse ref before this index.\n // Return that last verse ref\n didFindVerseRef = true;\n break;\n }\n // This verse ref is not past the index in USFM to find, so record this current verse\n // ref to return later if we determine this is the right verse ref\n lastVerseRef = {\n book: bookId,\n chapterNum: parseInt(chapterNumString, 10),\n verseNum: parseInt(verseNumString, 10),\n };\n // If the verse ref index is the same as the index to find, go ahead and return the\n // current verse ref. No need to look at the next index\n if (indexInUsfm === verseIndexInUsfm) {\n didFindVerseRef = true;\n break;\n }\n }\n\n verseIndex += 1;\n }\n }\n\n chapterIndex += 1;\n }\n }\n\n bookIndex += 1;\n }\n\n if (!lastVerseRef)\n throw new Error(`Did not find any verse refs while looking for index in USFM ${indexInUsfm}`);\n\n if (lastVerseRef.book === NO_BOOK_ID) {\n // Deal with no book ID\n if (!bookIdIfNotFound)\n throw new Error(\n `Could not find book ID and no book ID provided when finding USFM verse ref for index in USFM ${\n indexInUsfm\n }`,\n );\n\n lastVerseRef.book = bookIdIfNotFound;\n }\n\n // If `didFindVerseRef` is `false`, the index in USFM to find is greater than all known indices\n // in USFM. That means it's in the very last verse ref. That's fine; no need to do anything\n // special.\n\n // Add the verse range if the verse marker for this location's verse is a range\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(lastVerseRef);\n const verseFragmentInfo = this.fragmentsByIndexInUsfm.get(verseIndexInUsfm);\n if (\n verseFragmentInfo &&\n UsjReaderWriter.isFragmentAMarker(verseFragmentInfo.fragment) &&\n verseFragmentInfo.fragment.type === VERSE_TYPE &&\n verseFragmentInfo.fragment.number &&\n verseFragmentInfo.fragment.number !== `${lastVerseRef.verseNum}`\n )\n lastVerseRef.verse = verseFragmentInfo.fragment.number;\n\n return lastVerseRef;\n }\n\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n if (verseRefOffset < 0) throw new Error('offset must be >= 0');\n\n // Find the index in the whole USFM of this verse\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n // Add the verse offset to the verse index to get the USFM location's index in the USFM\n // representation of this USJ document\n const usfmVerseLocationIndexInUsfm = verseIndexInUsfm + verseRefOffset;\n\n return usfmVerseLocationIndexInUsfm;\n }\n\n // #endregion Handling VerseRefs\n\n // #region transforming location types to different types\n\n /**\n * Transforms a USFM verse-based location into a single standardized format of USFM verse-based\n * location for ease of accessing the location's properties\n *\n * @param usfmVerseLocation USFM verse-based location in one of multiple forms\n * @returns USFM verse-based location in one particular form. Also ensures `offset` is defined\n * (defaults to 0 as described in {@link UsfmVerseLocation})\n */\n static usfmVerseLocationToUsfmVerseRefVerseLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsfmVerseRefVerseLocation & { offset: number } {\n if ('verseRef' in usfmVerseLocation) {\n // UsfmVerseRefVerseLocation\n return {\n verseRef: usfmVerseLocation.verseRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n if ('scrRef' in usfmVerseLocation) {\n // Old deprecated form UsfmScrRefVerseLocation\n return {\n verseRef: usfmVerseLocation.scrRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n // SerializedVerseRef\n return {\n verseRef: usfmVerseLocation,\n offset: 0,\n };\n }\n\n /**\n * Transforms a USJ chapter-based location into a single standardized format of USJ chapter-based\n * location for ease of accessing the location's properties\n *\n * @param usjChapterLocation USJ chapter-based location in one of multiple forms\n * @returns USJ chapter-based location in one particular form.\n * @throws If erroneously received a {@link UsjBookLocation}, not a {@link UsjChapterLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjChapterLocationToUsjVerseRefChapterLocation(\n usjChapterLocation: UsjChapterLocation,\n ): UsjVerseRefChapterLocation {\n // Old deprecated UsjFlatTextChapterLocation\n if ('jsonPath' in usjChapterLocation) {\n if (usjChapterLocation.offset !== undefined)\n // with UsjTextContentLocation (has offset). Unfortunately, TypeScript really doesn't like\n // having this and the following type returned via the same object even though they're very\n // similar because of the required presence/absence of `offset` in each of the returned\n // types. Just breaking them out into separate returns.\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n offset: usjChapterLocation.offset,\n },\n };\n // with UsjMarkerLocation (does not have offset)\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n },\n };\n }\n\n // UsjVerseRefChapterLocation\n if ('verseRef' in usjChapterLocation) {\n if (\n // Make sure we are receiving a chapter location, not a book location\n usjChapterLocation.granularity !== undefined &&\n usjChapterLocation.granularity !== 'chapter'\n )\n throw new Error(\n 'Received UsjVerseRefBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return usjChapterLocation;\n }\n\n // UsjFlatChapterLocation\n // Make sure we are receiving a chapter location, not a book location\n if (usjChapterLocation.chapterNum === undefined)\n throw new Error(\n 'Received UsjFlatBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: usjChapterLocation.documentLocation,\n };\n }\n\n /**\n * Transforms a USJ book-based location into a single standardized format of USJ book-based\n * location for ease of accessing the location's properties\n *\n * @param usjBookLocation USJ book-based location in one of multiple forms\n * @returns USJ book-based location in one particular form.\n * @throws If erroneously received a {@link UsjChapterLocation}, not a {@link UsjBookLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjBookLocationToUsjVerseRefBookLocation(\n usjBookLocation: UsjBookLocation,\n ): UsjVerseRefBookLocation {\n // UsjVerseRefBookLocation\n if ('verseRef' in usjBookLocation) {\n if (\n // Make sure we are receiving a book location, not a chapter location\n usjBookLocation.granularity !== 'book'\n )\n throw new Error(\n 'Received UsjVerseRefChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return usjBookLocation;\n }\n\n // UsjFlatBookLocation\n // Make sure we are receiving a book location, not a chapter location\n if ('chapterNum' in usjBookLocation)\n throw new Error(\n 'Received UsjFlatChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return {\n verseRef: {\n book: usjBookLocation.book,\n chapterNum: 1,\n verseNum: 0,\n },\n granularity: 'book',\n documentLocation: usjBookLocation.documentLocation,\n };\n }\n\n // #endregion transforming location types to different types\n\n // #region USFM location -> USJ location\n\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n // Get the USFM location's index in the USFM representation of this USJ document\n const usfmVerseLocationIndexInUsfm = this.usfmVerseLocationToIndexInUsfm(usfmVerseLocation);\n\n // Find the fragment info at this USFM location\n const { value: fragmentInfo } = this.fragmentsByIndexInUsfm.findClosestLessThanOrEqual(\n usfmVerseLocationIndexInUsfm,\n ) ?? {\n value: undefined,\n };\n if (!fragmentInfo)\n throw new Error(\n `Somehow, did not find anything at index in verse ${verseRefOffset} or below in ${verseRef.book} ${verseRef.chapterNum}:${verseRef.verseNum}. Not sure how this would happen.`,\n );\n\n // Get the offset within the fragment where the USFM location is pointing\n const usjOffset = usfmVerseLocationIndexInUsfm - fragmentInfo.indexInUsfm;\n\n // Add the offset to the fragment's UsjDocumentLocation and return it\n return {\n ...fragmentInfo.nodeAndDocumentLocation,\n documentLocation: UsjReaderWriter.moveUsjDocumentLocationToNewOffset(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n usjOffset,\n ),\n };\n }\n\n usfmVerseLocationToUsjDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation | SerializedVerseRef,\n ): UsjDocumentLocation {\n return this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation).documentLocation;\n }\n\n // #endregion USFM location -> USJ location\n\n // #region UsjDocumentLocation utilities\n\n /**\n * Determine if the USJ document location is pointing to a text content location instead of some\n * location related to a marker object\n *\n * @param usjDocumentLocation USJ document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocation: UsjDocumentLocation,\n ): usjDocumentLocation is UsjTextContentLocation;\n /**\n * Determine if the USJ document location in this node and document location is pointing to a text\n * content location instead of some location related to a marker object\n *\n * @param usjNodeAndDocumentLocation USJ node and document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjNodeAndDocumentLocation: UsjNodeAndDocumentLocation,\n ): usjNodeAndDocumentLocation is UsjNodeAndDocumentLocation;\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocationMaybeNode: UsjDocumentLocation | UsjNodeAndDocumentLocation,\n ): boolean {\n let documentLocation = usjDocumentLocationMaybeNode;\n if ('node' in usjDocumentLocationMaybeNode) {\n // If it's a UsjNodeAndDocumentLocation, the node must be a string\n if (!isString(usjDocumentLocationMaybeNode.node)) return false;\n\n documentLocation = usjDocumentLocationMaybeNode.documentLocation;\n }\n\n // Text content representation in USJDocumentLocation requires offset and nothing else has offset\n return 'offset' in documentLocation;\n }\n\n // #endregion UsjDocumentLocation utilities\n\n // #region Search for text from a certain point\n\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n // Get the location of the verse marker\n const verseLocation = this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation);\n\n // Find the first string after the verse marker\n const firstStringLocationAfterVerseMarker = this.findNextLocationOfMatchingText(\n verseLocation,\n '',\n );\n\n if (!firstStringLocationAfterVerseMarker)\n throw new Error(\n `Could not find next text location after verse ${JSON.stringify(usfmVerseLocation)} at location ${\n verseLocation.documentLocation.jsonPath\n }`,\n );\n\n return firstStringLocationAfterVerseMarker;\n }\n\n findNextLocationOfMatchingText(\n startingPoint: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number = 1000,\n ): UsjNodeAndDocumentLocation | undefined {\n let textScanned = '';\n let lengthScanned = 0;\n let lengthTrimmed = 0;\n let foundStartingAtOffset = -1;\n const workingStackForStartingPoint = this.convertJsonPathToWorkingStack(\n startingPoint.documentLocation.jsonPath,\n );\n // Get the starting point stack item so we can offset our staring search point by the offset.\n // But if we started at the top USJ marker, the starting point isn't text, so we don't need to\n // worry about offsetting as there is no offset.\n // Cloning because the working stack items are modified during search\n const startingPointStackItem =\n workingStackForStartingPoint.length > 0\n ? {\n ...workingStackForStartingPoint[workingStackForStartingPoint.length - 1],\n }\n : undefined;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n workingStackForStartingPoint,\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n let nodeTextToSearch = node;\n\n const currentStackItem = workingStack[workingStack.length - 1];\n\n // If the node is the starting point, then we need to start scanning from the offset.\n // Otherwise look from the start of the string\n if (\n startingPointStackItem &&\n UsjReaderWriter.areStackItemsShallowEqual(currentStackItem, startingPointStackItem)\n ) {\n if (!('offset' in startingPoint.documentLocation))\n throw new Error(\n `Somehow 'offset' was not in text content string document location. This should not happen. ${JSON.stringify(startingPoint.documentLocation)}`,\n );\n nodeTextToSearch = node.substring(startingPoint.documentLocation.offset);\n // We're skipping the offset characters in the first node, so we need to adjust the final\n // foundStartingAtOffset to account for that\n lengthTrimmed += startingPoint.documentLocation.offset;\n }\n\n lengthScanned += nodeTextToSearch.length;\n textScanned = `${textScanned}${nodeTextToSearch}`;\n const textIndex = textScanned.indexOf(text);\n if (textIndex < 0) {\n // Keep the string we're keeping around from going too large\n lengthTrimmed += textScanned.length;\n if (textScanned.length > text.length)\n textScanned = textScanned.substring(textScanned.length - text.length);\n lengthTrimmed -= textScanned.length;\n\n // Stop looking if we haven't found it after scanning a lot of text\n return lengthScanned > maxTextLengthToSearch;\n }\n\n // We found it!\n foundStartingAtOffset = lengthTrimmed + textIndex;\n return true;\n },\n );\n\n // We never found what we wanted\n if (foundStartingAtOffset < 0) return undefined;\n\n // The text might have been split between nodes, so we have to go through it one more time\n lengthScanned = 0;\n let finalOffset = 0;\n let finalStack: WorkingStack = [];\n const finalNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, stack) => {\n if (typeof node !== 'string') return false;\n\n lengthScanned += node.length;\n if (lengthScanned < foundStartingAtOffset + 1) return false;\n\n finalOffset = foundStartingAtOffset - lengthScanned + node.length;\n finalStack = stack;\n return true;\n },\n );\n if (!finalNode) throw new Error('Internal error: inconsistent search results');\n if (!isString(finalNode))\n throw new Error(\n `Somehow found non-string node while searching for strings: ${JSON.stringify(finalNode)}`,\n );\n\n return {\n node: finalNode,\n documentLocation: {\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(finalStack),\n offset: finalOffset,\n },\n };\n }\n\n search(regex: RegExp): UsjSearchResult[] {\n const retVal: UsjSearchResult[] = [];\n if (this.usj.content.length === 0) return retVal;\n\n // Start searching from the first node in the USJ content tree\n const startingPoint: UsjNodeAndDocumentLocation = {\n node: this.usj,\n documentLocation: {\n jsonPath: `$`,\n },\n };\n\n // This will hold all of the text content from the USJ, so we can search it all at once\n const textChunks: string[] = [];\n // This will map the index of each text chunk in the full text, so we can find the location\n const fullTextIndexMap = new SortedNumberMap<\n UsjNodeAndDocumentLocation\n >();\n\n // Variables to track our current position while walking through the USJ content tree\n let currentIndex = 0;\n let nextNode: MarkerContent | Usj | undefined = startingPoint.node;\n while (nextNode !== undefined) {\n nextNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n [],\n // We need to use variables from outside the function to keep track of our current position\n // eslint-disable-next-line no-loop-func\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n textChunks.push(node);\n fullTextIndexMap.set(currentIndex, {\n node,\n documentLocation: {\n offset: 0,\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(workingStack),\n },\n });\n currentIndex += node.length;\n return false;\n },\n );\n }\n\n // Connect all the text chunks together so we can search them all at once. Note that there are\n // no spaces between the text chunks. If we need spaces inserted between verses, chapters, etc.\n // then we should adjust how we walk through the tree to insert extra spaces at the right times.\n const fullText = textChunks.join('');\n\n // Lean on regular expressions to do the heavy lifting of finding matches\n let match: RegExpExecArray | null = regex.exec(fullText);\n while (match) {\n // If the match is empty, then we don't want to include it in the results\n if (match[0].length > 0) {\n if (match.index < 0 || match.index >= fullText.length)\n throw new Error(`Match index out of bounds: ${match.index}`);\n\n const startingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(match.index);\n if (!startingNodeEntry)\n throw new Error(`Internal error: no starting node found for index ${match.index}`);\n const start: UsjNodeAndDocumentLocation = {\n node: startingNodeEntry.value.node,\n documentLocation: {\n jsonPath: startingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index - startingNodeEntry.key,\n },\n };\n\n // Have to find the node containing the last character in the match so we don't go past the\n // ending text node and to the next text node that may be multiple markers past the end text\n // node. Then do NOT subtract one from the index in the offset since the ending location is\n // exclusive, meaning the last character in the match is the character before the ending\n // location.\n const endingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(\n match.index + match[0].length - 1,\n );\n if (!endingNodeEntry)\n throw new Error(`Internal error: no ending node found for index ${match.index}`);\n const end: UsjNodeAndDocumentLocation = {\n node: endingNodeEntry.value.node,\n documentLocation: {\n jsonPath: endingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index + match[0].length - endingNodeEntry.key,\n },\n };\n\n retVal.push({ text: match[0], start, end });\n }\n\n // If the regex is not global, then running `exec` again will return the same match\n if (!regex.global) break;\n match = regex.exec(fullText);\n }\n\n return retVal;\n }\n\n // #endregion Search for text from a certain point\n\n // #region Extract text from a node + JSONPath + offset\n\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string {\n let retVal = '';\n let offsetRemaining = 'offset' in start.documentLocation ? start.documentLocation.offset : 0;\n let lengthRecorded = 0;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node) => {\n if (typeof node !== 'string') return false;\n if (offsetRemaining >= node.length) {\n offsetRemaining -= node.length;\n return false;\n }\n let remainingNode = node;\n if (offsetRemaining > 0) {\n remainingNode = remainingNode.substring(offsetRemaining);\n offsetRemaining = 0;\n }\n if (lengthRecorded + remainingNode.length < desiredLength) {\n lengthRecorded += remainingNode.length;\n retVal = `${retVal}${remainingNode}`;\n return false;\n }\n const lengthToCopy = desiredLength - lengthRecorded;\n retVal = `${retVal}${remainingNode.substring(0, lengthToCopy - 1)}`;\n return true;\n },\n );\n return retVal;\n }\n\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number = 100,\n ): string {\n let retVal = '';\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, currentStack) => {\n // `node` and `end.node` are both `MarkerContent` which might be strings or objects\n if (node === end.node) {\n // If both objects are the same, then we definitely found `end`\n if (typeof node === 'object') return true;\n\n // If both strings are the same, we need to verify that we're at the same place in `usj`\n if (\n end.documentLocation.jsonPath ===\n UsjReaderWriter.convertWorkingStackToJsonPath(currentStack)\n )\n return true;\n }\n if (typeof node !== 'string') return false;\n retVal = `${retVal}${node}`;\n if (retVal.length > maxLength) retVal = retVal.substring(0, maxLength);\n return retVal.length >= maxLength;\n },\n );\n return retVal;\n }\n\n // #endregion Extract text from a node + JSONPath + offset\n\n // #region Edit this USJ data\n\n private static removeContentNodesFromArray(\n contentArray: MarkerContent[],\n searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean,\n ) {\n let removedCount = 0;\n for (let i = contentArray.length - 1; i >= 0; i--) {\n const node = contentArray[i];\n if (searchFunction(node)) {\n contentArray.splice(i, 1);\n removedCount += 1;\n } else if (typeof node !== 'string' && node.content)\n removedCount += this.removeContentNodesFromArray(node.content, searchFunction);\n }\n return removedCount;\n }\n\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number {\n const retVal = UsjReaderWriter.removeContentNodesFromArray(this.usj.content, searchFunction);\n this.usjChanged();\n return retVal;\n }\n\n // #endregion Edit this USJ data\n\n // #region transform USJ to USFM\n\n /**\n * Get `MarkerInfo` by marker name\n *\n * @param markerName Name of the marker for which to get `MarkerInfo`\n * @returns `MarkerInfo` for the marker by name if the marker is in the markers map. `undefined`\n * if the marker is not in the markers map. If you have the marker type, you can build a fake\n * `MarkerInfo` for an unknown marker by making an object with just the type. If not, might be\n * best to throw an error since there probably isn't enough information available to do anything\n * with that marker.\n */\n private getMarkerInfo(markerName: string): MarkerInfo | undefined {\n // Try to get by exact marker name first\n let markerInfo = this.markersMap.markers[markerName];\n\n // If not found by exact name, try to match the RegExp marker names\n if (!markerInfo)\n [, markerInfo] =\n Object.entries(this.markersMap.markersRegExp).find(([markerRegExp]) =>\n new RegExp(markerRegExp).test(markerName),\n ) ?? [];\n\n // Return the marker info we found or `undefined` if we didn't find one\n return markerInfo;\n }\n\n /**\n * Gathers various pieces of information about a marker that are helpful for transforming the\n * marker to USFM\n *\n * WARNING: this only has the ability to return the info for the marker to be used in USFM. If you\n * need to use info for the marker in USX or USJ, this method needs to be modified.\n *\n * @param marker A USJ marker (can be USJ type) or a string which is the marker name\n * @param scriptureFormat The Scripture format to get the marker information for. For example, if\n * you are using this marker info to transform the marker into USFM, this should be `usfm`.\n * Defaults to `usfm`\n * @returns Various pieces of info about the marker\n */\n private getInfoForMarker(\n marker: MarkerObject | Usj | string,\n scriptureFormat: 'usfm' = 'usfm',\n ): {\n /**\n * Marker name on the original marker itself as opposed to the marker name in this Scripture\n * format\n */\n markerNameOriginal: string;\n /**\n * Name of the marker in this Scripture format. For example, In USFM format, the `usx` marker's\n * name is `usfm`\n */\n markerName: string;\n /** Marker info corresponding to `markerName`, not `markerNameOriginal` */\n markerInfo: MarkerInfo;\n /**\n * This marker's type in this Scripture format. For example, In USFM format, the `table:cell`\n * type is `cell`\n */\n markerType: string;\n /** Marker info corresponding to `markerType`, not the marker's original `type` */\n markerTypeInfo: MarkerTypeInfo;\n /**\n * Array of tuples containing the USFM name of an attribute marker that may be present on this\n * marker and the marker info for that attribute marker\n *\n * This is like the returned value from `Object.entries`. However, the order of these is\n * important in some cases, so it cannot simply be an object.\n */\n attributeMarkerInfoEntries: [\n attributeMarkerName: string,\n attributeMarkerInfo: AttributeMarkerInfo,\n ][];\n } {\n if (scriptureFormat !== 'usfm')\n throw new Error(\n 'Scripture formats beside usfm are not supported for getting info for markers',\n );\n\n const markerNameOriginal = isString(marker)\n ? marker\n : // Usj type has no `marker` property, but the Usj marker isn't really different than any other\n // marker with no `marker` property. It is appropriate to treat them the same to get the name\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n ((marker as MarkerObject).marker ?? marker.type);\n\n // If we don't have marker info for the marker or the marker type doesn't match the type in the\n // marker info, this marker is considered unknown. Do some special handling.\n let markerIsUnknown = false;\n\n let markerInfo = this.getMarkerInfo(markerNameOriginal);\n const markerTypeFromFirstMarkerInfo = markerInfo?.type ?? (isString(marker) ? '' : marker.type);\n let markerName = markerNameOriginal;\n\n // Get the actual marker name and info in this format if it is different\n if (markerInfo?.markerUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerName = markerInfo.markerUsfm;\n markerInfo = this.getMarkerInfo(markerName);\n }\n\n // Didn't find the marker, so create `MarkerInfo` with the marker type if possible\n if (!markerInfo) {\n if (isString(marker))\n throw new Error(`Unknown marker ${markerNameOriginal} and no marker type provided`);\n\n markerInfo = { type: marker.type };\n markerIsUnknown = true;\n\n console.warn(\n `Unknown marker ${markerNameOriginal}. Creating MarkerInfo to use: ${JSON.stringify(markerInfo)}`,\n );\n }\n\n // Get the marker type\n let markerType = markerInfo.type;\n let markerTypeInfo = this.markersMap.markerTypes[markerType];\n\n // Get the actual marker type and type info in this format if it is different\n if (markerTypeInfo?.markerTypeUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerType = markerTypeInfo.markerTypeUsfm;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n }\n\n // If the actual marker's type is not one of the expected types, something is wrong. Use the\n // actual marker's type\n if (\n !isString(marker) &&\n marker.type !== markerTypeFromFirstMarkerInfo &&\n (!markerTypeInfo ||\n (marker.type !== markerTypeInfo.markerTypeUsfm &&\n marker.type !== markerTypeInfo.markerTypeUsx &&\n marker.type !== markerTypeInfo.markerTypeUsj))\n ) {\n console.warn(\n `Warning: Mismatching marker type in the USJ content ${marker.type} vs marker type in the marker info ${markerInfo.type} for marker ${markerNameOriginal}. Using the type from the USJ content.`,\n );\n markerType = marker.type;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n markerIsUnknown = true;\n }\n\n // Couldn't find the marker type info\n // Note: In this case, Paratext just ignores the marker and prints the marker's content. This\n // really shouldn't happen, though. I had to manually change a marker type in USX and then import\n // it to Paratext to see this behavior. If you hit this, something is already going terribly wrong.\n if (!markerTypeInfo) {\n throw new Error(\n `Unknown marker type ${markerType} on marker ${markerNameOriginal}! Cannot proceed.`,\n );\n }\n\n if (markerIsUnknown && markerType === 'para')\n // Special case: If the marker type is para and it is unknown, do not add a newline before\n // the marker to match Paratext 9.4. We'll just do the same for spec for now since spec\n // seems to be silent regarding what to do about unknown markers\n markerTypeInfo = { ...markerTypeInfo, hasNewlineBefore: false };\n\n // Figure out attribute marker attribute names\n const attributeMarkerInfoEntries: [string, AttributeMarkerInfo][] = [];\n if (markerInfo.attributeMarkers) {\n markerInfo.attributeMarkers.forEach((attributeMarkerName) => {\n // Note: we are not attempting to get the appropriate marker for the relevant Scripture\n // representation aka we are not using `markerUsfm` for example. There are no attribute\n // markers that have alternate representations and are not likely to be any ever. If that\n // changes, this may cause bugs.\n const attributeMarkerInfo = this.getMarkerInfo(attributeMarkerName);\n\n // Markers map lists an attribute marker that doesn't exist. Just skip this attribute\n if (!attributeMarkerInfo) return;\n\n // Markers map lists an attribute marker that doesn't seem to be an attribute marker.\n // Just skip this attribute\n if (!('attributeMarkerAttributeName' in attributeMarkerInfo)) return;\n\n attributeMarkerInfoEntries.push([attributeMarkerName, attributeMarkerInfo]);\n });\n }\n\n // According to `cell`'s `outputToUsfmInstructions`, cell-type markers with `colspan` need to be\n // cell range marker in USFM, so let's figure that out now\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n if (scriptureFormat === 'usfm' && markerType === 'cell' && markerWithAnyAttributes.colspan) {\n // Get the number of columns that this cell spans\n const columnsSpanned = parseInt(markerWithAnyAttributes.colspan, 10);\n\n const tableMarkerMatches = TABLE_MARKER_NUMBER_REGEXP.exec(markerNameOriginal);\n\n if (tableMarkerMatches?.[1]) {\n // Get the starting cell column number\n const startingColumn = parseInt(tableMarkerMatches[1], 10);\n if (!Number.isNaN(startingColumn) && !Number.isNaN(columnsSpanned)) {\n // Create cell range marker like `tc1-3`\n markerName = `${markerNameOriginal}-${startingColumn + columnsSpanned - 1}`;\n // Set `colspan` so it is not output to USFM since it was just incorporated properly\n markerTypeInfo = {\n ...markerTypeInfo,\n skipOutputAttributeToUsfm: [\n ...(markerTypeInfo.skipOutputAttributeToUsfm ?? []),\n 'colspan',\n ],\n };\n }\n }\n }\n\n return {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n };\n }\n\n /** Converts the text content of a marker to its equivalent in USFM */\n private textContentToUsfm(textContent: string): UsfmSnippetAndUsjFragmentsInfo {\n // Special case: NBSP should be replaced with ~ in USFM if invisible characters are not allowed\n return {\n usfm: this.shouldAllowInvisibleCharacters\n ? textContent\n : textContent.replace(TEXT_CONTENT_NBSP_REGEXP, '~'),\n fragmentsInfo: [{ fragment: textContent, indexInUsfm: 0 }],\n };\n }\n\n /**\n * Merge an independent array of fragment info into an existing array of fragment info, offsetting\n * the indices of the new fragments so their locations start from the end of the string\n */\n private static mergeFragmentsInfoIntoExistingArray(\n newFragmentsInfo: UsjFragmentInfoMinimal[],\n existingFragmentsInfo: UsjFragmentInfoMinimal[],\n existingUsfmLength: number,\n ) {\n newFragmentsInfo.forEach((fragmentInfo) => {\n const fragmentIndex = existingUsfmLength + fragmentInfo.indexInUsfm;\n existingFragmentsInfo.push({\n ...fragmentInfo,\n indexInUsfm: fragmentIndex,\n });\n });\n }\n\n /**\n * Transforms the provided USJ marker into its opening marker representation in USFM\n *\n * Includes a newline before the marker if applicable. Generally also includes a space at the end.\n *\n * Opening markers generally look like the following:\n *\n * ```text\n * \\markerName leadingAttributes textContentAttribute attributeMarkers\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come before the contents of the\n * marker in USFM\n */\n private openingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { markerName, markerInfo, markerType, markerTypeInfo, attributeMarkerInfoEntries } =\n this.getInfoForMarker(marker);\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // Add newline before the marker if there's supposed to be one\n if (markerTypeInfo.hasNewlineBefore) usfm += `\\n`;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n // Add the marker name\n // Fragment representing the very beginning of the marker is the marker itself\n fragmentsInfo.push({ fragment: marker, indexInUsfm: usfm.length });\n // Special case: `optbreak` - transform to `//`\n usfm += markerType === 'optbreak' ? '//' : `\\\\${markerPrefix}`;\n\n if (markerType !== 'optbreak') {\n // Fragment representing the marker name is the `marker` property\n fragmentsInfo.push({\n fragment: { attributeValueForKey: 'marker', forMarker: marker },\n indexInUsfm: usfm.length,\n });\n\n // According to `unmatched`'s `outputToUsfmInstructions`, no space after the marker name\n // because it is basically a closing marker\n usfm += `${markerName}${markerType === 'unmatched' ? '' : ' '}`;\n }\n\n // Add leading attributes in listed order\n if (markerInfo.leadingAttributes) {\n markerInfo.leadingAttributes.forEach((attributeName) => {\n const attributeValue = markerWithAnyAttributes[attributeName];\n\n if (!attributeValue) return;\n\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeValue} `;\n });\n }\n\n // Add text content attribute\n if (\n markerInfo.textContentAttribute &&\n markerWithAnyAttributes[markerInfo.textContentAttribute]\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.textContentAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[markerInfo.textContentAttribute]} `;\n }\n\n // Add attribute markers in listed order\n if (markerInfo.attributeMarkers) {\n attributeMarkerInfoEntries.forEach(([attributeMarkerName, attributeMarkerInfo]) => {\n const attributeValue =\n markerWithAnyAttributes[attributeMarkerInfo.attributeMarkerAttributeName];\n\n if (!attributeValue) return;\n\n // Create a marker that represents this attribute marker so we can make the USFM\n const attributeMarker: MarkerObject = {\n type: attributeMarkerInfo.type,\n marker: attributeMarkerName,\n content: [attributeValue],\n };\n\n // Add the attribute marker USFM to the document\n\n // Collect opening and closing attribute marker fragments so we can modify them before adding\n // them to the main fragments\n const attributeMarkerFragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Caveat: it's not technically always true that this marker is the parent of the attribute\n // markers, but there is currently no known case where it matters because there are no\n // attribute markers that have the same marker type as the marker on which they are\n // attributes. It likely will never matter as this is a very strange concept and it seems\n // the USFM committee doesn't want to create more attribute markers.\n usfm = this.addMarkerUsfmToString(\n usfm,\n attributeMarker,\n marker,\n attributeMarkerFragmentsInfo,\n );\n const { usfm: textContentUsfm } = this.textContentToUsfm(attributeValue);\n fragmentsInfo.push({\n fragment: {\n attributeValueForKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n indexInUsfm: usfm.length,\n });\n usfm += textContentUsfm;\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: attributeMarker,\n },\n marker,\n attributeMarkerFragmentsInfo,\n );\n\n // Transform the opening fragments to attribute marker fragments and add them to the main\n // fragments\n attributeMarkerFragmentsInfo.forEach((fragmentInfo) => {\n // There should never be such a thing as text content in the opening/closing of an attribute\n // marker or an attribute key for an attribute marker\n if (isString(fragmentInfo.fragment) || 'attributeKey' in fragmentInfo.fragment)\n throw new Error(\n `Attribute marker opening or closing markers generated a text content fragment or an attribute key fragment! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n\n if (UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment)) {\n // Opening marker. Need to point to the original marker and indicate this is the opening\n // marker for its attribute marker\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n\n return;\n }\n\n if ('attributeValueForKey' in fragmentInfo.fragment) {\n // There should never be an attribute value for an attribute marker other than the marker name\n if (fragmentInfo.fragment.attributeValueForKey !== 'marker')\n throw new Error(\n `Attribute marker opening or closing markers generated an attribute value fragment for a key that was not marker! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n // Marker representation of the attribute marker. Change to attribute key for attribute\n // marker attribute name.\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n return;\n }\n\n if ('isClosingMarker' in fragmentInfo.fragment) {\n // Closing marker. Need to point to the original marker and indicate this is the closing\n // marker for its attribute marker\n\n // Need to remove isClosingMarker but will not use it again. This was the easiest way to\n // delete it without TypeScript going berserk\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars\n const { isClosingMarker: _, ...partialClosingFragment } = fragmentInfo.fragment;\n\n const fragment: UsjAttributeMarkerClosingMarkerFragment = {\n ...partialClosingFragment,\n forMarker: marker,\n attributeMarkerClosingMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n };\n\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment,\n });\n\n return;\n }\n\n // That should have been all of them, so not sure what other fragment this could be\n throw new Error(\n `Attribute marker opening or closing markers generated an unrecognized fragment: ${JSON.stringify(fragmentInfo)}`,\n );\n });\n\n if (\n !this.markersMap.isSpaceAfterAttributeMarkersContent &&\n attributeMarkerInfo.hasStructuralSpaceAfterCloseAttributeMarker\n )\n // Add the optional structural space after the attribute marker according to spec\n usfm += ' ';\n });\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Transforms the provided USJ marker into its closing marker representation in USFM\n *\n * Closing markers do not include the attributes listed as part of the opening markers (leading\n * attributes, text content attributes, and attribute markers). They only include other kinds of\n * attributes including the default attribute if present.\n *\n * Closing markers with only the default attribute present generally look like the following:\n *\n * ```text\n * |defaultAttribute\\markerName*\n * ```\n *\n * Closing markers with at least one non-default attribute present generally look like the\n * following:\n *\n * ```text\n * |attributeName=\"AttributeValue\" attributeName=\"AttributeValue\"\\markerName*\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come after the contents of the\n * marker in USFM\n */\n private closingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n const {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n } = this.getInfoForMarker(marker);\n\n // Gather attributes that are not listed as part of the opening marker and not skipped in USFM\n const closingMarkerAttributeNames = Object.keys(marker).filter((attributeName) => {\n // Special case: skip properties that are not attributes\n if (attributeName === 'type') return false;\n if (attributeName === 'marker') return false;\n if (attributeName === 'content') return false;\n if (attributeName === 'closed') return false;\n\n // Skip attributes that are supposed to be skipped when outputting to USFM\n if (markerTypeInfo.skipOutputAttributeToUsfm?.includes(attributeName)) return false;\n\n // Not a leadingAttribute\n if (markerInfo.leadingAttributes?.includes(attributeName)) return false;\n\n // Not a textContentAttribute\n if (markerInfo.textContentAttribute === attributeName) return false;\n\n // Not an attributeMarker\n if (\n attributeMarkerInfoEntries.some(\n ([, attributeMarkerInfo]) =>\n attributeMarkerInfo.attributeMarkerAttributeName === attributeName,\n )\n )\n return false;\n\n // There are no other attributes that go on the opening marker, so this must go on the closing\n // marker\n return true;\n });\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // We don't have examples of markers that have both normal closing markers and independent\n // closing markers, so just throw an error if we encounter this situation\n if (\n markerTypeInfo.isCloseable &&\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0\n )\n throw new Error(\n `Marker ${\n markerName\n } is intended to have a normal closing marker and independent closing markers. As of writing this code, there is no known syntax for this situation in USFM. Cannot proceed.`,\n );\n\n // Determine if the marker is supposed to have an explicit closing marker\n let hasExplicitClosingMarker = true;\n // If the closing marker is specified as not present, it should not be present no matter what\n if (markerWithAnyAttributes.closed === 'false') hasExplicitClosingMarker = false;\n else if (\n markerInfo.isClosingMarkerOptional &&\n !this.markersMap.shouldOptionalClosingMarkersBePresent &&\n markerWithAnyAttributes.closed !== 'true'\n ) {\n // If the closing marker is optional, if optional closing markers should be left out, and\n // if it is not specified as closed, then it should not have a closing marker\n hasExplicitClosingMarker = false;\n }\n\n // If this marker has an independent closing marker, create that\n if (\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0 &&\n hasExplicitClosingMarker\n ) {\n // Create a marker that represents this independent closing marker so we can make the USFM\n const independentClosingMarker: MarkerObject = {\n type: markerType,\n marker: markerInfo.independentClosingMarkers[0],\n // Put all the closing marker attributes on here since we don't really have a better place\n // to put them and might as well\n ...Object.fromEntries(\n closingMarkerAttributeNames.map((attributeName) => [\n attributeName,\n markerWithAnyAttributes[attributeName],\n ]),\n ),\n };\n\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { usfm: openingMarkerUsfm, fragmentsInfo: openingFragmentsInfo } =\n this.openingMarkerToUsfm(independentClosingMarker, isInsideMarkerWithSameType);\n // Fragment for independent closing marker is just the normal closing fragment. So find the\n // opening fragment, change it to closing fragment, and add it to the fragments for this\n // marker. Need to get the opening marker so we have the right indexInUsfm (might be 1 if\n // the marker has a newline before it, for example)\n const openingFragmentInfo = openingFragmentsInfo.find((fragmentInfo) => {\n return UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment);\n });\n if (!openingFragmentInfo)\n throw new Error(\n `Could not find opening fragment info for independent closing marker ${JSON.stringify(\n independentClosingMarker,\n )}. Fragments info generated: ${JSON.stringify(openingFragmentsInfo)}`,\n );\n fragmentsInfo.push({\n ...openingFragmentInfo,\n fragment: { isClosingMarker: true, forMarker: marker },\n });\n usfm += openingMarkerUsfm;\n // Only add the independent closing marker if it does not have the same name as the marker we\n // are closing so we don't get in an infinite loop\n if (markerNameOriginal !== independentClosingMarker.marker)\n // ENHANCE: If we ever have a situation where closing marker attributes get on a marker\n // with an independent closing marker, let's add fragments for the attributes here. Though\n // I think this may be something the USFM committee intends to avoid doing based on the\n // proposal to add attributes at the opening marker\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: independentClosingMarker,\n },\n isInsideMarkerWithSameType,\n );\n\n return { usfm, fragmentsInfo };\n }\n\n // This marker doesn't have an independent closing marker, so create a normal closing marker\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Add attributes to the closing marker USFM\n if (closingMarkerAttributeNames.length > 0) {\n // Add the bar before closing attributes\n usfm += '|';\n\n // Default attribute syntax if it is the only attribute present\n if (\n closingMarkerAttributeNames.length === 1 &&\n closingMarkerAttributeNames[0] === markerInfo.defaultAttribute\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.defaultAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += markerWithAnyAttributes[markerInfo.defaultAttribute];\n } else {\n // List all attributes with key and value\n closingMarkerAttributeNames.forEach((attributeName, index) => {\n // According to `figure`'s `outputToUsfmInstructions`, figure's file attribute is src in USFM\n const attributeNameUsfm =\n markerType === 'figure' && attributeName === 'file' ? 'src' : attributeName;\n // Add to the accumulated usfm (starting with a bar): a space if this is after the first\n // attribute, then the attribute name, then =, then \"the attribute value\"\n if (index > 0) usfm += ' ';\n fragmentsInfo.push({\n fragment: { attributeKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeNameUsfm}=\"`;\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[attributeName]}\"`;\n });\n }\n }\n\n // Add the normal closing marker\n if (markerTypeInfo.isCloseable && hasExplicitClosingMarker) {\n const closingMarkerName = markerTypeInfo.isClosingMarkerEmpty ? '' : markerName;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n fragmentsInfo.push({\n fragment: { isClosingMarker: true, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `\\\\${markerPrefix}${closingMarkerName}*`;\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Determines whether this marker and all its content should be skipped entirely when outputting\n * to USFM\n *\n * @param marker Marker to check\n * @returns `true` if this marker should be skipped; `false` otherwise\n */\n private shouldSkipOutputMarkerToUsfm(marker: MarkerObject | Usj) {\n const { markerTypeInfo } = this.getInfoForMarker(marker);\n\n if (markerTypeInfo.skipOutputMarkerToUsfm) return true;\n\n if (\n markerTypeInfo.skipOutputMarkerToUsfmIfAttributeIsPresent?.some(\n (attributeName) => attributeName in marker,\n )\n )\n return true;\n\n return false;\n }\n\n /** Removes one space at the end of the string if present */\n private static removeEndSpace(value: string) {\n // TODO: should this use the surrogate-aware functions?\n if (value.at(-1) !== ' ') return value;\n return value.slice(0, -1);\n }\n\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param markerParent Parent of the marker being added. Used to determine if this marker is\n * nested within another marker of the same type\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | Usj | UsjClosingMarkerFragment,\n markerParent: MarkerObject | Usj | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n isInsideMarkerWithSameType: boolean,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n markerParentOrIsInsideMarkerWithSameType: MarkerObject | Usj | boolean | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string {\n let usfmOutput = usfm;\n\n // Build up the marker's usfm and fragment info separately first because we may modify it before\n // adding it to the full usfm\n let markerUsfmOutput;\n let markerFragmentsInfo: UsjFragmentInfoMinimal[];\n\n const { markerNameOriginal, markerType, markerTypeInfo } = this.getInfoForMarker(\n 'isClosingMarker' in marker ? marker.forMarker : marker,\n );\n\n // Determine if this marker is a direct child of another marker of the same type\n let isParentSameType = false;\n if (typeof markerParentOrIsInsideMarkerWithSameType === 'boolean')\n isParentSameType = markerParentOrIsInsideMarkerWithSameType;\n else if (markerParentOrIsInsideMarkerWithSameType) {\n const { markerType: parentMarkerType } = this.getInfoForMarker(\n markerParentOrIsInsideMarkerWithSameType,\n );\n if (parentMarkerType === markerType) {\n isParentSameType = true;\n }\n }\n\n if ('isClosingMarker' in marker) {\n const { usfm: closingUsfm, fragmentsInfo: closingFragmentsInfo } = this.closingMarkerToUsfm(\n marker.forMarker,\n isParentSameType,\n );\n markerFragmentsInfo = closingFragmentsInfo;\n markerUsfmOutput = closingUsfm;\n\n // If the closing marker is supposed to be empty, there was nothing in the marker content, and\n // there are no closing marker attributes present, we need to remove the structural space after\n // the opening marker\n if (\n markerTypeInfo.isCloseable &&\n markerTypeInfo.isClosingMarkerEmpty &&\n // No contents\n (!marker.forMarker.content || marker.forMarker.content.length === 0) &&\n // No closing marker attributes\n !markerUsfmOutput.startsWith('|')\n ) {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n } else {\n const { usfm: openingUsfm, fragmentsInfo: openingFragmentsInfo } = this.openingMarkerToUsfm(\n marker,\n isParentSameType,\n );\n markerFragmentsInfo = openingFragmentsInfo;\n markerUsfmOutput = openingUsfm;\n }\n\n if (markerUsfmOutput.startsWith('\\n')) {\n if (usfmOutput.length === 0) {\n // If the USFM is empty, don't add a newline at the start\n markerFragmentsInfo = markerFragmentsInfo.map((fragmentInfo) => ({\n ...fragmentInfo,\n indexInUsfm: fragmentInfo.indexInUsfm - 1,\n }));\n markerUsfmOutput = markerUsfmOutput.substring(1);\n } else {\n // If there's supposed to be a newline before the marker, it should eat the last space if\n // there is one (that last space gets turned into the newline in this format)\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n }\n\n // Special case: `ca` after chapter marker needs a newline and space before in Paratext USFM for\n // some reason\n // Note that there is not a newline and space before `ca` after importing from USX in Paratext,\n // so maybe we should just remove the newline and space in the PDP\n if (this.markersMap.isSpaceAfterAttributeMarkersContent && markerNameOriginal === 'ca') {\n // Find the last marker in the current USFM output\n const lastMarkerBackslashIndex = usfmOutput.lastIndexOf('\\\\');\n if (lastMarkerBackslashIndex >= 0) {\n // We just want to know if it's a chapter marker, so we can just get two characters, c and space\n const lastMarker = usfm.substring(\n lastMarkerBackslashIndex + 1,\n lastMarkerBackslashIndex + 3,\n );\n if (lastMarker === 'c ') {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n usfmOutput += '\\n ';\n }\n }\n }\n\n // Add the marker fragments and USFM into the existing fragments and USFM\n if (fragmentsInfo)\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n markerFragmentsInfo,\n fragmentsInfo,\n usfmOutput.length,\n );\n usfmOutput += markerUsfmOutput;\n\n return usfmOutput;\n }\n\n toUsfm() {\n // See calculateUsfmProperties method for implementation\n return this.usfm;\n }\n\n // #endregion transform USJ to USFM\n\n // #region fragment utilities\n\n /**\n * Returns a new {@link UsjDocumentLocation} based on the one passed in but with the offset\n * provided. If the location passed in does not have an offset property, a shallow clone of the\n * location will be returned with no changes.\n */\n private static moveUsjDocumentLocationToNewOffset(\n usjLocation: UsjDocumentLocation,\n usjOffset: number,\n ): UsjDocumentLocation {\n const newLocation = { ...usjLocation };\n\n // UsjTextContentLocation\n if ('offset' in newLocation) newLocation.offset = usjOffset;\n // UsjClosingMarkerLocation\n else if ('closingMarkerOffset' in newLocation) newLocation.closingMarkerOffset = usjOffset;\n // UsjPropertyValueLocation\n else if ('propertyOffset' in newLocation) newLocation.propertyOffset = usjOffset;\n // UsjAttributeKeyLocation\n else if ('keyOffset' in newLocation) newLocation.keyOffset = usjOffset;\n // UsjClosingAttributeMarkerLocation\n else if ('keyClosingMarkerOffset' in newLocation)\n newLocation.keyClosingMarkerOffset = usjOffset;\n // No offset; no change:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return newLocation;\n }\n\n /**\n * Returns the offset of whatever kind that is found in the UsjDocumentLocation. Returns 0 if the\n * location passed in does not have an offset property.\n */\n private static getOffsetInUsjDocumentLocation(usjLocation: UsjDocumentLocation): number {\n // UsjTextContentLocation\n if ('offset' in usjLocation) return usjLocation.offset;\n // UsjClosingMarkerLocation\n if ('closingMarkerOffset' in usjLocation) return usjLocation.closingMarkerOffset;\n // UsjPropertyValueLocation\n if ('propertyOffset' in usjLocation) return usjLocation.propertyOffset;\n // UsjAttributeKeyLocation\n if ('keyOffset' in usjLocation) return usjLocation.keyOffset;\n // UsjClosingAttributeMarkerLocation\n if ('keyClosingMarkerOffset' in usjLocation) return usjLocation.keyClosingMarkerOffset;\n // No offset:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return 0;\n }\n\n /**\n * Compares two UsjDocumentLocations to determine if they are pointing to the same location\n *\n * @param a The first location to compare\n * @param b The second location to compare\n * @param ignoreJsonPath If `true`, the JSONPath properties of the locations will be ignored in\n * the comparison. This is useful if you have already determined that the JSONPaths are the\n * same\n */\n private static areUsjDocumentLocationsEqual(\n a: UsjDocumentLocation,\n b: UsjDocumentLocation,\n ignoreJsonPath = false,\n ) {\n const { jsonPath: aJsonPath, ...restOfA } = a;\n const { jsonPath: bJsonPath, ...restOfB } = b;\n\n // Determine if the two JSONPaths are equivalent even if they use different property syntax\n if (\n !ignoreJsonPath &&\n !deepEqual(JSONPath.toPathArray(aJsonPath), JSONPath.toPathArray(bJsonPath))\n )\n return false;\n\n // Determine if the rest of the location information is the same\n return deepEqual(restOfA, restOfB);\n }\n\n /** Find the fragment info corresponding to the specified USJ Document location. */\n private findFragmentInfoAtUsjDocumentLocation(\n usjLocation: UsjDocumentLocation,\n ): UsjFragmentInfo | undefined {\n // Set offset to 0 because all the fragments' locations are at offset 0\n const zeroedUsjLocation = UsjReaderWriter.moveUsjDocumentLocationToNewOffset(usjLocation, 0);\n\n let fragmentInfoAtLocation: UsjFragmentInfo | undefined;\n const allFragmentsInfoAtJsonPath = this.fragmentsByJsonPath.get(\n UsjReaderWriter.normalizeJsonPath(usjLocation.jsonPath),\n );\n\n // Couldn't find any fragment info at this JSONPath\n if (!allFragmentsInfoAtJsonPath) return undefined;\n\n // Look in the fragments at this JSONPath to find one that matches the full location\n allFragmentsInfoAtJsonPath.find((fragmentInfo) => {\n if (\n !UsjReaderWriter.areUsjDocumentLocationsEqual(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n zeroedUsjLocation,\n // We already compared the JSONPaths by looking in the map for this JSONPath\n true,\n )\n )\n return false;\n\n fragmentInfoAtLocation = fragmentInfo;\n return true;\n });\n\n return fragmentInfoAtLocation;\n }\n\n /**\n * Transform a node and its working stack into the {@link UsjDocumentLocation} corresponding to it.\n *\n * @param node Marker or string to convert\n * @param workingStack Working stack pointing to the node\n * @param locationOffset If applicable, this is the offset that will be put on the\n * {@link UsjDocumentLocation}. If not present, offset on the {@link UsjDocumentLocation} will be\n * `0`. Not all subtypes of {@link UsjDocumentLocation}s have offsets, so this is not used in all\n * situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertNodeToUsjDocumentLocation(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n locationOffset = 0,\n ): UsjTextContentLocation | UsjMarkerLocation {\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n if (isString(node)) {\n // If the node is a text content string, location is the jsonPath and the offset in that\n // string\n const documentLocation: UsjTextContentLocation = { jsonPath, offset: locationOffset };\n return documentLocation;\n }\n\n // The node is a marker itself, so location is just the marker jsonPath. We don't currently\n // provide a way to represent an offset within the opening marker.\n const documentLocation: UsjMarkerLocation = { jsonPath };\n return documentLocation;\n }\n\n /**\n * Transform a fragment and its working stack into the {@link UsjNodeAndDocumentLocation}\n * corresponding to it.\n *\n * @param fragment Fragment to convert\n * @param workingStack Working stack pointing to the marker or string the fragment is in\n * @param offsetWithinFragment If applicable, this is the offset within the fragment that the\n * location is pointing to, which is offset that will be put on the {@link UsjDocumentLocation}.\n * If not present, offset on the {@link UsjDocumentLocation} will be `0` because fragments don't\n * have their own offsets into the contents. Not all {@link UsjDocumentLocation}s have offsets,\n * so this is not used in all situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertFragmentToUsjNodeAndDocumentLocation(\n fragment: UsjFragment,\n workingStack: WorkingStack,\n offsetWithinFragment = 0,\n ): UsjNodeAndDocumentLocation {\n // Return the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n\n // Check if the fragment itself is the target, meaning the fragment is the node in the USJ\n // document (`string`, `MarkerObject`, and `Usj`)\n if (isString(fragment) || UsjReaderWriter.isFragmentAMarker(fragment)) {\n // The fragment/node itself is the target. Get document location for this node\n const documentLocation: UsjTextContentLocation | UsjMarkerLocation =\n UsjReaderWriter.convertNodeToUsjDocumentLocation(\n fragment,\n workingStack,\n offsetWithinFragment,\n );\n return {\n node: fragment,\n documentLocation,\n };\n }\n\n // Check if the target is a closing marker\n if ('isClosingMarker' in fragment) {\n // Get JsonPath to the marker this is a closing marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and an offset within the closing marker\n const documentLocation: UsjClosingMarkerLocation = {\n jsonPath,\n closingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is a property value (`marker` or an attribute)\n if ('attributeValueForKey' in fragment) {\n // Get JsonPath to the indicated property on the marker this is a property for\n const jsonPath = UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath(\n workingStack,\n fragment.attributeValueForKey,\n );\n\n // Location is the jsonPath to the property on the marker and the offset within the property\n // value\n const documentLocation: UsjPropertyValueLocation = {\n jsonPath,\n propertyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute key\n if ('attributeKey' in fragment) {\n // Get JsonPath to the marker this is an attribute key for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker, the key, and the offset within that key\n const documentLocation: UsjAttributeKeyLocation = {\n jsonPath,\n keyName: fragment.attributeKey,\n keyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker\n if ('attributeMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker. We don't\n // currently provide a way to represent an offset within the opening marker.\n const documentLocation: UsjAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarker,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker closing marker\n if ('attributeMarkerClosingMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker\n const documentLocation: UsjClosingAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarkerClosingMarker,\n keyClosingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n throw new Error(\n `Could not transform unrecognized fragment to UsjNodeAndDocumentLocation: ${JSON.stringify(\n fragment,\n )} at working stack ${JSON.stringify(JSON.stringify(fragment))}`,\n );\n }\n\n /**\n * Fill out fragments info from a minimal fragments info array and move them into the final\n * fragments map\n *\n * @param fragmentsInfo Minimal fragments info array to fill out and put into maps. ALL CONTENTS\n * OF THIS ARRAY ARE REMOVED IN THIS METHOD\n * @param workingStack Current working stack\n * @param position Object containing properties describing where in the USFM document these\n * fragments are. If this method encounters a verse range, only the starting verse number is\n * used (hence this is not a {@link SerializedVerseRef}). PROPERTIES ON THIS OBJECT ARE MODIFIED\n * IN THIS METHOD\n * @param fragmentsByIndexInUsfm Map to add fragment information to by index in USFM\n * @param fragmentsByJsonPath Map to add fragment information to by JSONPath\n * @param indicesInUsfmByVerseRef Map to add verse start locations to. If this method encounters a\n * verse range, only the starting verse number is used. See {@link IndicesInUsfmByVerseRef} for\n * potential adjustments to handle verse ranges differently when we know better what we ought to\n * do.\n */\n private static transferFragmentsInfoArrayToMaps(\n fragmentsInfo: UsjFragmentInfoMinimal[],\n workingStack: WorkingStack,\n position: {\n bookId: string;\n chapterNum: number;\n verseNum: number;\n },\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm,\n fragmentsByJsonPath: FragmentsByJsonPath,\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef,\n ): void {\n // Add the extra information to each fragment to make it complete\n const fullFragmentsInfo = fragmentsInfo.map((fragmentInfo) => {\n // Adjust current verse ref if we find start of book, chapter, or verse marker\n if (typeof fragmentInfo.fragment === 'object' && 'type' in fragmentInfo.fragment) {\n const marker = fragmentInfo.fragment;\n\n if (marker.type === BOOK_TYPE && marker.code) {\n // Found book marker. Update current verse ref to new book\n position.bookId = marker.code;\n position.chapterNum = 0;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered book id, move them to the first\n // encountered book id\n if (indicesInUsfmByVerseRef[NO_BOOK_ID]) {\n indicesInUsfmByVerseRef[position.bookId] = indicesInUsfmByVerseRef[NO_BOOK_ID];\n delete indicesInUsfmByVerseRef[NO_BOOK_ID];\n }\n } else if (marker.type === CHAPTER_TYPE && marker.number) {\n // Found chapter marker. Try to update chapter\n const nextChapterNum = parseInt(marker.number, 10);\n\n if (Number.isNaN(nextChapterNum)) {\n console.warn(\n `Found ${CHAPTER_TYPE} type marker with number ${\n marker.number\n }, but could not parse chapter number from it. Continuing using previous chapter number ${\n position.chapterNum\n }`,\n );\n } else {\n // Update current verse ref to new chapter\n position.chapterNum = nextChapterNum;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered chapter number, move them to\n // the first encountered chapter number\n const currentBookFragments = indicesInUsfmByVerseRef[position.bookId];\n if (currentBookFragments?.[0]) {\n // Not array destructuring because it's really hard to read here\n // eslint-disable-next-line prefer-destructuring\n currentBookFragments[position.chapterNum] = currentBookFragments[0];\n delete currentBookFragments[0];\n }\n }\n } else if (marker.type === VERSE_TYPE && marker.number) {\n // Found verse marker. Try to update verse\n const nextVerseNumString = VERSE_MARKER_NUMBER_SPAN_REGEXP.exec(marker.number)?.[1];\n\n if (!nextVerseNumString) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not find starting verse number in it. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else {\n const nextVerseNum = parseInt(nextVerseNumString, 10);\n\n if (Number.isNaN(nextVerseNum)) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not parse starting verse number from ${nextVerseNumString}. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else if (\n indicesInUsfmByVerseRef[position.bookId]?.[position.chapterNum]?.[nextVerseNum]\n ) {\n console.warn(`Found ${VERSE_TYPE} marker with existing number ${nextVerseNum} after\n current ${VERSE_TYPE} number ${\n position.verseNum\n }! Not updating verse start index. All positions in this duplicate verse will be based on the current ${\n VERSE_TYPE\n } marker, not the new duplicate marker.`);\n } else {\n if (nextVerseNum < position.verseNum)\n console.debug(\n `Found ${VERSE_TYPE} marker with number ${nextVerseNum} lower than current ${\n VERSE_TYPE\n } number ${position.verseNum}. Verses are out of order. There may be some issues.`,\n );\n\n // Update current verse ref to new verse\n position.verseNum = nextVerseNum;\n }\n }\n }\n }\n\n // Fill out the rest of the fragment info\n const fullFragmentInfo: UsjFragmentInfo = {\n ...fragmentInfo,\n // Determine the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n nodeAndDocumentLocation: UsjReaderWriter.convertFragmentToUsjNodeAndDocumentLocation(\n fragmentInfo.fragment,\n workingStack,\n ),\n };\n\n return fullFragmentInfo;\n });\n\n // Add staged fragments to final fragments maps\n fullFragmentsInfo.forEach((fragmentInfo) => {\n // Put the fragment info in the map by index in USFM\n fragmentsByIndexInUsfm.set(fragmentInfo.indexInUsfm, fragmentInfo);\n\n // Put the fragment info in the map by JSONPath. Note this JSONPath is generated using\n // UsjReaderWriter.convertWorkingStackToJsonPath and\n // UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath, so it is \"normalized\".\n // Must use \"normalized\" JSONPath when looking up fragments by JSONPath.\n const fragmentJsonPath = fragmentInfo.nodeAndDocumentLocation.documentLocation.jsonPath;\n const fragmentsAtJsonPath = fragmentsByJsonPath.get(fragmentJsonPath);\n if (fragmentsAtJsonPath) fragmentsAtJsonPath.push(fragmentInfo);\n else fragmentsByJsonPath.set(fragmentJsonPath, [fragmentInfo]);\n\n // Put the fragment's index in USFM in the map by verse reference\n // We are ensuring the properties are defined all the way through before use, so allow the\n // bang operator. This would be way more verbose without bang operator.\n /* eslint-disable no-type-assertion/no-type-assertion */\n if (!indicesInUsfmByVerseRef[position.bookId]) indicesInUsfmByVerseRef[position.bookId] = {};\n if (!indicesInUsfmByVerseRef[position.bookId]![position.chapterNum])\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum] = {};\n if (\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] ===\n undefined\n )\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] =\n fragmentInfo.indexInUsfm;\n /* eslint-enable no-type-assertion/no-type-assertion */\n });\n\n // Remove all elements from fragmentsInfo\n fragmentsInfo.splice(0);\n }\n\n // #endregion fragment utilities\n\n // #region USFM-related cached properties\n\n /**\n * Generates USFM representation of the USJ document passed in and returns it along with\n * information about how various locations in USFM and USJ map to each other\n */\n private calculateUsfmProperties(): {\n usfm: string;\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm;\n fragmentsByJsonPath: FragmentsByJsonPath;\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef;\n } {\n // Build the USFM up from the USJ content\n let usfm = '';\n // Build the fragments maps as we go\n const fragmentsByIndexInUsfm = new SortedNumberMap();\n const fragmentsByJsonPath = new Map();\n const indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef = {};\n\n // Temporary staging array to put fragments in before loading them into the map\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Keep track of current verse reference numbers as we go through the content so we can put\n // fragments in the right place\n const currentPosition = {\n bookId: NO_BOOK_ID,\n chapterNum: 0,\n verseNum: 0,\n };\n /** Move the fragments info that are in `fragmentsInfo` into the final fragments map */\n function transferFragmentsInfo(workingStack: WorkingStack) {\n UsjReaderWriter.transferFragmentsInfoArrayToMaps(\n fragmentsInfo,\n workingStack,\n currentPosition,\n fragmentsByIndexInUsfm,\n fragmentsByJsonPath,\n indicesInUsfmByVerseRef,\n );\n }\n\n // According to `USJ`'s `outputToUsfmInstructions`, need to move the top-level `USJ` marker after\n // `id` closes in USFM even though it is before it in USJ\n let topLevelUsjMarker: Usj | undefined;\n // The marker objects we're currently skipping ordered as a stack (last entry is the deepest\n // marker we are skipping and therefore will be the next to close). If this has entries, it\n // means we are walking through contents of marker objects whose opening marker we already skipped\n // and whose closing marker we should also skip outputting to USFM\n const markersToSkipOutput: (MarkerObject | Usj)[] = [];\n\n UsjReaderWriter.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n this.usj,\n // Working stack is empty since the top-level object doesn't have any parents\n [],\n // Don't skip anything\n [],\n (nodeOrClosingFragment, workingStack) => {\n if (typeof nodeOrClosingFragment !== 'object') {\n // Add the text contents USFM representation\n const { usfm: textContentUsfm, fragmentsInfo: textContentFragmentsInfo } =\n this.textContentToUsfm(nodeOrClosingFragment);\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n textContentFragmentsInfo,\n fragmentsInfo,\n usfm.length,\n );\n transferFragmentsInfo(workingStack);\n usfm += textContentUsfm;\n return false;\n }\n\n // Determine this marker's parent\n let markerParent: MarkerObject | Usj | undefined;\n if (workingStack.length > 0) {\n markerParent = workingStack[workingStack.length - 1].parent;\n }\n\n if ('isClosingMarker' in nodeOrClosingFragment) {\n // If we are supposed to skip this marker in USFM, skip its closing marker\n if (\n markersToSkipOutput.length > 0 &&\n markersToSkipOutput[markersToSkipOutput.length - 1] === nodeOrClosingFragment.forMarker\n ) {\n // Indicate the skipped marker has now closed by removing it from the stack\n markersToSkipOutput.pop();\n return false;\n }\n\n // Add the closing marker USFM representation\n usfm = this.addMarkerUsfmToString(\n usfm,\n nodeOrClosingFragment,\n markerParent,\n fragmentsInfo,\n );\n transferFragmentsInfo(workingStack);\n\n // If this is closing the `id` marker (the only marker whose type is `book`), add the\n // top-level USJ opening marker after it\n if (nodeOrClosingFragment.forMarker.type === 'book' && topLevelUsjMarker) {\n usfm = this.addMarkerUsfmToString(usfm, topLevelUsjMarker, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n topLevelUsjMarker = undefined;\n }\n\n return false;\n }\n\n // If we are supposed to skip this marker in USFM, skip its opening marker\n if (this.shouldSkipOutputMarkerToUsfm(nodeOrClosingFragment)) {\n markersToSkipOutput.push(nodeOrClosingFragment);\n return false;\n }\n\n // If this is the USJ marker at the start of the doc, save it until after `id` marker closes\n if (\n UsjReaderWriter.isTopLevelUsjMarker(nodeOrClosingFragment, workingStack) &&\n !topLevelUsjMarker\n ) {\n // The USJ types aren't set up to know about 3.0 right now, but we should handle it anyway\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if ((nodeOrClosingFragment.version as string) !== '3.0') {\n // Don't output the USJ marker if it is 3.0 (3.0 is assumed and should not appear in\n // the USFM)\n topLevelUsjMarker = nodeOrClosingFragment;\n }\n return false;\n }\n\n // Add the opening marker USFM representation\n usfm = this.addMarkerUsfmToString(usfm, nodeOrClosingFragment, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n\n // Keep going through the whole document\n return false;\n },\n );\n\n // Always add newline at the end of the file; likely replaces a space\n usfm = `${UsjReaderWriter.removeEndSpace(usfm)}\\n`;\n\n return { usfm, fragmentsByIndexInUsfm, fragmentsByJsonPath, indicesInUsfmByVerseRef };\n }\n\n /** The USFM representation of the USJ document passed in */\n private get usfm(): string {\n if (this.usfmInternal !== undefined) return this.usfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.usfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByIndexInUsfm(): FragmentsByIndexInUsfm {\n if (this.fragmentsByIndexInUsfmInternal) return this.fragmentsByIndexInUsfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByIndexInUsfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByJsonPath(): FragmentsByJsonPath {\n if (this.fragmentsByJsonPathInternal) return this.fragmentsByJsonPathInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByJsonPathInternal;\n }\n\n /**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. See {@link IndicesInUsfmByVerseRef} for more information.\n */\n private get indicesInUsfmByVerseRef(): IndicesInUsfmByVerseRef {\n if (this.indicesInUsfmByVerseRefInternal) return this.indicesInUsfmByVerseRefInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.indicesInUsfmByVerseRefInternal;\n }\n\n // #endregion USFM-related cached properties\n}\n\nexport default UsjReaderWriter;\n"],"names":["_AsyncVariable","variableName","rejectIfNotSettledWithinMS","__publicField","resolve","reject","enabled","value","throwIfAlreadySettled","reason","AsyncVariable","Collator","locales","options","string1","string2","DateTimeFormat","date","startDate","endDate","PlatformEventEmitter","event","callback","callbackIndex","newGuid","s","isString","o","deepClone","obj","debounce","fn","delay","timeout","promise","promiseResolve","promiseReject","args","e","groupBy","items","keySelector","valueSelector","map","item","index","key","group","isErrorWithMessage","error","toErrorWithMessage","maybeError","getErrorMessage","wait","ms","waitForDuration","maxWaitTimeInMS","getAllObjectFunctionNames","_objId","objectFunctionNames","property","objectPrototype","createSyncProxyForAsyncObject","getObject","objectToProxy","target","prop","isErrorMessageAboutParatextBlockingInternetAccess","errorMessage","paratextExceptionMessage","isErrorMessageAboutRegistryAuthFailure","paratextExceptionMessage1","paratextExceptionMessage2","errorString","DocumentCombiner","baseDocument","documentName","document","previousDocumentVersion","documentToSet","contributions","contributionName","potentialOutput","outputIteration","contribution","mergeObjects","output","finalOutput","areNonArrayObjects","values","allMatch","areArrayObjects","startingPoint","copyFrom","ignoreDuplicateProperties","retVal","mergeObjectsInternal","startingPointObj","copyFromObj","EventRollingTimeCounter","bufferSize","currentTime","minRollingTimeMs","Mutex","AsyncMutex","MutexMap","mutexID","NonValidatingDocumentCombiner","NumberFormat","startRange","endRange","defaultPromise","PromiseChainingMap","logger","promiseFunction","currentPromise","promiseHolder","newPromise","SortedNumberMap","insertIndex","left","right","result","mid","SortedSet","compareFn","low","high","UnsubscriberAsyncList","name","unsubscribers","unsubscriber","unsubs","results","unsubscriberSucceeded","PLATFORM_ERROR_VERSION","newPlatformError","platformError","isPlatformError","P","R","t","n","N","B","O","S","K","g","k","x","T","X","V","w","L","G","A","H","C","I","y","q","U","m","l","h","c","E","r","D","i","a","u","v","f","d","b","p","J","M","find","list","predicate","ac","hasOwn","freeze","object","oc","assign","source","HTML_BOOLEAN_ATTRIBUTES","isHTMLBooleanAttribute","HTML_VOID_ELEMENTS","isHTMLVoidElement","tagName","HTML_RAW_TEXT_ELEMENTS","isHTMLRawTextElement","isHTMLEscapableRawTextElement","isHTMLMimeType","mimeType","MIME_TYPE","hasDefaultHTMLNamespace","_MIME_TYPES","isValidMimeType","NAMESPACE","conventions","require$$0","extendError","constructor","writableName","DOMExceptionName","DOMExceptionNames","isValidDomExceptionCode","endsWithError","DOMException","messageOrCode","nameOrMessage","code","ExceptionCode","entries","ParseError","message","locator","errors","detectUnicodeSupport","RegExpImpl","match","UNICODE_SUPPORT","chars","regexp","chars_without","search","reg","self","part","isStr","regg","UNICODE_REPLACEMENT_CHARACTER","Char","_SChar","SChar_s","S_OPT","NameStartChar","NameStartChar_s","NameChar","Name","Nmtoken","EntityRef","CharRef","Reference","PEReference","EntityValue","AttValue","NCNameStartChar","NCNameChar","NCName","QName","QName_exact","QName_group","SystemLiteral","PI","PubidChar","PubidLiteral","COMMENT_START","COMMENT_END","Comment","PCDATA","Mixed","_children_quantity","children","contentspec","ELEMENTDECL_START","elementdecl","NotationType","Enumeration","EnumeratedType","AttType","DefaultDecl","AttDef","ATTLIST_DECL_START","AttlistDecl","ABOUT_LEGACY_COMPAT","ABOUT_LEGACY_COMPAT_SystemLiteral","SYSTEM","PUBLIC","ExternalID","ExternalID_match","NDataDecl","EntityDef","ENTITY_DECL_START","GEDecl","PEDef","PEDecl","EntityDecl","PublicID","NotationDecl","Eq","VersionNum","VersionInfo","EncName","EncodingDecl","SDDecl","XMLDecl","DOCTYPE_DECL_START","CDATA_START","CDATA_END","CDStart","CDEnd","CData","CDSect","grammar","PDC","require$$1","require$$2","checkSymbol","symbol","notEmptyString","input","splitOnASCIIWhitespace","orderedSetReducer","current","element","toOrderedSet","arrayIncludes","validateQualifiedName","qualifiedName","validateAndExtract","namespace","prefix","localName","splitResult","copy","src","dest","_extends","Class","Super","pt","NodeType","ELEMENT_NODE","ATTRIBUTE_NODE","TEXT_NODE","CDATA_SECTION_NODE","ENTITY_REFERENCE_NODE","ENTITY_NODE","PROCESSING_INSTRUCTION_NODE","COMMENT_NODE","DOCUMENT_NODE","DOCUMENT_TYPE_NODE","DOCUMENT_FRAGMENT_NODE","NOTATION_NODE","DocumentPosition","commonAncestor","docGUID","doc","NodeList","nodeFilter","buf","serializeToString","me","LiveNodeList","node","refresh","_updateLiveList","inc","ls","__set__","NamedNodeMap","_findNodeIndex","_addNamedNode","el","newAttr","oldAttr","_onRemoveAttribute","_onAddAttribute","_removeNamedNode","attr","lastIndex","namespaceURI","DOMImplementation","feature","version","doctype","contentType","Document","root","publicId","systemId","internalSubset","DocumentType","title","htmlNode","headNode","titleNode","Node","rootNode","other","parent","otherNode","newChild","refChild","_insertBefore","oldChild","assertPreReplacementValidityInDocument","_removeChild","deep","cloneNode","child","next","node1","node2","attr1","attr2","Attr","chain1","ancestor1","chain2","ancestor2","ca","_xmlEncoder","_visitNode","opt","ns","remove","_onUpdateChild","childNodes","parentNode","oldPreviousSibling","oldNextSibling","hasValidParentNodeType","hasInsertableNodeType","isDocTypeNode","isElementNode","isTextNode","isElementInsertionPossible","parentChildNodes","docTypeNode","isElementReplacementPossible","hasElementChildThatIsNotChild","assertPreInsertionValidity1to5","assertPreInsertionValidityInDocument","nodeChildNodes","nodeChildElements","parentElementChild","_inDocumentAssertion","cp","newFirst","newLast","pre","removed","importedNode","importNode","id","rtv","Element","attrs","DocumentFragment","data","Text","CDATASection","ProcessingInstruction","EntityReference","validated","old","classNames","classNamesSet","base","nodeClassNames","matches","nodeClassNamesSet","isHTMLDocument","lowerQualifiedName","nodeQualifiedName","matchingQName","CharacterData","offset","count","text","start","end","newText","newNode","Notation","Entity","XMLSerializer","nodeSerializeToString","refNode","uri","visibleNamespaces","needNamespaceDefine","isHTML","addSerializedAttribute","len","nodeName","prefixedNodeName","defaultNS","ai","nsi","canCloseTag","pubid","sysid","attrs2","getTextContent","dom","exports","S_TAG","S_ATTR","S_ATTR_SPACE","S_EQ","S_ATTR_NOQUOT_VALUE","S_ATTR_END","S_TAG_SPACE","S_TAG_CLOSE","XMLReader","defaultNSMap","entityMap","domBuilder","_copy","parse","ENTITY_REG","defaultNSMapCopy","errorHandler","fixedFromCharCode","surrogate1","surrogate2","entityReplacer","complete","appendText","xt","position","lineStart","lineEnd","linePattern","parseStack","unclosedTags","tagStart","fromSource","tagNameRaw","tagNameMatch","currentTagName","tagNameLower","config","localNSMap","parseProcessingInstruction","parseDoctypeCommentOrCData","ElementAttributes","currentNSMap","parseElementStartPart","locator2","copyLocator","appendElement","parseHtmlSpecialContent","addAttribute","qname","startIndex","attrName","qName","nsp","nsPrefix","elStartEnd","isEscapableRaw","elEndStart","parseUtils","char","skip","skipBlanks","blanks","substringFromIndex","substringStartsWith","substringStartsWithCaseInsensitive","getMatch","expr","parseDoctypeInternalSubset","parsePI","intSubsetStart","comment","cdata","sax","entities","require$$3","require$$4","normalizeLineEndings","DOMParser","DOMHandler","defaultNamespace","isXml","impl","ins","ch","length","_toString","charNode","comm","dt","level","_locator","handler","onErrorStopParsing","onWarningStopParsing","domParser","lib","charRegex","astralRange","comboRange","varRange","familyRange","astral","combo","fitz","modifier","nonAstral","regional","surrogatePair","zwj","blackFlag","family","optModifier","optVar","optJoin","seq","__importDefault","this","mod","dist","char_regex_1","toArray","str","substring","begin","substr","strLength","limit","padString","padPosition","padRepeats","indexOf","searchStr","pos","strArr","searchArr","finded","searchIndex","ensureArray","maybeArray","at","string","stringLength","charAt","codePointAt","endsWith","searchString","endPosition","lastIndexOfSearchString","lastIndexOf","indexOfClosestClosingCurlyBrace","escaped","closeCurlyBraceIndex","formatReplacementStringToArray","replacers","contents","nextIntermediateStartIndex","addToContents","newContent","newContentIndex","newContentLength","intermediateContent","baseSubstring","replacerKey","replacerContent","endContent","formatReplacementString","content","includes","partialString","stringzIndexOf","validatedPosition","stringzLength","normalize","form","upperCaseForm","ordinalCompare","padEnd","targetLength","stringzLimit","padStart","correctSliceIndex","slice","indexStart","indexEnd","newStart","newEnd","split","separator","splitLimit","regexSeparator","currentIndex","matchIndex","matchLength","startsWith","stringzSubstr","stringzSubstring","stringzToArray","isLocalizeKey","escapeStringRegexp","transformAndEnsureRegExpRegExpArray","stringStringMaybeArray","stringMaybeStringArray","transformAndEnsureRegExpArray","stringMaybeArray","whiteSpaceRegex","isWhiteSpace","toKebabCase","prevChar","nextChar","BLOCK_MARKER_TYPES","USJ_TYPE","ZWSP","scrBookData","FIRST_SCR_BOOK_NUM","LAST_SCR_BOOK_NUM","FIRST_SCR_CHAPTER_NUM","FIRST_SCR_VERSE_NUM","defaultScrRef","getChaptersForBook","bookNum","_a","offsetBook","scrRef","Canon","offsetChapter","offsetVerse","getLocalizedIdFromBookNumber","bookNumber","localizationLanguage","getLocalizedString","bookName","parts","scrRefToBBBCCC","VerseRef","scrRefToBBBCCCVVV","compareScrRefs","scrRef1","scrRef2","getLocalizeKeyForScrollGroupId","scrollGroupId","getLocalizeKeysForScrollGroupIds","scrollGroupIds","formatScrRef","optionOrLocalizedBookName","chapterVerseSeparator","bookChapterSeparator","book","Section","getSectionForBook","bookId","nonSemanticWhiteSpaceRegex","isNonSemanticWhiteSpace","invisibleCharOrWhiteSpaceRegex","isParatextSelectableInvisibleCharOrWhiteSpace","normalizeScriptureSpaces","lastCharWasSpace","prevCh","isUsjContentEmpty","isAtEndOfBlockMarker","contentObject","areUsjContentsEqualExceptWhitespaceInternal","aParent","bParent","aIsString","bIsString","aNormalized","bNormalized","aTrimmed","bTrimmed","aObject","bObject","aKeys","isAContentEmpty","isBContentEmpty","aContent","bContent","aLast","bLast","areUsjContentsEqualExceptWhitespace","aggregateUnsubscribers","success","aggregateUnsubscriberAsyncs","unsubPromises","BOOK_TYPE","CHAPTER_TYPE","VERSE_TYPE","NO_BOOK_ID","getDefaultCallerSequence","_","getNthCaller","callers","callerList","getFormatCallerFunction","footnotes","plusSequenceMap","autoCallerCounter","idx","caller","formattedCaller","extractFootnotesFromUsjContent","traverse","getPaneSizeLimits","availablePx","splitterThicknessPx","secondaryPaneMinSizePx","mainPaneMinSizePx","absoluteMinPercent","absoluteMaxPercent","usableHeightPx","minPercent","maxPercent","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","combineComparators","comparatorA","comparatorB","state","createIsCircular","areItemsEqual","cache","cachedA","cachedB","getStrictProperties","sameValueZeroEqual","PREACT_VNODE","PREACT_OWNER","REACT_OWNER","getOwnPropertyDescriptor","keys","areArraysEqual","areDatesEqual","areErrorsEqual","areFunctionsEqual","areMapsEqual","size","matchedIndices","aIterable","aResult","bResult","bIterable","hasMatch","aEntry","bEntry","areNumbersEqual","areObjectsEqual","properties","isPropertyEqual","areObjectsEqualStrict","descriptorA","descriptorB","arePrimitiveWrappersEqual","areRegExpsEqual","areSetsEqual","areTypedArraysEqual","areUrlsEqual","ARGUMENTS_TAG","BOOLEAN_TAG","DATE_TAG","ERROR_TAG","MAP_TAG","NUMBER_TAG","OBJECT_TAG","REG_EXP_TAG","SET_TAG","STRING_TAG","URL_TAG","isArray","isTypedArray","getTag","createEqualityComparator","type","tag","createEqualityComparatorConfig","circular","createCustomConfig","strict","areArraysEqual$1","areMapsEqual$1","areObjectsEqual$1","areSetsEqual$1","createInternalEqualityComparator","compare","_indexOrKeyA","_indexOrKeyB","_parentA","_parentB","createIsEqual","comparator","createState","equals","_b","meta","deepEqual","createCustomEqual","createCustomInternalComparator","isEqualDeep","isSubset","objectWithAllProperties","objectWithPartialProperties","partialArray","allArray","partialObj","allObj","serialize","replacer","space","replacerValue","newValue","deserialize","reviver","replaceNull","parsedObject","isSerializable","serializedValue","htmlEncode","getCurrentLocale","formatBytes","fileSize","decimals","sizes","sizeToUse","MILLISECONDS_PER_SECOND","SECONDS_PER_MINUTE","SECONDS_PER_HOUR","SECONDS_PER_DAY","formatTimeSpan","relativeTimeFormatter","since","to","spanSeconds","totalDays","totalHours","totalMinutes","formatRelativeDate","todayString","yesterdayString","locale","today","yesterday","isToday","isYesterday","MODIFIER_KEYS","settingsDefs","removeJsonToTypeScriptTypesStuff","defs","def","projectSettingsDocumentSchema","settingsDocumentSchema","localizedStringsDefs","localizedStringsDocumentSchema","menuDocumentSchema","themeDefs","themeDocumentSchema","THEME_STYLE_ELEMENT_ID","getThemeId","themeFamilyId","expandThemeContribution","themeFamiliesById","defaultThemeFamily","themeFamily","themeDefinition","getStylesheetForTheme","theme","applyThemeStylesheet","previousStyleElement","styleElementIdSuffix","previousThemeId","themeStyleElement","deepFreeze","USFM_MARKERS_MAP","USFM_MARKERS_MAP_PARATEXT","NODE_TYPES_NOT_CONTAINING_VERSE_TEXT","TEXT_CONTENT_NBSP_REGEXP","TABLE_MARKER_NUMBER_REGEXP","VERSE_MARKER_NUMBER_SPAN_REGEXP","UsjReaderWriter","usj","providedMarkersMap","shouldAllowInvisibleCharacters","USFM_MARKERS_MAP_3_0","versionA","versionB","jsonPathQuery","wrappedResults","JSONPath","unwrappedResults","marker","workingStack","fragment","parentMap","tempNode","tempParent","tempChild","pathArray","pathAcc","pathEntry","jsonPath","stack","stackLevel","levels","onNode","onLevel","indexString","nextNode","skipTypes","searchFunction","topNode","highestSkippedNode","stackItem","stackNode","skipNextNode","nextNodeClosingMarker","nextLevel","parentClosingMarker","potentiallyMatchingNodeOrClose","currentWorkingStack","nodeParent","bookIdIfNotFound","usjLocation","realParent","nodeIndexInParent","fragmentInfo","verseRef","verseIndexInUsfm","availableBookIds","noBookIdsFound","effectiveBookId","chapterIndices","indexInUsfm","bookEntries","bookIndex","lastVerseRef","didFindVerseRef","chapterEntries","chapterIndex","chapterNumString","verseIndices","verseEntries","verseIndex","verseNumString","verseFragmentInfo","usfmVerseLocation","verseRefOffset","usjChapterLocation","usjBookLocation","usfmVerseLocationIndexInUsfm","usjOffset","usjDocumentLocationMaybeNode","documentLocation","verseLocation","firstStringLocationAfterVerseMarker","maxTextLengthToSearch","textScanned","lengthScanned","lengthTrimmed","foundStartingAtOffset","workingStackForStartingPoint","startingPointStackItem","nodeTextToSearch","currentStackItem","textIndex","finalOffset","finalStack","finalNode","regex","textChunks","fullTextIndexMap","fullText","startingNodeEntry","endingNodeEntry","desiredLength","offsetRemaining","lengthRecorded","remainingNode","lengthToCopy","maxLength","currentStack","contentArray","removedCount","markerName","markerInfo","markerRegExp","scriptureFormat","markerNameOriginal","markerIsUnknown","markerTypeFromFirstMarkerInfo","markerType","markerTypeInfo","attributeMarkerInfoEntries","attributeMarkerName","attributeMarkerInfo","markerWithAnyAttributes","columnsSpanned","tableMarkerMatches","startingColumn","textContent","newFragmentsInfo","existingFragmentsInfo","existingUsfmLength","fragmentIndex","isInsideMarkerWithSameType","usfm","fragmentsInfo","markerPrefix","attributeName","attributeValue","attributeMarker","attributeMarkerFragmentsInfo","textContentUsfm","partialClosingFragment","closingMarkerAttributeNames","hasExplicitClosingMarker","independentClosingMarker","openingMarkerUsfm","openingFragmentsInfo","openingFragmentInfo","attributeNameUsfm","closingMarkerName","markerParentOrIsInsideMarkerWithSameType","usfmOutput","markerUsfmOutput","markerFragmentsInfo","isParentSameType","parentMarkerType","closingUsfm","closingFragmentsInfo","openingUsfm","lastMarkerBackslashIndex","newLocation","ignoreJsonPath","aJsonPath","restOfA","bJsonPath","restOfB","zeroedUsjLocation","fragmentInfoAtLocation","allFragmentsInfoAtJsonPath","locationOffset","offsetWithinFragment","fragmentsByIndexInUsfm","fragmentsByJsonPath","indicesInUsfmByVerseRef","nextChapterNum","currentBookFragments","nextVerseNumString","nextVerseNum","_c","fragmentJsonPath","fragmentsAtJsonPath","currentPosition","transferFragmentsInfo","topLevelUsjMarker","markersToSkipOutput","nodeOrClosingFragment","textContentFragmentsInfo","markerParent"],"mappings":"oTACaA,GAAN,MA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AuB,CACnF,CAQO,SAASG,GAAgBzF,EAAwC,CACtE,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,UAAY,yBAA0BA,CAC3E,CCzEA,IAAI0F,GAAI,OAAO,eACXC,GAAI,CAACC,EAAG,EAAGpH,IAAM,KAAKoH,EAAIF,GAAEE,EAAG,EAAG,CAAE,WAAY,GAAI,aAAc,GAAI,SAAU,GAAI,MAAOpH,CAAC,CAAE,EAAIoH,EAAE,CAAC,EAAIpH,EACzGqH,EAAI,CAACD,EAAG,EAAGpH,IAAMmH,GAAEC,EAAG,OAAO,GAAK,SAAW,EAAI,GAAK,EAAGpH,CAAC,EAW9D,MAAMsH,GAAI,CACR,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MAEA,MAEA,MAEA,MAEA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,MAEA,MAEA,MAEA,MAEA,MACA,MACA,MACA,MAEA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MAEA,MACA,MACA,KACF,EAAGC,GAAI,CACL,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,KACF,EAAGC,GAAI,CACL,UACA,SACA,YACA,UACA,cACA,SACA,SACA,OACA,WACA,WACA,UACA,UACA,eACA,eACA,OACA,WACA,kBACA,MACA,SACA,WACA,eACA,gBACA,SACA,WACA,eACA,UACA,kBACA,QACA,OACA,OACA,UACA,QACA,QACA,QACA,WACA,YACA,SACA,YACA,UACA,UACA,OACA,OACA,OACA,OACA,SACA,gBACA,gBACA,YACA,YACA,cACA,aACA,kBACA,kBACA,YACA,YACA,QACA,WACA,UACA,QACA,UACA,UACA,SACA,SACA,SACA,OACA,aACA,QACA,SACA,eACA,oBACA,0BACA,SACA,qBACA,sBACA,UACA,qBACA,cACA,cACA,cACA,cACA,mBACA,mBACA,qBACA,YACA,OACA,oBAGA,uBACA,uBACA,sBACA,yBACA,wBACA,qBACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,eACA,cACA,eACA,oBACA,qBACA,0BACA,0BACA,eACA,eACA,YACA,gBACA,cACA,eACA,iBACA,wBACA,mBACA,WACA,QACA,aACA,aACA,aACA,2BACA,4BACA,YACF,EAAGC,GAAIC,GAAG,EACV,SAASC,GAAEP,EAAG,EAAI,GAAI,CACpB,OAAO,IAAMA,EAAIA,EAAE,YAAa,GAAGA,KAAKK,GAAIA,GAAEL,CAAC,EAAI,CACrD,CACA,SAASQ,GAAER,EAAG,CACZ,OAAOO,GAAEP,CAAC,EAAI,CAChB,CACA,SAASS,GAAET,EAAG,CACZ,MAAM,EAAI,OAAOA,GAAK,SAAWO,GAAEP,CAAC,EAAIA,EACxC,OAAO,GAAK,IAAM,GAAK,EACzB,CACA,SAASU,GAAEV,EAAG,CACZ,OAAQ,OAAOA,GAAK,SAAWO,GAAEP,CAAC,EAAIA,IAAM,EAC9C,CACA,SAASW,GAAEX,EAAG,CACZ,OAAOA,GAAK,EACd,CACA,SAASY,GAAEZ,EAAG,CACZ,MAAM,EAAI,OAAOA,GAAK,SAAWO,GAAEP,CAAC,EAAIA,EACxC,OAAOa,GAAE,CAAC,GAAK,CAACF,GAAE,CAAC,CACrB,CACA,SAAUG,IAAI,CACZ,QAASd,EAAI,EAAGA,GAAKE,GAAE,OAAQF,IAAK,MAAMA,CA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AAa,0EACb,KAAM,SACN,kBAAmB,CACjB,0BAA2B,CACzB,KAAM,wBAAA,CAEV,EACA,qBAAsB,EACxB,EACA,eAAgB,CACd,YAAa,gDACb,MAAO,CACL,CACE,KAAM,2CAAA,CACR,CAEJ,EACA,kCAAmC,CACjC,YAAa,yDACb,MAAO,CACL,CACE,KAAM,4BACR,EACA,CACE,KAAM,qCAAA,CACR,CAEJ,EACA,mBAAoB,CAClB,YAAa,8DACb,MAAO,CACL,CACE,KAAM,qBACR,EACA,CACE,KAAM,yBAAA,CACR,CAEJ,EACA,gBAAiB,CACf,YAAa,8CACb,KAAM,SACN,WAAY,CACV,yBAA0B,CACxB,YACE,+3CACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CACL,MAAO,CACL,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CACF,CACF,CACF,CAEJ,EACA,yBAA0B,CACxB,YACE,igDACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CACL,MAAO,CACL,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CACF,CACF,CACF,CAEJ,EACA,qBAAsB,CACpB,YACE,ybACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CAEJ,EACA,qBAAsB,CACpB,YACE,mdACF,MAAO,CACL,CACE,KAAM,MACR,EACA,CACE,KAAM,QACR,EACA,CACE,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,CAAA,CAC1B,CACF,CACF,CAEJ,EACA,qBAAsB,CACpB,YACE,sFACF,MAAO,CACL,CACE,KAAM,uBACR,EACA,CACE,KAAM,QACN,MAAO,CACL,KAAM,uBAAA,CACR,CACF,CAE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ACA,mBAAoB,CAClB,YACE,uFACF,KAAM,SACN,kBAAmB,CACjB,0BAA2B,CACzB,YAAa,qCACb,KAAM,SACN,WAAY,CACV,MAAO,CACL,YAAa,6CACb,KAAM,qBACR,EACA,cAAe,CACb,YACE,wFACF,KAAM,QACR,EACA,MAAO,CACL,YACE,6EACF,KAAM,QACR,EACA,aAAc,CACZ,YACE,8EACF,KAAM,SAAA,CAEV,EACA,SAAU,CAAC,QAAS,OAAO,EAC3B,qBAAsB,EAAA,CAE1B,EACA,WAAY,CACV,aAAc,CACZ,YACE,qFACF,KAAM,SAAA,CACR,CAEJ,EACA,WAAY,CACV,YACE,uJACF,KAAM,SACN,kBAAmB,CACjB,0BAA2B,CACzB,YAAa,wCACb,KAAM,SACN,MAAO,CACL,CACE,WAAY,CACV,OAAQ,CACN,YACE,wEACF,KAAM,wBACR,EACA,MAAO,CACL,YACE,yGACF,KAAM,QACR,EACA,aAAc,CACZ,YACE,iFACF,KAAM,SAAA,CAEV,EACA,SAAU,CAAC,OAAO,EAClB,qBAAsB,EACxB,EACA,CACE,WAAY,CACV,SAAU,CACR,YAAa,8DACb,KAAM,wBACR,EACA,MAAO,CACL,YACE,yGACF,KAAM,QACR,EACA,aAAc,CACZ,YACE,iFACF,KAAM,SAAA,CAEV,EACA,SAAU,CAAC,WAAY,OAAO,EAC9B,qBAAsB,EAAA,CACxB,CACF,CAEJ,EACA,qBAAsB,EACxB,EACA,SAAU,CACR,YACE,mGACF,KAAM,SACN,MAAO,CACL,CACE,WAAY,CACV,GAAI,CACF,YAAa,6CACb,KAAM,wBAAA,CAEV,EACA,SAAU,CAAC,IAAI,CACjB,EACA,CACE,WAAY,CACV,QAAS,CACP,YAAa,mEACb,KAAM,wBACR,EACA,eAAgB,CACd,YACE,0GACF,KAAM,QACR,EACA,cAAe,CACb,YACE,yGACF,KAAM,QAAA,CAEV,EACA,SAAU,CAAC,SAAS,CAAA,CAExB,EACA,WAAY,CACV,MAAO,CACL,YAAa,4DACb,KAAM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BAAkB,CAAC,KAAK,CAC1B,EACA,IAAK,CACH,KAAM,QACR,EACA,GAAI,CACF,KAAM,OACN,YAAa,qBACb,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YACE,uHACF,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YAAa,0CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,yCACb,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YAAa,oDACb,wBAAyB,EAC3B,EACA,IAAK,CACH,KAAM,OACN,YAAa,iEACb,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YAAa,wCACb,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACb,wBAAyB,EAC3B,EACA,GAAI,CACF,KAAM,OACN,YAAa,yCACf,EACA,GAAI,CACF,KAAM,OACN,YACE,2GACF,wBAAyB,EAC3B,EACA,EAAG,CACD,KAAM,OACN,YAAa,gCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,qDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,sDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,yBACf,EACA,GAAI,CACF,KAAM,OACN,kBAAmB,CAAC,MAAM,CAC5B,EACA,IAAK,CACH,KAAM,OACN,YAAa,2BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACf,EACA,IAAK,CACH,KAAM,OACN,YACE,mGACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,yCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,4CACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YACE,kFACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,wEACf,EACA,IAAK,CACH,KAAM,OACN,YACE,mFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE;AAAA,sDACJ,EACA,KAAM,CACJ,KAAM,OACN,YAAa,wDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,mCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,mCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,gEACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,yEACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,4EACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,uDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,sDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,YACE,oFACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YACE;AAAA,yDACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,gEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,wDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,qDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,wDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mCACf,EACA,IAAK,CACH,KAAM,MACR,EACA,GAAI,CACF,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oCACf,EACA,IAAK,CACH,KAAM,OACN,iBAAkB,YAClB,YAAa,sDACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,eACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,yCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,gCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,sDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,iCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,mDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,yDACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,4DACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,uCACf,EACA,EAAG,CACD,KAAM,OACN,YACE,gGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,+EACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,gEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,8CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,iDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,iDACf,EACA,IAAK,CACH,KAAM,OACN,YACE;AAAA,8DACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,uFACJ,EACA,KAAM,CACJ,KAAM,OACN,YACE,4FACJ,EACA,KAAM,CACJ,KAAM,OACN,YAAa,qEACf,EACA,GAAI,CACF,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,mBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,2BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oCACf,EACA,SAAU,CACR,KAAM,UACR,EACA,IAAK,CACH,KAAM,OACN,YAAa,2CACf,EACA,EAAG,CACD,KAAM,OACN,YACE;AAAA,6CACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,mEACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mEACf,EACA,GAAI,CACF,KAAM,OACN,YACE,uGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,uCACf,EACA,OAAQ,CACN,KAAM,SACN,qBAAsB,KACxB,EACA,GAAI,CACF,KAAM,OACN,YACE,iGACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,kEACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6CACf,EACA,GAAI,CACF,KAAM,OACN,YACE,oGACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,uGACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,yBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,mBACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,8BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,gBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,wCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,6EACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,+CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,sCACf,EACA,IAAK,CACH,KAAM,OACN,YACE,kFACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,YACE,0FACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,yDACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,4DACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,IAAK,CACH,KAAM,OACN,YAAa,uCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,oBACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,8DACf,EACA,OAAQ,CACN,KAAM,KACN,iBAAkB,KACpB,EACA,OAAQ,CACN,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,QAAS,CACP,KAAM,KACN,iBAAkB,KACpB,EACA,EAAG,CACD,KAAM,OACN,YAAa,uBACf,EACA,GAAI,CACF,KAAM,OACN,iBAAkB,OACpB,EACA,IAAK,CACH,KAAM,MACN,iBAAkB,KACpB,EACA,IAAK,CACH,KAAM,OACN,YAAa,QACf,EACA,QAAS,CACP,KAAM,OACN,YAAa,sCACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,2EACf,EACA,EAAG,CACD,KAAM,OACN,YAAa,8CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,iDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,2DACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,4BACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,kDACf,EACA,GAAI,CACF,KAAM,OACN,YACE,iFACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,iHACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YACE,4FACJ,EACA,IAAK,CACH,KAAM,OACN,YAAa,+CACf,EACA,IAAK,CACH,KAAM,OACN,YACE,kGACJ,EACA,GAAI,CACF,KAAM,OACN,YAAa,+CACf,EACA,GAAI,CACF,KAAM,OACN,YAAa,6CACf,EACA,IAAK,CACH,KAAM,OACN,YAAa;AAAA,OACf,EACA,IAAK,CACH,KAAM,OACN,YACE,2FACJ,EACA,MAAO,CACL,KAAM,KACN,iBAAkB,KACpB,EACA,MAAO,CACL,KAAM,KACN,iBAAkB,KACpB,EACA,MAAO,CACL,KAAM,OACR,EACA,GAAI,CACF,KAAM,OACN,YAAa,0BACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,6BACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,8BACf,EACA,KAAM,CACJ,KAAM,OACN,YAAa,mBACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,kDACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,mDACf,EACA,MAAO,CACL,KAAM,OACN,YAAa,wCACf,EACA,GAAI,CACF,KAAM,MACN,YAAa,WACf,EACA,GAAI,CACF,KAAM,KACN,YACE,sFACJ,EACA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EAE1B,KAAK,gCAAA,CAIhB","x_google_ignoreList":[16,17,18,19,20,21,22,23,24,25,26,27,35]} \ No newline at end of file diff --git a/lib/platform-bible-utils/dist/index.d.ts b/lib/platform-bible-utils/dist/index.d.ts index 4e2ac78b39a..0708f094108 100644 --- a/lib/platform-bible-utils/dist/index.d.ts +++ b/lib/platform-bible-utils/dist/index.d.ts @@ -1567,8 +1567,10 @@ export declare function areUsjContentsEqualExceptWhitespace(a: Usj | undefined, * An attribute marker is a marker that adds information to a previous marker in USFM and is an * attribute on that previous marker instead in USX/USJ. * - * @example `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for - * `v`. `cat` is an attribute marker for `f`, `esb`, and more. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for `v`. `cat` + * is an attribute marker for `f`, `esb`, and more. * * Following is an example of using the `ca` and `cp` attribute markers in USFM: * @@ -1590,23 +1592,28 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { /** * List of normal marker names for which this marker is an attribute marker. * - * @example `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` - * for both `ca` and `cp`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` for both + * `ca` and `cp`. */ isAttributeMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an attribute marker. * - * @example Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. + * @example + * + * Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isAttributeMarkerForRegExp?: string[]; /** * The name of the USX/USJ attribute this attribute marker represents. * - * @example `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the - * `c` marker in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` - * marker. + * @example + * + * `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the `c` marker + * in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` marker. */ attributeMarkerAttributeName: string; /** @@ -1625,8 +1632,10 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * If not present or `undefined`, defaults to `false`. * - * @example According to specification, the `va` and `vp` attribute markers have a space after - * their normal closing markers: + * @example + * + * According to specification, the `va` and `vp` attribute markers have a space after their normal + * closing markers: * * ```usfm * \p \v 10 \va 10 va\va* \vp 10 vp\vp* Some verse text @@ -1644,8 +1653,9 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * The verse text in this example is " Some verse text" including a space at the start. * - * @example The `cat` attribute marker does not have a structural space after its normal closing - * marker: + * @example + * + * The `cat` attribute marker does not have a structural space after its normal closing marker: * * ```usfm * \f + \cat category here\cat*\fr 1:2 \ft Some footnote text\f* @@ -1676,13 +1686,17 @@ export type NormalMarkerInfo = { * An attribute can be provided with default syntax in the USFM only if it is the only attribute * provided for the marker. * - * @example A marker with a default attribute: + * @example + * + * A marker with a default attribute: * * ```usfm * \w stuff|thisIsTheLemmaDefaultAttribute\w* * ``` * - * @example A marker with multiple attributes (cannot use default attribute syntax): + * @example + * + * A marker with multiple attributes (cannot use default attribute syntax): * * ```usfm * \w stuff|lemma="thisIsTheLemma" strong="H1234,G1234"\w* @@ -1696,8 +1710,10 @@ export type NormalMarkerInfo = { * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual * text content of the marker. * - * @example `alt` is a text content attribute on the `periph` marker. This value would be `alt` - * for the `periph` marker. + * @example + * + * `alt` is a text content attribute on the `periph` marker. This value would be `alt` for the + * `periph` marker. * * Following is an example of a `periph` marker in USFM: * @@ -1723,8 +1739,10 @@ export type NormalMarkerInfo = { * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker * and separated only by a space. * - * @example `code` is a leading attribute on the `id` marker. This value would be `['code']` for - * the `id` marker. + * @example + * + * `code` is a leading attribute on the `id` marker. This value would be `['code']` for the `id` + * marker. * * Following is an example of an `id` marker in USFM: * @@ -1750,8 +1768,9 @@ export type NormalMarkerInfo = { * Note: the attribute names for attribute markers may be different than the marker names. See * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information. * - * @example `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for - * `c`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for `c`. */ attributeMarkers?: string[]; /** @@ -1793,7 +1812,9 @@ export type NormalMarkerInfo = { * closing marker for but rather are completely separate markers that close the corresponding * opening marker. * - * @example `esb` (a sidebar) is closed by the independent closing marker `esbe`. + * @example + * + * `esb` (a sidebar) is closed by the independent closing marker `esbe`. * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a * sidebar: * @@ -1807,20 +1828,24 @@ export type NormalMarkerInfo = { independentClosingMarkers?: string[]; /** * List of marker names for which this marker is an independent closing marker. See - * {@link NormalMarkerInfo.independentClosingMarker} for more information on independent closing + * {@link NormalMarkerInfo.independentClosingMarkers} for more information on independent closing * markers and their syntax. * - * @example `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` - * would be `['esb']` for `esbe`. + * @example + * + * `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` would be + * `['esb']` for `esbe`. */ isIndependentClosingMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an independent closing - * marker. See {@link NormalMarkerInfo.independentClosingMarker} for more information on + * marker. See {@link NormalMarkerInfo.independentClosingMarkers} for more information on * independent closing markers and their syntax. * - * @example Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp - * `/test/`. `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. + * @example + * + * Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp `/test/`. + * `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isIndependentClosingMarkerForRegExp?: string[]; /** @@ -1828,8 +1853,9 @@ export type NormalMarkerInfo = { * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used * instead of the marker info for the marker as listed in USX or USJ. * - * @example When the `usx` marker is output to USFM, it should be transformed to the `usfm` - * marker. + * @example + * + * When the `usx` marker is output to USFM, it should be transformed to the `usfm` marker. */ markerUsfm?: string; /** @@ -1846,9 +1872,11 @@ export type NormalMarkerInfo = { /** * Information about a USFM/USX/USJ marker that is essential for proper translation between formats. * - * @example `w` is a `char`-type marker, so it shares the characteristics of the `char` - * {@link MarkerTypeInfo} with other `char`-type markers and has its own set of characteristics. - * `w`'s `MarkerInfo` is as follows: + * @example + * + * `w` is a `char`-type marker, so it shares the characteristics of the `char` {@link MarkerTypeInfo} + * with other `char`-type markers and has its own set of characteristics. `w`'s `MarkerInfo` is as + * follows: * * ```json * { @@ -1866,8 +1894,10 @@ export type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo; * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` markers such - * as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` markers such as `p` do + * not: * * ```usfm * \p This is a plain paragraph. @@ -1904,7 +1934,9 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * * If not present or `undefined`, defaults to `false` * - * @example Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: + * @example + * + * Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: * * ```usfm * \qt1-s\* @@ -1930,8 +1962,10 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * Information about a USFM/USX/USJ marker type that does not have a closing marker. See * {@link MarkerTypeInfo} for other kinds of marker types. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` marker types - * such as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` marker types such as + * `p` do not: * * ```usfm * \p This is a plain paragraph. @@ -1983,8 +2017,10 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example The `sid` attribute on the `verse` type marker is not present in USFM because it is - * derived metadata in USX/USJ and is not present in USFM. + * @example + * + * The `sid` attribute on the `verse` type marker is not present in USFM because it is derived + * metadata in USX/USJ and is not present in USFM. */ skipOutputAttributeToUsfm?: string[]; /** @@ -1999,10 +2035,12 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the - * end of the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the - * `verse` marker does not have the `style="v"` attribute in this situation, so this list of - * attributes is on the marker type. + * @example + * + * If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the end of + * the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the `verse` + * marker does not have the `style="v"` attribute in this situation, so this list of attributes is + * on the marker type. * * Following is an example of a derived metadata `verse` marker in USX: * @@ -2020,8 +2058,10 @@ export type MarkerTypeInfoBase = { * \v 21 This is verse 21. * ``` * - * @example Generated `ref`s should be skipped but have content inside the marker that should not - * be skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have + * @example + * + * Generated `ref`s should be skipped but have content inside the marker that should not be + * skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived * metadata have the `gen` attribute set to `"true"` and can be removed if `gen="true"` is * present. @@ -2052,8 +2092,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ - * and is not preserved when transforming from USX/USJ to USFM. + * @example + * + * In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ and is + * not preserved when transforming from USX/USJ to USFM. * * Following is an example of a derived metadata `table` marker in USX: * @@ -2096,8 +2138,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example `para` marker types such as `p` should have a newline, but `char` marker types such as - * `nd` markers should not: + * @example + * + * `para` marker types such as `p` should have a newline, but `char` marker types such as `nd` + * markers should not: * * ```usfm * \p This is a plain paragraph. @@ -2127,8 +2171,10 @@ export type MarkerTypeInfoBase = { * Prefix to add to the opening and closing marker before the marker name if a marker of this type * occurs within another marker of this type when outputting to USFM. * - * @example In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is - * an example of `nd` inside `wj` (both are `char`-type markers) in USFM: + * @example + * + * In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is an + * example of `nd` inside `wj` (both are `char`-type markers) in USFM: * * ```usfm * \p \wj This is \+nd nested\+nd*!\wj* @@ -2160,9 +2206,11 @@ export type MarkerTypeInfoBase = { * Information about a USFM/USX/USJ marker type that is essential for proper translation between * formats. * - * @example `char` is a marker type, which means markers like `w` whose marker type is `char` share - * some characteristics, and each marker also has its own set of characteristics which are presented - * with type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: + * @example + * + * `char` is a marker type, which means markers like `w` whose marker type is `char` share some + * characteristics, and each marker also has its own set of characteristics which are presented with + * type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: * * ```json * { @@ -2453,8 +2501,7 @@ export type UsjVerseRefBookLocation {\n private static verboseLoggingEnabled: boolean = false;\n private readonly variableName: string;\n private readonly promiseToValue: Promise;\n private timeoutId: ReturnType | undefined;\n private timeoutOccurred: boolean;\n private resolver: ((value: T) => void) | undefined;\n private rejecter: ((reason: string | undefined) => void) | undefined;\n\n /**\n * Creates an instance of the class\n *\n * @param variableName Name to use when logging about this variable\n * @param rejectIfNotSettledWithinMS Milliseconds to wait before verifying if the promise was\n * settled (resolved or rejected); will reject if it has not settled by that time. Use -1 if you\n * do not want a timeout at all. Defaults to 10000 ms\n */\n constructor(variableName: string, rejectIfNotSettledWithinMS: number = 10000) {\n this.variableName = variableName;\n this.timeoutOccurred = false;\n this.promiseToValue = new Promise((resolve, reject) => {\n this.resolver = resolve;\n this.rejecter = reject;\n });\n if (rejectIfNotSettledWithinMS > 0) {\n this.timeoutId = setTimeout(() => {\n if (this.rejecter) {\n this.rejecter(`Timeout reached when waiting for ${this.variableName} to settle`);\n this.timeoutOccurred = true;\n this.complete();\n }\n }, rejectIfNotSettledWithinMS);\n }\n Object.seal(this);\n }\n\n /**\n * Get this variable's promise to a value. This always returns the same promise even after the\n * value has been resolved or rejected.\n *\n * @returns The promise for the value to be set\n */\n get promise(): Promise {\n return this.promiseToValue;\n }\n\n /**\n * A simple way to see if this variable's promise was resolved or rejected already\n *\n * @returns Whether the variable was already resolved or rejected\n */\n get hasSettled(): boolean {\n return Object.isFrozen(this);\n }\n\n /**\n * Can use to determine if a rejection occurred due to a timeout\n *\n * @returns Whether the variable timed out while waiting for a value to resolve\n */\n get hasTimedOut(): boolean {\n return this.timeoutOccurred;\n }\n\n /**\n * Allows enabling more verbose logging when async variables resolve and reject\n *\n * @param enabled Whether to enable verbose logging\n */\n static setVerboseLogging(enabled: boolean): void {\n this.verboseLoggingEnabled = enabled;\n }\n\n /**\n * Resolve this variable's promise to the given value\n *\n * @param value This variable's promise will resolve to this value\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n resolveToValue(value: T, throwIfAlreadySettled: boolean = false): void {\n if (this.resolver) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being resolved now`);\n this.resolver(value);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent resolution of ${this.variableName}`);\n }\n }\n\n /**\n * Reject this variable's promise for the value with the given reason\n *\n * @param reason This variable's promise will be rejected with this reason\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n rejectWithReason(reason: string, throwIfAlreadySettled: boolean = false): void {\n if (this.rejecter) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being rejected now with reason: ${reason}`);\n this.rejecter(reason);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent rejection of ${this.variableName}`);\n }\n }\n\n /** Prevent any further updates to this variable */\n private complete(): void {\n this.resolver = undefined;\n this.rejecter = undefined;\n if (this.timeoutId !== undefined) {\n clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n Object.freeze(this);\n }\n}\n\nexport default AsyncVariable;\n","/** Enables language-sensitive string comparison. Wraps Intl.Collator */\nexport class Collator {\n private collator: Intl.Collator;\n\n constructor(locales?: string | string[], options?: Intl.CollatorOptions) {\n this.collator = new Intl.Collator(locales, options);\n }\n\n /**\n * Compares two strings according to the sort order of this Collator object\n *\n * @param string1 String to compare\n * @param string2 String to compare\n * @returns A number indicating how string1 and string2 compare to each other according to the\n * sort order of this Collator object. Negative value if string1 comes before string2. Positive\n * value if string1 comes after string2. 0 if they are considered equal.\n */\n compare(string1: string, string2: string): number {\n return this.collator.compare(string1, string2);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and collation options computed\n * during initialization of this collator object.\n *\n * @returns ResolvedCollatorOptions object\n */\n resolvedOptions(): Intl.ResolvedCollatorOptions {\n return this.collator.resolvedOptions();\n }\n}\n\nexport default Collator;\n","/** Enables language-sensitive data and time formatting. Wraps Intl.DateTimeFormat */\nexport class DateTimeFormat {\n private dateTimeFormatter: Intl.DateTimeFormat;\n\n constructor(locales?: string | string[], options?: Intl.DateTimeFormatOptions) {\n this.dateTimeFormatter = new Intl.DateTimeFormat(locales, options);\n }\n\n /**\n * Formats a date according to the locale and formatting option for this DateTimeFormat object\n *\n * @param date The date to format\n * @returns String representing the given date formatted according to the locale and formatting\n * options of this DateTimeFormat object\n */\n format(date: Date): string {\n return this.dateTimeFormatter.format(date);\n }\n\n /**\n * Formats a date range in the most concise way based on the locales and options provided when\n * instantiating this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns String representing the given date range formatted according to the locale and\n * formatting options of this DateTimeFormat object\n */\n formatRange(startDate: Date, endDate: Date): string {\n return this.dateTimeFormatter.formatRange(startDate, endDate);\n }\n\n /**\n * Returns an array of locale-specific tokens representing each part of the formatted date range\n * produced by this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns Array of DateTimeRangeFormatPart objects\n */\n formatRangeToParts(startDate: Date, endDate: Date): Intl.DateTimeRangeFormatPart[] {\n return this.dateTimeFormatter.formatRangeToParts(startDate, endDate);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this DateTimeFormat object\n *\n * @param date The date to format\n * @returns Array of DateTimeFormatPart objects\n */\n formatToParts(date: Date): Intl.DateTimeFormatPart[] {\n return this.dateTimeFormatter.formatToParts(date);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and date and time formatting options\n * computed during initialization of this DateTimeFormat object\n *\n * @returns ResolvedDateTimeFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n return this.dateTimeFormatter.resolvedOptions();\n }\n}\n\nexport default DateTimeFormat;\n","/** Interfaces, classes, and functions related to events and event emitters */\n\nimport { Dispose } from '../lifetime-management/disposal.model';\nimport { PlatformEvent, PlatformEventHandler } from './platform-event';\n\n/**\n * Event manager - accepts subscriptions to an event and runs the subscription callbacks when the\n * event is emitted Use eventEmitter.event(callback) to subscribe to the event. Use\n * eventEmitter.emit(event) to run the subscriptions. Generally, this EventEmitter should be\n * private, and its event should be public. That way, the emitter is not publicized, but anyone can\n * subscribe to the event.\n */\nexport class PlatformEventEmitter implements Dispose {\n /**\n * Subscribes a function to run when this event is emitted.\n *\n * @param callback Function to run with the event when it is emitted\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n subscribe = this.event;\n\n /** All callback functions that will run when this event is emitted. Lazy loaded */\n private subscriptions?: PlatformEventHandler[];\n /** Event for listeners to subscribe to. Lazy loaded */\n private lazyEvent?: PlatformEvent;\n /** Whether this emitter has been disposed */\n private isDisposed = false;\n\n /**\n * Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.\n * Use like `const unsubscriber = event(callback)`\n *\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n get event(): PlatformEvent {\n this.assertNotDisposed();\n\n if (!this.lazyEvent) {\n this.lazyEvent = (callback) => {\n if (!callback || typeof callback !== 'function')\n throw new Error(`Event handler callback must be a function!`);\n\n // Initialize this.subscriptions if it does not exist\n if (!this.subscriptions) this.subscriptions = [];\n\n this.subscriptions.push(callback);\n\n return () => {\n if (!this.subscriptions) return false; // Did not find any subscribed callbacks\n\n const callbackIndex = this.subscriptions.indexOf(callback);\n\n if (callbackIndex < 0) return false; // Did not find this callback in the subscriptions\n\n // Remove the callback\n this.subscriptions.splice(callbackIndex, 1);\n\n return true;\n };\n };\n }\n return this.lazyEvent;\n }\n\n /** Disposes of this event, preparing it to release from memory */\n dispose = () => {\n return this.disposeFn();\n };\n\n /**\n * Runs the subscriptions for the event\n *\n * @param event Event data to provide to subscribed callbacks\n */\n emit = (event: T) => {\n // Do not do anything other than emitFn here. This emit is just binding `this` to emitFn\n this.emitFn(event);\n };\n\n /**\n * Function that runs the subscriptions for the event. Added here so children can override emit\n * and still call the base functionality. See NetworkEventEmitter.emit for example\n */\n protected emitFn(event: T) {\n this.assertNotDisposed();\n\n // Clone the subscriptions array before iterating over the callbacks so the callback index\n // doesn't get messed up if someone subscribes or unsubscribes inside one of the callbacks\n const emitCallbacks = [...(this.subscriptions ?? [])];\n emitCallbacks.forEach((callback) => callback(event));\n }\n\n /** Check to make sure this emitter is not disposed. Throw if it is */\n protected assertNotDisposed() {\n if (this.isDisposed) throw new Error('Emitter is disposed');\n }\n\n /**\n * Disposes of this event, preparing it to release from memory. Added here so children can\n * override emit and still call the base functionality.\n */\n protected disposeFn() {\n this.assertNotDisposed();\n\n this.isDisposed = true;\n this.subscriptions = undefined;\n this.lazyEvent = undefined;\n return Promise.resolve(true);\n }\n}\n\nexport default PlatformEventEmitter;\n","/** Collection of functions, objects, and types that are used as helpers in other services. */\n\n// Thanks to blubberdiblub at https://stackoverflow.com/a/68141099/217579\nexport function newGuid(): string {\n return '00-0-4-1-000'.replace(/[^-]/g, (s) =>\n // @ts-expect-error ts(2363) this works fine\n // eslint-disable-next-line no-bitwise\n (((Math.random() + ~~s) * 0x10000) >> s).toString(16).padStart(4, '0'),\n );\n}\n\n// thanks to DRAX at https://stackoverflow.com/a/9436948\n/**\n * Determine whether the object is a string\n *\n * @param o Object to determine if it is a string\n * @returns True if the object is a string; false otherwise\n */\nexport function isString(o: unknown): o is string {\n return typeof o === 'string' || o instanceof String;\n}\n\n/**\n * If deepClone isn't used when copying properties between objects, you may be left with dangling\n * references between the source and target of property copying operations.\n *\n * @param obj Object to clone\n * @returns Duplicate copy of `obj` without any references back to the original one\n */\nexport function deepClone(obj: T): T {\n // Assert the return type matches what is expected\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\n/**\n * Get a function that reduces calls to the function passed in\n *\n * @template T - A function type that takes any arguments and returns void. This is the type of the\n * function being debounced.\n * @param fn The function to debounce\n * @param delay How much delay in milliseconds after the most recent call to the debounced function\n * to call the function\n * @returns Function that, when called, only calls the function passed in at maximum every delay ms\n */\n// We don't know the parameter types since this function can be anything and can return anything\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce any>(\n fn: TFunc,\n delay = 300,\n): (...args: Parameters) => Promise> {\n let timeout: ReturnType;\n let promise: Promise> | undefined;\n let promiseResolve: (value: ReturnType | PromiseLike>) => void;\n let promiseReject: (reason?: unknown) => void;\n\n return (...args) => {\n clearTimeout(timeout);\n if (!promise)\n promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n timeout = setTimeout(async () => {\n try {\n promiseResolve(await fn(...args));\n } catch (e) {\n promiseReject(e);\n } finally {\n promise = undefined;\n }\n }, delay);\n\n return promise;\n };\n}\n\n/**\n * Groups each item in the array of items into a map according to the keySelector\n *\n * There are two overloads:\n *\n * - `groupBy(items, keySelector)` – groups the original items using the key returned by\n * `keySelector`.\n * - `groupBy(items, keySelector, valueSelector)` – groups transformed values using the key returned\n * by `keySelector` and the value returned by `valueSelector`.\n *\n * If `valueSelector` is not provided, the original item is used in the resulting groups.\n *\n * @param items - Array of items to group by.\n * @param keySelector - Function to run on each item to get the key for the group to which it\n * belongs. The first argument is the item, and the second argument is the index of the item in\n * the original array.\n * @param valueSelector - Optional function to run on each item to get the value to store in the\n * group. The first argument is the item, the second argument is the key for the group to which\n * this item belongs, and the third argument is the index of the item in the original array.\n * @returns Map of keys to groups of values corresponding to each item.\n */\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector: (item: T, key: K, index: number) => V,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector?: (item: T, key: K, index: number) => V,\n): Map> {\n const map = new Map>();\n items.forEach((item, index) => {\n const key = keySelector(item, index);\n const group = map.get(key);\n const value = valueSelector ? valueSelector(item, key, index) : item;\n if (group) group.push(value);\n else map.set(key, [value]);\n });\n return map;\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\ntype ErrorWithMessage = {\n message: string;\n};\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return (\n typeof error === 'object' &&\n // We're potentially dealing with objects we didn't create, so they might contain `null`\n // eslint-disable-next-line no-null/no-null\n error !== null &&\n 'message' in error &&\n // Type assert `error` to check it's `message`.\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n typeof (error as Record).message === 'string'\n );\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error from the object (useful for getting an error in a catch block)\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n // fallback in case there's an error stringifying the maybeError\n // like with circular references for example.\n return new Error(String(maybeError));\n }\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error message from the object (useful for getting error message in a catch\n * block)\n *\n * @example `try {...} catch (e) { logger.info(getErrorMessage(e)) }`\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\n/** Asynchronously waits for the specified number of milliseconds. (wraps setTimeout in a promise) */\nexport function wait(ms: number) {\n // eslint-disable-next-line no-promise-executor-return\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Runs the specified function and will timeout if it takes longer than the specified wait time\n *\n * @param fn The function to run\n * @param maxWaitTimeInMS The maximum amount of time to wait for the function to resolve\n * @returns Promise that resolves to the resolved value of the function or undefined if it ran\n * longer than the specified wait time\n */\nexport function waitForDuration(fn: () => Promise, maxWaitTimeInMS: number) {\n const timeout = wait(maxWaitTimeInMS).then(() => undefined);\n return Promise.any([timeout, fn()]);\n}\n\n/**\n * Get all functions on an object and its prototype chain (so we don't miss any class methods or any\n * object methods). Note that the functions on the final item in the prototype chain (i.e., Object)\n * are skipped to avoid including functions like `__defineGetter__`, `__defineSetter__`, `toString`,\n * etc.\n *\n * @param obj Object whose functions to get\n * @param _objId Optional ID of the object to use for debug logging\n * @returns Array of all function names on an object\n */\n// Note: lodash has something that MIGHT do the same thing as this. Investigate for https://github.com/paranext/paranext-core/issues/134\nexport function getAllObjectFunctionNames(\n obj: { [property: string]: unknown },\n // Leaving it here for debugging\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _objId: string = 'obj',\n): Set {\n const objectFunctionNames = new Set();\n\n // Get all function properties directly defined on the object\n Object.getOwnPropertyNames(obj).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId} due to error: ${error}`);\n }\n });\n\n // Walk up the prototype chain and get additional function properties, skipping the functions\n // provided by the final (Object) prototype\n let objectPrototype = Object.getPrototypeOf(obj);\n while (objectPrototype && Object.getPrototypeOf(objectPrototype)) {\n Object.getOwnPropertyNames(objectPrototype).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId}'s prototype due to error: ${error}`);\n }\n });\n objectPrototype = Object.getPrototypeOf(objectPrototype);\n }\n\n return objectFunctionNames;\n}\n\n/**\n * Creates a synchronous proxy for an asynchronous object. The proxy allows calling methods on an\n * object that is asynchronously fetched using a provided asynchronous function.\n *\n * @param getObject - A function that returns a promise resolving to the object whose asynchronous\n * methods to call.\n * @param objectToProxy - An optional object that is the object that is proxied. If a property is\n * accessed that does exist on this object, it will be returned. If a property is accessed that\n * does not exist on this object, it will be considered to be an asynchronous method called on the\n * object returned from getObject.\n * @returns A synchronous proxy for the asynchronous object.\n */\nexport function createSyncProxyForAsyncObject(\n getObject: (args?: unknown[]) => Promise,\n objectToProxy: Partial = {},\n): T {\n // objectToProxy will have only the synchronously accessed properties of T on it, and this proxy\n // makes the async methods that do not exist yet available synchronously so we have all of T\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return new Proxy(objectToProxy as T, {\n get(target, prop) {\n // We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // @ts-expect-error 7053\n if (prop in target) return target[prop];\n return async (...args: unknown[]) => {\n // 7053: We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // 2556: The args here are the parameters for the method specified\n // @ts-expect-error 7053 2556\n return (await getObject())[prop](...args);\n };\n },\n });\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that Paratext is blocking internet access.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates Paratext is blocking internet access, `false` otherwise\n */\nexport function isErrorMessageAboutParatextBlockingInternetAccess(errorMessage: unknown): boolean {\n // Copied from ParatextData/InternetAccess.cs, not a localized string\n const paratextExceptionMessage =\n 'Bug in Paratext caused attempted access to Internet. Request has been blocked.';\n\n if (isString(errorMessage)) return errorMessage.includes(paratextExceptionMessage);\n return getErrorMessage(errorMessage).includes(paratextExceptionMessage);\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that an authorization failure occurred regarding registry credentials.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates an auth failure, `false` otherwise\n */\nexport function isErrorMessageAboutRegistryAuthFailure(errorMessage: unknown): boolean {\n // Copied from ParatextProjectSendReceiveService.cs, not a localized string\n const paratextExceptionMessage1 = '401 Unauthorized error while getting shared projects.';\n // Copied from DblDownloadableDataProvider.cs, not a localized string\n const paratextExceptionMessage2 =\n 'User registration is not valid. Cannot retrieve resources from DBL.';\n\n const errorString = isString(errorMessage) ? errorMessage : getErrorMessage(errorMessage);\n return (\n errorString.includes(paratextExceptionMessage1) ||\n errorString.includes(paratextExceptionMessage2)\n );\n}\n\n/** Within type T, recursively change all properties to be optional */\nexport type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T;\n\n/** Within type T, recursively change properties that were of type A to be of type B */\nexport type ReplaceType = T extends A\n ? B\n : T extends object\n ? { [K in keyof T]: ReplaceType }\n : T;\n\n/**\n * Converts a string type from camelCase to kebab-case. Note this simply inserts hyphens before\n * uppercase letters and converts them to lowercase. It does not handle special cases like acronyms\n * or symbols. It can result in multiple hyphens in a row, leading hyphens, or trailing hyphens.\n *\n * By using this as the type for a string parameter or string property, you can enforce (somewhat)\n * at compile time that the string is in kebab-case format assuming it is provided as a string\n * literal.\n *\n * @example\n *\n * ```typescript\n * type Kebab1 = KebabCase<'backgroundColor'>; // 'background-color'\n * type Kebab2 = KebabCase<'HTMLParser'>; // '-h-t-m-l-parser'\n * type Kebab3 = KebabCase<'simpletest'>; // 'simpletest'\n * type Kebab4 = KebabCase<'My$Value'>; // '-my$-value'\n * ```\n */\nexport type KebabCase = T extends `${infer First}${infer Rest}`\n ? `${First extends Lowercase ? First : `-${Lowercase}`}${KebabCase}`\n : T;\n\n// Thanks to jcalz at https://stackoverflow.com/a/50375286\n/**\n * Converts a union type to an intersection type (`|` to `&`).\n *\n * Note: this utility type is for use on object types. It may fail on other types.\n *\n * @example\n *\n * ```typescript\n * type TypeOne = { one: string };\n * type TypeTwo = { two: number };\n * type TypeThree = { three: string };\n *\n * type TypeNums = { one: TypeOne; two: TypeTwo; three: TypeThree };\n * const numNames = ['one', 'two'] as const;\n * type TypeNumNames = typeof numNames;\n *\n * // Same as `TypeOne | TypeTwo`\n * // `{ one: string } | { two: number }`\n * type TypeOneTwoUnion = TypeNums[TypeNumNames[number]];\n *\n * // Same as `TypeOne & TypeTwo`\n * // `{ one: string; two: number }`\n * type TypeOneTwoIntersection = UnionToIntersection;\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (\n x: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Force VSCode to expand all the properties of a type by using this type. Useful for making complex\n * types more readable in hover tooltips.\n *\n * @example\n *\n * ```ts\n * type MyType = Prettify;\n * ```\n */\nexport type Prettify = {\n [K in keyof T]: T[K];\n} & {};\n","import { PlatformEventEmitter } from './events/platform-event-emitter.model';\nimport { deepClone } from './util';\n\ntype JsonObjectLike = { [key: string]: unknown };\ntype JsonArrayLike = unknown[];\n\nexport type JsonDocumentLike = JsonObjectLike | JsonArrayLike;\n\n/**\n * Options for DocumentCombiner objects\n *\n * - `copyDocuments`: If true, this instance will perform a deep copy of all provided documents before\n * composing the output. If false, then changes made to provided documents after they are\n * contributed will be reflected in the next time output is composed.\n * - `ignoreDuplicateProperties`: If true, then duplicate properties are skipped if they are seen in\n * contributed documents. If false, then throw when duplicate properties are seen in contributed\n * documents.\n */\nexport type DocumentCombinerOptions = {\n copyDocuments: boolean;\n ignoreDuplicateProperties: boolean;\n};\n\n/**\n * Base class for any code that wants to compose JSON documents (primarily in the form of JS objects\n * or arrays) together into a single output document.\n */\nexport class DocumentCombiner {\n protected baseDocument: JsonDocumentLike;\n protected readonly contributions = new Map();\n protected latestOutput: JsonDocumentLike | undefined;\n protected readonly options: DocumentCombinerOptions;\n private readonly onDidRebuildEmitter = new PlatformEventEmitter();\n /** Event that emits to announce that the document has been rebuilt and the output has been updated */\n // Need `onDidRebuildEmitter` to be instantiated before this line\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly onDidRebuild = this.onDidRebuildEmitter.subscribe;\n\n /**\n * Create a DocumentCombiner instance\n *\n * @param baseDocument This is the first document that will be used when composing the output\n * @param options Options used by this object when combining documents\n */\n protected constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n // Setting baseDocument redundantly because TS doesn't understand that updateBaseDocument does it\n this.baseDocument = baseDocument;\n this.options = options;\n this.updateBaseDocument(baseDocument);\n }\n\n /**\n * Update the starting document for composition process\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n * @returns Recalculated output document given the new starting state and existing other documents\n */\n updateBaseDocument(baseDocument: JsonDocumentLike): JsonDocumentLike | undefined {\n this.validateBaseDocument(baseDocument);\n this.baseDocument = this.options.copyDocuments ? deepClone(baseDocument) : baseDocument;\n this.baseDocument = this.transformBaseDocumentAfterValidation(this.baseDocument);\n return this.rebuild();\n }\n\n /**\n * Add or update one of the contribution documents for the composition process\n *\n * Note: the order in which contribution documents are added can be considered indeterminate as it\n * depends on the order in which `Map.forEach` iterates over the contributions. However, the order\n * matters when merging two arrays into one. Also, when `options.ignoreDuplicateProperties` is is\n * `true`, the order also matters when adding the same property to an object that is already\n * provided previously. Please let us know if you have trouble because of indeterminate\n * contribution ordering.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n * @returns Recalculated output document given the new or updated contribution and existing other\n * documents\n */\n addOrUpdateContribution(\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike | undefined {\n this.validateContribution(documentName, document);\n const previousDocumentVersion = this.contributions.get(documentName);\n let documentToSet = this.options.copyDocuments && !!document ? deepClone(document) : document;\n documentToSet = this.transformContributionAfterValidation(documentName, documentToSet);\n this.contributions.set(documentName, documentToSet);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after adding/updating the contribution, put it back how it was\n if (previousDocumentVersion) this.contributions.set(documentName, previousDocumentVersion);\n else this.contributions.delete(documentName);\n throw new Error(`Error when setting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete one of the contribution documents for the composition process\n *\n * @param documentName Name of the contributed document to delete\n * @returns Recalculated output document given the remaining other documents\n */\n deleteContribution(documentName: string): JsonDocumentLike | undefined {\n const document = this.contributions.get(documentName);\n if (!document) throw new Error(`${documentName} does not exist`);\n this.contributions.delete(documentName);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting the contribution, put it back and rethrow\n this.contributions.set(documentName, document);\n throw new Error(`Error when deleting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete all present contribution documents for the composition process and return to the base\n * document\n *\n * @returns Recalculated output document consisting only of the base document\n */\n deleteAllContributions(): JsonDocumentLike | undefined {\n if (this.contributions.size <= 0) return this.latestOutput;\n\n // Save out all contributions\n const contributions = [...this.contributions.entries()];\n\n // Delete all contributions\n contributions.forEach(([contributionName]) => this.contributions.delete(contributionName));\n\n // Rebuild with no contributions\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting all contributions, put them back and rethrow\n contributions.forEach(([contributionName, document]) =>\n this.contributions.set(contributionName, document),\n );\n throw new Error(`Error when deleting all contributions: ${error}`);\n }\n }\n\n /**\n * Run the document composition process given the starting document and all contributions. Throws\n * if the output document fails to validate properly.\n *\n * @returns Recalculated output document given the starting and contributed documents\n */\n rebuild(): JsonDocumentLike | undefined {\n // The starting document is the output if there are no other contributions\n if (this.contributions.size === 0) {\n let potentialOutput = deepClone(this.baseDocument);\n potentialOutput = this.transformFinalOutputBeforeValidation(potentialOutput);\n this.validateOutput(potentialOutput);\n this.latestOutput = potentialOutput;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n // Compose the output by validating each document one at a time to pinpoint errors better\n let outputIteration = this.baseDocument;\n this.contributions.forEach((contribution: JsonDocumentLike) => {\n outputIteration = mergeObjects(\n outputIteration,\n contribution,\n this.options.ignoreDuplicateProperties,\n );\n this.validateOutput(outputIteration);\n });\n outputIteration = this.transformFinalOutputBeforeValidation(outputIteration);\n this.validateOutput(outputIteration);\n this.latestOutput = outputIteration;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n /**\n * Transform the starting document that is given to the combiner. This transformation occurs after\n * validating the base document and before combining any contributions.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the `baseDocument` passed in.\n *\n * @param baseDocument Initial input document. Already validated via `validateBaseDocument`\n * @returns Transformed base document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformBaseDocumentAfterValidation(baseDocument: JsonDocumentLike): JsonDocumentLike {\n return baseDocument;\n }\n\n /**\n * Transform the contributed document associated with `documentName`. This transformation occurs\n * after validating the contributed document and before combining with other documents.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the contributed `document` passed in.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine. Already validated via\n * `validateContribution`\n * @returns Transformed contributed document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformContributionAfterValidation(\n // @ts-expect-error this parameter is unused but may be used in child classes\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike {\n return document;\n }\n\n /**\n * Throw an error if the provided document is not a valid starting document.\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateBaseDocument(baseDocument: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided document is not a valid contribution document.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateContribution(documentName: string, document: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided output is not valid.\n *\n * @param output Output document that could potentially be returned to callers\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateOutput(output: JsonDocumentLike): void {}\n\n /**\n * Transform the document that is the composition of the base document and all contribution\n * documents. This is the last step that will be run prior to validation via `validateOutput`\n * before `this.latestOutput` is updated to the new output.\n *\n * @param finalOutput Final output document that could potentially be returned to callers. \"Final\"\n * means no further contribution documents will be merged.\n */\n // no-op intended to be overridden by child classes. Can't be static\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformFinalOutputBeforeValidation(finalOutput: JsonDocumentLike): JsonDocumentLike {\n return finalOutput;\n }\n}\n\n// #region Helper functions\n\n/**\n * Determines if the input values are objects but not arrays\n *\n * @param values Objects to check\n * @returns True if all the values are objects but not arrays\n */\nfunction areNonArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Determines if the input values are arrays\n *\n * @param value Objects to check\n * @returns True if the values are arrays\n */\nfunction areArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || !Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Deep clone and recursively merge the properties of one object (copyFrom) into another\n * (startingPoint). Throws if copyFrom would overwrite values already existing in startingPoint.\n *\n * Does not modify the objects passed in.\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjects(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n const retVal = deepClone(startingPoint);\n\n if (!copyFrom) return retVal;\n\n return mergeObjectsInternal(retVal, deepClone(copyFrom), ignoreDuplicateProperties);\n}\n\n/**\n * Recursively merge the properties of one object (copyFrom) into another (startingPoint). Throws if\n * copyFrom would overwrite values already existing in startingPoint.\n *\n * WARNING: Modifies the argument objects in some way. Recommended to use `mergeObjects`\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjectsInternal(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n if (!copyFrom) return startingPoint;\n\n if (areNonArrayObjects(startingPoint, copyFrom)) {\n // Merge properties since they are both objects\n\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n const startingPointObj = startingPoint as JsonObjectLike;\n const copyFromObj = copyFrom as JsonObjectLike;\n /* eslint-enable no-type-assertion/no-type-assertion */\n Object.keys(copyFromObj).forEach((key: string | number) => {\n if (Object.hasOwn(startingPointObj, key)) {\n if (areNonArrayObjects(startingPointObj[key], copyFromObj[key])) {\n startingPointObj[key] = mergeObjectsInternal(\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] as JsonObjectLike,\n copyFromObj[key] as JsonObjectLike,\n ignoreDuplicateProperties,\n /* eslint-enable no-type-assertion/no-type-assertion */\n );\n } else if (areArrayObjects(startingPointObj[key], copyFromObj[key])) {\n // Concat the arrays since they are both arrays\n\n // We know these are arrays from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] = (startingPointObj[key] as JsonArrayLike).concat(\n copyFromObj[key] as JsonArrayLike,\n );\n /* eslint-enable no-type-assertion/no-type-assertion */\n } else if (!ignoreDuplicateProperties)\n throw new Error(`Cannot merge objects: key \"${key}\" already exists in the target object`);\n // Note that the first non-object non-array value that gets placed in a property stays.\n // New values do not override existing ones\n } else {\n startingPointObj[key] = copyFromObj[key];\n }\n });\n } else if (areArrayObjects(startingPoint, copyFrom)) {\n // Concat the arrays since they are both arrays\n\n // Push the contents of copyFrom into startingPoint since it is a const and was already deep cloned\n // We know these are objects from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n (startingPoint as JsonArrayLike).push(...(copyFrom as JsonArrayLike));\n /* eslint-enable no-type-assertion/no-type-assertion */\n }\n\n // Note that nothing happens if `startingPoint` is not an object or an array or if `startingPoint`\n // and `copyFrom` are not both object or both arrays. Should we throw? Should we push `copyFrom`'s\n // values into the array? Other? Maybe one day we can add some options to decide what to do in\n // this situation, but YAGNI for now\n\n return startingPoint;\n}\n\n// #endregion\n\nexport default DocumentCombiner;\n","/** Class that tracks how long it has taken the last N events to occur */\nexport class EventRollingTimeCounter {\n /** The ring buffer to store times */\n private readonly ringBuffer: number[];\n /** The size of the ring buffer */\n private readonly bufferSize: number;\n /** The next location where a time will be written */\n private writerIndex: number;\n /** The location where the first time in the buffer will be read */\n private readerIndex: number;\n /** The most recent difference in time between the newest and oldest events */\n private lastTimeDifference: number;\n /** How many instances in total have been recorded */\n private totalInstanceCount: number;\n\n /**\n * Create a new instance of the InstanceTimeCounter class\n *\n * @param bufferSize - Maximum number of instances to track\n */\n constructor(bufferSize: number) {\n this.bufferSize = bufferSize;\n this.ringBuffer = new Array(bufferSize).fill(0);\n this.writerIndex = 0;\n this.readerIndex = 0;\n this.lastTimeDifference = 0;\n this.totalInstanceCount = 0;\n }\n\n /** Get the total number of instances that have been recorded */\n get totalInstances(): number {\n return this.totalInstanceCount;\n }\n\n /** Add a new time measurement for an instance of an event */\n recordInstance(): void {\n this.totalInstanceCount += 1;\n const currentTime = performance.now();\n this.lastTimeDifference = currentTime - this.ringBuffer[this.readerIndex];\n\n this.ringBuffer[this.writerIndex] = currentTime;\n this.writerIndex += 1;\n if (this.writerIndex >= this.bufferSize) this.writerIndex %= this.bufferSize;\n if (this.writerIndex === this.readerIndex) {\n this.readerIndex += 1;\n if (this.readerIndex >= this.bufferSize) this.readerIndex %= this.bufferSize;\n }\n }\n\n /**\n * Check if the time between the last N events is less than the provided threshold\n *\n * @param minRollingTimeMs - Minimum time that must have passed when the last N events occurred\n * @returns - True if the threshold is violated, false otherwise\n */\n hasViolatedThreshold(minRollingTimeMs: number): boolean {\n return this.totalInstanceCount >= this.bufferSize && this.lastTimeDifference < minRollingTimeMs;\n }\n}\n","import { Mutex as AsyncMutex } from 'async-mutex';\n\n// Extending Mutex from async-mutex so we can add JSDoc\n\n/**\n * Class that allows calling asynchronous functions multiple times at once while only running one at\n * a time.\n *\n * @example\n *\n * ```typescript\n * const mutex = new Mutex();\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n * ```\n *\n * See [`async-mutex`](https://www.npmjs.com/package/async-mutex) for more information.\n */\nexport class Mutex extends AsyncMutex {}\n\nexport default Mutex;\n","import { Mutex } from './mutex';\n\n/** Map of {@link Mutex}es that automatically (lazily) generates a new {@link Mutex} for any new key */\nexport class MutexMap {\n private mutexesByID = new Map();\n\n /**\n * Retrieves the {@link Mutex} associated with the given ID. If no Mutex exists for the provided\n * ID, a new Mutex is created, stored, and returned.\n *\n * @param mutexID Unique identifier for the desired Mutex\n * @returns The Mutex associated with the provided ID\n */\n get(mutexID: string): Mutex {\n let retVal = this.mutexesByID.get(mutexID);\n if (retVal) return retVal;\n\n retVal = new Mutex();\n this.mutexesByID.set(mutexID, retVal);\n return retVal;\n }\n}\n\nexport default MutexMap;\n","import { DocumentCombiner, DocumentCombinerOptions, JsonDocumentLike } from './document-combiner';\n\nexport class NonValidatingDocumentCombiner extends DocumentCombiner {\n // Making the protected base constructor public\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n super(baseDocument, options);\n }\n\n get output(): JsonDocumentLike | undefined {\n return this.latestOutput;\n }\n}\n\nexport default NonValidatingDocumentCombiner;\n","/** Enables language-sensitive number formatting. Wraps Intl.NumberFormat */\nexport class NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n\n constructor(locales?: string | string[], options?: Intl.NumberFormatOptions) {\n this.numberFormatter = new Intl.NumberFormat(locales, options);\n }\n\n /**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @param value Number or BigInt to format\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\n format(value: number | bigint): string {\n return this.numberFormatter.format(value);\n }\n\n /**\n * Formats a range of numbers according to the locale and formatting options of this NumberFormat\n * object\n *\n * @param startRange Number or bigint representing the start of the range\n * @param endRange Number or bigint representing the end of the range\n * @returns String representing the given range of numbers formatted according to the locale and\n * formatting options of this NumberFormat object\n */\n formatRange(startRange: number | bigint, endRange: number | bigint): string {\n return this.numberFormatter.formatRange(startRange, endRange);\n }\n\n /**\n * Returns an array of objects containing the locale-specific tokens from which it is possible to\n * build custom strings while preserving the locale-specific parts.\n *\n * @param startRange Number or bigint representing start of the range\n * @param endRange Number or bigint representing end of the range\n * @returns Array of NumberRangeFormatPart objects containing the formatted range of numbers in\n * parts\n */\n formatRangeToParts(\n startRange: number | bigint,\n endRange: number | bigint,\n ): Intl.NumberRangeFormatPart[] {\n return this.numberFormatter.formatRangeToParts(startRange, endRange);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this NumberFormat object\n *\n * @param value Number or bigint to format\n * @returns Array of NumberFormatPart objects containing the formatted number in parts\n */\n formatToParts(value: number | bigint): Intl.NumberFormatPart[] {\n return this.numberFormatter.formatToParts(value);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and number formatting options\n * computed during initialization of this NumberFormat object\n *\n * @returns ResolvedNumberFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n return this.numberFormatter.resolvedOptions();\n }\n}\n\nexport default NumberFormat;\n","const defaultPromise = Promise.resolve();\n\n/**\n * Class that allows you to chain promises for a given key. This is useful when:\n *\n * 1. You need to run promises from synchronous code and don't need to look at the results.\n * 2. The promises to run, or at least precisely when to run them, are not known in advance.\n * 3. The promises need to be run sequentially, waiting for the previous one to finish.\n *\n * An example of when this can be helpful is inside of React components. Component code is mostly\n * synchronous, but you may need to run some asynchronous code. You can't use `await` inside of\n * React component code in many situations, so you can use this class to chain promises together.\n *\n * When promises are added to the map with a key, they will run in the order they were added to the\n * map for that key. If a promise rejects, a warning will be logged and the chain will continue. If\n * a promise is added while another promise in the map for that key is running, the new promise will\n * be chained to the existing one.\n */\nexport class PromiseChainingMap {\n private readonly map = new Map>();\n private readonly logger: { warn: (message: string) => void };\n\n /**\n * Creates a new PromiseChainingMap\n *\n * @param logger Object with a `warn` method that will be called when a promise rejects. This\n * defaults to `console`.\n */\n constructor(logger: { warn: (message: string) => void } = console) {\n this.logger = logger;\n }\n\n /**\n * Adds a promise function to the map for a given key. If a promise is already running for the\n * key, the new promise will be chained to the existing one. Once all promises for a key have\n * settled, the map will be cleared for that key.\n *\n * @param key Unique key to identify a distinct promise chain\n * @param promiseFunction Function that returns a promise to add to the chain\n */\n addPromiseFunction(key: TKey, promiseFunction: () => Promise): void {\n const currentPromise = this.map.get(key);\n this.map.set(key, currentPromise ? currentPromise.then(promiseFunction) : promiseFunction());\n this.cleanupPromiseChain(key);\n }\n\n /**\n * Gets the current promise chain for the given key. This is mostly useful for testing. Normally\n * you should just call {@link addPromiseFunction} and let the map handle the rest.\n *\n * @param key Unique key to identify a distinct promise chain\n * @returns The current promise chain for the key\n */\n get(key: TKey): Promise | undefined {\n return this.map.get(key);\n }\n\n /**\n * Configures a promise chain to be removed from the map for the given key after all the promises\n * have settled\n *\n * @param key Unique key to identify a distinct promise chain\n */\n private cleanupPromiseChain(key: TKey): void {\n const currentPromise = this.map.get(key);\n if (!currentPromise) return;\n\n const promiseHolder: { promise: Promise } = { promise: defaultPromise };\n const newPromise = currentPromise\n .catch((e) => this.logger.warn(`Error in promise for ${key}: ${e.message}`))\n .finally(() => {\n if (this.map.get(key) === promiseHolder.promise) this.map.delete(key);\n });\n promiseHolder.promise = newPromise;\n this.map.set(key, newPromise);\n }\n}\n\nexport default PromiseChainingMap;\n","/**\n * A map-like data structure that maintains numeric keys in sorted order and provides efficient\n * operations for finding the closest key-value pair less than or equal to a target.\n *\n * This class combines the benefits of a Map (O(1) key-value lookups) with sorted key access (O(log\n * n) binary search operations). It's particularly useful when you need to frequently find the\n * \"closest\" entry to a given numeric key.\n *\n * @example\n *\n * ```typescript\n * const versionMap = new SortedNumberMap();\n * versionMap.set(100, 'Version 1.0.0');\n * versionMap.set(150, 'Version 1.5.0');\n * versionMap.set(200, 'Version 2.0.0');\n *\n * // Find the highest version <= 175\n * const result = versionMap.findClosestLessThanOrEqual(175);\n * console.log(result); // { key: 150, value: 'Version 1.5.0' }\n * ```\n *\n * @template T The type of values stored in the map\n */\nexport class SortedNumberMap {\n private map = new Map();\n private sortedKeys: number[] = [];\n\n /**\n * Returns an iterable of keys in the map sorted in ascending order.\n *\n * Time complexity: internal detail to JavaScript engine. Reasonable expectation:\n *\n * - Executing this method to return an iterator: O(1)\n * - Iterating over the returned iterator: O(n)\n *\n * Note that iterating over the keys this way negates the benefits of using this class over a\n * using a {@link Map}. To access individual keys more quickly, use\n * {@link SortedNumberMap.findClosestLessThanOrEqual} or {@link SortedNumberMap.get}.\n *\n * TSDoc adapted from {@link Map.keys}\n */\n keys() {\n return this.sortedKeys.values();\n }\n\n /**\n * Returns a specified element from the Map object. If the value that is associated to the\n * provided key is an object, then you will get a reference to that object and any change made to\n * that object will effectively modify it inside the Map.\n *\n * Time complexity: O(1)\n *\n * @returns Returns the element associated with the specified key. If no element is associated\n * with the specified key, returns `undefined`.\n *\n * TSDoc adapted from {@link Map.get}\n */\n get(key: number) {\n return this.map.get(key);\n }\n\n /**\n * Sets a key-value pair in the map. If the key already exists, its value is updated. If the key\n * is new, it's inserted in the correct sorted position.\n *\n * Time complexity: O(log n) for new keys (due to binary search and array insertion), O(1) for\n * existing keys.\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(5, 'five');\n * map.set(15, 'fifteen');\n * // Keys are automatically maintained in sorted order: [5, 10, 15]\n * ```\n *\n * @param key - The numeric key to set\n * @param value - The value to associate with the key\n */\n set(key: number, value: T): void {\n if (!this.map.has(key)) {\n // Insert key in sorted position\n const insertIndex = this.binarySearchInsertIndex(key);\n this.sortedKeys.splice(insertIndex, 0, key);\n }\n this.map.set(key, value);\n }\n\n /**\n * Finds the key-value pair with the largest key that is less than or equal to the target.\n *\n * This method uses binary search to efficiently locate the closest match. If no key is less than\n * or equal to the target, it returns undefined.\n *\n * Time complexity: O(log n)\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(20, 'twenty');\n * map.set(30, 'thirty');\n *\n * // Exact match\n * map.findClosestLessThanOrEqual(20); // { key: 20, value: 'twenty' }\n *\n * // Closest less than\n * map.findClosestLessThanOrEqual(25); // { key: 20, value: 'twenty' }\n *\n * // No match (target too small)\n * map.findClosestLessThanOrEqual(5); // undefined\n * ```\n *\n * @param target - The number to search for\n * @returns The key-value pair with the largest key ≤ target, or undefined if none exists\n */\n findClosestLessThanOrEqual(target: number): { key: number; value: T } | undefined {\n const index = this.binarySearchLessThanOrEqual(target);\n if (index === -1) return undefined;\n\n const key = this.sortedKeys[index];\n const value = this.map.get(key);\n if (value === undefined) return undefined;\n return { key, value };\n }\n\n private binarySearchLessThanOrEqual(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length - 1;\n let result = -1;\n\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] <= target) {\n result = mid;\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return result;\n }\n\n private binarySearchInsertIndex(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return left;\n }\n}\n","/**\n * A collection of unique items that are automatically maintained in sorted order, similar to C#'s\n * SortedSet.\n *\n * @template T The type of elements in the set\n */\nexport class SortedSet {\n /** Internal storage for the sorted items */\n private readonly items: T[] = [];\n\n /**\n * Creates a new sorted set\n *\n * @param compareFn - Function used to determine the order of elements. Returns negative when a <\n * b, zero when a = b, positive when a > b\n */\n constructor(private readonly compareFn: (a: T, b: T) => number) {}\n\n /** Gets the number of elements in the set */\n get size(): number {\n return this.items.length;\n }\n\n /** Returns whether the set is empty */\n get isEmpty(): boolean {\n return this.items.length === 0;\n }\n\n /**\n * Inserts an item into the set if it's not already present\n *\n * @param item - The item to insert\n * @returns True if the item was added; false if an equal item already exists\n */\n insert(item: T): boolean {\n // Find where this item should be inserted\n const index = this.findInsertionIndex(item);\n\n // Check if an equal item exists at the found position\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) {\n // Item already exists\n return false;\n }\n\n // Insert the item at the correct position to maintain sort order\n this.items.splice(index, 0, item);\n return true;\n }\n\n /**\n * Removes an item from the set\n *\n * @param item - The item to remove\n * @returns True if the item was removed; false if it wasn't found\n */\n remove(item: T): boolean {\n const index = this.findIndex(item);\n if (index < 0) return false;\n\n this.items.splice(index, 1);\n return true;\n }\n\n /**\n * Checks if an item exists in the set\n *\n * @param item - The item to check\n * @returns True if the item exists; false otherwise\n */\n has(item: T): boolean {\n return this.findIndex(item) >= 0;\n }\n\n /** Returns all items in the set as an array, in sorted order */\n toArray(): T[] {\n return [...this.items];\n }\n\n /** Returns the index of an item in the set, or -1 if not found */\n findIndex(item: T): number {\n const index = this.findInsertionIndex(item);\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) return index;\n return -1;\n }\n\n /**\n * Returns the element at the specified index in the sorted order\n *\n * @param index - The zero-based index of the element to get\n * @returns The element at the specified index, or undefined if the index is out of range\n */\n at(index: number): T | undefined {\n if (index < 0 || index >= this.items.length) return undefined;\n return this.items[index];\n }\n\n /** Iterates through each item in the sorted set */\n forEach(callback: (item: T, index: number, set: SortedSet) => void): void {\n this.items.forEach((item, index) => callback(item, index, this));\n }\n\n /** Returns an iterator for the set's items */\n [Symbol.iterator](): Iterator {\n let index = 0;\n return {\n next: (): IteratorResult => {\n if (index < this.items.length) {\n index += 1;\n return { value: this.items[index - 1], done: false };\n }\n return { value: undefined as unknown, done: true };\n },\n };\n }\n\n /** Clears all items from the set */\n clear(): void {\n this.items.length = 0;\n }\n\n /**\n * Uses binary search to find the position where an item should be inserted to maintain the sorted\n * order\n */\n private findInsertionIndex(item: T): number {\n let low = 0;\n let high = this.items.length;\n\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n const comparison = this.compareFn(this.items[mid], item);\n\n if (comparison < 0) {\n // Current item is less than the one we're looking for\n low = mid + 1;\n } else {\n // Current item is greater than or equal to the one we're looking for\n high = mid;\n }\n }\n\n return low;\n }\n}\n","import { Dispose } from './disposal.model';\nimport { Unsubscriber, UnsubscriberAsync } from './unsubscriber';\n\n/** Simple collection for UnsubscriberAsync objects that also provides an easy way to run them. */\nexport class UnsubscriberAsyncList {\n readonly unsubscribers = new Set();\n\n constructor(private name = 'Anonymous') {}\n\n /**\n * Add unsubscribers to the list. Note that duplicates are not added twice.\n *\n * @param unsubscribers - Objects that were returned from a registration process.\n */\n add(...unsubscribers: (UnsubscriberAsync | Unsubscriber | Dispose)[]) {\n unsubscribers.forEach((unsubscriber) => {\n if ('dispose' in unsubscriber)\n this.unsubscribers.add(unsubscriber.dispose.bind(unsubscriber));\n else this.unsubscribers.add(unsubscriber);\n });\n }\n\n /**\n * Run all unsubscribers added to this list and then clear the list.\n *\n * @returns `true` if all unsubscribers succeeded, `false` otherwise.\n */\n async runAllUnsubscribers(): Promise {\n const unsubs = [...this.unsubscribers].map((unsubscriber) => unsubscriber());\n const results = await Promise.all(unsubs);\n this.unsubscribers.clear();\n return results.every((unsubscriberSucceeded, index) => {\n if (!unsubscriberSucceeded)\n console.error(`UnsubscriberAsyncList ${this.name}: Unsubscriber at index ${index} failed!`);\n\n return unsubscriberSucceeded;\n });\n }\n}\n\nexport default UnsubscriberAsyncList;\n","import { isString } from './util';\n\n/** The version of the PlatformError type */\nexport const PLATFORM_ERROR_VERSION = 1;\n\n/**\n * PlatformError is an error type with stronger typing of properties than `Error`. It is used to\n * represent errors that are returned by the platform.\n *\n * You can create a new PlatformError object using {@link newPlatformError}. You can check if a value\n * is a PlatformError object using {@link isPlatformError}.\n */\nexport type PlatformError = {\n /**\n * The underlying cause of the error, if any. Normally this will be copied from an `Error object\n * passed to {@link newPlatformError}. If a non-Error object is passed to {@link newPlatformError},\n * it will be stored here.\n */\n cause?: unknown;\n /**\n * A descriptive message explaining the error. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}. If a string is passed to {@link newPlatformError}, it will be\n * stored here.\n */\n message: string;\n /** The version of the PlatformError type. */\n platformErrorVersion: number;\n /**\n * The stack trace of the error, if available. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}.\n */\n stack?: string;\n};\n\n/**\n * Creates a new PlatformError object. If no argument is provided, a PlatformError object with an\n * empty `message` is returned.\n *\n * @param error The error message as a string, an Error object, or a value to assign to the `cause`\n * property of the returned PlatformError object\n * @returns A new PlatformError object\n */\nexport function newPlatformError(error?: unknown): PlatformError {\n if (!error) return { message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (isString(error)) return { message: error, platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n const platformError: PlatformError = {\n message: error.message,\n platformErrorVersion: PLATFORM_ERROR_VERSION,\n };\n Object.defineProperties(platformError, Object.getOwnPropertyDescriptors(error));\n Object.defineProperty(platformError, 'message', { enumerable: true });\n if ('stack' in error && isString(error.stack)) {\n // stack is generated lazily, and it seems this is causing some troubles with copying it into\n // another object via property descriptors as of Node 22.14.0 (no problems in 20.18.0).\n // So we shall set the value directly on the object\n Object.defineProperty(platformError, 'stack', { value: error.stack, enumerable: true });\n }\n if ('cause' in platformError)\n Object.defineProperty(platformError, 'cause', { enumerable: true });\n return platformError;\n }\n return { cause: error, message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n}\n\n/**\n * Checks if the provided value is a PlatformError object.\n *\n * @param error The value to check\n * @returns `true` if the value is a PlatformError object, otherwise `false`\n */\nexport function isPlatformError(error: unknown): error is PlatformError {\n return !!error && typeof error === 'object' && 'platformErrorVersion' in error;\n}\n","var P = Object.defineProperty;\nvar R = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;\nvar n = (t, e, s) => R(t, typeof e != \"symbol\" ? e + \"\" : e, s);\nclass _ {\n constructor() {\n n(this, \"books\");\n n(this, \"firstSelectedBookNum\");\n n(this, \"lastSelectedBookNum\");\n n(this, \"count\");\n n(this, \"selectedBookNumbers\");\n n(this, \"selectedBookIds\");\n }\n}\nconst N = [\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n // 10\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n // 20\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n // 30\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n \"MAT\",\n // 40\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n // 50\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n // 60\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n // 70\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n // 80\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"JSA\",\n // actual variant text for JOS, now in LXA text\n \"JDB\",\n // actual variant text for JDG, now in LXA text\n \"TBS\",\n // actual variant text for TOB, now in LXA text\n \"SST\",\n // actual variant text for SUS, now in LXA text // 90\n \"DNT\",\n // actual variant text for DAN, now in LXA text\n \"BLT\",\n // actual variant text for BEL, now in LXA text\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n // 100\n \"BAK\",\n \"OTH\",\n \"3ES\",\n // Used previously but really should be 2ES\n \"EZA\",\n // Used to be called 4ES, but not actually in any known project\n \"5EZ\",\n // Used to be called 5ES, but not actually in any known project\n \"6EZ\",\n // Used to be called 6ES, but not actually in any known project\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n // 110\n \"NDX\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n // 120\n \"REP\",\n \"4BA\",\n \"LAO\"\n], B = [\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\"\n], O = [\n \"Genesis\",\n \"Exodus\",\n \"Leviticus\",\n \"Numbers\",\n \"Deuteronomy\",\n \"Joshua\",\n \"Judges\",\n \"Ruth\",\n \"1 Samuel\",\n \"2 Samuel\",\n \"1 Kings\",\n \"2 Kings\",\n \"1 Chronicles\",\n \"2 Chronicles\",\n \"Ezra\",\n \"Nehemiah\",\n \"Esther (Hebrew)\",\n \"Job\",\n \"Psalms\",\n \"Proverbs\",\n \"Ecclesiastes\",\n \"Song of Songs\",\n \"Isaiah\",\n \"Jeremiah\",\n \"Lamentations\",\n \"Ezekiel\",\n \"Daniel (Hebrew)\",\n \"Hosea\",\n \"Joel\",\n \"Amos\",\n \"Obadiah\",\n \"Jonah\",\n \"Micah\",\n \"Nahum\",\n \"Habakkuk\",\n \"Zephaniah\",\n \"Haggai\",\n \"Zechariah\",\n \"Malachi\",\n \"Matthew\",\n \"Mark\",\n \"Luke\",\n \"John\",\n \"Acts\",\n \"Romans\",\n \"1 Corinthians\",\n \"2 Corinthians\",\n \"Galatians\",\n \"Ephesians\",\n \"Philippians\",\n \"Colossians\",\n \"1 Thessalonians\",\n \"2 Thessalonians\",\n \"1 Timothy\",\n \"2 Timothy\",\n \"Titus\",\n \"Philemon\",\n \"Hebrews\",\n \"James\",\n \"1 Peter\",\n \"2 Peter\",\n \"1 John\",\n \"2 John\",\n \"3 John\",\n \"Jude\",\n \"Revelation\",\n \"Tobit\",\n \"Judith\",\n \"Esther Greek\",\n \"Wisdom of Solomon\",\n \"Sirach (Ecclesiasticus)\",\n \"Baruch\",\n \"Letter of Jeremiah\",\n \"Song of 3 Young Men\",\n \"Susanna\",\n \"Bel and the Dragon\",\n \"1 Maccabees\",\n \"2 Maccabees\",\n \"3 Maccabees\",\n \"4 Maccabees\",\n \"1 Esdras (Greek)\",\n \"2 Esdras (Latin)\",\n \"Prayer of Manasseh\",\n \"Psalm 151\",\n \"Odes\",\n \"Psalms of Solomon\",\n // WARNING, if you change the spelling of the *obsolete* tag be sure to update\n // IsObsolete routine\n \"Joshua A. *obsolete*\",\n \"Judges B. *obsolete*\",\n \"Tobit S. *obsolete*\",\n \"Susanna Th. *obsolete*\",\n \"Daniel Th. *obsolete*\",\n \"Bel Th. *obsolete*\",\n \"Extra A\",\n \"Extra B\",\n \"Extra C\",\n \"Extra D\",\n \"Extra E\",\n \"Extra F\",\n \"Extra G\",\n \"Front Matter\",\n \"Back Matter\",\n \"Other Matter\",\n \"3 Ezra *obsolete*\",\n \"Apocalypse of Ezra\",\n \"5 Ezra (Latin Prologue)\",\n \"6 Ezra (Latin Epilogue)\",\n \"Introduction\",\n \"Concordance \",\n \"Glossary \",\n \"Topical Index\",\n \"Names Index\",\n \"Daniel Greek\",\n \"Psalms 152-155\",\n \"2 Baruch (Apocalypse)\",\n \"Letter of Baruch\",\n \"Jubilees\",\n \"Enoch\",\n \"1 Meqabyan\",\n \"2 Meqabyan\",\n \"3 Meqabyan\",\n \"Reproof (Proverbs 25-31)\",\n \"4 Baruch (Rest of Baruch)\",\n \"Laodiceans\"\n], S = K();\nfunction g(t, e = !0) {\n return e && (t = t.toUpperCase()), t in S ? S[t] : 0;\n}\nfunction k(t) {\n return g(t) > 0;\n}\nfunction x(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return e >= 40 && e <= 66;\n}\nfunction T(t) {\n return (typeof t == \"string\" ? g(t) : t) <= 39;\n}\nfunction X(t) {\n return t <= 66;\n}\nfunction V(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return w(e) && !X(e);\n}\nfunction* L() {\n for (let t = 1; t <= N.length; t++) yield t;\n}\nconst G = 1, A = N.length;\nfunction H() {\n return [\"XXA\", \"XXB\", \"XXC\", \"XXD\", \"XXE\", \"XXF\", \"XXG\"];\n}\nfunction C(t, e = \"***\") {\n const s = t - 1;\n return s < 0 || s >= N.length ? e : N[s];\n}\nfunction I(t) {\n return t <= 0 || t > A ? \"******\" : O[t - 1];\n}\nfunction y(t) {\n return I(g(t));\n}\nfunction w(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && !B.includes(e);\n}\nfunction q(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && B.includes(e);\n}\nfunction U(t) {\n return O[t - 1].includes(\"*obsolete*\");\n}\nfunction K() {\n const t = {};\n for (let e = 0; e < N.length; e++)\n t[N[e]] = e + 1;\n return t;\n}\nconst m = {\n allBookIds: N,\n nonCanonicalIds: B,\n bookIdToNumber: g,\n isBookIdValid: k,\n isBookNT: x,\n isBookOT: T,\n isBookOTNT: X,\n isBookDC: V,\n allBookNumbers: L,\n firstBook: G,\n lastBook: A,\n extraBooks: H,\n bookNumberToId: C,\n bookNumberToEnglishName: I,\n bookIdToEnglishName: y,\n isCanonical: w,\n isExtraMaterial: q,\n isObsolete: U\n};\nvar l = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = \"Unknown\", t[t.Original = 1] = \"Original\", t[t.Septuagint = 2] = \"Septuagint\", t[t.Vulgate = 3] = \"Vulgate\", t[t.English = 4] = \"English\", t[t.RussianProtestant = 5] = \"RussianProtestant\", t[t.RussianOrthodox = 6] = \"RussianOrthodox\", t))(l || {});\nconst h = class h {\n // private versInfo: Versification;\n constructor(e) {\n n(this, \"name\");\n n(this, \"fullPath\");\n n(this, \"isPresent\");\n n(this, \"hasVerseSegments\");\n n(this, \"isCustomized\");\n n(this, \"baseVersification\");\n n(this, \"scriptureBooks\");\n n(this, \"_type\");\n if (e == null)\n throw new Error(\"Argument undefined\");\n typeof e == \"string\" ? (this.name = e, this._type = l[e]) : (this._type = e, this.name = l[e]);\n }\n get type() {\n return this._type;\n }\n equals(e) {\n return !e.type || !this.type ? !1 : e.type === this.type;\n }\n};\nn(h, \"Original\", new h(l.Original)), n(h, \"Septuagint\", new h(l.Septuagint)), n(h, \"Vulgate\", new h(l.Vulgate)), n(h, \"English\", new h(l.English)), n(h, \"RussianProtestant\", new h(l.RussianProtestant)), n(h, \"RussianOrthodox\", new h(l.RussianOrthodox));\nlet c = h;\nfunction E(t, e) {\n const s = e[0];\n for (let r = 1; r < e.length; r++)\n t = t.split(e[r]).join(s);\n return t.split(s);\n}\nvar D = /* @__PURE__ */ ((t) => (t[t.Valid = 0] = \"Valid\", t[t.UnknownVersification = 1] = \"UnknownVersification\", t[t.OutOfRange = 2] = \"OutOfRange\", t[t.VerseOutOfOrder = 3] = \"VerseOutOfOrder\", t[t.VerseRepeated = 4] = \"VerseRepeated\", t))(D || {});\nconst i = class i {\n constructor(e, s, r, a) {\n /** Not yet implemented. */\n n(this, \"firstChapter\");\n /** Not yet implemented. */\n n(this, \"lastChapter\");\n /** Not yet implemented. */\n n(this, \"lastVerse\");\n /** Not yet implemented. */\n n(this, \"hasSegmentsDefined\");\n /** Not yet implemented. */\n n(this, \"text\");\n /** Not yet implemented. */\n n(this, \"BBBCCCVVVS\");\n /** Not yet implemented. */\n n(this, \"longHashCode\");\n /** The versification of the reference. */\n n(this, \"versification\");\n n(this, \"rtlMark\", \"‏\");\n n(this, \"_bookNum\", 0);\n n(this, \"_chapterNum\", 0);\n n(this, \"_verseNum\", 0);\n n(this, \"_verse\");\n if (r == null && a == null)\n if (e != null && typeof e == \"string\") {\n const o = e, u = s != null && s instanceof c ? s : void 0;\n this.setEmpty(u), this.parse(o);\n } else if (e != null && typeof e == \"number\") {\n const o = s != null && s instanceof c ? s : void 0;\n this.setEmpty(o), this._verseNum = e % i.chapterDigitShifter, this._chapterNum = Math.floor(\n e % i.bookDigitShifter / i.chapterDigitShifter\n ), this._bookNum = Math.floor(e / i.bookDigitShifter);\n } else if (s == null)\n if (e != null && e instanceof i) {\n const o = e;\n this._bookNum = o.bookNum, this._chapterNum = o.chapterNum, this._verseNum = o.verseNum, this._verse = o.verse, this.versification = o.versification;\n } else {\n if (e == null) return;\n const o = e instanceof c ? e : i.defaultVersification;\n this.setEmpty(o);\n }\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else if (e != null && s != null && r != null)\n if (typeof e == \"string\" && typeof s == \"string\" && typeof r == \"string\")\n this.setEmpty(a), this.updateInternal(e, s, r);\n else if (typeof e == \"number\" && typeof s == \"number\" && typeof r == \"number\")\n this._bookNum = e, this._chapterNum = s, this._verseNum = r, this.versification = a ?? i.defaultVersification;\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else\n throw new Error(\"VerseRef constructor not supported.\");\n }\n /**\n * Determines if the verse string is in a valid format (does not consider versification).\n */\n static isVerseParseable(e) {\n return e.length > 0 && \"0123456789\".includes(e[0]) && !e.endsWith(this.verseRangeSeparator) && !e.endsWith(this.verseSequenceIndicator);\n }\n /**\n * Tries to parse the specified string into a verse reference.\n * @param str - The string to attempt to parse.\n * @returns success: `true` if the specified string was successfully parsed, `false` otherwise.\n * @returns verseRef: The result of the parse if successful, or empty VerseRef if it failed\n */\n static tryParse(e) {\n let s;\n try {\n return s = new i(e), { success: !0, verseRef: s };\n } catch (r) {\n if (r instanceof v)\n return s = new i(), { success: !1, verseRef: s };\n throw r;\n }\n }\n /**\n * Gets the reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n * @param bookNum - Book number (this is 1-based, not an index).\n * @param chapterNum - Chapter number.\n * @param verseNum - Verse number.\n * @returns The reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n */\n static getBBBCCCVVV(e, s, r) {\n return e % i.bcvMaxValue * i.bookDigitShifter + (s >= 0 ? s % i.bcvMaxValue * i.chapterDigitShifter : 0) + (r >= 0 ? r % i.bcvMaxValue : 0);\n }\n /**\n * Deserializes a serialized VerseRef.\n * @param serializedVerseRef - Serialized VerseRef to create from.\n * @returns the deserialized VerseRef.\n */\n static fromJSON(e) {\n const { book: s, chapterNum: r, verseNum: a, verse: o, versificationStr: u } = e, f = o || a.toString();\n let d;\n return u && (d = new c(u)), s ? new i(s, r.toString(), f, d) : new i();\n }\n /**\n * Parses a verse string and gets the leading numeric portion as a number.\n * @param verseStr - verse string to parse\n * @returns true if the entire string could be parsed as a single, simple verse number (1-999);\n * false if the verse string represented a verse bridge, contained segment letters, or was invalid\n */\n static tryGetVerseNum(e) {\n let s;\n if (!e)\n return s = -1, { success: !0, vNum: s };\n s = 0;\n let r;\n for (let a = 0; a < e.length; a++) {\n if (r = e[a], r < \"0\" || r > \"9\")\n return a === 0 && (s = -1), { success: !1, vNum: s };\n if (s = s * 10 + +r - 0, s > i.bcvMaxValue)\n return s = -1, { success: !1, vNum: s };\n }\n return { success: !0, vNum: s };\n }\n /**\n * Checks to see if a VerseRef hasn't been set - all values are the default.\n */\n get isDefault() {\n return this.bookNum === 0 && this.chapterNum === 0 && this.verseNum === 0 && this.versification == null;\n }\n /**\n * Gets whether the verse contains multiple verses.\n */\n get hasMultiple() {\n return this._verse != null && (this._verse.includes(i.verseRangeSeparator) || this._verse.includes(i.verseSequenceIndicator));\n }\n /**\n * Gets or sets the book of the reference. Book is the 3-letter abbreviation in capital letters,\n * e.g. `'MAT'`.\n */\n get book() {\n return m.bookNumberToId(this.bookNum, \"\");\n }\n set book(e) {\n this.bookNum = m.bookIdToNumber(e);\n }\n /**\n * Gets or sets the chapter of the reference,. e.g. `'3'`.\n */\n get chapter() {\n return this.isDefault || this._chapterNum < 0 ? \"\" : this._chapterNum.toString();\n }\n set chapter(e) {\n const s = +e;\n this._chapterNum = Number.isInteger(s) ? s : -1;\n }\n /**\n * Gets or sets the verse of the reference, including range, segments, and sequences, e.g. `'4'`,\n * or `'4b-5a, 7'`.\n */\n get verse() {\n return this._verse != null ? this._verse : this.isDefault || this._verseNum < 0 ? \"\" : this._verseNum.toString();\n }\n set verse(e) {\n const { success: s, vNum: r } = i.tryGetVerseNum(e);\n this._verse = s ? void 0 : e.replace(this.rtlMark, \"\"), this._verseNum = r, !(this._verseNum >= 0) && ({ vNum: this._verseNum } = i.tryGetVerseNum(this._verse));\n }\n /**\n * Get or set Book based on book number, e.g. `42`.\n */\n get bookNum() {\n return this._bookNum;\n }\n set bookNum(e) {\n if (e <= 0 || e > m.lastBook)\n throw new v(\n \"BookNum must be greater than zero and less than or equal to last book\"\n );\n this._bookNum = e;\n }\n /**\n * Gets or sets the chapter number, e.g. `3`. `-1` if not valid.\n */\n get chapterNum() {\n return this._chapterNum;\n }\n set chapterNum(e) {\n this.chapterNum = e;\n }\n /**\n * Gets or sets verse start number, e.g. `4`. `-1` if not valid.\n */\n get verseNum() {\n return this._verseNum;\n }\n set verseNum(e) {\n this._verseNum = e;\n }\n /**\n * String representing the versification (should ONLY be used for serialization/deserialization).\n *\n * @remarks This is for backwards compatibility when ScrVers was an enumeration.\n */\n get versificationStr() {\n var e;\n return (e = this.versification) == null ? void 0 : e.name;\n }\n set versificationStr(e) {\n this.versification = this.versification != null ? new c(e) : void 0;\n }\n /**\n * Determines if the reference is valid.\n */\n get valid() {\n return this.validStatus === 0;\n }\n /**\n * Get the valid status for this reference.\n */\n get validStatus() {\n return this.validateVerse(i.verseRangeSeparators, i.verseSequenceIndicators);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits and the verse is 0.\n */\n get BBBCCC() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, 0);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits. If verse is not null\n * (i.e., this reference represents a complex reference with verse\n * segments or bridge) this cannot be used for an exact comparison.\n */\n get BBBCCCVVV() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, this._verseNum);\n }\n /**\n * Gets whether the verse is defined as an excluded verse in the versification.\n * Does not handle verse ranges.\n */\n // eslint-disable-next-line @typescript-eslint/class-literal-property-style\n get isExcluded() {\n return !1;\n }\n /**\n * Parses the reference in the specified string.\n * Optionally versification can follow reference as in GEN 3:11/4\n * Throw an exception if\n * - invalid book name\n * - chapter number is missing or not a number\n * - verse number is missing or does not start with a number\n * - versification is invalid\n * @param verseStr - string to parse e.g. 'MAT 3:11'\n */\n parse(e) {\n if (e = e.replace(this.rtlMark, \"\"), e.includes(\"/\")) {\n const o = e.split(\"/\");\n if (e = o[0], o.length > 1)\n try {\n const u = +o[1].trim();\n this.versification = new c(l[u]);\n } catch {\n throw new v(\"Invalid reference : \" + e);\n }\n }\n const s = e.trim().split(\" \");\n if (s.length !== 2)\n throw new v(\"Invalid reference : \" + e);\n const r = s[1].split(\":\"), a = +r[0];\n if (r.length !== 2 || m.bookIdToNumber(s[0]) === 0 || !Number.isInteger(a) || a < 0 || !i.isVerseParseable(r[1]))\n throw new v(\"Invalid reference : \" + e);\n this.updateInternal(s[0], r[0], r[1]);\n }\n /**\n * Simplifies this verse ref so that it has no bridging of verses or\n * verse segments like `'1a'`.\n */\n simplify() {\n this._verse = void 0;\n }\n /**\n * Makes a clone of the reference.\n *\n * @returns The cloned VerseRef.\n */\n clone() {\n return new i(this);\n }\n toString() {\n const e = this.book;\n return e === \"\" ? \"\" : `${e} ${this.chapter}:${this.verse}`;\n }\n toJSON() {\n let e = this.verse;\n (e === \"\" || e === this.verseNum.toString()) && (e = void 0);\n const s = {\n book: this.book,\n chapterNum: this.chapterNum,\n verseNum: this.verseNum,\n verse: e,\n versificationStr: this.versificationStr\n };\n return e || delete s.verse, s;\n }\n /**\n * Compares this `VerseRef` with supplied one.\n * @param verseRef - object to compare this one to.\n * @returns `true` if this `VerseRef` is equal to the supplied one, `false` otherwise.\n */\n equals(e) {\n return e instanceof i ? e._bookNum === this._bookNum && e._chapterNum === this._chapterNum && e._verseNum === this._verseNum && e.verse === this.verse && (e.versification == null && this.versification == null || e.versification != null && this.versification != null && e.versification.equals(this.versification)) : !1;\n }\n /**\n * Enumerate all individual verses contained in a VerseRef.\n * Verse ranges are indicated by \"-\" and consecutive verses by \",\"s.\n * Examples:\n * GEN 1:2 returns GEN 1:2\n * GEN 1:1a-3b,5 returns GEN 1:1a, GEN 1:2, GEN 1:3b, GEN 1:5\n * GEN 1:2a-2c returns //! ??????\n *\n * @param specifiedVersesOnly - if set to true return only verses that are\n * explicitly specified only, not verses within a range. Defaults to `false`.\n * @param verseRangeSeparators - Verse range separators.\n * Defaults to `VerseRef.verseRangeSeparators`.\n * @param verseSequenceSeparators - Verse sequence separators.\n * Defaults to `VerseRef.verseSequenceIndicators`.\n * @returns An array of all single verse references in this VerseRef.\n */\n allVerses(e = !1, s = i.verseRangeSeparators, r = i.verseSequenceIndicators) {\n if (this._verse == null || this.chapterNum <= 0)\n return [this.clone()];\n const a = [], o = E(this._verse, r);\n for (const u of o.map((f) => E(f, s))) {\n const f = this.clone();\n f.verse = u[0];\n const d = f.verseNum;\n if (a.push(f), u.length > 1) {\n const b = this.clone();\n if (b.verse = u[1], !e)\n for (let p = d + 1; p < b.verseNum; p++) {\n const J = new i(\n this._bookNum,\n this._chapterNum,\n p,\n this.versification\n );\n this.isExcluded || a.push(J);\n }\n a.push(b);\n }\n }\n return a;\n }\n /**\n * Validates a verse number using the supplied separators rather than the defaults.\n */\n validateVerse(e, s) {\n if (!this.verse)\n return this.internalValid;\n let r = 0;\n for (const a of this.allVerses(!0, e, s)) {\n const o = a.internalValid;\n if (o !== 0)\n return o;\n const u = a.BBBCCCVVV;\n if (r > u)\n return 3;\n if (r === u)\n return 4;\n r = u;\n }\n return 0;\n }\n /**\n * Gets whether a single verse reference is valid.\n */\n get internalValid() {\n return this.versification == null ? 1 : this._bookNum <= 0 || this._bookNum > m.lastBook ? 2 : (m.isCanonical(this._bookNum), 0);\n }\n setEmpty(e = i.defaultVersification) {\n this._bookNum = 0, this._chapterNum = -1, this._verse = void 0, this.versification = e;\n }\n updateInternal(e, s, r) {\n this.bookNum = m.bookIdToNumber(e), this.chapter = s, this.verse = r;\n }\n};\nn(i, \"defaultVersification\", c.English), n(i, \"verseRangeSeparator\", \"-\"), n(i, \"verseSequenceIndicator\", \",\"), n(i, \"verseRangeSeparators\", [i.verseRangeSeparator]), n(i, \"verseSequenceIndicators\", [i.verseSequenceIndicator]), n(i, \"chapterDigitShifter\", 1e3), n(i, \"bookDigitShifter\", i.chapterDigitShifter * i.chapterDigitShifter), n(i, \"bcvMaxValue\", i.chapterDigitShifter - 1), /**\n * The valid status of the VerseRef.\n */\nn(i, \"ValidStatusType\", D);\nlet M = i;\nclass v extends Error {\n}\nexport {\n _ as BookSet,\n m as Canon,\n c as ScrVers,\n l as ScrVersType,\n M as VerseRef,\n v as VerseRefException\n};\n//# sourceMappingURL=index.es.js.map\n","'use strict';\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties,\n * including NodeList.\n *\n * @param {T[] | { length: number; [number]: T }} list\n * @param {function (item: T, index: number, list:T[]):boolean} predicate\n * @param {Partial>?} ac\n * Allows injecting a custom implementation in tests (`Array.prototype` by default).\n * @returns {T | undefined}\n * @template {unknown} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (hasOwn(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * If `Object.getOwnPropertyDescriptors` is available,\n * a new object with all properties of object but without any prototype is created and returned\n * after freezing it.\n *\n * @param {T} object\n * The object to freeze.\n * @param {Pick} [oc=Object]\n * `Object` by default,\n * allows to inject custom object constructor for tests.\n * @returns {Readonly}\n * @template {Object} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n * @prettierignore\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object;\n\t}\n\tif (oc && typeof oc.getOwnPropertyDescriptors === 'function') {\n\t\tobject = oc.create(null, oc.getOwnPropertyDescriptors(object));\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;\n}\n\n/**\n * Implementation for `Object.hasOwn` but ES5 compatible.\n *\n * @param {any} object\n * @param {string | number} key\n * @returns {boolean}\n */\nfunction hasOwn(object, key) {\n\treturn Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Since xmldom can not rely on `Object.assign`,\n * it uses/provides a simplified version that is sufficient for its needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n * @returns {Object}\n * The target with the merged/overridden properties.\n * @throws {TypeError}\n * If target is not an object.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object');\n\t}\n\tfor (var key in source) {\n\t\tif (hasOwn(source, key)) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * A number of attributes are boolean attributes.\n * The presence of a boolean attribute on an element represents the `true` value,\n * and the absence of the attribute represents the `false` value.\n *\n * If the attribute is present, its value must either be the empty string, or a value that is\n * an ASCII case-insensitive match for the attribute's canonical name,\n * with no leading or trailing whitespace.\n *\n * Note: The values `\"true\"` and `\"false\"` are not allowed on boolean attributes.\n * To represent a `false` value, the attribute has to be omitted altogether.\n *\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nvar HTML_BOOLEAN_ATTRIBUTES = freeze({\n\tallowfullscreen: true,\n\tasync: true,\n\tautofocus: true,\n\tautoplay: true,\n\tchecked: true,\n\tcontrols: true,\n\tdefault: true,\n\tdefer: true,\n\tdisabled: true,\n\tformnovalidate: true,\n\thidden: true,\n\tismap: true,\n\titemscope: true,\n\tloop: true,\n\tmultiple: true,\n\tmuted: true,\n\tnomodule: true,\n\tnovalidate: true,\n\topen: true,\n\tplaysinline: true,\n\treadonly: true,\n\trequired: true,\n\treversed: true,\n\tselected: true,\n});\n\n/**\n * Check if `name` is matching one of the HTML boolean attribute names.\n * This method doesn't check if such attributes are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} name\n * @returns {boolean}\n * @see {@link HTML_BOOLEAN_ATTRIBUTES}\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nfunction isHTMLBooleanAttribute(name) {\n\treturn hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());\n}\n\n/**\n * Void elements only have a start tag; end tags must not be specified for void elements.\n * These elements should be written as self-closing like this: ``.\n * This should not be confused with optional tags that HTML allows to omit the end tag for\n * (like `li`, `tr` and others), which can have content after them,\n * so they can not be written as self-closing.\n * xmldom does not have any logic for optional end tags cases,\n * and will report them as a warning.\n * Content that would go into the unopened element,\n * will instead be added as a sibling text node.\n *\n * @type {Readonly<{\n * \tarea: boolean;\n * \tcol: boolean;\n * \timg: boolean;\n * \twbr: boolean;\n * \tlink: boolean;\n * \thr: boolean;\n * \tsource: boolean;\n * \tbr: boolean;\n * \tinput: boolean;\n * \tparam: boolean;\n * \tmeta: boolean;\n * \tembed: boolean;\n * \ttrack: boolean;\n * \tbase: boolean;\n * }>}\n * @see https://html.spec.whatwg.org/#void-elements\n * @see https://html.spec.whatwg.org/#optional-tags\n */\nvar HTML_VOID_ELEMENTS = freeze({\n\tarea: true,\n\tbase: true,\n\tbr: true,\n\tcol: true,\n\tembed: true,\n\thr: true,\n\timg: true,\n\tinput: true,\n\tlink: true,\n\tmeta: true,\n\tparam: true,\n\tsource: true,\n\ttrack: true,\n\twbr: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML void element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link HTML_VOID_ELEMENTS}\n * @see https://html.spec.whatwg.org/#void-elements\n */\nfunction isHTMLVoidElement(tagName) {\n\treturn hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());\n}\n\n/**\n * Tag names that are raw text elements according to HTML spec.\n * The value denotes whether they are escapable or not.\n *\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link isHTMLRawTextElement}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nvar HTML_RAW_TEXT_ELEMENTS = freeze({\n\tscript: false,\n\tstyle: false,\n\ttextarea: true,\n\ttitle: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Check if `tagName` is matching one of the HTML escapable raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLEscapableRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'text/html'}\n * @see https://www.iana.org/assignments/media-types/text/html\n * @see https://en.wikipedia.org/wiki/HTML\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n */\nfunction isHTMLMimeType(mimeType) {\n\treturn mimeType === MIME_TYPE.HTML;\n}\n/**\n * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the\n * HTML namespace is provided as the default.\n *\n * @param {string} mimeType\n * @returns {boolean}\n * @see https://dom.spec.whatwg.org/#dom-document-createelement\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n */\nfunction hasDefaultHTMLNamespace(mimeType) {\n\treturn isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02\n * MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype\n * WHATWG HTML Spec\n * @see {@link DOMParser.prototype.parseFromString}\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n\t * WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType\n\t * registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/xml`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType\n\t * registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n});\n/**\n * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n * MimeType\n */\n/**\n * @type {MimeType[]}\n * @private\n * Basically `Object.values`, which is not available in ES5.\n */\nvar _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {\n\treturn MIME_TYPE[key];\n});\n\n/**\n * Only returns true if `mimeType` is one of the allowed values for\n * `DOMParser.parseFromString`.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n *\n */\nfunction isValidMimeType(mimeType) {\n\treturn _MIME_TYPES.indexOf(mimeType) > -1;\n}\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace.\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n});\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;\nexports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;\nexports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;\nexports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;\nexports.hasOwn = hasOwn;\nexports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;\nexports.isHTMLRawTextElement = isHTMLRawTextElement;\nexports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;\nexports.isHTMLMimeType = isHTMLMimeType;\nexports.isHTMLVoidElement = isHTMLVoidElement;\nexports.isValidMimeType = isValidMimeType;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","'use strict';\n\nvar conventions = require('./conventions');\n\nfunction extendError(constructor, writableName) {\n\tconstructor.prototype = Object.create(Error.prototype, {\n\t\tconstructor: { value: constructor },\n\t\tname: { value: constructor.name, enumerable: true, writable: writableName },\n\t});\n}\n\nvar DOMExceptionName = conventions.freeze({\n\t/**\n\t * the default value as defined by the spec\n\t */\n\tError: 'Error',\n\t/**\n\t * @deprecated\n\t * Use RangeError instead.\n\t */\n\tIndexSizeError: 'IndexSizeError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tDomstringSizeError: 'DomstringSizeError',\n\tHierarchyRequestError: 'HierarchyRequestError',\n\tWrongDocumentError: 'WrongDocumentError',\n\tInvalidCharacterError: 'InvalidCharacterError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tNoDataAllowedError: 'NoDataAllowedError',\n\tNoModificationAllowedError: 'NoModificationAllowedError',\n\tNotFoundError: 'NotFoundError',\n\tNotSupportedError: 'NotSupportedError',\n\tInUseAttributeError: 'InUseAttributeError',\n\tInvalidStateError: 'InvalidStateError',\n\tSyntaxError: 'SyntaxError',\n\tInvalidModificationError: 'InvalidModificationError',\n\tNamespaceError: 'NamespaceError',\n\t/**\n\t * @deprecated\n\t * Use TypeError for invalid arguments,\n\t * \"NotSupportedError\" DOMException for unsupported operations,\n\t * and \"NotAllowedError\" DOMException for denied requests instead.\n\t */\n\tInvalidAccessError: 'InvalidAccessError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tValidationError: 'ValidationError',\n\t/**\n\t * @deprecated\n\t * Use TypeError instead.\n\t */\n\tTypeMismatchError: 'TypeMismatchError',\n\tSecurityError: 'SecurityError',\n\tNetworkError: 'NetworkError',\n\tAbortError: 'AbortError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tURLMismatchError: 'URLMismatchError',\n\tQuotaExceededError: 'QuotaExceededError',\n\tTimeoutError: 'TimeoutError',\n\tInvalidNodeTypeError: 'InvalidNodeTypeError',\n\tDataCloneError: 'DataCloneError',\n\tEncodingError: 'EncodingError',\n\tNotReadableError: 'NotReadableError',\n\tUnknownError: 'UnknownError',\n\tConstraintError: 'ConstraintError',\n\tDataError: 'DataError',\n\tTransactionInactiveError: 'TransactionInactiveError',\n\tReadOnlyError: 'ReadOnlyError',\n\tVersionError: 'VersionError',\n\tOperationError: 'OperationError',\n\tNotAllowedError: 'NotAllowedError',\n\tOptOutError: 'OptOutError',\n});\nvar DOMExceptionNames = Object.keys(DOMExceptionName);\n\nfunction isValidDomExceptionCode(value) {\n\treturn typeof value === 'number' && value >= 1 && value <= 25;\n}\nfunction endsWithError(value) {\n\treturn typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;\n}\n/**\n * DOM operations only raise exceptions in \"exceptional\" circumstances, i.e., when an operation\n * is impossible to perform (either for logical reasons, because data is lost, or because the\n * implementation has become unstable). In general, DOM methods return specific error values in\n * ordinary processing situations, such as out-of-bound errors when using NodeList.\n *\n * Implementations should raise other exceptions under other circumstances. For example,\n * implementations should raise an implementation-dependent exception if a null argument is\n * passed when null was not expected.\n *\n * This implementation supports the following usages:\n * 1. according to the living standard (both arguments are optional):\n * ```\n * new DOMException(\"message (can be empty)\", DOMExceptionNames.HierarchyRequestError)\n * ```\n * 2. according to previous xmldom implementation (only the first argument is required):\n * ```\n * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, \"optional message\")\n * ```\n * both result in the proper name being set.\n *\n * @class DOMException\n * @param {number | string} messageOrCode\n * The reason why an operation is not acceptable.\n * If it is a number, it is used to determine the `name`, see\n * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}\n * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]\n * The `name` to use for the error.\n * If `messageOrCode` is a number, this arguments is used as the `message` instead.\n * @augments Error\n * @see https://webidl.spec.whatwg.org/#idl-DOMException\n * @see https://webidl.spec.whatwg.org/#dfn-error-names-table\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(messageOrCode, nameOrMessage) {\n\t// support old way of passing arguments: first argument is a valid number\n\tif (isValidDomExceptionCode(messageOrCode)) {\n\t\tthis.name = DOMExceptionNames[messageOrCode];\n\t\tthis.message = nameOrMessage || '';\n\t} else {\n\t\tthis.message = messageOrCode;\n\t\tthis.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;\n\t}\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n}\nextendError(DOMException, true);\nObject.defineProperties(DOMException.prototype, {\n\tcode: {\n\t\tenumerable: true,\n\t\tget: function () {\n\t\t\tvar code = DOMExceptionNames.indexOf(this.name);\n\t\t\tif (isValidDomExceptionCode(code)) return code;\n\t\t\treturn 0;\n\t\t},\n\t},\n});\n\nvar ExceptionCode = {\n\tINDEX_SIZE_ERR: 1,\n\tDOMSTRING_SIZE_ERR: 2,\n\tHIERARCHY_REQUEST_ERR: 3,\n\tWRONG_DOCUMENT_ERR: 4,\n\tINVALID_CHARACTER_ERR: 5,\n\tNO_DATA_ALLOWED_ERR: 6,\n\tNO_MODIFICATION_ALLOWED_ERR: 7,\n\tNOT_FOUND_ERR: 8,\n\tNOT_SUPPORTED_ERR: 9,\n\tINUSE_ATTRIBUTE_ERR: 10,\n\tINVALID_STATE_ERR: 11,\n\tSYNTAX_ERR: 12,\n\tINVALID_MODIFICATION_ERR: 13,\n\tNAMESPACE_ERR: 14,\n\tINVALID_ACCESS_ERR: 15,\n\tVALIDATION_ERR: 16,\n\tTYPE_MISMATCH_ERR: 17,\n\tSECURITY_ERR: 18,\n\tNETWORK_ERR: 19,\n\tABORT_ERR: 20,\n\tURL_MISMATCH_ERR: 21,\n\tQUOTA_EXCEEDED_ERR: 22,\n\tTIMEOUT_ERR: 23,\n\tINVALID_NODE_TYPE_ERR: 24,\n\tDATA_CLONE_ERR: 25,\n};\n\nvar entries = Object.entries(ExceptionCode);\nfor (var i = 0; i < entries.length; i++) {\n\tvar key = entries[i][0];\n\tDOMException[key] = entries[i][1];\n}\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @class\n * @param {string} message\n * @param {any} [locator]\n */\nfunction ParseError(message, locator) {\n\tthis.message = message;\n\tthis.locator = locator;\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nextendError(ParseError);\n\nexports.DOMException = DOMException;\nexports.DOMExceptionName = DOMExceptionName;\nexports.ExceptionCode = ExceptionCode;\nexports.ParseError = ParseError;\n","'use strict';\n\n/**\n * Detects relevant unicode support for regular expressions in the runtime.\n * Should the runtime not accepts the flag `u` or unicode ranges,\n * character classes without unicode handling will be used.\n *\n * @param {typeof RegExp} [RegExpImpl=RegExp]\n * For testing: the RegExp class.\n * @returns {boolean}\n * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags\n */\nfunction detectUnicodeSupport(RegExpImpl) {\n\ttry {\n\t\tif (typeof RegExpImpl !== 'function') {\n\t\t\tRegExpImpl = RegExp;\n\t\t}\n\t\t// eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape\n\t\tvar match = new RegExpImpl('\\u{1d306}', 'u').exec('𝌆');\n\t\treturn !!match && match[0].length === 2;\n\t} catch (error) {}\n\treturn false;\n}\nvar UNICODE_SUPPORT = detectUnicodeSupport();\n\n/**\n * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.\n *\n * @param {RegExp} regexp\n */\nfunction chars(regexp) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error(regexp + ' can not be used with chars');\n\t}\n\treturn regexp.source.slice(1, regexp.source.lastIndexOf(']'));\n}\n\n/**\n * Creates a new character list regular expression,\n * by removing `search` from the source of `regexp`.\n *\n * @param {RegExp} regexp\n * @param {string} search\n * The character(s) to remove.\n * @returns {RegExp}\n */\nfunction chars_without(regexp, search) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error('/' + regexp.source + '/ can not be used with chars_without');\n\t}\n\tif (!search || typeof search !== 'string') {\n\t\tthrow new Error(JSON.stringify(search) + ' is not a valid search');\n\t}\n\tif (regexp.source.indexOf(search) === -1) {\n\t\tthrow new Error('\"' + search + '\" is not is /' + regexp.source + '/');\n\t}\n\tif (search === '-' && regexp.source.indexOf(search) !== 1) {\n\t\tthrow new Error('\"' + search + '\" is not at the first postion of /' + regexp.source + '/');\n\t}\n\treturn new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');\n}\n\n/**\n * Combines and Regular expressions correctly by using `RegExp.source`.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction reg(args) {\n\tvar self = this;\n\treturn new RegExp(\n\t\tArray.prototype.slice\n\t\t\t.call(arguments)\n\t\t\t.map(function (part) {\n\t\t\t\tvar isStr = typeof part === 'string';\n\t\t\t\tif (isStr && self === undefined && part === '|') {\n\t\t\t\t\tthrow new Error('use regg instead of reg to wrap expressions with `|`!');\n\t\t\t\t}\n\t\t\t\treturn isStr ? part : part.source;\n\t\t\t})\n\t\t\t.join(''),\n\t\tUNICODE_SUPPORT ? 'mu' : 'm'\n\t);\n}\n\n/**\n * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction regg(args) {\n\tif (arguments.length === 0) {\n\t\tthrow new Error('no parameters provided');\n\t}\n\treturn reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));\n}\n\n// /**\n// * Append ^ to the beginning of the expression.\n// * @param {...(RegExp | string)[]} args\n// * @returns {RegExp}\n// */\n// function reg_start(args) {\n// \tif (arguments.length === 0) {\n// \t\tthrow new Error('no parameters provided');\n// \t}\n// \treturn reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));\n// }\n\n// https://www.w3.org/TR/xml/#document\n// `[1] document ::= prolog element Misc*`\n// https://www.w3.org/TR/xml11/#NT-document\n// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`\n\n/**\n * A character usually appearing in wrongly converted strings.\n *\n * @type {string}\n * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character\n * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings\n * @see https://www.unicode.org/faq/utf_bom.html#BOM\n * @readonly\n */\nvar UNICODE_REPLACEMENT_CHARACTER = '\\uFFFD';\n// https://www.w3.org/TR/xml/#NT-Char\n// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-Char\n// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-RestrictedChar\n// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`\n// https://www.w3.org/TR/xml11/#charsets\nvar Char = /[-\\x09\\x0A\\x0D\\x20-\\x2C\\x2E-\\uD7FF\\uE000-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tChar = reg('[', chars(Char), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\n\nvar _SChar = /[\\x20\\x09\\x0D\\x0A]/;\nvar SChar_s = chars(_SChar);\n// https://www.w3.org/TR/xml11/#NT-S\n// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`\nvar S = reg(_SChar, '+');\n// optional whitespace described as `S?` in the grammar,\n// simplified to 0-n occurrences of the character class\n// instead of 0-1 occurrences of a non-capturing group around S\nvar S_OPT = reg(_SChar, '*');\n\n// https://www.w3.org/TR/xml11/#NT-NameStartChar\n// `[4] NameStartChar ::= \":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`\nvar NameStartChar =\n\t/[:_a-zA-Z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02FF\\u0370-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tNameStartChar = reg('[', chars(NameStartChar), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\nvar NameStartChar_s = chars(NameStartChar);\n\n// https://www.w3.org/TR/xml11/#NT-NameChar\n// `[4a] NameChar ::= NameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`\nvar NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\\xB7]/), chars(/[\\u0300-\\u036F\\u203F-\\u2040]/), ']');\n// https://www.w3.org/TR/xml11/#NT-Name\n// `[5] Name ::= NameStartChar (NameChar)*`\nvar Name = reg(NameStartChar, NameChar, '*');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Names\n`[6] Names ::= Name (#x20 Name)*`\n*/\n\n// https://www.w3.org/TR/xml11/#NT-Nmtoken\n// `[7] Nmtoken ::= (NameChar)+`\nvar Nmtoken = reg(NameChar, '+');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Nmtokens\n`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`\nvar Nmtokens = reg(Nmtoken, regg(/\\x20/, Nmtoken), '*');\n*/\n\n// https://www.w3.org/TR/xml11/#NT-EntityRef\n// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\nvar EntityRef = reg('&', Name, ';');\n// https://www.w3.org/TR/xml11/#NT-CharRef\n// `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\nvar CharRef = regg(/&#[0-9]+;|&#x[0-9a-fA-F]+;/);\n\n/*\nhttps://www.w3.org/TR/xml11/#NT-Reference\n- `[67] Reference ::= EntityRef | CharRef`\n- `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\n- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\n*/\nvar Reference = regg(EntityRef, '|', CharRef);\n\n// https://www.w3.org/TR/xml11/#NT-PEReference\n// `[69] PEReference ::= '%' Name ';'`\n// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]\nvar PEReference = reg('%', Name, ';');\n\n// https://www.w3.org/TR/xml11/#NT-EntityValue\n// `[9] EntityValue ::= '\"' ([^%&\"] | PEReference | Reference)* '\"' | \"'\" ([^%&'] | PEReference | Reference)* \"'\"`\nvar EntityValue = regg(\n\treg('\"', regg(/[^%&\"]/, '|', PEReference, '|', Reference), '*', '\"'),\n\t'|',\n\treg(\"'\", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', \"'\")\n);\n\n// https://www.w3.org/TR/xml11/#NT-AttValue\n// `[10] AttValue ::= '\"' ([^<&\"] | Reference)* '\"' | \"'\" ([^<&'] | Reference)* \"'\"`\nvar AttValue = regg('\"', regg(/[^<&\"]/, '|', Reference), '*', '\"', '|', \"'\", regg(/[^<&']/, '|', Reference), '*', \"'\");\n\n// https://www.w3.org/TR/xml-names/#ns-decl\n// https://www.w3.org/TR/xml-names/#ns-qualnames\n// NameStartChar without \":\"\nvar NCNameStartChar = chars_without(NameStartChar, ':');\n// https://www.w3.org/TR/xml-names/#orphans\n// `[5] NCNameChar ::= NameChar - ':'`\n// An XML NameChar, minus the \":\"\nvar NCNameChar = chars_without(NameChar, ':');\n// https://www.w3.org/TR/xml-names/#NT-NCName\n// `[4] NCName ::= Name - (Char* ':' Char*)`\n// An XML Name, minus the \":\"\nvar NCName = reg(NCNameStartChar, NCNameChar, '*');\n\n/**\nhttps://www.w3.org/TR/xml-names/#ns-qualnames\n\n```\n[7] QName ::= PrefixedName | UnprefixedName\n\t\t\t\t === (NCName ':' NCName) | NCName\n\t\t\t\t === NCName (':' NCName)?\n[8] PrefixedName ::= Prefix ':' LocalPart\n\t\t\t\t\t\t\t\t === NCName ':' NCName\n[9] UnprefixedName ::= LocalPart\n\t\t\t\t\t\t\t\t\t === NCName\n[10] Prefix ::= NCName\n[11] LocalPart ::= NCName\n```\n*/\nvar QName = reg(NCName, regg(':', NCName), '?');\nvar QName_exact = reg('^', QName, '$');\nvar QName_group = reg('(', QName, ')');\n\n// https://www.w3.org/TR/xml11/#NT-SystemLiteral\n// `[11] SystemLiteral ::= ('\"' [^\"]* '\"') | (\"'\" [^']* \"'\")`\nvar SystemLiteral = regg(/\"[^\"]*\"|'[^']*'/);\n\n/*\n https://www.w3.org/TR/xml11/#NT-PI\n ```\n [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))\n [16] PI ::= '' Char*)))? '?>'\n ```\n target /xml/i is not excluded!\n*/\nvar PI = reg(/^<\\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\\?>/);\n\n// https://www.w3.org/TR/xml11/#NT-PubidChar\n// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`\nvar PubidChar = /[\\x20\\x0D\\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;\n\n// https://www.w3.org/TR/xml11/#NT-PubidLiteral\n// `[12] PubidLiteral ::= '\"' PubidChar* '\"' | \"'\" (PubidChar - \"'\")* \"'\"`\nvar PubidLiteral = regg('\"', PubidChar, '*\"', '|', \"'\", chars_without(PubidChar, \"'\"), \"*'\");\n\n// https://www.w3.org/TR/xml11/#NT-CharData\n// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`\n\nvar COMMENT_START = '';\n// https://www.w3.org/TR/xml11/#NT-Comment\n// `[15] Comment ::= ''`\nvar Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);\n\nvar PCDATA = '#PCDATA';\n// https://www.w3.org/TR/xml11/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// https://www.w3.org/TR/xml-names/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]\nvar Mixed = regg(\n\treg(/\\(/, S_OPT, PCDATA, regg(S_OPT, /\\|/, S_OPT, QName), '*', S_OPT, /\\)\\*/),\n\t'|',\n\treg(/\\(/, S_OPT, PCDATA, S_OPT, /\\)/)\n);\n\nvar _children_quantity = /[?*+]?/;\n/*\n `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]\n `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');\n ```\n [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?\n === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?\n !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?\n ```\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.\nhttps://github.com/xmldom/xmldom/security/code-scanning/91\nvar choice = regg(/\\(/, S_OPT, cp, regg(S_OPT, /\\|/, S_OPT, cp), '+', S_OPT, /\\)/);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.\nhttps://github.com/xmldom/xmldom/security/code-scanning/92\nvar seq = regg(/\\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\\)/);\n*/\n\n// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`\n// simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\nvar children = reg(/\\([^>]+\\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);\n\n// https://www.w3.org/TR/xml11/#NT-contentspec\n// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`\nvar contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);\n\nvar ELEMENTDECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-elementdecl\n// `[17] elementdecl ::= ''`\n// because of https://www.w3.org/TR/xml11/#NT-PEReference\n// since xmldom is not supporting replacements of PEReferences in the DTD\n// this also supports PEReference in the possible places\nvar elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');\n\n// https://www.w3.org/TR/xml11/#NT-NotationType\n// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`\n// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]\nvar NotationType = reg('NOTATION', S, /\\(/, S_OPT, Name, regg(S_OPT, /\\|/, S_OPT, Name), '*', S_OPT, /\\)/);\n// https://www.w3.org/TR/xml11/#NT-Enumeration\n// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`\n// [VC: Enumeration] [VC: No Duplicate Tokens]\nvar Enumeration = reg(/\\(/, S_OPT, Nmtoken, regg(S_OPT, /\\|/, S_OPT, Nmtoken), '*', S_OPT, /\\)/);\n\n// https://www.w3.org/TR/xml11/#NT-EnumeratedType\n// `[57] EnumeratedType ::= NotationType | Enumeration`\nvar EnumeratedType = regg(NotationType, '|', Enumeration);\n\n/*\n```\n[55] StringType ::= 'CDATA'\n[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]\n | 'IDREF' [VC: IDREF]\n | 'IDREFS' [VC: IDREF]\n\t | 'ENTITY' [VC: Entity Name]\n\t | 'ENTITIES' [VC: Entity Name]\n\t | 'NMTOKEN' [VC: Name Token]\n\t | 'NMTOKENS' [VC: Name Token]\n [54] AttType ::= StringType | TokenizedType | EnumeratedType\n```*/\nvar AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);\n\n// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`\n// [WFC: No < in Attribute Values] [WFC: No External Entity References]\n// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]\nvar DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));\n\n// https://www.w3.org/TR/xml11/#NT-AttDef\n// [53] AttDef ::= S Name S AttType S DefaultDecl\n// https://www.w3.org/TR/xml-names/#NT-AttDef\n// [1] NSAttName ::= PrefixedAttName | DefaultAttName\n// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]\n// [3] DefaultAttName ::= 'xmlns'\n// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl\n// \t\t\t\t\t\t === S Name S AttType S DefaultDecl\n// xmldom is not distinguishing between QName and NSAttName on this level\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttDef = regg(S, Name, S, AttType, S, DefaultDecl);\n\nvar ATTLIST_DECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-AttlistDecl\n// `[20] AttlistDecl ::= ''`\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');\n\n// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat\nvar ABOUT_LEGACY_COMPAT = 'about:legacy-compat';\nvar ABOUT_LEGACY_COMPAT_SystemLiteral = regg('\"' + ABOUT_LEGACY_COMPAT + '\"', '|', \"'\" + ABOUT_LEGACY_COMPAT + \"'\");\nvar SYSTEM = 'SYSTEM';\nvar PUBLIC = 'PUBLIC';\n// https://www.w3.org/TR/xml11/#NT-ExternalID\n// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`\nvar ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));\nvar ExternalID_match = reg(\n\t'^',\n\tregg(\n\t\tregg(SYSTEM, S, '(?', SystemLiteral, ')'),\n\t\t'|',\n\t\tregg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')\n\t)\n);\n\n// https://www.w3.org/TR/xml11/#NT-NDataDecl\n// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]\nvar NDataDecl = regg(S, 'NDATA', S, Name);\n\n// https://www.w3.org/TR/xml11/#NT-EntityDef\n// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`\nvar EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));\n\nvar ENTITY_DECL_START = ''`\nvar GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-PEDef\n// `[74] PEDef ::= EntityValue | ExternalID`\nvar PEDef = regg(EntityValue, '|', ExternalID);\n// https://www.w3.org/TR/xml11/#NT-PEDecl\n// `[72] PEDecl ::= ''`\nvar PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-EntityDecl\n// `[70] EntityDecl ::= GEDecl | PEDecl`\nvar EntityDecl = regg(GEDecl, '|', PEDecl);\n\n// https://www.w3.org/TR/xml11/#NT-PublicID\n// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`\nvar PublicID = reg(PUBLIC, S, PubidLiteral);\n// https://www.w3.org/TR/xml11/#NT-NotationDecl\n// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]\nvar NotationDecl = reg('');\n\n// https://www.w3.org/TR/xml11/#NT-Eq\n// `[25] Eq ::= S? '=' S?`\nvar Eq = reg(S_OPT, '=', S_OPT);\n// https://www.w3.org/TR/xml/#NT-VersionNum\n// `[26] VersionNum ::= '1.' [0-9]+`\n// https://www.w3.org/TR/xml11/#NT-VersionNum\n// `[26] VersionNum ::= '1.1'`\nvar VersionNum = /1[.]\\d+/;\n// https://www.w3.org/TR/xml11/#NT-VersionInfo\n// `[24] VersionInfo ::= S 'version' Eq (\"'\" VersionNum \"'\" | '\"' VersionNum '\"')`\nvar VersionInfo = reg(S, 'version', Eq, regg(\"'\", VersionNum, \"'\", '|', '\"', VersionNum, '\"'));\n// https://www.w3.org/TR/xml11/#NT-EncName\n// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`\nvar EncName = /[A-Za-z][-A-Za-z0-9._]*/;\n// https://www.w3.org/TR/xml11/#NT-EncDecl\n// `[80] EncodingDecl ::= S 'encoding' Eq ('\"' EncName '\"' | \"'\" EncName \"'\" )`\nvar EncodingDecl = regg(S, 'encoding', Eq, regg('\"', EncName, '\"', '|', \"'\", EncName, \"'\"));\n// https://www.w3.org/TR/xml11/#NT-SDDecl\n// `[32] SDDecl ::= S 'standalone' Eq ((\"'\" ('yes' | 'no') \"'\") | ('\"' ('yes' | 'no') '\"'))`\nvar SDDecl = regg(S, 'standalone', Eq, regg(\"'\", regg('yes', '|', 'no'), \"'\", '|', '\"', regg('yes', '|', 'no'), '\"'));\n// https://www.w3.org/TR/xml11/#NT-XMLDecl\n// [23] XMLDecl ::= ''\nvar XMLDecl = reg(/^<\\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\\?>/);\n\n/*\n https://www.w3.org/TR/xml/#NT-markupdecl\n https://www.w3.org/TR/xml11/#NT-markupdecl\n `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`\n var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);\n*/\n/*\n https://www.w3.org/TR/xml-names/#NT-doctypedecl\n`[28a] DeclSep ::= PEReference | S`\n https://www.w3.org/TR/xml11/#NT-intSubset\n```\n [28b] intSubset ::= (markupdecl | DeclSep)*\n === (markupdecl | PEReference | S)*\n```\n [WFC: PE Between Declarations]\n var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');\n*/\nvar DOCTYPE_DECL_START = ''`\n https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl\n `[16] doctypedecl ::= ''`\n var doctypedecl = reg('');\n*/\n\nvar CDATA_START = '';\nvar CDStart = //;\nvar CData = reg(Char, '*?', CDEnd);\n/*\n https://www.w3.org/TR/xml/#dt-cdsection\n `[18] \tCDSect\t ::= \tCDStart CData CDEnd`\n `[19] \tCDStart\t ::= \t'' Char*))`\n `[21] \tCDEnd\t ::= \t']]>'`\n*/\nvar CDSect = reg(CDStart, CData);\n\n// unit tested\nexports.chars = chars;\nexports.chars_without = chars_without;\nexports.detectUnicodeSupport = detectUnicodeSupport;\nexports.reg = reg;\nexports.regg = regg;\nexports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;\nexports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;\nexports.AttlistDecl = AttlistDecl;\nexports.CDATA_START = CDATA_START;\nexports.CDATA_END = CDATA_END;\nexports.CDSect = CDSect;\nexports.Char = Char;\nexports.Comment = Comment;\nexports.COMMENT_START = COMMENT_START;\nexports.COMMENT_END = COMMENT_END;\nexports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;\nexports.elementdecl = elementdecl;\nexports.EntityDecl = EntityDecl;\nexports.EntityValue = EntityValue;\nexports.ExternalID = ExternalID;\nexports.ExternalID_match = ExternalID_match;\nexports.Name = Name;\nexports.NotationDecl = NotationDecl;\nexports.Reference = Reference;\nexports.PEReference = PEReference;\nexports.PI = PI;\nexports.PUBLIC = PUBLIC;\nexports.PubidLiteral = PubidLiteral;\nexports.QName = QName;\nexports.QName_exact = QName_exact;\nexports.QName_group = QName_group;\nexports.S = S;\nexports.SChar_s = SChar_s;\nexports.S_OPT = S_OPT;\nexports.SYSTEM = SYSTEM;\nexports.SystemLiteral = SystemLiteral;\nexports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;\nexports.UNICODE_SUPPORT = UNICODE_SUPPORT;\nexports.XMLDecl = XMLDecl;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar find = conventions.find;\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar hasOwn = conventions.hasOwn;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar isHTMLVoidElement = conventions.isHTMLVoidElement;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * Private DOM Constructor symbol\n *\n * Internal symbol used for construction of all classes whose constructors should be private.\n * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,\n * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`\n * so the constructor can't be used from outside the module.\n */\nvar PDC = Symbol();\n\nvar errors = require('./errors');\nvar DOMException = errors.DOMException;\nvar DOMExceptionName = errors.DOMExceptionName;\n\nvar g = require('./grammar');\n\n/**\n * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)\n * and throws an Illegal constructor exception when the symbols don't match.\n * This ensures that the constructor remains private and can't be used outside this module.\n */\nfunction checkSymbol(symbol) {\n\tif (symbol !== PDC) {\n\t\tthrow new TypeError('Illegal constructor');\n\t}\n}\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty.\n *\n * @param {string} input\n * The string to be checked.\n * @returns {boolean}\n * Returns `true` if the input string is not empty, `false` otherwise.\n */\nfunction notEmptyString(input) {\n\treturn input !== '';\n}\n/**\n * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,\n * U+0020 SPACE).\n * It follows the definition from the infra specification from WHATWG.\n *\n * @param {string} input\n * The string to be split.\n * @returns {string[]}\n * An array of the split strings. The array can be empty if the input string is empty or only\n * contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}\n * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : [];\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * The current record object to which the element will be added as a key.\n * The object's keys are string types and values are either boolean or undefined.\n * @param {string} element\n * The string to be added as a key to the current record.\n * @returns {Record}\n * The updated record object after the addition of the new element.\n */\nfunction orderedSetReducer(current, element) {\n\tif (!hasOwn(current, element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * Converts a string into an ordered set by splitting the input on ASCII whitespace and\n * ensuring uniqueness of elements.\n * This follows the definition of an ordered set from the infra specification by WHATWG.\n *\n * @param {string} input\n * The input string to be transformed into an ordered set.\n * @returns {string[]}\n * An array of unique strings obtained from the input, preserving the original order.\n * The array can be empty if the input string is empty or only contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#ordered-set}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}));\n}\n\n/**\n * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.\n * This function is used in environments where `Array.prototype.includes` may not be available.\n *\n * @param {any[]} list\n * The array in which to search for the element.\n * @returns {function(any): boolean}\n * A function that accepts an element and returns a boolean indicating whether the element is\n * included in the provided list.\n */\nfunction arrayIncludes(list) {\n\treturn function (element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t};\n}\n\n/**\n * Validates a qualified name based on the criteria provided in the DOM specification by\n * WHATWG.\n *\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @throws {DOMException}\n * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an\n * invalid character.\n * @see {@link https://dom.spec.whatwg.org/#validate}\n */\nfunction validateQualifiedName(qualifiedName) {\n\tif (!g.QName_exact.test(qualifiedName)) {\n\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name \"' + qualifiedName + '\"');\n\t}\n}\n\n/**\n * Validates a qualified name and the namespace associated with it,\n * based on the criteria provided in the DOM specification by WHATWG.\n *\n * @param {string | null} namespace\n * The namespace to be validated. It can be a string or null.\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @returns {[namespace: string | null, prefix: string | null, localName: string]}\n * Returns a tuple with the namespace,\n * prefix and local name of the qualified name.\n * @throws {DOMException}\n * Throws a DOMException if the qualified name or the namespace is not valid.\n * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}\n */\nfunction validateAndExtract(namespace, qualifiedName) {\n\tvalidateQualifiedName(qualifiedName);\n\tnamespace = namespace || null;\n\t/**\n\t * @type {string | null}\n\t */\n\tvar prefix = null;\n\tvar localName = qualifiedName;\n\tif (qualifiedName.indexOf(':') >= 0) {\n\t\tvar splitResult = qualifiedName.split(':');\n\t\tprefix = splitResult[0];\n\t\tlocalName = splitResult[1];\n\t}\n\tif (prefix !== null && namespace === null) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');\n\t}\n\tif (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is \"xml\" and namespace is not the XML namespace');\n\t}\n\tif ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'either qualifiedName or prefix is \"xmlns\" and namespace is not the XMLNS namespace'\n\t\t);\n\t}\n\tif (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'namespace is the XMLNS namespace and neither qualifiedName nor prefix is \"xmlns\"'\n\t\t);\n\t}\n\treturn [namespace, prefix, localName];\n}\n\n/**\n * Copies properties from one object to another.\n * It only copies the object's own (not inherited) properties.\n *\n * @param {Object} src\n * The source object from which properties are copied.\n * @param {Object} dest\n * The destination object to which properties are copied.\n */\nfunction copy(src, dest) {\n\tfor (var p in src) {\n\t\tif (hasOwn(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n * Extends a class with the properties and methods of a super class.\n * It uses a form of prototypal inheritance, and establishes the `constructor` property\n * correctly(?).\n *\n * It is not clear to the current maintainers if this implementation is making sense,\n * since it creates an intermediate prototype function,\n * which all properties of `Super` are copied onto using `_copy`.\n *\n * @param {Object} Class\n * The class that is to be extended.\n * @param {Object} Super\n * The super class from which properties and methods are inherited.\n * @private\n */\nfunction _extends(Class, Super) {\n\tvar pt = Class.prototype;\n\tif (!(pt instanceof Super)) {\n\t\tfunction t() {}\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt, t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif (pt.constructor != Class) {\n\t\tif (typeof Class != 'function') {\n\t\t\tconsole.error('unknown Class:' + Class);\n\t\t}\n\t\tpt.constructor = Class;\n\t}\n}\n\nvar NodeType = {};\nvar ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);\nvar ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);\nvar TEXT_NODE = (NodeType.TEXT_NODE = 3);\nvar CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);\nvar ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);\nvar ENTITY_NODE = (NodeType.ENTITY_NODE = 6);\nvar PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);\nvar COMMENT_NODE = (NodeType.COMMENT_NODE = 8);\nvar DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);\nvar DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);\nvar DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);\nvar NOTATION_NODE = (NodeType.NOTATION_NODE = 12);\n\nvar DocumentPosition = conventions.freeze({\n\tDOCUMENT_POSITION_DISCONNECTED: 1,\n\tDOCUMENT_POSITION_PRECEDING: 2,\n\tDOCUMENT_POSITION_FOLLOWING: 4,\n\tDOCUMENT_POSITION_CONTAINS: 8,\n\tDOCUMENT_POSITION_CONTAINED_BY: 16,\n\tDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,\n});\n\n//helper functions for compareDocumentPosition\n/**\n * Finds the common ancestor in two parent chains.\n *\n * @param {Node[]} a\n * The first parent chain.\n * @param {Node[]} b\n * The second parent chain.\n * @returns {Node}\n * The common ancestor node if it exists. If there is no common ancestor, the function will\n * return `null`.\n */\nfunction commonAncestor(a, b) {\n\tif (b.length < a.length) return commonAncestor(b, a);\n\tvar c = null;\n\tfor (var n in a) {\n\t\tif (a[n] !== b[n]) return c;\n\t\tc = a[n];\n\t}\n\treturn c;\n}\n\n/**\n * Assigns a unique identifier to a document to ensure consistency while comparing unrelated\n * nodes.\n *\n * @param {Document} doc\n * The document to which a unique identifier is to be assigned.\n * @returns {string}\n * The unique identifier of the document. If the document already had a unique identifier, the\n * function will return the existing one.\n */\nfunction docGUID(doc) {\n\tif (!doc.guid) doc.guid = Math.random();\n\treturn doc.guid;\n}\n//-- end of helper functions\n\n/**\n * The NodeList interface provides the abstraction of an ordered collection of nodes,\n * without defining or constraining how this collection is implemented.\n * NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n * You can also access the items of the NodeList with a `for...of` loop.\n *\n * @class NodeList\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * @constructs NodeList\n */\nfunction NodeList() {}\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1\n\t * inclusive.\n\t *\n\t * @type {number}\n\t */\n\tlength: 0,\n\t/**\n\t * Returns the item at `index`. If index is greater than or equal to the number of nodes in\n\t * the list, this returns null.\n\t *\n\t * @param index\n\t * Unsigned long Index into the collection.\n\t * @returns {Node | null}\n\t * The node at position `index` in the NodeList,\n\t * or null if that is not a valid index.\n\t */\n\titem: function (index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\t/**\n\t * Returns a string representation of the NodeList.\n\t *\n\t * @param {unknown} nodeFilter\n\t * __A filter function? Not implemented according to the spec?__.\n\t * @returns {string}\n\t * A string representation of the NodeList.\n\t */\n\ttoString: function (nodeFilter) {\n\t\tfor (var buf = [], i = 0; i < this.length; i++) {\n\t\t\tserializeToString(this[i], buf, nodeFilter);\n\t\t}\n\t\treturn buf.join('');\n\t},\n\t/**\n\t * Filters the NodeList based on a predicate.\n\t *\n\t * @param {function(Node): boolean} predicate\n\t * - A predicate function to filter the NodeList.\n\t * @returns {Node[]}\n\t * An array of nodes that satisfy the predicate.\n\t * @private\n\t */\n\tfilter: function (predicate) {\n\t\treturn Array.prototype.filter.call(this, predicate);\n\t},\n\t/**\n\t * Returns the first index at which a given node can be found in the NodeList, or -1 if it is\n\t * not present.\n\t *\n\t * @param {Node} item\n\t * - The Node item to locate in the NodeList.\n\t * @returns {number}\n\t * The first index of the node in the NodeList; -1 if not found.\n\t * @private\n\t */\n\tindexOf: function (item) {\n\t\treturn Array.prototype.indexOf.call(this, item);\n\t},\n};\nNodeList.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Represents a live collection of nodes that is automatically updated when its associated\n * document changes.\n *\n * @class LiveNodeList\n * @param {Node} node\n * The associated node.\n * @param {function} refresh\n * The function to refresh the live node list.\n * @augments NodeList\n * @constructs LiveNodeList\n */\nfunction LiveNodeList(node, refresh) {\n\tthis._node = node;\n\tthis._refresh = refresh;\n\t_updateLiveList(this);\n}\n/**\n * Updates the live node list.\n *\n * @param {LiveNodeList} list\n * The live node list to update.\n * @private\n */\nfunction _updateLiveList(list) {\n\tvar inc = list._node._inc || list._node.ownerDocument._inc;\n\tif (list._inc !== inc) {\n\t\tvar ls = list._refresh(list._node);\n\t\t__set__(list, 'length', ls.length);\n\t\tif (!list.$$length || ls.length < list.$$length) {\n\t\t\tfor (var i = ls.length; i in list; i++) {\n\t\t\t\tif (hasOwn(list, i)) {\n\t\t\t\t\tdelete list[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcopy(ls, list);\n\t\tlist._inc = inc;\n\t}\n}\n/**\n * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid\n * index.\n *\n * @param {number} i\n * Index into the collection.\n * @returns {Node | null}\n * The node at position `index` in the LiveNodeList, or null if that is not a valid index.\n */\nLiveNodeList.prototype.item = function (i) {\n\t_updateLiveList(this);\n\treturn this[i] || null;\n};\n\n_extends(LiveNodeList, NodeList);\n\n/**\n * Objects implementing the NamedNodeMap interface are used to represent collections of nodes\n * that can be accessed by name.\n * Note that NamedNodeMap does not inherit from NodeList;\n * NamedNodeMaps are not maintained in any particular order.\n * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal\n * index,\n * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,\n * and does not imply that the DOM specifies an order to these Nodes.\n * NamedNodeMap objects in the DOM are live.\n * used for attributes or DocumentType entities\n *\n * This implementation only supports property indices, but does not support named properties,\n * as specified in the living standard.\n *\n * @class NamedNodeMap\n * @see https://dom.spec.whatwg.org/#interface-namednodemap\n * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names\n * @constructs NamedNodeMap\n */\nfunction NamedNodeMap() {}\n/**\n * Returns the index of a node within the list.\n *\n * @param {Array} list\n * The list of nodes.\n * @param {Node} node\n * The node to find.\n * @returns {number}\n * The index of the node within the list, or -1 if not found.\n * @private\n */\nfunction _findNodeIndex(list, node) {\n\tvar i = 0;\n\twhile (i < list.length) {\n\t\tif (list[i] === node) {\n\t\t\treturn i;\n\t\t}\n\t\ti++;\n\t}\n}\n/**\n * Adds a new attribute to the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which will become the owner of the new attribute.\n * @param {NamedNodeMap} list\n * The list to which the new attribute will be added.\n * @param {Attr} newAttr\n * The new attribute to be added.\n * @param {Attr} oldAttr\n * The old attribute to be replaced, or null if no attribute is to be replaced.\n * @returns {void}\n * @private\n */\nfunction _addNamedNode(el, list, newAttr, oldAttr) {\n\tif (oldAttr) {\n\t\tlist[_findNodeIndex(list, oldAttr)] = newAttr;\n\t} else {\n\t\tlist[list.length] = newAttr;\n\t\tlist.length++;\n\t}\n\tif (el) {\n\t\tnewAttr.ownerElement = el;\n\t\tvar doc = el.ownerDocument;\n\t\tif (doc) {\n\t\t\toldAttr && _onRemoveAttribute(doc, el, oldAttr);\n\t\t\t_onAddAttribute(doc, el, newAttr);\n\t\t}\n\t}\n}\n/**\n * Removes an attribute from the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which is the current owner of the attribute.\n * @param {NamedNodeMap} list\n * The list from which the attribute will be removed.\n * @param {Attr} attr\n * The attribute to be removed.\n * @returns {void}\n * @private\n */\nfunction _removeNamedNode(el, list, attr) {\n\t//console.log('remove attr:'+attr)\n\tvar i = _findNodeIndex(list, attr);\n\tif (i >= 0) {\n\t\tvar lastIndex = list.length - 1;\n\t\twhile (i <= lastIndex) {\n\t\t\tlist[i] = list[++i];\n\t\t}\n\t\tlist.length = lastIndex;\n\t\tif (el) {\n\t\t\tvar doc = el.ownerDocument;\n\t\t\tif (doc) {\n\t\t\t\t_onRemoveAttribute(doc, el, attr);\n\t\t\t}\n\t\t\tattr.ownerElement = null;\n\t\t}\n\t}\n}\nNamedNodeMap.prototype = {\n\tlength: 0,\n\titem: NodeList.prototype.item,\n\n\t/**\n\t * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and\n\t * document.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given local name, or null if no such attribute exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name\n\t */\n\tgetNamedItem: function (localName) {\n\t\tif (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {\n\t\t\tlocalName = localName.toLowerCase();\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar attr = this[i];\n\t\t\tif (attr.nodeName === localName) {\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n\n\t/**\n\t * Set an attribute.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another\n\t * element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItem: function (attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif (el && el !== this._ownerElement) {\n\t\t\tthrow new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);\n\t\tif (oldAttr === attr) {\n\t\t\treturn attr;\n\t\t}\n\t\t_addNamedNode(this._ownerElement, this, attr, oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/**\n\t * Set an attribute, replacing an existing attribute with the same local name and namespace\n\t * URI if one exists.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * Throws a DOMException with the name \"InUseAttributeError\" if the attribute is already an\n\t * attribute of another element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItemNS: function (attr) {\n\t\treturn this.setNamedItem(attr);\n\t},\n\n\t/**\n\t * Removes an attribute specified by the local name.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name\n\t */\n\tremoveNamedItem: function (localName) {\n\t\tvar attr = this.getNamedItem(localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Removes an attribute specified by the namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute to be removed.\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local\n\t * name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace\n\t */\n\tremoveNamedItemNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getNamedItemNS(namespaceURI, localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Get an attribute by namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute.\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given namespace URI and local name, or null if no such attribute\n\t * exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace\n\t */\n\tgetNamedItemNS: function (namespaceURI, localName) {\n\t\tif (!namespaceURI) {\n\t\t\tnamespaceURI = null;\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar node = this[i];\n\t\t\tif (node.localName === localName && node.namespaceURI === namespaceURI) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n};\nNamedNodeMap.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * The DOMImplementation interface provides a number of methods for performing operations that\n * are independent of any particular instance of the document object model.\n *\n * The DOMImplementation interface represents an object providing methods which are not\n * dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * **The individual methods describe the differences compared to the specs**.\n *\n * @class DOMImplementation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core\n * (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n * @constructs DOMImplementation\n */\nfunction DOMImplementation() {}\n\nDOMImplementation.prototype = {\n\t/**\n\t * Test if the DOM implementation implements a specific feature and version, as specified in\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.\n\t *\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given\n\t * feature is supported. The different implementations fairly diverged in what kind of\n\t * features were reported. The latest version of the spec settled to force this method to\n\t * always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated\n\t * It is deprecated and modern browsers return true in all cases.\n\t * @function DOMImplementation#hasFeature\n\t * @param {string} feature\n\t * The name of the feature to test.\n\t * @param {string} [version]\n\t * This is the version number of the feature to test.\n\t * @returns {boolean}\n\t * Always returns true.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core\n\t */\n\thasFeature: function (feature, version) {\n\t\treturn true;\n\t},\n\t/**\n\t * Creates a DOM Document object of the specified type with its document element. Note that\n\t * based on the {@link DocumentType}\n\t * given to create the document, the implementation may instantiate specialized\n\t * {@link Document} objects that support additional features than the \"Core\", such as \"HTML\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.\n\t * On the other hand, setting the {@link DocumentType} after the document was created makes\n\t * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,\n\t * such as createHTMLDocument\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},\n\t * can be used to obtain specific types of {@link Document} objects.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document`\n\t * instance (with it's `type` set to `'xml'`).\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @function DOMImplementation.createDocument\n\t * @param {string | null} namespaceURI\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}\n\t * of the document element to create or null.\n\t * @param {string | null} qualifiedName\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}\n\t * of the document element to be created or null.\n\t * @param {DocumentType | null} [doctype=null]\n\t * The type of document to be created or null. When doctype is not null, its\n\t * {@link Node#ownerDocument} attribute is set to the document being created. Default is\n\t * `null`\n\t * @returns {Document}\n\t * A new {@link Document} object with its document element. If the NamespaceURI,\n\t * qualifiedName, and doctype are null, the returned {@link Document} is empty with no\n\t * document element.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a\n\t * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI\n\t * is different from null, or if the qualifiedName has a prefix that is \"xml\" and the\n\t * namespaceURI is different from \"{@link http://www.w3.org/XML/1998/namespace}\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},\n\t * or if the DOM implementation does not support the \"XML\" feature but a non-null namespace\n\t * URI was provided, since namespaces were defined by XML.\n\t * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document\n\t * or was created from a different implementation.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see {@link #createHTMLDocument}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 2 Core (initial)\n\t */\n\tcreateDocument: function (namespaceURI, qualifiedName, doctype) {\n\t\tvar contentType = MIME_TYPE.XML_APPLICATION;\n\t\tif (namespaceURI === NAMESPACE.HTML) {\n\t\t\tcontentType = MIME_TYPE.XML_XHTML_APPLICATION;\n\t\t} else if (namespaceURI === NAMESPACE.SVG) {\n\t\t\tcontentType = MIME_TYPE.XML_SVG_IMAGE;\n\t\t}\n\t\tvar doc = new Document(PDC, { contentType: contentType });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype) {\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName) {\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Creates an empty DocumentType node. Entity declarations and notations are not made\n\t * available. Entity reference expansions and default attribute additions do not occur.\n\t *\n\t * **This behavior is slightly different from the one in the specs**:\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - `publicId` and `systemId` contain the raw data including any possible quotes,\n\t * so they can always be serialized back to the original value\n\t * - `internalSubset` contains the raw string between `[` and `]` if present,\n\t * but is not parsed or validated in any form.\n\t *\n\t * @function DOMImplementation#createDocumentType\n\t * @param {string} qualifiedName\n\t * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified\n\t * name} of the document type to be created.\n\t * @param {string} [publicId]\n\t * The external subset public identifier.\n\t * @param {string} [systemId]\n\t * The external subset system identifier.\n\t * @param {string} [internalSubset]\n\t * the internal subset or an empty string if it is not present\n\t * @returns {DocumentType}\n\t * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType\n\t * MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living\n\t * Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM\n\t * Level 2 Core\n\t * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset\n\t * @prettierignore\n\t */\n\tcreateDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {\n\t\tvalidateQualifiedName(qualifiedName);\n\t\tvar node = new DocumentType(PDC);\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\t\tnode.internalSubset = internalSubset || '';\n\t\tnode.childNodes = new NodeList();\n\n\t\treturn node;\n\t},\n\t/**\n\t * Returns an HTML document, that might already have a basic DOM structure.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are\n\t * omitted)\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @param {string | false} [title]\n\t * A string containing the title to give the new HTML document.\n\t * @returns {Document}\n\t * The HTML document.\n\t * @since WHATWG Living Standard.\n\t * @see {@link #createDocument}\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n\t * @see https://dom.spec.whatwg.org/#html-document\n\t */\n\tcreateHTMLDocument: function (title) {\n\t\tvar doc = new Document(PDC, { contentType: MIME_TYPE.HTML });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tif (title !== false) {\n\t\t\tdoc.doctype = this.createDocumentType('html');\n\t\t\tdoc.doctype.ownerDocument = doc;\n\t\t\tdoc.appendChild(doc.doctype);\n\t\t\tvar htmlNode = doc.createElement('html');\n\t\t\tdoc.appendChild(htmlNode);\n\t\t\tvar headNode = doc.createElement('head');\n\t\t\thtmlNode.appendChild(headNode);\n\t\t\tif (typeof title === 'string') {\n\t\t\t\tvar titleNode = doc.createElement('title');\n\t\t\t\ttitleNode.appendChild(doc.createTextNode(title));\n\t\t\t\theadNode.appendChild(titleNode);\n\t\t\t}\n\t\t\thtmlNode.appendChild(doc.createElement('body'));\n\t\t}\n\t\treturn doc;\n\t},\n};\n\n/**\n * The DOM Node interface is an abstract base class upon which many other DOM API objects are\n * based, thus letting those object types to be used similarly and often interchangeably. As an\n * abstract class, there is no such thing as a plain Node object. All objects that implement\n * Node functionality are based on one of its subclasses. Most notable are Document, Element,\n * and DocumentFragment.\n *\n * In addition, every kind of DOM node is represented by an interface based on Node. These\n * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are\n * all based on), and DocumentType.\n *\n * In some cases, a particular feature of the base Node interface may not apply to one of its\n * child interfaces; in that case, the inheriting node may return null or throw an exception,\n * depending on circumstances. For example, attempting to add children to a node type that\n * cannot have children will throw an exception.\n *\n * **This behavior is slightly different from the in the specs**:\n * - unimplemented interfaces: `EventTarget`\n *\n * @class\n * @abstract\n * @param {Symbol} symbol\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n * @see https://dom.spec.whatwg.org/#node\n * @prettierignore\n */\nfunction Node(symbol) {\n\tcheckSymbol(symbol);\n}\n\nNode.prototype = {\n\t/**\n\t * The first child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tfirstChild: null,\n\t/**\n\t * The last child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tlastChild: null,\n\t/**\n\t * The previous sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tpreviousSibling: null,\n\t/**\n\t * The next sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tnextSibling: null,\n\t/**\n\t * The parent node of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tparentNode: null,\n\t/**\n\t * The parent element of this node.\n\t *\n\t * @type {Element | null}\n\t */\n\tget parentElement() {\n\t\treturn this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;\n\t},\n\t/**\n\t * The child nodes of this node.\n\t *\n\t * @type {NodeList}\n\t */\n\tchildNodes: null,\n\t/**\n\t * The document object associated with this node.\n\t *\n\t * @type {Document | null}\n\t */\n\townerDocument: null,\n\t/**\n\t * The value of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnodeValue: null,\n\t/**\n\t * The namespace URI of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnamespaceURI: null,\n\t/**\n\t * The prefix of the namespace for this node.\n\t *\n\t * @type {string | null}\n\t */\n\tprefix: null,\n\t/**\n\t * The local part of the qualified name of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tlocalName: null,\n\t/**\n\t * The baseURI is currently always `about:blank`,\n\t * since that's what happens when you create a document from scratch.\n\t *\n\t * @type {'about:blank'}\n\t */\n\tbaseURI: 'about:blank',\n\t/**\n\t * Is true if this node is part of a document.\n\t *\n\t * @type {boolean}\n\t */\n\tget isConnected() {\n\t\tvar rootNode = this.getRootNode();\n\t\treturn rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;\n\t},\n\t/**\n\t * Checks whether `other` is an inclusive descendant of this node.\n\t *\n\t * @param {Node | null | undefined} other\n\t * The node to check.\n\t * @returns {boolean}\n\t * True if `other` is an inclusive descendant of this node; false otherwise.\n\t * @see https://dom.spec.whatwg.org/#dom-node-contains\n\t */\n\tcontains: function (other) {\n\t\tif (!other) return false;\n\t\tvar parent = other;\n\t\tdo {\n\t\t\tif (this === parent) return true;\n\t\t\tparent = other.parentNode;\n\t\t} while (parent);\n\t\treturn false;\n\t},\n\t/**\n\t * @typedef GetRootNodeOptions\n\t * @property {boolean} [composed=false]\n\t */\n\t/**\n\t * Searches for the root node of this node.\n\t *\n\t * **This behavior is slightly different from the in the specs**:\n\t * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.\n\t *\n\t * @param {GetRootNodeOptions} [options]\n\t * @returns {Node}\n\t * Root node.\n\t * @see https://dom.spec.whatwg.org/#dom-node-getrootnode\n\t * @see https://dom.spec.whatwg.org/#concept-shadow-including-root\n\t */\n\tgetRootNode: function (options) {\n\t\tvar parent = this;\n\t\tdo {\n\t\t\tif (!parent.parentNode) {\n\t\t\t\treturn parent;\n\t\t\t}\n\t\t\tparent = parent.parentNode;\n\t\t} while (parent);\n\t},\n\t/**\n\t * Checks whether the given node is equal to this node.\n\t *\n\t * @param {Node} [otherNode]\n\t * @see https://dom.spec.whatwg.org/#concept-node-equals\n\t */\n\tisEqualNode: function (otherNode) {\n\t\tif (!otherNode) return false;\n\n\t\tif (this.nodeType !== otherNode.nodeType) return false;\n\n\t\tswitch (this.nodeType) {\n\t\t\tcase this.DOCUMENT_TYPE_NODE:\n\t\t\t\tif (this.name !== otherNode.name) return false;\n\t\t\t\tif (this.publicId !== otherNode.publicId) return false;\n\t\t\t\tif (this.systemId !== otherNode.systemId) return false;\n\t\t\t\tbreak;\n\t\t\tcase this.ELEMENT_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.prefix !== otherNode.prefix) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.attributes.length !== otherNode.attributes.length) return false;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attr = this.attributes.item(i);\n\t\t\t\t\tif (!attr.isEqualNode(otherNode.getAttributeNodeNS(attr.namespaceURI, attr.localName))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.ATTRIBUTE_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.value !== otherNode.value) return false;\n\n\t\t\t\tbreak;\n\t\t\tcase this.PROCESSING_INSTRUCTION_NODE:\n\t\t\t\tif (this.target !== otherNode.target || this.data !== otherNode.data) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.TEXT_NODE:\n\t\t\tcase this.COMMENT_NODE:\n\t\t\t\tif (this.data !== otherNode.data) return false;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (this.childNodes.length !== otherNode.childNodes.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < this.childNodes.length; i++) {\n\t\t\tif (!this.childNodes[i].isEqualNode(otherNode.childNodes[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n\t/**\n\t * Checks whether or not the given node is this node.\n\t *\n\t * @param {Node} [otherNode]\n\t */\n\tisSameNode: function (otherNode) {\n\t\treturn this === otherNode;\n\t},\n\t/**\n\t * Inserts a node before a reference node as a child of this node.\n\t *\n\t * @param {Node} newChild\n\t * The new child node to be inserted.\n\t * @param {Node | null} refChild\n\t * The reference node before which newChild will be inserted.\n\t * @returns {Node}\n\t * The new child node successfully inserted.\n\t * @throws {DOMException}\n\t * Throws a DOMException if inserting the node would result in a DOM tree that is not\n\t * well-formed, or if `child` is provided but is not a child of `parent`.\n\t * See {@link _insertBefore} for more details.\n\t * @since Modified in DOM L2\n\t */\n\tinsertBefore: function (newChild, refChild) {\n\t\treturn _insertBefore(this, newChild, refChild);\n\t},\n\t/**\n\t * Replaces an old child node with a new child node within this node.\n\t *\n\t * @param {Node} newChild\n\t * The new node that is to replace the old node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @param {Node} oldChild\n\t * The existing child node to be replaced.\n\t * @returns {Node}\n\t * Returns the replaced child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if replacing the node would result in a DOM tree that is not\n\t * well-formed, or if `oldChild` is not a child of `this`.\n\t * This can also occur if the pre-replacement validity assertion fails.\n\t * See {@link _insertBefore}, {@link Node.removeChild}, and\n\t * {@link assertPreReplacementValidityInDocument} for more details.\n\t * @see https://dom.spec.whatwg.org/#concept-node-replace\n\t */\n\treplaceChild: function (newChild, oldChild) {\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\t/**\n\t * Removes an existing child node from this node.\n\t *\n\t * @param {Node} oldChild\n\t * The child node to be removed.\n\t * @returns {Node}\n\t * Returns the removed child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if `oldChild` is not a child of `this`.\n\t * See {@link _removeChild} for more details.\n\t */\n\tremoveChild: function (oldChild) {\n\t\treturn _removeChild(this, oldChild);\n\t},\n\t/**\n\t * Appends a child node to this node.\n\t *\n\t * @param {Node} newChild\n\t * The child node to be appended to this node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @returns {Node}\n\t * Returns the appended child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if appending the node would result in a DOM tree that is not\n\t * well-formed, or if `newChild` is not a valid Node.\n\t * See {@link insertBefore} for more details.\n\t */\n\tappendChild: function (newChild) {\n\t\treturn this.insertBefore(newChild, null);\n\t},\n\t/**\n\t * Determines whether this node has any child nodes.\n\t *\n\t * @returns {boolean}\n\t * Returns true if this node has any child nodes, and false otherwise.\n\t */\n\thasChildNodes: function () {\n\t\treturn this.firstChild != null;\n\t},\n\t/**\n\t * Creates a copy of the calling node.\n\t *\n\t * @param {boolean} deep\n\t * If true, the contents of the node are recursively copied.\n\t * If false, only the node itself (and its attributes, if it is an element) are copied.\n\t * @returns {Node}\n\t * Returns the newly created copy of the node.\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within {@link Element#setAttributeNode} or\n\t * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their\n\t * specific constraints.\n\t * @see {@link cloneNode}\n\t */\n\tcloneNode: function (deep) {\n\t\treturn cloneNode(this.ownerDocument || this, this, deep);\n\t},\n\t/**\n\t * Puts the specified node and all of its subtree into a \"normalized\" form. In a normalized\n\t * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.\n\t *\n\t * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`\n\t * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text\n\t * nodes.\n\t *\n\t * This method operates recursively, so it also normalizes any and all descendent nodes within\n\t * the subtree.\n\t *\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within removeChild or appendData (which are\n\t * potentially invoked in this method) do not meet their specific constraints.\n\t * @since Modified in DOM Level 2\n\t * @see {@link Node.removeChild}\n\t * @see {@link CharacterData.appendData}\n\t */\n\tnormalize: function () {\n\t\tvar child = this.firstChild;\n\t\twhile (child) {\n\t\t\tvar next = child.nextSibling;\n\t\t\tif (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t} else {\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n\t/**\n\t * Checks whether the DOM implementation implements a specific feature and its version.\n\t *\n\t * @deprecated\n\t * Since `DOMImplementation.hasFeature` is deprecated and always returns true.\n\t * @param {string} feature\n\t * The package name of the feature to test. This is the same name that can be passed to the\n\t * method `hasFeature` on `DOMImplementation`.\n\t * @param {string} version\n\t * This is the version number of the package name to test.\n\t * @returns {boolean}\n\t * Returns true in all cases in the current implementation.\n\t * @since Introduced in DOM Level 2\n\t * @see {@link DOMImplementation.hasFeature}\n\t */\n\tisSupported: function (feature, version) {\n\t\treturn this.ownerDocument.implementation.hasFeature(feature, version);\n\t},\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI for which to find the associated prefix.\n\t * @returns {string | null}\n\t * The associated prefix, if found; otherwise, null.\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t * @prettierignore\n\t */\n\tlookupPrefix: function (namespaceURI) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tfor (var n in map) {\n\t\t\t\t\tif (hasOwn(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * This function is used to look up the namespace URI associated with the given prefix,\n\t * starting from this node.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} prefix\n\t * The prefix for which to find the associated namespace URI.\n\t * @returns {string | null}\n\t * The associated namespace URI, if found; otherwise, null.\n\t * @since DOM Level 3\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI\n\t * @prettierignore\n\t */\n\tlookupNamespaceURI: function (prefix) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tif (hasOwn(map, prefix)) {\n\t\t\t\t\treturn map[prefix];\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * Determines whether the given namespace URI is the default namespace.\n\t *\n\t * The function works by looking up the prefix associated with the given namespace URI. If no\n\t * prefix is found (i.e., the namespace URI is not registered in the namespace map of this\n\t * node or any of its ancestors), it returns `true`, implying the namespace URI is considered\n\t * the default.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI to be checked.\n\t * @returns {boolean}\n\t * Returns true if the given namespace URI is the default namespace, false otherwise.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace\n\t * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace\n\t * @prettierignore\n\t */\n\tisDefaultNamespace: function (namespaceURI) {\n\t\tvar prefix = this.lookupPrefix(namespaceURI);\n\t\treturn prefix == null;\n\t},\n\t/**\n\t * Compares the reference node with a node with regard to their position in the document and\n\t * according to the document order.\n\t *\n\t * @param {Node} other\n\t * The node to compare the reference node to.\n\t * @returns {number}\n\t * Returns how the node is positioned relatively to the reference node according to the\n\t * bitmask. 0 if reference node and given node are the same.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare\n\t * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition\n\t */\n\tcompareDocumentPosition: function (other) {\n\t\tif (this === other) return 0;\n\t\tvar node1 = other;\n\t\tvar node2 = this;\n\t\tvar attr1 = null;\n\t\tvar attr2 = null;\n\t\tif (node1 instanceof Attr) {\n\t\t\tattr1 = node1;\n\t\t\tnode1 = attr1.ownerElement;\n\t\t}\n\t\tif (node2 instanceof Attr) {\n\t\t\tattr2 = node2;\n\t\t\tnode2 = attr2.ownerElement;\n\t\t\tif (attr1 && node1 && node2 === node1) {\n\t\t\t\tfor (var i = 0, attr; (attr = node2.attributes[i]); i++) {\n\t\t\t\t\tif (attr === attr1)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t\t\tif (attr === attr2)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {\n\t\t\treturn (\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_DISCONNECTED +\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +\n\t\t\t\t(docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)\n\t\t\t\t\t? DocumentPosition.DOCUMENT_POSITION_FOLLOWING\n\t\t\t\t\t: DocumentPosition.DOCUMENT_POSITION_PRECEDING)\n\t\t\t);\n\t\t}\n\t\tif (attr2 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\tif (attr1 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t}\n\n\t\tvar chain1 = [];\n\t\tvar ancestor1 = node1.parentNode;\n\t\twhile (ancestor1) {\n\t\t\tif (!attr2 && ancestor1 === node2) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t}\n\t\t\tchain1.push(ancestor1);\n\t\t\tancestor1 = ancestor1.parentNode;\n\t\t}\n\t\tchain1.reverse();\n\n\t\tvar chain2 = [];\n\t\tvar ancestor2 = node2.parentNode;\n\t\twhile (ancestor2) {\n\t\t\tif (!attr1 && ancestor2 === node1) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t}\n\t\t\tchain2.push(ancestor2);\n\t\t\tancestor2 = ancestor2.parentNode;\n\t\t}\n\t\tchain2.reverse();\n\n\t\tvar ca = commonAncestor(chain1, chain2);\n\t\tfor (var n in ca.childNodes) {\n\t\t\tvar child = ca.childNodes[n];\n\t\t\tif (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\tif (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\treturn 0;\n\t},\n};\n\n/**\n * Encodes special XML characters to their corresponding entities.\n *\n * @param {string} c\n * The character to be encoded.\n * @returns {string}\n * The encoded character.\n * @private\n */\nfunction _xmlEncoder(c) {\n\treturn (\n\t\t(c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '\"' && '"') || '&#' + c.charCodeAt() + ';'\n\t);\n}\n\ncopy(NodeType, Node);\ncopy(NodeType, Node.prototype);\ncopy(DocumentPosition, Node);\ncopy(DocumentPosition, Node.prototype);\n\n/**\n * @param callback\n * Return true for continue,false for break.\n * @returns\n * boolean true: break visit;\n */\nfunction _visitNode(node, callback) {\n\tif (callback(node)) {\n\t\treturn true;\n\t}\n\tif ((node = node.firstChild)) {\n\t\tdo {\n\t\t\tif (_visitNode(node, callback)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} while ((node = node.nextSibling));\n\t}\n}\n\n/**\n * @typedef DocumentOptions\n * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]\n */\n/**\n * The Document interface describes the common properties and methods for any kind of document.\n *\n * It should usually be created using `new DOMImplementation().createDocument(...)`\n * or `new DOMImplementation().createHTMLDocument(...)`.\n *\n * The constructor is considered a private API and offers to initially set the `contentType`\n * property via it's options parameter.\n *\n * @class\n * @param {Symbol} symbol\n * @param {DocumentOptions} [options]\n * @augments Node\n * @private\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document\n * @see https://dom.spec.whatwg.org/#interface-document\n */\nfunction Document(symbol, options) {\n\tcheckSymbol(symbol);\n\n\tvar opt = options || {};\n\tthis.ownerDocument = this;\n\t/**\n\t * The mime type of the document is determined at creation time and can not be modified.\n\t *\n\t * @type {string}\n\t * @see https://dom.spec.whatwg.org/#concept-document-content-type\n\t * @see {@link DOMImplementation}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;\n\t/**\n\t * @type {'html' | 'xml'}\n\t * @see https://dom.spec.whatwg.org/#concept-document-type\n\t * @see {@link DOMImplementation}\n\t * @readonly\n\t */\n\tthis.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';\n}\n\n/**\n * Updates the namespace mapping of an element when a new attribute is added.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element to which the attribute is being added.\n * @param {Attr} newAttr\n * The new attribute being added.\n * @private\n */\nfunction _onAddAttribute(doc, el, newAttr) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;\n\t}\n}\n\n/**\n * Updates the namespace mapping of an element when an attribute is removed.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element from which the attribute is being removed.\n * @param {Attr} newAttr\n * The attribute being removed.\n * @param {boolean} remove\n * Indicates whether the attribute is to be removed.\n * @private\n */\nfunction _onRemoveAttribute(doc, el, newAttr, remove) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix ? newAttr.localName : ''];\n\t}\n}\n\n/**\n * Updates `parent.childNodes`, adjusting the indexed items and its `length`.\n * If `newChild` is provided and has no nextSibling, it will be appended.\n * Otherwise, it's assumed that an item has been removed or inserted,\n * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.\n *\n * @param {Document} doc\n * The parent document of `el`.\n * @param {Node} parent\n * The parent node whose childNodes list needs to be updated.\n * @param {Node} [newChild]\n * The new child node to be appended. If not provided, the function assumes a node has been\n * removed.\n * @private\n */\nfunction _onUpdateChild(doc, parent, newChild) {\n\tif (doc && doc._inc) {\n\t\tdoc._inc++;\n\t\tvar childNodes = parent.childNodes;\n\t\t// assumes nextSibling and previousSibling were already configured upfront\n\t\tif (newChild && !newChild.nextSibling) {\n\t\t\t// if an item has been appended, we only need to update the last index and the length\n\t\t\tchildNodes[childNodes.length++] = newChild;\n\t\t} else {\n\t\t\t// otherwise we need to reindex all items,\n\t\t\t// which can take a while when processing nodes with a lot of children\n\t\t\tvar child = parent.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile (child) {\n\t\t\t\tchildNodes[i++] = child;\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\tchildNodes.length = i;\n\t\t\tdelete childNodes[childNodes.length];\n\t\t}\n\t}\n}\n\n/**\n * Removes the connections between `parentNode` and `child`\n * and any existing `child.previousSibling` or `child.nextSibling`.\n *\n * @param {Node} parentNode\n * The parent node from which the child node is to be removed.\n * @param {Node} child\n * The child node to be removed from the parentNode.\n * @returns {Node}\n * Returns the child node that was removed.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.\n * @private\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n */\nfunction _removeChild(parentNode, child) {\n\tif (parentNode !== child.parentNode) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, \"child's parent is not parent\");\n\t}\n\tvar oldPreviousSibling = child.previousSibling;\n\tvar oldNextSibling = child.nextSibling;\n\tif (oldPreviousSibling) {\n\t\toldPreviousSibling.nextSibling = oldNextSibling;\n\t} else {\n\t\tparentNode.firstChild = oldNextSibling;\n\t}\n\tif (oldNextSibling) {\n\t\toldNextSibling.previousSibling = oldPreviousSibling;\n\t} else {\n\t\tparentNode.lastChild = oldPreviousSibling;\n\t}\n\t_onUpdateChild(parentNode.ownerDocument, parentNode);\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.CDATA_SECTION_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_TYPE_NODE ||\n\t\t\tnode.nodeType === Node.ELEMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||\n\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Asserts pre-insertion validity of a node into a parent before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Node} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | null} child\n * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,\n * DocumentFragment, or Element node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive\n * ancestor of `parent`. (Currently not implemented)\n * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not\n * `parent`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,\n * DocumentType, Element, or CharacterData node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is\n * a document, or if `node` is a doctype and `parent` is not a document.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.HIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * Asserts pre-insertion validity of a node into a document before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * The node that should become the `nextSibling` of `node`. If undefined, no sibling is\n * considered.\n * @returns {Node}\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than\n * one element child or has a Text node child.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one\n * element child and either `parent` has an element child, `child` is a doctype, or `child` is\n * non-null and a doctype is following `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an\n * element child, `child` is a doctype, or `child` is non-null and a doctype is following\n * `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a\n * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null\n * and `parent` has an element child.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws {DOMException}\n * For several node combinations that would create a DOM that is not well-formed.\n * @throws {DOMException}\n * If `child` is provided but is not a child of `parent`.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * Inserts a node into a parent node before a child node.\n *\n * @param {Node} parent\n * The parent node to insert the node into.\n * @param {Node} node\n * The node to insert into the parent.\n * @param {Node | null} child\n * The node that should become the next sibling of the node.\n * If null, the function inserts the node at the end of the children of the parent node.\n * @param {Function} [_inDocumentAssertion]\n * An optional function to check pre-insertion validity if parent is a document node.\n * Defaults to {@link assertPreInsertionValidityInDocument}\n * @returns {Node}\n * Returns the inserted node.\n * @throws {DOMException}\n * Throws a DOMException if inserting the node would result in a DOM tree that is not\n * well-formed. See {@link assertPreInsertionValidity1to5},\n * {@link assertPreInsertionValidityInDocument}.\n * @throws {DOMException}\n * Throws a DOMException if child is provided but is not a child of the parent. See\n * {@link Node.removeChild}\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif (cp) {\n\t\tcp.removeChild(node); //remove and update\n\t}\n\tif (node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t} else {\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\tif (pre) {\n\t\tpre.nextSibling = newFirst;\n\t} else {\n\t\tparent.firstChild = newFirst;\n\t}\n\tif (child == null) {\n\t\tparent.lastChild = newLast;\n\t} else {\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo {\n\t\tnewFirst.parentNode = parent;\n\t} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));\n\t_onUpdateChild(parent.ownerDocument || parent, parent, node);\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\n\treturn node;\n}\n\nDocument.prototype = {\n\t/**\n\t * The implementation that created this document.\n\t *\n\t * @type DOMImplementation\n\t * @readonly\n\t */\n\timplementation: null,\n\tnodeName: '#document',\n\tnodeType: DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @type DocumentType\n\t * @readonly\n\t */\n\tdoctype: null,\n\tdocumentElement: null,\n\t_inc: 1,\n\n\tinsertBefore: function (newChild, refChild) {\n\t\t//raises\n\t\tif (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child, refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild: function (oldChild) {\n\t\tvar removed = _removeChild(this, oldChild);\n\t\tif (removed === this.documentElement) {\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn removed;\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode: function (importedNode, deep) {\n\t\treturn importNode(this, importedNode, deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById: function (id) {\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement, function (node) {\n\t\t\tif (node.nodeType == ELEMENT_NODE) {\n\t\t\t\tif (node.getAttribute('id') == id) {\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * Creates a new `Element` that is owned by this `Document`.\n\t * In HTML Documents `localName` is the lower cased `tagName`,\n\t * otherwise no transformation is being applied.\n\t * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t * - There is no interface `HTMLElement`, it is always an `Element`.\n\t * - There is no support for a second argument to indicate using custom elements.\n\t *\n\t * @param {string} tagName\n\t * @returns {Element}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement\n\t * @see https://dom.spec.whatwg.org/#dom-document-createelement\n\t * @see https://dom.spec.whatwg.org/#concept-create-element\n\t */\n\tcreateElement: function (tagName) {\n\t\tvar node = new Element(PDC);\n\t\tnode.ownerDocument = this;\n\t\tif (this.type === 'html') {\n\t\t\ttagName = tagName.toLowerCase();\n\t\t}\n\t\tif (hasDefaultHTMLNamespace(this.contentType)) {\n\t\t\tnode.namespaceURI = NAMESPACE.HTML;\n\t\t}\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t/**\n\t * @returns {DocumentFragment}\n\t */\n\tcreateDocumentFragment: function () {\n\t\tvar node = new DocumentFragment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Text}\n\t */\n\tcreateTextNode: function (data) {\n\t\tvar node = new Text(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Comment}\n\t */\n\tcreateComment: function (data) {\n\t\tvar node = new Comment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {CDATASection}\n\t */\n\tcreateCDATASection: function (data) {\n\t\tvar node = new CDATASection(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} target\n\t * @param {string} data\n\t * @returns {ProcessingInstruction}\n\t */\n\tcreateProcessingInstruction: function (target, data) {\n\t\tvar node = new ProcessingInstruction(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an `Attr` node that is owned by this document.\n\t * In HTML Documents `localName` is the lower cased `name`,\n\t * otherwise no transformation is being applied.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t *\n\t * @param {string} name\n\t * @returns {Attr}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute\n\t * @see https://dom.spec.whatwg.org/#dom-document-createattribute\n\t */\n\tcreateAttribute: function (name) {\n\t\tif (!g.QName_exact.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this._createAttribute(name);\n\t},\n\t_createAttribute: function (name) {\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.name = name;\n\t\tnode.nodeName = name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an EntityReference object.\n\t * The current implementation does not fill the `childNodes` with those of the corresponding\n\t * `Entity`\n\t *\n\t * @deprecated\n\t * In DOM Level 4.\n\t * @param {string} name\n\t * The name of the entity to reference. No namespace well-formedness checks are performed.\n\t * @returns {EntityReference}\n\t * @throws {DOMException}\n\t * With code `INVALID_CHARACTER_ERR` when `name` is not valid.\n\t * @throws {DOMException}\n\t * with code `NOT_SUPPORTED_ERR` when the document is of type `html`\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE\n\t */\n\tcreateEntityReference: function (name) {\n\t\tif (!g.Name.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tthrow new DOMException('document is an html document', DOMExceptionName.NotSupportedError);\n\t\t}\n\n\t\tvar node = new EntityReference(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Element}\n\t */\n\tcreateElementNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Element(PDC);\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Attr}\n\t */\n\tcreateAttributeNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.specified = true;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\treturn node;\n\t},\n};\n_extends(Document, Node);\n\nfunction Element(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis._nsMap = Object.create(null);\n}\nElement.prototype = {\n\tnodeType: ELEMENT_NODE,\n\t/**\n\t * The attributes of this element.\n\t *\n\t * @type {NamedNodeMap | null}\n\t */\n\tattributes: null,\n\tgetQualifiedName: function () {\n\t\treturn this.prefix ? this.prefix + ':' + this.localName : this.localName;\n\t},\n\t_isInHTMLDocumentAndNamespace: function () {\n\t\treturn this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;\n\t},\n\t/**\n\t * Implementaton of Level2 Core function hasAttributes.\n\t *\n\t * @returns {boolean}\n\t * True if attribute list is not empty.\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs\n\t */\n\thasAttributes: function () {\n\t\treturn !!(this.attributes && this.attributes.length);\n\t},\n\thasAttribute: function (name) {\n\t\treturn !!this.getAttributeNode(name);\n\t},\n\t/**\n\t * Returns element’s first attribute whose qualified name is `name`, and `null`\n\t * if there is no such attribute.\n\t *\n\t * @param {string} name\n\t * @returns {string | null}\n\t */\n\tgetAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr ? attr.value : null;\n\t},\n\tgetAttributeNode: function (name) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\t/**\n\t * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.\n\t *\n\t * @param {string} name\n\t * @param {string} value\n\t */\n\tsetAttribute: function (name, value) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\tvar attr = this.getAttributeNode(name);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument._createAttribute(name);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tremoveAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\tsetAttributeNode: function (newAttr) {\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS: function (newAttr) {\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode: function (oldAttr) {\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS: function (namespaceURI, localName) {\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS: function (namespaceURI, localName) {\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName) != null;\n\t},\n\t/**\n\t * Returns element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName`,\n\t * or `null` if there is no such attribute.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} localName\n\t * @returns {string | null}\n\t */\n\tgetAttributeNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr ? attr.value : null;\n\t},\n\t/**\n\t * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName` to value.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {string} value\n\t * @see https://dom.spec.whatwg.org/#dom-element-setattributens\n\t */\n\tsetAttributeNS: function (namespaceURI, qualifiedName, value) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar localName = validated[2];\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tgetAttributeNodeNS: function (namespaceURI, localName) {\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classNames` is an empty string or only contains HTML white space\n\t * characters.\n\t *\n\t * Warning: This returns a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames\n\t * Is a string representing the class name(s) to match; multiple class names are separated by\n\t * (ASCII-)whitespace.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function (classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames);\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base, function (node) {\n\t\t\t\t\tif (node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class');\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames);\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of elements with the given qualifiedName.\n\t * Searching for all descendants can be done by passing `*` as `qualifiedName`.\n\t *\n\t * All descendants of the specified element are searched, but not the element itself.\n\t * The returned list is live, which means it updates itself with the DOM tree automatically.\n\t * Therefore, there is no need to call `Element.getElementsByTagName()`\n\t * with the same element and arguments repeatedly if the DOM changes in between calls.\n\t *\n\t * When called on an HTML element in an HTML document,\n\t * `getElementsByTagName` lower-cases the argument before searching for it.\n\t * This is undesirable when trying to match camel-cased SVG elements (such as\n\t * ``) in an HTML document.\n\t * Instead, use `Element.getElementsByTagNameNS()`,\n\t * which preserves the capitalization of the tag name.\n\t *\n\t * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,\n\t * except that it only searches for elements that are descendants of the specified element.\n\t *\n\t * @param {string} qualifiedName\n\t * @returns {LiveNodeList}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname\n\t */\n\tgetElementsByTagName: function (qualifiedName) {\n\t\tvar isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';\n\t\tvar lowerQualifiedName = qualifiedName.toLowerCase();\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (node === base || node.nodeType !== ELEMENT_NODE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (qualifiedName === '*') {\n\t\t\t\t\tls.push(node);\n\t\t\t\t} else {\n\t\t\t\t\tvar nodeQualifiedName = node.getQualifiedName();\n\t\t\t\t\tvar matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;\n\t\t\t\t\tif (nodeQualifiedName === matchingQName) {\n\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS: function (namespaceURI, localName) {\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== base &&\n\t\t\t\t\tnode.nodeType === ELEMENT_NODE &&\n\t\t\t\t\t(namespaceURI === '*' || node.namespaceURI === namespaceURI) &&\n\t\t\t\t\t(localName === '*' || node.localName == localName)\n\t\t\t\t) {\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n};\nDocument.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n_extends(Element, Node);\nfunction Attr(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis.namespaceURI = null;\n\tthis.prefix = null;\n\tthis.ownerElement = null;\n}\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr, Node);\n\nfunction CharacterData(symbol) {\n\tcheckSymbol(symbol);\n}\nCharacterData.prototype = {\n\tdata: '',\n\tsubstringData: function (offset, count) {\n\t\treturn this.data.substring(offset, offset + count);\n\t},\n\tappendData: function (text) {\n\t\ttext = this.data + text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function (offset, text) {\n\t\tthis.replaceData(offset, 0, text);\n\t},\n\tdeleteData: function (offset, count) {\n\t\tthis.replaceData(offset, count, '');\n\t},\n\treplaceData: function (offset, count, text) {\n\t\tvar start = this.data.substring(0, offset);\n\t\tvar end = this.data.substring(offset + count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n};\n_extends(CharacterData, Node);\nfunction Text(symbol) {\n\tcheckSymbol(symbol);\n}\nText.prototype = {\n\tnodeName: '#text',\n\tnodeType: TEXT_NODE,\n\tsplitText: function (offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif (this.parentNode) {\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t},\n};\n_extends(Text, CharacterData);\nfunction Comment(symbol) {\n\tcheckSymbol(symbol);\n}\nComment.prototype = {\n\tnodeName: '#comment',\n\tnodeType: COMMENT_NODE,\n};\n_extends(Comment, CharacterData);\n\nfunction CDATASection(symbol) {\n\tcheckSymbol(symbol);\n}\nCDATASection.prototype = {\n\tnodeName: '#cdata-section',\n\tnodeType: CDATA_SECTION_NODE,\n};\n_extends(CDATASection, Text);\n\nfunction DocumentType(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType, Node);\n\nfunction Notation(symbol) {\n\tcheckSymbol(symbol);\n}\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation, Node);\n\nfunction Entity(symbol) {\n\tcheckSymbol(symbol);\n}\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity, Node);\n\nfunction EntityReference(symbol) {\n\tcheckSymbol(symbol);\n}\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference, Node);\n\nfunction DocumentFragment(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentFragment.prototype.nodeName = '#document-fragment';\nDocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment, Node);\n\nfunction ProcessingInstruction(symbol) {\n\tcheckSymbol(symbol);\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction, CharacterData);\nfunction XMLSerializer() {}\nXMLSerializer.prototype.serializeToString = function (node, nodeFilter) {\n\treturn nodeSerializeToString.call(node, nodeFilter);\n};\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(nodeFilter) {\n\tvar buf = [];\n\tvar refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif (uri && prefix == null) {\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif (prefix == null) {\n\t\t\tvar visibleNamespaces = [\n\t\t\t\t{ namespace: uri, prefix: null },\n\t\t\t\t//{namespace:uri,prefix:''}\n\t\t\t];\n\t\t}\n\t}\n\tserializeToString(this, buf, nodeFilter, visibleNamespaces);\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length;\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Literal whitespace other than space that appear in attribute values are serialized as\n * their entity references, so they will be preserved.\n * (In contrast to whitespace literals in the input which are normalized to spaces).\n *\n * Well-formed constraint: No < in Attribute Values:\n * > The replacement text of any entity referred to directly or indirectly\n * > in an attribute value must not contain a <.\n *\n * @see https://www.w3.org/TR/xml11/#CleanAttrVals\n * @see https://www.w3.org/TR/xml11/#NT-AttValue\n * @see https://www.w3.org/TR/xml11/#AVNormalize\n * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes\n * @prettierignore\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<>&\"\\t\\n\\r]/g, _xmlEncoder), '\"');\n}\n\nfunction serializeToString(node, buf, nodeFilter, visibleNamespaces) {\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\tvar doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;\n\tvar isHTML = doc.type === 'html';\n\n\tif (nodeFilter) {\n\t\tnode = nodeFilter(node);\n\t\tif (node) {\n\t\t\tif (typeof node == 'string') {\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tvar attrs = node.attributes;\n\t\t\tvar len = attrs.length;\n\t\t\tvar child = node.firstChild;\n\t\t\tvar nodeName = node.tagName;\n\n\t\t\tvar prefixedNodeName = nodeName;\n\t\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\t\tvar defaultNS;\n\t\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\t\tdefaultNS = attrs.item(ai).value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultNS) {\n\t\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tdefaultNS = namespace.namespace;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuf.push('<', prefixedNodeName);\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\t// add namespaces for attributes\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (attr.prefix == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({\n\t\t\t\t\t\tprefix: attr.localName,\n\t\t\t\t\t\tnamespace: attr.value,\n\t\t\t\t\t});\n\t\t\t\t} else if (attr.nodeName == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({ prefix: '', namespace: attr.value });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {\n\t\t\t\t\tvar prefix = attr.prefix || '';\n\t\t\t\t\tvar uri = attr.namespaceURI;\n\t\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t\t}\n\t\t\t\tserializeToString(attr, buf, nodeFilter, visibleNamespaces);\n\t\t\t}\n\n\t\t\t// add namespace for current node\n\t\t\tif (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {\n\t\t\t\tvar prefix = node.prefix || '';\n\t\t\t\tvar uri = node.namespaceURI;\n\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t}\n\t\t\t// in XML elements can be closed when they have no children\n\t\t\tvar canCloseTag = !child;\n\t\t\tif (canCloseTag && (isHTML || node.namespaceURI === NAMESPACE.HTML)) {\n\t\t\t\t// in HTML (doc or ns) only void elements can be closed right away\n\t\t\t\tcanCloseTag = isHTMLVoidElement(nodeName);\n\t\t\t}\n\t\t\tif (canCloseTag) {\n\t\t\t\tbuf.push('/>');\n\t\t\t} else {\n\t\t\t\tbuf.push('>');\n\t\t\t\t//if is cdata child node\n\t\t\t\tif (isHTML && isHTMLRawTextElement(nodeName)) {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tif (child.data) {\n\t\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuf.push('');\n\t\t\t}\n\t\t\t// remove added visible namespaces\n\t\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\t\treturn;\n\t\tcase DOCUMENT_NODE:\n\t\tcase DOCUMENT_FRAGMENT_NODE:\n\t\t\tvar child = node.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\treturn;\n\t\tcase ATTRIBUTE_NODE:\n\t\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\t\tcase TEXT_NODE:\n\t\t\t/*\n\t\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t\t * except when used as markup delimiters, or within a comment, a processing instruction,\n\t\t\t * or a CDATA section.\n\t\t\t * If they are needed elsewhere, they must be escaped using either numeric character\n\t\t\t * references or the strings `&` and `<` respectively.\n\t\t\t * The right angle bracket (>) may be represented using the string \" > \",\n\t\t\t * and must, for compatibility, be escaped using either `>`,\n\t\t\t * or a character reference when it appears in the string `]]>` in content,\n\t\t\t * when that string is not marking the end of a CDATA section.\n\t\t\t *\n\t\t\t * In the content of elements, character data is any string of characters which does not\n\t\t\t * contain the start-delimiter of any markup and does not include the CDATA-section-close\n\t\t\t * delimiter, `]]>`.\n\t\t\t *\n\t\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t\t * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node\n\t\t\t */\n\t\t\treturn buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));\n\t\tcase CDATA_SECTION_NODE:\n\t\t\treturn buf.push(g.CDATA_START, node.data, g.CDATA_END);\n\t\tcase COMMENT_NODE:\n\t\t\treturn buf.push(g.COMMENT_START, node.data, g.COMMENT_END);\n\t\tcase DOCUMENT_TYPE_NODE:\n\t\t\tvar pubid = node.publicId;\n\t\t\tvar sysid = node.systemId;\n\t\t\tbuf.push(g.DOCTYPE_DECL_START, ' ', node.name);\n\t\t\tif (pubid) {\n\t\t\t\tbuf.push(' ', g.PUBLIC, ' ', pubid);\n\t\t\t\tif (sysid && sysid !== '.') {\n\t\t\t\t\tbuf.push(' ', sysid);\n\t\t\t\t}\n\t\t\t} else if (sysid && sysid !== '.') {\n\t\t\t\tbuf.push(' ', g.SYSTEM, ' ', sysid);\n\t\t\t}\n\t\t\tif (node.internalSubset) {\n\t\t\t\tbuf.push(' [', node.internalSubset, ']');\n\t\t\t}\n\t\t\tbuf.push('>');\n\t\t\treturn;\n\t\tcase PROCESSING_INSTRUCTION_NODE:\n\t\t\treturn buf.push('');\n\t\tcase ENTITY_REFERENCE_NODE:\n\t\t\treturn buf.push('&', node.nodeName, ';');\n\t\t//case ENTITY_NODE:\n\t\t//case NOTATION_NODE:\n\t\tdefault:\n\t\t\tbuf.push('??', node.nodeName);\n\t}\n}\nfunction importNode(doc, node, deep) {\n\tvar node2;\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tnode2 = node.cloneNode(false);\n\t\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see {@link XML_ENTITIES}\n * @see {@link DOMParser.parseFromString}\n * @see {@link DOMImplementation.prototype.createHTMLDocument}\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)\n * Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML\n * Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML\n * Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated\n * Use `HTML_ENTITIES` instead.\n * @see {@link HTML_ENTITIES}\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar g = require('./grammar');\nvar errors = require('./errors');\n\nvar isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar hasOwn = conventions.hasOwn;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\nvar DOMException = errors.DOMException;\n\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0; //tag name offerring\nvar S_ATTR = 1; //attr name offerring\nvar S_ATTR_SPACE = 2; //attr name end and space offer\nvar S_EQ = 3; //=space?\nvar S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)\nvar S_ATTR_END = 5; //attr value end and no space(quot end)\nvar S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7; //closed el\n\nfunction XMLReader() {}\n\nXMLReader.prototype = {\n\tparse: function (source, defaultNSMap, entityMap) {\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap, (defaultNSMap = Object.create(null)));\n\t\tparse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t},\n};\n\n/**\n * Detecting everything that might be a reference,\n * including those without ending `;`, since those are allowed in HTML.\n * The entityReplacer takes care of verifying and transforming each occurrence,\n * and reports to the errorHandler on those that are not OK,\n * depending on the context.\n */\nvar ENTITY_REG = /&#?\\w+;?/g;\n\nfunction parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {\n\tvar isHTML = isHTMLMimeType(domBuilder.mimeType);\n\tif (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {\n\t\terrorHandler.warning('Unicode replacement character detected, source encoding issues?');\n\t}\n\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10),\n\t\t\t\tsurrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\n\tfunction entityReplacer(a) {\n\t\tvar complete = a[a.length - 1] === ';' ? a : a + ';';\n\t\tif (!isHTML && complete !== a) {\n\t\t\terrorHandler.error('EntityRef: expecting ;');\n\t\t\treturn a;\n\t\t}\n\t\tvar match = g.Reference.exec(complete);\n\t\tif (!match || match[0].length !== complete.length) {\n\t\t\terrorHandler.error('entity not matching Reference production: ' + a);\n\t\t\treturn a;\n\t\t}\n\t\tvar k = complete.slice(1, -1);\n\t\tif (hasOwn(entityMap, k)) {\n\t\t\treturn entityMap[k];\n\t\t} else if (k.charAt(0) === '#') {\n\t\t\treturn fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));\n\t\t} else {\n\t\t\terrorHandler.error('entity not found:' + a);\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tfunction appendText(end) {\n\t\t//has some bugs\n\t\tif (end > start) {\n\t\t\tvar xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);\n\t\t\tlocator && position(start);\n\t\t\tdomBuilder.characters(xt, 0, end - start);\n\t\t\tstart = end;\n\t\t}\n\t}\n\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /\\r\\n?|\\n|$/g;\n\tvar locator = domBuilder.locator;\n\n\tfunction position(p, m) {\n\t\twhile (p >= lineEnd && (m = linePattern.exec(source))) {\n\t\t\tlineStart = lineEnd;\n\t\t\tlineEnd = m.index + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t}\n\t\tlocator.columnNumber = p - lineStart + 1;\n\t}\n\n\tvar parseStack = [{ currentNSMap: defaultNSMapCopy }];\n\tvar unclosedTags = [];\n\tvar start = 0;\n\twhile (true) {\n\t\ttry {\n\t\t\tvar tagStart = source.indexOf('<', start);\n\t\t\tif (tagStart < 0) {\n\t\t\t\tif (!isHTML && unclosedTags.length > 0) {\n\t\t\t\t\treturn errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));\n\t\t\t\t}\n\t\t\t\tif (!source.substring(start).match(/^\\s*$/)) {\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t\t\t\t\tvar text = doc.createTextNode(source.substring(start));\n\t\t\t\t\tif (doc.documentElement) {\n\t\t\t\t\t\treturn errorHandler.error('Extra content at the end of the document');\n\t\t\t\t\t}\n\t\t\t\t\tdoc.appendChild(text);\n\t\t\t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (tagStart > start) {\n\t\t\t\tvar fromSource = source.substring(start, tagStart);\n\t\t\t\tif (!isHTML && unclosedTags.length === 0) {\n\t\t\t\t\tfromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');\n\t\t\t\t\tfromSource && errorHandler.error(\"Unexpected content outside root element: '\" + fromSource + \"'\");\n\t\t\t\t}\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch (source.charAt(tagStart + 1)) {\n\t\t\t\tcase '/':\n\t\t\t\t\tvar end = source.indexOf('>', tagStart + 2);\n\t\t\t\t\tvar tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);\n\t\t\t\t\tif (!tagNameRaw) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name missing');\n\t\t\t\t\t}\n\t\t\t\t\tvar tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);\n\t\t\t\t\tif (!tagNameMatch) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name contains invalid characters: \"' + tagNameRaw + '\"');\n\t\t\t\t\t}\n\t\t\t\t\tif (!domBuilder.currentElement && !domBuilder.doc.documentElement) {\n\t\t\t\t\t\t// not enough information to provide a helpful error message,\n\t\t\t\t\t\t// but parsing will throw since there is no root element\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar currentTagName =\n\t\t\t\t\t\tunclosedTags[unclosedTags.length - 1] ||\n\t\t\t\t\t\tdomBuilder.currentElement.tagName ||\n\t\t\t\t\t\tdomBuilder.doc.documentElement.tagName ||\n\t\t\t\t\t\t'';\n\t\t\t\t\tif (currentTagName !== tagNameMatch[1]) {\n\t\t\t\t\t\tvar tagNameLower = tagNameMatch[1].toLowerCase();\n\t\t\t\t\t\tif (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('Opening and ending tag mismatch: \"' + currentTagName + '\" != \"' + tagNameRaw + '\"');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvar config = parseStack.pop();\n\t\t\t\t\tunclosedTags.pop();\n\t\t\t\t\tvar localNSMap = config.localNSMap;\n\t\t\t\t\tdomBuilder.endElement(config.uri, config.localName, currentTagName);\n\t\t\t\t\tif (localNSMap) {\n\t\t\t\t\t\tfor (var prefix in localNSMap) {\n\t\t\t\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tend++;\n\t\t\t\t\tbreak;\n\t\t\t\t// end element\n\t\t\t\tcase '?': // \n\t\t\t\t\tlocator && position(tagStart);\n\t\t\t\t\tend = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);\n\t\t\t\t\tbreak;\n\t\t\t\tcase '!': // start) {\n\t\t\tstart = end;\n\t\t} else {\n\t\t\t//Possible sax fallback here, risk of positional error\n\t\t\tappendText(Math.max(tagStart, start) + 1);\n\t\t}\n\t}\n}\n\nfunction copyLocator(f, t) {\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @returns\n * end of the elementStartPart(end of elementEndPart for selfClosed el)\n * @see {@link #appendElement}\n */\nfunction parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (hasOwn(el.attributeNames, qname)) {\n\t\t\treturn errorHandler.fatalError('Attribute ' + qname + ' redefined');\n\t\t}\n\t\tif (!isHTML && value.indexOf('<') >= 0) {\n\t\t\treturn errorHandler.fatalError(\"Unescaped '<' not allowed in attributes values\");\n\t\t}\n\t\tel.addValue(\n\t\t\tqname,\n\t\t\t// @see https://www.w3.org/TR/xml/#AVNormalize\n\t\t\t// since the xmldom sax parser does not \"interpret\" DTD the following is not implemented:\n\t\t\t// - recursive replacement of (DTD) entity references\n\t\t\t// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA\n\t\t\tvalue.replace(/[\\t\\n\\r]/g, ' ').replace(ENTITY_REG, entityReplacer),\n\t\t\tstartIndex\n\t\t);\n\t}\n\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG; //status\n\twhile (true) {\n\t\tvar c = source.charAt(p);\n\t\tswitch (c) {\n\t\t\tcase '=':\n\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t//attrName\n\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else if (s === S_ATTR_SPACE) {\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\tcase '\"':\n\t\t\t\tif (\n\t\t\t\t\ts === S_EQ ||\n\t\t\t\t\ts === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t) {\n\t\t\t\t\t//equal\n\t\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"');\n\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t}\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\tp = source.indexOf(c, start);\n\t\t\t\t\tif (p > 0) {\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\taddAttribute(attrName, value, start - 1);\n\t\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\t\tthrow new Error(\"attribute value no end '\" + c + \"' match\");\n\t\t\t\t\t}\n\t\t\t\t} else if (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed start quot(' + c + ')!!');\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: no equal before\n\t\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '/':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\ts = S_TAG_CLOSE;\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t//case S_EQ:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"attribute invalid close char('/')\"); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '': //end document\n\t\t\t\terrorHandler.error('unexpected end of input');\n\t\t\t\tif (s == S_TAG) {\n\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\tcase '>':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\tbreak; //normal\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE: //Compatible state\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\tif (value.slice(-1) === '/') {\n\t\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\t\tvalue = value.slice(0, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tif (s === S_ATTR_SPACE) {\n\t\t\t\t\t\t\tvalue = attrName;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed value!! \"' + value + '\" instead!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(value, value, start);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('AttValue: \\' or \" expected');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\t\tcase '\\u0080':\n\t\t\t\tc = ' ';\n\t\t\tdefault:\n\t\t\t\tif (c <= ' ') {\n\t\t\t\t\t//space\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\t\tel.setTagName(source.slice(start, p)); //tagName\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\t\t\tvar value = source.slice(start, p);\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t\t\t//case S_EQ:\n\t\t\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t\t\t//\tvoid();break;\n\t\t\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t\t//ignore warning\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//not space\n\t\t\t\t\t//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n\t\t\t\t\t//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed value!! \"' + attrName + '\" instead2!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\terrorHandler.warning('attribute space is required\"' + attrName + '\"!!');\n\t\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t} //end outer switch\n\t\tp++;\n\t}\n}\n\n/**\n * @returns\n * `true` if a new namespace has been defined.\n */\nfunction appendElement(el, domBuilder, currentNSMap) {\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\tvar i = el.length;\n\twhile (i--) {\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif (nsp > 0) {\n\t\t\tvar prefix = (a.prefix = qName.slice(0, nsp));\n\t\t\tvar localName = qName.slice(nsp + 1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName;\n\t\t} else {\n\t\t\tlocalName = qName;\n\t\t\tprefix = null;\n\t\t\tnsPrefix = qName === 'xmlns' && '';\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif (nsPrefix !== false) {\n\t\t\t//hack!!\n\t\t\tif (localNSMap == null) {\n\t\t\t\tlocalNSMap = Object.create(null);\n\t\t\t\t_copy(currentNSMap, (currentNSMap = Object.create(null)));\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS;\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value);\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile (i--) {\n\t\ta = el[i];\n\t\tif (a.prefix) {\n\t\t\t//no prefix attribute has no namespace\n\t\t\tif (a.prefix === 'xml') {\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}\n\t\t\tif (a.prefix !== 'xmlns') {\n\t\t\t\ta.uri = currentNSMap[a.prefix];\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif (nsp > 0) {\n\t\tprefix = el.prefix = tagName.slice(0, nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp + 1);\n\t} else {\n\t\tprefix = null; //important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = (el.uri = currentNSMap[prefix || '']);\n\tdomBuilder.startElement(ns, localName, tagName, el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif (el.closed) {\n\t\tdomBuilder.endElement(ns, localName, tagName);\n\t\tif (localNSMap) {\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\n\nfunction parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {\n\t// https://html.spec.whatwg.org/#raw-text-elements\n\t// https://html.spec.whatwg.org/#escapable-raw-text-elements\n\t// https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements\n\t// TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions\n\tvar isEscapableRaw = isHTMLEscapableRawTextElement(tagName);\n\tif (isEscapableRaw || isHTMLRawTextElement(tagName)) {\n\t\tvar elEndStart = source.indexOf('', elStartEnd);\n\t\tvar text = source.substring(elStartEnd + 1, elEndStart);\n\n\t\tif (isEscapableRaw) {\n\t\t\ttext = text.replace(ENTITY_REG, entityReplacer);\n\t\t}\n\t\tdomBuilder.characters(text, 0, text.length);\n\t\treturn elEndStart;\n\t}\n\treturn elStartEnd + 1;\n}\n\nfunction _copy(source, target) {\n\tfor (var n in source) {\n\t\tif (hasOwn(source, n)) {\n\t\t\ttarget[n] = source[n];\n\t\t}\n\t}\n}\n\n/**\n * @typedef ParseUtils\n * @property {function(relativeIndex: number?): string | undefined} char\n * Provides look ahead access to a singe character relative to the current index.\n * @property {function(): number} getIndex\n * Provides read-only access to the current index.\n * @property {function(reg: RegExp): string | null} getMatch\n * Applies the provided regular expression enforcing that it starts at the current index and\n * returns the complete matching string,\n * and moves the current index by the length of the matching string.\n * @property {function(): string} getSource\n * Provides read-only access to the complete source.\n * @property {function(places: number?): void} skip\n * moves the current index by places (defaults to 1)\n * @property {function(): number} skipBlanks\n * Moves the current index by the amount of white space that directly follows the current index\n * and returns the amount of whitespace chars skipped (0..n),\n * or -1 if the end of the source was reached.\n * @property {function(): string} substringFromIndex\n * creates a substring from the current index to the end of `source`\n * @property {function(compareWith: string): boolean} substringStartsWith\n * Checks if `source` contains `compareWith`, starting from the current index.\n * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive\n * Checks if `source` contains `compareWith`, starting from the current index,\n * comparing the upper case of both sides.\n * @see {@link parseUtils}\n */\n\n/**\n * A temporary scope for parsing and look ahead operations in `source`,\n * starting from index `start`.\n *\n * Some operations move the current index by a number of positions,\n * after which `getIndex` returns the new index.\n *\n * @param {string} source\n * @param {number} start\n * @returns {ParseUtils}\n */\nfunction parseUtils(source, start) {\n\tvar index = start;\n\n\tfunction char(n) {\n\t\tn = n || 0;\n\t\treturn source.charAt(index + n);\n\t}\n\n\tfunction skip(n) {\n\t\tn = n || 1;\n\t\tindex += n;\n\t}\n\n\tfunction skipBlanks() {\n\t\tvar blanks = 0;\n\t\twhile (index < source.length) {\n\t\t\tvar c = char();\n\t\t\tif (c !== ' ' && c !== '\\n' && c !== '\\t' && c !== '\\r') {\n\t\t\t\treturn blanks;\n\t\t\t}\n\t\t\tblanks++;\n\t\t\tskip();\n\t\t}\n\t\treturn -1;\n\t}\n\tfunction substringFromIndex() {\n\t\treturn source.substring(index);\n\t}\n\tfunction substringStartsWith(text) {\n\t\treturn source.substring(index, index + text.length) === text;\n\t}\n\tfunction substringStartsWithCaseInsensitive(text) {\n\t\treturn source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();\n\t}\n\n\tfunction getMatch(args) {\n\t\tvar expr = g.reg('^', args);\n\t\tvar match = expr.exec(substringFromIndex());\n\t\tif (match) {\n\t\t\tskip(match[0].length);\n\t\t\treturn match[0];\n\t\t}\n\t\treturn null;\n\t}\n\treturn {\n\t\tchar: char,\n\t\tgetIndex: function () {\n\t\t\treturn index;\n\t\t},\n\t\tgetMatch: getMatch,\n\t\tgetSource: function () {\n\t\t\treturn source;\n\t\t},\n\t\tskip: skip,\n\t\tskipBlanks: skipBlanks,\n\t\tsubstringFromIndex: substringFromIndex,\n\t\tsubstringStartsWith: substringStartsWith,\n\t\tsubstringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,\n\t};\n}\n\n/**\n * @param {ParseUtils} p\n * @param {DOMHandler} errorHandler\n * @returns {string}\n */\nfunction parseDoctypeInternalSubset(p, errorHandler) {\n\t/**\n\t * @param {ParseUtils} p\n\t * @param {DOMHandler} errorHandler\n\t * @returns {string}\n\t */\n\tfunction parsePI(p, errorHandler) {\n\t\tvar match = g.PI.exec(p.substringFromIndex());\n\t\tif (!match) {\n\t\t\treturn errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());\n\t\t}\n\t\tif (match[1].toLowerCase() === 'xml') {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()\n\t\t\t);\n\t\t}\n\t\tp.skip(match[0].length);\n\t\treturn match[0];\n\t}\n\t// Parse internal subset\n\tvar source = p.getSource();\n\tif (p.char() === '[') {\n\t\tp.skip(1);\n\t\tvar intSubsetStart = p.getIndex();\n\t\twhile (p.getIndex() < source.length) {\n\t\t\tp.skipBlanks();\n\t\t\tif (p.char() === ']') {\n\t\t\t\tvar internalSubset = source.substring(intSubsetStart, p.getIndex());\n\t\t\t\tp.skip(1);\n\t\t\t\treturn internalSubset;\n\t\t\t}\n\t\t\tvar current = null;\n\t\t\t// Only in external subset\n\t\t\t// if (char() === '<' && char(1) === '!' && char(2) === '[') {\n\t\t\t// \tparseConditionalSections(p, errorHandler);\n\t\t\t// } else\n\t\t\tif (p.char() === '<' && p.char(1) === '!') {\n\t\t\t\tswitch (p.char(2)) {\n\t\t\t\t\tcase 'E': // ELEMENT | ENTITY\n\t\t\t\t\t\tif (p.char(3) === 'L') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.elementdecl);\n\t\t\t\t\t\t} else if (p.char(3) === 'N') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.EntityDecl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'A': // ATTRIBUTE\n\t\t\t\t\t\tcurrent = p.getMatch(g.AttlistDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'N': // NOTATION\n\t\t\t\t\t\tcurrent = p.getMatch(g.NotationDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-': // COMMENT\n\t\t\t\t\t\tcurrent = p.getMatch(g.Comment);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (p.char() === '<' && p.char(1) === '?') {\n\t\t\t\tcurrent = parsePI(p, errorHandler);\n\t\t\t} else if (p.char() === '%') {\n\t\t\t\tcurrent = p.getMatch(g.PEReference);\n\t\t\t} else {\n\t\t\t\treturn errorHandler.fatalError('Error detected in Markup declaration');\n\t\t\t}\n\t\t\tif (!current) {\n\t\t\t\treturn errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());\n\t\t\t}\n\t\t}\n\t\treturn errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');\n\t}\n}\n\n/**\n * Called when the parser encounters an element starting with '') {\n\t\t\t\treturn errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());\n\t\t\t}\n\t\t\tp.skip(1);\n\t\t\tdomBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);\n\t\t\tdomBuilder.endDTD();\n\t\t\treturn p.getIndex();\n\t\t}\n\t\tdefault:\n\t\t\treturn errorHandler.fatalError('Not well-formed XML starting with \" 0) {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'\n\t\t\t);\n\t\t}\n\t\tif (!g.XMLDecl.test(source.substring(start))) {\n\t\t\treturn errorHandler.fatalError('xml declaration is not well-formed');\n\t\t}\n\t}\n\tdomBuilder.processingInstruction(match[1], match[2]);\n\treturn start + match[0].length;\n}\n\nfunction ElementAttributes() {\n\tthis.attributeNames = Object.create(null);\n}\n\nElementAttributes.prototype = {\n\tsetTagName: function (tagName) {\n\t\tif (!g.QName_exact.test(tagName)) {\n\t\t\tthrow new Error('invalid tagName:' + tagName);\n\t\t}\n\t\tthis.tagName = tagName;\n\t},\n\taddValue: function (qName, value, offset) {\n\t\tif (!g.QName_exact.test(qName)) {\n\t\t\tthrow new Error('invalid attribute:' + qName);\n\t\t}\n\t\tthis.attributeNames[qName] = this.length;\n\t\tthis[this.length++] = { qName: qName, value: value, offset: offset };\n\t},\n\tlength: 0,\n\tgetLocalName: function (i) {\n\t\treturn this[i].localName;\n\t},\n\tgetLocator: function (i) {\n\t\treturn this[i].locator;\n\t},\n\tgetQName: function (i) {\n\t\treturn this[i].qName;\n\t},\n\tgetURI: function (i) {\n\t\treturn this[i].uri;\n\t},\n\tgetValue: function (i) {\n\t\treturn this[i].value;\n\t},\n\t//\t,getIndex:function(uri, localName)){\n\t//\t\tif(localName){\n\t//\n\t//\t\t}else{\n\t//\t\t\tvar qName = uri\n\t//\t\t}\n\t//\t},\n\t//\tgetValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},\n\t//\tgetType:function(uri,localName){}\n\t//\tgetType:function(i){},\n};\n\nexports.XMLReader = XMLReader;\nexports.parseUtils = parseUtils;\nexports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar dom = require('./dom');\nvar errors = require('./errors');\nvar entities = require('./entities');\nvar sax = require('./sax');\n\nvar DOMImplementation = dom.DOMImplementation;\n\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isValidMimeType = conventions.isValidMimeType;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\n\nvar XMLReader = sax.XMLReader;\n\n/**\n * Normalizes line ending according to ,\n * including some Unicode \"newline\" characters:\n *\n * > XML parsed entities are often stored in computer files which,\n * > for editing convenience, are organized into lines.\n * > These lines are typically separated by some combination\n * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).\n * >\n * > To simplify the tasks of applications, the XML processor must behave\n * > as if it normalized all line breaks in external parsed entities (including the document entity)\n * > on input, before parsing, by translating the following to a single #xA character:\n * >\n * > 1. the two-character sequence #xD #xA,\n * > 2. the two-character sequence #xD #x85,\n * > 3. the single character #x85,\n * > 4. the single character #x2028,\n * > 5. the single character #x2029,\n * > 6. any #xD character that is not immediately followed by #xA or #x85.\n *\n * @param {string} input\n * @returns {string}\n * @prettierignore\n */\nfunction normalizeLineEndings(input) {\n\treturn input.replace(/\\r[\\n\\u0085]/g, '\\n').replace(/[\\r\\u0085\\u2028\\u2029]/g, '\\n');\n}\n\n/**\n * @typedef Locator\n * @property {number} [columnNumber]\n * @property {number} [lineNumber]\n */\n\n/**\n * @typedef DOMParserOptions\n * @property {typeof assign} [assign]\n * The method to use instead of `conventions.assign`, which is used to copy values from\n * `options` before they are used for parsing.\n * @property {typeof DOMHandler} [domHandler]\n * For internal testing: The class for creating an instance for handling events from the SAX\n * parser.\n * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n * be broken.*****.\n * @property {Function} [errorHandler]\n * DEPRECATED! use `onError` instead.\n * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n * [onError]\n * A function invoked for every error that occurs during parsing.\n *\n * If it is not provided, all errors are reported to `console.error`\n * and only `fatalError`s are thrown as a `ParseError`,\n * which prevents any further processing.\n * If the provided method throws, a `ParserError` is thrown,\n * which prevents any further processing.\n *\n * Be aware that many `warning`s are considered an error that prevents further processing in\n * most implementations.\n * @property {boolean} [locator=true]\n * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`\n * attribute describing their location in the XML string.\n * Default is true.\n * @property {(string) => string} [normalizeLineEndings]\n * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,\n * which normalizes line endings according to ,\n * including some Unicode \"newline\" characters.\n * @property {Object} [xmlns]\n * The XML namespaces that should be assumed when parsing.\n * The default namespace can be provided by the key that is the empty string.\n * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n * the default namespace that will be used,\n * will be overridden according to the specification.\n * @see {@link normalizeLineEndings}\n */\n\n/**\n * The DOMParser interface provides the ability to parse XML or HTML source code from a string\n * into a DOM `Document`.\n *\n * ***xmldom is different from the spec in that it allows an `options` parameter,\n * to control the behavior***.\n *\n * @class\n * @param {DOMParserOptions} [options]\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization\n */\nfunction DOMParser(options) {\n\toptions = options || {};\n\tif (options.locator === undefined) {\n\t\toptions.locator = true;\n\t}\n\n\t/**\n\t * The method to use instead of `conventions.assign`, which is used to copy values from\n\t * `options`\n\t * before they are used for parsing.\n\t *\n\t * @type {conventions.assign}\n\t * @private\n\t * @see {@link conventions.assign}\n\t * @readonly\n\t */\n\tthis.assign = options.assign || conventions.assign;\n\n\t/**\n\t * For internal testing: The class for creating an instance for handling events from the SAX\n\t * parser.\n\t * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n\t * be broken*****.\n\t *\n\t * @type {typeof DOMHandler}\n\t * @private\n\t * @readonly\n\t */\n\tthis.domHandler = options.domHandler || DOMHandler;\n\n\t/**\n\t * A function that is invoked for every error that occurs during parsing.\n\t *\n\t * If it is not provided, all errors are reported to `console.error`\n\t * and only `fatalError`s are thrown as a `ParseError`,\n\t * which prevents any further processing.\n\t * If the provided method throws, a `ParserError` is thrown,\n\t * which prevents any further processing.\n\t *\n\t * Be aware that many `warning`s are considered an error that prevents further processing in\n\t * most implementations.\n\t *\n\t * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n\t * @see {@link onErrorStopParsing}\n\t * @see {@link onWarningStopParsing}\n\t */\n\tthis.onError = options.onError || options.errorHandler;\n\tif (options.errorHandler && typeof options.errorHandler !== 'function') {\n\t\tthrow new TypeError('errorHandler object is no longer supported, switch to onError!');\n\t} else if (options.errorHandler) {\n\t\toptions.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);\n\t}\n\n\t/**\n\t * used to replace line endings before parsing, defaults to `normalizeLineEndings`\n\t *\n\t * @type {(string) => string}\n\t * @readonly\n\t */\n\tthis.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;\n\n\t/**\n\t * Configures if the nodes created during parsing will have a `lineNumber` and a\n\t * `columnNumber`\n\t * attribute describing their location in the XML string.\n\t * Default is true.\n\t *\n\t * @type {boolean}\n\t * @readonly\n\t */\n\tthis.locator = !!options.locator;\n\n\t/**\n\t * The default namespace can be provided by the key that is the empty string.\n\t * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n\t * the default namespace that will be used,\n\t * will be overridden according to the specification.\n\t *\n\t * @type {Readonly}\n\t * @readonly\n\t */\n\tthis.xmlns = this.assign(Object.create(null), options.xmlns);\n}\n\n/**\n * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`\n * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,\n * otherwise an XML `Document` is created.\n *\n * __It behaves different from the description in the living standard__:\n * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.\n * - Any unexpected input is reported to `onError` with either a `warning`,\n * `error` or `fatalError` level.\n * - Any `fatalError` throws a `ParseError` which prevents further processing.\n * - Any error thrown by `onError` is converted to a `ParseError` which prevents further\n * processing - If no `Document` was created during parsing it is reported as a `fatalError`.\n * *****Warning: By configuring a faulty DOMHandler implementation,\n * the specified behavior can completely be broken*****.\n *\n * @param {string} source\n * The XML mime type only allows string input!\n * @param {string} [mimeType='application/xml']\n * the mimeType or contentType of the document to be created determines the `type` of document\n * created (XML or HTML)\n * @returns {Document}\n * The `Document` node.\n * @throws {ParseError}\n * for any `fatalError` or anything that is thrown by `onError`\n * @throws {TypeError}\n * for any invalid `mimeType`\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev\n */\nDOMParser.prototype.parseFromString = function (source, mimeType) {\n\tif (!isValidMimeType(mimeType)) {\n\t\tthrow new TypeError('DOMParser.parseFromString: the provided mimeType \"' + mimeType + '\" is not valid.');\n\t}\n\tvar defaultNSMap = this.assign(Object.create(null), this.xmlns);\n\tvar entityMap = entities.XML_ENTITIES;\n\tvar defaultNamespace = defaultNSMap[''] || null;\n\tif (hasDefaultHTMLNamespace(mimeType)) {\n\t\tentityMap = entities.HTML_ENTITIES;\n\t\tdefaultNamespace = NAMESPACE.HTML;\n\t} else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {\n\t\tdefaultNamespace = NAMESPACE.SVG;\n\t}\n\tdefaultNSMap[''] = defaultNamespace;\n\tdefaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;\n\n\tvar domBuilder = new this.domHandler({\n\t\tmimeType: mimeType,\n\t\tdefaultNamespace: defaultNamespace,\n\t\tonError: this.onError,\n\t});\n\tvar locator = this.locator ? {} : undefined;\n\tif (this.locator) {\n\t\tdomBuilder.setDocumentLocator(locator);\n\t}\n\n\tvar sax = new XMLReader();\n\tsax.errorHandler = domBuilder;\n\tsax.domBuilder = domBuilder;\n\tvar isXml = !conventions.isHTMLMimeType(mimeType);\n\tif (isXml && typeof source !== 'string') {\n\t\tsax.errorHandler.fatalError('source is not a string');\n\t}\n\tsax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);\n\tif (!domBuilder.doc.documentElement) {\n\t\tsax.errorHandler.fatalError('missing root element');\n\t}\n\treturn domBuilder.doc;\n};\n\n/**\n * @typedef DOMHandlerOptions\n * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]\n * @property {string | null} [defaultNamespace=null]\n */\n/**\n * The class that is used to handle events from the SAX parser to create the related DOM\n * elements.\n *\n * Some methods are only implemented as an empty function,\n * since they are (at least currently) not relevant for xmldom.\n *\n * @class\n * @param {DOMHandlerOptions} [options]\n * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html\n */\nfunction DOMHandler(options) {\n\tvar opt = options || {};\n\t/**\n\t * The mime type is used to determine if the DOM handler will create an XML or HTML document.\n\t * Only if it is set to `text/html` it will create an HTML document.\n\t * It defaults to MIME_TYPE.XML_APPLICATION.\n\t *\n\t * @type {string}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;\n\n\t/**\n\t * The namespace to use to create an XML document.\n\t * For the following reasons this is required:\n\t * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,\n\t * since at that point there is no way for the parser to know what the default namespace from\n\t * the document will be.\n\t * - When creating using `DOMImplementation.createDocument` it is required to pass a\n\t * namespace,\n\t * to determine the correct `Document.contentType`, which should match `this.mimeType`.\n\t * - When parsing an XML document with the `application/xhtml+xml` mimeType,\n\t * the HTML namespace needs to be the default namespace.\n\t *\n\t * @type {string | null}\n\t * @private\n\t * @readonly\n\t */\n\tthis.defaultNamespace = opt.defaultNamespace || null;\n\n\t/**\n\t * @type {boolean}\n\t * @private\n\t */\n\tthis.cdata = false;\n\n\t/**\n\t * The last `Element` that was created by `startElement`.\n\t * `endElement` sets it to the `currentElement.parentNode`.\n\t *\n\t * Note: The sax parser currently sets it to white space text nodes between tags.\n\t *\n\t * @type {Element | Node | undefined}\n\t * @private\n\t */\n\tthis.currentElement = undefined;\n\n\t/**\n\t * The Document that is created as part of `startDocument`,\n\t * and returned by `DOMParser.parseFromString`.\n\t *\n\t * @type {Document | undefined}\n\t * @readonly\n\t */\n\tthis.doc = undefined;\n\n\t/**\n\t * The locator is stored as part of setDocumentLocator.\n\t * It is controlled and mutated by the SAX parser to store the current parsing position.\n\t * It is used by DOMHandler to set `columnNumber` and `lineNumber`\n\t * on the DOM nodes.\n\t *\n\t * @type {Readonly | undefined}\n\t * @private\n\t * @readonly (the\n\t * sax parser currently sometimes set's it)\n\t */\n\tthis.locator = undefined;\n\t/**\n\t * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}\n\t * @readonly\n\t */\n\tthis.onError = opt.onError;\n}\n\nfunction position(locator, node) {\n\tnode.lineNumber = locator.lineNumber;\n\tnode.columnNumber = locator.columnNumber;\n}\n\nDOMHandler.prototype = {\n\t/**\n\t * Either creates an XML or an HTML document and stores it under `this.doc`.\n\t * If it is an XML document, `this.defaultNamespace` is used to create it,\n\t * and it will not contain any `childNodes`.\n\t * If it is an HTML document, it will be created without any `childNodes`.\n\t *\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html\n\t */\n\tstartDocument: function () {\n\t\tvar impl = new DOMImplementation();\n\t\tthis.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');\n\t},\n\tstartElement: function (namespaceURI, localName, qName, attrs) {\n\t\tvar doc = this.doc;\n\t\tvar el = doc.createElementNS(namespaceURI, qName || localName);\n\t\tvar len = attrs.length;\n\t\tappendElement(this, el);\n\t\tthis.currentElement = el;\n\n\t\tthis.locator && position(this.locator, el);\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tvar namespaceURI = attrs.getURI(i);\n\t\t\tvar value = attrs.getValue(i);\n\t\t\tvar qName = attrs.getQName(i);\n\t\t\tvar attr = doc.createAttributeNS(namespaceURI, qName);\n\t\t\tthis.locator && position(attrs.getLocator(i), attr);\n\t\t\tattr.value = attr.nodeValue = value;\n\t\t\tel.setAttributeNode(attr);\n\t\t}\n\t},\n\tendElement: function (namespaceURI, localName, qName) {\n\t\tthis.currentElement = this.currentElement.parentNode;\n\t},\n\tstartPrefixMapping: function (prefix, uri) {},\n\tendPrefixMapping: function (prefix) {},\n\tprocessingInstruction: function (target, data) {\n\t\tvar ins = this.doc.createProcessingInstruction(target, data);\n\t\tthis.locator && position(this.locator, ins);\n\t\tappendElement(this, ins);\n\t},\n\tignorableWhitespace: function (ch, start, length) {},\n\tcharacters: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\t//console.log(chars)\n\t\tif (chars) {\n\t\t\tif (this.cdata) {\n\t\t\t\tvar charNode = this.doc.createCDATASection(chars);\n\t\t\t} else {\n\t\t\t\tvar charNode = this.doc.createTextNode(chars);\n\t\t\t}\n\t\t\tif (this.currentElement) {\n\t\t\t\tthis.currentElement.appendChild(charNode);\n\t\t\t} else if (/^\\s*$/.test(chars)) {\n\t\t\t\tthis.doc.appendChild(charNode);\n\t\t\t\t//process xml\n\t\t\t}\n\t\t\tthis.locator && position(this.locator, charNode);\n\t\t}\n\t},\n\tskippedEntity: function (name) {},\n\tendDocument: function () {\n\t\tthis.doc.normalize();\n\t},\n\t/**\n\t * Stores the locator to be able to set the `columnNumber` and `lineNumber`\n\t * on the created DOM nodes.\n\t *\n\t * @param {Locator} locator\n\t */\n\tsetDocumentLocator: function (locator) {\n\t\tif (locator) {\n\t\t\tlocator.lineNumber = 0;\n\t\t}\n\t\tthis.locator = locator;\n\t},\n\t//LexicalHandler\n\tcomment: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\tvar comm = this.doc.createComment(chars);\n\t\tthis.locator && position(this.locator, comm);\n\t\tappendElement(this, comm);\n\t},\n\n\tstartCDATA: function () {\n\t\t//used in characters() methods\n\t\tthis.cdata = true;\n\t},\n\tendCDATA: function () {\n\t\tthis.cdata = false;\n\t},\n\n\tstartDTD: function (name, publicId, systemId, internalSubset) {\n\t\tvar impl = this.doc.implementation;\n\t\tif (impl && impl.createDocumentType) {\n\t\t\tvar dt = impl.createDocumentType(name, publicId, systemId, internalSubset);\n\t\t\tthis.locator && position(this.locator, dt);\n\t\t\tappendElement(this, dt);\n\t\t\tthis.doc.doctype = dt;\n\t\t}\n\t},\n\treportError: function (level, message) {\n\t\tif (typeof this.onError === 'function') {\n\t\t\ttry {\n\t\t\t\tthis.onError(level, message, this);\n\t\t\t} catch (e) {\n\t\t\t\tthrow new ParseError('Reporting ' + level + ' \"' + message + '\" caused ' + e, this.locator);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error('[xmldom ' + level + ']\\t' + message, _locator(this.locator));\n\t\t}\n\t},\n\t/**\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html\n\t */\n\twarning: function (message) {\n\t\tthis.reportError('warning', message);\n\t},\n\terror: function (message) {\n\t\tthis.reportError('error', message);\n\t},\n\t/**\n\t * This function reports a fatal error and throws a ParseError.\n\t *\n\t * @param {string} message\n\t * - The message to be used for reporting and throwing the error.\n\t * @returns {never}\n\t * This function always throws an error and never returns a value.\n\t * @throws {ParseError}\n\t * Always throws a ParseError with the provided message.\n\t */\n\tfatalError: function (message) {\n\t\tthis.reportError('fatalError', message);\n\t\tthrow new ParseError(message, this.locator);\n\t},\n};\n\nfunction _locator(l) {\n\tif (l) {\n\t\treturn '\\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';\n\t}\n}\n\nfunction _toString(chars, start, length) {\n\tif (typeof chars == 'string') {\n\t\treturn chars.substr(start, length);\n\t} else {\n\t\t//java sax connect width xmldom on rhino(what about: \"? && !(chars instanceof String)\")\n\t\tif (chars.length >= start + length || start) {\n\t\t\treturn new java.lang.String(chars, start, length) + '';\n\t\t}\n\t\treturn chars;\n\t}\n}\n\n/*\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html\n * used method of org.xml.sax.ext.LexicalHandler:\n * #comment(chars, start, length)\n * #startCDATA()\n * #endCDATA()\n * #startDTD(name, publicId, systemId)\n *\n *\n * IGNORED method of org.xml.sax.ext.LexicalHandler:\n * #endDTD()\n * #startEntity(name)\n * #endEntity(name)\n *\n *\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html\n * IGNORED method of org.xml.sax.ext.DeclHandler\n * \t#attributeDecl(eName, aName, type, mode, value)\n * #elementDecl(name, model)\n * #externalEntityDecl(name, publicId, systemId)\n * #internalEntityDecl(name, value)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html\n * IGNORED method of org.xml.sax.EntityResolver2\n * #resolveEntity(String name,String publicId,String baseURI,String systemId)\n * #resolveEntity(publicId, systemId)\n * #getExternalSubset(name, baseURI)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html\n * IGNORED method of org.xml.sax.DTDHandler\n * #notationDecl(name, publicId, systemId) {};\n * #unparsedEntityDecl(name, publicId, systemId, notationName) {};\n */\n'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(\n\t/\\w+/g,\n\tfunction (key) {\n\t\tDOMHandler.prototype[key] = function () {\n\t\t\treturn null;\n\t\t};\n\t}\n);\n\n/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */\nfunction appendElement(handler, node) {\n\tif (!handler.currentElement) {\n\t\thandler.doc.appendChild(node);\n\t} else {\n\t\thandler.currentElement.appendChild(node);\n\t}\n}\n\n/**\n * A method that prevents any further parsing when an `error`\n * with level `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onWarningStopParsing}\n */\nfunction onErrorStopParsing(level) {\n\tif (level === 'error') throw 'onErrorStopParsing';\n}\n\n/**\n * A method that prevents any further parsing when any `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onErrorStopParsing}\n */\nfunction onWarningStopParsing() {\n\tthrow 'onWarningStopParsing';\n}\n\nexports.__DOMHandler = DOMHandler;\nexports.DOMParser = DOMParser;\nexports.normalizeLineEndings = normalizeLineEndings;\nexports.onErrorStopParsing = onErrorStopParsing;\nexports.onWarningStopParsing = onWarningStopParsing;\n","'use strict';\nvar conventions = require('./conventions');\nexports.assign = conventions.assign;\nexports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nexports.isHTMLMimeType = conventions.isHTMLMimeType;\nexports.isValidMimeType = conventions.isValidMimeType;\nexports.MIME_TYPE = conventions.MIME_TYPE;\nexports.NAMESPACE = conventions.NAMESPACE;\n\nvar errors = require('./errors');\nexports.DOMException = errors.DOMException;\nexports.DOMExceptionName = errors.DOMExceptionName;\nexports.ExceptionCode = errors.ExceptionCode;\nexports.ParseError = errors.ParseError;\n\nvar dom = require('./dom');\nexports.Attr = dom.Attr;\nexports.CDATASection = dom.CDATASection;\nexports.CharacterData = dom.CharacterData;\nexports.Comment = dom.Comment;\nexports.Document = dom.Document;\nexports.DocumentFragment = dom.DocumentFragment;\nexports.DocumentType = dom.DocumentType;\nexports.DOMImplementation = dom.DOMImplementation;\nexports.Element = dom.Element;\nexports.Entity = dom.Entity;\nexports.EntityReference = dom.EntityReference;\nexports.LiveNodeList = dom.LiveNodeList;\nexports.NamedNodeMap = dom.NamedNodeMap;\nexports.Node = dom.Node;\nexports.NodeList = dom.NodeList;\nexports.Notation = dom.Notation;\nexports.ProcessingInstruction = dom.ProcessingInstruction;\nexports.Text = dom.Text;\nexports.XMLSerializer = dom.XMLSerializer;\n\nvar domParser = require('./dom-parser');\nexports.DOMParser = domParser.DOMParser;\nexports.normalizeLineEndings = domParser.normalizeLineEndings;\nexports.onErrorStopParsing = domParser.onErrorStopParsing;\nexports.onWarningStopParsing = domParser.onWarningStopParsing;\n","import { DOMParser as g, DOMImplementation as J } from \"@xmldom/xmldom\";\nconst p = \"USJ\", O = \"3.1\", _ = Object.freeze({ type: p, version: O, content: [] }), B = [\n \"type\",\n \"marker\",\n \"content\",\n \"sid\",\n \"eid\",\n \"number\",\n \"code\",\n \"altnumber\",\n \"pubnumber\",\n \"caller\",\n \"align\",\n \"category\"\n];\nfunction H(e) {\n return M.includes(e);\n}\nconst M = [\n // Old Testament\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n // New Testament\n \"MAT\",\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n // Deuterocanon\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"EZA\",\n \"5EZ\",\n \"6EZ\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n \"REP\",\n \"4BA\",\n \"LAO\",\n // Non scripture\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\",\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\"\n], f = \"usx\", N = \"3.1\", I = `<${f} version=\"${N}\" />`;\nfunction V(e) {\n const n = new g().parseFromString(e, \"text/xml\");\n return m(n.documentElement);\n}\nfunction m(e) {\n const [t] = e ? b(e) : [{ content: [] }];\n return t.type = p, t.version = O, t;\n}\nfunction b(e) {\n const t = {};\n let n = e.tagName, o, s, c = \"append\";\n if ([\"row\", \"cell\"].includes(n) && (n = \"table:\" + n), e.attributes)\n for (const r of Array.from(e.attributes))\n t[r.name] = r.value;\n t.style && (o = t.style, delete t.style), t.vid && delete t.vid, t.status && delete t.status;\n let i = { type: n };\n o && (i.marker = o), i = { ...i, ...t }, e.firstChild && e.firstChild.nodeType === e.firstChild.TEXT_NODE && e.firstChild.nodeValue && E(e.firstChild.nodeValue) !== \"\" && (s = e.firstChild.nodeValue);\n const l = Array.from(e.childNodes);\n i.content = [], s && i.content.push(s);\n for (const r of l) {\n if (r.tagName === void 0)\n continue;\n const [u, S] = b(r);\n switch (S) {\n case \"append\":\n i.content.push(u);\n break;\n case \"merge\":\n i.content = i.content.concat(u);\n break;\n }\n r.nextSibling && r.nextSibling.nodeType === r.nextSibling.TEXT_NODE && r.nextSibling.nodeValue && (E(r.nextSibling.nodeValue) !== \"\" || r.nextSibling.nodeValue === \" \") && i.content.push(r.nextSibling.nodeValue);\n }\n return i.content.length === 0 && i.type !== f && delete i.content, \"eid\" in i && [\"verse\", \"chapter\"].includes(n) && (c = \"ignore\"), [i, c];\n}\nfunction E(e) {\n return e.replace(/(^[ \\t\\n\\r\\f\\v]+)|([ \\t\\n\\r\\f\\v]+$)/g, \"\");\n}\nlet d, a;\nfunction C(e) {\n const t = new J().createDocument(\"\", f);\n return t.documentElement && (t.documentElement.setAttribute(\"version\", N), y(e, t)), t.toString();\n}\nfunction y(e, t) {\n if (t.documentElement) {\n for (const [n, o] of e.content.entries()) {\n const s = n === e.content.length - 1;\n v(o, t.documentElement, t, s);\n }\n return t.documentElement ?? void 0;\n }\n}\nfunction v(e, t, n, o) {\n let s, c, i;\n if (typeof e == \"string\") s = n.createTextNode(e);\n else if (c = e.type.replace(\"table:\", \"\"), s = n.createElement(c), X(s, e), e.content)\n for (const [r, u] of e.content.entries()) {\n const S = r === e.content.length - 1;\n v(u, s, n, S);\n }\n a && (c === \"verse\" || t.tagName === \"para\" && o) && (i = T(n, a), a = void 0), c === \"verse\" && typeof e != \"string\" && e.sid !== void 0 && (a = e.sid), d && (c === \"chapter\" || c === \"para\" && o) && (i = h(n, d), d = void 0), c === \"chapter\" && typeof e != \"string\" && e.sid !== void 0 && (d = e.sid);\n const l = t.nodeName === f && (i == null ? void 0 : i.tagName) === \"verse\";\n i && (!o || l) && t.appendChild(i), t.appendChild(s), i && o && !l && t.appendChild(i), o && t.nodeName === f && (a && t.appendChild(T(n, a)), d && t.appendChild(h(n, d)), a = void 0, d = void 0);\n}\nfunction X(e, t) {\n t.marker && (t.type === \"unmatched\" ? e.setAttribute(\"marker\", t.marker) : e.setAttribute(\"style\", t.marker));\n for (const [n, o] of Object.entries(t))\n o && ![\"type\", \"marker\", \"content\"].includes(n) && e.setAttribute(n, o);\n}\nfunction T(e, t) {\n const n = e.createElement(\"verse\");\n return n.setAttribute(\"eid\", t), n;\n}\nfunction h(e, t) {\n const n = e.createElement(\"chapter\");\n return n.setAttribute(\"eid\", t), n;\n}\nconst A = \"$\", P = \".content[\";\nfunction D(e) {\n const t = e.split(P);\n if (t.shift() !== A)\n throw new Error(`indexesFromJsonPath: jsonPath didn't start with '${A}'`);\n return t.map((o) => parseInt(o, 10));\n}\nfunction U(e) {\n return e.reduce((t, n) => `${t}${P}${n}]`, A);\n}\nexport {\n _ as EMPTY_USJ,\n I as EMPTY_USX,\n B as MARKER_OBJECT_PROPS,\n p as USJ_TYPE,\n O as USJ_VERSION,\n f as USX_TYPE,\n N as USX_VERSION,\n M as VALID_BOOK_CODES,\n D as indexesFromUsjJsonPath,\n H as isValidBookCode,\n U as usjJsonPathFromIndexes,\n C as usjToUsxString,\n V as usxStringToUsj\n};\n//# sourceMappingURL=index.js.map\n","\"use strict\"\r\n\r\n// Based on: https://github.com/lodash/lodash/blob/6018350ac10d5ce6a5b7db625140b82aeab804df/.internal/unicodeSize.js\r\n\r\nmodule.exports = () => {\r\n\t// Used to compose unicode character classes.\r\n\tconst astralRange = \"\\\\ud800-\\\\udfff\"\r\n\tconst comboMarksRange = \"\\\\u0300-\\\\u036f\"\r\n\tconst comboHalfMarksRange = \"\\\\ufe20-\\\\ufe2f\"\r\n\tconst comboSymbolsRange = \"\\\\u20d0-\\\\u20ff\"\r\n\tconst comboMarksExtendedRange = \"\\\\u1ab0-\\\\u1aff\"\r\n\tconst comboMarksSupplementRange = \"\\\\u1dc0-\\\\u1dff\"\r\n\tconst comboRange = comboMarksRange + comboHalfMarksRange + comboSymbolsRange + comboMarksExtendedRange + comboMarksSupplementRange\r\n\tconst varRange = \"\\\\ufe0e\\\\ufe0f\"\r\n\tconst familyRange = \"\\\\uD83D\\\\uDC69\\\\uD83C\\\\uDFFB\\\\u200D\\\\uD83C\\\\uDF93\"\r\n\r\n\t// Used to compose unicode capture groups.\r\n\tconst astral = `[${astralRange}]`\r\n\tconst combo = `[${comboRange}]`\r\n\tconst fitz = \"\\\\ud83c[\\\\udffb-\\\\udfff]\"\r\n\tconst modifier = `(?:${combo}|${fitz})`\r\n\tconst nonAstral = `[^${astralRange}]`\r\n\tconst regional = \"(?:\\\\uD83C[\\\\uDDE6-\\\\uDDFF]){2}\"\r\n\tconst surrogatePair = \"[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]\"\r\n\tconst zwj = \"\\\\u200d\"\r\n\tconst blackFlag = \"(?:\\\\ud83c\\\\udff4\\\\udb40\\\\udc67\\\\udb40\\\\udc62\\\\udb40(?:\\\\udc65|\\\\udc73|\\\\udc77)\\\\udb40(?:\\\\udc6e|\\\\udc63|\\\\udc6c)\\\\udb40(?:\\\\udc67|\\\\udc74|\\\\udc73)\\\\udb40\\\\udc7f)\"\r\n\tconst family = `[${familyRange}]`\r\n\r\n\t// Used to compose unicode regexes.\r\n\tconst optModifier = `${modifier}?`\r\n\tconst optVar = `[${varRange}]?`\r\n\tconst optJoin = `(?:${zwj}(?:${[nonAstral, regional, surrogatePair].join(\"|\")})${optVar + optModifier})*`\r\n\tconst seq = optVar + optModifier + optJoin\r\n\tconst nonAstralCombo = `${nonAstral}${combo}?`\r\n\tconst symbol = `(?:${[nonAstralCombo, combo, regional, surrogatePair, astral, family].join(\"|\")})`\r\n\r\n\t// Used to match [String symbols](https://mathiasbynens.be/notes/javascript-unicode).\r\n\treturn new RegExp(`${blackFlag}|${fitz}(?=${fitz})|${symbol + seq}`, \"g\")\r\n}\r\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// @ts-ignore\nvar char_regex_1 = __importDefault(require(\"char-regex\"));\n/**\n * Converts a string to an array of string chars\n * @param {string} str The string to turn into array\n * @returns {string[]}\n */\nfunction toArray(str) {\n if (typeof str !== 'string') {\n throw new Error('A string is expected as input');\n }\n return str.match(char_regex_1.default()) || [];\n}\nexports.toArray = toArray;\n/**\n * Returns the length of a string\n *\n * @export\n * @param {string} str\n * @returns {number}\n */\nfunction length(str) {\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var match = str.match(char_regex_1.default());\n return match === null ? 0 : match.length;\n}\nexports.length = length;\n/**\n * Returns a substring by providing start and end position\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} end End position\n * @returns {string}\n */\nfunction substring(str, begin, end) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n // Even though negative numbers work here, theyre not in the spec\n if (typeof begin !== 'number' || begin < 0) {\n begin = 0;\n }\n if (typeof end === 'number' && end < 0) {\n end = 0;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substring = substring;\n/**\n * Returns a substring by providing start position and length\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} len Desired length\n * @returns {string}\n */\nfunction substr(str, begin, len) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var strLength = length(str);\n // Fix type\n if (typeof begin !== 'number') {\n begin = parseInt(begin, 10);\n }\n // Return zero-length string if got oversize number.\n if (begin >= strLength) {\n return '';\n }\n // Calculating postive version of negative value.\n if (begin < 0) {\n begin += strLength;\n }\n var end;\n if (typeof len === 'undefined') {\n end = strLength;\n }\n else {\n // Fix type\n if (typeof len !== 'number') {\n len = parseInt(len, 10);\n }\n end = len >= 0 ? len + begin : begin;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substr = substr;\n/**\n * Enforces a string to be a certain length by\n * adding or removing characters\n *\n * @export\n * @param {string} str\n * @param {number} [limit=16] Limit\n * @param {string} [padString='#'] The Pad String\n * @param {string} [padPosition='right'] The Pad Position\n * @returns {string}\n */\nfunction limit(str, limit, padString, padPosition) {\n if (limit === void 0) { limit = 16; }\n if (padString === void 0) { padString = '#'; }\n if (padPosition === void 0) { padPosition = 'right'; }\n // Input should be a string, limit should be a number\n if (typeof str !== 'string' || typeof limit !== 'number') {\n throw new Error('Invalid arguments specified');\n }\n // Pad position should be either left or right\n if (['left', 'right'].indexOf(padPosition) === -1) {\n throw new Error('Pad position should be either left or right');\n }\n // Pad string can be anything, we convert it to string\n if (typeof padString !== 'string') {\n padString = String(padString);\n }\n // Calculate string length considering astral code points\n var strLength = length(str);\n if (strLength > limit) {\n return substring(str, 0, limit);\n }\n else if (strLength < limit) {\n var padRepeats = padString.repeat(limit - strLength);\n return padPosition === 'left' ? padRepeats + str : str + padRepeats;\n }\n return str;\n}\nexports.limit = limit;\n/**\n * Returns the index of the first occurrence of a given string\n *\n * @export\n * @param {string} str\n * @param {string} [searchStr] the string to search\n * @param {number} [pos] starting position\n * @returns {number}\n */\nfunction indexOf(str, searchStr, pos) {\n if (pos === void 0) { pos = 0; }\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n if (str === '') {\n if (searchStr === '') {\n return 0;\n }\n return -1;\n }\n // fix type\n pos = Number(pos);\n pos = isNaN(pos) ? 0 : pos;\n searchStr = String(searchStr);\n var strArr = toArray(str);\n if (pos >= strArr.length) {\n if (searchStr === '') {\n return strArr.length;\n }\n return -1;\n }\n if (searchStr === '') {\n return pos;\n }\n var searchArr = toArray(searchStr);\n var finded = false;\n var index;\n for (index = pos; index < strArr.length; index += 1) {\n var searchIndex = 0;\n while (searchIndex < searchArr.length &&\n searchArr[searchIndex] === strArr[index + searchIndex]) {\n searchIndex += 1;\n }\n if (searchIndex === searchArr.length &&\n searchArr[searchIndex - 1] === strArr[index + searchIndex - 1]) {\n finded = true;\n break;\n }\n }\n return finded ? index : -1;\n}\nexports.indexOf = indexOf;\n","/**\n * Ensures that the given input is returned as an array.\n *\n * This function takes a value that might be a single item, an array, or `undefined` and returns it\n * as an array:\n *\n * - If the input is `undefined`, an empty array is returned.\n * - If the input is already an array, it is returned as-is.\n * - If the input is a single item, it is wrapped in an array.\n *\n * @typeParam T - The type of the elements in the array.\n * @param maybeArray - The value that may be a single item, an array, or `undefined`.\n * @returns An array containing the input value(s). If the input is `undefined`, an empty array is\n * returned.\n */\nexport function ensureArray(maybeArray: T | T[] | undefined): T[] {\n if (!maybeArray) return [];\n\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\nexport default ensureArray;\n","import { LocalizeKey } from 'extension-contributions/menus.model';\nimport {\n indexOf as stringzIndexOf,\n length as stringzLength,\n limit as stringzLimit,\n substr as stringzSubstr,\n substring as stringzSubstring,\n toArray as stringzToArray,\n} from 'stringz';\nimport { ensureArray } from './array-util';\nimport { isString } from './util';\n\n/**\n * This function mirrors the `at` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Finds the Unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the character to be returned in range of -length(string) to\n * length(string)\n * @returns New string consisting of the Unicode code point located at the specified offset,\n * undefined if index is out of bounds\n */\nexport function at(string: string, index: number): string | undefined {\n if (index > stringLength(string) || index < -stringLength(string)) return undefined;\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `charAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a new string consisting of the single unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns New string consisting of the Unicode code point located at the specified offset, empty\n * string if index is out of bounds\n */\nexport function charAt(string: string, index: number): string {\n if (index < 0 || index > stringLength(string) - 1) return '';\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `codePointAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a non-negative integer that is the Unicode code point value of the character starting at\n * the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns Non-negative integer representing the code point value of the character at the given\n * index, or undefined if there is no element at that position\n */\nexport function codePointAt(string: string, index: number): number | undefined {\n if (index < 0 || index > stringLength(string) - 1) return undefined;\n return substr(string, index, 1).codePointAt(0);\n}\n\n/**\n * This function mirrors the `endsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether a string ends with the characters of this string.\n *\n * @param string String to search through\n * @param searchString Characters to search for at the end of the string\n * @param endPosition End position where searchString is expected to be found. Default is\n * `length(string)`\n * @returns True if it ends with searchString, false if it does not\n */\nexport function endsWith(\n string: string,\n searchString: string,\n endPosition: number = stringLength(string),\n): boolean {\n const lastIndexOfSearchString = lastIndexOf(string, searchString);\n if (lastIndexOfSearchString === -1) return false;\n if (lastIndexOfSearchString + stringLength(searchString) !== endPosition) return false;\n return true;\n}\n\n/**\n * Get the index of the closest closing curly brace in a string.\n *\n * Note: when escaped, gets the index of the curly brace, not the backslash before it.\n *\n * @param str String to search\n * @param index Index at which to start searching. Inclusive of this index\n * @param escaped Whether to search for an escaped or an unescaped closing curly brace\n * @returns Index of closest closing curly brace or -1 if not found\n */\nfunction indexOfClosestClosingCurlyBrace(str: string, index: number, escaped: boolean) {\n if (index < 0) return -1;\n if (escaped) {\n if (charAt(str, index) === '}' && charAt(str, index - 1) === '\\\\') return index;\n const closeCurlyBraceIndex = indexOf(str, '\\\\}', index);\n return closeCurlyBraceIndex >= 0 ? closeCurlyBraceIndex + 1 : closeCurlyBraceIndex;\n }\n\n let i = index;\n const strLength = stringLength(str);\n while (i < strLength) {\n i = indexOf(str, '}', i);\n\n if (i === -1 || charAt(str, i - 1) !== '\\\\') break;\n\n // Didn't find an un-escaped close brace, so keep looking\n i += 1;\n }\n\n return i >= strLength ? -1 : i;\n}\n\n/**\n * Formats a string into an array of objects (adjacent strings are concatenated in one array entry),\n * replacing `{replacer key}` with the value in the `replacers` at that replacer key (or multiple\n * replacer values if there are multiple in the string). Will also remove \\ before curly braces if\n * curly braces are escaped with a backslash in order to preserve the curly braces. E.g. 'Hi, this\n * is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * Note: React elements can be used as replacer values.\n *\n * @example\n *\n * ```tsx\n *

\n * {formatReplacementStringToArray('Hi {other}! I am {name}.', {\n * other: 'Billy',\n * name: Jim,\n * })}\n *

\n * ```\n *\n * @example\n *\n * ```typescript\n * formatReplacementStringToArray(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carInfo} car. My favorite food is {food}.',\n * { name: ['Bill'], carInfo: { year: 2015, color: 'blue' } }\n * );\n *\n * =>\n *\n * ['Hi, this is ', ['Bill'], '! I like {curly braces}! I have a ', { year: 2015, color: 'blue' }, ' car. My favorite food is food.']\n * ```\n *\n * @param str String to format and break out into an array of objects\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. If the replacer value is a string,\n * it will be concatenated into existing strings in the array. Otherwise, the replacer value will\n * be added as a new entry in the array\n * @returns Array of formatted strings and replaced objects\n */\nexport function formatReplacementStringToArray(\n str: string,\n replacers: { [key: string | number]: T } | object,\n): (string | T)[] {\n /** The compiled list of contents with replacers replaced appropriately */\n const contents: (string | T)[] = [];\n\n // current index in the string as we go through it\n let i = 0;\n // first index of characters to include in the next plain string added to the content\n let nextIntermediateStartIndex = 0;\n\n /**\n * Adds some content to the array of contents that is being built and also add the intermediate\n * string between the last added content and this added content\n *\n * @param newContent Content to add\n * @param newContentIndex Position in string where newContent starts\n * @param newContentLength Length in the string of the representation of this newContent\n */\n function addToContents(\n newContent: string | T,\n newContentIndex: number,\n newContentLength: number,\n ) {\n // Get the string content between the last new content and this new content\n const intermediateContent = substring(str, nextIntermediateStartIndex, newContentIndex);\n\n // If the last item in contents is a string, pull it out and add intermediateContent to\n // it. Otherwise stick with just intermediateContent\n const baseSubstring =\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${intermediateContent}`\n : intermediateContent;\n\n if (isString(newContent)) {\n // If the new content is a string, add it all together\n contents.push(`${baseSubstring}${newContent}`);\n } else {\n // New content is not a string. Add the base string if it exists (don't add an\n // empty string between added contents), then add the new content separately\n if (baseSubstring) contents.push(baseSubstring);\n contents.push(newContent);\n }\n\n // Set the intermediate start index to right after the new content so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = newContentIndex + newContentLength;\n }\n\n const strLength = stringLength(str);\n while (i < strLength) {\n switch (charAt(str, i)) {\n case '{':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped open curly brace. Try to match and replace\n const closeCurlyBraceIndex = indexOfClosestClosingCurlyBrace(str, i, false);\n if (closeCurlyBraceIndex >= 0) {\n // We have matching open and close indices. Try to replace the contents\n const replacerKey = substring(str, i + 1, closeCurlyBraceIndex);\n\n // Replace with the replacer or just remove the curly braces\n const replacerContent =\n replacerKey in replacers\n ? // Just checked that the key is in the object\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n replacers[replacerKey as keyof typeof replacers]\n : replacerKey;\n\n addToContents(replacerContent, i, closeCurlyBraceIndex + 1 - i);\n\n // Put our index at the closing brace to keep processing the string after it\n i = closeCurlyBraceIndex;\n // Set the intermediate start index to right after our closing curly brace so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = closeCurlyBraceIndex + 1;\n } else {\n // This is an unexpected un-escaped open curly brace with no matching closing curly\n // brace. Just ignore, I guess\n }\n } else {\n // This character is an escaped open curly brace. Add the curly brace but skip over the\n // escape backslash\n addToContents('{', i - 1, 2);\n }\n break;\n case '}':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped closing curly brace with no matching open curly\n // brace. Just ignore, I guess\n } else {\n // This character is an escaped closing curly brace. Add the curly brace but skip over\n // the escape backslash\n addToContents('}', i - 1, 2);\n }\n break;\n default:\n // No need to do anything with other characters at this point\n break;\n }\n\n i += 1;\n }\n\n // Now we are through the whole string and need to add the string content after all replacers if\n // there is anything left\n if (nextIntermediateStartIndex < strLength) {\n // Get the string content between the last new content and this new content\n const endContent = substring(str, nextIntermediateStartIndex);\n\n // If the last item in contents is a string, pull it out and add endContent to\n // it. Then put it in the contents array\n contents.push(\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${endContent}`\n : endContent,\n );\n }\n\n return contents;\n}\n\n/**\n * Formats a string, replacing `{replacer key}` with the value in the `replacers` at that replacer\n * key (or multiple replacer values if there are multiple in the string). Will also remove \\ before\n * curly braces if curly braces are escaped with a backslash in order to preserve the curly braces.\n * E.g. 'Hi, this is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly\n * braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * @example\n *\n * ```typescript\n * formatReplacementString(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carColor} car. My favorite food is {food}.',\n * { name: 'Bill', carColor: 'blue' }\n * );\n *\n * =>\n *\n * 'Hi, this is Bill! I like {curly braces}! I have a blue car. My favorite food is food.'\n * ```\n *\n * @param str String to format\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. Will be coerced to strings using\n * `${replacerValue}`\n * @returns Formatted string\n */\nexport function formatReplacementString(\n str: string,\n replacers: { [key: string | number]: string | unknown } | object,\n): string {\n return formatReplacementStringToArray(str, replacers)\n .map((content) => `${content}`)\n .join('');\n}\n\n/**\n * This function mirrors the `includes` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Performs a case-sensitive search to determine if searchString is found in string.\n *\n * @param string String to search through\n * @param searchString String to search for\n * @param position Position within the string to start searching for searchString. Default is `0`\n * @returns True if search string is found, false if it is not\n */\nexport function includes(string: string, searchString: string, position: number = 0): boolean {\n const partialString = substring(string, position);\n const indexOfSearchString = indexOf(partialString, searchString);\n if (indexOfSearchString === -1) return false;\n return true;\n}\n\n/**\n * This function mirrors the `indexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the index of the first occurrence of a given string.\n *\n * @param string String to search through\n * @param searchString The string to search for\n * @param position Start of searching. Default is `0`\n * @returns Index of the first occurrence of a given string\n */\nexport function indexOf(\n string: string,\n searchString: string,\n position: number | undefined = 0,\n): number {\n return stringzIndexOf(string, searchString, position);\n}\n\n/**\n * This function mirrors the `lastIndexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Searches this string and returns the index of the last occurrence of the specified substring.\n *\n * @param string String to search through\n * @param searchString Substring to search for\n * @param position The index at which to begin searching. If omitted, the search begins at the end\n * of the string. Default is `undefined`\n * @returns Index of the last occurrence of searchString found, or -1 if not found.\n */\nexport function lastIndexOf(string: string, searchString: string, position?: number): number {\n let validatedPosition = position === undefined ? stringLength(string) : position;\n\n if (validatedPosition < 0) {\n validatedPosition = 0;\n } else if (validatedPosition >= stringLength(string)) {\n validatedPosition = stringLength(string) - 1;\n }\n\n for (let index = validatedPosition; index >= 0; index--) {\n if (substr(string, index, stringLength(searchString)) === searchString) {\n return index;\n }\n }\n\n return -1;\n}\n\n/**\n * This function mirrors the `length` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes. Since `length` appears to be a\n * reserved keyword, the function was renamed to `stringLength`\n *\n * Returns the length of a string.\n *\n * @param string String to return the length for\n * @returns Number that is length of the starting string\n */\nexport function stringLength(string: string): number {\n return stringzLength(string);\n}\n\n/**\n * This function mirrors the `normalize` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the Unicode Normalization Form of this string.\n *\n * @param string The starting string\n * @param form Form specifying the Unicode Normalization Form. Default is `'NFC'`\n * @returns A string containing the Unicode Normalization Form of the given string.\n */\nexport function normalize(string: string, form: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | 'none'): string {\n const upperCaseForm = form.toUpperCase();\n if (upperCaseForm === 'NONE') {\n return string;\n }\n return string.normalize(upperCaseForm);\n}\n\n/**\n * Compares two strings using an ordinal comparison approach based on the specified collation\n * options. This function uses the built-in `localeCompare` method with the 'en' locale and the\n * provided collation options to compare the strings.\n *\n * @param string1 The first string to compare.\n * @param string2 The second string to compare.\n * @param options Optional. The collation options used for comparison.\n * @returns A number indicating the result of the comparison: - Negative value if string1 precedes\n * string2 in sorting order. - Zero if string1 and string2 are equivalent in sorting order. -\n * Positive value if string1 follows string2 in sorting order.\n */\nexport function ordinalCompare(\n string1: string,\n string2: string,\n options?: Intl.CollatorOptions,\n): number {\n return string1.localeCompare(string2, 'en', options);\n}\n\n/**\n * This function mirrors the `padEnd` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the end of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within targetLength, it will be truncated. Default is `\" \"`\n * @returns String with appropriate padding at the end\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padEnd(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'right');\n}\n\n/**\n * This function mirrors the `padStart` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the start of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within the targetLength, it will be truncated from the end. Default is `\" \"`\n * @returns String with of specified targetLength with padString applied from the start\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padStart(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'left');\n}\n\n// This is a helper function that performs a correction on the slice index to make sure it\n// cannot go out of bounds\nfunction correctSliceIndex(length: number, index: number) {\n if (index > length) return length;\n if (index < -length) return 0;\n if (index < 0) return index + length;\n return index;\n}\n\n/**\n * This function mirrors the `slice` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Extracts a section of this string and returns it as a new string, without modifying the original\n * string.\n *\n * @param string The starting string\n * @param indexStart The index of the first character to include in the returned substring.\n * @param indexEnd The index of the first character to exclude from the returned substring.\n * @returns A new string containing the extracted section of the string.\n */\nexport function slice(string: string, indexStart: number, indexEnd?: number): string {\n const length: number = stringLength(string);\n if (\n indexStart > length ||\n (indexEnd &&\n ((indexStart > indexEnd &&\n !(indexStart >= 0 && indexStart < length && indexEnd < 0 && indexEnd > -length)) ||\n indexEnd < -length))\n )\n return '';\n\n const newStart = correctSliceIndex(length, indexStart);\n const newEnd = indexEnd ? correctSliceIndex(length, indexEnd) : undefined;\n\n return substring(string, newStart, newEnd);\n}\n\n/**\n * This function mirrors the `split` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Takes a pattern and divides the string into an ordered list of substrings by searching for the\n * pattern, puts these substrings into an array, and returns the array.\n *\n * @param string The string to split\n * @param separator The pattern describing where each split should occur\n * @param splitLimit Limit on the number of substrings to be included in the array. Splits the\n * string at each occurrence of specified separator, but stops when limit entries have been placed\n * in the array.\n * @returns An array of strings, split at each point where separator occurs in the starting string.\n * Returns undefined if separator is not found in string.\n */\nexport function split(string: string, separator: string | RegExp, splitLimit?: number): string[] {\n const result: string[] = [];\n\n if (splitLimit !== undefined && splitLimit <= 0) {\n return [string];\n }\n\n if (separator === '') return toArray(string).slice(0, splitLimit);\n\n let regexSeparator = separator;\n if (\n typeof separator === 'string' ||\n (separator instanceof RegExp && !includes(separator.flags, 'g'))\n ) {\n regexSeparator = new RegExp(separator, 'g');\n }\n\n const matches: RegExpMatchArray | null = string.match(regexSeparator);\n\n let currentIndex = 0;\n\n if (!matches) return [string];\n\n for (let index = 0; index < (splitLimit ? splitLimit - 1 : matches.length); index++) {\n const matchIndex = indexOf(string, matches[index], currentIndex);\n const matchLength = stringLength(matches[index]);\n\n result.push(substring(string, currentIndex, matchIndex));\n currentIndex = matchIndex + matchLength;\n\n if (splitLimit !== undefined && result.length === splitLimit) {\n break;\n }\n }\n\n result.push(substring(string, currentIndex));\n\n return result;\n}\n\n/**\n * This function mirrors the `startsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether the string begins with the characters of a specified string, returning true or\n * false as appropriate.\n *\n * @param string String to search through\n * @param searchString The characters to be searched for at the start of this string.\n * @param position The start position at which searchString is expected to be found (the index of\n * searchString's first character). Default is `0`\n * @returns True if the given characters are found at the beginning of the string, including when\n * searchString is an empty string; otherwise, false.\n */\nexport function startsWith(string: string, searchString: string, position: number = 0): boolean {\n const indexOfSearchString = indexOf(string, searchString, position);\n if (indexOfSearchString !== position) return false;\n return true;\n}\n\n/**\n * This function mirrors the `substr` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and length. This function is not exported because it is\n * considered deprecated, however it is still useful as a local helper function.\n *\n * @param string String to be divided\n * @param begin Start position. Default is `Start of string`\n * @param len Length of result. Default is `String length minus start parameter`. Default is `String\n * length minus start parameter`\n * @returns Substring from starting string\n */\nfunction substr(\n string: string,\n begin: number = 0,\n len: number = stringLength(string) - begin,\n): string {\n return stringzSubstr(string, begin, len);\n}\n\n/**\n * This function mirrors the `substring` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and end position.\n *\n * @param string String to be divided\n * @param begin Start position\n * @param end End position. Default is `End of string`\n * @returns Substring from starting string\n */\nexport function substring(\n string: string,\n begin: number,\n end: number = stringLength(string),\n): string {\n return stringzSubstring(string, begin, end);\n}\n\n/**\n * This function mirrors the `toArray` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Converts a string to an array of string characters.\n *\n * @param string String to convert to array\n * @returns An array of characters from the starting string\n */\nexport function toArray(string: string): string[] {\n return stringzToArray(string);\n}\n\n/** Determine whether the string is a `LocalizeKey` meant to be localized in Platform.Bible. */\nexport function isLocalizeKey(str: string): str is LocalizeKey {\n return startsWith(str, '%') && endsWith(str, '%');\n}\n\n/**\n * Escape RegExp special characters.\n *\n * You can also use this to escape a string that is inserted into the middle of a regex, for\n * example, into a character class.\n *\n * All credit to [`escape-string-regexp`](https://www.npmjs.com/package/escape-string-regexp) - this\n * function is simply copied directly from there to allow a common js export\n *\n * @example\n *\n * import escapeStringRegexp from 'platform-bible-utils';\n *\n * const escapedString = escapeStringRegexp('How much $ for a 🦄?');\n * //=> 'How much \\\\$ for a 🦄\\\\?'\n *\n * new RegExp(escapedString);\n */\nexport function escapeStringRegexp(string: string): string {\n if (typeof string !== 'string') {\n throw new TypeError('Expected a string');\n }\n\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions, ensuring that\n * the result is always an array.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - If the input is an array containing nested arrays, it converts each string in the nested arrays\n * into `RegExp` objects.\n * - Ensures that the result is always an array of `RegExp` objects or arrays of `RegExp` objects.\n *\n * @param stringStringMaybeArray - The value to be transformed, which can be a single string, an\n * array of strings or arrays of strings, or `undefined`.\n * @returns An array of `RegExp` objects or arrays of `RegExp` objects. If the input is `undefined`,\n * an empty array is returned.\n */\nexport function transformAndEnsureRegExpRegExpArray(\n stringStringMaybeArray: string | (string | string[])[] | undefined,\n): (RegExp | RegExp[])[] {\n if (!stringStringMaybeArray) return [];\n\n const stringStringArray = ensureArray(stringStringMaybeArray);\n\n const regExpRegExpArray = stringStringArray.map((stringMaybeStringArray: string | string[]) =>\n Array.isArray(stringMaybeStringArray)\n ? stringMaybeStringArray.map((str) => new RegExp(str))\n : new RegExp(stringMaybeStringArray),\n );\n\n return regExpRegExpArray;\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - Ensures that the result is always an array of `RegExp` objects.\n *\n * @param stringMaybeArray - The value to be transformed, which can be a single string, an array of\n * strings, or `undefined`.\n * @returns An array of `RegExp` objects. If the input is `undefined`, an empty array is returned.\n */\nexport function transformAndEnsureRegExpArray(\n stringMaybeArray: string | string[] | undefined,\n): RegExp[] {\n if (!stringMaybeArray) return [];\n\n const stringArray = ensureArray(stringMaybeArray);\n\n const regExpArray = stringArray.map((str: string) => new RegExp(str));\n\n return regExpArray;\n}\n\nconst whiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/;\n/**\n * Determines whether a string contains one or more white space characters and no other characters.\n *\n * This implementation uses [dotnet's `Char.IsWhiteSpace` definition of white\n * space](https://learn.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=net-9.0):\n *\n * ```ts\n * /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: This differs from\n * [`/\\s/.test(ch)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes#:~:text=Matches%20a%20single%20white%20space%20character%2C%20including%20space)\n * (usually considered the determiner of what is white space in JavaScript) in that it does not\n * include ZWNBSP (U+FEFF) but rather includes NEXT LINE (U+0085)\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more white space characters and no other\n * characters, `false` otherwise\n */\nexport function isWhiteSpace(ch: string) {\n return whiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts PascalCase or camelCase string to kebab-case. To detect upper- and lower-case\n * characters, uses `.toUpperCase` and `.toLowerCase` to be locale-independent.\n *\n * Current implementation supports only UTF-16.\n *\n * Thanks to ChatGPT https://chatgpt.com/share/67c8aa44-e054-800c-8068-e1e6630081f7\n */\nexport function toKebabCase(input: string): string {\n let result = '';\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n const isUpper = char === char.toUpperCase() && char !== char.toLowerCase();\n\n if (isUpper) {\n if (i > 0) {\n const prevChar = input[i - 1];\n const isPrevUpper =\n prevChar === prevChar.toUpperCase() && prevChar !== prevChar.toLowerCase();\n\n // If previous is not uppercase, always insert dash.\n if (!isPrevUpper) {\n result += '-';\n } else if (i + 1 < input.length) {\n // Deal with initialisms and acronyms as if they are whole words (\"APIFinder\" -> \"api-finder\")\n // Previous was uppercase; insert dash only if the next character exists and is lowercase.\n const nextChar = input[i + 1];\n const isNextLower =\n nextChar === nextChar.toLowerCase() && nextChar !== nextChar.toUpperCase();\n if (isNextLower) {\n result += '-';\n }\n }\n }\n result += char.toLowerCase();\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n/** This is an internal-only export for testing purposes and should not be used in development */\nexport const testingStringUtils = {\n indexOfClosestClosingCurlyBrace,\n};\n","import { Canon, SerializedVerseRef, VerseRef } from '@sillsdev/scripture';\nimport {\n MarkerContent,\n MarkerObject,\n Usj,\n USJ_TYPE,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { BookInfo, ScrollGroupId } from './scripture.model';\nimport { at, isWhiteSpace, slice, split, startsWith } from '../string-util';\nimport { LocalizeKey } from '../extension-contributions/menus.model';\nimport { isString } from '../util';\n\n/**\n * All marker types that seem to be block-level according to `UsxFragmenter.AppendStartUsfm`. And\n * the `type` for USJ documents' top-level object because that is effectively a block\n *\n * Note: This \"block-level\" means the marker is in its own paragraph (a [CSS\n * Block](https://developer.mozilla.org/en-US/docs/Glossary/Block/CSS)) as opposed to being\n * in-line.\n */\nconst BLOCK_MARKER_TYPES = ['chapter', 'book', 'para', 'row', 'sidebar', USJ_TYPE];\n\nconst ZWSP = '\\u200B';\n\nconst scrBookData: BookInfo[] = [\n { shortName: 'ERR', fullNames: ['ERROR'], chapters: -1 },\n { shortName: 'GEN', fullNames: ['Genesis'], chapters: 50 },\n { shortName: 'EXO', fullNames: ['Exodus'], chapters: 40 },\n { shortName: 'LEV', fullNames: ['Leviticus'], chapters: 27 },\n { shortName: 'NUM', fullNames: ['Numbers'], chapters: 36 },\n { shortName: 'DEU', fullNames: ['Deuteronomy'], chapters: 34 },\n { shortName: 'JOS', fullNames: ['Joshua'], chapters: 24 },\n { shortName: 'JDG', fullNames: ['Judges'], chapters: 21 },\n { shortName: 'RUT', fullNames: ['Ruth'], chapters: 4 },\n { shortName: '1SA', fullNames: ['1 Samuel'], chapters: 31 },\n { shortName: '2SA', fullNames: ['2 Samuel'], chapters: 24 },\n { shortName: '1KI', fullNames: ['1 Kings'], chapters: 22 },\n { shortName: '2KI', fullNames: ['2 Kings'], chapters: 25 },\n { shortName: '1CH', fullNames: ['1 Chronicles'], chapters: 29 },\n { shortName: '2CH', fullNames: ['2 Chronicles'], chapters: 36 },\n { shortName: 'EZR', fullNames: ['Ezra'], chapters: 10 },\n { shortName: 'NEH', fullNames: ['Nehemiah'], chapters: 13 },\n { shortName: 'EST', fullNames: ['Esther'], chapters: 10 },\n { shortName: 'JOB', fullNames: ['Job'], chapters: 42 },\n { shortName: 'PSA', fullNames: ['Psalm', 'Psalms'], chapters: 150 },\n { shortName: 'PRO', fullNames: ['Proverbs'], chapters: 31 },\n { shortName: 'ECC', fullNames: ['Ecclesiastes'], chapters: 12 },\n { shortName: 'SNG', fullNames: ['Song of Solomon', 'Song of Songs'], chapters: 8 },\n { shortName: 'ISA', fullNames: ['Isaiah'], chapters: 66 },\n { shortName: 'JER', fullNames: ['Jeremiah'], chapters: 52 },\n { shortName: 'LAM', fullNames: ['Lamentations'], chapters: 5 },\n { shortName: 'EZK', fullNames: ['Ezekiel'], chapters: 48 },\n { shortName: 'DAN', fullNames: ['Daniel'], chapters: 12 },\n { shortName: 'HOS', fullNames: ['Hosea'], chapters: 14 },\n { shortName: 'JOL', fullNames: ['Joel'], chapters: 3 },\n { shortName: 'AMO', fullNames: ['Amos'], chapters: 9 },\n { shortName: 'OBA', fullNames: ['Obadiah'], chapters: 1 },\n { shortName: 'JON', fullNames: ['Jonah'], chapters: 4 },\n { shortName: 'MIC', fullNames: ['Micah'], chapters: 7 },\n { shortName: 'NAM', fullNames: ['Nahum'], chapters: 3 },\n { shortName: 'HAB', fullNames: ['Habakkuk'], chapters: 3 },\n { shortName: 'ZEP', fullNames: ['Zephaniah'], chapters: 3 },\n { shortName: 'HAG', fullNames: ['Haggai'], chapters: 2 },\n { shortName: 'ZEC', fullNames: ['Zechariah'], chapters: 14 },\n { shortName: 'MAL', fullNames: ['Malachi'], chapters: 4 },\n { shortName: 'MAT', fullNames: ['Matthew'], chapters: 28 },\n { shortName: 'MRK', fullNames: ['Mark'], chapters: 16 },\n { shortName: 'LUK', fullNames: ['Luke'], chapters: 24 },\n { shortName: 'JHN', fullNames: ['John'], chapters: 21 },\n { shortName: 'ACT', fullNames: ['Acts'], chapters: 28 },\n { shortName: 'ROM', fullNames: ['Romans'], chapters: 16 },\n { shortName: '1CO', fullNames: ['1 Corinthians'], chapters: 16 },\n { shortName: '2CO', fullNames: ['2 Corinthians'], chapters: 13 },\n { shortName: 'GAL', fullNames: ['Galatians'], chapters: 6 },\n { shortName: 'EPH', fullNames: ['Ephesians'], chapters: 6 },\n { shortName: 'PHP', fullNames: ['Philippians'], chapters: 4 },\n { shortName: 'COL', fullNames: ['Colossians'], chapters: 4 },\n { shortName: '1TH', fullNames: ['1 Thessalonians'], chapters: 5 },\n { shortName: '2TH', fullNames: ['2 Thessalonians'], chapters: 3 },\n { shortName: '1TI', fullNames: ['1 Timothy'], chapters: 6 },\n { shortName: '2TI', fullNames: ['2 Timothy'], chapters: 4 },\n { shortName: 'TIT', fullNames: ['Titus'], chapters: 3 },\n { shortName: 'PHM', fullNames: ['Philemon'], chapters: 1 },\n { shortName: 'HEB', fullNames: ['Hebrews'], chapters: 13 },\n { shortName: 'JAS', fullNames: ['James'], chapters: 5 },\n { shortName: '1PE', fullNames: ['1 Peter'], chapters: 5 },\n { shortName: '2PE', fullNames: ['2 Peter'], chapters: 3 },\n { shortName: '1JN', fullNames: ['1 John'], chapters: 5 },\n { shortName: '2JN', fullNames: ['2 John'], chapters: 1 },\n { shortName: '3JN', fullNames: ['3 John'], chapters: 1 },\n { shortName: 'JUD', fullNames: ['Jude'], chapters: 1 },\n { shortName: 'REV', fullNames: ['Revelation'], chapters: 22 },\n];\n\n/** The first book number */\nexport const FIRST_SCR_BOOK_NUM = 1;\n/** The last book number */\nexport const LAST_SCR_BOOK_NUM = scrBookData.length - 1;\n/** The first chapter number */\nexport const FIRST_SCR_CHAPTER_NUM = 1;\n/** The first verse number */\nexport const FIRST_SCR_VERSE_NUM = 1;\n\n/** The default Scripture reference, representing the first chapter and verse of the first book. */\nexport const defaultScrRef: SerializedVerseRef = {\n book: 'GEN',\n chapterNum: 1,\n verseNum: 1,\n};\n\n/**\n * Retrieves the number of chapters for a given book number.\n *\n * @param bookNum The number representing the book.\n * @returns The number of chapters in the book, or -1 if the book number is invalid.\n */\nexport const getChaptersForBook = (bookNum: number): number => {\n return scrBookData[bookNum]?.chapters ?? -1;\n};\n\n/**\n * Adjusts the book of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose book is to be adjusted.\n * @param offset The number of books to offset the current book by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted book. The chapter and verse numbers are\n * reset to 1. If the resulting book number exceeds the bounds of available books, it is clamped\n * to the nearest valid book.\n */\nexport const offsetBook = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n book: Canon.bookNumberToId(\n Math.max(\n FIRST_SCR_BOOK_NUM,\n Math.min(Canon.bookIdToNumber(scrRef.book) + offset, LAST_SCR_BOOK_NUM),\n ),\n ),\n chapterNum: 1,\n verseNum: 1,\n});\n\n/**\n * Adjusts the chapter of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose chapter is to be adjusted.\n * @param offset The number of chapters to offset the current chapter by. Positive values move\n * forward, negative values move backward.\n * @returns A new Scripture reference with the adjusted chapter. The verse number is reset to 1. The\n * chapter number is clamped to stay within valid bounds for the book.\n */\nexport const offsetChapter = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n chapterNum: Math.min(\n Math.max(FIRST_SCR_CHAPTER_NUM, scrRef.chapterNum + offset),\n getChaptersForBook(Canon.bookIdToNumber(scrRef.book)),\n ),\n verseNum: 1,\n});\n\n/**\n * Adjusts the verse of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose verse is to be adjusted.\n * @param offset The number of verses to offset the current verse by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted verse. The verse number is clamped to stay\n * within valid bounds for the chapter.\n */\nexport const offsetVerse = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n verseNum: Math.max(FIRST_SCR_VERSE_NUM, scrRef.verseNum + offset),\n});\n\n/**\n * https://github.com/ubsicap/Paratext/blob/master/ParatextData/SILScriptureExtensions.cs#L72\n *\n * Convert book number to a localized Id (a short description of the book). This should be used\n * whenever a book ID (short code) is shown to the user. It is primarily needed for people who do\n * not read Roman script well and need to have books identified in a alternate script (e.g. Chinese\n * or Russian)\n *\n * @param bookNumber\n * @param localizationLanguage In BCP 47 format\n * @param getLocalizedString Function that provides the localized versions of the book ids and names\n * asynchronously.\n * @returns\n */\nexport async function getLocalizedIdFromBookNumber(\n bookNumber: number,\n localizationLanguage: string,\n getLocalizedString: (item: {\n localizeKey: string;\n languagesToSearch?: string[];\n }) => Promise,\n) {\n const id = Canon.bookNumberToId(bookNumber);\n\n if (!startsWith(Intl.getCanonicalLocales(localizationLanguage)[0], 'zh'))\n return getLocalizedString({\n localizeKey: `LocalizedId.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n\n // For Chinese the normal book name is already fairly short.\n const bookName = await getLocalizedString({\n localizeKey: `Book.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n const parts = split(bookName, '-');\n // some entries had a second name inside ideographic parenthesis\n const parts2 = split(parts[0], '\\xff08');\n const retVal = parts2[0].trim();\n return retVal;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer, without considering the\n * verse.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCC(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum).BBBCCC;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCCVVV(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum)\n .BBBCCCVVV;\n}\n\n/**\n * Compares two Scripture references canonically.\n *\n * @param scrRef1 The first Scripture reference to compare.\n * @param scrRef2 The second Scripture reference to compare.\n * @returns A number indicating the result of the comparison: - Negative value if scrRef1 precedes\n * scrRef2 in sorting order. - Zero if scrRef1 and scrRef2 are equivalent in sorting order. -\n * Positive value if scrRef1 follows scrRef2 in sorting order.\n */\nexport function compareScrRefs(scrRef1: SerializedVerseRef, scrRef2: SerializedVerseRef): number {\n // TODO: consider edge cases for invalid references (current implementation should suffice for\n // all but the most extreme cases)\n return scrRefToBBBCCCVVV(scrRef1) - scrRefToBBBCCCVVV(scrRef2);\n}\n\n/** Get the localized string key for a given scroll group Id (or no scroll group if `undefined`) */\nexport function getLocalizeKeyForScrollGroupId(\n scrollGroupId: ScrollGroupId | undefined | 'undefined',\n): LocalizeKey {\n return `%scrollGroup_${scrollGroupId}%`;\n}\n\n/**\n * Gets a list of localized string keys for provided scroll group Ids. Uses\n * {@link getLocalizeKeyForScrollGroupId} internally\n *\n * @example\n *\n * ```typescript\n * getLocalizeKeysForScrollGroupIds([undefined, 0, 1, 2, 3, 4]);\n * // Gives localized string keys for the provided scroll group ids in an array\n * ```\n *\n * @param scrollGroupIds Scroll group ids to include\n * @returns List of localized string keys for scroll group Ids\n */\nexport function getLocalizeKeysForScrollGroupIds(scrollGroupIds: (ScrollGroupId | undefined)[]) {\n return scrollGroupIds.map((scrollGroupId) => getLocalizeKeyForScrollGroupId(scrollGroupId));\n}\n\n/**\n * Formats a Scripture reference.\n *\n * @param scrRef The Scripture reference to format.\n * @param optionOrLocalizedBookName Either 'id' (the default) to format using the \"standard\" (as\n * defined by SIL/UBS) 3-letter book ID, 'English' to format using the English book name spelled\n * out, or some other string (e.g., a localized book name, vernacular abbreviation, FCBH book id,\n * etc.) to use.\n * @param chapterVerseSeparator The character used to separate the chapter number from the verse\n * number. Default is a colon (:). Note: More than one character is allowed.\n * @param bookChapterSeparator The character used to separate the book from the chapter number.\n * Default is a single space. Note: More than one character is allowed.\n * @returns The formatted reference.\n */\nexport function formatScrRef(\n scrRef: SerializedVerseRef,\n optionOrLocalizedBookName?: 'id' | 'English' | string,\n chapterVerseSeparator?: string,\n bookChapterSeparator?: string,\n): string {\n let book: string;\n switch (optionOrLocalizedBookName ?? 'id') {\n case 'English':\n book = Canon.bookIdToEnglishName(scrRef.book);\n break;\n case 'id':\n book = scrRef.book;\n break;\n default:\n // We already dealt with undefined about in the switch, but TS is getting confused.\n book = optionOrLocalizedBookName ?? '';\n break;\n }\n return `${book}${bookChapterSeparator ?? ' '}${scrRef.chapterNum}${chapterVerseSeparator ?? ':'}${scrRef.verseNum}`;\n}\n\n/**\n * Represents the major sections of the Bible and extra materials. Used for grouping and filtering\n * books in the book selector.\n */\nexport enum Section {\n /** Old Testament books (Genesis through Malachi) */\n OT = 'OT',\n /** New Testament books (Matthew through Revelation) */\n NT = 'NT',\n /** Deuterocanonical books (e.g. Tobit, Judith, 1-2 Maccabees) */\n DC = 'DC',\n /** Additional materials not part of the biblical canon (e.g. XXA, XXB etc.) */\n Extra = 'Extra',\n}\n\n/**\n * Determines which section a book belongs to based on its ID\n *\n * @param bookId The ID of the book (e.g., 'GEN', 'MAT')\n * @returns The section (OT, NT, DC, or Extra) that the book belongs to\n * @throws Error if the book ID is not recognized or cannot be categorized\n */\nexport const getSectionForBook = (bookId: string): Section => {\n if (Canon.isBookOT(bookId)) return Section.OT;\n if (Canon.isBookNT(bookId)) return Section.NT;\n if (Canon.isBookDC(bookId)) return Section.DC;\n if (Canon.isExtraMaterial(bookId)) return Section.Extra;\n\n throw new Error(`Unknown section for book: ${bookId}`);\n};\n\n// #region white space functions\n\nconst nonSemanticWhiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u200B\\u0085]+$/;\n/**\n * Determines whether a string contains one or more \"non-meaningful\" white space characters\n * according to `ParatextData.dll` and no other characters.\n *\n * \"Non-meaningful\" white space according to `ParatextData.dll` is white space (according to\n * {@link isWhiteSpace}) other than IDEOGRAPHIC SPACE (U+3000) and also includes ZWSP (U+200B)\n *\n * This function is a direct translation of `UsfmToken.IsNonSemanticWhiteSpace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more \"non-meaningful\" white space characters and\n * no other characters, `false` otherwise\n */\nfunction isNonSemanticWhiteSpace(ch: string) {\n return nonSemanticWhiteSpaceRegex.test(ch);\n}\n\n// Note Zero-width joiner is at the start because eslint thinks we're trying to test for joined\n// characters if it's in the middle. https://eslint.org/docs/latest/rules/no-misleading-character-class\nconst invisibleCharOrWhiteSpaceRegex =\n /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/;\n/**\n * Determines whether a string contains one or more Paratext-9-selectable invisible characters or\n * white space characters and no other characters.\n *\n * Paratext-9-selectable invisible characters or white space characters are characters listed in\n * [Paratext 9's \"Whitespace and invisible characters\n * drop-down\"](https://paratext.myjetbrains.com/youtrack/issue/PTX-23623) that the user can insert\n * into the text:\n *\n * ```ts\n * // Zero-width joiner, em space, en space, space, no-break space, narrow no-break space,\n * // thin space, hair space, ideographic space, zero-width space, zero-width non-joiner,\n * // word joiner, left-to-right mark, right-to-left mark\n * /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: more white space characters are supported in Paratext 9 but are not listed in this\n * dropdown. See {@link isWhiteSpace} for more information.\n *\n * This function is a direct translation of `CharExtensions.IsInvisibleCharOrWhitespace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more Paratext-9-selectable invisible characters\n * or white space characters and no other characters, `false` otherwise\n */\nfunction isParatextSelectableInvisibleCharOrWhiteSpace(ch: string) {\n return invisibleCharOrWhiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts all control characters, carriage returns, and tabs into spaces and then strips duplicate\n * spaces.\n *\n * This is mainly intended for use with individual Scripture strings in USFM, USX, USJ, etc. format.\n * It is not intended to implement the [USFM white space definition or reduction\n * rules](https://docs.usfm.bible/usfm/3.1/whitespace.html) but strictly follows Paratext 9's white\n * space rules. It is generally best suited to normalizing spaces within a Scripture marker as it\n * removes all newlines.\n *\n * This function is a direct translation of `UsfmToken.RegularizeSpaces` from `ParatextData.dll`\n */\nexport function normalizeScriptureSpaces(str: string): string {\n let result = '';\n let lastCharWasSpace = false;\n // Initialized to placeholder previous character\n let prevCh = '\\0';\n for (let i = 0; i < str.length; i += 1) {\n const ch = str[i];\n // Control characters, CR/LF, and TAB become spaces\n if (ch.charCodeAt(0) < 32) {\n if (!lastCharWasSpace) result += ' ';\n lastCharWasSpace = true;\n } else if (\n !lastCharWasSpace &&\n ch === ZWSP &&\n i + 1 < str.length &&\n isNonSemanticWhiteSpace(str[i + 1])\n ) {\n // ZWSP is redundant if followed by a space\n } else if (isNonSemanticWhiteSpace(ch)) {\n // Keep other kinds of spaces\n if (!lastCharWasSpace) result += ch;\n lastCharWasSpace = true;\n } else if (isParatextSelectableInvisibleCharOrWhiteSpace(ch) && prevCh === ch) {\n // If the char is a whitespace or invisible char that has not already been handled and is a\n // duplicate, remove the duplicate\n } else {\n result += ch;\n lastCharWasSpace = false;\n }\n\n prevCh = ch;\n }\n\n return result;\n}\n\n/**\n * Determines whether the array of marker contents is \"empty\" meaning it is undefined, is an empty\n * array, or has just `undefined` or `''` in it\n *\n * Paratext passed up \"\\va \\va*\" which had no content array coming in translated to USJ, but the\n * editor put a content array with an empty string. So this will help them be considered equal.\n */\nfunction isUsjContentEmpty(content: MarkerContent[] | undefined) {\n if (!content) return true;\n if (content.length === 0) return true;\n return content.length === 1 && (content[0] === undefined || content[0] === '');\n}\n\n/**\n * Determines if the content object is the final child of a parent that is a block-level marker.\n *\n * We do not need to walk up the ancestors to the _closest_ block marker because spaces are\n * preserved at the end of in-line markers even at the end of a paragraph. We just need to know if\n * the parent is a block marker because space at the end of a block marker is not preserved.\n *\n * @param contentObject USJ document or marker to check\n * @param parent Parent object of `contentObject`. If `contentObject` is a USJ document, this should\n * be `undefined`.\n * @returns `true` if `contentObject` is the final child of the closest block-level marker; `false`\n * otherwise\n */\nfunction isAtEndOfBlockMarker(\n contentObject: MarkerContent | Usj,\n parent: MarkerObject | Usj | undefined,\n) {\n if (!parent) return false;\n // If the parent is not a block-level marker, the content object is not at the end of a block-level marker\n if (!BLOCK_MARKER_TYPES.includes(parent.type)) return false;\n\n if (!parent.content)\n throw new Error(\n `Parent ${JSON.stringify(parent)} of ${JSON.stringify(contentObject)} does not have a content array! This should not happen!`,\n );\n // If the content object is not the last in its parent, it is not at the end of a block-level marker\n if (contentObject !== parent.content[parent.content.length - 1]) return false;\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n *\n * @param a First USJ document or marker to compare\n * @param aParent Parent object of `a`. If `a` is a USJ document, this should be `undefined`.\n * @param b Second USJ document or marker to compare\n * @param bParent Parent object of `b`. If `b` is a USJ document, this should be `undefined`.\n */\nfunction areUsjContentsEqualExceptWhitespaceInternal(\n a: MarkerContent | Usj | undefined,\n aParent: MarkerObject | Usj | undefined,\n b: MarkerContent | Usj | undefined,\n bParent: MarkerObject | Usj | undefined,\n) {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aIsString = isString(a);\n const bIsString = isString(b);\n if (aIsString && bIsString) {\n const aNormalized = normalizeScriptureSpaces(a);\n const bNormalized = normalizeScriptureSpaces(b);\n // Check to see if their regularized forms are equal. If so, they're equal. If not, they may still\n // be equal if they are at the end of a block-level marker and the only difference is space at the end.\n // If at the end of a block-level marker with space at the end, take off the final space and compare again\n if (aNormalized !== bNormalized) {\n // If neither ends in whitespace, they are not equal\n if (!isWhiteSpace(at(aNormalized, -1) ?? '') && !isWhiteSpace(at(bNormalized, -1) ?? ''))\n return false;\n\n // If either is not at the end of a block-level marker, they are not equal\n if (!isAtEndOfBlockMarker(a, aParent)) return false;\n if (!isAtEndOfBlockMarker(b, bParent)) return false;\n\n // Trim the end of each string\n let aTrimmed = aNormalized;\n while (isWhiteSpace(at(aTrimmed, -1) ?? '')) aTrimmed = slice(aTrimmed, 0, -1);\n let bTrimmed = bNormalized;\n while (isWhiteSpace(at(bTrimmed, -1) ?? '')) bTrimmed = slice(bTrimmed, 0, -1);\n // If they are not equal after trimming, they are not equal\n if (aTrimmed !== bTrimmed) return false;\n }\n } else if (!aIsString && !bIsString) {\n // We have determined they are not strings, so they must be objects with various simple properties and possibly a `content` array\n const aObject: MarkerObject | Usj = a;\n const bObject: MarkerObject | Usj = b;\n // Check if all properties are present and equal. We will check `content` separately\n // Seems Object.keys doesn't support proper key typing? Asserting to the key types\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const aKeys = Object.keys(aObject).filter(\n (key) => key !== 'content',\n ) as (keyof typeof aObject)[];\n if (aKeys.length !== Object.keys(bObject).filter((key) => key !== 'content').length)\n return false;\n if (aKeys.some((key) => !(key in bObject) || aObject[key] !== bObject[key])) return false;\n\n // Check that both `content`s are equal\n const isAContentEmpty = isUsjContentEmpty(aObject.content);\n const isBContentEmpty = isUsjContentEmpty(bObject.content);\n // If one is empty and the other is not, they are not equal\n if (isAContentEmpty !== isBContentEmpty) return false;\n // If both are empty, they are equal. If neither is empty, do more testing\n if (!isAContentEmpty && !isBContentEmpty) {\n // Although TypeScript doesn't realize `!isUsjContentEmpty(a)` means a is an array, we know\n // they are both arrays, so we can access the content with a bang.\n /* eslint-disable no-type-assertion/no-type-assertion */\n let aContent: MarkerContent[] = aObject.content!;\n let bContent: MarkerContent[] = bObject.content!;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const aLast = aContent[aContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(aObject.type) && isString(aLast) && isWhiteSpace(aLast))\n aContent = aContent.slice(0, -1);\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const bLast = bContent[bContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(bObject.type) && isString(bLast) && isWhiteSpace(bLast))\n bContent = bContent.slice(0, -1);\n\n if (aContent.length !== bContent.length) return false;\n for (let i = 0; i < aContent.length; i += 1) {\n if (\n !areUsjContentsEqualExceptWhitespaceInternal(aContent[i], aObject, bContent[i], bObject)\n )\n return false;\n }\n }\n } else {\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n */\nexport function areUsjContentsEqualExceptWhitespace(a: Usj | undefined, b: Usj | undefined) {\n return areUsjContentsEqualExceptWhitespaceInternal(a, undefined, b, undefined);\n}\n\n// #endregion\n","/** Function to run to dispose of something. Returns true if successfully unsubscribed */\nexport type Unsubscriber = () => boolean;\n\n/**\n * Returns an Unsubscriber function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers All unsubscribers to aggregate into one unsubscriber\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscribers = (unsubscribers: Unsubscriber[]): Unsubscriber => {\n return (...args) => {\n // Run the unsubscriber for each handler\n const unsubs = unsubscribers.map((unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return unsubs.every((success) => success);\n };\n};\n\n/**\n * Function to run to dispose of something that runs asynchronously. The promise resolves to true if\n * successfully unsubscribed\n */\nexport type UnsubscriberAsync = () => Promise;\n\n/**\n * Returns an UnsubscriberAsync function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers - All unsubscribers to aggregate into one unsubscriber.\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscriberAsyncs = (\n unsubscribers: (UnsubscriberAsync | Unsubscriber)[],\n): UnsubscriberAsync => {\n return async (...args) => {\n // Run the unsubscriber for each handler\n const unsubPromises = unsubscribers.map(async (unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return (await Promise.all(unsubPromises)).every((success) => success);\n };\n};\n","import {\n Usj,\n type MarkerContent,\n type MarkerObject,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { MarkersMap } from './markers-maps/markers-map-3.0.model';\n\n/** USJ content node type for a book */\nexport const BOOK_TYPE = 'book';\n\n/** USJ content node type for a chapter */\nexport const CHAPTER_TYPE = 'chapter';\n\n/** USJ content node type for a verse */\nexport const VERSE_TYPE = 'verse';\n\n/** 3-character code that indicates there is no known book */\nexport const NO_BOOK_ID = '***';\n\n/**\n * Represents a book, chapter, verse, and offset\n *\n * @deprecated 23 October 2025. Use {@link UsfmVerseLocation} or {@link UsfmVerseRefVerseLocation}\n * instead.\n */\nexport type VerseRefOffset = {\n verseRef: SerializedVerseRef;\n offset: number;\n};\n\n// #region Serializable USFM locations\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. If only a verse ref is provided, the offset is assumed to be 0.\n *\n * The USJ representation of the positions represented by this type are {@link UsjLocation}. Both are\n * absolute verse reference locations.\n *\n * {@link UsjDocumentLocation} also represents positions of this type, but those locations are\n * relative to a specific USJ document rather than being absolute verse reference locations like\n * this type. The closest equivalent concept in USFM to {@link UsjDocumentLocation} is a string\n * character index in a USFM document; such an index is relative to a specific USFM document rather\n * than indicating an absolute position in a Scripture text.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsfmScrRefVerseLocation} for details.\n */\nexport type UsfmVerseLocation =\n | UsfmVerseRefVerseLocation\n | SerializedVerseRef\n | UsfmScrRefVerseLocation;\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM\n */\nexport type UsfmVerseRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n verseRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. This uses `scrRef` instead of `verseRef` for backwards compatibility.\n *\n * @deprecated 13 November 2025. Use {@link UsfmVerseLocation} instead.\n */\nexport type UsfmScrRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n scrRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n// #endregion Serializable USFM locations\n\n// #region Serializable absolute USJ locations\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from either the start of the book or the chapter\n * depending on the type of location used.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the following USJ documents:\n *\n * - {@link UsjBookLocation} - a USJ document that contains the entire specified book. The first\n * content entry of the top-level `USJ` marker is the `id` marker of the book.\n * - {@link UsjChapterLocation} - a USJ document that contains only the specified chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjLocation =\n | UsjChapterLocation\n | UsjBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the book specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains the entire specified book. The first content entry of the top-level `USJ` marker is the\n * `id` marker of the book.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjBookLocation =\n | UsjVerseRefBookLocation\n | UsjFlatBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the chapter specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains only the specified chapter in the specified book. If the chapter number is 1, the first\n * content entry of the top-level `USJ` marker is the `id` marker of the book because the intro\n * content before chapter 1 is part of chapter 1. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsjFlatTextChapterLocation} for details. Also note that {@link UsjFlatTextChapterLocation}\n * can only be a marker- or text-based location and will _not_ follow the generic type specified as\n * `TDocumentLocation`.\n */\nexport type UsjChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> =\n | UsjVerseRefChapterLocation\n | UsjFlatChapterLocation\n | UsjFlatTextChapterLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified in the verse ref. The rest of the verse ref\n * is meaningless and can be disregarded.\n */\nexport type UsjVerseRefBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (see\n * {@link UsjVerseRefChapterLocation})\n */\n granularity: 'book';\n /** USJ document location specifying where in the book the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the chapter specified in the verse ref. The rest of the verse\n * ref is meaningless and can be disregarded.\n */\nexport type UsjVerseRefChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which chapter in which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (can alternatively be 'book';\n * {@link UsjVerseRefBookLocation})\n */\n granularity?: 'chapter';\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified.\n */\nexport type UsjFlatBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID, chapter number, and location in USJ space that point to a specific location in USJ.\n * The location in USJ space starts from the start of the chapter specified.\n */\nexport type UsjFlatChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = UsjFlatBookLocation & {\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n};\n\n/**\n * A book ID, chapter number, and text location or beginning of marker location in USJ space that\n * point to a specific location in USJ. The location in USJ space starts from the start of the\n * chapter specified. This can only represent the beginning of a marker or a location in the USJ\n * document's text content.\n *\n * @deprecated 13 November 2025. This type of location is not generic enough to support all\n * positions we need to be able to represent in USJ space. Use other forms of\n * {@link UsjChapterLocation} instead.\n */\nexport type UsjFlatTextChapterLocation = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n} & ((UsjMarkerLocation & { offset?: undefined }) | UsjTextContentLocation);\n\n// #endregion Serializable absolute USJ locations\n\n// #region Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * JSON path to a {@link MarkerObject}, {@link Usj}, or text content string in the current USJ\n * document.\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type ContentJsonPath =\n | ''\n | `$`\n | `$.content[${number}]`\n | `$.content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]`;\n\n/**\n * JSON path to the `marker` or an attribute on a {@link MarkerObject} or {@link Usj} in the current\n * USJ document. Note that it seems you must use `['bracket notation']` rather than `.dot` notation\n * if there are symbols other than underscore in the property name\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type PropertyJsonPath =\n | ''\n | `$.${string}`\n | `$['${string}']`\n | `$.content[${number}].${string}`\n | `$.content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]['${string}']`;\n\n/**\n * A JSONPath query to a {@link MarkerContent}, {@link Usj}, or property within a USJ document and\n * additional information that point to a specific location in that USJ document.\n *\n * This type does not include a verse reference because the JSONPath is relative to a specific USJ\n * document; that USJ document may have a book, a chapter, or something else in it. Use\n * {@link UsjLocation} to specify which USJ document this location is relative to, making the\n * location an absolute verse reference location. The closest equivalent concept in USFM to this\n * relative document location is a string character index in a USFM document; such an index is\n * relative to a specific USFM document rather than indicating an absolute position in a Scripture\n * text.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types:\n *\n * - The second slash in `optbreak`'s USFM representation `//` (literally not representable)\n * - Nested marker prefix on opening markers like `+` for character markers (literally not\n * representable)\n * - The bar `|` that indicates the start of closing marker attributes (no official representation)\n * - The equals sign for closing marker attributes (no official representation)\n * - The quotes around closing marker attribute values (no official representation)\n * - The space between closing marker attributes (no official representation)\n *\n * Also note that the following types do not specify a concrete location that is actually in the USJ\n * document but represent a USFM location relative to the most similar thing in USJ that there is:\n *\n * - {@link UsjClosingMarkerLocation} - there are no distinct closing objects in JSON; there is a\n * common syntax for closing every object, but it is only one character and is on every single\n * object as opposed to USFM closing markers which are multiple characters long and are only\n * sometimes present.\n * - {@link UsjAttributeKeyLocation} - when the attribute whose key is being pointed to is an attribute\n * marker in USFM, the `keyOffset` does not apply to the USJ attribute name (e.g. `altnumber`) but\n * to the USFM attribute marker name (e.g. `ca`).\n * - {@link UsjAttributeMarkerLocation} - attribute markers are just properties in JSON; they do not\n * have their own object such that they would have an opening that can be pointed to in the JSON\n * like they have their own opening in USFM.\n * - {@link UsjClosingAttributeMarkerLocation} - attribute markers are just properties in JSON, plus\n * they are in the same situation as {@link UsjClosingMarkerLocation} as detailed above.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n */\nexport type UsjDocumentLocation =\n | UsjMarkerLocation\n | UsjClosingMarkerLocation\n | UsjTextContentLocation\n | UsjPropertyValueLocation\n | UsjAttributeKeyLocation\n | UsjAttributeMarkerLocation\n | UsjClosingAttributeMarkerLocation;\n\n/**\n * A JSONPath query to a {@link MarkerObject} or {@link Usj} node. Indicates the very beginning of\n * that marker (at the backslash in USFM).\n */\nexport type UsjMarkerLocation = {\n /** JSON path to the marker object the location is pointing to. */\n jsonPath: ContentJsonPath;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of a\n * {@link MarkerObject} or {@link Usj} node.\n */\nexport type UsjClosingMarkerLocation = {\n /**\n * JSON path to the marker object whose closing marker the location is pointing to. The offset\n * applies to the closing marker representation of that marker (for example, `\\nd*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation.\n */\n closingMarkerOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a text content string in a {@link MarkerObject.content}\n * array.\n */\nexport type UsjTextContentLocation = {\n /**\n * JSON path to the text content string the location is pointing to. The offset applies to this\n * text string.\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the text content string where this location is pointing. The location is\n * at this offset within the text content string.\n */\n offset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a property (`marker` or an attribute) value string in a\n * {@link MarkerObject} or {@link Usj}. The property cannot be `type` because `type`'s value has no\n * representation in USFM.\n *\n * To represent a location in an attribute's key, use {@link UsjAttributeKeyLocation}.\n */\nexport type UsjPropertyValueLocation = {\n /**\n * JSON path to the property the location is pointing to. The offset applies to this property's\n * value string.\n */\n jsonPath: PropertyJsonPath;\n /**\n * The character index in the property's value string where this location is pointing. The\n * location is at this offset within the property's value string.\n */\n propertyOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in an attribute key string in a {@link MarkerObject} or\n * {@link Usj}. The property cannot be `type` or `marker` because these properties' keys have no\n * representation in USFM. The property also cannot be any special attribute whose key doesn't have\n * a text representation in USFM like default attribute, leading attribute, text content attribute\n *\n * To represent a location in an attribute's value, use {@link UsjPropertyValueLocation}.\n */\nexport type UsjAttributeKeyLocation = {\n /**\n * JSON path to the marker whose attribute key the location is pointing to. The offset applies to\n * this attribute's key string unless the attribute is an attribute marker in USFM.\n */\n jsonPath: ContentJsonPath;\n /** Attribute name on the marker object whose key this location is pointing to. */\n keyName: string;\n /**\n * The character index in the attribute's key string where this location is pointing.\n *\n * If the attribute is an attribute marker in USFM, the location is at this offset within the\n * marker name for this attribute marker (for example, `c`'s `altnumber` attribute has attribute\n * marker `ca`, so its `keyOffset` applies to `ca`).\n *\n * If the attribute is not an attribute marker in USFM, the location is at this offset within the\n * attribute's key string.\n */\n keyOffset: number;\n};\n\n/**\n * A JSONPath query to an attribute marker derived from an attribute on a {@link MarkerObject} or\n * {@link Usj}. Indicates the very beginning of that marker (at the backslash in USFM).\n */\nexport type UsjAttributeMarkerLocation = {\n /** JSON path to the marker whose attribute marker the location is pointing to. */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of an attribute marker\n * derived from an attribute on a {@link MarkerObject} or {@link Usj}.\n */\nexport type UsjClosingAttributeMarkerLocation = {\n /**\n * JSON path to the marker whose attribute marker's closing marker the location is pointing to.\n * The offset applies to the closing marker representation of that attribute marker (for example,\n * `\\ca*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation of the attribute marker.\n */\n keyClosingMarkerOffset: number;\n};\n\n// #endregion Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * Node in a USJ object (including the top-level Usj object) and its location in the document. You\n * must make sure you only add `node`s that correspond to the appropriate type of\n * `UsjDocumentLocation` (e.g. if `documentLocation` is a {@link UsjTextContentLocation}, `node` must\n * be a text content string)\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjNodeAndDocumentLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n node: TDocumentLocation extends UsjTextContentLocation ? string : MarkerObject | Usj;\n documentLocation: TDocumentLocation;\n};\n\n/** Result of a search for text within a USJ object */\nexport type UsjSearchResult = {\n /**\n * Beginning location in the USJ document of the search result. The text is inclusive of this\n * location, meaning this is the location of the first character of the found text\n */\n start: UsjNodeAndDocumentLocation;\n /**\n * Ending location in the USJ document of the search result. The text is exclusive of this\n * location, meaning this is the location right after the last character of the found text\n */\n end: UsjNodeAndDocumentLocation;\n /**\n * The matching Scripture text (not USFM string) that was found between the start and end\n * locations\n */\n text: string;\n};\n\n/**\n * Set of options to provide to `UsjReaderWriter`'s constructor to customize how the reading and\n * writing works\n */\nexport type UsjReaderWriterOptions = {\n /**\n * A map of all USFM/USX/USJ markers and some information about them. Used for translating between\n * the formats\n *\n * Defaults to trying to use a built-in markers map that matches the version of the USJ passed in.\n *\n * Currently supported built-in USFM versions:\n *\n * - 3.0/3.0.x\n */\n markersMap?: MarkersMap;\n /**\n * Whether the transformations should preserve invisible characters as in Paratext 9\n * (`ScrText.Settings.AllowInvisibleChars`).\n *\n * Defaults to `false`\n */\n shouldAllowInvisibleCharacters?: boolean;\n};\n\n/** Utilities for reading from and writing to `Usj` objects */\nexport interface IUsjReaderWriter {\n /**\n * Return a copy of text following a given starting point\n *\n * @param start Point where text extraction will start\n * @param desiredLength Length of text to extract from this USJ data\n */\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string;\n /**\n * Return a copy of text between two points\n *\n * @param start Point where text extraction will start\n * @param end Point where text extraction will end\n * @param maxLength Maximum length of string to return (defaults to 100)\n * @returns Text between the two points, capped at length `maxLength`\n */\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number,\n ): string;\n /**\n * Given a starting point, find the next location in this USJ data that matches the given text\n *\n * @param start Point where the search for `text` will start\n * @param text Text to find. Note you can use an empty string to find the closest text in or after\n * the `start` point.\n * @param maxTextLengthToSearch Maximum length of text to search before stopping (default is 1000)\n * @returns Object containing the USJ node where `text` begins (it might be split across nodes),\n * offset within that node that indicates where `text` begins, and a JSONPath string that\n * indicates the location of the of USJ node within `usj`. Note that if the USJ node returned is\n * an object, it is the same object that is within this USJ data. So if you change it, you are\n * changing this USJ data.\n */\n findNextLocationOfMatchingText(\n start: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number,\n ): UsjNodeAndDocumentLocation | undefined;\n /** Find the first value matching the given JSONPath query within this USJ data */\n findSingleValue(jsonPathQuery: string): T | undefined;\n /** Find the parent of the first value matching the given JSONPath query within this USJ data */\n findParent(jsonPathQuery: string): T | undefined;\n /**\n * Convert a JSONPath query into a SerializedVerseRef and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Convert a JSONPath query into a USJ node, JSONPath, and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @returns USJ node, JSONPath, and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n */\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation;\n /** Build a JSONPath query that uniquely identifies the given node with this USJ data. */\n nodeToJsonPath(node: MarkerObject): ContentJsonPath;\n /**\n * Determine the location in the USFM representation of this data that corresponds to the location\n * of a node somewhere within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USFM location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Determine the location in the USJ document that corresponds to the location of a node somewhere\n * within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USJ location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @returns Node, JSONPath, and offset info representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n */\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation;\n /**\n * Remove all nodes from this USJ data that match a given search function.\n *\n * @param searchFunction Function that returns `true` if the given node should be removed\n * @returns Number of nodes removed\n */\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number;\n /**\n * Search for matches of a regular expression within this USJ's text data\n *\n * @param regex Regular expression to search for. Specify the global flag to find all matches.\n * @returns Array of `UsjSearchResult` objects that match the given regular expression\n */\n search(regex: RegExp): UsjSearchResult[];\n /** Transforms the USJ document into USFM */\n toUsfm(): string;\n /**\n * Get the index in the USFM representation of this data relative to the start of the document\n * that corresponds to the absolute verse location in USFM space passed in\n *\n * @param usfmVerseLocation The location in USFM space relative to a verse to get the index for\n * @returns Index in the USFM representation of this data relative to the start of the document\n */\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number;\n /**\n * Get the node + offset and JSONPath query within this USJ data of the first encountered string\n * after the provided USFM location for a specific verse in a USJ document.\n *\n * Note: this may return a node that is in a subsequent verse or even chapter depending on how\n * much content the USJ data contains. It simply looks through the rest of the USJ data for the\n * first text node and returns that.\n *\n * @param usfmVerseLocation Indicates the location in USFM space (book, chapter, verse, character\n * offset) to find the next text for\n * @returns Object containing the first USJ text node after `verseRef`, and a JSONPath string that\n * indicates the location of the USJ text node within this USJ data.\n * @throws Error if there is no text after `usfmVerseLocation`\n * @throws Error if `usfmVerseLocation` does not point to a valid location in this USJ data\n */\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a location in USJ space within this USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ location within the USJ document indicated by\n * `usfmVerseLocation`.\n */\n usfmVerseLocationToUsjDocumentLocation(usfmVerseLocation: UsfmVerseLocation): UsjDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a node and location in USJ space within this\n * USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ node and location within the USJ document indicated by\n * `usfmVerseLocation`. Note that if the USJ node returned is an object, it is the same object\n * that is within this USJ data. So if you change it, you are changing this USJ data.\n */\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Inform this UsjReaderWriter that the underlying USJ object changed. This is needed to clear\n * caches used when querying.\n */\n usjChanged(): void;\n /**\n * Convert a location in USJ space within this USJ data into a location in USFM space.\n *\n * @param usjLocation Location in USJ space - a jsonPath and other information about where the\n * location is\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Location in USFM space that is equivalent to the USJ location specified\n * @throws If not able to find the location in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n}\n","import { MarkerObject, MarkerContent } from '@eten-tech-foundation/scripture-utilities';\n\n/** Gets the default caller sequence to use to generate callers for textual notes. */\nexport function getDefaultCallerSequence(): string[] {\n return Array.from({ length: 26 }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i));\n}\n\n/**\n * Gets a caller to be displayed for a textual note. This is primarily useful as a helper function\n * in {@link getFormatCallerFunction} , but it might be useful in stories, UI preview code, etc.\n *\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n * @param n Zero-based index into the caller list.\n */\nexport function getNthCaller(n: number, callers?: string[]): string {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n return callerList[n % callerList.length];\n}\n\n/**\n * Gets a function that provides a (stable) caller based on a given sequence of textual notes.\n *\n * @param footnotes Sequence of footnotes, cross-references, and/or end-notes.\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n */\nexport function getFormatCallerFunction(footnotes: MarkerObject[], callers: string[] | undefined) {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n // Precompute a stable sequence for '+' callers\n const plusSequenceMap = (() => {\n const map = new Map();\n let autoCallerCounter = 0;\n footnotes.forEach((fn, idx) => {\n if (fn.caller === '+') {\n map.set(idx, getNthCaller(autoCallerCounter, callerList));\n autoCallerCounter += 1;\n }\n });\n return map;\n })();\n\n return (caller: string | undefined, index: number): string | undefined => {\n if (caller === '+') {\n const formattedCaller = plusSequenceMap.get(index);\n if (!formattedCaller) {\n console.warn(`Caller index ${index} out of range for '+' callers`);\n return '?'; // Out of range'\n }\n return formattedCaller;\n }\n if (caller === '-') return undefined;\n return caller;\n };\n}\n\n/**\n * Extract footnotes from an array of `MarkerContent` objects.\n *\n * @param contents - An array of `MarkerContent` objects\n * @returns An array of MarkerObjects representing all textual notes found in the contents.\n */\nexport function extractFootnotesFromUsjContent(contents?: MarkerContent[]): MarkerObject[] {\n const footnotes: MarkerObject[] = [];\n if (!contents || contents.length === 0) return footnotes;\n\n function traverse(item: MarkerContent) {\n if (typeof item === 'string') return; // plain text node, ignore\n\n // item is a MarkerObject\n if (item.type === 'note') {\n footnotes.push(item);\n } else if (Array.isArray(item.content) && item.content.length > 0) {\n item.content.forEach(traverse);\n }\n }\n\n contents.forEach(traverse);\n return footnotes;\n}\n","/** Options for calculating resizable pane size limits. */\nexport type PaneSizeLimitsOptions = {\n /**\n * The thickness of the splitter between the two panes, in pixels.\n *\n * @default 4\n */\n splitterThicknessPx?: number;\n /**\n * Minimum size (height or width) of the secondary pane (the pane whose size is to be\n * constrained), in pixels. Ensures the secondary pane never shrinks below this size, if\n * possible.\n *\n * @default 20\n */\n secondaryPaneMinSizePx?: number;\n /**\n * Minimum size (height or width) of the main pane (the other pane), in pixels. Ensures the main\n * pane always has some visible content.\n *\n * @default 60\n */\n mainPaneMinSizePx?: number;\n /**\n * Absolute minimum percentage of the total available that the secondary pane can occupy. Used to\n * avoid the pane collapsing completely (e.g., if the available height or width is less than the\n * combined minimums).\n *\n * @default 3\n */\n absoluteMinPercent?: number;\n /**\n * Absolute maximum percentage of the total available that the secondary pane can occupy. Can be\n * used to keep the \"main\" pane from being overwhelmed by the size of the secondary pane.\n *\n * @default 90\n */\n absoluteMaxPercent?: number;\n};\n\n/**\n * Calculates the minimum and maximum size (as percentages) for a resizable pane in a two-pane\n * layout based on the total available height or width and optional constraints.\n *\n * The returned percentages indicate the allowable range for the secondary pane (the one whose size\n * limits are being computed). When applied, they ensure that pane never shrinks below its minimum\n * or grows beyond its maximum, leaving adequate space for both panes.\n *\n * @param availablePx - Total height or width available for both panes, in pixels.\n * @param options - Optional parameters for customizing pane size constraints.\n * @returns An object containing the minimum and maximum percentages the secondary pane can occupy:\n * `{ minPercent, maxPercent }`.\n */\nexport function getPaneSizeLimits(\n availablePx: number,\n options: PaneSizeLimitsOptions = {},\n): { minPercent: number; maxPercent: number } {\n const {\n splitterThicknessPx = 4,\n secondaryPaneMinSizePx = 20,\n mainPaneMinSizePx = 60,\n absoluteMinPercent = 3,\n absoluteMaxPercent = 90,\n } = options;\n\n const usableHeightPx = availablePx - splitterThicknessPx;\n\n let minPercent: number;\n let maxPercent: number;\n\n if (usableHeightPx < secondaryPaneMinSizePx + mainPaneMinSizePx) {\n minPercent = absoluteMinPercent;\n maxPercent = absoluteMaxPercent;\n } else {\n maxPercent = Math.min(\n Math.floor(((usableHeightPx - mainPaneMinSizePx) / usableHeightPx) * 100),\n absoluteMaxPercent,\n );\n\n minPercent = Math.min(\n Math.max(Math.ceil((secondaryPaneMinSizePx / usableHeightPx) * 100), absoluteMinPercent),\n maxPercent,\n );\n }\n\n return { minPercent, maxPercent };\n}\n","var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n/**\n * Combine two comparators into a single comparators.\n */\nfunction combineComparators(comparatorA, comparatorB) {\n return function isEqual(a, b, state) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nfunction createIsCircular(areItemsEqual) {\n return function isCircular(a, b, state) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n var cache = state.cache;\n var cachedA = cache.get(a);\n var cachedB = cache.get(b);\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n cache.set(a, b);\n cache.set(b, a);\n var result = areItemsEqual(a, b, state);\n cache.delete(a);\n cache.delete(b);\n return result;\n };\n}\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nfunction getStrictProperties(object) {\n return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));\n}\n/**\n * Whether the object contains the property passed as an own property.\n */\nvar hasOwn = Object.hasOwn ||\n (function (object, property) {\n return hasOwnProperty.call(object, property);\n });\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nfunction sameValueZeroEqual(a, b) {\n return a === b || (!a && !b && a !== a && b !== b);\n}\n\nvar PREACT_VNODE = '__v';\nvar PREACT_OWNER = '__o';\nvar REACT_OWNER = '_owner';\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys = Object.keys;\n/**\n * Whether the arrays are equal in value.\n */\nfunction areArraysEqual(a, b, state) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the dates passed are equal in value.\n */\nfunction areDatesEqual(a, b) {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n/**\n * Whether the errors passed are equal in value.\n */\nfunction areErrorsEqual(a, b) {\n return (a.name === b.name &&\n a.message === b.message &&\n a.cause === b.cause &&\n a.stack === b.stack);\n}\n/**\n * Whether the functions passed are equal in value.\n */\nfunction areFunctionsEqual(a, b) {\n return a === b;\n}\n/**\n * Whether the `Map`s are equal in value.\n */\nfunction areMapsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.entries();\n var aResult;\n var bResult;\n var index = 0;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.entries();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (matchedIndices[matchIndex]) {\n matchIndex++;\n continue;\n }\n var aEntry = aResult.value;\n var bEntry = bResult.value;\n if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) &&\n state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n index++;\n }\n return true;\n}\n/**\n * Whether the numbers are equal in value.\n */\nvar areNumbersEqual = sameValueZeroEqual;\n/**\n * Whether the objects are equal in value.\n */\nfunction areObjectsEqual(a, b, state) {\n var properties = keys(a);\n var index = properties.length;\n if (keys(b).length !== index) {\n return false;\n }\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n if (!isPropertyEqual(a, b, state, properties[index])) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nfunction areObjectsEqualStrict(a, b, state) {\n var properties = getStrictProperties(a);\n var index = properties.length;\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n var property;\n var descriptorA;\n var descriptorB;\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index];\n if (!isPropertyEqual(a, b, state, property)) {\n return false;\n }\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n if ((descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nfunction arePrimitiveWrappersEqual(a, b) {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n/**\n * Whether the regexps passed are equal in value.\n */\nfunction areRegExpsEqual(a, b) {\n return a.source === b.source && a.flags === b.flags;\n}\n/**\n * Whether the `Set`s are equal in value.\n */\nfunction areSetsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.values();\n var aResult;\n var bResult;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.values();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (!matchedIndices[matchIndex] &&\n state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the TypedArray instances are equal in value.\n */\nfunction areTypedArraysEqual(a, b) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the URL instances are equal in value.\n */\nfunction areUrlsEqual(a, b) {\n return (a.hostname === b.hostname &&\n a.pathname === b.pathname &&\n a.protocol === b.protocol &&\n a.port === b.port &&\n a.hash === b.hash &&\n a.username === b.username &&\n a.password === b.password);\n}\nfunction isPropertyEqual(a, b, state, property) {\n if ((property === REACT_OWNER ||\n property === PREACT_OWNER ||\n property === PREACT_VNODE) &&\n (a.$$typeof || b.$$typeof)) {\n return true;\n }\n return (hasOwn(b, property) &&\n state.equals(a[property], b[property], property, property, a, b, state));\n}\n\nvar ARGUMENTS_TAG = '[object Arguments]';\nvar BOOLEAN_TAG = '[object Boolean]';\nvar DATE_TAG = '[object Date]';\nvar ERROR_TAG = '[object Error]';\nvar MAP_TAG = '[object Map]';\nvar NUMBER_TAG = '[object Number]';\nvar OBJECT_TAG = '[object Object]';\nvar REG_EXP_TAG = '[object RegExp]';\nvar SET_TAG = '[object Set]';\nvar STRING_TAG = '[object String]';\nvar URL_TAG = '[object URL]';\nvar isArray = Array.isArray;\nvar isTypedArray = typeof ArrayBuffer === 'function' && ArrayBuffer.isView\n ? ArrayBuffer.isView\n : null;\nvar assign = Object.assign;\nvar getTag = Object.prototype.toString.call.bind(Object.prototype.toString);\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nfunction createEqualityComparator(_a) {\n var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areErrorsEqual = _a.areErrorsEqual, areFunctionsEqual = _a.areFunctionsEqual, areMapsEqual = _a.areMapsEqual, areNumbersEqual = _a.areNumbersEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual, areUrlsEqual = _a.areUrlsEqual;\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a, b, state) {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n // If either of the items are nullish and fail the strictly equal check\n // above, then they must be unequal.\n if (a == null || b == null) {\n return false;\n }\n var type = typeof a;\n if (type !== typeof b) {\n return false;\n }\n if (type !== 'object') {\n if (type === 'number') {\n return areNumbersEqual(a, b, state);\n }\n if (type === 'function') {\n return areFunctionsEqual(a, b, state);\n }\n // If a primitive value that is not strictly equal, it must be unequal.\n return false;\n }\n var constructor = a.constructor;\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n // Constructors should match, otherwise there is potential for false positives\n // between class and subclass or custom object and POJO.\n if (constructor !== b.constructor) {\n return false;\n }\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid capturing the string tag.\n if (constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing\n // the string tag or doing an `instanceof` check.\n if (isArray(a)) {\n return areArraysEqual(a, b, state);\n }\n // `isTypedArray()` works on all possible TypedArray classes, so we can avoid\n // capturing the string tag or comparing against all possible constructors.\n if (isTypedArray != null && isTypedArray(a)) {\n return areTypedArraysEqual(a, b, state);\n }\n // Try to fast-path equality checks for other complex object types in the\n // same realm to avoid capturing the string tag. Strict equality is used\n // instead of `instanceof` because it is more performant for the common\n // use-case. If someone is subclassing a native class, it will be handled\n // with the string tag comparison.\n if (constructor === Date) {\n return areDatesEqual(a, b, state);\n }\n if (constructor === RegExp) {\n return areRegExpsEqual(a, b, state);\n }\n if (constructor === Map) {\n return areMapsEqual(a, b, state);\n }\n if (constructor === Set) {\n return areSetsEqual(a, b, state);\n }\n // Since this is a custom object, capture the string tag to determing its type.\n // This is reasonably performant in modern environments like v8 and SpiderMonkey.\n var tag = getTag(a);\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n // For RegExp, the properties are not enumerable, and therefore will give false positives if\n // tested like a standard object.\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is custom `Promise`-like class instances. These should\n // be treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state));\n }\n // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === URL_TAG) {\n return areUrlsEqual(a, b, state);\n }\n // If an error tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === ERROR_TAG) {\n return areErrorsEqual(a, b, state);\n }\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n/**\n * Create the configuration object used for building comparators.\n */\nfunction createEqualityComparatorConfig(_a) {\n var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;\n var config = {\n areArraysEqual: strict\n ? areObjectsEqualStrict\n : areArraysEqual,\n areDatesEqual: areDatesEqual,\n areErrorsEqual: areErrorsEqual,\n areFunctionsEqual: areFunctionsEqual,\n areMapsEqual: strict\n ? combineComparators(areMapsEqual, areObjectsEqualStrict)\n : areMapsEqual,\n areNumbersEqual: areNumbersEqual,\n areObjectsEqual: strict\n ? areObjectsEqualStrict\n : areObjectsEqual,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,\n areRegExpsEqual: areRegExpsEqual,\n areSetsEqual: strict\n ? combineComparators(areSetsEqual, areObjectsEqualStrict)\n : areSetsEqual,\n areTypedArraysEqual: strict\n ? areObjectsEqualStrict\n : areTypedArraysEqual,\n areUrlsEqual: areUrlsEqual,\n };\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n if (circular) {\n var areArraysEqual$1 = createIsCircular(config.areArraysEqual);\n var areMapsEqual$1 = createIsCircular(config.areMapsEqual);\n var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);\n var areSetsEqual$1 = createIsCircular(config.areSetsEqual);\n config = assign({}, config, {\n areArraysEqual: areArraysEqual$1,\n areMapsEqual: areMapsEqual$1,\n areObjectsEqual: areObjectsEqual$1,\n areSetsEqual: areSetsEqual$1,\n });\n }\n return config;\n}\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nfunction createInternalEqualityComparator(compare) {\n return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {\n return compare(a, b, state);\n };\n}\n/**\n * Create the `isEqual` function used by the consuming application.\n */\nfunction createIsEqual(_a) {\n var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;\n if (createState) {\n return function isEqual(a, b) {\n var _a = createState(), _b = _a.cache, cache = _b === void 0 ? circular ? new WeakMap() : undefined : _b, meta = _a.meta;\n return comparator(a, b, {\n cache: cache,\n equals: equals,\n meta: meta,\n strict: strict,\n });\n };\n }\n if (circular) {\n return function isEqual(a, b) {\n return comparator(a, b, {\n cache: new WeakMap(),\n equals: equals,\n meta: undefined,\n strict: strict,\n });\n };\n }\n var state = {\n cache: undefined,\n equals: equals,\n meta: undefined,\n strict: strict,\n };\n return function isEqual(a, b) {\n return comparator(a, b, state);\n };\n}\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nvar deepEqual = createCustomEqual();\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nvar strictDeepEqual = createCustomEqual({ strict: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nvar circularDeepEqual = createCustomEqual({ circular: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nvar shallowEqual = createCustomEqual({\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nvar strictShallowEqual = createCustomEqual({\n strict: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nvar circularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n strict: true,\n});\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nfunction createCustomEqual(options) {\n if (options === void 0) { options = {}; }\n var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;\n var config = createEqualityComparatorConfig(options);\n var comparator = createEqualityComparator(config);\n var equals = createCustomInternalComparator\n ? createCustomInternalComparator(comparator)\n : createInternalEqualityComparator(comparator);\n return createIsEqual({ circular: circular, comparator: comparator, createState: createState, equals: equals, strict: strict });\n}\n\nexport { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };\n//# sourceMappingURL=index.mjs.map\n","// There is a circular version https://www.npmjs.com/package/fast-equals#circulardeepequal that I\n// think allows comparing React refs (which have circular references in particular places that this\n// library would ignore). Maybe we can change to that version sometime if needed.\nimport { deepEqual as isEqualDeep } from 'fast-equals';\n\n/**\n * Check that two objects are deeply equal, comparing members of each object and such\n *\n * @param a The first object to compare\n * @param b The second object to compare\n *\n * WARNING: Objects like arrays from different iframes have different constructor function\n * references even if they do the same thing, so this deep equality comparison fails objects that\n * look the same but have different constructors because different constructors could produce\n * false positives in [a few specific\n * situations](https://github.com/planttheidea/fast-equals/blob/a41afc0a240ad5a472e47b53791e9be017f52281/src/comparator.ts#L96).\n * This means that two objects like arrays from different iframes that look the same will fail\n * this check. Please use some other means to check deep equality in those situations.\n *\n * Note: This deep equality check considers `undefined` values on keys of objects NOT to be equal to\n * not specifying the key at all. For example, `{ stuff: 3, things: undefined }` and `{ stuff: 3\n * }` are not considered equal in this case\n *\n * - For more information and examples, see [this\n * CodeSandbox](https://codesandbox.io/s/deepequallibrarycomparison-4g4kk4?file=/src/index.mjs).\n *\n * @returns True if a and b are deeply equal; false otherwise\n */\nexport function deepEqual(a: unknown, b: unknown) {\n return isEqualDeep(a, b);\n}\n\nexport default deepEqual;\n","import { deepEqual } from './equality-checking';\n\n/**\n * Check if one object is a subset of the other object. \"Subset\" means that all properties of one\n * object are present in the other object, and if they are present that all values of those\n * properties are deeply equal. Sub-objects are also checked to be subsets of the corresponding\n * sub-object in the other object.\n *\n * @example ObjB is a subset of objA given these objects:\n *\n * ```ts\n * objA = { name: 'Alice', age: 30, address: { city: 'Seattle', state: 'Washington' } };\n * objB = { name: 'Alice', address: { city: 'Seattle' } };\n * ```\n *\n * It is important to note that only arrays of primitives (i.e., booleans, numbers, strings) are\n * supported. In particular, objects in arrays will not be checked for deep equality. Also, presence\n * in an array is all this checks, not the number of times that an item appears in an array. `[1,\n * 1]` is a subset of `[1]`.\n *\n * @param objectWithAllProperties Object to be checked if it is a superset of\n * `objectWithPartialProperties`\n * @param objectWithPartialProperties Object to be checked if it is a subset of\n * `objectWithAllProperties`\n * @returns True if `objectWithAllProperties` contains all the properties of\n * `objectWithPartialProperties` and all values of those properties are deeply equal\n */\nexport function isSubset(\n objectWithAllProperties: unknown,\n objectWithPartialProperties: unknown,\n): boolean {\n if (typeof objectWithAllProperties !== typeof objectWithPartialProperties) return false;\n\n // For this function we're saying that all falsy things of the same type are equal to each other\n if (!objectWithAllProperties && !objectWithPartialProperties) return true;\n\n if (Array.isArray(objectWithAllProperties)) {\n // We know these are arrays from the line above\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialArray = objectWithPartialProperties as Array;\n const allArray = objectWithAllProperties as Array;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n if (partialArray.length === 0) return true;\n\n // This only works with arrays of primitives.\n // If someone cares about checking arrays of objects this needs updating.\n return partialArray.every((item) => allArray.includes(item));\n }\n\n if (typeof objectWithAllProperties !== 'object')\n return deepEqual(objectWithAllProperties, objectWithPartialProperties);\n\n // We know these are objects that potentially have properties because of the earlier checks\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialObj = objectWithPartialProperties as Record;\n const allObj = objectWithAllProperties as Record;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n let retVal = true;\n Object.keys(partialObj).forEach((key) => {\n if (!retVal) return;\n if (!Object.hasOwn(allObj, key)) retVal = false;\n else if (!isSubset(allObj[key], partialObj[key])) retVal = false;\n });\n return retVal;\n}\n\nexport default isSubset;\n","/**\n * Converts a JavaScript value to a JSON string, changing `undefined` properties in the JavaScript\n * object to `null` properties in the JSON string.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer A function that transforms the results. Note that all `undefined` values returned\n * by the replacer will be further transformed into `null` in the JSON string.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON\n * text to make it easier to read. See the `space` parameter of `JSON.stringify` for more\n * details.\n */\nexport function serialize(\n value: unknown,\n replacer?: (this: unknown, key: string, value: unknown) => unknown,\n space?: string | number,\n): string {\n const undefinedReplacer = (replacerKey: string, replacerValue: unknown) => {\n let newValue = replacerValue;\n if (replacer) newValue = replacer(replacerKey, newValue);\n // All `undefined` values become `null` on the way from JS objects into JSON strings\n // eslint-disable-next-line no-null/no-null\n if (newValue === undefined) newValue = null;\n return newValue;\n };\n return JSON.stringify(value, undefinedReplacer, space);\n}\n\n/**\n * Converts a JSON string into a value, converting all `null` properties from JSON into `undefined`\n * in the returned JavaScript value/object.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A valid JSON string.\n * @param reviver A function that transforms the results. This function is called for each member of\n * the object. If a member contains nested objects, the nested objects are transformed before the\n * parent object is. Note that `null` values are converted into `undefined` values after the\n * reviver has run.\n */\nexport function deserialize(\n value: string,\n reviver?: (this: unknown, key: string, value: unknown) => unknown,\n // Need to use `any` instead of `unknown` here to match the signature of JSON.parse\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // Helper function to replace `null` with `undefined` on a per property basis. This can't be done\n // with our own reviver because `JSON.parse` removes `undefined` properties from the return value.\n function replaceNull(obj: Record): Record {\n Object.keys(obj).forEach((key: string | number) => {\n // We only want to replace `null`, not other falsy values\n // eslint-disable-next-line no-null/no-null\n if (obj[key] === null) obj[key] = undefined;\n // If the property is an object, recursively call the helper function on it\n else if (typeof obj[key] === 'object')\n // Since the object came from a string, we know the keys will not be symbols\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n obj[key] = replaceNull(obj[key] as Record);\n });\n return obj;\n }\n\n const parsedObject = JSON.parse(value, reviver);\n // Explicitly convert the value 'null' that isn't stored as a property on an object to 'undefined'\n // eslint-disable-next-line no-null/no-null\n if (parsedObject === null) return undefined;\n if (typeof parsedObject === 'object') return replaceNull(parsedObject);\n return parsedObject;\n}\n\n/**\n * Check to see if the value is serializable without losing information\n *\n * @param value Value to test\n * @returns True if serializable; false otherwise\n *\n * Note: the values `undefined` and `null` are serializable (on their own or in an array), but\n * `null` values get transformed into `undefined` when serializing/deserializing.\n *\n * WARNING: This is inefficient right now as it stringifies, parses, stringifies, and === the value.\n * Please only use this if you need to\n *\n * DISCLAIMER: this does not successfully detect that values are not serializable in some cases:\n *\n * - Losses of removed properties like functions and `Map`s\n * - Class instances (not deserializable into class instances without special code)\n *\n * We intend to improve this in the future if it becomes important to do so. See [`JSON.stringify`\n * documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)\n * for more information.\n */\nexport function isSerializable(value: unknown): boolean {\n try {\n const serializedValue = serialize(value);\n return serializedValue === serialize(deserialize(serializedValue));\n } catch (e) {\n return false;\n }\n}\n\n/**\n * HTML Encodes the provided string. Thanks to ChatGPT\n *\n * @param str String to HTML encode\n * @returns HTML-encoded string\n */\nexport const htmlEncode = (str: string): string =>\n str\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n","import { DateTimeFormat } from './intl-date-time-format';\n\n/**\n * Retrieves the current locale of the user's environment.\n *\n * @returns A string representing the current locale. If the locale cannot be determined, the\n * function returns an empty string.\n */\nexport function getCurrentLocale(): string {\n // Use navigator when available\n if (typeof navigator !== 'undefined' && navigator.languages) {\n const rawLocale = navigator.languages[0];\n // According to the MDN page for navigator.languages it should always return a valid BCP 47 tag.\n // However, some environments (e.g., certain Linux distros) may use the 'POSIX locale format'.\n // This code removes a (potential) trailing \"@posix\" so we will always return a valid BCP 47 tag\n // You can find the MDN page for navigator.languages here:\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n // You can learn more about the 'POSIX locale format' here:\n // https://learn.microsoft.com/en-us/globalization/locale/other-locale-names\n return rawLocale.replace(/@posix$/i, '');\n }\n // For Node.js\n return new DateTimeFormat().resolvedOptions().locale;\n}\n\nexport default getCurrentLocale;\n","import { NumberFormat } from './intl/intl-number-format';\n\n/**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @example FormatBytes(1024) => \"1 KB\"\n *\n * @example FormatBytes(1024, 0) => \"1 KB\"\n *\n * @param fileSize Number to format\n * @param decimals Number of decimal places to round to\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\nexport function formatBytes(fileSize: number, decimals: number = 2): string {\n if (fileSize === 0) return '0 Bytes';\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(fileSize) / Math.log(1024));\n const sizeToUse = sizes[i];\n const formattingFileSize = new NumberFormat('en', {\n style: 'decimal',\n maximumFractionDigits: decimals,\n minimumFractionDigits: 0,\n }).format(fileSize / 1024 ** i);\n return `${formattingFileSize} ${sizeToUse}`;\n}\n\nexport default formatBytes;\n","const MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60;\nconst SECONDS_PER_DAY = SECONDS_PER_HOUR * 24;\n\n/**\n * Get a localized string representation of the time between two dates\n *\n * @example\n *\n * `since` = 3 Aug 2024 8:00 AM\n *\n * `to` = 5 Aug 2024 8:000 AM\n *\n * Returns: \"two days ago\"\n *\n * @param since \"Destination\" time. time against which to get the time span.\n * @param to \"Starting\" time. Time span will be formatted relative to `to`. Defaults to `new Date()`\n * @returns Time span in words from `to` to `since`\n */\nexport function formatTimeSpan(\n relativeTimeFormatter: Intl.RelativeTimeFormat,\n since: Date,\n to = new Date(),\n) {\n const spanSeconds = Math.floor((since.getTime() - to.getTime()) / MILLISECONDS_PER_SECOND);\n\n const totalDays = Math.round(spanSeconds / SECONDS_PER_DAY);\n if (Math.abs(totalDays) >= 1) return relativeTimeFormatter.format(totalDays, 'day');\n\n const totalHours = Math.round(spanSeconds / SECONDS_PER_HOUR);\n if (Math.abs(totalHours) >= 1) return relativeTimeFormatter.format(totalHours, 'hour');\n\n const totalMinutes = Math.round(spanSeconds / SECONDS_PER_MINUTE);\n if (Math.abs(totalMinutes) >= 1) return relativeTimeFormatter.format(totalMinutes, 'minute');\n\n return relativeTimeFormatter.format(spanSeconds, 'second');\n}\n\n/**\n * Formats a date relative to today, showing \"Today\" or \"Yesterday\" when applicable, otherwise\n * returns the date in the specified format\n *\n * @param date The date to format\n * @param todayString The string to display when the date is today\n * @param yesterdayString The string to display when the date is yesterday\n * @param locale The locale to use for date formatting (defaults to user's locale)\n * @param options The Intl.DateTimeFormatOptions to use for date formatting when not\n * today/yesterday. Defaults to `{ year: 'numeric', month: 'short', day: 'numeric' }` which\n * produces formats like \"Nov 9, 2025\"\n */\nexport function formatRelativeDate(\n date: Date,\n todayString: string,\n yesterdayString: string,\n locale?: string,\n options: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n): string {\n const today = new Date();\n const yesterday = new Date(today);\n yesterday.setDate(yesterday.getDate() - 1);\n\n const isToday =\n date.getDate() === today.getDate() &&\n date.getMonth() === today.getMonth() &&\n date.getFullYear() === today.getFullYear();\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n if (isToday) {\n return todayString;\n }\n if (isYesterday) {\n return yesterdayString;\n }\n\n return date.toLocaleString(locale, options);\n}\n","/**\n * Modifier keys that don't constitute typed input\n *\n * Sourced from\n * https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys\n */\nexport const MODIFIER_KEYS = new Set([\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta',\n 'NumLock',\n 'ScrollLock',\n 'Shift',\n 'Super',\n 'Symbol',\n 'SymbolLock',\n]);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey, ReferencedItem } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the settings it provides */\nexport type SettingsContribution = SettingsGroup | SettingsGroup[];\n/** A description of an extension's setting entry */\nexport type Setting = ExtensionControlledSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledSetting = SettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a setting entry */\nexport type SettingBase = StateBase & {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the setting name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the setting */\n description?: LocalizeKey;\n /**\n * Boolean that controls whether a setting should be hidden or not. If hidden, the setting will\n * not show up in the settings dialog in `paranext-core`, and thus will not be configurable by the\n * user unless an extension provides a way to interact with the setting.\n */\n isHidden?: boolean;\n};\n/** The data an extension provides to inform Platform.Bible of the project settings it provides */\nexport type ProjectSettingsContribution = ProjectSettingsGroup | ProjectSettingsGroup[];\n/** A description of an extension's setting entry */\nexport type ProjectSetting = ExtensionControlledProjectSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledProjectSetting = ProjectSettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a project setting entry */\nexport type ProjectSettingBase = SettingBase & ModifierProject;\n/** A description of an extension's user state entry */\nexport type UserState = ExtensionControlledState;\n/** State definition that is validated by the extension. */\nexport type ExtensionControlledState = StateBase & ModifierExtensionControlled;\n/** Group of related settings definitions */\nexport interface SettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the group */\n description?: LocalizeKey;\n properties: SettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface SettingProperties {\n [k: ReferencedItem]: Setting;\n}\n/** Base information needed to describe a state entry */\nexport interface StateBase {\n [k: string]: unknown;\n /** Default value for the state/setting */\n default: unknown;\n /**\n * A state/setting ID whose value to set to this state/setting's starting value the first time\n * this state/setting is loaded\n */\n derivesFrom?: ReferencedItem;\n}\n/**\n * Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the\n * extension provides the component and the validator for the state/setting, so the state/setting is\n * controlled by the extension.\n */\nexport interface ModifierExtensionControlled {\n [k: string]: unknown;\n platformType?: undefined;\n type?: undefined;\n}\n/** Group of related settings definitions */\nexport interface ProjectSettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the project settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the project settings dialog to describe the group */\n description?: LocalizeKey;\n properties: ProjectSettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface ProjectSettingProperties {\n [k: ReferencedItem]: ProjectSetting;\n}\n\n// Note: we removed the index signature on ModifierProject to avoid having it on\n// `ProjectMetadataFilterOptions`. Unfortunately adding \"additionalProperties\": false on the json\n// schema messes up validation. Please remove the index signature again in the future if you\n// regenerate types\n/**\n * Defines a set of optional properties that can be used to filter projects based on their\n * `projectInterface` and Project Data Provider Factory Ids.\n */\nexport interface ModifierProject {\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should be included.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to pass):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to all `ProjectInterfaces`, so all projects that do not match\n * `excludeProjectInterfaces` will be included\n *\n * @example\n *\n * ```typescript\n * includeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed on projects whose `projectInterface`s fulfill at least one\n * of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n includeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should absolutely not be included even if they match with\n * `includeProjectInterfaces`.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to exclude the project):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition and exclude the project\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition and exclude the project\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will\n * be included\n *\n * @example\n *\n * ```typescript\n * excludeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed and exclude projects whose `projectInterface`s fulfill at\n * least one of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n excludeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should be included.\n *\n * Defaults to all Project Data Provider Factory Ids, so all projects that do not match\n * `excludePdpFactoryIds` will be included\n */\n includePdpFactoryIds?: undefined | string | string[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should absolutely not be included even if they match\n * with `includeProjectInterfaces`.\n *\n * Defaults to none, so all projects that match `includePdpFactoryIds` will be included\n */\n excludePdpFactoryIds?: undefined | string | string[];\n}\n\n/** The data an extension provides to inform Platform.Bible of the user state it provides */\nexport interface UserStateContribution {\n [k: ReferencedItem]: UserState;\n}\n/** The data an extension provides to inform Platform.Bible of the project state it provides */\nexport interface ProjectStateContribution {\n [k: ReferencedItem]: UserState;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\nconst settingsDefs = {\n projectSettingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n },\n projectSettingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the project settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description:\n 'localizeKey that displays in the project settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/projectSettingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n projectSettingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/projectSetting',\n },\n },\n additionalProperties: false,\n },\n projectSetting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledProjectSetting',\n },\n ],\n },\n extensionControlledProjectSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/projectSettingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n projectSettingBase: {\n description: 'Base information needed to describe a project setting entry',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierProject',\n },\n ],\n },\n modifierProject: {\n description: 'Modifies setting type to be project setting',\n type: 'object',\n properties: {\n includeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should be included.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to pass):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to all `ProjectInterfaces`, so all projects that do not match `excludeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nincludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed on projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n excludeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to exclude the project):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition and exclude the project\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition and exclude the project\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nexcludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed and exclude projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n includePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should be included.\\n\\nDefaults to all Project Data Provider Factory Ids, so all projects that do not match `excludePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n excludePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nDefaults to none, so all projects that match `includePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n },\n settingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n },\n settingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/settingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n settingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w-]+\\\\.[\\\\w-]+$': {\n $ref: '#/$defs/setting',\n },\n },\n additionalProperties: false,\n },\n setting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledSetting',\n },\n ],\n },\n extensionControlledSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n settingBase: {\n description: 'Base information needed to describe a setting entry',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the setting name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the setting',\n $ref: '#/$defs/localizeKey',\n },\n isHidden: {\n description: `Boolean that controls whether a setting should be hidden or not. If hidden\n , the setting will not show up in the settings dialog in \\`paranext-core\\`, and thus\n will not be configurable by the user unless an extension provides a way to interact with\n the setting.`,\n type: 'boolean',\n },\n },\n required: ['label'],\n },\n ],\n },\n projectStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the user state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateProperties: {\n description: 'Object whose keys are state IDs and whose values are state objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/userState',\n },\n },\n additionalProperties: false,\n },\n userState: {\n description: \"A description of an extension's user state entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledState',\n },\n ],\n },\n extensionControlledState: {\n description: 'State definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n modifierExtensionControlled: {\n description:\n 'Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the extension provides the component and the validator for the state/setting, so the state/setting is controlled by the extension.',\n not: {\n anyOf: [\n {\n type: 'object',\n required: ['platformType'],\n },\n {\n type: 'object',\n required: ['type'],\n },\n ],\n },\n },\n stateBase: {\n description: 'Base information needed to describe a state entry',\n type: 'object',\n properties: {\n default: {\n description: 'default value for the state/setting',\n type: 'any',\n },\n derivesFrom: {\n description:\n \"a state/setting ID whose value to set to this state/setting's starting value the first time this state/setting is loaded\",\n $ref: '#/$defs/id',\n },\n },\n required: ['default'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n id: {\n description: '',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n tsType: 'Id',\n },\n};\n\n/**\n * Json-schema-to-typescript has some added stuff that isn't actually compatible with JSON schema,\n * so we remove them here\n *\n * @param defs The `$defs` property of a JSON schema (will be modified in place)\n */\n// JSON schema types are weird, so we'll just be careful\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function removeJsonToTypeScriptTypesStuff(defs: any) {\n if (!defs) return;\n\n // JSON schema types are weird, so we'll just be careful\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.values(defs).forEach((def: any) => {\n if (!def.type) return;\n\n if ('tsType' in def) delete def.tsType;\n\n if (def.type === 'any') {\n delete def.type;\n return;\n }\n\n if (def.type === 'object') {\n removeJsonToTypeScriptTypesStuff(def.properties);\n }\n });\n}\n\nremoveJsonToTypeScriptTypesStuff(settingsDefs);\n\n/** JSON schema object that aligns with the ProjectSettingsContribution type */\nexport const projectSettingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Project Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(projectSettingsDocumentSchema);\n\n/** JSON schema object that aligns with the {@link SettingsContribution} type */\nexport const settingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(settingsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey } from './menus.model';\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\n\n/** Localized string value associated with this key */\nexport type LocalizedStringValue = string;\n/**\n * Date in YYYY-MM-DD format\n *\n * Use regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$` to test.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\nexport type DateYYYYMMDD = `${number}-${number}-${number}`;\n\n/** The data an extension provides to inform Platform.Bible of the localized strings it provides. */\nexport interface LocalizedStringDataContribution {\n [k: string]: unknown;\n metadata?: StringsMetadata;\n localizedStrings?: {\n [k: string]: LanguageStrings;\n };\n}\n/**\n * Map whose keys are localized string keys and whose values provide additional non-locale-specific\n * information about the localized string key\n */\nexport interface StringsMetadata {\n [k: LocalizeKey]: StringMetadata;\n}\n/** Additional non-locale-specific information about a localized string key */\nexport interface StringMetadata {\n [k: string]: unknown;\n /**\n * Localized string key from which to get this value if one does not exist in the specified\n * language. If a new key/value pair needs to be made to replace an existing one, this could help\n * smooth over the transition if the meanings are close enough\n *\n * You can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a\n * backslash `\\`.\n */\n fallbackKey?: LocalizeKey;\n /**\n * Additional information provided by developers in English to help the translator to know how to\n * translate this localized string accurately\n */\n notes?: string;\n /**\n * If this property is filled, the localized string is deprecated. Contains information about the\n * deprecation.\n */\n deprecationInfo?: LocalizedStringDeprecationInfo;\n}\n/**\n * Contains information about the deprecation of a localized string key, including the date of\n * deprecation and the reason.\n */\nexport interface LocalizedStringDeprecationInfo {\n [k: string]: unknown;\n /**\n * Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\n *\n * Tested against regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\n date: DateYYYYMMDD;\n /**\n * Should contain the reason for deprecation and what to use instead in what contexts.\n *\n * @example Reworded to clarify the meaning. Use %my_key_2% instead.\n */\n message: string;\n}\n/**\n * Map whose keys are localized string keys and whose values provide information about how to\n * localize strings for the localized string key\n */\nexport interface LanguageStrings {\n [k: LocalizeKey]: LocalizedStringValue;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n\nconst localizedStringsDefs = {\n languageStrings: {\n description:\n 'Map whose keys are localized string keys and whose values provide information about how to localize strings for the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/localizedStringValue',\n },\n },\n additionalProperties: false,\n },\n localizedStringValue: {\n description: 'Localized string value associated with this key',\n type: 'string',\n },\n stringsMetadata: {\n description:\n 'Map whose keys are localized string keys and whose values provide additional non-locale-specific information about the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/stringMetadata',\n },\n },\n additionalProperties: false,\n },\n stringMetadata: {\n description: 'Additional non-locale-specific information about a localized string key',\n type: 'object',\n properties: {\n fallbackKey: {\n description:\n 'Localized string key from which to get this value if one does not exist in the specified language. If a new key/value pair needs to be made to replace an existing one, this could help smooth over the transition if the meanings are close enough.\\nYou can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a backslash `\\\\`.',\n type: 'string',\n pattern: \"^%[\\\\w\\\\-\\\\.;&,' (){}#:/\\\\\\\\?%⋮|[\\\\]“”‘’!~*\\u00A0+=•`…\\u200B↑↓]+%$\",\n tsType: 'LocalizeKey',\n },\n notes: {\n description:\n 'Additional information provided by developers in English to help the translator to know how to translate this localized string accurately',\n type: 'string',\n },\n deprecationInfo: {\n description:\n 'If this property is filled, the localized string is deprecated. Contains information about the deprecation.',\n $ref: '#/$defs/localizedStringDeprecationInfo',\n },\n },\n },\n localizedStringDeprecationInfo: {\n description:\n 'Date of deprecation, the reason for deprecation, and what to use instead in what contexts',\n type: 'object',\n properties: {\n date: {\n description:\n 'Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\\n\\nTested against regex `^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\\n\\nThanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.',\n type: 'string',\n pattern: '^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$',\n tsType: 'DateYYYYMMDD',\n },\n message: {\n description:\n 'Should contain the reason for deprecation and what to use instead in what contexts.\\n\\n@example Reworded to clarify the meaning. Use %my_key_2% instead.',\n type: 'string',\n },\n },\n required: ['date', 'message'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(localizedStringsDefs);\n\n/** JSON schema object that aligns with the LocalizedStringDataContribution type */\nexport const localizedStringsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Localized String Data Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the localized strings it provides.',\n type: 'object',\n properties: {\n metadata: {\n $ref: '#/$defs/stringsMetadata',\n },\n localizedStrings: {\n type: 'object',\n additionalProperties: {\n $ref: '#/$defs/languageStrings',\n },\n },\n },\n $defs: localizedStringsDefs,\n};\n\nObject.freeze(localizedStringsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { ReplaceType } from '../util';\n\n/** Identifier for a string that will be localized in a menu based on the user's UI language */\nexport type LocalizeKey = `%${string}%`;\n\n/** Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command) */\nexport type ReferencedItem = `${string}.${string}`;\n\nexport type OrderedItem = {\n /** Relative order of this item compared to other items in the same parent/scope (sorted ascending) */\n order: number;\n};\n\nexport type OrderedExtensibleContainer = OrderedItem & {\n /** Determines whether other items can be added to this after it has been defined */\n isExtensible?: boolean;\n};\n\n/** Group of menu items that belongs in a column */\nexport type MenuGroupDetailsInColumn = OrderedExtensibleContainer & {\n /** ID of column in which this group resides */\n column: ReferencedItem;\n};\n\n/** Group of menu items that belongs in a submenu */\nexport type MenuGroupDetailsInSubMenu = OrderedExtensibleContainer & {\n /** ID of menu item hosting the submenu in which this group resides */\n menuItem: ReferencedItem;\n};\n\n/** Column that includes header text in a menu */\nexport type MenuColumnWithHeader = OrderedExtensibleContainer & {\n /** Key that represents the text of the header text of the column */\n label: LocalizeKey;\n};\n\nexport type MenuItemBase = OrderedItem & {\n /** Menu group to which this menu item belongs */\n group: ReferencedItem;\n /** Key that represents the text of this menu item to display */\n label: LocalizeKey;\n /** Key that represents words the platform should reference when users are searching for menu items */\n searchTerms?: LocalizeKey;\n /** Key that represents the text to display if a mouse pointer hovers over the menu item */\n tooltip?: LocalizeKey;\n /** Additional information provided by developers to help people who perform localization */\n localizeNotes: string;\n};\n\n/** Menu item that hosts a submenu */\nexport type MenuItemContainingSubmenu = MenuItemBase & {\n /** ID for this menu item that holds a submenu */\n id: ReferencedItem;\n};\n\n/** Menu item that runs a command */\nexport type MenuItemContainingCommand = MenuItemBase & {\n /** Name of the PAPI command to run when this menu item is selected. */\n command: ReferencedItem;\n /**\n * Uri path to the icon to display after the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathAfter?: string;\n /**\n * Uri path to the icon to display before the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathBefore?: string;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single context menu/submenu.\n * Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInSingleColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: OrderedExtensibleContainer | MenuGroupDetailsInSubMenu;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single menu/submenu within a\n * multi-column menu. Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInMultiColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: MenuGroupDetailsInColumn | MenuGroupDetailsInSubMenu;\n};\n\n/** Group of columns that can be combined with other columns to form a multi-column menu */\nexport type ColumnsWithHeaders = {\n /** Named column of a menu */\n [property: ReferencedItem]: MenuColumnWithHeader;\n /** Defines whether columns can be added to this multi-column menu */\n isExtensible?: boolean;\n};\n\n/** Menu that contains a column without a header */\nexport type SingleColumnMenu = {\n /** Groups that belong in this menu */\n groups: GroupsInSingleColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menu that contains multiple columns with headers */\nexport type MultiColumnMenu = {\n /** Columns that belong in this menu */\n columns: ColumnsWithHeaders;\n /** Groups that belong in this menu */\n groups: GroupsInMultiColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menus for one single web view */\nexport type WebViewMenu = {\n /** Indicates whether the platform default menus should be included for this webview */\n includeDefaults: boolean | undefined;\n /** Menu that opens when you click on the top left corner of a tab */\n topMenu: MultiColumnMenu | undefined;\n /** Menu that opens when you right click on the main body/area of a tab */\n contextMenu: SingleColumnMenu | undefined;\n};\n\n/** Menus for all web views */\nexport type WebViewMenus = {\n /** Named web view */\n [property: ReferencedItem]: WebViewMenu;\n};\n\n/** Platform.Bible menus before they are localized */\nexport type PlatformMenus = {\n /** Top level menu for the application */\n mainMenu: MultiColumnMenu;\n /** Menus that apply per web view in the application */\n webViewMenus: WebViewMenus;\n /** Default context menu for web views that don't specify their own */\n defaultWebViewContextMenu: SingleColumnMenu;\n /** Default top menu for web views that don't specify their own */\n defaultWebViewTopMenu: MultiColumnMenu;\n};\n\n/**\n * Type that converts any menu type before it is localized to what it is after it is localized. This\n * can be applied to any menu type as needed.\n */\nexport type Localized = ReplaceType, ReferencedItem, string>;\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n/** JSON schema object that aligns with the PlatformMenus type */\nexport const menuDocumentSchema = {\n title: 'Platform.Bible menus',\n type: 'object',\n properties: {\n mainMenu: {\n description: 'Top level menu for the application',\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewTopMenu: {\n description: \"Default top menu for web views that don't specify their own\",\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewContextMenu: {\n description: \"Default context menu for web views that don't specify their own\",\n $ref: '#/$defs/singleColumnMenu',\n },\n webViewMenus: {\n description: 'Menus that apply per web view in the application',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/menusForOneWebView',\n },\n },\n additionalProperties: false,\n },\n },\n required: ['mainMenu', 'defaultWebViewTopMenu', 'defaultWebViewContextMenu', 'webViewMenus'],\n additionalProperties: false,\n $defs: {\n localizeKey: {\n description:\n \"Identifier for a string that will be localized in a menu based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n },\n referencedItem: {\n description:\n 'Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command)',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n },\n columnsWithHeaders: {\n description:\n 'Group of columns that can be combined with other columns to form a multi-column menu',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single column with a header string',\n type: 'object',\n properties: {\n label: {\n description: 'Header text for this this column in the UI',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n order: {\n description:\n 'Relative order of this column compared to other columns (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu groups to this column',\n type: 'boolean',\n },\n },\n required: ['label', 'order'],\n additionalProperties: false,\n },\n },\n properties: {\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add columns to this multi-column menu',\n type: 'boolean',\n },\n },\n },\n menuGroups: {\n description:\n 'Group of menu items that can be combined with other groups to form a single menu/submenu. Groups are separated using a line within the menu/submenu.',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single group that contains menu items',\n type: 'object',\n oneOf: [\n {\n properties: {\n column: {\n description:\n 'Column where this group belongs, not required for single column menus',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['order'],\n additionalProperties: false,\n },\n {\n properties: {\n menuItem: {\n description: 'Menu item that anchors the submenu where this group belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['menuItem', 'order'],\n additionalProperties: false,\n },\n ],\n },\n },\n additionalProperties: false,\n },\n menuItem: {\n description:\n 'Single item in a menu that can be clicked on to take an action or can be the parent of a submenu',\n type: 'object',\n oneOf: [\n {\n properties: {\n id: {\n description: 'ID for this menu item that holds a submenu',\n $ref: '#/$defs/referencedItem',\n },\n },\n required: ['id'],\n },\n {\n properties: {\n command: {\n description: 'Name of the PAPI command to run when this menu item is selected.',\n $ref: '#/$defs/referencedItem',\n },\n iconPathBefore: {\n description:\n 'Uri path to the icon to display before the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n iconPathAfter: {\n description:\n 'Uri path to the icon to display after the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n },\n required: ['command'],\n },\n ],\n properties: {\n label: {\n description: 'Key that represents the text of this menu item to display',\n $ref: '#/$defs/localizeKey',\n },\n tooltip: {\n description:\n 'Key that represents the text to display if a mouse pointer hovers over the menu item',\n $ref: '#/$defs/localizeKey',\n },\n searchTerms: {\n description:\n 'Key that represents additional words the platform should reference when users are searching for menu items',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n group: {\n description: 'Group to which this menu item belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this menu item compared to other menu items in the same group (sorted ascending)',\n type: 'number',\n },\n },\n required: ['label', 'group', 'order'],\n unevaluatedProperties: false,\n },\n groupsAndItems: {\n description: 'Core schema for a column',\n type: 'object',\n properties: {\n groups: {\n description: 'Groups that belong in this menu',\n $ref: '#/$defs/menuGroups',\n },\n items: {\n description: 'List of menu items that belong in this menu',\n type: 'array',\n items: { $ref: '#/$defs/menuItem' },\n uniqueItems: true,\n },\n },\n required: ['groups', 'items'],\n },\n singleColumnMenu: {\n description: 'Menu that contains a column without a header',\n type: 'object',\n allOf: [{ $ref: '#/$defs/groupsAndItems' }],\n unevaluatedProperties: false,\n },\n multiColumnMenu: {\n description: 'Menu that can contain multiple columns with headers',\n type: 'object',\n allOf: [\n { $ref: '#/$defs/groupsAndItems' },\n {\n properties: {\n columns: {\n description: 'Columns that belong in this menu',\n $ref: '#/$defs/columnsWithHeaders',\n },\n },\n required: ['columns'],\n },\n ],\n unevaluatedProperties: false,\n },\n menusForOneWebView: {\n description: 'Set of menus that are associated with a single tab',\n type: 'object',\n properties: {\n includeDefaults: {\n description:\n 'Indicates whether the platform default menus should be included for this webview',\n type: 'boolean',\n },\n topMenu: {\n description: 'Menu that opens when you click on the top left corner of a tab',\n $ref: '#/$defs/multiColumnMenu',\n },\n contextMenu: {\n description: 'Menu that opens when you right click on the main body/area of a tab',\n $ref: '#/$defs/singleColumnMenu',\n },\n },\n additionalProperties: false,\n },\n },\n};\n\nObject.freeze(menuDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\nimport { LocalizeKey } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the themes it provides. */\nexport type ThemeContribution = ThemeFamiliesById;\n\n/** Object whose keys are theme family ids and whose values are {@link ThemeFamily}. */\nexport interface ThemeFamiliesById {\n [themeFamilyId: string]: ThemeFamily | undefined;\n}\n\n/**\n * A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\n *\n * A theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type\n * to determine how to look. Colors not present in the theme will fall back to the built-in colors\n * for this type.\n */\nexport interface ThemeFamily {\n [themeType: string]: ThemeDefinition | undefined;\n light?: ThemeDefinition;\n dark?: ThemeDefinition;\n}\n\n/**\n * The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark)\n * and belongs to a theme family. An extension can provide multiple themes with\n * {@link ThemeContribution}.\n */\nexport interface ThemeDefinition {\n [k: string]: unknown;\n /** LocalizeKey that is the display name for the theme */\n label: LocalizeKey;\n /**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\n cssVariables: ThemeCssVariables;\n}\n/**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\nexport interface ThemeCssVariables {\n [variableName: string]: string | undefined;\n background?: string;\n foreground?: string;\n card?: string;\n 'card-foreground'?: string;\n popover?: string;\n 'popover-foreground'?: string;\n primary?: string;\n 'primary-foreground'?: string;\n secondary?: string;\n 'secondary-foreground'?: string;\n muted?: string;\n 'muted-foreground'?: string;\n accent?: string;\n 'accent-foreground'?: string;\n destructive?: string;\n 'destructive-foreground'?: string;\n border?: string;\n input?: string;\n ring?: string;\n 'sidebar-background'?: string;\n 'sidebar-foreground'?: string;\n 'sidebar-primary'?: string;\n 'sidebar-primary-foreground'?: string;\n 'sidebar-accent'?: string;\n 'sidebar-accent-foreground'?: string;\n 'sidebar-border'?: string;\n 'sidebar-ring'?: string;\n radius?: string;\n}\n\nconst themeDefs = {\n themeCssVariables: {\n description:\n \"Theme colors and other CSS variable properties that adjust the looks of the application. These are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like `tw-bg-primary`\\n\\nSee the wiki's [Matching Application Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme) section for more information.\",\n type: 'object',\n properties: {\n background: { type: 'string' },\n foreground: { type: 'string' },\n card: { type: 'string' },\n 'card-foreground': { type: 'string' },\n popover: { type: 'string' },\n 'popover-foreground': { type: 'string' },\n primary: { type: 'string' },\n 'primary-foreground': { type: 'string' },\n secondary: { type: 'string' },\n 'secondary-foreground': { type: 'string' },\n muted: { type: 'string' },\n 'muted-foreground': { type: 'string' },\n accent: { type: 'string' },\n 'accent-foreground': { type: 'string' },\n destructive: { type: 'string' },\n 'destructive-foreground': { type: 'string' },\n border: { type: 'string' },\n input: { type: 'string' },\n ring: { type: 'string' },\n 'sidebar-background': { type: 'string' },\n 'sidebar-foreground': { type: 'string' },\n 'sidebar-primary': { type: 'string' },\n 'sidebar-primary-foreground': { type: 'string' },\n 'sidebar-accent': { type: 'string' },\n 'sidebar-accent-foreground': { type: 'string' },\n 'sidebar-border': { type: 'string' },\n 'sidebar-ring': { type: 'string' },\n radius: { type: 'string' },\n },\n additionalProperties: { anyOf: [{ type: 'string' }, { type: 'null' }] },\n },\n themeDefinition: {\n description:\n 'The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark) and belongs to a theme family. An extension can provide multiple themes with {@link ThemeContribution}.',\n type: 'object',\n properties: {\n label: {\n description: 'LocalizeKey that is the display name for the theme',\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n cssVariables: {\n $ref: '#/$defs/themeCssVariables',\n },\n },\n required: ['label', 'cssVariables'],\n },\n themeFamily: {\n description:\n 'A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\\n\\nA theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to look. Colors not present in the theme will fall back to the built-in colors for this type.',\n type: 'object',\n properties: {\n light: {\n $ref: '#/$defs/themeDefinition',\n },\n dark: {\n $ref: '#/$defs/themeDefinition',\n },\n },\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeDefinition',\n },\n { type: 'null' },\n ],\n },\n },\n themeFamiliesById: {\n description: 'Object whose keys are theme family ids and whose values are {@link ThemeFamily}.',\n type: 'object',\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeFamily',\n },\n { type: 'null' },\n ],\n },\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(themeDefs);\n\n// JSON schema object for ThemeContribution\nexport const themeDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Theme Contribution',\n description: 'The data an extension provides to inform Platform.Bible of the themes it provides.',\n anyOf: [\n {\n $ref: '#/$defs/themeFamiliesById',\n },\n ],\n $defs: themeDefs,\n};\n\nObject.freeze(themeDocumentSchema);\n","import { ReplaceType } from '../util';\nimport { ThemeDefinition, ThemeFamiliesById, ThemeFamily } from './theme.model';\n\n/**\n * {@link ThemeDefinition} with some additional properties derived from the {@link ThemeFamiliesById}\n * it comes from to help with managing the theme\n */\nexport type ThemeDefinitionExpanded = ThemeDefinition & {\n /**\n * Unique identifier for the {@link ThemeFamily} this theme is in.\n *\n * This is derived from the key of the {@link ThemeFamiliesById} this theme is in\n */\n themeFamilyId: string;\n /**\n * The kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to\n * look. Colors not present in the theme will fall back to the built-in colors for this type.\n *\n * This is derived from the key of the {@link ThemeFamily} this theme is in\n */\n type: string;\n /**\n * Unique identifier for this theme.\n *\n * This is derived by combining the theme family and type\n */\n id: string;\n};\n\n/**\n * Replaces {@link ThemeDefinition} with {@link ThemeDefinitionExpanded} recursively in the provided\n * type. Modifies the type to what is used in the theme service.\n */\nexport type ExpandThemeDefinition = ReplaceType;\n\n/**\n * {@link ThemeFamily} with all {@link ThemeDefinition} replaced by {@link ThemeDefinitionExpanded}.\n * This is used in the theme service\n */\nexport type ThemeFamilyExpanded = ExpandThemeDefinition;\n\n/**\n * {@link ThemeFamiliesById} with all {@link ThemeDefinition} replaced by\n * {@link ThemeDefinitionExpanded}. This is used in the theme service\n */\nexport type ThemeFamiliesByIdExpanded = ExpandThemeDefinition;\n\n/** ID for the style element the theme styles should go into */\nexport const THEME_STYLE_ELEMENT_ID = 'theme-styles';\n\nfunction getThemeId(themeFamilyId: string, type: string) {\n return `${themeFamilyId ? `${themeFamilyId}-` : ''}${type}`;\n}\n\n/**\n * Add the derived properties in {@link ThemeDefinitionExpanded} to {@link ThemeDefinition}s in the\n * given {@link ThemeFamiliesById} and fill in any missing `cssVariables` in the theme definitions\n * with those from the default themes.\n *\n * Does not modify the input object.\n *\n * @param themeFamiliesById Theme families to expand with the additional derived properties\n * @param defaultThemeFamily If provided, themes from this family are used to fill in missing\n * `cssVariables` in the theme definitions to make sure each theme definition has all necessary\n * `cssVariables`\n * @returns The expanded theme families\n */\nexport function expandThemeContribution(\n themeFamiliesById: ThemeFamiliesById,\n defaultThemeFamily: ThemeFamily | undefined,\n): ThemeFamiliesByIdExpanded {\n const themeFamiliesByIdExpanded: ThemeFamiliesByIdExpanded = Object.fromEntries(\n Object.entries(themeFamiliesById)\n .map(([themeFamilyId, themeFamily]) => [\n themeFamilyId,\n themeFamily\n ? Object.fromEntries(\n Object.entries(themeFamily)\n .map(([type, themeDefinition]): [string, ThemeDefinitionExpanded | undefined] => [\n type,\n themeDefinition\n ? {\n ...themeDefinition,\n // Add the derived properties\n themeFamilyId,\n type,\n id: getThemeId(themeFamilyId, type),\n cssVariables: {\n // Fill in the default css variables\n ...defaultThemeFamily?.[type]?.cssVariables,\n ...themeDefinition.cssVariables,\n },\n }\n : undefined,\n ])\n .filter(([, themeDefinition]) => !!themeDefinition),\n )\n : undefined,\n ])\n .filter(([, themeFamily]) => !!themeFamily),\n );\n return themeFamiliesByIdExpanded;\n}\n\n/** Gets the CSS stylesheet that should be applied for the given theme */\nexport function getStylesheetForTheme(theme: ThemeDefinitionExpanded): string {\n return `\n.${theme.id} {\n${Object.entries(theme.cssVariables)\n .map(([variableName, value]) => ` --${variableName}: ${value};`)\n .join('\\n')}\n}\n`;\n}\n\n/**\n * Applies a CSS stylesheet for the provided theme to the current window\n *\n * WARNING: THIS MUST BE BOUND TO `window` IN ORDER TO USE!\n *\n * ```ts\n * applyThemeStylesheet.bind(window)()`\n * ```\n *\n * @param theme Theme to apply\n * @param previousStyleElement Previous style element if applicable\n * @param styleElementIdSuffix Suffix to apply to the ID of the new style element. Will be\n * {@link THEME_STYLE_ELEMENT_ID} with a dash and the suffix added to it\n * @returns\n */\n// Must use `this` so it works across iframes\nexport function applyThemeStylesheet(\n this: Window,\n theme: ThemeDefinitionExpanded,\n previousStyleElement?: HTMLStyleElement,\n styleElementIdSuffix?: string,\n): HTMLStyleElement {\n // Set the class on the body\n const previousThemeId = previousStyleElement?.dataset.themeId;\n if (previousThemeId) this.document.body.classList.remove(previousThemeId);\n this.document.body.classList.add(theme.id);\n\n // Set up the stylesheet element\n if (previousStyleElement) this.document.head.removeChild(previousStyleElement);\n const themeStyleElement = this.document.createElement('style');\n themeStyleElement.id = `${THEME_STYLE_ELEMENT_ID}${styleElementIdSuffix ? `-${styleElementIdSuffix}` : ''}`;\n themeStyleElement.dataset.themeId = theme.id;\n themeStyleElement.textContent = getStylesheetForTheme(theme);\n this.document.head.appendChild(themeStyleElement);\n return themeStyleElement;\n}\n","/**\n * Information about a USFM marker that is just an attribute in USX/USJ. See {@link MarkerInfo} for\n * other kinds of markers.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker instead in USX/USJ.\n *\n * @example `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for\n * `v`. `cat` is an attribute marker for `f`, `esb`, and more.\n *\n * Following is an example of using the `ca` and `cp` attribute markers in USFM:\n *\n * ```usfm\n * \\c 1 \\ca 2\\ca*\n * \\cp A\n * \\s1 This is a section header\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * This is a section header\n * ```\n */\nexport type AttributeMarkerInfo = NormalMarkerInfo & {\n /**\n * List of normal marker names for which this marker is an attribute marker.\n *\n * @example `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']`\n * for both `ca` and `cp`.\n */\n isAttributeMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an attribute marker.\n *\n * @example Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`.\n * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isAttributeMarkerForRegExp?: string[];\n /**\n * The name of the USX/USJ attribute this attribute marker represents.\n *\n * @example `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the\n * `c` marker in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca`\n * marker.\n */\n attributeMarkerAttributeName: string;\n /**\n * Whether there should be a structural space after the normal closing marker in output USFM if\n * this marker is an attribute marker. If this marker is not an attribute marker, it should not\n * have a structural space after the normal closing marker.\n *\n * This field should be ignored if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `true`\n * because this space is only supposed to be added in contexts in which the space here is\n * structural. Otherwise we would be mistakenly adding content to the USFM.\n *\n * Note that, if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `false` (which is the\n * case according to spec), horizontal spaces after attribute markers are always considered\n * structural; this property only indicates whether there should be a space after the attribute\n * marker when outputting USFM as opposed to parsing it.\n *\n * If not present or `undefined`, defaults to `false`.\n *\n * @example According to specification, the `va` and `vp` attribute markers have a space after\n * their normal closing markers:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp 10 vp\\vp* Some verse text\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n *\n * However, when the `vp` marker is not an attribute marker, such as when it has markers in its\n * contents, there should not be a structural space after the normal closing marker, and any space\n * should be considered content:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp \\+wj 10 vp\\+wj*\\vp* Some verse text.\n * ```\n *\n * The verse text in this example is \" Some verse text\" including a space at the start.\n *\n * @example The `cat` attribute marker does not have a structural space after its normal closing\n * marker:\n *\n * ```usfm\n * \\f + \\cat category here\\cat*\\fr 1:2 \\ft Some footnote text\\f*\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n */\n hasStructuralSpaceAfterCloseAttributeMarker?: boolean;\n};\n\n/**\n * Information about a regular USFM/USX/USJ marker. See {@link MarkerInfo} for other kinds of\n * markers.\n */\nexport type NormalMarkerInfo = {\n /**\n * Which marker type the marker is. Determines how the marker is structured in the data such as\n * what kind of mandatory whitespace is around the marker in USFM. See {@link MarkerTypeInfoBase}\n * for information.\n */\n type: string;\n /** Explanation of the meaning of this marker */\n description?: string;\n /**\n * Which attribute can be provided without specifying the attribute name in USFM.\n *\n * A marker can have a default attribute only if it has zero or one non-optional attributes.\n *\n * An attribute can be provided with default syntax in the USFM only if it is the only attribute\n * provided for the marker.\n *\n * @example A marker with a default attribute:\n *\n * ```usfm\n * \\w stuff|thisIsTheLemmaDefaultAttribute\\w*\n * ```\n *\n * @example A marker with multiple attributes (cannot use default attribute syntax):\n *\n * ```usfm\n * \\w stuff|lemma=\"thisIsTheLemma\" strong=\"H1234,G1234\"\\w*\n * ```\n */\n defaultAttribute?: string;\n /**\n * The name of the text content attribute that is present on this marker if this marker has text\n * content in USFM.\n *\n * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual\n * text content of the marker.\n *\n * @example `alt` is a text content attribute on the `periph` marker. This value would be `alt`\n * for the `periph` marker.\n *\n * Following is an example of a `periph` marker in USFM:\n *\n * ```usfm\n * \\periph Example Peripheral|id=\"x-example\"\n * \\p Some contents of the example peripheral\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * Some contents of the example peripheral\n * \n * ```\n */\n textContentAttribute?: string;\n /**\n * List of leading attributes that must be present on this marker. This list is ordered by the\n * order in which the attributes should appear.\n *\n * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker\n * and separated only by a space.\n *\n * @example `code` is a leading attribute on the `id` marker. This value would be `['code']` for\n * the `id` marker.\n *\n * Following is an example of an `id` marker in USFM:\n *\n * ```usfm\n * \\id MAT 41MATEX.SFM, Example Translation, September 2025\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * 41MATEX.SFM, Example Translation, September 2025\n * ```\n */\n leadingAttributes?: string[];\n /**\n * List of attribute markers that may be present on this marker. This list is ordered by the order\n * in which the markers should appear.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker in USX/USJ.\n *\n * Note: the attribute names for attribute markers may be different than the marker names. See\n * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information.\n *\n * @example `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for\n * `c`.\n */\n attributeMarkers?: string[];\n /**\n * Whether the normal closing marker for this marker is considered optional in USFM, meaning in\n * some cases that the normal closing marker would be expected not to be present.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `true`, this marker\n * may or may not be expected to have a normal closing marker actually present in USFM depending\n * on the value of this property.\n *\n * - If this is `true`, the normal closing marker for this marker in USFM may be expected to be\n * present or absent depending on the value of\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}. If\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `true`, this marker is expected to\n * have the normal closing marker actually present in USFM just like markers for which this\n * property is `false`. If {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `false`,\n * this marker is expected not to have the normal closing marker actually present in USFM. The\n * `closed` attribute should be present if the presence of a normal closing marker for this\n * marker in USFM does not match the presence implied by\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}.\n * - If this is `false`, the normal closing marker for this marker in USFM is expected to always be\n * present. If the normal closing marker is absent in USFM, the USX/USJ for this marker should\n * have the attribute `closed` set to `false`.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `false`, this\n * property is unused; markers of that type do not have a normal closing marker.\n *\n * If not present or `undefined`, defaults to `false`\n */\n isClosingMarkerOptional?: boolean;\n /**\n * List of independent closing marker names for this marker in USFM if it has any. If this is\n * defined, this marker does not have a normal closing marker but rather is closed by a completely\n * separate marker in USFM. All contents between this marker and the independent closing marker\n * are contents of this marker. In USX and USJ, this marker is closed normally like any other\n * object because USX and USJ have clear hierarchical structure.\n *\n * Note that independent closing markers do not have a `*` at the end because they are not normal\n * closing marker for but rather are completely separate markers that close the corresponding\n * opening marker.\n *\n * @example `esb` (a sidebar) is closed by the independent closing marker `esbe`.\n * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a\n * sidebar:\n *\n * ```usfm\n * \\esb\n * \\p This paragraph is in a \\bd sidebar\\bd*.\n * \\p The sidebar can contain multiple paragraphs.\n * \\esbe\n * ```\n */\n independentClosingMarkers?: string[];\n /**\n * List of marker names for which this marker is an independent closing marker. See\n * {@link NormalMarkerInfo.independentClosingMarker} for more information on independent closing\n * markers and their syntax.\n *\n * @example `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor`\n * would be `['esb']` for `esbe`.\n */\n isIndependentClosingMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an independent closing\n * marker. See {@link NormalMarkerInfo.independentClosingMarker} for more information on\n * independent closing markers and their syntax.\n *\n * @example Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp\n * `/test/`. `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isIndependentClosingMarkerForRegExp?: string[];\n /**\n * Marker to use when operating on the USFM representation of this marker. For example, when\n * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used\n * instead of the marker info for the marker as listed in USX or USJ.\n *\n * @example When the `usx` marker is output to USFM, it should be transformed to the `usfm`\n * marker.\n */\n markerUsfm?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker when\n * transforming from USFM to USX or USJ. These instructions are an explanation of what needs to be\n * done to this marker to properly transform it to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker that is essential for proper translation between formats.\n *\n * @example `w` is a `char`-type marker, so it shares the characteristics of the `char`\n * {@link MarkerTypeInfo} with other `char`-type markers and has its own set of characteristics.\n * `w`'s `MarkerInfo` is as follows:\n *\n * ```json\n * {\n * \"type\": \"char\",\n * \"defaultAttribute\": \"lemma\"\n * }\n * ```\n */\nexport type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo;\n\n/**\n * Information about a USFM/USX/USJ marker type that has a closing marker. See {@link MarkerTypeInfo}\n * for other kinds of marker types.\n *\n * If the marker type has a closing marker but the closing marker is not present in the USFM for a\n * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to\n * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`.\n *\n * @example `char` marker types such as `nd` markers have closing markers, but `para` markers such\n * as `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type CloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable: true;\n /**\n * Whether the closing marker for markers of this type is \"empty\" in USFM, meaning the marker name\n * is absent from the closing marker. This also means that there should not be a structural space\n * between the opening and the closing markers in USFM if there are no attributes listed on the\n * marker.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker:\n *\n * ```usfm\n * \\qt1-s\\*\n * ...\n * \\qt1-e\\*\n * ```\n *\n * The closing marker for `qt1-s` is `\\*` as opposed to the closing marker for `nd` which is\n * `\\nd*`.\n *\n * Note that there is still a structural space after the opening marker if there are attributes\n * present:\n *\n * ```usfm\n * \\qt1-s |Someone\\*\n * ...\n * \\qt1-e\\*\n * ```\n */\n isClosingMarkerEmpty?: boolean;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that does not have a closing marker. See\n * {@link MarkerTypeInfo} for other kinds of marker types.\n *\n * @example `char` marker types such as `nd` markers have closing markers, but `para` marker types\n * such as `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type NonCloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable?: false;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is common to all marker types. See\n * {@link MarkerTypeInfo} for various kinds of marker types.\n */\nexport type MarkerTypeInfoBase = {\n /** Explanation of the meaning of this marker type */\n description?: string;\n /**\n * Whether markers of this type should have a `style` attribute in USX/USJ.\n *\n * If this is `false`, it also means the marker type is the same as the marker name.\n *\n * If not present or `undefined`, defaults to `true`.\n */\n hasStyleAttribute?: boolean;\n /**\n * List of attributes that should not be output to USFM on markers of this type.\n *\n * This is used for attributes that are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example The `sid` attribute on the `verse` type marker is not present in USFM because it is\n * derived metadata in USX/USJ and is not present in USFM.\n */\n skipOutputAttributeToUsfm?: string[];\n /**\n * List of attributes indicating whether to skip outputting this marker to USFM. If any of the\n * listed attributes is present on the marker, skip outputting this marker when converting to\n * USFM. Only skip outputting the opening and closing marker representations, though; the content\n * inside the marker (if present) should not be skipped.\n *\n * This is used for certain markers that sometimes are normal markers but sometimes are derived\n * metadata and are not present in USFM. These derived metadata markers are identified by whether\n * they have specific attributes on them.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the\n * end of the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the\n * `verse` marker does not have the `style=\"v\"` attribute in this situation, so this list of\n * attributes is on the marker type.\n *\n * Following is an example of a derived metadata `verse` marker in USX:\n *\n * ```xml\n * \n * \n * This is verse 21.\n * \n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\p\n * \\v 21 This is verse 21.\n * ```\n *\n * @example Generated `ref`s should be skipped but have content inside the marker that should not\n * be skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have\n * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived\n * metadata have the `gen` attribute set to `\"true\"` and can be removed if `gen=\"true\"` is\n * present.\n *\n * Following is an example of a generated `ref` in USX:\n *\n * ```xml\n * \n * 2Sam 1:1; 2Sam 1:2-3.\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\xt 2Sam 1:1; 2Sam 1:2-3.\\xt*\n * ```\n */\n skipOutputMarkerToUsfmIfAttributeIsPresent?: string[];\n /**\n * Whether to always skip outputting this marker when converting to USFM. Only skip outputting the\n * opening and closing marker representations, though; the content inside the marker (if present)\n * should not be skipped.\n *\n * This is used for marker types that have no representation in USFM in a given version, likely\n * meaning they are derived metadata and are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ\n * and is not preserved when transforming from USX/USJ to USFM.\n *\n * Following is an example of a derived metadata `table` marker in USX:\n *\n * ```xml\n * \n * \n * \n * Header 1\n * Header 2 space after \n * Header 3-4 centered\n * Header 5 right\n * \n * \n * Row 1 cell 1\n * Row 1 cell 2 space after \n * Row 1 cell 3 centered\n * Row 1 cell 4-5 right\n * \n * \n * Row 2 cell 1-4 right\n * Row 2 cell 5\n * \n *
\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\tr \\th1 Header 1\\th2 Header 2 space after \\thc3-4 Header 3-4 centered\\thr5 Header 5 right\n * \\tr \\tc1 Row 1 cell 1\\tc2 Row 1 cell 2 space after \\thc3 Row 1 cell 3 centered\\thr4-5 Row 1 cell 4-5 right\n * \\tr \\tcr1-4 Row 2 cell 1-4 right\\tc5 Row 2 cell 5\n * ```\n */\n skipOutputMarkerToUsfm?: boolean;\n /**\n * Whether markers of this type should have a newline before them in USFM.\n *\n * Note that the newline is never strictly necessary, and it is not usually present if the very\n * first marker in the file (or in examples such as the following example) should have a newline.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example `para` marker types such as `p` should have a newline, but `char` marker types such as\n * `nd` markers should not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\n hasNewlineBefore?: boolean;\n /**\n * Marker type to use when operating on the USFM representation of markers of this type. For\n * example, when outputting to USFM, the marker type listed here in `markerTypeUsfm` should be\n * used instead of the marker's type as listed in USX or USJ.\n */\n markerTypeUsfm?: string;\n /**\n * Marker type to use when operating on the USX representation of markers of this type. For\n * example, when outputting to USX, the marker type listed here in `markerTypeUsx` should be used\n * instead of the marker's type as listed in USFM or USJ.\n */\n markerTypeUsx?: string;\n /**\n * Marker type to use when operating on the USJ representation of markers of this type. For\n * example, when outputting to USJ, the marker type listed here in `markerTypeUsj` should be used\n * instead of the marker's type as listed in USFM or USX.\n */\n markerTypeUsj?: string;\n /**\n * Prefix to add to the opening and closing marker before the marker name if a marker of this type\n * occurs within another marker of this type when outputting to USFM.\n *\n * @example In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is\n * an example of `nd` inside `wj` (both are `char`-type markers) in USFM:\n *\n * ```usfm\n * \\p \\wj This is \\+nd nested\\+nd*!\\wj*\n * ```\n */\n nestedPrefix?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming to USFM. These instructions are an explanation of what needs to be done to\n * markers of this type to properly transform the marker to USFM.\n *\n * This property is generally only included when it is exceptionally difficult to output a marker\n * properly to USFM; the markers map attempts to use this property as little as possible, favoring\n * encoding information in other properties for more automatic transformation instead.\n */\n outputToUsfmInstructions?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming from USFM to USX or USJ. These instructions are an explanation of what needs\n * to be done to markers of this type to properly transform the marker to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is essential for proper translation between\n * formats.\n *\n * @example `char` is a marker type, which means markers like `w` whose marker type is `char` share\n * some characteristics, and each marker also has its own set of characteristics which are presented\n * with type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows:\n *\n * ```json\n * {\n * \"isCloseable\": true,\n * \"nestedPrefix\": \"+\"\n * }\n * ```\n */\nexport type MarkerTypeInfo = CloseableMarkerTypeInfo | NonCloseableMarkerTypeInfo;\n\n/** A map of all USFM/USX/USJ markers and some information about them */\nexport type MarkersMap = {\n /** Which version of USFM/USX/USJ this map represents */\n version: string;\n /** Which repository this map came from. */\n schemaRepo: string;\n /**\n * Which commit this map came from. This is necessary because the schema file seems to be\n * distributed multiple times in one release version. As such, this specifies the exact version of\n * the schema file.\n */\n schemaCommit: string;\n /**\n * Which version of the markers map types this markers map conforms to. Follows [Semantic\n * versioning](https://semver.org/); the same major version contains no breaking changes.\n */\n markersMapVersion: `1.${number}.${number}${string}`;\n /**\n * Which tag or commit in the `https://github.com/paranext/usfm-tools` repo this map is generated\n * from.\n *\n * Contains the output from `git tag --points-at HEAD` or `git rev-parse HEAD`\n *\n * Will also have a `+` at the end if there were working changes outside the `src/test-data`\n * folder when this was generated.\n */\n usfmToolsCommit: string;\n /**\n * Whether any whitespace after attribute markers and before the next content is not just\n * structural but should actually be considered part of the content of the marker.\n *\n * Structural whitespace is whitespace in the USFM that is required as part of the USFM syntax and\n * usually acts as a delimiter between markers and other things. Content whitespace is whitespace\n * in USFM that is part of the actual Scripture text or the \"content\" of the marker.\n *\n * According to specification, whitespace after attribute markers is not content but is just\n * structural.\n *\n * According to Paratext 9.4, whitespace after attribute markers is content and is not just\n * structural.\n *\n * This setting determines which interpretation to use when converting from USFM to USX/USJ.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n isSpaceAfterAttributeMarkersContent?: boolean;\n /**\n * Whether markers with optional closing markers (see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}) should still be explicitly closed in USFM.\n * That is, whether markers with optional closing markers still need the `closed` attribute set to\n * `\"false\"` in USX/USJ if the closing marker is not present in USFM.\n *\n * In other words, this setting determines whether markers with optional closing markers should\n * still be expected to be explicitly closed (meaning the closing marker is present in USFM) when\n * transforming USX/USJ to USFM unless otherwise indicated by the `closed` attribute.\n *\n * If this is `true` (matches Paratext 9.4), markers with optional closing markers are treated\n * like markers whose normal closing marker is not optional in that they are expected to be\n * explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they should have `closed=\"false\"`\n * - If they are explicitly closed in USFM, they do not need `closed=\"true\"`\n *\n * If this is `false` (matches specification), markers with optional closing markers are expected\n * _not_ to be explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they do not need `closed=\"false\"`\n * - If they are explicitly closed in USFM, they should have `closed=\"true\"`\n *\n * - Disclaimer: It is not clear that `closed=\"true\"` should be present in this case according to\n * `usx.rng`; it seems `usx.rng` indicates that optional closing markers should never be\n * output to USFM. It is possible that `usx.rng` considers this to be a case where\n * preserving the exact USFM is not important.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n shouldOptionalClosingMarkersBePresent?: boolean;\n /**\n * Map whose keys are the marker names and whose values are information about that marker\n *\n * If you find the marker name in this map, you do not need to search the `markersRegExp` map.\n */\n markers: Record;\n /**\n * Map whose keys are string representations of `RegExp` patterns to match against marker names\n * (using the\n * [test](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) and whose values are information about that marker\n *\n * You do not need to search this map if you found the marker name in the `markers` map.\n */\n markersRegExp: Record;\n /** Map whose keys are the marker types and whose values are information about that marker type */\n markerTypes: Record;\n};\n\n// This function should safely freeze anything, but TypeScript doesn't understand.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction deepFreeze(o: any) {\n Object.freeze(o);\n // Don't want to crash out on null\n // eslint-disable-next-line no-null/no-null\n if (o === undefined || o === null) {\n return o;\n }\n\n Object.getOwnPropertyNames(o).forEach(function freezeProperty(prop) {\n if (\n // Need to make sure to avoid null, which is an object type\n // eslint-disable-next-line no-null/no-null\n o[prop] !== null &&\n (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&\n !Object.isFrozen(o[prop])\n ) {\n deepFreeze(o[prop]);\n }\n });\n\n return o;\n}\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file\n */\nexport const USFM_MARKERS_MAP: MarkersMap = deepFreeze({\n version: '3.0.7',\n schemaRepo: 'https://github.com/ubsicap/usx.git',\n schemaCommit: '6c490bb5675d281b0fa01876fe67f6e3fd50a4ce',\n markersMapVersion: '1.0.0',\n usfmToolsCommit: 'b3475856e2b7c0f19739d247ae3f3c13cba66215',\n markers: {\n add: {\n type: 'char',\n description: 'For a translational addition to the text',\n },\n addpn: {\n type: 'char',\n description:\n 'For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)',\n },\n b: {\n type: 'para',\n description: 'Poetry text stanza break (e.g. stanza break)',\n },\n bd: {\n type: 'char',\n description: 'A character style, use bold text',\n },\n bdit: {\n type: 'char',\n description: 'A character style, use bold + italic text',\n },\n bk: {\n type: 'char',\n description: 'For the quoted name of a book',\n },\n c: {\n type: 'chapter',\n leadingAttributes: ['number'],\n attributeMarkers: ['ca', 'cp'],\n },\n ca: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['c'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description: 'Second (alternate) chapter number',\n },\n cat: {\n type: 'char',\n attributeMarkerAttributeName: 'category',\n isAttributeMarkerFor: ['ef', 'efe', 'esb', 'ex', 'f', 'fe', 'x'],\n description: 'Note category (study Bible)',\n },\n cd: {\n type: 'para',\n description: 'Chapter Description (Publishing option D, e.g. in Russian Bibles)',\n },\n cl: {\n type: 'para',\n description: 'Chapter label used for translations that add a word such as \"Chapter\"',\n },\n cls: {\n type: 'para',\n description: 'Closure of an Epistle',\n },\n cp: {\n type: 'para',\n description: 'Published chapter number',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['c'],\n },\n d: {\n type: 'para',\n description: 'A Hebrew text heading, to provide description (e.g. Psalms)',\n },\n dc: {\n type: 'char',\n description: 'Deuterocanonical/LXX additions or insertions in the Protocanonical text',\n },\n ef: {\n type: 'note',\n description: 'Study note',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efe: {\n type: 'note',\n description: 'Extended study endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efm: {\n type: 'char',\n description: 'Reference to caller of previous footnote in a study Bible',\n },\n em: {\n type: 'char',\n description: 'A character style, use emphasized text style',\n },\n esb: {\n type: 'sidebar',\n independentClosingMarkers: ['esbe'],\n attributeMarkers: ['cat'],\n },\n esbe: {\n type: 'sidebar',\n isIndependentClosingMarkerFor: ['esb'],\n },\n ex: {\n type: 'note',\n description: 'Extended cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n f: {\n type: 'note',\n description: 'Footnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fdc: {\n type: 'char',\n description: 'Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n fe: {\n type: 'note',\n description: 'Endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fig: {\n type: 'figure',\n },\n fk: {\n type: 'char',\n description: 'A footnote keyword',\n isClosingMarkerOptional: true,\n },\n fl: {\n type: 'char',\n description:\n 'A footnote label text item, for marking or \"labelling\" the type or alternate translation being provided in the note.',\n isClosingMarkerOptional: true,\n },\n fm: {\n type: 'char',\n description: 'Reference to caller of previous footnote',\n },\n fp: {\n type: 'char',\n description: 'A Footnote additional paragraph marker',\n isClosingMarkerOptional: true,\n },\n fq: {\n type: 'char',\n description: 'A footnote scripture quote or alternate rendering',\n isClosingMarkerOptional: true,\n },\n fqa: {\n type: 'char',\n description: 'A footnote alternate rendering for a portion of scripture text',\n isClosingMarkerOptional: true,\n },\n fr: {\n type: 'char',\n description: 'The origin reference for the footnote',\n isClosingMarkerOptional: true,\n },\n ft: {\n type: 'char',\n description: 'Footnote text, Protocanon',\n isClosingMarkerOptional: true,\n },\n fv: {\n type: 'char',\n description: 'A verse number within the footnote text',\n },\n fw: {\n type: 'char',\n description:\n 'A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.',\n isClosingMarkerOptional: true,\n },\n h: {\n type: 'para',\n description: 'Running header text for a book',\n },\n h1: {\n type: 'para',\n description: 'Running header text (DEPRECATED)',\n },\n h2: {\n type: 'para',\n description: 'Running header text, left side of page (DEPRECATED)',\n },\n h3: {\n type: 'para',\n description: 'Running header text, right side of page (DEPRECATED)',\n },\n ib: {\n type: 'para',\n description: 'Introduction blank line',\n },\n id: {\n type: 'book',\n leadingAttributes: ['code'],\n },\n ide: {\n type: 'para',\n description: 'File encoding information',\n },\n ie: {\n type: 'para',\n description: 'Introduction ending marker',\n },\n iex: {\n type: 'para',\n description:\n 'Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)',\n },\n ili: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n ili1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n ili2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n im: {\n type: 'para',\n description:\n 'Introduction prose paragraph, with no first line indent (may occur after poetry)',\n },\n imi: {\n type: 'para',\n description: 'Introduction prose paragraph text, indented, with no first line indent',\n },\n imq: {\n type: 'para',\n description:\n 'Introduction prose paragraph, quote from the body text, with no first line indent',\n },\n imt: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nIntroduction major title, level 1 - (if single level)',\n },\n imt1: {\n type: 'para',\n description: 'Introduction major title, level 1 (if multiple levels)',\n },\n imt2: {\n type: 'para',\n description: 'Introduction major title, level 2',\n },\n imt3: {\n type: 'para',\n description: 'Introduction major title, level 3',\n },\n imt4: {\n type: 'para',\n description: 'Introduction major title, level 4 (usually within parenthesis)',\n },\n imte: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if single level)',\n },\n imte1: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if multiple levels)',\n },\n imte2: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 2',\n },\n io: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if single level)',\n },\n io1: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if multiple levels)',\n },\n io2: {\n type: 'para',\n description: 'Introduction outline text, level 2',\n },\n io3: {\n type: 'para',\n description: 'Introduction outline text, level 3',\n },\n io4: {\n type: 'para',\n description: 'Introduction outline text, level 4',\n },\n ior: {\n type: 'char',\n description:\n 'Introduction references range for outline entry; for marking references separately',\n },\n iot: {\n type: 'para',\n description: 'Introduction outline title',\n },\n ip: {\n type: 'para',\n description:\n 'Introduction prose paragraph\\nDivision or Section introductory paragraph (study Bible)',\n },\n ipi: {\n type: 'para',\n description: 'Introduction prose paragraph, indented, with first line indent',\n },\n ipq: {\n type: 'para',\n description: 'Introduction prose paragraph, quote from the body text',\n },\n ipr: {\n type: 'para',\n description: 'Introduction prose paragraph, right aligned',\n },\n iq: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if single level)',\n },\n iq1: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if multiple levels)',\n },\n iq2: {\n type: 'para',\n description: 'Introduction poetry text, level 2',\n },\n iq3: {\n type: 'para',\n description: 'Introduction poetry text, level 3',\n },\n iqt: {\n type: 'char',\n },\n is: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if single level)',\n },\n is1: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if multiple levels)',\n },\n is2: {\n type: 'para',\n description: 'Introduction section heading, level 2',\n },\n it: {\n type: 'char',\n description: 'A character style, use italic text',\n },\n jmp: {\n type: 'char',\n defaultAttribute: 'link-href',\n description: 'For associating linking attributes to a span of text',\n },\n k: {\n type: 'char',\n description: 'For a keyword',\n },\n k1: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 1',\n },\n k2: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 2',\n },\n lf: {\n type: 'para',\n description: 'List footer (introductory remark)',\n },\n lh: {\n type: 'para',\n description: 'List header (introductory remark)',\n },\n li: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n li1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n li2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n li3: {\n type: 'para',\n description: 'A list entry, level 3',\n },\n li4: {\n type: 'para',\n description: 'A list entry, level 4',\n },\n lik: {\n type: 'char',\n description: 'Structured list entry key text',\n },\n lim: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if single level)',\n },\n lim1: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if multiple levels)',\n },\n lim2: {\n type: 'para',\n description: 'An embedded list entry, level 2',\n },\n lim3: {\n type: 'para',\n description: 'An embedded list entry, level 3',\n },\n lim4: {\n type: 'para',\n description: 'An embedded list entry, level 4',\n },\n lit: {\n type: 'para',\n description: 'For a comment or note inserted for liturgical use',\n },\n litl: {\n type: 'char',\n description: 'List entry total text',\n },\n liv: {\n type: 'char',\n description: 'Structured list entry value 1 content (if single value)',\n },\n liv1: {\n type: 'char',\n description: 'Structured list entrt value 1 content (if multiple values)',\n },\n liv2: {\n type: 'char',\n description: 'Structured list entry value 2 content',\n },\n liv3: {\n type: 'char',\n description: 'Structured list entry value 3 content',\n },\n liv4: {\n type: 'char',\n description: 'Structured list entry value 4 content',\n },\n liv5: {\n type: 'char',\n description: 'Structured list entry value 5 content',\n },\n m: {\n type: 'para',\n description:\n 'Paragraph text, with no first line indent (may occur after poetry) aka: Paragraph Continuation',\n },\n mi: {\n type: 'para',\n description: 'Paragraph text, indented, with no first line indent; often used for discourse',\n },\n mr: {\n type: 'para',\n description: 'A major section division references range heading',\n },\n ms: {\n type: 'para',\n description: 'A major section division heading, level 1 (if single level)',\n },\n ms1: {\n type: 'para',\n description: 'A major section division heading, level 1 (if multiple levels)',\n },\n ms2: {\n type: 'para',\n description: 'A major section division heading, level 2',\n },\n ms3: {\n type: 'para',\n description: 'A major section division heading, level 3',\n },\n mt: {\n type: 'para',\n description: 'The main title of the book (if single level)',\n },\n mt1: {\n type: 'para',\n description: 'The main title of the book (if multiple levels)',\n },\n mt2: {\n type: 'para',\n description: 'A secondary title usually occurring before the main title',\n },\n mt3: {\n type: 'para',\n description: 'A tertiary title occurring after the main title',\n },\n mt4: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nA small secondary title sometimes occuring within parentheses',\n },\n mte: {\n type: 'para',\n description:\n 'The main title of the book repeated at the end of the book, level 1 (if single level)',\n },\n mte1: {\n type: 'para',\n description:\n 'The main title of the book repeat /ed at the end of the book, level 1 (if multiple levels)',\n },\n mte2: {\n type: 'para',\n description: \"A secondary title occurring before or after the 'ending' main title\",\n },\n nb: {\n type: 'para',\n description:\n 'Paragraph text, with no break from previous paragraph text (at chapter boundary)',\n },\n nd: {\n type: 'char',\n description: 'For name of deity',\n },\n ndx: {\n type: 'char',\n description: 'A subject index text item',\n },\n no: {\n type: 'char',\n description: 'A character style, use normal text',\n },\n optbreak: {\n type: 'optbreak',\n },\n ord: {\n type: 'char',\n description: 'For the text portion of an ordinal number',\n },\n p: {\n type: 'para',\n description:\n 'Paragraph text, with first line indent\\nFront or back matter text paragraph, level 1',\n },\n p1: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 1 (if multiple levels)',\n },\n p2: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 2 (if multiple levels)',\n },\n pb: {\n type: 'para',\n description:\n \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n },\n pc: {\n type: 'para',\n description: 'Inscription (paragraph text centered)',\n },\n periph: {\n type: 'periph',\n textContentAttribute: 'alt',\n },\n ph: {\n type: 'para',\n description:\n 'Paragraph text, with level 1 hanging indent (if single level) (DEPRECATED - use para@style li#)',\n },\n ph1: {\n type: 'para',\n description: 'Paragraph text, with level 1 hanging indent (if multiple levels)',\n },\n ph2: {\n type: 'para',\n description: 'Paragraph text, with level 2 hanging indent',\n },\n ph3: {\n type: 'para',\n description: 'Paragraph text, with level 3 hanging indent',\n },\n pi: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse',\n },\n pi1: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse',\n },\n pi2: {\n type: 'para',\n description:\n 'Paragraph text, level 2 indent, with first line indent; often used for discourse',\n },\n pi3: {\n type: 'para',\n description:\n 'Paragraph text, level 3 indent, with first line indent; often used for discourse',\n },\n pm: {\n type: 'para',\n description: 'Embedded text paragraph',\n },\n pmc: {\n type: 'para',\n description: 'Embedded text closing',\n },\n pmo: {\n type: 'para',\n description: 'Embedded text opening',\n },\n pmr: {\n type: 'para',\n description: 'Embedded text refrain',\n },\n pn: {\n type: 'char',\n description: 'For a proper name',\n },\n png: {\n type: 'char',\n description: 'For a geographic proper name',\n },\n po: {\n type: 'para',\n description: 'Letter opening',\n },\n pr: {\n type: 'para',\n description: 'Text refrain (paragraph right-aligned)',\n },\n pro: {\n type: 'char',\n description: 'For indicating pronunciation in CJK texts (DEPRECATED - used char@style rb)',\n },\n q: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if single level)',\n },\n q1: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if multiple levels)',\n },\n q2: {\n type: 'para',\n description: 'Poetry text, level 2 indent',\n },\n q3: {\n type: 'para',\n description: 'Poetry text, level 3 indent',\n },\n q4: {\n type: 'para',\n description: 'Poetry text, level 4 indent',\n },\n qa: {\n type: 'para',\n description: 'Poetry text, Acrostic marker/heading',\n },\n qac: {\n type: 'char',\n description:\n 'Poetry text, Acrostic markup of the first character of a line of acrostic poetry',\n },\n qc: {\n type: 'para',\n description: 'Poetry text, centered',\n },\n qd: {\n type: 'para',\n description:\n 'A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.',\n },\n qm: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if single level)',\n },\n qm1: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if multiple levels)',\n },\n qm2: {\n type: 'para',\n description: 'Poetry text, embedded, level 2 indent',\n },\n qm3: {\n type: 'para',\n description: 'Poetry text, embedded, level 3 indent',\n },\n qr: {\n type: 'para',\n description: 'Poetry text, Right Aligned',\n },\n qs: {\n type: 'char',\n description: 'Poetry text, Selah',\n },\n qt: {\n type: 'char',\n description: 'For Old Testament quoted text appearing in the New Testament',\n },\n 'qt-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt1-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt1-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt2-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt2-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt3-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt3-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt4-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt4-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt5-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt5-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n r: {\n type: 'para',\n description: 'Parallel reference(s)',\n },\n rb: {\n type: 'char',\n defaultAttribute: 'gloss',\n },\n ref: {\n type: 'ref',\n defaultAttribute: 'loc',\n },\n rem: {\n type: 'para',\n description: 'Remark',\n },\n restore: {\n type: 'para',\n description: 'Comment about when text was restored',\n },\n rq: {\n type: 'char',\n description: 'A cross-reference indicating the source text for the preceding quotation.',\n },\n s: {\n type: 'para',\n description: 'A section heading, level 1 (if single level)',\n },\n s1: {\n type: 'para',\n description: 'A section heading, level 1 (if multiple levels)',\n },\n s2: {\n type: 'para',\n description: 'A section heading, level 2 (e.g. Proverbs 22-24)',\n },\n s3: {\n type: 'para',\n description: 'A section heading, level 3 (e.g. Genesis \"The First Day\")',\n },\n s4: {\n type: 'para',\n description: 'A section heading, level 4',\n },\n sc: {\n type: 'char',\n description: 'A character style, for small capitalization text',\n },\n sd: {\n type: 'para',\n description:\n 'Vertical space used to divide the text into sections, level 1 (if single level)',\n },\n sd1: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 1 (if multiple levels)',\n },\n sd2: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 2',\n },\n sd3: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 3',\n },\n sd4: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 4',\n },\n sig: {\n type: 'char',\n description: 'For the signature of the author of an Epistle',\n },\n sls: {\n type: 'char',\n description:\n 'To represent where the original text is in a secondary language or from an alternate text source',\n },\n sp: {\n type: 'para',\n description: 'A heading, to identify the speaker (e.g. Job)',\n },\n sr: {\n type: 'para',\n description: 'A section division references range heading',\n },\n sts: {\n type: 'para',\n description: 'Status\\nRemark',\n },\n sup: {\n type: 'char',\n description:\n 'A character style, for superscript text. Typically for use in critical edition footnotes.',\n },\n 't-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 't-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n table: {\n type: 'table',\n },\n tl: {\n type: 'char',\n description: 'For transliterated words',\n },\n toc1: {\n type: 'para',\n description: 'Long table of contents text',\n },\n toc2: {\n type: 'para',\n description: 'Short table of contents text',\n },\n toc3: {\n type: 'para',\n description: 'Book Abbreviation',\n },\n toca1: {\n type: 'para',\n description: 'Alternative language long table of contents text',\n },\n toca2: {\n type: 'para',\n description: 'Alternative language short table of contents text',\n },\n toca3: {\n type: 'para',\n description: 'Alternative language book Abbreviation',\n },\n tr: {\n type: 'row',\n description: 'Table row',\n },\n ts: {\n type: 'ms',\n description:\n \"Translator's chunk (to identify chunks of text suitable for translating at one time)\",\n },\n 'ts-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'ts-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n usfm: {\n type: 'para',\n textContentAttribute: 'version',\n parseUsfmInstructions:\n \"If this marker is directly after the first id marker, this marker's version attribute should determine the version attribute of the usx or USJ marker at the top of the USX or USJ document, then this marker should be removed.\",\n },\n USJ: {\n type: 'USJ',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n usx: {\n type: 'usx',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n v: {\n type: 'verse',\n leadingAttributes: ['number'],\n attributeMarkers: ['va', 'vp'],\n },\n va: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description:\n 'Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)',\n },\n vp: {\n type: 'char',\n description:\n 'Published verse marker - this is a verse marking that would be used in the published text',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n },\n w: {\n type: 'char',\n defaultAttribute: 'lemma',\n },\n wa: {\n type: 'char',\n description: 'An Aramaic wordlist text item',\n },\n wg: {\n type: 'char',\n description: 'A Greek Wordlist text item',\n },\n wh: {\n type: 'char',\n description: 'A Hebrew wordlist text item',\n },\n wj: {\n type: 'char',\n description: 'For marking the words of Jesus',\n },\n x: {\n type: 'note',\n description: 'Cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n xdc: {\n type: 'char',\n description:\n 'Cross-reference target reference(s), Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n xk: {\n type: 'char',\n description: 'A cross reference keyword',\n isClosingMarkerOptional: true,\n },\n xnt: {\n type: 'char',\n description: 'Cross-reference target reference(s), New Testament only',\n isClosingMarkerOptional: true,\n },\n xo: {\n type: 'char',\n description: 'The cross reference origin reference',\n isClosingMarkerOptional: true,\n },\n xop: {\n type: 'char',\n description:\n 'Published cross reference origin text (origin reference that should appear in the published text)',\n isClosingMarkerOptional: true,\n },\n xot: {\n type: 'char',\n description: 'Cross-reference target reference(s), Old Testament only',\n isClosingMarkerOptional: true,\n },\n xq: {\n type: 'char',\n description: 'A cross-reference quotation from the scripture text',\n isClosingMarkerOptional: true,\n },\n xt: {\n type: 'char',\n defaultAttribute: 'link-href',\n description:\n 'A target reference(s)\\nA cross reference target reference(s)\\nThe cross reference target reference(s), protocanon only',\n isClosingMarkerOptional: true,\n },\n xta: {\n type: 'char',\n description: 'Cross reference target references added text',\n isClosingMarkerOptional: true,\n },\n },\n markersRegExp: {\n '[Zz].+': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 'qt[1-5]?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 't[hc][rc]?\\\\d+': {\n type: 'cell',\n },\n 'ts?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n },\n markerTypes: {\n book: {},\n cell: {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n },\n chapter: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n char: {\n isCloseable: true,\n nestedPrefix: '+',\n },\n figure: {\n isCloseable: true,\n outputToUsfmInstructions: 'The USX/USJ file attribute needs its name changed to src in USFM',\n parseUsfmInstructions: 'The USFM src attribute needs its name changed to file in USX/USJ',\n },\n ms: {\n isCloseable: true,\n isClosingMarkerEmpty: true,\n },\n note: {\n isCloseable: true,\n },\n optbreak: {\n hasStyleAttribute: false,\n },\n para: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['vid'],\n },\n periph: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n },\n ref: {\n isCloseable: true,\n hasStyleAttribute: false,\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['gen'],\n skipOutputMarkerToUsfm: true,\n },\n row: {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n },\n sidebar: {\n hasNewlineBefore: true,\n },\n table: {\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['vid'],\n skipOutputMarkerToUsfm: true,\n },\n 'table:cell': {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n markerTypeUsfm: 'cell',\n markerTypeUsx: 'cell',\n },\n 'table:row': {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n markerTypeUsfm: 'row',\n markerTypeUsx: 'row',\n },\n unmatched: {\n description:\n 'Paratext uses this type for closing markers that it cannot find opening markers for. They are treated like char markers but have no contents, no closing markers, and no space after the marker.',\n outputToUsfmInstructions:\n 'Do not output a structural space after the opening marker for markers with unmatched type.',\n parseUsfmInstructions:\n 'If a closing marker occurs but does not seem to have a matching opening marker, create an unmatched-type marker. There is no structural space after the unmatched-type marker; its end is determined by the asterisk at the end of the marker.',\n },\n USJ: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n usx: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n verse: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n },\n});\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file and adjusted to reflect the way Paratext 9.4 handles USFM.\n */\nexport const USFM_MARKERS_MAP_PARATEXT: MarkersMap = Object.freeze({\n ...USFM_MARKERS_MAP,\n isSpaceAfterAttributeMarkersContent: true,\n shouldOptionalClosingMarkersBePresent: true,\n});\n","// This was disabled so class functions that are similar in purpose can be grouped together\n/* eslint-disable @typescript-eslint/member-ordering */\nimport {\n USJ_TYPE,\n type MarkerContent,\n type MarkerObject,\n type Usj,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { JSONPath } from 'jsonpath-plus';\nimport { deepEqual } from '../equality-checking';\nimport { SortedNumberMap } from '../sorted-number-map';\nimport { isString } from '../util';\nimport { extractFootnotesFromUsjContent } from './footnote-util';\nimport {\n AttributeMarkerInfo,\n MarkerInfo,\n MarkersMap,\n MarkerTypeInfo,\n USFM_MARKERS_MAP as USFM_MARKERS_MAP_3_0,\n} from './markers-maps/markers-map-3.0.model';\nimport {\n BOOK_TYPE,\n CHAPTER_TYPE,\n ContentJsonPath,\n IUsjReaderWriter,\n NO_BOOK_ID,\n PropertyJsonPath,\n UsfmVerseLocation,\n UsfmVerseRefVerseLocation,\n UsjAttributeKeyLocation,\n UsjAttributeMarkerLocation,\n UsjBookLocation,\n UsjChapterLocation,\n UsjClosingAttributeMarkerLocation,\n UsjClosingMarkerLocation,\n UsjDocumentLocation,\n UsjMarkerLocation,\n UsjNodeAndDocumentLocation,\n UsjPropertyValueLocation,\n UsjReaderWriterOptions,\n UsjSearchResult,\n UsjTextContentLocation,\n UsjVerseRefBookLocation,\n UsjVerseRefChapterLocation,\n VERSE_TYPE,\n} from './usj-reader-writer.model';\n\nconst NODE_TYPES_NOT_CONTAINING_VERSE_TEXT = ['figure', 'note', 'sidebar', 'table'];\nObject.freeze(NODE_TYPES_NOT_CONTAINING_VERSE_TEXT);\n\n/** RegExp that matches all NBSP characters in a string. Used to convert NBSP in USJ to ~ in USFM */\nconst TEXT_CONTENT_NBSP_REGEXP = /\\u00A0/g;\n\n/**\n * RegExp that matches a USX/USJ table marker to get the number out of it. Used to figure out the\n * USFM cell range for table markers with `colspan` attribute in USX/USJ\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the number portion of the marker (the starting column of this cell)\n */\nconst TABLE_MARKER_NUMBER_REGEXP = /\\w+(\\d+)/;\n\n/**\n * RegExp that matches a USFM/USX/USJ verse number (optionally a span) to get the starting verse\n * number and optionally an ending verse number out of it.\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the starting number portion of the verse number\n * - 2: the ending number portion of the verse number if one exists\n *\n * Example:\n *\n * ```usfm\n * \\v 15-16\n * ```\n *\n * We would match this RegExp against `\"15-16\"`\n *\n * Match 1 would be `\"15\"`, and match 2 would be `\"16\"`\n */\nconst VERSE_MARKER_NUMBER_SPAN_REGEXP = /(\\d+)-?(\\d+)?/;\n\n/**\n * Map of USJ content arrays and objects inside content arrays to the content array owner\n *\n * Note that `USJ` markers may have parents if they are unexpectedly present within the contents of\n * the USJ document. We can tell which `USJ` marker is the top-level marker by receiving `undefined`\n * when looking up the `USJ` marker.\n */\ntype UsjParentMap = Map;\n\n/** Fragment indicating a marker closed */\ntype UsjClosingMarkerFragment = { isClosingMarker: true; forMarker: MarkerObject | Usj };\n/** Fragment indicating the value for an attribute */\ntype UsjAttributeValueFragment = { attributeValueForKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the key for an attribute */\ntype UsjAttributeKeyFragment = { attributeKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the opening of an attribute marker */\ntype UsjAttributeMarkerFragment = { attributeMarker: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the closing of an attribute marker */\ntype UsjAttributeMarkerClosingMarkerFragment = {\n attributeMarkerClosingMarker: string;\n forMarker: MarkerObject | Usj;\n};\n\n/**\n * A piece of Scripture data in a USJ document. This could be any of the following:\n *\n * 1. A marker or content string in a USJ document\n *\n * - `Usj`\n * - `MarkerContent`\n * 2. A JavaScript object representation of some part of a marker that isn't actually a JavaScript\n * object\n *\n * - `UsjClosingMarker`\n * - `UsjAttributeValue`\n * - `UsjAttributeKey` except when the attribute whose key is being pointed to is an attribute marker\n * in USFM, in which case this fragment is type 3 below. This fragment represents the USFM\n * attribute marker name in USFM (e.g. `ca`), not the attribute key name (e.g. `altnumber`)\n * 3. Part of a marker as it appears in USFM but that doesn't have a direct equivalence in USJ\n *\n * - `UsjAttributeKey` when pointing to an attribute marker. See fragment type 2 above.\n * - `UsjAttributeMarker`\n * - `UsjAttributeMarkerClosingMarker`\n *\n * This is somewhat similar to `UsfmToken` in `ParatextData.dll`, but there are many differences.\n * `UsfmToken` is a class with many methods and divides Scripture data based on the USFM contents.\n * `UsjFragment`, however, is just a union of object types (and `string`) that indicates the\n * division of Scripture data primarily by USJ contents.\n *\n * This is not the same as or similar to `IFragment` in `ParatextData.dll`. `IFragment` is a bit\n * more similar to {@link UsjFragmentInfo}.\n *\n * If you think of a better name for this, feel free to replace it.\n */\ntype UsjFragment =\n | Usj\n | MarkerContent\n | UsjClosingMarkerFragment\n | UsjAttributeValueFragment\n | UsjAttributeKeyFragment\n | UsjAttributeMarkerFragment\n | UsjAttributeMarkerClosingMarkerFragment;\n\n/**\n * Information about a fragment including its position in the USFM representation. Built while\n * determining the USFM representation of the USJ document\n */\ntype UsjFragmentInfoMinimal = {\n fragment: UsjFragment;\n indexInUsfm: number;\n};\n\n/**\n * A snippet of USFM along with information about what fragments of the marker are where in that\n * USFM snippet\n */\ntype UsfmSnippetAndUsjFragmentsInfo = {\n usfm: string;\n /** USFM position info about the fragments that are represented in this USFM string */\n fragmentsInfo: UsjFragmentInfoMinimal[];\n};\n\n/**\n * Information about a fragment that includes its position in the USFM and the USJ representation.\n * Transformed from {@link UsjFragmentInfoMinimal} in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} while sorting the fragments into the\n * right places after finishing determining the USFM representation.\n *\n * This is somewhat similar to `IFragment` in `ParatextData.dll` in that both contain information\n * that connects some position in USFM to some position in USX (`IFragment`) or USJ\n * (`UsjFragmentInfo`).\n */\ntype UsjFragmentInfo = UsjFragmentInfoMinimal & {\n /**\n * The node this fragment is on and the document location of the start of this fragment (any\n * offset property will be 0)\n */\n nodeAndDocumentLocation: UsjNodeAndDocumentLocation;\n};\n\n/** Fragments at each index in the USFM string */\ntype FragmentsByIndexInUsfm = SortedNumberMap;\n\n/**\n * Array of fragments that have the JSONPath (content or property) that is the key\n *\n * The JSONPath must be \"normalized\" as generated by UsjReaderWriter.convertWorkingStackToJsonPath\n * and UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath. Otherwise, your JSONPath will not\n * match the keys in this map.\n */\ntype FragmentsByJsonPath = Map;\n\n/**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. Used for taking an index based on the start of a verse and\n * determining the index in the whole USFM document to look up in {@link FragmentsByIndexInUsfm}.\n *\n * Notes:\n *\n * - All indices before a book id are associated with the first book id present. If there is not a\n * book id present in the USJ data, everything will be in book {@link NO_BOOK_ID}.\n * - All indices before a chapter number are associated with the first chapter number present. If\n * there is not a chapter number present in the USJ data, everything will be in chapter 0.\n * - Any indices that occur before a verse number will be in verse 0.\n * - The start of a book is at the book name, chapter 1 (or 0 if no chapter numbers), verse 0. The\n * start of a chapter is at the book name, chapter number, verse 0.\n * - There are no verse ranges in this object. Only the starting verse in any range that is found in\n * the USFM is added to this map (in {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}), so\n * we should always look up verse ranges with the starting verse in the range (in\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}). Presumably, if someone is trying to find the\n * index in USFM of a verse that isn't standalone but is in the middle of a range, they are likely\n * going to run into less obvious trouble with index in USFM calculations.\n *\n * TODO: Should we do something else to support verse ranges? Depending on how we want to support\n * them, we can do different things:\n *\n * - If we just want to support getting the first verse in a range (`SerializedVerseRef.verseNum`), we\n * don't need to change anything as this is how it works currently.\n * - If we want to support getting the verse range exactly as it appears in the text and _not_ from\n * the first verse in the range, we could change the index signature `[verseNum: number]` to be\n * accessible by `string | number` and put the `SerializedVerseRef.verse` range text as the key\n * instead of `verseNum` when it is defined and looked up (in at least\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} and\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}; maybe other places as well).\n * - If we want to support getting any verse in a range, we could add the same index in USFM for all\n * the verses within a verse range `SerializedVerseRef.verse` (in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}).\n *\n * In any case, once we come to a clear decision on what we want to do, we should probably document\n * it in the TSDoc for {@link UsjReaderWriter}.\n */\ntype IndicesInUsfmByVerseRef = {\n [book: string]:\n | {\n [chapterNum: number]:\n | {\n [verseNum: number]: number | undefined;\n }\n | undefined;\n }\n | undefined;\n};\n\n/**\n * Represents information about where a USJ node resides in the `content` array of its parent.\n * `parent` is a reference to the node's parent, and `index` represents the numeric index inside of\n * `parent`'s content array.\n */\ntype StackItem = { parent: MarkerObject | Usj; index: number };\n\n/**\n * Stack of levels inside a USJ tree relative to a specific node. The top of the stack should always\n * be the root Usj object.\n */\ntype WorkingStack = StackItem[];\n\n/**\n * Represents USJ formatted scripture with helpful utilities for working with it. Some notable\n * features:\n *\n * - Find Scripture text in the USJ document\n *\n * - `extractText`\n * - `extractTextBetweenPoints`\n * - `findNextLocationOfMatchingText`\n * - `search`\n * - `usfmVerseLocationToNextTextLocation`\n * - Edit the USJ document: `removeContentNodes`\n * - Transform USJ to USFM: `toUsfm`\n * - Transform USJ document locations to USFM locations and vice versa\n *\n * - `usfmVerseLocationToUsjDocumentLocation`\n * - `usjDocumentLocationToUsfmVerseRefVerseLocation`\n * - Use the version of USFM you need by passing in a custom markers map to the constructor if the\n * version in your USJ document is not supported by default:\n * {@link UsjReaderWriterOptions.markersMap}\n *\n * Notes:\n *\n * - \"node\" is a term used in the methods in this class that usually means an object or content string\n * somewhere in the USj document, either {@link Usj} or {@link MarkerContent}. However, in specific\n * situations, it may refer only to {@link MarkerObject} or {@link MarkerContent}. The TypeScript\n * types indicate when this is the case.\n * - See {@link UsfmVerseLocation} and {@link UsjDocumentLocation} for information about transforming\n * USFM locations and USJ locations including what kinds of USFM locations are and are not\n * representable in USJ locations, which USJ locations actually correspond to something in USJ,\n * etc.\n * - It is best to reuse the same `UsjReaderWriter` for the same USJ document as long as possible\n * because there is a significant amount of processing and caching done internally to facilitate\n * various operations. Note that, if the USJ document added to `UsjReaderWriter` changes, you must\n * run `usjChanged` to clear the internal caches and receive accurate results from future method\n * calls\n */\nexport class UsjReaderWriter implements IUsjReaderWriter {\n private readonly usj: Usj;\n private readonly markersMap: MarkersMap;\n private readonly shouldAllowInvisibleCharacters: boolean;\n\n // Cached properties\n private parentMapInternal: UsjParentMap | undefined;\n private fragmentsByIndexInUsfmInternal: FragmentsByIndexInUsfm | undefined;\n private fragmentsByJsonPathInternal: FragmentsByJsonPath | undefined;\n private indicesInUsfmByVerseRefInternal: IndicesInUsfmByVerseRef | undefined;\n private usfmInternal: string | undefined;\n\n constructor(usj: Usj, options?: UsjReaderWriterOptions) {\n this.usj = usj;\n\n const { markersMap: providedMarkersMap, shouldAllowInvisibleCharacters } = options ?? {};\n\n // If they passed in a markers map, use it\n if (providedMarkersMap) {\n this.markersMap = providedMarkersMap;\n\n // Warn if the passed in markers map is not compatible\n if (!UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, this.markersMap.version))\n console.warn(\n `Warning: USJ provided has version ${\n this.usj.version\n }, but provided markers map has version ${\n this.markersMap.version\n }. This may cause unexpected issues when transforming between formats.`,\n );\n }\n // They didn't pass in a markers map, so try to use a built-in markers map matching the USJ version\n else if (\n UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, USFM_MARKERS_MAP_3_0.version)\n )\n this.markersMap = USFM_MARKERS_MAP_3_0;\n else\n throw new Error(\n 'USJ version is not 3.0 or 3.0.x! Not equipped to handle yet without passing in a markers map',\n );\n\n if (!this.markersMap.markersMapVersion.startsWith('1.'))\n throw new Error(\n `Incompatible markers map version: ${\n this.markersMap.markersMapVersion\n }. This class only supports version 1.x.y`,\n );\n\n this.shouldAllowInvisibleCharacters = shouldAllowInvisibleCharacters ?? false;\n }\n\n // If new variables are created to speed up queries, they should be reset here\n usjChanged(): void {\n this.parentMapInternal = undefined;\n this.fragmentsByIndexInUsfmInternal = undefined;\n this.fragmentsByJsonPathInternal = undefined;\n this.indicesInUsfmByVerseRefInternal = undefined;\n this.usfmInternal = undefined;\n }\n\n private static areUsjVersionsCompatible(versionA: string, versionB: string) {\n if (versionA === '3.0' || versionA.startsWith('3.0.'))\n return versionB === '3.0' || versionB.startsWith('3.0.');\n return versionA === versionB;\n }\n\n // #region Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n findSingleValue(jsonPathQuery: string): T | undefined {\n const wrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n if (wrappedResults === undefined || wrappedResults.length === 0) return undefined;\n if (!Array.isArray(wrappedResults[0])) return wrappedResults[0];\n\n // There is no way to tell the difference between a query that returns a single result that is an\n // array and a query that returns multiple results wrapped in an array when `wrap` is false.\n // However, if `wrap` is true then a single result that is an array will be a different array\n // object than the array object within `usj`. So we need to run with `wrap` as true and false to\n // get the original array object back for a query that returns a single array.\n const unwrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: false });\n if (unwrappedResults.length === 1 && Array.isArray(unwrappedResults[0]))\n // I have no idea why eslint is mad about casting from `any` to `T`, but it doesn't like it\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return unwrappedResults[0] as T;\n return unwrappedResults;\n }\n\n findParent(jsonPathQuery: string): T | undefined {\n // Note that \"resultType: 'parent'\" does not work for queries\n // The \"jsonpath-plus\" package allows putting a carat at the end of a query to get a parent\n return this.findSingleValue(`${jsonPathQuery}^`);\n }\n\n // #endregion Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n // #region marker helper methods\n\n /**\n * Determine if the passed in marker is the top-level USJ marker.\n *\n * Note that USJ markers that are not the top-level USJ markers technically should not occur, but\n * they can occur. We should treat them like any other marker. They conform to\n * {@link MarkerObject}, so it's not hard to do.\n *\n * @param marker Marker to test if it is USJ marker\n * @returns `true` if it is a USJ marker; false otherwise\n */\n static isTopLevelUsjMarker(\n marker: Usj | MarkerContent,\n workingStack: WorkingStack,\n ): marker is Usj {\n return typeof marker === 'object' && marker.type === USJ_TYPE && workingStack.length === 0;\n }\n\n /**\n * Determine if a fragment is a marker, not a text content string or some kind of position\n * fragment that isn't actually a marker e.g. closing marker fragment\n */\n private static isFragmentAMarker(fragment: UsjFragment): fragment is MarkerObject | Usj {\n return !isString(fragment) && !('forMarker' in fragment);\n }\n\n // #endregion marker helper methods\n\n // #region Parent Maps\n\n private static createParentMapInternal(\n obj: MarkerObject,\n parent: MarkerObject | Usj,\n parentMap: UsjParentMap,\n ): void {\n parentMap.set(obj, parent);\n // USJ queries may return pointers to content arrays, not just objects\n if (obj.content) parentMap.set(obj.content, obj);\n obj.content?.forEach((child) => {\n if (typeof child === 'object') UsjReaderWriter.createParentMapInternal(child, obj, parentMap);\n });\n }\n\n /** Viewing a Usj object as a tree, build a map to walk up the tree */\n private createUsjParentMap(): UsjParentMap {\n const parentMap = new Map();\n if (this.usj.content) parentMap.set(this.usj.content, this.usj);\n this.usj.content.forEach((content) => {\n if (typeof content === 'object')\n UsjReaderWriter.createParentMapInternal(content, this.usj, parentMap);\n });\n return parentMap;\n }\n\n /** Create the parent map if it doesn't already exist and return it */\n private get parentMap(): UsjParentMap {\n if (this.parentMapInternal) return this.parentMapInternal;\n this.parentMapInternal = this.createUsjParentMap();\n return this.parentMapInternal;\n }\n\n // #endregion Parent Maps\n\n // #region Working Stacks\n\n /**\n * Checks if two stack items are equal using shallow equivalence, testing the stack item\n * properties for [strict\n * equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)\n *\n * Note that this requires the parent of the two stack items to have reference equality\n */\n private static areStackItemsShallowEqual(a: StackItem, b: StackItem): boolean {\n return a.index === b.index && a.parent === b.parent;\n }\n\n /** Return the working stack applicable to the given node */\n private createWorkingStack(node: MarkerObject | Usj): WorkingStack {\n // Represents levels in the USJ node tree that are above the current node (i.e., ancestors)\n // Levels in the tree are represented as a stack, so the last item in the stack is node's parent\n const workingStack: WorkingStack = [];\n\n // Grab a reference so we don't keep checking if it exists\n const { parentMap } = this;\n\n // `node` might be in the middle of the USJ tree, so build up the stack before walking the tree\n let tempNode: MarkerObject | Usj = node;\n let tempParent = parentMap.get(tempNode);\n while (tempParent !== undefined) {\n if (!tempParent.content)\n throw new Error('Invalid parentMap: all parents should have content');\n\n if (\n // Referencing tempNode and tempParent is OK in the loop since 'let' is used instead of 'var'\n // eslint-disable-next-line no-loop-func\n !tempParent.content.find((tempChild, index) => {\n if (tempChild !== tempNode) return false;\n if (!tempParent) throw new Error('undefined \"tempParent\" should not be possible');\n workingStack.unshift({ parent: tempParent, index });\n return true;\n })\n )\n throw new Error(`Unable to find correct parent node of ${JSON.stringify(tempNode)}`);\n\n tempNode = tempParent;\n tempParent = parentMap.get(tempParent);\n }\n\n return workingStack;\n }\n\n /**\n * Transform a JSONPath array (`JSONPath.toPathArray`) to a \"normalized\" JSONPath. We can use this\n * JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static jsonPathArrayToJsonPath(pathArray: string[]): string {\n return pathArray.reduce((pathAcc, pathEntry) => {\n if (pathEntry === 'content') return `${pathAcc}.${pathEntry}`;\n if (!Number.isNaN(parseInt(pathEntry, 10))) return `${pathAcc}[${pathEntry}]`;\n return `${pathAcc}['${pathEntry}']`;\n });\n }\n\n /** \"Normalize\" the JSONPath passed in so we can use it for lookups in {@link FragmentsByJsonPath} */\n private static normalizeJsonPath(jsonPath: string): string {\n // Convert to path array and back to standardize property access syntax\n const pathArray = JSONPath.toPathArray(jsonPath);\n return UsjReaderWriter.jsonPathArrayToJsonPath(pathArray);\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack. We can use this JSONPath\n * for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackToJsonPath(stack: WorkingStack): ContentJsonPath {\n let jsonPath = '$';\n stack.forEach((stackLevel) => {\n jsonPath = `${jsonPath}.content[${stackLevel.index}]`;\n });\n // The JSONPath string construction above conforms to the ContentJsonPath type\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return jsonPath as ContentJsonPath;\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack and property. We can use\n * this JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackAndPropertyToJsonPath(\n stack: WorkingStack,\n property: string,\n ): PropertyJsonPath {\n // Adding this property makes it conform to PropertyJsonPath. Always using bracket notation\n // because it works in more cases than dot notation does\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return `${UsjReaderWriter.convertWorkingStackToJsonPath(stack)}['${property}']` as PropertyJsonPath;\n }\n\n private convertJsonPathToWorkingStack(\n jsonPath: ContentJsonPath | PropertyJsonPath,\n ): WorkingStack {\n const retVal: WorkingStack = [];\n\n // If the JSONPath is pointing to the top marker, there are no content levels\n if (jsonPath === '$') return retVal;\n\n const levels = jsonPath.match(/content\\[(\\d+)\\]/g);\n if (!levels) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n\n let onNode: Usj | MarkerObject = this.usj;\n\n levels.forEach((level, onLevel) => {\n const indexString = /(\\d+)/.exec(level);\n if (!indexString) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n const index = parseInt(indexString[0], 10);\n retVal.push({ parent: onNode, index });\n if (onLevel + 1 < levels.length) {\n if (typeof onNode === 'string' || !onNode.content)\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(onNode)}`);\n const nextNode = onNode.content[index];\n if (typeof nextNode === 'string')\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(nextNode)}`);\n onNode = nextNode;\n }\n });\n\n return retVal;\n }\n\n // #endregion Working Stacks\n\n // #region Walk the node tree\n\n /**\n * Extract textual notes (aka, \"footnotes\") from a full USJ object.\n *\n * @returns An array of MarkerObjects representing all textual notes found in the USJ content.\n */\n findAllNotes(): MarkerObject[] {\n return extractFootnotesFromUsjContent(this.usj?.content);\n\n // Note that the following could be used instead of the above call to\n // extractFootnotesFromUsjContent, and that function could be removed. However, this is about\n // 100x slower than the custom traversal in extractFootnotesFromUsjContent.\n // return this.findAll('$.content..[?(@.type==\"note\")]');\n // This would depend on implementing findAll in this class:\n // findAll(jsonPathQuery: string): T[] {\n // const results = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n // return Array.isArray(results) ? results as T[] : [];\n // }\n }\n\n /**\n * Look through the USJ document for a node or the closing of a node matching some condition. This\n * will run `searchFunction` for `node`, all nodes encountered in `node.contents` (recursively),\n * when `node` closes, and all nodes after `node`\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes and representations of the closing of nodes will be\n * passed into to determine if they are the correct node or representation of the closing of a\n * node. Stops searching and returns the node/close if this function returns `true`\n * @returns Node or representation of the closing of a node matching condition tested by the\n * search function\n */\n private static findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNodeOrClose: MarkerContent | Usj | UsjClosingMarkerFragment,\n workingStack: WorkingStack,\n ) => boolean,\n ) {\n let nextNode: MarkerContent | Usj | undefined = node;\n\n const topNode = workingStack.length === 0 ? node : workingStack[0].parent;\n // If the top node is a marker as we would expect, we need to check if `node` is under a\n // skipped-type node and skip past all that skipped stuff if so. If the top node is a `string`,\n // don't need to worry about this since we should just be searching against that one string\n if (!isString(topNode)) {\n // Determine if we are in a skipped-type node and skip to the next node after it if so\n // If the top node is skipped, return `undefined` because everything is skipped\n if (skipTypes.includes(topNode.type)) return undefined;\n\n // Find the highest (lowest index) stack item level that is skipped so we can go to its next\n // sibling\n let highestSkippedNode: MarkerContent | undefined;\n workingStack.some((stackItem) => {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const stackNode = stackItem.parent.content![stackItem.index];\n if (!isString(stackNode) && skipTypes.includes(stackNode.type)) {\n highestSkippedNode = stackNode;\n return true;\n }\n\n return false;\n });\n\n // Set nextNode to the highest skipped node so it will skip and go to the next sibling in the\n // following code\n if (highestSkippedNode) nextNode = highestSkippedNode;\n }\n\n // Walk the nodes in a depth-first, left-to-right manner until the search function returns true\n while (nextNode !== undefined) {\n const skipNextNode = typeof nextNode === 'object' && skipTypes.includes(nextNode.type);\n\n // If we found the node we're looking for, we're done\n if (!skipNextNode && searchFunction(nextNode, workingStack)) return nextNode;\n\n // Look at the node's children\n if (!skipNextNode && typeof nextNode === 'object' && (nextNode.content?.length ?? 0) > 0) {\n workingStack.push({ parent: nextNode, index: 0 });\n // Same as `nextNode = nextNode.content[0];` without triggering 2 different eslint errors\n [nextNode] = nextNode.content;\n } else {\n if (!skipNextNode) {\n // The node has no children, so check the closing marker for this node\n const nextNodeClosingMarker: UsjClosingMarkerFragment | undefined =\n typeof nextNode === 'object'\n ? { isClosingMarker: true, forMarker: nextNode }\n : undefined;\n if (nextNodeClosingMarker && searchFunction(nextNodeClosingMarker, workingStack))\n return nextNodeClosingMarker;\n }\n\n // Then look at the next sibling, or the parent's next sibling, or the parent's closing\n // marker, etc. up the stack\n nextNode = undefined;\n while (workingStack.length > 0) {\n const nextLevel = workingStack.pop();\n if (nextLevel) {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if (nextLevel.index + 1 < nextLevel.parent.content!.length) {\n // Check the next sibling\n nextLevel.index += 1;\n workingStack.push(nextLevel);\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n nextNode = nextLevel.parent.content![nextLevel.index];\n break;\n } else {\n // There is no next sibling, so check the closing marker for the parent before we\n // continue to look at the parent's next sibling and etc.\n const parentClosingMarker: UsjClosingMarkerFragment = {\n isClosingMarker: true,\n forMarker: nextLevel.parent,\n };\n if (searchFunction(parentClosingMarker, workingStack)) return parentClosingMarker;\n }\n }\n }\n }\n }\n\n // We've looked everywhere, so there must not be an appropriate node anywhere\n return undefined;\n }\n\n /**\n * Look through the USJ document for a node matching some condition\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes will be passed into to determine if they are the\n * correct node. Stops searching and returns the node if this function returns `true`\n * @returns Node matching condition tested by the search function\n */\n private static findNextMatchingNodeUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNode: MarkerContent | Usj,\n workingStack: WorkingStack,\n ) => boolean,\n ): MarkerContent | undefined {\n // We are filtering out closing markers in our search function\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const result = this.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node,\n workingStack,\n skipTypes,\n (potentiallyMatchingNodeOrClose, currentWorkingStack) => {\n if (\n typeof potentiallyMatchingNodeOrClose === 'object' &&\n 'isClosingMarker' in potentiallyMatchingNodeOrClose\n )\n // Skip closing markers\n return false;\n\n // Just search normal markers and text as appropriate for this method\n return searchFunction(potentiallyMatchingNodeOrClose, currentWorkingStack);\n },\n ) as MarkerContent | undefined;\n\n return result;\n }\n\n // #endregion Walk the node tree\n\n // #region Node -> JSONPath\n\n nodeToJsonPath(node: MarkerObject): ContentJsonPath {\n return UsjReaderWriter.convertWorkingStackToJsonPath(this.createWorkingStack(node));\n }\n\n // #endregion Node -> JSONPath\n\n // #region USJ node -> SerializedVerseRef + offset in USFM\n\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { documentLocation: usjLocation } = this.nodeToUsjNodeAndDocumentLocation(\n node,\n nodeParent,\n );\n\n // Find the UsjFragmentInfo at this location\n return this.usjDocumentLocationToUsfmVerseRefVerseLocation(usjLocation, bookIdIfNotFound);\n }\n\n // #endregion USJ node -> SerializedVerseRef + offset in USFM\n\n // #region USJ node -> USJ location\n\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation {\n // Get working stack to the node\n let workingStack: WorkingStack;\n\n if (isString(node)) {\n // If the node is a string, we need to get the working stack from the parent and add the last\n // level for the string node\n if (nodeParent === undefined)\n throw new Error(`If \"node\" is a string, then \"nodeParent\" cannot be undefined`);\n\n // Get the real parent\n const realParent = Array.isArray(nodeParent) ? this.parentMap.get(nodeParent) : nodeParent;\n if (realParent === undefined)\n throw new Error(`Cannot find parent for ${JSON.stringify(nodeParent)}`);\n\n // Get the working stack to the parent\n workingStack = this.createWorkingStack(realParent);\n\n // Add the stack item for the string node\n const nodeIndexInParent = realParent.content?.indexOf(node);\n if (nodeIndexInParent === undefined || nodeIndexInParent < 0)\n throw new Error(`Could not find index of node in parent for creating working stack`);\n workingStack.push({ parent: realParent, index: nodeIndexInParent });\n } else {\n // The node is not a string, so it's easy to get the working stack\n workingStack = this.createWorkingStack(node);\n }\n\n // Get the UsjDocumentLocation for this node so we can find the fragment at that location\n const usjLocation = UsjReaderWriter.convertNodeToUsjDocumentLocation(node, workingStack);\n\n return {\n node,\n documentLocation: usjLocation,\n };\n }\n\n // #endregion USJ node -> USJ location\n\n // #region JSONPath > USJ location\n\n /**\n * Finds the node associated with the JSONPath provided, and also gets the parent of the node if\n * the node is a string. This is helpful so you can find a real object that is actually somewhere\n * in the USJ document from the JSONPath\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered.\n * @returns First node found at the JSONPath and the parent of that node _if_ the node is a\n * string. Note that the object returned is the actual object in the USJ document.\n */\n private jsonPathToNodeAndParentIfString(jsonPathQuery: string): {\n node: MarkerContent | Usj;\n parent: MarkerObject | Usj | MarkerContent[] | undefined;\n } {\n // Find the node this JSONPath is pointing to\n const target: MarkerContent | Usj | undefined = this.findSingleValue(jsonPathQuery);\n if (!target) throw new Error(`No result found for JSONPath query: ${jsonPathQuery}`);\n\n // Find the parent of this node if it is a string so we can know where it is\n const parent: MarkerObject | Usj | MarkerContent[] | undefined = isString(target)\n ? this.findParent(jsonPathQuery)\n : undefined;\n if (!parent && isString(target))\n throw new Error(`Could not determine parent for ${jsonPathQuery}`);\n\n return {\n node: target,\n parent,\n };\n }\n\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usjNodeAndDocumentLocation = this.nodeToUsjNodeAndDocumentLocation(node, parent);\n\n return usjNodeAndDocumentLocation;\n }\n\n // #endregion JSONPath > USJ location\n\n // #region JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usfmVerseLocation = this.nodeToUsfmVerseRefVerseLocation(node, parent, bookIdIfNotFound);\n\n return usfmVerseLocation;\n }\n\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n // Find the fragment with the matching UsjDocumentLocation except offset\n const fragmentInfo = this.findFragmentInfoAtUsjDocumentLocation(usjLocation);\n if (fragmentInfo === undefined)\n throw new Error(\n `Could not find fragment info at USJ document location while transforming to USFM verse location: ${JSON.stringify(\n usjLocation,\n )}`,\n );\n\n const verseRef = this.getVerseRefForIndexInUsfm(fragmentInfo.indexInUsfm, bookIdIfNotFound);\n\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n return {\n verseRef,\n // Final USFM verse offset is the fragment's location relative to the verse plus whatever\n // offset is in the USJ location\n offset:\n fragmentInfo.indexInUsfm -\n verseIndexInUsfm +\n UsjReaderWriter.getOffsetInUsjDocumentLocation(usjLocation),\n };\n }\n\n // #endregion JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n // #region Handling VerseRefs\n\n /**\n * Gets the book ID in the internal USJ document data corresponding to the book ID passed in.\n *\n * @param bookId The book ID to look up data in the USJ document for\n * @returns If there isn't a book ID in the USJ document, {@link NO_BOOK_ID} will be returned\n * @throws If the requested book is not found in the USJ data and there are other books\n * @throws If there is no USJ content in the document whatsoever\n */\n private getEffectiveBookId(bookId: string): string {\n const availableBookIds = Object.keys(this.indicesInUsfmByVerseRef);\n const noBookIdsFound =\n availableBookIds.length === 0 ||\n (availableBookIds.length === 1 && availableBookIds[0] === NO_BOOK_ID);\n const effectiveBookId = noBookIdsFound ? NO_BOOK_ID : bookId;\n const bookIndices = this.indicesInUsfmByVerseRef[effectiveBookId];\n if (!bookIndices)\n throw new Error(\n `Book ID ${bookId} not found in USJ! ${noBookIdsFound ? `There seems to be no USJ content because there is no content in ${NO_BOOK_ID} either` : `Book IDs in USJ: ${JSON.stringify(availableBookIds)}`}`,\n );\n\n return effectiveBookId;\n }\n\n /**\n * Gets the index in USFM of the start of the verse (the backslash on the verse marker or the\n * beginning of the chapter if verse 0 is provided)\n */\n private getIndexInUsfmForVerseRef(verseRef: SerializedVerseRef): number {\n // Make sure the requested book ID is in the USJ content\n const bookId = this.getEffectiveBookId(verseRef.book);\n // `getEffectiveBookId` guaranteed bookIndices is defined\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const bookIndices = this.indicesInUsfmByVerseRef[bookId]!;\n\n // Make sure the requested chapter number is in the USJ content\n const chapterIndices = bookIndices[verseRef.chapterNum];\n if (!chapterIndices) throw new Error(`Could not find ${bookId} chapter ${verseRef.chapterNum}`);\n\n // Make sure the requested verse number is in the USJ content\n // Only look for the verse number even if it is the starting number in a requested verse range\n // because you are likely going to run into less obvious trouble if you get the index in USFM of\n // the wrong verse in a range\n const verseIndexInUsfm = chapterIndices[verseRef.verseNum];\n if (verseIndexInUsfm === undefined)\n throw new Error(`Verse ${verseRef.verseNum} not found in ${bookId} ${verseRef.chapterNum}`);\n\n return verseIndexInUsfm;\n }\n\n /**\n * Gets the verse ref that the provided index in USFM is in (including verse range if applicable).\n * Finds the closest verse ref before the index in USFM.\n *\n * @param indexInUsfm The index in USFM from the beginning of this document\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Closest verse reference before or at the index in USFM\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n private getVerseRefForIndexInUsfm(\n indexInUsfm: number,\n bookIdIfNotFound?: string,\n ): SerializedVerseRef {\n // ENHANCE: This could be sped up and simplified significantly by storing a sorted number map of\n // verse refs by index in USFM like so:\n /**\n * Index in the USFM representation of the USJ document of where the start of each verse ref is\n * (the backslash on the verse marker)\n */\n // type VerseRefsByIndexInUsfm = SortedNumberMap;\n\n const bookEntries = Object.entries(this.indicesInUsfmByVerseRef);\n let bookIndex = 0;\n let lastVerseRef: SerializedVerseRef | undefined;\n let didFindVerseRef = false;\n\n // Loop through all the books looking for the right book\n while (!didFindVerseRef && bookIndex < bookEntries.length) {\n const [bookId, chapterIndices] = bookEntries[bookIndex];\n\n if (chapterIndices) {\n const chapterEntries = Object.entries(chapterIndices);\n let chapterIndex = 0;\n // Loop through all the chapters looking for the right chapter\n while (!didFindVerseRef && chapterIndex < chapterEntries.length) {\n const [chapterNumString, verseIndices] = chapterEntries[chapterIndex];\n if (verseIndices) {\n const verseEntries = Object.entries(verseIndices);\n let verseIndex = 0;\n // Loop through all the verses looking for the right verse\n while (!didFindVerseRef && verseIndex < verseEntries.length) {\n const [verseNumString, verseIndexInUsfm] = verseEntries[verseIndex];\n\n if (verseIndexInUsfm !== undefined) {\n // If the verse ref index in USFM is past the index in USFM to find for the first time,\n // this is the verse ref after this index in USFM. Return the last one\n if (indexInUsfm < verseIndexInUsfm) {\n if (!lastVerseRef)\n // Somehow the index to find is less than the very first known index. Maybe that\n // means it's negative? Either way, it doesn't make sense\n throw new Error(\n `Could not find verse ref for index in USFM ${\n indexInUsfm\n } less than the first known index ${verseIndexInUsfm}`,\n );\n\n // We know the last verse ref, which was the final verse ref before this index.\n // Return that last verse ref\n didFindVerseRef = true;\n break;\n }\n // This verse ref is not past the index in USFM to find, so record this current verse\n // ref to return later if we determine this is the right verse ref\n lastVerseRef = {\n book: bookId,\n chapterNum: parseInt(chapterNumString, 10),\n verseNum: parseInt(verseNumString, 10),\n };\n // If the verse ref index is the same as the index to find, go ahead and return the\n // current verse ref. No need to look at the next index\n if (indexInUsfm === verseIndexInUsfm) {\n didFindVerseRef = true;\n break;\n }\n }\n\n verseIndex += 1;\n }\n }\n\n chapterIndex += 1;\n }\n }\n\n bookIndex += 1;\n }\n\n if (!lastVerseRef)\n throw new Error(`Did not find any verse refs while looking for index in USFM ${indexInUsfm}`);\n\n if (lastVerseRef.book === NO_BOOK_ID) {\n // Deal with no book ID\n if (!bookIdIfNotFound)\n throw new Error(\n `Could not find book ID and no book ID provided when finding USFM verse ref for index in USFM ${\n indexInUsfm\n }`,\n );\n\n lastVerseRef.book = bookIdIfNotFound;\n }\n\n // If `didFindVerseRef` is `false`, the index in USFM to find is greater than all known indices\n // in USFM. That means it's in the very last verse ref. That's fine; no need to do anything\n // special.\n\n // Add the verse range if the verse marker for this location's verse is a range\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(lastVerseRef);\n const verseFragmentInfo = this.fragmentsByIndexInUsfm.get(verseIndexInUsfm);\n if (\n verseFragmentInfo &&\n UsjReaderWriter.isFragmentAMarker(verseFragmentInfo.fragment) &&\n verseFragmentInfo.fragment.type === VERSE_TYPE &&\n verseFragmentInfo.fragment.number &&\n verseFragmentInfo.fragment.number !== `${lastVerseRef.verseNum}`\n )\n lastVerseRef.verse = verseFragmentInfo.fragment.number;\n\n return lastVerseRef;\n }\n\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n if (verseRefOffset < 0) throw new Error('offset must be >= 0');\n\n // Find the index in the whole USFM of this verse\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n // Add the verse offset to the verse index to get the USFM location's index in the USFM\n // representation of this USJ document\n const usfmVerseLocationIndexInUsfm = verseIndexInUsfm + verseRefOffset;\n\n return usfmVerseLocationIndexInUsfm;\n }\n\n // #endregion Handling VerseRefs\n\n // #region transforming location types to different types\n\n /**\n * Transforms a USFM verse-based location into a single standardized format of USFM verse-based\n * location for ease of accessing the location's properties\n *\n * @param usfmVerseLocation USFM verse-based location in one of multiple forms\n * @returns USFM verse-based location in one particular form. Also ensures `offset` is defined\n * (defaults to 0 as described in {@link UsfmVerseLocation})\n */\n static usfmVerseLocationToUsfmVerseRefVerseLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsfmVerseRefVerseLocation & { offset: number } {\n if ('verseRef' in usfmVerseLocation) {\n // UsfmVerseRefVerseLocation\n return {\n verseRef: usfmVerseLocation.verseRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n if ('scrRef' in usfmVerseLocation) {\n // Old deprecated form UsfmScrRefVerseLocation\n return {\n verseRef: usfmVerseLocation.scrRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n // SerializedVerseRef\n return {\n verseRef: usfmVerseLocation,\n offset: 0,\n };\n }\n\n /**\n * Transforms a USJ chapter-based location into a single standardized format of USJ chapter-based\n * location for ease of accessing the location's properties\n *\n * @param usjChapterLocation USJ chapter-based location in one of multiple forms\n * @returns USJ chapter-based location in one particular form.\n * @throws If erroneously received a {@link UsjBookLocation}, not a {@link UsjChapterLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjChapterLocationToUsjVerseRefChapterLocation(\n usjChapterLocation: UsjChapterLocation,\n ): UsjVerseRefChapterLocation {\n // Old deprecated UsjFlatTextChapterLocation\n if ('jsonPath' in usjChapterLocation) {\n if (usjChapterLocation.offset !== undefined)\n // with UsjTextContentLocation (has offset). Unfortunately, TypeScript really doesn't like\n // having this and the following type returned via the same object even though they're very\n // similar because of the required presence/absence of `offset` in each of the returned\n // types. Just breaking them out into separate returns.\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n offset: usjChapterLocation.offset,\n },\n };\n // with UsjMarkerLocation (does not have offset)\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n },\n };\n }\n\n // UsjVerseRefChapterLocation\n if ('verseRef' in usjChapterLocation) {\n if (\n // Make sure we are receiving a chapter location, not a book location\n usjChapterLocation.granularity !== undefined &&\n usjChapterLocation.granularity !== 'chapter'\n )\n throw new Error(\n 'Received UsjVerseRefBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return usjChapterLocation;\n }\n\n // UsjFlatChapterLocation\n // Make sure we are receiving a chapter location, not a book location\n if (usjChapterLocation.chapterNum === undefined)\n throw new Error(\n 'Received UsjFlatBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: usjChapterLocation.documentLocation,\n };\n }\n\n /**\n * Transforms a USJ book-based location into a single standardized format of USJ book-based\n * location for ease of accessing the location's properties\n *\n * @param usjBookLocation USJ book-based location in one of multiple forms\n * @returns USJ book-based location in one particular form.\n * @throws If erroneously received a {@link UsjChapterLocation}, not a {@link UsjBookLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjBookLocationToUsjVerseRefBookLocation(\n usjBookLocation: UsjBookLocation,\n ): UsjVerseRefBookLocation {\n // UsjVerseRefBookLocation\n if ('verseRef' in usjBookLocation) {\n if (\n // Make sure we are receiving a book location, not a chapter location\n usjBookLocation.granularity !== 'book'\n )\n throw new Error(\n 'Received UsjVerseRefChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return usjBookLocation;\n }\n\n // UsjFlatBookLocation\n // Make sure we are receiving a book location, not a chapter location\n if ('chapterNum' in usjBookLocation)\n throw new Error(\n 'Received UsjFlatChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return {\n verseRef: {\n book: usjBookLocation.book,\n chapterNum: 1,\n verseNum: 0,\n },\n granularity: 'book',\n documentLocation: usjBookLocation.documentLocation,\n };\n }\n\n // #endregion transforming location types to different types\n\n // #region USFM location -> USJ location\n\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n // Get the USFM location's index in the USFM representation of this USJ document\n const usfmVerseLocationIndexInUsfm = this.usfmVerseLocationToIndexInUsfm(usfmVerseLocation);\n\n // Find the fragment info at this USFM location\n const { value: fragmentInfo } = this.fragmentsByIndexInUsfm.findClosestLessThanOrEqual(\n usfmVerseLocationIndexInUsfm,\n ) ?? {\n value: undefined,\n };\n if (!fragmentInfo)\n throw new Error(\n `Somehow, did not find anything at index in verse ${verseRefOffset} or below in ${verseRef.book} ${verseRef.chapterNum}:${verseRef.verseNum}. Not sure how this would happen.`,\n );\n\n // Get the offset within the fragment where the USFM location is pointing\n const usjOffset = usfmVerseLocationIndexInUsfm - fragmentInfo.indexInUsfm;\n\n // Add the offset to the fragment's UsjDocumentLocation and return it\n return {\n ...fragmentInfo.nodeAndDocumentLocation,\n documentLocation: UsjReaderWriter.moveUsjDocumentLocationToNewOffset(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n usjOffset,\n ),\n };\n }\n\n usfmVerseLocationToUsjDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation | SerializedVerseRef,\n ): UsjDocumentLocation {\n return this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation).documentLocation;\n }\n\n // #endregion USFM location -> USJ location\n\n // #region UsjDocumentLocation utilities\n\n /**\n * Determine if the USJ document location is pointing to a text content location instead of some\n * location related to a marker object\n *\n * @param usjDocumentLocation USJ document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocation: UsjDocumentLocation,\n ): usjDocumentLocation is UsjTextContentLocation;\n /**\n * Determine if the USJ document location in this node and document location is pointing to a text\n * content location instead of some location related to a marker object\n *\n * @param usjNodeAndDocumentLocation USJ node and document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjNodeAndDocumentLocation: UsjNodeAndDocumentLocation,\n ): usjNodeAndDocumentLocation is UsjNodeAndDocumentLocation;\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocationMaybeNode: UsjDocumentLocation | UsjNodeAndDocumentLocation,\n ): boolean {\n let documentLocation = usjDocumentLocationMaybeNode;\n if ('node' in usjDocumentLocationMaybeNode) {\n // If it's a UsjNodeAndDocumentLocation, the node must be a string\n if (!isString(usjDocumentLocationMaybeNode.node)) return false;\n\n documentLocation = usjDocumentLocationMaybeNode.documentLocation;\n }\n\n // Text content representation in USJDocumentLocation requires offset and nothing else has offset\n return 'offset' in documentLocation;\n }\n\n // #endregion UsjDocumentLocation utilities\n\n // #region Search for text from a certain point\n\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n // Get the location of the verse marker\n const verseLocation = this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation);\n\n // Find the first string after the verse marker\n const firstStringLocationAfterVerseMarker = this.findNextLocationOfMatchingText(\n verseLocation,\n '',\n );\n\n if (!firstStringLocationAfterVerseMarker)\n throw new Error(\n `Could not find next text location after verse ${JSON.stringify(usfmVerseLocation)} at location ${\n verseLocation.documentLocation.jsonPath\n }`,\n );\n\n return firstStringLocationAfterVerseMarker;\n }\n\n findNextLocationOfMatchingText(\n startingPoint: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number = 1000,\n ): UsjNodeAndDocumentLocation | undefined {\n let textScanned = '';\n let lengthScanned = 0;\n let lengthTrimmed = 0;\n let foundStartingAtOffset = -1;\n const workingStackForStartingPoint = this.convertJsonPathToWorkingStack(\n startingPoint.documentLocation.jsonPath,\n );\n // Get the starting point stack item so we can offset our staring search point by the offset.\n // But if we started at the top USJ marker, the starting point isn't text, so we don't need to\n // worry about offsetting as there is no offset.\n // Cloning because the working stack items are modified during search\n const startingPointStackItem =\n workingStackForStartingPoint.length > 0\n ? {\n ...workingStackForStartingPoint[workingStackForStartingPoint.length - 1],\n }\n : undefined;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n workingStackForStartingPoint,\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n let nodeTextToSearch = node;\n\n const currentStackItem = workingStack[workingStack.length - 1];\n\n // If the node is the starting point, then we need to start scanning from the offset.\n // Otherwise look from the start of the string\n if (\n startingPointStackItem &&\n UsjReaderWriter.areStackItemsShallowEqual(currentStackItem, startingPointStackItem)\n ) {\n if (!('offset' in startingPoint.documentLocation))\n throw new Error(\n `Somehow 'offset' was not in text content string document location. This should not happen. ${JSON.stringify(startingPoint.documentLocation)}`,\n );\n nodeTextToSearch = node.substring(startingPoint.documentLocation.offset);\n // We're skipping the offset characters in the first node, so we need to adjust the final\n // foundStartingAtOffset to account for that\n lengthTrimmed += startingPoint.documentLocation.offset;\n }\n\n lengthScanned += nodeTextToSearch.length;\n textScanned = `${textScanned}${nodeTextToSearch}`;\n const textIndex = textScanned.indexOf(text);\n if (textIndex < 0) {\n // Keep the string we're keeping around from going too large\n lengthTrimmed += textScanned.length;\n if (textScanned.length > text.length)\n textScanned = textScanned.substring(textScanned.length - text.length);\n lengthTrimmed -= textScanned.length;\n\n // Stop looking if we haven't found it after scanning a lot of text\n return lengthScanned > maxTextLengthToSearch;\n }\n\n // We found it!\n foundStartingAtOffset = lengthTrimmed + textIndex;\n return true;\n },\n );\n\n // We never found what we wanted\n if (foundStartingAtOffset < 0) return undefined;\n\n // The text might have been split between nodes, so we have to go through it one more time\n lengthScanned = 0;\n let finalOffset = 0;\n let finalStack: WorkingStack = [];\n const finalNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, stack) => {\n if (typeof node !== 'string') return false;\n\n lengthScanned += node.length;\n if (lengthScanned < foundStartingAtOffset + 1) return false;\n\n finalOffset = foundStartingAtOffset - lengthScanned + node.length;\n finalStack = stack;\n return true;\n },\n );\n if (!finalNode) throw new Error('Internal error: inconsistent search results');\n if (!isString(finalNode))\n throw new Error(\n `Somehow found non-string node while searching for strings: ${JSON.stringify(finalNode)}`,\n );\n\n return {\n node: finalNode,\n documentLocation: {\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(finalStack),\n offset: finalOffset,\n },\n };\n }\n\n search(regex: RegExp): UsjSearchResult[] {\n const retVal: UsjSearchResult[] = [];\n if (this.usj.content.length === 0) return retVal;\n\n // Start searching from the first node in the USJ content tree\n const startingPoint: UsjNodeAndDocumentLocation = {\n node: this.usj,\n documentLocation: {\n jsonPath: `$`,\n },\n };\n\n // This will hold all of the text content from the USJ, so we can search it all at once\n const textChunks: string[] = [];\n // This will map the index of each text chunk in the full text, so we can find the location\n const fullTextIndexMap = new SortedNumberMap<\n UsjNodeAndDocumentLocation\n >();\n\n // Variables to track our current position while walking through the USJ content tree\n let currentIndex = 0;\n let nextNode: MarkerContent | Usj | undefined = startingPoint.node;\n while (nextNode !== undefined) {\n nextNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n [],\n // We need to use variables from outside the function to keep track of our current position\n // eslint-disable-next-line no-loop-func\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n textChunks.push(node);\n fullTextIndexMap.set(currentIndex, {\n node,\n documentLocation: {\n offset: 0,\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(workingStack),\n },\n });\n currentIndex += node.length;\n return false;\n },\n );\n }\n\n // Connect all the text chunks together so we can search them all at once. Note that there are\n // no spaces between the text chunks. If we need spaces inserted between verses, chapters, etc.\n // then we should adjust how we walk through the tree to insert extra spaces at the right times.\n const fullText = textChunks.join('');\n\n // Lean on regular expressions to do the heavy lifting of finding matches\n let match: RegExpExecArray | null = regex.exec(fullText);\n while (match) {\n // If the match is empty, then we don't want to include it in the results\n if (match[0].length > 0) {\n if (match.index < 0 || match.index >= fullText.length)\n throw new Error(`Match index out of bounds: ${match.index}`);\n\n const startingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(match.index);\n if (!startingNodeEntry)\n throw new Error(`Internal error: no starting node found for index ${match.index}`);\n const start: UsjNodeAndDocumentLocation = {\n node: startingNodeEntry.value.node,\n documentLocation: {\n jsonPath: startingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index - startingNodeEntry.key,\n },\n };\n\n // Have to find the node containing the last character in the match so we don't go past the\n // ending text node and to the next text node that may be multiple markers past the end text\n // node. Then do NOT subtract one from the index in the offset since the ending location is\n // exclusive, meaning the last character in the match is the character before the ending\n // location.\n const endingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(\n match.index + match[0].length - 1,\n );\n if (!endingNodeEntry)\n throw new Error(`Internal error: no ending node found for index ${match.index}`);\n const end: UsjNodeAndDocumentLocation = {\n node: endingNodeEntry.value.node,\n documentLocation: {\n jsonPath: endingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index + match[0].length - endingNodeEntry.key,\n },\n };\n\n retVal.push({ text: match[0], start, end });\n }\n\n // If the regex is not global, then running `exec` again will return the same match\n if (!regex.global) break;\n match = regex.exec(fullText);\n }\n\n return retVal;\n }\n\n // #endregion Search for text from a certain point\n\n // #region Extract text from a node + JSONPath + offset\n\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string {\n let retVal = '';\n let offsetRemaining = 'offset' in start.documentLocation ? start.documentLocation.offset : 0;\n let lengthRecorded = 0;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node) => {\n if (typeof node !== 'string') return false;\n if (offsetRemaining >= node.length) {\n offsetRemaining -= node.length;\n return false;\n }\n let remainingNode = node;\n if (offsetRemaining > 0) {\n remainingNode = remainingNode.substring(offsetRemaining);\n offsetRemaining = 0;\n }\n if (lengthRecorded + remainingNode.length < desiredLength) {\n lengthRecorded += remainingNode.length;\n retVal = `${retVal}${remainingNode}`;\n return false;\n }\n const lengthToCopy = desiredLength - lengthRecorded;\n retVal = `${retVal}${remainingNode.substring(0, lengthToCopy - 1)}`;\n return true;\n },\n );\n return retVal;\n }\n\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number = 100,\n ): string {\n let retVal = '';\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, currentStack) => {\n // `node` and `end.node` are both `MarkerContent` which might be strings or objects\n if (node === end.node) {\n // If both objects are the same, then we definitely found `end`\n if (typeof node === 'object') return true;\n\n // If both strings are the same, we need to verify that we're at the same place in `usj`\n if (\n end.documentLocation.jsonPath ===\n UsjReaderWriter.convertWorkingStackToJsonPath(currentStack)\n )\n return true;\n }\n if (typeof node !== 'string') return false;\n retVal = `${retVal}${node}`;\n if (retVal.length > maxLength) retVal = retVal.substring(0, maxLength);\n return retVal.length >= maxLength;\n },\n );\n return retVal;\n }\n\n // #endregion Extract text from a node + JSONPath + offset\n\n // #region Edit this USJ data\n\n private static removeContentNodesFromArray(\n contentArray: MarkerContent[],\n searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean,\n ) {\n let removedCount = 0;\n for (let i = contentArray.length - 1; i >= 0; i--) {\n const node = contentArray[i];\n if (searchFunction(node)) {\n contentArray.splice(i, 1);\n removedCount += 1;\n } else if (typeof node !== 'string' && node.content)\n removedCount += this.removeContentNodesFromArray(node.content, searchFunction);\n }\n return removedCount;\n }\n\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number {\n const retVal = UsjReaderWriter.removeContentNodesFromArray(this.usj.content, searchFunction);\n this.usjChanged();\n return retVal;\n }\n\n // #endregion Edit this USJ data\n\n // #region transform USJ to USFM\n\n /**\n * Get `MarkerInfo` by marker name\n *\n * @param markerName Name of the marker for which to get `MarkerInfo`\n * @returns `MarkerInfo` for the marker by name if the marker is in the markers map. `undefined`\n * if the marker is not in the markers map. If you have the marker type, you can build a fake\n * `MarkerInfo` for an unknown marker by making an object with just the type. If not, might be\n * best to throw an error since there probably isn't enough information available to do anything\n * with that marker.\n */\n private getMarkerInfo(markerName: string): MarkerInfo | undefined {\n // Try to get by exact marker name first\n let markerInfo = this.markersMap.markers[markerName];\n\n // If not found by exact name, try to match the RegExp marker names\n if (!markerInfo)\n [, markerInfo] =\n Object.entries(this.markersMap.markersRegExp).find(([markerRegExp]) =>\n new RegExp(markerRegExp).test(markerName),\n ) ?? [];\n\n // Return the marker info we found or `undefined` if we didn't find one\n return markerInfo;\n }\n\n /**\n * Gathers various pieces of information about a marker that are helpful for transforming the\n * marker to USFM\n *\n * WARNING: this only has the ability to return the info for the marker to be used in USFM. If you\n * need to use info for the marker in USX or USJ, this method needs to be modified.\n *\n * @param marker A USJ marker (can be USJ type) or a string which is the marker name\n * @param scriptureFormat The Scripture format to get the marker information for. For example, if\n * you are using this marker info to transform the marker into USFM, this should be `usfm`.\n * Defaults to `usfm`\n * @returns Various pieces of info about the marker\n */\n private getInfoForMarker(\n marker: MarkerObject | Usj | string,\n scriptureFormat: 'usfm' = 'usfm',\n ): {\n /**\n * Marker name on the original marker itself as opposed to the marker name in this Scripture\n * format\n */\n markerNameOriginal: string;\n /**\n * Name of the marker in this Scripture format. For example, In USFM format, the `usx` marker's\n * name is `usfm`\n */\n markerName: string;\n /** Marker info corresponding to `markerName`, not `markerNameOriginal` */\n markerInfo: MarkerInfo;\n /**\n * This marker's type in this Scripture format. For example, In USFM format, the `table:cell`\n * type is `cell`\n */\n markerType: string;\n /** Marker info corresponding to `markerType`, not the marker's original `type` */\n markerTypeInfo: MarkerTypeInfo;\n /**\n * Array of tuples containing the USFM name of an attribute marker that may be present on this\n * marker and the marker info for that attribute marker\n *\n * This is like the returned value from `Object.entries`. However, the order of these is\n * important in some cases, so it cannot simply be an object.\n */\n attributeMarkerInfoEntries: [\n attributeMarkerName: string,\n attributeMarkerInfo: AttributeMarkerInfo,\n ][];\n } {\n if (scriptureFormat !== 'usfm')\n throw new Error(\n 'Scripture formats beside usfm are not supported for getting info for markers',\n );\n\n const markerNameOriginal = isString(marker)\n ? marker\n : // Usj type has no `marker` property, but the Usj marker isn't really different than any other\n // marker with no `marker` property. It is appropriate to treat them the same to get the name\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n ((marker as MarkerObject).marker ?? marker.type);\n\n // If we don't have marker info for the marker or the marker type doesn't match the type in the\n // marker info, this marker is considered unknown. Do some special handling.\n let markerIsUnknown = false;\n\n let markerInfo = this.getMarkerInfo(markerNameOriginal);\n const markerTypeFromFirstMarkerInfo = markerInfo?.type ?? (isString(marker) ? '' : marker.type);\n let markerName = markerNameOriginal;\n\n // Get the actual marker name and info in this format if it is different\n if (markerInfo?.markerUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerName = markerInfo.markerUsfm;\n markerInfo = this.getMarkerInfo(markerName);\n }\n\n // Didn't find the marker, so create `MarkerInfo` with the marker type if possible\n if (!markerInfo) {\n if (isString(marker))\n throw new Error(`Unknown marker ${markerNameOriginal} and no marker type provided`);\n\n markerInfo = { type: marker.type };\n markerIsUnknown = true;\n\n console.warn(\n `Unknown marker ${markerNameOriginal}. Creating MarkerInfo to use: ${JSON.stringify(markerInfo)}`,\n );\n }\n\n // Get the marker type\n let markerType = markerInfo.type;\n let markerTypeInfo = this.markersMap.markerTypes[markerType];\n\n // Get the actual marker type and type info in this format if it is different\n if (markerTypeInfo?.markerTypeUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerType = markerTypeInfo.markerTypeUsfm;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n }\n\n // If the actual marker's type is not one of the expected types, something is wrong. Use the\n // actual marker's type\n if (\n !isString(marker) &&\n marker.type !== markerTypeFromFirstMarkerInfo &&\n (!markerTypeInfo ||\n (marker.type !== markerTypeInfo.markerTypeUsfm &&\n marker.type !== markerTypeInfo.markerTypeUsx &&\n marker.type !== markerTypeInfo.markerTypeUsj))\n ) {\n console.warn(\n `Warning: Mismatching marker type in the USJ content ${marker.type} vs marker type in the marker info ${markerInfo.type} for marker ${markerNameOriginal}. Using the type from the USJ content.`,\n );\n markerType = marker.type;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n markerIsUnknown = true;\n }\n\n // Couldn't find the marker type info\n // Note: In this case, Paratext just ignores the marker and prints the marker's content. This\n // really shouldn't happen, though. I had to manually change a marker type in USX and then import\n // it to Paratext to see this behavior. If you hit this, something is already going terribly wrong.\n if (!markerTypeInfo) {\n throw new Error(\n `Unknown marker type ${markerType} on marker ${markerNameOriginal}! Cannot proceed.`,\n );\n }\n\n if (markerIsUnknown && markerType === 'para')\n // Special case: If the marker type is para and it is unknown, do not add a newline before\n // the marker to match Paratext 9.4. We'll just do the same for spec for now since spec\n // seems to be silent regarding what to do about unknown markers\n markerTypeInfo = { ...markerTypeInfo, hasNewlineBefore: false };\n\n // Figure out attribute marker attribute names\n const attributeMarkerInfoEntries: [string, AttributeMarkerInfo][] = [];\n if (markerInfo.attributeMarkers) {\n markerInfo.attributeMarkers.forEach((attributeMarkerName) => {\n // Note: we are not attempting to get the appropriate marker for the relevant Scripture\n // representation aka we are not using `markerUsfm` for example. There are no attribute\n // markers that have alternate representations and are not likely to be any ever. If that\n // changes, this may cause bugs.\n const attributeMarkerInfo = this.getMarkerInfo(attributeMarkerName);\n\n // Markers map lists an attribute marker that doesn't exist. Just skip this attribute\n if (!attributeMarkerInfo) return;\n\n // Markers map lists an attribute marker that doesn't seem to be an attribute marker.\n // Just skip this attribute\n if (!('attributeMarkerAttributeName' in attributeMarkerInfo)) return;\n\n attributeMarkerInfoEntries.push([attributeMarkerName, attributeMarkerInfo]);\n });\n }\n\n // According to `cell`'s `outputToUsfmInstructions`, cell-type markers with `colspan` need to be\n // cell range marker in USFM, so let's figure that out now\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n if (scriptureFormat === 'usfm' && markerType === 'cell' && markerWithAnyAttributes.colspan) {\n // Get the number of columns that this cell spans\n const columnsSpanned = parseInt(markerWithAnyAttributes.colspan, 10);\n\n const tableMarkerMatches = TABLE_MARKER_NUMBER_REGEXP.exec(markerNameOriginal);\n\n if (tableMarkerMatches?.[1]) {\n // Get the starting cell column number\n const startingColumn = parseInt(tableMarkerMatches[1], 10);\n if (!Number.isNaN(startingColumn) && !Number.isNaN(columnsSpanned)) {\n // Create cell range marker like `tc1-3`\n markerName = `${markerNameOriginal}-${startingColumn + columnsSpanned - 1}`;\n // Set `colspan` so it is not output to USFM since it was just incorporated properly\n markerTypeInfo = {\n ...markerTypeInfo,\n skipOutputAttributeToUsfm: [\n ...(markerTypeInfo.skipOutputAttributeToUsfm ?? []),\n 'colspan',\n ],\n };\n }\n }\n }\n\n return {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n };\n }\n\n /** Converts the text content of a marker to its equivalent in USFM */\n private textContentToUsfm(textContent: string): UsfmSnippetAndUsjFragmentsInfo {\n // Special case: NBSP should be replaced with ~ in USFM if invisible characters are not allowed\n return {\n usfm: this.shouldAllowInvisibleCharacters\n ? textContent\n : textContent.replace(TEXT_CONTENT_NBSP_REGEXP, '~'),\n fragmentsInfo: [{ fragment: textContent, indexInUsfm: 0 }],\n };\n }\n\n /**\n * Merge an independent array of fragment info into an existing array of fragment info, offsetting\n * the indices of the new fragments so their locations start from the end of the string\n */\n private static mergeFragmentsInfoIntoExistingArray(\n newFragmentsInfo: UsjFragmentInfoMinimal[],\n existingFragmentsInfo: UsjFragmentInfoMinimal[],\n existingUsfmLength: number,\n ) {\n newFragmentsInfo.forEach((fragmentInfo) => {\n const fragmentIndex = existingUsfmLength + fragmentInfo.indexInUsfm;\n existingFragmentsInfo.push({\n ...fragmentInfo,\n indexInUsfm: fragmentIndex,\n });\n });\n }\n\n /**\n * Transforms the provided USJ marker into its opening marker representation in USFM\n *\n * Includes a newline before the marker if applicable. Generally also includes a space at the end.\n *\n * Opening markers generally look like the following:\n *\n * ```text\n * \\markerName leadingAttributes textContentAttribute attributeMarkers\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come before the contents of the\n * marker in USFM\n */\n private openingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { markerName, markerInfo, markerType, markerTypeInfo, attributeMarkerInfoEntries } =\n this.getInfoForMarker(marker);\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // Add newline before the marker if there's supposed to be one\n if (markerTypeInfo.hasNewlineBefore) usfm += `\\n`;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n // Add the marker name\n // Fragment representing the very beginning of the marker is the marker itself\n fragmentsInfo.push({ fragment: marker, indexInUsfm: usfm.length });\n // Special case: `optbreak` - transform to `//`\n usfm += markerType === 'optbreak' ? '//' : `\\\\${markerPrefix}`;\n\n if (markerType !== 'optbreak') {\n // Fragment representing the marker name is the `marker` property\n fragmentsInfo.push({\n fragment: { attributeValueForKey: 'marker', forMarker: marker },\n indexInUsfm: usfm.length,\n });\n\n // According to `unmatched`'s `outputToUsfmInstructions`, no space after the marker name\n // because it is basically a closing marker\n usfm += `${markerName}${markerType === 'unmatched' ? '' : ' '}`;\n }\n\n // Add leading attributes in listed order\n if (markerInfo.leadingAttributes) {\n markerInfo.leadingAttributes.forEach((attributeName) => {\n const attributeValue = markerWithAnyAttributes[attributeName];\n\n if (!attributeValue) return;\n\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeValue} `;\n });\n }\n\n // Add text content attribute\n if (\n markerInfo.textContentAttribute &&\n markerWithAnyAttributes[markerInfo.textContentAttribute]\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.textContentAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[markerInfo.textContentAttribute]} `;\n }\n\n // Add attribute markers in listed order\n if (markerInfo.attributeMarkers) {\n attributeMarkerInfoEntries.forEach(([attributeMarkerName, attributeMarkerInfo]) => {\n const attributeValue =\n markerWithAnyAttributes[attributeMarkerInfo.attributeMarkerAttributeName];\n\n if (!attributeValue) return;\n\n // Create a marker that represents this attribute marker so we can make the USFM\n const attributeMarker: MarkerObject = {\n type: attributeMarkerInfo.type,\n marker: attributeMarkerName,\n content: [attributeValue],\n };\n\n // Add the attribute marker USFM to the document\n\n // Collect opening and closing attribute marker fragments so we can modify them before adding\n // them to the main fragments\n const attributeMarkerFragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Caveat: it's not technically always true that this marker is the parent of the attribute\n // markers, but there is currently no known case where it matters because there are no\n // attribute markers that have the same marker type as the marker on which they are\n // attributes. It likely will never matter as this is a very strange concept and it seems\n // the USFM committee doesn't want to create more attribute markers.\n usfm = this.addMarkerUsfmToString(\n usfm,\n attributeMarker,\n marker,\n attributeMarkerFragmentsInfo,\n );\n const { usfm: textContentUsfm } = this.textContentToUsfm(attributeValue);\n fragmentsInfo.push({\n fragment: {\n attributeValueForKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n indexInUsfm: usfm.length,\n });\n usfm += textContentUsfm;\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: attributeMarker,\n },\n marker,\n attributeMarkerFragmentsInfo,\n );\n\n // Transform the opening fragments to attribute marker fragments and add them to the main\n // fragments\n attributeMarkerFragmentsInfo.forEach((fragmentInfo) => {\n // There should never be such a thing as text content in the opening/closing of an attribute\n // marker or an attribute key for an attribute marker\n if (isString(fragmentInfo.fragment) || 'attributeKey' in fragmentInfo.fragment)\n throw new Error(\n `Attribute marker opening or closing markers generated a text content fragment or an attribute key fragment! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n\n if (UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment)) {\n // Opening marker. Need to point to the original marker and indicate this is the opening\n // marker for its attribute marker\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n\n return;\n }\n\n if ('attributeValueForKey' in fragmentInfo.fragment) {\n // There should never be an attribute value for an attribute marker other than the marker name\n if (fragmentInfo.fragment.attributeValueForKey !== 'marker')\n throw new Error(\n `Attribute marker opening or closing markers generated an attribute value fragment for a key that was not marker! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n // Marker representation of the attribute marker. Change to attribute key for attribute\n // marker attribute name.\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n return;\n }\n\n if ('isClosingMarker' in fragmentInfo.fragment) {\n // Closing marker. Need to point to the original marker and indicate this is the closing\n // marker for its attribute marker\n\n // Need to remove isClosingMarker but will not use it again. This was the easiest way to\n // delete it without TypeScript going berserk\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars\n const { isClosingMarker: _, ...partialClosingFragment } = fragmentInfo.fragment;\n\n const fragment: UsjAttributeMarkerClosingMarkerFragment = {\n ...partialClosingFragment,\n forMarker: marker,\n attributeMarkerClosingMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n };\n\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment,\n });\n\n return;\n }\n\n // That should have been all of them, so not sure what other fragment this could be\n throw new Error(\n `Attribute marker opening or closing markers generated an unrecognized fragment: ${JSON.stringify(fragmentInfo)}`,\n );\n });\n\n if (\n !this.markersMap.isSpaceAfterAttributeMarkersContent &&\n attributeMarkerInfo.hasStructuralSpaceAfterCloseAttributeMarker\n )\n // Add the optional structural space after the attribute marker according to spec\n usfm += ' ';\n });\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Transforms the provided USJ marker into its closing marker representation in USFM\n *\n * Closing markers do not include the attributes listed as part of the opening markers (leading\n * attributes, text content attributes, and attribute markers). They only include other kinds of\n * attributes including the default attribute if present.\n *\n * Closing markers with only the default attribute present generally look like the following:\n *\n * ```text\n * |defaultAttribute\\markerName*\n * ```\n *\n * Closing markers with at least one non-default attribute present generally look like the\n * following:\n *\n * ```text\n * |attributeName=\"AttributeValue\" attributeName=\"AttributeValue\"\\markerName*\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come after the contents of the\n * marker in USFM\n */\n private closingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n const {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n } = this.getInfoForMarker(marker);\n\n // Gather attributes that are not listed as part of the opening marker and not skipped in USFM\n const closingMarkerAttributeNames = Object.keys(marker).filter((attributeName) => {\n // Special case: skip properties that are not attributes\n if (attributeName === 'type') return false;\n if (attributeName === 'marker') return false;\n if (attributeName === 'content') return false;\n if (attributeName === 'closed') return false;\n\n // Skip attributes that are supposed to be skipped when outputting to USFM\n if (markerTypeInfo.skipOutputAttributeToUsfm?.includes(attributeName)) return false;\n\n // Not a leadingAttribute\n if (markerInfo.leadingAttributes?.includes(attributeName)) return false;\n\n // Not a textContentAttribute\n if (markerInfo.textContentAttribute === attributeName) return false;\n\n // Not an attributeMarker\n if (\n attributeMarkerInfoEntries.some(\n ([, attributeMarkerInfo]) =>\n attributeMarkerInfo.attributeMarkerAttributeName === attributeName,\n )\n )\n return false;\n\n // There are no other attributes that go on the opening marker, so this must go on the closing\n // marker\n return true;\n });\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // We don't have examples of markers that have both normal closing markers and independent\n // closing markers, so just throw an error if we encounter this situation\n if (\n markerTypeInfo.isCloseable &&\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0\n )\n throw new Error(\n `Marker ${\n markerName\n } is intended to have a normal closing marker and independent closing markers. As of writing this code, there is no known syntax for this situation in USFM. Cannot proceed.`,\n );\n\n // Determine if the marker is supposed to have an explicit closing marker\n let hasExplicitClosingMarker = true;\n // If the closing marker is specified as not present, it should not be present no matter what\n if (markerWithAnyAttributes.closed === 'false') hasExplicitClosingMarker = false;\n else if (\n markerInfo.isClosingMarkerOptional &&\n !this.markersMap.shouldOptionalClosingMarkersBePresent &&\n markerWithAnyAttributes.closed !== 'true'\n ) {\n // If the closing marker is optional, if optional closing markers should be left out, and\n // if it is not specified as closed, then it should not have a closing marker\n hasExplicitClosingMarker = false;\n }\n\n // If this marker has an independent closing marker, create that\n if (\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0 &&\n hasExplicitClosingMarker\n ) {\n // Create a marker that represents this independent closing marker so we can make the USFM\n const independentClosingMarker: MarkerObject = {\n type: markerType,\n marker: markerInfo.independentClosingMarkers[0],\n // Put all the closing marker attributes on here since we don't really have a better place\n // to put them and might as well\n ...Object.fromEntries(\n closingMarkerAttributeNames.map((attributeName) => [\n attributeName,\n markerWithAnyAttributes[attributeName],\n ]),\n ),\n };\n\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { usfm: openingMarkerUsfm, fragmentsInfo: openingFragmentsInfo } =\n this.openingMarkerToUsfm(independentClosingMarker, isInsideMarkerWithSameType);\n // Fragment for independent closing marker is just the normal closing fragment. So find the\n // opening fragment, change it to closing fragment, and add it to the fragments for this\n // marker. Need to get the opening marker so we have the right indexInUsfm (might be 1 if\n // the marker has a newline before it, for example)\n const openingFragmentInfo = openingFragmentsInfo.find((fragmentInfo) => {\n return UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment);\n });\n if (!openingFragmentInfo)\n throw new Error(\n `Could not find opening fragment info for independent closing marker ${JSON.stringify(\n independentClosingMarker,\n )}. Fragments info generated: ${JSON.stringify(openingFragmentsInfo)}`,\n );\n fragmentsInfo.push({\n ...openingFragmentInfo,\n fragment: { isClosingMarker: true, forMarker: marker },\n });\n usfm += openingMarkerUsfm;\n // Only add the independent closing marker if it does not have the same name as the marker we\n // are closing so we don't get in an infinite loop\n if (markerNameOriginal !== independentClosingMarker.marker)\n // ENHANCE: If we ever have a situation where closing marker attributes get on a marker\n // with an independent closing marker, let's add fragments for the attributes here. Though\n // I think this may be something the USFM committee intends to avoid doing based on the\n // proposal to add attributes at the opening marker\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: independentClosingMarker,\n },\n isInsideMarkerWithSameType,\n );\n\n return { usfm, fragmentsInfo };\n }\n\n // This marker doesn't have an independent closing marker, so create a normal closing marker\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Add attributes to the closing marker USFM\n if (closingMarkerAttributeNames.length > 0) {\n // Add the bar before closing attributes\n usfm += '|';\n\n // Default attribute syntax if it is the only attribute present\n if (\n closingMarkerAttributeNames.length === 1 &&\n closingMarkerAttributeNames[0] === markerInfo.defaultAttribute\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.defaultAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += markerWithAnyAttributes[markerInfo.defaultAttribute];\n } else {\n // List all attributes with key and value\n closingMarkerAttributeNames.forEach((attributeName, index) => {\n // According to `figure`'s `outputToUsfmInstructions`, figure's file attribute is src in USFM\n const attributeNameUsfm =\n markerType === 'figure' && attributeName === 'file' ? 'src' : attributeName;\n // Add to the accumulated usfm (starting with a bar): a space if this is after the first\n // attribute, then the attribute name, then =, then \"the attribute value\"\n if (index > 0) usfm += ' ';\n fragmentsInfo.push({\n fragment: { attributeKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeNameUsfm}=\"`;\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[attributeName]}\"`;\n });\n }\n }\n\n // Add the normal closing marker\n if (markerTypeInfo.isCloseable && hasExplicitClosingMarker) {\n const closingMarkerName = markerTypeInfo.isClosingMarkerEmpty ? '' : markerName;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n fragmentsInfo.push({\n fragment: { isClosingMarker: true, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `\\\\${markerPrefix}${closingMarkerName}*`;\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Determines whether this marker and all its content should be skipped entirely when outputting\n * to USFM\n *\n * @param marker Marker to check\n * @returns `true` if this marker should be skipped; `false` otherwise\n */\n private shouldSkipOutputMarkerToUsfm(marker: MarkerObject | Usj) {\n const { markerTypeInfo } = this.getInfoForMarker(marker);\n\n if (markerTypeInfo.skipOutputMarkerToUsfm) return true;\n\n if (\n markerTypeInfo.skipOutputMarkerToUsfmIfAttributeIsPresent?.some(\n (attributeName) => attributeName in marker,\n )\n )\n return true;\n\n return false;\n }\n\n /** Removes one space at the end of the string if present */\n private static removeEndSpace(value: string) {\n // TODO: should this use the surrogate-aware functions?\n if (value.at(-1) !== ' ') return value;\n return value.slice(0, -1);\n }\n\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param markerParent Parent of the marker being added. Used to determine if this marker is\n * nested within another marker of the same type\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | Usj | UsjClosingMarkerFragment,\n markerParent: MarkerObject | Usj | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n isInsideMarkerWithSameType: boolean,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n markerParentOrIsInsideMarkerWithSameType: MarkerObject | Usj | boolean | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string {\n let usfmOutput = usfm;\n\n // Build up the marker's usfm and fragment info separately first because we may modify it before\n // adding it to the full usfm\n let markerUsfmOutput;\n let markerFragmentsInfo: UsjFragmentInfoMinimal[];\n\n const { markerNameOriginal, markerType, markerTypeInfo } = this.getInfoForMarker(\n 'isClosingMarker' in marker ? marker.forMarker : marker,\n );\n\n // Determine if this marker is a direct child of another marker of the same type\n let isParentSameType = false;\n if (typeof markerParentOrIsInsideMarkerWithSameType === 'boolean')\n isParentSameType = markerParentOrIsInsideMarkerWithSameType;\n else if (markerParentOrIsInsideMarkerWithSameType) {\n const { markerType: parentMarkerType } = this.getInfoForMarker(\n markerParentOrIsInsideMarkerWithSameType,\n );\n if (parentMarkerType === markerType) {\n isParentSameType = true;\n }\n }\n\n if ('isClosingMarker' in marker) {\n const { usfm: closingUsfm, fragmentsInfo: closingFragmentsInfo } = this.closingMarkerToUsfm(\n marker.forMarker,\n isParentSameType,\n );\n markerFragmentsInfo = closingFragmentsInfo;\n markerUsfmOutput = closingUsfm;\n\n // If the closing marker is supposed to be empty, there was nothing in the marker content, and\n // there are no closing marker attributes present, we need to remove the structural space after\n // the opening marker\n if (\n markerTypeInfo.isCloseable &&\n markerTypeInfo.isClosingMarkerEmpty &&\n // No contents\n (!marker.forMarker.content || marker.forMarker.content.length === 0) &&\n // No closing marker attributes\n !markerUsfmOutput.startsWith('|')\n ) {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n } else {\n const { usfm: openingUsfm, fragmentsInfo: openingFragmentsInfo } = this.openingMarkerToUsfm(\n marker,\n isParentSameType,\n );\n markerFragmentsInfo = openingFragmentsInfo;\n markerUsfmOutput = openingUsfm;\n }\n\n if (markerUsfmOutput.startsWith('\\n')) {\n if (usfmOutput.length === 0) {\n // If the USFM is empty, don't add a newline at the start\n markerFragmentsInfo = markerFragmentsInfo.map((fragmentInfo) => ({\n ...fragmentInfo,\n indexInUsfm: fragmentInfo.indexInUsfm - 1,\n }));\n markerUsfmOutput = markerUsfmOutput.substring(1);\n } else {\n // If there's supposed to be a newline before the marker, it should eat the last space if\n // there is one (that last space gets turned into the newline in this format)\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n }\n\n // Special case: `ca` after chapter marker needs a newline and space before in Paratext USFM for\n // some reason\n // Note that there is not a newline and space before `ca` after importing from USX in Paratext,\n // so maybe we should just remove the newline and space in the PDP\n if (this.markersMap.isSpaceAfterAttributeMarkersContent && markerNameOriginal === 'ca') {\n // Find the last marker in the current USFM output\n const lastMarkerBackslashIndex = usfmOutput.lastIndexOf('\\\\');\n if (lastMarkerBackslashIndex >= 0) {\n // We just want to know if it's a chapter marker, so we can just get two characters, c and space\n const lastMarker = usfm.substring(\n lastMarkerBackslashIndex + 1,\n lastMarkerBackslashIndex + 3,\n );\n if (lastMarker === 'c ') {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n usfmOutput += '\\n ';\n }\n }\n }\n\n // Add the marker fragments and USFM into the existing fragments and USFM\n if (fragmentsInfo)\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n markerFragmentsInfo,\n fragmentsInfo,\n usfmOutput.length,\n );\n usfmOutput += markerUsfmOutput;\n\n return usfmOutput;\n }\n\n toUsfm() {\n // See calculateUsfmProperties method for implementation\n return this.usfm;\n }\n\n // #endregion transform USJ to USFM\n\n // #region fragment utilities\n\n /**\n * Returns a new {@link UsjDocumentLocation} based on the one passed in but with the offset\n * provided. If the location passed in does not have an offset property, a shallow clone of the\n * location will be returned with no changes.\n */\n private static moveUsjDocumentLocationToNewOffset(\n usjLocation: UsjDocumentLocation,\n usjOffset: number,\n ): UsjDocumentLocation {\n const newLocation = { ...usjLocation };\n\n // UsjTextContentLocation\n if ('offset' in newLocation) newLocation.offset = usjOffset;\n // UsjClosingMarkerLocation\n else if ('closingMarkerOffset' in newLocation) newLocation.closingMarkerOffset = usjOffset;\n // UsjPropertyValueLocation\n else if ('propertyOffset' in newLocation) newLocation.propertyOffset = usjOffset;\n // UsjAttributeKeyLocation\n else if ('keyOffset' in newLocation) newLocation.keyOffset = usjOffset;\n // UsjClosingAttributeMarkerLocation\n else if ('keyClosingMarkerOffset' in newLocation)\n newLocation.keyClosingMarkerOffset = usjOffset;\n // No offset; no change:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return newLocation;\n }\n\n /**\n * Returns the offset of whatever kind that is found in the UsjDocumentLocation. Returns 0 if the\n * location passed in does not have an offset property.\n */\n private static getOffsetInUsjDocumentLocation(usjLocation: UsjDocumentLocation): number {\n // UsjTextContentLocation\n if ('offset' in usjLocation) return usjLocation.offset;\n // UsjClosingMarkerLocation\n if ('closingMarkerOffset' in usjLocation) return usjLocation.closingMarkerOffset;\n // UsjPropertyValueLocation\n if ('propertyOffset' in usjLocation) return usjLocation.propertyOffset;\n // UsjAttributeKeyLocation\n if ('keyOffset' in usjLocation) return usjLocation.keyOffset;\n // UsjClosingAttributeMarkerLocation\n if ('keyClosingMarkerOffset' in usjLocation) return usjLocation.keyClosingMarkerOffset;\n // No offset:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return 0;\n }\n\n /**\n * Compares two UsjDocumentLocations to determine if they are pointing to the same location\n *\n * @param a The first location to compare\n * @param b The second location to compare\n * @param ignoreJsonPath If `true`, the JSONPath properties of the locations will be ignored in\n * the comparison. This is useful if you have already determined that the JSONPaths are the\n * same\n */\n private static areUsjDocumentLocationsEqual(\n a: UsjDocumentLocation,\n b: UsjDocumentLocation,\n ignoreJsonPath = false,\n ) {\n const { jsonPath: aJsonPath, ...restOfA } = a;\n const { jsonPath: bJsonPath, ...restOfB } = b;\n\n // Determine if the two JSONPaths are equivalent even if they use different property syntax\n if (\n !ignoreJsonPath &&\n !deepEqual(JSONPath.toPathArray(aJsonPath), JSONPath.toPathArray(bJsonPath))\n )\n return false;\n\n // Determine if the rest of the location information is the same\n return deepEqual(restOfA, restOfB);\n }\n\n /** Find the fragment info corresponding to the specified USJ Document location. */\n private findFragmentInfoAtUsjDocumentLocation(\n usjLocation: UsjDocumentLocation,\n ): UsjFragmentInfo | undefined {\n // Set offset to 0 because all the fragments' locations are at offset 0\n const zeroedUsjLocation = UsjReaderWriter.moveUsjDocumentLocationToNewOffset(usjLocation, 0);\n\n let fragmentInfoAtLocation: UsjFragmentInfo | undefined;\n const allFragmentsInfoAtJsonPath = this.fragmentsByJsonPath.get(\n UsjReaderWriter.normalizeJsonPath(usjLocation.jsonPath),\n );\n\n // Couldn't find any fragment info at this JSONPath\n if (!allFragmentsInfoAtJsonPath) return undefined;\n\n // Look in the fragments at this JSONPath to find one that matches the full location\n allFragmentsInfoAtJsonPath.find((fragmentInfo) => {\n if (\n !UsjReaderWriter.areUsjDocumentLocationsEqual(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n zeroedUsjLocation,\n // We already compared the JSONPaths by looking in the map for this JSONPath\n true,\n )\n )\n return false;\n\n fragmentInfoAtLocation = fragmentInfo;\n return true;\n });\n\n return fragmentInfoAtLocation;\n }\n\n /**\n * Transform a node and its working stack into the {@link UsjDocumentLocation} corresponding to it.\n *\n * @param node Marker or string to convert\n * @param workingStack Working stack pointing to the node\n * @param locationOffset If applicable, this is the offset that will be put on the\n * {@link UsjDocumentLocation}. If not present, offset on the {@link UsjDocumentLocation} will be\n * `0`. Not all subtypes of {@link UsjDocumentLocation}s have offsets, so this is not used in all\n * situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertNodeToUsjDocumentLocation(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n locationOffset = 0,\n ): UsjTextContentLocation | UsjMarkerLocation {\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n if (isString(node)) {\n // If the node is a text content string, location is the jsonPath and the offset in that\n // string\n const documentLocation: UsjTextContentLocation = { jsonPath, offset: locationOffset };\n return documentLocation;\n }\n\n // The node is a marker itself, so location is just the marker jsonPath. We don't currently\n // provide a way to represent an offset within the opening marker.\n const documentLocation: UsjMarkerLocation = { jsonPath };\n return documentLocation;\n }\n\n /**\n * Transform a fragment and its working stack into the {@link UsjNodeAndDocumentLocation}\n * corresponding to it.\n *\n * @param fragment Fragment to convert\n * @param workingStack Working stack pointing to the marker or string the fragment is in\n * @param offsetWithinFragment If applicable, this is the offset within the fragment that the\n * location is pointing to, which is offset that will be put on the {@link UsjDocumentLocation}.\n * If not present, offset on the {@link UsjDocumentLocation} will be `0` because fragments don't\n * have their own offsets into the contents. Not all {@link UsjDocumentLocation}s have offsets,\n * so this is not used in all situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertFragmentToUsjNodeAndDocumentLocation(\n fragment: UsjFragment,\n workingStack: WorkingStack,\n offsetWithinFragment = 0,\n ): UsjNodeAndDocumentLocation {\n // Return the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n\n // Check if the fragment itself is the target, meaning the fragment is the node in the USJ\n // document (`string`, `MarkerObject`, and `Usj`)\n if (isString(fragment) || UsjReaderWriter.isFragmentAMarker(fragment)) {\n // The fragment/node itself is the target. Get document location for this node\n const documentLocation: UsjTextContentLocation | UsjMarkerLocation =\n UsjReaderWriter.convertNodeToUsjDocumentLocation(\n fragment,\n workingStack,\n offsetWithinFragment,\n );\n return {\n node: fragment,\n documentLocation,\n };\n }\n\n // Check if the target is a closing marker\n if ('isClosingMarker' in fragment) {\n // Get JsonPath to the marker this is a closing marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and an offset within the closing marker\n const documentLocation: UsjClosingMarkerLocation = {\n jsonPath,\n closingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is a property value (`marker` or an attribute)\n if ('attributeValueForKey' in fragment) {\n // Get JsonPath to the indicated property on the marker this is a property for\n const jsonPath = UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath(\n workingStack,\n fragment.attributeValueForKey,\n );\n\n // Location is the jsonPath to the property on the marker and the offset within the property\n // value\n const documentLocation: UsjPropertyValueLocation = {\n jsonPath,\n propertyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute key\n if ('attributeKey' in fragment) {\n // Get JsonPath to the marker this is an attribute key for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker, the key, and the offset within that key\n const documentLocation: UsjAttributeKeyLocation = {\n jsonPath,\n keyName: fragment.attributeKey,\n keyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker\n if ('attributeMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker. We don't\n // currently provide a way to represent an offset within the opening marker.\n const documentLocation: UsjAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarker,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker closing marker\n if ('attributeMarkerClosingMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker\n const documentLocation: UsjClosingAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarkerClosingMarker,\n keyClosingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n throw new Error(\n `Could not transform unrecognized fragment to UsjNodeAndDocumentLocation: ${JSON.stringify(\n fragment,\n )} at working stack ${JSON.stringify(JSON.stringify(fragment))}`,\n );\n }\n\n /**\n * Fill out fragments info from a minimal fragments info array and move them into the final\n * fragments map\n *\n * @param fragmentsInfo Minimal fragments info array to fill out and put into maps. ALL CONTENTS\n * OF THIS ARRAY ARE REMOVED IN THIS METHOD\n * @param workingStack Current working stack\n * @param position Object containing properties describing where in the USFM document these\n * fragments are. If this method encounters a verse range, only the starting verse number is\n * used (hence this is not a {@link SerializedVerseRef}). PROPERTIES ON THIS OBJECT ARE MODIFIED\n * IN THIS METHOD\n * @param fragmentsByIndexInUsfm Map to add fragment information to by index in USFM\n * @param fragmentsByJsonPath Map to add fragment information to by JSONPath\n * @param indicesInUsfmByVerseRef Map to add verse start locations to. If this method encounters a\n * verse range, only the starting verse number is used. See {@link IndicesInUsfmByVerseRef} for\n * potential adjustments to handle verse ranges differently when we know better what we ought to\n * do.\n */\n private static transferFragmentsInfoArrayToMaps(\n fragmentsInfo: UsjFragmentInfoMinimal[],\n workingStack: WorkingStack,\n position: {\n bookId: string;\n chapterNum: number;\n verseNum: number;\n },\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm,\n fragmentsByJsonPath: FragmentsByJsonPath,\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef,\n ): void {\n // Add the extra information to each fragment to make it complete\n const fullFragmentsInfo = fragmentsInfo.map((fragmentInfo) => {\n // Adjust current verse ref if we find start of book, chapter, or verse marker\n if (typeof fragmentInfo.fragment === 'object' && 'type' in fragmentInfo.fragment) {\n const marker = fragmentInfo.fragment;\n\n if (marker.type === BOOK_TYPE && marker.code) {\n // Found book marker. Update current verse ref to new book\n position.bookId = marker.code;\n position.chapterNum = 0;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered book id, move them to the first\n // encountered book id\n if (indicesInUsfmByVerseRef[NO_BOOK_ID]) {\n indicesInUsfmByVerseRef[position.bookId] = indicesInUsfmByVerseRef[NO_BOOK_ID];\n delete indicesInUsfmByVerseRef[NO_BOOK_ID];\n }\n } else if (marker.type === CHAPTER_TYPE && marker.number) {\n // Found chapter marker. Try to update chapter\n const nextChapterNum = parseInt(marker.number, 10);\n\n if (Number.isNaN(nextChapterNum)) {\n console.warn(\n `Found ${CHAPTER_TYPE} type marker with number ${\n marker.number\n }, but could not parse chapter number from it. Continuing using previous chapter number ${\n position.chapterNum\n }`,\n );\n } else {\n // Update current verse ref to new chapter\n position.chapterNum = nextChapterNum;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered chapter number, move them to\n // the first encountered chapter number\n const currentBookFragments = indicesInUsfmByVerseRef[position.bookId];\n if (currentBookFragments?.[0]) {\n // Not array destructuring because it's really hard to read here\n // eslint-disable-next-line prefer-destructuring\n currentBookFragments[position.chapterNum] = currentBookFragments[0];\n delete currentBookFragments[0];\n }\n }\n } else if (marker.type === VERSE_TYPE && marker.number) {\n // Found verse marker. Try to update verse\n const nextVerseNumString = VERSE_MARKER_NUMBER_SPAN_REGEXP.exec(marker.number)?.[1];\n\n if (!nextVerseNumString) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not find starting verse number in it. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else {\n const nextVerseNum = parseInt(nextVerseNumString, 10);\n\n if (Number.isNaN(nextVerseNum)) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not parse starting verse number from ${nextVerseNumString}. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else if (\n indicesInUsfmByVerseRef[position.bookId]?.[position.chapterNum]?.[nextVerseNum]\n ) {\n console.warn(`Found ${VERSE_TYPE} marker with existing number ${nextVerseNum} after\n current ${VERSE_TYPE} number ${\n position.verseNum\n }! Not updating verse start index. All positions in this duplicate verse will be based on the current ${\n VERSE_TYPE\n } marker, not the new duplicate marker.`);\n } else {\n if (nextVerseNum < position.verseNum)\n console.debug(\n `Found ${VERSE_TYPE} marker with number ${nextVerseNum} lower than current ${\n VERSE_TYPE\n } number ${position.verseNum}. Verses are out of order. There may be some issues.`,\n );\n\n // Update current verse ref to new verse\n position.verseNum = nextVerseNum;\n }\n }\n }\n }\n\n // Fill out the rest of the fragment info\n const fullFragmentInfo: UsjFragmentInfo = {\n ...fragmentInfo,\n // Determine the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n nodeAndDocumentLocation: UsjReaderWriter.convertFragmentToUsjNodeAndDocumentLocation(\n fragmentInfo.fragment,\n workingStack,\n ),\n };\n\n return fullFragmentInfo;\n });\n\n // Add staged fragments to final fragments maps\n fullFragmentsInfo.forEach((fragmentInfo) => {\n // Put the fragment info in the map by index in USFM\n fragmentsByIndexInUsfm.set(fragmentInfo.indexInUsfm, fragmentInfo);\n\n // Put the fragment info in the map by JSONPath. Note this JSONPath is generated using\n // UsjReaderWriter.convertWorkingStackToJsonPath and\n // UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath, so it is \"normalized\".\n // Must use \"normalized\" JSONPath when looking up fragments by JSONPath.\n const fragmentJsonPath = fragmentInfo.nodeAndDocumentLocation.documentLocation.jsonPath;\n const fragmentsAtJsonPath = fragmentsByJsonPath.get(fragmentJsonPath);\n if (fragmentsAtJsonPath) fragmentsAtJsonPath.push(fragmentInfo);\n else fragmentsByJsonPath.set(fragmentJsonPath, [fragmentInfo]);\n\n // Put the fragment's index in USFM in the map by verse reference\n // We are ensuring the properties are defined all the way through before use, so allow the\n // bang operator. This would be way more verbose without bang operator.\n /* eslint-disable no-type-assertion/no-type-assertion */\n if (!indicesInUsfmByVerseRef[position.bookId]) indicesInUsfmByVerseRef[position.bookId] = {};\n if (!indicesInUsfmByVerseRef[position.bookId]![position.chapterNum])\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum] = {};\n if (\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] ===\n undefined\n )\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] =\n fragmentInfo.indexInUsfm;\n /* eslint-enable no-type-assertion/no-type-assertion */\n });\n\n // Remove all elements from fragmentsInfo\n fragmentsInfo.splice(0);\n }\n\n // #endregion fragment utilities\n\n // #region USFM-related cached properties\n\n /**\n * Generates USFM representation of the USJ document passed in and returns it along with\n * information about how various locations in USFM and USJ map to each other\n */\n private calculateUsfmProperties(): {\n usfm: string;\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm;\n fragmentsByJsonPath: FragmentsByJsonPath;\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef;\n } {\n // Build the USFM up from the USJ content\n let usfm = '';\n // Build the fragments maps as we go\n const fragmentsByIndexInUsfm = new SortedNumberMap();\n const fragmentsByJsonPath = new Map();\n const indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef = {};\n\n // Temporary staging array to put fragments in before loading them into the map\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Keep track of current verse reference numbers as we go through the content so we can put\n // fragments in the right place\n const currentPosition = {\n bookId: NO_BOOK_ID,\n chapterNum: 0,\n verseNum: 0,\n };\n /** Move the fragments info that are in `fragmentsInfo` into the final fragments map */\n function transferFragmentsInfo(workingStack: WorkingStack) {\n UsjReaderWriter.transferFragmentsInfoArrayToMaps(\n fragmentsInfo,\n workingStack,\n currentPosition,\n fragmentsByIndexInUsfm,\n fragmentsByJsonPath,\n indicesInUsfmByVerseRef,\n );\n }\n\n // According to `USJ`'s `outputToUsfmInstructions`, need to move the top-level `USJ` marker after\n // `id` closes in USFM even though it is before it in USJ\n let topLevelUsjMarker: Usj | undefined;\n // The marker objects we're currently skipping ordered as a stack (last entry is the deepest\n // marker we are skipping and therefore will be the next to close). If this has entries, it\n // means we are walking through contents of marker objects whose opening marker we already skipped\n // and whose closing marker we should also skip outputting to USFM\n const markersToSkipOutput: (MarkerObject | Usj)[] = [];\n\n UsjReaderWriter.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n this.usj,\n // Working stack is empty since the top-level object doesn't have any parents\n [],\n // Don't skip anything\n [],\n (nodeOrClosingFragment, workingStack) => {\n if (typeof nodeOrClosingFragment !== 'object') {\n // Add the text contents USFM representation\n const { usfm: textContentUsfm, fragmentsInfo: textContentFragmentsInfo } =\n this.textContentToUsfm(nodeOrClosingFragment);\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n textContentFragmentsInfo,\n fragmentsInfo,\n usfm.length,\n );\n transferFragmentsInfo(workingStack);\n usfm += textContentUsfm;\n return false;\n }\n\n // Determine this marker's parent\n let markerParent: MarkerObject | Usj | undefined;\n if (workingStack.length > 0) {\n markerParent = workingStack[workingStack.length - 1].parent;\n }\n\n if ('isClosingMarker' in nodeOrClosingFragment) {\n // If we are supposed to skip this marker in USFM, skip its closing marker\n if (\n markersToSkipOutput.length > 0 &&\n markersToSkipOutput[markersToSkipOutput.length - 1] === nodeOrClosingFragment.forMarker\n ) {\n // Indicate the skipped marker has now closed by removing it from the stack\n markersToSkipOutput.pop();\n return false;\n }\n\n // Add the closing marker USFM representation\n usfm = this.addMarkerUsfmToString(\n usfm,\n nodeOrClosingFragment,\n markerParent,\n fragmentsInfo,\n );\n transferFragmentsInfo(workingStack);\n\n // If this is closing the `id` marker (the only marker whose type is `book`), add the\n // top-level USJ opening marker after it\n if (nodeOrClosingFragment.forMarker.type === 'book' && topLevelUsjMarker) {\n usfm = this.addMarkerUsfmToString(usfm, topLevelUsjMarker, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n topLevelUsjMarker = undefined;\n }\n\n return false;\n }\n\n // If we are supposed to skip this marker in USFM, skip its opening marker\n if (this.shouldSkipOutputMarkerToUsfm(nodeOrClosingFragment)) {\n markersToSkipOutput.push(nodeOrClosingFragment);\n return false;\n }\n\n // If this is the USJ marker at the start of the doc, save it until after `id` marker closes\n if (\n UsjReaderWriter.isTopLevelUsjMarker(nodeOrClosingFragment, workingStack) &&\n !topLevelUsjMarker\n ) {\n // The USJ types aren't set up to know about 3.0 right now, but we should handle it anyway\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if ((nodeOrClosingFragment.version as string) !== '3.0') {\n // Don't output the USJ marker if it is 3.0 (3.0 is assumed and should not appear in\n // the USFM)\n topLevelUsjMarker = nodeOrClosingFragment;\n }\n return false;\n }\n\n // Add the opening marker USFM representation\n usfm = this.addMarkerUsfmToString(usfm, nodeOrClosingFragment, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n\n // Keep going through the whole document\n return false;\n },\n );\n\n // Always add newline at the end of the file; likely replaces a space\n usfm = `${UsjReaderWriter.removeEndSpace(usfm)}\\n`;\n\n return { usfm, fragmentsByIndexInUsfm, fragmentsByJsonPath, indicesInUsfmByVerseRef };\n }\n\n /** The USFM representation of the USJ document passed in */\n private get usfm(): string {\n if (this.usfmInternal !== undefined) return this.usfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.usfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByIndexInUsfm(): FragmentsByIndexInUsfm {\n if (this.fragmentsByIndexInUsfmInternal) return this.fragmentsByIndexInUsfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByIndexInUsfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByJsonPath(): FragmentsByJsonPath {\n if (this.fragmentsByJsonPathInternal) return this.fragmentsByJsonPathInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByJsonPathInternal;\n }\n\n /**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. See {@link IndicesInUsfmByVerseRef} for more information.\n */\n private get indicesInUsfmByVerseRef(): IndicesInUsfmByVerseRef {\n if (this.indicesInUsfmByVerseRefInternal) return this.indicesInUsfmByVerseRefInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.indicesInUsfmByVerseRefInternal;\n }\n\n // #endregion USFM-related cached properties\n}\n\nexport default UsjReaderWriter;\n"],"names":["_AsyncVariable","variableName","rejectIfNotSettledWithinMS","__publicField","resolve","reject","enabled","value","throwIfAlreadySettled","reason","AsyncVariable","Collator","locales","options","string1","string2","DateTimeFormat","date","startDate","endDate","PlatformEventEmitter","event","callback","callbackIndex","newGuid","s","isString","o","deepClone","obj","debounce","fn","delay","timeout","promise","promiseResolve","promiseReject","args","e","groupBy","items","keySelector","valueSelector","map","item","index","key","group","isErrorWithMessage","error","toErrorWithMessage","maybeError","getErrorMessage","wait","ms","waitForDuration","maxWaitTimeInMS","getAllObjectFunctionNames","_objId","objectFunctionNames","property","objectPrototype","createSyncProxyForAsyncObject","getObject","objectToProxy","target","prop","isErrorMessageAboutParatextBlockingInternetAccess","errorMessage","paratextExceptionMessage","isErrorMessageAboutRegistryAuthFailure","paratextExceptionMessage1","paratextExceptionMessage2","errorString","DocumentCombiner","baseDocument","documentName","document","previousDocumentVersion","documentToSet","contributions","contributionName","potentialOutput","outputIteration","contribution","mergeObjects","output","finalOutput","areNonArrayObjects","values","allMatch","areArrayObjects","startingPoint","copyFrom","ignoreDuplicateProperties","retVal","mergeObjectsInternal","startingPointObj","copyFromObj","EventRollingTimeCounter","bufferSize","currentTime","minRollingTimeMs","Mutex","AsyncMutex","MutexMap","mutexID","NonValidatingDocumentCombiner","NumberFormat","startRange","endRange","defaultPromise","PromiseChainingMap","logger","promiseFunction","currentPromise","promiseHolder","newPromise","SortedNumberMap","insertIndex","left","right","result","mid","SortedSet","compareFn","low","high","UnsubscriberAsyncList","name","unsubscribers","unsubscriber","unsubs","results","unsubscriberSucceeded","PLATFORM_ERROR_VERSION","newPlatformError","platformError","isPlatformError","P","R","t","n","N","B","O","S","K","g","k","x","T","X","V","w","L","G","A","H","C","I","y","q","U","m","l","h","c","E","r","D","i","a","u","v","f","d","b","p","J","M","find","list","predicate","ac","hasOwn","freeze","object","oc","assign","source","HTML_BOOLEAN_ATTRIBUTES","isHTMLBooleanAttribute","HTML_VOID_ELEMENTS","isHTMLVoidElement","tagName","HTML_RAW_TEXT_ELEMENTS","isHTMLRawTextElement","isHTMLEscapableRawTextElement","isHTMLMimeType","mimeType","MIME_TYPE","hasDefaultHTMLNamespace","_MIME_TYPES","isValidMimeType","NAMESPACE","conventions","require$$0","extendError","constructor","writableName","DOMExceptionName","DOMExceptionNames","isValidDomExceptionCode","endsWithError","DOMException","messageOrCode","nameOrMessage","code","ExceptionCode","entries","ParseError","message","locator","errors","detectUnicodeSupport","RegExpImpl","match","UNICODE_SUPPORT","chars","regexp","chars_without","search","reg","self","part","isStr","regg","UNICODE_REPLACEMENT_CHARACTER","Char","_SChar","SChar_s","S_OPT","NameStartChar","NameStartChar_s","NameChar","Name","Nmtoken","EntityRef","CharRef","Reference","PEReference","EntityValue","AttValue","NCNameStartChar","NCNameChar","NCName","QName","QName_exact","QName_group","SystemLiteral","PI","PubidChar","PubidLiteral","COMMENT_START","COMMENT_END","Comment","PCDATA","Mixed","_children_quantity","children","contentspec","ELEMENTDECL_START","elementdecl","NotationType","Enumeration","EnumeratedType","AttType","DefaultDecl","AttDef","ATTLIST_DECL_START","AttlistDecl","ABOUT_LEGACY_COMPAT","ABOUT_LEGACY_COMPAT_SystemLiteral","SYSTEM","PUBLIC","ExternalID","ExternalID_match","NDataDecl","EntityDef","ENTITY_DECL_START","GEDecl","PEDef","PEDecl","EntityDecl","PublicID","NotationDecl","Eq","VersionNum","VersionInfo","EncName","EncodingDecl","SDDecl","XMLDecl","DOCTYPE_DECL_START","CDATA_START","CDATA_END","CDStart","CDEnd","CData","CDSect","grammar","PDC","require$$1","require$$2","checkSymbol","symbol","notEmptyString","input","splitOnASCIIWhitespace","orderedSetReducer","current","element","toOrderedSet","arrayIncludes","validateQualifiedName","qualifiedName","validateAndExtract","namespace","prefix","localName","splitResult","copy","src","dest","_extends","Class","Super","pt","NodeType","ELEMENT_NODE","ATTRIBUTE_NODE","TEXT_NODE","CDATA_SECTION_NODE","ENTITY_REFERENCE_NODE","ENTITY_NODE","PROCESSING_INSTRUCTION_NODE","COMMENT_NODE","DOCUMENT_NODE","DOCUMENT_TYPE_NODE","DOCUMENT_FRAGMENT_NODE","NOTATION_NODE","DocumentPosition","commonAncestor","docGUID","doc","NodeList","nodeFilter","buf","serializeToString","me","LiveNodeList","node","refresh","_updateLiveList","inc","ls","__set__","NamedNodeMap","_findNodeIndex","_addNamedNode","el","newAttr","oldAttr","_onRemoveAttribute","_onAddAttribute","_removeNamedNode","attr","lastIndex","namespaceURI","DOMImplementation","feature","version","doctype","contentType","Document","root","publicId","systemId","internalSubset","DocumentType","title","htmlNode","headNode","titleNode","Node","rootNode","other","parent","otherNode","newChild","refChild","_insertBefore","oldChild","assertPreReplacementValidityInDocument","_removeChild","deep","cloneNode","child","next","node1","node2","attr1","attr2","Attr","chain1","ancestor1","chain2","ancestor2","ca","_xmlEncoder","_visitNode","opt","ns","remove","_onUpdateChild","childNodes","parentNode","oldPreviousSibling","oldNextSibling","hasValidParentNodeType","hasInsertableNodeType","isDocTypeNode","isElementNode","isTextNode","isElementInsertionPossible","parentChildNodes","docTypeNode","isElementReplacementPossible","hasElementChildThatIsNotChild","assertPreInsertionValidity1to5","assertPreInsertionValidityInDocument","nodeChildNodes","nodeChildElements","parentElementChild","_inDocumentAssertion","cp","newFirst","newLast","pre","removed","importedNode","importNode","id","rtv","Element","attrs","DocumentFragment","data","Text","CDATASection","ProcessingInstruction","EntityReference","validated","old","classNames","classNamesSet","base","nodeClassNames","matches","nodeClassNamesSet","isHTMLDocument","lowerQualifiedName","nodeQualifiedName","matchingQName","CharacterData","offset","count","text","start","end","newText","newNode","Notation","Entity","XMLSerializer","nodeSerializeToString","refNode","uri","visibleNamespaces","needNamespaceDefine","isHTML","addSerializedAttribute","len","nodeName","prefixedNodeName","defaultNS","ai","nsi","canCloseTag","pubid","sysid","attrs2","getTextContent","dom","exports","S_TAG","S_ATTR","S_ATTR_SPACE","S_EQ","S_ATTR_NOQUOT_VALUE","S_ATTR_END","S_TAG_SPACE","S_TAG_CLOSE","XMLReader","defaultNSMap","entityMap","domBuilder","_copy","parse","ENTITY_REG","defaultNSMapCopy","errorHandler","fixedFromCharCode","surrogate1","surrogate2","entityReplacer","complete","appendText","xt","position","lineStart","lineEnd","linePattern","parseStack","unclosedTags","tagStart","fromSource","tagNameRaw","tagNameMatch","currentTagName","tagNameLower","config","localNSMap","parseProcessingInstruction","parseDoctypeCommentOrCData","ElementAttributes","currentNSMap","parseElementStartPart","locator2","copyLocator","appendElement","parseHtmlSpecialContent","addAttribute","qname","startIndex","attrName","qName","nsp","nsPrefix","elStartEnd","isEscapableRaw","elEndStart","parseUtils","char","skip","skipBlanks","blanks","substringFromIndex","substringStartsWith","substringStartsWithCaseInsensitive","getMatch","expr","parseDoctypeInternalSubset","parsePI","intSubsetStart","comment","cdata","sax","entities","require$$3","require$$4","normalizeLineEndings","DOMParser","DOMHandler","defaultNamespace","isXml","impl","ins","ch","length","_toString","charNode","comm","dt","level","_locator","handler","onErrorStopParsing","onWarningStopParsing","domParser","lib","charRegex","astralRange","comboRange","varRange","familyRange","astral","combo","fitz","modifier","nonAstral","regional","surrogatePair","zwj","blackFlag","family","optModifier","optVar","optJoin","seq","__importDefault","this","mod","dist","char_regex_1","toArray","str","substring","begin","substr","strLength","limit","padString","padPosition","padRepeats","indexOf","searchStr","pos","strArr","searchArr","finded","searchIndex","ensureArray","maybeArray","at","string","stringLength","charAt","codePointAt","endsWith","searchString","endPosition","lastIndexOfSearchString","lastIndexOf","indexOfClosestClosingCurlyBrace","escaped","closeCurlyBraceIndex","formatReplacementStringToArray","replacers","contents","nextIntermediateStartIndex","addToContents","newContent","newContentIndex","newContentLength","intermediateContent","baseSubstring","replacerKey","replacerContent","endContent","formatReplacementString","content","includes","partialString","stringzIndexOf","validatedPosition","stringzLength","normalize","form","upperCaseForm","ordinalCompare","padEnd","targetLength","stringzLimit","padStart","correctSliceIndex","slice","indexStart","indexEnd","newStart","newEnd","split","separator","splitLimit","regexSeparator","currentIndex","matchIndex","matchLength","startsWith","stringzSubstr","stringzSubstring","stringzToArray","isLocalizeKey","escapeStringRegexp","transformAndEnsureRegExpRegExpArray","stringStringMaybeArray","stringMaybeStringArray","transformAndEnsureRegExpArray","stringMaybeArray","whiteSpaceRegex","isWhiteSpace","toKebabCase","prevChar","nextChar","BLOCK_MARKER_TYPES","USJ_TYPE","ZWSP","scrBookData","FIRST_SCR_BOOK_NUM","LAST_SCR_BOOK_NUM","FIRST_SCR_CHAPTER_NUM","FIRST_SCR_VERSE_NUM","defaultScrRef","getChaptersForBook","bookNum","_a","offsetBook","scrRef","Canon","offsetChapter","offsetVerse","getLocalizedIdFromBookNumber","bookNumber","localizationLanguage","getLocalizedString","bookName","parts","scrRefToBBBCCC","VerseRef","scrRefToBBBCCCVVV","compareScrRefs","scrRef1","scrRef2","getLocalizeKeyForScrollGroupId","scrollGroupId","getLocalizeKeysForScrollGroupIds","scrollGroupIds","formatScrRef","optionOrLocalizedBookName","chapterVerseSeparator","bookChapterSeparator","book","Section","getSectionForBook","bookId","nonSemanticWhiteSpaceRegex","isNonSemanticWhiteSpace","invisibleCharOrWhiteSpaceRegex","isParatextSelectableInvisibleCharOrWhiteSpace","normalizeScriptureSpaces","lastCharWasSpace","prevCh","isUsjContentEmpty","isAtEndOfBlockMarker","contentObject","areUsjContentsEqualExceptWhitespaceInternal","aParent","bParent","aIsString","bIsString","aNormalized","bNormalized","aTrimmed","bTrimmed","aObject","bObject","aKeys","isAContentEmpty","isBContentEmpty","aContent","bContent","aLast","bLast","areUsjContentsEqualExceptWhitespace","aggregateUnsubscribers","success","aggregateUnsubscriberAsyncs","unsubPromises","BOOK_TYPE","CHAPTER_TYPE","VERSE_TYPE","NO_BOOK_ID","getDefaultCallerSequence","_","getNthCaller","callers","callerList","getFormatCallerFunction","footnotes","plusSequenceMap","autoCallerCounter","idx","caller","formattedCaller","extractFootnotesFromUsjContent","traverse","getPaneSizeLimits","availablePx","splitterThicknessPx","secondaryPaneMinSizePx","mainPaneMinSizePx","absoluteMinPercent","absoluteMaxPercent","usableHeightPx","minPercent","maxPercent","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","combineComparators","comparatorA","comparatorB","state","createIsCircular","areItemsEqual","cache","cachedA","cachedB","getStrictProperties","sameValueZeroEqual","PREACT_VNODE","PREACT_OWNER","REACT_OWNER","getOwnPropertyDescriptor","keys","areArraysEqual","areDatesEqual","areErrorsEqual","areFunctionsEqual","areMapsEqual","size","matchedIndices","aIterable","aResult","bResult","bIterable","hasMatch","aEntry","bEntry","areNumbersEqual","areObjectsEqual","properties","isPropertyEqual","areObjectsEqualStrict","descriptorA","descriptorB","arePrimitiveWrappersEqual","areRegExpsEqual","areSetsEqual","areTypedArraysEqual","areUrlsEqual","ARGUMENTS_TAG","BOOLEAN_TAG","DATE_TAG","ERROR_TAG","MAP_TAG","NUMBER_TAG","OBJECT_TAG","REG_EXP_TAG","SET_TAG","STRING_TAG","URL_TAG","isArray","isTypedArray","getTag","createEqualityComparator","type","tag","createEqualityComparatorConfig","circular","createCustomConfig","strict","areArraysEqual$1","areMapsEqual$1","areObjectsEqual$1","areSetsEqual$1","createInternalEqualityComparator","compare","_indexOrKeyA","_indexOrKeyB","_parentA","_parentB","createIsEqual","comparator","createState","equals","_b","meta","deepEqual","createCustomEqual","createCustomInternalComparator","isEqualDeep","isSubset","objectWithAllProperties","objectWithPartialProperties","partialArray","allArray","partialObj","allObj","serialize","replacer","space","replacerValue","newValue","deserialize","reviver","replaceNull","parsedObject","isSerializable","serializedValue","htmlEncode","getCurrentLocale","formatBytes","fileSize","decimals","sizes","sizeToUse","MILLISECONDS_PER_SECOND","SECONDS_PER_MINUTE","SECONDS_PER_HOUR","SECONDS_PER_DAY","formatTimeSpan","relativeTimeFormatter","since","to","spanSeconds","totalDays","totalHours","totalMinutes","formatRelativeDate","todayString","yesterdayString","locale","today","yesterday","isToday","isYesterday","MODIFIER_KEYS","settingsDefs","removeJsonToTypeScriptTypesStuff","defs","def","projectSettingsDocumentSchema","settingsDocumentSchema","localizedStringsDefs","localizedStringsDocumentSchema","menuDocumentSchema","themeDefs","themeDocumentSchema","THEME_STYLE_ELEMENT_ID","getThemeId","themeFamilyId","expandThemeContribution","themeFamiliesById","defaultThemeFamily","themeFamily","themeDefinition","getStylesheetForTheme","theme","applyThemeStylesheet","previousStyleElement","styleElementIdSuffix","previousThemeId","themeStyleElement","deepFreeze","USFM_MARKERS_MAP","USFM_MARKERS_MAP_PARATEXT","NODE_TYPES_NOT_CONTAINING_VERSE_TEXT","TEXT_CONTENT_NBSP_REGEXP","TABLE_MARKER_NUMBER_REGEXP","VERSE_MARKER_NUMBER_SPAN_REGEXP","UsjReaderWriter","usj","providedMarkersMap","shouldAllowInvisibleCharacters","USFM_MARKERS_MAP_3_0","versionA","versionB","jsonPathQuery","wrappedResults","JSONPath","unwrappedResults","marker","workingStack","fragment","parentMap","tempNode","tempParent","tempChild","pathArray","pathAcc","pathEntry","jsonPath","stack","stackLevel","levels","onNode","onLevel","indexString","nextNode","skipTypes","searchFunction","topNode","highestSkippedNode","stackItem","stackNode","skipNextNode","nextNodeClosingMarker","nextLevel","parentClosingMarker","potentiallyMatchingNodeOrClose","currentWorkingStack","nodeParent","bookIdIfNotFound","usjLocation","realParent","nodeIndexInParent","fragmentInfo","verseRef","verseIndexInUsfm","availableBookIds","noBookIdsFound","effectiveBookId","chapterIndices","indexInUsfm","bookEntries","bookIndex","lastVerseRef","didFindVerseRef","chapterEntries","chapterIndex","chapterNumString","verseIndices","verseEntries","verseIndex","verseNumString","verseFragmentInfo","usfmVerseLocation","verseRefOffset","usjChapterLocation","usjBookLocation","usfmVerseLocationIndexInUsfm","usjOffset","usjDocumentLocationMaybeNode","documentLocation","verseLocation","firstStringLocationAfterVerseMarker","maxTextLengthToSearch","textScanned","lengthScanned","lengthTrimmed","foundStartingAtOffset","workingStackForStartingPoint","startingPointStackItem","nodeTextToSearch","currentStackItem","textIndex","finalOffset","finalStack","finalNode","regex","textChunks","fullTextIndexMap","fullText","startingNodeEntry","endingNodeEntry","desiredLength","offsetRemaining","lengthRecorded","remainingNode","lengthToCopy","maxLength","currentStack","contentArray","removedCount","markerName","markerInfo","markerRegExp","scriptureFormat","markerNameOriginal","markerIsUnknown","markerTypeFromFirstMarkerInfo","markerType","markerTypeInfo","attributeMarkerInfoEntries","attributeMarkerName","attributeMarkerInfo","markerWithAnyAttributes","columnsSpanned","tableMarkerMatches","startingColumn","textContent","newFragmentsInfo","existingFragmentsInfo","existingUsfmLength","fragmentIndex","isInsideMarkerWithSameType","usfm","fragmentsInfo","markerPrefix","attributeName","attributeValue","attributeMarker","attributeMarkerFragmentsInfo","textContentUsfm","partialClosingFragment","closingMarkerAttributeNames","hasExplicitClosingMarker","independentClosingMarker","openingMarkerUsfm","openingFragmentsInfo","openingFragmentInfo","attributeNameUsfm","closingMarkerName","markerParentOrIsInsideMarkerWithSameType","usfmOutput","markerUsfmOutput","markerFragmentsInfo","isParentSameType","parentMarkerType","closingUsfm","closingFragmentsInfo","openingUsfm","lastMarkerBackslashIndex","newLocation","ignoreJsonPath","aJsonPath","restOfA","bJsonPath","restOfB","zeroedUsjLocation","fragmentInfoAtLocation","allFragmentsInfoAtJsonPath","locationOffset","offsetWithinFragment","fragmentsByIndexInUsfm","fragmentsByJsonPath","indicesInUsfmByVerseRef","nextChapterNum","currentBookFragments","nextVerseNumString","nextVerseNum","_c","fragmentJsonPath","fragmentsAtJsonPath","currentPosition","transferFragmentsInfo","topLevelUsjMarker","markersToSkipOutput","nodeOrClosingFragment","textContentFragmentsInfo","markerParent"],"mappings":";;;;;AACO,MAAMA,KAAN,MAAMA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiB5B,YAAYC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AAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAAA,EAId,IAAY,sBAA2C;AACjD,WAAA,KAAK,8BAAoC,KAAK,+BAEjD;AAAA,MACC,MAAM,KAAK;AAAA,MACX,wBAAwB,KAAK;AAAA,MAC7B,qBAAqB,KAAK;AAAA,MAC1B,yBAAyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,IAAY,0BAAmD;AACzD,WAAA,KAAK,kCAAwC,KAAK,mCAErD;AAAA,MACC,MAAM,KAAK;AAAA,MACX,wBAAwB,KAAK;AAAA,MAC7B,qBAAqB,KAAK;AAAA,MAC1B,yBAAyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAIhB;","x_google_ignoreList":[16,17,18,19,20,21,22,23,24,25,26,27,35]} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../src/promises/async-variable.ts","../src/intl/intl-collator.ts","../src/intl/intl-date-time-format.ts","../src/events/platform-event-emitter.model.ts","../src/util.ts","../src/document-combiner.ts","../src/event-rolling-time-counter.ts","../src/promises/mutex.ts","../src/promises/mutex-map.ts","../src/non-validating-document-combiner.ts","../src/intl/intl-number-format.ts","../src/promises/promise-chaining-map.ts","../src/sorted-number-map.ts","../src/sorted-set.ts","../src/lifetime-management/unsubscriber-async-list.ts","../src/platform-error.ts","../../../node_modules/@sillsdev/scripture/dist/index.es.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/conventions.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/errors.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/grammar.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/dom.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/entities.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/sax.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/dom-parser.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/node_modules/@xmldom/xmldom/lib/index.js","../../../node_modules/@eten-tech-foundation/scripture-utilities/dist/index.js","../../../node_modules/char-regex/index.js","../../../node_modules/stringz/dist/index.js","../src/array-util.ts","../src/string-util.ts","../src/scripture/scripture-util.ts","../src/lifetime-management/unsubscriber.ts","../src/scripture/usj-reader-writer.model.ts","../src/scripture/footnote-util.ts","../src/pane-utils.ts","../../../node_modules/fast-equals/dist/esm/index.mjs","../src/equality-checking.ts","../src/subset-checking.ts","../src/serialization.ts","../src/intl/intl-util.ts","../src/number-utils.ts","../src/date-time-format-util.ts","../src/keyboard-util.ts","../src/extension-contributions/settings.model.ts","../src/extension-contributions/localized-strings.model.ts","../src/extension-contributions/menus.model.ts","../src/extension-contributions/theme.model.ts","../src/extension-contributions/theme.util.ts","../src/scripture/markers-maps/markers-map-3.0.model.ts","../src/scripture/usj-reader-writer.ts"],"sourcesContent":["/** This class provides a convenient way for one task to wait on a variable that another task sets. */\nexport class AsyncVariable {\n private static verboseLoggingEnabled: boolean = false;\n private readonly variableName: string;\n private readonly promiseToValue: Promise;\n private timeoutId: ReturnType | undefined;\n private timeoutOccurred: boolean;\n private resolver: ((value: T) => void) | undefined;\n private rejecter: ((reason: string | undefined) => void) | undefined;\n\n /**\n * Creates an instance of the class\n *\n * @param variableName Name to use when logging about this variable\n * @param rejectIfNotSettledWithinMS Milliseconds to wait before verifying if the promise was\n * settled (resolved or rejected); will reject if it has not settled by that time. Use -1 if you\n * do not want a timeout at all. Defaults to 10000 ms\n */\n constructor(variableName: string, rejectIfNotSettledWithinMS: number = 10000) {\n this.variableName = variableName;\n this.timeoutOccurred = false;\n this.promiseToValue = new Promise((resolve, reject) => {\n this.resolver = resolve;\n this.rejecter = reject;\n });\n if (rejectIfNotSettledWithinMS > 0) {\n this.timeoutId = setTimeout(() => {\n if (this.rejecter) {\n this.rejecter(`Timeout reached when waiting for ${this.variableName} to settle`);\n this.timeoutOccurred = true;\n this.complete();\n }\n }, rejectIfNotSettledWithinMS);\n }\n Object.seal(this);\n }\n\n /**\n * Get this variable's promise to a value. This always returns the same promise even after the\n * value has been resolved or rejected.\n *\n * @returns The promise for the value to be set\n */\n get promise(): Promise {\n return this.promiseToValue;\n }\n\n /**\n * A simple way to see if this variable's promise was resolved or rejected already\n *\n * @returns Whether the variable was already resolved or rejected\n */\n get hasSettled(): boolean {\n return Object.isFrozen(this);\n }\n\n /**\n * Can use to determine if a rejection occurred due to a timeout\n *\n * @returns Whether the variable timed out while waiting for a value to resolve\n */\n get hasTimedOut(): boolean {\n return this.timeoutOccurred;\n }\n\n /**\n * Allows enabling more verbose logging when async variables resolve and reject\n *\n * @param enabled Whether to enable verbose logging\n */\n static setVerboseLogging(enabled: boolean): void {\n this.verboseLoggingEnabled = enabled;\n }\n\n /**\n * Resolve this variable's promise to the given value\n *\n * @param value This variable's promise will resolve to this value\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n resolveToValue(value: T, throwIfAlreadySettled: boolean = false): void {\n if (this.resolver) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being resolved now`);\n this.resolver(value);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent resolution of ${this.variableName}`);\n }\n }\n\n /**\n * Reject this variable's promise for the value with the given reason\n *\n * @param reason This variable's promise will be rejected with this reason\n * @param throwIfAlreadySettled Determines whether to throw if the variable was already resolved\n * or rejected. Defaults to `false`\n */\n rejectWithReason(reason: string, throwIfAlreadySettled: boolean = false): void {\n if (this.rejecter) {\n if (AsyncVariable.verboseLoggingEnabled)\n console.debug(`${this.variableName} is being rejected now with reason: ${reason}`);\n this.rejecter(reason);\n this.complete();\n } else {\n if (throwIfAlreadySettled) throw Error(`${this.variableName} was already settled`);\n console.debug(`Ignoring subsequent rejection of ${this.variableName}`);\n }\n }\n\n /** Prevent any further updates to this variable */\n private complete(): void {\n this.resolver = undefined;\n this.rejecter = undefined;\n if (this.timeoutId !== undefined) {\n clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n Object.freeze(this);\n }\n}\n\nexport default AsyncVariable;\n","/** Enables language-sensitive string comparison. Wraps Intl.Collator */\nexport class Collator {\n private collator: Intl.Collator;\n\n constructor(locales?: string | string[], options?: Intl.CollatorOptions) {\n this.collator = new Intl.Collator(locales, options);\n }\n\n /**\n * Compares two strings according to the sort order of this Collator object\n *\n * @param string1 String to compare\n * @param string2 String to compare\n * @returns A number indicating how string1 and string2 compare to each other according to the\n * sort order of this Collator object. Negative value if string1 comes before string2. Positive\n * value if string1 comes after string2. 0 if they are considered equal.\n */\n compare(string1: string, string2: string): number {\n return this.collator.compare(string1, string2);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and collation options computed\n * during initialization of this collator object.\n *\n * @returns ResolvedCollatorOptions object\n */\n resolvedOptions(): Intl.ResolvedCollatorOptions {\n return this.collator.resolvedOptions();\n }\n}\n\nexport default Collator;\n","/** Enables language-sensitive data and time formatting. Wraps Intl.DateTimeFormat */\nexport class DateTimeFormat {\n private dateTimeFormatter: Intl.DateTimeFormat;\n\n constructor(locales?: string | string[], options?: Intl.DateTimeFormatOptions) {\n this.dateTimeFormatter = new Intl.DateTimeFormat(locales, options);\n }\n\n /**\n * Formats a date according to the locale and formatting option for this DateTimeFormat object\n *\n * @param date The date to format\n * @returns String representing the given date formatted according to the locale and formatting\n * options of this DateTimeFormat object\n */\n format(date: Date): string {\n return this.dateTimeFormatter.format(date);\n }\n\n /**\n * Formats a date range in the most concise way based on the locales and options provided when\n * instantiating this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns String representing the given date range formatted according to the locale and\n * formatting options of this DateTimeFormat object\n */\n formatRange(startDate: Date, endDate: Date): string {\n return this.dateTimeFormatter.formatRange(startDate, endDate);\n }\n\n /**\n * Returns an array of locale-specific tokens representing each part of the formatted date range\n * produced by this DateTimeFormat object\n *\n * @param startDate Date object representing start of the date range\n * @param endDate Date object representing the end of the date range\n * @returns Array of DateTimeRangeFormatPart objects\n */\n formatRangeToParts(startDate: Date, endDate: Date): Intl.DateTimeRangeFormatPart[] {\n return this.dateTimeFormatter.formatRangeToParts(startDate, endDate);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this DateTimeFormat object\n *\n * @param date The date to format\n * @returns Array of DateTimeFormatPart objects\n */\n formatToParts(date: Date): Intl.DateTimeFormatPart[] {\n return this.dateTimeFormatter.formatToParts(date);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and date and time formatting options\n * computed during initialization of this DateTimeFormat object\n *\n * @returns ResolvedDateTimeFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n return this.dateTimeFormatter.resolvedOptions();\n }\n}\n\nexport default DateTimeFormat;\n","/** Interfaces, classes, and functions related to events and event emitters */\n\nimport { Dispose } from '../lifetime-management/disposal.model';\nimport { PlatformEvent, PlatformEventHandler } from './platform-event';\n\n/**\n * Event manager - accepts subscriptions to an event and runs the subscription callbacks when the\n * event is emitted Use eventEmitter.event(callback) to subscribe to the event. Use\n * eventEmitter.emit(event) to run the subscriptions. Generally, this EventEmitter should be\n * private, and its event should be public. That way, the emitter is not publicized, but anyone can\n * subscribe to the event.\n */\nexport class PlatformEventEmitter implements Dispose {\n /**\n * Subscribes a function to run when this event is emitted.\n *\n * @param callback Function to run with the event when it is emitted\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n subscribe = this.event;\n\n /** All callback functions that will run when this event is emitted. Lazy loaded */\n private subscriptions?: PlatformEventHandler[];\n /** Event for listeners to subscribe to. Lazy loaded */\n private lazyEvent?: PlatformEvent;\n /** Whether this emitter has been disposed */\n private isDisposed = false;\n\n /**\n * Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.\n * Use like `const unsubscriber = event(callback)`\n *\n * @returns Unsubscriber function to run to stop calling the passed-in function when the event is\n * emitted\n */\n get event(): PlatformEvent {\n this.assertNotDisposed();\n\n if (!this.lazyEvent) {\n this.lazyEvent = (callback) => {\n if (!callback || typeof callback !== 'function')\n throw new Error(`Event handler callback must be a function!`);\n\n // Initialize this.subscriptions if it does not exist\n if (!this.subscriptions) this.subscriptions = [];\n\n this.subscriptions.push(callback);\n\n return () => {\n if (!this.subscriptions) return false; // Did not find any subscribed callbacks\n\n const callbackIndex = this.subscriptions.indexOf(callback);\n\n if (callbackIndex < 0) return false; // Did not find this callback in the subscriptions\n\n // Remove the callback\n this.subscriptions.splice(callbackIndex, 1);\n\n return true;\n };\n };\n }\n return this.lazyEvent;\n }\n\n /** Disposes of this event, preparing it to release from memory */\n dispose = () => {\n return this.disposeFn();\n };\n\n /**\n * Runs the subscriptions for the event\n *\n * @param event Event data to provide to subscribed callbacks\n */\n emit = (event: T) => {\n // Do not do anything other than emitFn here. This emit is just binding `this` to emitFn\n this.emitFn(event);\n };\n\n /**\n * Function that runs the subscriptions for the event. Added here so children can override emit\n * and still call the base functionality. See NetworkEventEmitter.emit for example\n */\n protected emitFn(event: T) {\n this.assertNotDisposed();\n\n // Clone the subscriptions array before iterating over the callbacks so the callback index\n // doesn't get messed up if someone subscribes or unsubscribes inside one of the callbacks\n const emitCallbacks = [...(this.subscriptions ?? [])];\n emitCallbacks.forEach((callback) => callback(event));\n }\n\n /** Check to make sure this emitter is not disposed. Throw if it is */\n protected assertNotDisposed() {\n if (this.isDisposed) throw new Error('Emitter is disposed');\n }\n\n /**\n * Disposes of this event, preparing it to release from memory. Added here so children can\n * override emit and still call the base functionality.\n */\n protected disposeFn() {\n this.assertNotDisposed();\n\n this.isDisposed = true;\n this.subscriptions = undefined;\n this.lazyEvent = undefined;\n return Promise.resolve(true);\n }\n}\n\nexport default PlatformEventEmitter;\n","/** Collection of functions, objects, and types that are used as helpers in other services. */\n\n// Thanks to blubberdiblub at https://stackoverflow.com/a/68141099/217579\nexport function newGuid(): string {\n return '00-0-4-1-000'.replace(/[^-]/g, (s) =>\n // @ts-expect-error ts(2363) this works fine\n // eslint-disable-next-line no-bitwise\n (((Math.random() + ~~s) * 0x10000) >> s).toString(16).padStart(4, '0'),\n );\n}\n\n// thanks to DRAX at https://stackoverflow.com/a/9436948\n/**\n * Determine whether the object is a string\n *\n * @param o Object to determine if it is a string\n * @returns True if the object is a string; false otherwise\n */\nexport function isString(o: unknown): o is string {\n return typeof o === 'string' || o instanceof String;\n}\n\n/**\n * If deepClone isn't used when copying properties between objects, you may be left with dangling\n * references between the source and target of property copying operations.\n *\n * @param obj Object to clone\n * @returns Duplicate copy of `obj` without any references back to the original one\n */\nexport function deepClone(obj: T): T {\n // Assert the return type matches what is expected\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\n/**\n * Get a function that reduces calls to the function passed in\n *\n * @template T - A function type that takes any arguments and returns void. This is the type of the\n * function being debounced.\n * @param fn The function to debounce\n * @param delay How much delay in milliseconds after the most recent call to the debounced function\n * to call the function\n * @returns Function that, when called, only calls the function passed in at maximum every delay ms\n */\n// We don't know the parameter types since this function can be anything and can return anything\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function debounce any>(\n fn: TFunc,\n delay = 300,\n): (...args: Parameters) => Promise> {\n let timeout: ReturnType;\n let promise: Promise> | undefined;\n let promiseResolve: (value: ReturnType | PromiseLike>) => void;\n let promiseReject: (reason?: unknown) => void;\n\n return (...args) => {\n clearTimeout(timeout);\n if (!promise)\n promise = new Promise((resolve, reject) => {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n timeout = setTimeout(async () => {\n try {\n promiseResolve(await fn(...args));\n } catch (e) {\n promiseReject(e);\n } finally {\n promise = undefined;\n }\n }, delay);\n\n return promise;\n };\n}\n\n/**\n * Groups each item in the array of items into a map according to the keySelector\n *\n * There are two overloads:\n *\n * - `groupBy(items, keySelector)` – groups the original items using the key returned by\n * `keySelector`.\n * - `groupBy(items, keySelector, valueSelector)` – groups transformed values using the key returned\n * by `keySelector` and the value returned by `valueSelector`.\n *\n * If `valueSelector` is not provided, the original item is used in the resulting groups.\n *\n * @param items - Array of items to group by.\n * @param keySelector - Function to run on each item to get the key for the group to which it\n * belongs. The first argument is the item, and the second argument is the index of the item in\n * the original array.\n * @param valueSelector - Optional function to run on each item to get the value to store in the\n * group. The first argument is the item, the second argument is the key for the group to which\n * this item belongs, and the third argument is the index of the item in the original array.\n * @returns Map of keys to groups of values corresponding to each item.\n */\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector: (item: T, key: K, index: number) => V,\n): Map>;\nexport function groupBy(\n items: T[],\n keySelector: (item: T, index: number) => K,\n valueSelector?: (item: T, key: K, index: number) => V,\n): Map> {\n const map = new Map>();\n items.forEach((item, index) => {\n const key = keySelector(item, index);\n const group = map.get(key);\n const value = valueSelector ? valueSelector(item, key, index) : item;\n if (group) group.push(value);\n else map.set(key, [value]);\n });\n return map;\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\ntype ErrorWithMessage = {\n message: string;\n};\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\nfunction isErrorWithMessage(error: unknown): error is ErrorWithMessage {\n return (\n typeof error === 'object' &&\n // We're potentially dealing with objects we didn't create, so they might contain `null`\n // eslint-disable-next-line no-null/no-null\n error !== null &&\n 'message' in error &&\n // Type assert `error` to check it's `message`.\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n typeof (error as Record).message === 'string'\n );\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error from the object (useful for getting an error in a catch block)\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nfunction toErrorWithMessage(maybeError: unknown): ErrorWithMessage {\n if (isErrorWithMessage(maybeError)) return maybeError;\n\n try {\n return new Error(JSON.stringify(maybeError));\n } catch {\n // fallback in case there's an error stringifying the maybeError\n // like with circular references for example.\n return new Error(String(maybeError));\n }\n}\n\n// From https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript\n/**\n * Function to get an error message from the object (useful for getting error message in a catch\n * block)\n *\n * @example `try {...} catch (e) { logger.info(getErrorMessage(e)) }`\n *\n * @param error Error object whose message to get\n * @returns Message of the error - if object has message, returns message. Otherwise tries to\n * stringify\n */\nexport function getErrorMessage(error: unknown) {\n return toErrorWithMessage(error).message;\n}\n\n/** Asynchronously waits for the specified number of milliseconds. (wraps setTimeout in a promise) */\nexport function wait(ms: number) {\n // eslint-disable-next-line no-promise-executor-return\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Runs the specified function and will timeout if it takes longer than the specified wait time\n *\n * @param fn The function to run\n * @param maxWaitTimeInMS The maximum amount of time to wait for the function to resolve\n * @returns Promise that resolves to the resolved value of the function or undefined if it ran\n * longer than the specified wait time\n */\nexport function waitForDuration(fn: () => Promise, maxWaitTimeInMS: number) {\n const timeout = wait(maxWaitTimeInMS).then(() => undefined);\n return Promise.any([timeout, fn()]);\n}\n\n/**\n * Get all functions on an object and its prototype chain (so we don't miss any class methods or any\n * object methods). Note that the functions on the final item in the prototype chain (i.e., Object)\n * are skipped to avoid including functions like `__defineGetter__`, `__defineSetter__`, `toString`,\n * etc.\n *\n * @param obj Object whose functions to get\n * @param _objId Optional ID of the object to use for debug logging\n * @returns Array of all function names on an object\n */\n// Note: lodash has something that MIGHT do the same thing as this. Investigate for https://github.com/paranext/paranext-core/issues/134\nexport function getAllObjectFunctionNames(\n obj: { [property: string]: unknown },\n // Leaving it here for debugging\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _objId: string = 'obj',\n): Set {\n const objectFunctionNames = new Set();\n\n // Get all function properties directly defined on the object\n Object.getOwnPropertyNames(obj).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId} due to error: ${error}`);\n }\n });\n\n // Walk up the prototype chain and get additional function properties, skipping the functions\n // provided by the final (Object) prototype\n let objectPrototype = Object.getPrototypeOf(obj);\n while (objectPrototype && Object.getPrototypeOf(objectPrototype)) {\n Object.getOwnPropertyNames(objectPrototype).forEach((property) => {\n try {\n if (typeof obj[property] === 'function') objectFunctionNames.add(property);\n } catch (error) {\n // Too noisy - only reenable if you need more details\n // console.trace(`Skipping ${property} on ${objId}'s prototype due to error: ${error}`);\n }\n });\n objectPrototype = Object.getPrototypeOf(objectPrototype);\n }\n\n return objectFunctionNames;\n}\n\n/**\n * Creates a synchronous proxy for an asynchronous object. The proxy allows calling methods on an\n * object that is asynchronously fetched using a provided asynchronous function.\n *\n * @param getObject - A function that returns a promise resolving to the object whose asynchronous\n * methods to call.\n * @param objectToProxy - An optional object that is the object that is proxied. If a property is\n * accessed that does exist on this object, it will be returned. If a property is accessed that\n * does not exist on this object, it will be considered to be an asynchronous method called on the\n * object returned from getObject.\n * @returns A synchronous proxy for the asynchronous object.\n */\nexport function createSyncProxyForAsyncObject(\n getObject: (args?: unknown[]) => Promise,\n objectToProxy: Partial = {},\n): T {\n // objectToProxy will have only the synchronously accessed properties of T on it, and this proxy\n // makes the async methods that do not exist yet available synchronously so we have all of T\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return new Proxy(objectToProxy as T, {\n get(target, prop) {\n // We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // @ts-expect-error 7053\n if (prop in target) return target[prop];\n return async (...args: unknown[]) => {\n // 7053: We don't have any type information for T, so we assume methodName exists on it and will let JavaScript throw if it doesn't exist\n // 2556: The args here are the parameters for the method specified\n // @ts-expect-error 7053 2556\n return (await getObject())[prop](...args);\n };\n },\n });\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that Paratext is blocking internet access.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates Paratext is blocking internet access, `false` otherwise\n */\nexport function isErrorMessageAboutParatextBlockingInternetAccess(errorMessage: unknown): boolean {\n // Copied from ParatextData/InternetAccess.cs, not a localized string\n const paratextExceptionMessage =\n 'Bug in Paratext caused attempted access to Internet. Request has been blocked.';\n\n if (isString(errorMessage)) return errorMessage.includes(paratextExceptionMessage);\n return getErrorMessage(errorMessage).includes(paratextExceptionMessage);\n}\n\n/**\n * Indicates if the exception or error message provided appears to be from ParatextData.dll\n * indicating that an authorization failure occurred regarding registry credentials.\n *\n * @param errorMessage Error message or exception to check\n * @returns `true` if the message indicates an auth failure, `false` otherwise\n */\nexport function isErrorMessageAboutRegistryAuthFailure(errorMessage: unknown): boolean {\n // Copied from ParatextProjectSendReceiveService.cs, not a localized string\n const paratextExceptionMessage1 = '401 Unauthorized error while getting shared projects.';\n // Copied from DblDownloadableDataProvider.cs, not a localized string\n const paratextExceptionMessage2 =\n 'User registration is not valid. Cannot retrieve resources from DBL.';\n\n const errorString = isString(errorMessage) ? errorMessage : getErrorMessage(errorMessage);\n return (\n errorString.includes(paratextExceptionMessage1) ||\n errorString.includes(paratextExceptionMessage2)\n );\n}\n\n/** Within type T, recursively change all properties to be optional */\nexport type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T;\n\n/** Within type T, recursively change properties that were of type A to be of type B */\nexport type ReplaceType = T extends A\n ? B\n : T extends object\n ? { [K in keyof T]: ReplaceType }\n : T;\n\n/**\n * Converts a string type from camelCase to kebab-case. Note this simply inserts hyphens before\n * uppercase letters and converts them to lowercase. It does not handle special cases like acronyms\n * or symbols. It can result in multiple hyphens in a row, leading hyphens, or trailing hyphens.\n *\n * By using this as the type for a string parameter or string property, you can enforce (somewhat)\n * at compile time that the string is in kebab-case format assuming it is provided as a string\n * literal.\n *\n * @example\n *\n * ```typescript\n * type Kebab1 = KebabCase<'backgroundColor'>; // 'background-color'\n * type Kebab2 = KebabCase<'HTMLParser'>; // '-h-t-m-l-parser'\n * type Kebab3 = KebabCase<'simpletest'>; // 'simpletest'\n * type Kebab4 = KebabCase<'My$Value'>; // '-my$-value'\n * ```\n */\nexport type KebabCase = T extends `${infer First}${infer Rest}`\n ? `${First extends Lowercase ? First : `-${Lowercase}`}${KebabCase}`\n : T;\n\n// Thanks to jcalz at https://stackoverflow.com/a/50375286\n/**\n * Converts a union type to an intersection type (`|` to `&`).\n *\n * Note: this utility type is for use on object types. It may fail on other types.\n *\n * @example\n *\n * ```typescript\n * type TypeOne = { one: string };\n * type TypeTwo = { two: number };\n * type TypeThree = { three: string };\n *\n * type TypeNums = { one: TypeOne; two: TypeTwo; three: TypeThree };\n * const numNames = ['one', 'two'] as const;\n * type TypeNumNames = typeof numNames;\n *\n * // Same as `TypeOne | TypeTwo`\n * // `{ one: string } | { two: number }`\n * type TypeOneTwoUnion = TypeNums[TypeNumNames[number]];\n *\n * // Same as `TypeOne & TypeTwo`\n * // `{ one: string; two: number }`\n * type TypeOneTwoIntersection = UnionToIntersection;\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (\n x: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Force VSCode to expand all the properties of a type by using this type. Useful for making complex\n * types more readable in hover tooltips.\n *\n * @example\n *\n * ```ts\n * type MyType = Prettify;\n * ```\n */\nexport type Prettify = {\n [K in keyof T]: T[K];\n} & {};\n","import { PlatformEventEmitter } from './events/platform-event-emitter.model';\nimport { deepClone } from './util';\n\ntype JsonObjectLike = { [key: string]: unknown };\ntype JsonArrayLike = unknown[];\n\nexport type JsonDocumentLike = JsonObjectLike | JsonArrayLike;\n\n/**\n * Options for DocumentCombiner objects\n *\n * - `copyDocuments`: If true, this instance will perform a deep copy of all provided documents before\n * composing the output. If false, then changes made to provided documents after they are\n * contributed will be reflected in the next time output is composed.\n * - `ignoreDuplicateProperties`: If true, then duplicate properties are skipped if they are seen in\n * contributed documents. If false, then throw when duplicate properties are seen in contributed\n * documents.\n */\nexport type DocumentCombinerOptions = {\n copyDocuments: boolean;\n ignoreDuplicateProperties: boolean;\n};\n\n/**\n * Base class for any code that wants to compose JSON documents (primarily in the form of JS objects\n * or arrays) together into a single output document.\n */\nexport class DocumentCombiner {\n protected baseDocument: JsonDocumentLike;\n protected readonly contributions = new Map();\n protected latestOutput: JsonDocumentLike | undefined;\n protected readonly options: DocumentCombinerOptions;\n private readonly onDidRebuildEmitter = new PlatformEventEmitter();\n /** Event that emits to announce that the document has been rebuilt and the output has been updated */\n // Need `onDidRebuildEmitter` to be instantiated before this line\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly onDidRebuild = this.onDidRebuildEmitter.subscribe;\n\n /**\n * Create a DocumentCombiner instance\n *\n * @param baseDocument This is the first document that will be used when composing the output\n * @param options Options used by this object when combining documents\n */\n protected constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n // Setting baseDocument redundantly because TS doesn't understand that updateBaseDocument does it\n this.baseDocument = baseDocument;\n this.options = options;\n this.updateBaseDocument(baseDocument);\n }\n\n /**\n * Update the starting document for composition process\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n * @returns Recalculated output document given the new starting state and existing other documents\n */\n updateBaseDocument(baseDocument: JsonDocumentLike): JsonDocumentLike | undefined {\n this.validateBaseDocument(baseDocument);\n this.baseDocument = this.options.copyDocuments ? deepClone(baseDocument) : baseDocument;\n this.baseDocument = this.transformBaseDocumentAfterValidation(this.baseDocument);\n return this.rebuild();\n }\n\n /**\n * Add or update one of the contribution documents for the composition process\n *\n * Note: the order in which contribution documents are added can be considered indeterminate as it\n * depends on the order in which `Map.forEach` iterates over the contributions. However, the order\n * matters when merging two arrays into one. Also, when `options.ignoreDuplicateProperties` is is\n * `true`, the order also matters when adding the same property to an object that is already\n * provided previously. Please let us know if you have trouble because of indeterminate\n * contribution ordering.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n * @returns Recalculated output document given the new or updated contribution and existing other\n * documents\n */\n addOrUpdateContribution(\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike | undefined {\n this.validateContribution(documentName, document);\n const previousDocumentVersion = this.contributions.get(documentName);\n let documentToSet = this.options.copyDocuments && !!document ? deepClone(document) : document;\n documentToSet = this.transformContributionAfterValidation(documentName, documentToSet);\n this.contributions.set(documentName, documentToSet);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after adding/updating the contribution, put it back how it was\n if (previousDocumentVersion) this.contributions.set(documentName, previousDocumentVersion);\n else this.contributions.delete(documentName);\n throw new Error(`Error when setting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete one of the contribution documents for the composition process\n *\n * @param documentName Name of the contributed document to delete\n * @returns Recalculated output document given the remaining other documents\n */\n deleteContribution(documentName: string): JsonDocumentLike | undefined {\n const document = this.contributions.get(documentName);\n if (!document) throw new Error(`${documentName} does not exist`);\n this.contributions.delete(documentName);\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting the contribution, put it back and rethrow\n this.contributions.set(documentName, document);\n throw new Error(`Error when deleting the document named ${documentName}: ${error}`);\n }\n }\n\n /**\n * Delete all present contribution documents for the composition process and return to the base\n * document\n *\n * @returns Recalculated output document consisting only of the base document\n */\n deleteAllContributions(): JsonDocumentLike | undefined {\n if (this.contributions.size <= 0) return this.latestOutput;\n\n // Save out all contributions\n const contributions = [...this.contributions.entries()];\n\n // Delete all contributions\n contributions.forEach(([contributionName]) => this.contributions.delete(contributionName));\n\n // Rebuild with no contributions\n try {\n return this.rebuild();\n } catch (error) {\n // If the output isn't valid after deleting all contributions, put them back and rethrow\n contributions.forEach(([contributionName, document]) =>\n this.contributions.set(contributionName, document),\n );\n throw new Error(`Error when deleting all contributions: ${error}`);\n }\n }\n\n /**\n * Run the document composition process given the starting document and all contributions. Throws\n * if the output document fails to validate properly.\n *\n * @returns Recalculated output document given the starting and contributed documents\n */\n rebuild(): JsonDocumentLike | undefined {\n // The starting document is the output if there are no other contributions\n if (this.contributions.size === 0) {\n let potentialOutput = deepClone(this.baseDocument);\n potentialOutput = this.transformFinalOutputBeforeValidation(potentialOutput);\n this.validateOutput(potentialOutput);\n this.latestOutput = potentialOutput;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n // Compose the output by validating each document one at a time to pinpoint errors better\n let outputIteration = this.baseDocument;\n this.contributions.forEach((contribution: JsonDocumentLike) => {\n outputIteration = mergeObjects(\n outputIteration,\n contribution,\n this.options.ignoreDuplicateProperties,\n );\n this.validateOutput(outputIteration);\n });\n outputIteration = this.transformFinalOutputBeforeValidation(outputIteration);\n this.validateOutput(outputIteration);\n this.latestOutput = outputIteration;\n this.onDidRebuildEmitter.emit(undefined);\n return this.latestOutput;\n }\n\n /**\n * Transform the starting document that is given to the combiner. This transformation occurs after\n * validating the base document and before combining any contributions.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the `baseDocument` passed in.\n *\n * @param baseDocument Initial input document. Already validated via `validateBaseDocument`\n * @returns Transformed base document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformBaseDocumentAfterValidation(baseDocument: JsonDocumentLike): JsonDocumentLike {\n return baseDocument;\n }\n\n /**\n * Transform the contributed document associated with `documentName`. This transformation occurs\n * after validating the contributed document and before combining with other documents.\n *\n * WARNING: If you do not create the combiner with option `copyDocuments: true` or clone inside\n * this method, this method will directly modify the contributed `document` passed in.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine. Already validated via\n * `validateContribution`\n * @returns Transformed contributed document\n */\n // We just don't need `this` here. This is basically a no-op function that is available to child\n // classes to override\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformContributionAfterValidation(\n // @ts-expect-error this parameter is unused but may be used in child classes\n documentName: string,\n document: JsonDocumentLike,\n ): JsonDocumentLike {\n return document;\n }\n\n /**\n * Throw an error if the provided document is not a valid starting document.\n *\n * @param baseDocument Base JSON document/JS object that all other documents are added to\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateBaseDocument(baseDocument: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided document is not a valid contribution document.\n *\n * @param documentName Name of the contributed document to combine\n * @param document Content of the contributed document to combine\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateContribution(documentName: string, document: JsonDocumentLike): void {}\n\n /**\n * Throw an error if the provided output is not valid.\n *\n * @param output Output document that could potentially be returned to callers\n */\n // no-op intended to be overridden by child classes. Can't be static\n // @ts-expect-error ts(6133) parameter doesn't need to be used but still needs the right name\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars\n protected validateOutput(output: JsonDocumentLike): void {}\n\n /**\n * Transform the document that is the composition of the base document and all contribution\n * documents. This is the last step that will be run prior to validation via `validateOutput`\n * before `this.latestOutput` is updated to the new output.\n *\n * @param finalOutput Final output document that could potentially be returned to callers. \"Final\"\n * means no further contribution documents will be merged.\n */\n // no-op intended to be overridden by child classes. Can't be static\n // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n protected transformFinalOutputBeforeValidation(finalOutput: JsonDocumentLike): JsonDocumentLike {\n return finalOutput;\n }\n}\n\n// #region Helper functions\n\n/**\n * Determines if the input values are objects but not arrays\n *\n * @param values Objects to check\n * @returns True if all the values are objects but not arrays\n */\nfunction areNonArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Determines if the input values are arrays\n *\n * @param value Objects to check\n * @returns True if the values are arrays\n */\nfunction areArrayObjects(...values: unknown[]): boolean {\n let allMatch = true;\n values.forEach((value: unknown) => {\n if (!value || typeof value !== 'object' || !Array.isArray(value)) allMatch = false;\n });\n return allMatch;\n}\n\n/**\n * Deep clone and recursively merge the properties of one object (copyFrom) into another\n * (startingPoint). Throws if copyFrom would overwrite values already existing in startingPoint.\n *\n * Does not modify the objects passed in.\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjects(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n const retVal = deepClone(startingPoint);\n\n if (!copyFrom) return retVal;\n\n return mergeObjectsInternal(retVal, deepClone(copyFrom), ignoreDuplicateProperties);\n}\n\n/**\n * Recursively merge the properties of one object (copyFrom) into another (startingPoint). Throws if\n * copyFrom would overwrite values already existing in startingPoint.\n *\n * WARNING: Modifies the argument objects in some way. Recommended to use `mergeObjects`\n *\n * @param startingPoint Object that is the starting point for the return value\n * @param copyFrom Object whose values are copied into the return value\n * @param ignoreDuplicateProperties Whether to ignore object properties that are present in\n * `copyFrom` that are already present in `startingPoint`. If `false`, throws when an object\n * property in `copyFrom` is already present in `startingPoint`\n * @returns Object that is the combination of the two documents\n */\nfunction mergeObjectsInternal(\n startingPoint: JsonDocumentLike,\n copyFrom: JsonDocumentLike,\n ignoreDuplicateProperties: boolean,\n): JsonDocumentLike {\n if (!copyFrom) return startingPoint;\n\n if (areNonArrayObjects(startingPoint, copyFrom)) {\n // Merge properties since they are both objects\n\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n const startingPointObj = startingPoint as JsonObjectLike;\n const copyFromObj = copyFrom as JsonObjectLike;\n /* eslint-enable no-type-assertion/no-type-assertion */\n Object.keys(copyFromObj).forEach((key: string | number) => {\n if (Object.hasOwn(startingPointObj, key)) {\n if (areNonArrayObjects(startingPointObj[key], copyFromObj[key])) {\n startingPointObj[key] = mergeObjectsInternal(\n // We know these are objects from the `if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] as JsonObjectLike,\n copyFromObj[key] as JsonObjectLike,\n ignoreDuplicateProperties,\n /* eslint-enable no-type-assertion/no-type-assertion */\n );\n } else if (areArrayObjects(startingPointObj[key], copyFromObj[key])) {\n // Concat the arrays since they are both arrays\n\n // We know these are arrays from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n startingPointObj[key] = (startingPointObj[key] as JsonArrayLike).concat(\n copyFromObj[key] as JsonArrayLike,\n );\n /* eslint-enable no-type-assertion/no-type-assertion */\n } else if (!ignoreDuplicateProperties)\n throw new Error(`Cannot merge objects: key \"${key}\" already exists in the target object`);\n // Note that the first non-object non-array value that gets placed in a property stays.\n // New values do not override existing ones\n } else {\n startingPointObj[key] = copyFromObj[key];\n }\n });\n } else if (areArrayObjects(startingPoint, copyFrom)) {\n // Concat the arrays since they are both arrays\n\n // Push the contents of copyFrom into startingPoint since it is a const and was already deep cloned\n // We know these are objects from the `else if` check\n /* eslint-disable no-type-assertion/no-type-assertion */\n (startingPoint as JsonArrayLike).push(...(copyFrom as JsonArrayLike));\n /* eslint-enable no-type-assertion/no-type-assertion */\n }\n\n // Note that nothing happens if `startingPoint` is not an object or an array or if `startingPoint`\n // and `copyFrom` are not both object or both arrays. Should we throw? Should we push `copyFrom`'s\n // values into the array? Other? Maybe one day we can add some options to decide what to do in\n // this situation, but YAGNI for now\n\n return startingPoint;\n}\n\n// #endregion\n\nexport default DocumentCombiner;\n","/** Class that tracks how long it has taken the last N events to occur */\nexport class EventRollingTimeCounter {\n /** The ring buffer to store times */\n private readonly ringBuffer: number[];\n /** The size of the ring buffer */\n private readonly bufferSize: number;\n /** The next location where a time will be written */\n private writerIndex: number;\n /** The location where the first time in the buffer will be read */\n private readerIndex: number;\n /** The most recent difference in time between the newest and oldest events */\n private lastTimeDifference: number;\n /** How many instances in total have been recorded */\n private totalInstanceCount: number;\n\n /**\n * Create a new instance of the InstanceTimeCounter class\n *\n * @param bufferSize - Maximum number of instances to track\n */\n constructor(bufferSize: number) {\n this.bufferSize = bufferSize;\n this.ringBuffer = new Array(bufferSize).fill(0);\n this.writerIndex = 0;\n this.readerIndex = 0;\n this.lastTimeDifference = 0;\n this.totalInstanceCount = 0;\n }\n\n /** Get the total number of instances that have been recorded */\n get totalInstances(): number {\n return this.totalInstanceCount;\n }\n\n /** Add a new time measurement for an instance of an event */\n recordInstance(): void {\n this.totalInstanceCount += 1;\n const currentTime = performance.now();\n this.lastTimeDifference = currentTime - this.ringBuffer[this.readerIndex];\n\n this.ringBuffer[this.writerIndex] = currentTime;\n this.writerIndex += 1;\n if (this.writerIndex >= this.bufferSize) this.writerIndex %= this.bufferSize;\n if (this.writerIndex === this.readerIndex) {\n this.readerIndex += 1;\n if (this.readerIndex >= this.bufferSize) this.readerIndex %= this.bufferSize;\n }\n }\n\n /**\n * Check if the time between the last N events is less than the provided threshold\n *\n * @param minRollingTimeMs - Minimum time that must have passed when the last N events occurred\n * @returns - True if the threshold is violated, false otherwise\n */\n hasViolatedThreshold(minRollingTimeMs: number): boolean {\n return this.totalInstanceCount >= this.bufferSize && this.lastTimeDifference < minRollingTimeMs;\n }\n}\n","import { Mutex as AsyncMutex } from 'async-mutex';\n\n// Extending Mutex from async-mutex so we can add JSDoc\n\n/**\n * Class that allows calling asynchronous functions multiple times at once while only running one at\n * a time.\n *\n * @example\n *\n * ```typescript\n * const mutex = new Mutex();\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n *\n * mutex.runExclusive(async () => {\n * // Do some asynchronous stuff\n * console.log('These run one-at-a-time');\n * });\n * ```\n *\n * See [`async-mutex`](https://www.npmjs.com/package/async-mutex) for more information.\n */\nexport class Mutex extends AsyncMutex {}\n\nexport default Mutex;\n","import { Mutex } from './mutex';\n\n/** Map of {@link Mutex}es that automatically (lazily) generates a new {@link Mutex} for any new key */\nexport class MutexMap {\n private mutexesByID = new Map();\n\n /**\n * Retrieves the {@link Mutex} associated with the given ID. If no Mutex exists for the provided\n * ID, a new Mutex is created, stored, and returned.\n *\n * @param mutexID Unique identifier for the desired Mutex\n * @returns The Mutex associated with the provided ID\n */\n get(mutexID: string): Mutex {\n let retVal = this.mutexesByID.get(mutexID);\n if (retVal) return retVal;\n\n retVal = new Mutex();\n this.mutexesByID.set(mutexID, retVal);\n return retVal;\n }\n}\n\nexport default MutexMap;\n","import { DocumentCombiner, DocumentCombinerOptions, JsonDocumentLike } from './document-combiner';\n\nexport class NonValidatingDocumentCombiner extends DocumentCombiner {\n // Making the protected base constructor public\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(baseDocument: JsonDocumentLike, options: DocumentCombinerOptions) {\n super(baseDocument, options);\n }\n\n get output(): JsonDocumentLike | undefined {\n return this.latestOutput;\n }\n}\n\nexport default NonValidatingDocumentCombiner;\n","/** Enables language-sensitive number formatting. Wraps Intl.NumberFormat */\nexport class NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n\n constructor(locales?: string | string[], options?: Intl.NumberFormatOptions) {\n this.numberFormatter = new Intl.NumberFormat(locales, options);\n }\n\n /**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @param value Number or BigInt to format\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\n format(value: number | bigint): string {\n return this.numberFormatter.format(value);\n }\n\n /**\n * Formats a range of numbers according to the locale and formatting options of this NumberFormat\n * object\n *\n * @param startRange Number or bigint representing the start of the range\n * @param endRange Number or bigint representing the end of the range\n * @returns String representing the given range of numbers formatted according to the locale and\n * formatting options of this NumberFormat object\n */\n formatRange(startRange: number | bigint, endRange: number | bigint): string {\n return this.numberFormatter.formatRange(startRange, endRange);\n }\n\n /**\n * Returns an array of objects containing the locale-specific tokens from which it is possible to\n * build custom strings while preserving the locale-specific parts.\n *\n * @param startRange Number or bigint representing start of the range\n * @param endRange Number or bigint representing end of the range\n * @returns Array of NumberRangeFormatPart objects containing the formatted range of numbers in\n * parts\n */\n formatRangeToParts(\n startRange: number | bigint,\n endRange: number | bigint,\n ): Intl.NumberRangeFormatPart[] {\n return this.numberFormatter.formatRangeToParts(startRange, endRange);\n }\n\n /**\n * Allows locale-aware formatting of strings produced by this NumberFormat object\n *\n * @param value Number or bigint to format\n * @returns Array of NumberFormatPart objects containing the formatted number in parts\n */\n formatToParts(value: number | bigint): Intl.NumberFormatPart[] {\n return this.numberFormatter.formatToParts(value);\n }\n\n /**\n * Returns a new object with properties reflecting the locale and number formatting options\n * computed during initialization of this NumberFormat object\n *\n * @returns ResolvedNumberFormatOptions object\n */\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n return this.numberFormatter.resolvedOptions();\n }\n}\n\nexport default NumberFormat;\n","const defaultPromise = Promise.resolve();\n\n/**\n * Class that allows you to chain promises for a given key. This is useful when:\n *\n * 1. You need to run promises from synchronous code and don't need to look at the results.\n * 2. The promises to run, or at least precisely when to run them, are not known in advance.\n * 3. The promises need to be run sequentially, waiting for the previous one to finish.\n *\n * An example of when this can be helpful is inside of React components. Component code is mostly\n * synchronous, but you may need to run some asynchronous code. You can't use `await` inside of\n * React component code in many situations, so you can use this class to chain promises together.\n *\n * When promises are added to the map with a key, they will run in the order they were added to the\n * map for that key. If a promise rejects, a warning will be logged and the chain will continue. If\n * a promise is added while another promise in the map for that key is running, the new promise will\n * be chained to the existing one.\n */\nexport class PromiseChainingMap {\n private readonly map = new Map>();\n private readonly logger: { warn: (message: string) => void };\n\n /**\n * Creates a new PromiseChainingMap\n *\n * @param logger Object with a `warn` method that will be called when a promise rejects. This\n * defaults to `console`.\n */\n constructor(logger: { warn: (message: string) => void } = console) {\n this.logger = logger;\n }\n\n /**\n * Adds a promise function to the map for a given key. If a promise is already running for the\n * key, the new promise will be chained to the existing one. Once all promises for a key have\n * settled, the map will be cleared for that key.\n *\n * @param key Unique key to identify a distinct promise chain\n * @param promiseFunction Function that returns a promise to add to the chain\n */\n addPromiseFunction(key: TKey, promiseFunction: () => Promise): void {\n const currentPromise = this.map.get(key);\n this.map.set(key, currentPromise ? currentPromise.then(promiseFunction) : promiseFunction());\n this.cleanupPromiseChain(key);\n }\n\n /**\n * Gets the current promise chain for the given key. This is mostly useful for testing. Normally\n * you should just call {@link addPromiseFunction} and let the map handle the rest.\n *\n * @param key Unique key to identify a distinct promise chain\n * @returns The current promise chain for the key\n */\n get(key: TKey): Promise | undefined {\n return this.map.get(key);\n }\n\n /**\n * Configures a promise chain to be removed from the map for the given key after all the promises\n * have settled\n *\n * @param key Unique key to identify a distinct promise chain\n */\n private cleanupPromiseChain(key: TKey): void {\n const currentPromise = this.map.get(key);\n if (!currentPromise) return;\n\n const promiseHolder: { promise: Promise } = { promise: defaultPromise };\n const newPromise = currentPromise\n .catch((e) => this.logger.warn(`Error in promise for ${key}: ${e.message}`))\n .finally(() => {\n if (this.map.get(key) === promiseHolder.promise) this.map.delete(key);\n });\n promiseHolder.promise = newPromise;\n this.map.set(key, newPromise);\n }\n}\n\nexport default PromiseChainingMap;\n","/**\n * A map-like data structure that maintains numeric keys in sorted order and provides efficient\n * operations for finding the closest key-value pair less than or equal to a target.\n *\n * This class combines the benefits of a Map (O(1) key-value lookups) with sorted key access (O(log\n * n) binary search operations). It's particularly useful when you need to frequently find the\n * \"closest\" entry to a given numeric key.\n *\n * @example\n *\n * ```typescript\n * const versionMap = new SortedNumberMap();\n * versionMap.set(100, 'Version 1.0.0');\n * versionMap.set(150, 'Version 1.5.0');\n * versionMap.set(200, 'Version 2.0.0');\n *\n * // Find the highest version <= 175\n * const result = versionMap.findClosestLessThanOrEqual(175);\n * console.log(result); // { key: 150, value: 'Version 1.5.0' }\n * ```\n *\n * @template T The type of values stored in the map\n */\nexport class SortedNumberMap {\n private map = new Map();\n private sortedKeys: number[] = [];\n\n /**\n * Returns an iterable of keys in the map sorted in ascending order.\n *\n * Time complexity: internal detail to JavaScript engine. Reasonable expectation:\n *\n * - Executing this method to return an iterator: O(1)\n * - Iterating over the returned iterator: O(n)\n *\n * Note that iterating over the keys this way negates the benefits of using this class over a\n * using a {@link Map}. To access individual keys more quickly, use\n * {@link SortedNumberMap.findClosestLessThanOrEqual} or {@link SortedNumberMap.get}.\n *\n * TSDoc adapted from {@link Map.keys}\n */\n keys() {\n return this.sortedKeys.values();\n }\n\n /**\n * Returns a specified element from the Map object. If the value that is associated to the\n * provided key is an object, then you will get a reference to that object and any change made to\n * that object will effectively modify it inside the Map.\n *\n * Time complexity: O(1)\n *\n * @returns Returns the element associated with the specified key. If no element is associated\n * with the specified key, returns `undefined`.\n *\n * TSDoc adapted from {@link Map.get}\n */\n get(key: number) {\n return this.map.get(key);\n }\n\n /**\n * Sets a key-value pair in the map. If the key already exists, its value is updated. If the key\n * is new, it's inserted in the correct sorted position.\n *\n * Time complexity: O(log n) for new keys (due to binary search and array insertion), O(1) for\n * existing keys.\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(5, 'five');\n * map.set(15, 'fifteen');\n * // Keys are automatically maintained in sorted order: [5, 10, 15]\n * ```\n *\n * @param key - The numeric key to set\n * @param value - The value to associate with the key\n */\n set(key: number, value: T): void {\n if (!this.map.has(key)) {\n // Insert key in sorted position\n const insertIndex = this.binarySearchInsertIndex(key);\n this.sortedKeys.splice(insertIndex, 0, key);\n }\n this.map.set(key, value);\n }\n\n /**\n * Finds the key-value pair with the largest key that is less than or equal to the target.\n *\n * This method uses binary search to efficiently locate the closest match. If no key is less than\n * or equal to the target, it returns undefined.\n *\n * Time complexity: O(log n)\n *\n * @example\n *\n * ```typescript\n * const map = new SortedNumberMap();\n * map.set(10, 'ten');\n * map.set(20, 'twenty');\n * map.set(30, 'thirty');\n *\n * // Exact match\n * map.findClosestLessThanOrEqual(20); // { key: 20, value: 'twenty' }\n *\n * // Closest less than\n * map.findClosestLessThanOrEqual(25); // { key: 20, value: 'twenty' }\n *\n * // No match (target too small)\n * map.findClosestLessThanOrEqual(5); // undefined\n * ```\n *\n * @param target - The number to search for\n * @returns The key-value pair with the largest key ≤ target, or undefined if none exists\n */\n findClosestLessThanOrEqual(target: number): { key: number; value: T } | undefined {\n const index = this.binarySearchLessThanOrEqual(target);\n if (index === -1) return undefined;\n\n const key = this.sortedKeys[index];\n const value = this.map.get(key);\n if (value === undefined) return undefined;\n return { key, value };\n }\n\n private binarySearchLessThanOrEqual(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length - 1;\n let result = -1;\n\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] <= target) {\n result = mid;\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return result;\n }\n\n private binarySearchInsertIndex(target: number): number {\n let left = 0;\n let right = this.sortedKeys.length;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (this.sortedKeys[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return left;\n }\n}\n","/**\n * A collection of unique items that are automatically maintained in sorted order, similar to C#'s\n * SortedSet.\n *\n * @template T The type of elements in the set\n */\nexport class SortedSet {\n /** Internal storage for the sorted items */\n private readonly items: T[] = [];\n\n /**\n * Creates a new sorted set\n *\n * @param compareFn - Function used to determine the order of elements. Returns negative when a <\n * b, zero when a = b, positive when a > b\n */\n constructor(private readonly compareFn: (a: T, b: T) => number) {}\n\n /** Gets the number of elements in the set */\n get size(): number {\n return this.items.length;\n }\n\n /** Returns whether the set is empty */\n get isEmpty(): boolean {\n return this.items.length === 0;\n }\n\n /**\n * Inserts an item into the set if it's not already present\n *\n * @param item - The item to insert\n * @returns True if the item was added; false if an equal item already exists\n */\n insert(item: T): boolean {\n // Find where this item should be inserted\n const index = this.findInsertionIndex(item);\n\n // Check if an equal item exists at the found position\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) {\n // Item already exists\n return false;\n }\n\n // Insert the item at the correct position to maintain sort order\n this.items.splice(index, 0, item);\n return true;\n }\n\n /**\n * Removes an item from the set\n *\n * @param item - The item to remove\n * @returns True if the item was removed; false if it wasn't found\n */\n remove(item: T): boolean {\n const index = this.findIndex(item);\n if (index < 0) return false;\n\n this.items.splice(index, 1);\n return true;\n }\n\n /**\n * Checks if an item exists in the set\n *\n * @param item - The item to check\n * @returns True if the item exists; false otherwise\n */\n has(item: T): boolean {\n return this.findIndex(item) >= 0;\n }\n\n /** Returns all items in the set as an array, in sorted order */\n toArray(): T[] {\n return [...this.items];\n }\n\n /** Returns the index of an item in the set, or -1 if not found */\n findIndex(item: T): number {\n const index = this.findInsertionIndex(item);\n if (index < this.items.length && this.compareFn(this.items[index], item) === 0) return index;\n return -1;\n }\n\n /**\n * Returns the element at the specified index in the sorted order\n *\n * @param index - The zero-based index of the element to get\n * @returns The element at the specified index, or undefined if the index is out of range\n */\n at(index: number): T | undefined {\n if (index < 0 || index >= this.items.length) return undefined;\n return this.items[index];\n }\n\n /** Iterates through each item in the sorted set */\n forEach(callback: (item: T, index: number, set: SortedSet) => void): void {\n this.items.forEach((item, index) => callback(item, index, this));\n }\n\n /** Returns an iterator for the set's items */\n [Symbol.iterator](): Iterator {\n let index = 0;\n return {\n next: (): IteratorResult => {\n if (index < this.items.length) {\n index += 1;\n return { value: this.items[index - 1], done: false };\n }\n return { value: undefined as unknown, done: true };\n },\n };\n }\n\n /** Clears all items from the set */\n clear(): void {\n this.items.length = 0;\n }\n\n /**\n * Uses binary search to find the position where an item should be inserted to maintain the sorted\n * order\n */\n private findInsertionIndex(item: T): number {\n let low = 0;\n let high = this.items.length;\n\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n const comparison = this.compareFn(this.items[mid], item);\n\n if (comparison < 0) {\n // Current item is less than the one we're looking for\n low = mid + 1;\n } else {\n // Current item is greater than or equal to the one we're looking for\n high = mid;\n }\n }\n\n return low;\n }\n}\n","import { Dispose } from './disposal.model';\nimport { Unsubscriber, UnsubscriberAsync } from './unsubscriber';\n\n/** Simple collection for UnsubscriberAsync objects that also provides an easy way to run them. */\nexport class UnsubscriberAsyncList {\n readonly unsubscribers = new Set();\n\n constructor(private name = 'Anonymous') {}\n\n /**\n * Add unsubscribers to the list. Note that duplicates are not added twice.\n *\n * @param unsubscribers - Objects that were returned from a registration process.\n */\n add(...unsubscribers: (UnsubscriberAsync | Unsubscriber | Dispose)[]) {\n unsubscribers.forEach((unsubscriber) => {\n if ('dispose' in unsubscriber)\n this.unsubscribers.add(unsubscriber.dispose.bind(unsubscriber));\n else this.unsubscribers.add(unsubscriber);\n });\n }\n\n /**\n * Run all unsubscribers added to this list and then clear the list.\n *\n * @returns `true` if all unsubscribers succeeded, `false` otherwise.\n */\n async runAllUnsubscribers(): Promise {\n const unsubs = [...this.unsubscribers].map((unsubscriber) => unsubscriber());\n const results = await Promise.all(unsubs);\n this.unsubscribers.clear();\n return results.every((unsubscriberSucceeded, index) => {\n if (!unsubscriberSucceeded)\n console.error(`UnsubscriberAsyncList ${this.name}: Unsubscriber at index ${index} failed!`);\n\n return unsubscriberSucceeded;\n });\n }\n}\n\nexport default UnsubscriberAsyncList;\n","import { isString } from './util';\n\n/** The version of the PlatformError type */\nexport const PLATFORM_ERROR_VERSION = 1;\n\n/**\n * PlatformError is an error type with stronger typing of properties than `Error`. It is used to\n * represent errors that are returned by the platform.\n *\n * You can create a new PlatformError object using {@link newPlatformError}. You can check if a value\n * is a PlatformError object using {@link isPlatformError}.\n */\nexport type PlatformError = {\n /**\n * The underlying cause of the error, if any. Normally this will be copied from an `Error object\n * passed to {@link newPlatformError}. If a non-Error object is passed to {@link newPlatformError},\n * it will be stored here.\n */\n cause?: unknown;\n /**\n * A descriptive message explaining the error. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}. If a string is passed to {@link newPlatformError}, it will be\n * stored here.\n */\n message: string;\n /** The version of the PlatformError type. */\n platformErrorVersion: number;\n /**\n * The stack trace of the error, if available. Normally this will be copied from an `Error` object\n * passed to {@link newPlatformError}.\n */\n stack?: string;\n};\n\n/**\n * Creates a new PlatformError object. If no argument is provided, a PlatformError object with an\n * empty `message` is returned.\n *\n * @param error The error message as a string, an Error object, or a value to assign to the `cause`\n * property of the returned PlatformError object\n * @returns A new PlatformError object\n */\nexport function newPlatformError(error?: unknown): PlatformError {\n if (!error) return { message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (isString(error)) return { message: error, platformErrorVersion: PLATFORM_ERROR_VERSION };\n if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n const platformError: PlatformError = {\n message: error.message,\n platformErrorVersion: PLATFORM_ERROR_VERSION,\n };\n Object.defineProperties(platformError, Object.getOwnPropertyDescriptors(error));\n Object.defineProperty(platformError, 'message', { enumerable: true });\n if ('stack' in error && isString(error.stack)) {\n // stack is generated lazily, and it seems this is causing some troubles with copying it into\n // another object via property descriptors as of Node 22.14.0 (no problems in 20.18.0).\n // So we shall set the value directly on the object\n Object.defineProperty(platformError, 'stack', { value: error.stack, enumerable: true });\n }\n if ('cause' in platformError)\n Object.defineProperty(platformError, 'cause', { enumerable: true });\n return platformError;\n }\n return { cause: error, message: '', platformErrorVersion: PLATFORM_ERROR_VERSION };\n}\n\n/**\n * Checks if the provided value is a PlatformError object.\n *\n * @param error The value to check\n * @returns `true` if the value is a PlatformError object, otherwise `false`\n */\nexport function isPlatformError(error: unknown): error is PlatformError {\n return !!error && typeof error === 'object' && 'platformErrorVersion' in error;\n}\n","var P = Object.defineProperty;\nvar R = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;\nvar n = (t, e, s) => R(t, typeof e != \"symbol\" ? e + \"\" : e, s);\nclass _ {\n constructor() {\n n(this, \"books\");\n n(this, \"firstSelectedBookNum\");\n n(this, \"lastSelectedBookNum\");\n n(this, \"count\");\n n(this, \"selectedBookNumbers\");\n n(this, \"selectedBookIds\");\n }\n}\nconst N = [\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n // 10\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n // 20\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n // 30\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n \"MAT\",\n // 40\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n // 50\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n // 60\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n // 70\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n // 80\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"JSA\",\n // actual variant text for JOS, now in LXA text\n \"JDB\",\n // actual variant text for JDG, now in LXA text\n \"TBS\",\n // actual variant text for TOB, now in LXA text\n \"SST\",\n // actual variant text for SUS, now in LXA text // 90\n \"DNT\",\n // actual variant text for DAN, now in LXA text\n \"BLT\",\n // actual variant text for BEL, now in LXA text\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n // 100\n \"BAK\",\n \"OTH\",\n \"3ES\",\n // Used previously but really should be 2ES\n \"EZA\",\n // Used to be called 4ES, but not actually in any known project\n \"5EZ\",\n // Used to be called 5ES, but not actually in any known project\n \"6EZ\",\n // Used to be called 6ES, but not actually in any known project\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n // 110\n \"NDX\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n // 120\n \"REP\",\n \"4BA\",\n \"LAO\"\n], B = [\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\",\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\"\n], O = [\n \"Genesis\",\n \"Exodus\",\n \"Leviticus\",\n \"Numbers\",\n \"Deuteronomy\",\n \"Joshua\",\n \"Judges\",\n \"Ruth\",\n \"1 Samuel\",\n \"2 Samuel\",\n \"1 Kings\",\n \"2 Kings\",\n \"1 Chronicles\",\n \"2 Chronicles\",\n \"Ezra\",\n \"Nehemiah\",\n \"Esther (Hebrew)\",\n \"Job\",\n \"Psalms\",\n \"Proverbs\",\n \"Ecclesiastes\",\n \"Song of Songs\",\n \"Isaiah\",\n \"Jeremiah\",\n \"Lamentations\",\n \"Ezekiel\",\n \"Daniel (Hebrew)\",\n \"Hosea\",\n \"Joel\",\n \"Amos\",\n \"Obadiah\",\n \"Jonah\",\n \"Micah\",\n \"Nahum\",\n \"Habakkuk\",\n \"Zephaniah\",\n \"Haggai\",\n \"Zechariah\",\n \"Malachi\",\n \"Matthew\",\n \"Mark\",\n \"Luke\",\n \"John\",\n \"Acts\",\n \"Romans\",\n \"1 Corinthians\",\n \"2 Corinthians\",\n \"Galatians\",\n \"Ephesians\",\n \"Philippians\",\n \"Colossians\",\n \"1 Thessalonians\",\n \"2 Thessalonians\",\n \"1 Timothy\",\n \"2 Timothy\",\n \"Titus\",\n \"Philemon\",\n \"Hebrews\",\n \"James\",\n \"1 Peter\",\n \"2 Peter\",\n \"1 John\",\n \"2 John\",\n \"3 John\",\n \"Jude\",\n \"Revelation\",\n \"Tobit\",\n \"Judith\",\n \"Esther Greek\",\n \"Wisdom of Solomon\",\n \"Sirach (Ecclesiasticus)\",\n \"Baruch\",\n \"Letter of Jeremiah\",\n \"Song of 3 Young Men\",\n \"Susanna\",\n \"Bel and the Dragon\",\n \"1 Maccabees\",\n \"2 Maccabees\",\n \"3 Maccabees\",\n \"4 Maccabees\",\n \"1 Esdras (Greek)\",\n \"2 Esdras (Latin)\",\n \"Prayer of Manasseh\",\n \"Psalm 151\",\n \"Odes\",\n \"Psalms of Solomon\",\n // WARNING, if you change the spelling of the *obsolete* tag be sure to update\n // IsObsolete routine\n \"Joshua A. *obsolete*\",\n \"Judges B. *obsolete*\",\n \"Tobit S. *obsolete*\",\n \"Susanna Th. *obsolete*\",\n \"Daniel Th. *obsolete*\",\n \"Bel Th. *obsolete*\",\n \"Extra A\",\n \"Extra B\",\n \"Extra C\",\n \"Extra D\",\n \"Extra E\",\n \"Extra F\",\n \"Extra G\",\n \"Front Matter\",\n \"Back Matter\",\n \"Other Matter\",\n \"3 Ezra *obsolete*\",\n \"Apocalypse of Ezra\",\n \"5 Ezra (Latin Prologue)\",\n \"6 Ezra (Latin Epilogue)\",\n \"Introduction\",\n \"Concordance \",\n \"Glossary \",\n \"Topical Index\",\n \"Names Index\",\n \"Daniel Greek\",\n \"Psalms 152-155\",\n \"2 Baruch (Apocalypse)\",\n \"Letter of Baruch\",\n \"Jubilees\",\n \"Enoch\",\n \"1 Meqabyan\",\n \"2 Meqabyan\",\n \"3 Meqabyan\",\n \"Reproof (Proverbs 25-31)\",\n \"4 Baruch (Rest of Baruch)\",\n \"Laodiceans\"\n], S = K();\nfunction g(t, e = !0) {\n return e && (t = t.toUpperCase()), t in S ? S[t] : 0;\n}\nfunction k(t) {\n return g(t) > 0;\n}\nfunction x(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return e >= 40 && e <= 66;\n}\nfunction T(t) {\n return (typeof t == \"string\" ? g(t) : t) <= 39;\n}\nfunction X(t) {\n return t <= 66;\n}\nfunction V(t) {\n const e = typeof t == \"string\" ? g(t) : t;\n return w(e) && !X(e);\n}\nfunction* L() {\n for (let t = 1; t <= N.length; t++) yield t;\n}\nconst G = 1, A = N.length;\nfunction H() {\n return [\"XXA\", \"XXB\", \"XXC\", \"XXD\", \"XXE\", \"XXF\", \"XXG\"];\n}\nfunction C(t, e = \"***\") {\n const s = t - 1;\n return s < 0 || s >= N.length ? e : N[s];\n}\nfunction I(t) {\n return t <= 0 || t > A ? \"******\" : O[t - 1];\n}\nfunction y(t) {\n return I(g(t));\n}\nfunction w(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && !B.includes(e);\n}\nfunction q(t) {\n const e = typeof t == \"number\" ? C(t) : t;\n return k(e) && B.includes(e);\n}\nfunction U(t) {\n return O[t - 1].includes(\"*obsolete*\");\n}\nfunction K() {\n const t = {};\n for (let e = 0; e < N.length; e++)\n t[N[e]] = e + 1;\n return t;\n}\nconst m = {\n allBookIds: N,\n nonCanonicalIds: B,\n bookIdToNumber: g,\n isBookIdValid: k,\n isBookNT: x,\n isBookOT: T,\n isBookOTNT: X,\n isBookDC: V,\n allBookNumbers: L,\n firstBook: G,\n lastBook: A,\n extraBooks: H,\n bookNumberToId: C,\n bookNumberToEnglishName: I,\n bookIdToEnglishName: y,\n isCanonical: w,\n isExtraMaterial: q,\n isObsolete: U\n};\nvar l = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = \"Unknown\", t[t.Original = 1] = \"Original\", t[t.Septuagint = 2] = \"Septuagint\", t[t.Vulgate = 3] = \"Vulgate\", t[t.English = 4] = \"English\", t[t.RussianProtestant = 5] = \"RussianProtestant\", t[t.RussianOrthodox = 6] = \"RussianOrthodox\", t))(l || {});\nconst h = class h {\n // private versInfo: Versification;\n constructor(e) {\n n(this, \"name\");\n n(this, \"fullPath\");\n n(this, \"isPresent\");\n n(this, \"hasVerseSegments\");\n n(this, \"isCustomized\");\n n(this, \"baseVersification\");\n n(this, \"scriptureBooks\");\n n(this, \"_type\");\n if (e == null)\n throw new Error(\"Argument undefined\");\n typeof e == \"string\" ? (this.name = e, this._type = l[e]) : (this._type = e, this.name = l[e]);\n }\n get type() {\n return this._type;\n }\n equals(e) {\n return !e.type || !this.type ? !1 : e.type === this.type;\n }\n};\nn(h, \"Original\", new h(l.Original)), n(h, \"Septuagint\", new h(l.Septuagint)), n(h, \"Vulgate\", new h(l.Vulgate)), n(h, \"English\", new h(l.English)), n(h, \"RussianProtestant\", new h(l.RussianProtestant)), n(h, \"RussianOrthodox\", new h(l.RussianOrthodox));\nlet c = h;\nfunction E(t, e) {\n const s = e[0];\n for (let r = 1; r < e.length; r++)\n t = t.split(e[r]).join(s);\n return t.split(s);\n}\nvar D = /* @__PURE__ */ ((t) => (t[t.Valid = 0] = \"Valid\", t[t.UnknownVersification = 1] = \"UnknownVersification\", t[t.OutOfRange = 2] = \"OutOfRange\", t[t.VerseOutOfOrder = 3] = \"VerseOutOfOrder\", t[t.VerseRepeated = 4] = \"VerseRepeated\", t))(D || {});\nconst i = class i {\n constructor(e, s, r, a) {\n /** Not yet implemented. */\n n(this, \"firstChapter\");\n /** Not yet implemented. */\n n(this, \"lastChapter\");\n /** Not yet implemented. */\n n(this, \"lastVerse\");\n /** Not yet implemented. */\n n(this, \"hasSegmentsDefined\");\n /** Not yet implemented. */\n n(this, \"text\");\n /** Not yet implemented. */\n n(this, \"BBBCCCVVVS\");\n /** Not yet implemented. */\n n(this, \"longHashCode\");\n /** The versification of the reference. */\n n(this, \"versification\");\n n(this, \"rtlMark\", \"‏\");\n n(this, \"_bookNum\", 0);\n n(this, \"_chapterNum\", 0);\n n(this, \"_verseNum\", 0);\n n(this, \"_verse\");\n if (r == null && a == null)\n if (e != null && typeof e == \"string\") {\n const o = e, u = s != null && s instanceof c ? s : void 0;\n this.setEmpty(u), this.parse(o);\n } else if (e != null && typeof e == \"number\") {\n const o = s != null && s instanceof c ? s : void 0;\n this.setEmpty(o), this._verseNum = e % i.chapterDigitShifter, this._chapterNum = Math.floor(\n e % i.bookDigitShifter / i.chapterDigitShifter\n ), this._bookNum = Math.floor(e / i.bookDigitShifter);\n } else if (s == null)\n if (e != null && e instanceof i) {\n const o = e;\n this._bookNum = o.bookNum, this._chapterNum = o.chapterNum, this._verseNum = o.verseNum, this._verse = o.verse, this.versification = o.versification;\n } else {\n if (e == null) return;\n const o = e instanceof c ? e : i.defaultVersification;\n this.setEmpty(o);\n }\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else if (e != null && s != null && r != null)\n if (typeof e == \"string\" && typeof s == \"string\" && typeof r == \"string\")\n this.setEmpty(a), this.updateInternal(e, s, r);\n else if (typeof e == \"number\" && typeof s == \"number\" && typeof r == \"number\")\n this._bookNum = e, this._chapterNum = s, this._verseNum = r, this.versification = a ?? i.defaultVersification;\n else\n throw new Error(\"VerseRef constructor not supported.\");\n else\n throw new Error(\"VerseRef constructor not supported.\");\n }\n /**\n * Determines if the verse string is in a valid format (does not consider versification).\n */\n static isVerseParseable(e) {\n return e.length > 0 && \"0123456789\".includes(e[0]) && !e.endsWith(this.verseRangeSeparator) && !e.endsWith(this.verseSequenceIndicator);\n }\n /**\n * Tries to parse the specified string into a verse reference.\n * @param str - The string to attempt to parse.\n * @returns success: `true` if the specified string was successfully parsed, `false` otherwise.\n * @returns verseRef: The result of the parse if successful, or empty VerseRef if it failed\n */\n static tryParse(e) {\n let s;\n try {\n return s = new i(e), { success: !0, verseRef: s };\n } catch (r) {\n if (r instanceof v)\n return s = new i(), { success: !1, verseRef: s };\n throw r;\n }\n }\n /**\n * Gets the reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n * @param bookNum - Book number (this is 1-based, not an index).\n * @param chapterNum - Chapter number.\n * @param verseNum - Verse number.\n * @returns The reference as a comparable integer where the book, chapter, and verse each occupy 3\n * digits.\n */\n static getBBBCCCVVV(e, s, r) {\n return e % i.bcvMaxValue * i.bookDigitShifter + (s >= 0 ? s % i.bcvMaxValue * i.chapterDigitShifter : 0) + (r >= 0 ? r % i.bcvMaxValue : 0);\n }\n /**\n * Deserializes a serialized VerseRef.\n * @param serializedVerseRef - Serialized VerseRef to create from.\n * @returns the deserialized VerseRef.\n */\n static fromJSON(e) {\n const { book: s, chapterNum: r, verseNum: a, verse: o, versificationStr: u } = e, f = o || a.toString();\n let d;\n return u && (d = new c(u)), s ? new i(s, r.toString(), f, d) : new i();\n }\n /**\n * Parses a verse string and gets the leading numeric portion as a number.\n * @param verseStr - verse string to parse\n * @returns true if the entire string could be parsed as a single, simple verse number (1-999);\n * false if the verse string represented a verse bridge, contained segment letters, or was invalid\n */\n static tryGetVerseNum(e) {\n let s;\n if (!e)\n return s = -1, { success: !0, vNum: s };\n s = 0;\n let r;\n for (let a = 0; a < e.length; a++) {\n if (r = e[a], r < \"0\" || r > \"9\")\n return a === 0 && (s = -1), { success: !1, vNum: s };\n if (s = s * 10 + +r - 0, s > i.bcvMaxValue)\n return s = -1, { success: !1, vNum: s };\n }\n return { success: !0, vNum: s };\n }\n /**\n * Checks to see if a VerseRef hasn't been set - all values are the default.\n */\n get isDefault() {\n return this.bookNum === 0 && this.chapterNum === 0 && this.verseNum === 0 && this.versification == null;\n }\n /**\n * Gets whether the verse contains multiple verses.\n */\n get hasMultiple() {\n return this._verse != null && (this._verse.includes(i.verseRangeSeparator) || this._verse.includes(i.verseSequenceIndicator));\n }\n /**\n * Gets or sets the book of the reference. Book is the 3-letter abbreviation in capital letters,\n * e.g. `'MAT'`.\n */\n get book() {\n return m.bookNumberToId(this.bookNum, \"\");\n }\n set book(e) {\n this.bookNum = m.bookIdToNumber(e);\n }\n /**\n * Gets or sets the chapter of the reference,. e.g. `'3'`.\n */\n get chapter() {\n return this.isDefault || this._chapterNum < 0 ? \"\" : this._chapterNum.toString();\n }\n set chapter(e) {\n const s = +e;\n this._chapterNum = Number.isInteger(s) ? s : -1;\n }\n /**\n * Gets or sets the verse of the reference, including range, segments, and sequences, e.g. `'4'`,\n * or `'4b-5a, 7'`.\n */\n get verse() {\n return this._verse != null ? this._verse : this.isDefault || this._verseNum < 0 ? \"\" : this._verseNum.toString();\n }\n set verse(e) {\n const { success: s, vNum: r } = i.tryGetVerseNum(e);\n this._verse = s ? void 0 : e.replace(this.rtlMark, \"\"), this._verseNum = r, !(this._verseNum >= 0) && ({ vNum: this._verseNum } = i.tryGetVerseNum(this._verse));\n }\n /**\n * Get or set Book based on book number, e.g. `42`.\n */\n get bookNum() {\n return this._bookNum;\n }\n set bookNum(e) {\n if (e <= 0 || e > m.lastBook)\n throw new v(\n \"BookNum must be greater than zero and less than or equal to last book\"\n );\n this._bookNum = e;\n }\n /**\n * Gets or sets the chapter number, e.g. `3`. `-1` if not valid.\n */\n get chapterNum() {\n return this._chapterNum;\n }\n set chapterNum(e) {\n this.chapterNum = e;\n }\n /**\n * Gets or sets verse start number, e.g. `4`. `-1` if not valid.\n */\n get verseNum() {\n return this._verseNum;\n }\n set verseNum(e) {\n this._verseNum = e;\n }\n /**\n * String representing the versification (should ONLY be used for serialization/deserialization).\n *\n * @remarks This is for backwards compatibility when ScrVers was an enumeration.\n */\n get versificationStr() {\n var e;\n return (e = this.versification) == null ? void 0 : e.name;\n }\n set versificationStr(e) {\n this.versification = this.versification != null ? new c(e) : void 0;\n }\n /**\n * Determines if the reference is valid.\n */\n get valid() {\n return this.validStatus === 0;\n }\n /**\n * Get the valid status for this reference.\n */\n get validStatus() {\n return this.validateVerse(i.verseRangeSeparators, i.verseSequenceIndicators);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits and the verse is 0.\n */\n get BBBCCC() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, 0);\n }\n /**\n * Gets the reference as a comparable integer where the book,\n * chapter, and verse each occupy three digits. If verse is not null\n * (i.e., this reference represents a complex reference with verse\n * segments or bridge) this cannot be used for an exact comparison.\n */\n get BBBCCCVVV() {\n return i.getBBBCCCVVV(this._bookNum, this._chapterNum, this._verseNum);\n }\n /**\n * Gets whether the verse is defined as an excluded verse in the versification.\n * Does not handle verse ranges.\n */\n // eslint-disable-next-line @typescript-eslint/class-literal-property-style\n get isExcluded() {\n return !1;\n }\n /**\n * Parses the reference in the specified string.\n * Optionally versification can follow reference as in GEN 3:11/4\n * Throw an exception if\n * - invalid book name\n * - chapter number is missing or not a number\n * - verse number is missing or does not start with a number\n * - versification is invalid\n * @param verseStr - string to parse e.g. 'MAT 3:11'\n */\n parse(e) {\n if (e = e.replace(this.rtlMark, \"\"), e.includes(\"/\")) {\n const o = e.split(\"/\");\n if (e = o[0], o.length > 1)\n try {\n const u = +o[1].trim();\n this.versification = new c(l[u]);\n } catch {\n throw new v(\"Invalid reference : \" + e);\n }\n }\n const s = e.trim().split(\" \");\n if (s.length !== 2)\n throw new v(\"Invalid reference : \" + e);\n const r = s[1].split(\":\"), a = +r[0];\n if (r.length !== 2 || m.bookIdToNumber(s[0]) === 0 || !Number.isInteger(a) || a < 0 || !i.isVerseParseable(r[1]))\n throw new v(\"Invalid reference : \" + e);\n this.updateInternal(s[0], r[0], r[1]);\n }\n /**\n * Simplifies this verse ref so that it has no bridging of verses or\n * verse segments like `'1a'`.\n */\n simplify() {\n this._verse = void 0;\n }\n /**\n * Makes a clone of the reference.\n *\n * @returns The cloned VerseRef.\n */\n clone() {\n return new i(this);\n }\n toString() {\n const e = this.book;\n return e === \"\" ? \"\" : `${e} ${this.chapter}:${this.verse}`;\n }\n toJSON() {\n let e = this.verse;\n (e === \"\" || e === this.verseNum.toString()) && (e = void 0);\n const s = {\n book: this.book,\n chapterNum: this.chapterNum,\n verseNum: this.verseNum,\n verse: e,\n versificationStr: this.versificationStr\n };\n return e || delete s.verse, s;\n }\n /**\n * Compares this `VerseRef` with supplied one.\n * @param verseRef - object to compare this one to.\n * @returns `true` if this `VerseRef` is equal to the supplied one, `false` otherwise.\n */\n equals(e) {\n return e instanceof i ? e._bookNum === this._bookNum && e._chapterNum === this._chapterNum && e._verseNum === this._verseNum && e.verse === this.verse && (e.versification == null && this.versification == null || e.versification != null && this.versification != null && e.versification.equals(this.versification)) : !1;\n }\n /**\n * Enumerate all individual verses contained in a VerseRef.\n * Verse ranges are indicated by \"-\" and consecutive verses by \",\"s.\n * Examples:\n * GEN 1:2 returns GEN 1:2\n * GEN 1:1a-3b,5 returns GEN 1:1a, GEN 1:2, GEN 1:3b, GEN 1:5\n * GEN 1:2a-2c returns //! ??????\n *\n * @param specifiedVersesOnly - if set to true return only verses that are\n * explicitly specified only, not verses within a range. Defaults to `false`.\n * @param verseRangeSeparators - Verse range separators.\n * Defaults to `VerseRef.verseRangeSeparators`.\n * @param verseSequenceSeparators - Verse sequence separators.\n * Defaults to `VerseRef.verseSequenceIndicators`.\n * @returns An array of all single verse references in this VerseRef.\n */\n allVerses(e = !1, s = i.verseRangeSeparators, r = i.verseSequenceIndicators) {\n if (this._verse == null || this.chapterNum <= 0)\n return [this.clone()];\n const a = [], o = E(this._verse, r);\n for (const u of o.map((f) => E(f, s))) {\n const f = this.clone();\n f.verse = u[0];\n const d = f.verseNum;\n if (a.push(f), u.length > 1) {\n const b = this.clone();\n if (b.verse = u[1], !e)\n for (let p = d + 1; p < b.verseNum; p++) {\n const J = new i(\n this._bookNum,\n this._chapterNum,\n p,\n this.versification\n );\n this.isExcluded || a.push(J);\n }\n a.push(b);\n }\n }\n return a;\n }\n /**\n * Validates a verse number using the supplied separators rather than the defaults.\n */\n validateVerse(e, s) {\n if (!this.verse)\n return this.internalValid;\n let r = 0;\n for (const a of this.allVerses(!0, e, s)) {\n const o = a.internalValid;\n if (o !== 0)\n return o;\n const u = a.BBBCCCVVV;\n if (r > u)\n return 3;\n if (r === u)\n return 4;\n r = u;\n }\n return 0;\n }\n /**\n * Gets whether a single verse reference is valid.\n */\n get internalValid() {\n return this.versification == null ? 1 : this._bookNum <= 0 || this._bookNum > m.lastBook ? 2 : (m.isCanonical(this._bookNum), 0);\n }\n setEmpty(e = i.defaultVersification) {\n this._bookNum = 0, this._chapterNum = -1, this._verse = void 0, this.versification = e;\n }\n updateInternal(e, s, r) {\n this.bookNum = m.bookIdToNumber(e), this.chapter = s, this.verse = r;\n }\n};\nn(i, \"defaultVersification\", c.English), n(i, \"verseRangeSeparator\", \"-\"), n(i, \"verseSequenceIndicator\", \",\"), n(i, \"verseRangeSeparators\", [i.verseRangeSeparator]), n(i, \"verseSequenceIndicators\", [i.verseSequenceIndicator]), n(i, \"chapterDigitShifter\", 1e3), n(i, \"bookDigitShifter\", i.chapterDigitShifter * i.chapterDigitShifter), n(i, \"bcvMaxValue\", i.chapterDigitShifter - 1), /**\n * The valid status of the VerseRef.\n */\nn(i, \"ValidStatusType\", D);\nlet M = i;\nclass v extends Error {\n}\nexport {\n _ as BookSet,\n m as Canon,\n c as ScrVers,\n l as ScrVersType,\n M as VerseRef,\n v as VerseRefException\n};\n//# sourceMappingURL=index.es.js.map\n","'use strict';\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties,\n * including NodeList.\n *\n * @param {T[] | { length: number; [number]: T }} list\n * @param {function (item: T, index: number, list:T[]):boolean} predicate\n * @param {Partial>?} ac\n * Allows injecting a custom implementation in tests (`Array.prototype` by default).\n * @returns {T | undefined}\n * @template {unknown} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (hasOwn(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * If `Object.getOwnPropertyDescriptors` is available,\n * a new object with all properties of object but without any prototype is created and returned\n * after freezing it.\n *\n * @param {T} object\n * The object to freeze.\n * @param {Pick} [oc=Object]\n * `Object` by default,\n * allows to inject custom object constructor for tests.\n * @returns {Readonly}\n * @template {Object} T\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n * @prettierignore\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object;\n\t}\n\tif (oc && typeof oc.getOwnPropertyDescriptors === 'function') {\n\t\tobject = oc.create(null, oc.getOwnPropertyDescriptors(object));\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;\n}\n\n/**\n * Implementation for `Object.hasOwn` but ES5 compatible.\n *\n * @param {any} object\n * @param {string | number} key\n * @returns {boolean}\n */\nfunction hasOwn(object, key) {\n\treturn Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Since xmldom can not rely on `Object.assign`,\n * it uses/provides a simplified version that is sufficient for its needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n * @returns {Object}\n * The target with the merged/overridden properties.\n * @throws {TypeError}\n * If target is not an object.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object');\n\t}\n\tfor (var key in source) {\n\t\tif (hasOwn(source, key)) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * A number of attributes are boolean attributes.\n * The presence of a boolean attribute on an element represents the `true` value,\n * and the absence of the attribute represents the `false` value.\n *\n * If the attribute is present, its value must either be the empty string, or a value that is\n * an ASCII case-insensitive match for the attribute's canonical name,\n * with no leading or trailing whitespace.\n *\n * Note: The values `\"true\"` and `\"false\"` are not allowed on boolean attributes.\n * To represent a `false` value, the attribute has to be omitted altogether.\n *\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nvar HTML_BOOLEAN_ATTRIBUTES = freeze({\n\tallowfullscreen: true,\n\tasync: true,\n\tautofocus: true,\n\tautoplay: true,\n\tchecked: true,\n\tcontrols: true,\n\tdefault: true,\n\tdefer: true,\n\tdisabled: true,\n\tformnovalidate: true,\n\thidden: true,\n\tismap: true,\n\titemscope: true,\n\tloop: true,\n\tmultiple: true,\n\tmuted: true,\n\tnomodule: true,\n\tnovalidate: true,\n\topen: true,\n\tplaysinline: true,\n\treadonly: true,\n\trequired: true,\n\treversed: true,\n\tselected: true,\n});\n\n/**\n * Check if `name` is matching one of the HTML boolean attribute names.\n * This method doesn't check if such attributes are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} name\n * @returns {boolean}\n * @see {@link HTML_BOOLEAN_ATTRIBUTES}\n * @see https://html.spec.whatwg.org/#boolean-attributes\n * @see https://html.spec.whatwg.org/#attributes-3\n */\nfunction isHTMLBooleanAttribute(name) {\n\treturn hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());\n}\n\n/**\n * Void elements only have a start tag; end tags must not be specified for void elements.\n * These elements should be written as self-closing like this: ``.\n * This should not be confused with optional tags that HTML allows to omit the end tag for\n * (like `li`, `tr` and others), which can have content after them,\n * so they can not be written as self-closing.\n * xmldom does not have any logic for optional end tags cases,\n * and will report them as a warning.\n * Content that would go into the unopened element,\n * will instead be added as a sibling text node.\n *\n * @type {Readonly<{\n * \tarea: boolean;\n * \tcol: boolean;\n * \timg: boolean;\n * \twbr: boolean;\n * \tlink: boolean;\n * \thr: boolean;\n * \tsource: boolean;\n * \tbr: boolean;\n * \tinput: boolean;\n * \tparam: boolean;\n * \tmeta: boolean;\n * \tembed: boolean;\n * \ttrack: boolean;\n * \tbase: boolean;\n * }>}\n * @see https://html.spec.whatwg.org/#void-elements\n * @see https://html.spec.whatwg.org/#optional-tags\n */\nvar HTML_VOID_ELEMENTS = freeze({\n\tarea: true,\n\tbase: true,\n\tbr: true,\n\tcol: true,\n\tembed: true,\n\thr: true,\n\timg: true,\n\tinput: true,\n\tlink: true,\n\tmeta: true,\n\tparam: true,\n\tsource: true,\n\ttrack: true,\n\twbr: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML void element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link HTML_VOID_ELEMENTS}\n * @see https://html.spec.whatwg.org/#void-elements\n */\nfunction isHTMLVoidElement(tagName) {\n\treturn hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());\n}\n\n/**\n * Tag names that are raw text elements according to HTML spec.\n * The value denotes whether they are escapable or not.\n *\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link isHTMLRawTextElement}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nvar HTML_RAW_TEXT_ELEMENTS = freeze({\n\tscript: false,\n\tstyle: false,\n\ttextarea: true,\n\ttitle: true,\n});\n\n/**\n * Check if `tagName` is matching one of the HTML raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLEscapableRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Check if `tagName` is matching one of the HTML escapable raw text element names.\n * This method doesn't check if such tags are allowed in the context of the current\n * document/parsing.\n *\n * @param {string} tagName\n * @returns {boolean}\n * @see {@link isHTMLRawTextElement}\n * @see {@link HTML_RAW_TEXT_ELEMENTS}\n * @see https://html.spec.whatwg.org/#raw-text-elements\n * @see https://html.spec.whatwg.org/#escapable-raw-text-elements\n */\nfunction isHTMLEscapableRawTextElement(tagName) {\n\tvar key = tagName.toLowerCase();\n\treturn hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];\n}\n/**\n * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'text/html'}\n * @see https://www.iana.org/assignments/media-types/text/html\n * @see https://en.wikipedia.org/wiki/HTML\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n */\nfunction isHTMLMimeType(mimeType) {\n\treturn mimeType === MIME_TYPE.HTML;\n}\n/**\n * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the\n * HTML namespace is provided as the default.\n *\n * @param {string} mimeType\n * @returns {boolean}\n * @see https://dom.spec.whatwg.org/#dom-document-createelement\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument\n * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n */\nfunction hasDefaultHTMLNamespace(mimeType) {\n\treturn isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02\n * MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype\n * WHATWG HTML Spec\n * @see {@link DOMParser.prototype.parseFromString}\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring\n\t * WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType\n\t * registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/xml`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType\n\t * registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n});\n/**\n * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n * MimeType\n */\n/**\n * @type {MimeType[]}\n * @private\n * Basically `Object.values`, which is not available in ES5.\n */\nvar _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {\n\treturn MIME_TYPE[key];\n});\n\n/**\n * Only returns true if `mimeType` is one of the allowed values for\n * `DOMParser.parseFromString`.\n *\n * @param {string} mimeType\n * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}\n *\n */\nfunction isValidMimeType(mimeType) {\n\treturn _MIME_TYPES.indexOf(mimeType) > -1;\n}\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace.\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n});\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;\nexports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;\nexports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;\nexports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;\nexports.hasOwn = hasOwn;\nexports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;\nexports.isHTMLRawTextElement = isHTMLRawTextElement;\nexports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;\nexports.isHTMLMimeType = isHTMLMimeType;\nexports.isHTMLVoidElement = isHTMLVoidElement;\nexports.isValidMimeType = isValidMimeType;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","'use strict';\n\nvar conventions = require('./conventions');\n\nfunction extendError(constructor, writableName) {\n\tconstructor.prototype = Object.create(Error.prototype, {\n\t\tconstructor: { value: constructor },\n\t\tname: { value: constructor.name, enumerable: true, writable: writableName },\n\t});\n}\n\nvar DOMExceptionName = conventions.freeze({\n\t/**\n\t * the default value as defined by the spec\n\t */\n\tError: 'Error',\n\t/**\n\t * @deprecated\n\t * Use RangeError instead.\n\t */\n\tIndexSizeError: 'IndexSizeError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tDomstringSizeError: 'DomstringSizeError',\n\tHierarchyRequestError: 'HierarchyRequestError',\n\tWrongDocumentError: 'WrongDocumentError',\n\tInvalidCharacterError: 'InvalidCharacterError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tNoDataAllowedError: 'NoDataAllowedError',\n\tNoModificationAllowedError: 'NoModificationAllowedError',\n\tNotFoundError: 'NotFoundError',\n\tNotSupportedError: 'NotSupportedError',\n\tInUseAttributeError: 'InUseAttributeError',\n\tInvalidStateError: 'InvalidStateError',\n\tSyntaxError: 'SyntaxError',\n\tInvalidModificationError: 'InvalidModificationError',\n\tNamespaceError: 'NamespaceError',\n\t/**\n\t * @deprecated\n\t * Use TypeError for invalid arguments,\n\t * \"NotSupportedError\" DOMException for unsupported operations,\n\t * and \"NotAllowedError\" DOMException for denied requests instead.\n\t */\n\tInvalidAccessError: 'InvalidAccessError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tValidationError: 'ValidationError',\n\t/**\n\t * @deprecated\n\t * Use TypeError instead.\n\t */\n\tTypeMismatchError: 'TypeMismatchError',\n\tSecurityError: 'SecurityError',\n\tNetworkError: 'NetworkError',\n\tAbortError: 'AbortError',\n\t/**\n\t * @deprecated\n\t * Just to match the related static code, not part of the spec.\n\t */\n\tURLMismatchError: 'URLMismatchError',\n\tQuotaExceededError: 'QuotaExceededError',\n\tTimeoutError: 'TimeoutError',\n\tInvalidNodeTypeError: 'InvalidNodeTypeError',\n\tDataCloneError: 'DataCloneError',\n\tEncodingError: 'EncodingError',\n\tNotReadableError: 'NotReadableError',\n\tUnknownError: 'UnknownError',\n\tConstraintError: 'ConstraintError',\n\tDataError: 'DataError',\n\tTransactionInactiveError: 'TransactionInactiveError',\n\tReadOnlyError: 'ReadOnlyError',\n\tVersionError: 'VersionError',\n\tOperationError: 'OperationError',\n\tNotAllowedError: 'NotAllowedError',\n\tOptOutError: 'OptOutError',\n});\nvar DOMExceptionNames = Object.keys(DOMExceptionName);\n\nfunction isValidDomExceptionCode(value) {\n\treturn typeof value === 'number' && value >= 1 && value <= 25;\n}\nfunction endsWithError(value) {\n\treturn typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;\n}\n/**\n * DOM operations only raise exceptions in \"exceptional\" circumstances, i.e., when an operation\n * is impossible to perform (either for logical reasons, because data is lost, or because the\n * implementation has become unstable). In general, DOM methods return specific error values in\n * ordinary processing situations, such as out-of-bound errors when using NodeList.\n *\n * Implementations should raise other exceptions under other circumstances. For example,\n * implementations should raise an implementation-dependent exception if a null argument is\n * passed when null was not expected.\n *\n * This implementation supports the following usages:\n * 1. according to the living standard (both arguments are optional):\n * ```\n * new DOMException(\"message (can be empty)\", DOMExceptionNames.HierarchyRequestError)\n * ```\n * 2. according to previous xmldom implementation (only the first argument is required):\n * ```\n * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, \"optional message\")\n * ```\n * both result in the proper name being set.\n *\n * @class DOMException\n * @param {number | string} messageOrCode\n * The reason why an operation is not acceptable.\n * If it is a number, it is used to determine the `name`, see\n * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}\n * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]\n * The `name` to use for the error.\n * If `messageOrCode` is a number, this arguments is used as the `message` instead.\n * @augments Error\n * @see https://webidl.spec.whatwg.org/#idl-DOMException\n * @see https://webidl.spec.whatwg.org/#dfn-error-names-table\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(messageOrCode, nameOrMessage) {\n\t// support old way of passing arguments: first argument is a valid number\n\tif (isValidDomExceptionCode(messageOrCode)) {\n\t\tthis.name = DOMExceptionNames[messageOrCode];\n\t\tthis.message = nameOrMessage || '';\n\t} else {\n\t\tthis.message = messageOrCode;\n\t\tthis.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;\n\t}\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n}\nextendError(DOMException, true);\nObject.defineProperties(DOMException.prototype, {\n\tcode: {\n\t\tenumerable: true,\n\t\tget: function () {\n\t\t\tvar code = DOMExceptionNames.indexOf(this.name);\n\t\t\tif (isValidDomExceptionCode(code)) return code;\n\t\t\treturn 0;\n\t\t},\n\t},\n});\n\nvar ExceptionCode = {\n\tINDEX_SIZE_ERR: 1,\n\tDOMSTRING_SIZE_ERR: 2,\n\tHIERARCHY_REQUEST_ERR: 3,\n\tWRONG_DOCUMENT_ERR: 4,\n\tINVALID_CHARACTER_ERR: 5,\n\tNO_DATA_ALLOWED_ERR: 6,\n\tNO_MODIFICATION_ALLOWED_ERR: 7,\n\tNOT_FOUND_ERR: 8,\n\tNOT_SUPPORTED_ERR: 9,\n\tINUSE_ATTRIBUTE_ERR: 10,\n\tINVALID_STATE_ERR: 11,\n\tSYNTAX_ERR: 12,\n\tINVALID_MODIFICATION_ERR: 13,\n\tNAMESPACE_ERR: 14,\n\tINVALID_ACCESS_ERR: 15,\n\tVALIDATION_ERR: 16,\n\tTYPE_MISMATCH_ERR: 17,\n\tSECURITY_ERR: 18,\n\tNETWORK_ERR: 19,\n\tABORT_ERR: 20,\n\tURL_MISMATCH_ERR: 21,\n\tQUOTA_EXCEEDED_ERR: 22,\n\tTIMEOUT_ERR: 23,\n\tINVALID_NODE_TYPE_ERR: 24,\n\tDATA_CLONE_ERR: 25,\n};\n\nvar entries = Object.entries(ExceptionCode);\nfor (var i = 0; i < entries.length; i++) {\n\tvar key = entries[i][0];\n\tDOMException[key] = entries[i][1];\n}\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @class\n * @param {string} message\n * @param {any} [locator]\n */\nfunction ParseError(message, locator) {\n\tthis.message = message;\n\tthis.locator = locator;\n\tif (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nextendError(ParseError);\n\nexports.DOMException = DOMException;\nexports.DOMExceptionName = DOMExceptionName;\nexports.ExceptionCode = ExceptionCode;\nexports.ParseError = ParseError;\n","'use strict';\n\n/**\n * Detects relevant unicode support for regular expressions in the runtime.\n * Should the runtime not accepts the flag `u` or unicode ranges,\n * character classes without unicode handling will be used.\n *\n * @param {typeof RegExp} [RegExpImpl=RegExp]\n * For testing: the RegExp class.\n * @returns {boolean}\n * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags\n */\nfunction detectUnicodeSupport(RegExpImpl) {\n\ttry {\n\t\tif (typeof RegExpImpl !== 'function') {\n\t\t\tRegExpImpl = RegExp;\n\t\t}\n\t\t// eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape\n\t\tvar match = new RegExpImpl('\\u{1d306}', 'u').exec('𝌆');\n\t\treturn !!match && match[0].length === 2;\n\t} catch (error) {}\n\treturn false;\n}\nvar UNICODE_SUPPORT = detectUnicodeSupport();\n\n/**\n * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.\n *\n * @param {RegExp} regexp\n */\nfunction chars(regexp) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error(regexp + ' can not be used with chars');\n\t}\n\treturn regexp.source.slice(1, regexp.source.lastIndexOf(']'));\n}\n\n/**\n * Creates a new character list regular expression,\n * by removing `search` from the source of `regexp`.\n *\n * @param {RegExp} regexp\n * @param {string} search\n * The character(s) to remove.\n * @returns {RegExp}\n */\nfunction chars_without(regexp, search) {\n\tif (regexp.source[0] !== '[') {\n\t\tthrow new Error('/' + regexp.source + '/ can not be used with chars_without');\n\t}\n\tif (!search || typeof search !== 'string') {\n\t\tthrow new Error(JSON.stringify(search) + ' is not a valid search');\n\t}\n\tif (regexp.source.indexOf(search) === -1) {\n\t\tthrow new Error('\"' + search + '\" is not is /' + regexp.source + '/');\n\t}\n\tif (search === '-' && regexp.source.indexOf(search) !== 1) {\n\t\tthrow new Error('\"' + search + '\" is not at the first postion of /' + regexp.source + '/');\n\t}\n\treturn new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');\n}\n\n/**\n * Combines and Regular expressions correctly by using `RegExp.source`.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction reg(args) {\n\tvar self = this;\n\treturn new RegExp(\n\t\tArray.prototype.slice\n\t\t\t.call(arguments)\n\t\t\t.map(function (part) {\n\t\t\t\tvar isStr = typeof part === 'string';\n\t\t\t\tif (isStr && self === undefined && part === '|') {\n\t\t\t\t\tthrow new Error('use regg instead of reg to wrap expressions with `|`!');\n\t\t\t\t}\n\t\t\t\treturn isStr ? part : part.source;\n\t\t\t})\n\t\t\t.join(''),\n\t\tUNICODE_SUPPORT ? 'mu' : 'm'\n\t);\n}\n\n/**\n * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.\n *\n * @param {...(RegExp | string)[]} args\n * @returns {RegExp}\n */\nfunction regg(args) {\n\tif (arguments.length === 0) {\n\t\tthrow new Error('no parameters provided');\n\t}\n\treturn reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));\n}\n\n// /**\n// * Append ^ to the beginning of the expression.\n// * @param {...(RegExp | string)[]} args\n// * @returns {RegExp}\n// */\n// function reg_start(args) {\n// \tif (arguments.length === 0) {\n// \t\tthrow new Error('no parameters provided');\n// \t}\n// \treturn reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));\n// }\n\n// https://www.w3.org/TR/xml/#document\n// `[1] document ::= prolog element Misc*`\n// https://www.w3.org/TR/xml11/#NT-document\n// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`\n\n/**\n * A character usually appearing in wrongly converted strings.\n *\n * @type {string}\n * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character\n * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings\n * @see https://www.unicode.org/faq/utf_bom.html#BOM\n * @readonly\n */\nvar UNICODE_REPLACEMENT_CHARACTER = '\\uFFFD';\n// https://www.w3.org/TR/xml/#NT-Char\n// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-Char\n// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`\n// https://www.w3.org/TR/xml11/#NT-RestrictedChar\n// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`\n// https://www.w3.org/TR/xml11/#charsets\nvar Char = /[-\\x09\\x0A\\x0D\\x20-\\x2C\\x2E-\\uD7FF\\uE000-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tChar = reg('[', chars(Char), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\n\nvar _SChar = /[\\x20\\x09\\x0D\\x0A]/;\nvar SChar_s = chars(_SChar);\n// https://www.w3.org/TR/xml11/#NT-S\n// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`\nvar S = reg(_SChar, '+');\n// optional whitespace described as `S?` in the grammar,\n// simplified to 0-n occurrences of the character class\n// instead of 0-1 occurrences of a non-capturing group around S\nvar S_OPT = reg(_SChar, '*');\n\n// https://www.w3.org/TR/xml11/#NT-NameStartChar\n// `[4] NameStartChar ::= \":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`\nvar NameStartChar =\n\t/[:_a-zA-Z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02FF\\u0370-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/; // without \\u10000-\\uEFFFF\nif (UNICODE_SUPPORT) {\n\t// eslint-disable-next-line es5/no-unicode-code-point-escape\n\tNameStartChar = reg('[', chars(NameStartChar), '\\\\u{10000}-\\\\u{10FFFF}', ']');\n}\nvar NameStartChar_s = chars(NameStartChar);\n\n// https://www.w3.org/TR/xml11/#NT-NameChar\n// `[4a] NameChar ::= NameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`\nvar NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\\xB7]/), chars(/[\\u0300-\\u036F\\u203F-\\u2040]/), ']');\n// https://www.w3.org/TR/xml11/#NT-Name\n// `[5] Name ::= NameStartChar (NameChar)*`\nvar Name = reg(NameStartChar, NameChar, '*');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Names\n`[6] Names ::= Name (#x20 Name)*`\n*/\n\n// https://www.w3.org/TR/xml11/#NT-Nmtoken\n// `[7] Nmtoken ::= (NameChar)+`\nvar Nmtoken = reg(NameChar, '+');\n/*\nhttps://www.w3.org/TR/xml11/#NT-Nmtokens\n`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`\nvar Nmtokens = reg(Nmtoken, regg(/\\x20/, Nmtoken), '*');\n*/\n\n// https://www.w3.org/TR/xml11/#NT-EntityRef\n// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\nvar EntityRef = reg('&', Name, ';');\n// https://www.w3.org/TR/xml11/#NT-CharRef\n// `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\nvar CharRef = regg(/&#[0-9]+;|&#x[0-9a-fA-F]+;/);\n\n/*\nhttps://www.w3.org/TR/xml11/#NT-Reference\n- `[67] Reference ::= EntityRef | CharRef`\n- `[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'` [WFC: Legal Character]\n- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]\n*/\nvar Reference = regg(EntityRef, '|', CharRef);\n\n// https://www.w3.org/TR/xml11/#NT-PEReference\n// `[69] PEReference ::= '%' Name ';'`\n// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]\nvar PEReference = reg('%', Name, ';');\n\n// https://www.w3.org/TR/xml11/#NT-EntityValue\n// `[9] EntityValue ::= '\"' ([^%&\"] | PEReference | Reference)* '\"' | \"'\" ([^%&'] | PEReference | Reference)* \"'\"`\nvar EntityValue = regg(\n\treg('\"', regg(/[^%&\"]/, '|', PEReference, '|', Reference), '*', '\"'),\n\t'|',\n\treg(\"'\", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', \"'\")\n);\n\n// https://www.w3.org/TR/xml11/#NT-AttValue\n// `[10] AttValue ::= '\"' ([^<&\"] | Reference)* '\"' | \"'\" ([^<&'] | Reference)* \"'\"`\nvar AttValue = regg('\"', regg(/[^<&\"]/, '|', Reference), '*', '\"', '|', \"'\", regg(/[^<&']/, '|', Reference), '*', \"'\");\n\n// https://www.w3.org/TR/xml-names/#ns-decl\n// https://www.w3.org/TR/xml-names/#ns-qualnames\n// NameStartChar without \":\"\nvar NCNameStartChar = chars_without(NameStartChar, ':');\n// https://www.w3.org/TR/xml-names/#orphans\n// `[5] NCNameChar ::= NameChar - ':'`\n// An XML NameChar, minus the \":\"\nvar NCNameChar = chars_without(NameChar, ':');\n// https://www.w3.org/TR/xml-names/#NT-NCName\n// `[4] NCName ::= Name - (Char* ':' Char*)`\n// An XML Name, minus the \":\"\nvar NCName = reg(NCNameStartChar, NCNameChar, '*');\n\n/**\nhttps://www.w3.org/TR/xml-names/#ns-qualnames\n\n```\n[7] QName ::= PrefixedName | UnprefixedName\n\t\t\t\t === (NCName ':' NCName) | NCName\n\t\t\t\t === NCName (':' NCName)?\n[8] PrefixedName ::= Prefix ':' LocalPart\n\t\t\t\t\t\t\t\t === NCName ':' NCName\n[9] UnprefixedName ::= LocalPart\n\t\t\t\t\t\t\t\t\t === NCName\n[10] Prefix ::= NCName\n[11] LocalPart ::= NCName\n```\n*/\nvar QName = reg(NCName, regg(':', NCName), '?');\nvar QName_exact = reg('^', QName, '$');\nvar QName_group = reg('(', QName, ')');\n\n// https://www.w3.org/TR/xml11/#NT-SystemLiteral\n// `[11] SystemLiteral ::= ('\"' [^\"]* '\"') | (\"'\" [^']* \"'\")`\nvar SystemLiteral = regg(/\"[^\"]*\"|'[^']*'/);\n\n/*\n https://www.w3.org/TR/xml11/#NT-PI\n ```\n [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))\n [16] PI ::= '' Char*)))? '?>'\n ```\n target /xml/i is not excluded!\n*/\nvar PI = reg(/^<\\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\\?>/);\n\n// https://www.w3.org/TR/xml11/#NT-PubidChar\n// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`\nvar PubidChar = /[\\x20\\x0D\\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;\n\n// https://www.w3.org/TR/xml11/#NT-PubidLiteral\n// `[12] PubidLiteral ::= '\"' PubidChar* '\"' | \"'\" (PubidChar - \"'\")* \"'\"`\nvar PubidLiteral = regg('\"', PubidChar, '*\"', '|', \"'\", chars_without(PubidChar, \"'\"), \"*'\");\n\n// https://www.w3.org/TR/xml11/#NT-CharData\n// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`\n\nvar COMMENT_START = '';\n// https://www.w3.org/TR/xml11/#NT-Comment\n// `[15] Comment ::= ''`\nvar Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);\n\nvar PCDATA = '#PCDATA';\n// https://www.w3.org/TR/xml11/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// https://www.w3.org/TR/xml-names/#NT-Mixed\n// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`\n// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]\nvar Mixed = regg(\n\treg(/\\(/, S_OPT, PCDATA, regg(S_OPT, /\\|/, S_OPT, QName), '*', S_OPT, /\\)\\*/),\n\t'|',\n\treg(/\\(/, S_OPT, PCDATA, S_OPT, /\\)/)\n);\n\nvar _children_quantity = /[?*+]?/;\n/*\n `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]\n `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');\n ```\n [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?\n === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?\n !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?\n ```\n simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\n var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.\nhttps://github.com/xmldom/xmldom/security/code-scanning/91\nvar choice = regg(/\\(/, S_OPT, cp, regg(S_OPT, /\\|/, S_OPT, cp), '+', S_OPT, /\\)/);\n*/\n/*\nInefficient regular expression (High)\nThis part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.\nhttps://github.com/xmldom/xmldom/security/code-scanning/92\nvar seq = regg(/\\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\\)/);\n*/\n\n// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`\n// simplification to solve circular referencing, but doesn't check validity constraint \"Proper Group/PE Nesting\"\nvar children = reg(/\\([^>]+\\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);\n\n// https://www.w3.org/TR/xml11/#NT-contentspec\n// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`\nvar contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);\n\nvar ELEMENTDECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-elementdecl\n// `[17] elementdecl ::= ''`\n// because of https://www.w3.org/TR/xml11/#NT-PEReference\n// since xmldom is not supporting replacements of PEReferences in the DTD\n// this also supports PEReference in the possible places\nvar elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');\n\n// https://www.w3.org/TR/xml11/#NT-NotationType\n// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`\n// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]\nvar NotationType = reg('NOTATION', S, /\\(/, S_OPT, Name, regg(S_OPT, /\\|/, S_OPT, Name), '*', S_OPT, /\\)/);\n// https://www.w3.org/TR/xml11/#NT-Enumeration\n// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`\n// [VC: Enumeration] [VC: No Duplicate Tokens]\nvar Enumeration = reg(/\\(/, S_OPT, Nmtoken, regg(S_OPT, /\\|/, S_OPT, Nmtoken), '*', S_OPT, /\\)/);\n\n// https://www.w3.org/TR/xml11/#NT-EnumeratedType\n// `[57] EnumeratedType ::= NotationType | Enumeration`\nvar EnumeratedType = regg(NotationType, '|', Enumeration);\n\n/*\n```\n[55] StringType ::= 'CDATA'\n[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]\n | 'IDREF' [VC: IDREF]\n | 'IDREFS' [VC: IDREF]\n\t | 'ENTITY' [VC: Entity Name]\n\t | 'ENTITIES' [VC: Entity Name]\n\t | 'NMTOKEN' [VC: Name Token]\n\t | 'NMTOKENS' [VC: Name Token]\n [54] AttType ::= StringType | TokenizedType | EnumeratedType\n```*/\nvar AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);\n\n// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`\n// [WFC: No < in Attribute Values] [WFC: No External Entity References]\n// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]\nvar DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));\n\n// https://www.w3.org/TR/xml11/#NT-AttDef\n// [53] AttDef ::= S Name S AttType S DefaultDecl\n// https://www.w3.org/TR/xml-names/#NT-AttDef\n// [1] NSAttName ::= PrefixedAttName | DefaultAttName\n// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]\n// [3] DefaultAttName ::= 'xmlns'\n// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl\n// \t\t\t\t\t\t === S Name S AttType S DefaultDecl\n// xmldom is not distinguishing between QName and NSAttName on this level\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttDef = regg(S, Name, S, AttType, S, DefaultDecl);\n\nvar ATTLIST_DECL_START = ''`\n// https://www.w3.org/TR/xml-names/#NT-AttlistDecl\n// `[20] AttlistDecl ::= ''`\n// to support XML without namespaces in DTD we can not restrict it to QName\nvar AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');\n\n// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat\nvar ABOUT_LEGACY_COMPAT = 'about:legacy-compat';\nvar ABOUT_LEGACY_COMPAT_SystemLiteral = regg('\"' + ABOUT_LEGACY_COMPAT + '\"', '|', \"'\" + ABOUT_LEGACY_COMPAT + \"'\");\nvar SYSTEM = 'SYSTEM';\nvar PUBLIC = 'PUBLIC';\n// https://www.w3.org/TR/xml11/#NT-ExternalID\n// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`\nvar ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));\nvar ExternalID_match = reg(\n\t'^',\n\tregg(\n\t\tregg(SYSTEM, S, '(?', SystemLiteral, ')'),\n\t\t'|',\n\t\tregg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')\n\t)\n);\n\n// https://www.w3.org/TR/xml11/#NT-NDataDecl\n// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]\nvar NDataDecl = regg(S, 'NDATA', S, Name);\n\n// https://www.w3.org/TR/xml11/#NT-EntityDef\n// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`\nvar EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));\n\nvar ENTITY_DECL_START = ''`\nvar GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-PEDef\n// `[74] PEDef ::= EntityValue | ExternalID`\nvar PEDef = regg(EntityValue, '|', ExternalID);\n// https://www.w3.org/TR/xml11/#NT-PEDecl\n// `[72] PEDecl ::= ''`\nvar PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');\n// https://www.w3.org/TR/xml11/#NT-EntityDecl\n// `[70] EntityDecl ::= GEDecl | PEDecl`\nvar EntityDecl = regg(GEDecl, '|', PEDecl);\n\n// https://www.w3.org/TR/xml11/#NT-PublicID\n// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`\nvar PublicID = reg(PUBLIC, S, PubidLiteral);\n// https://www.w3.org/TR/xml11/#NT-NotationDecl\n// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]\nvar NotationDecl = reg('');\n\n// https://www.w3.org/TR/xml11/#NT-Eq\n// `[25] Eq ::= S? '=' S?`\nvar Eq = reg(S_OPT, '=', S_OPT);\n// https://www.w3.org/TR/xml/#NT-VersionNum\n// `[26] VersionNum ::= '1.' [0-9]+`\n// https://www.w3.org/TR/xml11/#NT-VersionNum\n// `[26] VersionNum ::= '1.1'`\nvar VersionNum = /1[.]\\d+/;\n// https://www.w3.org/TR/xml11/#NT-VersionInfo\n// `[24] VersionInfo ::= S 'version' Eq (\"'\" VersionNum \"'\" | '\"' VersionNum '\"')`\nvar VersionInfo = reg(S, 'version', Eq, regg(\"'\", VersionNum, \"'\", '|', '\"', VersionNum, '\"'));\n// https://www.w3.org/TR/xml11/#NT-EncName\n// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`\nvar EncName = /[A-Za-z][-A-Za-z0-9._]*/;\n// https://www.w3.org/TR/xml11/#NT-EncDecl\n// `[80] EncodingDecl ::= S 'encoding' Eq ('\"' EncName '\"' | \"'\" EncName \"'\" )`\nvar EncodingDecl = regg(S, 'encoding', Eq, regg('\"', EncName, '\"', '|', \"'\", EncName, \"'\"));\n// https://www.w3.org/TR/xml11/#NT-SDDecl\n// `[32] SDDecl ::= S 'standalone' Eq ((\"'\" ('yes' | 'no') \"'\") | ('\"' ('yes' | 'no') '\"'))`\nvar SDDecl = regg(S, 'standalone', Eq, regg(\"'\", regg('yes', '|', 'no'), \"'\", '|', '\"', regg('yes', '|', 'no'), '\"'));\n// https://www.w3.org/TR/xml11/#NT-XMLDecl\n// [23] XMLDecl ::= ''\nvar XMLDecl = reg(/^<\\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\\?>/);\n\n/*\n https://www.w3.org/TR/xml/#NT-markupdecl\n https://www.w3.org/TR/xml11/#NT-markupdecl\n `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`\n var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);\n*/\n/*\n https://www.w3.org/TR/xml-names/#NT-doctypedecl\n`[28a] DeclSep ::= PEReference | S`\n https://www.w3.org/TR/xml11/#NT-intSubset\n```\n [28b] intSubset ::= (markupdecl | DeclSep)*\n === (markupdecl | PEReference | S)*\n```\n [WFC: PE Between Declarations]\n var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');\n*/\nvar DOCTYPE_DECL_START = ''`\n https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl\n `[16] doctypedecl ::= ''`\n var doctypedecl = reg('');\n*/\n\nvar CDATA_START = '';\nvar CDStart = //;\nvar CData = reg(Char, '*?', CDEnd);\n/*\n https://www.w3.org/TR/xml/#dt-cdsection\n `[18] \tCDSect\t ::= \tCDStart CData CDEnd`\n `[19] \tCDStart\t ::= \t'' Char*))`\n `[21] \tCDEnd\t ::= \t']]>'`\n*/\nvar CDSect = reg(CDStart, CData);\n\n// unit tested\nexports.chars = chars;\nexports.chars_without = chars_without;\nexports.detectUnicodeSupport = detectUnicodeSupport;\nexports.reg = reg;\nexports.regg = regg;\nexports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;\nexports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;\nexports.AttlistDecl = AttlistDecl;\nexports.CDATA_START = CDATA_START;\nexports.CDATA_END = CDATA_END;\nexports.CDSect = CDSect;\nexports.Char = Char;\nexports.Comment = Comment;\nexports.COMMENT_START = COMMENT_START;\nexports.COMMENT_END = COMMENT_END;\nexports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;\nexports.elementdecl = elementdecl;\nexports.EntityDecl = EntityDecl;\nexports.EntityValue = EntityValue;\nexports.ExternalID = ExternalID;\nexports.ExternalID_match = ExternalID_match;\nexports.Name = Name;\nexports.NotationDecl = NotationDecl;\nexports.Reference = Reference;\nexports.PEReference = PEReference;\nexports.PI = PI;\nexports.PUBLIC = PUBLIC;\nexports.PubidLiteral = PubidLiteral;\nexports.QName = QName;\nexports.QName_exact = QName_exact;\nexports.QName_group = QName_group;\nexports.S = S;\nexports.SChar_s = SChar_s;\nexports.S_OPT = S_OPT;\nexports.SYSTEM = SYSTEM;\nexports.SystemLiteral = SystemLiteral;\nexports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;\nexports.UNICODE_SUPPORT = UNICODE_SUPPORT;\nexports.XMLDecl = XMLDecl;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar find = conventions.find;\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar hasOwn = conventions.hasOwn;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar isHTMLVoidElement = conventions.isHTMLVoidElement;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * Private DOM Constructor symbol\n *\n * Internal symbol used for construction of all classes whose constructors should be private.\n * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,\n * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`\n * so the constructor can't be used from outside the module.\n */\nvar PDC = Symbol();\n\nvar errors = require('./errors');\nvar DOMException = errors.DOMException;\nvar DOMExceptionName = errors.DOMExceptionName;\n\nvar g = require('./grammar');\n\n/**\n * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)\n * and throws an Illegal constructor exception when the symbols don't match.\n * This ensures that the constructor remains private and can't be used outside this module.\n */\nfunction checkSymbol(symbol) {\n\tif (symbol !== PDC) {\n\t\tthrow new TypeError('Illegal constructor');\n\t}\n}\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty.\n *\n * @param {string} input\n * The string to be checked.\n * @returns {boolean}\n * Returns `true` if the input string is not empty, `false` otherwise.\n */\nfunction notEmptyString(input) {\n\treturn input !== '';\n}\n/**\n * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,\n * U+0020 SPACE).\n * It follows the definition from the infra specification from WHATWG.\n *\n * @param {string} input\n * The string to be split.\n * @returns {string[]}\n * An array of the split strings. The array can be empty if the input string is empty or only\n * contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}\n * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : [];\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * The current record object to which the element will be added as a key.\n * The object's keys are string types and values are either boolean or undefined.\n * @param {string} element\n * The string to be added as a key to the current record.\n * @returns {Record}\n * The updated record object after the addition of the new element.\n */\nfunction orderedSetReducer(current, element) {\n\tif (!hasOwn(current, element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * Converts a string into an ordered set by splitting the input on ASCII whitespace and\n * ensuring uniqueness of elements.\n * This follows the definition of an ordered set from the infra specification by WHATWG.\n *\n * @param {string} input\n * The input string to be transformed into an ordered set.\n * @returns {string[]}\n * An array of unique strings obtained from the input, preserving the original order.\n * The array can be empty if the input string is empty or only contains whitespace characters.\n * @see {@link https://infra.spec.whatwg.org/#ordered-set}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}));\n}\n\n/**\n * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.\n * This function is used in environments where `Array.prototype.includes` may not be available.\n *\n * @param {any[]} list\n * The array in which to search for the element.\n * @returns {function(any): boolean}\n * A function that accepts an element and returns a boolean indicating whether the element is\n * included in the provided list.\n */\nfunction arrayIncludes(list) {\n\treturn function (element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t};\n}\n\n/**\n * Validates a qualified name based on the criteria provided in the DOM specification by\n * WHATWG.\n *\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @throws {DOMException}\n * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an\n * invalid character.\n * @see {@link https://dom.spec.whatwg.org/#validate}\n */\nfunction validateQualifiedName(qualifiedName) {\n\tif (!g.QName_exact.test(qualifiedName)) {\n\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name \"' + qualifiedName + '\"');\n\t}\n}\n\n/**\n * Validates a qualified name and the namespace associated with it,\n * based on the criteria provided in the DOM specification by WHATWG.\n *\n * @param {string | null} namespace\n * The namespace to be validated. It can be a string or null.\n * @param {string} qualifiedName\n * The qualified name to be validated.\n * @returns {[namespace: string | null, prefix: string | null, localName: string]}\n * Returns a tuple with the namespace,\n * prefix and local name of the qualified name.\n * @throws {DOMException}\n * Throws a DOMException if the qualified name or the namespace is not valid.\n * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}\n */\nfunction validateAndExtract(namespace, qualifiedName) {\n\tvalidateQualifiedName(qualifiedName);\n\tnamespace = namespace || null;\n\t/**\n\t * @type {string | null}\n\t */\n\tvar prefix = null;\n\tvar localName = qualifiedName;\n\tif (qualifiedName.indexOf(':') >= 0) {\n\t\tvar splitResult = qualifiedName.split(':');\n\t\tprefix = splitResult[0];\n\t\tlocalName = splitResult[1];\n\t}\n\tif (prefix !== null && namespace === null) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');\n\t}\n\tif (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {\n\t\tthrow new DOMException(DOMException.NAMESPACE_ERR, 'prefix is \"xml\" and namespace is not the XML namespace');\n\t}\n\tif ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'either qualifiedName or prefix is \"xmlns\" and namespace is not the XMLNS namespace'\n\t\t);\n\t}\n\tif (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {\n\t\tthrow new DOMException(\n\t\t\tDOMException.NAMESPACE_ERR,\n\t\t\t'namespace is the XMLNS namespace and neither qualifiedName nor prefix is \"xmlns\"'\n\t\t);\n\t}\n\treturn [namespace, prefix, localName];\n}\n\n/**\n * Copies properties from one object to another.\n * It only copies the object's own (not inherited) properties.\n *\n * @param {Object} src\n * The source object from which properties are copied.\n * @param {Object} dest\n * The destination object to which properties are copied.\n */\nfunction copy(src, dest) {\n\tfor (var p in src) {\n\t\tif (hasOwn(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n * Extends a class with the properties and methods of a super class.\n * It uses a form of prototypal inheritance, and establishes the `constructor` property\n * correctly(?).\n *\n * It is not clear to the current maintainers if this implementation is making sense,\n * since it creates an intermediate prototype function,\n * which all properties of `Super` are copied onto using `_copy`.\n *\n * @param {Object} Class\n * The class that is to be extended.\n * @param {Object} Super\n * The super class from which properties and methods are inherited.\n * @private\n */\nfunction _extends(Class, Super) {\n\tvar pt = Class.prototype;\n\tif (!(pt instanceof Super)) {\n\t\tfunction t() {}\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt, t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif (pt.constructor != Class) {\n\t\tif (typeof Class != 'function') {\n\t\t\tconsole.error('unknown Class:' + Class);\n\t\t}\n\t\tpt.constructor = Class;\n\t}\n}\n\nvar NodeType = {};\nvar ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);\nvar ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);\nvar TEXT_NODE = (NodeType.TEXT_NODE = 3);\nvar CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);\nvar ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);\nvar ENTITY_NODE = (NodeType.ENTITY_NODE = 6);\nvar PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);\nvar COMMENT_NODE = (NodeType.COMMENT_NODE = 8);\nvar DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);\nvar DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);\nvar DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);\nvar NOTATION_NODE = (NodeType.NOTATION_NODE = 12);\n\nvar DocumentPosition = conventions.freeze({\n\tDOCUMENT_POSITION_DISCONNECTED: 1,\n\tDOCUMENT_POSITION_PRECEDING: 2,\n\tDOCUMENT_POSITION_FOLLOWING: 4,\n\tDOCUMENT_POSITION_CONTAINS: 8,\n\tDOCUMENT_POSITION_CONTAINED_BY: 16,\n\tDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,\n});\n\n//helper functions for compareDocumentPosition\n/**\n * Finds the common ancestor in two parent chains.\n *\n * @param {Node[]} a\n * The first parent chain.\n * @param {Node[]} b\n * The second parent chain.\n * @returns {Node}\n * The common ancestor node if it exists. If there is no common ancestor, the function will\n * return `null`.\n */\nfunction commonAncestor(a, b) {\n\tif (b.length < a.length) return commonAncestor(b, a);\n\tvar c = null;\n\tfor (var n in a) {\n\t\tif (a[n] !== b[n]) return c;\n\t\tc = a[n];\n\t}\n\treturn c;\n}\n\n/**\n * Assigns a unique identifier to a document to ensure consistency while comparing unrelated\n * nodes.\n *\n * @param {Document} doc\n * The document to which a unique identifier is to be assigned.\n * @returns {string}\n * The unique identifier of the document. If the document already had a unique identifier, the\n * function will return the existing one.\n */\nfunction docGUID(doc) {\n\tif (!doc.guid) doc.guid = Math.random();\n\treturn doc.guid;\n}\n//-- end of helper functions\n\n/**\n * The NodeList interface provides the abstraction of an ordered collection of nodes,\n * without defining or constraining how this collection is implemented.\n * NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n * You can also access the items of the NodeList with a `for...of` loop.\n *\n * @class NodeList\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * @constructs NodeList\n */\nfunction NodeList() {}\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1\n\t * inclusive.\n\t *\n\t * @type {number}\n\t */\n\tlength: 0,\n\t/**\n\t * Returns the item at `index`. If index is greater than or equal to the number of nodes in\n\t * the list, this returns null.\n\t *\n\t * @param index\n\t * Unsigned long Index into the collection.\n\t * @returns {Node | null}\n\t * The node at position `index` in the NodeList,\n\t * or null if that is not a valid index.\n\t */\n\titem: function (index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\t/**\n\t * Returns a string representation of the NodeList.\n\t *\n\t * @param {unknown} nodeFilter\n\t * __A filter function? Not implemented according to the spec?__.\n\t * @returns {string}\n\t * A string representation of the NodeList.\n\t */\n\ttoString: function (nodeFilter) {\n\t\tfor (var buf = [], i = 0; i < this.length; i++) {\n\t\t\tserializeToString(this[i], buf, nodeFilter);\n\t\t}\n\t\treturn buf.join('');\n\t},\n\t/**\n\t * Filters the NodeList based on a predicate.\n\t *\n\t * @param {function(Node): boolean} predicate\n\t * - A predicate function to filter the NodeList.\n\t * @returns {Node[]}\n\t * An array of nodes that satisfy the predicate.\n\t * @private\n\t */\n\tfilter: function (predicate) {\n\t\treturn Array.prototype.filter.call(this, predicate);\n\t},\n\t/**\n\t * Returns the first index at which a given node can be found in the NodeList, or -1 if it is\n\t * not present.\n\t *\n\t * @param {Node} item\n\t * - The Node item to locate in the NodeList.\n\t * @returns {number}\n\t * The first index of the node in the NodeList; -1 if not found.\n\t * @private\n\t */\n\tindexOf: function (item) {\n\t\treturn Array.prototype.indexOf.call(this, item);\n\t},\n};\nNodeList.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * Represents a live collection of nodes that is automatically updated when its associated\n * document changes.\n *\n * @class LiveNodeList\n * @param {Node} node\n * The associated node.\n * @param {function} refresh\n * The function to refresh the live node list.\n * @augments NodeList\n * @constructs LiveNodeList\n */\nfunction LiveNodeList(node, refresh) {\n\tthis._node = node;\n\tthis._refresh = refresh;\n\t_updateLiveList(this);\n}\n/**\n * Updates the live node list.\n *\n * @param {LiveNodeList} list\n * The live node list to update.\n * @private\n */\nfunction _updateLiveList(list) {\n\tvar inc = list._node._inc || list._node.ownerDocument._inc;\n\tif (list._inc !== inc) {\n\t\tvar ls = list._refresh(list._node);\n\t\t__set__(list, 'length', ls.length);\n\t\tif (!list.$$length || ls.length < list.$$length) {\n\t\t\tfor (var i = ls.length; i in list; i++) {\n\t\t\t\tif (hasOwn(list, i)) {\n\t\t\t\t\tdelete list[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcopy(ls, list);\n\t\tlist._inc = inc;\n\t}\n}\n/**\n * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid\n * index.\n *\n * @param {number} i\n * Index into the collection.\n * @returns {Node | null}\n * The node at position `index` in the LiveNodeList, or null if that is not a valid index.\n */\nLiveNodeList.prototype.item = function (i) {\n\t_updateLiveList(this);\n\treturn this[i] || null;\n};\n\n_extends(LiveNodeList, NodeList);\n\n/**\n * Objects implementing the NamedNodeMap interface are used to represent collections of nodes\n * that can be accessed by name.\n * Note that NamedNodeMap does not inherit from NodeList;\n * NamedNodeMaps are not maintained in any particular order.\n * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal\n * index,\n * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,\n * and does not imply that the DOM specifies an order to these Nodes.\n * NamedNodeMap objects in the DOM are live.\n * used for attributes or DocumentType entities\n *\n * This implementation only supports property indices, but does not support named properties,\n * as specified in the living standard.\n *\n * @class NamedNodeMap\n * @see https://dom.spec.whatwg.org/#interface-namednodemap\n * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names\n * @constructs NamedNodeMap\n */\nfunction NamedNodeMap() {}\n/**\n * Returns the index of a node within the list.\n *\n * @param {Array} list\n * The list of nodes.\n * @param {Node} node\n * The node to find.\n * @returns {number}\n * The index of the node within the list, or -1 if not found.\n * @private\n */\nfunction _findNodeIndex(list, node) {\n\tvar i = 0;\n\twhile (i < list.length) {\n\t\tif (list[i] === node) {\n\t\t\treturn i;\n\t\t}\n\t\ti++;\n\t}\n}\n/**\n * Adds a new attribute to the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which will become the owner of the new attribute.\n * @param {NamedNodeMap} list\n * The list to which the new attribute will be added.\n * @param {Attr} newAttr\n * The new attribute to be added.\n * @param {Attr} oldAttr\n * The old attribute to be replaced, or null if no attribute is to be replaced.\n * @returns {void}\n * @private\n */\nfunction _addNamedNode(el, list, newAttr, oldAttr) {\n\tif (oldAttr) {\n\t\tlist[_findNodeIndex(list, oldAttr)] = newAttr;\n\t} else {\n\t\tlist[list.length] = newAttr;\n\t\tlist.length++;\n\t}\n\tif (el) {\n\t\tnewAttr.ownerElement = el;\n\t\tvar doc = el.ownerDocument;\n\t\tif (doc) {\n\t\t\toldAttr && _onRemoveAttribute(doc, el, oldAttr);\n\t\t\t_onAddAttribute(doc, el, newAttr);\n\t\t}\n\t}\n}\n/**\n * Removes an attribute from the list and updates the owner element of the attribute.\n *\n * @param {Element} el\n * The element which is the current owner of the attribute.\n * @param {NamedNodeMap} list\n * The list from which the attribute will be removed.\n * @param {Attr} attr\n * The attribute to be removed.\n * @returns {void}\n * @private\n */\nfunction _removeNamedNode(el, list, attr) {\n\t//console.log('remove attr:'+attr)\n\tvar i = _findNodeIndex(list, attr);\n\tif (i >= 0) {\n\t\tvar lastIndex = list.length - 1;\n\t\twhile (i <= lastIndex) {\n\t\t\tlist[i] = list[++i];\n\t\t}\n\t\tlist.length = lastIndex;\n\t\tif (el) {\n\t\t\tvar doc = el.ownerDocument;\n\t\t\tif (doc) {\n\t\t\t\t_onRemoveAttribute(doc, el, attr);\n\t\t\t}\n\t\t\tattr.ownerElement = null;\n\t\t}\n\t}\n}\nNamedNodeMap.prototype = {\n\tlength: 0,\n\titem: NodeList.prototype.item,\n\n\t/**\n\t * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and\n\t * document.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given local name, or null if no such attribute exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name\n\t */\n\tgetNamedItem: function (localName) {\n\t\tif (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {\n\t\t\tlocalName = localName.toLowerCase();\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar attr = this[i];\n\t\t\tif (attr.nodeName === localName) {\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n\n\t/**\n\t * Set an attribute.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another\n\t * element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItem: function (attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif (el && el !== this._ownerElement) {\n\t\t\tthrow new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);\n\t\tif (oldAttr === attr) {\n\t\t\treturn attr;\n\t\t}\n\t\t_addNamedNode(this._ownerElement, this, attr, oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/**\n\t * Set an attribute, replacing an existing attribute with the same local name and namespace\n\t * URI if one exists.\n\t *\n\t * @param {Attr} attr\n\t * The attribute to set.\n\t * @returns {Attr | null}\n\t * The old attribute with the same local name and namespace URI as the new one, or null if no\n\t * such attribute exists.\n\t * @throws {DOMException}\n\t * Throws a DOMException with the name \"InUseAttributeError\" if the attribute is already an\n\t * attribute of another element.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-set\n\t */\n\tsetNamedItemNS: function (attr) {\n\t\treturn this.setNamedItem(attr);\n\t},\n\n\t/**\n\t * Removes an attribute specified by the local name.\n\t *\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name\n\t */\n\tremoveNamedItem: function (localName) {\n\t\tvar attr = this.getNamedItem(localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Removes an attribute specified by the namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute to be removed.\n\t * @param {string} localName\n\t * The local name of the attribute to be removed.\n\t * @returns {Attr}\n\t * The attribute node that was removed.\n\t * @throws {DOMException}\n\t * With code:\n\t * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local\n\t * name is found.\n\t * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace\n\t */\n\tremoveNamedItemNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getNamedItemNS(namespaceURI, localName);\n\t\tif (!attr) {\n\t\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);\n\t\t}\n\t\t_removeNamedNode(this._ownerElement, this, attr);\n\t\treturn attr;\n\t},\n\n\t/**\n\t * Get an attribute by namespace and local name.\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI of the attribute.\n\t * @param {string} localName\n\t * The local name of the attribute.\n\t * @returns {Attr | null}\n\t * The attribute with the given namespace URI and local name, or null if no such attribute\n\t * exists.\n\t * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace\n\t */\n\tgetNamedItemNS: function (namespaceURI, localName) {\n\t\tif (!namespaceURI) {\n\t\t\tnamespaceURI = null;\n\t\t}\n\t\tvar i = 0;\n\t\twhile (i < this.length) {\n\t\t\tvar node = this[i];\n\t\t\tif (node.localName === localName && node.namespaceURI === namespaceURI) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn null;\n\t},\n};\nNamedNodeMap.prototype[Symbol.iterator] = function () {\n\tvar me = this;\n\tvar index = 0;\n\n\treturn {\n\t\tnext: function () {\n\t\t\tif (index < me.length) {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: me[index++],\n\t\t\t\t\tdone: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\treturn: function () {\n\t\t\treturn {\n\t\t\t\tdone: true,\n\t\t\t};\n\t\t},\n\t};\n};\n\n/**\n * The DOMImplementation interface provides a number of methods for performing operations that\n * are independent of any particular instance of the document object model.\n *\n * The DOMImplementation interface represents an object providing methods which are not\n * dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * **The individual methods describe the differences compared to the specs**.\n *\n * @class DOMImplementation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core\n * (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n * @constructs DOMImplementation\n */\nfunction DOMImplementation() {}\n\nDOMImplementation.prototype = {\n\t/**\n\t * Test if the DOM implementation implements a specific feature and version, as specified in\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.\n\t *\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given\n\t * feature is supported. The different implementations fairly diverged in what kind of\n\t * features were reported. The latest version of the spec settled to force this method to\n\t * always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated\n\t * It is deprecated and modern browsers return true in all cases.\n\t * @function DOMImplementation#hasFeature\n\t * @param {string} feature\n\t * The name of the feature to test.\n\t * @param {string} [version]\n\t * This is the version number of the feature to test.\n\t * @returns {boolean}\n\t * Always returns true.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core\n\t */\n\thasFeature: function (feature, version) {\n\t\treturn true;\n\t},\n\t/**\n\t * Creates a DOM Document object of the specified type with its document element. Note that\n\t * based on the {@link DocumentType}\n\t * given to create the document, the implementation may instantiate specialized\n\t * {@link Document} objects that support additional features than the \"Core\", such as \"HTML\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.\n\t * On the other hand, setting the {@link DocumentType} after the document was created makes\n\t * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,\n\t * such as createHTMLDocument\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},\n\t * can be used to obtain specific types of {@link Document} objects.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document`\n\t * instance (with it's `type` set to `'xml'`).\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @function DOMImplementation.createDocument\n\t * @param {string | null} namespaceURI\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}\n\t * of the document element to create or null.\n\t * @param {string | null} qualifiedName\n\t * The\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}\n\t * of the document element to be created or null.\n\t * @param {DocumentType | null} [doctype=null]\n\t * The type of document to be created or null. When doctype is not null, its\n\t * {@link Node#ownerDocument} attribute is set to the document being created. Default is\n\t * `null`\n\t * @returns {Document}\n\t * A new {@link Document} object with its document element. If the NamespaceURI,\n\t * qualifiedName, and doctype are null, the returned {@link Document} is empty with no\n\t * document element.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a\n\t * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI\n\t * is different from null, or if the qualifiedName has a prefix that is \"xml\" and the\n\t * namespaceURI is different from \"{@link http://www.w3.org/XML/1998/namespace}\"\n\t * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},\n\t * or if the DOM implementation does not support the \"XML\" feature but a non-null namespace\n\t * URI was provided, since namespaces were defined by XML.\n\t * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document\n\t * or was created from a different implementation.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see {@link #createHTMLDocument}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM\n\t * Level 2 Core (initial)\n\t */\n\tcreateDocument: function (namespaceURI, qualifiedName, doctype) {\n\t\tvar contentType = MIME_TYPE.XML_APPLICATION;\n\t\tif (namespaceURI === NAMESPACE.HTML) {\n\t\t\tcontentType = MIME_TYPE.XML_XHTML_APPLICATION;\n\t\t} else if (namespaceURI === NAMESPACE.SVG) {\n\t\t\tcontentType = MIME_TYPE.XML_SVG_IMAGE;\n\t\t}\n\t\tvar doc = new Document(PDC, { contentType: contentType });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype) {\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName) {\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Creates an empty DocumentType node. Entity declarations and notations are not made\n\t * available. Entity reference expansions and default attribute additions do not occur.\n\t *\n\t * **This behavior is slightly different from the one in the specs**:\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - `publicId` and `systemId` contain the raw data including any possible quotes,\n\t * so they can always be serialized back to the original value\n\t * - `internalSubset` contains the raw string between `[` and `]` if present,\n\t * but is not parsed or validated in any form.\n\t *\n\t * @function DOMImplementation#createDocumentType\n\t * @param {string} qualifiedName\n\t * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified\n\t * name} of the document type to be created.\n\t * @param {string} [publicId]\n\t * The external subset public identifier.\n\t * @param {string} [systemId]\n\t * The external subset system identifier.\n\t * @param {string} [internalSubset]\n\t * the internal subset or an empty string if it is not present\n\t * @returns {DocumentType}\n\t * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.\n\t * @throws {DOMException}\n\t * With code:\n\t *\n\t * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name\n\t * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.\n\t * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.\n\t * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature\n\t * \"XML\" and the language exposed through the Document does not support XML Namespaces (such\n\t * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).\n\t * @since DOM Level 2.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType\n\t * MDN\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living\n\t * Standard\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM\n\t * Level 3 Core\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM\n\t * Level 2 Core\n\t * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset\n\t * @prettierignore\n\t */\n\tcreateDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {\n\t\tvalidateQualifiedName(qualifiedName);\n\t\tvar node = new DocumentType(PDC);\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\t\tnode.internalSubset = internalSubset || '';\n\t\tnode.childNodes = new NodeList();\n\n\t\treturn node;\n\t},\n\t/**\n\t * Returns an HTML document, that might already have a basic DOM structure.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are\n\t * omitted)\n\t * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t *\n\t * @param {string | false} [title]\n\t * A string containing the title to give the new HTML document.\n\t * @returns {Document}\n\t * The HTML document.\n\t * @since WHATWG Living Standard.\n\t * @see {@link #createDocument}\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument\n\t * @see https://dom.spec.whatwg.org/#html-document\n\t */\n\tcreateHTMLDocument: function (title) {\n\t\tvar doc = new Document(PDC, { contentType: MIME_TYPE.HTML });\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tif (title !== false) {\n\t\t\tdoc.doctype = this.createDocumentType('html');\n\t\t\tdoc.doctype.ownerDocument = doc;\n\t\t\tdoc.appendChild(doc.doctype);\n\t\t\tvar htmlNode = doc.createElement('html');\n\t\t\tdoc.appendChild(htmlNode);\n\t\t\tvar headNode = doc.createElement('head');\n\t\t\thtmlNode.appendChild(headNode);\n\t\t\tif (typeof title === 'string') {\n\t\t\t\tvar titleNode = doc.createElement('title');\n\t\t\t\ttitleNode.appendChild(doc.createTextNode(title));\n\t\t\t\theadNode.appendChild(titleNode);\n\t\t\t}\n\t\t\thtmlNode.appendChild(doc.createElement('body'));\n\t\t}\n\t\treturn doc;\n\t},\n};\n\n/**\n * The DOM Node interface is an abstract base class upon which many other DOM API objects are\n * based, thus letting those object types to be used similarly and often interchangeably. As an\n * abstract class, there is no such thing as a plain Node object. All objects that implement\n * Node functionality are based on one of its subclasses. Most notable are Document, Element,\n * and DocumentFragment.\n *\n * In addition, every kind of DOM node is represented by an interface based on Node. These\n * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are\n * all based on), and DocumentType.\n *\n * In some cases, a particular feature of the base Node interface may not apply to one of its\n * child interfaces; in that case, the inheriting node may return null or throw an exception,\n * depending on circumstances. For example, attempting to add children to a node type that\n * cannot have children will throw an exception.\n *\n * **This behavior is slightly different from the in the specs**:\n * - unimplemented interfaces: `EventTarget`\n *\n * @class\n * @abstract\n * @param {Symbol} symbol\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n * @see https://dom.spec.whatwg.org/#node\n * @prettierignore\n */\nfunction Node(symbol) {\n\tcheckSymbol(symbol);\n}\n\nNode.prototype = {\n\t/**\n\t * The first child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tfirstChild: null,\n\t/**\n\t * The last child of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tlastChild: null,\n\t/**\n\t * The previous sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tpreviousSibling: null,\n\t/**\n\t * The next sibling of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tnextSibling: null,\n\t/**\n\t * The parent node of this node.\n\t *\n\t * @type {Node | null}\n\t */\n\tparentNode: null,\n\t/**\n\t * The parent element of this node.\n\t *\n\t * @type {Element | null}\n\t */\n\tget parentElement() {\n\t\treturn this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;\n\t},\n\t/**\n\t * The child nodes of this node.\n\t *\n\t * @type {NodeList}\n\t */\n\tchildNodes: null,\n\t/**\n\t * The document object associated with this node.\n\t *\n\t * @type {Document | null}\n\t */\n\townerDocument: null,\n\t/**\n\t * The value of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnodeValue: null,\n\t/**\n\t * The namespace URI of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tnamespaceURI: null,\n\t/**\n\t * The prefix of the namespace for this node.\n\t *\n\t * @type {string | null}\n\t */\n\tprefix: null,\n\t/**\n\t * The local part of the qualified name of this node.\n\t *\n\t * @type {string | null}\n\t */\n\tlocalName: null,\n\t/**\n\t * The baseURI is currently always `about:blank`,\n\t * since that's what happens when you create a document from scratch.\n\t *\n\t * @type {'about:blank'}\n\t */\n\tbaseURI: 'about:blank',\n\t/**\n\t * Is true if this node is part of a document.\n\t *\n\t * @type {boolean}\n\t */\n\tget isConnected() {\n\t\tvar rootNode = this.getRootNode();\n\t\treturn rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;\n\t},\n\t/**\n\t * Checks whether `other` is an inclusive descendant of this node.\n\t *\n\t * @param {Node | null | undefined} other\n\t * The node to check.\n\t * @returns {boolean}\n\t * True if `other` is an inclusive descendant of this node; false otherwise.\n\t * @see https://dom.spec.whatwg.org/#dom-node-contains\n\t */\n\tcontains: function (other) {\n\t\tif (!other) return false;\n\t\tvar parent = other;\n\t\tdo {\n\t\t\tif (this === parent) return true;\n\t\t\tparent = other.parentNode;\n\t\t} while (parent);\n\t\treturn false;\n\t},\n\t/**\n\t * @typedef GetRootNodeOptions\n\t * @property {boolean} [composed=false]\n\t */\n\t/**\n\t * Searches for the root node of this node.\n\t *\n\t * **This behavior is slightly different from the in the specs**:\n\t * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.\n\t *\n\t * @param {GetRootNodeOptions} [options]\n\t * @returns {Node}\n\t * Root node.\n\t * @see https://dom.spec.whatwg.org/#dom-node-getrootnode\n\t * @see https://dom.spec.whatwg.org/#concept-shadow-including-root\n\t */\n\tgetRootNode: function (options) {\n\t\tvar parent = this;\n\t\tdo {\n\t\t\tif (!parent.parentNode) {\n\t\t\t\treturn parent;\n\t\t\t}\n\t\t\tparent = parent.parentNode;\n\t\t} while (parent);\n\t},\n\t/**\n\t * Checks whether the given node is equal to this node.\n\t *\n\t * @param {Node} [otherNode]\n\t * @see https://dom.spec.whatwg.org/#concept-node-equals\n\t */\n\tisEqualNode: function (otherNode) {\n\t\tif (!otherNode) return false;\n\n\t\tif (this.nodeType !== otherNode.nodeType) return false;\n\n\t\tswitch (this.nodeType) {\n\t\t\tcase this.DOCUMENT_TYPE_NODE:\n\t\t\t\tif (this.name !== otherNode.name) return false;\n\t\t\t\tif (this.publicId !== otherNode.publicId) return false;\n\t\t\t\tif (this.systemId !== otherNode.systemId) return false;\n\t\t\t\tbreak;\n\t\t\tcase this.ELEMENT_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.prefix !== otherNode.prefix) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.attributes.length !== otherNode.attributes.length) return false;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attr = this.attributes.item(i);\n\t\t\t\t\tif (!attr.isEqualNode(otherNode.getAttributeNodeNS(attr.namespaceURI, attr.localName))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.ATTRIBUTE_NODE:\n\t\t\t\tif (this.namespaceURI !== otherNode.namespaceURI) return false;\n\t\t\t\tif (this.localName !== otherNode.localName) return false;\n\t\t\t\tif (this.value !== otherNode.value) return false;\n\n\t\t\t\tbreak;\n\t\t\tcase this.PROCESSING_INSTRUCTION_NODE:\n\t\t\t\tif (this.target !== otherNode.target || this.data !== otherNode.data) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase this.TEXT_NODE:\n\t\t\tcase this.COMMENT_NODE:\n\t\t\t\tif (this.data !== otherNode.data) return false;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (this.childNodes.length !== otherNode.childNodes.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (var i = 0; i < this.childNodes.length; i++) {\n\t\t\tif (!this.childNodes[i].isEqualNode(otherNode.childNodes[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n\t/**\n\t * Checks whether or not the given node is this node.\n\t *\n\t * @param {Node} [otherNode]\n\t */\n\tisSameNode: function (otherNode) {\n\t\treturn this === otherNode;\n\t},\n\t/**\n\t * Inserts a node before a reference node as a child of this node.\n\t *\n\t * @param {Node} newChild\n\t * The new child node to be inserted.\n\t * @param {Node | null} refChild\n\t * The reference node before which newChild will be inserted.\n\t * @returns {Node}\n\t * The new child node successfully inserted.\n\t * @throws {DOMException}\n\t * Throws a DOMException if inserting the node would result in a DOM tree that is not\n\t * well-formed, or if `child` is provided but is not a child of `parent`.\n\t * See {@link _insertBefore} for more details.\n\t * @since Modified in DOM L2\n\t */\n\tinsertBefore: function (newChild, refChild) {\n\t\treturn _insertBefore(this, newChild, refChild);\n\t},\n\t/**\n\t * Replaces an old child node with a new child node within this node.\n\t *\n\t * @param {Node} newChild\n\t * The new node that is to replace the old node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @param {Node} oldChild\n\t * The existing child node to be replaced.\n\t * @returns {Node}\n\t * Returns the replaced child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if replacing the node would result in a DOM tree that is not\n\t * well-formed, or if `oldChild` is not a child of `this`.\n\t * This can also occur if the pre-replacement validity assertion fails.\n\t * See {@link _insertBefore}, {@link Node.removeChild}, and\n\t * {@link assertPreReplacementValidityInDocument} for more details.\n\t * @see https://dom.spec.whatwg.org/#concept-node-replace\n\t */\n\treplaceChild: function (newChild, oldChild) {\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\t/**\n\t * Removes an existing child node from this node.\n\t *\n\t * @param {Node} oldChild\n\t * The child node to be removed.\n\t * @returns {Node}\n\t * Returns the removed child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if `oldChild` is not a child of `this`.\n\t * See {@link _removeChild} for more details.\n\t */\n\tremoveChild: function (oldChild) {\n\t\treturn _removeChild(this, oldChild);\n\t},\n\t/**\n\t * Appends a child node to this node.\n\t *\n\t * @param {Node} newChild\n\t * The child node to be appended to this node.\n\t * If it already exists in the DOM, it is removed from its original position.\n\t * @returns {Node}\n\t * Returns the appended child node.\n\t * @throws {DOMException}\n\t * Throws a DOMException if appending the node would result in a DOM tree that is not\n\t * well-formed, or if `newChild` is not a valid Node.\n\t * See {@link insertBefore} for more details.\n\t */\n\tappendChild: function (newChild) {\n\t\treturn this.insertBefore(newChild, null);\n\t},\n\t/**\n\t * Determines whether this node has any child nodes.\n\t *\n\t * @returns {boolean}\n\t * Returns true if this node has any child nodes, and false otherwise.\n\t */\n\thasChildNodes: function () {\n\t\treturn this.firstChild != null;\n\t},\n\t/**\n\t * Creates a copy of the calling node.\n\t *\n\t * @param {boolean} deep\n\t * If true, the contents of the node are recursively copied.\n\t * If false, only the node itself (and its attributes, if it is an element) are copied.\n\t * @returns {Node}\n\t * Returns the newly created copy of the node.\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within {@link Element#setAttributeNode} or\n\t * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their\n\t * specific constraints.\n\t * @see {@link cloneNode}\n\t */\n\tcloneNode: function (deep) {\n\t\treturn cloneNode(this.ownerDocument || this, this, deep);\n\t},\n\t/**\n\t * Puts the specified node and all of its subtree into a \"normalized\" form. In a normalized\n\t * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.\n\t *\n\t * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`\n\t * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text\n\t * nodes.\n\t *\n\t * This method operates recursively, so it also normalizes any and all descendent nodes within\n\t * the subtree.\n\t *\n\t * @throws {DOMException}\n\t * May throw a DOMException if operations within removeChild or appendData (which are\n\t * potentially invoked in this method) do not meet their specific constraints.\n\t * @since Modified in DOM Level 2\n\t * @see {@link Node.removeChild}\n\t * @see {@link CharacterData.appendData}\n\t */\n\tnormalize: function () {\n\t\tvar child = this.firstChild;\n\t\twhile (child) {\n\t\t\tvar next = child.nextSibling;\n\t\t\tif (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t} else {\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n\t/**\n\t * Checks whether the DOM implementation implements a specific feature and its version.\n\t *\n\t * @deprecated\n\t * Since `DOMImplementation.hasFeature` is deprecated and always returns true.\n\t * @param {string} feature\n\t * The package name of the feature to test. This is the same name that can be passed to the\n\t * method `hasFeature` on `DOMImplementation`.\n\t * @param {string} version\n\t * This is the version number of the package name to test.\n\t * @returns {boolean}\n\t * Returns true in all cases in the current implementation.\n\t * @since Introduced in DOM Level 2\n\t * @see {@link DOMImplementation.hasFeature}\n\t */\n\tisSupported: function (feature, version) {\n\t\treturn this.ownerDocument.implementation.hasFeature(feature, version);\n\t},\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI for which to find the associated prefix.\n\t * @returns {string | null}\n\t * The associated prefix, if found; otherwise, null.\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t * @prettierignore\n\t */\n\tlookupPrefix: function (namespaceURI) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tfor (var n in map) {\n\t\t\t\t\tif (hasOwn(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * This function is used to look up the namespace URI associated with the given prefix,\n\t * starting from this node.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} prefix\n\t * The prefix for which to find the associated namespace URI.\n\t * @returns {string | null}\n\t * The associated namespace URI, if found; otherwise, null.\n\t * @since DOM Level 3\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI\n\t * @prettierignore\n\t */\n\tlookupNamespaceURI: function (prefix) {\n\t\tvar el = this;\n\t\twhile (el) {\n\t\t\tvar map = el._nsMap;\n\t\t\t//console.dir(map)\n\t\t\tif (map) {\n\t\t\t\tif (hasOwn(map, prefix)) {\n\t\t\t\t\treturn map[prefix];\n\t\t\t\t}\n\t\t\t}\n\t\t\tel = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;\n\t\t}\n\t\treturn null;\n\t},\n\t/**\n\t * Determines whether the given namespace URI is the default namespace.\n\t *\n\t * The function works by looking up the prefix associated with the given namespace URI. If no\n\t * prefix is found (i.e., the namespace URI is not registered in the namespace map of this\n\t * node or any of its ancestors), it returns `true`, implying the namespace URI is considered\n\t * the default.\n\t *\n\t * **This behavior is different from the in the specs**:\n\t * - no node type specific handling\n\t * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes\n\t *\n\t * @param {string | null} namespaceURI\n\t * The namespace URI to be checked.\n\t * @returns {boolean}\n\t * Returns true if the given namespace URI is the default namespace, false otherwise.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace\n\t * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace\n\t * @prettierignore\n\t */\n\tisDefaultNamespace: function (namespaceURI) {\n\t\tvar prefix = this.lookupPrefix(namespaceURI);\n\t\treturn prefix == null;\n\t},\n\t/**\n\t * Compares the reference node with a node with regard to their position in the document and\n\t * according to the document order.\n\t *\n\t * @param {Node} other\n\t * The node to compare the reference node to.\n\t * @returns {number}\n\t * Returns how the node is positioned relatively to the reference node according to the\n\t * bitmask. 0 if reference node and given node are the same.\n\t * @since DOM Level 3\n\t * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare\n\t * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition\n\t */\n\tcompareDocumentPosition: function (other) {\n\t\tif (this === other) return 0;\n\t\tvar node1 = other;\n\t\tvar node2 = this;\n\t\tvar attr1 = null;\n\t\tvar attr2 = null;\n\t\tif (node1 instanceof Attr) {\n\t\t\tattr1 = node1;\n\t\t\tnode1 = attr1.ownerElement;\n\t\t}\n\t\tif (node2 instanceof Attr) {\n\t\t\tattr2 = node2;\n\t\t\tnode2 = attr2.ownerElement;\n\t\t\tif (attr1 && node1 && node2 === node1) {\n\t\t\t\tfor (var i = 0, attr; (attr = node2.attributes[i]); i++) {\n\t\t\t\t\tif (attr === attr1)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t\t\tif (attr === attr2)\n\t\t\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {\n\t\t\treturn (\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_DISCONNECTED +\n\t\t\t\tDocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +\n\t\t\t\t(docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)\n\t\t\t\t\t? DocumentPosition.DOCUMENT_POSITION_FOLLOWING\n\t\t\t\t\t: DocumentPosition.DOCUMENT_POSITION_PRECEDING)\n\t\t\t);\n\t\t}\n\t\tif (attr2 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\tif (attr1 && node1 === node2) {\n\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t}\n\n\t\tvar chain1 = [];\n\t\tvar ancestor1 = node1.parentNode;\n\t\twhile (ancestor1) {\n\t\t\tif (!attr2 && ancestor1 === node2) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\t}\n\t\t\tchain1.push(ancestor1);\n\t\t\tancestor1 = ancestor1.parentNode;\n\t\t}\n\t\tchain1.reverse();\n\n\t\tvar chain2 = [];\n\t\tvar ancestor2 = node2.parentNode;\n\t\twhile (ancestor2) {\n\t\t\tif (!attr1 && ancestor2 === node1) {\n\t\t\t\treturn DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\t}\n\t\t\tchain2.push(ancestor2);\n\t\t\tancestor2 = ancestor2.parentNode;\n\t\t}\n\t\tchain2.reverse();\n\n\t\tvar ca = commonAncestor(chain1, chain2);\n\t\tfor (var n in ca.childNodes) {\n\t\t\tvar child = ca.childNodes[n];\n\t\t\tif (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t\tif (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;\n\t\t}\n\t\treturn 0;\n\t},\n};\n\n/**\n * Encodes special XML characters to their corresponding entities.\n *\n * @param {string} c\n * The character to be encoded.\n * @returns {string}\n * The encoded character.\n * @private\n */\nfunction _xmlEncoder(c) {\n\treturn (\n\t\t(c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '\"' && '"') || '&#' + c.charCodeAt() + ';'\n\t);\n}\n\ncopy(NodeType, Node);\ncopy(NodeType, Node.prototype);\ncopy(DocumentPosition, Node);\ncopy(DocumentPosition, Node.prototype);\n\n/**\n * @param callback\n * Return true for continue,false for break.\n * @returns\n * boolean true: break visit;\n */\nfunction _visitNode(node, callback) {\n\tif (callback(node)) {\n\t\treturn true;\n\t}\n\tif ((node = node.firstChild)) {\n\t\tdo {\n\t\t\tif (_visitNode(node, callback)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} while ((node = node.nextSibling));\n\t}\n}\n\n/**\n * @typedef DocumentOptions\n * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]\n */\n/**\n * The Document interface describes the common properties and methods for any kind of document.\n *\n * It should usually be created using `new DOMImplementation().createDocument(...)`\n * or `new DOMImplementation().createHTMLDocument(...)`.\n *\n * The constructor is considered a private API and offers to initially set the `contentType`\n * property via it's options parameter.\n *\n * @class\n * @param {Symbol} symbol\n * @param {DocumentOptions} [options]\n * @augments Node\n * @private\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document\n * @see https://dom.spec.whatwg.org/#interface-document\n */\nfunction Document(symbol, options) {\n\tcheckSymbol(symbol);\n\n\tvar opt = options || {};\n\tthis.ownerDocument = this;\n\t/**\n\t * The mime type of the document is determined at creation time and can not be modified.\n\t *\n\t * @type {string}\n\t * @see https://dom.spec.whatwg.org/#concept-document-content-type\n\t * @see {@link DOMImplementation}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;\n\t/**\n\t * @type {'html' | 'xml'}\n\t * @see https://dom.spec.whatwg.org/#concept-document-type\n\t * @see {@link DOMImplementation}\n\t * @readonly\n\t */\n\tthis.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';\n}\n\n/**\n * Updates the namespace mapping of an element when a new attribute is added.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element to which the attribute is being added.\n * @param {Attr} newAttr\n * The new attribute being added.\n * @private\n */\nfunction _onAddAttribute(doc, el, newAttr) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;\n\t}\n}\n\n/**\n * Updates the namespace mapping of an element when an attribute is removed.\n *\n * @param {Document} doc\n * The document that the element belongs to.\n * @param {Element} el\n * The element from which the attribute is being removed.\n * @param {Attr} newAttr\n * The attribute being removed.\n * @param {boolean} remove\n * Indicates whether the attribute is to be removed.\n * @private\n */\nfunction _onRemoveAttribute(doc, el, newAttr, remove) {\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI;\n\tif (ns === NAMESPACE.XMLNS) {\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix ? newAttr.localName : ''];\n\t}\n}\n\n/**\n * Updates `parent.childNodes`, adjusting the indexed items and its `length`.\n * If `newChild` is provided and has no nextSibling, it will be appended.\n * Otherwise, it's assumed that an item has been removed or inserted,\n * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.\n *\n * @param {Document} doc\n * The parent document of `el`.\n * @param {Node} parent\n * The parent node whose childNodes list needs to be updated.\n * @param {Node} [newChild]\n * The new child node to be appended. If not provided, the function assumes a node has been\n * removed.\n * @private\n */\nfunction _onUpdateChild(doc, parent, newChild) {\n\tif (doc && doc._inc) {\n\t\tdoc._inc++;\n\t\tvar childNodes = parent.childNodes;\n\t\t// assumes nextSibling and previousSibling were already configured upfront\n\t\tif (newChild && !newChild.nextSibling) {\n\t\t\t// if an item has been appended, we only need to update the last index and the length\n\t\t\tchildNodes[childNodes.length++] = newChild;\n\t\t} else {\n\t\t\t// otherwise we need to reindex all items,\n\t\t\t// which can take a while when processing nodes with a lot of children\n\t\t\tvar child = parent.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile (child) {\n\t\t\t\tchildNodes[i++] = child;\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\tchildNodes.length = i;\n\t\t\tdelete childNodes[childNodes.length];\n\t\t}\n\t}\n}\n\n/**\n * Removes the connections between `parentNode` and `child`\n * and any existing `child.previousSibling` or `child.nextSibling`.\n *\n * @param {Node} parentNode\n * The parent node from which the child node is to be removed.\n * @param {Node} child\n * The child node to be removed from the parentNode.\n * @returns {Node}\n * Returns the child node that was removed.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.\n * @private\n * @see https://github.com/xmldom/xmldom/issues/135\n * @see https://github.com/xmldom/xmldom/issues/145\n */\nfunction _removeChild(parentNode, child) {\n\tif (parentNode !== child.parentNode) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, \"child's parent is not parent\");\n\t}\n\tvar oldPreviousSibling = child.previousSibling;\n\tvar oldNextSibling = child.nextSibling;\n\tif (oldPreviousSibling) {\n\t\toldPreviousSibling.nextSibling = oldNextSibling;\n\t} else {\n\t\tparentNode.firstChild = oldNextSibling;\n\t}\n\tif (oldNextSibling) {\n\t\toldNextSibling.previousSibling = oldPreviousSibling;\n\t} else {\n\t\tparentNode.lastChild = oldPreviousSibling;\n\t}\n\t_onUpdateChild(parentNode.ownerDocument, parentNode);\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.CDATA_SECTION_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.DOCUMENT_TYPE_NODE ||\n\t\t\tnode.nodeType === Node.ELEMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||\n\t\t\tnode.nodeType === Node.TEXT_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node.\n *\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc\n * The document node.\n * @param {Node} child\n * The node that would become the nextSibling if the element would be inserted.\n * @returns {boolean}\n * `true` if an element can be inserted before child.\n * @private\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Asserts pre-insertion validity of a node into a parent before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Node} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | null} child\n * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,\n * DocumentFragment, or Element node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive\n * ancestor of `parent`. (Currently not implemented)\n * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not\n * `parent`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,\n * DocumentType, Element, or CharacterData node.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is\n * a document, or if `node` is a doctype and `parent` is not a document.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tDOMException.HIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * Asserts pre-insertion validity of a node into a document before a child.\n * Throws errors for invalid node combinations that would result in an ill-formed DOM.\n *\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * The node that should become the `nextSibling` of `node`. If undefined, no sibling is\n * considered.\n * @returns {Node}\n * @throws {DOMException}\n * With code:\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than\n * one element child or has a Text node child.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one\n * element child and either `parent` has an element child, `child` is a doctype, or `child` is\n * non-null and a doctype is following `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an\n * element child, `child` is a doctype, or `child` is non-null and a doctype is following\n * `child`.\n * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a\n * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null\n * and `parent` has an element child.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @param {Document} parent\n * The parent node to insert `node` into.\n * @param {Node} node\n * The node to insert.\n * @param {Node | undefined} child\n * the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws {DOMException}\n * For several node combinations that would create a DOM that is not well-formed.\n * @throws {DOMException}\n * If `child` is provided but is not a child of `parent`.\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * Inserts a node into a parent node before a child node.\n *\n * @param {Node} parent\n * The parent node to insert the node into.\n * @param {Node} node\n * The node to insert into the parent.\n * @param {Node | null} child\n * The node that should become the next sibling of the node.\n * If null, the function inserts the node at the end of the children of the parent node.\n * @param {Function} [_inDocumentAssertion]\n * An optional function to check pre-insertion validity if parent is a document node.\n * Defaults to {@link assertPreInsertionValidityInDocument}\n * @returns {Node}\n * Returns the inserted node.\n * @throws {DOMException}\n * Throws a DOMException if inserting the node would result in a DOM tree that is not\n * well-formed. See {@link assertPreInsertionValidity1to5},\n * {@link assertPreInsertionValidityInDocument}.\n * @throws {DOMException}\n * Throws a DOMException if child is provided but is not a child of the parent. See\n * {@link Node.removeChild}\n * @private\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif (cp) {\n\t\tcp.removeChild(node); //remove and update\n\t}\n\tif (node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t} else {\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\tif (pre) {\n\t\tpre.nextSibling = newFirst;\n\t} else {\n\t\tparent.firstChild = newFirst;\n\t}\n\tif (child == null) {\n\t\tparent.lastChild = newLast;\n\t} else {\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo {\n\t\tnewFirst.parentNode = parent;\n\t} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));\n\t_onUpdateChild(parent.ownerDocument || parent, parent, node);\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\n\treturn node;\n}\n\nDocument.prototype = {\n\t/**\n\t * The implementation that created this document.\n\t *\n\t * @type DOMImplementation\n\t * @readonly\n\t */\n\timplementation: null,\n\tnodeName: '#document',\n\tnodeType: DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @type DocumentType\n\t * @readonly\n\t */\n\tdoctype: null,\n\tdocumentElement: null,\n\t_inc: 1,\n\n\tinsertBefore: function (newChild, refChild) {\n\t\t//raises\n\t\tif (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child, refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild: function (oldChild) {\n\t\tvar removed = _removeChild(this, oldChild);\n\t\tif (removed === this.documentElement) {\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn removed;\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode: function (importedNode, deep) {\n\t\treturn importNode(this, importedNode, deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById: function (id) {\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement, function (node) {\n\t\t\tif (node.nodeType == ELEMENT_NODE) {\n\t\t\t\tif (node.getAttribute('id') == id) {\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * Creates a new `Element` that is owned by this `Document`.\n\t * In HTML Documents `localName` is the lower cased `tagName`,\n\t * otherwise no transformation is being applied.\n\t * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t * - There is no interface `HTMLElement`, it is always an `Element`.\n\t * - There is no support for a second argument to indicate using custom elements.\n\t *\n\t * @param {string} tagName\n\t * @returns {Element}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement\n\t * @see https://dom.spec.whatwg.org/#dom-document-createelement\n\t * @see https://dom.spec.whatwg.org/#concept-create-element\n\t */\n\tcreateElement: function (tagName) {\n\t\tvar node = new Element(PDC);\n\t\tnode.ownerDocument = this;\n\t\tif (this.type === 'html') {\n\t\t\ttagName = tagName.toLowerCase();\n\t\t}\n\t\tif (hasDefaultHTMLNamespace(this.contentType)) {\n\t\t\tnode.namespaceURI = NAMESPACE.HTML;\n\t\t}\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t/**\n\t * @returns {DocumentFragment}\n\t */\n\tcreateDocumentFragment: function () {\n\t\tvar node = new DocumentFragment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Text}\n\t */\n\tcreateTextNode: function (data) {\n\t\tvar node = new Text(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {Comment}\n\t */\n\tcreateComment: function (data) {\n\t\tvar node = new Comment(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} data\n\t * @returns {CDATASection}\n\t */\n\tcreateCDATASection: function (data) {\n\t\tvar node = new CDATASection(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.appendData(data);\n\t\treturn node;\n\t},\n\t/**\n\t * @param {string} target\n\t * @param {string} data\n\t * @returns {ProcessingInstruction}\n\t */\n\tcreateProcessingInstruction: function (target, data) {\n\t\tvar node = new ProcessingInstruction(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an `Attr` node that is owned by this document.\n\t * In HTML Documents `localName` is the lower cased `name`,\n\t * otherwise no transformation is being applied.\n\t *\n\t * __This implementation differs from the specification:__ - The provided name is not checked\n\t * against the `Name` production,\n\t * so no related error will be thrown.\n\t *\n\t * @param {string} name\n\t * @returns {Attr}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute\n\t * @see https://dom.spec.whatwg.org/#dom-document-createattribute\n\t */\n\tcreateAttribute: function (name) {\n\t\tif (!g.QName_exact.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this._createAttribute(name);\n\t},\n\t_createAttribute: function (name) {\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.name = name;\n\t\tnode.nodeName = name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\t/**\n\t * Creates an EntityReference object.\n\t * The current implementation does not fill the `childNodes` with those of the corresponding\n\t * `Entity`\n\t *\n\t * @deprecated\n\t * In DOM Level 4.\n\t * @param {string} name\n\t * The name of the entity to reference. No namespace well-formedness checks are performed.\n\t * @returns {EntityReference}\n\t * @throws {DOMException}\n\t * With code `INVALID_CHARACTER_ERR` when `name` is not valid.\n\t * @throws {DOMException}\n\t * with code `NOT_SUPPORTED_ERR` when the document is of type `html`\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE\n\t */\n\tcreateEntityReference: function (name) {\n\t\tif (!g.Name.test(name)) {\n\t\t\tthrow new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name \"' + name + '\"');\n\t\t}\n\t\tif (this.type === 'html') {\n\t\t\tthrow new DOMException('document is an html document', DOMExceptionName.NotSupportedError);\n\t\t}\n\n\t\tvar node = new EntityReference(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Element}\n\t */\n\tcreateElementNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Element(PDC);\n\t\tvar attrs = (node.attributes = new NamedNodeMap());\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\t/**\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @returns {Attr}\n\t */\n\tcreateAttributeNS: function (namespaceURI, qualifiedName) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar node = new Attr(PDC);\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.specified = true;\n\t\tnode.namespaceURI = validated[0];\n\t\tnode.prefix = validated[1];\n\t\tnode.localName = validated[2];\n\t\treturn node;\n\t},\n};\n_extends(Document, Node);\n\nfunction Element(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis._nsMap = Object.create(null);\n}\nElement.prototype = {\n\tnodeType: ELEMENT_NODE,\n\t/**\n\t * The attributes of this element.\n\t *\n\t * @type {NamedNodeMap | null}\n\t */\n\tattributes: null,\n\tgetQualifiedName: function () {\n\t\treturn this.prefix ? this.prefix + ':' + this.localName : this.localName;\n\t},\n\t_isInHTMLDocumentAndNamespace: function () {\n\t\treturn this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;\n\t},\n\t/**\n\t * Implementaton of Level2 Core function hasAttributes.\n\t *\n\t * @returns {boolean}\n\t * True if attribute list is not empty.\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs\n\t */\n\thasAttributes: function () {\n\t\treturn !!(this.attributes && this.attributes.length);\n\t},\n\thasAttribute: function (name) {\n\t\treturn !!this.getAttributeNode(name);\n\t},\n\t/**\n\t * Returns element’s first attribute whose qualified name is `name`, and `null`\n\t * if there is no such attribute.\n\t *\n\t * @param {string} name\n\t * @returns {string | null}\n\t */\n\tgetAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr ? attr.value : null;\n\t},\n\tgetAttributeNode: function (name) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\t/**\n\t * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.\n\t *\n\t * @param {string} name\n\t * @param {string} value\n\t */\n\tsetAttribute: function (name, value) {\n\t\tif (this._isInHTMLDocumentAndNamespace()) {\n\t\t\tname = name.toLowerCase();\n\t\t}\n\t\tvar attr = this.getAttributeNode(name);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument._createAttribute(name);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tremoveAttribute: function (name) {\n\t\tvar attr = this.getAttributeNode(name);\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\tsetAttributeNode: function (newAttr) {\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS: function (newAttr) {\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode: function (oldAttr) {\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS: function (namespaceURI, localName) {\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS: function (namespaceURI, localName) {\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName) != null;\n\t},\n\t/**\n\t * Returns element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName`,\n\t * or `null` if there is no such attribute.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} localName\n\t * @returns {string | null}\n\t */\n\tgetAttributeNS: function (namespaceURI, localName) {\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr ? attr.value : null;\n\t},\n\t/**\n\t * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is\n\t * `localName` to value.\n\t *\n\t * @param {string} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {string} value\n\t * @see https://dom.spec.whatwg.org/#dom-element-setattributens\n\t */\n\tsetAttributeNS: function (namespaceURI, qualifiedName, value) {\n\t\tvar validated = validateAndExtract(namespaceURI, qualifiedName);\n\t\tvar localName = validated[2];\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\tif (attr) {\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t} else {\n\t\t\tattr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\t\tattr.value = attr.nodeValue = '' + value;\n\t\t\tthis.setAttributeNode(attr);\n\t\t}\n\t},\n\tgetAttributeNodeNS: function (namespaceURI, localName) {\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classNames` is an empty string or only contains HTML white space\n\t * characters.\n\t *\n\t * Warning: This returns a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames\n\t * Is a string representing the class name(s) to match; multiple class names are separated by\n\t * (ASCII-)whitespace.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function (classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames);\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base, function (node) {\n\t\t\t\t\tif (node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class');\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames);\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t/**\n\t * Returns a LiveNodeList of elements with the given qualifiedName.\n\t * Searching for all descendants can be done by passing `*` as `qualifiedName`.\n\t *\n\t * All descendants of the specified element are searched, but not the element itself.\n\t * The returned list is live, which means it updates itself with the DOM tree automatically.\n\t * Therefore, there is no need to call `Element.getElementsByTagName()`\n\t * with the same element and arguments repeatedly if the DOM changes in between calls.\n\t *\n\t * When called on an HTML element in an HTML document,\n\t * `getElementsByTagName` lower-cases the argument before searching for it.\n\t * This is undesirable when trying to match camel-cased SVG elements (such as\n\t * ``) in an HTML document.\n\t * Instead, use `Element.getElementsByTagNameNS()`,\n\t * which preserves the capitalization of the tag name.\n\t *\n\t * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,\n\t * except that it only searches for elements that are descendants of the specified element.\n\t *\n\t * @param {string} qualifiedName\n\t * @returns {LiveNodeList}\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname\n\t */\n\tgetElementsByTagName: function (qualifiedName) {\n\t\tvar isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';\n\t\tvar lowerQualifiedName = qualifiedName.toLowerCase();\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (node === base || node.nodeType !== ELEMENT_NODE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (qualifiedName === '*') {\n\t\t\t\t\tls.push(node);\n\t\t\t\t} else {\n\t\t\t\t\tvar nodeQualifiedName = node.getQualifiedName();\n\t\t\t\t\tvar matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;\n\t\t\t\t\tif (nodeQualifiedName === matchingQName) {\n\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS: function (namespaceURI, localName) {\n\t\treturn new LiveNodeList(this, function (base) {\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base, function (node) {\n\t\t\t\tif (\n\t\t\t\t\tnode !== base &&\n\t\t\t\t\tnode.nodeType === ELEMENT_NODE &&\n\t\t\t\t\t(namespaceURI === '*' || node.namespaceURI === namespaceURI) &&\n\t\t\t\t\t(localName === '*' || node.localName == localName)\n\t\t\t\t) {\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n};\nDocument.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n_extends(Element, Node);\nfunction Attr(symbol) {\n\tcheckSymbol(symbol);\n\n\tthis.namespaceURI = null;\n\tthis.prefix = null;\n\tthis.ownerElement = null;\n}\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr, Node);\n\nfunction CharacterData(symbol) {\n\tcheckSymbol(symbol);\n}\nCharacterData.prototype = {\n\tdata: '',\n\tsubstringData: function (offset, count) {\n\t\treturn this.data.substring(offset, offset + count);\n\t},\n\tappendData: function (text) {\n\t\ttext = this.data + text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function (offset, text) {\n\t\tthis.replaceData(offset, 0, text);\n\t},\n\tdeleteData: function (offset, count) {\n\t\tthis.replaceData(offset, count, '');\n\t},\n\treplaceData: function (offset, count, text) {\n\t\tvar start = this.data.substring(0, offset);\n\t\tvar end = this.data.substring(offset + count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n};\n_extends(CharacterData, Node);\nfunction Text(symbol) {\n\tcheckSymbol(symbol);\n}\nText.prototype = {\n\tnodeName: '#text',\n\tnodeType: TEXT_NODE,\n\tsplitText: function (offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif (this.parentNode) {\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t},\n};\n_extends(Text, CharacterData);\nfunction Comment(symbol) {\n\tcheckSymbol(symbol);\n}\nComment.prototype = {\n\tnodeName: '#comment',\n\tnodeType: COMMENT_NODE,\n};\n_extends(Comment, CharacterData);\n\nfunction CDATASection(symbol) {\n\tcheckSymbol(symbol);\n}\nCDATASection.prototype = {\n\tnodeName: '#cdata-section',\n\tnodeType: CDATA_SECTION_NODE,\n};\n_extends(CDATASection, Text);\n\nfunction DocumentType(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType, Node);\n\nfunction Notation(symbol) {\n\tcheckSymbol(symbol);\n}\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation, Node);\n\nfunction Entity(symbol) {\n\tcheckSymbol(symbol);\n}\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity, Node);\n\nfunction EntityReference(symbol) {\n\tcheckSymbol(symbol);\n}\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference, Node);\n\nfunction DocumentFragment(symbol) {\n\tcheckSymbol(symbol);\n}\nDocumentFragment.prototype.nodeName = '#document-fragment';\nDocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment, Node);\n\nfunction ProcessingInstruction(symbol) {\n\tcheckSymbol(symbol);\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction, CharacterData);\nfunction XMLSerializer() {}\nXMLSerializer.prototype.serializeToString = function (node, nodeFilter) {\n\treturn nodeSerializeToString.call(node, nodeFilter);\n};\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(nodeFilter) {\n\tvar buf = [];\n\tvar refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif (uri && prefix == null) {\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif (prefix == null) {\n\t\t\tvar visibleNamespaces = [\n\t\t\t\t{ namespace: uri, prefix: null },\n\t\t\t\t//{namespace:uri,prefix:''}\n\t\t\t];\n\t\t}\n\t}\n\tserializeToString(this, buf, nodeFilter, visibleNamespaces);\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length;\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Literal whitespace other than space that appear in attribute values are serialized as\n * their entity references, so they will be preserved.\n * (In contrast to whitespace literals in the input which are normalized to spaces).\n *\n * Well-formed constraint: No < in Attribute Values:\n * > The replacement text of any entity referred to directly or indirectly\n * > in an attribute value must not contain a <.\n *\n * @see https://www.w3.org/TR/xml11/#CleanAttrVals\n * @see https://www.w3.org/TR/xml11/#NT-AttValue\n * @see https://www.w3.org/TR/xml11/#AVNormalize\n * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes\n * @prettierignore\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<>&\"\\t\\n\\r]/g, _xmlEncoder), '\"');\n}\n\nfunction serializeToString(node, buf, nodeFilter, visibleNamespaces) {\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\tvar doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;\n\tvar isHTML = doc.type === 'html';\n\n\tif (nodeFilter) {\n\t\tnode = nodeFilter(node);\n\t\tif (node) {\n\t\t\tif (typeof node == 'string') {\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tvar attrs = node.attributes;\n\t\t\tvar len = attrs.length;\n\t\t\tvar child = node.firstChild;\n\t\t\tvar nodeName = node.tagName;\n\n\t\t\tvar prefixedNodeName = nodeName;\n\t\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\t\tvar defaultNS;\n\t\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\t\tdefaultNS = attrs.item(ai).value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultNS) {\n\t\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tdefaultNS = namespace.namespace;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\t\tvar namespace = visibleNamespaces[nsi];\n\t\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuf.push('<', prefixedNodeName);\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\t// add namespaces for attributes\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (attr.prefix == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({\n\t\t\t\t\t\tprefix: attr.localName,\n\t\t\t\t\t\tnamespace: attr.value,\n\t\t\t\t\t});\n\t\t\t\t} else if (attr.nodeName == 'xmlns') {\n\t\t\t\t\tvisibleNamespaces.push({ prefix: '', namespace: attr.value });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < len; i++) {\n\t\t\t\tvar attr = attrs.item(i);\n\t\t\t\tif (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {\n\t\t\t\t\tvar prefix = attr.prefix || '';\n\t\t\t\t\tvar uri = attr.namespaceURI;\n\t\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t\t}\n\t\t\t\tserializeToString(attr, buf, nodeFilter, visibleNamespaces);\n\t\t\t}\n\n\t\t\t// add namespace for current node\n\t\t\tif (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {\n\t\t\t\tvar prefix = node.prefix || '';\n\t\t\t\tvar uri = node.namespaceURI;\n\t\t\t\taddSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri);\n\t\t\t\tvisibleNamespaces.push({ prefix: prefix, namespace: uri });\n\t\t\t}\n\t\t\t// in XML elements can be closed when they have no children\n\t\t\tvar canCloseTag = !child;\n\t\t\tif (canCloseTag && (isHTML || node.namespaceURI === NAMESPACE.HTML)) {\n\t\t\t\t// in HTML (doc or ns) only void elements can be closed right away\n\t\t\t\tcanCloseTag = isHTMLVoidElement(nodeName);\n\t\t\t}\n\t\t\tif (canCloseTag) {\n\t\t\t\tbuf.push('/>');\n\t\t\t} else {\n\t\t\t\tbuf.push('>');\n\t\t\t\t//if is cdata child node\n\t\t\t\tif (isHTML && isHTMLRawTextElement(nodeName)) {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tif (child.data) {\n\t\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twhile (child) {\n\t\t\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuf.push('');\n\t\t\t}\n\t\t\t// remove added visible namespaces\n\t\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\t\treturn;\n\t\tcase DOCUMENT_NODE:\n\t\tcase DOCUMENT_FRAGMENT_NODE:\n\t\t\tvar child = node.firstChild;\n\t\t\twhile (child) {\n\t\t\t\tserializeToString(child, buf, nodeFilter, visibleNamespaces.slice());\n\t\t\t\tchild = child.nextSibling;\n\t\t\t}\n\t\t\treturn;\n\t\tcase ATTRIBUTE_NODE:\n\t\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\t\tcase TEXT_NODE:\n\t\t\t/*\n\t\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t\t * except when used as markup delimiters, or within a comment, a processing instruction,\n\t\t\t * or a CDATA section.\n\t\t\t * If they are needed elsewhere, they must be escaped using either numeric character\n\t\t\t * references or the strings `&` and `<` respectively.\n\t\t\t * The right angle bracket (>) may be represented using the string \" > \",\n\t\t\t * and must, for compatibility, be escaped using either `>`,\n\t\t\t * or a character reference when it appears in the string `]]>` in content,\n\t\t\t * when that string is not marking the end of a CDATA section.\n\t\t\t *\n\t\t\t * In the content of elements, character data is any string of characters which does not\n\t\t\t * contain the start-delimiter of any markup and does not include the CDATA-section-close\n\t\t\t * delimiter, `]]>`.\n\t\t\t *\n\t\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t\t * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node\n\t\t\t */\n\t\t\treturn buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));\n\t\tcase CDATA_SECTION_NODE:\n\t\t\treturn buf.push(g.CDATA_START, node.data, g.CDATA_END);\n\t\tcase COMMENT_NODE:\n\t\t\treturn buf.push(g.COMMENT_START, node.data, g.COMMENT_END);\n\t\tcase DOCUMENT_TYPE_NODE:\n\t\t\tvar pubid = node.publicId;\n\t\t\tvar sysid = node.systemId;\n\t\t\tbuf.push(g.DOCTYPE_DECL_START, ' ', node.name);\n\t\t\tif (pubid) {\n\t\t\t\tbuf.push(' ', g.PUBLIC, ' ', pubid);\n\t\t\t\tif (sysid && sysid !== '.') {\n\t\t\t\t\tbuf.push(' ', sysid);\n\t\t\t\t}\n\t\t\t} else if (sysid && sysid !== '.') {\n\t\t\t\tbuf.push(' ', g.SYSTEM, ' ', sysid);\n\t\t\t}\n\t\t\tif (node.internalSubset) {\n\t\t\t\tbuf.push(' [', node.internalSubset, ']');\n\t\t\t}\n\t\t\tbuf.push('>');\n\t\t\treturn;\n\t\tcase PROCESSING_INSTRUCTION_NODE:\n\t\t\treturn buf.push('');\n\t\tcase ENTITY_REFERENCE_NODE:\n\t\t\treturn buf.push('&', node.nodeName, ';');\n\t\t//case ENTITY_NODE:\n\t\t//case NOTATION_NODE:\n\t\tdefault:\n\t\t\tbuf.push('??', node.nodeName);\n\t}\n}\nfunction importNode(doc, node, deep) {\n\tvar node2;\n\tswitch (node.nodeType) {\n\t\tcase ELEMENT_NODE:\n\t\t\tnode2 = node.cloneNode(false);\n\t\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see {@link XML_ENTITIES}\n * @see {@link DOMParser.parseFromString}\n * @see {@link DOMImplementation.prototype.createHTMLDocument}\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)\n * Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML\n * Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML\n * Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated\n * Use `HTML_ENTITIES` instead.\n * @see {@link HTML_ENTITIES}\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar g = require('./grammar');\nvar errors = require('./errors');\n\nvar isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isHTMLRawTextElement = conventions.isHTMLRawTextElement;\nvar hasOwn = conventions.hasOwn;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\nvar DOMException = errors.DOMException;\n\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0; //tag name offerring\nvar S_ATTR = 1; //attr name offerring\nvar S_ATTR_SPACE = 2; //attr name end and space offer\nvar S_EQ = 3; //=space?\nvar S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)\nvar S_ATTR_END = 5; //attr value end and no space(quot end)\nvar S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7; //closed el\n\nfunction XMLReader() {}\n\nXMLReader.prototype = {\n\tparse: function (source, defaultNSMap, entityMap) {\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap, (defaultNSMap = Object.create(null)));\n\t\tparse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t},\n};\n\n/**\n * Detecting everything that might be a reference,\n * including those without ending `;`, since those are allowed in HTML.\n * The entityReplacer takes care of verifying and transforming each occurrence,\n * and reports to the errorHandler on those that are not OK,\n * depending on the context.\n */\nvar ENTITY_REG = /&#?\\w+;?/g;\n\nfunction parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {\n\tvar isHTML = isHTMLMimeType(domBuilder.mimeType);\n\tif (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {\n\t\terrorHandler.warning('Unicode replacement character detected, source encoding issues?');\n\t}\n\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10),\n\t\t\t\tsurrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\n\tfunction entityReplacer(a) {\n\t\tvar complete = a[a.length - 1] === ';' ? a : a + ';';\n\t\tif (!isHTML && complete !== a) {\n\t\t\terrorHandler.error('EntityRef: expecting ;');\n\t\t\treturn a;\n\t\t}\n\t\tvar match = g.Reference.exec(complete);\n\t\tif (!match || match[0].length !== complete.length) {\n\t\t\terrorHandler.error('entity not matching Reference production: ' + a);\n\t\t\treturn a;\n\t\t}\n\t\tvar k = complete.slice(1, -1);\n\t\tif (hasOwn(entityMap, k)) {\n\t\t\treturn entityMap[k];\n\t\t} else if (k.charAt(0) === '#') {\n\t\t\treturn fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));\n\t\t} else {\n\t\t\terrorHandler.error('entity not found:' + a);\n\t\t\treturn a;\n\t\t}\n\t}\n\n\tfunction appendText(end) {\n\t\t//has some bugs\n\t\tif (end > start) {\n\t\t\tvar xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);\n\t\t\tlocator && position(start);\n\t\t\tdomBuilder.characters(xt, 0, end - start);\n\t\t\tstart = end;\n\t\t}\n\t}\n\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /\\r\\n?|\\n|$/g;\n\tvar locator = domBuilder.locator;\n\n\tfunction position(p, m) {\n\t\twhile (p >= lineEnd && (m = linePattern.exec(source))) {\n\t\t\tlineStart = lineEnd;\n\t\t\tlineEnd = m.index + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t}\n\t\tlocator.columnNumber = p - lineStart + 1;\n\t}\n\n\tvar parseStack = [{ currentNSMap: defaultNSMapCopy }];\n\tvar unclosedTags = [];\n\tvar start = 0;\n\twhile (true) {\n\t\ttry {\n\t\t\tvar tagStart = source.indexOf('<', start);\n\t\t\tif (tagStart < 0) {\n\t\t\t\tif (!isHTML && unclosedTags.length > 0) {\n\t\t\t\t\treturn errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));\n\t\t\t\t}\n\t\t\t\tif (!source.substring(start).match(/^\\s*$/)) {\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t\t\t\t\tvar text = doc.createTextNode(source.substring(start));\n\t\t\t\t\tif (doc.documentElement) {\n\t\t\t\t\t\treturn errorHandler.error('Extra content at the end of the document');\n\t\t\t\t\t}\n\t\t\t\t\tdoc.appendChild(text);\n\t\t\t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (tagStart > start) {\n\t\t\t\tvar fromSource = source.substring(start, tagStart);\n\t\t\t\tif (!isHTML && unclosedTags.length === 0) {\n\t\t\t\t\tfromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');\n\t\t\t\t\tfromSource && errorHandler.error(\"Unexpected content outside root element: '\" + fromSource + \"'\");\n\t\t\t\t}\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch (source.charAt(tagStart + 1)) {\n\t\t\t\tcase '/':\n\t\t\t\t\tvar end = source.indexOf('>', tagStart + 2);\n\t\t\t\t\tvar tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);\n\t\t\t\t\tif (!tagNameRaw) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name missing');\n\t\t\t\t\t}\n\t\t\t\t\tvar tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);\n\t\t\t\t\tif (!tagNameMatch) {\n\t\t\t\t\t\treturn errorHandler.fatalError('end tag name contains invalid characters: \"' + tagNameRaw + '\"');\n\t\t\t\t\t}\n\t\t\t\t\tif (!domBuilder.currentElement && !domBuilder.doc.documentElement) {\n\t\t\t\t\t\t// not enough information to provide a helpful error message,\n\t\t\t\t\t\t// but parsing will throw since there is no root element\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar currentTagName =\n\t\t\t\t\t\tunclosedTags[unclosedTags.length - 1] ||\n\t\t\t\t\t\tdomBuilder.currentElement.tagName ||\n\t\t\t\t\t\tdomBuilder.doc.documentElement.tagName ||\n\t\t\t\t\t\t'';\n\t\t\t\t\tif (currentTagName !== tagNameMatch[1]) {\n\t\t\t\t\t\tvar tagNameLower = tagNameMatch[1].toLowerCase();\n\t\t\t\t\t\tif (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('Opening and ending tag mismatch: \"' + currentTagName + '\" != \"' + tagNameRaw + '\"');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvar config = parseStack.pop();\n\t\t\t\t\tunclosedTags.pop();\n\t\t\t\t\tvar localNSMap = config.localNSMap;\n\t\t\t\t\tdomBuilder.endElement(config.uri, config.localName, currentTagName);\n\t\t\t\t\tif (localNSMap) {\n\t\t\t\t\t\tfor (var prefix in localNSMap) {\n\t\t\t\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tend++;\n\t\t\t\t\tbreak;\n\t\t\t\t// end element\n\t\t\t\tcase '?': // \n\t\t\t\t\tlocator && position(tagStart);\n\t\t\t\t\tend = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);\n\t\t\t\t\tbreak;\n\t\t\t\tcase '!': // start) {\n\t\t\tstart = end;\n\t\t} else {\n\t\t\t//Possible sax fallback here, risk of positional error\n\t\t\tappendText(Math.max(tagStart, start) + 1);\n\t\t}\n\t}\n}\n\nfunction copyLocator(f, t) {\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @returns\n * end of the elementStartPart(end of elementEndPart for selfClosed el)\n * @see {@link #appendElement}\n */\nfunction parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (hasOwn(el.attributeNames, qname)) {\n\t\t\treturn errorHandler.fatalError('Attribute ' + qname + ' redefined');\n\t\t}\n\t\tif (!isHTML && value.indexOf('<') >= 0) {\n\t\t\treturn errorHandler.fatalError(\"Unescaped '<' not allowed in attributes values\");\n\t\t}\n\t\tel.addValue(\n\t\t\tqname,\n\t\t\t// @see https://www.w3.org/TR/xml/#AVNormalize\n\t\t\t// since the xmldom sax parser does not \"interpret\" DTD the following is not implemented:\n\t\t\t// - recursive replacement of (DTD) entity references\n\t\t\t// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA\n\t\t\tvalue.replace(/[\\t\\n\\r]/g, ' ').replace(ENTITY_REG, entityReplacer),\n\t\t\tstartIndex\n\t\t);\n\t}\n\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG; //status\n\twhile (true) {\n\t\tvar c = source.charAt(p);\n\t\tswitch (c) {\n\t\t\tcase '=':\n\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t//attrName\n\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else if (s === S_ATTR_SPACE) {\n\t\t\t\t\ts = S_EQ;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"'\":\n\t\t\tcase '\"':\n\t\t\t\tif (\n\t\t\t\t\ts === S_EQ ||\n\t\t\t\t\ts === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t) {\n\t\t\t\t\t//equal\n\t\t\t\t\tif (s === S_ATTR) {\n\t\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"');\n\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t}\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\tp = source.indexOf(c, start);\n\t\t\t\t\tif (p > 0) {\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\taddAttribute(attrName, value, start - 1);\n\t\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\t\tthrow new Error(\"attribute value no end '\" + c + \"' match\");\n\t\t\t\t\t}\n\t\t\t\t} else if (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed start quot(' + c + ')!!');\n\t\t\t\t\tstart = p + 1;\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t} else {\n\t\t\t\t\t//fatalError: no equal before\n\t\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '/':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\ts = S_TAG_CLOSE;\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t//case S_EQ:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(\"attribute invalid close char('/')\"); // No known test case\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase '': //end document\n\t\t\t\terrorHandler.error('unexpected end of input');\n\t\t\t\tif (s == S_TAG) {\n\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\tcase '>':\n\t\t\t\tswitch (s) {\n\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\tel.setTagName(source.slice(start, p));\n\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\tbreak; //normal\n\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE: //Compatible state\n\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\tvalue = source.slice(start, p);\n\t\t\t\t\t\tif (value.slice(-1) === '/') {\n\t\t\t\t\t\t\tel.closed = true;\n\t\t\t\t\t\t\tvalue = value.slice(0, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\tif (s === S_ATTR_SPACE) {\n\t\t\t\t\t\t\tvalue = attrName;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (s == S_ATTR_NOQUOT_VALUE) {\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed value!! \"' + value + '\" instead!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(value, value, start);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\treturn errorHandler.fatalError('AttValue: \\' or \" expected');\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn p;\n\t\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\t\tcase '\\u0080':\n\t\t\t\tc = ' ';\n\t\t\tdefault:\n\t\t\t\tif (c <= ' ') {\n\t\t\t\t\t//space\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\tcase S_TAG:\n\t\t\t\t\t\t\tel.setTagName(source.slice(start, p)); //tagName\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR:\n\t\t\t\t\t\t\tattrName = source.slice(start, p);\n\t\t\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\t\t\tvar value = source.slice(start, p);\n\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + value + '\" missed quot(\")!!');\n\t\t\t\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t\t\t//case S_EQ:\n\t\t\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t\t\t//\tvoid();break;\n\t\t\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t\t//ignore warning\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//not space\n\t\t\t\t\t//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n\t\t\t\t\t//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\t\tswitch (s) {\n\t\t\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\t\t\tif (!isHTML) {\n\t\t\t\t\t\t\t\terrorHandler.warning('attribute \"' + attrName + '\" missed value!! \"' + attrName + '\" instead2!!');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\t\t\terrorHandler.warning('attribute space is required\"' + attrName + '\"!!');\n\t\t\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_EQ:\n\t\t\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\t\t\tstart = p;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t} //end outer switch\n\t\tp++;\n\t}\n}\n\n/**\n * @returns\n * `true` if a new namespace has been defined.\n */\nfunction appendElement(el, domBuilder, currentNSMap) {\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\tvar i = el.length;\n\twhile (i--) {\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif (nsp > 0) {\n\t\t\tvar prefix = (a.prefix = qName.slice(0, nsp));\n\t\t\tvar localName = qName.slice(nsp + 1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName;\n\t\t} else {\n\t\t\tlocalName = qName;\n\t\t\tprefix = null;\n\t\t\tnsPrefix = qName === 'xmlns' && '';\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif (nsPrefix !== false) {\n\t\t\t//hack!!\n\t\t\tif (localNSMap == null) {\n\t\t\t\tlocalNSMap = Object.create(null);\n\t\t\t\t_copy(currentNSMap, (currentNSMap = Object.create(null)));\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS;\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value);\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile (i--) {\n\t\ta = el[i];\n\t\tif (a.prefix) {\n\t\t\t//no prefix attribute has no namespace\n\t\t\tif (a.prefix === 'xml') {\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}\n\t\t\tif (a.prefix !== 'xmlns') {\n\t\t\t\ta.uri = currentNSMap[a.prefix];\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif (nsp > 0) {\n\t\tprefix = el.prefix = tagName.slice(0, nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp + 1);\n\t} else {\n\t\tprefix = null; //important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = (el.uri = currentNSMap[prefix || '']);\n\tdomBuilder.startElement(ns, localName, tagName, el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif (el.closed) {\n\t\tdomBuilder.endElement(ns, localName, tagName);\n\t\tif (localNSMap) {\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (hasOwn(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\n\nfunction parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {\n\t// https://html.spec.whatwg.org/#raw-text-elements\n\t// https://html.spec.whatwg.org/#escapable-raw-text-elements\n\t// https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements\n\t// TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions\n\tvar isEscapableRaw = isHTMLEscapableRawTextElement(tagName);\n\tif (isEscapableRaw || isHTMLRawTextElement(tagName)) {\n\t\tvar elEndStart = source.indexOf('', elStartEnd);\n\t\tvar text = source.substring(elStartEnd + 1, elEndStart);\n\n\t\tif (isEscapableRaw) {\n\t\t\ttext = text.replace(ENTITY_REG, entityReplacer);\n\t\t}\n\t\tdomBuilder.characters(text, 0, text.length);\n\t\treturn elEndStart;\n\t}\n\treturn elStartEnd + 1;\n}\n\nfunction _copy(source, target) {\n\tfor (var n in source) {\n\t\tif (hasOwn(source, n)) {\n\t\t\ttarget[n] = source[n];\n\t\t}\n\t}\n}\n\n/**\n * @typedef ParseUtils\n * @property {function(relativeIndex: number?): string | undefined} char\n * Provides look ahead access to a singe character relative to the current index.\n * @property {function(): number} getIndex\n * Provides read-only access to the current index.\n * @property {function(reg: RegExp): string | null} getMatch\n * Applies the provided regular expression enforcing that it starts at the current index and\n * returns the complete matching string,\n * and moves the current index by the length of the matching string.\n * @property {function(): string} getSource\n * Provides read-only access to the complete source.\n * @property {function(places: number?): void} skip\n * moves the current index by places (defaults to 1)\n * @property {function(): number} skipBlanks\n * Moves the current index by the amount of white space that directly follows the current index\n * and returns the amount of whitespace chars skipped (0..n),\n * or -1 if the end of the source was reached.\n * @property {function(): string} substringFromIndex\n * creates a substring from the current index to the end of `source`\n * @property {function(compareWith: string): boolean} substringStartsWith\n * Checks if `source` contains `compareWith`, starting from the current index.\n * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive\n * Checks if `source` contains `compareWith`, starting from the current index,\n * comparing the upper case of both sides.\n * @see {@link parseUtils}\n */\n\n/**\n * A temporary scope for parsing and look ahead operations in `source`,\n * starting from index `start`.\n *\n * Some operations move the current index by a number of positions,\n * after which `getIndex` returns the new index.\n *\n * @param {string} source\n * @param {number} start\n * @returns {ParseUtils}\n */\nfunction parseUtils(source, start) {\n\tvar index = start;\n\n\tfunction char(n) {\n\t\tn = n || 0;\n\t\treturn source.charAt(index + n);\n\t}\n\n\tfunction skip(n) {\n\t\tn = n || 1;\n\t\tindex += n;\n\t}\n\n\tfunction skipBlanks() {\n\t\tvar blanks = 0;\n\t\twhile (index < source.length) {\n\t\t\tvar c = char();\n\t\t\tif (c !== ' ' && c !== '\\n' && c !== '\\t' && c !== '\\r') {\n\t\t\t\treturn blanks;\n\t\t\t}\n\t\t\tblanks++;\n\t\t\tskip();\n\t\t}\n\t\treturn -1;\n\t}\n\tfunction substringFromIndex() {\n\t\treturn source.substring(index);\n\t}\n\tfunction substringStartsWith(text) {\n\t\treturn source.substring(index, index + text.length) === text;\n\t}\n\tfunction substringStartsWithCaseInsensitive(text) {\n\t\treturn source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();\n\t}\n\n\tfunction getMatch(args) {\n\t\tvar expr = g.reg('^', args);\n\t\tvar match = expr.exec(substringFromIndex());\n\t\tif (match) {\n\t\t\tskip(match[0].length);\n\t\t\treturn match[0];\n\t\t}\n\t\treturn null;\n\t}\n\treturn {\n\t\tchar: char,\n\t\tgetIndex: function () {\n\t\t\treturn index;\n\t\t},\n\t\tgetMatch: getMatch,\n\t\tgetSource: function () {\n\t\t\treturn source;\n\t\t},\n\t\tskip: skip,\n\t\tskipBlanks: skipBlanks,\n\t\tsubstringFromIndex: substringFromIndex,\n\t\tsubstringStartsWith: substringStartsWith,\n\t\tsubstringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,\n\t};\n}\n\n/**\n * @param {ParseUtils} p\n * @param {DOMHandler} errorHandler\n * @returns {string}\n */\nfunction parseDoctypeInternalSubset(p, errorHandler) {\n\t/**\n\t * @param {ParseUtils} p\n\t * @param {DOMHandler} errorHandler\n\t * @returns {string}\n\t */\n\tfunction parsePI(p, errorHandler) {\n\t\tvar match = g.PI.exec(p.substringFromIndex());\n\t\tif (!match) {\n\t\t\treturn errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());\n\t\t}\n\t\tif (match[1].toLowerCase() === 'xml') {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()\n\t\t\t);\n\t\t}\n\t\tp.skip(match[0].length);\n\t\treturn match[0];\n\t}\n\t// Parse internal subset\n\tvar source = p.getSource();\n\tif (p.char() === '[') {\n\t\tp.skip(1);\n\t\tvar intSubsetStart = p.getIndex();\n\t\twhile (p.getIndex() < source.length) {\n\t\t\tp.skipBlanks();\n\t\t\tif (p.char() === ']') {\n\t\t\t\tvar internalSubset = source.substring(intSubsetStart, p.getIndex());\n\t\t\t\tp.skip(1);\n\t\t\t\treturn internalSubset;\n\t\t\t}\n\t\t\tvar current = null;\n\t\t\t// Only in external subset\n\t\t\t// if (char() === '<' && char(1) === '!' && char(2) === '[') {\n\t\t\t// \tparseConditionalSections(p, errorHandler);\n\t\t\t// } else\n\t\t\tif (p.char() === '<' && p.char(1) === '!') {\n\t\t\t\tswitch (p.char(2)) {\n\t\t\t\t\tcase 'E': // ELEMENT | ENTITY\n\t\t\t\t\t\tif (p.char(3) === 'L') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.elementdecl);\n\t\t\t\t\t\t} else if (p.char(3) === 'N') {\n\t\t\t\t\t\t\tcurrent = p.getMatch(g.EntityDecl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'A': // ATTRIBUTE\n\t\t\t\t\t\tcurrent = p.getMatch(g.AttlistDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'N': // NOTATION\n\t\t\t\t\t\tcurrent = p.getMatch(g.NotationDecl);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '-': // COMMENT\n\t\t\t\t\t\tcurrent = p.getMatch(g.Comment);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (p.char() === '<' && p.char(1) === '?') {\n\t\t\t\tcurrent = parsePI(p, errorHandler);\n\t\t\t} else if (p.char() === '%') {\n\t\t\t\tcurrent = p.getMatch(g.PEReference);\n\t\t\t} else {\n\t\t\t\treturn errorHandler.fatalError('Error detected in Markup declaration');\n\t\t\t}\n\t\t\tif (!current) {\n\t\t\t\treturn errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());\n\t\t\t}\n\t\t}\n\t\treturn errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');\n\t}\n}\n\n/**\n * Called when the parser encounters an element starting with '') {\n\t\t\t\treturn errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());\n\t\t\t}\n\t\t\tp.skip(1);\n\t\t\tdomBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);\n\t\t\tdomBuilder.endDTD();\n\t\t\treturn p.getIndex();\n\t\t}\n\t\tdefault:\n\t\t\treturn errorHandler.fatalError('Not well-formed XML starting with \" 0) {\n\t\t\treturn errorHandler.fatalError(\n\t\t\t\t'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'\n\t\t\t);\n\t\t}\n\t\tif (!g.XMLDecl.test(source.substring(start))) {\n\t\t\treturn errorHandler.fatalError('xml declaration is not well-formed');\n\t\t}\n\t}\n\tdomBuilder.processingInstruction(match[1], match[2]);\n\treturn start + match[0].length;\n}\n\nfunction ElementAttributes() {\n\tthis.attributeNames = Object.create(null);\n}\n\nElementAttributes.prototype = {\n\tsetTagName: function (tagName) {\n\t\tif (!g.QName_exact.test(tagName)) {\n\t\t\tthrow new Error('invalid tagName:' + tagName);\n\t\t}\n\t\tthis.tagName = tagName;\n\t},\n\taddValue: function (qName, value, offset) {\n\t\tif (!g.QName_exact.test(qName)) {\n\t\t\tthrow new Error('invalid attribute:' + qName);\n\t\t}\n\t\tthis.attributeNames[qName] = this.length;\n\t\tthis[this.length++] = { qName: qName, value: value, offset: offset };\n\t},\n\tlength: 0,\n\tgetLocalName: function (i) {\n\t\treturn this[i].localName;\n\t},\n\tgetLocator: function (i) {\n\t\treturn this[i].locator;\n\t},\n\tgetQName: function (i) {\n\t\treturn this[i].qName;\n\t},\n\tgetURI: function (i) {\n\t\treturn this[i].uri;\n\t},\n\tgetValue: function (i) {\n\t\treturn this[i].value;\n\t},\n\t//\t,getIndex:function(uri, localName)){\n\t//\t\tif(localName){\n\t//\n\t//\t\t}else{\n\t//\t\t\tvar qName = uri\n\t//\t\t}\n\t//\t},\n\t//\tgetValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},\n\t//\tgetType:function(uri,localName){}\n\t//\tgetType:function(i){},\n};\n\nexports.XMLReader = XMLReader;\nexports.parseUtils = parseUtils;\nexports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;\n","'use strict';\n\nvar conventions = require('./conventions');\nvar dom = require('./dom');\nvar errors = require('./errors');\nvar entities = require('./entities');\nvar sax = require('./sax');\n\nvar DOMImplementation = dom.DOMImplementation;\n\nvar hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nvar isHTMLMimeType = conventions.isHTMLMimeType;\nvar isValidMimeType = conventions.isValidMimeType;\nvar MIME_TYPE = conventions.MIME_TYPE;\nvar NAMESPACE = conventions.NAMESPACE;\nvar ParseError = errors.ParseError;\n\nvar XMLReader = sax.XMLReader;\n\n/**\n * Normalizes line ending according to ,\n * including some Unicode \"newline\" characters:\n *\n * > XML parsed entities are often stored in computer files which,\n * > for editing convenience, are organized into lines.\n * > These lines are typically separated by some combination\n * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).\n * >\n * > To simplify the tasks of applications, the XML processor must behave\n * > as if it normalized all line breaks in external parsed entities (including the document entity)\n * > on input, before parsing, by translating the following to a single #xA character:\n * >\n * > 1. the two-character sequence #xD #xA,\n * > 2. the two-character sequence #xD #x85,\n * > 3. the single character #x85,\n * > 4. the single character #x2028,\n * > 5. the single character #x2029,\n * > 6. any #xD character that is not immediately followed by #xA or #x85.\n *\n * @param {string} input\n * @returns {string}\n * @prettierignore\n */\nfunction normalizeLineEndings(input) {\n\treturn input.replace(/\\r[\\n\\u0085]/g, '\\n').replace(/[\\r\\u0085\\u2028\\u2029]/g, '\\n');\n}\n\n/**\n * @typedef Locator\n * @property {number} [columnNumber]\n * @property {number} [lineNumber]\n */\n\n/**\n * @typedef DOMParserOptions\n * @property {typeof assign} [assign]\n * The method to use instead of `conventions.assign`, which is used to copy values from\n * `options` before they are used for parsing.\n * @property {typeof DOMHandler} [domHandler]\n * For internal testing: The class for creating an instance for handling events from the SAX\n * parser.\n * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n * be broken.*****.\n * @property {Function} [errorHandler]\n * DEPRECATED! use `onError` instead.\n * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n * [onError]\n * A function invoked for every error that occurs during parsing.\n *\n * If it is not provided, all errors are reported to `console.error`\n * and only `fatalError`s are thrown as a `ParseError`,\n * which prevents any further processing.\n * If the provided method throws, a `ParserError` is thrown,\n * which prevents any further processing.\n *\n * Be aware that many `warning`s are considered an error that prevents further processing in\n * most implementations.\n * @property {boolean} [locator=true]\n * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`\n * attribute describing their location in the XML string.\n * Default is true.\n * @property {(string) => string} [normalizeLineEndings]\n * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,\n * which normalizes line endings according to ,\n * including some Unicode \"newline\" characters.\n * @property {Object} [xmlns]\n * The XML namespaces that should be assumed when parsing.\n * The default namespace can be provided by the key that is the empty string.\n * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n * the default namespace that will be used,\n * will be overridden according to the specification.\n * @see {@link normalizeLineEndings}\n */\n\n/**\n * The DOMParser interface provides the ability to parse XML or HTML source code from a string\n * into a DOM `Document`.\n *\n * ***xmldom is different from the spec in that it allows an `options` parameter,\n * to control the behavior***.\n *\n * @class\n * @param {DOMParserOptions} [options]\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization\n */\nfunction DOMParser(options) {\n\toptions = options || {};\n\tif (options.locator === undefined) {\n\t\toptions.locator = true;\n\t}\n\n\t/**\n\t * The method to use instead of `conventions.assign`, which is used to copy values from\n\t * `options`\n\t * before they are used for parsing.\n\t *\n\t * @type {conventions.assign}\n\t * @private\n\t * @see {@link conventions.assign}\n\t * @readonly\n\t */\n\tthis.assign = options.assign || conventions.assign;\n\n\t/**\n\t * For internal testing: The class for creating an instance for handling events from the SAX\n\t * parser.\n\t * *****Warning: By configuring a faulty implementation, the specified behavior can completely\n\t * be broken*****.\n\t *\n\t * @type {typeof DOMHandler}\n\t * @private\n\t * @readonly\n\t */\n\tthis.domHandler = options.domHandler || DOMHandler;\n\n\t/**\n\t * A function that is invoked for every error that occurs during parsing.\n\t *\n\t * If it is not provided, all errors are reported to `console.error`\n\t * and only `fatalError`s are thrown as a `ParseError`,\n\t * which prevents any further processing.\n\t * If the provided method throws, a `ParserError` is thrown,\n\t * which prevents any further processing.\n\t *\n\t * Be aware that many `warning`s are considered an error that prevents further processing in\n\t * most implementations.\n\t *\n\t * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}\n\t * @see {@link onErrorStopParsing}\n\t * @see {@link onWarningStopParsing}\n\t */\n\tthis.onError = options.onError || options.errorHandler;\n\tif (options.errorHandler && typeof options.errorHandler !== 'function') {\n\t\tthrow new TypeError('errorHandler object is no longer supported, switch to onError!');\n\t} else if (options.errorHandler) {\n\t\toptions.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);\n\t}\n\n\t/**\n\t * used to replace line endings before parsing, defaults to `normalizeLineEndings`\n\t *\n\t * @type {(string) => string}\n\t * @readonly\n\t */\n\tthis.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;\n\n\t/**\n\t * Configures if the nodes created during parsing will have a `lineNumber` and a\n\t * `columnNumber`\n\t * attribute describing their location in the XML string.\n\t * Default is true.\n\t *\n\t * @type {boolean}\n\t * @readonly\n\t */\n\tthis.locator = !!options.locator;\n\n\t/**\n\t * The default namespace can be provided by the key that is the empty string.\n\t * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,\n\t * the default namespace that will be used,\n\t * will be overridden according to the specification.\n\t *\n\t * @type {Readonly}\n\t * @readonly\n\t */\n\tthis.xmlns = this.assign(Object.create(null), options.xmlns);\n}\n\n/**\n * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`\n * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,\n * otherwise an XML `Document` is created.\n *\n * __It behaves different from the description in the living standard__:\n * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.\n * - Any unexpected input is reported to `onError` with either a `warning`,\n * `error` or `fatalError` level.\n * - Any `fatalError` throws a `ParseError` which prevents further processing.\n * - Any error thrown by `onError` is converted to a `ParseError` which prevents further\n * processing - If no `Document` was created during parsing it is reported as a `fatalError`.\n * *****Warning: By configuring a faulty DOMHandler implementation,\n * the specified behavior can completely be broken*****.\n *\n * @param {string} source\n * The XML mime type only allows string input!\n * @param {string} [mimeType='application/xml']\n * the mimeType or contentType of the document to be created determines the `type` of document\n * created (XML or HTML)\n * @returns {Document}\n * The `Document` node.\n * @throws {ParseError}\n * for any `fatalError` or anything that is thrown by `onError`\n * @throws {TypeError}\n * for any invalid `mimeType`\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString\n * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev\n */\nDOMParser.prototype.parseFromString = function (source, mimeType) {\n\tif (!isValidMimeType(mimeType)) {\n\t\tthrow new TypeError('DOMParser.parseFromString: the provided mimeType \"' + mimeType + '\" is not valid.');\n\t}\n\tvar defaultNSMap = this.assign(Object.create(null), this.xmlns);\n\tvar entityMap = entities.XML_ENTITIES;\n\tvar defaultNamespace = defaultNSMap[''] || null;\n\tif (hasDefaultHTMLNamespace(mimeType)) {\n\t\tentityMap = entities.HTML_ENTITIES;\n\t\tdefaultNamespace = NAMESPACE.HTML;\n\t} else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {\n\t\tdefaultNamespace = NAMESPACE.SVG;\n\t}\n\tdefaultNSMap[''] = defaultNamespace;\n\tdefaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;\n\n\tvar domBuilder = new this.domHandler({\n\t\tmimeType: mimeType,\n\t\tdefaultNamespace: defaultNamespace,\n\t\tonError: this.onError,\n\t});\n\tvar locator = this.locator ? {} : undefined;\n\tif (this.locator) {\n\t\tdomBuilder.setDocumentLocator(locator);\n\t}\n\n\tvar sax = new XMLReader();\n\tsax.errorHandler = domBuilder;\n\tsax.domBuilder = domBuilder;\n\tvar isXml = !conventions.isHTMLMimeType(mimeType);\n\tif (isXml && typeof source !== 'string') {\n\t\tsax.errorHandler.fatalError('source is not a string');\n\t}\n\tsax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);\n\tif (!domBuilder.doc.documentElement) {\n\t\tsax.errorHandler.fatalError('missing root element');\n\t}\n\treturn domBuilder.doc;\n};\n\n/**\n * @typedef DOMHandlerOptions\n * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]\n * @property {string | null} [defaultNamespace=null]\n */\n/**\n * The class that is used to handle events from the SAX parser to create the related DOM\n * elements.\n *\n * Some methods are only implemented as an empty function,\n * since they are (at least currently) not relevant for xmldom.\n *\n * @class\n * @param {DOMHandlerOptions} [options]\n * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html\n */\nfunction DOMHandler(options) {\n\tvar opt = options || {};\n\t/**\n\t * The mime type is used to determine if the DOM handler will create an XML or HTML document.\n\t * Only if it is set to `text/html` it will create an HTML document.\n\t * It defaults to MIME_TYPE.XML_APPLICATION.\n\t *\n\t * @type {string}\n\t * @see {@link MIME_TYPE}\n\t * @readonly\n\t */\n\tthis.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;\n\n\t/**\n\t * The namespace to use to create an XML document.\n\t * For the following reasons this is required:\n\t * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,\n\t * since at that point there is no way for the parser to know what the default namespace from\n\t * the document will be.\n\t * - When creating using `DOMImplementation.createDocument` it is required to pass a\n\t * namespace,\n\t * to determine the correct `Document.contentType`, which should match `this.mimeType`.\n\t * - When parsing an XML document with the `application/xhtml+xml` mimeType,\n\t * the HTML namespace needs to be the default namespace.\n\t *\n\t * @type {string | null}\n\t * @private\n\t * @readonly\n\t */\n\tthis.defaultNamespace = opt.defaultNamespace || null;\n\n\t/**\n\t * @type {boolean}\n\t * @private\n\t */\n\tthis.cdata = false;\n\n\t/**\n\t * The last `Element` that was created by `startElement`.\n\t * `endElement` sets it to the `currentElement.parentNode`.\n\t *\n\t * Note: The sax parser currently sets it to white space text nodes between tags.\n\t *\n\t * @type {Element | Node | undefined}\n\t * @private\n\t */\n\tthis.currentElement = undefined;\n\n\t/**\n\t * The Document that is created as part of `startDocument`,\n\t * and returned by `DOMParser.parseFromString`.\n\t *\n\t * @type {Document | undefined}\n\t * @readonly\n\t */\n\tthis.doc = undefined;\n\n\t/**\n\t * The locator is stored as part of setDocumentLocator.\n\t * It is controlled and mutated by the SAX parser to store the current parsing position.\n\t * It is used by DOMHandler to set `columnNumber` and `lineNumber`\n\t * on the DOM nodes.\n\t *\n\t * @type {Readonly | undefined}\n\t * @private\n\t * @readonly (the\n\t * sax parser currently sometimes set's it)\n\t */\n\tthis.locator = undefined;\n\t/**\n\t * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}\n\t * @readonly\n\t */\n\tthis.onError = opt.onError;\n}\n\nfunction position(locator, node) {\n\tnode.lineNumber = locator.lineNumber;\n\tnode.columnNumber = locator.columnNumber;\n}\n\nDOMHandler.prototype = {\n\t/**\n\t * Either creates an XML or an HTML document and stores it under `this.doc`.\n\t * If it is an XML document, `this.defaultNamespace` is used to create it,\n\t * and it will not contain any `childNodes`.\n\t * If it is an HTML document, it will be created without any `childNodes`.\n\t *\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html\n\t */\n\tstartDocument: function () {\n\t\tvar impl = new DOMImplementation();\n\t\tthis.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');\n\t},\n\tstartElement: function (namespaceURI, localName, qName, attrs) {\n\t\tvar doc = this.doc;\n\t\tvar el = doc.createElementNS(namespaceURI, qName || localName);\n\t\tvar len = attrs.length;\n\t\tappendElement(this, el);\n\t\tthis.currentElement = el;\n\n\t\tthis.locator && position(this.locator, el);\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tvar namespaceURI = attrs.getURI(i);\n\t\t\tvar value = attrs.getValue(i);\n\t\t\tvar qName = attrs.getQName(i);\n\t\t\tvar attr = doc.createAttributeNS(namespaceURI, qName);\n\t\t\tthis.locator && position(attrs.getLocator(i), attr);\n\t\t\tattr.value = attr.nodeValue = value;\n\t\t\tel.setAttributeNode(attr);\n\t\t}\n\t},\n\tendElement: function (namespaceURI, localName, qName) {\n\t\tthis.currentElement = this.currentElement.parentNode;\n\t},\n\tstartPrefixMapping: function (prefix, uri) {},\n\tendPrefixMapping: function (prefix) {},\n\tprocessingInstruction: function (target, data) {\n\t\tvar ins = this.doc.createProcessingInstruction(target, data);\n\t\tthis.locator && position(this.locator, ins);\n\t\tappendElement(this, ins);\n\t},\n\tignorableWhitespace: function (ch, start, length) {},\n\tcharacters: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\t//console.log(chars)\n\t\tif (chars) {\n\t\t\tif (this.cdata) {\n\t\t\t\tvar charNode = this.doc.createCDATASection(chars);\n\t\t\t} else {\n\t\t\t\tvar charNode = this.doc.createTextNode(chars);\n\t\t\t}\n\t\t\tif (this.currentElement) {\n\t\t\t\tthis.currentElement.appendChild(charNode);\n\t\t\t} else if (/^\\s*$/.test(chars)) {\n\t\t\t\tthis.doc.appendChild(charNode);\n\t\t\t\t//process xml\n\t\t\t}\n\t\t\tthis.locator && position(this.locator, charNode);\n\t\t}\n\t},\n\tskippedEntity: function (name) {},\n\tendDocument: function () {\n\t\tthis.doc.normalize();\n\t},\n\t/**\n\t * Stores the locator to be able to set the `columnNumber` and `lineNumber`\n\t * on the created DOM nodes.\n\t *\n\t * @param {Locator} locator\n\t */\n\tsetDocumentLocator: function (locator) {\n\t\tif (locator) {\n\t\t\tlocator.lineNumber = 0;\n\t\t}\n\t\tthis.locator = locator;\n\t},\n\t//LexicalHandler\n\tcomment: function (chars, start, length) {\n\t\tchars = _toString.apply(this, arguments);\n\t\tvar comm = this.doc.createComment(chars);\n\t\tthis.locator && position(this.locator, comm);\n\t\tappendElement(this, comm);\n\t},\n\n\tstartCDATA: function () {\n\t\t//used in characters() methods\n\t\tthis.cdata = true;\n\t},\n\tendCDATA: function () {\n\t\tthis.cdata = false;\n\t},\n\n\tstartDTD: function (name, publicId, systemId, internalSubset) {\n\t\tvar impl = this.doc.implementation;\n\t\tif (impl && impl.createDocumentType) {\n\t\t\tvar dt = impl.createDocumentType(name, publicId, systemId, internalSubset);\n\t\t\tthis.locator && position(this.locator, dt);\n\t\t\tappendElement(this, dt);\n\t\t\tthis.doc.doctype = dt;\n\t\t}\n\t},\n\treportError: function (level, message) {\n\t\tif (typeof this.onError === 'function') {\n\t\t\ttry {\n\t\t\t\tthis.onError(level, message, this);\n\t\t\t} catch (e) {\n\t\t\t\tthrow new ParseError('Reporting ' + level + ' \"' + message + '\" caused ' + e, this.locator);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error('[xmldom ' + level + ']\\t' + message, _locator(this.locator));\n\t\t}\n\t},\n\t/**\n\t * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html\n\t */\n\twarning: function (message) {\n\t\tthis.reportError('warning', message);\n\t},\n\terror: function (message) {\n\t\tthis.reportError('error', message);\n\t},\n\t/**\n\t * This function reports a fatal error and throws a ParseError.\n\t *\n\t * @param {string} message\n\t * - The message to be used for reporting and throwing the error.\n\t * @returns {never}\n\t * This function always throws an error and never returns a value.\n\t * @throws {ParseError}\n\t * Always throws a ParseError with the provided message.\n\t */\n\tfatalError: function (message) {\n\t\tthis.reportError('fatalError', message);\n\t\tthrow new ParseError(message, this.locator);\n\t},\n};\n\nfunction _locator(l) {\n\tif (l) {\n\t\treturn '\\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';\n\t}\n}\n\nfunction _toString(chars, start, length) {\n\tif (typeof chars == 'string') {\n\t\treturn chars.substr(start, length);\n\t} else {\n\t\t//java sax connect width xmldom on rhino(what about: \"? && !(chars instanceof String)\")\n\t\tif (chars.length >= start + length || start) {\n\t\t\treturn new java.lang.String(chars, start, length) + '';\n\t\t}\n\t\treturn chars;\n\t}\n}\n\n/*\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html\n * used method of org.xml.sax.ext.LexicalHandler:\n * #comment(chars, start, length)\n * #startCDATA()\n * #endCDATA()\n * #startDTD(name, publicId, systemId)\n *\n *\n * IGNORED method of org.xml.sax.ext.LexicalHandler:\n * #endDTD()\n * #startEntity(name)\n * #endEntity(name)\n *\n *\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html\n * IGNORED method of org.xml.sax.ext.DeclHandler\n * \t#attributeDecl(eName, aName, type, mode, value)\n * #elementDecl(name, model)\n * #externalEntityDecl(name, publicId, systemId)\n * #internalEntityDecl(name, value)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html\n * IGNORED method of org.xml.sax.EntityResolver2\n * #resolveEntity(String name,String publicId,String baseURI,String systemId)\n * #resolveEntity(publicId, systemId)\n * #getExternalSubset(name, baseURI)\n * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html\n * IGNORED method of org.xml.sax.DTDHandler\n * #notationDecl(name, publicId, systemId) {};\n * #unparsedEntityDecl(name, publicId, systemId, notationName) {};\n */\n'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(\n\t/\\w+/g,\n\tfunction (key) {\n\t\tDOMHandler.prototype[key] = function () {\n\t\t\treturn null;\n\t\t};\n\t}\n);\n\n/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */\nfunction appendElement(handler, node) {\n\tif (!handler.currentElement) {\n\t\thandler.doc.appendChild(node);\n\t} else {\n\t\thandler.currentElement.appendChild(node);\n\t}\n}\n\n/**\n * A method that prevents any further parsing when an `error`\n * with level `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onWarningStopParsing}\n */\nfunction onErrorStopParsing(level) {\n\tif (level === 'error') throw 'onErrorStopParsing';\n}\n\n/**\n * A method that prevents any further parsing when any `error` is reported during parsing.\n *\n * @see {@link DOMParserOptions.onError}\n * @see {@link onErrorStopParsing}\n */\nfunction onWarningStopParsing() {\n\tthrow 'onWarningStopParsing';\n}\n\nexports.__DOMHandler = DOMHandler;\nexports.DOMParser = DOMParser;\nexports.normalizeLineEndings = normalizeLineEndings;\nexports.onErrorStopParsing = onErrorStopParsing;\nexports.onWarningStopParsing = onWarningStopParsing;\n","'use strict';\nvar conventions = require('./conventions');\nexports.assign = conventions.assign;\nexports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;\nexports.isHTMLMimeType = conventions.isHTMLMimeType;\nexports.isValidMimeType = conventions.isValidMimeType;\nexports.MIME_TYPE = conventions.MIME_TYPE;\nexports.NAMESPACE = conventions.NAMESPACE;\n\nvar errors = require('./errors');\nexports.DOMException = errors.DOMException;\nexports.DOMExceptionName = errors.DOMExceptionName;\nexports.ExceptionCode = errors.ExceptionCode;\nexports.ParseError = errors.ParseError;\n\nvar dom = require('./dom');\nexports.Attr = dom.Attr;\nexports.CDATASection = dom.CDATASection;\nexports.CharacterData = dom.CharacterData;\nexports.Comment = dom.Comment;\nexports.Document = dom.Document;\nexports.DocumentFragment = dom.DocumentFragment;\nexports.DocumentType = dom.DocumentType;\nexports.DOMImplementation = dom.DOMImplementation;\nexports.Element = dom.Element;\nexports.Entity = dom.Entity;\nexports.EntityReference = dom.EntityReference;\nexports.LiveNodeList = dom.LiveNodeList;\nexports.NamedNodeMap = dom.NamedNodeMap;\nexports.Node = dom.Node;\nexports.NodeList = dom.NodeList;\nexports.Notation = dom.Notation;\nexports.ProcessingInstruction = dom.ProcessingInstruction;\nexports.Text = dom.Text;\nexports.XMLSerializer = dom.XMLSerializer;\n\nvar domParser = require('./dom-parser');\nexports.DOMParser = domParser.DOMParser;\nexports.normalizeLineEndings = domParser.normalizeLineEndings;\nexports.onErrorStopParsing = domParser.onErrorStopParsing;\nexports.onWarningStopParsing = domParser.onWarningStopParsing;\n","import { DOMParser as g, DOMImplementation as J } from \"@xmldom/xmldom\";\nconst p = \"USJ\", O = \"3.1\", _ = Object.freeze({ type: p, version: O, content: [] }), B = [\n \"type\",\n \"marker\",\n \"content\",\n \"sid\",\n \"eid\",\n \"number\",\n \"code\",\n \"altnumber\",\n \"pubnumber\",\n \"caller\",\n \"align\",\n \"category\"\n];\nfunction H(e) {\n return M.includes(e);\n}\nconst M = [\n // Old Testament\n \"GEN\",\n \"EXO\",\n \"LEV\",\n \"NUM\",\n \"DEU\",\n \"JOS\",\n \"JDG\",\n \"RUT\",\n \"1SA\",\n \"2SA\",\n \"1KI\",\n \"2KI\",\n \"1CH\",\n \"2CH\",\n \"EZR\",\n \"NEH\",\n \"EST\",\n \"JOB\",\n \"PSA\",\n \"PRO\",\n \"ECC\",\n \"SNG\",\n \"ISA\",\n \"JER\",\n \"LAM\",\n \"EZK\",\n \"DAN\",\n \"HOS\",\n \"JOL\",\n \"AMO\",\n \"OBA\",\n \"JON\",\n \"MIC\",\n \"NAM\",\n \"HAB\",\n \"ZEP\",\n \"HAG\",\n \"ZEC\",\n \"MAL\",\n // New Testament\n \"MAT\",\n \"MRK\",\n \"LUK\",\n \"JHN\",\n \"ACT\",\n \"ROM\",\n \"1CO\",\n \"2CO\",\n \"GAL\",\n \"EPH\",\n \"PHP\",\n \"COL\",\n \"1TH\",\n \"2TH\",\n \"1TI\",\n \"2TI\",\n \"TIT\",\n \"PHM\",\n \"HEB\",\n \"JAS\",\n \"1PE\",\n \"2PE\",\n \"1JN\",\n \"2JN\",\n \"3JN\",\n \"JUD\",\n \"REV\",\n // Deuterocanon\n \"TOB\",\n \"JDT\",\n \"ESG\",\n \"WIS\",\n \"SIR\",\n \"BAR\",\n \"LJE\",\n \"S3Y\",\n \"SUS\",\n \"BEL\",\n \"1MA\",\n \"2MA\",\n \"3MA\",\n \"4MA\",\n \"1ES\",\n \"2ES\",\n \"MAN\",\n \"PS2\",\n \"ODA\",\n \"PSS\",\n \"EZA\",\n \"5EZ\",\n \"6EZ\",\n \"DAG\",\n \"PS3\",\n \"2BA\",\n \"LBA\",\n \"JUB\",\n \"ENO\",\n \"1MQ\",\n \"2MQ\",\n \"3MQ\",\n \"REP\",\n \"4BA\",\n \"LAO\",\n // Non scripture\n \"FRT\",\n \"BAK\",\n \"OTH\",\n \"INT\",\n \"CNC\",\n \"GLO\",\n \"TDX\",\n \"NDX\",\n \"XXA\",\n \"XXB\",\n \"XXC\",\n \"XXD\",\n \"XXE\",\n \"XXF\",\n \"XXG\"\n], f = \"usx\", N = \"3.1\", I = `<${f} version=\"${N}\" />`;\nfunction V(e) {\n const n = new g().parseFromString(e, \"text/xml\");\n return m(n.documentElement);\n}\nfunction m(e) {\n const [t] = e ? b(e) : [{ content: [] }];\n return t.type = p, t.version = O, t;\n}\nfunction b(e) {\n const t = {};\n let n = e.tagName, o, s, c = \"append\";\n if ([\"row\", \"cell\"].includes(n) && (n = \"table:\" + n), e.attributes)\n for (const r of Array.from(e.attributes))\n t[r.name] = r.value;\n t.style && (o = t.style, delete t.style), t.vid && delete t.vid, t.status && delete t.status;\n let i = { type: n };\n o && (i.marker = o), i = { ...i, ...t }, e.firstChild && e.firstChild.nodeType === e.firstChild.TEXT_NODE && e.firstChild.nodeValue && E(e.firstChild.nodeValue) !== \"\" && (s = e.firstChild.nodeValue);\n const l = Array.from(e.childNodes);\n i.content = [], s && i.content.push(s);\n for (const r of l) {\n if (r.tagName === void 0)\n continue;\n const [u, S] = b(r);\n switch (S) {\n case \"append\":\n i.content.push(u);\n break;\n case \"merge\":\n i.content = i.content.concat(u);\n break;\n }\n r.nextSibling && r.nextSibling.nodeType === r.nextSibling.TEXT_NODE && r.nextSibling.nodeValue && (E(r.nextSibling.nodeValue) !== \"\" || r.nextSibling.nodeValue === \" \") && i.content.push(r.nextSibling.nodeValue);\n }\n return i.content.length === 0 && i.type !== f && delete i.content, \"eid\" in i && [\"verse\", \"chapter\"].includes(n) && (c = \"ignore\"), [i, c];\n}\nfunction E(e) {\n return e.replace(/(^[ \\t\\n\\r\\f\\v]+)|([ \\t\\n\\r\\f\\v]+$)/g, \"\");\n}\nlet d, a;\nfunction C(e) {\n const t = new J().createDocument(\"\", f);\n return t.documentElement && (t.documentElement.setAttribute(\"version\", N), y(e, t)), t.toString();\n}\nfunction y(e, t) {\n if (t.documentElement) {\n for (const [n, o] of e.content.entries()) {\n const s = n === e.content.length - 1;\n v(o, t.documentElement, t, s);\n }\n return t.documentElement ?? void 0;\n }\n}\nfunction v(e, t, n, o) {\n let s, c, i;\n if (typeof e == \"string\") s = n.createTextNode(e);\n else if (c = e.type.replace(\"table:\", \"\"), s = n.createElement(c), X(s, e), e.content)\n for (const [r, u] of e.content.entries()) {\n const S = r === e.content.length - 1;\n v(u, s, n, S);\n }\n a && (c === \"verse\" || t.tagName === \"para\" && o) && (i = T(n, a), a = void 0), c === \"verse\" && typeof e != \"string\" && e.sid !== void 0 && (a = e.sid), d && (c === \"chapter\" || c === \"para\" && o) && (i = h(n, d), d = void 0), c === \"chapter\" && typeof e != \"string\" && e.sid !== void 0 && (d = e.sid);\n const l = t.nodeName === f && (i == null ? void 0 : i.tagName) === \"verse\";\n i && (!o || l) && t.appendChild(i), t.appendChild(s), i && o && !l && t.appendChild(i), o && t.nodeName === f && (a && t.appendChild(T(n, a)), d && t.appendChild(h(n, d)), a = void 0, d = void 0);\n}\nfunction X(e, t) {\n t.marker && (t.type === \"unmatched\" ? e.setAttribute(\"marker\", t.marker) : e.setAttribute(\"style\", t.marker));\n for (const [n, o] of Object.entries(t))\n o && ![\"type\", \"marker\", \"content\"].includes(n) && e.setAttribute(n, o);\n}\nfunction T(e, t) {\n const n = e.createElement(\"verse\");\n return n.setAttribute(\"eid\", t), n;\n}\nfunction h(e, t) {\n const n = e.createElement(\"chapter\");\n return n.setAttribute(\"eid\", t), n;\n}\nconst A = \"$\", P = \".content[\";\nfunction D(e) {\n const t = e.split(P);\n if (t.shift() !== A)\n throw new Error(`indexesFromJsonPath: jsonPath didn't start with '${A}'`);\n return t.map((o) => parseInt(o, 10));\n}\nfunction U(e) {\n return e.reduce((t, n) => `${t}${P}${n}]`, A);\n}\nexport {\n _ as EMPTY_USJ,\n I as EMPTY_USX,\n B as MARKER_OBJECT_PROPS,\n p as USJ_TYPE,\n O as USJ_VERSION,\n f as USX_TYPE,\n N as USX_VERSION,\n M as VALID_BOOK_CODES,\n D as indexesFromUsjJsonPath,\n H as isValidBookCode,\n U as usjJsonPathFromIndexes,\n C as usjToUsxString,\n V as usxStringToUsj\n};\n//# sourceMappingURL=index.js.map\n","\"use strict\"\r\n\r\n// Based on: https://github.com/lodash/lodash/blob/6018350ac10d5ce6a5b7db625140b82aeab804df/.internal/unicodeSize.js\r\n\r\nmodule.exports = () => {\r\n\t// Used to compose unicode character classes.\r\n\tconst astralRange = \"\\\\ud800-\\\\udfff\"\r\n\tconst comboMarksRange = \"\\\\u0300-\\\\u036f\"\r\n\tconst comboHalfMarksRange = \"\\\\ufe20-\\\\ufe2f\"\r\n\tconst comboSymbolsRange = \"\\\\u20d0-\\\\u20ff\"\r\n\tconst comboMarksExtendedRange = \"\\\\u1ab0-\\\\u1aff\"\r\n\tconst comboMarksSupplementRange = \"\\\\u1dc0-\\\\u1dff\"\r\n\tconst comboRange = comboMarksRange + comboHalfMarksRange + comboSymbolsRange + comboMarksExtendedRange + comboMarksSupplementRange\r\n\tconst varRange = \"\\\\ufe0e\\\\ufe0f\"\r\n\tconst familyRange = \"\\\\uD83D\\\\uDC69\\\\uD83C\\\\uDFFB\\\\u200D\\\\uD83C\\\\uDF93\"\r\n\r\n\t// Used to compose unicode capture groups.\r\n\tconst astral = `[${astralRange}]`\r\n\tconst combo = `[${comboRange}]`\r\n\tconst fitz = \"\\\\ud83c[\\\\udffb-\\\\udfff]\"\r\n\tconst modifier = `(?:${combo}|${fitz})`\r\n\tconst nonAstral = `[^${astralRange}]`\r\n\tconst regional = \"(?:\\\\uD83C[\\\\uDDE6-\\\\uDDFF]){2}\"\r\n\tconst surrogatePair = \"[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]\"\r\n\tconst zwj = \"\\\\u200d\"\r\n\tconst blackFlag = \"(?:\\\\ud83c\\\\udff4\\\\udb40\\\\udc67\\\\udb40\\\\udc62\\\\udb40(?:\\\\udc65|\\\\udc73|\\\\udc77)\\\\udb40(?:\\\\udc6e|\\\\udc63|\\\\udc6c)\\\\udb40(?:\\\\udc67|\\\\udc74|\\\\udc73)\\\\udb40\\\\udc7f)\"\r\n\tconst family = `[${familyRange}]`\r\n\r\n\t// Used to compose unicode regexes.\r\n\tconst optModifier = `${modifier}?`\r\n\tconst optVar = `[${varRange}]?`\r\n\tconst optJoin = `(?:${zwj}(?:${[nonAstral, regional, surrogatePair].join(\"|\")})${optVar + optModifier})*`\r\n\tconst seq = optVar + optModifier + optJoin\r\n\tconst nonAstralCombo = `${nonAstral}${combo}?`\r\n\tconst symbol = `(?:${[nonAstralCombo, combo, regional, surrogatePair, astral, family].join(\"|\")})`\r\n\r\n\t// Used to match [String symbols](https://mathiasbynens.be/notes/javascript-unicode).\r\n\treturn new RegExp(`${blackFlag}|${fitz}(?=${fitz})|${symbol + seq}`, \"g\")\r\n}\r\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// @ts-ignore\nvar char_regex_1 = __importDefault(require(\"char-regex\"));\n/**\n * Converts a string to an array of string chars\n * @param {string} str The string to turn into array\n * @returns {string[]}\n */\nfunction toArray(str) {\n if (typeof str !== 'string') {\n throw new Error('A string is expected as input');\n }\n return str.match(char_regex_1.default()) || [];\n}\nexports.toArray = toArray;\n/**\n * Returns the length of a string\n *\n * @export\n * @param {string} str\n * @returns {number}\n */\nfunction length(str) {\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var match = str.match(char_regex_1.default());\n return match === null ? 0 : match.length;\n}\nexports.length = length;\n/**\n * Returns a substring by providing start and end position\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} end End position\n * @returns {string}\n */\nfunction substring(str, begin, end) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n // Even though negative numbers work here, theyre not in the spec\n if (typeof begin !== 'number' || begin < 0) {\n begin = 0;\n }\n if (typeof end === 'number' && end < 0) {\n end = 0;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substring = substring;\n/**\n * Returns a substring by providing start position and length\n *\n * @export\n * @param {string} str\n * @param {number} [begin=0] Starting position\n * @param {number} len Desired length\n * @returns {string}\n */\nfunction substr(str, begin, len) {\n if (begin === void 0) { begin = 0; }\n // Check for input\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n var strLength = length(str);\n // Fix type\n if (typeof begin !== 'number') {\n begin = parseInt(begin, 10);\n }\n // Return zero-length string if got oversize number.\n if (begin >= strLength) {\n return '';\n }\n // Calculating postive version of negative value.\n if (begin < 0) {\n begin += strLength;\n }\n var end;\n if (typeof len === 'undefined') {\n end = strLength;\n }\n else {\n // Fix type\n if (typeof len !== 'number') {\n len = parseInt(len, 10);\n }\n end = len >= 0 ? len + begin : begin;\n }\n var match = str.match(char_regex_1.default());\n if (!match)\n return '';\n return match.slice(begin, end).join('');\n}\nexports.substr = substr;\n/**\n * Enforces a string to be a certain length by\n * adding or removing characters\n *\n * @export\n * @param {string} str\n * @param {number} [limit=16] Limit\n * @param {string} [padString='#'] The Pad String\n * @param {string} [padPosition='right'] The Pad Position\n * @returns {string}\n */\nfunction limit(str, limit, padString, padPosition) {\n if (limit === void 0) { limit = 16; }\n if (padString === void 0) { padString = '#'; }\n if (padPosition === void 0) { padPosition = 'right'; }\n // Input should be a string, limit should be a number\n if (typeof str !== 'string' || typeof limit !== 'number') {\n throw new Error('Invalid arguments specified');\n }\n // Pad position should be either left or right\n if (['left', 'right'].indexOf(padPosition) === -1) {\n throw new Error('Pad position should be either left or right');\n }\n // Pad string can be anything, we convert it to string\n if (typeof padString !== 'string') {\n padString = String(padString);\n }\n // Calculate string length considering astral code points\n var strLength = length(str);\n if (strLength > limit) {\n return substring(str, 0, limit);\n }\n else if (strLength < limit) {\n var padRepeats = padString.repeat(limit - strLength);\n return padPosition === 'left' ? padRepeats + str : str + padRepeats;\n }\n return str;\n}\nexports.limit = limit;\n/**\n * Returns the index of the first occurrence of a given string\n *\n * @export\n * @param {string} str\n * @param {string} [searchStr] the string to search\n * @param {number} [pos] starting position\n * @returns {number}\n */\nfunction indexOf(str, searchStr, pos) {\n if (pos === void 0) { pos = 0; }\n if (typeof str !== 'string') {\n throw new Error('Input must be a string');\n }\n if (str === '') {\n if (searchStr === '') {\n return 0;\n }\n return -1;\n }\n // fix type\n pos = Number(pos);\n pos = isNaN(pos) ? 0 : pos;\n searchStr = String(searchStr);\n var strArr = toArray(str);\n if (pos >= strArr.length) {\n if (searchStr === '') {\n return strArr.length;\n }\n return -1;\n }\n if (searchStr === '') {\n return pos;\n }\n var searchArr = toArray(searchStr);\n var finded = false;\n var index;\n for (index = pos; index < strArr.length; index += 1) {\n var searchIndex = 0;\n while (searchIndex < searchArr.length &&\n searchArr[searchIndex] === strArr[index + searchIndex]) {\n searchIndex += 1;\n }\n if (searchIndex === searchArr.length &&\n searchArr[searchIndex - 1] === strArr[index + searchIndex - 1]) {\n finded = true;\n break;\n }\n }\n return finded ? index : -1;\n}\nexports.indexOf = indexOf;\n","/**\n * Ensures that the given input is returned as an array.\n *\n * This function takes a value that might be a single item, an array, or `undefined` and returns it\n * as an array:\n *\n * - If the input is `undefined`, an empty array is returned.\n * - If the input is already an array, it is returned as-is.\n * - If the input is a single item, it is wrapped in an array.\n *\n * @typeParam T - The type of the elements in the array.\n * @param maybeArray - The value that may be a single item, an array, or `undefined`.\n * @returns An array containing the input value(s). If the input is `undefined`, an empty array is\n * returned.\n */\nexport function ensureArray(maybeArray: T | T[] | undefined): T[] {\n if (!maybeArray) return [];\n\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\nexport default ensureArray;\n","import { LocalizeKey } from 'extension-contributions/menus.model';\nimport {\n indexOf as stringzIndexOf,\n length as stringzLength,\n limit as stringzLimit,\n substr as stringzSubstr,\n substring as stringzSubstring,\n toArray as stringzToArray,\n} from 'stringz';\nimport { ensureArray } from './array-util';\nimport { isString } from './util';\n\n/**\n * This function mirrors the `at` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Finds the Unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the character to be returned in range of -length(string) to\n * length(string)\n * @returns New string consisting of the Unicode code point located at the specified offset,\n * undefined if index is out of bounds\n */\nexport function at(string: string, index: number): string | undefined {\n if (index > stringLength(string) || index < -stringLength(string)) return undefined;\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `charAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a new string consisting of the single unicode code point at the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns New string consisting of the Unicode code point located at the specified offset, empty\n * string if index is out of bounds\n */\nexport function charAt(string: string, index: number): string {\n if (index < 0 || index > stringLength(string) - 1) return '';\n return substr(string, index, 1);\n}\n\n/**\n * This function mirrors the `codePointAt` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a non-negative integer that is the Unicode code point value of the character starting at\n * the given index.\n *\n * @param string String to index\n * @param index Position of the string character to be returned, in the range of 0 to\n * length(string)-1\n * @returns Non-negative integer representing the code point value of the character at the given\n * index, or undefined if there is no element at that position\n */\nexport function codePointAt(string: string, index: number): number | undefined {\n if (index < 0 || index > stringLength(string) - 1) return undefined;\n return substr(string, index, 1).codePointAt(0);\n}\n\n/**\n * This function mirrors the `endsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether a string ends with the characters of this string.\n *\n * @param string String to search through\n * @param searchString Characters to search for at the end of the string\n * @param endPosition End position where searchString is expected to be found. Default is\n * `length(string)`\n * @returns True if it ends with searchString, false if it does not\n */\nexport function endsWith(\n string: string,\n searchString: string,\n endPosition: number = stringLength(string),\n): boolean {\n const lastIndexOfSearchString = lastIndexOf(string, searchString);\n if (lastIndexOfSearchString === -1) return false;\n if (lastIndexOfSearchString + stringLength(searchString) !== endPosition) return false;\n return true;\n}\n\n/**\n * Get the index of the closest closing curly brace in a string.\n *\n * Note: when escaped, gets the index of the curly brace, not the backslash before it.\n *\n * @param str String to search\n * @param index Index at which to start searching. Inclusive of this index\n * @param escaped Whether to search for an escaped or an unescaped closing curly brace\n * @returns Index of closest closing curly brace or -1 if not found\n */\nfunction indexOfClosestClosingCurlyBrace(str: string, index: number, escaped: boolean) {\n if (index < 0) return -1;\n if (escaped) {\n if (charAt(str, index) === '}' && charAt(str, index - 1) === '\\\\') return index;\n const closeCurlyBraceIndex = indexOf(str, '\\\\}', index);\n return closeCurlyBraceIndex >= 0 ? closeCurlyBraceIndex + 1 : closeCurlyBraceIndex;\n }\n\n let i = index;\n const strLength = stringLength(str);\n while (i < strLength) {\n i = indexOf(str, '}', i);\n\n if (i === -1 || charAt(str, i - 1) !== '\\\\') break;\n\n // Didn't find an un-escaped close brace, so keep looking\n i += 1;\n }\n\n return i >= strLength ? -1 : i;\n}\n\n/**\n * Formats a string into an array of objects (adjacent strings are concatenated in one array entry),\n * replacing `{replacer key}` with the value in the `replacers` at that replacer key (or multiple\n * replacer values if there are multiple in the string). Will also remove \\ before curly braces if\n * curly braces are escaped with a backslash in order to preserve the curly braces. E.g. 'Hi, this\n * is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * Note: React elements can be used as replacer values.\n *\n * @example\n *\n * ```tsx\n *

\n * {formatReplacementStringToArray('Hi {other}! I am {name}.', {\n * other: 'Billy',\n * name: Jim,\n * })}\n *

\n * ```\n *\n * @example\n *\n * ```typescript\n * formatReplacementStringToArray(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carInfo} car. My favorite food is {food}.',\n * { name: ['Bill'], carInfo: { year: 2015, color: 'blue' } }\n * );\n *\n * =>\n *\n * ['Hi, this is ', ['Bill'], '! I like {curly braces}! I have a ', { year: 2015, color: 'blue' }, ' car. My favorite food is food.']\n * ```\n *\n * @param str String to format and break out into an array of objects\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. If the replacer value is a string,\n * it will be concatenated into existing strings in the array. Otherwise, the replacer value will\n * be added as a new entry in the array\n * @returns Array of formatted strings and replaced objects\n */\nexport function formatReplacementStringToArray(\n str: string,\n replacers: { [key: string | number]: T } | object,\n): (string | T)[] {\n /** The compiled list of contents with replacers replaced appropriately */\n const contents: (string | T)[] = [];\n\n // current index in the string as we go through it\n let i = 0;\n // first index of characters to include in the next plain string added to the content\n let nextIntermediateStartIndex = 0;\n\n /**\n * Adds some content to the array of contents that is being built and also add the intermediate\n * string between the last added content and this added content\n *\n * @param newContent Content to add\n * @param newContentIndex Position in string where newContent starts\n * @param newContentLength Length in the string of the representation of this newContent\n */\n function addToContents(\n newContent: string | T,\n newContentIndex: number,\n newContentLength: number,\n ) {\n // Get the string content between the last new content and this new content\n const intermediateContent = substring(str, nextIntermediateStartIndex, newContentIndex);\n\n // If the last item in contents is a string, pull it out and add intermediateContent to\n // it. Otherwise stick with just intermediateContent\n const baseSubstring =\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${intermediateContent}`\n : intermediateContent;\n\n if (isString(newContent)) {\n // If the new content is a string, add it all together\n contents.push(`${baseSubstring}${newContent}`);\n } else {\n // New content is not a string. Add the base string if it exists (don't add an\n // empty string between added contents), then add the new content separately\n if (baseSubstring) contents.push(baseSubstring);\n contents.push(newContent);\n }\n\n // Set the intermediate start index to right after the new content so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = newContentIndex + newContentLength;\n }\n\n const strLength = stringLength(str);\n while (i < strLength) {\n switch (charAt(str, i)) {\n case '{':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped open curly brace. Try to match and replace\n const closeCurlyBraceIndex = indexOfClosestClosingCurlyBrace(str, i, false);\n if (closeCurlyBraceIndex >= 0) {\n // We have matching open and close indices. Try to replace the contents\n const replacerKey = substring(str, i + 1, closeCurlyBraceIndex);\n\n // Replace with the replacer or just remove the curly braces\n const replacerContent =\n replacerKey in replacers\n ? // Just checked that the key is in the object\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n replacers[replacerKey as keyof typeof replacers]\n : replacerKey;\n\n addToContents(replacerContent, i, closeCurlyBraceIndex + 1 - i);\n\n // Put our index at the closing brace to keep processing the string after it\n i = closeCurlyBraceIndex;\n // Set the intermediate start index to right after our closing curly brace so whatever\n // string content is between replacers gets added\n nextIntermediateStartIndex = closeCurlyBraceIndex + 1;\n } else {\n // This is an unexpected un-escaped open curly brace with no matching closing curly\n // brace. Just ignore, I guess\n }\n } else {\n // This character is an escaped open curly brace. Add the curly brace but skip over the\n // escape backslash\n addToContents('{', i - 1, 2);\n }\n break;\n case '}':\n if (charAt(str, i - 1) !== '\\\\') {\n // This character is an un-escaped closing curly brace with no matching open curly\n // brace. Just ignore, I guess\n } else {\n // This character is an escaped closing curly brace. Add the curly brace but skip over\n // the escape backslash\n addToContents('}', i - 1, 2);\n }\n break;\n default:\n // No need to do anything with other characters at this point\n break;\n }\n\n i += 1;\n }\n\n // Now we are through the whole string and need to add the string content after all replacers if\n // there is anything left\n if (nextIntermediateStartIndex < strLength) {\n // Get the string content between the last new content and this new content\n const endContent = substring(str, nextIntermediateStartIndex);\n\n // If the last item in contents is a string, pull it out and add endContent to\n // it. Then put it in the contents array\n contents.push(\n contents.length > 0 && isString(contents[contents.length - 1])\n ? `${contents.pop()}${endContent}`\n : endContent,\n );\n }\n\n return contents;\n}\n\n/**\n * Formats a string, replacing `{replacer key}` with the value in the `replacers` at that replacer\n * key (or multiple replacer values if there are multiple in the string). Will also remove \\ before\n * curly braces if curly braces are escaped with a backslash in order to preserve the curly braces.\n * E.g. 'Hi, this is {name}! I like `\\{curly braces\\}`! would become Hi, this is Jim! I like {curly\n * braces}!\n *\n * If the key in unescaped braces is not found, returns the key without the braces. Empty unescaped\n * curly braces will just return a string without the braces e.g. ('I am {Nemo}', { 'name': 'Jim'})\n * would return 'I am Nemo'.\n *\n * @example\n *\n * ```typescript\n * formatReplacementString(\n * 'Hi, this is {name}! I like \\{curly braces\\}! I have a {carColor} car. My favorite food is {food}.',\n * { name: 'Bill', carColor: 'blue' }\n * );\n *\n * =>\n *\n * 'Hi, this is Bill! I like {curly braces}! I have a blue car. My favorite food is food.'\n * ```\n *\n * @param str String to format\n * @param replacers Object whose keys are replacer keys and whose values are the values with which\n * to replace `{replacer key}`s found in the string to format. Will be coerced to strings using\n * `${replacerValue}`\n * @returns Formatted string\n */\nexport function formatReplacementString(\n str: string,\n replacers: { [key: string | number]: string | unknown } | object,\n): string {\n return formatReplacementStringToArray(str, replacers)\n .map((content) => `${content}`)\n .join('');\n}\n\n/**\n * This function mirrors the `includes` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Performs a case-sensitive search to determine if searchString is found in string.\n *\n * @param string String to search through\n * @param searchString String to search for\n * @param position Position within the string to start searching for searchString. Default is `0`\n * @returns True if search string is found, false if it is not\n */\nexport function includes(string: string, searchString: string, position: number = 0): boolean {\n const partialString = substring(string, position);\n const indexOfSearchString = indexOf(partialString, searchString);\n if (indexOfSearchString === -1) return false;\n return true;\n}\n\n/**\n * This function mirrors the `indexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the index of the first occurrence of a given string.\n *\n * @param string String to search through\n * @param searchString The string to search for\n * @param position Start of searching. Default is `0`\n * @returns Index of the first occurrence of a given string\n */\nexport function indexOf(\n string: string,\n searchString: string,\n position: number | undefined = 0,\n): number {\n return stringzIndexOf(string, searchString, position);\n}\n\n/**\n * This function mirrors the `lastIndexOf` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Searches this string and returns the index of the last occurrence of the specified substring.\n *\n * @param string String to search through\n * @param searchString Substring to search for\n * @param position The index at which to begin searching. If omitted, the search begins at the end\n * of the string. Default is `undefined`\n * @returns Index of the last occurrence of searchString found, or -1 if not found.\n */\nexport function lastIndexOf(string: string, searchString: string, position?: number): number {\n let validatedPosition = position === undefined ? stringLength(string) : position;\n\n if (validatedPosition < 0) {\n validatedPosition = 0;\n } else if (validatedPosition >= stringLength(string)) {\n validatedPosition = stringLength(string) - 1;\n }\n\n for (let index = validatedPosition; index >= 0; index--) {\n if (substr(string, index, stringLength(searchString)) === searchString) {\n return index;\n }\n }\n\n return -1;\n}\n\n/**\n * This function mirrors the `length` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes. Since `length` appears to be a\n * reserved keyword, the function was renamed to `stringLength`\n *\n * Returns the length of a string.\n *\n * @param string String to return the length for\n * @returns Number that is length of the starting string\n */\nexport function stringLength(string: string): number {\n return stringzLength(string);\n}\n\n/**\n * This function mirrors the `normalize` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns the Unicode Normalization Form of this string.\n *\n * @param string The starting string\n * @param form Form specifying the Unicode Normalization Form. Default is `'NFC'`\n * @returns A string containing the Unicode Normalization Form of the given string.\n */\nexport function normalize(string: string, form: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | 'none'): string {\n const upperCaseForm = form.toUpperCase();\n if (upperCaseForm === 'NONE') {\n return string;\n }\n return string.normalize(upperCaseForm);\n}\n\n/**\n * Compares two strings using an ordinal comparison approach based on the specified collation\n * options. This function uses the built-in `localeCompare` method with the 'en' locale and the\n * provided collation options to compare the strings.\n *\n * @param string1 The first string to compare.\n * @param string2 The second string to compare.\n * @param options Optional. The collation options used for comparison.\n * @returns A number indicating the result of the comparison: - Negative value if string1 precedes\n * string2 in sorting order. - Zero if string1 and string2 are equivalent in sorting order. -\n * Positive value if string1 follows string2 in sorting order.\n */\nexport function ordinalCompare(\n string1: string,\n string2: string,\n options?: Intl.CollatorOptions,\n): number {\n return string1.localeCompare(string2, 'en', options);\n}\n\n/**\n * This function mirrors the `padEnd` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the end of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within targetLength, it will be truncated. Default is `\" \"`\n * @returns String with appropriate padding at the end\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padEnd(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'right');\n}\n\n/**\n * This function mirrors the `padStart` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Pads this string with another string (multiple times, if needed) until the resulting string\n * reaches the given length. The padding is applied from the start of this string.\n *\n * @param string String to add padding too\n * @param targetLength The length of the resulting string once the starting string has been padded.\n * If value is less than or equal to length(string), then string is returned as is.\n * @param padString The string to pad the current string with. If padString is too long to stay\n * within the targetLength, it will be truncated from the end. Default is `\" \"`\n * @returns String with of specified targetLength with padString applied from the start\n */\n// Note: Limit with padString only works when length(padString) = 1, will be fixed with https://github.com/sallar/stringz/pull/59\nexport function padStart(string: string, targetLength: number, padString: string = ' '): string {\n if (targetLength <= stringLength(string)) return string;\n return stringzLimit(string, targetLength, padString, 'left');\n}\n\n// This is a helper function that performs a correction on the slice index to make sure it\n// cannot go out of bounds\nfunction correctSliceIndex(length: number, index: number) {\n if (index > length) return length;\n if (index < -length) return 0;\n if (index < 0) return index + length;\n return index;\n}\n\n/**\n * This function mirrors the `slice` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Extracts a section of this string and returns it as a new string, without modifying the original\n * string.\n *\n * @param string The starting string\n * @param indexStart The index of the first character to include in the returned substring.\n * @param indexEnd The index of the first character to exclude from the returned substring.\n * @returns A new string containing the extracted section of the string.\n */\nexport function slice(string: string, indexStart: number, indexEnd?: number): string {\n const length: number = stringLength(string);\n if (\n indexStart > length ||\n (indexEnd &&\n ((indexStart > indexEnd &&\n !(indexStart >= 0 && indexStart < length && indexEnd < 0 && indexEnd > -length)) ||\n indexEnd < -length))\n )\n return '';\n\n const newStart = correctSliceIndex(length, indexStart);\n const newEnd = indexEnd ? correctSliceIndex(length, indexEnd) : undefined;\n\n return substring(string, newStart, newEnd);\n}\n\n/**\n * This function mirrors the `split` function from the JavaScript Standard String object. It handles\n * Unicode code points instead of UTF-16 character codes.\n *\n * Takes a pattern and divides the string into an ordered list of substrings by searching for the\n * pattern, puts these substrings into an array, and returns the array.\n *\n * @param string The string to split\n * @param separator The pattern describing where each split should occur\n * @param splitLimit Limit on the number of substrings to be included in the array. Splits the\n * string at each occurrence of specified separator, but stops when limit entries have been placed\n * in the array.\n * @returns An array of strings, split at each point where separator occurs in the starting string.\n * Returns undefined if separator is not found in string.\n */\nexport function split(string: string, separator: string | RegExp, splitLimit?: number): string[] {\n const result: string[] = [];\n\n if (splitLimit !== undefined && splitLimit <= 0) {\n return [string];\n }\n\n if (separator === '') return toArray(string).slice(0, splitLimit);\n\n let regexSeparator = separator;\n if (\n typeof separator === 'string' ||\n (separator instanceof RegExp && !includes(separator.flags, 'g'))\n ) {\n regexSeparator = new RegExp(separator, 'g');\n }\n\n const matches: RegExpMatchArray | null = string.match(regexSeparator);\n\n let currentIndex = 0;\n\n if (!matches) return [string];\n\n for (let index = 0; index < (splitLimit ? splitLimit - 1 : matches.length); index++) {\n const matchIndex = indexOf(string, matches[index], currentIndex);\n const matchLength = stringLength(matches[index]);\n\n result.push(substring(string, currentIndex, matchIndex));\n currentIndex = matchIndex + matchLength;\n\n if (splitLimit !== undefined && result.length === splitLimit) {\n break;\n }\n }\n\n result.push(substring(string, currentIndex));\n\n return result;\n}\n\n/**\n * This function mirrors the `startsWith` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Determines whether the string begins with the characters of a specified string, returning true or\n * false as appropriate.\n *\n * @param string String to search through\n * @param searchString The characters to be searched for at the start of this string.\n * @param position The start position at which searchString is expected to be found (the index of\n * searchString's first character). Default is `0`\n * @returns True if the given characters are found at the beginning of the string, including when\n * searchString is an empty string; otherwise, false.\n */\nexport function startsWith(string: string, searchString: string, position: number = 0): boolean {\n const indexOfSearchString = indexOf(string, searchString, position);\n if (indexOfSearchString !== position) return false;\n return true;\n}\n\n/**\n * This function mirrors the `substr` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and length. This function is not exported because it is\n * considered deprecated, however it is still useful as a local helper function.\n *\n * @param string String to be divided\n * @param begin Start position. Default is `Start of string`\n * @param len Length of result. Default is `String length minus start parameter`. Default is `String\n * length minus start parameter`\n * @returns Substring from starting string\n */\nfunction substr(\n string: string,\n begin: number = 0,\n len: number = stringLength(string) - begin,\n): string {\n return stringzSubstr(string, begin, len);\n}\n\n/**\n * This function mirrors the `substring` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Returns a substring by providing start and end position.\n *\n * @param string String to be divided\n * @param begin Start position\n * @param end End position. Default is `End of string`\n * @returns Substring from starting string\n */\nexport function substring(\n string: string,\n begin: number,\n end: number = stringLength(string),\n): string {\n return stringzSubstring(string, begin, end);\n}\n\n/**\n * This function mirrors the `toArray` function from the JavaScript Standard String object. It\n * handles Unicode code points instead of UTF-16 character codes.\n *\n * Converts a string to an array of string characters.\n *\n * @param string String to convert to array\n * @returns An array of characters from the starting string\n */\nexport function toArray(string: string): string[] {\n return stringzToArray(string);\n}\n\n/** Determine whether the string is a `LocalizeKey` meant to be localized in Platform.Bible. */\nexport function isLocalizeKey(str: string): str is LocalizeKey {\n return startsWith(str, '%') && endsWith(str, '%');\n}\n\n/**\n * Escape RegExp special characters.\n *\n * You can also use this to escape a string that is inserted into the middle of a regex, for\n * example, into a character class.\n *\n * All credit to [`escape-string-regexp`](https://www.npmjs.com/package/escape-string-regexp) - this\n * function is simply copied directly from there to allow a common js export\n *\n * @example\n *\n * import escapeStringRegexp from 'platform-bible-utils';\n *\n * const escapedString = escapeStringRegexp('How much $ for a 🦄?');\n * //=> 'How much \\\\$ for a 🦄\\\\?'\n *\n * new RegExp(escapedString);\n */\nexport function escapeStringRegexp(string: string): string {\n if (typeof string !== 'string') {\n throw new TypeError('Expected a string');\n }\n\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions, ensuring that\n * the result is always an array.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - If the input is an array containing nested arrays, it converts each string in the nested arrays\n * into `RegExp` objects.\n * - Ensures that the result is always an array of `RegExp` objects or arrays of `RegExp` objects.\n *\n * @param stringStringMaybeArray - The value to be transformed, which can be a single string, an\n * array of strings or arrays of strings, or `undefined`.\n * @returns An array of `RegExp` objects or arrays of `RegExp` objects. If the input is `undefined`,\n * an empty array is returned.\n */\nexport function transformAndEnsureRegExpRegExpArray(\n stringStringMaybeArray: string | (string | string[])[] | undefined,\n): (RegExp | RegExp[])[] {\n if (!stringStringMaybeArray) return [];\n\n const stringStringArray = ensureArray(stringStringMaybeArray);\n\n const regExpRegExpArray = stringStringArray.map((stringMaybeStringArray: string | string[]) =>\n Array.isArray(stringMaybeStringArray)\n ? stringMaybeStringArray.map((str) => new RegExp(str))\n : new RegExp(stringMaybeStringArray),\n );\n\n return regExpRegExpArray;\n}\n\n/**\n * Transforms a string or an array of strings into an array of regular expressions.\n *\n * This function accepts a value that may be a single string, an array of strings, or `undefined`.\n * It then:\n *\n * - Converts each string into a `RegExp` object.\n * - Ensures that the result is always an array of `RegExp` objects.\n *\n * @param stringMaybeArray - The value to be transformed, which can be a single string, an array of\n * strings, or `undefined`.\n * @returns An array of `RegExp` objects. If the input is `undefined`, an empty array is returned.\n */\nexport function transformAndEnsureRegExpArray(\n stringMaybeArray: string | string[] | undefined,\n): RegExp[] {\n if (!stringMaybeArray) return [];\n\n const stringArray = ensureArray(stringMaybeArray);\n\n const regExpArray = stringArray.map((str: string) => new RegExp(str));\n\n return regExpArray;\n}\n\nconst whiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/;\n/**\n * Determines whether a string contains one or more white space characters and no other characters.\n *\n * This implementation uses [dotnet's `Char.IsWhiteSpace` definition of white\n * space](https://learn.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=net-9.0):\n *\n * ```ts\n * /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\u0085]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: This differs from\n * [`/\\s/.test(ch)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes#:~:text=Matches%20a%20single%20white%20space%20character%2C%20including%20space)\n * (usually considered the determiner of what is white space in JavaScript) in that it does not\n * include ZWNBSP (U+FEFF) but rather includes NEXT LINE (U+0085)\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more white space characters and no other\n * characters, `false` otherwise\n */\nexport function isWhiteSpace(ch: string) {\n return whiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts PascalCase or camelCase string to kebab-case. To detect upper- and lower-case\n * characters, uses `.toUpperCase` and `.toLowerCase` to be locale-independent.\n *\n * Current implementation supports only UTF-16.\n *\n * Thanks to ChatGPT https://chatgpt.com/share/67c8aa44-e054-800c-8068-e1e6630081f7\n */\nexport function toKebabCase(input: string): string {\n let result = '';\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n const isUpper = char === char.toUpperCase() && char !== char.toLowerCase();\n\n if (isUpper) {\n if (i > 0) {\n const prevChar = input[i - 1];\n const isPrevUpper =\n prevChar === prevChar.toUpperCase() && prevChar !== prevChar.toLowerCase();\n\n // If previous is not uppercase, always insert dash.\n if (!isPrevUpper) {\n result += '-';\n } else if (i + 1 < input.length) {\n // Deal with initialisms and acronyms as if they are whole words (\"APIFinder\" -> \"api-finder\")\n // Previous was uppercase; insert dash only if the next character exists and is lowercase.\n const nextChar = input[i + 1];\n const isNextLower =\n nextChar === nextChar.toLowerCase() && nextChar !== nextChar.toUpperCase();\n if (isNextLower) {\n result += '-';\n }\n }\n }\n result += char.toLowerCase();\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n/** This is an internal-only export for testing purposes and should not be used in development */\nexport const testingStringUtils = {\n indexOfClosestClosingCurlyBrace,\n};\n","import { Canon, SerializedVerseRef, VerseRef } from '@sillsdev/scripture';\nimport {\n MarkerContent,\n MarkerObject,\n Usj,\n USJ_TYPE,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { BookInfo, ScrollGroupId } from './scripture.model';\nimport { at, isWhiteSpace, slice, split, startsWith } from '../string-util';\nimport { LocalizeKey } from '../extension-contributions/menus.model';\nimport { isString } from '../util';\n\n/**\n * All marker types that seem to be block-level according to `UsxFragmenter.AppendStartUsfm`. And\n * the `type` for USJ documents' top-level object because that is effectively a block\n *\n * Note: This \"block-level\" means the marker is in its own paragraph (a [CSS\n * Block](https://developer.mozilla.org/en-US/docs/Glossary/Block/CSS)) as opposed to being\n * in-line.\n */\nconst BLOCK_MARKER_TYPES = ['chapter', 'book', 'para', 'row', 'sidebar', USJ_TYPE];\n\nconst ZWSP = '\\u200B';\n\nconst scrBookData: BookInfo[] = [\n { shortName: 'ERR', fullNames: ['ERROR'], chapters: -1 },\n { shortName: 'GEN', fullNames: ['Genesis'], chapters: 50 },\n { shortName: 'EXO', fullNames: ['Exodus'], chapters: 40 },\n { shortName: 'LEV', fullNames: ['Leviticus'], chapters: 27 },\n { shortName: 'NUM', fullNames: ['Numbers'], chapters: 36 },\n { shortName: 'DEU', fullNames: ['Deuteronomy'], chapters: 34 },\n { shortName: 'JOS', fullNames: ['Joshua'], chapters: 24 },\n { shortName: 'JDG', fullNames: ['Judges'], chapters: 21 },\n { shortName: 'RUT', fullNames: ['Ruth'], chapters: 4 },\n { shortName: '1SA', fullNames: ['1 Samuel'], chapters: 31 },\n { shortName: '2SA', fullNames: ['2 Samuel'], chapters: 24 },\n { shortName: '1KI', fullNames: ['1 Kings'], chapters: 22 },\n { shortName: '2KI', fullNames: ['2 Kings'], chapters: 25 },\n { shortName: '1CH', fullNames: ['1 Chronicles'], chapters: 29 },\n { shortName: '2CH', fullNames: ['2 Chronicles'], chapters: 36 },\n { shortName: 'EZR', fullNames: ['Ezra'], chapters: 10 },\n { shortName: 'NEH', fullNames: ['Nehemiah'], chapters: 13 },\n { shortName: 'EST', fullNames: ['Esther'], chapters: 10 },\n { shortName: 'JOB', fullNames: ['Job'], chapters: 42 },\n { shortName: 'PSA', fullNames: ['Psalm', 'Psalms'], chapters: 150 },\n { shortName: 'PRO', fullNames: ['Proverbs'], chapters: 31 },\n { shortName: 'ECC', fullNames: ['Ecclesiastes'], chapters: 12 },\n { shortName: 'SNG', fullNames: ['Song of Solomon', 'Song of Songs'], chapters: 8 },\n { shortName: 'ISA', fullNames: ['Isaiah'], chapters: 66 },\n { shortName: 'JER', fullNames: ['Jeremiah'], chapters: 52 },\n { shortName: 'LAM', fullNames: ['Lamentations'], chapters: 5 },\n { shortName: 'EZK', fullNames: ['Ezekiel'], chapters: 48 },\n { shortName: 'DAN', fullNames: ['Daniel'], chapters: 12 },\n { shortName: 'HOS', fullNames: ['Hosea'], chapters: 14 },\n { shortName: 'JOL', fullNames: ['Joel'], chapters: 3 },\n { shortName: 'AMO', fullNames: ['Amos'], chapters: 9 },\n { shortName: 'OBA', fullNames: ['Obadiah'], chapters: 1 },\n { shortName: 'JON', fullNames: ['Jonah'], chapters: 4 },\n { shortName: 'MIC', fullNames: ['Micah'], chapters: 7 },\n { shortName: 'NAM', fullNames: ['Nahum'], chapters: 3 },\n { shortName: 'HAB', fullNames: ['Habakkuk'], chapters: 3 },\n { shortName: 'ZEP', fullNames: ['Zephaniah'], chapters: 3 },\n { shortName: 'HAG', fullNames: ['Haggai'], chapters: 2 },\n { shortName: 'ZEC', fullNames: ['Zechariah'], chapters: 14 },\n { shortName: 'MAL', fullNames: ['Malachi'], chapters: 4 },\n { shortName: 'MAT', fullNames: ['Matthew'], chapters: 28 },\n { shortName: 'MRK', fullNames: ['Mark'], chapters: 16 },\n { shortName: 'LUK', fullNames: ['Luke'], chapters: 24 },\n { shortName: 'JHN', fullNames: ['John'], chapters: 21 },\n { shortName: 'ACT', fullNames: ['Acts'], chapters: 28 },\n { shortName: 'ROM', fullNames: ['Romans'], chapters: 16 },\n { shortName: '1CO', fullNames: ['1 Corinthians'], chapters: 16 },\n { shortName: '2CO', fullNames: ['2 Corinthians'], chapters: 13 },\n { shortName: 'GAL', fullNames: ['Galatians'], chapters: 6 },\n { shortName: 'EPH', fullNames: ['Ephesians'], chapters: 6 },\n { shortName: 'PHP', fullNames: ['Philippians'], chapters: 4 },\n { shortName: 'COL', fullNames: ['Colossians'], chapters: 4 },\n { shortName: '1TH', fullNames: ['1 Thessalonians'], chapters: 5 },\n { shortName: '2TH', fullNames: ['2 Thessalonians'], chapters: 3 },\n { shortName: '1TI', fullNames: ['1 Timothy'], chapters: 6 },\n { shortName: '2TI', fullNames: ['2 Timothy'], chapters: 4 },\n { shortName: 'TIT', fullNames: ['Titus'], chapters: 3 },\n { shortName: 'PHM', fullNames: ['Philemon'], chapters: 1 },\n { shortName: 'HEB', fullNames: ['Hebrews'], chapters: 13 },\n { shortName: 'JAS', fullNames: ['James'], chapters: 5 },\n { shortName: '1PE', fullNames: ['1 Peter'], chapters: 5 },\n { shortName: '2PE', fullNames: ['2 Peter'], chapters: 3 },\n { shortName: '1JN', fullNames: ['1 John'], chapters: 5 },\n { shortName: '2JN', fullNames: ['2 John'], chapters: 1 },\n { shortName: '3JN', fullNames: ['3 John'], chapters: 1 },\n { shortName: 'JUD', fullNames: ['Jude'], chapters: 1 },\n { shortName: 'REV', fullNames: ['Revelation'], chapters: 22 },\n];\n\n/** The first book number */\nexport const FIRST_SCR_BOOK_NUM = 1;\n/** The last book number */\nexport const LAST_SCR_BOOK_NUM = scrBookData.length - 1;\n/** The first chapter number */\nexport const FIRST_SCR_CHAPTER_NUM = 1;\n/** The first verse number */\nexport const FIRST_SCR_VERSE_NUM = 1;\n\n/** The default Scripture reference, representing the first chapter and verse of the first book. */\nexport const defaultScrRef: SerializedVerseRef = {\n book: 'GEN',\n chapterNum: 1,\n verseNum: 1,\n};\n\n/**\n * Retrieves the number of chapters for a given book number.\n *\n * @param bookNum The number representing the book.\n * @returns The number of chapters in the book, or -1 if the book number is invalid.\n */\nexport const getChaptersForBook = (bookNum: number): number => {\n return scrBookData[bookNum]?.chapters ?? -1;\n};\n\n/**\n * Adjusts the book of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose book is to be adjusted.\n * @param offset The number of books to offset the current book by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted book. The chapter and verse numbers are\n * reset to 1. If the resulting book number exceeds the bounds of available books, it is clamped\n * to the nearest valid book.\n */\nexport const offsetBook = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n book: Canon.bookNumberToId(\n Math.max(\n FIRST_SCR_BOOK_NUM,\n Math.min(Canon.bookIdToNumber(scrRef.book) + offset, LAST_SCR_BOOK_NUM),\n ),\n ),\n chapterNum: 1,\n verseNum: 1,\n});\n\n/**\n * Adjusts the chapter of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose chapter is to be adjusted.\n * @param offset The number of chapters to offset the current chapter by. Positive values move\n * forward, negative values move backward.\n * @returns A new Scripture reference with the adjusted chapter. The verse number is reset to 1. The\n * chapter number is clamped to stay within valid bounds for the book.\n */\nexport const offsetChapter = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n chapterNum: Math.min(\n Math.max(FIRST_SCR_CHAPTER_NUM, scrRef.chapterNum + offset),\n getChaptersForBook(Canon.bookIdToNumber(scrRef.book)),\n ),\n verseNum: 1,\n});\n\n/**\n * Adjusts the verse of a Scripture reference by a specified offset.\n *\n * @param scrRef The Scripture reference whose verse is to be adjusted.\n * @param offset The number of verses to offset the current verse by. Positive values move forward,\n * negative values move backward.\n * @returns A new Scripture reference with the adjusted verse. The verse number is clamped to stay\n * within valid bounds for the chapter.\n */\nexport const offsetVerse = (scrRef: SerializedVerseRef, offset: number): SerializedVerseRef => ({\n ...scrRef,\n verseNum: Math.max(FIRST_SCR_VERSE_NUM, scrRef.verseNum + offset),\n});\n\n/**\n * https://github.com/ubsicap/Paratext/blob/master/ParatextData/SILScriptureExtensions.cs#L72\n *\n * Convert book number to a localized Id (a short description of the book). This should be used\n * whenever a book ID (short code) is shown to the user. It is primarily needed for people who do\n * not read Roman script well and need to have books identified in a alternate script (e.g. Chinese\n * or Russian)\n *\n * @param bookNumber\n * @param localizationLanguage In BCP 47 format\n * @param getLocalizedString Function that provides the localized versions of the book ids and names\n * asynchronously.\n * @returns\n */\nexport async function getLocalizedIdFromBookNumber(\n bookNumber: number,\n localizationLanguage: string,\n getLocalizedString: (item: {\n localizeKey: string;\n languagesToSearch?: string[];\n }) => Promise,\n) {\n const id = Canon.bookNumberToId(bookNumber);\n\n if (!startsWith(Intl.getCanonicalLocales(localizationLanguage)[0], 'zh'))\n return getLocalizedString({\n localizeKey: `LocalizedId.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n\n // For Chinese the normal book name is already fairly short.\n const bookName = await getLocalizedString({\n localizeKey: `Book.${id}`,\n languagesToSearch: [localizationLanguage],\n });\n const parts = split(bookName, '-');\n // some entries had a second name inside ideographic parenthesis\n const parts2 = split(parts[0], '\\xff08');\n const retVal = parts2[0].trim();\n return retVal;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer, without considering the\n * verse.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCC(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum).BBBCCC;\n}\n\n/**\n * Get the Scripture reference as an easily comparable/sortable integer.\n *\n * @param scrRef The Scripture reference.\n * @returns An integer where the first three digits represent the book, the next three represent the\n * chapter and the last three represent the verse.\n */\nexport function scrRefToBBBCCCVVV(scrRef: SerializedVerseRef): number {\n return new VerseRef(Canon.bookIdToNumber(scrRef.book), scrRef.chapterNum, scrRef.verseNum)\n .BBBCCCVVV;\n}\n\n/**\n * Compares two Scripture references canonically.\n *\n * @param scrRef1 The first Scripture reference to compare.\n * @param scrRef2 The second Scripture reference to compare.\n * @returns A number indicating the result of the comparison: - Negative value if scrRef1 precedes\n * scrRef2 in sorting order. - Zero if scrRef1 and scrRef2 are equivalent in sorting order. -\n * Positive value if scrRef1 follows scrRef2 in sorting order.\n */\nexport function compareScrRefs(scrRef1: SerializedVerseRef, scrRef2: SerializedVerseRef): number {\n // TODO: consider edge cases for invalid references (current implementation should suffice for\n // all but the most extreme cases)\n return scrRefToBBBCCCVVV(scrRef1) - scrRefToBBBCCCVVV(scrRef2);\n}\n\n/** Get the localized string key for a given scroll group Id (or no scroll group if `undefined`) */\nexport function getLocalizeKeyForScrollGroupId(\n scrollGroupId: ScrollGroupId | undefined | 'undefined',\n): LocalizeKey {\n return `%scrollGroup_${scrollGroupId}%`;\n}\n\n/**\n * Gets a list of localized string keys for provided scroll group Ids. Uses\n * {@link getLocalizeKeyForScrollGroupId} internally\n *\n * @example\n *\n * ```typescript\n * getLocalizeKeysForScrollGroupIds([undefined, 0, 1, 2, 3, 4]);\n * // Gives localized string keys for the provided scroll group ids in an array\n * ```\n *\n * @param scrollGroupIds Scroll group ids to include\n * @returns List of localized string keys for scroll group Ids\n */\nexport function getLocalizeKeysForScrollGroupIds(scrollGroupIds: (ScrollGroupId | undefined)[]) {\n return scrollGroupIds.map((scrollGroupId) => getLocalizeKeyForScrollGroupId(scrollGroupId));\n}\n\n/**\n * Formats a Scripture reference.\n *\n * @param scrRef The Scripture reference to format.\n * @param optionOrLocalizedBookName Either 'id' (the default) to format using the \"standard\" (as\n * defined by SIL/UBS) 3-letter book ID, 'English' to format using the English book name spelled\n * out, or some other string (e.g., a localized book name, vernacular abbreviation, FCBH book id,\n * etc.) to use.\n * @param chapterVerseSeparator The character used to separate the chapter number from the verse\n * number. Default is a colon (:). Note: More than one character is allowed.\n * @param bookChapterSeparator The character used to separate the book from the chapter number.\n * Default is a single space. Note: More than one character is allowed.\n * @returns The formatted reference.\n */\nexport function formatScrRef(\n scrRef: SerializedVerseRef,\n optionOrLocalizedBookName?: 'id' | 'English' | string,\n chapterVerseSeparator?: string,\n bookChapterSeparator?: string,\n): string {\n let book: string;\n switch (optionOrLocalizedBookName ?? 'id') {\n case 'English':\n book = Canon.bookIdToEnglishName(scrRef.book);\n break;\n case 'id':\n book = scrRef.book;\n break;\n default:\n // We already dealt with undefined about in the switch, but TS is getting confused.\n book = optionOrLocalizedBookName ?? '';\n break;\n }\n return `${book}${bookChapterSeparator ?? ' '}${scrRef.chapterNum}${chapterVerseSeparator ?? ':'}${scrRef.verseNum}`;\n}\n\n/**\n * Represents the major sections of the Bible and extra materials. Used for grouping and filtering\n * books in the book selector.\n */\nexport enum Section {\n /** Old Testament books (Genesis through Malachi) */\n OT = 'OT',\n /** New Testament books (Matthew through Revelation) */\n NT = 'NT',\n /** Deuterocanonical books (e.g. Tobit, Judith, 1-2 Maccabees) */\n DC = 'DC',\n /** Additional materials not part of the biblical canon (e.g. XXA, XXB etc.) */\n Extra = 'Extra',\n}\n\n/**\n * Determines which section a book belongs to based on its ID\n *\n * @param bookId The ID of the book (e.g., 'GEN', 'MAT')\n * @returns The section (OT, NT, DC, or Extra) that the book belongs to\n * @throws Error if the book ID is not recognized or cannot be categorized\n */\nexport const getSectionForBook = (bookId: string): Section => {\n if (Canon.isBookOT(bookId)) return Section.OT;\n if (Canon.isBookNT(bookId)) return Section.NT;\n if (Canon.isBookDC(bookId)) return Section.DC;\n if (Canon.isExtraMaterial(bookId)) return Section.Extra;\n\n throw new Error(`Unknown section for book: ${bookId}`);\n};\n\n// #region white space functions\n\nconst nonSemanticWhiteSpaceRegex =\n // Using unicode control characters to be very explicit about which characters we are using.\n // The first 6 characters are the control characters \\f\\n\\r\\t\\v.\n // eslint-disable-next-line no-control-regex\n /^[\\u000C\\u000A\\u000D\\u0009\\u000B\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u200B\\u0085]+$/;\n/**\n * Determines whether a string contains one or more \"non-meaningful\" white space characters\n * according to `ParatextData.dll` and no other characters.\n *\n * \"Non-meaningful\" white space according to `ParatextData.dll` is white space (according to\n * {@link isWhiteSpace}) other than IDEOGRAPHIC SPACE (U+3000) and also includes ZWSP (U+200B)\n *\n * This function is a direct translation of `UsfmToken.IsNonSemanticWhiteSpace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more \"non-meaningful\" white space characters and\n * no other characters, `false` otherwise\n */\nfunction isNonSemanticWhiteSpace(ch: string) {\n return nonSemanticWhiteSpaceRegex.test(ch);\n}\n\n// Note Zero-width joiner is at the start because eslint thinks we're trying to test for joined\n// characters if it's in the middle. https://eslint.org/docs/latest/rules/no-misleading-character-class\nconst invisibleCharOrWhiteSpaceRegex =\n /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/;\n/**\n * Determines whether a string contains one or more Paratext-9-selectable invisible characters or\n * white space characters and no other characters.\n *\n * Paratext-9-selectable invisible characters or white space characters are characters listed in\n * [Paratext 9's \"Whitespace and invisible characters\n * drop-down\"](https://paratext.myjetbrains.com/youtrack/issue/PTX-23623) that the user can insert\n * into the text:\n *\n * ```ts\n * // Zero-width joiner, em space, en space, space, no-break space, narrow no-break space,\n * // thin space, hair space, ideographic space, zero-width space, zero-width non-joiner,\n * // word joiner, left-to-right mark, right-to-left mark\n * /^[\\u200d\\u2003\\u2002\\u0020\\u00a0\\u202f\\u2009\\u200a\\u3000\\u200b\\u200c\\u2060\\u200e\\u200f]+$/.test(\n * ch,\n * );\n * ```\n *\n * Note: more white space characters are supported in Paratext 9 but are not listed in this\n * dropdown. See {@link isWhiteSpace} for more information.\n *\n * This function is a direct translation of `CharExtensions.IsInvisibleCharOrWhitespace` from\n * `ParatextData.dll`\n *\n * @param ch Single character or a string of characters\n * @returns `true` if the string consists of one or more Paratext-9-selectable invisible characters\n * or white space characters and no other characters, `false` otherwise\n */\nfunction isParatextSelectableInvisibleCharOrWhiteSpace(ch: string) {\n return invisibleCharOrWhiteSpaceRegex.test(ch);\n}\n\n/**\n * Converts all control characters, carriage returns, and tabs into spaces and then strips duplicate\n * spaces.\n *\n * This is mainly intended for use with individual Scripture strings in USFM, USX, USJ, etc. format.\n * It is not intended to implement the [USFM white space definition or reduction\n * rules](https://docs.usfm.bible/usfm/3.1/whitespace.html) but strictly follows Paratext 9's white\n * space rules. It is generally best suited to normalizing spaces within a Scripture marker as it\n * removes all newlines.\n *\n * This function is a direct translation of `UsfmToken.RegularizeSpaces` from `ParatextData.dll`\n */\nexport function normalizeScriptureSpaces(str: string): string {\n let result = '';\n let lastCharWasSpace = false;\n // Initialized to placeholder previous character\n let prevCh = '\\0';\n for (let i = 0; i < str.length; i += 1) {\n const ch = str[i];\n // Control characters, CR/LF, and TAB become spaces\n if (ch.charCodeAt(0) < 32) {\n if (!lastCharWasSpace) result += ' ';\n lastCharWasSpace = true;\n } else if (\n !lastCharWasSpace &&\n ch === ZWSP &&\n i + 1 < str.length &&\n isNonSemanticWhiteSpace(str[i + 1])\n ) {\n // ZWSP is redundant if followed by a space\n } else if (isNonSemanticWhiteSpace(ch)) {\n // Keep other kinds of spaces\n if (!lastCharWasSpace) result += ch;\n lastCharWasSpace = true;\n } else if (isParatextSelectableInvisibleCharOrWhiteSpace(ch) && prevCh === ch) {\n // If the char is a whitespace or invisible char that has not already been handled and is a\n // duplicate, remove the duplicate\n } else {\n result += ch;\n lastCharWasSpace = false;\n }\n\n prevCh = ch;\n }\n\n return result;\n}\n\n/**\n * Determines whether the array of marker contents is \"empty\" meaning it is undefined, is an empty\n * array, or has just `undefined` or `''` in it\n *\n * Paratext passed up \"\\va \\va*\" which had no content array coming in translated to USJ, but the\n * editor put a content array with an empty string. So this will help them be considered equal.\n */\nfunction isUsjContentEmpty(content: MarkerContent[] | undefined) {\n if (!content) return true;\n if (content.length === 0) return true;\n return content.length === 1 && (content[0] === undefined || content[0] === '');\n}\n\n/**\n * Determines if the content object is the final child of a parent that is a block-level marker.\n *\n * We do not need to walk up the ancestors to the _closest_ block marker because spaces are\n * preserved at the end of in-line markers even at the end of a paragraph. We just need to know if\n * the parent is a block marker because space at the end of a block marker is not preserved.\n *\n * @param contentObject USJ document or marker to check\n * @param parent Parent object of `contentObject`. If `contentObject` is a USJ document, this should\n * be `undefined`.\n * @returns `true` if `contentObject` is the final child of the closest block-level marker; `false`\n * otherwise\n */\nfunction isAtEndOfBlockMarker(\n contentObject: MarkerContent | Usj,\n parent: MarkerObject | Usj | undefined,\n) {\n if (!parent) return false;\n // If the parent is not a block-level marker, the content object is not at the end of a block-level marker\n if (!BLOCK_MARKER_TYPES.includes(parent.type)) return false;\n\n if (!parent.content)\n throw new Error(\n `Parent ${JSON.stringify(parent)} of ${JSON.stringify(contentObject)} does not have a content array! This should not happen!`,\n );\n // If the content object is not the last in its parent, it is not at the end of a block-level marker\n if (contentObject !== parent.content[parent.content.length - 1]) return false;\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n *\n * @param a First USJ document or marker to compare\n * @param aParent Parent object of `a`. If `a` is a USJ document, this should be `undefined`.\n * @param b Second USJ document or marker to compare\n * @param bParent Parent object of `b`. If `b` is a USJ document, this should be `undefined`.\n */\nfunction areUsjContentsEqualExceptWhitespaceInternal(\n a: MarkerContent | Usj | undefined,\n aParent: MarkerObject | Usj | undefined,\n b: MarkerContent | Usj | undefined,\n bParent: MarkerObject | Usj | undefined,\n) {\n if (!a && !b) return true;\n if (!a || !b) return false;\n\n const aIsString = isString(a);\n const bIsString = isString(b);\n if (aIsString && bIsString) {\n const aNormalized = normalizeScriptureSpaces(a);\n const bNormalized = normalizeScriptureSpaces(b);\n // Check to see if their regularized forms are equal. If so, they're equal. If not, they may still\n // be equal if they are at the end of a block-level marker and the only difference is space at the end.\n // If at the end of a block-level marker with space at the end, take off the final space and compare again\n if (aNormalized !== bNormalized) {\n // If neither ends in whitespace, they are not equal\n if (!isWhiteSpace(at(aNormalized, -1) ?? '') && !isWhiteSpace(at(bNormalized, -1) ?? ''))\n return false;\n\n // If either is not at the end of a block-level marker, they are not equal\n if (!isAtEndOfBlockMarker(a, aParent)) return false;\n if (!isAtEndOfBlockMarker(b, bParent)) return false;\n\n // Trim the end of each string\n let aTrimmed = aNormalized;\n while (isWhiteSpace(at(aTrimmed, -1) ?? '')) aTrimmed = slice(aTrimmed, 0, -1);\n let bTrimmed = bNormalized;\n while (isWhiteSpace(at(bTrimmed, -1) ?? '')) bTrimmed = slice(bTrimmed, 0, -1);\n // If they are not equal after trimming, they are not equal\n if (aTrimmed !== bTrimmed) return false;\n }\n } else if (!aIsString && !bIsString) {\n // We have determined they are not strings, so they must be objects with various simple properties and possibly a `content` array\n const aObject: MarkerObject | Usj = a;\n const bObject: MarkerObject | Usj = b;\n // Check if all properties are present and equal. We will check `content` separately\n // Seems Object.keys doesn't support proper key typing? Asserting to the key types\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const aKeys = Object.keys(aObject).filter(\n (key) => key !== 'content',\n ) as (keyof typeof aObject)[];\n if (aKeys.length !== Object.keys(bObject).filter((key) => key !== 'content').length)\n return false;\n if (aKeys.some((key) => !(key in bObject) || aObject[key] !== bObject[key])) return false;\n\n // Check that both `content`s are equal\n const isAContentEmpty = isUsjContentEmpty(aObject.content);\n const isBContentEmpty = isUsjContentEmpty(bObject.content);\n // If one is empty and the other is not, they are not equal\n if (isAContentEmpty !== isBContentEmpty) return false;\n // If both are empty, they are equal. If neither is empty, do more testing\n if (!isAContentEmpty && !isBContentEmpty) {\n // Although TypeScript doesn't realize `!isUsjContentEmpty(a)` means a is an array, we know\n // they are both arrays, so we can access the content with a bang.\n /* eslint-disable no-type-assertion/no-type-assertion */\n let aContent: MarkerContent[] = aObject.content!;\n let bContent: MarkerContent[] = bObject.content!;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const aLast = aContent[aContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(aObject.type) && isString(aLast) && isWhiteSpace(aLast))\n aContent = aContent.slice(0, -1);\n\n // If either of the two contents is block-level and has an extra whitespace string at the end, remove it\n const bLast = bContent[bContent.length - 1];\n if (BLOCK_MARKER_TYPES.includes(bObject.type) && isString(bLast) && isWhiteSpace(bLast))\n bContent = bContent.slice(0, -1);\n\n if (aContent.length !== bContent.length) return false;\n for (let i = 0; i < aContent.length; i += 1) {\n if (\n !areUsjContentsEqualExceptWhitespaceInternal(aContent[i], aObject, bContent[i], bObject)\n )\n return false;\n }\n }\n } else {\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if the USJ documents or markers (and all contents) are equivalent after regularizing\n * spaces according to the way `ParatextData.dll` does.\n *\n * Note that this will not work properly if there ever exist any properties of USJ document or USJ\n * markers other than `content` that are complex objects like arrays or objects as the properties\n * are shallow equaled.\n */\nexport function areUsjContentsEqualExceptWhitespace(a: Usj | undefined, b: Usj | undefined) {\n return areUsjContentsEqualExceptWhitespaceInternal(a, undefined, b, undefined);\n}\n\n// #endregion\n","/** Function to run to dispose of something. Returns true if successfully unsubscribed */\nexport type Unsubscriber = () => boolean;\n\n/**\n * Returns an Unsubscriber function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers All unsubscribers to aggregate into one unsubscriber\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscribers = (unsubscribers: Unsubscriber[]): Unsubscriber => {\n return (...args) => {\n // Run the unsubscriber for each handler\n const unsubs = unsubscribers.map((unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return unsubs.every((success) => success);\n };\n};\n\n/**\n * Function to run to dispose of something that runs asynchronously. The promise resolves to true if\n * successfully unsubscribed\n */\nexport type UnsubscriberAsync = () => Promise;\n\n/**\n * Returns an UnsubscriberAsync function that combines all the unsubscribers passed in.\n *\n * @param unsubscribers - All unsubscribers to aggregate into one unsubscriber.\n * @returns Function that unsubscribes from all passed in unsubscribers when run\n */\nexport const aggregateUnsubscriberAsyncs = (\n unsubscribers: (UnsubscriberAsync | Unsubscriber)[],\n): UnsubscriberAsync => {\n return async (...args) => {\n // Run the unsubscriber for each handler\n const unsubPromises = unsubscribers.map(async (unsubscriber) => unsubscriber(...args));\n\n // If all the unsubscribers resolve to truthiness, we succeed\n return (await Promise.all(unsubPromises)).every((success) => success);\n };\n};\n","import {\n Usj,\n type MarkerContent,\n type MarkerObject,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { MarkersMap } from './markers-maps/markers-map-3.0.model';\n\n/** USJ content node type for a book */\nexport const BOOK_TYPE = 'book';\n\n/** USJ content node type for a chapter */\nexport const CHAPTER_TYPE = 'chapter';\n\n/** USJ content node type for a verse */\nexport const VERSE_TYPE = 'verse';\n\n/** 3-character code that indicates there is no known book */\nexport const NO_BOOK_ID = '***';\n\n/**\n * Represents a book, chapter, verse, and offset\n *\n * @deprecated 23 October 2025. Use {@link UsfmVerseLocation} or {@link UsfmVerseRefVerseLocation}\n * instead.\n */\nexport type VerseRefOffset = {\n verseRef: SerializedVerseRef;\n offset: number;\n};\n\n// #region Serializable USFM locations\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. If only a verse ref is provided, the offset is assumed to be 0.\n *\n * The USJ representation of the positions represented by this type are {@link UsjLocation}. Both are\n * absolute verse reference locations.\n *\n * {@link UsjDocumentLocation} also represents positions of this type, but those locations are\n * relative to a specific USJ document rather than being absolute verse reference locations like\n * this type. The closest equivalent concept in USFM to {@link UsjDocumentLocation} is a string\n * character index in a USFM document; such an index is relative to a specific USFM document rather\n * than indicating an absolute position in a Scripture text.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsfmScrRefVerseLocation} for details.\n */\nexport type UsfmVerseLocation =\n | UsfmVerseRefVerseLocation\n | SerializedVerseRef\n | UsfmScrRefVerseLocation;\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM\n */\nexport type UsfmVerseRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n verseRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n/**\n * A verse ref and an offset within that verse in USFM space that point to a specific location in\n * USFM. This uses `scrRef` instead of `verseRef` for backwards compatibility.\n *\n * @deprecated 13 November 2025. Use {@link UsfmVerseLocation} instead.\n */\nexport type UsfmScrRefVerseLocation = {\n /** Verse reference indicating which verse the location is in */\n scrRef: SerializedVerseRef;\n /**\n * Offset to apply to start of the verse indicated by `verseRef`.\n *\n * If the verse is 0, offset 0 is the start of the chapter. If the verse is greater than 0, offset\n * 0 is the backslash on the verse marker.\n *\n * If not provided, defaults to 0.\n */\n offset?: number;\n};\n\n// #endregion Serializable USFM locations\n\n// #region Serializable absolute USJ locations\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from either the start of the book or the chapter\n * depending on the type of location used.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the following USJ documents:\n *\n * - {@link UsjBookLocation} - a USJ document that contains the entire specified book. The first\n * content entry of the top-level `USJ` marker is the `id` marker of the book.\n * - {@link UsjChapterLocation} - a USJ document that contains only the specified chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjLocation =\n | UsjChapterLocation\n | UsjBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the book specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains the entire specified book. The first content entry of the top-level `USJ` marker is the\n * `id` marker of the book.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjBookLocation =\n | UsjVerseRefBookLocation\n | UsjFlatBookLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space should be interpreted as starting from the start of the chapter specified.\n *\n * The USFM representation of the positions represented by this type are {@link UsfmVerseLocation}.\n *\n * The locations in USJ space are specified as {@link UsjDocumentLocation}s, which, on their own, are\n * relative to a specific USJ document. However, the other information in this type specifies which\n * USJ document the document location is relative to, meaning this location is an absolute verse\n * reference location.\n *\n * The JSONPaths in these USJ-based locations are specified relative to the USJ document that\n * contains only the specified chapter in the specified book. If the chapter number is 1, the first\n * content entry of the top-level `USJ` marker is the `id` marker of the book because the intro\n * content before chapter 1 is part of chapter 1. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types; see\n * {@link UsjDocumentLocation} for more information.\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n *\n * Note: some forms of this type are deprecated and will be removed eventually; see\n * {@link UsjFlatTextChapterLocation} for details. Also note that {@link UsjFlatTextChapterLocation}\n * can only be a marker- or text-based location and will _not_ follow the generic type specified as\n * `TDocumentLocation`.\n */\nexport type UsjChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> =\n | UsjVerseRefChapterLocation\n | UsjFlatChapterLocation\n | UsjFlatTextChapterLocation;\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified in the verse ref. The rest of the verse ref\n * is meaningless and can be disregarded.\n */\nexport type UsjVerseRefBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book because the intro content before chapter 1 is part of\n * chapter 1. If the chapter number is greater than 1, the first content entry of the top-level\n * `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * Defaults to 'chapter' (see {@link UsjVerseRefChapterLocation})\n */\n granularity: 'book';\n /** USJ document location specifying where in the book the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A verse ref and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the chapter specified in the verse ref. The rest of the verse\n * ref is meaningless and can be disregarded.\n */\nexport type UsjVerseRefChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Verse reference indicating which chapter in which book the document location is in */\n verseRef: SerializedVerseRef;\n /**\n * Specifies which part of the verse reference the document location is relative to:\n *\n * - `book` = document location is specified relative to the start of the book. The first content\n * entry of the top-level `USJ` marker is the `id` marker of the book\n * - `chapter` = document location is specified relative to the start of the chapter in the\n * specified book. If the chapter number is 1, the first content entry of the top-level `USJ`\n * marker is the `id` marker of the book. If the chapter number is greater than 1, the first\n * content entry of the top-level `USJ` marker is the `c` marker of the chapter\n *\n * - Note: this is likely to be the case with peripheral books as well, but these books have\n * `periph` markers between `id` and chapters, so this may need to be revised when\n * peripheral books are more fully supported\n *\n * Defaults to 'chapter' (can alternatively be 'book'; {@link UsjVerseRefBookLocation})\n */\n granularity?: 'chapter';\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID and a location in USJ space that point to a specific location in USJ. The location in\n * USJ space starts from the start of the book specified.\n */\nexport type UsjFlatBookLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** USJ document location specifying where in the chapter the location is pointing to */\n documentLocation: TDocumentLocation;\n};\n\n/**\n * A book ID, chapter number, and location in USJ space that point to a specific location in USJ.\n * The location in USJ space starts from the start of the chapter specified.\n */\nexport type UsjFlatChapterLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = UsjFlatBookLocation & {\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n};\n\n/**\n * A book ID, chapter number, and text location or beginning of marker location in USJ space that\n * point to a specific location in USJ. The location in USJ space starts from the start of the\n * chapter specified. This can only represent the beginning of a marker or a location in the USJ\n * document's text content.\n *\n * @deprecated 13 November 2025. This type of location is not generic enough to support all\n * positions we need to be able to represent in USJ space. Use other forms of\n * {@link UsjChapterLocation} instead.\n */\nexport type UsjFlatTextChapterLocation = {\n /** Book ID indicating which book the document location is in */\n book: string;\n /** Chapter number indicating which chapter the document location is in */\n chapterNum: number;\n} & ((UsjMarkerLocation & { offset?: undefined }) | UsjTextContentLocation);\n\n// #endregion Serializable absolute USJ locations\n\n// #region Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * JSON path to a {@link MarkerObject}, {@link Usj}, or text content string in the current USJ\n * document.\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type ContentJsonPath =\n | ''\n | `$`\n | `$.content[${number}]`\n | `$.content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}]`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]`;\n\n/**\n * JSON path to the `marker` or an attribute on a {@link MarkerObject} or {@link Usj} in the current\n * USJ document. Note that it seems you must use `['bracket notation']` rather than `.dot` notation\n * if there are symbols other than underscore in the property name\n *\n * This could actually have more content clauses at the end, but TS types are limited\n */\nexport type PropertyJsonPath =\n | ''\n | `$.${string}`\n | `$['${string}']`\n | `$.content[${number}].${string}`\n | `$.content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}]['${string}']`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}].${string}`\n | `$.content[${number}].content[${number}].content[${number}].content[${number}]['${string}']`;\n\n/**\n * A JSONPath query to a {@link MarkerContent}, {@link Usj}, or property within a USJ document and\n * additional information that point to a specific location in that USJ document.\n *\n * This type does not include a verse reference because the JSONPath is relative to a specific USJ\n * document; that USJ document may have a book, a chapter, or something else in it. Use\n * {@link UsjLocation} to specify which USJ document this location is relative to, making the\n * location an absolute verse reference location. The closest equivalent concept in USFM to this\n * relative document location is a string character index in a USFM document; such an index is\n * relative to a specific USFM document rather than indicating an absolute position in a Scripture\n * text.\n *\n * This type intends to represent USFM positions ({@link UsfmVerseLocation}) in USJ space. However,\n * there are some USFM positions that are not currently representable with these types:\n *\n * - The second slash in `optbreak`'s USFM representation `//` (literally not representable)\n * - Nested marker prefix on opening markers like `+` for character markers (literally not\n * representable)\n * - The bar `|` that indicates the start of closing marker attributes (no official representation)\n * - The equals sign for closing marker attributes (no official representation)\n * - The quotes around closing marker attribute values (no official representation)\n * - The space between closing marker attributes (no official representation)\n *\n * Also note that the following types do not specify a concrete location that is actually in the USJ\n * document but represent a USFM location relative to the most similar thing in USJ that there is:\n *\n * - {@link UsjClosingMarkerLocation} - there are no distinct closing objects in JSON; there is a\n * common syntax for closing every object, but it is only one character and is on every single\n * object as opposed to USFM closing markers which are multiple characters long and are only\n * sometimes present.\n * - {@link UsjAttributeKeyLocation} - when the attribute whose key is being pointed to is an attribute\n * marker in USFM, the `keyOffset` does not apply to the USJ attribute name (e.g. `altnumber`) but\n * to the USFM attribute marker name (e.g. `ca`).\n * - {@link UsjAttributeMarkerLocation} - attribute markers are just properties in JSON; they do not\n * have their own object such that they would have an opening that can be pointed to in the JSON\n * like they have their own opening in USFM.\n * - {@link UsjClosingAttributeMarkerLocation} - attribute markers are just properties in JSON, plus\n * they are in the same situation as {@link UsjClosingMarkerLocation} as detailed above.\n *\n * To see many examples of the same point represented by both USFM and USJ locations, go to\n * https://github.com/paranext/paranext-core/tree/main/lib/platform-bible-utils/src/scripture/usj-reader-writer-test-data/testUSFM-2SA-1-locations.ts\n */\nexport type UsjDocumentLocation =\n | UsjMarkerLocation\n | UsjClosingMarkerLocation\n | UsjTextContentLocation\n | UsjPropertyValueLocation\n | UsjAttributeKeyLocation\n | UsjAttributeMarkerLocation\n | UsjClosingAttributeMarkerLocation;\n\n/**\n * A JSONPath query to a {@link MarkerObject} or {@link Usj} node. Indicates the very beginning of\n * that marker (at the backslash in USFM).\n */\nexport type UsjMarkerLocation = {\n /** JSON path to the marker object the location is pointing to. */\n jsonPath: ContentJsonPath;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of a\n * {@link MarkerObject} or {@link Usj} node.\n */\nexport type UsjClosingMarkerLocation = {\n /**\n * JSON path to the marker object whose closing marker the location is pointing to. The offset\n * applies to the closing marker representation of that marker (for example, `\\nd*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation.\n */\n closingMarkerOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a text content string in a {@link MarkerObject.content}\n * array.\n */\nexport type UsjTextContentLocation = {\n /**\n * JSON path to the text content string the location is pointing to. The offset applies to this\n * text string.\n */\n jsonPath: ContentJsonPath;\n /**\n * The character index in the text content string where this location is pointing. The location is\n * at this offset within the text content string.\n */\n offset: number;\n};\n\n/**\n * A JSONPath query to a specific point in a property (`marker` or an attribute) value string in a\n * {@link MarkerObject} or {@link Usj}. The property cannot be `type` because `type`'s value has no\n * representation in USFM.\n *\n * To represent a location in an attribute's key, use {@link UsjAttributeKeyLocation}.\n */\nexport type UsjPropertyValueLocation = {\n /**\n * JSON path to the property the location is pointing to. The offset applies to this property's\n * value string.\n */\n jsonPath: PropertyJsonPath;\n /**\n * The character index in the property's value string where this location is pointing. The\n * location is at this offset within the property's value string.\n */\n propertyOffset: number;\n};\n\n/**\n * A JSONPath query to a specific point in an attribute key string in a {@link MarkerObject} or\n * {@link Usj}. The property cannot be `type` or `marker` because these properties' keys have no\n * representation in USFM. The property also cannot be any special attribute whose key doesn't have\n * a text representation in USFM like default attribute, leading attribute, text content attribute\n *\n * To represent a location in an attribute's value, use {@link UsjPropertyValueLocation}.\n */\nexport type UsjAttributeKeyLocation = {\n /**\n * JSON path to the marker whose attribute key the location is pointing to. The offset applies to\n * this attribute's key string unless the attribute is an attribute marker in USFM.\n */\n jsonPath: ContentJsonPath;\n /** Attribute name on the marker object whose key this location is pointing to. */\n keyName: string;\n /**\n * The character index in the attribute's key string where this location is pointing.\n *\n * If the attribute is an attribute marker in USFM, the location is at this offset within the\n * marker name for this attribute marker (for example, `c`'s `altnumber` attribute has attribute\n * marker `ca`, so its `keyOffset` applies to `ca`).\n *\n * If the attribute is not an attribute marker in USFM, the location is at this offset within the\n * attribute's key string.\n */\n keyOffset: number;\n};\n\n/**\n * A JSONPath query to an attribute marker derived from an attribute on a {@link MarkerObject} or\n * {@link Usj}. Indicates the very beginning of that marker (at the backslash in USFM).\n */\nexport type UsjAttributeMarkerLocation = {\n /** JSON path to the marker whose attribute marker the location is pointing to. */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n};\n\n/**\n * A JSONPath query to a specific point in the closing marker representation of an attribute marker\n * derived from an attribute on a {@link MarkerObject} or {@link Usj}.\n */\nexport type UsjClosingAttributeMarkerLocation = {\n /**\n * JSON path to the marker whose attribute marker's closing marker the location is pointing to.\n * The offset applies to the closing marker representation of that attribute marker (for example,\n * `\\ca*` in USFM).\n */\n jsonPath: ContentJsonPath;\n /**\n * Attribute name on the marker object whose key this location is pointing to. This attribute is\n * an attribute marker in USFM.\n */\n keyName: string;\n /**\n * The character index in the closing marker representation where this location is pointing. The\n * location is at this offset within the closing marker representation of the attribute marker.\n */\n keyClosingMarkerOffset: number;\n};\n\n// #endregion Serializable USJ locations relative to a specific USJ document (chapter or book)\n\n/**\n * Node in a USJ object (including the top-level Usj object) and its location in the document. You\n * must make sure you only add `node`s that correspond to the appropriate type of\n * `UsjDocumentLocation` (e.g. if `documentLocation` is a {@link UsjTextContentLocation}, `node` must\n * be a text content string)\n *\n * You can specify a particular kind of `UsjDocumentLocation` in the generic type\n * `TDocumentLocation`, and that will narrow `documentLocation` to that specific kind of location.\n */\nexport type UsjNodeAndDocumentLocation<\n TDocumentLocation extends UsjDocumentLocation = UsjDocumentLocation,\n> = {\n node: TDocumentLocation extends UsjTextContentLocation ? string : MarkerObject | Usj;\n documentLocation: TDocumentLocation;\n};\n\n/** Result of a search for text within a USJ object */\nexport type UsjSearchResult = {\n /**\n * Beginning location in the USJ document of the search result. The text is inclusive of this\n * location, meaning this is the location of the first character of the found text\n */\n start: UsjNodeAndDocumentLocation;\n /**\n * Ending location in the USJ document of the search result. The text is exclusive of this\n * location, meaning this is the location right after the last character of the found text\n */\n end: UsjNodeAndDocumentLocation;\n /**\n * The matching Scripture text (not USFM string) that was found between the start and end\n * locations\n */\n text: string;\n};\n\n/**\n * Set of options to provide to `UsjReaderWriter`'s constructor to customize how the reading and\n * writing works\n */\nexport type UsjReaderWriterOptions = {\n /**\n * A map of all USFM/USX/USJ markers and some information about them. Used for translating between\n * the formats\n *\n * Defaults to trying to use a built-in markers map that matches the version of the USJ passed in.\n *\n * Currently supported built-in USFM versions:\n *\n * - 3.0/3.0.x\n */\n markersMap?: MarkersMap;\n /**\n * Whether the transformations should preserve invisible characters as in Paratext 9\n * (`ScrText.Settings.AllowInvisibleChars`).\n *\n * Defaults to `false`\n */\n shouldAllowInvisibleCharacters?: boolean;\n};\n\n/** Utilities for reading from and writing to `Usj` objects */\nexport interface IUsjReaderWriter {\n /**\n * Return a copy of text following a given starting point\n *\n * @param start Point where text extraction will start\n * @param desiredLength Length of text to extract from this USJ data\n */\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string;\n /**\n * Return a copy of text between two points\n *\n * @param start Point where text extraction will start\n * @param end Point where text extraction will end\n * @param maxLength Maximum length of string to return (defaults to 100)\n * @returns Text between the two points, capped at length `maxLength`\n */\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number,\n ): string;\n /**\n * Given a starting point, find the next location in this USJ data that matches the given text\n *\n * @param start Point where the search for `text` will start\n * @param text Text to find. Note you can use an empty string to find the closest text in or after\n * the `start` point.\n * @param maxTextLengthToSearch Maximum length of text to search before stopping (default is 1000)\n * @returns Object containing the USJ node where `text` begins (it might be split across nodes),\n * offset within that node that indicates where `text` begins, and a JSONPath string that\n * indicates the location of the of USJ node within `usj`. Note that if the USJ node returned is\n * an object, it is the same object that is within this USJ data. So if you change it, you are\n * changing this USJ data.\n */\n findNextLocationOfMatchingText(\n start: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number,\n ): UsjNodeAndDocumentLocation | undefined;\n /** Find the first value matching the given JSONPath query within this USJ data */\n findSingleValue(jsonPathQuery: string): T | undefined;\n /** Find the parent of the first value matching the given JSONPath query within this USJ data */\n findParent(jsonPathQuery: string): T | undefined;\n /**\n * Convert a JSONPath query into a SerializedVerseRef and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Convert a JSONPath query into a USJ node, JSONPath, and offset\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered. Note\n * that this query must yield a {@link MarkerContent} or {@link Usj}; JSONPaths yielding\n * properties on nodes are not currently supported.\n * @returns USJ node, JSONPath, and offset that represent the location within this USJ data\n * indicated by `jsonPathQuery`\n */\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation;\n /** Build a JSONPath query that uniquely identifies the given node with this USJ data. */\n nodeToJsonPath(node: MarkerObject): ContentJsonPath;\n /**\n * Determine the location in the USFM representation of this data that corresponds to the location\n * of a node somewhere within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USFM location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns SerializedVerseRef and offset representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n /**\n * Determine the location in the USJ document that corresponds to the location of a node somewhere\n * within this USJ data\n *\n * @param node JSON object or string in the USJ data to get the USJ location for\n * @param nodeParent JSON object that owns the `content` array that includes `node`. Required if\n * `node` is a string; optional and unused if `node` is a {@link MarkerObject} or {@link Usj}\n * @returns Node, JSONPath, and offset info representing the location of `node`, if one could be\n * found\n * @throws If `node` is a string and no `nodeParent` is provided\n * @throws If not able to establish relationship between string `node` and `nodeParent`\n * @throws If not able to find the node in the USJ document\n */\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation;\n /**\n * Remove all nodes from this USJ data that match a given search function.\n *\n * @param searchFunction Function that returns `true` if the given node should be removed\n * @returns Number of nodes removed\n */\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number;\n /**\n * Search for matches of a regular expression within this USJ's text data\n *\n * @param regex Regular expression to search for. Specify the global flag to find all matches.\n * @returns Array of `UsjSearchResult` objects that match the given regular expression\n */\n search(regex: RegExp): UsjSearchResult[];\n /** Transforms the USJ document into USFM */\n toUsfm(): string;\n /**\n * Get the index in the USFM representation of this data relative to the start of the document\n * that corresponds to the absolute verse location in USFM space passed in\n *\n * @param usfmVerseLocation The location in USFM space relative to a verse to get the index for\n * @returns Index in the USFM representation of this data relative to the start of the document\n */\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number;\n /**\n * Get the node + offset and JSONPath query within this USJ data of the first encountered string\n * after the provided USFM location for a specific verse in a USJ document.\n *\n * Note: this may return a node that is in a subsequent verse or even chapter depending on how\n * much content the USJ data contains. It simply looks through the rest of the USJ data for the\n * first text node and returns that.\n *\n * @param usfmVerseLocation Indicates the location in USFM space (book, chapter, verse, character\n * offset) to find the next text for\n * @returns Object containing the first USJ text node after `verseRef`, and a JSONPath string that\n * indicates the location of the USJ text node within this USJ data.\n * @throws Error if there is no text after `usfmVerseLocation`\n * @throws Error if `usfmVerseLocation` does not point to a valid location in this USJ data\n */\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a location in USJ space within this USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ location within the USJ document indicated by\n * `usfmVerseLocation`.\n */\n usfmVerseLocationToUsjDocumentLocation(usfmVerseLocation: UsfmVerseLocation): UsjDocumentLocation;\n /**\n * Convert a verse-based location in USFM space into a node and location in USJ space within this\n * USJ data.\n *\n * If the USJ document has no book markers in it to determine which book the USJ is in, the\n * `verseRef.book` will be ignored, and only the chapter and verse numbers will be used to\n * determine the location.\n *\n * @param usfmVerseLocation Location in USFM space - a book, chapter, verse, and character offset\n * within the verse's USFM\n * @returns Object containing the USJ node and location within the USJ document indicated by\n * `usfmVerseLocation`. Note that if the USJ node returned is an object, it is the same object\n * that is within this USJ data. So if you change it, you are changing this USJ data.\n */\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation;\n /**\n * Inform this UsjReaderWriter that the underlying USJ object changed. This is needed to clear\n * caches used when querying.\n */\n usjChanged(): void;\n /**\n * Convert a location in USJ space within this USJ data into a location in USFM space.\n *\n * @param usjLocation Location in USJ space - a jsonPath and other information about where the\n * location is\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Location in USFM space that is equivalent to the USJ location specified\n * @throws If not able to find the location in the USJ document\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation;\n}\n","import { MarkerObject, MarkerContent } from '@eten-tech-foundation/scripture-utilities';\n\n/** Gets the default caller sequence to use to generate callers for textual notes. */\nexport function getDefaultCallerSequence(): string[] {\n return Array.from({ length: 26 }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i));\n}\n\n/**\n * Gets a caller to be displayed for a textual note. This is primarily useful as a helper function\n * in {@link getFormatCallerFunction} , but it might be useful in stories, UI preview code, etc.\n *\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n * @param n Zero-based index into the caller list.\n */\nexport function getNthCaller(n: number, callers?: string[]): string {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n return callerList[n % callerList.length];\n}\n\n/**\n * Gets a function that provides a (stable) caller based on a given sequence of textual notes.\n *\n * @param footnotes Sequence of footnotes, cross-references, and/or end-notes.\n * @param callers Array of caller symbols, or `undefined` to use the default sequence, which is the\n * lowercase Roman-script letters as sequenced in the English alphabet.\n */\nexport function getFormatCallerFunction(footnotes: MarkerObject[], callers: string[] | undefined) {\n const callerList = callers && callers.length > 0 ? callers : getDefaultCallerSequence();\n // Precompute a stable sequence for '+' callers\n const plusSequenceMap = (() => {\n const map = new Map();\n let autoCallerCounter = 0;\n footnotes.forEach((fn, idx) => {\n if (fn.caller === '+') {\n map.set(idx, getNthCaller(autoCallerCounter, callerList));\n autoCallerCounter += 1;\n }\n });\n return map;\n })();\n\n return (caller: string | undefined, index: number): string | undefined => {\n if (caller === '+') {\n const formattedCaller = plusSequenceMap.get(index);\n if (!formattedCaller) {\n console.warn(`Caller index ${index} out of range for '+' callers`);\n return '?'; // Out of range'\n }\n return formattedCaller;\n }\n if (caller === '-') return undefined;\n return caller;\n };\n}\n\n/**\n * Extract footnotes from an array of `MarkerContent` objects.\n *\n * @param contents - An array of `MarkerContent` objects\n * @returns An array of MarkerObjects representing all textual notes found in the contents.\n */\nexport function extractFootnotesFromUsjContent(contents?: MarkerContent[]): MarkerObject[] {\n const footnotes: MarkerObject[] = [];\n if (!contents || contents.length === 0) return footnotes;\n\n function traverse(item: MarkerContent) {\n if (typeof item === 'string') return; // plain text node, ignore\n\n // item is a MarkerObject\n if (item.type === 'note') {\n footnotes.push(item);\n } else if (Array.isArray(item.content) && item.content.length > 0) {\n item.content.forEach(traverse);\n }\n }\n\n contents.forEach(traverse);\n return footnotes;\n}\n","/** Options for calculating resizable pane size limits. */\nexport type PaneSizeLimitsOptions = {\n /**\n * The thickness of the splitter between the two panes, in pixels.\n *\n * @default 4\n */\n splitterThicknessPx?: number;\n /**\n * Minimum size (height or width) of the secondary pane (the pane whose size is to be\n * constrained), in pixels. Ensures the secondary pane never shrinks below this size, if\n * possible.\n *\n * @default 20\n */\n secondaryPaneMinSizePx?: number;\n /**\n * Minimum size (height or width) of the main pane (the other pane), in pixels. Ensures the main\n * pane always has some visible content.\n *\n * @default 60\n */\n mainPaneMinSizePx?: number;\n /**\n * Absolute minimum percentage of the total available that the secondary pane can occupy. Used to\n * avoid the pane collapsing completely (e.g., if the available height or width is less than the\n * combined minimums).\n *\n * @default 3\n */\n absoluteMinPercent?: number;\n /**\n * Absolute maximum percentage of the total available that the secondary pane can occupy. Can be\n * used to keep the \"main\" pane from being overwhelmed by the size of the secondary pane.\n *\n * @default 90\n */\n absoluteMaxPercent?: number;\n};\n\n/**\n * Calculates the minimum and maximum size (as percentages) for a resizable pane in a two-pane\n * layout based on the total available height or width and optional constraints.\n *\n * The returned percentages indicate the allowable range for the secondary pane (the one whose size\n * limits are being computed). When applied, they ensure that pane never shrinks below its minimum\n * or grows beyond its maximum, leaving adequate space for both panes.\n *\n * @param availablePx - Total height or width available for both panes, in pixels.\n * @param options - Optional parameters for customizing pane size constraints.\n * @returns An object containing the minimum and maximum percentages the secondary pane can occupy:\n * `{ minPercent, maxPercent }`.\n */\nexport function getPaneSizeLimits(\n availablePx: number,\n options: PaneSizeLimitsOptions = {},\n): { minPercent: number; maxPercent: number } {\n const {\n splitterThicknessPx = 4,\n secondaryPaneMinSizePx = 20,\n mainPaneMinSizePx = 60,\n absoluteMinPercent = 3,\n absoluteMaxPercent = 90,\n } = options;\n\n const usableHeightPx = availablePx - splitterThicknessPx;\n\n let minPercent: number;\n let maxPercent: number;\n\n if (usableHeightPx < secondaryPaneMinSizePx + mainPaneMinSizePx) {\n minPercent = absoluteMinPercent;\n maxPercent = absoluteMaxPercent;\n } else {\n maxPercent = Math.min(\n Math.floor(((usableHeightPx - mainPaneMinSizePx) / usableHeightPx) * 100),\n absoluteMaxPercent,\n );\n\n minPercent = Math.min(\n Math.max(Math.ceil((secondaryPaneMinSizePx / usableHeightPx) * 100), absoluteMinPercent),\n maxPercent,\n );\n }\n\n return { minPercent, maxPercent };\n}\n","var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n/**\n * Combine two comparators into a single comparators.\n */\nfunction combineComparators(comparatorA, comparatorB) {\n return function isEqual(a, b, state) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nfunction createIsCircular(areItemsEqual) {\n return function isCircular(a, b, state) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n var cache = state.cache;\n var cachedA = cache.get(a);\n var cachedB = cache.get(b);\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n cache.set(a, b);\n cache.set(b, a);\n var result = areItemsEqual(a, b, state);\n cache.delete(a);\n cache.delete(b);\n return result;\n };\n}\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nfunction getStrictProperties(object) {\n return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));\n}\n/**\n * Whether the object contains the property passed as an own property.\n */\nvar hasOwn = Object.hasOwn ||\n (function (object, property) {\n return hasOwnProperty.call(object, property);\n });\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nfunction sameValueZeroEqual(a, b) {\n return a === b || (!a && !b && a !== a && b !== b);\n}\n\nvar PREACT_VNODE = '__v';\nvar PREACT_OWNER = '__o';\nvar REACT_OWNER = '_owner';\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys = Object.keys;\n/**\n * Whether the arrays are equal in value.\n */\nfunction areArraysEqual(a, b, state) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the dates passed are equal in value.\n */\nfunction areDatesEqual(a, b) {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n/**\n * Whether the errors passed are equal in value.\n */\nfunction areErrorsEqual(a, b) {\n return (a.name === b.name &&\n a.message === b.message &&\n a.cause === b.cause &&\n a.stack === b.stack);\n}\n/**\n * Whether the functions passed are equal in value.\n */\nfunction areFunctionsEqual(a, b) {\n return a === b;\n}\n/**\n * Whether the `Map`s are equal in value.\n */\nfunction areMapsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.entries();\n var aResult;\n var bResult;\n var index = 0;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.entries();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (matchedIndices[matchIndex]) {\n matchIndex++;\n continue;\n }\n var aEntry = aResult.value;\n var bEntry = bResult.value;\n if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) &&\n state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n index++;\n }\n return true;\n}\n/**\n * Whether the numbers are equal in value.\n */\nvar areNumbersEqual = sameValueZeroEqual;\n/**\n * Whether the objects are equal in value.\n */\nfunction areObjectsEqual(a, b, state) {\n var properties = keys(a);\n var index = properties.length;\n if (keys(b).length !== index) {\n return false;\n }\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n if (!isPropertyEqual(a, b, state, properties[index])) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nfunction areObjectsEqualStrict(a, b, state) {\n var properties = getStrictProperties(a);\n var index = properties.length;\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n var property;\n var descriptorA;\n var descriptorB;\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index];\n if (!isPropertyEqual(a, b, state, property)) {\n return false;\n }\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n if ((descriptorA || descriptorB) &&\n (!descriptorA ||\n !descriptorB ||\n descriptorA.configurable !== descriptorB.configurable ||\n descriptorA.enumerable !== descriptorB.enumerable ||\n descriptorA.writable !== descriptorB.writable)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nfunction arePrimitiveWrappersEqual(a, b) {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n/**\n * Whether the regexps passed are equal in value.\n */\nfunction areRegExpsEqual(a, b) {\n return a.source === b.source && a.flags === b.flags;\n}\n/**\n * Whether the `Set`s are equal in value.\n */\nfunction areSetsEqual(a, b, state) {\n var size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n var matchedIndices = new Array(size);\n var aIterable = a.values();\n var aResult;\n var bResult;\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n var bIterable = b.values();\n var hasMatch = false;\n var matchIndex = 0;\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (!matchedIndices[matchIndex] &&\n state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the TypedArray instances are equal in value.\n */\nfunction areTypedArraysEqual(a, b) {\n var index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the URL instances are equal in value.\n */\nfunction areUrlsEqual(a, b) {\n return (a.hostname === b.hostname &&\n a.pathname === b.pathname &&\n a.protocol === b.protocol &&\n a.port === b.port &&\n a.hash === b.hash &&\n a.username === b.username &&\n a.password === b.password);\n}\nfunction isPropertyEqual(a, b, state, property) {\n if ((property === REACT_OWNER ||\n property === PREACT_OWNER ||\n property === PREACT_VNODE) &&\n (a.$$typeof || b.$$typeof)) {\n return true;\n }\n return (hasOwn(b, property) &&\n state.equals(a[property], b[property], property, property, a, b, state));\n}\n\nvar ARGUMENTS_TAG = '[object Arguments]';\nvar BOOLEAN_TAG = '[object Boolean]';\nvar DATE_TAG = '[object Date]';\nvar ERROR_TAG = '[object Error]';\nvar MAP_TAG = '[object Map]';\nvar NUMBER_TAG = '[object Number]';\nvar OBJECT_TAG = '[object Object]';\nvar REG_EXP_TAG = '[object RegExp]';\nvar SET_TAG = '[object Set]';\nvar STRING_TAG = '[object String]';\nvar URL_TAG = '[object URL]';\nvar isArray = Array.isArray;\nvar isTypedArray = typeof ArrayBuffer === 'function' && ArrayBuffer.isView\n ? ArrayBuffer.isView\n : null;\nvar assign = Object.assign;\nvar getTag = Object.prototype.toString.call.bind(Object.prototype.toString);\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nfunction createEqualityComparator(_a) {\n var areArraysEqual = _a.areArraysEqual, areDatesEqual = _a.areDatesEqual, areErrorsEqual = _a.areErrorsEqual, areFunctionsEqual = _a.areFunctionsEqual, areMapsEqual = _a.areMapsEqual, areNumbersEqual = _a.areNumbersEqual, areObjectsEqual = _a.areObjectsEqual, arePrimitiveWrappersEqual = _a.arePrimitiveWrappersEqual, areRegExpsEqual = _a.areRegExpsEqual, areSetsEqual = _a.areSetsEqual, areTypedArraysEqual = _a.areTypedArraysEqual, areUrlsEqual = _a.areUrlsEqual;\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a, b, state) {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n // If either of the items are nullish and fail the strictly equal check\n // above, then they must be unequal.\n if (a == null || b == null) {\n return false;\n }\n var type = typeof a;\n if (type !== typeof b) {\n return false;\n }\n if (type !== 'object') {\n if (type === 'number') {\n return areNumbersEqual(a, b, state);\n }\n if (type === 'function') {\n return areFunctionsEqual(a, b, state);\n }\n // If a primitive value that is not strictly equal, it must be unequal.\n return false;\n }\n var constructor = a.constructor;\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n // Constructors should match, otherwise there is potential for false positives\n // between class and subclass or custom object and POJO.\n if (constructor !== b.constructor) {\n return false;\n }\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid capturing the string tag.\n if (constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing\n // the string tag or doing an `instanceof` check.\n if (isArray(a)) {\n return areArraysEqual(a, b, state);\n }\n // `isTypedArray()` works on all possible TypedArray classes, so we can avoid\n // capturing the string tag or comparing against all possible constructors.\n if (isTypedArray != null && isTypedArray(a)) {\n return areTypedArraysEqual(a, b, state);\n }\n // Try to fast-path equality checks for other complex object types in the\n // same realm to avoid capturing the string tag. Strict equality is used\n // instead of `instanceof` because it is more performant for the common\n // use-case. If someone is subclassing a native class, it will be handled\n // with the string tag comparison.\n if (constructor === Date) {\n return areDatesEqual(a, b, state);\n }\n if (constructor === RegExp) {\n return areRegExpsEqual(a, b, state);\n }\n if (constructor === Map) {\n return areMapsEqual(a, b, state);\n }\n if (constructor === Set) {\n return areSetsEqual(a, b, state);\n }\n // Since this is a custom object, capture the string tag to determing its type.\n // This is reasonably performant in modern environments like v8 and SpiderMonkey.\n var tag = getTag(a);\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n // For RegExp, the properties are not enumerable, and therefore will give false positives if\n // tested like a standard object.\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is custom `Promise`-like class instances. These should\n // be treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return (typeof a.then !== 'function' &&\n typeof b.then !== 'function' &&\n areObjectsEqual(a, b, state));\n }\n // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === URL_TAG) {\n return areUrlsEqual(a, b, state);\n }\n // If an error tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === ERROR_TAG) {\n return areErrorsEqual(a, b, state);\n }\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n/**\n * Create the configuration object used for building comparators.\n */\nfunction createEqualityComparatorConfig(_a) {\n var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;\n var config = {\n areArraysEqual: strict\n ? areObjectsEqualStrict\n : areArraysEqual,\n areDatesEqual: areDatesEqual,\n areErrorsEqual: areErrorsEqual,\n areFunctionsEqual: areFunctionsEqual,\n areMapsEqual: strict\n ? combineComparators(areMapsEqual, areObjectsEqualStrict)\n : areMapsEqual,\n areNumbersEqual: areNumbersEqual,\n areObjectsEqual: strict\n ? areObjectsEqualStrict\n : areObjectsEqual,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,\n areRegExpsEqual: areRegExpsEqual,\n areSetsEqual: strict\n ? combineComparators(areSetsEqual, areObjectsEqualStrict)\n : areSetsEqual,\n areTypedArraysEqual: strict\n ? areObjectsEqualStrict\n : areTypedArraysEqual,\n areUrlsEqual: areUrlsEqual,\n };\n if (createCustomConfig) {\n config = assign({}, config, createCustomConfig(config));\n }\n if (circular) {\n var areArraysEqual$1 = createIsCircular(config.areArraysEqual);\n var areMapsEqual$1 = createIsCircular(config.areMapsEqual);\n var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);\n var areSetsEqual$1 = createIsCircular(config.areSetsEqual);\n config = assign({}, config, {\n areArraysEqual: areArraysEqual$1,\n areMapsEqual: areMapsEqual$1,\n areObjectsEqual: areObjectsEqual$1,\n areSetsEqual: areSetsEqual$1,\n });\n }\n return config;\n}\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nfunction createInternalEqualityComparator(compare) {\n return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {\n return compare(a, b, state);\n };\n}\n/**\n * Create the `isEqual` function used by the consuming application.\n */\nfunction createIsEqual(_a) {\n var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;\n if (createState) {\n return function isEqual(a, b) {\n var _a = createState(), _b = _a.cache, cache = _b === void 0 ? circular ? new WeakMap() : undefined : _b, meta = _a.meta;\n return comparator(a, b, {\n cache: cache,\n equals: equals,\n meta: meta,\n strict: strict,\n });\n };\n }\n if (circular) {\n return function isEqual(a, b) {\n return comparator(a, b, {\n cache: new WeakMap(),\n equals: equals,\n meta: undefined,\n strict: strict,\n });\n };\n }\n var state = {\n cache: undefined,\n equals: equals,\n meta: undefined,\n strict: strict,\n };\n return function isEqual(a, b) {\n return comparator(a, b, state);\n };\n}\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nvar deepEqual = createCustomEqual();\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nvar strictDeepEqual = createCustomEqual({ strict: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nvar circularDeepEqual = createCustomEqual({ circular: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nvar shallowEqual = createCustomEqual({\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nvar strictShallowEqual = createCustomEqual({\n strict: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nvar circularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nvar strictCircularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: function () { return sameValueZeroEqual; },\n strict: true,\n});\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nfunction createCustomEqual(options) {\n if (options === void 0) { options = {}; }\n var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;\n var config = createEqualityComparatorConfig(options);\n var comparator = createEqualityComparator(config);\n var equals = createCustomInternalComparator\n ? createCustomInternalComparator(comparator)\n : createInternalEqualityComparator(comparator);\n return createIsEqual({ circular: circular, comparator: comparator, createState: createState, equals: equals, strict: strict });\n}\n\nexport { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };\n//# sourceMappingURL=index.mjs.map\n","// There is a circular version https://www.npmjs.com/package/fast-equals#circulardeepequal that I\n// think allows comparing React refs (which have circular references in particular places that this\n// library would ignore). Maybe we can change to that version sometime if needed.\nimport { deepEqual as isEqualDeep } from 'fast-equals';\n\n/**\n * Check that two objects are deeply equal, comparing members of each object and such\n *\n * @param a The first object to compare\n * @param b The second object to compare\n *\n * WARNING: Objects like arrays from different iframes have different constructor function\n * references even if they do the same thing, so this deep equality comparison fails objects that\n * look the same but have different constructors because different constructors could produce\n * false positives in [a few specific\n * situations](https://github.com/planttheidea/fast-equals/blob/a41afc0a240ad5a472e47b53791e9be017f52281/src/comparator.ts#L96).\n * This means that two objects like arrays from different iframes that look the same will fail\n * this check. Please use some other means to check deep equality in those situations.\n *\n * Note: This deep equality check considers `undefined` values on keys of objects NOT to be equal to\n * not specifying the key at all. For example, `{ stuff: 3, things: undefined }` and `{ stuff: 3\n * }` are not considered equal in this case\n *\n * - For more information and examples, see [this\n * CodeSandbox](https://codesandbox.io/s/deepequallibrarycomparison-4g4kk4?file=/src/index.mjs).\n *\n * @returns True if a and b are deeply equal; false otherwise\n */\nexport function deepEqual(a: unknown, b: unknown) {\n return isEqualDeep(a, b);\n}\n\nexport default deepEqual;\n","import { deepEqual } from './equality-checking';\n\n/**\n * Check if one object is a subset of the other object. \"Subset\" means that all properties of one\n * object are present in the other object, and if they are present that all values of those\n * properties are deeply equal. Sub-objects are also checked to be subsets of the corresponding\n * sub-object in the other object.\n *\n * @example ObjB is a subset of objA given these objects:\n *\n * ```ts\n * objA = { name: 'Alice', age: 30, address: { city: 'Seattle', state: 'Washington' } };\n * objB = { name: 'Alice', address: { city: 'Seattle' } };\n * ```\n *\n * It is important to note that only arrays of primitives (i.e., booleans, numbers, strings) are\n * supported. In particular, objects in arrays will not be checked for deep equality. Also, presence\n * in an array is all this checks, not the number of times that an item appears in an array. `[1,\n * 1]` is a subset of `[1]`.\n *\n * @param objectWithAllProperties Object to be checked if it is a superset of\n * `objectWithPartialProperties`\n * @param objectWithPartialProperties Object to be checked if it is a subset of\n * `objectWithAllProperties`\n * @returns True if `objectWithAllProperties` contains all the properties of\n * `objectWithPartialProperties` and all values of those properties are deeply equal\n */\nexport function isSubset(\n objectWithAllProperties: unknown,\n objectWithPartialProperties: unknown,\n): boolean {\n if (typeof objectWithAllProperties !== typeof objectWithPartialProperties) return false;\n\n // For this function we're saying that all falsy things of the same type are equal to each other\n if (!objectWithAllProperties && !objectWithPartialProperties) return true;\n\n if (Array.isArray(objectWithAllProperties)) {\n // We know these are arrays from the line above\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialArray = objectWithPartialProperties as Array;\n const allArray = objectWithAllProperties as Array;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n if (partialArray.length === 0) return true;\n\n // This only works with arrays of primitives.\n // If someone cares about checking arrays of objects this needs updating.\n return partialArray.every((item) => allArray.includes(item));\n }\n\n if (typeof objectWithAllProperties !== 'object')\n return deepEqual(objectWithAllProperties, objectWithPartialProperties);\n\n // We know these are objects that potentially have properties because of the earlier checks\n /* eslint-disable no-type-assertion/no-type-assertion */\n const partialObj = objectWithPartialProperties as Record;\n const allObj = objectWithAllProperties as Record;\n /* eslint-enable no-type-assertion/no-type-assertion */\n\n let retVal = true;\n Object.keys(partialObj).forEach((key) => {\n if (!retVal) return;\n if (!Object.hasOwn(allObj, key)) retVal = false;\n else if (!isSubset(allObj[key], partialObj[key])) retVal = false;\n });\n return retVal;\n}\n\nexport default isSubset;\n","/**\n * Converts a JavaScript value to a JSON string, changing `undefined` properties in the JavaScript\n * object to `null` properties in the JSON string.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer A function that transforms the results. Note that all `undefined` values returned\n * by the replacer will be further transformed into `null` in the JSON string.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON\n * text to make it easier to read. See the `space` parameter of `JSON.stringify` for more\n * details.\n */\nexport function serialize(\n value: unknown,\n replacer?: (this: unknown, key: string, value: unknown) => unknown,\n space?: string | number,\n): string {\n const undefinedReplacer = (replacerKey: string, replacerValue: unknown) => {\n let newValue = replacerValue;\n if (replacer) newValue = replacer(replacerKey, newValue);\n // All `undefined` values become `null` on the way from JS objects into JSON strings\n // eslint-disable-next-line no-null/no-null\n if (newValue === undefined) newValue = null;\n return newValue;\n };\n return JSON.stringify(value, undefinedReplacer, space);\n}\n\n/**\n * Converts a JSON string into a value, converting all `null` properties from JSON into `undefined`\n * in the returned JavaScript value/object.\n *\n * WARNING: `null` values will become `undefined` values after passing through {@link serialize} then\n * {@link deserialize}. For example, `{ a: 1, b: undefined, c: null }` will become `{ a: 1, b:\n * undefined, c: undefined }`. If you are passing around user data that needs to retain `null`\n * values, you should wrap them yourself in a string before using this function. Alternatively, you\n * can write your own replacer that will preserve `null` in a way that you can recover later.\n *\n * @param value A valid JSON string.\n * @param reviver A function that transforms the results. This function is called for each member of\n * the object. If a member contains nested objects, the nested objects are transformed before the\n * parent object is. Note that `null` values are converted into `undefined` values after the\n * reviver has run.\n */\nexport function deserialize(\n value: string,\n reviver?: (this: unknown, key: string, value: unknown) => unknown,\n // Need to use `any` instead of `unknown` here to match the signature of JSON.parse\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // Helper function to replace `null` with `undefined` on a per property basis. This can't be done\n // with our own reviver because `JSON.parse` removes `undefined` properties from the return value.\n function replaceNull(obj: Record): Record {\n Object.keys(obj).forEach((key: string | number) => {\n // We only want to replace `null`, not other falsy values\n // eslint-disable-next-line no-null/no-null\n if (obj[key] === null) obj[key] = undefined;\n // If the property is an object, recursively call the helper function on it\n else if (typeof obj[key] === 'object')\n // Since the object came from a string, we know the keys will not be symbols\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n obj[key] = replaceNull(obj[key] as Record);\n });\n return obj;\n }\n\n const parsedObject = JSON.parse(value, reviver);\n // Explicitly convert the value 'null' that isn't stored as a property on an object to 'undefined'\n // eslint-disable-next-line no-null/no-null\n if (parsedObject === null) return undefined;\n if (typeof parsedObject === 'object') return replaceNull(parsedObject);\n return parsedObject;\n}\n\n/**\n * Check to see if the value is serializable without losing information\n *\n * @param value Value to test\n * @returns True if serializable; false otherwise\n *\n * Note: the values `undefined` and `null` are serializable (on their own or in an array), but\n * `null` values get transformed into `undefined` when serializing/deserializing.\n *\n * WARNING: This is inefficient right now as it stringifies, parses, stringifies, and === the value.\n * Please only use this if you need to\n *\n * DISCLAIMER: this does not successfully detect that values are not serializable in some cases:\n *\n * - Losses of removed properties like functions and `Map`s\n * - Class instances (not deserializable into class instances without special code)\n *\n * We intend to improve this in the future if it becomes important to do so. See [`JSON.stringify`\n * documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)\n * for more information.\n */\nexport function isSerializable(value: unknown): boolean {\n try {\n const serializedValue = serialize(value);\n return serializedValue === serialize(deserialize(serializedValue));\n } catch (e) {\n return false;\n }\n}\n\n/**\n * HTML Encodes the provided string. Thanks to ChatGPT\n *\n * @param str String to HTML encode\n * @returns HTML-encoded string\n */\nexport const htmlEncode = (str: string): string =>\n str\n .replace(/&/g, '&')\n .replace(//g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(/\\//g, '/');\n","import { DateTimeFormat } from './intl-date-time-format';\n\n/**\n * Retrieves the current locale of the user's environment.\n *\n * @returns A string representing the current locale. If the locale cannot be determined, the\n * function returns an empty string.\n */\nexport function getCurrentLocale(): string {\n // Use navigator when available\n if (typeof navigator !== 'undefined' && navigator.languages) {\n const rawLocale = navigator.languages[0];\n // According to the MDN page for navigator.languages it should always return a valid BCP 47 tag.\n // However, some environments (e.g., certain Linux distros) may use the 'POSIX locale format'.\n // This code removes a (potential) trailing \"@posix\" so we will always return a valid BCP 47 tag\n // You can find the MDN page for navigator.languages here:\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n // You can learn more about the 'POSIX locale format' here:\n // https://learn.microsoft.com/en-us/globalization/locale/other-locale-names\n return rawLocale.replace(/@posix$/i, '');\n }\n // For Node.js\n return new DateTimeFormat().resolvedOptions().locale;\n}\n\nexport default getCurrentLocale;\n","import { NumberFormat } from './intl/intl-number-format';\n\n/**\n * Formats a number according to the locale and formatting options of this NumberFormat object\n *\n * @example FormatBytes(1024) => \"1 KB\"\n *\n * @example FormatBytes(1024, 0) => \"1 KB\"\n *\n * @param fileSize Number to format\n * @param decimals Number of decimal places to round to\n * @returns String representing the given number formatted according to the locale and formatting\n * options of this NumberFormat object\n */\nexport function formatBytes(fileSize: number, decimals: number = 2): string {\n if (fileSize === 0) return '0 Bytes';\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(fileSize) / Math.log(1024));\n const sizeToUse = sizes[i];\n const formattingFileSize = new NumberFormat('en', {\n style: 'decimal',\n maximumFractionDigits: decimals,\n minimumFractionDigits: 0,\n }).format(fileSize / 1024 ** i);\n return `${formattingFileSize} ${sizeToUse}`;\n}\n\nexport default formatBytes;\n","const MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60;\nconst SECONDS_PER_DAY = SECONDS_PER_HOUR * 24;\n\n/**\n * Get a localized string representation of the time between two dates\n *\n * @example\n *\n * `since` = 3 Aug 2024 8:00 AM\n *\n * `to` = 5 Aug 2024 8:000 AM\n *\n * Returns: \"two days ago\"\n *\n * @param since \"Destination\" time. time against which to get the time span.\n * @param to \"Starting\" time. Time span will be formatted relative to `to`. Defaults to `new Date()`\n * @returns Time span in words from `to` to `since`\n */\nexport function formatTimeSpan(\n relativeTimeFormatter: Intl.RelativeTimeFormat,\n since: Date,\n to = new Date(),\n) {\n const spanSeconds = Math.floor((since.getTime() - to.getTime()) / MILLISECONDS_PER_SECOND);\n\n const totalDays = Math.round(spanSeconds / SECONDS_PER_DAY);\n if (Math.abs(totalDays) >= 1) return relativeTimeFormatter.format(totalDays, 'day');\n\n const totalHours = Math.round(spanSeconds / SECONDS_PER_HOUR);\n if (Math.abs(totalHours) >= 1) return relativeTimeFormatter.format(totalHours, 'hour');\n\n const totalMinutes = Math.round(spanSeconds / SECONDS_PER_MINUTE);\n if (Math.abs(totalMinutes) >= 1) return relativeTimeFormatter.format(totalMinutes, 'minute');\n\n return relativeTimeFormatter.format(spanSeconds, 'second');\n}\n\n/**\n * Formats a date relative to today, showing \"Today\" or \"Yesterday\" when applicable, otherwise\n * returns the date in the specified format\n *\n * @param date The date to format\n * @param todayString The string to display when the date is today\n * @param yesterdayString The string to display when the date is yesterday\n * @param locale The locale to use for date formatting (defaults to user's locale)\n * @param options The Intl.DateTimeFormatOptions to use for date formatting when not\n * today/yesterday. Defaults to `{ year: 'numeric', month: 'short', day: 'numeric' }` which\n * produces formats like \"Nov 9, 2025\"\n */\nexport function formatRelativeDate(\n date: Date,\n todayString: string,\n yesterdayString: string,\n locale?: string,\n options: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n): string {\n const today = new Date();\n const yesterday = new Date(today);\n yesterday.setDate(yesterday.getDate() - 1);\n\n const isToday =\n date.getDate() === today.getDate() &&\n date.getMonth() === today.getMonth() &&\n date.getFullYear() === today.getFullYear();\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n if (isToday) {\n return todayString;\n }\n if (isYesterday) {\n return yesterdayString;\n }\n\n return date.toLocaleString(locale, options);\n}\n","/**\n * Modifier keys that don't constitute typed input\n *\n * Sourced from\n * https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys\n */\nexport const MODIFIER_KEYS = new Set([\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta',\n 'NumLock',\n 'ScrollLock',\n 'Shift',\n 'Super',\n 'Symbol',\n 'SymbolLock',\n]);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey, ReferencedItem } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the settings it provides */\nexport type SettingsContribution = SettingsGroup | SettingsGroup[];\n/** A description of an extension's setting entry */\nexport type Setting = ExtensionControlledSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledSetting = SettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a setting entry */\nexport type SettingBase = StateBase & {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the setting name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the setting */\n description?: LocalizeKey;\n /**\n * Boolean that controls whether a setting should be hidden or not. If hidden, the setting will\n * not show up in the settings dialog in `paranext-core`, and thus will not be configurable by the\n * user unless an extension provides a way to interact with the setting.\n */\n isHidden?: boolean;\n};\n/** The data an extension provides to inform Platform.Bible of the project settings it provides */\nexport type ProjectSettingsContribution = ProjectSettingsGroup | ProjectSettingsGroup[];\n/** A description of an extension's setting entry */\nexport type ProjectSetting = ExtensionControlledProjectSetting;\n/** Setting definition that is validated by the extension. */\nexport type ExtensionControlledProjectSetting = ProjectSettingBase & ModifierExtensionControlled;\n/** Base information needed to describe a project setting entry */\nexport type ProjectSettingBase = SettingBase & ModifierProject;\n/** A description of an extension's user state entry */\nexport type UserState = ExtensionControlledState;\n/** State definition that is validated by the extension. */\nexport type ExtensionControlledState = StateBase & ModifierExtensionControlled;\n/** Group of related settings definitions */\nexport interface SettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the settings dialog to describe the group */\n description?: LocalizeKey;\n properties: SettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface SettingProperties {\n [k: ReferencedItem]: Setting;\n}\n/** Base information needed to describe a state entry */\nexport interface StateBase {\n [k: string]: unknown;\n /** Default value for the state/setting */\n default: unknown;\n /**\n * A state/setting ID whose value to set to this state/setting's starting value the first time\n * this state/setting is loaded\n */\n derivesFrom?: ReferencedItem;\n}\n/**\n * Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the\n * extension provides the component and the validator for the state/setting, so the state/setting is\n * controlled by the extension.\n */\nexport interface ModifierExtensionControlled {\n [k: string]: unknown;\n platformType?: undefined;\n type?: undefined;\n}\n/** Group of related settings definitions */\nexport interface ProjectSettingsGroup {\n [k: string]: unknown;\n /** LocalizeKey that displays in the project settings dialog as the group name */\n label: LocalizeKey;\n /** LocalizeKey that displays in the project settings dialog to describe the group */\n description?: LocalizeKey;\n properties: ProjectSettingProperties;\n}\n/** Object whose keys are setting IDs and whose values are settings objects */\nexport interface ProjectSettingProperties {\n [k: ReferencedItem]: ProjectSetting;\n}\n\n// Note: we removed the index signature on ModifierProject to avoid having it on\n// `ProjectMetadataFilterOptions`. Unfortunately adding \"additionalProperties\": false on the json\n// schema messes up validation. Please remove the index signature again in the future if you\n// regenerate types\n/**\n * Defines a set of optional properties that can be used to filter projects based on their\n * `projectInterface` and Project Data Provider Factory Ids.\n */\nexport interface ModifierProject {\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should be included.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to pass):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to all `ProjectInterfaces`, so all projects that do not match\n * `excludeProjectInterfaces` will be included\n *\n * @example\n *\n * ```typescript\n * includeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed on projects whose `projectInterface`s fulfill at least one\n * of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n includeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s\n * (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if they should absolutely not be included even if they match with\n * `includeProjectInterfaces`.\n *\n * If this is one string, it will be matched against `projectInterface`s. If this is an array,\n * each entry is handled based on its type (at least one entry must match for this filter\n * condition to exclude the project):\n *\n * - If the entry is a string, it will be matched against each `projectInterface`. If any match, the\n * project will pass this filter condition and exclude the project\n * - If the entry is an array of strings, each will be matched against each `projectInterface`. If\n * every string matches against at least one `projectInterface`, the project will pass this\n * filter condition and exclude the project\n *\n * In other words, each entry in the first-level array is `OR`'ed together. Each entry in\n * second-level arrays (arrays within the first-level array) are `AND`'ed together.\n *\n * Defaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will\n * be included\n *\n * @example\n *\n * ```typescript\n * excludeProjectInterfaces: ['one', ['two', 'three']];\n * ```\n *\n * This filter condition will succeed and exclude projects whose `projectInterface`s fulfill at\n * least one of the following conditions (At least one entry in the array must match):\n *\n * - Include `one`\n * - Include both `two` and `three`.\n */\n excludeProjectInterfaces?: undefined | string | (string | string[])[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should be included.\n *\n * Defaults to all Project Data Provider Factory Ids, so all projects that do not match\n * `excludePdpFactoryIds` will be included\n */\n includePdpFactoryIds?: undefined | string | string[];\n /**\n * String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory\n * Ids that provided each project's metadata (using the\n * [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) to determine if the projects should absolutely not be included even if they match\n * with `includeProjectInterfaces`.\n *\n * Defaults to none, so all projects that match `includePdpFactoryIds` will be included\n */\n excludePdpFactoryIds?: undefined | string | string[];\n}\n\n/** The data an extension provides to inform Platform.Bible of the user state it provides */\nexport interface UserStateContribution {\n [k: ReferencedItem]: UserState;\n}\n/** The data an extension provides to inform Platform.Bible of the project state it provides */\nexport interface ProjectStateContribution {\n [k: ReferencedItem]: UserState;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\nconst settingsDefs = {\n projectSettingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n },\n projectSettingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the project settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description:\n 'localizeKey that displays in the project settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/projectSettingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n projectSettingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/projectSetting',\n },\n },\n additionalProperties: false,\n },\n projectSetting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledProjectSetting',\n },\n ],\n },\n extensionControlledProjectSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/projectSettingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n projectSettingBase: {\n description: 'Base information needed to describe a project setting entry',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierProject',\n },\n ],\n },\n modifierProject: {\n description: 'Modifies setting type to be project setting',\n type: 'object',\n properties: {\n includeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should be included.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to pass):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to all `ProjectInterfaces`, so all projects that do not match `excludeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nincludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed on projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n excludeProjectInterfaces: {\n description:\n \"String representation of `RegExp` pattern(s) to match against projects' `projectInterface`s (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if they should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nIf this is one string, it will be matched against `projectInterface`s. If this is an array, each entry is handled based on its type (at least one entry must match for this filter condition to exclude the project):\\n\\n- If the entry is a string, it will be matched against each `projectInterface`. If any match, the project will pass this filter condition and exclude the project\\n- If the entry is an array of strings, each will be matched against each `projectInterface`. If every string matches against at least one `projectInterface`, the project will pass this filter condition and exclude the project\\n\\nIn other words, each entry in the first-level array is `OR`'ed together. Each entry in second-level arrays (arrays within the first-level array) are `AND`'ed together.\\n\\nDefaults to no `ProjectInterfaces`, so all projects that match `includeProjectInterfaces` will be included\\n\\n@example\\n\\n```typescript\\nexcludeProjectInterfaces: ['one', ['two', 'three']];\\n```\\n\\nThis filter condition will succeed and exclude projects whose `projectInterface`s fulfill at least one of the following conditions (At least one entry in the array must match):\\n\\n- Include `one`\\n- Include both `two` and `three`.\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n ],\n },\n includePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should be included.\\n\\nDefaults to all Project Data Provider Factory Ids, so all projects that do not match `excludePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n excludePdpFactoryIds: {\n description:\n \"String representation of `RegExp` pattern(s) to match against the Project Data Provider Factory Ids that provided each project's metadata (using the [`test`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) function) to determine if the projects should absolutely not be included even if they match with `includeProjectInterfaces`.\\n\\nDefaults to none, so all projects that match `includePdpFactoryIds` will be included\",\n anyOf: [\n {\n type: 'null',\n },\n {\n type: 'string',\n },\n {\n type: 'array',\n items: { type: 'string' },\n },\n ],\n },\n },\n },\n settingsContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n },\n settingsGroup: {\n description: 'Group of related settings definitions',\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the group name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the group',\n $ref: '#/$defs/localizeKey',\n },\n properties: {\n $ref: '#/$defs/settingProperties',\n },\n },\n required: ['label', 'properties'],\n },\n settingProperties: {\n description: 'Object whose keys are setting IDs and whose values are settings objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w-]+\\\\.[\\\\w-]+$': {\n $ref: '#/$defs/setting',\n },\n },\n additionalProperties: false,\n },\n setting: {\n description: \"A description of an extension's setting entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledSetting',\n },\n ],\n },\n extensionControlledSetting: {\n description: 'Setting definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/settingBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n settingBase: {\n description: 'Base information needed to describe a setting entry',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n type: 'object',\n properties: {\n label: {\n description: 'localizeKey that displays in the settings dialog as the setting name',\n $ref: '#/$defs/localizeKey',\n },\n description: {\n description: 'localizeKey that displays in the settings dialog to describe the setting',\n $ref: '#/$defs/localizeKey',\n },\n isHidden: {\n description: `Boolean that controls whether a setting should be hidden or not. If hidden\n , the setting will not show up in the settings dialog in \\`paranext-core\\`, and thus\n will not be configurable by the user unless an extension provides a way to interact with\n the setting.`,\n type: 'boolean',\n },\n },\n required: ['label'],\n },\n ],\n },\n projectStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the project state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateContribution: {\n description:\n 'The data an extension provides to inform Platform.Bible of the user state it provides',\n $ref: '#/$defs/userStateProperties',\n },\n userStateProperties: {\n description: 'Object whose keys are state IDs and whose values are state objects',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/userState',\n },\n },\n additionalProperties: false,\n },\n userState: {\n description: \"A description of an extension's user state entry\",\n anyOf: [\n {\n $ref: '#/$defs/extensionControlledState',\n },\n ],\n },\n extensionControlledState: {\n description: 'State definition that is validated by the extension.',\n allOf: [\n {\n $ref: '#/$defs/stateBase',\n },\n {\n $ref: '#/$defs/modifierExtensionControlled',\n },\n ],\n },\n modifierExtensionControlled: {\n description:\n 'Modifies state/setting type to be extension-controlled. \"Extension-controlled\" means the extension provides the component and the validator for the state/setting, so the state/setting is controlled by the extension.',\n not: {\n anyOf: [\n {\n type: 'object',\n required: ['platformType'],\n },\n {\n type: 'object',\n required: ['type'],\n },\n ],\n },\n },\n stateBase: {\n description: 'Base information needed to describe a state entry',\n type: 'object',\n properties: {\n default: {\n description: 'default value for the state/setting',\n type: 'any',\n },\n derivesFrom: {\n description:\n \"a state/setting ID whose value to set to this state/setting's starting value the first time this state/setting is loaded\",\n $ref: '#/$defs/id',\n },\n },\n required: ['default'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n id: {\n description: '',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n tsType: 'Id',\n },\n};\n\n/**\n * Json-schema-to-typescript has some added stuff that isn't actually compatible with JSON schema,\n * so we remove them here\n *\n * @param defs The `$defs` property of a JSON schema (will be modified in place)\n */\n// JSON schema types are weird, so we'll just be careful\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function removeJsonToTypeScriptTypesStuff(defs: any) {\n if (!defs) return;\n\n // JSON schema types are weird, so we'll just be careful\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.values(defs).forEach((def: any) => {\n if (!def.type) return;\n\n if ('tsType' in def) delete def.tsType;\n\n if (def.type === 'any') {\n delete def.type;\n return;\n }\n\n if (def.type === 'object') {\n removeJsonToTypeScriptTypesStuff(def.properties);\n }\n });\n}\n\nremoveJsonToTypeScriptTypesStuff(settingsDefs);\n\n/** JSON schema object that aligns with the ProjectSettingsContribution type */\nexport const projectSettingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Project Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the project settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/projectSettingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/projectSettingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(projectSettingsDocumentSchema);\n\n/** JSON schema object that aligns with the {@link SettingsContribution} type */\nexport const settingsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Settings Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the settings it provides',\n anyOf: [\n {\n $ref: '#/$defs/settingsGroup',\n },\n {\n type: 'array',\n items: {\n $ref: '#/$defs/settingsGroup',\n },\n },\n ],\n\n $defs: settingsDefs,\n};\n\nObject.freeze(settingsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { LocalizeKey } from './menus.model';\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\n\n/** Localized string value associated with this key */\nexport type LocalizedStringValue = string;\n/**\n * Date in YYYY-MM-DD format\n *\n * Use regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$` to test.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\nexport type DateYYYYMMDD = `${number}-${number}-${number}`;\n\n/** The data an extension provides to inform Platform.Bible of the localized strings it provides. */\nexport interface LocalizedStringDataContribution {\n [k: string]: unknown;\n metadata?: StringsMetadata;\n localizedStrings?: {\n [k: string]: LanguageStrings;\n };\n}\n/**\n * Map whose keys are localized string keys and whose values provide additional non-locale-specific\n * information about the localized string key\n */\nexport interface StringsMetadata {\n [k: LocalizeKey]: StringMetadata;\n}\n/** Additional non-locale-specific information about a localized string key */\nexport interface StringMetadata {\n [k: string]: unknown;\n /**\n * Localized string key from which to get this value if one does not exist in the specified\n * language. If a new key/value pair needs to be made to replace an existing one, this could help\n * smooth over the transition if the meanings are close enough\n *\n * You can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a\n * backslash `\\`.\n */\n fallbackKey?: LocalizeKey;\n /**\n * Additional information provided by developers in English to help the translator to know how to\n * translate this localized string accurately\n */\n notes?: string;\n /**\n * If this property is filled, the localized string is deprecated. Contains information about the\n * deprecation.\n */\n deprecationInfo?: LocalizedStringDeprecationInfo;\n}\n/**\n * Contains information about the deprecation of a localized string key, including the date of\n * deprecation and the reason.\n */\nexport interface LocalizedStringDeprecationInfo {\n [k: string]: unknown;\n /**\n * Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\n *\n * Tested against regex `^\\d\\d\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\n *\n * Thanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.\n */\n date: DateYYYYMMDD;\n /**\n * Should contain the reason for deprecation and what to use instead in what contexts.\n *\n * @example Reworded to clarify the meaning. Use %my_key_2% instead.\n */\n message: string;\n}\n/**\n * Map whose keys are localized string keys and whose values provide information about how to\n * localize strings for the localized string key\n */\nexport interface LanguageStrings {\n [k: LocalizeKey]: LocalizedStringValue;\n}\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n\nconst localizedStringsDefs = {\n languageStrings: {\n description:\n 'Map whose keys are localized string keys and whose values provide information about how to localize strings for the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/localizedStringValue',\n },\n },\n additionalProperties: false,\n },\n localizedStringValue: {\n description: 'Localized string value associated with this key',\n type: 'string',\n },\n stringsMetadata: {\n description:\n 'Map whose keys are localized string keys and whose values provide additional non-locale-specific information about the localized string key',\n type: 'object',\n patternProperties: {\n '^%[\\\\w\\\\-\\\\.]+%$': {\n $ref: '#/$defs/stringMetadata',\n },\n },\n additionalProperties: false,\n },\n stringMetadata: {\n description: 'Additional non-locale-specific information about a localized string key',\n type: 'object',\n properties: {\n fallbackKey: {\n description:\n 'Localized string key from which to get this value if one does not exist in the specified language. If a new key/value pair needs to be made to replace an existing one, this could help smooth over the transition if the meanings are close enough.\\nYou can use Paratext 9 Localized String Keys here. Be sure to escape any % signs with a backslash `\\\\`.',\n type: 'string',\n pattern: \"^%[\\\\w\\\\-\\\\.;&,' (){}#:/\\\\\\\\?%⋮|[\\\\]“”‘’!~*\\u00A0+=•`…\\u200B↑↓]+%$\",\n tsType: 'LocalizeKey',\n },\n notes: {\n description:\n 'Additional information provided by developers in English to help the translator to know how to translate this localized string accurately',\n type: 'string',\n },\n deprecationInfo: {\n description:\n 'If this property is filled, the localized string is deprecated. Contains information about the deprecation.',\n $ref: '#/$defs/localizedStringDeprecationInfo',\n },\n },\n },\n localizedStringDeprecationInfo: {\n description:\n 'Date of deprecation, the reason for deprecation, and what to use instead in what contexts',\n type: 'object',\n properties: {\n date: {\n description:\n 'Date of deprecation. Must be in YYYY-MM-DD format e.g. 2024-11-13.\\n\\nTested against regex `^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$`.\\n\\nThanks to Vinod at https://stackoverflow.com/a/22061879 for the regex.',\n type: 'string',\n pattern: '^\\\\d\\\\d\\\\d\\\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$',\n tsType: 'DateYYYYMMDD',\n },\n message: {\n description:\n 'Should contain the reason for deprecation and what to use instead in what contexts.\\n\\n@example Reworded to clarify the meaning. Use %my_key_2% instead.',\n type: 'string',\n },\n },\n required: ['date', 'message'],\n },\n localizeKey: {\n description: \"Identifier for a string that will be localized based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(localizedStringsDefs);\n\n/** JSON schema object that aligns with the LocalizedStringDataContribution type */\nexport const localizedStringsDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Localized String Data Contribution',\n description:\n 'The data an extension provides to inform Platform.Bible of the localized strings it provides.',\n type: 'object',\n properties: {\n metadata: {\n $ref: '#/$defs/stringsMetadata',\n },\n localizedStrings: {\n type: 'object',\n additionalProperties: {\n $ref: '#/$defs/languageStrings',\n },\n },\n },\n $defs: localizedStringsDefs,\n};\n\nObject.freeze(localizedStringsDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { ReplaceType } from '../util';\n\n/** Identifier for a string that will be localized in a menu based on the user's UI language */\nexport type LocalizeKey = `%${string}%`;\n\n/** Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command) */\nexport type ReferencedItem = `${string}.${string}`;\n\nexport type OrderedItem = {\n /** Relative order of this item compared to other items in the same parent/scope (sorted ascending) */\n order: number;\n};\n\nexport type OrderedExtensibleContainer = OrderedItem & {\n /** Determines whether other items can be added to this after it has been defined */\n isExtensible?: boolean;\n};\n\n/** Group of menu items that belongs in a column */\nexport type MenuGroupDetailsInColumn = OrderedExtensibleContainer & {\n /** ID of column in which this group resides */\n column: ReferencedItem;\n};\n\n/** Group of menu items that belongs in a submenu */\nexport type MenuGroupDetailsInSubMenu = OrderedExtensibleContainer & {\n /** ID of menu item hosting the submenu in which this group resides */\n menuItem: ReferencedItem;\n};\n\n/** Column that includes header text in a menu */\nexport type MenuColumnWithHeader = OrderedExtensibleContainer & {\n /** Key that represents the text of the header text of the column */\n label: LocalizeKey;\n};\n\nexport type MenuItemBase = OrderedItem & {\n /** Menu group to which this menu item belongs */\n group: ReferencedItem;\n /** Key that represents the text of this menu item to display */\n label: LocalizeKey;\n /** Key that represents words the platform should reference when users are searching for menu items */\n searchTerms?: LocalizeKey;\n /** Key that represents the text to display if a mouse pointer hovers over the menu item */\n tooltip?: LocalizeKey;\n /** Additional information provided by developers to help people who perform localization */\n localizeNotes: string;\n};\n\n/** Menu item that hosts a submenu */\nexport type MenuItemContainingSubmenu = MenuItemBase & {\n /** ID for this menu item that holds a submenu */\n id: ReferencedItem;\n};\n\n/** Menu item that runs a command */\nexport type MenuItemContainingCommand = MenuItemBase & {\n /** Name of the PAPI command to run when this menu item is selected. */\n command: ReferencedItem;\n /**\n * Uri path to the icon to display after the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathAfter?: string;\n /**\n * Uri path to the icon to display before the menu text. Ex:\n * `papi-extension://helloWorld/assets/icon.png`\n */\n iconPathBefore?: string;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single context menu/submenu.\n * Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInSingleColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: OrderedExtensibleContainer | MenuGroupDetailsInSubMenu;\n};\n\n/**\n * Group of menu items that can be combined with other groups to form a single menu/submenu within a\n * multi-column menu. Groups are separated using a line within the menu/submenu.\n */\nexport type GroupsInMultiColumnMenu = {\n /** Named menu group */\n [property: ReferencedItem]: MenuGroupDetailsInColumn | MenuGroupDetailsInSubMenu;\n};\n\n/** Group of columns that can be combined with other columns to form a multi-column menu */\nexport type ColumnsWithHeaders = {\n /** Named column of a menu */\n [property: ReferencedItem]: MenuColumnWithHeader;\n /** Defines whether columns can be added to this multi-column menu */\n isExtensible?: boolean;\n};\n\n/** Menu that contains a column without a header */\nexport type SingleColumnMenu = {\n /** Groups that belong in this menu */\n groups: GroupsInSingleColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menu that contains multiple columns with headers */\nexport type MultiColumnMenu = {\n /** Columns that belong in this menu */\n columns: ColumnsWithHeaders;\n /** Groups that belong in this menu */\n groups: GroupsInMultiColumnMenu;\n /** List of menu items that belong in this menu */\n items: (MenuItemContainingCommand | MenuItemContainingSubmenu)[];\n};\n\n/** Menus for one single web view */\nexport type WebViewMenu = {\n /** Indicates whether the platform default menus should be included for this webview */\n includeDefaults: boolean | undefined;\n /** Menu that opens when you click on the top left corner of a tab */\n topMenu: MultiColumnMenu | undefined;\n /** Menu that opens when you right click on the main body/area of a tab */\n contextMenu: SingleColumnMenu | undefined;\n};\n\n/** Menus for all web views */\nexport type WebViewMenus = {\n /** Named web view */\n [property: ReferencedItem]: WebViewMenu;\n};\n\n/** Platform.Bible menus before they are localized */\nexport type PlatformMenus = {\n /** Top level menu for the application */\n mainMenu: MultiColumnMenu;\n /** Menus that apply per web view in the application */\n webViewMenus: WebViewMenus;\n /** Default context menu for web views that don't specify their own */\n defaultWebViewContextMenu: SingleColumnMenu;\n /** Default top menu for web views that don't specify their own */\n defaultWebViewTopMenu: MultiColumnMenu;\n};\n\n/**\n * Type that converts any menu type before it is localized to what it is after it is localized. This\n * can be applied to any menu type as needed.\n */\nexport type Localized = ReplaceType, ReferencedItem, string>;\n\n//----------------------------------------------------------------------------------------------\n// NOTE: If you change the schema below, make sure the TS types above get changed so they align.\n//----------------------------------------------------------------------------------------------\n/** JSON schema object that aligns with the PlatformMenus type */\nexport const menuDocumentSchema = {\n title: 'Platform.Bible menus',\n type: 'object',\n properties: {\n mainMenu: {\n description: 'Top level menu for the application',\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewTopMenu: {\n description: \"Default top menu for web views that don't specify their own\",\n $ref: '#/$defs/multiColumnMenu',\n },\n defaultWebViewContextMenu: {\n description: \"Default context menu for web views that don't specify their own\",\n $ref: '#/$defs/singleColumnMenu',\n },\n webViewMenus: {\n description: 'Menus that apply per web view in the application',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n $ref: '#/$defs/menusForOneWebView',\n },\n },\n additionalProperties: false,\n },\n },\n required: ['mainMenu', 'defaultWebViewTopMenu', 'defaultWebViewContextMenu', 'webViewMenus'],\n additionalProperties: false,\n $defs: {\n localizeKey: {\n description:\n \"Identifier for a string that will be localized in a menu based on the user's UI language\",\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n },\n referencedItem: {\n description:\n 'Name of some UI element (i.e., tab, column, group, menu item) or some PAPI object (i.e., command)',\n type: 'string',\n pattern: '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$',\n },\n columnsWithHeaders: {\n description:\n 'Group of columns that can be combined with other columns to form a multi-column menu',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single column with a header string',\n type: 'object',\n properties: {\n label: {\n description: 'Header text for this this column in the UI',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n order: {\n description:\n 'Relative order of this column compared to other columns (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu groups to this column',\n type: 'boolean',\n },\n },\n required: ['label', 'order'],\n additionalProperties: false,\n },\n },\n properties: {\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add columns to this multi-column menu',\n type: 'boolean',\n },\n },\n },\n menuGroups: {\n description:\n 'Group of menu items that can be combined with other groups to form a single menu/submenu. Groups are separated using a line within the menu/submenu.',\n type: 'object',\n patternProperties: {\n '^[\\\\w\\\\-]+\\\\.[\\\\w\\\\-]+$': {\n description: 'Single group that contains menu items',\n type: 'object',\n oneOf: [\n {\n properties: {\n column: {\n description:\n 'Column where this group belongs, not required for single column menus',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['order'],\n additionalProperties: false,\n },\n {\n properties: {\n menuItem: {\n description: 'Menu item that anchors the submenu where this group belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this group compared to other groups in the same column or submenu (sorted ascending)',\n type: 'number',\n },\n isExtensible: {\n description:\n 'Defines whether contributions are allowed to add menu items to this menu group',\n type: 'boolean',\n },\n },\n required: ['menuItem', 'order'],\n additionalProperties: false,\n },\n ],\n },\n },\n additionalProperties: false,\n },\n menuItem: {\n description:\n 'Single item in a menu that can be clicked on to take an action or can be the parent of a submenu',\n type: 'object',\n oneOf: [\n {\n properties: {\n id: {\n description: 'ID for this menu item that holds a submenu',\n $ref: '#/$defs/referencedItem',\n },\n },\n required: ['id'],\n },\n {\n properties: {\n command: {\n description: 'Name of the PAPI command to run when this menu item is selected.',\n $ref: '#/$defs/referencedItem',\n },\n iconPathBefore: {\n description:\n 'Uri path to the icon to display before the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n iconPathAfter: {\n description:\n 'Uri path to the icon to display after the menu text. Ex: `papi-extension://helloWorld/assets/icon.png`',\n type: 'string',\n },\n },\n required: ['command'],\n },\n ],\n properties: {\n label: {\n description: 'Key that represents the text of this menu item to display',\n $ref: '#/$defs/localizeKey',\n },\n tooltip: {\n description:\n 'Key that represents the text to display if a mouse pointer hovers over the menu item',\n $ref: '#/$defs/localizeKey',\n },\n searchTerms: {\n description:\n 'Key that represents additional words the platform should reference when users are searching for menu items',\n $ref: '#/$defs/localizeKey',\n },\n localizeNotes: {\n description:\n 'Additional information provided by developers to help people who perform localization',\n type: 'string',\n },\n group: {\n description: 'Group to which this menu item belongs',\n $ref: '#/$defs/referencedItem',\n },\n order: {\n description:\n 'Relative order of this menu item compared to other menu items in the same group (sorted ascending)',\n type: 'number',\n },\n },\n required: ['label', 'group', 'order'],\n unevaluatedProperties: false,\n },\n groupsAndItems: {\n description: 'Core schema for a column',\n type: 'object',\n properties: {\n groups: {\n description: 'Groups that belong in this menu',\n $ref: '#/$defs/menuGroups',\n },\n items: {\n description: 'List of menu items that belong in this menu',\n type: 'array',\n items: { $ref: '#/$defs/menuItem' },\n uniqueItems: true,\n },\n },\n required: ['groups', 'items'],\n },\n singleColumnMenu: {\n description: 'Menu that contains a column without a header',\n type: 'object',\n allOf: [{ $ref: '#/$defs/groupsAndItems' }],\n unevaluatedProperties: false,\n },\n multiColumnMenu: {\n description: 'Menu that can contain multiple columns with headers',\n type: 'object',\n allOf: [\n { $ref: '#/$defs/groupsAndItems' },\n {\n properties: {\n columns: {\n description: 'Columns that belong in this menu',\n $ref: '#/$defs/columnsWithHeaders',\n },\n },\n required: ['columns'],\n },\n ],\n unevaluatedProperties: false,\n },\n menusForOneWebView: {\n description: 'Set of menus that are associated with a single tab',\n type: 'object',\n properties: {\n includeDefaults: {\n description:\n 'Indicates whether the platform default menus should be included for this webview',\n type: 'boolean',\n },\n topMenu: {\n description: 'Menu that opens when you click on the top left corner of a tab',\n $ref: '#/$defs/multiColumnMenu',\n },\n contextMenu: {\n description: 'Menu that opens when you right click on the main body/area of a tab',\n $ref: '#/$defs/singleColumnMenu',\n },\n },\n additionalProperties: false,\n },\n },\n};\n\nObject.freeze(menuDocumentSchema);\n","//----------------------------------------------------------------------------------------------\n// NOTE: If you change any of the types, make sure the JSON schema at the end of this file gets\n// changed so they align.\n//----------------------------------------------------------------------------------------------\n\nimport { removeJsonToTypeScriptTypesStuff } from './settings.model';\nimport { LocalizeKey } from './menus.model';\n\n/** The data an extension provides to inform Platform.Bible of the themes it provides. */\nexport type ThemeContribution = ThemeFamiliesById;\n\n/** Object whose keys are theme family ids and whose values are {@link ThemeFamily}. */\nexport interface ThemeFamiliesById {\n [themeFamilyId: string]: ThemeFamily | undefined;\n}\n\n/**\n * A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\n *\n * A theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type\n * to determine how to look. Colors not present in the theme will fall back to the built-in colors\n * for this type.\n */\nexport interface ThemeFamily {\n [themeType: string]: ThemeDefinition | undefined;\n light?: ThemeDefinition;\n dark?: ThemeDefinition;\n}\n\n/**\n * The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark)\n * and belongs to a theme family. An extension can provide multiple themes with\n * {@link ThemeContribution}.\n */\nexport interface ThemeDefinition {\n [k: string]: unknown;\n /** LocalizeKey that is the display name for the theme */\n label: LocalizeKey;\n /**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\n cssVariables: ThemeCssVariables;\n}\n/**\n * Theme colors and other CSS variable properties that adjust the looks of the application. These\n * are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like\n * `tw-bg-primary`\n *\n * See the wiki's [Matching Application\n * Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme)\n * section for more information.\n */\nexport interface ThemeCssVariables {\n [variableName: string]: string | undefined;\n background?: string;\n foreground?: string;\n card?: string;\n 'card-foreground'?: string;\n popover?: string;\n 'popover-foreground'?: string;\n primary?: string;\n 'primary-foreground'?: string;\n secondary?: string;\n 'secondary-foreground'?: string;\n muted?: string;\n 'muted-foreground'?: string;\n accent?: string;\n 'accent-foreground'?: string;\n destructive?: string;\n 'destructive-foreground'?: string;\n border?: string;\n input?: string;\n ring?: string;\n 'sidebar-background'?: string;\n 'sidebar-foreground'?: string;\n 'sidebar-primary'?: string;\n 'sidebar-primary-foreground'?: string;\n 'sidebar-accent'?: string;\n 'sidebar-accent-foreground'?: string;\n 'sidebar-border'?: string;\n 'sidebar-ring'?: string;\n radius?: string;\n}\n\nconst themeDefs = {\n themeCssVariables: {\n description:\n \"Theme colors and other CSS variable properties that adjust the looks of the application. These are applied in CSS properties using `hsl(var(--variableName))` or Tailwind classes like `tw-bg-primary`\\n\\nSee the wiki's [Matching Application Theme](https://github.com/paranext/paranext-extension-template/wiki/Extension-Anatomy#matching-application-theme) section for more information.\",\n type: 'object',\n properties: {\n background: { type: 'string' },\n foreground: { type: 'string' },\n card: { type: 'string' },\n 'card-foreground': { type: 'string' },\n popover: { type: 'string' },\n 'popover-foreground': { type: 'string' },\n primary: { type: 'string' },\n 'primary-foreground': { type: 'string' },\n secondary: { type: 'string' },\n 'secondary-foreground': { type: 'string' },\n muted: { type: 'string' },\n 'muted-foreground': { type: 'string' },\n accent: { type: 'string' },\n 'accent-foreground': { type: 'string' },\n destructive: { type: 'string' },\n 'destructive-foreground': { type: 'string' },\n border: { type: 'string' },\n input: { type: 'string' },\n ring: { type: 'string' },\n 'sidebar-background': { type: 'string' },\n 'sidebar-foreground': { type: 'string' },\n 'sidebar-primary': { type: 'string' },\n 'sidebar-primary-foreground': { type: 'string' },\n 'sidebar-accent': { type: 'string' },\n 'sidebar-accent-foreground': { type: 'string' },\n 'sidebar-border': { type: 'string' },\n 'sidebar-ring': { type: 'string' },\n radius: { type: 'string' },\n },\n additionalProperties: { anyOf: [{ type: 'string' }, { type: 'null' }] },\n },\n themeDefinition: {\n description:\n 'The data an extension provides for one individual theme. Each theme has a type (e.g. light, dark) and belongs to a theme family. An extension can provide multiple themes with {@link ThemeContribution}.',\n type: 'object',\n properties: {\n label: {\n description: 'LocalizeKey that is the display name for the theme',\n type: 'string',\n pattern: '^%[\\\\w\\\\-\\\\.]+%$',\n tsType: 'LocalizeKey',\n },\n cssVariables: {\n $ref: '#/$defs/themeCssVariables',\n },\n },\n required: ['label', 'cssVariables'],\n },\n themeFamily: {\n description:\n 'A group of related themes. Each key is a theme type, and each value is a {@link ThemeDefinition}.\\n\\nA theme type indicates the kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to look. Colors not present in the theme will fall back to the built-in colors for this type.',\n type: 'object',\n properties: {\n light: {\n $ref: '#/$defs/themeDefinition',\n },\n dark: {\n $ref: '#/$defs/themeDefinition',\n },\n },\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeDefinition',\n },\n { type: 'null' },\n ],\n },\n },\n themeFamiliesById: {\n description: 'Object whose keys are theme family ids and whose values are {@link ThemeFamily}.',\n type: 'object',\n additionalProperties: {\n anyOf: [\n {\n $ref: '#/$defs/themeFamily',\n },\n { type: 'null' },\n ],\n },\n },\n};\n\nremoveJsonToTypeScriptTypesStuff(themeDefs);\n\n// JSON schema object for ThemeContribution\nexport const themeDocumentSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n title: 'Theme Contribution',\n description: 'The data an extension provides to inform Platform.Bible of the themes it provides.',\n anyOf: [\n {\n $ref: '#/$defs/themeFamiliesById',\n },\n ],\n $defs: themeDefs,\n};\n\nObject.freeze(themeDocumentSchema);\n","import { ReplaceType } from '../util';\nimport { ThemeDefinition, ThemeFamiliesById, ThemeFamily } from './theme.model';\n\n/**\n * {@link ThemeDefinition} with some additional properties derived from the {@link ThemeFamiliesById}\n * it comes from to help with managing the theme\n */\nexport type ThemeDefinitionExpanded = ThemeDefinition & {\n /**\n * Unique identifier for the {@link ThemeFamily} this theme is in.\n *\n * This is derived from the key of the {@link ThemeFamiliesById} this theme is in\n */\n themeFamilyId: string;\n /**\n * The kind of theme (e.g. light, dark). Some UI elements use the theme type to determine how to\n * look. Colors not present in the theme will fall back to the built-in colors for this type.\n *\n * This is derived from the key of the {@link ThemeFamily} this theme is in\n */\n type: string;\n /**\n * Unique identifier for this theme.\n *\n * This is derived by combining the theme family and type\n */\n id: string;\n};\n\n/**\n * Replaces {@link ThemeDefinition} with {@link ThemeDefinitionExpanded} recursively in the provided\n * type. Modifies the type to what is used in the theme service.\n */\nexport type ExpandThemeDefinition = ReplaceType;\n\n/**\n * {@link ThemeFamily} with all {@link ThemeDefinition} replaced by {@link ThemeDefinitionExpanded}.\n * This is used in the theme service\n */\nexport type ThemeFamilyExpanded = ExpandThemeDefinition;\n\n/**\n * {@link ThemeFamiliesById} with all {@link ThemeDefinition} replaced by\n * {@link ThemeDefinitionExpanded}. This is used in the theme service\n */\nexport type ThemeFamiliesByIdExpanded = ExpandThemeDefinition;\n\n/** ID for the style element the theme styles should go into */\nexport const THEME_STYLE_ELEMENT_ID = 'theme-styles';\n\nfunction getThemeId(themeFamilyId: string, type: string) {\n return `${themeFamilyId ? `${themeFamilyId}-` : ''}${type}`;\n}\n\n/**\n * Add the derived properties in {@link ThemeDefinitionExpanded} to {@link ThemeDefinition}s in the\n * given {@link ThemeFamiliesById} and fill in any missing `cssVariables` in the theme definitions\n * with those from the default themes.\n *\n * Does not modify the input object.\n *\n * @param themeFamiliesById Theme families to expand with the additional derived properties\n * @param defaultThemeFamily If provided, themes from this family are used to fill in missing\n * `cssVariables` in the theme definitions to make sure each theme definition has all necessary\n * `cssVariables`\n * @returns The expanded theme families\n */\nexport function expandThemeContribution(\n themeFamiliesById: ThemeFamiliesById,\n defaultThemeFamily: ThemeFamily | undefined,\n): ThemeFamiliesByIdExpanded {\n const themeFamiliesByIdExpanded: ThemeFamiliesByIdExpanded = Object.fromEntries(\n Object.entries(themeFamiliesById)\n .map(([themeFamilyId, themeFamily]) => [\n themeFamilyId,\n themeFamily\n ? Object.fromEntries(\n Object.entries(themeFamily)\n .map(([type, themeDefinition]): [string, ThemeDefinitionExpanded | undefined] => [\n type,\n themeDefinition\n ? {\n ...themeDefinition,\n // Add the derived properties\n themeFamilyId,\n type,\n id: getThemeId(themeFamilyId, type),\n cssVariables: {\n // Fill in the default css variables\n ...defaultThemeFamily?.[type]?.cssVariables,\n ...themeDefinition.cssVariables,\n },\n }\n : undefined,\n ])\n .filter(([, themeDefinition]) => !!themeDefinition),\n )\n : undefined,\n ])\n .filter(([, themeFamily]) => !!themeFamily),\n );\n return themeFamiliesByIdExpanded;\n}\n\n/** Gets the CSS stylesheet that should be applied for the given theme */\nexport function getStylesheetForTheme(theme: ThemeDefinitionExpanded): string {\n return `\n.${theme.id} {\n${Object.entries(theme.cssVariables)\n .map(([variableName, value]) => ` --${variableName}: ${value};`)\n .join('\\n')}\n}\n`;\n}\n\n/**\n * Applies a CSS stylesheet for the provided theme to the current window\n *\n * WARNING: THIS MUST BE BOUND TO `window` IN ORDER TO USE!\n *\n * ```ts\n * applyThemeStylesheet.bind(window)()`\n * ```\n *\n * @param theme Theme to apply\n * @param previousStyleElement Previous style element if applicable\n * @param styleElementIdSuffix Suffix to apply to the ID of the new style element. Will be\n * {@link THEME_STYLE_ELEMENT_ID} with a dash and the suffix added to it\n * @returns\n */\n// Must use `this` so it works across iframes\nexport function applyThemeStylesheet(\n this: Window,\n theme: ThemeDefinitionExpanded,\n previousStyleElement?: HTMLStyleElement,\n styleElementIdSuffix?: string,\n): HTMLStyleElement {\n // Set the class on the body\n const previousThemeId = previousStyleElement?.dataset.themeId;\n if (previousThemeId) this.document.body.classList.remove(previousThemeId);\n this.document.body.classList.add(theme.id);\n\n // Set up the stylesheet element\n if (previousStyleElement) this.document.head.removeChild(previousStyleElement);\n const themeStyleElement = this.document.createElement('style');\n themeStyleElement.id = `${THEME_STYLE_ELEMENT_ID}${styleElementIdSuffix ? `-${styleElementIdSuffix}` : ''}`;\n themeStyleElement.dataset.themeId = theme.id;\n themeStyleElement.textContent = getStylesheetForTheme(theme);\n this.document.head.appendChild(themeStyleElement);\n return themeStyleElement;\n}\n","/**\n * Information about a USFM marker that is just an attribute in USX/USJ. See {@link MarkerInfo} for\n * other kinds of markers.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker instead in USX/USJ.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for `v`. `cat`\n * is an attribute marker for `f`, `esb`, and more.\n *\n * Following is an example of using the `ca` and `cp` attribute markers in USFM:\n *\n * ```usfm\n * \\c 1 \\ca 2\\ca*\n * \\cp A\n * \\s1 This is a section header\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * This is a section header\n * ```\n */\nexport type AttributeMarkerInfo = NormalMarkerInfo & {\n /**\n * List of normal marker names for which this marker is an attribute marker.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` for both\n * `ca` and `cp`.\n */\n isAttributeMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an attribute marker.\n *\n * @example\n *\n * Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`.\n * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isAttributeMarkerForRegExp?: string[];\n /**\n * The name of the USX/USJ attribute this attribute marker represents.\n *\n * @example\n *\n * `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the `c` marker\n * in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` marker.\n */\n attributeMarkerAttributeName: string;\n /**\n * Whether there should be a structural space after the normal closing marker in output USFM if\n * this marker is an attribute marker. If this marker is not an attribute marker, it should not\n * have a structural space after the normal closing marker.\n *\n * This field should be ignored if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `true`\n * because this space is only supposed to be added in contexts in which the space here is\n * structural. Otherwise we would be mistakenly adding content to the USFM.\n *\n * Note that, if {@link MarkersMap.isSpaceAfterAttributeMarkersContent} is `false` (which is the\n * case according to spec), horizontal spaces after attribute markers are always considered\n * structural; this property only indicates whether there should be a space after the attribute\n * marker when outputting USFM as opposed to parsing it.\n *\n * If not present or `undefined`, defaults to `false`.\n *\n * @example\n *\n * According to specification, the `va` and `vp` attribute markers have a space after their normal\n * closing markers:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp 10 vp\\vp* Some verse text\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n *\n * However, when the `vp` marker is not an attribute marker, such as when it has markers in its\n * contents, there should not be a structural space after the normal closing marker, and any space\n * should be considered content:\n *\n * ```usfm\n * \\p \\v 10 \\va 10 va\\va* \\vp \\+wj 10 vp\\+wj*\\vp* Some verse text.\n * ```\n *\n * The verse text in this example is \" Some verse text\" including a space at the start.\n *\n * @example\n *\n * The `cat` attribute marker does not have a structural space after its normal closing marker:\n *\n * ```usfm\n * \\f + \\cat category here\\cat*\\fr 1:2 \\ft Some footnote text\\f*\n * ```\n *\n * The verse text in this example is just \"Some verse text\" without a space at the start.\n */\n hasStructuralSpaceAfterCloseAttributeMarker?: boolean;\n};\n\n/**\n * Information about a regular USFM/USX/USJ marker. See {@link MarkerInfo} for other kinds of\n * markers.\n */\nexport type NormalMarkerInfo = {\n /**\n * Which marker type the marker is. Determines how the marker is structured in the data such as\n * what kind of mandatory whitespace is around the marker in USFM. See {@link MarkerTypeInfoBase}\n * for information.\n */\n type: string;\n /** Explanation of the meaning of this marker */\n description?: string;\n /**\n * Which attribute can be provided without specifying the attribute name in USFM.\n *\n * A marker can have a default attribute only if it has zero or one non-optional attributes.\n *\n * An attribute can be provided with default syntax in the USFM only if it is the only attribute\n * provided for the marker.\n *\n * @example\n *\n * A marker with a default attribute:\n *\n * ```usfm\n * \\w stuff|thisIsTheLemmaDefaultAttribute\\w*\n * ```\n *\n * @example\n *\n * A marker with multiple attributes (cannot use default attribute syntax):\n *\n * ```usfm\n * \\w stuff|lemma=\"thisIsTheLemma\" strong=\"H1234,G1234\"\\w*\n * ```\n */\n defaultAttribute?: string;\n /**\n * The name of the text content attribute that is present on this marker if this marker has text\n * content in USFM.\n *\n * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual\n * text content of the marker.\n *\n * @example\n *\n * `alt` is a text content attribute on the `periph` marker. This value would be `alt` for the\n * `periph` marker.\n *\n * Following is an example of a `periph` marker in USFM:\n *\n * ```usfm\n * \\periph Example Peripheral|id=\"x-example\"\n * \\p Some contents of the example peripheral\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * \n * Some contents of the example peripheral\n * \n * ```\n */\n textContentAttribute?: string;\n /**\n * List of leading attributes that must be present on this marker. This list is ordered by the\n * order in which the attributes should appear.\n *\n * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker\n * and separated only by a space.\n *\n * @example\n *\n * `code` is a leading attribute on the `id` marker. This value would be `['code']` for the `id`\n * marker.\n *\n * Following is an example of an `id` marker in USFM:\n *\n * ```usfm\n * \\id MAT 41MATEX.SFM, Example Translation, September 2025\n * ```\n *\n * The equivalent in USX would be:\n *\n * ```xml\n * \n * 41MATEX.SFM, Example Translation, September 2025\n * ```\n */\n leadingAttributes?: string[];\n /**\n * List of attribute markers that may be present on this marker. This list is ordered by the order\n * in which the markers should appear.\n *\n * An attribute marker is a marker that adds information to a previous marker in USFM and is an\n * attribute on that previous marker in USX/USJ.\n *\n * Note: the attribute names for attribute markers may be different than the marker names. See\n * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information.\n *\n * @example\n *\n * `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for `c`.\n */\n attributeMarkers?: string[];\n /**\n * Whether the normal closing marker for this marker is considered optional in USFM, meaning in\n * some cases that the normal closing marker would be expected not to be present.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `true`, this marker\n * may or may not be expected to have a normal closing marker actually present in USFM depending\n * on the value of this property.\n *\n * - If this is `true`, the normal closing marker for this marker in USFM may be expected to be\n * present or absent depending on the value of\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}. If\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `true`, this marker is expected to\n * have the normal closing marker actually present in USFM just like markers for which this\n * property is `false`. If {@link MarkersMap.shouldOptionalClosingMarkersBePresent} is `false`,\n * this marker is expected not to have the normal closing marker actually present in USFM. The\n * `closed` attribute should be present if the presence of a normal closing marker for this\n * marker in USFM does not match the presence implied by\n * {@link MarkersMap.shouldOptionalClosingMarkersBePresent}.\n * - If this is `false`, the normal closing marker for this marker in USFM is expected to always be\n * present. If the normal closing marker is absent in USFM, the USX/USJ for this marker should\n * have the attribute `closed` set to `false`.\n *\n * If this marker's type has {@link CloseableMarkerTypeInfo.isCloseable} set to `false`, this\n * property is unused; markers of that type do not have a normal closing marker.\n *\n * If not present or `undefined`, defaults to `false`\n */\n isClosingMarkerOptional?: boolean;\n /**\n * List of independent closing marker names for this marker in USFM if it has any. If this is\n * defined, this marker does not have a normal closing marker but rather is closed by a completely\n * separate marker in USFM. All contents between this marker and the independent closing marker\n * are contents of this marker. In USX and USJ, this marker is closed normally like any other\n * object because USX and USJ have clear hierarchical structure.\n *\n * Note that independent closing markers do not have a `*` at the end because they are not normal\n * closing marker for but rather are completely separate markers that close the corresponding\n * opening marker.\n *\n * @example\n *\n * `esb` (a sidebar) is closed by the independent closing marker `esbe`.\n * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a\n * sidebar:\n *\n * ```usfm\n * \\esb\n * \\p This paragraph is in a \\bd sidebar\\bd*.\n * \\p The sidebar can contain multiple paragraphs.\n * \\esbe\n * ```\n */\n independentClosingMarkers?: string[];\n /**\n * List of marker names for which this marker is an independent closing marker. See\n * {@link NormalMarkerInfo.independentClosingMarkers} for more information on independent closing\n * markers and their syntax.\n *\n * @example\n *\n * `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` would be\n * `['esb']` for `esbe`.\n */\n isIndependentClosingMarkerFor?: string[];\n /**\n * List of RegExp patterns matching marker names for which this marker is an independent closing\n * marker. See {@link NormalMarkerInfo.independentClosingMarkers} for more information on\n * independent closing markers and their syntax.\n *\n * @example\n *\n * Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp `/test/`.\n * `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`.\n */\n isIndependentClosingMarkerForRegExp?: string[];\n /**\n * Marker to use when operating on the USFM representation of this marker. For example, when\n * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used\n * instead of the marker info for the marker as listed in USX or USJ.\n *\n * @example\n *\n * When the `usx` marker is output to USFM, it should be transformed to the `usfm` marker.\n */\n markerUsfm?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker when\n * transforming from USFM to USX or USJ. These instructions are an explanation of what needs to be\n * done to this marker to properly transform it to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker that is essential for proper translation between formats.\n *\n * @example\n *\n * `w` is a `char`-type marker, so it shares the characteristics of the `char` {@link MarkerTypeInfo}\n * with other `char`-type markers and has its own set of characteristics. `w`'s `MarkerInfo` is as\n * follows:\n *\n * ```json\n * {\n * \"type\": \"char\",\n * \"defaultAttribute\": \"lemma\"\n * }\n * ```\n */\nexport type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo;\n\n/**\n * Information about a USFM/USX/USJ marker type that has a closing marker. See {@link MarkerTypeInfo}\n * for other kinds of marker types.\n *\n * If the marker type has a closing marker but the closing marker is not present in the USFM for a\n * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to\n * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`.\n *\n * @example\n *\n * `char` marker types such as `nd` markers have closing markers, but `para` markers such as `p` do\n * not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type CloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable: true;\n /**\n * Whether the closing marker for markers of this type is \"empty\" in USFM, meaning the marker name\n * is absent from the closing marker. This also means that there should not be a structural space\n * between the opening and the closing markers in USFM if there are no attributes listed on the\n * marker.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker:\n *\n * ```usfm\n * \\qt1-s\\*\n * ...\n * \\qt1-e\\*\n * ```\n *\n * The closing marker for `qt1-s` is `\\*` as opposed to the closing marker for `nd` which is\n * `\\nd*`.\n *\n * Note that there is still a structural space after the opening marker if there are attributes\n * present:\n *\n * ```usfm\n * \\qt1-s |Someone\\*\n * ...\n * \\qt1-e\\*\n * ```\n */\n isClosingMarkerEmpty?: boolean;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that does not have a closing marker. See\n * {@link MarkerTypeInfo} for other kinds of marker types.\n *\n * @example\n *\n * `char` marker types such as `nd` markers have closing markers, but `para` marker types such as\n * `p` do not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\nexport type NonCloseableMarkerTypeInfo = MarkerTypeInfoBase & {\n /**\n * Whether markers of this type can have a normal closing marker in USFM. This property concerns\n * normal closing markers like `\\wj*`, not independent closing markers like\n * {@link NormalMarkerInfo.independentClosingMarkers}, which are completely separate markers.\n *\n * If this is `true`, markers of this type _may_ have a normal closing marker present in USFM.\n * Usually, markers whose type has `isCloseable` set to `true` are expected to have a normal\n * closing marker actually present in USFM unless otherwise specified using the `closed`\n * attribute. However, some markers are expected _not_ to have a normal closing marker actually\n * present in USFM unless otherwise specified using the `closed` attribute. To determine whether a\n * specific marker of this type is expected not to have a closing marker present in USFM, see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}.\n *\n * If this is `false`, markers of this type do not have a normal closing marker; there is never\n * expected to be a normal closing marker in USFM for markers of this type. In this case,\n * {@link NormalMarkerInfo.isClosingMarkerOptional} is unused.\n *\n * If not present or `undefined`, defaults to `false` (meaning this `MarkerTypeInfo` is a\n * {@link NonCloseableMarkerTypeInfo}, not a {@link CloseableMarkerTypeInfo})\n */\n isCloseable?: false;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is common to all marker types. See\n * {@link MarkerTypeInfo} for various kinds of marker types.\n */\nexport type MarkerTypeInfoBase = {\n /** Explanation of the meaning of this marker type */\n description?: string;\n /**\n * Whether markers of this type should have a `style` attribute in USX/USJ.\n *\n * If this is `false`, it also means the marker type is the same as the marker name.\n *\n * If not present or `undefined`, defaults to `true`.\n */\n hasStyleAttribute?: boolean;\n /**\n * List of attributes that should not be output to USFM on markers of this type.\n *\n * This is used for attributes that are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example\n *\n * The `sid` attribute on the `verse` type marker is not present in USFM because it is derived\n * metadata in USX/USJ and is not present in USFM.\n */\n skipOutputAttributeToUsfm?: string[];\n /**\n * List of attributes indicating whether to skip outputting this marker to USFM. If any of the\n * listed attributes is present on the marker, skip outputting this marker when converting to\n * USFM. Only skip outputting the opening and closing marker representations, though; the content\n * inside the marker (if present) should not be skipped.\n *\n * This is used for certain markers that sometimes are normal markers but sometimes are derived\n * metadata and are not present in USFM. These derived metadata markers are identified by whether\n * they have specific attributes on them.\n *\n * This property is not used when converting to USX or USJ.\n *\n * @example\n *\n * If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the end of\n * the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the `verse`\n * marker does not have the `style=\"v\"` attribute in this situation, so this list of attributes is\n * on the marker type.\n *\n * Following is an example of a derived metadata `verse` marker in USX:\n *\n * ```xml\n * \n * \n * This is verse 21.\n * \n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\p\n * \\v 21 This is verse 21.\n * ```\n *\n * @example\n *\n * Generated `ref`s should be skipped but have content inside the marker that should not be\n * skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have\n * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived\n * metadata have the `gen` attribute set to `\"true\"` and can be removed if `gen=\"true\"` is\n * present.\n *\n * Following is an example of a generated `ref` in USX:\n *\n * ```xml\n * \n * 2Sam 1:1; 2Sam 1:2-3.\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\xt 2Sam 1:1; 2Sam 1:2-3.\\xt*\n * ```\n */\n skipOutputMarkerToUsfmIfAttributeIsPresent?: string[];\n /**\n * Whether to always skip outputting this marker when converting to USFM. Only skip outputting the\n * opening and closing marker representations, though; the content inside the marker (if present)\n * should not be skipped.\n *\n * This is used for marker types that have no representation in USFM in a given version, likely\n * meaning they are derived metadata and are not present in USFM.\n *\n * This property is not used when converting to USX or USJ.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ and is\n * not preserved when transforming from USX/USJ to USFM.\n *\n * Following is an example of a derived metadata `table` marker in USX:\n *\n * ```xml\n * \n * \n * \n * Header 1\n * Header 2 space after \n * Header 3-4 centered\n * Header 5 right\n * \n * \n * Row 1 cell 1\n * Row 1 cell 2 space after \n * Row 1 cell 3 centered\n * Row 1 cell 4-5 right\n * \n * \n * Row 2 cell 1-4 right\n * Row 2 cell 5\n * \n *
\n * ```\n *\n * The equivalent in USFM would be:\n *\n * ```usfm\n * \\tr \\th1 Header 1\\th2 Header 2 space after \\thc3-4 Header 3-4 centered\\thr5 Header 5 right\n * \\tr \\tc1 Row 1 cell 1\\tc2 Row 1 cell 2 space after \\thc3 Row 1 cell 3 centered\\thr4-5 Row 1 cell 4-5 right\n * \\tr \\tcr1-4 Row 2 cell 1-4 right\\tc5 Row 2 cell 5\n * ```\n */\n skipOutputMarkerToUsfm?: boolean;\n /**\n * Whether markers of this type should have a newline before them in USFM.\n *\n * Note that the newline is never strictly necessary, and it is not usually present if the very\n * first marker in the file (or in examples such as the following example) should have a newline.\n *\n * If not present or `undefined`, defaults to `false`\n *\n * @example\n *\n * `para` marker types such as `p` should have a newline, but `char` marker types such as `nd`\n * markers should not:\n *\n * ```usfm\n * \\p This is a plain paragraph.\n * \\p This is a paragraph \\nd with some special text\\nd* in it.\n * ```\n */\n hasNewlineBefore?: boolean;\n /**\n * Marker type to use when operating on the USFM representation of markers of this type. For\n * example, when outputting to USFM, the marker type listed here in `markerTypeUsfm` should be\n * used instead of the marker's type as listed in USX or USJ.\n */\n markerTypeUsfm?: string;\n /**\n * Marker type to use when operating on the USX representation of markers of this type. For\n * example, when outputting to USX, the marker type listed here in `markerTypeUsx` should be used\n * instead of the marker's type as listed in USFM or USJ.\n */\n markerTypeUsx?: string;\n /**\n * Marker type to use when operating on the USJ representation of markers of this type. For\n * example, when outputting to USJ, the marker type listed here in `markerTypeUsj` should be used\n * instead of the marker's type as listed in USFM or USX.\n */\n markerTypeUsj?: string;\n /**\n * Prefix to add to the opening and closing marker before the marker name if a marker of this type\n * occurs within another marker of this type when outputting to USFM.\n *\n * @example\n *\n * In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is an\n * example of `nd` inside `wj` (both are `char`-type markers) in USFM:\n *\n * ```usfm\n * \\p \\wj This is \\+nd nested\\+nd*!\\wj*\n * ```\n */\n nestedPrefix?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming to USFM. These instructions are an explanation of what needs to be done to\n * markers of this type to properly transform the marker to USFM.\n *\n * This property is generally only included when it is exceptionally difficult to output a marker\n * properly to USFM; the markers map attempts to use this property as little as possible, favoring\n * encoding information in other properties for more automatic transformation instead.\n */\n outputToUsfmInstructions?: string;\n /**\n * Instructions written in plain text regarding special handling required for this marker type\n * when transforming from USFM to USX or USJ. These instructions are an explanation of what needs\n * to be done to markers of this type to properly transform the marker to USX or USJ.\n *\n * This property is generally only included when it is exceptionally difficult to parse a marker\n * properly from USFM; the markers map attempts to use this property as little as possible,\n * favoring encoding information in other properties for more automatic transformation instead.\n */\n parseUsfmInstructions?: string;\n};\n\n/**\n * Information about a USFM/USX/USJ marker type that is essential for proper translation between\n * formats.\n *\n * @example\n *\n * `char` is a marker type, which means markers like `w` whose marker type is `char` share some\n * characteristics, and each marker also has its own set of characteristics which are presented with\n * type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows:\n *\n * ```json\n * {\n * \"isCloseable\": true,\n * \"nestedPrefix\": \"+\"\n * }\n * ```\n */\nexport type MarkerTypeInfo = CloseableMarkerTypeInfo | NonCloseableMarkerTypeInfo;\n\n/** A map of all USFM/USX/USJ markers and some information about them */\nexport type MarkersMap = {\n /** Which version of USFM/USX/USJ this map represents */\n version: string;\n /** Which repository this map came from. */\n schemaRepo: string;\n /**\n * Which commit this map came from. This is necessary because the schema file seems to be\n * distributed multiple times in one release version. As such, this specifies the exact version of\n * the schema file.\n */\n schemaCommit: string;\n /**\n * Which version of the markers map types this markers map conforms to. Follows [Semantic\n * versioning](https://semver.org/); the same major version contains no breaking changes.\n */\n markersMapVersion: `1.${number}.${number}${string}`;\n /**\n * Which tag or commit in the `https://github.com/paranext/usfm-tools` repo this map is generated\n * from.\n *\n * Contains the output from `git tag --points-at HEAD` or `git rev-parse HEAD`\n *\n * Will also have a `+` at the end if there were working changes outside the `src/test-data`\n * folder when this was generated.\n */\n usfmToolsCommit: string;\n /**\n * Whether any whitespace after attribute markers and before the next content is not just\n * structural but should actually be considered part of the content of the marker.\n *\n * Structural whitespace is whitespace in the USFM that is required as part of the USFM syntax and\n * usually acts as a delimiter between markers and other things. Content whitespace is whitespace\n * in USFM that is part of the actual Scripture text or the \"content\" of the marker.\n *\n * According to specification, whitespace after attribute markers is not content but is just\n * structural.\n *\n * According to Paratext 9.4, whitespace after attribute markers is content and is not just\n * structural.\n *\n * This setting determines which interpretation to use when converting from USFM to USX/USJ.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n isSpaceAfterAttributeMarkersContent?: boolean;\n /**\n * Whether markers with optional closing markers (see\n * {@link NormalMarkerInfo.isClosingMarkerOptional}) should still be explicitly closed in USFM.\n * That is, whether markers with optional closing markers still need the `closed` attribute set to\n * `\"false\"` in USX/USJ if the closing marker is not present in USFM.\n *\n * In other words, this setting determines whether markers with optional closing markers should\n * still be expected to be explicitly closed (meaning the closing marker is present in USFM) when\n * transforming USX/USJ to USFM unless otherwise indicated by the `closed` attribute.\n *\n * If this is `true` (matches Paratext 9.4), markers with optional closing markers are treated\n * like markers whose normal closing marker is not optional in that they are expected to be\n * explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they should have `closed=\"false\"`\n * - If they are explicitly closed in USFM, they do not need `closed=\"true\"`\n *\n * If this is `false` (matches specification), markers with optional closing markers are expected\n * _not_ to be explicitly closed in USFM unless otherwise indicated:\n *\n * - If they are not explicitly closed in USFM, they do not need `closed=\"false\"`\n * - If they are explicitly closed in USFM, they should have `closed=\"true\"`\n *\n * - Disclaimer: It is not clear that `closed=\"true\"` should be present in this case according to\n * `usx.rng`; it seems `usx.rng` indicates that optional closing markers should never be\n * output to USFM. It is possible that `usx.rng` considers this to be a case where\n * preserving the exact USFM is not important.\n *\n * If not present or `undefined`, defaults to `false`.\n */\n shouldOptionalClosingMarkersBePresent?: boolean;\n /**\n * Map whose keys are the marker names and whose values are information about that marker\n *\n * If you find the marker name in this map, you do not need to search the `markersRegExp` map.\n */\n markers: Record;\n /**\n * Map whose keys are string representations of `RegExp` patterns to match against marker names\n * (using the\n * [test](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)\n * function) and whose values are information about that marker\n *\n * You do not need to search this map if you found the marker name in the `markers` map.\n */\n markersRegExp: Record;\n /** Map whose keys are the marker types and whose values are information about that marker type */\n markerTypes: Record;\n};\n\n// This function should safely freeze anything, but TypeScript doesn't understand.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction deepFreeze(o: any) {\n Object.freeze(o);\n // Don't want to crash out on null\n // eslint-disable-next-line no-null/no-null\n if (o === undefined || o === null) {\n return o;\n }\n\n Object.getOwnPropertyNames(o).forEach(function freezeProperty(prop) {\n if (\n // Need to make sure to avoid null, which is an object type\n // eslint-disable-next-line no-null/no-null\n o[prop] !== null &&\n (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&\n !Object.isFrozen(o[prop])\n ) {\n deepFreeze(o[prop]);\n }\n });\n\n return o;\n}\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file\n */\nexport const USFM_MARKERS_MAP: MarkersMap = deepFreeze({\n version: '3.0.7',\n schemaRepo: 'https://github.com/ubsicap/usx.git',\n schemaCommit: '6c490bb5675d281b0fa01876fe67f6e3fd50a4ce',\n markersMapVersion: '1.0.0',\n usfmToolsCommit: '6c7bb8d75eda47893296a635c1e6e0b67165ac7f',\n markers: {\n add: {\n type: 'char',\n description: 'For a translational addition to the text',\n },\n addpn: {\n type: 'char',\n description:\n 'For chinese words to be dot underline & underline (DEPRECATED - used nested char@style pn)',\n },\n b: {\n type: 'para',\n description: 'Poetry text stanza break (e.g. stanza break)',\n },\n bd: {\n type: 'char',\n description: 'A character style, use bold text',\n },\n bdit: {\n type: 'char',\n description: 'A character style, use bold + italic text',\n },\n bk: {\n type: 'char',\n description: 'For the quoted name of a book',\n },\n c: {\n type: 'chapter',\n leadingAttributes: ['number'],\n attributeMarkers: ['ca', 'cp'],\n },\n ca: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['c'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description: 'Second (alternate) chapter number',\n },\n cat: {\n type: 'char',\n attributeMarkerAttributeName: 'category',\n isAttributeMarkerFor: ['ef', 'efe', 'esb', 'ex', 'f', 'fe', 'x'],\n description: 'Note category (study Bible)',\n },\n cd: {\n type: 'para',\n description: 'Chapter Description (Publishing option D, e.g. in Russian Bibles)',\n },\n cl: {\n type: 'para',\n description: 'Chapter label used for translations that add a word such as \"Chapter\"',\n },\n cls: {\n type: 'para',\n description: 'Closure of an Epistle',\n },\n cp: {\n type: 'para',\n description: 'Published chapter number',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['c'],\n },\n d: {\n type: 'para',\n description: 'A Hebrew text heading, to provide description (e.g. Psalms)',\n },\n dc: {\n type: 'char',\n description: 'Deuterocanonical/LXX additions or insertions in the Protocanonical text',\n },\n ef: {\n type: 'note',\n description: 'Study note',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efe: {\n type: 'note',\n description: 'Extended study endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n efm: {\n type: 'char',\n description: 'Reference to caller of previous footnote in a study Bible',\n },\n em: {\n type: 'char',\n description: 'A character style, use emphasized text style',\n },\n esb: {\n type: 'sidebar',\n independentClosingMarkers: ['esbe'],\n attributeMarkers: ['cat'],\n },\n esbe: {\n type: 'sidebar',\n isIndependentClosingMarkerFor: ['esb'],\n },\n ex: {\n type: 'note',\n description: 'Extended cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n f: {\n type: 'note',\n description: 'Footnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fdc: {\n type: 'char',\n description: 'Footnote text, applies to Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n fe: {\n type: 'note',\n description: 'Endnote',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n fig: {\n type: 'figure',\n },\n fk: {\n type: 'char',\n description: 'A footnote keyword',\n isClosingMarkerOptional: true,\n },\n fl: {\n type: 'char',\n description:\n 'A footnote label text item, for marking or \"labelling\" the type or alternate translation being provided in the note.',\n isClosingMarkerOptional: true,\n },\n fm: {\n type: 'char',\n description: 'Reference to caller of previous footnote',\n },\n fp: {\n type: 'char',\n description: 'A Footnote additional paragraph marker',\n isClosingMarkerOptional: true,\n },\n fq: {\n type: 'char',\n description: 'A footnote scripture quote or alternate rendering',\n isClosingMarkerOptional: true,\n },\n fqa: {\n type: 'char',\n description: 'A footnote alternate rendering for a portion of scripture text',\n isClosingMarkerOptional: true,\n },\n fr: {\n type: 'char',\n description: 'The origin reference for the footnote',\n isClosingMarkerOptional: true,\n },\n ft: {\n type: 'char',\n description: 'Footnote text, Protocanon',\n isClosingMarkerOptional: true,\n },\n fv: {\n type: 'char',\n description: 'A verse number within the footnote text',\n },\n fw: {\n type: 'char',\n description:\n 'A footnote witness list, for distinguishing a list of sigla representing witnesses in critical editions.',\n isClosingMarkerOptional: true,\n },\n h: {\n type: 'para',\n description: 'Running header text for a book',\n },\n h1: {\n type: 'para',\n description: 'Running header text (DEPRECATED)',\n },\n h2: {\n type: 'para',\n description: 'Running header text, left side of page (DEPRECATED)',\n },\n h3: {\n type: 'para',\n description: 'Running header text, right side of page (DEPRECATED)',\n },\n ib: {\n type: 'para',\n description: 'Introduction blank line',\n },\n id: {\n type: 'book',\n leadingAttributes: ['code'],\n },\n ide: {\n type: 'para',\n description: 'File encoding information',\n },\n ie: {\n type: 'para',\n description: 'Introduction ending marker',\n },\n iex: {\n type: 'para',\n description:\n 'Introduction explanatory or bridge text (e.g. explanation of missing book in Short Old Testament)',\n },\n ili: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n ili1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n ili2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n im: {\n type: 'para',\n description:\n 'Introduction prose paragraph, with no first line indent (may occur after poetry)',\n },\n imi: {\n type: 'para',\n description: 'Introduction prose paragraph text, indented, with no first line indent',\n },\n imq: {\n type: 'para',\n description:\n 'Introduction prose paragraph, quote from the body text, with no first line indent',\n },\n imt: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nIntroduction major title, level 1 - (if single level)',\n },\n imt1: {\n type: 'para',\n description: 'Introduction major title, level 1 (if multiple levels)',\n },\n imt2: {\n type: 'para',\n description: 'Introduction major title, level 2',\n },\n imt3: {\n type: 'para',\n description: 'Introduction major title, level 3',\n },\n imt4: {\n type: 'para',\n description: 'Introduction major title, level 4 (usually within parenthesis)',\n },\n imte: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if single level)',\n },\n imte1: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 1 (if multiple levels)',\n },\n imte2: {\n type: 'para',\n description: 'Introduction major title at introduction end, level 2',\n },\n io: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if single level)',\n },\n io1: {\n type: 'para',\n description: 'Introduction outline text, level 1 (if multiple levels)',\n },\n io2: {\n type: 'para',\n description: 'Introduction outline text, level 2',\n },\n io3: {\n type: 'para',\n description: 'Introduction outline text, level 3',\n },\n io4: {\n type: 'para',\n description: 'Introduction outline text, level 4',\n },\n ior: {\n type: 'char',\n description:\n 'Introduction references range for outline entry; for marking references separately',\n },\n iot: {\n type: 'para',\n description: 'Introduction outline title',\n },\n ip: {\n type: 'para',\n description:\n 'Introduction prose paragraph\\nDivision or Section introductory paragraph (study Bible)',\n },\n ipi: {\n type: 'para',\n description: 'Introduction prose paragraph, indented, with first line indent',\n },\n ipq: {\n type: 'para',\n description: 'Introduction prose paragraph, quote from the body text',\n },\n ipr: {\n type: 'para',\n description: 'Introduction prose paragraph, right aligned',\n },\n iq: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if single level)',\n },\n iq1: {\n type: 'para',\n description: 'Introduction poetry text, level 1 (if multiple levels)',\n },\n iq2: {\n type: 'para',\n description: 'Introduction poetry text, level 2',\n },\n iq3: {\n type: 'para',\n description: 'Introduction poetry text, level 3',\n },\n iqt: {\n type: 'char',\n },\n is: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if single level)',\n },\n is1: {\n type: 'para',\n description: 'Introduction section heading, level 1 (if multiple levels)',\n },\n is2: {\n type: 'para',\n description: 'Introduction section heading, level 2',\n },\n it: {\n type: 'char',\n description: 'A character style, use italic text',\n },\n jmp: {\n type: 'char',\n defaultAttribute: 'link-href',\n description: 'For associating linking attributes to a span of text',\n },\n k: {\n type: 'char',\n description: 'For a keyword',\n },\n k1: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 1',\n },\n k2: {\n type: 'para',\n description: 'Concordance main entry text or keyword, level 2',\n },\n lf: {\n type: 'para',\n description: 'List footer (introductory remark)',\n },\n lh: {\n type: 'para',\n description: 'List header (introductory remark)',\n },\n li: {\n type: 'para',\n description: 'A list entry, level 1 (if single level)',\n },\n li1: {\n type: 'para',\n description: 'A list entry, level 1 (if multiple levels)',\n },\n li2: {\n type: 'para',\n description: 'A list entry, level 2',\n },\n li3: {\n type: 'para',\n description: 'A list entry, level 3',\n },\n li4: {\n type: 'para',\n description: 'A list entry, level 4',\n },\n lik: {\n type: 'char',\n description: 'Structured list entry key text',\n },\n lim: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if single level)',\n },\n lim1: {\n type: 'para',\n description: 'An embedded list entry, level 1 (if multiple levels)',\n },\n lim2: {\n type: 'para',\n description: 'An embedded list entry, level 2',\n },\n lim3: {\n type: 'para',\n description: 'An embedded list entry, level 3',\n },\n lim4: {\n type: 'para',\n description: 'An embedded list entry, level 4',\n },\n lit: {\n type: 'para',\n description: 'For a comment or note inserted for liturgical use',\n },\n litl: {\n type: 'char',\n description: 'List entry total text',\n },\n liv: {\n type: 'char',\n description: 'Structured list entry value 1 content (if single value)',\n },\n liv1: {\n type: 'char',\n description: 'Structured list entrt value 1 content (if multiple values)',\n },\n liv2: {\n type: 'char',\n description: 'Structured list entry value 2 content',\n },\n liv3: {\n type: 'char',\n description: 'Structured list entry value 3 content',\n },\n liv4: {\n type: 'char',\n description: 'Structured list entry value 4 content',\n },\n liv5: {\n type: 'char',\n description: 'Structured list entry value 5 content',\n },\n m: {\n type: 'para',\n description:\n 'Paragraph text, with no first line indent (may occur after poetry) aka: Paragraph Continuation',\n },\n mi: {\n type: 'para',\n description: 'Paragraph text, indented, with no first line indent; often used for discourse',\n },\n mr: {\n type: 'para',\n description: 'A major section division references range heading',\n },\n ms: {\n type: 'para',\n description: 'A major section division heading, level 1 (if single level)',\n },\n ms1: {\n type: 'para',\n description: 'A major section division heading, level 1 (if multiple levels)',\n },\n ms2: {\n type: 'para',\n description: 'A major section division heading, level 2',\n },\n ms3: {\n type: 'para',\n description: 'A major section division heading, level 3',\n },\n mt: {\n type: 'para',\n description: 'The main title of the book (if single level)',\n },\n mt1: {\n type: 'para',\n description: 'The main title of the book (if multiple levels)',\n },\n mt2: {\n type: 'para',\n description: 'A secondary title usually occurring before the main title',\n },\n mt3: {\n type: 'para',\n description: 'A tertiary title occurring after the main title',\n },\n mt4: {\n type: 'para',\n description:\n 'Introduction major title, level 1 (if single level)\\nA small secondary title sometimes occuring within parentheses',\n },\n mte: {\n type: 'para',\n description:\n 'The main title of the book repeated at the end of the book, level 1 (if single level)',\n },\n mte1: {\n type: 'para',\n description:\n 'The main title of the book repeat /ed at the end of the book, level 1 (if multiple levels)',\n },\n mte2: {\n type: 'para',\n description: \"A secondary title occurring before or after the 'ending' main title\",\n },\n nb: {\n type: 'para',\n description:\n 'Paragraph text, with no break from previous paragraph text (at chapter boundary)',\n },\n nd: {\n type: 'char',\n description: 'For name of deity',\n },\n ndx: {\n type: 'char',\n description: 'A subject index text item',\n },\n no: {\n type: 'char',\n description: 'A character style, use normal text',\n },\n optbreak: {\n type: 'optbreak',\n },\n ord: {\n type: 'char',\n description: 'For the text portion of an ordinal number',\n },\n p: {\n type: 'para',\n description:\n 'Paragraph text, with first line indent\\nFront or back matter text paragraph, level 1',\n },\n p1: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 1 (if multiple levels)',\n },\n p2: {\n type: 'para',\n description: 'Front or back matter text paragraph, level 2 (if multiple levels)',\n },\n pb: {\n type: 'para',\n description:\n \"Page Break used for new reader portions and children's bibles where content is controlled by the page\",\n },\n pc: {\n type: 'para',\n description: 'Inscription (paragraph text centered)',\n },\n periph: {\n type: 'periph',\n textContentAttribute: 'alt',\n },\n ph: {\n type: 'para',\n description:\n 'Paragraph text, with level 1 hanging indent (if single level) (DEPRECATED - use para@style li#)',\n },\n ph1: {\n type: 'para',\n description: 'Paragraph text, with level 1 hanging indent (if multiple levels)',\n },\n ph2: {\n type: 'para',\n description: 'Paragraph text, with level 2 hanging indent',\n },\n ph3: {\n type: 'para',\n description: 'Paragraph text, with level 3 hanging indent',\n },\n pi: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if single level), with first line indent; often used for discourse',\n },\n pi1: {\n type: 'para',\n description:\n 'Paragraph text, level 1 indent (if multiple levels), with first line indent; often used for discourse',\n },\n pi2: {\n type: 'para',\n description:\n 'Paragraph text, level 2 indent, with first line indent; often used for discourse',\n },\n pi3: {\n type: 'para',\n description:\n 'Paragraph text, level 3 indent, with first line indent; often used for discourse',\n },\n pm: {\n type: 'para',\n description: 'Embedded text paragraph',\n },\n pmc: {\n type: 'para',\n description: 'Embedded text closing',\n },\n pmo: {\n type: 'para',\n description: 'Embedded text opening',\n },\n pmr: {\n type: 'para',\n description: 'Embedded text refrain',\n },\n pn: {\n type: 'char',\n description: 'For a proper name',\n },\n png: {\n type: 'char',\n description: 'For a geographic proper name',\n },\n po: {\n type: 'para',\n description: 'Letter opening',\n },\n pr: {\n type: 'para',\n description: 'Text refrain (paragraph right-aligned)',\n },\n pro: {\n type: 'char',\n description: 'For indicating pronunciation in CJK texts (DEPRECATED - used char@style rb)',\n },\n q: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if single level)',\n },\n q1: {\n type: 'para',\n description: 'Poetry text, level 1 indent (if multiple levels)',\n },\n q2: {\n type: 'para',\n description: 'Poetry text, level 2 indent',\n },\n q3: {\n type: 'para',\n description: 'Poetry text, level 3 indent',\n },\n q4: {\n type: 'para',\n description: 'Poetry text, level 4 indent',\n },\n qa: {\n type: 'para',\n description: 'Poetry text, Acrostic marker/heading',\n },\n qac: {\n type: 'char',\n description:\n 'Poetry text, Acrostic markup of the first character of a line of acrostic poetry',\n },\n qc: {\n type: 'para',\n description: 'Poetry text, centered',\n },\n qd: {\n type: 'para',\n description:\n 'A Hebrew musical performance annotation, similar in content to Hebrew descriptive title.',\n },\n qm: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if single level)',\n },\n qm1: {\n type: 'para',\n description: 'Poetry text, embedded, level 1 indent (if multiple levels)',\n },\n qm2: {\n type: 'para',\n description: 'Poetry text, embedded, level 2 indent',\n },\n qm3: {\n type: 'para',\n description: 'Poetry text, embedded, level 3 indent',\n },\n qr: {\n type: 'para',\n description: 'Poetry text, Right Aligned',\n },\n qs: {\n type: 'char',\n description: 'Poetry text, Selah',\n },\n qt: {\n type: 'char',\n description: 'For Old Testament quoted text appearing in the New Testament',\n },\n 'qt-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt1-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt1-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt2-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt2-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt3-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt3-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt4-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt4-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n 'qt5-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'qt5-s': {\n type: 'ms',\n defaultAttribute: 'who',\n },\n r: {\n type: 'para',\n description: 'Parallel reference(s)',\n },\n rb: {\n type: 'char',\n defaultAttribute: 'gloss',\n },\n ref: {\n type: 'ref',\n defaultAttribute: 'loc',\n },\n rem: {\n type: 'para',\n description: 'Remark',\n },\n restore: {\n type: 'para',\n description: 'Comment about when text was restored',\n },\n rq: {\n type: 'char',\n description: 'A cross-reference indicating the source text for the preceding quotation.',\n },\n s: {\n type: 'para',\n description: 'A section heading, level 1 (if single level)',\n },\n s1: {\n type: 'para',\n description: 'A section heading, level 1 (if multiple levels)',\n },\n s2: {\n type: 'para',\n description: 'A section heading, level 2 (e.g. Proverbs 22-24)',\n },\n s3: {\n type: 'para',\n description: 'A section heading, level 3 (e.g. Genesis \"The First Day\")',\n },\n s4: {\n type: 'para',\n description: 'A section heading, level 4',\n },\n sc: {\n type: 'char',\n description: 'A character style, for small capitalization text',\n },\n sd: {\n type: 'para',\n description:\n 'Vertical space used to divide the text into sections, level 1 (if single level)',\n },\n sd1: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 1 (if multiple levels)',\n },\n sd2: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 2',\n },\n sd3: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 3',\n },\n sd4: {\n type: 'para',\n description:\n 'Semantic division location (vertical space used to divide the text into sections), level 4',\n },\n sig: {\n type: 'char',\n description: 'For the signature of the author of an Epistle',\n },\n sls: {\n type: 'char',\n description:\n 'To represent where the original text is in a secondary language or from an alternate text source',\n },\n sp: {\n type: 'para',\n description: 'A heading, to identify the speaker (e.g. Job)',\n },\n sr: {\n type: 'para',\n description: 'A section division references range heading',\n },\n sts: {\n type: 'para',\n description: 'Status\\nRemark',\n },\n sup: {\n type: 'char',\n description:\n 'A character style, for superscript text. Typically for use in critical edition footnotes.',\n },\n 't-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 't-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n table: {\n type: 'table',\n },\n tl: {\n type: 'char',\n description: 'For transliterated words',\n },\n toc1: {\n type: 'para',\n description: 'Long table of contents text',\n },\n toc2: {\n type: 'para',\n description: 'Short table of contents text',\n },\n toc3: {\n type: 'para',\n description: 'Book Abbreviation',\n },\n toca1: {\n type: 'para',\n description: 'Alternative language long table of contents text',\n },\n toca2: {\n type: 'para',\n description: 'Alternative language short table of contents text',\n },\n toca3: {\n type: 'para',\n description: 'Alternative language book Abbreviation',\n },\n tr: {\n type: 'row',\n description: 'Table row',\n },\n ts: {\n type: 'ms',\n description:\n \"Translator's chunk (to identify chunks of text suitable for translating at one time)\",\n },\n 'ts-e': {\n type: 'ms',\n defaultAttribute: 'eid',\n },\n 'ts-s': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n usfm: {\n type: 'para',\n textContentAttribute: 'version',\n parseUsfmInstructions:\n \"If this marker is directly after the first id marker, this marker's version attribute should determine the version attribute of the usx or USJ marker at the top of the USX or USJ document, then this marker should be removed.\",\n },\n USJ: {\n type: 'USJ',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n usx: {\n type: 'usx',\n textContentAttribute: 'version',\n markerUsfm: 'usfm',\n },\n v: {\n type: 'verse',\n leadingAttributes: ['number'],\n attributeMarkers: ['va', 'vp'],\n },\n va: {\n type: 'char',\n attributeMarkerAttributeName: 'altnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n description:\n 'Second (alternate) verse number (for coding dual numeration in Psalms; see also NRSV Exo 22.1-4)',\n },\n vp: {\n type: 'char',\n description:\n 'Published verse marker - this is a verse marking that would be used in the published text',\n attributeMarkerAttributeName: 'pubnumber',\n isAttributeMarkerFor: ['v'],\n hasStructuralSpaceAfterCloseAttributeMarker: true,\n },\n w: {\n type: 'char',\n defaultAttribute: 'lemma',\n },\n wa: {\n type: 'char',\n description: 'An Aramaic wordlist text item',\n },\n wg: {\n type: 'char',\n description: 'A Greek Wordlist text item',\n },\n wh: {\n type: 'char',\n description: 'A Hebrew wordlist text item',\n },\n wj: {\n type: 'char',\n description: 'For marking the words of Jesus',\n },\n x: {\n type: 'note',\n description: 'Cross reference',\n leadingAttributes: ['caller'],\n attributeMarkers: ['cat'],\n },\n xdc: {\n type: 'char',\n description:\n 'Cross-reference target reference(s), Deuterocanon only (DEPRECATED - use char@style dc)',\n isClosingMarkerOptional: true,\n },\n xk: {\n type: 'char',\n description: 'A cross reference keyword',\n isClosingMarkerOptional: true,\n },\n xnt: {\n type: 'char',\n description: 'Cross-reference target reference(s), New Testament only',\n isClosingMarkerOptional: true,\n },\n xo: {\n type: 'char',\n description: 'The cross reference origin reference',\n isClosingMarkerOptional: true,\n },\n xop: {\n type: 'char',\n description:\n 'Published cross reference origin text (origin reference that should appear in the published text)',\n isClosingMarkerOptional: true,\n },\n xot: {\n type: 'char',\n description: 'Cross-reference target reference(s), Old Testament only',\n isClosingMarkerOptional: true,\n },\n xq: {\n type: 'char',\n description: 'A cross-reference quotation from the scripture text',\n isClosingMarkerOptional: true,\n },\n xt: {\n type: 'char',\n defaultAttribute: 'link-href',\n description:\n 'A target reference(s)\\nA cross reference target reference(s)\\nThe cross reference target reference(s), protocanon only',\n isClosingMarkerOptional: true,\n },\n xta: {\n type: 'char',\n description: 'Cross reference target references added text',\n isClosingMarkerOptional: true,\n },\n },\n markersRegExp: {\n '[Zz].+': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 'qt[1-5]?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n 't[hc][rc]?\\\\d+': {\n type: 'cell',\n },\n 'ts?(\\\\-[se])?': {\n type: 'ms',\n defaultAttribute: 'sid',\n },\n },\n markerTypes: {\n book: {},\n cell: {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n },\n chapter: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n char: {\n isCloseable: true,\n nestedPrefix: '+',\n },\n figure: {\n isCloseable: true,\n outputToUsfmInstructions: 'The USX/USJ file attribute needs its name changed to src in USFM',\n parseUsfmInstructions: 'The USFM src attribute needs its name changed to file in USX/USJ',\n },\n ms: {\n isCloseable: true,\n isClosingMarkerEmpty: true,\n },\n note: {\n isCloseable: true,\n },\n optbreak: {\n hasStyleAttribute: false,\n },\n para: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['vid'],\n },\n periph: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n },\n ref: {\n isCloseable: true,\n hasStyleAttribute: false,\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['gen'],\n skipOutputMarkerToUsfm: true,\n },\n row: {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n },\n sidebar: {\n hasNewlineBefore: true,\n },\n table: {\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['vid'],\n skipOutputMarkerToUsfm: true,\n },\n 'table:cell': {\n skipOutputAttributeToUsfm: ['align'],\n outputToUsfmInstructions:\n \"If this marker has a colspan attribute, the USFM marker name should be this marker's name plus hyphen (-) plus the marker's final column number (first column number found in the marker name plus colspan minus 1). Then the colspan attribute should not be output as a USFM attribute.\",\n parseUsfmInstructions:\n \"If this marker's name has a hyphen (-) and a number after the marker, the USX/USJ marker name should be just the portion of the marker name before the hyphen, and it should have the colspan attribute which is the number of columns spanned by the marker (second column number plus 1 minus first column number).\",\n markerTypeUsj: 'table:cell',\n markerTypeUsfm: 'cell',\n markerTypeUsx: 'cell',\n },\n 'table:row': {\n hasNewlineBefore: true,\n markerTypeUsj: 'table:row',\n markerTypeUsfm: 'row',\n markerTypeUsx: 'row',\n },\n unmatched: {\n description:\n 'Paratext uses this type for closing markers that it cannot find opening markers for. They are treated like char markers but have no contents, no closing markers, and no space after the marker.',\n outputToUsfmInstructions:\n 'Do not output a structural space after the opening marker for markers with unmatched type.',\n parseUsfmInstructions:\n 'If a closing marker occurs but does not seem to have a matching opening marker, create an unmatched-type marker. There is no structural space after the unmatched-type marker; its end is determined by the asterisk at the end of the marker.',\n },\n USJ: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n usx: {\n hasNewlineBefore: true,\n hasStyleAttribute: false,\n skipOutputAttributeToUsfm: ['xsi:noNamespaceSchemaLocation'],\n outputToUsfmInstructions:\n \"If this marker is the top-level marker containing all other markers in this document, it should not be directly output to USFM. Instead, if this marker's version attribute is other than 3.0, a new usfm marker with this version attribute needs to be added after the id marker if one is present in the USFM.\",\n },\n verse: {\n hasNewlineBefore: true,\n skipOutputAttributeToUsfm: ['sid'],\n skipOutputMarkerToUsfmIfAttributeIsPresent: ['eid'],\n },\n },\n});\n\n/**\n * A map of all USFM/USX/USJ markers and some information about them. Generated from a `usx.rng`\n * file and adjusted to reflect the way Paratext 9.4 handles USFM.\n */\nexport const USFM_MARKERS_MAP_PARATEXT: MarkersMap = Object.freeze({\n ...USFM_MARKERS_MAP,\n isSpaceAfterAttributeMarkersContent: true,\n shouldOptionalClosingMarkersBePresent: true,\n});\n","// This was disabled so class functions that are similar in purpose can be grouped together\n/* eslint-disable @typescript-eslint/member-ordering */\nimport {\n USJ_TYPE,\n type MarkerContent,\n type MarkerObject,\n type Usj,\n} from '@eten-tech-foundation/scripture-utilities';\nimport { SerializedVerseRef } from '@sillsdev/scripture';\nimport { JSONPath } from 'jsonpath-plus';\nimport { deepEqual } from '../equality-checking';\nimport { SortedNumberMap } from '../sorted-number-map';\nimport { isString } from '../util';\nimport { extractFootnotesFromUsjContent } from './footnote-util';\nimport {\n AttributeMarkerInfo,\n MarkerInfo,\n MarkersMap,\n MarkerTypeInfo,\n USFM_MARKERS_MAP as USFM_MARKERS_MAP_3_0,\n} from './markers-maps/markers-map-3.0.model';\nimport {\n BOOK_TYPE,\n CHAPTER_TYPE,\n ContentJsonPath,\n IUsjReaderWriter,\n NO_BOOK_ID,\n PropertyJsonPath,\n UsfmVerseLocation,\n UsfmVerseRefVerseLocation,\n UsjAttributeKeyLocation,\n UsjAttributeMarkerLocation,\n UsjBookLocation,\n UsjChapterLocation,\n UsjClosingAttributeMarkerLocation,\n UsjClosingMarkerLocation,\n UsjDocumentLocation,\n UsjMarkerLocation,\n UsjNodeAndDocumentLocation,\n UsjPropertyValueLocation,\n UsjReaderWriterOptions,\n UsjSearchResult,\n UsjTextContentLocation,\n UsjVerseRefBookLocation,\n UsjVerseRefChapterLocation,\n VERSE_TYPE,\n} from './usj-reader-writer.model';\n\nconst NODE_TYPES_NOT_CONTAINING_VERSE_TEXT = ['figure', 'note', 'sidebar', 'table'];\nObject.freeze(NODE_TYPES_NOT_CONTAINING_VERSE_TEXT);\n\n/** RegExp that matches all NBSP characters in a string. Used to convert NBSP in USJ to ~ in USFM */\nconst TEXT_CONTENT_NBSP_REGEXP = /\\u00A0/g;\n\n/**\n * RegExp that matches a USX/USJ table marker to get the number out of it. Used to figure out the\n * USFM cell range for table markers with `colspan` attribute in USX/USJ\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the number portion of the marker (the starting column of this cell)\n */\nconst TABLE_MARKER_NUMBER_REGEXP = /\\w+(\\d+)/;\n\n/**\n * RegExp that matches a USFM/USX/USJ verse number (optionally a span) to get the starting verse\n * number and optionally an ending verse number out of it.\n *\n * Matches:\n *\n * - 0: the whole string\n * - 1: the starting number portion of the verse number\n * - 2: the ending number portion of the verse number if one exists\n *\n * Example:\n *\n * ```usfm\n * \\v 15-16\n * ```\n *\n * We would match this RegExp against `\"15-16\"`\n *\n * Match 1 would be `\"15\"`, and match 2 would be `\"16\"`\n */\nconst VERSE_MARKER_NUMBER_SPAN_REGEXP = /(\\d+)-?(\\d+)?/;\n\n/**\n * Map of USJ content arrays and objects inside content arrays to the content array owner\n *\n * Note that `USJ` markers may have parents if they are unexpectedly present within the contents of\n * the USJ document. We can tell which `USJ` marker is the top-level marker by receiving `undefined`\n * when looking up the `USJ` marker.\n */\ntype UsjParentMap = Map;\n\n/** Fragment indicating a marker closed */\ntype UsjClosingMarkerFragment = { isClosingMarker: true; forMarker: MarkerObject | Usj };\n/** Fragment indicating the value for an attribute */\ntype UsjAttributeValueFragment = { attributeValueForKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the key for an attribute */\ntype UsjAttributeKeyFragment = { attributeKey: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the opening of an attribute marker */\ntype UsjAttributeMarkerFragment = { attributeMarker: string; forMarker: MarkerObject | Usj };\n/** Fragment indicating the closing of an attribute marker */\ntype UsjAttributeMarkerClosingMarkerFragment = {\n attributeMarkerClosingMarker: string;\n forMarker: MarkerObject | Usj;\n};\n\n/**\n * A piece of Scripture data in a USJ document. This could be any of the following:\n *\n * 1. A marker or content string in a USJ document\n *\n * - `Usj`\n * - `MarkerContent`\n * 2. A JavaScript object representation of some part of a marker that isn't actually a JavaScript\n * object\n *\n * - `UsjClosingMarker`\n * - `UsjAttributeValue`\n * - `UsjAttributeKey` except when the attribute whose key is being pointed to is an attribute marker\n * in USFM, in which case this fragment is type 3 below. This fragment represents the USFM\n * attribute marker name in USFM (e.g. `ca`), not the attribute key name (e.g. `altnumber`)\n * 3. Part of a marker as it appears in USFM but that doesn't have a direct equivalence in USJ\n *\n * - `UsjAttributeKey` when pointing to an attribute marker. See fragment type 2 above.\n * - `UsjAttributeMarker`\n * - `UsjAttributeMarkerClosingMarker`\n *\n * This is somewhat similar to `UsfmToken` in `ParatextData.dll`, but there are many differences.\n * `UsfmToken` is a class with many methods and divides Scripture data based on the USFM contents.\n * `UsjFragment`, however, is just a union of object types (and `string`) that indicates the\n * division of Scripture data primarily by USJ contents.\n *\n * This is not the same as or similar to `IFragment` in `ParatextData.dll`. `IFragment` is a bit\n * more similar to {@link UsjFragmentInfo}.\n *\n * If you think of a better name for this, feel free to replace it.\n */\ntype UsjFragment =\n | Usj\n | MarkerContent\n | UsjClosingMarkerFragment\n | UsjAttributeValueFragment\n | UsjAttributeKeyFragment\n | UsjAttributeMarkerFragment\n | UsjAttributeMarkerClosingMarkerFragment;\n\n/**\n * Information about a fragment including its position in the USFM representation. Built while\n * determining the USFM representation of the USJ document\n */\ntype UsjFragmentInfoMinimal = {\n fragment: UsjFragment;\n indexInUsfm: number;\n};\n\n/**\n * A snippet of USFM along with information about what fragments of the marker are where in that\n * USFM snippet\n */\ntype UsfmSnippetAndUsjFragmentsInfo = {\n usfm: string;\n /** USFM position info about the fragments that are represented in this USFM string */\n fragmentsInfo: UsjFragmentInfoMinimal[];\n};\n\n/**\n * Information about a fragment that includes its position in the USFM and the USJ representation.\n * Transformed from {@link UsjFragmentInfoMinimal} in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} while sorting the fragments into the\n * right places after finishing determining the USFM representation.\n *\n * This is somewhat similar to `IFragment` in `ParatextData.dll` in that both contain information\n * that connects some position in USFM to some position in USX (`IFragment`) or USJ\n * (`UsjFragmentInfo`).\n */\ntype UsjFragmentInfo = UsjFragmentInfoMinimal & {\n /**\n * The node this fragment is on and the document location of the start of this fragment (any\n * offset property will be 0)\n */\n nodeAndDocumentLocation: UsjNodeAndDocumentLocation;\n};\n\n/** Fragments at each index in the USFM string */\ntype FragmentsByIndexInUsfm = SortedNumberMap;\n\n/**\n * Array of fragments that have the JSONPath (content or property) that is the key\n *\n * The JSONPath must be \"normalized\" as generated by UsjReaderWriter.convertWorkingStackToJsonPath\n * and UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath. Otherwise, your JSONPath will not\n * match the keys in this map.\n */\ntype FragmentsByJsonPath = Map;\n\n/**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. Used for taking an index based on the start of a verse and\n * determining the index in the whole USFM document to look up in {@link FragmentsByIndexInUsfm}.\n *\n * Notes:\n *\n * - All indices before a book id are associated with the first book id present. If there is not a\n * book id present in the USJ data, everything will be in book {@link NO_BOOK_ID}.\n * - All indices before a chapter number are associated with the first chapter number present. If\n * there is not a chapter number present in the USJ data, everything will be in chapter 0.\n * - Any indices that occur before a verse number will be in verse 0.\n * - The start of a book is at the book name, chapter 1 (or 0 if no chapter numbers), verse 0. The\n * start of a chapter is at the book name, chapter number, verse 0.\n * - There are no verse ranges in this object. Only the starting verse in any range that is found in\n * the USFM is added to this map (in {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}), so\n * we should always look up verse ranges with the starting verse in the range (in\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}). Presumably, if someone is trying to find the\n * index in USFM of a verse that isn't standalone but is in the middle of a range, they are likely\n * going to run into less obvious trouble with index in USFM calculations.\n *\n * TODO: Should we do something else to support verse ranges? Depending on how we want to support\n * them, we can do different things:\n *\n * - If we just want to support getting the first verse in a range (`SerializedVerseRef.verseNum`), we\n * don't need to change anything as this is how it works currently.\n * - If we want to support getting the verse range exactly as it appears in the text and _not_ from\n * the first verse in the range, we could change the index signature `[verseNum: number]` to be\n * accessible by `string | number` and put the `SerializedVerseRef.verse` range text as the key\n * instead of `verseNum` when it is defined and looked up (in at least\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps} and\n * {@link UsjReaderWriter.getIndexInUsfmForVerseRef}; maybe other places as well).\n * - If we want to support getting any verse in a range, we could add the same index in USFM for all\n * the verses within a verse range `SerializedVerseRef.verse` (in\n * {@link UsjReaderWriter.transferFragmentsInfoArrayToMaps}).\n *\n * In any case, once we come to a clear decision on what we want to do, we should probably document\n * it in the TSDoc for {@link UsjReaderWriter}.\n */\ntype IndicesInUsfmByVerseRef = {\n [book: string]:\n | {\n [chapterNum: number]:\n | {\n [verseNum: number]: number | undefined;\n }\n | undefined;\n }\n | undefined;\n};\n\n/**\n * Represents information about where a USJ node resides in the `content` array of its parent.\n * `parent` is a reference to the node's parent, and `index` represents the numeric index inside of\n * `parent`'s content array.\n */\ntype StackItem = { parent: MarkerObject | Usj; index: number };\n\n/**\n * Stack of levels inside a USJ tree relative to a specific node. The top of the stack should always\n * be the root Usj object.\n */\ntype WorkingStack = StackItem[];\n\n/**\n * Represents USJ formatted scripture with helpful utilities for working with it. Some notable\n * features:\n *\n * - Find Scripture text in the USJ document\n *\n * - `extractText`\n * - `extractTextBetweenPoints`\n * - `findNextLocationOfMatchingText`\n * - `search`\n * - `usfmVerseLocationToNextTextLocation`\n * - Edit the USJ document: `removeContentNodes`\n * - Transform USJ to USFM: `toUsfm`\n * - Transform USJ document locations to USFM locations and vice versa\n *\n * - `usfmVerseLocationToUsjDocumentLocation`\n * - `usjDocumentLocationToUsfmVerseRefVerseLocation`\n * - Use the version of USFM you need by passing in a custom markers map to the constructor if the\n * version in your USJ document is not supported by default:\n * {@link UsjReaderWriterOptions.markersMap}\n *\n * Notes:\n *\n * - \"node\" is a term used in the methods in this class that usually means an object or content string\n * somewhere in the USj document, either {@link Usj} or {@link MarkerContent}. However, in specific\n * situations, it may refer only to {@link MarkerObject} or {@link MarkerContent}. The TypeScript\n * types indicate when this is the case.\n * - See {@link UsfmVerseLocation} and {@link UsjDocumentLocation} for information about transforming\n * USFM locations and USJ locations including what kinds of USFM locations are and are not\n * representable in USJ locations, which USJ locations actually correspond to something in USJ,\n * etc.\n * - It is best to reuse the same `UsjReaderWriter` for the same USJ document as long as possible\n * because there is a significant amount of processing and caching done internally to facilitate\n * various operations. Note that, if the USJ document added to `UsjReaderWriter` changes, you must\n * run `usjChanged` to clear the internal caches and receive accurate results from future method\n * calls\n */\nexport class UsjReaderWriter implements IUsjReaderWriter {\n private readonly usj: Usj;\n private readonly markersMap: MarkersMap;\n private readonly shouldAllowInvisibleCharacters: boolean;\n\n // Cached properties\n private parentMapInternal: UsjParentMap | undefined;\n private fragmentsByIndexInUsfmInternal: FragmentsByIndexInUsfm | undefined;\n private fragmentsByJsonPathInternal: FragmentsByJsonPath | undefined;\n private indicesInUsfmByVerseRefInternal: IndicesInUsfmByVerseRef | undefined;\n private usfmInternal: string | undefined;\n\n constructor(usj: Usj, options?: UsjReaderWriterOptions) {\n this.usj = usj;\n\n const { markersMap: providedMarkersMap, shouldAllowInvisibleCharacters } = options ?? {};\n\n // If they passed in a markers map, use it\n if (providedMarkersMap) {\n this.markersMap = providedMarkersMap;\n\n // Warn if the passed in markers map is not compatible\n if (!UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, this.markersMap.version))\n console.warn(\n `Warning: USJ provided has version ${\n this.usj.version\n }, but provided markers map has version ${\n this.markersMap.version\n }. This may cause unexpected issues when transforming between formats.`,\n );\n }\n // They didn't pass in a markers map, so try to use a built-in markers map matching the USJ version\n else if (\n UsjReaderWriter.areUsjVersionsCompatible(this.usj.version, USFM_MARKERS_MAP_3_0.version)\n )\n this.markersMap = USFM_MARKERS_MAP_3_0;\n else\n throw new Error(\n 'USJ version is not 3.0 or 3.0.x! Not equipped to handle yet without passing in a markers map',\n );\n\n if (!this.markersMap.markersMapVersion.startsWith('1.'))\n throw new Error(\n `Incompatible markers map version: ${\n this.markersMap.markersMapVersion\n }. This class only supports version 1.x.y`,\n );\n\n this.shouldAllowInvisibleCharacters = shouldAllowInvisibleCharacters ?? false;\n }\n\n // If new variables are created to speed up queries, they should be reset here\n usjChanged(): void {\n this.parentMapInternal = undefined;\n this.fragmentsByIndexInUsfmInternal = undefined;\n this.fragmentsByJsonPathInternal = undefined;\n this.indicesInUsfmByVerseRefInternal = undefined;\n this.usfmInternal = undefined;\n }\n\n private static areUsjVersionsCompatible(versionA: string, versionB: string) {\n if (versionA === '3.0' || versionA.startsWith('3.0.'))\n return versionB === '3.0' || versionB.startsWith('3.0.');\n return versionA === versionB;\n }\n\n // #region Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n findSingleValue(jsonPathQuery: string): T | undefined {\n const wrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n if (wrappedResults === undefined || wrappedResults.length === 0) return undefined;\n if (!Array.isArray(wrappedResults[0])) return wrappedResults[0];\n\n // There is no way to tell the difference between a query that returns a single result that is an\n // array and a query that returns multiple results wrapped in an array when `wrap` is false.\n // However, if `wrap` is true then a single result that is an array will be a different array\n // object than the array object within `usj`. So we need to run with `wrap` as true and false to\n // get the original array object back for a query that returns a single array.\n const unwrappedResults = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: false });\n if (unwrappedResults.length === 1 && Array.isArray(unwrappedResults[0]))\n // I have no idea why eslint is mad about casting from `any` to `T`, but it doesn't like it\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return unwrappedResults[0] as T;\n return unwrappedResults;\n }\n\n findParent(jsonPathQuery: string): T | undefined {\n // Note that \"resultType: 'parent'\" does not work for queries\n // The \"jsonpath-plus\" package allows putting a carat at the end of a query to get a parent\n return this.findSingleValue(`${jsonPathQuery}^`);\n }\n\n // #endregion Directly using the JSONPath package to perform JSONPath query -> USJ node\n\n // #region marker helper methods\n\n /**\n * Determine if the passed in marker is the top-level USJ marker.\n *\n * Note that USJ markers that are not the top-level USJ markers technically should not occur, but\n * they can occur. We should treat them like any other marker. They conform to\n * {@link MarkerObject}, so it's not hard to do.\n *\n * @param marker Marker to test if it is USJ marker\n * @returns `true` if it is a USJ marker; false otherwise\n */\n static isTopLevelUsjMarker(\n marker: Usj | MarkerContent,\n workingStack: WorkingStack,\n ): marker is Usj {\n return typeof marker === 'object' && marker.type === USJ_TYPE && workingStack.length === 0;\n }\n\n /**\n * Determine if a fragment is a marker, not a text content string or some kind of position\n * fragment that isn't actually a marker e.g. closing marker fragment\n */\n private static isFragmentAMarker(fragment: UsjFragment): fragment is MarkerObject | Usj {\n return !isString(fragment) && !('forMarker' in fragment);\n }\n\n // #endregion marker helper methods\n\n // #region Parent Maps\n\n private static createParentMapInternal(\n obj: MarkerObject,\n parent: MarkerObject | Usj,\n parentMap: UsjParentMap,\n ): void {\n parentMap.set(obj, parent);\n // USJ queries may return pointers to content arrays, not just objects\n if (obj.content) parentMap.set(obj.content, obj);\n obj.content?.forEach((child) => {\n if (typeof child === 'object') UsjReaderWriter.createParentMapInternal(child, obj, parentMap);\n });\n }\n\n /** Viewing a Usj object as a tree, build a map to walk up the tree */\n private createUsjParentMap(): UsjParentMap {\n const parentMap = new Map();\n if (this.usj.content) parentMap.set(this.usj.content, this.usj);\n this.usj.content.forEach((content) => {\n if (typeof content === 'object')\n UsjReaderWriter.createParentMapInternal(content, this.usj, parentMap);\n });\n return parentMap;\n }\n\n /** Create the parent map if it doesn't already exist and return it */\n private get parentMap(): UsjParentMap {\n if (this.parentMapInternal) return this.parentMapInternal;\n this.parentMapInternal = this.createUsjParentMap();\n return this.parentMapInternal;\n }\n\n // #endregion Parent Maps\n\n // #region Working Stacks\n\n /**\n * Checks if two stack items are equal using shallow equivalence, testing the stack item\n * properties for [strict\n * equality](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)\n *\n * Note that this requires the parent of the two stack items to have reference equality\n */\n private static areStackItemsShallowEqual(a: StackItem, b: StackItem): boolean {\n return a.index === b.index && a.parent === b.parent;\n }\n\n /** Return the working stack applicable to the given node */\n private createWorkingStack(node: MarkerObject | Usj): WorkingStack {\n // Represents levels in the USJ node tree that are above the current node (i.e., ancestors)\n // Levels in the tree are represented as a stack, so the last item in the stack is node's parent\n const workingStack: WorkingStack = [];\n\n // Grab a reference so we don't keep checking if it exists\n const { parentMap } = this;\n\n // `node` might be in the middle of the USJ tree, so build up the stack before walking the tree\n let tempNode: MarkerObject | Usj = node;\n let tempParent = parentMap.get(tempNode);\n while (tempParent !== undefined) {\n if (!tempParent.content)\n throw new Error('Invalid parentMap: all parents should have content');\n\n if (\n // Referencing tempNode and tempParent is OK in the loop since 'let' is used instead of 'var'\n // eslint-disable-next-line no-loop-func\n !tempParent.content.find((tempChild, index) => {\n if (tempChild !== tempNode) return false;\n if (!tempParent) throw new Error('undefined \"tempParent\" should not be possible');\n workingStack.unshift({ parent: tempParent, index });\n return true;\n })\n )\n throw new Error(`Unable to find correct parent node of ${JSON.stringify(tempNode)}`);\n\n tempNode = tempParent;\n tempParent = parentMap.get(tempParent);\n }\n\n return workingStack;\n }\n\n /**\n * Transform a JSONPath array (`JSONPath.toPathArray`) to a \"normalized\" JSONPath. We can use this\n * JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static jsonPathArrayToJsonPath(pathArray: string[]): string {\n return pathArray.reduce((pathAcc, pathEntry) => {\n if (pathEntry === 'content') return `${pathAcc}.${pathEntry}`;\n if (!Number.isNaN(parseInt(pathEntry, 10))) return `${pathAcc}[${pathEntry}]`;\n return `${pathAcc}['${pathEntry}']`;\n });\n }\n\n /** \"Normalize\" the JSONPath passed in so we can use it for lookups in {@link FragmentsByJsonPath} */\n private static normalizeJsonPath(jsonPath: string): string {\n // Convert to path array and back to standardize property access syntax\n const pathArray = JSONPath.toPathArray(jsonPath);\n return UsjReaderWriter.jsonPathArrayToJsonPath(pathArray);\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack. We can use this JSONPath\n * for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackToJsonPath(stack: WorkingStack): ContentJsonPath {\n let jsonPath = '$';\n stack.forEach((stackLevel) => {\n jsonPath = `${jsonPath}.content[${stackLevel.index}]`;\n });\n // The JSONPath string construction above conforms to the ContentJsonPath type\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return jsonPath as ContentJsonPath;\n }\n\n /**\n * Returns a \"normalized\" JSONPath transformed from the working stack and property. We can use\n * this JSONPath for lookups in {@link FragmentsByJsonPath}\n */\n private static convertWorkingStackAndPropertyToJsonPath(\n stack: WorkingStack,\n property: string,\n ): PropertyJsonPath {\n // Adding this property makes it conform to PropertyJsonPath. Always using bracket notation\n // because it works in more cases than dot notation does\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n return `${UsjReaderWriter.convertWorkingStackToJsonPath(stack)}['${property}']` as PropertyJsonPath;\n }\n\n private convertJsonPathToWorkingStack(\n jsonPath: ContentJsonPath | PropertyJsonPath,\n ): WorkingStack {\n const retVal: WorkingStack = [];\n\n // If the JSONPath is pointing to the top marker, there are no content levels\n if (jsonPath === '$') return retVal;\n\n const levels = jsonPath.match(/content\\[(\\d+)\\]/g);\n if (!levels) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n\n let onNode: Usj | MarkerObject = this.usj;\n\n levels.forEach((level, onLevel) => {\n const indexString = /(\\d+)/.exec(level);\n if (!indexString) throw new Error(`Malformed or unexpected jsonPath: ${jsonPath}`);\n const index = parseInt(indexString[0], 10);\n retVal.push({ parent: onNode, index });\n if (onLevel + 1 < levels.length) {\n if (typeof onNode === 'string' || !onNode.content)\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(onNode)}`);\n const nextNode = onNode.content[index];\n if (typeof nextNode === 'string')\n throw new Error(`jsonPath points to node without children: ${JSON.stringify(nextNode)}`);\n onNode = nextNode;\n }\n });\n\n return retVal;\n }\n\n // #endregion Working Stacks\n\n // #region Walk the node tree\n\n /**\n * Extract textual notes (aka, \"footnotes\") from a full USJ object.\n *\n * @returns An array of MarkerObjects representing all textual notes found in the USJ content.\n */\n findAllNotes(): MarkerObject[] {\n return extractFootnotesFromUsjContent(this.usj?.content);\n\n // Note that the following could be used instead of the above call to\n // extractFootnotesFromUsjContent, and that function could be removed. However, this is about\n // 100x slower than the custom traversal in extractFootnotesFromUsjContent.\n // return this.findAll('$.content..[?(@.type==\"note\")]');\n // This would depend on implementing findAll in this class:\n // findAll(jsonPathQuery: string): T[] {\n // const results = JSONPath({ path: jsonPathQuery, json: this.usj, wrap: true });\n // return Array.isArray(results) ? results as T[] : [];\n // }\n }\n\n /**\n * Look through the USJ document for a node or the closing of a node matching some condition. This\n * will run `searchFunction` for `node`, all nodes encountered in `node.contents` (recursively),\n * when `node` closes, and all nodes after `node`\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes and representations of the closing of nodes will be\n * passed into to determine if they are the correct node or representation of the closing of a\n * node. Stops searching and returns the node/close if this function returns `true`\n * @returns Node or representation of the closing of a node matching condition tested by the\n * search function\n */\n private static findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNodeOrClose: MarkerContent | Usj | UsjClosingMarkerFragment,\n workingStack: WorkingStack,\n ) => boolean,\n ) {\n let nextNode: MarkerContent | Usj | undefined = node;\n\n const topNode = workingStack.length === 0 ? node : workingStack[0].parent;\n // If the top node is a marker as we would expect, we need to check if `node` is under a\n // skipped-type node and skip past all that skipped stuff if so. If the top node is a `string`,\n // don't need to worry about this since we should just be searching against that one string\n if (!isString(topNode)) {\n // Determine if we are in a skipped-type node and skip to the next node after it if so\n // If the top node is skipped, return `undefined` because everything is skipped\n if (skipTypes.includes(topNode.type)) return undefined;\n\n // Find the highest (lowest index) stack item level that is skipped so we can go to its next\n // sibling\n let highestSkippedNode: MarkerContent | undefined;\n workingStack.some((stackItem) => {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const stackNode = stackItem.parent.content![stackItem.index];\n if (!isString(stackNode) && skipTypes.includes(stackNode.type)) {\n highestSkippedNode = stackNode;\n return true;\n }\n\n return false;\n });\n\n // Set nextNode to the highest skipped node so it will skip and go to the next sibling in the\n // following code\n if (highestSkippedNode) nextNode = highestSkippedNode;\n }\n\n // Walk the nodes in a depth-first, left-to-right manner until the search function returns true\n while (nextNode !== undefined) {\n const skipNextNode = typeof nextNode === 'object' && skipTypes.includes(nextNode.type);\n\n // If we found the node we're looking for, we're done\n if (!skipNextNode && searchFunction(nextNode, workingStack)) return nextNode;\n\n // Look at the node's children\n if (!skipNextNode && typeof nextNode === 'object' && (nextNode.content?.length ?? 0) > 0) {\n workingStack.push({ parent: nextNode, index: 0 });\n // Same as `nextNode = nextNode.content[0];` without triggering 2 different eslint errors\n [nextNode] = nextNode.content;\n } else {\n if (!skipNextNode) {\n // The node has no children, so check the closing marker for this node\n const nextNodeClosingMarker: UsjClosingMarkerFragment | undefined =\n typeof nextNode === 'object'\n ? { isClosingMarker: true, forMarker: nextNode }\n : undefined;\n if (nextNodeClosingMarker && searchFunction(nextNodeClosingMarker, workingStack))\n return nextNodeClosingMarker;\n }\n\n // Then look at the next sibling, or the parent's next sibling, or the parent's closing\n // marker, etc. up the stack\n nextNode = undefined;\n while (workingStack.length > 0) {\n const nextLevel = workingStack.pop();\n if (nextLevel) {\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if (nextLevel.index + 1 < nextLevel.parent.content!.length) {\n // Check the next sibling\n nextLevel.index += 1;\n workingStack.push(nextLevel);\n // We know that `content` exists due to its presence in this data structure\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n nextNode = nextLevel.parent.content![nextLevel.index];\n break;\n } else {\n // There is no next sibling, so check the closing marker for the parent before we\n // continue to look at the parent's next sibling and etc.\n const parentClosingMarker: UsjClosingMarkerFragment = {\n isClosingMarker: true,\n forMarker: nextLevel.parent,\n };\n if (searchFunction(parentClosingMarker, workingStack)) return parentClosingMarker;\n }\n }\n }\n }\n }\n\n // We've looked everywhere, so there must not be an appropriate node anywhere\n return undefined;\n }\n\n /**\n * Look through the USJ document for a node matching some condition\n *\n * @param node Node from which to start looking\n * @param workingStack Working stack pointing to this node (should not include this node)\n * @param skipTypes List of marker types to skip (skips all contents of skipped markers)\n * @param searchFunction Function that nodes will be passed into to determine if they are the\n * correct node. Stops searching and returns the node if this function returns `true`\n * @returns Node matching condition tested by the search function\n */\n private static findNextMatchingNodeUsingWorkingStack(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n skipTypes: string[],\n searchFunction: (\n potentiallyMatchingNode: MarkerContent | Usj,\n workingStack: WorkingStack,\n ) => boolean,\n ): MarkerContent | undefined {\n // We are filtering out closing markers in our search function\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const result = this.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n node,\n workingStack,\n skipTypes,\n (potentiallyMatchingNodeOrClose, currentWorkingStack) => {\n if (\n typeof potentiallyMatchingNodeOrClose === 'object' &&\n 'isClosingMarker' in potentiallyMatchingNodeOrClose\n )\n // Skip closing markers\n return false;\n\n // Just search normal markers and text as appropriate for this method\n return searchFunction(potentiallyMatchingNodeOrClose, currentWorkingStack);\n },\n ) as MarkerContent | undefined;\n\n return result;\n }\n\n // #endregion Walk the node tree\n\n // #region Node -> JSONPath\n\n nodeToJsonPath(node: MarkerObject): ContentJsonPath {\n return UsjReaderWriter.convertWorkingStackToJsonPath(this.createWorkingStack(node));\n }\n\n // #endregion Node -> JSONPath\n\n // #region USJ node -> SerializedVerseRef + offset in USFM\n\n nodeToUsfmVerseRefVerseLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { documentLocation: usjLocation } = this.nodeToUsjNodeAndDocumentLocation(\n node,\n nodeParent,\n );\n\n // Find the UsjFragmentInfo at this location\n return this.usjDocumentLocationToUsfmVerseRefVerseLocation(usjLocation, bookIdIfNotFound);\n }\n\n // #endregion USJ node -> SerializedVerseRef + offset in USFM\n\n // #region USJ node -> USJ location\n\n nodeToUsjNodeAndDocumentLocation(\n node: MarkerContent | Usj,\n nodeParent?: MarkerObject | MarkerContent[] | Usj,\n ): UsjNodeAndDocumentLocation {\n // Get working stack to the node\n let workingStack: WorkingStack;\n\n if (isString(node)) {\n // If the node is a string, we need to get the working stack from the parent and add the last\n // level for the string node\n if (nodeParent === undefined)\n throw new Error(`If \"node\" is a string, then \"nodeParent\" cannot be undefined`);\n\n // Get the real parent\n const realParent = Array.isArray(nodeParent) ? this.parentMap.get(nodeParent) : nodeParent;\n if (realParent === undefined)\n throw new Error(`Cannot find parent for ${JSON.stringify(nodeParent)}`);\n\n // Get the working stack to the parent\n workingStack = this.createWorkingStack(realParent);\n\n // Add the stack item for the string node\n const nodeIndexInParent = realParent.content?.indexOf(node);\n if (nodeIndexInParent === undefined || nodeIndexInParent < 0)\n throw new Error(`Could not find index of node in parent for creating working stack`);\n workingStack.push({ parent: realParent, index: nodeIndexInParent });\n } else {\n // The node is not a string, so it's easy to get the working stack\n workingStack = this.createWorkingStack(node);\n }\n\n // Get the UsjDocumentLocation for this node so we can find the fragment at that location\n const usjLocation = UsjReaderWriter.convertNodeToUsjDocumentLocation(node, workingStack);\n\n return {\n node,\n documentLocation: usjLocation,\n };\n }\n\n // #endregion USJ node -> USJ location\n\n // #region JSONPath > USJ location\n\n /**\n * Finds the node associated with the JSONPath provided, and also gets the parent of the node if\n * the node is a string. This is helpful so you can find a real object that is actually somewhere\n * in the USJ document from the JSONPath\n *\n * @param jsonPathQuery JSONPath search expression that indicates a node within this USJ data. If\n * the expression matches more than one node, then only the first node found is considered.\n * @returns First node found at the JSONPath and the parent of that node _if_ the node is a\n * string. Note that the object returned is the actual object in the USJ document.\n */\n private jsonPathToNodeAndParentIfString(jsonPathQuery: string): {\n node: MarkerContent | Usj;\n parent: MarkerObject | Usj | MarkerContent[] | undefined;\n } {\n // Find the node this JSONPath is pointing to\n const target: MarkerContent | Usj | undefined = this.findSingleValue(jsonPathQuery);\n if (!target) throw new Error(`No result found for JSONPath query: ${jsonPathQuery}`);\n\n // Find the parent of this node if it is a string so we can know where it is\n const parent: MarkerObject | Usj | MarkerContent[] | undefined = isString(target)\n ? this.findParent(jsonPathQuery)\n : undefined;\n if (!parent && isString(target))\n throw new Error(`Could not determine parent for ${jsonPathQuery}`);\n\n return {\n node: target,\n parent,\n };\n }\n\n jsonPathToUsjNodeAndDocumentLocation(jsonPathQuery: string): UsjNodeAndDocumentLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usjNodeAndDocumentLocation = this.nodeToUsjNodeAndDocumentLocation(node, parent);\n\n return usjNodeAndDocumentLocation;\n }\n\n // #endregion JSONPath > USJ location\n\n // #region JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n jsonPathToUsfmVerseRefVerseLocation(\n jsonPathQuery: string,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n const { node, parent } = this.jsonPathToNodeAndParentIfString(jsonPathQuery);\n\n const usfmVerseLocation = this.nodeToUsfmVerseRefVerseLocation(node, parent, bookIdIfNotFound);\n\n return usfmVerseLocation;\n }\n\n usjDocumentLocationToUsfmVerseRefVerseLocation(\n usjLocation: UsjDocumentLocation,\n bookIdIfNotFound?: string,\n ): UsfmVerseRefVerseLocation {\n // Find the fragment with the matching UsjDocumentLocation except offset\n const fragmentInfo = this.findFragmentInfoAtUsjDocumentLocation(usjLocation);\n if (fragmentInfo === undefined)\n throw new Error(\n `Could not find fragment info at USJ document location while transforming to USFM verse location: ${JSON.stringify(\n usjLocation,\n )}`,\n );\n\n const verseRef = this.getVerseRefForIndexInUsfm(fragmentInfo.indexInUsfm, bookIdIfNotFound);\n\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n return {\n verseRef,\n // Final USFM verse offset is the fragment's location relative to the verse plus whatever\n // offset is in the USJ location\n offset:\n fragmentInfo.indexInUsfm -\n verseIndexInUsfm +\n UsjReaderWriter.getOffsetInUsjDocumentLocation(usjLocation),\n };\n }\n\n // #endregion JSONPath or USJ location -> SerializedVerseRef + offset in USFM\n\n // #region Handling VerseRefs\n\n /**\n * Gets the book ID in the internal USJ document data corresponding to the book ID passed in.\n *\n * @param bookId The book ID to look up data in the USJ document for\n * @returns If there isn't a book ID in the USJ document, {@link NO_BOOK_ID} will be returned\n * @throws If the requested book is not found in the USJ data and there are other books\n * @throws If there is no USJ content in the document whatsoever\n */\n private getEffectiveBookId(bookId: string): string {\n const availableBookIds = Object.keys(this.indicesInUsfmByVerseRef);\n const noBookIdsFound =\n availableBookIds.length === 0 ||\n (availableBookIds.length === 1 && availableBookIds[0] === NO_BOOK_ID);\n const effectiveBookId = noBookIdsFound ? NO_BOOK_ID : bookId;\n const bookIndices = this.indicesInUsfmByVerseRef[effectiveBookId];\n if (!bookIndices)\n throw new Error(\n `Book ID ${bookId} not found in USJ! ${noBookIdsFound ? `There seems to be no USJ content because there is no content in ${NO_BOOK_ID} either` : `Book IDs in USJ: ${JSON.stringify(availableBookIds)}`}`,\n );\n\n return effectiveBookId;\n }\n\n /**\n * Gets the index in USFM of the start of the verse (the backslash on the verse marker or the\n * beginning of the chapter if verse 0 is provided)\n */\n private getIndexInUsfmForVerseRef(verseRef: SerializedVerseRef): number {\n // Make sure the requested book ID is in the USJ content\n const bookId = this.getEffectiveBookId(verseRef.book);\n // `getEffectiveBookId` guaranteed bookIndices is defined\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const bookIndices = this.indicesInUsfmByVerseRef[bookId]!;\n\n // Make sure the requested chapter number is in the USJ content\n const chapterIndices = bookIndices[verseRef.chapterNum];\n if (!chapterIndices) throw new Error(`Could not find ${bookId} chapter ${verseRef.chapterNum}`);\n\n // Make sure the requested verse number is in the USJ content\n // Only look for the verse number even if it is the starting number in a requested verse range\n // because you are likely going to run into less obvious trouble if you get the index in USFM of\n // the wrong verse in a range\n const verseIndexInUsfm = chapterIndices[verseRef.verseNum];\n if (verseIndexInUsfm === undefined)\n throw new Error(`Verse ${verseRef.verseNum} not found in ${bookId} ${verseRef.chapterNum}`);\n\n return verseIndexInUsfm;\n }\n\n /**\n * Gets the verse ref that the provided index in USFM is in (including verse range if applicable).\n * Finds the closest verse ref before the index in USFM.\n *\n * @param indexInUsfm The index in USFM from the beginning of this document\n * @param bookIdIfNotFound 3-letter ID of the book this USJ document is in (only used if a book ID\n * is not found in the USJ document)\n * @returns Closest verse reference before or at the index in USFM\n * @throws If not able to find a book ID in the USJ document and `bookIdIfNotFound` is not\n * provided\n */\n private getVerseRefForIndexInUsfm(\n indexInUsfm: number,\n bookIdIfNotFound?: string,\n ): SerializedVerseRef {\n // ENHANCE: This could be sped up and simplified significantly by storing a sorted number map of\n // verse refs by index in USFM like so:\n /**\n * Index in the USFM representation of the USJ document of where the start of each verse ref is\n * (the backslash on the verse marker)\n */\n // type VerseRefsByIndexInUsfm = SortedNumberMap;\n\n const bookEntries = Object.entries(this.indicesInUsfmByVerseRef);\n let bookIndex = 0;\n let lastVerseRef: SerializedVerseRef | undefined;\n let didFindVerseRef = false;\n\n // Loop through all the books looking for the right book\n while (!didFindVerseRef && bookIndex < bookEntries.length) {\n const [bookId, chapterIndices] = bookEntries[bookIndex];\n\n if (chapterIndices) {\n const chapterEntries = Object.entries(chapterIndices);\n let chapterIndex = 0;\n // Loop through all the chapters looking for the right chapter\n while (!didFindVerseRef && chapterIndex < chapterEntries.length) {\n const [chapterNumString, verseIndices] = chapterEntries[chapterIndex];\n if (verseIndices) {\n const verseEntries = Object.entries(verseIndices);\n let verseIndex = 0;\n // Loop through all the verses looking for the right verse\n while (!didFindVerseRef && verseIndex < verseEntries.length) {\n const [verseNumString, verseIndexInUsfm] = verseEntries[verseIndex];\n\n if (verseIndexInUsfm !== undefined) {\n // If the verse ref index in USFM is past the index in USFM to find for the first time,\n // this is the verse ref after this index in USFM. Return the last one\n if (indexInUsfm < verseIndexInUsfm) {\n if (!lastVerseRef)\n // Somehow the index to find is less than the very first known index. Maybe that\n // means it's negative? Either way, it doesn't make sense\n throw new Error(\n `Could not find verse ref for index in USFM ${\n indexInUsfm\n } less than the first known index ${verseIndexInUsfm}`,\n );\n\n // We know the last verse ref, which was the final verse ref before this index.\n // Return that last verse ref\n didFindVerseRef = true;\n break;\n }\n // This verse ref is not past the index in USFM to find, so record this current verse\n // ref to return later if we determine this is the right verse ref\n lastVerseRef = {\n book: bookId,\n chapterNum: parseInt(chapterNumString, 10),\n verseNum: parseInt(verseNumString, 10),\n };\n // If the verse ref index is the same as the index to find, go ahead and return the\n // current verse ref. No need to look at the next index\n if (indexInUsfm === verseIndexInUsfm) {\n didFindVerseRef = true;\n break;\n }\n }\n\n verseIndex += 1;\n }\n }\n\n chapterIndex += 1;\n }\n }\n\n bookIndex += 1;\n }\n\n if (!lastVerseRef)\n throw new Error(`Did not find any verse refs while looking for index in USFM ${indexInUsfm}`);\n\n if (lastVerseRef.book === NO_BOOK_ID) {\n // Deal with no book ID\n if (!bookIdIfNotFound)\n throw new Error(\n `Could not find book ID and no book ID provided when finding USFM verse ref for index in USFM ${\n indexInUsfm\n }`,\n );\n\n lastVerseRef.book = bookIdIfNotFound;\n }\n\n // If `didFindVerseRef` is `false`, the index in USFM to find is greater than all known indices\n // in USFM. That means it's in the very last verse ref. That's fine; no need to do anything\n // special.\n\n // Add the verse range if the verse marker for this location's verse is a range\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(lastVerseRef);\n const verseFragmentInfo = this.fragmentsByIndexInUsfm.get(verseIndexInUsfm);\n if (\n verseFragmentInfo &&\n UsjReaderWriter.isFragmentAMarker(verseFragmentInfo.fragment) &&\n verseFragmentInfo.fragment.type === VERSE_TYPE &&\n verseFragmentInfo.fragment.number &&\n verseFragmentInfo.fragment.number !== `${lastVerseRef.verseNum}`\n )\n lastVerseRef.verse = verseFragmentInfo.fragment.number;\n\n return lastVerseRef;\n }\n\n usfmVerseLocationToIndexInUsfm(usfmVerseLocation: UsfmVerseLocation): number {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n if (verseRefOffset < 0) throw new Error('offset must be >= 0');\n\n // Find the index in the whole USFM of this verse\n const verseIndexInUsfm = this.getIndexInUsfmForVerseRef(verseRef);\n\n // Add the verse offset to the verse index to get the USFM location's index in the USFM\n // representation of this USJ document\n const usfmVerseLocationIndexInUsfm = verseIndexInUsfm + verseRefOffset;\n\n return usfmVerseLocationIndexInUsfm;\n }\n\n // #endregion Handling VerseRefs\n\n // #region transforming location types to different types\n\n /**\n * Transforms a USFM verse-based location into a single standardized format of USFM verse-based\n * location for ease of accessing the location's properties\n *\n * @param usfmVerseLocation USFM verse-based location in one of multiple forms\n * @returns USFM verse-based location in one particular form. Also ensures `offset` is defined\n * (defaults to 0 as described in {@link UsfmVerseLocation})\n */\n static usfmVerseLocationToUsfmVerseRefVerseLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsfmVerseRefVerseLocation & { offset: number } {\n if ('verseRef' in usfmVerseLocation) {\n // UsfmVerseRefVerseLocation\n return {\n verseRef: usfmVerseLocation.verseRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n if ('scrRef' in usfmVerseLocation) {\n // Old deprecated form UsfmScrRefVerseLocation\n return {\n verseRef: usfmVerseLocation.scrRef,\n offset: usfmVerseLocation.offset ?? 0,\n };\n }\n\n // SerializedVerseRef\n return {\n verseRef: usfmVerseLocation,\n offset: 0,\n };\n }\n\n /**\n * Transforms a USJ chapter-based location into a single standardized format of USJ chapter-based\n * location for ease of accessing the location's properties\n *\n * @param usjChapterLocation USJ chapter-based location in one of multiple forms\n * @returns USJ chapter-based location in one particular form.\n * @throws If erroneously received a {@link UsjBookLocation}, not a {@link UsjChapterLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjChapterLocationToUsjVerseRefChapterLocation(\n usjChapterLocation: UsjChapterLocation,\n ): UsjVerseRefChapterLocation {\n // Old deprecated UsjFlatTextChapterLocation\n if ('jsonPath' in usjChapterLocation) {\n if (usjChapterLocation.offset !== undefined)\n // with UsjTextContentLocation (has offset). Unfortunately, TypeScript really doesn't like\n // having this and the following type returned via the same object even though they're very\n // similar because of the required presence/absence of `offset` in each of the returned\n // types. Just breaking them out into separate returns.\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n offset: usjChapterLocation.offset,\n },\n };\n // with UsjMarkerLocation (does not have offset)\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: {\n jsonPath: usjChapterLocation.jsonPath,\n },\n };\n }\n\n // UsjVerseRefChapterLocation\n if ('verseRef' in usjChapterLocation) {\n if (\n // Make sure we are receiving a chapter location, not a book location\n usjChapterLocation.granularity !== undefined &&\n usjChapterLocation.granularity !== 'chapter'\n )\n throw new Error(\n 'Received UsjVerseRefBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return usjChapterLocation;\n }\n\n // UsjFlatChapterLocation\n // Make sure we are receiving a chapter location, not a book location\n if (usjChapterLocation.chapterNum === undefined)\n throw new Error(\n 'Received UsjFlatBookLocation! Cannot statically transform JSONPath from book-relative to chapter-relative',\n );\n\n return {\n verseRef: {\n book: usjChapterLocation.book,\n chapterNum: usjChapterLocation.chapterNum,\n verseNum: 0,\n },\n granularity: 'chapter',\n documentLocation: usjChapterLocation.documentLocation,\n };\n }\n\n /**\n * Transforms a USJ book-based location into a single standardized format of USJ book-based\n * location for ease of accessing the location's properties\n *\n * @param usjBookLocation USJ book-based location in one of multiple forms\n * @returns USJ book-based location in one particular form.\n * @throws If erroneously received a {@link UsjChapterLocation}, not a {@link UsjBookLocation}.\n * Cannot statically transform between those because there is no way to know how to change the\n * JSONPath\n */\n static usjBookLocationToUsjVerseRefBookLocation(\n usjBookLocation: UsjBookLocation,\n ): UsjVerseRefBookLocation {\n // UsjVerseRefBookLocation\n if ('verseRef' in usjBookLocation) {\n if (\n // Make sure we are receiving a book location, not a chapter location\n usjBookLocation.granularity !== 'book'\n )\n throw new Error(\n 'Received UsjVerseRefChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return usjBookLocation;\n }\n\n // UsjFlatBookLocation\n // Make sure we are receiving a book location, not a chapter location\n if ('chapterNum' in usjBookLocation)\n throw new Error(\n 'Received UsjFlatChapterLocation! Cannot statically transform JSONPath from chapter-relative to book-relative',\n );\n\n return {\n verseRef: {\n book: usjBookLocation.book,\n chapterNum: 1,\n verseNum: 0,\n },\n granularity: 'book',\n documentLocation: usjBookLocation.documentLocation,\n };\n }\n\n // #endregion transforming location types to different types\n\n // #region USFM location -> USJ location\n\n usfmVerseLocationToUsjNodeAndDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n const { verseRef, offset: verseRefOffset } =\n UsjReaderWriter.usfmVerseLocationToUsfmVerseRefVerseLocation(usfmVerseLocation);\n\n // Get the USFM location's index in the USFM representation of this USJ document\n const usfmVerseLocationIndexInUsfm = this.usfmVerseLocationToIndexInUsfm(usfmVerseLocation);\n\n // Find the fragment info at this USFM location\n const { value: fragmentInfo } = this.fragmentsByIndexInUsfm.findClosestLessThanOrEqual(\n usfmVerseLocationIndexInUsfm,\n ) ?? {\n value: undefined,\n };\n if (!fragmentInfo)\n throw new Error(\n `Somehow, did not find anything at index in verse ${verseRefOffset} or below in ${verseRef.book} ${verseRef.chapterNum}:${verseRef.verseNum}. Not sure how this would happen.`,\n );\n\n // Get the offset within the fragment where the USFM location is pointing\n const usjOffset = usfmVerseLocationIndexInUsfm - fragmentInfo.indexInUsfm;\n\n // Add the offset to the fragment's UsjDocumentLocation and return it\n return {\n ...fragmentInfo.nodeAndDocumentLocation,\n documentLocation: UsjReaderWriter.moveUsjDocumentLocationToNewOffset(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n usjOffset,\n ),\n };\n }\n\n usfmVerseLocationToUsjDocumentLocation(\n usfmVerseLocation: UsfmVerseLocation | SerializedVerseRef,\n ): UsjDocumentLocation {\n return this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation).documentLocation;\n }\n\n // #endregion USFM location -> USJ location\n\n // #region UsjDocumentLocation utilities\n\n /**\n * Determine if the USJ document location is pointing to a text content location instead of some\n * location related to a marker object\n *\n * @param usjDocumentLocation USJ document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocation: UsjDocumentLocation,\n ): usjDocumentLocation is UsjTextContentLocation;\n /**\n * Determine if the USJ document location in this node and document location is pointing to a text\n * content location instead of some location related to a marker object\n *\n * @param usjNodeAndDocumentLocation USJ node and document location to test\n * @returns `true` if the location is for text content; `false` otherwise\n */\n static isUsjDocumentLocationForTextContent(\n usjNodeAndDocumentLocation: UsjNodeAndDocumentLocation,\n ): usjNodeAndDocumentLocation is UsjNodeAndDocumentLocation;\n static isUsjDocumentLocationForTextContent(\n usjDocumentLocationMaybeNode: UsjDocumentLocation | UsjNodeAndDocumentLocation,\n ): boolean {\n let documentLocation = usjDocumentLocationMaybeNode;\n if ('node' in usjDocumentLocationMaybeNode) {\n // If it's a UsjNodeAndDocumentLocation, the node must be a string\n if (!isString(usjDocumentLocationMaybeNode.node)) return false;\n\n documentLocation = usjDocumentLocationMaybeNode.documentLocation;\n }\n\n // Text content representation in USJDocumentLocation requires offset and nothing else has offset\n return 'offset' in documentLocation;\n }\n\n // #endregion UsjDocumentLocation utilities\n\n // #region Search for text from a certain point\n\n usfmVerseLocationToNextTextLocation(\n usfmVerseLocation: UsfmVerseLocation,\n ): UsjNodeAndDocumentLocation {\n // Get the location of the verse marker\n const verseLocation = this.usfmVerseLocationToUsjNodeAndDocumentLocation(usfmVerseLocation);\n\n // Find the first string after the verse marker\n const firstStringLocationAfterVerseMarker = this.findNextLocationOfMatchingText(\n verseLocation,\n '',\n );\n\n if (!firstStringLocationAfterVerseMarker)\n throw new Error(\n `Could not find next text location after verse ${JSON.stringify(usfmVerseLocation)} at location ${\n verseLocation.documentLocation.jsonPath\n }`,\n );\n\n return firstStringLocationAfterVerseMarker;\n }\n\n findNextLocationOfMatchingText(\n startingPoint: UsjNodeAndDocumentLocation,\n text: string,\n maxTextLengthToSearch: number = 1000,\n ): UsjNodeAndDocumentLocation | undefined {\n let textScanned = '';\n let lengthScanned = 0;\n let lengthTrimmed = 0;\n let foundStartingAtOffset = -1;\n const workingStackForStartingPoint = this.convertJsonPathToWorkingStack(\n startingPoint.documentLocation.jsonPath,\n );\n // Get the starting point stack item so we can offset our staring search point by the offset.\n // But if we started at the top USJ marker, the starting point isn't text, so we don't need to\n // worry about offsetting as there is no offset.\n // Cloning because the working stack items are modified during search\n const startingPointStackItem =\n workingStackForStartingPoint.length > 0\n ? {\n ...workingStackForStartingPoint[workingStackForStartingPoint.length - 1],\n }\n : undefined;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n workingStackForStartingPoint,\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n let nodeTextToSearch = node;\n\n const currentStackItem = workingStack[workingStack.length - 1];\n\n // If the node is the starting point, then we need to start scanning from the offset.\n // Otherwise look from the start of the string\n if (\n startingPointStackItem &&\n UsjReaderWriter.areStackItemsShallowEqual(currentStackItem, startingPointStackItem)\n ) {\n if (!('offset' in startingPoint.documentLocation))\n throw new Error(\n `Somehow 'offset' was not in text content string document location. This should not happen. ${JSON.stringify(startingPoint.documentLocation)}`,\n );\n nodeTextToSearch = node.substring(startingPoint.documentLocation.offset);\n // We're skipping the offset characters in the first node, so we need to adjust the final\n // foundStartingAtOffset to account for that\n lengthTrimmed += startingPoint.documentLocation.offset;\n }\n\n lengthScanned += nodeTextToSearch.length;\n textScanned = `${textScanned}${nodeTextToSearch}`;\n const textIndex = textScanned.indexOf(text);\n if (textIndex < 0) {\n // Keep the string we're keeping around from going too large\n lengthTrimmed += textScanned.length;\n if (textScanned.length > text.length)\n textScanned = textScanned.substring(textScanned.length - text.length);\n lengthTrimmed -= textScanned.length;\n\n // Stop looking if we haven't found it after scanning a lot of text\n return lengthScanned > maxTextLengthToSearch;\n }\n\n // We found it!\n foundStartingAtOffset = lengthTrimmed + textIndex;\n return true;\n },\n );\n\n // We never found what we wanted\n if (foundStartingAtOffset < 0) return undefined;\n\n // The text might have been split between nodes, so we have to go through it one more time\n lengthScanned = 0;\n let finalOffset = 0;\n let finalStack: WorkingStack = [];\n const finalNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, stack) => {\n if (typeof node !== 'string') return false;\n\n lengthScanned += node.length;\n if (lengthScanned < foundStartingAtOffset + 1) return false;\n\n finalOffset = foundStartingAtOffset - lengthScanned + node.length;\n finalStack = stack;\n return true;\n },\n );\n if (!finalNode) throw new Error('Internal error: inconsistent search results');\n if (!isString(finalNode))\n throw new Error(\n `Somehow found non-string node while searching for strings: ${JSON.stringify(finalNode)}`,\n );\n\n return {\n node: finalNode,\n documentLocation: {\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(finalStack),\n offset: finalOffset,\n },\n };\n }\n\n search(regex: RegExp): UsjSearchResult[] {\n const retVal: UsjSearchResult[] = [];\n if (this.usj.content.length === 0) return retVal;\n\n // Start searching from the first node in the USJ content tree\n const startingPoint: UsjNodeAndDocumentLocation = {\n node: this.usj,\n documentLocation: {\n jsonPath: `$`,\n },\n };\n\n // This will hold all of the text content from the USJ, so we can search it all at once\n const textChunks: string[] = [];\n // This will map the index of each text chunk in the full text, so we can find the location\n const fullTextIndexMap = new SortedNumberMap<\n UsjNodeAndDocumentLocation\n >();\n\n // Variables to track our current position while walking through the USJ content tree\n let currentIndex = 0;\n let nextNode: MarkerContent | Usj | undefined = startingPoint.node;\n while (nextNode !== undefined) {\n nextNode = UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n startingPoint.node,\n this.convertJsonPathToWorkingStack(startingPoint.documentLocation.jsonPath),\n [],\n // We need to use variables from outside the function to keep track of our current position\n // eslint-disable-next-line no-loop-func\n (node, workingStack) => {\n if (typeof node !== 'string') return false;\n\n textChunks.push(node);\n fullTextIndexMap.set(currentIndex, {\n node,\n documentLocation: {\n offset: 0,\n jsonPath: UsjReaderWriter.convertWorkingStackToJsonPath(workingStack),\n },\n });\n currentIndex += node.length;\n return false;\n },\n );\n }\n\n // Connect all the text chunks together so we can search them all at once. Note that there are\n // no spaces between the text chunks. If we need spaces inserted between verses, chapters, etc.\n // then we should adjust how we walk through the tree to insert extra spaces at the right times.\n const fullText = textChunks.join('');\n\n // Lean on regular expressions to do the heavy lifting of finding matches\n let match: RegExpExecArray | null = regex.exec(fullText);\n while (match) {\n // If the match is empty, then we don't want to include it in the results\n if (match[0].length > 0) {\n if (match.index < 0 || match.index >= fullText.length)\n throw new Error(`Match index out of bounds: ${match.index}`);\n\n const startingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(match.index);\n if (!startingNodeEntry)\n throw new Error(`Internal error: no starting node found for index ${match.index}`);\n const start: UsjNodeAndDocumentLocation = {\n node: startingNodeEntry.value.node,\n documentLocation: {\n jsonPath: startingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index - startingNodeEntry.key,\n },\n };\n\n // Have to find the node containing the last character in the match so we don't go past the\n // ending text node and to the next text node that may be multiple markers past the end text\n // node. Then do NOT subtract one from the index in the offset since the ending location is\n // exclusive, meaning the last character in the match is the character before the ending\n // location.\n const endingNodeEntry = fullTextIndexMap.findClosestLessThanOrEqual(\n match.index + match[0].length - 1,\n );\n if (!endingNodeEntry)\n throw new Error(`Internal error: no ending node found for index ${match.index}`);\n const end: UsjNodeAndDocumentLocation = {\n node: endingNodeEntry.value.node,\n documentLocation: {\n jsonPath: endingNodeEntry.value.documentLocation.jsonPath,\n offset: match.index + match[0].length - endingNodeEntry.key,\n },\n };\n\n retVal.push({ text: match[0], start, end });\n }\n\n // If the regex is not global, then running `exec` again will return the same match\n if (!regex.global) break;\n match = regex.exec(fullText);\n }\n\n return retVal;\n }\n\n // #endregion Search for text from a certain point\n\n // #region Extract text from a node + JSONPath + offset\n\n extractText(start: UsjNodeAndDocumentLocation, desiredLength: number): string {\n let retVal = '';\n let offsetRemaining = 'offset' in start.documentLocation ? start.documentLocation.offset : 0;\n let lengthRecorded = 0;\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node) => {\n if (typeof node !== 'string') return false;\n if (offsetRemaining >= node.length) {\n offsetRemaining -= node.length;\n return false;\n }\n let remainingNode = node;\n if (offsetRemaining > 0) {\n remainingNode = remainingNode.substring(offsetRemaining);\n offsetRemaining = 0;\n }\n if (lengthRecorded + remainingNode.length < desiredLength) {\n lengthRecorded += remainingNode.length;\n retVal = `${retVal}${remainingNode}`;\n return false;\n }\n const lengthToCopy = desiredLength - lengthRecorded;\n retVal = `${retVal}${remainingNode.substring(0, lengthToCopy - 1)}`;\n return true;\n },\n );\n return retVal;\n }\n\n extractTextBetweenPoints(\n start: UsjNodeAndDocumentLocation,\n end: UsjNodeAndDocumentLocation,\n maxLength: number = 100,\n ): string {\n let retVal = '';\n UsjReaderWriter.findNextMatchingNodeUsingWorkingStack(\n start.node,\n this.convertJsonPathToWorkingStack(start.documentLocation.jsonPath),\n NODE_TYPES_NOT_CONTAINING_VERSE_TEXT,\n (node, currentStack) => {\n // `node` and `end.node` are both `MarkerContent` which might be strings or objects\n if (node === end.node) {\n // If both objects are the same, then we definitely found `end`\n if (typeof node === 'object') return true;\n\n // If both strings are the same, we need to verify that we're at the same place in `usj`\n if (\n end.documentLocation.jsonPath ===\n UsjReaderWriter.convertWorkingStackToJsonPath(currentStack)\n )\n return true;\n }\n if (typeof node !== 'string') return false;\n retVal = `${retVal}${node}`;\n if (retVal.length > maxLength) retVal = retVal.substring(0, maxLength);\n return retVal.length >= maxLength;\n },\n );\n return retVal;\n }\n\n // #endregion Extract text from a node + JSONPath + offset\n\n // #region Edit this USJ data\n\n private static removeContentNodesFromArray(\n contentArray: MarkerContent[],\n searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean,\n ) {\n let removedCount = 0;\n for (let i = contentArray.length - 1; i >= 0; i--) {\n const node = contentArray[i];\n if (searchFunction(node)) {\n contentArray.splice(i, 1);\n removedCount += 1;\n } else if (typeof node !== 'string' && node.content)\n removedCount += this.removeContentNodesFromArray(node.content, searchFunction);\n }\n return removedCount;\n }\n\n removeContentNodes(searchFunction: (potentiallyMatchingNode: MarkerContent) => boolean): number {\n const retVal = UsjReaderWriter.removeContentNodesFromArray(this.usj.content, searchFunction);\n this.usjChanged();\n return retVal;\n }\n\n // #endregion Edit this USJ data\n\n // #region transform USJ to USFM\n\n /**\n * Get `MarkerInfo` by marker name\n *\n * @param markerName Name of the marker for which to get `MarkerInfo`\n * @returns `MarkerInfo` for the marker by name if the marker is in the markers map. `undefined`\n * if the marker is not in the markers map. If you have the marker type, you can build a fake\n * `MarkerInfo` for an unknown marker by making an object with just the type. If not, might be\n * best to throw an error since there probably isn't enough information available to do anything\n * with that marker.\n */\n private getMarkerInfo(markerName: string): MarkerInfo | undefined {\n // Try to get by exact marker name first\n let markerInfo = this.markersMap.markers[markerName];\n\n // If not found by exact name, try to match the RegExp marker names\n if (!markerInfo)\n [, markerInfo] =\n Object.entries(this.markersMap.markersRegExp).find(([markerRegExp]) =>\n new RegExp(markerRegExp).test(markerName),\n ) ?? [];\n\n // Return the marker info we found or `undefined` if we didn't find one\n return markerInfo;\n }\n\n /**\n * Gathers various pieces of information about a marker that are helpful for transforming the\n * marker to USFM\n *\n * WARNING: this only has the ability to return the info for the marker to be used in USFM. If you\n * need to use info for the marker in USX or USJ, this method needs to be modified.\n *\n * @param marker A USJ marker (can be USJ type) or a string which is the marker name\n * @param scriptureFormat The Scripture format to get the marker information for. For example, if\n * you are using this marker info to transform the marker into USFM, this should be `usfm`.\n * Defaults to `usfm`\n * @returns Various pieces of info about the marker\n */\n private getInfoForMarker(\n marker: MarkerObject | Usj | string,\n scriptureFormat: 'usfm' = 'usfm',\n ): {\n /**\n * Marker name on the original marker itself as opposed to the marker name in this Scripture\n * format\n */\n markerNameOriginal: string;\n /**\n * Name of the marker in this Scripture format. For example, In USFM format, the `usx` marker's\n * name is `usfm`\n */\n markerName: string;\n /** Marker info corresponding to `markerName`, not `markerNameOriginal` */\n markerInfo: MarkerInfo;\n /**\n * This marker's type in this Scripture format. For example, In USFM format, the `table:cell`\n * type is `cell`\n */\n markerType: string;\n /** Marker info corresponding to `markerType`, not the marker's original `type` */\n markerTypeInfo: MarkerTypeInfo;\n /**\n * Array of tuples containing the USFM name of an attribute marker that may be present on this\n * marker and the marker info for that attribute marker\n *\n * This is like the returned value from `Object.entries`. However, the order of these is\n * important in some cases, so it cannot simply be an object.\n */\n attributeMarkerInfoEntries: [\n attributeMarkerName: string,\n attributeMarkerInfo: AttributeMarkerInfo,\n ][];\n } {\n if (scriptureFormat !== 'usfm')\n throw new Error(\n 'Scripture formats beside usfm are not supported for getting info for markers',\n );\n\n const markerNameOriginal = isString(marker)\n ? marker\n : // Usj type has no `marker` property, but the Usj marker isn't really different than any other\n // marker with no `marker` property. It is appropriate to treat them the same to get the name\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n ((marker as MarkerObject).marker ?? marker.type);\n\n // If we don't have marker info for the marker or the marker type doesn't match the type in the\n // marker info, this marker is considered unknown. Do some special handling.\n let markerIsUnknown = false;\n\n let markerInfo = this.getMarkerInfo(markerNameOriginal);\n const markerTypeFromFirstMarkerInfo = markerInfo?.type ?? (isString(marker) ? '' : marker.type);\n let markerName = markerNameOriginal;\n\n // Get the actual marker name and info in this format if it is different\n if (markerInfo?.markerUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerName = markerInfo.markerUsfm;\n markerInfo = this.getMarkerInfo(markerName);\n }\n\n // Didn't find the marker, so create `MarkerInfo` with the marker type if possible\n if (!markerInfo) {\n if (isString(marker))\n throw new Error(`Unknown marker ${markerNameOriginal} and no marker type provided`);\n\n markerInfo = { type: marker.type };\n markerIsUnknown = true;\n\n console.warn(\n `Unknown marker ${markerNameOriginal}. Creating MarkerInfo to use: ${JSON.stringify(markerInfo)}`,\n );\n }\n\n // Get the marker type\n let markerType = markerInfo.type;\n let markerTypeInfo = this.markersMap.markerTypes[markerType];\n\n // Get the actual marker type and type info in this format if it is different\n if (markerTypeInfo?.markerTypeUsfm) {\n // Replace the current marker name and info with the info appropriate to this format\n markerType = markerTypeInfo.markerTypeUsfm;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n }\n\n // If the actual marker's type is not one of the expected types, something is wrong. Use the\n // actual marker's type\n if (\n !isString(marker) &&\n marker.type !== markerTypeFromFirstMarkerInfo &&\n (!markerTypeInfo ||\n (marker.type !== markerTypeInfo.markerTypeUsfm &&\n marker.type !== markerTypeInfo.markerTypeUsx &&\n marker.type !== markerTypeInfo.markerTypeUsj))\n ) {\n console.warn(\n `Warning: Mismatching marker type in the USJ content ${marker.type} vs marker type in the marker info ${markerInfo.type} for marker ${markerNameOriginal}. Using the type from the USJ content.`,\n );\n markerType = marker.type;\n markerTypeInfo = this.markersMap.markerTypes[markerType];\n markerIsUnknown = true;\n }\n\n // Couldn't find the marker type info\n // Note: In this case, Paratext just ignores the marker and prints the marker's content. This\n // really shouldn't happen, though. I had to manually change a marker type in USX and then import\n // it to Paratext to see this behavior. If you hit this, something is already going terribly wrong.\n if (!markerTypeInfo) {\n throw new Error(\n `Unknown marker type ${markerType} on marker ${markerNameOriginal}! Cannot proceed.`,\n );\n }\n\n if (markerIsUnknown && markerType === 'para')\n // Special case: If the marker type is para and it is unknown, do not add a newline before\n // the marker to match Paratext 9.4. We'll just do the same for spec for now since spec\n // seems to be silent regarding what to do about unknown markers\n markerTypeInfo = { ...markerTypeInfo, hasNewlineBefore: false };\n\n // Figure out attribute marker attribute names\n const attributeMarkerInfoEntries: [string, AttributeMarkerInfo][] = [];\n if (markerInfo.attributeMarkers) {\n markerInfo.attributeMarkers.forEach((attributeMarkerName) => {\n // Note: we are not attempting to get the appropriate marker for the relevant Scripture\n // representation aka we are not using `markerUsfm` for example. There are no attribute\n // markers that have alternate representations and are not likely to be any ever. If that\n // changes, this may cause bugs.\n const attributeMarkerInfo = this.getMarkerInfo(attributeMarkerName);\n\n // Markers map lists an attribute marker that doesn't exist. Just skip this attribute\n if (!attributeMarkerInfo) return;\n\n // Markers map lists an attribute marker that doesn't seem to be an attribute marker.\n // Just skip this attribute\n if (!('attributeMarkerAttributeName' in attributeMarkerInfo)) return;\n\n attributeMarkerInfoEntries.push([attributeMarkerName, attributeMarkerInfo]);\n });\n }\n\n // According to `cell`'s `outputToUsfmInstructions`, cell-type markers with `colspan` need to be\n // cell range marker in USFM, so let's figure that out now\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n if (scriptureFormat === 'usfm' && markerType === 'cell' && markerWithAnyAttributes.colspan) {\n // Get the number of columns that this cell spans\n const columnsSpanned = parseInt(markerWithAnyAttributes.colspan, 10);\n\n const tableMarkerMatches = TABLE_MARKER_NUMBER_REGEXP.exec(markerNameOriginal);\n\n if (tableMarkerMatches?.[1]) {\n // Get the starting cell column number\n const startingColumn = parseInt(tableMarkerMatches[1], 10);\n if (!Number.isNaN(startingColumn) && !Number.isNaN(columnsSpanned)) {\n // Create cell range marker like `tc1-3`\n markerName = `${markerNameOriginal}-${startingColumn + columnsSpanned - 1}`;\n // Set `colspan` so it is not output to USFM since it was just incorporated properly\n markerTypeInfo = {\n ...markerTypeInfo,\n skipOutputAttributeToUsfm: [\n ...(markerTypeInfo.skipOutputAttributeToUsfm ?? []),\n 'colspan',\n ],\n };\n }\n }\n }\n\n return {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n };\n }\n\n /** Converts the text content of a marker to its equivalent in USFM */\n private textContentToUsfm(textContent: string): UsfmSnippetAndUsjFragmentsInfo {\n // Special case: NBSP should be replaced with ~ in USFM if invisible characters are not allowed\n return {\n usfm: this.shouldAllowInvisibleCharacters\n ? textContent\n : textContent.replace(TEXT_CONTENT_NBSP_REGEXP, '~'),\n fragmentsInfo: [{ fragment: textContent, indexInUsfm: 0 }],\n };\n }\n\n /**\n * Merge an independent array of fragment info into an existing array of fragment info, offsetting\n * the indices of the new fragments so their locations start from the end of the string\n */\n private static mergeFragmentsInfoIntoExistingArray(\n newFragmentsInfo: UsjFragmentInfoMinimal[],\n existingFragmentsInfo: UsjFragmentInfoMinimal[],\n existingUsfmLength: number,\n ) {\n newFragmentsInfo.forEach((fragmentInfo) => {\n const fragmentIndex = existingUsfmLength + fragmentInfo.indexInUsfm;\n existingFragmentsInfo.push({\n ...fragmentInfo,\n indexInUsfm: fragmentIndex,\n });\n });\n }\n\n /**\n * Transforms the provided USJ marker into its opening marker representation in USFM\n *\n * Includes a newline before the marker if applicable. Generally also includes a space at the end.\n *\n * Opening markers generally look like the following:\n *\n * ```text\n * \\markerName leadingAttributes textContentAttribute attributeMarkers\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come before the contents of the\n * marker in USFM\n */\n private openingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { markerName, markerInfo, markerType, markerTypeInfo, attributeMarkerInfoEntries } =\n this.getInfoForMarker(marker);\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // Add newline before the marker if there's supposed to be one\n if (markerTypeInfo.hasNewlineBefore) usfm += `\\n`;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n // Add the marker name\n // Fragment representing the very beginning of the marker is the marker itself\n fragmentsInfo.push({ fragment: marker, indexInUsfm: usfm.length });\n // Special case: `optbreak` - transform to `//`\n usfm += markerType === 'optbreak' ? '//' : `\\\\${markerPrefix}`;\n\n if (markerType !== 'optbreak') {\n // Fragment representing the marker name is the `marker` property\n fragmentsInfo.push({\n fragment: { attributeValueForKey: 'marker', forMarker: marker },\n indexInUsfm: usfm.length,\n });\n\n // According to `unmatched`'s `outputToUsfmInstructions`, no space after the marker name\n // because it is basically a closing marker\n usfm += `${markerName}${markerType === 'unmatched' ? '' : ' '}`;\n }\n\n // Add leading attributes in listed order\n if (markerInfo.leadingAttributes) {\n markerInfo.leadingAttributes.forEach((attributeName) => {\n const attributeValue = markerWithAnyAttributes[attributeName];\n\n if (!attributeValue) return;\n\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeValue} `;\n });\n }\n\n // Add text content attribute\n if (\n markerInfo.textContentAttribute &&\n markerWithAnyAttributes[markerInfo.textContentAttribute]\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.textContentAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[markerInfo.textContentAttribute]} `;\n }\n\n // Add attribute markers in listed order\n if (markerInfo.attributeMarkers) {\n attributeMarkerInfoEntries.forEach(([attributeMarkerName, attributeMarkerInfo]) => {\n const attributeValue =\n markerWithAnyAttributes[attributeMarkerInfo.attributeMarkerAttributeName];\n\n if (!attributeValue) return;\n\n // Create a marker that represents this attribute marker so we can make the USFM\n const attributeMarker: MarkerObject = {\n type: attributeMarkerInfo.type,\n marker: attributeMarkerName,\n content: [attributeValue],\n };\n\n // Add the attribute marker USFM to the document\n\n // Collect opening and closing attribute marker fragments so we can modify them before adding\n // them to the main fragments\n const attributeMarkerFragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Caveat: it's not technically always true that this marker is the parent of the attribute\n // markers, but there is currently no known case where it matters because there are no\n // attribute markers that have the same marker type as the marker on which they are\n // attributes. It likely will never matter as this is a very strange concept and it seems\n // the USFM committee doesn't want to create more attribute markers.\n usfm = this.addMarkerUsfmToString(\n usfm,\n attributeMarker,\n marker,\n attributeMarkerFragmentsInfo,\n );\n const { usfm: textContentUsfm } = this.textContentToUsfm(attributeValue);\n fragmentsInfo.push({\n fragment: {\n attributeValueForKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n indexInUsfm: usfm.length,\n });\n usfm += textContentUsfm;\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: attributeMarker,\n },\n marker,\n attributeMarkerFragmentsInfo,\n );\n\n // Transform the opening fragments to attribute marker fragments and add them to the main\n // fragments\n attributeMarkerFragmentsInfo.forEach((fragmentInfo) => {\n // There should never be such a thing as text content in the opening/closing of an attribute\n // marker or an attribute key for an attribute marker\n if (isString(fragmentInfo.fragment) || 'attributeKey' in fragmentInfo.fragment)\n throw new Error(\n `Attribute marker opening or closing markers generated a text content fragment or an attribute key fragment! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n\n if (UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment)) {\n // Opening marker. Need to point to the original marker and indicate this is the opening\n // marker for its attribute marker\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n\n return;\n }\n\n if ('attributeValueForKey' in fragmentInfo.fragment) {\n // There should never be an attribute value for an attribute marker other than the marker name\n if (fragmentInfo.fragment.attributeValueForKey !== 'marker')\n throw new Error(\n `Attribute marker opening or closing markers generated an attribute value fragment for a key that was not marker! This does not make sense. ${JSON.stringify(fragmentInfo)}`,\n );\n // Marker representation of the attribute marker. Change to attribute key for attribute\n // marker attribute name.\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment: {\n attributeKey: attributeMarkerInfo.attributeMarkerAttributeName,\n forMarker: marker,\n },\n });\n return;\n }\n\n if ('isClosingMarker' in fragmentInfo.fragment) {\n // Closing marker. Need to point to the original marker and indicate this is the closing\n // marker for its attribute marker\n\n // Need to remove isClosingMarker but will not use it again. This was the easiest way to\n // delete it without TypeScript going berserk\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars\n const { isClosingMarker: _, ...partialClosingFragment } = fragmentInfo.fragment;\n\n const fragment: UsjAttributeMarkerClosingMarkerFragment = {\n ...partialClosingFragment,\n forMarker: marker,\n attributeMarkerClosingMarker: attributeMarkerInfo.attributeMarkerAttributeName,\n };\n\n fragmentsInfo.push({\n ...fragmentInfo,\n fragment,\n });\n\n return;\n }\n\n // That should have been all of them, so not sure what other fragment this could be\n throw new Error(\n `Attribute marker opening or closing markers generated an unrecognized fragment: ${JSON.stringify(fragmentInfo)}`,\n );\n });\n\n if (\n !this.markersMap.isSpaceAfterAttributeMarkersContent &&\n attributeMarkerInfo.hasStructuralSpaceAfterCloseAttributeMarker\n )\n // Add the optional structural space after the attribute marker according to spec\n usfm += ' ';\n });\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Transforms the provided USJ marker into its closing marker representation in USFM\n *\n * Closing markers do not include the attributes listed as part of the opening markers (leading\n * attributes, text content attributes, and attribute markers). They only include other kinds of\n * attributes including the default attribute if present.\n *\n * Closing markers with only the default attribute present generally look like the following:\n *\n * ```text\n * |defaultAttribute\\markerName*\n * ```\n *\n * Closing markers with at least one non-default attribute present generally look like the\n * following:\n *\n * ```text\n * |attributeName=\"AttributeValue\" attributeName=\"AttributeValue\"\\markerName*\n * ```\n *\n * @param marker The marker to transform\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @returns String containing the marker information that should come after the contents of the\n * marker in USFM\n */\n private closingMarkerToUsfm(\n marker: MarkerObject | Usj,\n isInsideMarkerWithSameType: boolean,\n ): UsfmSnippetAndUsjFragmentsInfo {\n const {\n markerNameOriginal,\n markerName,\n markerInfo,\n markerType,\n markerTypeInfo,\n attributeMarkerInfoEntries,\n } = this.getInfoForMarker(marker);\n\n // Gather attributes that are not listed as part of the opening marker and not skipped in USFM\n const closingMarkerAttributeNames = Object.keys(marker).filter((attributeName) => {\n // Special case: skip properties that are not attributes\n if (attributeName === 'type') return false;\n if (attributeName === 'marker') return false;\n if (attributeName === 'content') return false;\n if (attributeName === 'closed') return false;\n\n // Skip attributes that are supposed to be skipped when outputting to USFM\n if (markerTypeInfo.skipOutputAttributeToUsfm?.includes(attributeName)) return false;\n\n // Not a leadingAttribute\n if (markerInfo.leadingAttributes?.includes(attributeName)) return false;\n\n // Not a textContentAttribute\n if (markerInfo.textContentAttribute === attributeName) return false;\n\n // Not an attributeMarker\n if (\n attributeMarkerInfoEntries.some(\n ([, attributeMarkerInfo]) =>\n attributeMarkerInfo.attributeMarkerAttributeName === attributeName,\n )\n )\n return false;\n\n // There are no other attributes that go on the opening marker, so this must go on the closing\n // marker\n return true;\n });\n\n // Markers can have any properties. All are strings. Only exception is content, so don't use\n // it here\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n const markerWithAnyAttributes = marker as unknown as Record;\n\n // We don't have examples of markers that have both normal closing markers and independent\n // closing markers, so just throw an error if we encounter this situation\n if (\n markerTypeInfo.isCloseable &&\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0\n )\n throw new Error(\n `Marker ${\n markerName\n } is intended to have a normal closing marker and independent closing markers. As of writing this code, there is no known syntax for this situation in USFM. Cannot proceed.`,\n );\n\n // Determine if the marker is supposed to have an explicit closing marker\n let hasExplicitClosingMarker = true;\n // If the closing marker is specified as not present, it should not be present no matter what\n if (markerWithAnyAttributes.closed === 'false') hasExplicitClosingMarker = false;\n else if (\n markerInfo.isClosingMarkerOptional &&\n !this.markersMap.shouldOptionalClosingMarkersBePresent &&\n markerWithAnyAttributes.closed !== 'true'\n ) {\n // If the closing marker is optional, if optional closing markers should be left out, and\n // if it is not specified as closed, then it should not have a closing marker\n hasExplicitClosingMarker = false;\n }\n\n // If this marker has an independent closing marker, create that\n if (\n markerInfo.independentClosingMarkers &&\n markerInfo.independentClosingMarkers.length > 0 &&\n hasExplicitClosingMarker\n ) {\n // Create a marker that represents this independent closing marker so we can make the USFM\n const independentClosingMarker: MarkerObject = {\n type: markerType,\n marker: markerInfo.independentClosingMarkers[0],\n // Put all the closing marker attributes on here since we don't really have a better place\n // to put them and might as well\n ...Object.fromEntries(\n closingMarkerAttributeNames.map((attributeName) => [\n attributeName,\n markerWithAnyAttributes[attributeName],\n ]),\n ),\n };\n\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n const { usfm: openingMarkerUsfm, fragmentsInfo: openingFragmentsInfo } =\n this.openingMarkerToUsfm(independentClosingMarker, isInsideMarkerWithSameType);\n // Fragment for independent closing marker is just the normal closing fragment. So find the\n // opening fragment, change it to closing fragment, and add it to the fragments for this\n // marker. Need to get the opening marker so we have the right indexInUsfm (might be 1 if\n // the marker has a newline before it, for example)\n const openingFragmentInfo = openingFragmentsInfo.find((fragmentInfo) => {\n return UsjReaderWriter.isFragmentAMarker(fragmentInfo.fragment);\n });\n if (!openingFragmentInfo)\n throw new Error(\n `Could not find opening fragment info for independent closing marker ${JSON.stringify(\n independentClosingMarker,\n )}. Fragments info generated: ${JSON.stringify(openingFragmentsInfo)}`,\n );\n fragmentsInfo.push({\n ...openingFragmentInfo,\n fragment: { isClosingMarker: true, forMarker: marker },\n });\n usfm += openingMarkerUsfm;\n // Only add the independent closing marker if it does not have the same name as the marker we\n // are closing so we don't get in an infinite loop\n if (markerNameOriginal !== independentClosingMarker.marker)\n // ENHANCE: If we ever have a situation where closing marker attributes get on a marker\n // with an independent closing marker, let's add fragments for the attributes here. Though\n // I think this may be something the USFM committee intends to avoid doing based on the\n // proposal to add attributes at the opening marker\n usfm = this.addMarkerUsfmToString(\n usfm,\n {\n isClosingMarker: true,\n forMarker: independentClosingMarker,\n },\n isInsideMarkerWithSameType,\n );\n\n return { usfm, fragmentsInfo };\n }\n\n // This marker doesn't have an independent closing marker, so create a normal closing marker\n let usfm = '';\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Add attributes to the closing marker USFM\n if (closingMarkerAttributeNames.length > 0) {\n // Add the bar before closing attributes\n usfm += '|';\n\n // Default attribute syntax if it is the only attribute present\n if (\n closingMarkerAttributeNames.length === 1 &&\n closingMarkerAttributeNames[0] === markerInfo.defaultAttribute\n ) {\n fragmentsInfo.push({\n fragment: { attributeValueForKey: markerInfo.defaultAttribute, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += markerWithAnyAttributes[markerInfo.defaultAttribute];\n } else {\n // List all attributes with key and value\n closingMarkerAttributeNames.forEach((attributeName, index) => {\n // According to `figure`'s `outputToUsfmInstructions`, figure's file attribute is src in USFM\n const attributeNameUsfm =\n markerType === 'figure' && attributeName === 'file' ? 'src' : attributeName;\n // Add to the accumulated usfm (starting with a bar): a space if this is after the first\n // attribute, then the attribute name, then =, then \"the attribute value\"\n if (index > 0) usfm += ' ';\n fragmentsInfo.push({\n fragment: { attributeKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${attributeNameUsfm}=\"`;\n fragmentsInfo.push({\n fragment: { attributeValueForKey: attributeName, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `${markerWithAnyAttributes[attributeName]}\"`;\n });\n }\n }\n\n // Add the normal closing marker\n if (markerTypeInfo.isCloseable && hasExplicitClosingMarker) {\n const closingMarkerName = markerTypeInfo.isClosingMarkerEmpty ? '' : markerName;\n\n // Add the nested prefix if the marker is in a marker of the same type\n const markerPrefix = isInsideMarkerWithSameType ? (markerTypeInfo.nestedPrefix ?? '') : '';\n\n fragmentsInfo.push({\n fragment: { isClosingMarker: true, forMarker: marker },\n indexInUsfm: usfm.length,\n });\n usfm += `\\\\${markerPrefix}${closingMarkerName}*`;\n }\n\n return { usfm, fragmentsInfo };\n }\n\n /**\n * Determines whether this marker and all its content should be skipped entirely when outputting\n * to USFM\n *\n * @param marker Marker to check\n * @returns `true` if this marker should be skipped; `false` otherwise\n */\n private shouldSkipOutputMarkerToUsfm(marker: MarkerObject | Usj) {\n const { markerTypeInfo } = this.getInfoForMarker(marker);\n\n if (markerTypeInfo.skipOutputMarkerToUsfm) return true;\n\n if (\n markerTypeInfo.skipOutputMarkerToUsfmIfAttributeIsPresent?.some(\n (attributeName) => attributeName in marker,\n )\n )\n return true;\n\n return false;\n }\n\n /** Removes one space at the end of the string if present */\n private static removeEndSpace(value: string) {\n // TODO: should this use the surrogate-aware functions?\n if (value.at(-1) !== ' ') return value;\n return value.slice(0, -1);\n }\n\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param markerParent Parent of the marker being added. Used to determine if this marker is\n * nested within another marker of the same type\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | Usj | UsjClosingMarkerFragment,\n markerParent: MarkerObject | Usj | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n /**\n * Add an opening or closing marker USFM representation to the end of a string of USFM\n *\n * @param usfm The USFM string to add the marker to\n * @param marker The opening or closing marker to add to the USFM\n * @param isInsideMarkerWithSameType `true` if this marker is inside another marker of the same\n * type. This is used to determine if a prefix should be added before the marker name.\n * @param fragmentsInfo The array of fragment information built so far for the USFM string passed\n * in. THIS METHOD WILL MODIFY THE ARRAY PASSED IN; it will add new fragments that correspond to\n * the marker added.\n * @returns Final USFM string with the marker added\n */\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n isInsideMarkerWithSameType: boolean,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string;\n private addMarkerUsfmToString(\n usfm: string,\n marker: MarkerObject | UsjClosingMarkerFragment,\n markerParentOrIsInsideMarkerWithSameType: MarkerObject | Usj | boolean | undefined,\n fragmentsInfo?: UsjFragmentInfoMinimal[],\n ): string {\n let usfmOutput = usfm;\n\n // Build up the marker's usfm and fragment info separately first because we may modify it before\n // adding it to the full usfm\n let markerUsfmOutput;\n let markerFragmentsInfo: UsjFragmentInfoMinimal[];\n\n const { markerNameOriginal, markerType, markerTypeInfo } = this.getInfoForMarker(\n 'isClosingMarker' in marker ? marker.forMarker : marker,\n );\n\n // Determine if this marker is a direct child of another marker of the same type\n let isParentSameType = false;\n if (typeof markerParentOrIsInsideMarkerWithSameType === 'boolean')\n isParentSameType = markerParentOrIsInsideMarkerWithSameType;\n else if (markerParentOrIsInsideMarkerWithSameType) {\n const { markerType: parentMarkerType } = this.getInfoForMarker(\n markerParentOrIsInsideMarkerWithSameType,\n );\n if (parentMarkerType === markerType) {\n isParentSameType = true;\n }\n }\n\n if ('isClosingMarker' in marker) {\n const { usfm: closingUsfm, fragmentsInfo: closingFragmentsInfo } = this.closingMarkerToUsfm(\n marker.forMarker,\n isParentSameType,\n );\n markerFragmentsInfo = closingFragmentsInfo;\n markerUsfmOutput = closingUsfm;\n\n // If the closing marker is supposed to be empty, there was nothing in the marker content, and\n // there are no closing marker attributes present, we need to remove the structural space after\n // the opening marker\n if (\n markerTypeInfo.isCloseable &&\n markerTypeInfo.isClosingMarkerEmpty &&\n // No contents\n (!marker.forMarker.content || marker.forMarker.content.length === 0) &&\n // No closing marker attributes\n !markerUsfmOutput.startsWith('|')\n ) {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n } else {\n const { usfm: openingUsfm, fragmentsInfo: openingFragmentsInfo } = this.openingMarkerToUsfm(\n marker,\n isParentSameType,\n );\n markerFragmentsInfo = openingFragmentsInfo;\n markerUsfmOutput = openingUsfm;\n }\n\n if (markerUsfmOutput.startsWith('\\n')) {\n if (usfmOutput.length === 0) {\n // If the USFM is empty, don't add a newline at the start\n markerFragmentsInfo = markerFragmentsInfo.map((fragmentInfo) => ({\n ...fragmentInfo,\n indexInUsfm: fragmentInfo.indexInUsfm - 1,\n }));\n markerUsfmOutput = markerUsfmOutput.substring(1);\n } else {\n // If there's supposed to be a newline before the marker, it should eat the last space if\n // there is one (that last space gets turned into the newline in this format)\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n }\n }\n\n // Special case: `ca` after chapter marker needs a newline and space before in Paratext USFM for\n // some reason\n // Note that there is not a newline and space before `ca` after importing from USX in Paratext,\n // so maybe we should just remove the newline and space in the PDP\n if (this.markersMap.isSpaceAfterAttributeMarkersContent && markerNameOriginal === 'ca') {\n // Find the last marker in the current USFM output\n const lastMarkerBackslashIndex = usfmOutput.lastIndexOf('\\\\');\n if (lastMarkerBackslashIndex >= 0) {\n // We just want to know if it's a chapter marker, so we can just get two characters, c and space\n const lastMarker = usfm.substring(\n lastMarkerBackslashIndex + 1,\n lastMarkerBackslashIndex + 3,\n );\n if (lastMarker === 'c ') {\n usfmOutput = UsjReaderWriter.removeEndSpace(usfmOutput);\n usfmOutput += '\\n ';\n }\n }\n }\n\n // Add the marker fragments and USFM into the existing fragments and USFM\n if (fragmentsInfo)\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n markerFragmentsInfo,\n fragmentsInfo,\n usfmOutput.length,\n );\n usfmOutput += markerUsfmOutput;\n\n return usfmOutput;\n }\n\n toUsfm() {\n // See calculateUsfmProperties method for implementation\n return this.usfm;\n }\n\n // #endregion transform USJ to USFM\n\n // #region fragment utilities\n\n /**\n * Returns a new {@link UsjDocumentLocation} based on the one passed in but with the offset\n * provided. If the location passed in does not have an offset property, a shallow clone of the\n * location will be returned with no changes.\n */\n private static moveUsjDocumentLocationToNewOffset(\n usjLocation: UsjDocumentLocation,\n usjOffset: number,\n ): UsjDocumentLocation {\n const newLocation = { ...usjLocation };\n\n // UsjTextContentLocation\n if ('offset' in newLocation) newLocation.offset = usjOffset;\n // UsjClosingMarkerLocation\n else if ('closingMarkerOffset' in newLocation) newLocation.closingMarkerOffset = usjOffset;\n // UsjPropertyValueLocation\n else if ('propertyOffset' in newLocation) newLocation.propertyOffset = usjOffset;\n // UsjAttributeKeyLocation\n else if ('keyOffset' in newLocation) newLocation.keyOffset = usjOffset;\n // UsjClosingAttributeMarkerLocation\n else if ('keyClosingMarkerOffset' in newLocation)\n newLocation.keyClosingMarkerOffset = usjOffset;\n // No offset; no change:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return newLocation;\n }\n\n /**\n * Returns the offset of whatever kind that is found in the UsjDocumentLocation. Returns 0 if the\n * location passed in does not have an offset property.\n */\n private static getOffsetInUsjDocumentLocation(usjLocation: UsjDocumentLocation): number {\n // UsjTextContentLocation\n if ('offset' in usjLocation) return usjLocation.offset;\n // UsjClosingMarkerLocation\n if ('closingMarkerOffset' in usjLocation) return usjLocation.closingMarkerOffset;\n // UsjPropertyValueLocation\n if ('propertyOffset' in usjLocation) return usjLocation.propertyOffset;\n // UsjAttributeKeyLocation\n if ('keyOffset' in usjLocation) return usjLocation.keyOffset;\n // UsjClosingAttributeMarkerLocation\n if ('keyClosingMarkerOffset' in usjLocation) return usjLocation.keyClosingMarkerOffset;\n // No offset:\n // UsjMarkerLocation\n // UsjAttributeMarkerLocation\n return 0;\n }\n\n /**\n * Compares two UsjDocumentLocations to determine if they are pointing to the same location\n *\n * @param a The first location to compare\n * @param b The second location to compare\n * @param ignoreJsonPath If `true`, the JSONPath properties of the locations will be ignored in\n * the comparison. This is useful if you have already determined that the JSONPaths are the\n * same\n */\n private static areUsjDocumentLocationsEqual(\n a: UsjDocumentLocation,\n b: UsjDocumentLocation,\n ignoreJsonPath = false,\n ) {\n const { jsonPath: aJsonPath, ...restOfA } = a;\n const { jsonPath: bJsonPath, ...restOfB } = b;\n\n // Determine if the two JSONPaths are equivalent even if they use different property syntax\n if (\n !ignoreJsonPath &&\n !deepEqual(JSONPath.toPathArray(aJsonPath), JSONPath.toPathArray(bJsonPath))\n )\n return false;\n\n // Determine if the rest of the location information is the same\n return deepEqual(restOfA, restOfB);\n }\n\n /** Find the fragment info corresponding to the specified USJ Document location. */\n private findFragmentInfoAtUsjDocumentLocation(\n usjLocation: UsjDocumentLocation,\n ): UsjFragmentInfo | undefined {\n // Set offset to 0 because all the fragments' locations are at offset 0\n const zeroedUsjLocation = UsjReaderWriter.moveUsjDocumentLocationToNewOffset(usjLocation, 0);\n\n let fragmentInfoAtLocation: UsjFragmentInfo | undefined;\n const allFragmentsInfoAtJsonPath = this.fragmentsByJsonPath.get(\n UsjReaderWriter.normalizeJsonPath(usjLocation.jsonPath),\n );\n\n // Couldn't find any fragment info at this JSONPath\n if (!allFragmentsInfoAtJsonPath) return undefined;\n\n // Look in the fragments at this JSONPath to find one that matches the full location\n allFragmentsInfoAtJsonPath.find((fragmentInfo) => {\n if (\n !UsjReaderWriter.areUsjDocumentLocationsEqual(\n fragmentInfo.nodeAndDocumentLocation.documentLocation,\n zeroedUsjLocation,\n // We already compared the JSONPaths by looking in the map for this JSONPath\n true,\n )\n )\n return false;\n\n fragmentInfoAtLocation = fragmentInfo;\n return true;\n });\n\n return fragmentInfoAtLocation;\n }\n\n /**\n * Transform a node and its working stack into the {@link UsjDocumentLocation} corresponding to it.\n *\n * @param node Marker or string to convert\n * @param workingStack Working stack pointing to the node\n * @param locationOffset If applicable, this is the offset that will be put on the\n * {@link UsjDocumentLocation}. If not present, offset on the {@link UsjDocumentLocation} will be\n * `0`. Not all subtypes of {@link UsjDocumentLocation}s have offsets, so this is not used in all\n * situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertNodeToUsjDocumentLocation(\n node: MarkerContent | Usj,\n workingStack: WorkingStack,\n locationOffset = 0,\n ): UsjTextContentLocation | UsjMarkerLocation {\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n if (isString(node)) {\n // If the node is a text content string, location is the jsonPath and the offset in that\n // string\n const documentLocation: UsjTextContentLocation = { jsonPath, offset: locationOffset };\n return documentLocation;\n }\n\n // The node is a marker itself, so location is just the marker jsonPath. We don't currently\n // provide a way to represent an offset within the opening marker.\n const documentLocation: UsjMarkerLocation = { jsonPath };\n return documentLocation;\n }\n\n /**\n * Transform a fragment and its working stack into the {@link UsjNodeAndDocumentLocation}\n * corresponding to it.\n *\n * @param fragment Fragment to convert\n * @param workingStack Working stack pointing to the marker or string the fragment is in\n * @param offsetWithinFragment If applicable, this is the offset within the fragment that the\n * location is pointing to, which is offset that will be put on the {@link UsjDocumentLocation}.\n * If not present, offset on the {@link UsjDocumentLocation} will be `0` because fragments don't\n * have their own offsets into the contents. Not all {@link UsjDocumentLocation}s have offsets,\n * so this is not used in all situations\n * @returns The node and the document location corresponding to this fragment\n */\n private static convertFragmentToUsjNodeAndDocumentLocation(\n fragment: UsjFragment,\n workingStack: WorkingStack,\n offsetWithinFragment = 0,\n ): UsjNodeAndDocumentLocation {\n // Return the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n\n // Check if the fragment itself is the target, meaning the fragment is the node in the USJ\n // document (`string`, `MarkerObject`, and `Usj`)\n if (isString(fragment) || UsjReaderWriter.isFragmentAMarker(fragment)) {\n // The fragment/node itself is the target. Get document location for this node\n const documentLocation: UsjTextContentLocation | UsjMarkerLocation =\n UsjReaderWriter.convertNodeToUsjDocumentLocation(\n fragment,\n workingStack,\n offsetWithinFragment,\n );\n return {\n node: fragment,\n documentLocation,\n };\n }\n\n // Check if the target is a closing marker\n if ('isClosingMarker' in fragment) {\n // Get JsonPath to the marker this is a closing marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and an offset within the closing marker\n const documentLocation: UsjClosingMarkerLocation = {\n jsonPath,\n closingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is a property value (`marker` or an attribute)\n if ('attributeValueForKey' in fragment) {\n // Get JsonPath to the indicated property on the marker this is a property for\n const jsonPath = UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath(\n workingStack,\n fragment.attributeValueForKey,\n );\n\n // Location is the jsonPath to the property on the marker and the offset within the property\n // value\n const documentLocation: UsjPropertyValueLocation = {\n jsonPath,\n propertyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute key\n if ('attributeKey' in fragment) {\n // Get JsonPath to the marker this is an attribute key for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker, the key, and the offset within that key\n const documentLocation: UsjAttributeKeyLocation = {\n jsonPath,\n keyName: fragment.attributeKey,\n keyOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker\n if ('attributeMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker. We don't\n // currently provide a way to represent an offset within the opening marker.\n const documentLocation: UsjAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarker,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n // Check if the target is an attribute marker closing marker\n if ('attributeMarkerClosingMarker' in fragment) {\n // Get JsonPath to the marker this is an attribute marker for\n const jsonPath = UsjReaderWriter.convertWorkingStackToJsonPath(workingStack);\n\n // Location is the jsonPath to the marker and the key for the attribute marker\n const documentLocation: UsjClosingAttributeMarkerLocation = {\n jsonPath,\n keyName: fragment.attributeMarkerClosingMarker,\n keyClosingMarkerOffset: offsetWithinFragment,\n };\n return {\n node: fragment.forMarker,\n documentLocation,\n };\n }\n\n throw new Error(\n `Could not transform unrecognized fragment to UsjNodeAndDocumentLocation: ${JSON.stringify(\n fragment,\n )} at working stack ${JSON.stringify(JSON.stringify(fragment))}`,\n );\n }\n\n /**\n * Fill out fragments info from a minimal fragments info array and move them into the final\n * fragments map\n *\n * @param fragmentsInfo Minimal fragments info array to fill out and put into maps. ALL CONTENTS\n * OF THIS ARRAY ARE REMOVED IN THIS METHOD\n * @param workingStack Current working stack\n * @param position Object containing properties describing where in the USFM document these\n * fragments are. If this method encounters a verse range, only the starting verse number is\n * used (hence this is not a {@link SerializedVerseRef}). PROPERTIES ON THIS OBJECT ARE MODIFIED\n * IN THIS METHOD\n * @param fragmentsByIndexInUsfm Map to add fragment information to by index in USFM\n * @param fragmentsByJsonPath Map to add fragment information to by JSONPath\n * @param indicesInUsfmByVerseRef Map to add verse start locations to. If this method encounters a\n * verse range, only the starting verse number is used. See {@link IndicesInUsfmByVerseRef} for\n * potential adjustments to handle verse ranges differently when we know better what we ought to\n * do.\n */\n private static transferFragmentsInfoArrayToMaps(\n fragmentsInfo: UsjFragmentInfoMinimal[],\n workingStack: WorkingStack,\n position: {\n bookId: string;\n chapterNum: number;\n verseNum: number;\n },\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm,\n fragmentsByJsonPath: FragmentsByJsonPath,\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef,\n ): void {\n // Add the extra information to each fragment to make it complete\n const fullFragmentsInfo = fragmentsInfo.map((fragmentInfo) => {\n // Adjust current verse ref if we find start of book, chapter, or verse marker\n if (typeof fragmentInfo.fragment === 'object' && 'type' in fragmentInfo.fragment) {\n const marker = fragmentInfo.fragment;\n\n if (marker.type === BOOK_TYPE && marker.code) {\n // Found book marker. Update current verse ref to new book\n position.bookId = marker.code;\n position.chapterNum = 0;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered book id, move them to the first\n // encountered book id\n if (indicesInUsfmByVerseRef[NO_BOOK_ID]) {\n indicesInUsfmByVerseRef[position.bookId] = indicesInUsfmByVerseRef[NO_BOOK_ID];\n delete indicesInUsfmByVerseRef[NO_BOOK_ID];\n }\n } else if (marker.type === CHAPTER_TYPE && marker.number) {\n // Found chapter marker. Try to update chapter\n const nextChapterNum = parseInt(marker.number, 10);\n\n if (Number.isNaN(nextChapterNum)) {\n console.warn(\n `Found ${CHAPTER_TYPE} type marker with number ${\n marker.number\n }, but could not parse chapter number from it. Continuing using previous chapter number ${\n position.chapterNum\n }`,\n );\n } else {\n // Update current verse ref to new chapter\n position.chapterNum = nextChapterNum;\n position.verseNum = 0;\n\n // If there are any fragments before the first encountered chapter number, move them to\n // the first encountered chapter number\n const currentBookFragments = indicesInUsfmByVerseRef[position.bookId];\n if (currentBookFragments?.[0]) {\n // Not array destructuring because it's really hard to read here\n // eslint-disable-next-line prefer-destructuring\n currentBookFragments[position.chapterNum] = currentBookFragments[0];\n delete currentBookFragments[0];\n }\n }\n } else if (marker.type === VERSE_TYPE && marker.number) {\n // Found verse marker. Try to update verse\n const nextVerseNumString = VERSE_MARKER_NUMBER_SPAN_REGEXP.exec(marker.number)?.[1];\n\n if (!nextVerseNumString) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not find starting verse number in it. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else {\n const nextVerseNum = parseInt(nextVerseNumString, 10);\n\n if (Number.isNaN(nextVerseNum)) {\n console.warn(\n `Found ${VERSE_TYPE} type marker with number ${\n marker.number\n }, but could not parse starting verse number from ${nextVerseNumString}. Continuing using previous verse number ${\n position.verseNum\n }`,\n );\n } else if (\n indicesInUsfmByVerseRef[position.bookId]?.[position.chapterNum]?.[nextVerseNum]\n ) {\n console.warn(`Found ${VERSE_TYPE} marker with existing number ${nextVerseNum} after\n current ${VERSE_TYPE} number ${\n position.verseNum\n }! Not updating verse start index. All positions in this duplicate verse will be based on the current ${\n VERSE_TYPE\n } marker, not the new duplicate marker.`);\n } else {\n if (nextVerseNum < position.verseNum)\n console.debug(\n `Found ${VERSE_TYPE} marker with number ${nextVerseNum} lower than current ${\n VERSE_TYPE\n } number ${position.verseNum}. Verses are out of order. There may be some issues.`,\n );\n\n // Update current verse ref to new verse\n position.verseNum = nextVerseNum;\n }\n }\n }\n }\n\n // Fill out the rest of the fragment info\n const fullFragmentInfo: UsjFragmentInfo = {\n ...fragmentInfo,\n // Determine the appropriate `UsjDocumentLocation` subtype based on what this fragment is\n nodeAndDocumentLocation: UsjReaderWriter.convertFragmentToUsjNodeAndDocumentLocation(\n fragmentInfo.fragment,\n workingStack,\n ),\n };\n\n return fullFragmentInfo;\n });\n\n // Add staged fragments to final fragments maps\n fullFragmentsInfo.forEach((fragmentInfo) => {\n // Put the fragment info in the map by index in USFM\n fragmentsByIndexInUsfm.set(fragmentInfo.indexInUsfm, fragmentInfo);\n\n // Put the fragment info in the map by JSONPath. Note this JSONPath is generated using\n // UsjReaderWriter.convertWorkingStackToJsonPath and\n // UsjReaderWriter.convertWorkingStackAndPropertyToJsonPath, so it is \"normalized\".\n // Must use \"normalized\" JSONPath when looking up fragments by JSONPath.\n const fragmentJsonPath = fragmentInfo.nodeAndDocumentLocation.documentLocation.jsonPath;\n const fragmentsAtJsonPath = fragmentsByJsonPath.get(fragmentJsonPath);\n if (fragmentsAtJsonPath) fragmentsAtJsonPath.push(fragmentInfo);\n else fragmentsByJsonPath.set(fragmentJsonPath, [fragmentInfo]);\n\n // Put the fragment's index in USFM in the map by verse reference\n // We are ensuring the properties are defined all the way through before use, so allow the\n // bang operator. This would be way more verbose without bang operator.\n /* eslint-disable no-type-assertion/no-type-assertion */\n if (!indicesInUsfmByVerseRef[position.bookId]) indicesInUsfmByVerseRef[position.bookId] = {};\n if (!indicesInUsfmByVerseRef[position.bookId]![position.chapterNum])\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum] = {};\n if (\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] ===\n undefined\n )\n indicesInUsfmByVerseRef[position.bookId]![position.chapterNum]![position.verseNum] =\n fragmentInfo.indexInUsfm;\n /* eslint-enable no-type-assertion/no-type-assertion */\n });\n\n // Remove all elements from fragmentsInfo\n fragmentsInfo.splice(0);\n }\n\n // #endregion fragment utilities\n\n // #region USFM-related cached properties\n\n /**\n * Generates USFM representation of the USJ document passed in and returns it along with\n * information about how various locations in USFM and USJ map to each other\n */\n private calculateUsfmProperties(): {\n usfm: string;\n fragmentsByIndexInUsfm: FragmentsByIndexInUsfm;\n fragmentsByJsonPath: FragmentsByJsonPath;\n indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef;\n } {\n // Build the USFM up from the USJ content\n let usfm = '';\n // Build the fragments maps as we go\n const fragmentsByIndexInUsfm = new SortedNumberMap();\n const fragmentsByJsonPath = new Map();\n const indicesInUsfmByVerseRef: IndicesInUsfmByVerseRef = {};\n\n // Temporary staging array to put fragments in before loading them into the map\n const fragmentsInfo: UsjFragmentInfoMinimal[] = [];\n\n // Keep track of current verse reference numbers as we go through the content so we can put\n // fragments in the right place\n const currentPosition = {\n bookId: NO_BOOK_ID,\n chapterNum: 0,\n verseNum: 0,\n };\n /** Move the fragments info that are in `fragmentsInfo` into the final fragments map */\n function transferFragmentsInfo(workingStack: WorkingStack) {\n UsjReaderWriter.transferFragmentsInfoArrayToMaps(\n fragmentsInfo,\n workingStack,\n currentPosition,\n fragmentsByIndexInUsfm,\n fragmentsByJsonPath,\n indicesInUsfmByVerseRef,\n );\n }\n\n // According to `USJ`'s `outputToUsfmInstructions`, need to move the top-level `USJ` marker after\n // `id` closes in USFM even though it is before it in USJ\n let topLevelUsjMarker: Usj | undefined;\n // The marker objects we're currently skipping ordered as a stack (last entry is the deepest\n // marker we are skipping and therefore will be the next to close). If this has entries, it\n // means we are walking through contents of marker objects whose opening marker we already skipped\n // and whose closing marker we should also skip outputting to USFM\n const markersToSkipOutput: (MarkerObject | Usj)[] = [];\n\n UsjReaderWriter.findNextMatchingNodeOrClosingFragmentUsingWorkingStack(\n this.usj,\n // Working stack is empty since the top-level object doesn't have any parents\n [],\n // Don't skip anything\n [],\n (nodeOrClosingFragment, workingStack) => {\n if (typeof nodeOrClosingFragment !== 'object') {\n // Add the text contents USFM representation\n const { usfm: textContentUsfm, fragmentsInfo: textContentFragmentsInfo } =\n this.textContentToUsfm(nodeOrClosingFragment);\n UsjReaderWriter.mergeFragmentsInfoIntoExistingArray(\n textContentFragmentsInfo,\n fragmentsInfo,\n usfm.length,\n );\n transferFragmentsInfo(workingStack);\n usfm += textContentUsfm;\n return false;\n }\n\n // Determine this marker's parent\n let markerParent: MarkerObject | Usj | undefined;\n if (workingStack.length > 0) {\n markerParent = workingStack[workingStack.length - 1].parent;\n }\n\n if ('isClosingMarker' in nodeOrClosingFragment) {\n // If we are supposed to skip this marker in USFM, skip its closing marker\n if (\n markersToSkipOutput.length > 0 &&\n markersToSkipOutput[markersToSkipOutput.length - 1] === nodeOrClosingFragment.forMarker\n ) {\n // Indicate the skipped marker has now closed by removing it from the stack\n markersToSkipOutput.pop();\n return false;\n }\n\n // Add the closing marker USFM representation\n usfm = this.addMarkerUsfmToString(\n usfm,\n nodeOrClosingFragment,\n markerParent,\n fragmentsInfo,\n );\n transferFragmentsInfo(workingStack);\n\n // If this is closing the `id` marker (the only marker whose type is `book`), add the\n // top-level USJ opening marker after it\n if (nodeOrClosingFragment.forMarker.type === 'book' && topLevelUsjMarker) {\n usfm = this.addMarkerUsfmToString(usfm, topLevelUsjMarker, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n topLevelUsjMarker = undefined;\n }\n\n return false;\n }\n\n // If we are supposed to skip this marker in USFM, skip its opening marker\n if (this.shouldSkipOutputMarkerToUsfm(nodeOrClosingFragment)) {\n markersToSkipOutput.push(nodeOrClosingFragment);\n return false;\n }\n\n // If this is the USJ marker at the start of the doc, save it until after `id` marker closes\n if (\n UsjReaderWriter.isTopLevelUsjMarker(nodeOrClosingFragment, workingStack) &&\n !topLevelUsjMarker\n ) {\n // The USJ types aren't set up to know about 3.0 right now, but we should handle it anyway\n // eslint-disable-next-line no-type-assertion/no-type-assertion\n if ((nodeOrClosingFragment.version as string) !== '3.0') {\n // Don't output the USJ marker if it is 3.0 (3.0 is assumed and should not appear in\n // the USFM)\n topLevelUsjMarker = nodeOrClosingFragment;\n }\n return false;\n }\n\n // Add the opening marker USFM representation\n usfm = this.addMarkerUsfmToString(usfm, nodeOrClosingFragment, markerParent, fragmentsInfo);\n transferFragmentsInfo(workingStack);\n\n // Keep going through the whole document\n return false;\n },\n );\n\n // Always add newline at the end of the file; likely replaces a space\n usfm = `${UsjReaderWriter.removeEndSpace(usfm)}\\n`;\n\n return { usfm, fragmentsByIndexInUsfm, fragmentsByJsonPath, indicesInUsfmByVerseRef };\n }\n\n /** The USFM representation of the USJ document passed in */\n private get usfm(): string {\n if (this.usfmInternal !== undefined) return this.usfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.usfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByIndexInUsfm(): FragmentsByIndexInUsfm {\n if (this.fragmentsByIndexInUsfmInternal) return this.fragmentsByIndexInUsfmInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByIndexInUsfmInternal;\n }\n\n /** Fragments at each index in the USFM string */\n private get fragmentsByJsonPath(): FragmentsByJsonPath {\n if (this.fragmentsByJsonPathInternal) return this.fragmentsByJsonPathInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.fragmentsByJsonPathInternal;\n }\n\n /**\n * String index of the start of each verse (the backslash on the verse marker) in the USFM\n * representation of the USJ document. See {@link IndicesInUsfmByVerseRef} for more information.\n */\n private get indicesInUsfmByVerseRef(): IndicesInUsfmByVerseRef {\n if (this.indicesInUsfmByVerseRefInternal) return this.indicesInUsfmByVerseRefInternal;\n\n ({\n usfm: this.usfmInternal,\n fragmentsByIndexInUsfm: this.fragmentsByIndexInUsfmInternal,\n fragmentsByJsonPath: this.fragmentsByJsonPathInternal,\n indicesInUsfmByVerseRef: this.indicesInUsfmByVerseRefInternal,\n } = this.calculateUsfmProperties());\n\n return this.indicesInUsfmByVerseRefInternal;\n }\n\n // #endregion USFM-related cached properties\n}\n\nexport default UsjReaderWriter;\n"],"names":["_AsyncVariable","variableName","rejectIfNotSettledWithinMS","__publicField","resolve","reject","enabled","value","throwIfAlreadySettled","reason","AsyncVariable","Collator","locales","options","string1","string2","DateTimeFormat","date","startDate","endDate","PlatformEventEmitter","event","callback","callbackIndex","newGuid","s","isString","o","deepClone","obj","debounce","fn","delay","timeout","promise","promiseResolve","promiseReject","args","e","groupBy","items","keySelector","valueSelector","map","item","index","key","group","isErrorWithMessage","error","toErrorWithMessage","maybeError","getErrorMessage","wait","ms","waitForDuration","maxWaitTimeInMS","getAllObjectFunctionNames","_objId","objectFunctionNames","property","objectPrototype","createSyncProxyForAsyncObject","getObject","objectToProxy","target","prop","isErrorMessageAboutParatextBlockingInternetAccess","errorMessage","paratextExceptionMessage","isErrorMessageAboutRegistryAuthFailure","paratextExceptionMessage1","paratextExceptionMessage2","errorString","DocumentCombiner","baseDocument","documentName","document","previousDocumentVersion","documentToSet","contributions","contributionName","potentialOutput","outputIteration","contribution","mergeObjects","output","finalOutput","areNonArrayObjects","values","allMatch","areArrayObjects","startingPoint","copyFrom","ignoreDuplicateProperties","retVal","mergeObjectsInternal","startingPointObj","copyFromObj","EventRollingTimeCounter","bufferSize","currentTime","minRollingTimeMs","Mutex","AsyncMutex","MutexMap","mutexID","NonValidatingDocumentCombiner","NumberFormat","startRange","endRange","defaultPromise","PromiseChainingMap","logger","promiseFunction","currentPromise","promiseHolder","newPromise","SortedNumberMap","insertIndex","left","right","result","mid","SortedSet","compareFn","low","high","UnsubscriberAsyncList","name","unsubscribers","unsubscriber","unsubs","results","unsubscriberSucceeded","PLATFORM_ERROR_VERSION","newPlatformError","platformError","isPlatformError","P","R","t","n","N","B","O","S","K","g","k","x","T","X","V","w","L","G","A","H","C","I","y","q","U","m","l","h","c","E","r","D","i","a","u","v","f","d","b","p","J","M","find","list","predicate","ac","hasOwn","freeze","object","oc","assign","source","HTML_BOOLEAN_ATTRIBUTES","isHTMLBooleanAttribute","HTML_VOID_ELEMENTS","isHTMLVoidElement","tagName","HTML_RAW_TEXT_ELEMENTS","isHTMLRawTextElement","isHTMLEscapableRawTextElement","isHTMLMimeType","mimeType","MIME_TYPE","hasDefaultHTMLNamespace","_MIME_TYPES","isValidMimeType","NAMESPACE","conventions","require$$0","extendError","constructor","writableName","DOMExceptionName","DOMExceptionNames","isValidDomExceptionCode","endsWithError","DOMException","messageOrCode","nameOrMessage","code","ExceptionCode","entries","ParseError","message","locator","errors","detectUnicodeSupport","RegExpImpl","match","UNICODE_SUPPORT","chars","regexp","chars_without","search","reg","self","part","isStr","regg","UNICODE_REPLACEMENT_CHARACTER","Char","_SChar","SChar_s","S_OPT","NameStartChar","NameStartChar_s","NameChar","Name","Nmtoken","EntityRef","CharRef","Reference","PEReference","EntityValue","AttValue","NCNameStartChar","NCNameChar","NCName","QName","QName_exact","QName_group","SystemLiteral","PI","PubidChar","PubidLiteral","COMMENT_START","COMMENT_END","Comment","PCDATA","Mixed","_children_quantity","children","contentspec","ELEMENTDECL_START","elementdecl","NotationType","Enumeration","EnumeratedType","AttType","DefaultDecl","AttDef","ATTLIST_DECL_START","AttlistDecl","ABOUT_LEGACY_COMPAT","ABOUT_LEGACY_COMPAT_SystemLiteral","SYSTEM","PUBLIC","ExternalID","ExternalID_match","NDataDecl","EntityDef","ENTITY_DECL_START","GEDecl","PEDef","PEDecl","EntityDecl","PublicID","NotationDecl","Eq","VersionNum","VersionInfo","EncName","EncodingDecl","SDDecl","XMLDecl","DOCTYPE_DECL_START","CDATA_START","CDATA_END","CDStart","CDEnd","CData","CDSect","grammar","PDC","require$$1","require$$2","checkSymbol","symbol","notEmptyString","input","splitOnASCIIWhitespace","orderedSetReducer","current","element","toOrderedSet","arrayIncludes","validateQualifiedName","qualifiedName","validateAndExtract","namespace","prefix","localName","splitResult","copy","src","dest","_extends","Class","Super","pt","NodeType","ELEMENT_NODE","ATTRIBUTE_NODE","TEXT_NODE","CDATA_SECTION_NODE","ENTITY_REFERENCE_NODE","ENTITY_NODE","PROCESSING_INSTRUCTION_NODE","COMMENT_NODE","DOCUMENT_NODE","DOCUMENT_TYPE_NODE","DOCUMENT_FRAGMENT_NODE","NOTATION_NODE","DocumentPosition","commonAncestor","docGUID","doc","NodeList","nodeFilter","buf","serializeToString","me","LiveNodeList","node","refresh","_updateLiveList","inc","ls","__set__","NamedNodeMap","_findNodeIndex","_addNamedNode","el","newAttr","oldAttr","_onRemoveAttribute","_onAddAttribute","_removeNamedNode","attr","lastIndex","namespaceURI","DOMImplementation","feature","version","doctype","contentType","Document","root","publicId","systemId","internalSubset","DocumentType","title","htmlNode","headNode","titleNode","Node","rootNode","other","parent","otherNode","newChild","refChild","_insertBefore","oldChild","assertPreReplacementValidityInDocument","_removeChild","deep","cloneNode","child","next","node1","node2","attr1","attr2","Attr","chain1","ancestor1","chain2","ancestor2","ca","_xmlEncoder","_visitNode","opt","ns","remove","_onUpdateChild","childNodes","parentNode","oldPreviousSibling","oldNextSibling","hasValidParentNodeType","hasInsertableNodeType","isDocTypeNode","isElementNode","isTextNode","isElementInsertionPossible","parentChildNodes","docTypeNode","isElementReplacementPossible","hasElementChildThatIsNotChild","assertPreInsertionValidity1to5","assertPreInsertionValidityInDocument","nodeChildNodes","nodeChildElements","parentElementChild","_inDocumentAssertion","cp","newFirst","newLast","pre","removed","importedNode","importNode","id","rtv","Element","attrs","DocumentFragment","data","Text","CDATASection","ProcessingInstruction","EntityReference","validated","old","classNames","classNamesSet","base","nodeClassNames","matches","nodeClassNamesSet","isHTMLDocument","lowerQualifiedName","nodeQualifiedName","matchingQName","CharacterData","offset","count","text","start","end","newText","newNode","Notation","Entity","XMLSerializer","nodeSerializeToString","refNode","uri","visibleNamespaces","needNamespaceDefine","isHTML","addSerializedAttribute","len","nodeName","prefixedNodeName","defaultNS","ai","nsi","canCloseTag","pubid","sysid","attrs2","getTextContent","dom","exports","S_TAG","S_ATTR","S_ATTR_SPACE","S_EQ","S_ATTR_NOQUOT_VALUE","S_ATTR_END","S_TAG_SPACE","S_TAG_CLOSE","XMLReader","defaultNSMap","entityMap","domBuilder","_copy","parse","ENTITY_REG","defaultNSMapCopy","errorHandler","fixedFromCharCode","surrogate1","surrogate2","entityReplacer","complete","appendText","xt","position","lineStart","lineEnd","linePattern","parseStack","unclosedTags","tagStart","fromSource","tagNameRaw","tagNameMatch","currentTagName","tagNameLower","config","localNSMap","parseProcessingInstruction","parseDoctypeCommentOrCData","ElementAttributes","currentNSMap","parseElementStartPart","locator2","copyLocator","appendElement","parseHtmlSpecialContent","addAttribute","qname","startIndex","attrName","qName","nsp","nsPrefix","elStartEnd","isEscapableRaw","elEndStart","parseUtils","char","skip","skipBlanks","blanks","substringFromIndex","substringStartsWith","substringStartsWithCaseInsensitive","getMatch","expr","parseDoctypeInternalSubset","parsePI","intSubsetStart","comment","cdata","sax","entities","require$$3","require$$4","normalizeLineEndings","DOMParser","DOMHandler","defaultNamespace","isXml","impl","ins","ch","length","_toString","charNode","comm","dt","level","_locator","handler","onErrorStopParsing","onWarningStopParsing","domParser","lib","charRegex","astralRange","comboRange","varRange","familyRange","astral","combo","fitz","modifier","nonAstral","regional","surrogatePair","zwj","blackFlag","family","optModifier","optVar","optJoin","seq","__importDefault","this","mod","dist","char_regex_1","toArray","str","substring","begin","substr","strLength","limit","padString","padPosition","padRepeats","indexOf","searchStr","pos","strArr","searchArr","finded","searchIndex","ensureArray","maybeArray","at","string","stringLength","charAt","codePointAt","endsWith","searchString","endPosition","lastIndexOfSearchString","lastIndexOf","indexOfClosestClosingCurlyBrace","escaped","closeCurlyBraceIndex","formatReplacementStringToArray","replacers","contents","nextIntermediateStartIndex","addToContents","newContent","newContentIndex","newContentLength","intermediateContent","baseSubstring","replacerKey","replacerContent","endContent","formatReplacementString","content","includes","partialString","stringzIndexOf","validatedPosition","stringzLength","normalize","form","upperCaseForm","ordinalCompare","padEnd","targetLength","stringzLimit","padStart","correctSliceIndex","slice","indexStart","indexEnd","newStart","newEnd","split","separator","splitLimit","regexSeparator","currentIndex","matchIndex","matchLength","startsWith","stringzSubstr","stringzSubstring","stringzToArray","isLocalizeKey","escapeStringRegexp","transformAndEnsureRegExpRegExpArray","stringStringMaybeArray","stringMaybeStringArray","transformAndEnsureRegExpArray","stringMaybeArray","whiteSpaceRegex","isWhiteSpace","toKebabCase","prevChar","nextChar","BLOCK_MARKER_TYPES","USJ_TYPE","ZWSP","scrBookData","FIRST_SCR_BOOK_NUM","LAST_SCR_BOOK_NUM","FIRST_SCR_CHAPTER_NUM","FIRST_SCR_VERSE_NUM","defaultScrRef","getChaptersForBook","bookNum","_a","offsetBook","scrRef","Canon","offsetChapter","offsetVerse","getLocalizedIdFromBookNumber","bookNumber","localizationLanguage","getLocalizedString","bookName","parts","scrRefToBBBCCC","VerseRef","scrRefToBBBCCCVVV","compareScrRefs","scrRef1","scrRef2","getLocalizeKeyForScrollGroupId","scrollGroupId","getLocalizeKeysForScrollGroupIds","scrollGroupIds","formatScrRef","optionOrLocalizedBookName","chapterVerseSeparator","bookChapterSeparator","book","Section","getSectionForBook","bookId","nonSemanticWhiteSpaceRegex","isNonSemanticWhiteSpace","invisibleCharOrWhiteSpaceRegex","isParatextSelectableInvisibleCharOrWhiteSpace","normalizeScriptureSpaces","lastCharWasSpace","prevCh","isUsjContentEmpty","isAtEndOfBlockMarker","contentObject","areUsjContentsEqualExceptWhitespaceInternal","aParent","bParent","aIsString","bIsString","aNormalized","bNormalized","aTrimmed","bTrimmed","aObject","bObject","aKeys","isAContentEmpty","isBContentEmpty","aContent","bContent","aLast","bLast","areUsjContentsEqualExceptWhitespace","aggregateUnsubscribers","success","aggregateUnsubscriberAsyncs","unsubPromises","BOOK_TYPE","CHAPTER_TYPE","VERSE_TYPE","NO_BOOK_ID","getDefaultCallerSequence","_","getNthCaller","callers","callerList","getFormatCallerFunction","footnotes","plusSequenceMap","autoCallerCounter","idx","caller","formattedCaller","extractFootnotesFromUsjContent","traverse","getPaneSizeLimits","availablePx","splitterThicknessPx","secondaryPaneMinSizePx","mainPaneMinSizePx","absoluteMinPercent","absoluteMaxPercent","usableHeightPx","minPercent","maxPercent","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","combineComparators","comparatorA","comparatorB","state","createIsCircular","areItemsEqual","cache","cachedA","cachedB","getStrictProperties","sameValueZeroEqual","PREACT_VNODE","PREACT_OWNER","REACT_OWNER","getOwnPropertyDescriptor","keys","areArraysEqual","areDatesEqual","areErrorsEqual","areFunctionsEqual","areMapsEqual","size","matchedIndices","aIterable","aResult","bResult","bIterable","hasMatch","aEntry","bEntry","areNumbersEqual","areObjectsEqual","properties","isPropertyEqual","areObjectsEqualStrict","descriptorA","descriptorB","arePrimitiveWrappersEqual","areRegExpsEqual","areSetsEqual","areTypedArraysEqual","areUrlsEqual","ARGUMENTS_TAG","BOOLEAN_TAG","DATE_TAG","ERROR_TAG","MAP_TAG","NUMBER_TAG","OBJECT_TAG","REG_EXP_TAG","SET_TAG","STRING_TAG","URL_TAG","isArray","isTypedArray","getTag","createEqualityComparator","type","tag","createEqualityComparatorConfig","circular","createCustomConfig","strict","areArraysEqual$1","areMapsEqual$1","areObjectsEqual$1","areSetsEqual$1","createInternalEqualityComparator","compare","_indexOrKeyA","_indexOrKeyB","_parentA","_parentB","createIsEqual","comparator","createState","equals","_b","meta","deepEqual","createCustomEqual","createCustomInternalComparator","isEqualDeep","isSubset","objectWithAllProperties","objectWithPartialProperties","partialArray","allArray","partialObj","allObj","serialize","replacer","space","replacerValue","newValue","deserialize","reviver","replaceNull","parsedObject","isSerializable","serializedValue","htmlEncode","getCurrentLocale","formatBytes","fileSize","decimals","sizes","sizeToUse","MILLISECONDS_PER_SECOND","SECONDS_PER_MINUTE","SECONDS_PER_HOUR","SECONDS_PER_DAY","formatTimeSpan","relativeTimeFormatter","since","to","spanSeconds","totalDays","totalHours","totalMinutes","formatRelativeDate","todayString","yesterdayString","locale","today","yesterday","isToday","isYesterday","MODIFIER_KEYS","settingsDefs","removeJsonToTypeScriptTypesStuff","defs","def","projectSettingsDocumentSchema","settingsDocumentSchema","localizedStringsDefs","localizedStringsDocumentSchema","menuDocumentSchema","themeDefs","themeDocumentSchema","THEME_STYLE_ELEMENT_ID","getThemeId","themeFamilyId","expandThemeContribution","themeFamiliesById","defaultThemeFamily","themeFamily","themeDefinition","getStylesheetForTheme","theme","applyThemeStylesheet","previousStyleElement","styleElementIdSuffix","previousThemeId","themeStyleElement","deepFreeze","USFM_MARKERS_MAP","USFM_MARKERS_MAP_PARATEXT","NODE_TYPES_NOT_CONTAINING_VERSE_TEXT","TEXT_CONTENT_NBSP_REGEXP","TABLE_MARKER_NUMBER_REGEXP","VERSE_MARKER_NUMBER_SPAN_REGEXP","UsjReaderWriter","usj","providedMarkersMap","shouldAllowInvisibleCharacters","USFM_MARKERS_MAP_3_0","versionA","versionB","jsonPathQuery","wrappedResults","JSONPath","unwrappedResults","marker","workingStack","fragment","parentMap","tempNode","tempParent","tempChild","pathArray","pathAcc","pathEntry","jsonPath","stack","stackLevel","levels","onNode","onLevel","indexString","nextNode","skipTypes","searchFunction","topNode","highestSkippedNode","stackItem","stackNode","skipNextNode","nextNodeClosingMarker","nextLevel","parentClosingMarker","potentiallyMatchingNodeOrClose","currentWorkingStack","nodeParent","bookIdIfNotFound","usjLocation","realParent","nodeIndexInParent","fragmentInfo","verseRef","verseIndexInUsfm","availableBookIds","noBookIdsFound","effectiveBookId","chapterIndices","indexInUsfm","bookEntries","bookIndex","lastVerseRef","didFindVerseRef","chapterEntries","chapterIndex","chapterNumString","verseIndices","verseEntries","verseIndex","verseNumString","verseFragmentInfo","usfmVerseLocation","verseRefOffset","usjChapterLocation","usjBookLocation","usfmVerseLocationIndexInUsfm","usjOffset","usjDocumentLocationMaybeNode","documentLocation","verseLocation","firstStringLocationAfterVerseMarker","maxTextLengthToSearch","textScanned","lengthScanned","lengthTrimmed","foundStartingAtOffset","workingStackForStartingPoint","startingPointStackItem","nodeTextToSearch","currentStackItem","textIndex","finalOffset","finalStack","finalNode","regex","textChunks","fullTextIndexMap","fullText","startingNodeEntry","endingNodeEntry","desiredLength","offsetRemaining","lengthRecorded","remainingNode","lengthToCopy","maxLength","currentStack","contentArray","removedCount","markerName","markerInfo","markerRegExp","scriptureFormat","markerNameOriginal","markerIsUnknown","markerTypeFromFirstMarkerInfo","markerType","markerTypeInfo","attributeMarkerInfoEntries","attributeMarkerName","attributeMarkerInfo","markerWithAnyAttributes","columnsSpanned","tableMarkerMatches","startingColumn","textContent","newFragmentsInfo","existingFragmentsInfo","existingUsfmLength","fragmentIndex","isInsideMarkerWithSameType","usfm","fragmentsInfo","markerPrefix","attributeName","attributeValue","attributeMarker","attributeMarkerFragmentsInfo","textContentUsfm","partialClosingFragment","closingMarkerAttributeNames","hasExplicitClosingMarker","independentClosingMarker","openingMarkerUsfm","openingFragmentsInfo","openingFragmentInfo","attributeNameUsfm","closingMarkerName","markerParentOrIsInsideMarkerWithSameType","usfmOutput","markerUsfmOutput","markerFragmentsInfo","isParentSameType","parentMarkerType","closingUsfm","closingFragmentsInfo","openingUsfm","lastMarkerBackslashIndex","newLocation","ignoreJsonPath","aJsonPath","restOfA","bJsonPath","restOfB","zeroedUsjLocation","fragmentInfoAtLocation","allFragmentsInfoAtJsonPath","locationOffset","offsetWithinFragment","fragmentsByIndexInUsfm","fragmentsByJsonPath","indicesInUsfmByVerseRef","nextChapterNum","currentBookFragments","nextVerseNumString","nextVerseNum","_c","fragmentJsonPath","fragmentsAtJsonPath","currentPosition","transferFragmentsInfo","topLevelUsjMarker","markersToSkipOutput","nodeOrClosingFragment","textContentFragmentsInfo","markerParent"],"mappings":";;;;;AACO,MAAMA,KAAN,MAAMA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiB5B,YAAYC,GAAsBC,IAAqC,KAAO;AAf7D,IAAAC,EAAA;AACA,IAAAA,EAAA;AACT,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAWN,SAAK,eAAeF,GACpB,KAAK,kBAAkB,IACvB,KAAK,iBAAiB,IAAI,QAAW,CAACG,GAASC,MAAW;AACxD,WAAK,WAAWD,GAChB,KAAK,WAAWC;AAAA,IAAA,CACjB,GACGH,IAA6B,MAC1B,KAAA,YAAY,WAAW,MAAM;AAChC,MAAI,KAAK,aACP,KAAK,SAAS,oCAAoC,KAAK,YAAY,YAAY,GAC/E,KAAK,kBAAkB,IACvB,KAAK,SAAS;AAAA,OAEfA,CAA0B,IAE/B,OAAO,KAAK,IAAI;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlB,IAAI,UAAsB;AACxB,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQd,IAAI,aAAsB;AACjB,WAAA,OAAO,SAAS,IAAI;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,IAAI,cAAuB;AACzB,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQd,OAAO,kBAAkBI,GAAwB;AAC/C,SAAK,wBAAwBA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/B,eAAeC,GAAUC,IAAiC,IAAa;AACrE,QAAI,KAAK;AACP,MAAIR,GAAc,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AyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAAA,EAId,IAAY,yBAAiD;AACvD,WAAA,KAAK,iCAAuC,KAAK,kCAEpD;AAAA,MACC,MAAM,KAAK;AAAA,MACX,wBAAwB,KAAK;AAAA,MAC7B,qBAAqB,KAAK;AAAA,MAC1B,yBAAyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAAA,EAId,IAAY,sBAA2C;AACjD,WAAA,KAAK,8BAAoC,KAAK,+BAEjD;AAAA,MACC,MAAM,KAAK;AAAA,MACX,wBAAwB,KAAK;AAAA,MAC7B,qBAAqB,KAAK;AAAA,MAC1B,yBAAyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,IAAY,0BAAmD;AACzD,WAAA,KAAK,kCAAwC,KAAK,mCAErD;AAAA,MACC,MAAM,KAAK;AAAA,MACX,wBAAwB,KAAK;AAAA,MAC7B,qBAAqB,KAAK;AAAA,MAC1B,yBAAyB,KAAK;AAAA,IAAA,IAC5B,KAAK,wBAAwB,GAE1B,KAAK;AAAA,EAAA;AAAA;AAIhB;","x_google_ignoreList":[16,17,18,19,20,21,22,23,24,25,26,27,35]} \ No newline at end of file diff --git a/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.0.model.ts b/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.0.model.ts index 52c341b6a2c..161fd94fa51 100644 --- a/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.0.model.ts +++ b/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.0.model.ts @@ -5,8 +5,10 @@ * An attribute marker is a marker that adds information to a previous marker in USFM and is an * attribute on that previous marker instead in USX/USJ. * - * @example `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for - * `v`. `cat` is an attribute marker for `f`, `esb`, and more. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for `v`. `cat` + * is an attribute marker for `f`, `esb`, and more. * * Following is an example of using the `ca` and `cp` attribute markers in USFM: * @@ -28,23 +30,28 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { /** * List of normal marker names for which this marker is an attribute marker. * - * @example `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` - * for both `ca` and `cp`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` for both + * `ca` and `cp`. */ isAttributeMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an attribute marker. * - * @example Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. + * @example + * + * Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isAttributeMarkerForRegExp?: string[]; /** * The name of the USX/USJ attribute this attribute marker represents. * - * @example `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the - * `c` marker in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` - * marker. + * @example + * + * `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the `c` marker + * in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` marker. */ attributeMarkerAttributeName: string; /** @@ -63,8 +70,10 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * If not present or `undefined`, defaults to `false`. * - * @example According to specification, the `va` and `vp` attribute markers have a space after - * their normal closing markers: + * @example + * + * According to specification, the `va` and `vp` attribute markers have a space after their normal + * closing markers: * * ```usfm * \p \v 10 \va 10 va\va* \vp 10 vp\vp* Some verse text @@ -82,8 +91,9 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * The verse text in this example is " Some verse text" including a space at the start. * - * @example The `cat` attribute marker does not have a structural space after its normal closing - * marker: + * @example + * + * The `cat` attribute marker does not have a structural space after its normal closing marker: * * ```usfm * \f + \cat category here\cat*\fr 1:2 \ft Some footnote text\f* @@ -115,13 +125,17 @@ export type NormalMarkerInfo = { * An attribute can be provided with default syntax in the USFM only if it is the only attribute * provided for the marker. * - * @example A marker with a default attribute: + * @example + * + * A marker with a default attribute: * * ```usfm * \w stuff|thisIsTheLemmaDefaultAttribute\w* * ``` * - * @example A marker with multiple attributes (cannot use default attribute syntax): + * @example + * + * A marker with multiple attributes (cannot use default attribute syntax): * * ```usfm * \w stuff|lemma="thisIsTheLemma" strong="H1234,G1234"\w* @@ -135,8 +149,10 @@ export type NormalMarkerInfo = { * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual * text content of the marker. * - * @example `alt` is a text content attribute on the `periph` marker. This value would be `alt` - * for the `periph` marker. + * @example + * + * `alt` is a text content attribute on the `periph` marker. This value would be `alt` for the + * `periph` marker. * * Following is an example of a `periph` marker in USFM: * @@ -162,8 +178,10 @@ export type NormalMarkerInfo = { * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker * and separated only by a space. * - * @example `code` is a leading attribute on the `id` marker. This value would be `['code']` for - * the `id` marker. + * @example + * + * `code` is a leading attribute on the `id` marker. This value would be `['code']` for the `id` + * marker. * * Following is an example of an `id` marker in USFM: * @@ -189,8 +207,9 @@ export type NormalMarkerInfo = { * Note: the attribute names for attribute markers may be different than the marker names. See * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information. * - * @example `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for - * `c`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for `c`. */ attributeMarkers?: string[]; /** @@ -232,7 +251,9 @@ export type NormalMarkerInfo = { * closing marker for but rather are completely separate markers that close the corresponding * opening marker. * - * @example `esb` (a sidebar) is closed by the independent closing marker `esbe`. + * @example + * + * `esb` (a sidebar) is closed by the independent closing marker `esbe`. * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a * sidebar: * @@ -246,20 +267,24 @@ export type NormalMarkerInfo = { independentClosingMarkers?: string[]; /** * List of marker names for which this marker is an independent closing marker. See - * {@link NormalMarkerInfo.independentClosingMarker} for more information on independent closing + * {@link NormalMarkerInfo.independentClosingMarkers} for more information on independent closing * markers and their syntax. * - * @example `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` - * would be `['esb']` for `esbe`. + * @example + * + * `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` would be + * `['esb']` for `esbe`. */ isIndependentClosingMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an independent closing - * marker. See {@link NormalMarkerInfo.independentClosingMarker} for more information on + * marker. See {@link NormalMarkerInfo.independentClosingMarkers} for more information on * independent closing markers and their syntax. * - * @example Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp - * `/test/`. `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. + * @example + * + * Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp `/test/`. + * `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isIndependentClosingMarkerForRegExp?: string[]; /** @@ -267,8 +292,9 @@ export type NormalMarkerInfo = { * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used * instead of the marker info for the marker as listed in USX or USJ. * - * @example When the `usx` marker is output to USFM, it should be transformed to the `usfm` - * marker. + * @example + * + * When the `usx` marker is output to USFM, it should be transformed to the `usfm` marker. */ markerUsfm?: string; /** @@ -286,9 +312,11 @@ export type NormalMarkerInfo = { /** * Information about a USFM/USX/USJ marker that is essential for proper translation between formats. * - * @example `w` is a `char`-type marker, so it shares the characteristics of the `char` - * {@link MarkerTypeInfo} with other `char`-type markers and has its own set of characteristics. - * `w`'s `MarkerInfo` is as follows: + * @example + * + * `w` is a `char`-type marker, so it shares the characteristics of the `char` {@link MarkerTypeInfo} + * with other `char`-type markers and has its own set of characteristics. `w`'s `MarkerInfo` is as + * follows: * * ```json * { @@ -307,8 +335,10 @@ export type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo; * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` markers such - * as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` markers such as `p` do + * not: * * ```usfm * \p This is a plain paragraph. @@ -345,7 +375,9 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * * If not present or `undefined`, defaults to `false` * - * @example Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: + * @example + * + * Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: * * ```usfm * \qt1-s\* @@ -372,8 +404,10 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * Information about a USFM/USX/USJ marker type that does not have a closing marker. See * {@link MarkerTypeInfo} for other kinds of marker types. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` marker types - * such as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` marker types such as + * `p` do not: * * ```usfm * \p This is a plain paragraph. @@ -426,8 +460,10 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example The `sid` attribute on the `verse` type marker is not present in USFM because it is - * derived metadata in USX/USJ and is not present in USFM. + * @example + * + * The `sid` attribute on the `verse` type marker is not present in USFM because it is derived + * metadata in USX/USJ and is not present in USFM. */ skipOutputAttributeToUsfm?: string[]; /** @@ -442,10 +478,12 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the - * end of the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the - * `verse` marker does not have the `style="v"` attribute in this situation, so this list of - * attributes is on the marker type. + * @example + * + * If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the end of + * the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the `verse` + * marker does not have the `style="v"` attribute in this situation, so this list of attributes is + * on the marker type. * * Following is an example of a derived metadata `verse` marker in USX: * @@ -463,8 +501,10 @@ export type MarkerTypeInfoBase = { * \v 21 This is verse 21. * ``` * - * @example Generated `ref`s should be skipped but have content inside the marker that should not - * be skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have + * @example + * + * Generated `ref`s should be skipped but have content inside the marker that should not be + * skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived * metadata have the `gen` attribute set to `"true"` and can be removed if `gen="true"` is * present. @@ -495,8 +535,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ - * and is not preserved when transforming from USX/USJ to USFM. + * @example + * + * In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ and is + * not preserved when transforming from USX/USJ to USFM. * * Following is an example of a derived metadata `table` marker in USX: * @@ -539,8 +581,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example `para` marker types such as `p` should have a newline, but `char` marker types such as - * `nd` markers should not: + * @example + * + * `para` marker types such as `p` should have a newline, but `char` marker types such as `nd` + * markers should not: * * ```usfm * \p This is a plain paragraph. @@ -570,8 +614,10 @@ export type MarkerTypeInfoBase = { * Prefix to add to the opening and closing marker before the marker name if a marker of this type * occurs within another marker of this type when outputting to USFM. * - * @example In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is - * an example of `nd` inside `wj` (both are `char`-type markers) in USFM: + * @example + * + * In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is an + * example of `nd` inside `wj` (both are `char`-type markers) in USFM: * * ```usfm * \p \wj This is \+nd nested\+nd*!\wj* @@ -604,9 +650,11 @@ export type MarkerTypeInfoBase = { * Information about a USFM/USX/USJ marker type that is essential for proper translation between * formats. * - * @example `char` is a marker type, which means markers like `w` whose marker type is `char` share - * some characteristics, and each marker also has its own set of characteristics which are presented - * with type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: + * @example + * + * `char` is a marker type, which means markers like `w` whose marker type is `char` share some + * characteristics, and each marker also has its own set of characteristics which are presented with + * type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: * * ```json * { @@ -747,7 +795,7 @@ export const USFM_MARKERS_MAP: MarkersMap = deepFreeze({ schemaRepo: 'https://github.com/ubsicap/usx.git', schemaCommit: '6c490bb5675d281b0fa01876fe67f6e3fd50a4ce', markersMapVersion: '1.0.0', - usfmToolsCommit: 'b3475856e2b7c0f19739d247ae3f3c13cba66215', + usfmToolsCommit: '6c7bb8d75eda47893296a635c1e6e0b67165ac7f', markers: { add: { type: 'char', diff --git a/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.1.model.ts b/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.1.model.ts index 0c33c4d59b6..cdeb199696d 100644 --- a/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.1.model.ts +++ b/lib/platform-bible-utils/src/scripture/markers-maps/markers-map-3.1.model.ts @@ -5,8 +5,10 @@ * An attribute marker is a marker that adds information to a previous marker in USFM and is an * attribute on that previous marker instead in USX/USJ. * - * @example `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for - * `v`. `cat` is an attribute marker for `f`, `esb`, and more. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `va` and `vp` are attribute markers for `v`. `cat` + * is an attribute marker for `f`, `esb`, and more. * * Following is an example of using the `ca` and `cp` attribute markers in USFM: * @@ -28,23 +30,28 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { /** * List of normal marker names for which this marker is an attribute marker. * - * @example `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` - * for both `ca` and `cp`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. `isAttributeMarkerFor` would be `['c']` for both + * `ca` and `cp`. */ isAttributeMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an attribute marker. * - * @example Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. + * @example + * + * Pretend `ex1` and `ex2` are attribute markers for markers matching RegExp `/test/`. * `isAttributeMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isAttributeMarkerForRegExp?: string[]; /** * The name of the USX/USJ attribute this attribute marker represents. * - * @example `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the - * `c` marker in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` - * marker. + * @example + * + * `ca` is an attribute marker for `c` and represents the `altnumber` attribute on the `c` marker + * in USX/USJ. `attributeMarkerAttributeName` would be `altnumber` for the `ca` marker. */ attributeMarkerAttributeName: string; /** @@ -63,8 +70,10 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * If not present or `undefined`, defaults to `false`. * - * @example According to specification, the `va` and `vp` attribute markers have a space after - * their normal closing markers: + * @example + * + * According to specification, the `va` and `vp` attribute markers have a space after their normal + * closing markers: * * ```usfm * \p \v 10 \va 10 va\va* \vp 10 vp\vp* Some verse text @@ -82,8 +91,9 @@ export type AttributeMarkerInfo = NormalMarkerInfo & { * * The verse text in this example is " Some verse text" including a space at the start. * - * @example The `cat` attribute marker does not have a structural space after its normal closing - * marker: + * @example + * + * The `cat` attribute marker does not have a structural space after its normal closing marker: * * ```usfm * \f + \cat category here\cat*\fr 1:2 \ft Some footnote text\f* @@ -115,13 +125,17 @@ export type NormalMarkerInfo = { * An attribute can be provided with default syntax in the USFM only if it is the only attribute * provided for the marker. * - * @example A marker with a default attribute: + * @example + * + * A marker with a default attribute: * * ```usfm * \w stuff|thisIsTheLemmaDefaultAttribute\w* * ``` * - * @example A marker with multiple attributes (cannot use default attribute syntax): + * @example + * + * A marker with multiple attributes (cannot use default attribute syntax): * * ```usfm * \w stuff|lemma="thisIsTheLemma" strong="H1234,G1234"\w* @@ -135,8 +149,10 @@ export type NormalMarkerInfo = { * Text content attributes are attributes in USX/USJ that are represented in USFM as the actual * text content of the marker. * - * @example `alt` is a text content attribute on the `periph` marker. This value would be `alt` - * for the `periph` marker. + * @example + * + * `alt` is a text content attribute on the `periph` marker. This value would be `alt` for the + * `periph` marker. * * Following is an example of a `periph` marker in USFM: * @@ -162,8 +178,10 @@ export type NormalMarkerInfo = { * Leading attributes are attributes in USJ/USX that are listed in USFM directly after the marker * and separated only by a space. * - * @example `code` is a leading attribute on the `id` marker. This value would be `['code']` for - * the `id` marker. + * @example + * + * `code` is a leading attribute on the `id` marker. This value would be `['code']` for the `id` + * marker. * * Following is an example of an `id` marker in USFM: * @@ -189,8 +207,9 @@ export type NormalMarkerInfo = { * Note: the attribute names for attribute markers may be different than the marker names. See * {@link AttributeMarkerInfo.attributeMarkerAttributeName} for more information. * - * @example `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for - * `c`. + * @example + * + * `ca` and `cp` are attribute markers for `c`. This value would be `['ca', 'cp']` for `c`. */ attributeMarkers?: string[]; /** @@ -232,7 +251,9 @@ export type NormalMarkerInfo = { * closing marker for but rather are completely separate markers that close the corresponding * opening marker. * - * @example `esb` (a sidebar) is closed by the independent closing marker `esbe`. + * @example + * + * `esb` (a sidebar) is closed by the independent closing marker `esbe`. * `independentClosingMarkers` would be `['esbe']` for `esb`. Following is an example of a * sidebar: * @@ -246,20 +267,24 @@ export type NormalMarkerInfo = { independentClosingMarkers?: string[]; /** * List of marker names for which this marker is an independent closing marker. See - * {@link NormalMarkerInfo.independentClosingMarker} for more information on independent closing + * {@link NormalMarkerInfo.independentClosingMarkers} for more information on independent closing * markers and their syntax. * - * @example `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` - * would be `['esb']` for `esbe`. + * @example + * + * `esbe` is an independent closing marker for `esb`. `isIndependentClosingMarkerFor` would be + * `['esb']` for `esbe`. */ isIndependentClosingMarkerFor?: string[]; /** * List of RegExp patterns matching marker names for which this marker is an independent closing - * marker. See {@link NormalMarkerInfo.independentClosingMarker} for more information on + * marker. See {@link NormalMarkerInfo.independentClosingMarkers} for more information on * independent closing markers and their syntax. * - * @example Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp - * `/test/`. `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. + * @example + * + * Pretend `ex1` and `ex2` are independent closing markers for markers matching RegExp `/test/`. + * `isIndependentClosingMarkerForRegExp` would be `['test']` for both `ex1` and `ex2`. */ isIndependentClosingMarkerForRegExp?: string[]; /** @@ -267,8 +292,9 @@ export type NormalMarkerInfo = { * outputting to USFM, the marker info for the marker listed here in `markerUsfm` should be used * instead of the marker info for the marker as listed in USX or USJ. * - * @example When the `usx` marker is output to USFM, it should be transformed to the `usfm` - * marker. + * @example + * + * When the `usx` marker is output to USFM, it should be transformed to the `usfm` marker. */ markerUsfm?: string; /** @@ -286,9 +312,11 @@ export type NormalMarkerInfo = { /** * Information about a USFM/USX/USJ marker that is essential for proper translation between formats. * - * @example `w` is a `char`-type marker, so it shares the characteristics of the `char` - * {@link MarkerTypeInfo} with other `char`-type markers and has its own set of characteristics. - * `w`'s `MarkerInfo` is as follows: + * @example + * + * `w` is a `char`-type marker, so it shares the characteristics of the `char` {@link MarkerTypeInfo} + * with other `char`-type markers and has its own set of characteristics. `w`'s `MarkerInfo` is as + * follows: * * ```json * { @@ -307,8 +335,10 @@ export type MarkerInfo = NormalMarkerInfo | AttributeMarkerInfo; * marker with this marker type, the USX/USJ for the marker will have the attribute `closed` set to * `false` unless {@link NormalMarkerInfo.isClosingMarkerOptional} is `true`. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` markers such - * as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` markers such as `p` do + * not: * * ```usfm * \p This is a plain paragraph. @@ -345,7 +375,9 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * * If not present or `undefined`, defaults to `false` * - * @example Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: + * @example + * + * Markers of type `ms` (such as `qt1-s` and `qt1-e`) have an empty closing marker: * * ```usfm * \qt1-s\* @@ -372,8 +404,10 @@ export type CloseableMarkerTypeInfo = MarkerTypeInfoBase & { * Information about a USFM/USX/USJ marker type that does not have a closing marker. See * {@link MarkerTypeInfo} for other kinds of marker types. * - * @example `char` marker types such as `nd` markers have closing markers, but `para` marker types - * such as `p` do not: + * @example + * + * `char` marker types such as `nd` markers have closing markers, but `para` marker types such as + * `p` do not: * * ```usfm * \p This is a plain paragraph. @@ -426,8 +460,10 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example The `sid` attribute on the `verse` type marker is not present in USFM because it is - * derived metadata in USX/USJ and is not present in USFM. + * @example + * + * The `sid` attribute on the `verse` type marker is not present in USFM because it is derived + * metadata in USX/USJ and is not present in USFM. */ skipOutputAttributeToUsfm?: string[]; /** @@ -442,10 +478,12 @@ export type MarkerTypeInfoBase = { * * This property is not used when converting to USX or USJ. * - * @example If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the - * end of the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the - * `verse` marker does not have the `style="v"` attribute in this situation, so this list of - * attributes is on the marker type. + * @example + * + * If the `verse` marker has an `eid` attribute, it indicates it is a marker denoting the end of + * the verse that is derived metadata in USX/USJ and is not present in USFM. Note that the `verse` + * marker does not have the `style="v"` attribute in this situation, so this list of attributes is + * on the marker type. * * Following is an example of a derived metadata `verse` marker in USX: * @@ -463,8 +501,10 @@ export type MarkerTypeInfoBase = { * \v 21 This is verse 21. * ``` * - * @example Generated `ref`s should be skipped but have content inside the marker that should not - * be skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have + * @example + * + * Generated `ref`s should be skipped but have content inside the marker that should not be + * skipped. These `ref`s wrap project-localized Scripture references in `xt` markers and have * computer-readable Scripture References as their `loc` attribute. These `ref`s that are derived * metadata have the `gen` attribute set to `"true"` and can be removed if `gen="true"` is * present. @@ -495,8 +535,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ - * and is not preserved when transforming from USX/USJ to USFM. + * @example + * + * In USFM 3.1, the `table` marker type is generated while transforming USFM into USX/USJ and is + * not preserved when transforming from USX/USJ to USFM. * * Following is an example of a derived metadata `table` marker in USX: * @@ -539,8 +581,10 @@ export type MarkerTypeInfoBase = { * * If not present or `undefined`, defaults to `false` * - * @example `para` marker types such as `p` should have a newline, but `char` marker types such as - * `nd` markers should not: + * @example + * + * `para` marker types such as `p` should have a newline, but `char` marker types such as `nd` + * markers should not: * * ```usfm * \p This is a plain paragraph. @@ -570,8 +614,10 @@ export type MarkerTypeInfoBase = { * Prefix to add to the opening and closing marker before the marker name if a marker of this type * occurs within another marker of this type when outputting to USFM. * - * @example In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is - * an example of `nd` inside `wj` (both are `char`-type markers) in USFM: + * @example + * + * In USFM 3.0, `char`-type markers that are nested must have a `+` prefix. Following is an + * example of `nd` inside `wj` (both are `char`-type markers) in USFM: * * ```usfm * \p \wj This is \+nd nested\+nd*!\wj* @@ -604,9 +650,11 @@ export type MarkerTypeInfoBase = { * Information about a USFM/USX/USJ marker type that is essential for proper translation between * formats. * - * @example `char` is a marker type, which means markers like `w` whose marker type is `char` share - * some characteristics, and each marker also has its own set of characteristics which are presented - * with type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: + * @example + * + * `char` is a marker type, which means markers like `w` whose marker type is `char` share some + * characteristics, and each marker also has its own set of characteristics which are presented with + * type {@link MarkerInfo}. `char`'s `MarkerTypeInfo` is as follows: * * ```json * { @@ -747,7 +795,7 @@ export const USFM_MARKERS_MAP: MarkersMap = deepFreeze({ schemaRepo: 'https://github.com/usfm-bible/tcdocs.git', schemaCommit: '50f2a6ac3fc1d867d906df28bc00fcff729a7b76', markersMapVersion: '1.0.0', - usfmToolsCommit: 'b3475856e2b7c0f19739d247ae3f3c13cba66215', + usfmToolsCommit: '6c7bb8d75eda47893296a635c1e6e0b67165ac7f', markers: { add: { type: 'char', diff --git a/lib/platform-bible-utils/src/scripture/usj-reader-writer.model.ts b/lib/platform-bible-utils/src/scripture/usj-reader-writer.model.ts index 93176520f75..1d3c8a215b8 100644 --- a/lib/platform-bible-utils/src/scripture/usj-reader-writer.model.ts +++ b/lib/platform-bible-utils/src/scripture/usj-reader-writer.model.ts @@ -217,8 +217,7 @@ export type UsjVerseRefBookLocation< * `periph` markers between `id` and chapters, so this may need to be revised when * peripheral books are more fully supported * - * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (see - * {@link UsjVerseRefChapterLocation}) + * Defaults to 'chapter' (see {@link UsjVerseRefChapterLocation}) */ granularity: 'book'; /** USJ document location specifying where in the book the location is pointing to */ @@ -249,8 +248,7 @@ export type UsjVerseRefChapterLocation< * `periph` markers between `id` and chapters, so this may need to be revised when * peripheral books are more fully supported * - * When using {@link UsjVerseRefLocation}, defaults to 'chapter' (can alternatively be 'book'; - * {@link UsjVerseRefBookLocation}) + * Defaults to 'chapter' (can alternatively be 'book'; {@link UsjVerseRefBookLocation}) */ granularity?: 'chapter'; /** USJ document location specifying where in the chapter the location is pointing to */ diff --git a/lib/platform-bible-utils/typedoc.json b/lib/platform-bible-utils/typedoc.json index c3b22403495..d3ab5df3b2f 100644 --- a/lib/platform-bible-utils/typedoc.json +++ b/lib/platform-bible-utils/typedoc.json @@ -11,5 +11,20 @@ "rewrittenLink": true, "unusedMergeModuleWith": true }, + "highlightLanguages": [ + "bash", + "console", + "css", + "html", + "javascript", + "json", + "jsonc", + "json5", + "yaml", + "tsx", + "typescript", + "xml" + ], + "ignoredHighlightLanguages": ["usfm"], "requiredToBeDocumented": ["Enum", "Variable", "Function", "Class", "Interface", "Method"] }