/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 *
 * @typedef {'paired' | 'independent'} ReplacementsMode
 * @typedef {'insertion' | 'deletion' | 'formatting'} ParentSide
 *
 * @typedef {{
 *   logicalId: string,
 *   side: ParentSide,
 *   sourceId: string,
 *   author: string,
 *   date: string,
 * }} ParentFrame
 *
 * @typedef {(
 *   | 'IMPORT_UNSUPPORTED_STRUCTURAL_OVERLAP'
 *   | 'IMPORT_MISSING_AUTHOR_IDENTITY'
 *   | 'IMPORT_HEURISTIC_RECONSTRUCTION'
 *   | 'IMPORT_REPLACEMENT_MISSING_SIDE'
 *   | 'IMPORT_CHILD_MISSING_PARENT'
 *   | 'IMPORT_DUPLICATE_LOGICAL_ID'
 *   | 'EXPORT_FALLBACK_LOSSY'
 * )} ImportDiagnosticCode
 *
 * @typedef {{
 *   code: ImportDiagnosticCode,
 *   partPath: string,
 *   logicalId?: string,
 *   parentLogicalId?: string,
 *   sourceId?: string,
 *   side?: ParentSide,
 *   message?: string,
 *   detail?: Record<string, unknown>,
 * }} ImportDiagnostic
 *
 * @typedef {{
 *   partPath: string,
 *   replacements: ReplacementsMode,
 *   parentStack: () => ReadonlyArray<ParentFrame>,
 *   currentParent: () => ParentFrame | null,
 *   pushParent: (frame: ParentFrame) => void,
 *   popParent: () => ParentFrame | null,
 *   reportDiagnostic: (d: ImportDiagnostic) => void,
 *   diagnostics: () => ReadonlyArray<ImportDiagnostic>,
 *   recordLogicalId: (id: string, source: { sourceId?: string, side?: ParentSide }) => void,
 *   hasLogicalId: (id: string) => boolean,
 *   forNestedPart: (partPath: string) => ImportTrackingContext,
 * }} ImportTrackingContext
 */
/**
 * @param {{
 *   partPath?: string,
 *   replacements?: ReplacementsMode,
 *   diagnostics?: ImportDiagnostic[],
 *   knownLogicalIds?: Map<string, { sourceId?: string, side?: ParentSide, sides?: Set<ParentSide> }>,
 * }} [options]
 * @returns {ImportTrackingContext}
 */
export function createImportTrackingContext(options?: {
    partPath?: string;
    replacements?: ReplacementsMode;
    diagnostics?: ImportDiagnostic[];
    knownLogicalIds?: Map<string, {
        sourceId?: string;
        side?: ParentSide;
        sides?: Set<ParentSide>;
    }>;
}): ImportTrackingContext;
/**
 * Convenience helper that wraps a recursive descent, ensuring `popParent`
 * runs even when the body throws. Used by the tracked-change translator
 * integration helpers.
 *
 * @template T
 * @param {ImportTrackingContext} ctx
 * @param {ParentFrame} frame
 * @param {() => T} body
 * @returns {T}
 */
export function withParentFrame<T>(ctx: ImportTrackingContext, frame: ParentFrame, body: () => T): T;
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ReplacementsMode = "paired" | "independent";
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ParentSide = "insertion" | "deletion" | "formatting";
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ParentFrame = {
    logicalId: string;
    side: ParentSide;
    sourceId: string;
    author: string;
    date: string;
};
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ImportDiagnosticCode = ("IMPORT_UNSUPPORTED_STRUCTURAL_OVERLAP" | "IMPORT_MISSING_AUTHOR_IDENTITY" | "IMPORT_HEURISTIC_RECONSTRUCTION" | "IMPORT_REPLACEMENT_MISSING_SIDE" | "IMPORT_CHILD_MISSING_PARENT" | "IMPORT_DUPLICATE_LOGICAL_ID" | "EXPORT_FALLBACK_LOSSY");
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ImportDiagnostic = {
    code: ImportDiagnosticCode;
    partPath: string;
    logicalId?: string;
    parentLogicalId?: string;
    sourceId?: string;
    side?: ParentSide;
    message?: string;
    detail?: Record<string, unknown>;
};
/**
 * Importer tracking context for DOCX tracked-change overlap.
 *
 * The current `w:ins`/`w:del`/`w:rPrChange` translators receive an
 * `insideTrackChange` boolean. That's enough to decide that a nested change
 * exists, but it carries no information about the parent's logical id, side,
 * or part path. The import pipeline needs all of that to stamp `overlapParentId` and to
 * report diagnostics when the imported OOXML shape cannot reconstruct the
 * full internal graph.
 *
 * Usage:
 *   const ctx = createImportTrackingContext({
 *     partPath: 'word/document.xml',
 *     replacements: 'paired',
 *   });
 *
 *   ctx.pushParent({ logicalId, side, sourceId, author, date });
 *   // ... descend into nested element ...
 *   ctx.popParent();
 *
 *   ctx.reportDiagnostic({ code: 'IMPORT_MISSING_REPLACEMENT_SIDE', ...details });
 *
 * The context is intentionally lightweight: it does not own the PM document
 * and does not allocate ids. The translators continue to call
 * `buildTrackedChangeIdMap`; the context only adds parent-stack and
 * diagnostics surfaces that the legacy translator code lacked.
 */
export type ImportTrackingContext = {
    partPath: string;
    replacements: ReplacementsMode;
    parentStack: () => ReadonlyArray<ParentFrame>;
    currentParent: () => ParentFrame | null;
    pushParent: (frame: ParentFrame) => void;
    popParent: () => ParentFrame | null;
    reportDiagnostic: (d: ImportDiagnostic) => void;
    diagnostics: () => ReadonlyArray<ImportDiagnostic>;
    recordLogicalId: (id: string, source: {
        sourceId?: string;
        side?: ParentSide;
    }) => void;
    hasLogicalId: (id: string) => boolean;
    forNestedPart: (partPath: string) => ImportTrackingContext;
};
//# sourceMappingURL=import-context.d.ts.map