export const modelsByProviders = {
  AMAZON: 'awsRecognitionModels',
  CLARIFAI: 'clarifaiModels',
  GOOGLE: 'googleModels',
  WEAVO: 'weavoModels',
};

export const iabClassificationCategoriesCollection = [
  {
    name: 'BRANDS',
    value: 'BRANDS',
  },
  {
    name: 'BRAND_SAFETY',
    value: 'BRAND_SAFETY',
  },
  {
    name: 'KEYWORDS',
    value: 'KEYWORDS',
  },
  {
    name: 'PEOPLE',
    value: 'PEOPLE',
  },
  {
    name: 'TEXT',
    value: 'TEXT',
  },
];

export const getDefaultTempForm = (providers, providerName) => {
  const providerModels = providers.find(($el) => $el.provider === providerName)?.models ?? [];

  return {
    model: {
      options: providerModels.map((item) => ({ ...item })),
      selected: providerModels[0]?.value ?? '',
    },
    category: {
      options: iabClassificationCategoriesCollection.map((item) => ({ ...item })),
      selected: iabClassificationCategoriesCollection[0].value,
    },
    lowerBound: {
      value: '0.5',
    },
    maxResults: {
      value: '',
    },
  };
};

export const numberInRange = ({ min, max, isFloat, value }) => {
  let resultValue = isFloat ? parseFloat(value) : parseInt(value, 10);

  if (resultValue < min) {
    resultValue = min;
  } else if (resultValue > max) {
    resultValue = max;
  }

  return resultValue;
};
