import { getKeyValue } from '../../../../helpers/get-key-value';
import { getErrorObject } from '../../../../helpers/get-error-object'; 
import { 
  transformMessage,
  transformText,
  transformInput,
  transformMenu,
  transformDropdown,
  transformCheckboxGroup,
  transformRadioGroup,
  transformButtonList,
  transformDatepicker,
  transformTimepicker,
  transformGeoLocation,
  transformFileUpload,
  transformCard,
  transformCarousel,
  transformSlider,
  transformMedias
} from '.';

const methods: { [key: string]: Function } = {
  message: transformMessage,
  text: transformText,
  'or-textbox': transformInput,
  'rwc-menu': transformMenu,
  'rwc-dropdown': transformDropdown,
  'rwc-checkbox-group': transformCheckboxGroup,
  'rwc-radio-group': transformRadioGroup,
  'rwc-buttons-list': transformButtonList,
  'rwc-datepicker': transformDatepicker,
  'rwc-timepicker': transformTimepicker,
  'rwc-location': transformGeoLocation,
  'rwc-attachment': transformFileUpload,
  'rwc-card': transformCard,
  'rwc-carousel': transformCarousel,
  'rwc-slider': transformSlider,
  'medias': transformMedias
};

export const getMethods = (type: string): Function => {
  return getKeyValue(methods)(type) || getErrorObject({ type, message: 'RWCv4 to Generic' });
};
