import { type DefaultItemType } from '@composed-components/ConditionLine/types';
import { isConditionEmpty } from '@composed-components/ConditionLine/utils';

import { type SegmentationCriteriaValues } from './types';

export const isSegmentationCriteriaEmpty = <
  FieldItemType extends DefaultItemType,
  ValueItemType extends DefaultItemType,
>(
  values: SegmentationCriteriaValues<FieldItemType, ValueItemType>,
) => {
  if (!values?.conditions?.length) return true;
  return values.conditions.every(isConditionEmpty);
};
