"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModularChangeFormatVersion = exports.makeModularChangeCodecFamily = void 0;
const internal_1 = require("@fluidframework/core-utils/internal");
const index_js_1 = require("../../codec/index.js");
const index_js_2 = require("../../util/index.js");
const treeCompressionUtils_js_1 = require("../treeCompressionUtils.js");
const modularChangeCodecV1_js_1 = require("./modularChangeCodecV1.js");
const modularChangeCodecV2_js_1 = require("./modularChangeCodecV2.js");
function makeModularChangeCodecFamily(fieldKindConfigurations, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy = treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed) {
    return (0, index_js_1.makeCodecFamily)(Array.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => {
        switch (version) {
            case exports.ModularChangeFormatVersion.v3:
            case exports.ModularChangeFormatVersion.v4: {
                return [
                    version,
                    (0, modularChangeCodecV1_js_1.makeModularChangeCodecV1)(fieldKinds, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy),
                ];
            }
            case exports.ModularChangeFormatVersion.v5: {
                return [
                    version,
                    (0, modularChangeCodecV2_js_1.makeModularChangeCodecV2)(fieldKinds, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy),
                ];
            }
            default: {
                (0, internal_1.fail)(0xcc5 /* Unsupported modular change codec version */);
            }
        }
    }));
}
exports.makeModularChangeCodecFamily = makeModularChangeCodecFamily;
/**
 * The format version for `ModularChangeset`.
 */
exports.ModularChangeFormatVersion = (0, index_js_2.strictEnum)("ModularChangeFormatVersion", {
    /**
     * Introduced prior to 2.0 and used beyond.
     * Reading capability must be maintained for backwards compatibility.
     * Writing capability needs to be maintained so long as {@link lowestMinVersionForCollab} is less than 2.2.0.
     */
    v3: 3,
    /**
     * Introduced in 2.2.0.
     * Was inadvertently made usable for writing in 2.43.0 (through configuredSharedTree) and remains available.
     * Reading capability must be maintained for backwards compatibility.
     * Writing capability could be dropped in favor of {@link ModularChangeFormatVersion.v3},
     * but doing so would make the pattern of writable versions more complex and gain little
     * because the logic for this format is shared with {@link ModularChangeFormatVersion.v3}.
     */
    v4: 4,
    /**
     * Introduced and made available for writing in 2.80.0
     * Adds support for "no change" constraints.
     */
    v5: 5,
});
//# sourceMappingURL=modularChangeCodecs.js.map