"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ResponsiveColumnsState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _mobx = require("mobx");
class ResponsiveColumnsState {
  constructor({
    gridState,
    minItemWidth,
    rectState,
    containerPadding = 0
  }) {
    (0, _defineProperty2.default)(this, "gridState", void 0);
    (0, _defineProperty2.default)(this, "_minItemWidth", void 0);
    (0, _defineProperty2.default)(this, "_rectState", void 0);
    (0, _defineProperty2.default)(this, "_containerPadding", void 0);
    this.gridState = gridState;
    this._minItemWidth = minItemWidth;
    this._rectState = rectState;
    this._containerPadding = containerPadding;
    (0, _mobx.makeObservable)(this, {
      itemsContentWidth: _mobx.computed,
      widthWithLastColumnGap: _mobx.computed,
      columnCount: _mobx.computed,
      containerPadding: _mobx.computed
    });
  }
  get gap() {
    return this.gridState.gap;
  }
  get minItemWidth() {
    return this._minItemWidth;
  }
  get itemsContentWidth() {
    return this._rectState.rect.width ?? 0;
  }
  get widthWithLastColumnGap() {
    return this.itemsContentWidth + this.gap - this.containerPadding;
  }
  get containerPadding() {
    return this._containerPadding;
  }
  get columnCount() {
    const {
      gap,
      minItemWidth,
      widthWithLastColumnGap
    } = this;
    const maxItemWidthWithGap = minItemWidth + gap;
    return Math.max(Math.floor(widthWithLastColumnGap / maxItemWidthWithGap), 1);
  }
}
exports.ResponsiveColumnsState = ResponsiveColumnsState;
//# sourceMappingURL=ResponsiveColumnsState.js.map