<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import MultipleChoiceInput from '../BuiltInFormControls/MultipleChoiceInput';

const BucketInput = ({ signup, ...otherProps }) => {
  const bucketChoices = signup.run.event.registration_policy.buckets.map((bucket) => {
    const addenda = [];
    if (bucket.key === signup.bucket_key) {
      addenda.push('current');
    }
    if (bucket.key === signup.requested_bucket_key) {
      addenda.push('user requested');
    }
    const addendaString = (addenda.length > 0 ? ` (${addenda.join(', ')})` : '');

    const disabled = (
      bucket.key === signup.bucket_key ||
      (bucket.anything && signup.bucket_key)
    );

    return {
      value: bucket.key,
      label: `${bucket.name}${addendaString}`,
      disabled,
    };
  });

  return (
    <MultipleChoiceInput
      choices={bucketChoices}<commit_msg>Refactor for complexity reduction<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import MultipleChoiceInput from '../BuiltInFormControls/MultipleChoiceInput';

function getLabelForBucketChoice(signup, bucket) {
  const addenda = [];
  if (bucket.key === signup.bucket_key) {
    addenda.push('current');
  }
  if (bucket.key === signup.requested_bucket_key) {
    addenda.push('user requested');
  }
  const addendaString = (addenda.length > 0 ? ` (${addenda.join(', ')})` : '');

  return `${bucket.name}${addendaString}`;
}

function shouldBucketChoiceBeDisabled(signup, bucket) {
  return (
    bucket.key === signup.bucket_key ||
    (bucket.anything && signup.bucket_key)
  );
}

const BucketInput = ({ signup, ...otherProps }) => {
  const bucketChoices = signup.run.event.registration_policy.buckets.map(bucket => ({
    value: bucket.key,
    label: getLabelForBucketChoice(signup, bucket),
    disabled: shouldBucketChoiceBeDisabled(signup, bucket),
  }));

  return (
    <MultipleChoiceInput
      choices={bucketChoices}
{'fraction_non_alphanumeric': 0.15148413510747186, 'fraction_numerical': 0.0010235414534288639, 'mean_word_length': 3.8753117206982544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5617251', 'n_tokens_mistral': 615, 'n_tokens_neox': 602, 'n_words': 111}