import { Range, type RangeInput } from "./range.js";
import { Row, type RowModel } from "./row.js";
import { Column, type ColumnModel, type ColumnDefn } from "./column.js";
import type { Cell, FormulaResult } from "./cell.js";
import { Image, type ImageModel } from "./image.js";
import { Table, type TableModel } from "./table.js";
import { DataValidations } from "./data-validations.js";
import { FormCheckbox, type FormCheckboxModel, type FormCheckboxOptions, type FormControlRange } from "./form-control.js";
import { type PivotTable, type PivotTableModel } from "./pivot-table.js";
import type { Workbook } from "./workbook.js";
import type { AddImageRange, AutoFilter, CellValue, ColBreak, ConditionalFormattingOptions, DataValidation, RowBreak, RowValues, TableProperties, WorksheetProperties, WorksheetView } from "./types.js";
type DataValidationModel = {
    [address: string]: DataValidation | undefined;
};
interface SheetProtection {
    sheet?: boolean;
    objects?: boolean;
    scenarios?: boolean;
    selectLockedCells?: boolean;
    selectUnlockedCells?: boolean;
    formatCells?: boolean;
    formatColumns?: boolean;
    formatRows?: boolean;
    insertColumns?: boolean;
    insertRows?: boolean;
    insertHyperlinks?: boolean;
    deleteColumns?: boolean;
    deleteRows?: boolean;
    sort?: boolean;
    autoFilter?: boolean;
    pivotTables?: boolean;
    algorithmName?: string;
    hashValue?: string;
    saltValue?: string;
    spinCount?: number;
}
interface WorksheetOptions {
    workbook?: Workbook;
    id?: number;
    orderNo?: number;
    name?: string;
    state?: string;
    properties?: Partial<WorksheetProperties>;
    pageSetup?: Partial<PageSetup>;
    headerFooter?: Partial<HeaderFooter>;
    views?: Partial<WorksheetView>[];
    autoFilter?: AutoFilter | null;
}
interface PageSetupMargins {
    left: number;
    right: number;
    top: number;
    bottom: number;
    header: number;
    footer: number;
}
interface PageSetup {
    margins: PageSetupMargins;
    orientation: string;
    horizontalDpi: number;
    verticalDpi: number;
    fitToPage: boolean;
    pageOrder: string;
    blackAndWhite: boolean;
    draft: boolean;
    cellComments: string;
    errors: string;
    scale: number;
    fitToWidth: number;
    fitToHeight: number;
    paperSize?: number;
    showRowColHeaders: boolean;
    showGridLines: boolean;
    firstPageNumber?: number;
    horizontalCentered: boolean;
    verticalCentered: boolean;
    rowBreaks: RowBreak[];
    printTitlesRow?: string;
    printTitlesColumn?: string;
}
interface HeaderFooter {
    differentFirst: boolean;
    differentOddEven: boolean;
    oddHeader: string | null;
    oddFooter: string | null;
    evenHeader: string | null;
    evenFooter: string | null;
    firstHeader: string | null;
    firstFooter: string | null;
}
interface WorksheetModel {
    id: number;
    name: string;
    dataValidations: DataValidationModel;
    properties: Partial<WorksheetProperties>;
    state: string;
    pageSetup: PageSetup;
    headerFooter: HeaderFooter;
    rowBreaks: RowBreak[];
    colBreaks: ColBreak[];
    views: Partial<WorksheetView>[];
    autoFilter: AutoFilter | null;
    media: ImageModel[];
    sheetProtection: SheetProtection | null;
    tables: TableModel[];
    pivotTables: PivotTable[];
    conditionalFormattings: ConditionalFormattingOptions[];
    formControls: FormCheckboxModel[];
    cols?: ColumnModel[];
    rows?: RowModel[];
    dimensions?: Range;
    merges?: string[];
    mergeCells?: string[];
    /** Loaded drawing data (for charts, etc.) - preserved for round-trip */
    drawing?: any;
}
declare class Worksheet {
    private _workbook;
    id: number;
    orderNo: number;
    private _name;
    state: string;
    private _rows;
    private _columns;
    private _keys;
    private _merges;
    rowBreaks: RowBreak[];
    colBreaks: ColBreak[];
    properties: Partial<WorksheetProperties>;
    pageSetup: PageSetup;
    headerFooter: HeaderFooter;
    dataValidations: DataValidations;
    views: Partial<WorksheetView>[];
    autoFilter: AutoFilter | null;
    private _media;
    sheetProtection: SheetProtection | null;
    tables: {
        [key: string]: Table;
    };
    pivotTables: PivotTable[];
    conditionalFormattings: ConditionalFormattingOptions[];
    formControls: FormCheckbox[];
    private _headerRowCount?;
    /** Loaded drawing data (for charts, etc.) - preserved for round-trip */
    private _drawing;
    constructor(options: WorksheetOptions);
    get name(): string;
    set name(name: string | undefined);
    /**
     * The workbook that contains this worksheet
     */
    get workbook(): Workbook;
    /**
     * When you're done with this worksheet, call this to remove from workbook
     */
    destroy(): void;
    /**
     * Get the bounding range of the cells in this worksheet
     */
    get dimensions(): Range;
    /**
     * Get the current columns array
     */
    get columns(): Column[];
    /**
     * Add column headers and define column keys and widths.
     *
     * Note: these column structures are a workbook-building convenience only,
     * apart from the column width, they will not be fully persisted.
     */
    set columns(value: ColumnDefn[]);
    getColumnKey(key: string): Column | undefined;
    setColumnKey(key: string, value: Column): void;
    deleteColumnKey(key: string): void;
    eachColumnKey(f: (column: Column, key: string) => void): void;
    /**
     * Access an individual column by key, letter and 1-based column number
     */
    getColumn(c: string | number): Column;
    /**
     * Cut one or more columns (columns to the right are shifted left)
     * and optionally insert more
     *
     * If column properties have been defined, they will be cut or moved accordingly
     *
     * Known limitation: If a splice causes any merged cells to move, the results may be unpredictable
     *
     * Also: If the worksheet has more rows than values in the column inserts,
     * the rows will still be shifted as if the values existed
     */
    spliceColumns(start: number, count: number, ...inserts: CellValue[][]): void;
    /**
     * Get the last column in a worksheet
     */
    get lastColumn(): Column;
    /**
     * The total column size of the document. Equal to the maximum cell count from all of the rows
     */
    get columnCount(): number;
    /**
     * A count of the number of columns that have values
     */
    get actualColumnCount(): number;
    _commitRow(row: Row): void;
    get _lastRowNumber(): number;
    get _nextRow(): number;
    /**
     * Get the last editable row in a worksheet (or undefined if there are none)
     */
    get lastRow(): Row | undefined;
    /**
     * Tries to find and return row for row number, else undefined
     *
     * @param r - The 1-indexed row number
     */
    findRow(r: number): Row | undefined;
    /**
     * Tries to find and return rows for row number start and length, else undefined
     *
     * @param start - The 1-indexed starting row number
     * @param length - The length of the expected array
     */
    findRows(start: number, length: number): (Row | undefined)[];
    /**
     * The total row size of the document. Equal to the row number of the last row that has values.
     */
    get rowCount(): number;
    /**
     * A count of the number of rows that have values. If a mid-document row is empty, it will not be included in the count.
     */
    get actualRowCount(): number;
    getRow(r: number): any;
    getRows(start: number, length: number): any[] | undefined;
    addRow(value: any, style?: string): any;
    addRows(value: any[], style?: string): any[];
    insertRow(pos: number, value: any, style?: string): any;
    insertRows(pos: number, values: any[], style?: string): Row[] | undefined;
    _setStyleOption(pos: number, style?: string): void;
    _copyStyle(src: number, dest: number, styleEmpty?: boolean): void;
    /**
     * Duplicate rows and insert new rows
     */
    duplicateRow(rowNum: number, count: number, insert?: boolean): void;
    /**
     * Cut one or more rows (rows below are shifted up)
     * and optionally insert more
     *
     * Known limitation: If a splice causes any merged cells to move, the results may be unpredictable
     */
    spliceRows(start: number, count: number, ...inserts: RowValues[]): void;
    /**
     * Iterate over all rows that have values in a worksheet
     */
    eachRow(callback: (row: Row, rowNumber: number) => void): void;
    /**
     * Iterate over all rows (including empty rows) in a worksheet
     */
    eachRow(opt: {
        includeEmpty?: boolean;
    }, callback: (row: Row, rowNumber: number) => void): void;
    /**
     * Return all rows as sparse array
     */
    getSheetValues(): CellValue[][];
    /**
     * Returns the cell at [r,c] or address given by r. If not found, return undefined
     */
    findCell(r: number | string, c?: number): Cell | undefined;
    /**
     * Get or create cell at [r,c] or address given by r
     */
    getCell(r: number | string, c?: number): Cell;
    /**
     * Merge cells, either:
     *
     * tlbr string, e.g. `'A4:B5'`
     *
     * tl string, br string, e.g. `'G10', 'H11'`
     *
     * t, l, b, r numbers, e.g. `10,11,12,13`
     */
    mergeCells(...cells: RangeInput[]): void;
    mergeCellsWithoutStyle(...cells: RangeInput[]): void;
    _mergeCellsInternal(dimensions: Range, ignoreStyle?: boolean): void;
    _unMergeMaster(master: Cell): void;
    /**
     * Update _merges dictionary and cell-level merge references after a row or column splice.
     */
    private _spliceMerges;
    get hasMerges(): boolean;
    /**
     * Scan the range and if any cell is part of a merge, un-merge the group.
     * Note this function can affect multiple merges and merge-blocks are
     * atomic - either they're all merged or all un-merged.
     */
    unMergeCells(...cells: RangeInput[]): void;
    fillFormula(range: string, formula: string, results?: FormulaResult[][] | FormulaResult[] | ((row: number, col: number) => FormulaResult | undefined), shareType?: string): void;
    /**
     * Using the image id from `Workbook.addImage`,
     * embed an image within the worksheet to cover a range
     */
    addImage(imageId: string | number, range: AddImageRange): void;
    getImages(): Image[];
    /**
     * Using the image id from `Workbook.addImage`, set the background to the worksheet
     */
    addBackgroundImage(imageId: string | number): void;
    getBackgroundImageId(): string | undefined;
    /**
     * Add a form control checkbox to the worksheet.
     *
     * Form control checkboxes are the legacy style that work in Office 2007+,
     * WPS Office, LibreOffice, and other spreadsheet applications.
     *
     * Unlike modern in-cell checkboxes (which only work in Microsoft 365),
     * form control checkboxes are floating controls positioned over cells.
     *
     * @param range - Cell reference (e.g., "B2") or range (e.g., "B2:D3") for positioning
     * @param options - Checkbox options
     * @returns The created FormCheckbox instance
     *
     * @example
     * // Simple checkbox at B2
     * ws.addFormCheckbox("B2");
     *
     * // Checkbox with label and linked cell
     * ws.addFormCheckbox("B2:D3", {
     *   text: "Accept terms",
     *   link: "A2",
     *   checked: false
     * });
     */
    addFormCheckbox(range: FormControlRange, options?: FormCheckboxOptions): FormCheckbox;
    /**
     * Get all form control checkboxes in the worksheet
     */
    getFormCheckboxes(): FormCheckbox[];
    /**
     * Protect the worksheet with optional password and options
     */
    protect(password?: string, options?: Partial<SheetProtection>): Promise<void>;
    unprotect(): void;
    /**
     * Add a new table and return a reference to it
     */
    addTable(model: TableProperties): Table;
    /**
     * Fetch table by name
     */
    getTable(name: string): Table;
    /**
     * Delete table by name
     */
    removeTable(name: string): void;
    /**
     * Fetch all tables in the worksheet
     */
    getTables(): Table[];
    addPivotTable(model: PivotTableModel): PivotTable;
    /**
     * Add conditional formatting rules
     */
    addConditionalFormatting(cf: ConditionalFormattingOptions): void;
    /**
     * Delete conditional formatting rules
     */
    removeConditionalFormatting(filter: number | ((value: ConditionalFormattingOptions, index: number, array: ConditionalFormattingOptions[]) => boolean)): void;
    get model(): WorksheetModel;
    _parseRows(model: WorksheetModel): void;
    _parseMergeCells(model: WorksheetModel): void;
    set model(value: WorksheetModel);
}
export { Worksheet, type WorksheetModel };
