import { VegaRichTextEditor } from '../../vega-rich-text-editor';
import { RTEBlock } from '../../dto/blocks/block.abstract';
import { RTENode } from '../../dto/nodes/node.abstract';
import { RTERange, RTERangeOptions } from '../../dto/range';
import { RTESelectionState } from '../../dto/selection-state';
import { AutoRunWhenReRenderTaskQueueSlimmer } from '../../../../helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract';
declare type SelectionStateType = {
  startNode: Node | RTENode;
  endNode: Node | RTENode;
  startOffset: number;
  endOffset: number;
};
/**
 * The text selection controller
 */
export declare class SelectionController extends AutoRunWhenReRenderTaskQueueSlimmer {
  static readonly SELECTION_CHANGE_DEBOUNCE_TIME: number;
  vegaRichTextEditorRenderer: VegaRichTextEditor['vegaRichTextEditorRenderer'];
  selectionMap: VegaRichTextEditor['selectionMap'];
  host: VegaRichTextEditor['host'];
  protected readonly value: VegaRichTextEditor['value'];
  protected readonly disabled: VegaRichTextEditor['disabled'];
  protected readonly sourceView: VegaRichTextEditor['sourceView'];
  protected readonly valueController: VegaRichTextEditor['valueController'];
  protected insertCompositionTextController: VegaRichTextEditor['insertCompositionTextController'];
  protected readonly historyController: VegaRichTextEditor['historyController'];
  protected internalCodeBlockSelectionController: VegaRichTextEditor['internalCodeBlockSelectionController'];
  private currentRange;
  private handleSelectionWithDebounce;
  private pendingRestoreSelectionNodes;
  private selectionRangeChangeObserver;
  private selectionState;
  /**
   * Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
   */
  connectedCallback(): void;
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
   */
  disconnectedCallback(): void;
  /**
   * Component lifecycle - [componentDidLoad]{@link VegaRichTextEditor.componentDidLoad}
   */
  componentDidLoad(): void;
  constructor();
  /**
   * Watches the internal value of the editor
   */
  watchValueUpdate(): void;
  /**
   * Get the current RTE selection range
   *
   * @returns {RTERange} - The current RTE selection range
   */
  getCurrentRange(): RTERange;
  /**
   * Get the selected rich text node
   *
   * @returns {RTENode[]} Selected rich text nodes
   */
  getSelectedNodes(): RTENode[];
  /**
   * Set the selected rich text nodes
   *
   * @param {RTENode[]} nodes - The rich text nodes to set as selected
   * @param {RTERangeOptions} [rangeOptions] - The range options to set the selection range
   */
  setSelectedNodes(nodes: RTENode[], rangeOptions?: RTERangeOptions): void;
  /**
   * Get the selected rich text blocks
   *
   * @returns {RTEBlock[]} Selected rich text blocks
   */
  getSelectedBlocks(): RTEBlock[];
  /**
   * Set the selection state
   *
   * @param {RTESelectionState} state - The selection state to set
   */
  setSelectionState(state: RTESelectionState): void;
  /**
   * Sets the next selection state with specified start and end nodes, offsets, push the update task to a queue
   *
   * @param {SelectionStateType['startNode']} startNode - The starting node of the selection range. It is a Node object representing the node where the selection range starts.
   * @param {number} startOffset - The `startNode` where the selection range should start. It indicates the position within the `startNode` where the selection should begin.
   * @param {SelectionStateType['endNode']} [endNode] - The ending node of the selection range. If a value is provided for `endNode`, it will be used as the ending node of the selection range.
   * @param {number} [endOffset] - The ending offset within the `endNode` where the selection range should end.
   * @param {boolean} [immediatelyRun] - Should the task run immediately. default is false
   */
  enqueueSelectionRangeFutureState(startNode: SelectionStateType['startNode'], startOffset: number, endNode?: SelectionStateType['endNode'], endOffset?: number, immediatelyRun?: boolean): void;
  /**
   * Set selection with a new range
   *
   * @param {Range} range - The range to set
   */
  setSelectionRange(range: Range): void;
  /**
   * Get the rich text content selected range
   *
   * @returns {Selection} A [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) object
   */
  getSelection(): Selection;
  /**
   * The method invoke after the component re-render.
   */
  protected doTask: () => Promise<void>;
  /**
   * Save the current selection range detail
   */
  private saveSelection;
  /**
   * Restore the selection to the current selected nodes
   */
  private restoreSelection;
  /**
   * Get selected rich text
   */
  private handleSelectionChange;
  /**
   * Add nodes to the selection map
   *
   * @param {RTENode[]} nodes - The rich text nodes to add
   */
  private addNodesToSelectionMap;
  /**
   * Clear the selection map.
   * The code node don't need clear here, because the code node will manager the selection state itself. `code-node-renderer.tsx#handleSelectionChange`
   */
  private clearSelectionMap;
  /**
   * Check if the selection range change is acceptable
   *
   * @returns {boolean} - Returns a boolean value.
   */
  private isAcceptableSelectionRangeChange;
  /**
   * Register the selection range change observer
   */
  private registerSelectionRangeChangeObserver;
  /**
   * Prepare the selection state to restore
   */
  private prepareRestoreSelectionState;
  /**
   * Register the update caret position observer.
   */
  private registerUpdateCaretPositionObserver;
  /**
   * If no node is selected, try to get the nearest node from the current range and set the range to it
   *
   * @param {Range} range - The current range
   * @param {RTENode[]} selectedNodes - The selected nodes array
   */
  private tryToFindTheNearestSelectedNode;
  /**
   * Detects the nearest element in the block at the given offset.
   *
   * @param {RTEBlock} block - The block to search within.
   * @param {number} offset - The offset to search from.
   * @returns {Nullable<FocusNodeRangeState>} - The detected element's range state or null if not found.
   */
  private detectNearestElement;
}
export {};
