/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { TreeNodeSchema, EditableTreeEvents, TreeStatus } from "../feature-libraries";
import { TypedNode, TreeNode } from "./types";
/**
 * Provides various functions for analyzing {@link TreeNode}s.
 * @privateRemarks
 * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,
 * which avoids typescript expanding the type of TreeNodeSchema and thus encountering
 * https://github.com/microsoft/rushstack/issues/1958.
 */
export interface TreeApi {
    /**
     * The schema information for this node.
     */
    readonly schema: (node: TreeNode) => TreeNodeSchema;
    /**
     * Narrow the type of the given value if it satisfies the given schema.
     * @example
     * ```ts
     * if (node.is(myNode, point)) {
     *     const y = myNode.y; // `myNode` is now known to satisfy the `point` schema and therefore has a `y` coordinate.
     * }
     * ```
     */
    readonly is: <TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema) => value is TypedNode<TSchema>;
    /**
     * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).
     */
    readonly parent: (node: TreeNode) => TreeNode | undefined;
    /**
     * The key of the given node under its parent.
     * @remarks
     * If `node` is an element in a {@link (TreeListNode:interface)}, this returns the index of `node` in the list (a `number`).
     * Otherwise, this returns the key of the field that it is under (a `string`).
     */
    readonly key: (node: TreeNode) => string | number;
    /**
     * Register an event listener on the given node.
     * @returns A callback function which will deregister the event.
     * This callback should be called only once.
     */
    readonly on: <K extends keyof EditableTreeEvents>(node: TreeNode, eventName: K, listener: EditableTreeEvents[K]) => () => void;
    /**
     * Returns the {@link TreeStatus} of the given node.
     */
    readonly status: (node: TreeNode) => TreeStatus;
}
/**
 * The `Tree` object holds various functions for analyzing {@link TreeNode}s.
 */
export declare const nodeApi: TreeApi;
//# sourceMappingURL=node.d.ts.map