import React from "react";
import { TABLE_DEFAULT_COL_WIDTH, TABLE_LAST_COL_MIN_WIDTH } from "../../../../Constants/mobile";
var ROW_INDEX_COL_WIDTH = 12;
var isPercent = function isPercent(v) {
    return typeof v === 'string' && v.endsWith('%');
};
export var TableColgroup = function TableColgroup(param) {
    var colWidths = param.colWidths, prefixColWidth = param.prefixColWidth;
    var showPrefix = (prefixColWidth !== null && prefixColWidth !== void 0 ? prefixColWidth : 0) > 0;
    if (!showPrefix && !colWidths.length) return null;
    return /*#__PURE__*/ React.createElement("colgroup", null, showPrefix && /*#__PURE__*/ React.createElement("col", {
        style: {
            width: prefixColWidth,
            minWidth: prefixColWidth,
            maxWidth: prefixColWidth
        }
    }), colWidths.map(function(w, i) {
        var last = i === colWidths.length - 1;
        var style = isPercent(w) ? {
            width: w,
            minWidth: TABLE_DEFAULT_COL_WIDTH,
            maxWidth: w
        } : last ? {
            minWidth: TABLE_LAST_COL_MIN_WIDTH
        } : {
            width: w,
            minWidth: w,
            maxWidth: w
        };
        return /*#__PURE__*/ React.createElement("col", {
            key: i,
            style: style
        });
    }));
};
TableColgroup.displayName = 'TableColgroup';
export var TABLE_ROW_INDEX_COL_WIDTH = ROW_INDEX_COL_WIDTH;
