/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Type } from "@sinclair/typebox";
import { RevisionTagSchema, SessionIdSchema, } from "../core/index.js";
import { brandedNumberType } from "../util/index.js";
const noAdditionalProps = { additionalProperties: false };
// Many of the return types in this module are intentionally derived, rather than explicitly specified.
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const CommitBase = (tChange) => Type.Object({
    revision: RevisionTagSchema,
    change: tChange,
    sessionId: SessionIdSchema,
});
/**
 * @privateRemarks Commits are generally encoded from `GraphCommit`s, which often contain extra data.
 * This `noAdditionalProps` is especially important in that light.
 */
const Commit = (tChange) => Type.Composite([CommitBase(tChange)], noAdditionalProps);
const SeqNumber = brandedNumberType({ multipleOf: 1 });
const SequenceId = Type.Object({
    sequenceNumber: SeqNumber,
    indexInBatch: Type.Optional(Type.Number({ multipleOf: 1, minimum: 0 })),
});
export const SequencedCommit = (tChange) => Type.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);
export const SummarySessionBranch = (tChange) => Type.Object({
    base: RevisionTagSchema,
    commits: Type.Array(Commit(tChange)),
}, noAdditionalProps);
export const EncodedSharedBranch = (tChange) => Type.Object({
    id: Type.Optional(Type.Number()),
    name: Type.Optional(Type.String()),
    session: Type.Optional(SessionIdSchema),
    author: Type.Optional(Type.String()),
    base: Type.Optional(RevisionTagSchema),
    trunk: Type.Array(SequencedCommit(tChange)),
    peers: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
}, noAdditionalProps);
/* eslint-enable @typescript-eslint/explicit-function-return-type */
//# sourceMappingURL=editManagerFormatCommons.js.map