import { Nullable } from '../../../../..';
import { ClassType } from '../../../../../types/class.type';
import { RTEBlock } from '../../../dto/blocks/block.abstract';
import { RTENode } from '../../../dto/nodes/node.abstract';
import { RTETableBlock } from '../dto/table-block';
import { VegaRTETableBodyBlock } from '../dto/table-body-block';
import { RTETableCellBlock, VegaRTETableCellBlock } from '../dto/table-cell-block';
import { RTETableRowBlock, VegaRTETableRowBlock } from '../dto/table-row-block';
import { RTETableHeadCellBlock } from '../dto/table-head-cell-block';
import { MergeCellsOperationType } from '../setting-event-handlers/merge-cells-operation';
/**
 * Recursively searches for a parent block of a specific type.
 *
 * @typedef T - Generic type extending RTEBlock.
 * @param {RTEBlock} block - The starting block to search from.
 * @param {ClassType<unknown>} dtoClass - The class type to match the parent block against.
 * @returns {T | null} - The found parent block of the specified type, or null if not found.
 */
export declare function getParentBlockByType<T extends RTEBlock>(block: RTEBlock, dtoClass: ClassType<unknown>): T | null;
/**
 * Generate the table body with the specified number of rows and columns.
 *
 * @param {number} rowCount - The number of rows in the table body.
 * @param {number} columnCount - The number of columns in the table body.
 * @returns {VegaRTETableBodyBlock} The generated table body block.
 */
export declare function generateTableBody(rowCount: number, columnCount: number): VegaRTETableBodyBlock;
/**
 * Create a table row block with the specified number of columns and cell type.
 *
 * @param {number} columnCount - The number of columns in the row.
 * @returns {VegaRTETableRowBlock} The created table row block.
 */
export declare function generateTableRow(columnCount: number): VegaRTETableRowBlock;
/**
 * Get all table rows from a table block (including rows from all table bodies and headers).
 *
 * @param {RTETableBlock} tableBlock - The table block.
 * @returns {RTETableRowBlock[]} Array of all table row blocks.
 */
export declare function getAllTableRows(tableBlock: RTETableBlock): RTETableRowBlock[];
/**
 * Find the first node within a block recursively.
 *
 * @param {Nullable<RTEBlock>} block - The block to find the first node in.
 * @returns {Nullable<RTENode>} The focusable node within the block.
 */
export declare function getFirstNode(block: Nullable<RTEBlock>): Nullable<RTENode>;
/**
 * Find a cell block by its ID across all table rows.
 *
 * @param {RTETableRowBlock[]} allTableRows - All table rows to search within.
 * @param {string} cellId - The unique identifier of the cell to find.
 * @returns {Nullable<RTETableCellBlock | RTETableHeadCellBlock>} The found cell block, or null if not found.
 */
export declare function findCellBlockById(allTableRows: RTETableRowBlock[], cellId: string): Nullable<RTETableCellBlock | RTETableHeadCellBlock>;
/**
 * Get the default cell block template.
 *
 * @param {string} cellType - The type of the cell block.
 * @returns {VegaRTETableCellBlock} The default cell block template.
 */
export declare function getDefaultCellBlockTemplate(cellType: string): VegaRTETableCellBlock;
export declare type CellSpan = {
  colSpan: number;
  rowSpan: number;
};
/**
 * Get the actual col span and row span of a cell.
 *
 * @param {RTETableCellBlock | RTETableHeadCellBlock} cell - The cell to check.
 * @returns {CellSpan} The actual span values.
 */
export declare function getCellSpan(cell: RTETableCellBlock | RTETableHeadCellBlock): CellSpan;
/**
 * Get the actual column position of a cell considering previous cells' colspan
 * and cells from previous rows with rowspan that extend into the current row.
 *
 * @param {RTETableCellBlock | RTETableHeadCellBlock} cell - The cell to check.
 * @param {RTETableRowBlock[]} allRows - The table all rows.
 * @param {string[][]} grid - The 2D grid representation of the table
 * @returns {number} The actual column position.
 */
export declare function getActualColumnPosition(cell: RTETableCellBlock | RTETableHeadCellBlock, allRows: RTETableRowBlock[], grid?: string[][]): number;
/**
 * Build a 2D grid representation of a table section where each occupied position
 * contains the cell id covering that (row, col) coordinate, accounting for colSpan/rowSpan.
 *
 * @param {RTETableRowBlock[]} allRows - All rows in the current table section.
 * @returns {string[][]} The table grid.
 */
export declare function buildTableGrid(allRows: RTETableRowBlock[]): string[][];
export declare type AdjacentCellDirection = 'up' | 'right' | 'down' | 'left';
/**
 * Get the adjacent cell in the specified direction based on the table matrix.
 *
 * @param {RTETableCellBlock | RTETableHeadCellBlock} cell - The current cell.
 * @param {AdjacentCellDirection} direction - The direction to locate the adjacent cell.
 * @returns {RTETableCellBlock | RTETableHeadCellBlock | null} The adjacent cell or null.
 */
