import { FiltersMap } from '@wix/bex-core';
import { ToolbarCollectionState } from '../../state';
import { ReorderModeState } from './ReorderModeState';
import { runInAction } from 'mobx';

export function setReorderModeState<T, F extends FiltersMap>(
  toolbar: ToolbarCollectionState<T, F>,
) {
  runInAction(() => {
    if (!toolbar._dnd) {
      return;
    }
    toolbar._dnd.reorderModeState ??= new ReorderModeState({
      toolbar,
      container: toolbar.container,
      closeSidePanel: toolbar.closeSidePanel,
    });
  });
}
