import { LitElement, PropertyValues, TemplateResult } from "lit";
import "@openremote/or-mwc-components/or-mwc-input";
import { OrMwcInput } from "@openremote/or-mwc-components/or-mwc-input";
import "@openremote/or-icon";
import { Asset, AssetDescriptor, AssetEvent, AssetQueryOrderBy$Property, AssetTreeEvent, AssetTreeNode, SharedEvent } from "@openremote/model";
import "@openremote/or-translate";
import { style } from "./style";
import { EventCallback, Util } from "@openremote/core";
import "@openremote/or-mwc-components/or-mwc-menu";
import { ListItem } from "@openremote/or-mwc-components/or-mwc-list";
import "@openremote/or-mwc-components/or-mwc-list";
import "@openremote/or-mwc-components/or-mwc-dialog";
import "./or-add-asset-dialog";
export interface AssetTreeTypeConfig {
    include?: string[];
    exclude?: string[];
}
export interface AssetTreeConfig {
    select?: {
        multiSelect?: boolean;
        types?: string[];
    };
    add?: {
        typesProvider?: (parent: UiAssetTreeNode | undefined) => AssetDescriptor[] | undefined;
        typesParent?: {
            default?: AssetTreeTypeConfig;
            none?: AssetTreeTypeConfig;
            assetTypes?: {
                [assetType: string]: AssetTreeTypeConfig;
            };
        };
    };
}
interface AssetWithReparentId extends Asset {
    reparentId?: string | null;
}
export interface UiAssetTreeNode extends AssetTreeNode {
    selected: boolean;
    expandable: boolean;
    expanded: boolean;
    parent: UiAssetTreeNode;
    children: UiAssetTreeNode[];
    someChildrenSelected: boolean;
    allChildrenSelected: boolean;
    notMatchingFilter: boolean;
    hidden: boolean;
}
export interface NodeSelectEventDetail {
    oldNodes: UiAssetTreeNode[];
    newNodes: UiAssetTreeNode[];
}
export interface ChangeParentEventDetail {
    parentId: string | undefined;
    assetIds: string[];
}
export { style };
export declare class OrAssetTreeRequestSelectionEvent extends CustomEvent<Util.RequestEventDetail<NodeSelectEventDetail>> {
    static readonly NAME = "or-asset-tree-request-selection";
    constructor(request: NodeSelectEventDetail);
}
export declare class OrAssetTreeSelectionEvent extends CustomEvent<NodeSelectEventDetail> {
    static readonly NAME = "or-asset-tree-selection";
    constructor(detail: NodeSelectEventDetail);
}
export declare class OrAssetTreeChangeParentEvent extends CustomEvent<ChangeParentEventDetail> {
    static readonly NAME = "or-asset-tree-change-parent";
    constructor(parent: string | undefined, assetsIds: string[]);
}
export interface ToggleExpandEventDetail {
    node: UiAssetTreeNode;
}
export declare class OrAssetTreeToggleExpandEvent extends CustomEvent<ToggleExpandEventDetail> {
    static readonly NAME = "or-asset-tree-expand";
    constructor(detail: ToggleExpandEventDetail);
}
export type AddEventDetail = {
    sourceAsset?: Asset;
    asset: Asset;
};
export declare class OrAssetTreeRequestAddEvent extends CustomEvent<Util.RequestEventDetail<AddEventDetail>> {
    static readonly NAME = "or-asset-tree-request-add";
    constructor(detail: AddEventDetail);
}
export declare class OrAssetTreeAddEvent extends CustomEvent<AddEventDetail> {
    static readonly NAME = "or-asset-tree-add";
    constructor(detail: AddEventDetail);
}
export declare class OrAssetTreeRequestDeleteEvent extends CustomEvent<Util.RequestEventDetail<UiAssetTreeNode[]>> {
    static readonly NAME = "or-asset-tree-request-delete";
    constructor(request: UiAssetTreeNode[]);
}
export declare class OrAssetTreeAssetEvent extends CustomEvent<AssetEvent> {
    static readonly NAME = "or-asset-tree-asset-event";
    constructor(assetEvent: AssetEvent);
}
export declare class OrAssetTreeFilter {
    asset: string | undefined;
    assetType: string[];
    attribute: string[];
    attributeValue: string[];
    constructor(asset?: string);
}
declare global {
    export interface HTMLElementEventMap {
        [OrAssetTreeRequestSelectionEvent.NAME]: OrAssetTreeRequestSelectionEvent;
        [OrAssetTreeSelectionEvent.NAME]: OrAssetTreeSelectionEvent;
        [OrAssetTreeRequestAddEvent.NAME]: OrAssetTreeRequestAddEvent;
        [OrAssetTreeAddEvent.NAME]: OrAssetTreeAddEvent;
        [OrAssetTreeRequestDeleteEvent.NAME]: OrAssetTreeRequestDeleteEvent;
        [OrAssetTreeAssetEvent.NAME]: OrAssetTreeAssetEvent;
        [OrAssetTreeChangeParentEvent.NAME]: OrAssetTreeChangeParentEvent;
    }
}
declare const OrAssetTree_base: (new (...args: any[]) => {
    _connectRequested: boolean;
    _subscriptionIds?: string[];
    _assetIds?: string[];
    _attributeRefs?: import("@openremote/model").AttributeRef[];
    _status: import("@openremote/core").EventProviderStatus;
    _statusCallback: (status: import("@openremote/core").EventProviderStatus) => void;
    connectedCallback(): void;
    disconnectedCallback(): void;
    connectEvents(): void;
    disconnectEvents(): void;
    _doConnect(): Promise<void>;
    readonly eventsConnected: boolean;
    _onEventProviderStatusChanged(status: import("@openremote/core").EventProviderStatus): void;
    _onEventsConnect(): void;
    _onEventsDisconnect(): void;
    _addEventSubscriptions(): Promise<void>;
    _removeEventSubscriptions(): void;
    _refreshEventSubscriptions(): void;
    assetIds: string[] | undefined;
    attributeRefs: import("@openremote/model").AttributeRef[] | undefined;
    _sendEvent(event: SharedEvent): void;
    _sendEventWithReply<U extends SharedEvent, V extends SharedEvent>(event: U): Promise<V>;
    onEventsConnect(): void;
    onEventsDisconnect(): void;
    _onEvent(event: SharedEvent): void;
    requestUpdate(name?: PropertyKey, oldValue?: unknown): void;
    readonly isConnected: boolean;
}) & typeof LitElement;
export declare class OrAssetTree extends OrAssetTree_base {
    static get styles(): import("lit").CSSResult[];
    /**
     * Allows arbitrary assets to be displayed using a tree
     */
    readonly assets?: Asset[];
    readonly rootAssets?: Asset[];
    readonly rootAssetIds?: string[];
    readonly dataProvider?: (offset: number, limit: number, parentId?: string) => Promise<Asset[]>;
    readonly readonly: boolean;
    disabled: boolean;
    readonly disableSubscribe: boolean;
    selectedIds?: string[];
    showDeselectBtn?: boolean;
    showSortBtn?: boolean;
    showFilter: boolean;
    showFilterIcon: boolean;
    sortBy?: string;
    expandAllNodes?: boolean;
    checkboxes?: boolean;
    readonly queryLimit = 100;
    protected config?: AssetTreeConfig;
    protected _nodes?: UiAssetTreeNode[];
    protected _loading: boolean;
    protected _connected: boolean;
    protected _selectedNodes: UiAssetTreeNode[];
    protected _expandedNodes: UiAssetTreeNode[];
    protected _initCallback?: EventCallback;
    protected _filter: OrAssetTreeFilter;
    protected _clearIconContainer: HTMLElement;
    protected _filterInput: OrMwcInput;
    protected _filterSettingOpen: boolean;
    protected _assetTypes: AssetDescriptor[];
    protected _attributeNameFilter: OrMwcInput;
    protected _attributeValueFilter: OrMwcInput;
    protected _assetTypeFilter: string;
    protected _uniqueAssetTypes: string[];
    protected _hasMoreParents: boolean;
    protected _incompleteParentIds: string[];
    private _dragDropParentId;
    protected _expandTimer?: number;
    private _latestSelected;
    protected assetsChildren: {
        [key: string]: UiAssetTreeNode[];
    };
    get selectedNodes(): UiAssetTreeNode[];
    set selectedNodes(nodes: UiAssetTreeNode[]);
    connectedCallback(): void;
    disconnectedCallback(): void;
    refresh(): void;
    isAncestorSelected(node: UiAssetTreeNode): boolean;
    /**
     * A setter function for updating the list of nodes (assets) shown in the UI.
     * @param filter - The {@link OrAssetTreeFilter} to apply.
     * @param reflect - If the changes should be reflected in the filtering UI. (default: false)
     */
    applyFilter(filter?: OrAssetTreeFilter | string, reflect?: boolean): void;
    protected mapDescriptors(descriptors: (AssetDescriptor)[], withNoneValue?: ListItem): ListItem[];
    protected getSelectHeader(): TemplateResult;
    protected getSelectedHeader(descriptor: AssetDescriptor): TemplateResult;
    protected assetTypeSelect(): TemplateResult;
    protected atLeastOneNodeToBeShown(): boolean;
    protected render(): TemplateResult<1>;
    protected _isReadonly(): boolean;
    protected shouldUpdate(_changedProperties: PropertyValues): boolean;
    protected _updateSelectedNodes(): void;
    protected _updateSort(nodes: UiAssetTreeNode[], sortFunction: (a: UiAssetTreeNode, b: UiAssetTreeNode) => number): void;
    protected _toggleExpander(expander: HTMLElement, node: UiAssetTreeNode | null, silent?: boolean): Promise<void>;
    private _buildPaths;
    private _findNode;
    private _findNodeFromAssetId;
    protected _onNodeClicked(evt: MouseEvent | null, node: UiAssetTreeNode | null): void;
    protected _onDeselectClicked(): void;
    protected parseFromInputFilter(inputValue?: any): OrAssetTreeFilter;
    protected formatFilter(newFilter: OrAssetTreeFilter): string;
    protected _shouldEnableAttrTypeEvent(e: KeyboardEvent): void;
    protected _shouldEnableAttrType(value: string | undefined): void;
    protected applySettingFields(filter: OrAssetTreeFilter): OrAssetTreeFilter;
    protected _filterFromSettings(): void;
    protected _onFilterInput(newValue: string | undefined): void;
    protected _doFiltering(): Promise<void>;
    protected getMatcher(requireQuery: boolean): Promise<{
        matcher: ((asset: Asset) => boolean);
        assets?: Asset[];
    }>;
    protected getSimpleNameMatcher(): Promise<((asset: Asset) => boolean)>;
    protected getMatcherFromQuery(): Promise<{
        assets: Asset[];
        matcher: ((asset: Asset) => boolean);
    }>;
    protected isAnyFilter(): boolean;
    protected filterTreeNode(currentNode: UiAssetTreeNode, matcher: (asset: Asset) => boolean, parentMatching?: boolean): boolean;
    protected _onCopyClicked(): Promise<void>;
    protected _onAddClicked(): void;
    protected _gatewayDescendantIsSelected(): boolean;
    protected _onDeleteClicked(): void;
    protected _onSortClicked(sortBy: string): void;
    protected _doDelete(): void;
    protected _canAdd(): boolean;
    protected _getAllowedChildTypes(selectedNode: UiAssetTreeNode | undefined): AssetDescriptor[];
    protected _getSortFunction(): (a: UiAssetTreeNode, b: UiAssetTreeNode) => number;
    protected _getOrderBy(sortBy?: string): AssetQueryOrderBy$Property;
    /**
     * Main function to load assets and populate the tree.
     * Based on the HTML attributes of this component, it either fetches using a WebSocket connection or using a dataProvider.
     * Once retrieved, these assets will be passed along to the {@link _buildTreeNodes} to construct the tree nodes.
     * If the user has applied a filter, it will also be taken into count using {@link _doFiltering}.
     *
     * @param parentId - The parent ID an asset MUST be a child of during WebSocket retrieval. This is useful for pagination.
     * @param offset - Offset number of the assets to request through WebSocket. This is useful for pagination.
     * @param cache - An array of assets to populate the tree with alongside the retrieved nodes.
     * @protected
     */
    protected _loadAssets(parentId?: string, offset?: number, cache?: Asset[]): Promise<AssetTreeEvent | undefined>;
    _addEventSubscriptions(): Promise<void>;
    onEventsConnect(): void;
    onEventsDisconnect(): void;
    getNodes(): UiAssetTreeNode[];
    _onEvent(event: SharedEvent): void;
    /**
     * Function that creates and constructs the tree node objects to display.
     * @param assets - List of assets to display in the tree
     * @param sortFunction - Optional sorting function for ordering the nodes
     * @protected
     */
    protected _buildTreeNodes(assets: Asset[], sortFunction?: (a: UiAssetTreeNode, b: UiAssetTreeNode) => number): void;
    protected _buildChildTreeNodes(treeNode: UiAssetTreeNode, assets: AssetWithReparentId[], sortFunction: (a: UiAssetTreeNode, b: UiAssetTreeNode) => number): void;
    _onDragStart(ev: any): void;
    _onDragEnd(ev: any): void;
    protected isExpandable(assetId: string): boolean;
    _onDragOver(ev: any): void;
    protected expandNode(assetId: string | null): void;
    _onDragEnter(ev: any): void;
    _onDragLeave(ev: any): void;
    /**
     * Generates the HTML TemplateResult for an individual node / tree item.
     * @param treeNode Node to display
     * @param level Level of depth in the tree from 0 to infinite. (0 = top level. If it has 2 parents, level = 2)
     * @protected
     */
    protected _treeNodeTemplate(treeNode: UiAssetTreeNode, level: number): TemplateResult | string | undefined;
    protected static _forEachNodeRecursive(nodes: UiAssetTreeNode[], fn: (node: UiAssetTreeNode) => void): void;
}
//# sourceMappingURL=index.d.ts.map