/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { makeCodecFamily } from "../../codec/index.js";
import { EncodedGenericChangeset, } from "./genericFieldKindFormat.js";
import { EncodedNodeChangeset } from "./modularChangeFormat.js";
export function makeGenericChangeCodec() {
    return makeCodecFamily([[1, makeV1Codec()]]);
}
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: EncodedGenericChangeset(EncodedNodeChangeset),
    };
}
//# sourceMappingURL=genericFieldKindCodecs.js.map