import identity from './identity';
import metadata from './metadata';
import summary from './summary';
import county from './county';
import metadataCollection from './metadataCollection';
import candidateMetadata from './candidateMetadata';
import candidateMetadataCollection from './candidateMetadataCollection';
import summaryCollection from './summaryCollection';
import countyCollection from './countyCollection';
import cycleCandidateMetadataCollection from './cycleCandidateMetadataCollection';
import delegates from './delegates';
import combinedMetadata from './combinedMetadata';
import combinedMetadataCollection from './combinedMetadataCollection';
import callFeed from './callFeed';
const typeReformatter = {
  metadata,
  summary,
  county,
  'metadata-collection': metadataCollection,
  candidate: candidateMetadata,
  'candidate-collection': candidateMetadataCollection,
  'summary-collection': summaryCollection,
  'county-collection': countyCollection,
  'cycle-candidate-collection': cycleCandidateMetadataCollection,
  delegates,
  'combined-metadata': combinedMetadata,
  'combined-metadata-collection': combinedMetadataCollection,
  'call-feed': callFeed
};
const reformat = function reformat(source) {
  if (!source || !source.data) return source;
  const {
    config: {
      type
    },
    data
  } = source;
  const reformatter = typeReformatter[type] || identity;
  return {
    ...source,
    data: reformatter(data)
  };
};
export default reformat;