import { syncWithSharedQuery, TaskState, } from '@wix/bex-core';
import { createNestedOptimisticActions } from './createNestedOptimisticActions';
export class NestedTableFlatModeSectionState {
    constructor(params) {
        this.levelDescriptors = [];
        this.initTask = new TaskState();
        const { levelDescriptor } = params;
        this.levelDescriptor = levelDescriptor;
        const nestedOptimisticActionsState = {
            levelDescriptor: this.levelDescriptor,
        };
        const { collection, parentFilter } = levelDescriptor.createCollection(nestedOptimisticActionsState);
        createNestedOptimisticActions(params.flatModeState.wrapper.container, collection, {
            ...nestedOptimisticActionsState,
            parentFilter,
        });
        this.collection = collection;
        const { query: sharedQuery } = params;
        const { query } = collection;
        syncWithSharedQuery(query, sharedQuery);
    }
    get query() {
        return this.collection.query;
    }
    get columns() {
        return this.levelDescriptor.columns;
    }
    get renderMainColumn() {
        return this.levelDescriptor.renderMainColumn;
    }
    get breadcrumbs() {
        return this.levelDescriptor.breadcrumbs;
    }
    get expandable() {
        return this.levelDescriptor.expandable;
    }
    init() {
        const { collection } = this;
        const disposers = [collection._optimisticActions?.init()];
        return () => {
            disposers.forEach((d) => d?.());
        };
    }
}
//# sourceMappingURL=NestedTableFlatModeSectionState.js.map