"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.calcColumns = void 0;
var _ui = require("@mirai/ui");
const ITEMS_PER_COLUMN = 18;
const ITEM_WIDTH = 300;
const MAX_COLUMNS = 3;
const THEME_KEY = '--mirai-places';
const calcColumns = function () {
  let {
    dataSource: {
      length: items
    } = [],
    device: {
      width: deviceWidth
    } = {}
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  const {
    ItemsPerColumn = ITEMS_PER_COLUMN,
    ItemWidth: itemWidth = ITEM_WIDTH
  } = _ui.Theme.get(THEME_KEY);
  const itemsPerColumn = Number(ItemsPerColumn);
  let columns = items > itemsPerColumn ? Math.ceil(items / itemsPerColumn) : undefined;
  if (columns * itemWidth > deviceWidth * 0.8 || columns > MAX_COLUMNS) columns = 1;
  return columns;
};
exports.calcColumns = calcColumns;
//# sourceMappingURL=calcColumns.js.map