export function parseMargin(margin) {
    if (null == margin) return [ 10, 10, 10, 10 ];
    if ("number" == typeof margin) return [ margin, margin, margin, margin ];
    if (Array.isArray(margin)) {
        if (2 === margin.length) {
            const [vertical, horizontal] = margin;
            return [ vertical, horizontal, vertical, horizontal ];
        }
        if (4 === margin.length) return margin;
    }
    return [ 10, 10, 10, 10 ];
}

export function getInternalProps(table) {
    return table.internalProps;
}

export function getRecordByRowIndex(table, bodyRowIndex) {
    return table.dataSource.getRaw(bodyRowIndex);
}

export function getOriginalRowHeight(table, bodyRowIndex) {
    var _a;
    return (null === (_a = getInternalProps(table).originalRowHeights) || void 0 === _a ? void 0 : _a.get(bodyRowIndex)) || 0;
}

const columnIndexCache = new WeakMap;

export function findCheckboxColumnIndex(table, field) {
    let tableCache = columnIndexCache.get(table);
    if (tableCache || (tableCache = new Map, columnIndexCache.set(table, tableCache)), 
    tableCache.has(field)) return tableCache.get(field);
    for (let col = 0; col < table.colCount; col++) {
        if (table.getHeaderField(col, 0) === field) return tableCache.set(field, col), col;
    }
    return tableCache.set(field, -1), -1;
}

export function setCellCheckboxStateByAttribute(col, row, checked, table) {
    const cellGroup = table.scenegraph.getCell(col, row);
    cellGroup && cellGroup.forEachChildren((child => {
        const childNode = child;
        ("checkbox-icon" === childNode.name || "checkbox" === childNode.name || "checkbox" === childNode.type || childNode.attribute && "checkbox" === childNode.attribute.type) && childNode.setAttributes && ("indeterminate" === checked ? childNode.setAttributes({
            checked: !1,
            indeterminate: !0
        }) : childNode.setAttributes({
            checked: checked,
            indeterminate: !1
        }));
    }));
}
//# sourceMappingURL=utils.js.map
