function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
/**
 * 将间距值转换为 CSS 值
 * @param value - 间距值，可以是数字或字符串
 * @returns CSS 间距值字符串
 * @example
 * normalizeGap(16) // '16px'
 * normalizeGap('1rem') // '1rem'
 * normalizeGap(undefined) // undefined
 */
export var normalizeGap = function normalizeGap(value) {
  if (value === undefined || value === null) {
    return undefined;
  }
  if (typeof value === 'number') {
    return "".concat(value, "px");
  }
  return value;
};

/**
 * 计算 flex-basis 值，考虑 gap 影响
 * @param columns - 一行显示的元素个数
 * @param gap - 间距值
 * @returns flex-basis CSS 值
 * @description 公式：calc((100% - gap * (N-1)) / N)
 * @example
 * calculateFlexBasis(4, 16) // 'calc((100% - 16px * 3) / 4)'
 * calculateFlexBasis(3, '1rem') // 'calc((100% - 1rem * 2) / 3)'
 */
export var calculateFlexBasis = function calculateFlexBasis(columns, gap) {
  var gapValue = normalizeGap(gap) || '0px';
  var gapCount = columns - 1;
  if (gapCount <= 0) {
    return '100%';
  }
  return "calc((100% - ".concat(gapValue, " * ").concat(gapCount, ") / ").concat(columns, ")");
};

/**
 * 获取数据项的唯一 key
 * @param item - 数据项
 * @param index - 索引
 * @param rowKey - rowKey 配置
 * @returns 唯一 key 字符串
 * @example
 * getRowKey({ id: 1 }, 0, 'id') // '1'
 * getRowKey({ id: 1 }, 0, (item, index) => `item-${item.id}`) // 'item-1'
 * getRowKey({ id: 1 }, 0) // '0'
 */
export var getRowKey = function getRowKey(item, index, rowKey) {
  if (typeof rowKey === 'function') {
    return rowKey(item, index);
  }
  if (typeof rowKey === 'string' && item && _typeof(item) === 'object') {
    var key = item[rowKey];
    if (key !== undefined && key !== null) {
      return String(key);
    }
  }
  return String(index);
};

/**
 * flex-direction 映射表
 * @description 将 direction 属性值映射为 CSS flex-direction 值
 */
export var DIRECTION_MAP = {
  horizontal: 'row',
  'horizontal-reverse': 'row-reverse',
  vertical: 'column',
  'vertical-reverse': 'column-reverse'
};

/**
 * flex-wrap 映射表
 * @description 将 wrap 属性值映射为 CSS flex-wrap 值
 */
export var WRAP_MAP = {
  nowrap: 'nowrap',
  wrap: 'wrap',
  'wrap-reverse': 'wrap-reverse'
};

/**
 * justify-content 映射表
 * @description 将 justify 属性值映射为 CSS justify-content 值
 */
export var JUSTIFY_MAP = {
  start: 'flex-start',
  end: 'flex-end',
  center: 'center',
  between: 'space-between',
  around: 'space-around',
  evenly: 'space-evenly'
};

/**
 * align-items 映射表
 * @description 将 align 属性值映射为 CSS align-items 值
 */
export var ALIGN_MAP = {
  start: 'flex-start',
  end: 'flex-end',
  center: 'center',
  stretch: 'stretch',
  baseline: 'baseline'
};

/**
 * align-content 映射表
 * @description 将 alignContent 属性值映射为 CSS align-content 值
 */
export var ALIGN_CONTENT_MAP = {
  start: 'flex-start',
  end: 'flex-end',
  center: 'center',
  between: 'space-between',
  around: 'space-around',
  stretch: 'stretch'
};

/**
 * 组件样式前缀
 */
export var COMPONENT_PREFIX = 'pisell-basic-grid';