import { CheckboxFilterInput, CheckboxFilterInputOption } from '../core';

export function getAllCheckboxOptionsHelper(
  input: CheckboxFilterInput,
): CheckboxFilterInputOption[] {
  const getAllOptions = (
    options: CheckboxFilterInputOption[],
  ): CheckboxFilterInputOption[] => {
    return options.flatMap((option) => [
      option,
      ...getAllOptions(option.values || []),
    ]);
  };

  return getAllOptions(input.options || []);
}
