"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.TableGridSwitchFoldersState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _bexCore = require("@wix/bex-core");
var _GridFoldersState = require("./GridFoldersState");
var _TableFoldersState = require("./TableFoldersState");
var _mobx = require("mobx");
var _ToolbarCollectionState = require("./ToolbarCollectionState");
var _ViewTypeState = require("./ViewTypeState");
class TableGridSwitchFoldersState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "container", void 0);
    (0, _defineProperty2.default)(this, "initTask", new _bexCore.TaskState());
    (0, _defineProperty2.default)(this, "containerOverrides", void 0);
    (0, _defineProperty2.default)(this, "gridFoldersState", void 0);
    (0, _defineProperty2.default)(this, "tableFoldersState", void 0);
    (0, _defineProperty2.default)(this, "viewTypeState", void 0);
    this.container = params.container;
    this.containerOverrides = params.containerOverrides;
    this.tableFoldersState = new _TableFoldersState.TableFoldersState({
      items: params.items,
      folders: params.folders,
      container: this.container,
      toolbar: new _ToolbarCollectionState.ToolbarCollectionState({
        componentType: 'TableGridSwitchFolders',
        collection: params.items,
        container: params.container,
        reportBi: biParams => this.container.reportBi({
          ...biParams,
          params: {
            ...biParams.params,
            componentStatus: this.viewTypeState.viewType
          }
        })
      })
    });
    this.gridFoldersState = new _GridFoldersState.GridFoldersState({
      items: params.items,
      folders: params.folders,
      container: this.container,
      toolbar: this.tableFoldersState.toolbar,
      collections: this.tableFoldersState.collections
    });
    this.viewTypeState = new _ViewTypeState.ViewTypeState({
      container: this.container,
      dataCapsule: this.toolbar.dataCapsule,
      componentType: 'TableGridSwitchFolders'
    });
    (0, _mobx.makeObservable)(this, {
      viewType: _mobx.computed
    });
  }
  get viewType() {
    return this.viewTypeState.viewType;
  }
  set viewType(viewType) {
    (0, _mobx.runInAction)(() => {
      this.viewTypeState.viewType = viewType;
    });
  }
  get toolbar() {
    return this.tableFoldersState.toolbar;
  }
  init() {
    this.initTask.runOnce(async () => {
      await this.viewTypeState.init();
    });
  }
}
exports.TableGridSwitchFoldersState = TableGridSwitchFoldersState;
//# sourceMappingURL=TableGridSwitchFoldersState.js.map