import type { DraftTimelineAnnotation } from "@opengeni/sdk"; import type { TimelineAnnotationSourceDescriptor } from "./types.js"; import { type TextSpan } from "./annotation-alignment.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. * Falls back to the longest matching prefix, then suffix (at least 8 * characters), for text whose rendering differs from its source (such as math). */ 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; /** `bestQuoteOccurrence` for spans of source text that may differ in length. */ export declare function bestSpanOccurrence(sourceText: string, spans: readonly TextSpan[], textBefore: string, textAfter: string): number; export type AnnotationSelection = { /** The selected text as rendered. */ text: string; /** * Which occurrence of the selected text in the rendered message 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. * * The quote is the exact source text behind the selection. A selection that * crosses formatting (bold, links, list items) maps to the markdown that * renders it, so the whole selection is kept rather than just a plain part. */ export declare function annotationFromSelection(source: TimelineAnnotationSourceDescriptor, selection: AnnotationSelection, id?: string): DraftTimelineAnnotation | null; /** * The text an annotation's quote shows as. Quotes of messages are markdown * source, so they are shown the way the message renders them; tool output is * shown as is. */ export declare function annotationQuoteText(annotation: { readonly quote: string; readonly source: { readonly kind: TimelineAnnotationSourceDescriptor["kind"]; }; }): string;