/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
import { ClientVersionDispatchingCodecBuilder, FluidClientVersion, makeDiscontinuedCodecAndSchema, } from "../codec/index.js";
import { makeV1toV4andV6CodecWithVersion } from "./editManagerCodecsV1toV4.js";
import { makeSharedBranchesCodecWithVersion } from "./editManagerCodecsVSharedBranches.js";
import { EditManagerFormatVersion } from "./editManagerFormatCommons.js";
/**
 * Codec name used to identify the {@link EditManager} codec, see {@link makeEditManagerCodecBuilder}.
 */
export const editManagerCodecName = "EditManager";
/**
 * Creates a {@link ClientVersionDispatchingCodecBuilder} encoding for {@link SummaryData}.
 */
export function makeEditManagerCodecBuilder() {
    // See EditManagerFormatVersion and its members for documentation on what changed in each version.
    const versions = [
        makeDiscontinuedCodecAndSchema(EditManagerFormatVersion.v1, "2.73.0"),
        makeDiscontinuedCodecAndSchema(EditManagerFormatVersion.v2, "2.73.0"),
        {
            minVersionForCollab: lowestMinVersionForCollab,
            formatVersion: EditManagerFormatVersion.v3,
            codec: (options) => makeV1toV4andV6CodecWithVersion(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(EditManagerFormatVersion.v3)), options.revisionTagCodec, EditManagerFormatVersion.v3),
        },
        {
            minVersionForCollab: FluidClientVersion.v2_43,
            formatVersion: EditManagerFormatVersion.v4,
            codec: (options) => makeV1toV4andV6CodecWithVersion(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(EditManagerFormatVersion.v4)), options.revisionTagCodec, EditManagerFormatVersion.v4),
        },
        makeDiscontinuedCodecAndSchema(EditManagerFormatVersion.v5, "2.74.0"),
        {
            minVersionForCollab: FluidClientVersion.v2_80,
            formatVersion: EditManagerFormatVersion.v6,
            codec: (options) => makeV1toV4andV6CodecWithVersion(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(EditManagerFormatVersion.v6)), options.revisionTagCodec, EditManagerFormatVersion.v6),
        },
        {
            minVersionForCollab: undefined,
            formatVersion: EditManagerFormatVersion.vSharedBranches,
            codec: (options) => makeSharedBranchesCodecWithVersion(options.changeCodecs.resolve(options.dependentChangeFormatVersion.lookup(EditManagerFormatVersion.vSharedBranches)), options.revisionTagCodec, EditManagerFormatVersion.vSharedBranches),
        },
    ];
    return ClientVersionDispatchingCodecBuilder.build(editManagerCodecName, versions);
}
/**
 * Returns a {@link CodecTree} for the EditManager format at the given client version,
 * with the provided change codec tree as a child.
 */
export function getCodecTreeForEditManagerFormatWithChange(clientVersion, changeFormat) {
    const builder = makeEditManagerCodecBuilder();
    return {
        ...builder.getCodecTree(clientVersion),
        children: [changeFormat],
    };
}
//# sourceMappingURL=editManagerCodecs.js.map