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