export declare function getAdjacentCell(cell: RTETableCellBlock | RTETableHeadCellBlock, direction: MergeCellsOperationType): RTETableCellBlock | RTETableHeadCellBlock | null;
/**
 * Find the cell that covers the specified matrix position.
 *
 * @param {RTETableRowBlock[]} rows - Rows in the current table section.
 * @param {number} targetRowIndex - Target matrix row index.
 * @param {number} targetColPosition - Target matrix column position.
 * @returns {RTETableCellBlock | RTETableHeadCellBlock | null} The covering cell or null.
 */
export declare function findCellAtPosition(rows: RTETableRowBlock[], targetRowIndex: number, targetColPosition: number): RTETableCellBlock | RTETableHeadCellBlock | null;
/**
 * Rectangular bounds information for selected table cells.
 */
export declare type RectangularBounds = {
  minRow: number;
  maxRow: number;
  minCol: number;
  maxCol: number;
  targetCell: RTETableCellBlock | RTETableHeadCellBlock;
  coveredPositions: Set<string>;
};
/**
 * Get the rectangular bounds of selected cells.
 * Calculates the bounding box (minRow, maxRow, minCol, maxCol) and returns related information.
 *
 * @param {RTETableCellBlock[] | RTETableHeadCellBlock[]} selectedCells - The selected table cells.
 * @returns {RectangularBounds} The rectangular bounds' information.
 */
export declare function getRectangularBounds(selectedCells: RTETableCellBlock[] | RTETableHeadCellBlock[]): RectangularBounds;
/**
 * Calculate the total number of columns in the table.
 * Accounts for cells with col span.
 *
 * @param {RTETableBlock} table - The table block.
 * @returns {number} The total number of columns in the table.
 */
export declare function getTableColumnCount(table: RTETableBlock): number;
/**
 * Check if the selected cells form a rectangular area.
 * Considers cells with col span and row span.
 *
 * @param {RTETableCellBlock[] | RTETableHeadCellBlock[]} selectedCells - The selected table cells.
 * @returns {boolean} True if the selected cells form a rectangle, false otherwise.
 */
export declare function isRectangularSelection(selectedCells: RTETableCellBlock[] | RTETableHeadCellBlock[]): boolean;
/**
 * Set the col span and row span attributes for a target cell.
 * When colSpan equals the table's total columns, rowSpan is removed.
 *
 * @param {RTETableCellBlock | RTETableHeadCellBlock} targetCell - The target cell to set attributes on.
 * @param {number} colSpan - The column span value.
 * @param {number} rowSpan - The row span value.
 * @param {RTETableBlock} table - The table block.
 * @param {boolean} insertColumn - Whether the operation is an insert-column action.
 */
export declare function setSpanAttributes(targetCell: RTETableCellBlock | RTETableHeadCellBlock, colSpan: number, rowSpan: number, table: RTETableBlock, insertColumn?: boolean): void;
/**
 * Create a new cell of the specified type.
 *
 * @param {string} cellType - The type of cell ('table-cell' or 'table-head-cell').
 * @returns {RTETableCellBlock | RTETableHeadCellBlock} The newly created cell.
 */
export declare function createNewCell(cellType: string): RTETableCellBlock | RTETableHeadCellBlock;
/**
 * Find the first logical column index in a row that is not a header cell.
 *
 * @param {string[]} gridRow - The grid row array.
 * @param {RTETableRowBlock} row - The table row block.
 * @param {number} maxColLength - The maximum number of columns.
 * @returns {number} The first non-header logical column index, or -1 if not found.
 */
export declare function findFirstBodyColIndex(gridRow: string[], row: RTETableRowBlock, maxColLength: number): number;
/**
 * Build a map of cell id to its first logical column index in the table grid.
 *
 * @param {string[][]} tableGrid - The table grid.
 * @returns {Map<string, number>} Cell id to start column index.
 */
export declare function buildCellStartColumnMap(tableGrid: string[][]): Map<string, number>;
/**
 * Find the index range of the table selection.
 * Returns the starting and ending indices of the selected cells.
 *
 * @param {(RTETableCellBlock | RTETableHeadCellBlock)[]} selectedCells - The selected table cells.
 * @param {RTETableBlock} table - The table block
 * @param {RTETableRowBlock[]} allTableRows - All table rows.
 * @param {string[][]} grid - The 2D grid representation of the table
 * @returns {[number, number]} A tuple containing the start and end indices.
 */
export declare function getSelectedCellsBoundary(selectedCells: (RTETableCellBlock | RTETableHeadCellBlock)[], table: RTETableBlock, allTableRows?: RTETableRowBlock[], grid?: string[][]): [number, number];
