/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/core-utils/internal";
import { RevisionTagSchema } from "./types.js";
export class RevisionTagCodec {
    constructor(idCompressor) {
        this.idCompressor = idCompressor;
        this.encodedSchema = RevisionTagSchema;
        this.localSessionId = idCompressor.localSessionId;
    }
    encode(tag) {
        return tag === "root"
            ? tag
            : this.idCompressor.normalizeToOpSpace(tag);
    }
    decode(tag, context) {
        if (tag === "root") {
            return tag;
        }
        assert(typeof tag === "number", 0x88d /* String revision tag must be the literal 'root' */);
        return this.idCompressor.normalizeToSessionSpace(tag, context.originatorId);
    }
}
//# sourceMappingURL=revisionTagCodec.js.map