import _extends from "@babel/runtime/helpers/extends";
import "core-js/modules/es.array.map.js";
import * as React from 'react';
import { Grid, GridColumn } from '@megafon/ui-core';
import { cnCreate } from '@megafon/ui-helpers';
import "./DownloadLinks.css";
export var getColumnConfig = function getColumnConfig(itemsCount) {
  switch (true) {
    case itemsCount <= 2:
      {
        return {
          all: '7',
          mobile: '12'
        };
      }
    case itemsCount <= 4:
      {
        return {
          all: '6',
          mobile: '12'
        };
      }
    default:
      {
        return {
          wide: '4',
          desktop: '4',
          tablet: '6',
          mobile: '12'
        };
      }
  }
};
var testIdPrefix = 'DownloadLinks';
var cn = cnCreate('mfui-9-download-links');
var DownloadLinks = function DownloadLinks(_ref) {
  var _ref$inOneColumn = _ref.inOneColumn,
    inOneColumn = _ref$inOneColumn === void 0 ? false : _ref$inOneColumn,
    children = _ref.children;
  if (inOneColumn) {
    return /*#__PURE__*/React.createElement("div", {
      className: cn(),
      "data-testid": "".concat(testIdPrefix, "-oneColumn")
    }, React.Children.map(children, function (child) {
      return /*#__PURE__*/React.createElement("div", {
        className: cn('item')
      }, child);
    }));
  }
  var itemsCount = React.Children.count(children);
  var columnConfig = getColumnConfig(itemsCount);
  return /*#__PURE__*/React.createElement("div", {
    className: cn({
      count: "".concat(itemsCount)
    })
  }, /*#__PURE__*/React.createElement(Grid, {
    guttersLeft: "medium"
  }, React.Children.map(children, function (child) {
    return /*#__PURE__*/React.createElement(GridColumn, _extends({}, columnConfig, {
      className: cn('column')
    }), child);
  })));
};
export default DownloadLinks;