svgedit
Version:
Powerful SVG-Editor for your browser
1,139 lines • 2.76 MB
JavaScript
//#region \0rolldown/runtime.js
var e = Object.defineProperty, t = (e, t, n) => () => {
if (n) throw n[0];
try {
return e && (t = e(e = 0)), t;
} catch (e) {
throw n = [e], e;
}
}, n = (t, n) => {
let r = {};
for (var i in t) e(r, i, {
get: t[i],
enumerable: !0
});
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
};
//#endregion
//#region node_modules/i18next/dist/esm/i18next.js
function r() {
let e = [], t = Object.create(null), n;
return t.get = (r, i) => (n?.revoke?.(), i === N ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
}
function i(e, t) {
let { [N]: n } = e(r()), i = t?.keySeparator ?? ".", a = t?.nsSeparator ?? ":", o = t?.enableSelector === "strict";
if (n.length > 1 && a) {
let e = t?.ns, r = o ? Array.isArray(e) ? e : e ? [e] : null : Array.isArray(e) ? e : null;
if (r && (o ? r : r.length > 1 ? r.slice(1) : []).includes(n[0])) return `${n[0]}${a}${n.slice(1).join(i)}`;
}
return n.join(i);
}
var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, j, M, N, P, ee, F, te, ne, I, L, re, ie, ae, oe, R, z, se, ce, le, ue, B, de, fe, pe, me = t((() => {
a = (e) => typeof e == "string", o = () => {
let e, t, n = new Promise((n, r) => {
e = n, t = r;
});
return n.resolve = e, n.reject = t, n;
}, s = (e) => e == null ? "" : String(e), c = (e, t, n) => {
e.forEach((e) => {
t[e] && (n[e] = t[e]);
});
}, l = /###/g, u = (e) => e && e.includes("###") ? e.replace(l, ".") : e, d = (e) => !e || a(e), f = (e, t, n) => {
let r = a(t) ? t.split(".") : t, i = 0;
for (; i < r.length - 1;) {
if (d(e)) return {};
let t = u(r[i]);
!e[t] && n && (e[t] = new n()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++i;
}
return d(e) ? {} : {
obj: e,
k: u(r[i])
};
}, p = (e, t, n) => {
let { obj: r, k: i } = f(e, t, Object);
if (r !== void 0 || t.length === 1) {
r[i] = n;
return;
}
let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = f(e, o, Object);
for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = f(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
s.obj[`${s.k}.${a}`] = n;
}, m = (e, t, n, r) => {
let { obj: i, k: a } = f(e, t, Object);
i[a] = i[a] || [], i[a].push(n);
}, h = (e, t) => {
let { obj: n, k: r } = f(e, t);
if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
}, g = (e, t, n) => {
let r = h(e, n);
return r === void 0 ? h(t, n) : r;
}, _ = (e, t, n) => {
for (let r in t) r !== "__proto__" && r !== "constructor" && (Object.prototype.hasOwnProperty.call(e, r) ? a(e[r]) || e[r] instanceof String || a(t[r]) || t[r] instanceof String ? n && (e[r] = t[r]) : _(e[r], t[r], n) : e[r] = t[r]);
return e;
}, v = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), y = {
"&": "&",
"<": "<",
">": ">",
"\"": """,
"'": "'",
"/": "/"
}, b = (e) => a(e) ? e.replace(/[&<>"'\/]/g, (e) => y[e]) : e, x = class {
constructor(e) {
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
}
getRegExp(e) {
let t = this.regExpMap.get(e);
if (t !== void 0) return t;
let n = new RegExp(e);
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
}
}, S = [
" ",
",",
"?",
"!",
";"
], C = new x(20), w = (e, t, n) => {
t ||= "", n ||= "";
let r = S.filter((e) => !t.includes(e) && !n.includes(e));
if (r.length === 0) return !0;
let i = C.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
if (!a) {
let t = e.indexOf(n);
t > 0 && !i.test(e.substring(0, t)) && (a = !0);
}
return a;
}, T = (e, t, n = ".") => {
if (!e) return;
if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
let r = t.split(n), i = e;
for (let e = 0; e < r.length;) {
if (!i || typeof i != "object") return;
let t, a = "";
for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
if ([
"string",
"number",
"boolean"
].includes(typeof t) && o < r.length - 1) continue;
e += o - e + 1;
break;
}
i = t;
}
return i;
}, E = (e) => e?.replace(/_/g, "-"), D = {
type: "logger",
log(e) {
this.output("log", e);
},
warn(e) {
this.output("warn", e);
},
error(e) {
this.output("error", e);
},
output(e, t) {
console?.[e]?.apply?.(console, t);
}
}, O = class e {
constructor(e, t = {}) {
this.init(e, t);
}
init(e, t = {}) {
this.prefix = t.prefix || "i18next:", this.logger = e || D, 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, n, r) {
return r && !this.debug ? null : (e = e.map((e) => a(e) ? e.replace(/[\r\n\x00-\x1F\x7F]/g, " ") : e), a(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
}
create(t) {
return new e(this.logger, {
prefix: `${this.prefix}:${t}:`,
...this.options
});
}
clone(t) {
return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
}
}, k = new O(), A = class {
constructor() {
this.observers = {};
}
on(e, t) {
return e.split(" ").forEach((e) => {
this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
let n = this.observers[e].get(t) || 0;
this.observers[e].set(t, n + 1);
}), this;
}
off(e, t) {
if (this.observers[e]) {
if (!t) {
delete this.observers[e];
return;
}
this.observers[e].delete(t);
}
}
once(e, t) {
let n = (...r) => {
t(...r), this.off(e, n);
};
return this.on(e, n), this;
}
emit(e, ...t) {
this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
for (let r = 0; r < n; r++) e(...t);
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
for (let i = 0; i < r; i++) n(e, ...t);
});
}
}, j = class extends A {
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.includes(e) || this.options.ns.push(e);
}
removeNamespaces(e) {
let t = this.options.ns.indexOf(e);
t > -1 && this.options.ns.splice(t, 1);
}
getResource(e, t, n, r = {}) {
let i = r.keySeparator === void 0 ? this.options.keySeparator : r.keySeparator, o = r.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : r.ignoreJSONStructure, s;
e.includes(".") ? s = e.split(".") : (s = [e, t], n && (Array.isArray(n) ? s.push(...n) : a(n) && i ? s.push(...n.split(i)) : s.push(n)));
let c = h(this.data, s);
return !c && !t && !n && e.includes(".") && (e = s[0], t = s[1], n = s.slice(2).join(".")), c || !o || !a(n) ? c : T(this.data?.[e]?.[t], n, i);
}
addResource(e, t, n, r, i = { silent: !1 }) {
let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
n && (o = o.concat(a ? n.split(a) : n)), e.includes(".") && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), p(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
}
addResources(e, t, n, r = { silent: !1 }) {
for (let r in n) (a(n[r]) || Array.isArray(n[r])) && this.addResource(e, t, r, n[r], { silent: !0 });
r.silent || this.emit("added", e, t, n);
}
addResourceBundle(e, t, n, r, i, a = {
silent: !1,
skipCopy: !1
}) {
let o = [e, t];
e.includes(".") && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
let s = h(this.data, o) || {};
a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? _(s, n, i) : s = {
...s,
...n
}, p(this.data, o, s), a.silent || this.emit("added", e, t, n);
}
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 ||= this.options.defaultNS, this.getResource(e, t);
}
getDataByLanguage(e) {
return this.data[e];
}
hasLanguageSomeTranslations(e) {
let t = this.getDataByLanguage(e);
return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
}
toJSON() {
return this.data;
}
}, M = {
processors: {},
addPostProcessor(e) {
this.processors[e.name] = e;
},
handle(e, t, n, r, i) {
return e.forEach((e) => {
t = this.processors[e]?.process(t, n, r, i) ?? t;
}), t;
}
}, N = Symbol("i18next/PATH_KEY"), P = (e) => !a(e) && typeof e != "boolean" && typeof e != "number", ee = class e extends A {
constructor(e, t = {}) {
super(), c([
"resourceStore",
"languageUtils",
"pluralResolver",
"interpolator",
"backendConnector",
"i18nFormat",
"utils"
], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = k.create("translator"), this.checkedLoadedFor = {};
}
changeLanguage(e) {
e && (this.language = e);
}
exists(e, t = { interpolation: {} }) {
let n = { ...t };
if (e == null) return !1;
let r = this.resolve(e, n);
if (r?.res === void 0) return !1;
let i = P(r.res);
return !(n.returnObjects === !1 && i);
}
extractFromKey(e, t) {
let n = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
n === void 0 && (n = ":");
let r = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, i = t.ns || this.options.defaultNS || [], o = n && e.includes(n), s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !w(e, n, r);
if (o && !s) {
let t = e.match(this.interpolator.nestingRegexp);
if (t && t.length > 0) return {
key: e,
namespaces: a(i) ? [i] : i
};
let o = e.split(n);
(n !== r || n === r && this.options.ns.includes(o[0])) && (i = o.shift()), e = o.join(r);
}
return {
key: e,
namespaces: a(i) ? [i] : i
};
}
translate(t, n, r) {
let o = typeof n == "object" ? { ...n } : n;
if (typeof o != "object" && this.options.overloadTranslationOptionHandler && (o = this.options.overloadTranslationOptionHandler(arguments)), typeof o == "object" && (o = { ...o }), o ||= {}, t == null) return "";
typeof t == "function" && (t = i(t, {
...this.options,
...o
})), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? i(e, {
...this.options,
...o
}) : String(e));
let s = o.returnDetails === void 0 ? this.options.returnDetails : o.returnDetails, c = o.keySeparator === void 0 ? this.options.keySeparator : o.keySeparator, { key: l, namespaces: u } = this.extractFromKey(t[t.length - 1], o), d = u[u.length - 1], f = o.nsSeparator === void 0 ? this.options.nsSeparator : o.nsSeparator;
f === void 0 && (f = ":");
let p = o.lng || this.language, m = o.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
if (p?.toLowerCase() === "cimode") return m ? s ? {
res: `${d}${f}${l}`,
usedKey: l,
exactUsedKey: l,
usedLng: p,
usedNS: d,
usedParams: this.getUsedParamsDetails(o)
} : `${d}${f}${l}` : s ? {
res: l,
usedKey: l,
exactUsedKey: l,
usedLng: p,
usedNS: d,
usedParams: this.getUsedParamsDetails(o)
} : l;
let h = this.resolve(t, o), g = h?.res, _ = h?.usedKey || l, v = h?.exactUsedKey || l, y = [
"[object Number]",
"[object Function]",
"[object RegExp]"
], b = o.joinArrays === void 0 ? this.options.joinArrays : o.joinArrays, x = !this.i18nFormat || this.i18nFormat.handleAsObject, S = o.count !== void 0 && !a(o.count), C = e.hasDefaultValue(o), w = S ? this.pluralResolver.getSuffix(p, o.count, o) : "", T = o.ordinal && S ? this.pluralResolver.getSuffix(p, o.count, { ordinal: !1 }) : "", E = S && !o.ordinal && o.count === 0, D = E && o[`defaultValue${this.options.pluralSeparator}zero`] || o[`defaultValue${w}`] || o[`defaultValue${T}`] || o.defaultValue, O = g;
x && !g && C && (O = D);
let k = P(O), A = Object.prototype.toString.apply(O);
if (x && O && k && !y.includes(A) && !(a(b) && Array.isArray(O))) {
if (!o.returnObjects && !this.options.returnObjects) {
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(_, O, {
...o,
ns: u
}) : `key '${l} (${this.language})' returned an object instead of string.`;
return s ? (h.res = e, h.usedParams = this.getUsedParamsDetails(o), h) : e;
}
if (c) {
let e = Array.isArray(O), t = e ? [] : {}, n = e ? v : _;
for (let e in O) if (Object.prototype.hasOwnProperty.call(O, e)) {
let r = `${n}${c}${e}`;
C && !g ? t[e] = this.translate(r, {
...o,
defaultValue: P(D) ? D[e] : void 0,
joinArrays: !1,
ns: u
}) : t[e] = this.translate(r, {
...o,
joinArrays: !1,
ns: u
}), t[e] === r && (t[e] = O[e]);
}
g = t;
}
} else if (x && a(b) && Array.isArray(g)) g = g.join(b), g &&= this.extendTranslation(g, t, o, r);
else {
let e = !1, n = !1;
!this.isValidLookup(g) && C && (e = !0, g = D), this.isValidLookup(g) || (n = !0, g = l);
let i = (o.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : g, a = C && D !== g && this.options.updateMissing;
if (n || e || a) {
if (this.logger.log(a ? "updateKey" : "missingKey", p, d, S && !a ? `${l}${this.pluralResolver.getSuffix(p, o.count, o)}` : l, a ? D : g), c) {
let e = this.resolve(l, {
...o,
keySeparator: !1
});
e && e.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 e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, o.lng || this.language);
if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(o.lng || this.language) : e.push(o.lng || this.language);
let n = (e, t, n) => {
let r = C && n !== g ? n : i;
this.options.missingKeyHandler ? this.options.missingKeyHandler(e, d, t, r, a, o) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, d, t, r, a, o), this.emit("missingKey", e, d, t, g);
};
this.options.saveMissing && (this.options.saveMissingPlurals && S ? e.forEach((e) => {
let t = this.pluralResolver.getSuffixes(e, o);
E && o[`defaultValue${this.options.pluralSeparator}zero`] && !t.includes(`${this.options.pluralSeparator}zero`) && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
n([e], l + t, o[`defaultValue${t}`] || D);
});
}) : n(e, l, D));
}
g = this.extendTranslation(g, t, o, h, r), n && g === l && this.options.appendNamespaceToMissingKey && (g = `${d}${f}${l}`), (n || e) && this.options.parseMissingKeyHandler && (g = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${d}${f}${l}` : l, e ? g : void 0, o));
}
return s ? (h.res = g, h.usedParams = this.getUsedParamsDetails(o), h) : g;
}
extendTranslation(e, t, n, r, i) {
if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
...this.options.interpolation.defaultVariables,
...n
}, n.lng || this.language || r.usedLng, r.usedNS, r.usedKey, { resolved: r });
else if (!n.skipInterpolation) {
n.interpolation && this.interpolator.init({
...n,
interpolation: {
...this.options.interpolation,
...n.interpolation
}
});
let o = a(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), s;
if (o) {
let t = e.match(this.interpolator.nestingRegexp);
s = t && t.length;
}
let c = n.replace && !a(n.replace) ? n.replace : n;
if (this.options.interpolation.defaultVariables && (c = {
...this.options.interpolation.defaultVariables,
...c
}), e = this.interpolator.interpolate(e, c, n.lng || this.language || r.usedLng, n), o) {
let t = e.match(this.interpolator.nestingRegexp), r = t && t.length;
s < r && (n.nest = !1);
}
!n.lng && r && r.res && (n.lng = this.language || r.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, (...e) => i?.[0] === e[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), n)), n.interpolation && this.interpolator.reset();
}
let o = n.postProcess || this.options.postProcess, s = a(o) ? [o] : o;
return e != null && s?.length && n.applyPostProcessor !== !1 && (e = M.handle(s, e, t, this.options && this.options.postProcessPassResolved ? {
i18nResolved: {
...r,
usedParams: this.getUsedParamsDetails(n)
},
...n
} : n, this)), e;
}
resolve(e, t = {}) {
let n, r, o, s, c;
return a(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? i(e, {
...this.options,
...t
}) : e)), e.forEach((e) => {
if (this.isValidLookup(n)) return;
let i = this.extractFromKey(e, t), l = i.key;
r = l;
let u = i.namespaces;
this.options.fallbackNS && (u = u.concat(this.options.fallbackNS));
let d = t.count !== void 0 && !a(t.count), f = d && !t.ordinal && t.count === 0, p = t.context !== void 0 && (a(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
u.forEach((e) => {
this.isValidLookup(n) || (c = e, !this.checkedLoadedFor[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(c) && (this.checkedLoadedFor[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${r}" for languages "${m.join(", ")}" won't get resolved as namespace "${c}" 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((r) => {
if (this.isValidLookup(n)) return;
s = r;
let i = [l];
if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(i, l, r, e, t);
else {
let e;
d && (e = this.pluralResolver.getSuffix(r, t.count, t));
let n = `${this.options.pluralSeparator}zero`, a = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
if (d && (t.ordinal && e.startsWith(a) && i.push(l + e.replace(a, this.options.pluralSeparator)), i.push(l + e), f && i.push(l + n)), p) {
let r = `${l}${this.options.contextSeparator || "_"}${t.context}`;
i.push(r), d && (t.ordinal && e.startsWith(a) && i.push(r + e.replace(a, this.options.pluralSeparator)), i.push(r + e), f && i.push(r + n));
}
}
let a;
for (; a = i.pop();) this.isValidLookup(n) || (o = a, n = this.getResource(r, e, a, t));
}));
});
}), {
res: n,
usedKey: r,
exactUsedKey: o,
usedLng: s,
usedNS: c
};
}
isValidLookup(e) {
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
}
getResource(e, t, n, r = {}) {
return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
}
getUsedParamsDetails(e = {}) {
let t = [
"defaultValue",
"ordinal",
"context",
"replace",
"lng",
"lngs",
"fallbackLng",
"ns",
"keySeparator",
"nsSeparator",
"returnObjects",
"returnDetails",
"joinArrays",
"postProcess",
"interpolation"
], n = e.replace && !a(e.replace), r = n ? e.replace : e;
if (n && e.count !== void 0 && (r = {
...r,
count: e.count
}), this.options.interpolation.defaultVariables && (r = {
...this.options.interpolation.defaultVariables,
...r
}), !n) {
r = { ...r };
for (let e of t) delete r[e];
}
return r;
}
static hasDefaultValue(e) {
for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.startsWith("defaultValue") && e[t] !== void 0) return !0;
return !1;
}
}, F = class {
constructor(e) {
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = k.create("languageUtils");
}
getScriptPartFromCode(e) {
if (e = E(e), !e || !e.includes("-")) return null;
let t = e.split("-");
return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
}
getLanguagePartFromCode(e) {
if (e = E(e), !e || !e.includes("-")) return e;
let t = e.split("-");
return this.formatLanguageCode(t[0]);
}
formatLanguageCode(e) {
if (a(e) && e.includes("-")) {
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.includes(e);
}
getBestMatchFromCodes(e) {
if (!e) return null;
let t;
return e.forEach((e) => {
if (t) return;
let n = this.formatLanguageCode(e);
(!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
}), !t && this.options.supportedLngs && e.forEach((e) => {
if (t) return;
let n = this.getScriptPartFromCode(e);
if (this.isSupportedCode(n)) return t = n;
let r = this.getLanguagePartFromCode(e);
if (this.isSupportedCode(r)) return t = r;
t = this.options.supportedLngs.find((e) => e === r ? !0 : !e.includes("-") && !r.includes("-") ? !1 : !!(e.includes("-") && !r.includes("-") && e.slice(0, e.indexOf("-")) === r || e.startsWith(r) && r.length > 1));
}), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
}
getFallbackCodes(e, t) {
if (!e) return [];
if (typeof e == "function" && (e = e(t)), a(e) && (e = [e]), Array.isArray(e)) return e;
if (!t) return e.default || [];
let n = e[t];
return n ||= e[this.getScriptPartFromCode(t)], n ||= e[this.formatLanguageCode(t)], n ||= e[this.getLanguagePartFromCode(t)], n ||= e.default, n || [];
}
toResolveHierarchy(e, t) {
let n = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), r = [], i = (e) => {
e && (this.isSupportedCode(e) ? r.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
};
return a(e) && (e.includes("-") || e.includes("_")) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : a(e) && i(this.formatLanguageCode(e)), n.forEach((e) => {
r.includes(e) || i(this.formatLanguageCode(e));
}), r;
}
}, te = {
zero: 0,
one: 1,
two: 2,
few: 3,
many: 4,
other: 5
}, ne = {
select: (e) => e === 1 ? "one" : "other",
resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
}, I = class {
constructor(e, t = {}) {
this.languageUtils = e, this.options = t, this.logger = k.create("pluralResolver"), this.pluralRulesCache = {};
}
clearCache() {
this.pluralRulesCache = {};
}
getRule(e, t = {}) {
let n = E(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
cleanedCode: n,
type: r
});
if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
let a;
try {
a = new Intl.PluralRules(n, { type: r });
} catch {
if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), ne;
if (!e.match(/-|_/)) return ne;
let n = this.languageUtils.getLanguagePartFromCode(e);
a = this.getRule(n, t);
}
return this.pluralRulesCache[i] = a, a;
}
needsPlural(e, t = {}) {
let n = this.getRule(e, t);
return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
}
getPluralFormsOfKey(e, t, n = {}) {
return this.getSuffixes(e, n).map((e) => `${t}${e}`);
}
getSuffixes(e, t = {}) {
let n = this.getRule(e, t);
return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => te[e] - te[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
}
getSuffix(e, t, n = {}) {
let r = this.getRule(e, n);
return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
}
}, L = (e, t, n, r = ".", i = !0) => {
let o = g(e, t, n);
return !o && i && a(n) && (o = T(e, n, r), o === void 0 && (o = T(t, n, r))), o;
}, re = (e) => e.replace(/\$/g, "$$$$"), ie = class {
constructor(e = {}) {
this.logger = k.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
}
init(e = {}) {
e.interpolation ||= { escapeValue: !0 };
let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: h, maxReplaces: g, alwaysFormat: _ } = e.interpolation;
this.escape = t === void 0 ? b : t, this.escapeValue = n === void 0 || n, this.useRawValueToEscape = r !== void 0 && r, this.prefix = i ? v(i) : a || "{{", this.suffix = o ? v(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u ? v(u) : "-", this.unescapeSuffix = this.unescapePrefix ? "" : l ? v(l) : "", this.nestingPrefix = d ? v(d) : f || v("$t("), this.nestingSuffix = p ? v(p) : m || v(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = g || 1e3, this.alwaysFormat = _ !== void 0 && _, this.resetRegExp();
}
reset() {
this.options && this.init(this.options);
}
resetRegExp() {
let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "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, n, r) {
let i, o, c, l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (e) => {
if (!e.includes(this.formatSeparator)) {
let i = L(t, l, e, this.options.keySeparator, this.options.ignoreJSONStructure);
return this.alwaysFormat ? this.format(i, void 0, n, {
...r,
...t,
interpolationkey: e
}) : i;
}
let i = e.split(this.formatSeparator), a = i.shift().trim(), o = i.join(this.formatSeparator).trim();
return this.format(L(t, l, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
...r,
...t,
interpolationkey: a
});
};
this.resetRegExp(), !this.escapeValue && typeof e == "string" && /\$t\([^)]*\{[^}]*\{\{/.test(e) && this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");
let d = r?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables;
return [{
regex: this.regexpUnescape,
safeValue: (e) => e
}, {
regex: this.regexp,
safeValue: (e) => this.escapeValue ? this.escape(e) : e
}].forEach((t) => {
for (c = 0; i = t.regex.exec(e);) {
let n = i[1].trim();
if (o = u(n), o === void 0) if (typeof d == "function") {
let t = d(e, i, r);
o = a(t) ? t : "";
} else if (r && Object.prototype.hasOwnProperty.call(r, n)) o = "";
else if (f) {
o = i[0];
continue;
} else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`), o = "";
else !a(o) && !this.useRawValueToEscape && (o = s(o));
let l = t.safeValue(o);
if (e = e.replace(i[0], re(l)), f ? (t.regex.lastIndex += l.length, t.regex.lastIndex -= i[0].length) : t.regex.lastIndex = 0, c++, c >= this.maxReplaces) break;
}
}), e;
}
nest(e, t, n = {}) {
let r, i, o, c = (e, t) => {
let n = this.nestingOptionsSeparator;
if (!e.includes(n)) return e;
let r = e.split(RegExp(`${v(n)}[ ]*{`)), i = `{${r[1]}`;
e = r[0], i = this.interpolate(i, o);
let a = i.match(/'/g), s = i.match(/"/g);
((a?.length ?? 0) % 2 == 0 && !s || (s?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
try {
o = JSON.parse(i), t && (o = {
...t,
...o
});
} catch (t) {
return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
}
return o.defaultValue && o.defaultValue.includes(this.prefix) && delete o.defaultValue, e;
};
for (; r = this.nestingRegexp.exec(e);) {
let l = [];
o = { ...n }, o = o.replace && !a(o.replace) ? o.replace : o, o.applyPostProcessor = !1, delete o.defaultValue;
let u = /{.*}/s.test(r[1]) ? r[1].lastIndexOf("}") + 1 : r[1].indexOf(this.formatSeparator);
if (u !== -1 && (l = r[1].slice(u).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), r[1] = r[1].slice(0, u)), i = t(c.call(this, r[1].trim(), o), o), i && r[0] === e && !a(i)) return i;
a(i) || (i = s(i)), i ||= (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), ""), l.length && (i = l.reduce((e, t) => this.format(e, t, n.lng, {
...n,
interpolationkey: r[1].trim()
}), i.trim())), e = e.replace(r[0], i), this.regexp.lastIndex = 0;
}
return e;
}
}, ae = (e) => {
let t = e.toLowerCase().trim(), n = {};
if (e.includes("(")) {
let r = e.split("(");
t = r[0].toLowerCase().trim();
let i = r[1].slice(0, -1);
t === "currency" && !i.includes(":") ? n.currency ||= i.trim() : t === "relativetime" && !i.includes(":") ? n.range ||= i.trim() : i.split(";").forEach((e) => {
if (e) {
let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
}
});
}
return {
formatName: t,
formatOptions: n
};
}, oe = (e) => {
let t = {};
return (n, r, i) => {
let a = i;
i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
...a,
[i.interpolationkey]: void 0
});
let o = r + JSON.stringify(a), s = t[o];
return s || (s = e(E(r), i), t[o] = s), s(n);
};
}, R = (e) => (t, n, r) => e(E(n), r)(t), z = class {
constructor(e = {}) {
this.logger = k.create("formatter"), this.options = e, this.init(e);
}
init(e, t = { interpolation: {} }) {
this.formatSeparator = t.interpolation.formatSeparator || ",";
let n = t.cacheInBuiltFormats ? oe : R;
this.formats = {
number: n((e, t) => {
let n = new Intl.NumberFormat(e, { ...t });
return (e) => n.format(e);
}),
currency: n((e, t) => {
let n = new Intl.NumberFormat(e, {
...t,
style: "currency"
});
return (e) => n.format(e);
}),
datetime: n((e, t) => {
let n = new Intl.DateTimeFormat(e, { ...t });
return (e) => n.format(e);
}),
relativetime: n((e, t) => {
let n = new Intl.RelativeTimeFormat(e, { ...t });
return (e) => n.format(e, t.range || "day");
}),
list: n((e, t) => {
let n = new Intl.ListFormat(e, { ...t });
return (e) => n.format(e);
})
};
}
add(e, t) {
this.formats[e.toLowerCase().trim()] = t;
}
addCached(e, t) {
this.formats[e.toLowerCase().trim()] = oe(t);
}
format(e, t, n, r = {}) {
if (!t || e == null) return e;
let i = t.split(this.formatSeparator), a = [];
for (let e = 0; e < i.length; e++) {
let t = i[e];
for (; t.indexOf("(") > -1 && !t.includes(")") && e + 1 < i.length;) t = `${t}${this.formatSeparator}${i[++e]}`;
a.push(t);
}
return a.reduce((e, t) => {
let { formatName: i, formatOptions: a } = ae(t);
if (this.formats[i]) {
let t = e;
try {
let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
t = this.formats[i](e, s, {
...a,
...r,
...o
});
} catch (e) {
this.logger.warn(e);
}
return t;
} else this.logger.warn(`there was no format function for ${i}`);
return e;
}, e);
}
}, se = (e, t) => {
e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
}, ce = class extends A {
constructor(e, t, n, r = {}) {
super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = k.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
}
queueLoad(e, t, n, r) {
let i = {}, a = {}, o = {}, s = {};
return e.forEach((e) => {
let r = !0;
t.forEach((t) => {
let o = `${e}|${t}`;
!n.reload && this.store.hasResourceBundle(e, t) ? this.state[o] = 2 : this.state[o] < 0 || (this.state[o] === 1 ? a[o] === void 0 && (a[o] = !0) : (this.state[o] = 1, r = !1, a[o] === void 0 && (a[o] = !0), i[o] === void 0 && (i[o] = !0), s[t] === void 0 && (s[t] = !0)));
}), r || (o[e] = !0);
}), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
pending: a,
pendingCount: Object.keys(a).length,
loaded: {},
errors: [],
callback: r
}), {
toLoad: Object.keys(i),
pending: Object.keys(a),
toLoadLanguages: Object.keys(o),
toLoadNamespaces: Object.keys(s)
};
}
loaded(e, t, n) {
let r = e.split("|"), i = r[0], a = r[1];
t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
let o = {};
this.queue.forEach((n) => {
m(n.loaded, [i], a), se(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
o[e] || (o[e] = {});
let t = n.loaded[e];
t.length && t.forEach((t) => {
o[e][t] === void 0 && (o[e][t] = !0);
});
}), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
}), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
}
read(e, t, n, r = 0, i = this.retryTimeout, a) {
if (!e.length) return a(null, {});
if (this.readingCalls >= this.maxParallelReads) {
this.waitingReads.push({
lng: e,
ns: t,
fcName: n,
tried: r,
wait: i,
callback: a
});
return;
}
this.readingCalls++;
let o = (o, s) => {
if (this.readingCalls--, this.waitingReads.length > 0) {
let e = this.waitingReads.shift();
this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
}
if (o && s && r < this.maxRetries) {
setTimeout(() => {
this.read(e, t, n, r + 1, i * 2, a);
}, i);
return;
}
a(o, s);
}, s = this.backend[n].bind(this.backend);
if (s.length === 2) {
try {
let n = s(e, t);
n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
} catch (e) {
o(e);
}
return;
}
return s(e, t, o);
}
prepareLoading(e, t, n = {}, r) {
if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), r && r();
a(e) && (e = this.languageUtils.toResolveHierarchy(e)), a(t) && (t = [t]);
let i = this.queueLoad(e, t, n, r);
if (!i.toLoad.length) return i.pending.length || r(), null;
i.toLoad.forEach((e) => {
this.loadOne(e);
});
}
load(e, t, n) {
this.prepareLoading(e, t, {}, n);
}
reload(e, t, n) {
this.prepareLoading(e, t, { reload: !0 }, n);
}
loadOne(e, t = "") {
let n = e.split("|"), r = n[0], i = n[1];
this.read(r, i, "read", void 0, void 0, (n, a) => {
n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
});
}
saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
this.logger.warn(`did not save key "${n}" 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 (!(n == null || n === "")) {
if (this.backend?.create) {
let s = {
...a,
isUpdate: i
}, c = this.backend.create.bind(this.backend);
if (c.length < 6) try {
let i;
i = c.length === 5 ? c(e, t, n, r, s) : c(e, t, n, r), i && typeof i.then == "function" ? i.then((e) => o(null, e)).catch(o) : o(null, i);
} catch (e) {
o(e);
}
else c(e, t, n, r, o, s);
}
!e || !e[0] || this.store.addResource(e[0], t, n, r);
}
}
}, le = () => ({
debug: !1,
initAsync: !0,
ns: ["translation"],
defaultNS: ["translation"],
fallbackLng: ["dev"],
fallbackNS: !1,
supportedLngs: !1,
nonExplicitSupportedLngs: !1,
load: "all",
preload: !1,
keySeparator: ".",
nsSeparator: ":",
pluralSeparator: "_",
contextSeparator: "_",
enableSelector: !1,
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: (e) => {
let t = {};
if (typeof e[1] == "object" && (t = e[1]), a(e[1]) && (t.defaultValue = e[1]), a(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
let n = e[3] || e[2];
Object.keys(n).forEach((e) => {
t[e] = n[e];
});
}
return t;
},
interpolation: {
escapeValue: !0,
prefix: "{{",
suffix: "}}",
formatSeparator: ",",
unescapePrefix: "-",
nestingPrefix: "$t(",
nestingSuffix: ")",
nestingOptionsSeparator: ",",
maxReplaces: 1e3,
skipOnVariables: !0
},
cacheInBuiltFormats: !0
}), ue = (e) => (a(e.ns) && (e.ns = [e.ns]), a(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), a(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs && !e.supportedLngs.includes("cimode") && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), e), B = () => {}, de = (e) => {
Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
typeof e[t] == "function" && (e[t] = e[t].bind(e));
});
}, fe = class e extends A {
constructor(e = {}, t) {
if (super(), this.options = ue(e), this.services = {}, this.logger = k, 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 && (a(e.ns) ? e.defaultNS = e.ns : e.ns.includes("translation") || (e.defaultNS = e.ns[0]));
let n = le();
this.options = {
...n,
...this.options,
...ue(e)
}, this.options.interpolation = {
...n.interpolation,
...this.options.interpolation
}, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = n.overloadTranslationOptionHandler);
let r = (e) => e ? typeof e == "function" ? new e() : e : null;
if (!this.options.isClone) {
this.modules.logger ? k.init(r(this.modules.logger), this.options) : k.init(null, this.options);
let e;
e = this.modules.formatter ? this.modules.formatter : z;
let t = new F(this.options);
this.store = new j(this.options.resources, this.options);
let n = this.services;
n.logger = k, n.resourceStore = this.store, n.languageUtils = t, n.pluralResolver = new I(t, { prepend: this.options.pluralSeparator }), e && (n.formatter = r(e), n.formatter.init && n.formatter.init(n, this.options), this.options.interpolation.format = n.formatter.format.bind(n.formatter)), n.interpolator = new ie(this.options), n.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, n.backendConnector = new ce(r(this.modules.backend), n.resourceStore, n, this.options), n.backendConnector.on("*", (e, ...t) => {
this.emit(e, ...t);
}), this.modules.languageDetector && (n.languageDetector = r(this.modules.languageDetector), n.languageDetector.init && n.languageDetector.init(n, this.options.detection, this.options)), this.modules.i18nFormat && (n.i18nFormat = r(this.modules.i18nFormat), n.i18nFormat.init && n.i18nFormat.init(this)), this.translator = new ee(this.services, this.options), this.translator.on("*", (e, ...t) => {
this.emit(e, ...t);
}), this.modules.external.forEach((e) => {
e.init && e.init(this);
});
}
if (this.format = this.options.interpolation.format, t ||= B, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
e.length > 0 && e[0] !== "dev" && (this.options.lng = e[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((e) => {
this[e] = (...t) => this.store[e](...t);
}), [
"addResource",
"addResources",
"addResourceBundle",
"removeResourceBundle"
].forEach((e) => {
this[e] = (...t) => (this.store[e](...t), this);
});
let i = o(), s = () => {
let e = (e, n) => {
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), i.resolve(n), t(e, n);
};
if ((this.languages || this.isLanguageChangingTo) && !this.isInitialized) return e(null, this.t.bind(this));
this.changeLanguage(this.options.lng, e);
};
return this.options.resources || !this.options.initAsync ? s() : setTimeout(s, 0), i;
}
loadResources(e, t = B) {
let n = t, r = a(e) ? e : this.language;
if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
if (r?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
let e = [], t = (t) => {
t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
t !== "cimode" && (e.includes(t) || e.push(t));
});
};
r ? t(r) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
!e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(e);
});
} else n(null);
}
reloadResources(e, t, n) {
let r = o();
return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= B, this.services.backendConnector.reload(e, t, (e) => {
r.resolve(), n(e);
}), r;
}
use(e) {
if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
if (!e.type) throw 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" && M.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"].includes(e)) {
for (let e = 0; e < this.languages.length; e++) {
let t = this.languages[e];
if (!["cimode", "dev"].includes(t) && this.store.hasLanguageSomeTranslations(t)) {
this.resolvedLanguage = t;
break;
}
}
!this.resolvedLanguage && !this.languages.includes(e) && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
}
}
changeLanguage(e, t) {
this.isLanguageChangingTo = e;
let n = o();
this.emit("languageChanging", e);
let r = (e) => {
this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
}, i = (i, a) => {
a ? this.isLanguageChangingTo === e && (r(a), this.translator.changeLanguage(a), this.isLanguageChangingTo = void 0, this.emit("languageChanged", a), this.logger.log("languageChanged", a)) : this.isLanguageChangingTo = void 0, n.resolve((...e) => this.t(...e)), t && t(i, (...e) => this.t(...e));
}, s = (t) => {
!e && !t && this.services.languageDetector && (t = []);
let n = a(t) ? t : t && t[0], o = this.store.hasLanguageSomeTranslations(n) ? n : this.services.languageUtils.getBestMatchFromCodes(a(t) ? [t] : t);
o && (this.language || r(o), this.translator.language || this.translator.changeLanguage(o), this.services.languageDetector?.cacheUserLanguage?.(o)), this.loadResources(o, (e) => {
i(e, o);
});
};
return !e && this.services.languageDetector && !this.services.languageDetector.async ? s(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(s) : this.services.languageDetector.detect(s) : s(e), n;
}
getFixedT(e, t, n, r) {
let o = r?.scopeNs, s = (e, t, ...r) => {
let a;
a = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(r)), a.lng = a.lng || s.lng, a.lngs = a.lngs || s.lngs;
let c = a.ns !== void 0 && a.ns !== null;
a.ns = a.ns || s.ns, a.keyPrefix !== "" && (a.keyPrefix = a.keyPrefix || n || s.keyPrefix);
let l = {
...this.options,
...a
};
Array.isArray(o) && !c && (l.ns = o), typeof a.keyPrefix == "function" && (a.keyPrefix = i(a.keyPrefix, l));
let u = this.options.keySeparator || ".", d;
return a.keyPrefix && Array.isArray(e) ? d = e.map((e) => (typeof e == "function" && (e = i(e, l)), `${a.keyPrefix}${u}${e}`)) : (typeof e == "function" && (e = i(e, l)), d = a.keyPrefix ? `${a.keyPrefix}${u}${e}` : e), this.t(d, a);
};
return a(e) ? s.lng = e : s.lngs = e, s.ns = t, s.keyPrefix = n, 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.isIni