"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.EncodedEditManager = exports.version = void 0;
const typebox_1 = require("@sinclair/typebox");
const index_js_1 = require("../util/index.js");
const index_js_2 = require("../core/index.js");
const noAdditionalProps = { additionalProperties: false };
const CommitBase = (tChange) => typebox_1.Type.Object({
    revision: index_js_2.RevisionTagSchema,
    change: tChange,
    sessionId: index_js_2.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) => typebox_1.Type.Composite([CommitBase(tChange)], noAdditionalProps);
const SeqNumber = (0, index_js_1.brandedNumberType)({ multipleOf: 1 });
const SequenceId = typebox_1.Type.Object({
    sequenceNumber: SeqNumber,
    indexInBatch: typebox_1.Type.Optional(typebox_1.Type.Number({ multipleOf: 1, minimum: 0 })),
});
const SequencedCommit = (tChange) => typebox_1.Type.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);
const SummarySessionBranch = (tChange) => typebox_1.Type.Object({
    base: index_js_2.RevisionTagSchema,
    commits: typebox_1.Type.Array(Commit(tChange)),
}, noAdditionalProps);
exports.version = 1.0;
const EncodedEditManager = (tChange) => typebox_1.Type.Object({
    version: typebox_1.Type.Literal(exports.version),
    trunk: typebox_1.Type.Array(SequencedCommit(tChange)),
    branches: typebox_1.Type.Array(typebox_1.Type.Tuple([index_js_2.SessionIdSchema, SummarySessionBranch(tChange)])),
}, noAdditionalProps);
exports.EncodedEditManager = EncodedEditManager;
//# sourceMappingURL=editManagerFormat.js.map