import { Document } from '../../core/models/Document';
/**
 * Constructor.
 * @param {Document} document
 * @class
 * @author eric.wittmann@gmail.com
 */
export declare class OtEngine {
    pendingCommands: Array<OtCommand>;
    commands: Array<OtCommand>;
    document: Document;
    pendingUndos: Array<number>;
    constructor(document: Document);
    /**
     * Gets the current document.
     * @return {Document} {OasDocument}
     */
    getCurrentDocument(): Document;
    /**
     * Returns true if there is at least one pending command in the engine.  A pending command is one
     * that has not yet been finalized.  This typically means that the command has been applied to
     * the local document but not persisted in some remote store.
     * @return {boolean} {boolean}
     */
    hasPendingCommands(): boolean;
    /**
     * Returns true if the OT engine has already seen the given command.
     * @param {OtCommand} command
     * @return {boolean}
     */
    hasCommand(command: OtCommand): boolean;
    /**
     * Executes the given command in the correct sequence.  This command must have a valid
     * finalized contentVersion property.  This property will determine where in the sequence
     * of commands this one falls.  The engine will revert the document to an appropriate state
     * so that the command can be executed in the correct order.  During this process, existing
     * commands may need to be undone and then re-executed after.
     *
     * Here's what happens when executing a command:
     *
     * 1) "undo" all pending commands, since those are always executed last
     * 2) identify the insertion point of the command in the finalized command queue
     * 3) "undo" all finalized commands that fall AFTER this command in the finalized command queue
     * 4) execute this command and insert it into the finalized command queue
     * 5) re-execute all finalized commands that were undone in step #3
     * 6) re-execute all pending commands
     * 7) profit!
     *
     * A future optimization of this algorithm is to only undo/redo the commands that conflict
     * with this command.  This will avoid unnecessary work (why bother undoing/redoing when
     * there is no potential for a conflict in the document).  This optimization can be achieved
     * by ensuring that each command has a list of NodePaths that represent the affected parts of
     * the document tree.  These paths can be used to determine which commands conflict with
     * other commands.
     *
     * Whenever a command is executed, any local commands that have been undone can now be
     * safely removed from the list of commands, because making a change (by definition) orphans
     * any existing reverted commands.  There is no way to recover them.
     *
     * @param {OtCommand} command
     * @param {boolean} pending
     */
    executeCommand(command: OtCommand, pending: boolean): void;
    /**
     * Moves a commands from the "pending" queue to the "finalized" command queue.  This occurs
     * when a local (aka pending) command is acknowledged by the coordinating server and assigned
     * a final content version.  The engine must remove the command from the pending queue, update
     * its contentVersion, and then insert it at the correct location in the finalized queue.
     *
     * Here's what happens when finalizing a command:
     *
     * 1) "undo" all pending commands, shrinking the pending command queue to 0
     * 2) update the given pending command's contentVersion
     * 3) call "executeCommand()" with the newly finalized command
     * 4) re-execute all remaining pending commands
     *
     * @param {number} pendingCommandId
     * @param {number} finalizedContentVersion
     */
    finalizeCommand(pendingCommandId: number, finalizedContentVersion: number): void;
    /**
     * Called to undo the last local command.  Returns the command that was undone (on success)
     * or null if there was no command to undo.
     * @return {OtCommand}
     */
    undoLastLocalCommand(): OtCommand;
    /**
     * Called to redo the last "undone" local command.  Returns the command that was redone (on success)
     * or null if there was no command to redo.
     * @return {OtCommand}
     */
    redoLastLocalCommand(): OtCommand;
    /**
     * Called to undo a specific command by its contentVersion identifier.  Note: this will never
     * be invoked for a pending command (pending commands don't have content versions yet).
     * @param {number} contentVersion
     * @return {OtCommand}
     */
    undo(contentVersion: number): OtCommand;
    /**
     * Called to redo a specific command by its contentVersion identifier.
     * @param {number} contentVersion
     * @return {OtCommand}
     */
    redo(contentVersion: number): OtCommand;
    /**
     * Called to remove any (local only) commands that have been undone/reverted.  This is
     * done whenever a new local command is executed.  It is done because when a new command
     * is executed, any existing reverted commands can no longer be "redone".
     */
    pruneRevertedCommands(): void;
}
import { OtCommand } from './OtCommand';
