/**
 * Local equivalent of XLSX.utils.encode_col (0 → A, 25 → Z, 26 → AA) so these
 * synchronous helpers never need the xlsx runtime — callers lazy-load xlsx for
 * parsing only, and cell addressing stays dependency-free.
 */
export function encodeColumnLetter(col) {
    let letters = '';
    for (let n = col + 1; n > 0; n = Math.floor((n - 1) / 26)) {
        letters = String.fromCharCode(((n - 1) % 26) + 65) + letters;
    }
    return letters;
}
/** Local equivalent of XLSX.utils.encode_cell ({r: 1, c: 1} → "B2"). */
export function encodeCellAddress(row, col) {
    return `${encodeColumnLetter(col)}${row + 1}`;
}
export function getCell(sheet, row, col) {
    return sheet[encodeCellAddress(row, col)];
}
export function renderCell(cell) {
    if (!cell)
        return '';
    if (typeof cell.w === 'string' && cell.w.trim())
        return cell.w.trim();
    if (cell.v instanceof Date)
        return cell.v.toISOString();
    if (cell.t === 'b')
        return String(Boolean(cell.v));
    if (cell.t === 'e')
        return cell.w?.trim() || '#ERROR';
    if (cell.v == null)
        return cell.f?.trim() || '';
    return String(cell.v).trim();
}
export function isNonEmptyCell(cell) {
    if (cell.f)
        return true;
    // Comment- or hyperlink-only cells are stub cells of type 'z', so these
    // checks must precede the blank-type early return.
    if (cell.c?.length)
        return true;
    if (cell.l?.Target)
        return true;
    if (cell.t === 'z')
        return false;
    return renderCell(cell).length > 0;
}
//# sourceMappingURL=xlsx-cells.js.map