/** * accept_ai_edits — selective accept/reject of tracked changes by revision id or * author (#123). * * The strongest argument for tracked-changes-as-canonical (#118/#120) is that * acceptance can target only the AI actor's revisions, leaving any pre-existing * third-party tracked changes byte-untouched. This module resolves a target set * of revision ids (directly, or from an author string), refuses ambiguous * overlaps by default, and drives the existing (whole-document) accept/reject * engines through a revision-id filter so only the targeted revisions are * resolved. * * Ambiguity: OOXML permits — but Word does not define behavior for — a revision * of one actor structurally containing a revision of another (nested * `w:ins`/`w:del`/`w:moveFrom`/`w:moveTo`). Selective accept/reject is defined * only on a normalized, non-overlapping revision graph; the ambiguous case * hard-errors with a structured list of the offending pairs unless the caller * opts into `normalizeFirst` (best-effort, no byte-identical promise). */ import { type AcceptChangesResult, type RevisionFilter } from './accept_changes.js'; import { type RejectChangesResult } from './reject_changes.js'; /** Selector for a selective accept/reject operation. */ export interface AiEditSelector { /** Explicit `w:id` values to target (strings or numbers). Primary signature. */ revisionIds?: Array; /** Convenience: resolve every revision authored by this `w:author` to its id. */ author?: string; /** * Opt in to best-effort operation on an ambiguous (overlapping) graph instead * of hard-erroring. Foreign revisions are still left in place, but byte-identical * preservation is not promised in ambiguous cases. */ normalizeFirst?: boolean; } /** One offending pair where a targeted revision overlaps a non-targeted one. */ export interface AiRevisionOverlap { outerId: string | null; outerLocalName: string; outerAuthor: string | null; innerId: string | null; innerLocalName: string; innerAuthor: string | null; } /** Thrown when selective accept/reject would touch an ambiguous revision graph. */ export declare class AmbiguousRevisionOverlapError extends Error { readonly code = "AMBIGUOUS_REVISION_OVERLAP"; readonly overlaps: AiRevisionOverlap[]; constructor(overlaps: AiRevisionOverlap[]); } export interface SelectiveAcceptResult { result: AcceptChangesResult; selectedIds: string[]; overlaps: AiRevisionOverlap[]; } export interface SelectiveRejectResult { result: RejectChangesResult; selectedIds: string[]; overlaps: AiRevisionOverlap[]; } /** Every tracked-change element under `root` (any revision type). */ export declare function collectRevisionElements(root: Element | Document): Element[]; /** * Resolve the target revision-id set from a selector, given the revision * elements available across all stories. `revisionIds` wins when provided; * otherwise `author` resolves to the ids of every revision it authored. */ export declare function resolveSelectedIds(revisionElements: Element[], selector: AiEditSelector): Set; /** * Find ambiguous overlaps within a single story: a targeted content-wrapper * revision that structurally contains — or is contained by — a non-targeted * content-wrapper revision. */ export declare function detectAmbiguousOverlaps(root: Element | Document, selectedIds: Set): AiRevisionOverlap[]; /** Build a revision filter that matches exactly the selected ids. */ export declare function selectedIdFilter(selectedIds: Set): RevisionFilter; /** * Accept only the targeted revisions in a single story `doc`, leaving all other * revisions byte-untouched. Hard-errors on an ambiguous overlap unless * `normalizeFirst` is set. Mutates `doc` in place. */ export declare function acceptAIEdits(doc: Document, selector: AiEditSelector): SelectiveAcceptResult; /** * Reject only the targeted revisions in a single story `doc`, leaving all other * revisions byte-untouched. Symmetric to {@link acceptAIEdits}. */ export declare function rejectAIEdits(doc: Document, selector: AiEditSelector): SelectiveRejectResult; //# sourceMappingURL=accept_ai_edits.d.ts.map