export const language = {
  PoweredByDigitalTechnologyCenterYIP: {
    en: 'Powered by Yili Data Technology Center',
    zh: '由数字科技中心YIP提供支持'
  },

  PleaseSelectAtLeastOneOptionsPerLine: {
    en: (count, row) =>
      typeof row === 'number'
        ? `Please select at least ${count} answer option${count > 1 ? 's' : ''} at row ${row + 1}.`
        : `Please select at least ${count} answer option${count > 1 ? 's' : ''} per row.`,
    zh: (count, row) =>
      typeof row === 'number' ? `第${row + 1}行最少选${count}个。` : `每行最少选${count}个。`
  },
  PleaseSelectLessOptionsPerLine: {
    en: (count, row) =>
      typeof row === 'number'
        ? `Please select no more than ${count} answer option${count > 1 ? 's' : ''} at row ${row + 1}.`
        : `Please select no more than ${count} answer option${count > 1 ? 's' : ''} per row.`,
    zh: (count, row) =>
      typeof row === 'number' ? `第${row + 1}行最多选${count}个。` : `每行最多选${count}个。`
  },
  PleaseSelectAtLeastOneOptionsPerColumn: {
    en: (count, column) =>
      typeof column === 'number'
        ? `Please select at least ${count} answer option${count > 1 ? 's' : ''} at column ${column + 1}.`
        : `Please select at least ${count} answer option${count > 1 ? 's' : ''} per column.`,
    zh: (count, column) =>
      typeof column === 'number' ? `第${column + 1}列最少选${count}个。` : `每列最少选${count}个。`
  },
  PleaseSelectLessOptionsPerColumn: {
    en: (count, column) =>
      typeof column === 'number'
        ? `Please select no more than ${count} answer option${count > 1 ? 's' : ''} at column ${column + 1}.`
        : `Please select no more than ${count} answer option${count > 1 ? 's' : ''} per column.`,
    zh: (count, column) =>
      typeof column === 'number' ? `第${column + 1}列最多选${count}个。` : `每列最多选${count}个。`
  },
  PleaseCategorizeAllOptions: {
    en: 'Please categorize all answer options.',
    zh: '部分选项未归类。'
  },
  ThisIsARequiredQuestion: {
    en: 'This is compulsory.',
    zh: '请填写当前题目'
  },
  PleaseSelectAllRows: {
    en: 'Please select all rows.',
    zh: '请完成所有行。'
  },
  PleaseInputAValue: {
    en: 'Please input a value.',
    zh: '请输入。'
  },
  PleaseSelectAtLeastOneOptions: {
    en: (count) => `Please select at least ${count} answer option${count > 1 ? 's' : ''}.`,
    zh: (count) => `最少选择${count}个。`
  },
  PleaseSelectNoMoreOptions: {
    en: (count) => `Please select no more than ${count} answer option${count > 1 ? 's' : ''}.`,
    zh: (count) => `最多选择${count}个。`
  },
  PleaseSelectAtLeastOneOptionsInTitleGroup: {
    en: (count, title) =>
      `Please select at least ${count} answer option${count > 1 ? 's' : ''} in ${title} group.`,
    zh: (count, title) => `${title}最少选择${count}个。`
  },
  PleaseSelectAtMostOneOptionsInTitleGroup: {
    en: (count, title) =>
      `Please select at most ${count} answer option${count > 1 ? 's' : ''} in ${title} group.`,
    zh: (count, title) => `${title}最多选择${count}个。`
  },
  PleaseSelectAtLeastOnePictures: {
    en: (count) => `Please select at least ${count} picture${count > 1 ? 's' : ''}.`,
    zh: (count) => `最少选择${count}个。`
  },
  PleaseLetTheSumEqualToTotal: {
    en: (count) => `Please let the sum equal to ${count}.`,
    zh: (count) => `请让总和等于${count}。`
  },
  PleaseUploadAtLeastOneFiles: {
    en: (count) => `Please upload at least ${count} file${count > 1 ? 's' : ''}.`,
    zh: (count) => `最少上传${count}个文件。`
  },
  PleaseEnterEnglishLetters: {
    en: 'Please enter English letters.',
    zh: '请输入字母。'
  },
  PleaseEnterChineseWords: {
    en: 'Please enter Chinese characters.',
    zh: '请输入中文。'
  },
  PleaseEnterACorrectEmail: {
    en: 'Please enter a valid email.',
    zh: '请输入正确的email。'
  },
  PleaseEnterACorrectPhone: {
    en: 'Please enter a valid phone number.',
    zh: '请输入正确的手机号。'
  },
  PleaseEnterACorrectID: {
    en: 'Please enter a valid ID card number.',
    zh: '请输入正确的身份证号。'
  },
  PleaseEnterMoreThanOneCharacters: {
    en: (count) => `Please enter more than ${count} character${count > 1 ? 's' : ''}.`,
    zh: (count) => `请输入大于${count}个字符。`
  },
  PleaseEnterLessCharacters: {
    en: (count) => `Please enter less than ${count} character${count > 1 ? 's' : ''}.`,
    zh: (count) => `请输入小于${count}个字符。`
  },
  PleaseEnterMoreCharacters: {
    en: (count) => `Please enter more than ${count} character${count > 1 ? 's' : ''}.`,
    zh: (count) => `请输入大于${count}个字符。`
  },

  // 质量控制
  PleaseAnswerCarefully: {
    en: 'Please answer carefully.',
    zh: '请认真作答。'
  },
  ContinueAnswer: {
    en: 'Continue',
    zh: '继续作答'
  },
  ReviseAnswer: {
    en: 'Revise',
    zh: '去修改'
  },
  TheAnswerIsRepeatedMoreThanOneTimesPleaseRevise: {
    en: (count) => `The answer is continuously repeated more than ${count} times, please revise.`,
    zh: (count, type) => `答案连续重复超过${count}个，${type ? '建议' : '请'}修改。`
  },

  // 预览
  QuestionRemark: {
    en: (title) => `${title} remark`,
    zh: (title) => `${title}问题评论`
  },

  // 问卷结束的各种提示
  SurveyEndNotice: {
    en: 'This survey has ended. We look forward to your participation next time.',
    zh: '本次调研活动已经结束，感谢您的参与，请您持续关注'
  },
  SurveyNotStartNotice: {
    en: 'This survey has not yet started.',
    zh: '答题时间还没有开始'
  },
  SurveyTemporarilySuspendedNotice: {
    en: 'This survey is temporarily suspended for collection',
    zh: '此问卷暂停收集'
  },
  LinkDisabledNotice: {
    en: 'The provider has not enabled this link. Please try again later',
    zh: '投放者未启用该链接，请稍后重试'
  },
  FeedbackNotice: {
    en: 'Thank you for participating in this survey. We look forward to your participation next time',
    zh: '感谢您的反馈，期待您下次参与'
  },
  SubmittedNotice: {
    en: 'You have submitted the questionnaire. We look forward to your participation next time.',
    zh: '您已提交答卷，期待您下次反馈'
  },
  SurveyFilledNotice: {
    en: 'You have already filled out this questionnaire',
    zh: '您已填过此问卷'
  },
  FillOutNewSurvey: {
    en: 'Fill out new one',
    zh: '填份新的'
  },
  ReviseSurvey: {
    en: 'Revise',
    zh: '修改内容'
  },

  // 问题的提示文字
  UploadSuccessful: {
    en: 'Upload successful.',
    zh: '上传成功'
  },
  UploadFailed: {
    en: 'Upload failed.',
    zh: '上传失败'
  },
  Loading: {
    en: 'Loading',
    zh: '加载中'
  },
  Start: {
    en: 'Start',
    zh: '开始'
  },

  PleaseAnswerCarefullyOtherwiseRestart: {
    en: 'Please be sure to read the questions carefully. Consecutive answers may invalidate the entire questionnaire. Your answer to each question is of great significance to us.',
    zh: '您在每一题的态度与观点均对我们有非常重要的意义，请您务必仔细阅读题目后回答，连续一致的答案可能会导致整个问卷的作废，请您重新作答。'
  },

  IGotIt: {
    en: 'Got it',
    zh: '我知道啦'
  },

  // BPTO
  Product: {
    en: 'Product',
    zh: '产品'
  },
  Character: {
    en: 'Character',
    zh: '特性'
  },
  Price: {
    en: 'Price',
    zh: '价格'
  },
  PleaseSelect: {
    en: 'Please select',
    zh: '请选择'
  },

  // CBC
  YouHaveNotAnsweredThisQuestionAnswerToContinue: {
    en: 'You have not answered this question. You can continue after answering!',
    zh: '您没有对该问题进行回答，回答后可继续做答！'
  },
  ProductNumber: {
    en: 'Product Number',
    zh: '商品编号'
  },
  ProductName: {
    en: 'Product Name',
    zh: '商品名称'
  },
  ProductDescription: {
    en: 'Product Description',
    zh: '商品介绍'
  },
  ProductDetail: {
    en: 'Product detail',
    zh: '商品详情'
  },
  Above: {
    en: 'Above',
    zh: '以上'
  },
  ChooseNeither: {
    en: 'Choose neither',
    zh: '都不选'
  },

  // KANO
  HaveSomeFeature: {
    en: (feature) => `Have the feature ${feature}`,
    zh: (feature) => `具备${feature}`
  },
  DoNotHaveSomeFeature: {
    en: (feature) => `Do not have the feature ${feature}`,
    zh: (feature) => `不具备${feature}`
  },
  Dislike: {
    en: 'Dislike',
    zh: '不喜欢'
  },
  Tolerable: {
    en: 'Tolerable',
    zh: '能忍受'
  },
  DoesNotMatter: {
    en: 'Does not matter',
    zh: '无所谓'
  },
  ShouldBe: {
    en: 'Should be',
    zh: '理应如此'
  },
  Like: {
    en: 'Like',
    zh: '喜欢'
  },

  // MaxDiff
  PleaseSelectSome: {
    en: (option) => `Please select ${option}`,
    zh: (option) => `请选择${option}`
  },

  // PSM
  PleaseSelectAValueThatIsNoLessThanOneAndNoMoreThanOne: {
    en: (min, max) => `Please select a value that is no less than ${min} and no more than ${max}`,
    zh: (min, max) => `请选择不小于${min}不大于${max}的值`
  },
  PleaseSelectAValueThatIsNoMoreThanOne: {
    en: (min, max) => `Please select a value that is no more than ${max}`,
    zh: (min, max) => `请选择不大于${max}的值`
  },

  // 密码
  PleaseEnterPassword: {
    en: 'Please enter password',
    zh: '请输入密码'
  },

  // 填空题
  PleaseInputANumber: {
    en: 'Please input a number',
    zh: '请输入数字'
  },
  PleaseEnterANumberGreaterThanOrEqualToOne: {
    en: (count) => `Please enter a number greater than or equal to ${count}`,
    zh: (count) => `请输入大于等于${count}的数字`
  },
  PleaseEnterANumberLessThanOrEqualToOne: {
    en: (count) => `Please enter a number less than or equal to ${count}`,
    zh: (count) => `请输入小于等于${count}的数字`
  },

  // 级联题
  PleaseSelectAProvince: {
    en: 'Please select a province',
    zh: '请选择省份'
  },
  PleaseSelectACity: {
    en: 'Please select a city',
    zh: '请选择城市'
  },
  PleaseSelectADistrict: {
    en: 'Please select a district',
    zh: '请选择区县'
  },

  // 分类题
  Option: {
    en: 'Answer Option',
    zh: '选项'
  },
  Category: {
    en: 'Category',
    zh: '分类'
  },
  BracketDragAndDropOptionsHere: {
    en: '(Drag and drop options here)',
    zh: '(选项拖入此处)'
  },

  // 知情同意书题
  OneSecondsLeftToRead: {
    en: (count) => `${count} seconds left to read`,
    zh: (count) => `还需阅读${count}秒`
  },

  // 热区题
  PleaseSelectOneAreas: {
    en: (count) => `Please select ${count} areas`,
    zh: (count) => `请选择${count}个选区`
  },
  PleaseSelectOneFavoriteAreas: {
    en: (count) => `Please select ${count} areas you like`,
    zh: (count) => `请选择${count}个喜欢选区`
  },
  PleaseSelectOneDislikeAreas: {
    en: (count) => `Please select ${count} areas you dislike`,
    zh: (count) => `请选择${count}个不喜欢选区`
  },

  // 图片题
  PleaseClickToViewAllPictures: {
    en: 'Please click to view all pictures',
    zh: '请点击查看所有图片'
  },
  ClickToViewPicture: {
    en: 'Click to view picture',
    zh: '点击查看图片'
  },
  AutoDestructionAfterViewingTimeout: {
    en: 'Auto destruction after viewing timeout',
    zh: '查看超时后自动焚毁'
  },
  ImageHasExpired: {
    en: 'Image has expired',
    zh: '图片已失效'
  },
  PleaseClickToViewPicture: {
    en: 'Click to view picture',
    zh: '请点击查看图片'
  },
  NoteCantViewAfterTimeLimit: {
    en: "Note: Can't view after time limit",
    zh: '注意：超过显示时间限制后将无法再次查看'
  },
  DisplayTimeLimitExceeded: {
    en: 'Display time limit exceeded',
    zh: '已超过显示时间限制'
  },
  AutomaticallyCloseAfterOneSecond: {
    en: (count) => `Automatically close after ${count} seconds`,
    zh: (count) => `${count}秒后自动关闭`
  },

  // 多项填空
  ContentIsRequired: {
    en: 'is required',
    zh: '必答'
  },
  ContentShouldNotBeTheSameAsOtherBlanks: {
    en: 'should not be the same as other blanks',
    zh: '的内容请勿与其他空相同'
  },
  TheBlankIs: {
    en: (message) => `The blank ${message}`,
    zh: (message) => `填空${message}`
  },

  // 地图题
  ObtainGeographicalLocation: {
    en: 'Obtain geographical location',
    zh: '获取地理位置'
  },
  LongitudeAndLatitude: {
    en: (lng, lat) => `Longitude: ${lng}, Latitude: ${lat}`,
    zh: (lng, lat) => `经度：${lng}, 纬度：${lat}`
  },
  PleaseEnterTheLocationOrStreetYouWantToSearchFor: {
    en: 'Please enter the location or street you want to search for',
    zh: '请输入要搜索的地点、街道'
  },

  // 密码题
  PleaseEnterAtLeastOneCharacters: {
    en: (count) => `Please enter at least ${count} characters.`,
    zh: (count) => `请至少输入${count}位`
  },
  ThePasswordNeedsToIncludeLettersNumbersOrBoth: {
    en: 'The password needs to include letters, numbers, or both letters and numbers.',
    zh: '密码需要包含字母/数字/字母和数字'
  },
  ThePasswordNeedsToIncludeLettersNumbersSymbolsOrCombination: {
    en: 'The password needs to include letters, numbers, symbols, or a combination of letters, numbers, and symbols.',
    zh: '密码需要包含字母/数字/符号/字母和数字/字母和符号/符号和数字/字母、数字和符号'
  },
  ThePasswordNeedsToIncludeUpperLowerLettersNumbersSymbolsOrCombination: {
    en: 'The password needs to include uppercase letters, lowercase letters, numbers, symbols, or a combination of uppercase and lowercase letters, numbers and symbols.',
    zh: '密码需要包含大/小写字母/数字/符号/大/小写字母和数字/大/小写字母和符号/符号和数字/大/小写字母、数字和符号'
  },
  ThePasswordMustBeACombinationOfLettersAndNumbers: {
    en: 'The password must be a combination of letters and numbers.',
    zh: '密码必须为字母和数字'
  },
  ThePasswordsEnteredDoNotMatch: {
    en: 'The passwords entered do not match.',
    zh: '两次密码输入不一致'
  },

  // 手机号题
  GetCaptcha: {
    en: 'Get Captcha',
    zh: '获取验证码'
  },
  SentSuccessfully: {
    en: 'Sent successfully.',
    zh: '发送成功'
  },
  PleaseEnterAValidPhoneNumber: {
    en: 'Please enter a valid phone number.',
    zh: '请输入正确的手机号'
  },

  // 签名题
  Clear: {
    en: 'Clear',
    zh: '清空'
  },
  Undo: {
    en: 'Undo',
    zh: '撤销'
  },
  Eraser: {
    en: 'Eraser',
    zh: '橡皮'
  },
  Brush: {
    en: 'Brush',
    zh: '画笔'
  },
  CompleteAndUpload: {
    en: 'Upload',
    zh: '完成并上传'
  },

  // 恒定总和题
  Sum: {
    en: 'Sum',
    zh: '总和'
  },

  // 上传文件题的提示
  ClickOrDragTheFileHereToUpload: {
    en: 'Click or drag the file here to upload.',
    zh: '点击或将文件拖拽到这里上传'
  },
  UploadFileDesc: {
    en: (min, max, minSize, maxSize, type) => {
      let result = `Upload at least ${min} files, up to a maximum of ${max} files, with each file size between ${minSize}MB and ${maxSize}MB`;
      if (type) {
        result += `, and the file format limited to ${type}`;
      }
      result += '.';
      return result;
    },
    zh: (min, max, minSize, maxSize, type) => {
      let result = `最少上传${min}个文件，最多上传${max}个文件，每个文件不小于${minSize}M不大于${maxSize}M`;
      if (type) {
        result += `，文件格式限制为${type}`;
      }
      result += '。';
      return result;
    }
  },
  FileSizeIsLessThanOneMB: {
    en: (size) => `File size is less than ${size}MB.`,
    zh: (size) => `文件小于${size}M`
  },
  FileSizeIsGreaterThanOneMB: {
    en: (size) => `File size is greater than ${size}MB.`,
    zh: (size) => `文件大于${size}M`
  },
  FileFormatIsIncorrect: {
    en: 'The file format is incorrect.',
    zh: '文件格式不正确'
  },
  UploadFileSuccessful: {
    en: (title) => `Upload ${title} successful.`,
    zh: (title) => `${title} 上传成功`
  },
  UploadFileFailed: {
    en: (title) => `Upload ${title} failed.`,
    zh: (title) => `${title} 上传失败`
  },
  EquipmentNotice: {
    en: () =>
      `Sorry, the number of submissions you have made under the current IP address has reached the limit. Thank you for participating.`,
    zh: () => `很抱歉，您使用当前设备填写问卷已达到限制次数，感谢参与`
  },
  SubmitIpNotice: {
    en: () =>
      `Sorry, the number of submissions you have made under the current IP address has reached the limit. Thank you for participating.`,
    zh: () => `很抱歉，您在当前IP地址下填写问卷已达到限制次数，感谢参与`
  },
  PrivatizationWxWorkIdentityNotice: {
    en: () =>
      `Sorry, the current environment does not allow you to answer this questionnaire.\nPlease click on the link or scan the code to answer through the privatized enterprise WeChat.`,
    zh: () => `很抱歉，当前环境无法作答该问卷\n请通过私有化企业微信点击链接或扫码作答`
  },

  // QLast 提示
  QLast_Stay: {
    en: 'Cancel',
    zh: '停止跳转'
  },
  QLast_Redirect: {
    en: 'Continue',
    zh: '立即跳转'
  },
  QLast_RedirectingIn5Seconds: {
    en: (countdown) => `You will be redirecting to another page in ${countdown} seconds.`,
    zh: (countdown) => `发布者设置了作答后跳转，页面将于【${countdown}】秒后跳转`
  },
  QLast_IosRedirectingPrompt: {
    en: 'If you are using an Apple (iOS) device，please click the button below to jump now.',
    zh: '页面跳转中，如您使用苹果（iOS）设备或页面长时间未跳转，请手动点击下方按钮进行跳转'
  }
};

