"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeGenericChangeCodec = void 0;
const index_js_1 = require("../../codec/index.js");
const genericFieldKindFormat_js_1 = require("./genericFieldKindFormat.js");
const modularChangeFormat_js_1 = require("./modularChangeFormat.js");
function makeGenericChangeCodec() {
    return (0, index_js_1.makeCodecFamily)([[1, makeV1Codec()]]);
}
exports.makeGenericChangeCodec = makeGenericChangeCodec;
function makeV1Codec() {
    return {
        encode: (change, context) => {
            const encoded = change.map(({ index, nodeChange }) => [
                index,
                context.encodeNode(nodeChange),
            ]);
            return encoded;
        },
        decode: (encoded, context) => {
            return encoded.map(([index, nodeChange]) => ({
                index,
                nodeChange: context.decodeNode(nodeChange),
            }));
        },
        encodedSchema: (0, genericFieldKindFormat_js_1.EncodedGenericChangeset)(modularChangeFormat_js_1.EncodedNodeChangeset),
    };
}
//# sourceMappingURL=genericFieldKindCodecs.js.map