"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ToolbarResponsivePriorityState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _mobx = require("mobx");
class ToolbarResponsivePriorityState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "responsive", void 0);
    (0, _defineProperty2.default)(this, "expandedWidth", void 0);
    (0, _defineProperty2.default)(this, "collapsedWidth", void 0);
    (0, _defineProperty2.default)(this, "_shouldShrink", false);
    (0, _defineProperty2.default)(this, "_groupElement", null);
    this.expandedWidth = params.expandedWidth ?? 0;
    this.collapsedWidth = params.collapsedWidth ?? 0;
    this.responsive = params.responsive;
    (0, _mobx.makeObservable)(this, {
      _shouldShrink: _mobx.observable.ref,
      _syncWidth: _mobx.action
    });
  }
  _syncWidth() {
    const {
      _groupElement,
      _shouldShrink,
      responsive
    } = this;
    if (responsive.responsiveDisabled) {
      return;
    }
    if (!_groupElement) {
      return;
    }
    const measured = _groupElement.scrollWidth;
    if (_shouldShrink) {
      this.collapsedWidth = measured;
    } else {
      this.expandedWidth = measured;
    }
    responsive._scheduleRecompute();
  }
}
exports.ToolbarResponsivePriorityState = ToolbarResponsivePriorityState;
//# sourceMappingURL=ToolbarResponsivePriorityState.js.map