/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Type } from "@sinclair/typebox";
import { brandedNumberType, brandedStringType, } from "../../util/index.js";
/**
 * The identifier for a particular session/user/client that can generate `GraphCommit`s
 */
export const SessionIdSchema = brandedStringType();
export const RevisionTagSchema = Type.Union([
    Type.Literal("root"),
    brandedNumberType(),
]);
/**
 * @returns true iff `a` and `b` are the same.
 */
export function areEqualChangeAtomIds(a, b) {
    return a.localId === b.localId && a.revision === b.revision;
}
/**
 * @returns a ChangeAtomId with the given revision and local ID.
 */
export function makeChangeAtomId(localId, revision) {
    return revision === undefined ? { localId } : { localId, revision };
}
export function asChangeAtomId(id) {
    return typeof id === "object" ? id : { localId: id };
}
/**
 * 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
 */
// Note that this function is synchronous, and therefore it is not a Promise.
// However, it is still a strong commit-mint.
export function mintCommit(parent, commit) {
    const { revision, change } = commit;
    return {
        revision,
        change,
        parent,
    };
}
//# sourceMappingURL=types.js.map