@connectycube/chat-widget
Version:
A React component that seamlessly integrates ConnectyCube's real-time chat capabilities into your web applications. This widget offers an out-of-the-box solution for embedding chat features—such as instant messaging, user presence, and file sharing—withou
1,274 lines • 993 kB
JavaScript
import * as V from "react";
import z, { createContext as au, useContext as iu, useCallback as Kr, useState as xe, useRef as Re, useEffect as ge, useLayoutEffect as Au, useMemo as Ye, forwardRef as lu, createElement as Ta, memo as As } from "react";
import ce from "connectycube";
import * as cu from "react-dom";
import gi from "react-dom";
function ot(e, t) {
for (var r = 0; r < t.length; r++) {
const n = t[r];
if (typeof n != "string" && !Array.isArray(n)) {
for (const o in n)
if (o !== "default" && !(o in e)) {
const s = Object.getOwnPropertyDescriptor(n, o);
s && Object.defineProperty(e, o, s.get ? s : {
enumerable: !0,
get: () => n[o]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
var Os = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function $e(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function bp(e) {
if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
var t = e.default;
if (typeof t == "function") {
var r = function n() {
return this instanceof n ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
};
r.prototype = t.prototype;
} else r = {};
return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
var o = Object.getOwnPropertyDescriptor(e, n);
Object.defineProperty(r, n, o.get ? o : {
enumerable: !0,
get: function() {
return e[n];
}
});
}), r;
}
var Fn = { exports: {} }, tn = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var CA;
function Ip() {
if (CA) return tn;
CA = 1;
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
function r(n, o, s) {
var a = null;
if (s !== void 0 && (a = "" + s), o.key !== void 0 && (a = "" + o.key), "key" in o) {
s = {};
for (var i in o)
i !== "key" && (s[i] = o[i]);
} else s = o;
return o = s.ref, {
$$typeof: e,
type: n,
key: a,
ref: o !== void 0 ? o : null,
props: s
};
}
return tn.Fragment = t, tn.jsx = r, tn.jsxs = r, tn;
}
var rn = {}, EA;
function Cp() {
if (EA) return rn;
EA = 1;
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
return "production".NODE_ENV !== "production" && function() {
function e(E) {
if (E == null) return null;
if (typeof E == "function")
return E.$$typeof === U ? null : E.displayName || E.name || null;
if (typeof E == "string") return E;
switch (E) {
case y:
return "Fragment";
case b:
return "Profiler";
case I:
return "StrictMode";
case u:
return "Suspense";
case C:
return "SuspenseList";
case R:
return "Activity";
}
if (typeof E == "object")
switch (typeof E.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), E.$$typeof) {
case w:
return "Portal";
case m:
return (E.displayName || "Context") + ".Provider";
case h:
return (E._context.displayName || "Context") + ".Consumer";
case f:
var k = E.render;
return E = E.displayName, E || (E = k.displayName || k.name || "", E = E !== "" ? "ForwardRef(" + E + ")" : "ForwardRef"), E;
case x:
return k = E.displayName || null, k !== null ? k : e(E.type) || "Memo";
case B:
k = E._payload, E = E._init;
try {
return e(E(k));
} catch {
}
}
return null;
}
function t(E) {
return "" + E;
}
function r(E) {
try {
t(E);
var k = !1;
} catch {
k = !0;
}
if (k) {
k = console;
var G = k.error, Y = typeof Symbol == "function" && Symbol.toStringTag && E[Symbol.toStringTag] || E.constructor.name || "Object";
return G.call(
k,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
Y
), t(E);
}
}
function n(E) {
if (E === y) return "<>";
if (typeof E == "object" && E !== null && E.$$typeof === B)
return "<...>";
try {
var k = e(E);
return k ? "<" + k + ">" : "<...>";
} catch {
return "<...>";
}
}
function o() {
var E = N.A;
return E === null ? null : E.getOwner();
}
function s() {
return Error("react-stack-top-frame");
}
function a(E) {
if (q.call(E, "key")) {
var k = Object.getOwnPropertyDescriptor(E, "key").get;
if (k && k.isReactWarning) return !1;
}
return E.key !== void 0;
}
function i(E, k) {
function G() {
S || (S = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
k
));
}
G.isReactWarning = !0, Object.defineProperty(E, "key", {
get: G,
configurable: !0
});
}
function l() {
var E = e(this.type);
return O[E] || (O[E] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), E = this.props.ref, E !== void 0 ? E : null;
}
function c(E, k, G, Y, Z, ne, $, te) {
return G = ne.ref, E = {
$$typeof: v,
type: E,
key: k,
props: ne,
_owner: Z
}, (G !== void 0 ? G : null) !== null ? Object.defineProperty(E, "ref", {
enumerable: !1,
get: l
}) : Object.defineProperty(E, "ref", { enumerable: !1, value: null }), E._store = {}, Object.defineProperty(E._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(E, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(E, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: $
}), Object.defineProperty(E, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: te
}), Object.freeze && (Object.freeze(E.props), Object.freeze(E)), E;
}
function d(E, k, G, Y, Z, ne, $, te) {
var D = k.children;
if (D !== void 0)
if (Y)
if (L(D)) {
for (Y = 0; Y < D.length; Y++)
A(D[Y]);
Object.freeze && Object.freeze(D);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else A(D);
if (q.call(k, "key")) {
D = e(E);
var Q = Object.keys(k).filter(function(H) {
return H !== "key";
});
Y = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", T[D + Y] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
Y,
D,
Q,
D
), T[D + Y] = !0);
}
if (D = null, G !== void 0 && (r(G), D = "" + G), a(k) && (r(k.key), D = "" + k.key), "key" in k) {
G = {};
for (var W in k)
W !== "key" && (G[W] = k[W]);
} else G = k;
return D && i(
G,
typeof E == "function" ? E.displayName || E.name || "Unknown" : E
), c(
E,
D,
ne,
Z,
o(),
G,
$,
te
);
}
function A(E) {
typeof E == "object" && E !== null && E.$$typeof === v && E._store && (E._store.validated = 1);
}
var g = z, v = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), I = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), h = Symbol.for("react.consumer"), m = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), u = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), x = Symbol.for("react.memo"), B = Symbol.for("react.lazy"), R = Symbol.for("react.activity"), U = Symbol.for("react.client.reference"), N = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, q = Object.prototype.hasOwnProperty, L = Array.isArray, M = console.createTask ? console.createTask : function() {
return null;
};
g = {
"react-stack-bottom-frame": function(E) {
return E();
}
};
var S, O = {}, X = g["react-stack-bottom-frame"].bind(
g,
s
)(), K = M(n(s)), T = {};
rn.Fragment = y, rn.jsx = function(E, k, G, Y, Z) {
var ne = 1e4 > N.recentlyCreatedOwnerStacks++;
return d(
E,
k,
G,
!1,
Y,
Z,
ne ? Error("react-stack-top-frame") : X,
ne ? M(n(E)) : K
);
}, rn.jsxs = function(E, k, G, Y, Z) {
var ne = 1e4 > N.recentlyCreatedOwnerStacks++;
return d(
E,
k,
G,
!0,
Y,
Z,
ne ? Error("react-stack-top-frame") : X,
ne ? M(n(E)) : K
);
};
}(), rn;
}
var xA;
function Ep() {
return xA || (xA = 1, "production".NODE_ENV === "production" ? Fn.exports = Ip() : Fn.exports = Cp()), Fn.exports;
}
var p = Ep();
const de = (e) => typeof e == "string", nn = () => {
let e, t;
const r = new Promise((n, o) => {
e = n, t = o;
});
return r.resolve = e, r.reject = t, r;
}, VA = (e) => e == null ? "" : "" + e, xp = (e, t, r) => {
e.forEach((n) => {
t[n] && (r[n] = t[n]);
});
}, Vp = /###/g, SA = (e) => e && e.indexOf("###") > -1 ? e.replace(Vp, ".") : e, BA = (e) => !e || de(e), pn = (e, t, r) => {
const n = de(t) ? t.split(".") : t;
let o = 0;
for (; o < n.length - 1; ) {
if (BA(e)) return {};
const s = SA(n[o]);
!e[s] && r && (e[s] = new r()), Object.prototype.hasOwnProperty.call(e, s) ? e = e[s] : e = {}, ++o;
}
return BA(e) ? {} : {
obj: e,
k: SA(n[o])
};
}, PA = (e, t, r) => {
const {
obj: n,
k: o
} = pn(e, t, Object);
if (n !== void 0 || t.length === 1) {
n[o] = r;
return;
}
let s = t[t.length - 1], a = t.slice(0, t.length - 1), i = pn(e, a, Object);
for (; i.obj === void 0 && a.length; )
s = `${a[a.length - 1]}.${s}`, a = a.slice(0, a.length - 1), i = pn(e, a, Object), i != null && i.obj && typeof i.obj[`${i.k}.${s}`] < "u" && (i.obj = void 0);
i.obj[`${i.k}.${s}`] = r;
}, Sp = (e, t, r, n) => {
const {
obj: o,
k: s
} = pn(e, t, Object);
o[s] = o[s] || [], o[s].push(r);
}, wo = (e, t) => {
const {
obj: r,
k: n
} = pn(e, t);
if (r && Object.prototype.hasOwnProperty.call(r, n))
return r[n];
}, Bp = (e, t, r) => {
const n = wo(e, r);
return n !== void 0 ? n : wo(t, r);
}, uu = (e, t, r) => {
for (const n in t)
n !== "__proto__" && n !== "constructor" && (n in e ? de(e[n]) || e[n] instanceof String || de(t[n]) || t[n] instanceof String ? r && (e[n] = t[n]) : uu(e[n], t[n], r) : e[n] = t[n]);
return e;
}, Mr = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var Pp = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/"
};
const Mp = (e) => de(e) ? e.replace(/[&<>"'\/]/g, (t) => Pp[t]) : e;
class Rp {
constructor(t) {
this.capacity = t, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
}
getRegExp(t) {
const r = this.regExpMap.get(t);
if (r !== void 0)
return r;
const n = new RegExp(t);
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(t, n), this.regExpQueue.push(t), n;
}
}
const kp = [" ", ",", "?", "!", ";"], Op = new Rp(20), Dp = (e, t, r) => {
t = t || "", r = r || "";
const n = kp.filter((a) => t.indexOf(a) < 0 && r.indexOf(a) < 0);
if (n.length === 0) return !0;
const o = Op.getRegExp(`(${n.map((a) => a === "?" ? "\\?" : a).join("|")})`);
let s = !o.test(e);
if (!s) {
const a = e.indexOf(r);
a > 0 && !o.test(e.substring(0, a)) && (s = !0);
}
return s;
}, qa = function(e, t) {
let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
if (!e) return;
if (e[t])
return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
const n = t.split(r);
let o = e;
for (let s = 0; s < n.length; ) {
if (!o || typeof o != "object")
return;
let a, i = "";
for (let l = s; l < n.length; ++l)
if (l !== s && (i += r), i += n[l], a = o[i], a !== void 0) {
if (["string", "number", "boolean"].indexOf(typeof a) > -1 && l < n.length - 1)
continue;
s += l - s + 1;
break;
}
o = a;
}
return o;
}, bo = (e) => e == null ? void 0 : e.replace("_", "-"), Tp = {
type: "logger",
log(e) {
this.output("log", e);
},
warn(e) {
this.output("warn", e);
},
error(e) {
this.output("error", e);
},
output(e, t) {
var r, n;
(n = (r = console == null ? void 0 : console[e]) == null ? void 0 : r.apply) == null || n.call(r, console, t);
}
};
class Io {
constructor(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.init(t, r);
}
init(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.prefix = r.prefix || "i18next:", this.logger = t || Tp, this.options = r, this.debug = r.debug;
}
log() {
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
r[n] = arguments[n];
return this.forward(r, "log", "", !0);
}
warn() {
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
r[n] = arguments[n];
return this.forward(r, "warn", "", !0);
}
error() {
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
r[n] = arguments[n];
return this.forward(r, "error", "");
}
deprecate() {
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
r[n] = arguments[n];
return this.forward(r, "warn", "WARNING DEPRECATED: ", !0);
}
forward(t, r, n, o) {
return o && !this.debug ? null : (de(t[0]) && (t[0] = `${n}${this.prefix} ${t[0]}`), this.logger[r](t));
}
create(t) {
return new Io(this.logger, {
prefix: `${this.prefix}:${t}:`,
...this.options
});
}
clone(t) {
return t = t || this.options, t.prefix = t.prefix || this.prefix, new Io(this.logger, t);
}
}
var Mt = new Io();
class ls {
constructor() {
this.observers = {};
}
on(t, r) {
return t.split(" ").forEach((n) => {
this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map());
const o = this.observers[n].get(r) || 0;
this.observers[n].set(r, o + 1);
}), this;
}
off(t, r) {
if (this.observers[t]) {
if (!r) {
delete this.observers[t];
return;
}
this.observers[t].delete(r);
}
}
emit(t) {
for (var r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), o = 1; o < r; o++)
n[o - 1] = arguments[o];
this.observers[t] && Array.from(this.observers[t].entries()).forEach((a) => {
let [i, l] = a;
for (let c = 0; c < l; c++)
i(...n);
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((a) => {
let [i, l] = a;
for (let c = 0; c < l; c++)
i.apply(i, [t, ...n]);
});
}
}
class MA extends ls {
constructor(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
ns: ["translation"],
defaultNS: "translation"
};
super(), this.data = t || {}, this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
}
addNamespaces(t) {
this.options.ns.indexOf(t) < 0 && this.options.ns.push(t);
}
removeNamespaces(t) {
const r = this.options.ns.indexOf(t);
r > -1 && this.options.ns.splice(r, 1);
}
getResource(t, r, n) {
var c, d;
let o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
const s = o.keySeparator !== void 0 ? o.keySeparator : this.options.keySeparator, a = o.ignoreJSONStructure !== void 0 ? o.ignoreJSONStructure : this.options.ignoreJSONStructure;
let i;
t.indexOf(".") > -1 ? i = t.split(".") : (i = [t, r], n && (Array.isArray(n) ? i.push(...n) : de(n) && s ? i.push(...n.split(s)) : i.push(n)));
const l = wo(this.data, i);
return !l && !r && !n && t.indexOf(".") > -1 && (t = i[0], r = i[1], n = i.slice(2).join(".")), l || !a || !de(n) ? l : qa((d = (c = this.data) == null ? void 0 : c[t]) == null ? void 0 : d[r], n, s);
}
addResource(t, r, n, o) {
let s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
silent: !1
};
const a = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator;
let i = [t, r];
n && (i = i.concat(a ? n.split(a) : n)), t.indexOf(".") > -1 && (i = t.split("."), o = r, r = i[1]), this.addNamespaces(r), PA(this.data, i, o), s.silent || this.emit("added", t, r, n, o);
}
addResources(t, r, n) {
let o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
silent: !1
};
for (const s in n)
(de(n[s]) || Array.isArray(n[s])) && this.addResource(t, r, s, n[s], {
silent: !0
});
o.silent || this.emit("added", t, r, n);
}
addResourceBundle(t, r, n, o, s) {
let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
silent: !1,
skipCopy: !1
}, i = [t, r];
t.indexOf(".") > -1 && (i = t.split("."), o = n, n = r, r = i[1]), this.addNamespaces(r);
let l = wo(this.data, i) || {};
a.skipCopy || (n = JSON.parse(JSON.stringify(n))), o ? uu(l, n, s) : l = {
...l,
...n
}, PA(this.data, i, l), a.silent || this.emit("added", t, r, n);
}
removeResourceBundle(t, r) {
this.hasResourceBundle(t, r) && delete this.data[t][r], this.removeNamespaces(r), this.emit("removed", t, r);
}
hasResourceBundle(t, r) {
return this.getResource(t, r) !== void 0;
}
getResourceBundle(t, r) {
return r || (r = this.options.defaultNS), this.getResource(t, r);
}
getDataByLanguage(t) {
return this.data[t];
}
hasLanguageSomeTranslations(t) {
const r = this.getDataByLanguage(t);
return !!(r && Object.keys(r) || []).find((o) => r[o] && Object.keys(r[o]).length > 0);
}
toJSON() {
return this.data;
}
}
var du = {
processors: {},
addPostProcessor(e) {
this.processors[e.name] = e;
},
handle(e, t, r, n, o) {
return e.forEach((s) => {
var a;
t = ((a = this.processors[s]) == null ? void 0 : a.process(t, r, n, o)) ?? t;
}), t;
}
};
const RA = {}, kA = (e) => !de(e) && typeof e != "boolean" && typeof e != "number";
class Co extends ls {
constructor(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
super(), xp(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], t, this), this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = Mt.create("translator");
}
changeLanguage(t) {
t && (this.language = t);
}
exists(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
interpolation: {}
};
if (t == null)
return !1;
const n = this.resolve(t, r);
return (n == null ? void 0 : n.res) !== void 0;
}
extractFromKey(t, r) {
let n = r.nsSeparator !== void 0 ? r.nsSeparator : this.options.nsSeparator;
n === void 0 && (n = ":");
const o = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
let s = r.ns || this.options.defaultNS || [];
const a = n && t.indexOf(n) > -1, i = !this.options.userDefinedKeySeparator && !r.keySeparator && !this.options.userDefinedNsSeparator && !r.nsSeparator && !Dp(t, n, o);
if (a && !i) {
const l = t.match(this.interpolator.nestingRegexp);
if (l && l.length > 0)
return {
key: t,
namespaces: de(s) ? [s] : s
};
const c = t.split(n);
(n !== o || n === o && this.options.ns.indexOf(c[0]) > -1) && (s = c.shift()), t = c.join(o);
}
return {
key: t,
namespaces: de(s) ? [s] : s
};
}
translate(t, r, n) {
if (typeof r != "object" && this.options.overloadTranslationOptionHandler && (r = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (r = {
...r
}), r || (r = {}), t == null) return "";
Array.isArray(t) || (t = [String(t)]);
const o = r.returnDetails !== void 0 ? r.returnDetails : this.options.returnDetails, s = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator, {
key: a,
namespaces: i
} = this.extractFromKey(t[t.length - 1], r), l = i[i.length - 1], c = r.lng || this.language, d = r.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
if ((c == null ? void 0 : c.toLowerCase()) === "cimode") {
if (d) {
const N = r.nsSeparator || this.options.nsSeparator;
return o ? {
res: `${l}${N}${a}`,
usedKey: a,
exactUsedKey: a,
usedLng: c,
usedNS: l,
usedParams: this.getUsedParamsDetails(r)
} : `${l}${N}${a}`;
}
return o ? {
res: a,
usedKey: a,
exactUsedKey: a,
usedLng: c,
usedNS: l,
usedParams: this.getUsedParamsDetails(r)
} : a;
}
const A = this.resolve(t, r);
let g = A == null ? void 0 : A.res;
const v = (A == null ? void 0 : A.usedKey) || a, w = (A == null ? void 0 : A.exactUsedKey) || a, y = ["[object Number]", "[object Function]", "[object RegExp]"], I = r.joinArrays !== void 0 ? r.joinArrays : this.options.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, h = r.count !== void 0 && !de(r.count), m = Co.hasDefaultValue(r), f = h ? this.pluralResolver.getSuffix(c, r.count, r) : "", u = r.ordinal && h ? this.pluralResolver.getSuffix(c, r.count, {
ordinal: !1
}) : "", C = h && !r.ordinal && r.count === 0, x = C && r[`defaultValue${this.options.pluralSeparator}zero`] || r[`defaultValue${f}`] || r[`defaultValue${u}`] || r.defaultValue;
let B = g;
b && !g && m && (B = x);
const R = kA(B), U = Object.prototype.toString.apply(B);
if (b && B && R && y.indexOf(U) < 0 && !(de(I) && Array.isArray(B))) {
if (!r.returnObjects && !this.options.returnObjects) {
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
const N = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(v, B, {
...r,
ns: i
}) : `key '${a} (${this.language})' returned an object instead of string.`;
return o ? (A.res = N, A.usedParams = this.getUsedParamsDetails(r), A) : N;
}
if (s) {
const N = Array.isArray(B), q = N ? [] : {}, L = N ? w : v;
for (const M in B)
if (Object.prototype.hasOwnProperty.call(B, M)) {
const S = `${L}${s}${M}`;
m && !g ? q[M] = this.translate(S, {
...r,
defaultValue: kA(x) ? x[M] : void 0,
joinArrays: !1,
ns: i
}) : q[M] = this.translate(S, {
...r,
joinArrays: !1,
ns: i
}), q[M] === S && (q[M] = B[M]);
}
g = q;
}
} else if (b && de(I) && Array.isArray(g))
g = g.join(I), g && (g = this.extendTranslation(g, t, r, n));
else {
let N = !1, q = !1;
!this.isValidLookup(g) && m && (N = !0, g = x), this.isValidLookup(g) || (q = !0, g = a);
const M = (r.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && q ? void 0 : g, S = m && x !== g && this.options.updateMissing;
if (q || N || S) {
if (this.logger.log(S ? "updateKey" : "missingKey", c, l, a, S ? x : g), s) {
const T = this.resolve(a, {
...r,
keySeparator: !1
});
T && T.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 O = [];
const X = this.languageUtils.getFallbackCodes(this.options.fallbackLng, r.lng || this.language);
if (this.options.saveMissingTo === "fallback" && X && X[0])
for (let T = 0; T < X.length; T++)
O.push(X[T]);
else this.options.saveMissingTo === "all" ? O = this.languageUtils.toResolveHierarchy(r.lng || this.language) : O.push(r.lng || this.language);
const K = (T, E, k) => {
var Y;
const G = m && k !== g ? k : M;
this.options.missingKeyHandler ? this.options.missingKeyHandler(T, l, E, G, S, r) : (Y = this.backendConnector) != null && Y.saveMissing && this.backendConnector.saveMissing(T, l, E, G, S, r), this.emit("missingKey", T, l, E, g);
};
this.options.saveMissing && (this.options.saveMissingPlurals && h ? O.forEach((T) => {
const E = this.pluralResolver.getSuffixes(T, r);
C && r[`defaultValue${this.options.pluralSeparator}zero`] && E.indexOf(`${this.options.pluralSeparator}zero`) < 0 && E.push(`${this.options.pluralSeparator}zero`), E.forEach((k) => {
K([T], a + k, r[`defaultValue${k}`] || x);
});
}) : K(O, a, x));
}
g = this.extendTranslation(g, t, r, A, n), q && g === a && this.options.appendNamespaceToMissingKey && (g = `${l}:${a}`), (q || N) && this.options.parseMissingKeyHandler && (g = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${l}:${a}` : a, N ? g : void 0));
}
return o ? (A.res = g, A.usedParams = this.getUsedParamsDetails(r), A) : g;
}
extendTranslation(t, r, n, o, s) {
var c, d;
var a = this;
if ((c = this.i18nFormat) != null && c.parse)
t = this.i18nFormat.parse(t, {
...this.options.interpolation.defaultVariables,
...n
}, n.lng || this.language || o.usedLng, o.usedNS, o.usedKey, {
resolved: o
});
else if (!n.skipInterpolation) {
n.interpolation && this.interpolator.init({
...n,
interpolation: {
...this.options.interpolation,
...n.interpolation
}
});
const A = de(t) && (((d = n == null ? void 0 : n.interpolation) == null ? void 0 : d.skipOnVariables) !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
let g;
if (A) {
const w = t.match(this.interpolator.nestingRegexp);
g = w && w.length;
}
let v = n.replace && !de(n.replace) ? n.replace : n;
if (this.options.interpolation.defaultVariables && (v = {
...this.options.interpolation.defaultVariables,
...v
}), t = this.interpolator.interpolate(t, v, n.lng || this.language || o.usedLng, n), A) {
const w = t.match(this.interpolator.nestingRegexp), y = w && w.length;
g < y && (n.nest = !1);
}
!n.lng && o && o.res && (n.lng = this.language || o.usedLng), n.nest !== !1 && (t = this.interpolator.nest(t, function() {
for (var w = arguments.length, y = new Array(w), I = 0; I < w; I++)
y[I] = arguments[I];
return (s == null ? void 0 : s[0]) === y[0] && !n.context ? (a.logger.warn(`It seems you are nesting recursively key: ${y[0]} in key: ${r[0]}`), null) : a.translate(...y, r);
}, n)), n.interpolation && this.interpolator.reset();
}
const i = n.postProcess || this.options.postProcess, l = de(i) ? [i] : i;
return t != null && (l != null && l.length) && n.applyPostProcessor !== !1 && (t = du.handle(l, t, r, this.options && this.options.postProcessPassResolved ? {
i18nResolved: {
...o,
usedParams: this.getUsedParamsDetails(n)
},
...n
} : n, this)), t;
}
resolve(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, o, s, a, i;
return de(t) && (t = [t]), t.forEach((l) => {
if (this.isValidLookup(n)) return;
const c = this.extractFromKey(l, r), d = c.key;
o = d;
let A = c.namespaces;
this.options.fallbackNS && (A = A.concat(this.options.fallbackNS));
const g = r.count !== void 0 && !de(r.count), v = g && !r.ordinal && r.count === 0, w = r.context !== void 0 && (de(r.context) || typeof r.context == "number") && r.context !== "", y = r.lngs ? r.lngs : this.languageUtils.toResolveHierarchy(r.lng || this.language, r.fallbackLng);
A.forEach((I) => {
var b, h;
this.isValidLookup(n) || (i = I, !RA[`${y[0]}-${I}`] && ((b = this.utils) != null && b.hasLoadedNamespace) && !((h = this.utils) != null && h.hasLoadedNamespace(i)) && (RA[`${y[0]}-${I}`] = !0, this.logger.warn(`key "${o}" for languages "${y.join(", ")}" won't get resolved as namespace "${i}" 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!!!")), y.forEach((m) => {
var C;
if (this.isValidLookup(n)) return;
a = m;
const f = [d];
if ((C = this.i18nFormat) != null && C.addLookupKeys)
this.i18nFormat.addLookupKeys(f, d, m, I, r);
else {
let x;
g && (x = this.pluralResolver.getSuffix(m, r.count, r));
const B = `${this.options.pluralSeparator}zero`, R = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
if (g && (f.push(d + x), r.ordinal && x.indexOf(R) === 0 && f.push(d + x.replace(R, this.options.pluralSeparator)), v && f.push(d + B)), w) {
const U = `${d}${this.options.contextSeparator}${r.context}`;
f.push(U), g && (f.push(U + x), r.ordinal && x.indexOf(R) === 0 && f.push(U + x.replace(R, this.options.pluralSeparator)), v && f.push(U + B));
}
}
let u;
for (; u = f.pop(); )
this.isValidLookup(n) || (s = u, n = this.getResource(m, I, u, r));
}));
});
}), {
res: n,
usedKey: o,
exactUsedKey: s,
usedLng: a,
usedNS: i
};
}
isValidLookup(t) {
return t !== void 0 && !(!this.options.returnNull && t === null) && !(!this.options.returnEmptyString && t === "");
}
getResource(t, r, n) {
var s;
let o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
return (s = this.i18nFormat) != null && s.getResource ? this.i18nFormat.getResource(t, r, n, o) : this.resourceStore.getResource(t, r, n, o);
}
getUsedParamsDetails() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
const r = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = t.replace && !de(t.replace);
let o = n ? t.replace : t;
if (n && typeof t.count < "u" && (o.count = t.count), this.options.interpolation.defaultVariables && (o = {
...this.options.interpolation.defaultVariables,
...o
}), !n) {
o = {
...o
};
for (const s of r)
delete o[s];
}
return o;
}
static hasDefaultValue(t) {
const r = "defaultValue";
for (const n in t)
if (Object.prototype.hasOwnProperty.call(t, n) && r === n.substring(0, r.length) && t[n] !== void 0)
return !0;
return !1;
}
}
class OA {
constructor(t) {
this.options = t, this.supportedLngs = this.options.supportedLngs || !1, this.logger = Mt.create("languageUtils");
}
getScriptPartFromCode(t) {
if (t = bo(t), !t || t.indexOf("-") < 0) return null;
const r = t.split("-");
return r.length === 2 || (r.pop(), r[r.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(r.join("-"));
}
getLanguagePartFromCode(t) {
if (t = bo(t), !t || t.indexOf("-") < 0) return t;
const r = t.split("-");
return this.formatLanguageCode(r[0]);
}
formatLanguageCode(t) {
if (de(t) && t.indexOf("-") > -1) {
let r;
try {
r = Intl.getCanonicalLocales(t)[0];
} catch {
}
return r && this.options.lowerCaseLng && (r = r.toLowerCase()), r || (this.options.lowerCaseLng ? t.toLowerCase() : t);
}
return this.options.cleanCode || this.options.lowerCaseLng ? t.toLowerCase() : t;
}
isSupportedCode(t) {
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (t = this.getLanguagePartFromCode(t)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(t) > -1;
}
getBestMatchFromCodes(t) {
if (!t) return null;
let r;
return t.forEach((n) => {
if (r) return;
const o = this.formatLanguageCode(n);
(!this.options.supportedLngs || this.isSupportedCode(o)) && (r = o);
}), !r && this.options.supportedLngs && t.forEach((n) => {
if (r) return;
const o = this.getScriptPartFromCode(n);
if (this.isSupportedCode(o)) return r = o;
const s = this.getLanguagePartFromCode(n);
if (this.isSupportedCode(s)) return r = s;
r = this.options.supportedLngs.find((a) => {
if (a === s) return a;
if (!(a.indexOf("-") < 0 && s.indexOf("-") < 0) && (a.indexOf("-") > 0 && s.indexOf("-") < 0 && a.substring(0, a.indexOf("-")) === s || a.indexOf(s) === 0 && s.length > 1))
return a;
});
}), r || (r = this.getFallbackCodes(this.options.fallbackLng)[0]), r;
}
getFallbackCodes(t, r) {
if (!t) return [];
if (typeof t == "function" && (t = t(r)), de(t) && (t = [t]), Array.isArray(t)) return t;
if (!r) return t.default || [];
let n = t[r];
return n || (n = t[this.getScriptPartFromCode(r)]), n || (n = t[this.formatLanguageCode(r)]), n || (n = t[this.getLanguagePartFromCode(r)]), n || (n = t.default), n || [];
}
toResolveHierarchy(t, r) {
const n = this.getFallbackCodes(r || this.options.fallbackLng || [], t), o = [], s = (a) => {
a && (this.isSupportedCode(a) ? o.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
};
return de(t) && (t.indexOf("-") > -1 || t.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && s(this.formatLanguageCode(t)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && s(this.getScriptPartFromCode(t)), this.options.load !== "currentOnly" && s(this.getLanguagePartFromCode(t))) : de(t) && s(this.formatLanguageCode(t)), n.forEach((a) => {
o.indexOf(a) < 0 && s(this.formatLanguageCode(a));
}), o;
}
}
const DA = {
zero: 0,
one: 1,
two: 2,
few: 3,
many: 4,
other: 5
}, TA = {
select: (e) => e === 1 ? "one" : "other",
resolvedOptions: () => ({
pluralCategories: ["one", "other"]
})
};
class qp {
constructor(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.languageUtils = t, this.options = r, this.logger = Mt.create("pluralResolver"), this.pluralRulesCache = {};
}
addRule(t, r) {
this.rules[t] = r;
}
clearCache() {
this.pluralRulesCache = {};
}
getRule(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
const n = bo(t === "dev" ? "en" : t), o = r.ordinal ? "ordinal" : "cardinal", s = JSON.stringify({
cleanedCode: n,
type: o
});
if (s in this.pluralRulesCache)
return this.pluralRulesCache[s];
let a;
try {
a = new Intl.PluralRules(n, {
type: o
});
} catch {
if (!Intl)
return this.logger.error("No Intl support, please use an Intl polyfill!"), TA;
if (!t.match(/-|_/)) return TA;
const l = this.languageUtils.getLanguagePartFromCode(t);
a = this.getRule(l, r);
}
return this.pluralRulesCache[s] = a, a;
}
needsPlural(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(t, r);
return n || (n = this.getRule("dev", r)), (n == null ? void 0 : n.resolvedOptions().pluralCategories.length) > 1;
}
getPluralFormsOfKey(t, r) {
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
return this.getSuffixes(t, n).map((o) => `${r}${o}`);
}
getSuffixes(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(t, r);
return n || (n = this.getRule("dev", r)), n ? n.resolvedOptions().pluralCategories.sort((o, s) => DA[o] - DA[s]).map((o) => `${this.options.prepend}${r.ordinal ? `ordinal${this.options.prepend}` : ""}${o}`) : [];
}
getSuffix(t, r) {
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
const o = this.getRule(t, n);
return o ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${o.select(r)}` : (this.logger.warn(`no plural rule found for: ${t}`), this.getSuffix("dev", r, n));
}
}
const qA = function(e, t, r) {
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", o = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, s = Bp(e, t, r);
return !s && o && de(r) && (s = qa(e, r, n), s === void 0 && (s = qa(t, r, n))), s;
}, Ds = (e) => e.replace(/\$/g, "$$$$");
class Lp {
constructor() {
var r;
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this.logger = Mt.create("interpolator"), this.options = t, this.format = ((r = t == null ? void 0 : t.interpolation) == null ? void 0 : r.format) || ((n) => n), this.init(t);
}
init() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
t.interpolation || (t.interpolation = {
escapeValue: !0
});
const {
escape: r,
escapeValue: n,
useRawValueToEscape: o,
prefix: s,
prefixEscaped: a,
suffix: i,
suffixEscaped: l,
formatSeparator: c,
unescapeSuffix: d,
unescapePrefix: A,
nestingPrefix: g,
nestingPrefixEscaped: v,
nestingSuffix: w,
nestingSuffixEscaped: y,
nestingOptionsSeparator: I,
maxReplaces: b,
alwaysFormat: h
} = t.interpolation;
this.escape = r !== void 0 ? r : Mp, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = o !== void 0 ? o : !1, this.prefix = s ? Mr(s) : a || "{{", this.suffix = i ? Mr(i) : l || "}}", this.formatSeparator = c || ",", this.unescapePrefix = d ? "" : A || "-", this.unescapeSuffix = this.unescapePrefix ? "" : d || "", this.nestingPrefix = g ? Mr(g) : v || Mr("$t("), this.nestingSuffix = w ? Mr(w) : y || Mr(")"), this.nestingOptionsSeparator = I || ",", this.maxReplaces = b || 1e3, this.alwaysFormat = h !== void 0 ? h : !1, this.resetRegExp();
}
reset() {
this.options && this.init(this.options);
}
resetRegExp() {
const t = (r, n) => (r == null ? void 0 : r.source) === n ? (r.lastIndex = 0, r) : new RegExp(n, "g");
this.regexp = t(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = t(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = t(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
}
interpolate(t, r, n, o) {
var v;
let s, a, i;
const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (w) => {
if (w.indexOf(this.formatSeparator) < 0) {
const h = qA(r, l, w, this.options.keySeparator, this.options.ignoreJSONStructure);
return this.alwaysFormat ? this.format(h, void 0, n, {
...o,
...r,
interpolationkey: w
}) : h;
}
const y = w.split(this.formatSeparator), I = y.shift().trim(), b = y.join(this.formatSeparator).trim();
return this.format(qA(r, l, I, this.options.keySeparator, this.options.ignoreJSONStructure), b, n, {
...o,
...r,
interpolationkey: I
});
};
this.resetRegExp();
const d = (o == null ? void 0 : o.missingInterpolationHandler) || this.options.missingInterpolationHandler, A = ((v = o == null ? void 0 : o.interpolation) == null ? void 0 : v.skipOnVariables) !== void 0 ? o.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
return [{
regex: this.regexpUnescape,
safeValue: (w) => Ds(w)
}, {
regex: this.regexp,
safeValue: (w) => this.escapeValue ? Ds(this.escape(w)) : Ds(w)
}].forEach((w) => {
for (i = 0; s = w.regex.exec(t); ) {
const y = s[1].trim();
if (a = c(y), a === void 0)
if (typeof d == "function") {
const b = d(t, s, o);
a = de(b) ? b : "";
} else if (o && Object.prototype.hasOwnProperty.call(o, y))
a = "";
else if (A) {
a = s[0];
continue;
} else
this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`), a = "";
else !de(a) && !this.useRawValueToEscape && (a = VA(a));
const I = w.safeValue(a);
if (t = t.replace(s[0], I), A ? (w.regex.lastIndex += a.length, w.regex.lastIndex -= s[0].length) : w.regex.lastIndex = 0, i++, i >= this.maxReplaces)
break;
}
}), t;
}
nest(t, r) {
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o, s, a;
const i = (l, c) => {
const d = this.nestingOptionsSeparator;
if (l.indexOf(d) < 0) return l;
const A = l.split(new RegExp(`${d}[ ]*{`));
let g = `{${A[1]}`;
l = A[0], g = this.interpolate(g, a);
const v = g.match(/'/g), w = g.match(/"/g);
(((v == null ? void 0 : v.length) ?? 0) % 2 === 0 && !w || w.length % 2 !== 0) && (g = g.replace(/'/g, '"'));
try {
a = JSON.parse(g), c && (a = {
...c,
...a
});
} catch (y) {
return this.logger.warn(`failed parsing options string in nesting for key ${l}`, y), `${l}${d}${g}`;
}
return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, l;
};
for (; o = this.nestingRegexp.exec(t); ) {
let l = [];
a = {
...n
}, a = a.replace && !de(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
let c = !1;
if (o[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(o[1])) {
const d = o[1].split(this.formatSeparator).map((A) => A.trim());
o[1] = d.shift(), l = d, c = !0;
}
if (s = r(i.call(this, o[1].trim(), a), a), s && o[0] === t && !de(s)) return s;
de(s) || (s = VA(s)), s || (this.logger.warn(`missed to resolve ${o[1]} for nesting ${t}`), s = ""), c && (s = l.reduce((d, A) => this.format(d, A, n.lng, {
...n,
interpolationkey: o[1].trim()
}), s.trim())), t = t.replace(o[0], s), this.regexp.lastIndex = 0;
}
return t;
}
}
const Np = (e) => {
let t = e.toLowerCase().trim();
const r = {};
if (e.indexOf("(") > -1) {
const n = e.split("(");
t = n[0].toLowerCase().trim();
const o = n[1].substring(0, n[1].length - 1);
t === "currency" && o.indexOf(":") < 0 ? r.currency || (r.currency = o.trim()) : t === "relativetime" && o.indexOf(":") < 0 ? r.range || (r.range = o.trim()) : o.split(";").forEach((a) => {
if (a) {
const [i, ...l] = a.split(":"), c = l.join(":").trim().replace(/^'+|'+$/g, ""), d = i.trim();
r[d] || (r[d] = c), c === "false" && (r[d] = !1), c === "true" && (r[d] = !0), isNaN(c) || (r[d] = parseInt(c, 10));
}
});
}
return {
formatName: t,
formatOptions: r
};
}, Rr = (e) => {
const t = {};
return (r, n, o) => {
let s = o;
o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey] && (s = {
...s,
[o.interpolationkey]: void 0
});
const a = n + JSON.stringify(s);
let i = t[a];
return i || (i = e(bo(n), o), t[a] = i), i(r);
};
};
class Qp {
constructor() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this.logger = Mt.create("formatter"), this.options = t, this.formats = {
number: Rr((r, n) => {
const o = new Intl.NumberFormat(r, {
...n
});
return (s) => o.format(s);
}),
currency: Rr((r, n) => {
const o = new Intl.NumberFormat(r, {
...n,
style: "currency"
});
return (s) => o.format(s);
}),
datetime: Rr((r, n) => {
const o = new Intl.DateTimeFormat(r, {
...n
});
return (s) => o.format(s);
}),
relativetime: Rr((r, n) => {
const o = new Intl.RelativeTimeFormat(r, {
...n
});
return (s) => o.format(s, n.range || "day");
}),
list: Rr((r, n) => {
const o = new Intl.ListFormat(r, {
...n
});
return (s) => o.format(s);
})
}, this.init(t);
}
init(t) {
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
interpolation: {}
};
this.formatSeparator = r.interpolation.formatSeparator || ",";
}
add(t, r) {
this.formats[t.toLowerCase().trim()] = r;
}
addCached(t, r) {
this.formats[t.toLowerCase().trim()] = Rr(r);
}
format(t, r, n) {
let o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
const s = r.split(this.formatSeparator);
if (s.length > 1 && s[0].indexOf("(") > 1 && s[0].indexOf(")") < 0 && s.find((i) => i.indexOf(")") > -1)) {
const i = s.findIndex((l) => l.indexOf(")") > -1);
s[0] = [s[0], ...s.splice(1, i)].join(this.formatSeparator);
}
return s.reduce((i, l) => {
var A;
const {
formatName: c,
formatOptions: d
} = Np(l);
if (this.formats[c]) {
let g = i;
try {
const v = ((A = o == null ? void 0 : o.formatParams) == null ? void 0 : A[o.interpolationkey]) || {}, w = v.locale || v.lng || o.locale || o.lng || n;
g = this.formats[c](i, w, {
...d,
...o,
...v
});
} catch (v) {
this.logger.warn(v);
}
return g;
} else
this.logger.warn(`there was no format function for ${c}`);
return i;
}, t);
}
}
const Up = (e, t) => {
e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
};
class Kp extends ls {
constructor(t, r, n) {
var s, a;
let o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
super(), this.backend = t, this.store = r, this.services = n, this.languageUtils = n.languageUtils, this.options = o, this.logger = Mt.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = o.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = o.maxRetries >= 0 ? o.maxRetries : 5, this.retryTimeout = o.retryTimeout >= 1 ? o.retryTimeout : 350, this.state = {}, this.queue = [], (a = (s = this.backend) == null ? void 0 : s.init) == null || a.call(s, n, o.backend, o);
}
queueLoad(t, r, n, o) {
const s = {}, a = {}, i = {}, l = {};
return t.forEach((c) => {
let d = !0;
r.forEach((A) => {
const g = `${c}|${A}`;
!n.reload && this.store.hasResourceBundle(c, A) ? this.state[g] = 2 : this.state[g] < 0 || (this.state[g] === 1 ? a[g] === void 0 && (a[g] = !0) : (this.state[g] = 1, d = !1, a[g] === void 0 && (a[g] = !0), s[g] === void 0 && (s[g] = !0), l[A] === void 0 && (l[A] = !0)));
}), d || (i[c] = !0);
}), (Object.keys(s).length || Object.keys(a).length) && this.queue.push({
pending: a,
pendingCount: Object.keys(a).length,
loaded: {},
errors: [],
callback: o
}), {
toLoad: Object.keys(s),
pending: Object.keys(a),
toLoadLanguages: Object.keys(i),
toLoadNamespaces: Object.keys(l)
};
}
loaded(t, r, n) {
const o = t.split("|