export const allLanguageTypes = Object.keys(language[Object.keys(language)[0]]);
export const languageTypes = ['zh'];

export function setLanguageTypes(types) {
  languageTypes.push(...types);
}

/**
 * @typedef {import('@/views/Survey/views/Preview/components/questions/types/translatedText').languageArea} LanguageArea
 * @typedef {import('@/views/Survey/views/Preview/components/questions/types/translatedText').ITranslatedText} ITranslatedText I
 */

/**
 *
 * @alias
 * @param langArr { languageArea[] } 语言区域类型
 * @returns {ITranslatedText} 获取到的文本
 */
export function getLanguage(langArr = languageTypes) {
  /**
   * langArr: 语言数组 default: ['zh']
   * 1. langArr 为空时，使用 ['zh']
   * 2. langArr 是数组时，使用传入的语言
   * 3. langArr 是字符串时，使用该字符串语言
   */
  const l = [];
  if (!langArr) {
    l.push('zh');
  } else if (Array.isArray(langArr)) {
    if (langArr.length) {
      l.push(...langArr);
    } else {
      l.push('zh');
    }
  } else {
    l.push(langArr);
  }

  const result = {};
  Object.keys(language).forEach((key) => {
    result[key] = '';

    const tempStr = [];
    const tempFunc = [];

    l.forEach((lang) => {
      const res = language[key][lang];

      if (typeof res === 'string') {
        tempStr.push(language[key][lang]);
      } else {
        tempFunc.push(language[key][lang]);
      }
    });

    if (tempStr.length) {
      result[key] = tempStr.join('\n');
    }
    if (tempFunc.length) {
      result[key] = (...rest) => tempFunc.map((func) => func(...rest)).join('\n');
    }
  });

  return result;
}
