"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.RevisionTagCodec = void 0;
const core_utils_1 = require("@fluidframework/core-utils");
class RevisionTagCodec {
    constructor(idCompressor) {
        this.idCompressor = idCompressor;
        this.localSessionId = idCompressor.localSessionId;
    }
    encode(tag) {
        return tag === "root"
            ? tag
            : this.idCompressor.normalizeToOpSpace(tag);
    }
    decode(tag, context) {
        if (tag === "root") {
            return tag;
        }
        (0, core_utils_1.assert)(typeof tag === "number", 0x88d /* String revision tag must be the literal 'root' */);
        return this.idCompressor.normalizeToSessionSpace(tag, context.originatorId);
    }
}
exports.RevisionTagCodec = RevisionTagCodec;
//# sourceMappingURL=revisionTagCodec.js.map