const s = /* @__PURE__ */ Symbol.for("react-aria.i18n.locale"), d = /* @__PURE__ */ Symbol.for("react-aria.i18n.strings");
let o;
class l {
  /** Returns a localized string for the given key and locale. */
  getStringForLocale(t, r) {
    let n = this.getStringsForLocale(r)[t];
    if (!n) throw new Error(`Could not find intl message ${t} in ${r} locale`);
    return n;
  }
  /** Returns all localized strings for the given locale. */
  getStringsForLocale(t) {
    let r = this.strings[t];
    return r || (r = g(t, this.strings, this.defaultLocale), this.strings[t] = r), r;
  }
  static getGlobalDictionaryForPackage(t) {
    if (typeof window > "u") return null;
    let r = window[s];
    if (o === void 0) {
      let n = window[d];
      if (!n) return null;
      o = {};
      for (let a in n) o[a] = new l({
        [r]: n[a]
      }, r);
    }
    let e = o?.[t];
    if (!e) throw new Error(`Strings for package "${t}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);
    return e;
  }
  constructor(t, r = "en-US") {
    this.strings = Object.fromEntries(Object.entries(t).filter(([, e]) => e)), this.defaultLocale = r;
  }
}
function g(i, t, r = "en-US") {
  if (t[i]) return t[i];
  let e = c(i);
  if (t[e]) return t[e];
  for (let n in t)
    if (n.startsWith(e + "-")) return t[n];
  return t[r];
}
function c(i) {
  return Intl.Locale ? new Intl.Locale(i).language : i.split("-")[0];
}
export {
  l as $
};
//# sourceMappingURL=LocalizedStringDictionary-rmcyf3BY.es.js.map
