"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.areDetachedNodeIdsEqual = exports.offsetDetachId = exports.makeDetachedNodeId = exports.deltaForRootInitialization = exports.emptyDelta = void 0;
const types_js_1 = require("./types.js");
exports.emptyDelta = {};
function deltaForRootInitialization(content) {
    if (content.topLevelLength === 0) {
        return exports.emptyDelta;
    }
    const buildId = { minor: 0 };
    const delta = {
        build: [{ id: buildId, trees: content }],
        fields: new Map([
            [types_js_1.rootFieldKey, [{ count: content.topLevelLength, attach: buildId }]],
        ]),
    };
    return delta;
}
exports.deltaForRootInitialization = deltaForRootInitialization;
function makeDetachedNodeId(major, minor) {
    const out = { minor };
    if (major !== undefined) {
        out.major = major;
    }
    return out;
}
exports.makeDetachedNodeId = makeDetachedNodeId;
function offsetDetachId(id, offset) {
    if (id === undefined) {
        return undefined;
    }
    return {
        ...id,
        minor: id.minor + offset,
    };
}
exports.offsetDetachId = offsetDetachId;
function areDetachedNodeIdsEqual(a, b) {
    return a.major === b.major && a.minor === b.minor;
}
exports.areDetachedNodeIdsEqual = areDetachedNodeIdsEqual;
//# sourceMappingURL=deltaUtil.js.map