"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeSchemaChangeCodec = void 0;
const internal_1 = require("@fluidframework/core-utils/internal");
const index_js_1 = require("../schema-index/index.js");
const schemaChangeFormat_js_1 = require("./schemaChangeFormat.js");
/**
 * Creates a codec for schema changes.
 * @param options - The codec options.
 * @returns The composed schema change codec part.
 */
function makeSchemaChangeCodec(options) {
    const schemaCodec = index_js_1.schemaCodecBuilder.build(options);
    return {
        encode: (schemaChange) => {
            (0, internal_1.assert)(!schemaChange.isInverse, 0x933 /* Inverse schema changes should never be transmitted */);
            return {
                new: schemaCodec.encode(schemaChange.schema.new),
                old: schemaCodec.encode(schemaChange.schema.old),
            };
        },
        decode: (encoded) => {
            return {
                schema: {
                    new: schemaCodec.decode(encoded.new),
                    old: schemaCodec.decode(encoded.old),
                },
                isInverse: false,
            };
        },
        encodedSchema: schemaChangeFormat_js_1.EncodedSchemaChange,
    };
}
exports.makeSchemaChangeCodec = makeSchemaChangeCodec;
//# sourceMappingURL=schemaChangeCodecs.js.map