import type { DraftTimelineAnnotation } from "@opengeni/sdk"; import type { TimelineAnnotationSourceDescriptor } from "./types.js"; /** Bytes of source text kept on each side of a quote. */ export declare const ANNOTATION_SOURCE_CONTEXT_BYTES = 160; /** Longest quote an annotation may carry. */ export declare const ANNOTATION_MAX_QUOTE_BYTES: number; /** Longest note an annotation may carry (characters). */ export declare const ANNOTATION_MAX_NOTE_LENGTH = 2048; export declare function annotationHasNote(note: string): boolean; export declare function annotationDisplayOrdinal(annotation: { readonly id?: string; readonly ordinal?: number | undefined; }, index: number): number; export declare function truncateAnnotationQuote(quote: string, maxChars?: number): string; export declare function occurrenceOffsets(text: string, quote: string): number[]; /** * The part of a rendered selection that appears verbatim in the source text. * Rendered text drops markdown syntax, so a selection across formatting falls * back to its longest matching prefix, then suffix (at least 8 characters). */ export declare function matchingQuoteInSource(sourceText: string, quote: string): string | null; export declare function utf8ByteLength(value: string): number; export declare function utf8Prefix(value: string, maxBytes: number): string; export declare function utf8Suffix(value: string, maxBytes: number): string; /** * Which occurrence of `quote` in `sourceText` a selection meant, judged by the * rendered text around the selection. Markdown syntax breaks exact matches, * so the occurrence whose neighbouring characters agree longest wins. */ export declare function bestQuoteOccurrence(sourceText: string, quote: string, offsets: readonly number[], textBefore: string, textAfter: string): number; export type AnnotationSelection = { /** The selected text as rendered. */ text: string; /** * Which occurrence of the quote in the source was selected, when the * renderer can count it; otherwise the surrounding rendered text decides. */ occurrence?: number | undefined; /** Rendered text just before the selection (used when `occurrence` is unknown). */ textBefore?: string | undefined; /** Rendered text just after the selection. */ textAfter?: string | undefined; }; /** * A draft annotation for a selection inside `source`, or null when nothing * selected is in the source text or the quote is empty or too long. */ export declare function annotationFromSelection(source: TimelineAnnotationSourceDescriptor, selection: AnnotationSelection, id?: string): DraftTimelineAnnotation | null;