'use strict';

var vueI18n = require('vue-i18n');
require('../api/index.js');
var de = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/de.js');
var en$1 = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/en.js');
var es = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/es.js');
var fi = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/fi.js');
var fr = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/fr.js');
var it = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/it.js');
var ja = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/ja.js');
var ko = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/ko.js');
var no = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/no.js');
var pl = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/pl.js');
var pt = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/pt.js');
var ru = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/ru.js');
var zhCn$1 = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/zh-cn.js');
var zhTw = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/zh-tw.js');
var th = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/th.js');
var id = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/id.js');
var ms = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.3_/node_modules/element-plus/es/locale/lang/ms.js');
var vi = require('../../node_modules/.pnpm/element-plus@2.14.1_vue@3.5.35_typescript@6.0.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');
var en = require('./lang/en.js');
var zhCn = require('./lang/zh-cn.js');
var index = require('../api/base/index.js');

const messages = {};
const element = {
  "zh-CN": zhCn$1.default,
  "zh-TW": zhTw.default,
  "zh-HK": zhTw.default,
  en: en$1.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': '繁體中文(台灣)',
  // 'zh-HK': '繁體中文(香港)',
  en: "English"
  // de: 'Deutsch',
  // es: 'Español',
  // fi: 'Suomeksi',
  // fr: 'Français',
  // it: 'Italiano',
  // ja: '日本語',
  // ko: '한국어',
  // no: 'Norsk',
  // pl: 'Polski',
  // pt: 'Português',
  // ru: 'Русский',
  // th: 'ไทย',
  // id: 'Indonesia',
  // ms: 'Malaysia',
  // vi: 'Việt 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, msg);
}
async function loadRemoteMessages(teanId) {
  const res = await index.useBaseApi("sysLanguagePack").get(null, "lgpk/" + teanId);
  const data = res.data.result;
  i18n.global.mergeLocaleMessage("zh-CN", {
    message: {
      menu: data.mencn
    }
  });
  i18n.global.mergeLocaleMessage("en", {
    message: {
      menu: data.menen
    }
  });
}
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.en = en.default;
exports.zhCn = zhCn.default;
exports.getCountryCode = getCountryCode;
exports.i18n = i18n;
exports.iso_3166_1_CountryList = iso_3166_1_CountryList;
exports.languageList = languageList;
exports.loadRemoteMessages = loadRemoteMessages;
exports.mergMessage = mergMessage;
exports.setupI18n = setupI18n;
