/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { EncodedChangeAtomId } from "./modular-schema/index.js";
export function makeChangeAtomIdCodec(revisionTagCodec) {
    return {
        encode(changeAtomId, context) {
            return changeAtomId.revision === undefined || changeAtomId.revision === context.revision
                ? changeAtomId.localId
                : [changeAtomId.localId, revisionTagCodec.encode(changeAtomId.revision, context)];
        },
        decode(changeAtomId, context) {
            return Array.isArray(changeAtomId)
                ? {
                    localId: changeAtomId[0],
                    revision: revisionTagCodec.decode(changeAtomId[1], context),
                }
                : { localId: changeAtomId, revision: context.revision };
        },
        encodedSchema: EncodedChangeAtomId,
    };
}
//# sourceMappingURL=changeAtomIdCodec.js.map