var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
import { IntlMessageFormat } from "intl-messageformat";
import { DictionaryCache } from "./DictionaryCache.js";
class DictionaryResolver {
  constructor(mainDictionaries) {
    __publicField(this, "dictionaries", /* @__PURE__ */ new Map());
    for (const localeCode in mainDictionaries) {
      this.dictionaries.set(localeCode, new DictionaryCache(mainDictionaries[localeCode]));
    }
  }
  resolveDictionary(locale, fallbackDictionary) {
    return this.dictionaries.get(locale.code) || fallbackDictionary;
  }
  getMessageFormat(locale, key, fallbackDictionary) {
    const targetDictionary = this.resolveDictionary(locale, fallbackDictionary);
    let messageAST = targetDictionary.getMessageAST(key);
    if (messageAST === void 0) {
      messageAST = fallbackDictionary.getMessageAST(key);
    }
    if (messageAST === void 0) {
      return void 0;
    }
    return new IntlMessageFormat(messageAST, locale.code);
  }
  getResolvedMessageForDebuggingPurposes(locale, key, fallbackDictionary) {
    const targetDictionary = this.resolveDictionary(locale, fallbackDictionary);
    return targetDictionary.getOriginalMessageForDebuggingPurposes(key) ?? fallbackDictionary.getOriginalMessageForDebuggingPurposes(key);
  }
}
export { DictionaryResolver };
//# sourceMappingURL=DictionaryResolver.js.map
