import { TaskState, } from '@wix/bex-core';
import { GridFoldersState } from './GridFoldersState';
import { TableFoldersState } from './TableFoldersState';
import { runInAction, makeObservable, computed } from 'mobx';
import { ToolbarCollectionState } from './ToolbarCollectionState';
import { ViewTypeState } from './ViewTypeState';
export class TableGridSwitchFoldersState {
    constructor(params) {
        this.initTask = new TaskState();
        this.container = params.container;
        this.containerOverrides = params.containerOverrides;
        this.tableFoldersState = new TableFoldersState({
            items: params.items,
            folders: params.folders,
            container: this.container,
            toolbar: new 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({
            items: params.items,
            folders: params.folders,
            container: this.container,
            toolbar: this.tableFoldersState.toolbar,
            collections: this.tableFoldersState.collections,
        });
        this.viewTypeState = new ViewTypeState({
            container: this.container,
            dataCapsule: this.toolbar.dataCapsule,
            componentType: 'TableGridSwitchFolders',
            options: ['table', 'grid'],
        });
        this.toolbar.layoutState = this;
        makeObservable(this, {
            viewType: computed,
        });
    }
    get viewType() {
        return this.viewTypeState.viewType;
    }
    set viewType(viewType) {
        runInAction(() => {
            this.viewTypeState.viewType = viewType;
        });
    }
    get toolbar() {
        return this.tableFoldersState.toolbar;
    }
    init() {
        this.initTask.runOnce(async () => {
            await this.viewTypeState.init();
        });
    }
}
//# sourceMappingURL=TableGridSwitchFoldersState.js.map