import { get } from 'mobx';
import { ShowHelp } from '../field/enum';
export function defaultAggregationRenderer(_ref) {
  var text = _ref.text;
  return text;
}
export var ColumnDefaultProps = {
  hidden: false,
  lock: false,
  resizable: true,
  sortable: false,
  hideable: true,
  aggregationLimit: 4,
  showHelp: ShowHelp.tooltip
};

var Column = function Column() {
  return null;
};

Column.__PRO_TABLE_COLUMN = true;
Column.defaultProps = ColumnDefaultProps;
export default Column;
export function minColumnWidth(col, store) {
  var hidden = get(col, 'hidden');

  if (hidden) {
    return 0;
  }

  var width = get(col, 'width');
  var min = get(col, 'minWidth');
  var aggregation = get(col, 'aggregation');
  var minWidth = min === undefined ? store.getConfig(aggregation ? 'tableAggregationColumnDefaultMinWidth' : 'tableColumnDefaultMinWidth') : min;

  if (width === undefined) {
    return minWidth;
  }

  return Math.min(width, minWidth);
}

function getDefaultWidth(col, store, aggregation) {
  var defaultWidth = get(col, 'defaultWidth');

  if (defaultWidth === undefined) {
    return store.getConfig(aggregation ? 'tableAggregationColumnDefaultWidth' : 'tableColumnDefaultWidth');
  }

  return defaultWidth;
}

function getMinWidth(col, store, aggregation) {
  var minWidth = get(col, 'minWidth');

  if (minWidth === undefined) {
    return store.getConfig(aggregation ? 'tableAggregationColumnDefaultMinWidth' : 'tableColumnDefaultMinWidth');
  }

  return minWidth;
}

export function columnWidth(col, store) {
  var hidden = get(col, 'hidden');

  if (hidden) {
    return 0;
  }

  var width = get(col, 'width');

  if (width === undefined) {
    var aggregation = get(col, 'aggregation');
    var defaultWidth = getDefaultWidth(col, store, aggregation);
    var minWidth = getMinWidth(col, store, aggregation);
    return Math.max(minWidth, defaultWidth);
  }

  return width;
}
//# sourceMappingURL=Column.js.map
