"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 genericFieldKindTypes_js_1 = require("./genericFieldKindTypes.js");
const modularChangeFormatV1_js_1 = require("./modularChangeFormatV1.js");
function makeGenericChangeCodec() {
    return (0, index_js_1.makeCodecFamily)([[1, makeV1Codec()]]);
}
exports.makeGenericChangeCodec = makeGenericChangeCodec;
function makeV1Codec() {
    return {
        encode: (change, context) => {
            const encoded = change
                .toArray()
                .map(([index, nodeChange]) => [index, context.encodeNode(nodeChange)]);
            return encoded;
        },
        decode: (encoded, context) => {
            return (0, genericFieldKindTypes_js_1.newGenericChangeset)(encoded.map(([index, nodeChange]) => [index, context.decodeNode(nodeChange)]));
        },
        encodedSchema: (0, genericFieldKindFormat_js_1.EncodedGenericChangeset)(modularChangeFormatV1_js_1.EncodedNodeChangeset),
    };
}
//# sourceMappingURL=genericFieldKindCodecs.js.map