/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/core-utils";
import { detachedFieldAsKey, rootField, } from "../tree";
/**
 * @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 /* Ok */, 0x42d /* Navigation to detached fields should never fail */);
}
/**
 * @public
 */
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 = {}));
/**
 * @public
 */
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