/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/core-utils/internal";
import { detachedFieldAsKey, rootField, } from "../tree/index.js";
/**
 * @param field - defaults to {@link rootField}.
 * @returns anchor to `field`.
 */
export function rootAnchor(field = rootField) {
    return {
        parent: undefined,
        fieldKey: detachedFieldAsKey(field),
    };
}
/**
 * @param field - defaults to {@link rootField}.
 * @returns anchor to `field`.
 */
export function moveToDetachedField(forest, cursorToMove, field = rootField) {
    const result = forest.tryMoveCursorToField(rootAnchor(field), cursorToMove);
    assert(result === 1 /* TreeNavigationResult.Ok */, 0x42d /* Navigation to detached fields should never fail */);
}
/**
 * @internal
 */
export var ITreeSubscriptionCursorState;
(function (ITreeSubscriptionCursorState) {
    /**
     * On the current revision of the forest.
     */
    ITreeSubscriptionCursorState[ITreeSubscriptionCursorState["Current"] = 0] = "Current";
    /**
     * Empty, but can be reused.
     */
    ITreeSubscriptionCursorState[ITreeSubscriptionCursorState["Cleared"] = 1] = "Cleared";
    /**
     * Freed and must not be used.
     */
    ITreeSubscriptionCursorState[ITreeSubscriptionCursorState["Freed"] = 2] = "Freed";
})(ITreeSubscriptionCursorState || (ITreeSubscriptionCursorState = {}));
/**
 * @internal
 */
export var TreeNavigationResult;
(function (TreeNavigationResult) {
    /**
     * Attempt to navigate cursor to a key or index that is outside the client's view.
     */
    TreeNavigationResult[TreeNavigationResult["NotFound"] = -1] = "NotFound";
    /**
     * Attempt to navigate cursor to a portion of the tree that has not yet been loaded.
     */
    TreeNavigationResult[TreeNavigationResult["Pending"] = 0] = "Pending";
    /**
     * ITreeReader successfully navigated to the desired node.
     */
    TreeNavigationResult[TreeNavigationResult["Ok"] = 1] = "Ok";
})(TreeNavigationResult || (TreeNavigationResult = {}));
//# sourceMappingURL=forest.js.map