import { $ as b } from "./context-BfHy4NgG.es.js";
import { $ as s } from "./LocalizedStringDictionary-rmcyf3BY.es.js";
import { useMemo as u } from "react";
const n = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
class d {
  /** Formats a localized string for the given key with the provided variables. */
  format(e, t) {
    let a = this.strings.getStringForLocale(e, this.locale);
    return typeof a == "function" ? a(t, this) : a;
  }
  plural(e, t, a = "cardinal") {
    let l = t["=" + e];
    if (l) return typeof l == "function" ? l() : l;
    let o = this.locale + ":" + a, c = n.get(o);
    c || (c = new Intl.PluralRules(this.locale, {
      type: a
    }), n.set(o, c));
    let $ = c.select(e);
    return l = t[$] || t.other, typeof l == "function" ? l() : l;
  }
  number(e) {
    let t = f.get(this.locale);
    return t || (t = new Intl.NumberFormat(this.locale), f.set(this.locale, t)), t.format(e);
  }
  select(e, t) {
    let a = e[t] || e.other;
    return typeof a == "function" ? a() : a;
  }
  constructor(e, t) {
    this.locale = e, this.strings = t;
  }
}
const i = /* @__PURE__ */ new WeakMap();
function p(r) {
  let e = i.get(r);
  return e || (e = new s(r), i.set(r, e)), e;
}
function h(r, e) {
  return e && s.getGlobalDictionaryForPackage(e) || p(r);
}
function w(r, e) {
  let { locale: t } = b(), a = h(r, e);
  return u(() => new d(t, a), [
    t,
    a
  ]);
}
export {
  w as $,
  h as a,
  d as b
};
//# sourceMappingURL=useLocalizedStringFormatter-CYDf7GZk.es.js.map
