import { Input, InputType } from '../../types';
import { TextFilterInput, TextFilterInputSchema } from '../schemas';

/**
 * Maps an Input object to a TextFilterInput object
 *
 * This function takes an input of type Text and maps it to a strongly-typed
 * TextFilterInput object, validating it against a schema.
 *
 * @param group - The group identifier that this input belongs to
 * @param input - The source input object to map
 * @returns A validated TextFilterInput object
 */
export function textFilterInputMapping(
  group: string,
  input: Input,
): TextFilterInput {
  return TextFilterInputSchema.parse({
    group,
    key: input.key,
    label: input.label,
    description: input.description,
    type: InputType.Text,
    defaultValue: input.value,
    value: input.value,
    placeholder: input.placeholder,
    target: input.target,
  });
}
