import { TFunction } from 'i18next';

export const CLUSTER_NAME_MAX_LENGTH = 54;

export const clusterNameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH_OCM: t('ai:1-{{count}} characters', { count: CLUSTER_NAME_MAX_LENGTH }),
  INVALID_LENGTH_ACM: t('ai:2-{{count}} characters', { count: CLUSTER_NAME_MAX_LENGTH }),
  INVALID_VALUE: t('ai:Use lowercase alphanumeric characters or hyphen (-)'),
  INVALID_START_END: t('ai:Start and end with a lowercase letter or a number.'),
  NOT_UNIQUE: t('ai:Must be unique'),
});

export const ocmClusterNameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: clusterNameValidationMessages(t).INVALID_LENGTH_OCM,
  INVALID_VALUE: clusterNameValidationMessages(t).INVALID_VALUE,
  INVALID_START_END: clusterNameValidationMessages(t).INVALID_START_END,
});

export const uniqueOcmClusterNameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: clusterNameValidationMessages(t).INVALID_LENGTH_OCM,
  INVALID_VALUE: clusterNameValidationMessages(t).INVALID_VALUE,
  INVALID_START_END: clusterNameValidationMessages(t).INVALID_START_END,
  NOT_UNIQUE: clusterNameValidationMessages(t).NOT_UNIQUE,
});

export const acmClusterNameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: clusterNameValidationMessages(t).INVALID_LENGTH_ACM,
  INVALID_VALUE: clusterNameValidationMessages(t).INVALID_VALUE,
  INVALID_START_END: clusterNameValidationMessages(t).INVALID_START_END,
  NOT_UNIQUE: clusterNameValidationMessages(t).NOT_UNIQUE,
});

export const nameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: t('ai:1-253 characters'),
  NOT_UNIQUE: t('ai:Must be unique'),
  INVALID_VALUE: t('ai:Use lowercase alphanumeric characters, dot (.) or hyphen (-)'),
  INVALID_START_END: t('ai:Must start and end with an lowercase alphanumeric character'),
  INVALID_FORMAT: t('ai:Number of characters between dots (.) must be 1-63'),
});

export const BMCValidationMessages = (t: TFunction) => ({
  ...nameValidationMessages(t),
  LOCALHOST_ERR: t('ai:Do not use forbidden words, for example: "localhost".'),
});

export const hostnameValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: t('ai:1-63 characters'),
  NOT_UNIQUE: t('ai:Must be unique'),
  INVALID_VALUE: t('ai:Use lowercase alphanumeric characters, dot (.) or hyphen (-)'),
  INVALID_START_END: t('ai:Must start and end with an lowercase alphanumeric character'),
  LOCALHOST_ERR: t('ai:Do not use forbidden words, for example: "localhost".'),
});

export const locationValidationMessages = (t: TFunction) => ({
  INVALID_LENGTH: t('ai:1-63 characters'),
  INVALID_VALUE: t('ai:Use alphanumeric characters, dot (.), underscore (_) or hyphen (-)'),
  INVALID_START_END: t('ai:Must start and end with an alphanumeric character'),
});

export const FORBIDDEN_HOSTNAMES = [
  'localhost',
  'localhost.localdomain',
  'localhost4',
  'localhost4.localdomain4',
  'localhost6',
  'localhost6.localdomain6',
];

export const getIncorrectFileTypeMessage = (t: TFunction) =>
  t('ai:File type is not supported. File type must be yaml, yml, json, yaml.patch. or yml.patch.');
