import config from 'config'

type RegionOption = {
  label: string
  value: string
}

export const APP_DELIVERY_REPO = () => {
  return config.PARTITION === 'CN'
    ? 'pingkaicloud/app-delivery'
    : 'tidbcloud/app-delivery'
}

export const TICKET_URL = () => {
  return config.PARTITION === 'CN'
    ? 'https://ones.cn/project/#/team/L2Lt9J6g/project/OPS/component/MQDZEUKm/view/EumRMBUH/issue/'
    : 'https://tidb.atlassian.net/browse/'
}

const GLOBAL_REGION_OPTIONS: RegionOption[] = [
  { label: 'AWS Oregon (us-west-2)', value: 'aws-us-west-2' },
  { label: 'AWS N. Virginia (us-east-1)', value: 'aws-us-east-1' },
  { label: 'AWS Mumbai (ap-south-1)', value: 'aws-ap-south-1' },
  { label: 'AWS Singapore (ap-southeast-1)', value: 'aws-ap-southeast-1' },
  { label: 'AWS Sydney (ap-southeast-2)', value: 'aws-ap-southeast-2' },
  { label: 'AWS Jakarta (ap-southeast-3)', value: 'aws-ap-southeast-3' },
  { label: 'AWS Seoul (ap-northeast-2)', value: 'aws-ap-northeast-2' },
  { label: 'AWS Tokyo (ap-northeast-1)', value: 'aws-ap-northeast-1' },
  { label: 'AWS Frankfurt (eu-central-1)', value: 'aws-eu-central-1' },
  { label: 'AWS Sao Paulo (sa-east-1)', value: 'aws-sa-east-1' },
  { label: 'GCP Oregon (us-west1)', value: 'gcp-us-west1' },
  { label: 'GCP N. Virginia (us-east4)', value: 'gcp-us-east4' },
  { label: 'GCP Iowa (us-central1)', value: 'gcp-us-central1' },
  { label: 'GCP Singapore (asia-southeast1)', value: 'gcp-asia-southeast1' },
  { label: 'GCP Taiwan (asia-east1)', value: 'gcp-asia-east1' },
  { label: 'GCP Tokyo (asia-northeast1)', value: 'gcp-asia-northeast1' },
  { label: 'GCP Osaka (asia-northeast2)', value: 'gcp-asia-northeast2' },
  {
    label: 'Azure Southeast Asia (southeastasia)',
    value: 'azure-southeastasia'
  },
  { label: 'Azure Japan East (japaneast)', value: 'azure-japaneast' },
  { label: 'AWS Stockholm (eu-north-1)', value: 'aws-eu-north-1' },
  { label: 'AWS Hong Kong (ap-east-1)', value: 'aws-ap-east-1' },
  { label: 'AWS Ohio (us-east-2)', value: 'aws-us-east-2' },
  { label: 'AWS Malaysia (ap-southeast-5)', value: 'aws-ap-southeast-5' },
  { label: 'AWS Osaka (ap-northeast-3)', value: 'aws-ap-northeast-3' },
  { label: 'AWS Ireland (eu-west-1)', value: 'aws-eu-west-1' },
  { label: 'GCP Jakarta (ap-southeast-3)', value: 'gcp-ap-southeast3' },
  { label: 'GCP Hong Kong (asia-east-2)', value: 'gcp-asia-east2' },
  { label: 'Azure East US 2 (eastus2)', value: 'azure-eastus2' },
  { label: 'Azure West Europe (westeurope)', value: 'azure-westeurope' },
  {
    label: 'Alicloud Singapore (ap-southeast-1)',
    value: 'alicloud-ap-southeast-1'
  },
  {
    label: 'Alicloud Jakarta (ap-southeast-5)',
    value: 'alicloud-ap-southeast-5'
  },
  {
    label: 'Alicloud Tokyo (ap-northeast-1)',
    value: 'alicloud-ap-northeast-1'
  },
  { label: 'Alicloud Mexico (na-south-1)', value: 'alicloud-na-south-1' },
  { label: 'Alicloud Virginia (us-east-1)', value: 'alicloud-us-east-1' }
]

const CN_REGION_OPTIONS: RegionOption[] = [
  { label: 'Alicloud Beijing (cn-beijing)', value: 'alicloud-cn-beijing' },
  { label: 'Alicloud Shanghai (cn-shanghai)', value: 'alicloud-cn-shanghai' },
  { label: 'Alicloud Shanghai (cn-shanghai)', value: 'alicloud-cn-shanghai' },
  {
    label: 'Tencentcloud Shanghai (cn-shanghai)',
    value: 'tencentcloud-cn-shanghai'
  }
]

export const REGION_OPTIONS = (provider?: string) => {
  const options =
    config.PARTITION === 'CN' ? CN_REGION_OPTIONS : GLOBAL_REGION_OPTIONS

  if (!provider) {
    return options
  }

  return options.filter((option) => option.value.startsWith(provider))
}
