'use strict';

var vueI18n = require('vue-i18n');
var de = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/de.js');
var en = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/en.js');
var es = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/es.js');
var fi = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/fi.js');
var fr = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/fr.js');
var it = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/it.js');
var ja = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/ja.js');
var ko = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/ko.js');
var no = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/no.js');
var pl = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/pl.js');
var pt = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/pt.js');
var ru = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/ru.js');
var zhCn = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/zh-cn.js');
var zhTw = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/zh-tw.js');
var th = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/th.js');
var id = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/id.js');
var ms = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/ms.js');
var vi = require('../../../node_modules/.pnpm/element-plus@2.13.1_vue@3.5.26_typescript@5.8.3_/node_modules/element-plus/es/locale/lang/vi.js');
var enUS = require('../../../_virtual/en-US.js');
var deDE = require('../../../_virtual/de-DE.js');
var esES = require('../../../_virtual/es-ES.js');
var frFR = require('../../../_virtual/fr-FR.js');
var itIT = require('../../../_virtual/it-IT.js');
var jaJP = require('../../../_virtual/ja-JP.js');
var koKR = require('../../../_virtual/ko-KR.js');
var nbNO = require('../../../_virtual/nb-NO.js');
var ptBR = require('../../../_virtual/pt-BR.js');
var ruRU = require('../../../_virtual/ru-RU.js');
var zhCN = require('../../../_virtual/zh-CN.js');
var zhHK = require('../../../_virtual/zh-HK.js');
var zhTW = require('../../../_virtual/zh-TW.js');
var thTH = require('../../../_virtual/th-TH.js');
var viVN = require('../../../_virtual/vi-VN.js');

const messages = {};
const element = {
  "zh-CN": zhCn.default,
  "zh-TW": zhTw.default,
  "zh-HK": zhTw.default,
  en: en.default,
  de: de.default,
  es: es.default,
  fi: fi.default,
  fr: fr.default,
  it: it.default,
  ja: ja.default,
  ko: ko.default,
  no: no.default,
  pl: pl.default,
  pt: pt.default,
  ru: ru.default,
  th: th.default,
  id: id.default,
  ms: ms.default,
  vi: vi.default
};
const vxe = {
  "zh-CN": zhCN.default,
  "zh-TW": zhTW.default,
  "zh-HK": zhHK.default,
  en: enUS.default,
  de: deDE.default,
  es: esES.default,
  fi: enUS.default,
  fr: frFR.default,
  it: itIT.default,
  ja: jaJP.default,
  ko: koKR.default,
  no: nbNO.default,
  pl: enUS.default,
  pt: ptBR.default,
  ru: ruRU.default,
  th: thTH.default,
  id: enUS.default,
  ms: enUS.default,
  vi: viVN.default
};
const languageList = {
  "zh-CN": "\u7B80\u4F53\u4E2D\u6587",
  "zh-TW": "\u7E41\u9AD4\u4E2D\u6587(\u53F0\u7063)",
  "zh-HK": "\u7E41\u9AD4\u4E2D\u6587(\u9999\u6E2F)",
  en: "English",
  de: "Deutsch",
  es: "Espa\xF1ol",
  fi: "Suomeksi",
  fr: "Fran\xE7ais",
  it: "Italiano",
  ja: "\u65E5\u672C\u8A9E",
  ko: "\uD55C\uAD6D\uC5B4",
  no: "Norsk",
  pl: "Polski",
  pt: "Portugu\xEAs",
  ru: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
  th: "\u0E44\u0E17\u0E22",
  id: "Indonesia",
  ms: "Malaysia",
  vi: "Vi\u1EC7t Nam"
};
const iso_3166_1_CountryList = {
  de: "de",
  en: "us",
  es: "es",
  fi: "fi",
  fr: "fr",
  it: "it",
  ja: "jp",
  ko: "kr",
  no: "no",
  pl: "pl",
  pt: "pt",
  ru: "ru",
  "zh-CN": "cn",
  "zh-TW": "tw",
  "zh-HK": "hk",
  th: "th",
  id: "id",
  ms: "ms",
  vi: "vi"
};
const itemize = { en: [], "zh-CN": [], "zh-TW": [], "zh-HK": [], de: [], es: [], fi: [], fr: [], it: [], ja: [], ko: [], no: [], pl: [], pt: [], ru: [], th: [], id: [], ms: [], vi: [] };
const getCountryCode = (locale) => {
  return iso_3166_1_CountryList[locale];
};
function mergeArrObj(list, key) {
  let obj = {};
  list[key].forEach((i) => {
    obj = Object.assign({}, obj, i);
  });
  return obj;
}
const i18n = vueI18n.createI18n({
  legacy: false,
  silentTranslationWarn: true,
  missingWarn: false,
  silentFallbackWarn: true,
  fallbackWarn: false,
  locale: "zh-CN",
  fallbackLocale: "zh-CN",
  messages: {},
  globalInjection: true,
  fallbackFormat: false,
  // 关闭默认的 fallback 行为
  missing: (locale, key) => {
    const lastPart = key.includes(".") ? key.split(".").pop() : key;
    return lastPart.replace(/\${(.+?)}/g, "$1");
  }
});
async function mergMessage(lang, msg) {
  i18n.global.mergeLocaleMessage(lang, {
    "\u4F60\u597D\u5417": "\u4F60\u597D\u5417\uFF1F",
    "\u6765\u5566": "\u5566\u5566\u5566"
  });
}
async function loadLocaleMessages(tempmodel) {
  for (const path in tempmodel) {
    const key = path.match(/(\S+)\/(\S+).ts/);
    if (itemize[key[2]]) itemize[key[2]].push(tempmodel[path].default);
    else itemize[key[2]] = tempmodel[path];
  }
  for (const key in itemize) {
    messages[key] = {
      name: key,
      el: element[key].el,
      message: mergeArrObj(itemize, key),
      vxe: vxe[key].vxe
    };
    i18n.global.setLocaleMessage(key, messages[key]);
  }
}
async function setupI18n(app, tempmodel, lang) {
  await loadLocaleMessages(tempmodel);
  i18n.global.locale.value = lang;
  app.use(i18n);
  i18n.global.setMissingHandler((locale, key) => {
    if (key.includes(".")) {
      console.warn(
        `[intlify] Not found '${key}' key in '${locale}' locale messages.`
      );
    }
  });
}

exports.getCountryCode = getCountryCode;
exports.i18n = i18n;
exports.iso_3166_1_CountryList = iso_3166_1_CountryList;
exports.languageList = languageList;
exports.mergMessage = mergMessage;
exports.setupI18n = setupI18n;
