import {
  CollectionState,
  Filter,
  FiltersMap,
  KeyedItem,
  SelectState,
} from '@wix/bex-core';

export interface CollectionFilterStateParams<T, F extends FiltersMap> {
  filter: Filter<T[]>;
  collection: CollectionState<T, F>;
}

export class CollectionFilterState<T, F extends FiltersMap> {
  readonly filter: CollectionFilterStateParams<T, F>['filter'];
  readonly collection: CollectionFilterStateParams<T, F>['collection'];
  readonly select = new SelectState<KeyedItem<T>>({
    keyGetter: (value) => value.key,
  });

  constructor(params: CollectionFilterStateParams<T, F>) {
    this.filter = params.filter;
    this.collection = params.collection;
  }
}
