/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { OpSpaceCompressedId, SessionId, SessionSpaceCompressedId } from "@fluidframework/id-compressor";
import { type Brand, type NestedMap, type RangeMap } from "../../util/index.js";
import type { TaggedChange } from "./changeRebaser.js";
/**
 * The identifier for a particular session/user/client that can generate `GraphCommit`s
 */
export declare const SessionIdSchema: import("@sinclair/typebox").TUnsafe<SessionId>;
/**
 * A unique identifier for a commit. Commits that have been rebased, but are semantically
 * the same, will share the same revision tag.
 *
 * The constant 'root' is reserved for the trunk base: minting a SessionSpaceCompressedId is not
 * possible on readonly clients. These clients generally don't need ids, but  must be done at tree initialization time.
 * @internal
 */
export type RevisionTag = SessionSpaceCompressedId | "root";
export type EncodedRevisionTag = Brand<OpSpaceCompressedId, "EncodedRevisionTag"> | "root";
export declare const RevisionTagSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"root">, import("@sinclair/typebox").TUnsafe<Brand<OpSpaceCompressedId, "EncodedRevisionTag">>]>;
/**
 * An ID which is unique within a revision of a `ModularChangeset`.
 * A `ModularChangeset` which is a composition of multiple revisions may contain duplicate `ChangesetLocalId`s,
 * but they are unique when qualified by the revision of the change they are used in.
 * @internal
 */
export type ChangesetLocalId = Brand<number, "ChangesetLocalId">;
/**
 * A globally unique ID for an atom of change, or a node associated with the atom of change.
 * @internal
 *
 * @privateRemarks
 * TODO: Rename this to be more general.
 */
export interface ChangeAtomId {
    /**
     * Uniquely identifies the changeset within which the change was made.
     * Only undefined when referring to an anonymous changesets.
     */
    readonly revision?: RevisionTag;
    /**
     * Uniquely identifies, in the scope of the changeset, the change made to the field.
     */
    readonly localId: ChangesetLocalId;
}
export type EncodedChangeAtomId = [ChangesetLocalId, EncodedRevisionTag] | ChangesetLocalId;
/**
 * @internal
 */
export type ChangeAtomIdMap<T> = NestedMap<RevisionTag | undefined, ChangesetLocalId, T>;
/**
 * @internal
 */
export type ChangeAtomIdRangeMap<T> = Map<RevisionTag | undefined, RangeMap<T>>;
/**
 * @returns true iff `a` and `b` are the same.
 */
export declare function areEqualChangeAtomIds(a: ChangeAtomId, b: ChangeAtomId): boolean;
/**
 * @returns a ChangeAtomId with the given revision and local ID.
 */
export declare function makeChangeAtomId(localId: ChangesetLocalId, revision?: RevisionTag): ChangeAtomId;
export declare function asChangeAtomId(id: ChangesetLocalId | ChangeAtomId): ChangeAtomId;
export declare function taggedAtomId(id: ChangeAtomId, revision: RevisionTag | undefined): ChangeAtomId;
export declare function taggedOptAtomId(id: ChangeAtomId | undefined, revision: RevisionTag | undefined): ChangeAtomId | undefined;
export declare function offsetChangeAtomId(id: ChangeAtomId, offset: number): ChangeAtomId;
export declare function replaceAtomRevisions(id: ChangeAtomId, oldRevisions: Set<RevisionTag | undefined>, newRevision: RevisionTag | undefined): ChangeAtomId;
/**
 * A node in a graph of commits. A commit's parent is the commit on which it was based.
 */
export interface GraphCommit<TChange> {
    /** The tag for this commit. If this commit is rebased, the corresponding rebased commit will retain this tag. */
    readonly revision: RevisionTag;
    /** The change that will result from applying this commit */
    readonly change: TChange;
    /** The parent of this commit, on whose change this commit's change is based */
    readonly parent?: GraphCommit<TChange>;
    /** The rollback of this commit */
    rollback?: TaggedChange<TChange, RevisionTag>;
}
/**
 * The type of a commit. This is used to describe the context in which the commit was created.
 *
 * @public
 */
export declare enum CommitKind {
    /** A commit corresponding to a change that is not the result of an undo/redo. */
    Default = 0,
    /** A commit that is the result of an undo. */
    Undo = 1,
    /** A commit that is the result of a redo. */
    Redo = 2
}
/**
 * Information about a commit that has been applied.
 *
 * @sealed @public
 */
export interface CommitMetadata {
    /**
     * A {@link CommitKind} enum value describing whether the commit represents an Edit, an Undo, or a Redo.
     */
    readonly kind: CommitKind;
    /**
     * Indicates whether the commit is a local edit
     */
    readonly isLocal: boolean;
}
/**
 * Creates a new graph commit object. This is useful for creating copies of commits with different parentage.
 * @param parent - the parent of the new commit
 * @param commit - the contents of the new commit object
 * @returns the new commit object
 */
export declare function mintCommit<TChange>(parent: GraphCommit<TChange>, commit: Omit<GraphCommit<TChange>, "parent">): GraphCommit<TChange>;
export declare function replaceChange<TChange>(commit: GraphCommit<TChange>, change: TChange): GraphCommit<TChange>;
//# sourceMappingURL=types.d.ts.map