const d = (o) => typeof o == "string", K = () => {
  let o, e;
  const t = new Promise((i, s) => {
    o = i, e = s;
  });
  return t.resolve = o, t.reject = e, t;
}, ee = (o) => o == null ? "" : "" + o, ye = (o, e, t) => {
  o.forEach((i) => {
    e[i] && (t[i] = e[i]);
  });
}, ve = /###/g, te = (o) => o && o.indexOf("###") > -1 ? o.replace(ve, ".") : o, se = (o) => !o || d(o), A = (o, e, t) => {
  const i = d(e) ? e.split(".") : e;
  let s = 0;
  for (; s < i.length - 1; ) {
    if (se(o)) return {};
    const r = te(i[s]);
    !o[r] && t && (o[r] = new t()), Object.prototype.hasOwnProperty.call(o, r) ? o = o[r] : o = {}, ++s;
  }
  return se(o) ? {} : {
    obj: o,
    k: te(i[s])
  };
}, ie = (o, e, t) => {
  const {
    obj: i,
    k: s
  } = A(o, e, Object);
  if (i !== void 0 || e.length === 1) {
    i[s] = t;
    return;
  }
  let r = e[e.length - 1], n = e.slice(0, e.length - 1), a = A(o, n, Object);
  for (; a.obj === void 0 && n.length; )
    r = `${n[n.length - 1]}.${r}`, n = n.slice(0, n.length - 1), a = A(o, n, Object), a?.obj && typeof a.obj[`${a.k}.${r}`] < "u" && (a.obj = void 0);
  a.obj[`${a.k}.${r}`] = t;
}, Se = (o, e, t, i) => {
  const {
    obj: s,
    k: r
  } = A(o, e, Object);
  s[r] = s[r] || [], s[r].push(t);
}, z = (o, e) => {
  const {
    obj: t,
    k: i
  } = A(o, e);
  if (t && Object.prototype.hasOwnProperty.call(t, i))
    return t[i];
}, Oe = (o, e, t) => {
  const i = z(o, t);
  return i !== void 0 ? i : z(e, t);
}, ge = (o, e, t) => {
  for (const i in e)
    i !== "__proto__" && i !== "constructor" && (i in o ? d(o[i]) || o[i] instanceof String || d(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : ge(o[i], e[i], t) : o[i] = e[i]);
  return o;
}, T = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var Le = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;",
  "/": "&#x2F;"
};
const be = (o) => d(o) ? o.replace(/[&<>"'\/]/g, (e) => Le[e]) : o;
class we {
  constructor(e) {
    this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
  }
  getRegExp(e) {
    const t = this.regExpMap.get(e);
    if (t !== void 0)
      return t;
    const i = new RegExp(e);
    return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
  }
}
const Ce = [" ", ",", "?", "!", ";"], Re = new we(20), $e = (o, e, t) => {
  e = e || "", t = t || "";
  const i = Ce.filter((n) => e.indexOf(n) < 0 && t.indexOf(n) < 0);
  if (i.length === 0) return !0;
  const s = Re.getRegExp(`(${i.map((n) => n === "?" ? "\\?" : n).join("|")})`);
  let r = !s.test(o);
  if (!r) {
    const n = o.indexOf(t);
    n > 0 && !s.test(o.substring(0, n)) && (r = !0);
  }
  return r;
}, _ = (o, e, t = ".") => {
  if (!o) return;
  if (o[e])
    return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
  const i = e.split(t);
  let s = o;
  for (let r = 0; r < i.length; ) {
    if (!s || typeof s != "object")
      return;
    let n, a = "";
    for (let l = r; l < i.length; ++l)
      if (l !== r && (a += t), a += i[l], n = s[a], n !== void 0) {
        if (["string", "number", "boolean"].indexOf(typeof n) > -1 && l < i.length - 1)
          continue;
        r += l - r + 1;
        break;
      }
    s = n;
  }
  return s;
}, U = (o) => o?.replace("_", "-"), Pe = {
  type: "logger",
  log(o) {
    this.output("log", o);
  },
  warn(o) {
    this.output("warn", o);
  },
  error(o) {
    this.output("error", o);
  },
  output(o, e) {
    console?.[o]?.apply?.(console, e);
  }
};
class J {
  constructor(e, t = {}) {
    this.init(e, t);
  }
  init(e, t = {}) {
    this.prefix = t.prefix || "i18next:", this.logger = e || Pe, this.options = t, this.debug = t.debug;
  }
  log(...e) {
    return this.forward(e, "log", "", !0);
  }
  warn(...e) {
    return this.forward(e, "warn", "", !0);
  }
  error(...e) {
    return this.forward(e, "error", "");
  }
  deprecate(...e) {
    return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
  }
  forward(e, t, i, s) {
    return s && !this.debug ? null : (d(e[0]) && (e[0] = `${i}${this.prefix} ${e[0]}`), this.logger[t](e));
  }
  create(e) {
    return new J(this.logger, {
      prefix: `${this.prefix}:${e}:`,
      ...this.options
    });
  }
  clone(e) {
    return e = e || this.options, e.prefix = e.prefix || this.prefix, new J(this.logger, e);
  }
}
var $ = new J();
class Q {
  constructor() {
    this.observers = {};
  }
  on(e, t) {
    return e.split(" ").forEach((i) => {
      this.observers[i] || (this.observers[i] = /* @__PURE__ */ new Map());
      const s = this.observers[i].get(t) || 0;
      this.observers[i].set(t, s + 1);
    }), this;
  }
  off(e, t) {
    if (this.observers[e]) {
      if (!t) {
        delete this.observers[e];
        return;
      }
      this.observers[e].delete(t);
    }
  }
  emit(e, ...t) {
    this.observers[e] && Array.from(this.observers[e].entries()).forEach(([s, r]) => {
      for (let n = 0; n < r; n++)
        s(...t);
    }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([s, r]) => {
      for (let n = 0; n < r; n++)
        s.apply(s, [e, ...t]);
    });
  }
}
class re extends Q {
  constructor(e, t = {
    ns: ["translation"],
    defaultNS: "translation"
  }) {
    super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
  }
  addNamespaces(e) {
    this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
  }
  removeNamespaces(e) {
    const t = this.options.ns.indexOf(e);
    t > -1 && this.options.ns.splice(t, 1);
  }
  getResource(e, t, i, s = {}) {
    const r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, n = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
    let a;
    e.indexOf(".") > -1 ? a = e.split(".") : (a = [e, t], i && (Array.isArray(i) ? a.push(...i) : d(i) && r ? a.push(...i.split(r)) : a.push(i)));
    const l = z(this.data, a);
    return !l && !t && !i && e.indexOf(".") > -1 && (e = a[0], t = a[1], i = a.slice(2).join(".")), l || !n || !d(i) ? l : _(this.data?.[e]?.[t], i, r);
  }
  addResource(e, t, i, s, r = {
    silent: !1
  }) {
    const n = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
    let a = [e, t];
    i && (a = a.concat(n ? i.split(n) : i)), e.indexOf(".") > -1 && (a = e.split("."), s = t, t = a[1]), this.addNamespaces(t), ie(this.data, a, s), r.silent || this.emit("added", e, t, i, s);
  }
  addResources(e, t, i, s = {
    silent: !1
  }) {
    for (const r in i)
      (d(i[r]) || Array.isArray(i[r])) && this.addResource(e, t, r, i[r], {
        silent: !0
      });
    s.silent || this.emit("added", e, t, i);
  }
  addResourceBundle(e, t, i, s, r, n = {
    silent: !1,
    skipCopy: !1
  }) {
    let a = [e, t];
    e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
    let l = z(this.data, a) || {};
    n.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? ge(l, i, r) : l = {
      ...l,
      ...i
    }, ie(this.data, a, l), n.silent || this.emit("added", e, t, i);
  }
  removeResourceBundle(e, t) {
    this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
  }
  hasResourceBundle(e, t) {
    return this.getResource(e, t) !== void 0;
  }
  getResourceBundle(e, t) {
    return t || (t = this.options.defaultNS), this.getResource(e, t);
  }
  getDataByLanguage(e) {
    return this.data[e];
  }
  hasLanguageSomeTranslations(e) {
    const t = this.getDataByLanguage(e);
    return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
  }
  toJSON() {
    return this.data;
  }
}
var pe = {
  processors: {},
  addPostProcessor(o) {
    this.processors[o.name] = o;
  },
  handle(o, e, t, i, s) {
    return o.forEach((r) => {
      e = this.processors[r]?.process(e, t, i, s) ?? e;
    }), e;
  }
};
const ne = {}, ae = (o) => !d(o) && typeof o != "boolean" && typeof o != "number";
class W extends Q {
  constructor(e, t = {}) {
    super(), ye(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = $.create("translator");
  }
  changeLanguage(e) {
    e && (this.language = e);
  }
  exists(e, t = {
    interpolation: {}
  }) {
    const i = {
      ...t
    };
    return e == null ? !1 : this.resolve(e, i)?.res !== void 0;
  }
  extractFromKey(e, t) {
    let i = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
    i === void 0 && (i = ":");
    const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
    let r = t.ns || this.options.defaultNS || [];
    const n = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !$e(e, i, s);
    if (n && !a) {
      const l = e.match(this.interpolator.nestingRegexp);
      if (l && l.length > 0)
        return {
          key: e,
          namespaces: d(r) ? [r] : r
        };
      const u = e.split(i);
      (i !== s || i === s && this.options.ns.indexOf(u[0]) > -1) && (r = u.shift()), e = u.join(s);
    }
    return {
      key: e,
      namespaces: d(r) ? [r] : r
    };
  }
  translate(e, t, i) {
    let s = typeof t == "object" ? {
      ...t
    } : t;
    if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = {
      ...s
    }), s || (s = {}), e == null) return "";
    Array.isArray(e) || (e = [String(e)]);
    const r = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
      key: a,
      namespaces: l
    } = this.extractFromKey(e[e.length - 1], s), u = l[l.length - 1];
    let f = s.nsSeparator !== void 0 ? s.nsSeparator : this.options.nsSeparator;
    f === void 0 && (f = ":");
    const h = s.lng || this.language, p = s.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
    if (h?.toLowerCase() === "cimode")
      return p ? r ? {
        res: `${u}${f}${a}`,
        usedKey: a,
        exactUsedKey: a,
        usedLng: h,
        usedNS: u,
        usedParams: this.getUsedParamsDetails(s)
      } : `${u}${f}${a}` : r ? {
        res: a,
        usedKey: a,
        exactUsedKey: a,
        usedLng: h,
        usedNS: u,
        usedParams: this.getUsedParamsDetails(s)
      } : a;
    const g = this.resolve(e, s);
    let c = g?.res;
    const m = g?.usedKey || a, v = g?.exactUsedKey || a, L = ["[object Number]", "[object Function]", "[object RegExp]"], x = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, F = !this.i18nFormat || this.i18nFormat.handleAsObject, O = s.count !== void 0 && !d(s.count), N = W.hasDefaultValue(s), j = O ? this.pluralResolver.getSuffix(h, s.count, s) : "", I = s.ordinal && O ? this.pluralResolver.getSuffix(h, s.count, {
      ordinal: !1
    }) : "", G = O && !s.ordinal && s.count === 0, k = G && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${j}`] || s[`defaultValue${I}`] || s.defaultValue;
    let w = c;
    F && !c && N && (w = k);
    const me = ae(w), xe = Object.prototype.toString.apply(w);
    if (F && w && me && L.indexOf(xe) < 0 && !(d(x) && Array.isArray(w))) {
      if (!s.returnObjects && !this.options.returnObjects) {
        this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
        const C = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, w, {
          ...s,
          ns: l
        }) : `key '${a} (${this.language})' returned an object instead of string.`;
        return r ? (g.res = C, g.usedParams = this.getUsedParamsDetails(s), g) : C;
      }
      if (n) {
        const C = Array.isArray(w), b = C ? [] : {}, Z = C ? v : m;
        for (const R in w)
          if (Object.prototype.hasOwnProperty.call(w, R)) {
            const P = `${Z}${n}${R}`;
            N && !c ? b[R] = this.translate(P, {
              ...s,
              defaultValue: ae(k) ? k[R] : void 0,
              joinArrays: !1,
              ns: l
            }) : b[R] = this.translate(P, {
              ...s,
              joinArrays: !1,
              ns: l
            }), b[R] === P && (b[R] = w[R]);
          }
        c = b;
      }
    } else if (F && d(x) && Array.isArray(c))
      c = c.join(x), c && (c = this.extendTranslation(c, e, s, i));
    else {
      let C = !1, b = !1;
      !this.isValidLookup(c) && N && (C = !0, c = k), this.isValidLookup(c) || (b = !0, c = a);
      const R = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && b ? void 0 : c, P = N && k !== c && this.options.updateMissing;
      if (b || C || P) {
        if (this.logger.log(P ? "updateKey" : "missingKey", h, u, a, P ? k : c), n) {
          const S = this.resolve(a, {
            ...s,
            keySeparator: !1
          });
          S && S.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
        }
        let D = [];
        const H = this.languageUtils.getFallbackCodes(this.options.fallbackLng, s.lng || this.language);
        if (this.options.saveMissingTo === "fallback" && H && H[0])
          for (let S = 0; S < H.length; S++)
            D.push(H[S]);
        else this.options.saveMissingTo === "all" ? D = this.languageUtils.toResolveHierarchy(s.lng || this.language) : D.push(s.lng || this.language);
        const X = (S, E, V) => {
          const q = N && V !== c ? V : R;
          this.options.missingKeyHandler ? this.options.missingKeyHandler(S, u, E, q, P, s) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(S, u, E, q, P, s), this.emit("missingKey", S, u, E, c);
        };
        this.options.saveMissing && (this.options.saveMissingPlurals && O ? D.forEach((S) => {
          const E = this.pluralResolver.getSuffixes(S, s);
          G && s[`defaultValue${this.options.pluralSeparator}zero`] && E.indexOf(`${this.options.pluralSeparator}zero`) < 0 && E.push(`${this.options.pluralSeparator}zero`), E.forEach((V) => {
            X([S], a + V, s[`defaultValue${V}`] || k);
          });
        }) : X(D, a, k));
      }
      c = this.extendTranslation(c, e, s, g, i), b && c === a && this.options.appendNamespaceToMissingKey && (c = `${u}${f}${a}`), (b || C) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${f}${a}` : a, C ? c : void 0, s));
    }
    return r ? (g.res = c, g.usedParams = this.getUsedParamsDetails(s), g) : c;
  }
  extendTranslation(e, t, i, s, r) {
    if (this.i18nFormat?.parse)
      e = this.i18nFormat.parse(e, {
        ...this.options.interpolation.defaultVariables,
        ...i
      }, i.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
        resolved: s
      });
    else if (!i.skipInterpolation) {
      i.interpolation && this.interpolator.init({
        ...i,
        interpolation: {
          ...this.options.interpolation,
          ...i.interpolation
        }
      });
      const l = d(e) && (i?.interpolation?.skipOnVariables !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
      let u;
      if (l) {
        const h = e.match(this.interpolator.nestingRegexp);
        u = h && h.length;
      }
      let f = i.replace && !d(i.replace) ? i.replace : i;
      if (this.options.interpolation.defaultVariables && (f = {
        ...this.options.interpolation.defaultVariables,
        ...f
      }), e = this.interpolator.interpolate(e, f, i.lng || this.language || s.usedLng, i), l) {
        const h = e.match(this.interpolator.nestingRegexp), p = h && h.length;
        u < p && (i.nest = !1);
      }
      !i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...h) => r?.[0] === h[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${t[0]}`), null) : this.translate(...h, t), i)), i.interpolation && this.interpolator.reset();
    }
    const n = i.postProcess || this.options.postProcess, a = d(n) ? [n] : n;
    return e != null && a?.length && i.applyPostProcessor !== !1 && (e = pe.handle(a, e, t, this.options && this.options.postProcessPassResolved ? {
      i18nResolved: {
        ...s,
        usedParams: this.getUsedParamsDetails(i)
      },
      ...i
    } : i, this)), e;
  }
  resolve(e, t = {}) {
    let i, s, r, n, a;
    return d(e) && (e = [e]), e.forEach((l) => {
      if (this.isValidLookup(i)) return;
      const u = this.extractFromKey(l, t), f = u.key;
      s = f;
      let h = u.namespaces;
      this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
      const p = t.count !== void 0 && !d(t.count), g = p && !t.ordinal && t.count === 0, c = t.context !== void 0 && (d(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
      h.forEach((v) => {
        this.isValidLookup(i) || (a = v, !ne[`${m[0]}-${v}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(a) && (ne[`${m[0]}-${v}`] = !0, this.logger.warn(`key "${s}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), m.forEach((L) => {
          if (this.isValidLookup(i)) return;
          n = L;
          const x = [f];
          if (this.i18nFormat?.addLookupKeys)
            this.i18nFormat.addLookupKeys(x, f, L, v, t);
          else {
            let O;
            p && (O = this.pluralResolver.getSuffix(L, t.count, t));
            const N = `${this.options.pluralSeparator}zero`, j = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
            if (p && (x.push(f + O), t.ordinal && O.indexOf(j) === 0 && x.push(f + O.replace(j, this.options.pluralSeparator)), g && x.push(f + N)), c) {
              const I = `${f}${this.options.contextSeparator}${t.context}`;
              x.push(I), p && (x.push(I + O), t.ordinal && O.indexOf(j) === 0 && x.push(I + O.replace(j, this.options.pluralSeparator)), g && x.push(I + N));
            }
          }
          let F;
          for (; F = x.pop(); )
            this.isValidLookup(i) || (r = F, i = this.getResource(L, v, F, t));
        }));
      });
    }), {
      res: i,
      usedKey: s,
      exactUsedKey: r,
      usedLng: n,
      usedNS: a
    };
  }
  isValidLookup(e) {
    return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
  }
  getResource(e, t, i, s = {}) {
    return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, i, s) : this.resourceStore.getResource(e, t, i, s);
  }
  getUsedParamsDetails(e = {}) {
    const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], i = e.replace && !d(e.replace);
    let s = i ? e.replace : e;
    if (i && typeof e.count < "u" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = {
      ...this.options.interpolation.defaultVariables,
      ...s
    }), !i) {
      s = {
        ...s
      };
      for (const r of t)
        delete s[r];
    }
    return s;
  }
  static hasDefaultValue(e) {
    const t = "defaultValue";
    for (const i in e)
      if (Object.prototype.hasOwnProperty.call(e, i) && t === i.substring(0, t.length) && e[i] !== void 0)
        return !0;
    return !1;
  }
}
class oe {
  constructor(e) {
    this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = $.create("languageUtils");
  }
  getScriptPartFromCode(e) {
    if (e = U(e), !e || e.indexOf("-") < 0) return null;
    const t = e.split("-");
    return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
  }
  getLanguagePartFromCode(e) {
    if (e = U(e), !e || e.indexOf("-") < 0) return e;
    const t = e.split("-");
    return this.formatLanguageCode(t[0]);
  }
  formatLanguageCode(e) {
    if (d(e) && e.indexOf("-") > -1) {
      let t;
      try {
        t = Intl.getCanonicalLocales(e)[0];
      } catch {
      }
      return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
    }
    return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
  }
  isSupportedCode(e) {
    return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
  }
  getBestMatchFromCodes(e) {
    if (!e) return null;
    let t;
    return e.forEach((i) => {
      if (t) return;
      const s = this.formatLanguageCode(i);
      (!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
    }), !t && this.options.supportedLngs && e.forEach((i) => {
      if (t) return;
      const s = this.getScriptPartFromCode(i);
      if (this.isSupportedCode(s)) return t = s;
      const r = this.getLanguagePartFromCode(i);
      if (this.isSupportedCode(r)) return t = r;
      t = this.options.supportedLngs.find((n) => {
        if (n === r) return n;
        if (!(n.indexOf("-") < 0 && r.indexOf("-") < 0) && (n.indexOf("-") > 0 && r.indexOf("-") < 0 && n.substring(0, n.indexOf("-")) === r || n.indexOf(r) === 0 && r.length > 1))
          return n;
      });
    }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
  }
  getFallbackCodes(e, t) {
    if (!e) return [];
    if (typeof e == "function" && (e = e(t)), d(e) && (e = [e]), Array.isArray(e)) return e;
    if (!t) return e.default || [];
    let i = e[t];
    return i || (i = e[this.getScriptPartFromCode(t)]), i || (i = e[this.formatLanguageCode(t)]), i || (i = e[this.getLanguagePartFromCode(t)]), i || (i = e.default), i || [];
  }
  toResolveHierarchy(e, t) {
    const i = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), s = [], r = (n) => {
      n && (this.isSupportedCode(n) ? s.push(n) : this.logger.warn(`rejecting language code not found in supportedLngs: ${n}`));
    };
    return d(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(e))) : d(e) && r(this.formatLanguageCode(e)), i.forEach((n) => {
      s.indexOf(n) < 0 && r(this.formatLanguageCode(n));
    }), s;
  }
}
const le = {
  zero: 0,
  one: 1,
  two: 2,
  few: 3,
  many: 4,
  other: 5
}, ue = {
  select: (o) => o === 1 ? "one" : "other",
  resolvedOptions: () => ({
    pluralCategories: ["one", "other"]
  })
};
class Ne {
  constructor(e, t = {}) {
    this.languageUtils = e, this.options = t, this.logger = $.create("pluralResolver"), this.pluralRulesCache = {};
  }
  addRule(e, t) {
    this.rules[e] = t;
  }
  clearCache() {
    this.pluralRulesCache = {};
  }
  getRule(e, t = {}) {
    const i = U(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", r = JSON.stringify({
      cleanedCode: i,
      type: s
    });
    if (r in this.pluralRulesCache)
      return this.pluralRulesCache[r];
    let n;
    try {
      n = new Intl.PluralRules(i, {
        type: s
      });
    } catch {
      if (!Intl)
        return this.logger.error("No Intl support, please use an Intl polyfill!"), ue;
      if (!e.match(/-|_/)) return ue;
      const l = this.languageUtils.getLanguagePartFromCode(e);
      n = this.getRule(l, t);
    }
    return this.pluralRulesCache[r] = n, n;
  }
  needsPlural(e, t = {}) {
    let i = this.getRule(e, t);
    return i || (i = this.getRule("dev", t)), i?.resolvedOptions().pluralCategories.length > 1;
  }
  getPluralFormsOfKey(e, t, i = {}) {
    return this.getSuffixes(e, i).map((s) => `${t}${s}`);
  }
  getSuffixes(e, t = {}) {
    let i = this.getRule(e, t);
    return i || (i = this.getRule("dev", t)), i ? i.resolvedOptions().pluralCategories.sort((s, r) => le[s] - le[r]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
  }
  getSuffix(e, t, i = {}) {
    const s = this.getRule(e, i);
    return s ? `${this.options.prepend}${i.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, i));
  }
}
const he = (o, e, t, i = ".", s = !0) => {
  let r = Oe(o, e, t);
  return !r && s && d(t) && (r = _(o, t, i), r === void 0 && (r = _(e, t, i))), r;
}, Y = (o) => o.replace(/\$/g, "$$$$");
class ke {
  constructor(e = {}) {
    this.logger = $.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((t) => t), this.init(e);
  }
  init(e = {}) {
    e.interpolation || (e.interpolation = {
      escapeValue: !0
    });
    const {
      escape: t,
      escapeValue: i,
      useRawValueToEscape: s,
      prefix: r,
      prefixEscaped: n,
      suffix: a,
      suffixEscaped: l,
      formatSeparator: u,
      unescapeSuffix: f,
      unescapePrefix: h,
      nestingPrefix: p,
      nestingPrefixEscaped: g,
      nestingSuffix: c,
      nestingSuffixEscaped: m,
      nestingOptionsSeparator: v,
      maxReplaces: L,
      alwaysFormat: x
    } = e.interpolation;
    this.escape = t !== void 0 ? t : be, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = r ? T(r) : n || "{{", this.suffix = a ? T(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = f ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : f || "", this.nestingPrefix = p ? T(p) : g || T("$t("), this.nestingSuffix = c ? T(c) : m || T(")"), this.nestingOptionsSeparator = v || ",", this.maxReplaces = L || 1e3, this.alwaysFormat = x !== void 0 ? x : !1, this.resetRegExp();
  }
  reset() {
    this.options && this.init(this.options);
  }
  resetRegExp() {
    const e = (t, i) => t?.source === i ? (t.lastIndex = 0, t) : new RegExp(i, "g");
    this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
  }
  interpolate(e, t, i, s) {
    let r, n, a;
    const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (g) => {
      if (g.indexOf(this.formatSeparator) < 0) {
        const L = he(t, l, g, this.options.keySeparator, this.options.ignoreJSONStructure);
        return this.alwaysFormat ? this.format(L, void 0, i, {
          ...s,
          ...t,
          interpolationkey: g
        }) : L;
      }
      const c = g.split(this.formatSeparator), m = c.shift().trim(), v = c.join(this.formatSeparator).trim();
      return this.format(he(t, l, m, this.options.keySeparator, this.options.ignoreJSONStructure), v, i, {
        ...s,
        ...t,
        interpolationkey: m
      });
    };
    this.resetRegExp();
    const f = s?.missingInterpolationHandler || this.options.missingInterpolationHandler, h = s?.interpolation?.skipOnVariables !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
    return [{
      regex: this.regexpUnescape,
      safeValue: (g) => Y(g)
    }, {
      regex: this.regexp,
      safeValue: (g) => this.escapeValue ? Y(this.escape(g)) : Y(g)
    }].forEach((g) => {
      for (a = 0; r = g.regex.exec(e); ) {
        const c = r[1].trim();
        if (n = u(c), n === void 0)
          if (typeof f == "function") {
            const v = f(e, r, s);
            n = d(v) ? v : "";
          } else if (s && Object.prototype.hasOwnProperty.call(s, c))
            n = "";
          else if (h) {
            n = r[0];
            continue;
          } else
            this.logger.warn(`missed to pass in variable ${c} for interpolating ${e}`), n = "";
        else !d(n) && !this.useRawValueToEscape && (n = ee(n));
        const m = g.safeValue(n);
        if (e = e.replace(r[0], m), h ? (g.regex.lastIndex += n.length, g.regex.lastIndex -= r[0].length) : g.regex.lastIndex = 0, a++, a >= this.maxReplaces)
          break;
      }
    }), e;
  }
  nest(e, t, i = {}) {
    let s, r, n;
    const a = (l, u) => {
      const f = this.nestingOptionsSeparator;
      if (l.indexOf(f) < 0) return l;
      const h = l.split(new RegExp(`${f}[ ]*{`));
      let p = `{${h[1]}`;
      l = h[0], p = this.interpolate(p, n);
      const g = p.match(/'/g), c = p.match(/"/g);
      ((g?.length ?? 0) % 2 === 0 && !c || c.length % 2 !== 0) && (p = p.replace(/'/g, '"'));
      try {
        n = JSON.parse(p), u && (n = {
          ...u,
          ...n
        });
      } catch (m) {
        return this.logger.warn(`failed parsing options string in nesting for key ${l}`, m), `${l}${f}${p}`;
      }
      return n.defaultValue && n.defaultValue.indexOf(this.prefix) > -1 && delete n.defaultValue, l;
    };
    for (; s = this.nestingRegexp.exec(e); ) {
      let l = [];
      n = {
        ...i
      }, n = n.replace && !d(n.replace) ? n.replace : n, n.applyPostProcessor = !1, delete n.defaultValue;
      const u = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
      if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((f) => f.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), r = t(a.call(this, s[1].trim(), n), n), r && s[0] === e && !d(r)) return r;
      d(r) || (r = ee(r)), r || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), r = ""), l.length && (r = l.reduce((f, h) => this.format(f, h, i.lng, {
        ...i,
        interpolationkey: s[1].trim()
      }), r.trim())), e = e.replace(s[0], r), this.regexp.lastIndex = 0;
    }
    return e;
  }
}
const Fe = (o) => {
  let e = o.toLowerCase().trim();
  const t = {};
  if (o.indexOf("(") > -1) {
    const i = o.split("(");
    e = i[0].toLowerCase().trim();
    const s = i[1].substring(0, i[1].length - 1);
    e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((n) => {
      if (n) {
        const [a, ...l] = n.split(":"), u = l.join(":").trim().replace(/^'+|'+$/g, ""), f = a.trim();
        t[f] || (t[f] = u), u === "false" && (t[f] = !1), u === "true" && (t[f] = !0), isNaN(u) || (t[f] = parseInt(u, 10));
      }
    });
  }
  return {
    formatName: e,
    formatOptions: t
  };
}, fe = (o) => {
  const e = {};
  return (t, i, s) => {
    let r = s;
    s && s.interpolationkey && s.formatParams && s.formatParams[s.interpolationkey] && s[s.interpolationkey] && (r = {
      ...r,
      [s.interpolationkey]: void 0
    });
    const n = i + JSON.stringify(r);
    let a = e[n];
    return a || (a = o(U(i), s), e[n] = a), a(t);
  };
}, Ee = (o) => (e, t, i) => o(U(t), i)(e);
class je {
  constructor(e = {}) {
    this.logger = $.create("formatter"), this.options = e, this.init(e);
  }
  init(e, t = {
    interpolation: {}
  }) {
    this.formatSeparator = t.interpolation.formatSeparator || ",";
    const i = t.cacheInBuiltFormats ? fe : Ee;
    this.formats = {
      number: i((s, r) => {
        const n = new Intl.NumberFormat(s, {
          ...r
        });
        return (a) => n.format(a);
      }),
      currency: i((s, r) => {
        const n = new Intl.NumberFormat(s, {
          ...r,
          style: "currency"
        });
        return (a) => n.format(a);
      }),
      datetime: i((s, r) => {
        const n = new Intl.DateTimeFormat(s, {
          ...r
        });
        return (a) => n.format(a);
      }),
      relativetime: i((s, r) => {
        const n = new Intl.RelativeTimeFormat(s, {
          ...r
        });
        return (a) => n.format(a, r.range || "day");
      }),
      list: i((s, r) => {
        const n = new Intl.ListFormat(s, {
          ...r
        });
        return (a) => n.format(a);
      })
    };
  }
  add(e, t) {
    this.formats[e.toLowerCase().trim()] = t;
  }
  addCached(e, t) {
    this.formats[e.toLowerCase().trim()] = fe(t);
  }
  format(e, t, i, s = {}) {
    const r = t.split(this.formatSeparator);
    if (r.length > 1 && r[0].indexOf("(") > 1 && r[0].indexOf(")") < 0 && r.find((a) => a.indexOf(")") > -1)) {
      const a = r.findIndex((l) => l.indexOf(")") > -1);
      r[0] = [r[0], ...r.splice(1, a)].join(this.formatSeparator);
    }
    return r.reduce((a, l) => {
      const {
        formatName: u,
        formatOptions: f
      } = Fe(l);
      if (this.formats[u]) {
        let h = a;
        try {
          const p = s?.formatParams?.[s.interpolationkey] || {}, g = p.locale || p.lng || s.locale || s.lng || i;
          h = this.formats[u](a, g, {
            ...f,
            ...s,
            ...p
          });
        } catch (p) {
          this.logger.warn(p);
        }
        return h;
      } else
        this.logger.warn(`there was no format function for ${u}`);
      return a;
    }, e);
  }
}
const Ie = (o, e) => {
  o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
};
class Te extends Q {
  constructor(e, t, i, s = {}) {
    super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger = $.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(i, s.backend, s);
  }
  queueLoad(e, t, i, s) {
    const r = {}, n = {}, a = {}, l = {};
    return e.forEach((u) => {
      let f = !0;
      t.forEach((h) => {
        const p = `${u}|${h}`;
        !i.reload && this.store.hasResourceBundle(u, h) ? this.state[p] = 2 : this.state[p] < 0 || (this.state[p] === 1 ? n[p] === void 0 && (n[p] = !0) : (this.state[p] = 1, f = !1, n[p] === void 0 && (n[p] = !0), r[p] === void 0 && (r[p] = !0), l[h] === void 0 && (l[h] = !0)));
      }), f || (a[u] = !0);
    }), (Object.keys(r).length || Object.keys(n).length) && this.queue.push({
      pending: n,
      pendingCount: Object.keys(n).length,
      loaded: {},
      errors: [],
      callback: s
    }), {
      toLoad: Object.keys(r),
      pending: Object.keys(n),
      toLoadLanguages: Object.keys(a),
      toLoadNamespaces: Object.keys(l)
    };
  }
  loaded(e, t, i) {
    const s = e.split("|"), r = s[0], n = s[1];
    t && this.emit("failedLoading", r, n, t), !t && i && this.store.addResourceBundle(r, n, i, void 0, void 0, {
      skipCopy: !0
    }), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
    const a = {};
    this.queue.forEach((l) => {
      Se(l.loaded, [r], n), Ie(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
        a[u] || (a[u] = {});
        const f = l.loaded[u];
        f.length && f.forEach((h) => {
          a[u][h] === void 0 && (a[u][h] = !0);
        });
      }), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback());
    }), this.emit("loaded", a), this.queue = this.queue.filter((l) => !l.done);
  }
  read(e, t, i, s = 0, r = this.retryTimeout, n) {
    if (!e.length) return n(null, {});
    if (this.readingCalls >= this.maxParallelReads) {
      this.waitingReads.push({
        lng: e,
        ns: t,
        fcName: i,
        tried: s,
        wait: r,
        callback: n
      });
      return;
    }
    this.readingCalls++;
    const a = (u, f) => {
      if (this.readingCalls--, this.waitingReads.length > 0) {
        const h = this.waitingReads.shift();
        this.read(h.lng, h.ns, h.fcName, h.tried, h.wait, h.callback);
      }
      if (u && f && s < this.maxRetries) {
        setTimeout(() => {
          this.read.call(this, e, t, i, s + 1, r * 2, n);
        }, r);
        return;
      }
      n(u, f);
    }, l = this.backend[i].bind(this.backend);
    if (l.length === 2) {
      try {
        const u = l(e, t);
        u && typeof u.then == "function" ? u.then((f) => a(null, f)).catch(a) : a(null, u);
      } catch (u) {
        a(u);
      }
      return;
    }
    return l(e, t, a);
  }
  prepareLoading(e, t, i = {}, s) {
    if (!this.backend)
      return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
    d(e) && (e = this.languageUtils.toResolveHierarchy(e)), d(t) && (t = [t]);
    const r = this.queueLoad(e, t, i, s);
    if (!r.toLoad.length)
      return r.pending.length || s(), null;
    r.toLoad.forEach((n) => {
      this.loadOne(n);
    });
  }
  load(e, t, i) {
    this.prepareLoading(e, t, {}, i);
  }
  reload(e, t, i) {
    this.prepareLoading(e, t, {
      reload: !0
    }, i);
  }
  loadOne(e, t = "") {
    const i = e.split("|"), s = i[0], r = i[1];
    this.read(s, r, "read", void 0, void 0, (n, a) => {
      n && this.logger.warn(`${t}loading namespace ${r} for language ${s} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${r} for language ${s}`, a), this.loaded(e, n, a);
    });
  }
  saveMissing(e, t, i, s, r, n = {}, a = () => {
  }) {
    if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
      this.logger.warn(`did not save key "${i}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
      return;
    }
    if (!(i == null || i === "")) {
      if (this.backend?.create) {
        const l = {
          ...n,
          isUpdate: r
        }, u = this.backend.create.bind(this.backend);
        if (u.length < 6)
          try {
            let f;
            u.length === 5 ? f = u(e, t, i, s, l) : f = u(e, t, i, s), f && typeof f.then == "function" ? f.then((h) => a(null, h)).catch(a) : a(null, f);
          } catch (f) {
            a(f);
          }
        else
          u(e, t, i, s, a, l);
      }
      !e || !e[0] || this.store.addResource(e[0], t, i, s);
    }
  }
}
const ce = () => ({
  debug: !1,
  initAsync: !0,
  ns: ["translation"],
  defaultNS: ["translation"],
  fallbackLng: ["dev"],
  fallbackNS: !1,
  supportedLngs: !1,
  nonExplicitSupportedLngs: !1,
  load: "all",
  preload: !1,
  simplifyPluralSuffix: !0,
  keySeparator: ".",
  nsSeparator: ":",
  pluralSeparator: "_",
  contextSeparator: "_",
  partialBundledLanguages: !1,
  saveMissing: !1,
  updateMissing: !1,
  saveMissingTo: "fallback",
  saveMissingPlurals: !0,
  missingKeyHandler: !1,
  missingInterpolationHandler: !1,
  postProcess: !1,
  postProcessPassResolved: !1,
  returnNull: !1,
  returnEmptyString: !0,
  returnObjects: !1,
  joinArrays: !1,
  returnedObjectHandler: !1,
  parseMissingKeyHandler: !1,
  appendNamespaceToMissingKey: !1,
  appendNamespaceToCIMode: !1,
  overloadTranslationOptionHandler: (o) => {
    let e = {};
    if (typeof o[1] == "object" && (e = o[1]), d(o[1]) && (e.defaultValue = o[1]), d(o[2]) && (e.tDescription = o[2]), typeof o[2] == "object" || typeof o[3] == "object") {
      const t = o[3] || o[2];
      Object.keys(t).forEach((i) => {
        e[i] = t[i];
      });
    }
    return e;
  },
  interpolation: {
    escapeValue: !0,
    format: (o) => o,
    prefix: "{{",
    suffix: "}}",
    formatSeparator: ",",
    unescapePrefix: "-",
    nestingPrefix: "$t(",
    nestingSuffix: ")",
    nestingOptionsSeparator: ",",
    maxReplaces: 1e3,
    skipOnVariables: !0
  },
  cacheInBuiltFormats: !0
}), de = (o) => (d(o.ns) && (o.ns = [o.ns]), d(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), d(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), o.supportedLngs?.indexOf?.("cimode") < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o), B = () => {
}, De = (o) => {
  Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
    typeof o[t] == "function" && (o[t] = o[t].bind(o));
  });
};
class M extends Q {
  constructor(e = {}, t) {
    if (super(), this.options = de(e), this.services = {}, this.logger = $, this.modules = {
      external: []
    }, De(this), t && !this.isInitialized && !e.isClone) {
      if (!this.options.initAsync)
        return this.init(e, t), this;
      setTimeout(() => {
        this.init(e, t);
      }, 0);
    }
  }
  init(e = {}, t) {
    this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (d(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
    const i = ce();
    this.options = {
      ...i,
      ...this.options,
      ...de(e)
    }, this.options.interpolation = {
      ...i.interpolation,
      ...this.options.interpolation
    }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator);
    const s = (u) => u ? typeof u == "function" ? new u() : u : null;
    if (!this.options.isClone) {
      this.modules.logger ? $.init(s(this.modules.logger), this.options) : $.init(null, this.options);
      let u;
      this.modules.formatter ? u = this.modules.formatter : u = je;
      const f = new oe(this.options);
      this.store = new re(this.options.resources, this.options);
      const h = this.services;
      h.logger = $, h.resourceStore = this.store, h.languageUtils = f, h.pluralResolver = new Ne(f, {
        prepend: this.options.pluralSeparator,
        simplifyPluralSuffix: this.options.simplifyPluralSuffix
      }), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (h.formatter = s(u), h.formatter.init && h.formatter.init(h, this.options), this.options.interpolation.format = h.formatter.format.bind(h.formatter)), h.interpolator = new ke(this.options), h.utils = {
        hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
      }, h.backendConnector = new Te(s(this.modules.backend), h.resourceStore, h, this.options), h.backendConnector.on("*", (g, ...c) => {
        this.emit(g, ...c);
      }), this.modules.languageDetector && (h.languageDetector = s(this.modules.languageDetector), h.languageDetector.init && h.languageDetector.init(h, this.options.detection, this.options)), this.modules.i18nFormat && (h.i18nFormat = s(this.modules.i18nFormat), h.i18nFormat.init && h.i18nFormat.init(this)), this.translator = new W(this.services, this.options), this.translator.on("*", (g, ...c) => {
        this.emit(g, ...c);
      }), this.modules.external.forEach((g) => {
        g.init && g.init(this);
      });
    }
    if (this.format = this.options.interpolation.format, t || (t = B), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
      const u = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
      u.length > 0 && u[0] !== "dev" && (this.options.lng = u[0]);
    }
    !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((u) => {
      this[u] = (...f) => this.store[u](...f);
    }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
      this[u] = (...f) => (this.store[u](...f), this);
    });
    const a = K(), l = () => {
      const u = (f, h) => {
        this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), a.resolve(h), t(f, h);
      };
      if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
      this.changeLanguage(this.options.lng, u);
    };
    return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
  }
  loadResources(e, t = B) {
    let i = t;
    const s = d(e) ? e : this.language;
    if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
      if (s?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
      const r = [], n = (a) => {
        if (!a || a === "cimode") return;
        this.services.languageUtils.toResolveHierarchy(a).forEach((u) => {
          u !== "cimode" && r.indexOf(u) < 0 && r.push(u);
        });
      };
      s ? n(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => n(l)), this.options.preload?.forEach?.((a) => n(a)), this.services.backendConnector.load(r, this.options.ns, (a) => {
        !a && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), i(a);
      });
    } else
      i(null);
  }
  reloadResources(e, t, i) {
    const s = K();
    return typeof e == "function" && (i = e, e = void 0), typeof t == "function" && (i = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), i || (i = B), this.services.backendConnector.reload(e, t, (r) => {
      s.resolve(), i(r);
    }), s;
  }
  use(e) {
    if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
    if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
    return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && pe.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
  }
  setResolvedLanguage(e) {
    if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
      for (let t = 0; t < this.languages.length; t++) {
        const i = this.languages[t];
        if (!(["cimode", "dev"].indexOf(i) > -1) && this.store.hasLanguageSomeTranslations(i)) {
          this.resolvedLanguage = i;
          break;
        }
      }
      !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
    }
  }
  changeLanguage(e, t) {
    this.isLanguageChangingTo = e;
    const i = K();
    this.emit("languageChanging", e);
    const s = (a) => {
      this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
    }, r = (a, l) => {
      l ? this.isLanguageChangingTo === e && (s(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, i.resolve((...u) => this.t(...u)), t && t(a, (...u) => this.t(...u));
    }, n = (a) => {
      !e && !a && this.services.languageDetector && (a = []);
      const l = d(a) ? a : a && a[0], u = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes(d(a) ? [a] : a);
      u && (this.language || s(u), this.translator.language || this.translator.changeLanguage(u), this.services.languageDetector?.cacheUserLanguage?.(u)), this.loadResources(u, (f) => {
        r(f, u);
      });
    };
    return !e && this.services.languageDetector && !this.services.languageDetector.async ? n(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(n) : this.services.languageDetector.detect(n) : n(e), i;
  }
  getFixedT(e, t, i) {
    const s = (r, n, ...a) => {
      let l;
      typeof n != "object" ? l = this.options.overloadTranslationOptionHandler([r, n].concat(a)) : l = {
        ...n
      }, l.lng = l.lng || s.lng, l.lngs = l.lngs || s.lngs, l.ns = l.ns || s.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || i || s.keyPrefix);
      const u = this.options.keySeparator || ".";
      let f;
      return l.keyPrefix && Array.isArray(r) ? f = r.map((h) => `${l.keyPrefix}${u}${h}`) : f = l.keyPrefix ? `${l.keyPrefix}${u}${r}` : r, this.t(f, l);
    };
    return d(e) ? s.lng = e : s.lngs = e, s.ns = t, s.keyPrefix = i, s;
  }
  t(...e) {
    return this.translator?.translate(...e);
  }
  exists(...e) {
    return this.translator?.exists(...e);
  }
  setDefaultNamespace(e) {
    this.options.defaultNS = e;
  }
  hasLoadedNamespace(e, t = {}) {
    if (!this.isInitialized)
      return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
    if (!this.languages || !this.languages.length)
      return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
    const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, r = this.languages[this.languages.length - 1];
    if (i.toLowerCase() === "cimode") return !0;
    const n = (a, l) => {
      const u = this.services.backendConnector.state[`${a}|${l}`];
      return u === -1 || u === 0 || u === 2;
    };
    if (t.precheck) {
      const a = t.precheck(this, n);
      if (a !== void 0) return a;
    }
    return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || n(i, e) && (!s || n(r, e)));
  }
  loadNamespaces(e, t) {
    const i = K();
    return this.options.ns ? (d(e) && (e = [e]), e.forEach((s) => {
      this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
    }), this.loadResources((s) => {
      i.resolve(), t && t(s);
    }), i) : (t && t(), Promise.resolve());
  }
  loadLanguages(e, t) {
    const i = K();
    d(e) && (e = [e]);
    const s = this.options.preload || [], r = e.filter((n) => s.indexOf(n) < 0 && this.services.languageUtils.isSupportedCode(n));
    return r.length ? (this.options.preload = s.concat(r), this.loadResources((n) => {
      i.resolve(), t && t(n);
    }), i) : (t && t(), Promise.resolve());
  }
  dir(e) {
    if (e || (e = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language)), !e) return "rtl";
    try {
      const s = new Intl.Locale(e);
      if (s && s.getTextInfo) {
        const r = s.getTextInfo();
        if (r && r.direction) return r.direction;
      }
    } catch {
    }
    const t = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], i = this.services?.languageUtils || new oe(ce());
    return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
  }
  static createInstance(e = {}, t) {
    return new M(e, t);
  }
  cloneInstance(e = {}, t = B) {
    const i = e.forkResourceStore;
    i && delete e.forkResourceStore;
    const s = {
      ...this.options,
      ...e,
      isClone: !0
    }, r = new M(s);
    if ((e.debug !== void 0 || e.prefix !== void 0) && (r.logger = r.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
      r[a] = this[a];
    }), r.services = {
      ...this.services
    }, r.services.utils = {
      hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
    }, i) {
      const a = Object.keys(this.store.data).reduce((l, u) => (l[u] = {
        ...this.store.data[u]
      }, l[u] = Object.keys(l[u]).reduce((f, h) => (f[h] = {
        ...l[u][h]
      }, f), l[u]), l), {});
      r.store = new re(a, s), r.services.resourceStore = r.store;
    }
    return r.translator = new W(r.services, s), r.translator.on("*", (a, ...l) => {
      r.emit(a, ...l);
    }), r.init(s, t), r.translator.options = s, r.translator.backendConnector.services.utils = {
      hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
    }, r;
  }
  toJSON() {
    return {
      options: this.options,
      store: this.store,
      language: this.language,
      languages: this.languages,
      resolvedLanguage: this.resolvedLanguage
    };
  }
}
const y = M.createInstance();
y.createInstance = M.createInstance;
const Ve = y.createInstance;
y.dir;
y.init;
y.loadResources;
y.reloadResources;
y.use;
y.changeLanguage;
y.getFixedT;
y.t;
y.exists;
y.setDefaultNamespace;
y.hasLoadedNamespace;
y.loadNamespaces;
y.loadLanguages;
export {
  Ve as createInstance,
  y as default
};
//# sourceMappingURL=index.es76.js.map
