/** @packageDocumentation
 * @module Elements
 */
import { Id64Array, Id64String } from "@itwin/core-bentley";
import { IModelDb } from "./IModelDb";
import { Model } from "./Model";
/** @beta */
export interface ElementTreeWalkerModelInfo {
    model: Model;
    isDefinitionModel: boolean;
}
/** Records the path that a tree search took to reach an element or model. This object is immutable.
 * @beta
 */
export declare class ElementTreeWalkerScope {
    readonly topElement: Id64String;
    /** path of parent elements and enclosing models */
    readonly path: Array<Id64String | ElementTreeWalkerModelInfo>;
    /** cached info about the immediately enclosing model (i.e., the last model in path) */
    readonly enclosingModelInfo: ElementTreeWalkerModelInfo;
    constructor(topElement: Id64String, model: Model);
    constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);
    get enclosingModel(): Model;
    get inDefinitionModel(): boolean;
    get inRepositoryModel(): boolean;
    static createTopScope(iModel: IModelDb, topElementId: Id64String): ElementTreeWalkerScope;
    private fmtItem;
    toString(): string;
}
/** Does a depth-first search on the tree defined by an element and its sub-models and children.
 * Sub-models are visited before their modeled elements, and children are visited before their parents.
 *
 * The following callbacks allow the subclass to exclude elements and sub-trees from the search:
 *  * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]
 *  * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]
 *
 * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow
 * the subclass to process the elements and models that are encountered in the search.
 * @beta
 */
export declare abstract class ElementTreeBottomUp {
    protected _iModel: IModelDb;
    constructor(_iModel: IModelDb);
    /** Return true if the search should recurse into this model  */
    protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean;
    /** Return true if the search should recurse into the children (if any) of this element  */
    protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean;
    /** Return true if the search should visit this element  */
    protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean;
    /** Return true if the search should visit this model  */
    protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean;
    /** Called to visit a model */
    protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;
    /** Called to visit an element */
    protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;
    /** The main tree-walking function */
    protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope): void;
    /** process the children of the specified parent element */
    private _processChildren;
    /** process the elements in the specified model */
    private _processSubModel;
}
/** Helper class that manages the deletion of definitions and subjects */
declare class SpecialElements {
    definitionModels: Id64Array;
    definitions: Id64Array;
    subjects: Id64Array;
    recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean;
    /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then
     * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.
     * @note Caller must ensure that the special elements were recorded in a depth-first search.
     */
    deleteSpecialElements(iModel: IModelDb): void;
}
/** Deletes an entire element tree, including sub-models and child elements.
 * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.
 * Call deleteNormalElements on each tree. Then call deleteSpecialElements.
 * @see deleteElementTree for a simple way to use this class.
 * @beta
 */
export declare class ElementTreeDeleter extends ElementTreeBottomUp {
    protected _special: SpecialElements;
    protected shouldExploreModel(_model: Model): boolean;
    protected shouldVisitElement(_elementId: Id64String): boolean;
    protected visitModel(model: Model, _scope: ElementTreeWalkerScope): void;
    protected visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void;
    /**
     * Delete the "normal" elements and record the special elements for deferred processing.
     * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.
     * @param scope How the parent was found
     * @see deleteSpecialElements
     */
    deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void;
    /** Delete all special elements that were found and deferred by deleteNormalElements. Call this
     * function once after all element trees are processed by deleteNormalElements.
     */
    deleteSpecialElements(): void;
}
/** Does a breadth-first search on the tree defined by an element and its sub-models and children.
 * Parents are visited first, then children, then sub-models.
 * The subclass can "prune" sub-trees from the search. When a sub-tree is "pruned" the search does *not* recurse into it.
 * If a sub-tree is not pruned, then the search does recurse into it.
 * @beta
 */
declare abstract class ElementTreeTopDown {
    protected _iModel: IModelDb;
    constructor(_iModel: IModelDb);
    /** Should the search *not* recurse into this sub-tree? */
    protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean;
    protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;
    protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope): void;
    private _processChildren;
    private _processSubModel;
}
/** Signature of the filter function used by ElementSubTreeDeleter.
 * @param elementId The sub-tree parent element.
 * @param scope The path followed by the top-down search to the element
 * @return true if the element and its children and sub-models should be deleted.
 * @beta
 */
export type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;
/** Performs a breadth-first search to visit elements in top-down order.
 * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.
 * @beta
 */
export declare class ElementSubTreeDeleter extends ElementTreeTopDown {
    private _treeDeleter;
    private _shouldPruneCb;
    /** Construct an ElementSubTreeDeleter.
     * @param iModel The iModel
     * @param topElement Where to start the search.
     * @param shouldPruneCb Callback that selects sub-trees that should be deleted.
     * @see deleteElementSubTrees for a simple way to use this class.
     */
    constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter);
    protected shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean;
    protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void;
    /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.
     * Normal elements are deleted. Any special elements that are encountered are deferred.
     * Call deleteSpecialElementSubTrees after all top elements have been processed. */
    deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope): void;
    /** Delete all special elements and their sub-trees that were found in the course of processing.
     * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.
     */
    deleteSpecialElementSubTrees(): void;
}
/** Arguments supplied to [[deleteElementTree]].
 * @beta
 */
export interface DeleteElementTreeArgs {
    /** The iModel containing the elements to delete. */
    iModel: IModelDb;
    /** The Id of the root element of the tree to delete. */
    topElement: Id64String;
    /** The maximum number of passes to make when deleting definition elements.
     * Default: 5
     */
    maxPasses?: number;
}
/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.
 * @param iModel The iModel
 * @param topElement The parent of the sub-tree
 * @beta
 */
export declare function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;
/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.
 * @param args Specifies the iModel and top element.
 * @beta
 */
export declare function deleteElementTree(args: DeleteElementTreeArgs): void;
/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.
 * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.
 * That has the same effect as calling [[deleteElementTree]] on the top element.
 * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.
 * @param iModel The iModel
 * @param topElement Where to start the search.
 * @param filter Callback that selects sub-trees that should be deleted.
 * @beta
 */
export declare function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void;
export {};
//# sourceMappingURL=ElementTreeWalker.d.ts.map