import { computed, makeObservable, observable } from 'mobx';
export class GridSectionsState {
    constructor(params) {
        this.collection = params.collection;
        this.toolbar = params.toolbar;
        this.renderSection = params.renderSection;
        this.parentState = params.parentState;
        makeObservable(this, {
            sections: computed,
            renderSection: observable.ref,
        });
    }
    get sections() {
        const { collection, renderSection } = this;
        if (!renderSection) {
            return [];
        }
        return Object.values(collection.result.items.reduce((acc, item, index) => {
            const section = renderSection(item);
            if (!acc[section.id]) {
                acc[section.id] = {
                    section,
                    range: {
                        start: index,
                        length: 0,
                    },
                };
            }
            acc[section.id].range.length++;
            return acc;
        }, {}));
    }
}
//# sourceMappingURL=GridSectionsState.js.map