/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ChangeFamily, ChangeFamilyEditor } from "../change-family";
import { GraphCommit } from "../rebase";
import { ReadonlyRepairDataStore } from "../repair";
import { IRepairDataStoreProvider } from "./repairDataStoreProvider";
/**
 * Manages a branch of the undoable/redoable commit trees and repair data associated with the undoable and redoable commits.
 */
export declare class UndoRedoManager<TChange, TEditor extends ChangeFamilyEditor> {
    readonly repairDataStoreProvider: IRepairDataStoreProvider;
    private readonly changeFamily;
    private readonly getHead?;
    private headUndoableCommit?;
    private headRedoableCommit?;
    /**
     * @param repairDataStoryFactory - Factory for creating {@link RepairDataStore}s to create and store repair
     * data for {@link ReversibleCommit}s.
     * @param changeFamily - {@link ChangeFamily} used for inverting changes.
     * @param getHead - Function for retrieving the head commit of the branch associated with this undo redo manager.
     * @param headUndoableCommit - Optional commit to set as the initial undoable commit.
     * @param headRedoableCommit - Optional commit to set as the initial redoable commit.
     */
    constructor(repairDataStoreProvider: IRepairDataStoreProvider, changeFamily: ChangeFamily<TEditor, TChange>, getHead?: (() => GraphCommit<TChange>) | undefined, headUndoableCommit?: ReversibleCommit<TChange> | undefined, headRedoableCommit?: ReversibleCommit<TChange> | undefined);
    get headUndoable(): ReversibleCommit<TChange> | undefined;
    get headRedoable(): ReversibleCommit<TChange> | undefined;
    /**
     * Adds the provided commit to the undo or redo commit tree, depending on the type of commit it is.
     * Should be called for all commits on the relevant branch, including undo and redo commits.
     */
    trackCommit(commit: GraphCommit<TChange>, type: UndoRedoManagerCommitType): void;
    /**
     * Inverts the head undoable commit and returns the inverted change.
     * This change can then be applied and tracked.
     */
    undo(): TChange | undefined;
    /**
     * Inverts the head redoable commit and returns the inverted change.
     * This change can then be applied and tracked.
     */
    redo(): TChange | undefined;
    private createInvertedChange;
    /**
     * Creates a copy of this `UndoRedoManager`.
     * @param getHead - Optional function to use for retrieving the head commit for the branch associated with the
     * the new {@link UndoRedoManager}. If one is not provided, the one from this {@link UndoRedoManager} will be used.
     * @param repairDataStoreProvider - Optional {@link IRepairDataStoreProvider} to use for the new {@link UndoRedoManager}.
     * If one is not provided, the `repairDataStoreProvider` of this {@link UndoRedoManager} will be cloned.
     * @param headUndoableCommit - Optional head undoable commit, if one is not provided the head undoable commit
     * of this {@link UndoRedoManager} will be used.
     */
    clone(getHead?: () => GraphCommit<TChange>, repairDataStoreProvider?: IRepairDataStoreProvider, headUndoableCommit?: ReversibleCommit<TChange>, headRedoableCommit?: ReversibleCommit<TChange>): UndoRedoManager<TChange, TEditor>;
    /**
     * Updates the state of this {@link UndoRedoManager} to correctly reference commits that have been rebased after merging.
     * @param newHead - the head commit of the newly rebased branch.
     * @param mergedUndoRedoManager - the {@link UndoRedoManager} of the branch that was merged.
     */
    updateAfterMerge(newHead: GraphCommit<TChange>, mergedUndoRedoManager: UndoRedoManager<TChange, TEditor>): void;
    /**
     * Updates the state of this {@link UndoRedoManager} to correctly reference commits that have been rebased.
     * @param newHead - the head commit of the newly rebased branch.
     * @param baseUndoRedoManager - the {@link UndoRedoManager} of the branch that was rebased onto
     */
    updateAfterRebase(newHead: GraphCommit<TChange>, baseUndoRedoManager: UndoRedoManager<TChange, TEditor>): void;
    private updateBasedOnNewCommits;
}
/**
 * Represents a commit that can be undone.
 */
export interface ReversibleCommit<TChange> {
    readonly commit: GraphCommit<TChange>;
    readonly repairData: ReadonlyRepairDataStore;
    readonly parent?: ReversibleCommit<TChange>;
}
/**
 * The type of a commit in the context of undo/redo manager.
 */
export declare enum UndoRedoManagerCommitType {
    Undoable = 0,
    Redoable = 1,
    Undo = 2,
    Redo = 3
}
/**
 * Marks the commits in the provided path as undoable or redoable.
 * @param path - the path of commits that may or may not be undoable or redoable.
 * @param headUndoableCommit - the head undoable commit of the undo commit tree that may contain the commits in the path.
 * @param headRedoableCommit - the head redoable commit of the redo commit tree that may contain the commits in the path.
 */
export declare function markCommits<TChange>(path: GraphCommit<TChange>[], headUndoableCommit?: ReversibleCommit<TChange>, headRedoableCommit?: ReversibleCommit<TChange>): {
    commit: GraphCommit<TChange>;
    undoRedoManagerCommitType?: UndoRedoManagerCommitType;
}[];
//# sourceMappingURL=undoRedoManager.d.ts.map