UNPKG

@betterstore/react

Version:

1,323 lines 1.35 MB
import * as g from "react"; import i, { createContext as xp, useContext as $p, useCallback as la, useState as Ne, useRef as wr, useEffect as it, forwardRef as Kc, createElement as wo, useMemo as Qn, useLayoutEffect as Cp, memo as ys } from "react"; import { jsx as f, jsxs as K, Fragment as xa } from "react/jsx-runtime"; import * as qc from "react-dom"; import Zc from "react-dom"; const M1 = (t) => { let e; const a = /* @__PURE__ */ new Set(), n = (c, h) => { const u = typeof c == "function" ? c(e) : c; if (!Object.is(u, e)) { const p = e; e = h ?? (typeof u != "object" || u === null) ? u : Object.assign({}, e, u), a.forEach((m) => m(e, p)); } }, r = () => e, s = { setState: n, getState: r, getInitialState: () => d, subscribe: (c) => (a.add(c), () => a.delete(c)) }, d = e = t(n, r, s); return s; }, zp = ((t) => t ? M1(t) : M1), Sp = (t) => t; function Mp(t, e = Sp) { const a = i.useSyncExternalStore( t.subscribe, i.useCallback(() => e(t.getState()), [t, e]), i.useCallback(() => e(t.getInitialState()), [t, e]) ); return i.useDebugValue(a), a; } const k1 = (t) => { const e = zp(t), a = (n) => Mp(e, n); return Object.assign(a, e), a; }, bs = ((t) => t ? k1(t) : k1); function kp(t, e) { let a; try { a = t(); } catch { return; } return { getItem: (r) => { var l; const o = (d) => d === null ? null : JSON.parse(d, void 0), s = (l = a.getItem(r)) != null ? l : null; return s instanceof Promise ? s.then(o) : o(s); }, setItem: (r, l) => a.setItem(r, JSON.stringify(l, void 0)), removeItem: (r) => a.removeItem(r) }; } const Eo = (t) => (e) => { try { const a = t(e); return a instanceof Promise ? a : { then(n) { return Eo(n)(a); }, catch(n) { return this; } }; } catch (a) { return { then(n) { return this; }, catch(n) { return Eo(n)(a); } }; } }, Fp = (t, e) => (a, n, r) => { let l = { storage: kp(() => localStorage), partialize: (v) => v, version: 0, merge: (v, $) => ({ ...$, ...v }), ...e }, o = !1, s = 0; const d = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(); let h = l.storage; if (!h) return t( (...v) => { console.warn( `[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.` ), a(...v); }, n, r ); const u = () => { const v = l.partialize({ ...n() }); return h.setItem(l.name, { state: v, version: l.version }); }, p = r.setState; r.setState = (v, $) => (p(v, $), u()); const m = t( (...v) => (a(...v), u()), n, r ); r.getInitialState = () => m; let b; const y = () => { var v, $; if (!h) return; const C = ++s; o = !1, d.forEach((S) => { var w; return S((w = n()) != null ? w : m); }); const F = (($ = l.onRehydrateStorage) == null ? void 0 : $.call(l, (v = n()) != null ? v : m)) || void 0; return Eo(h.getItem.bind(h))(l.name).then((S) => { if (S) if (typeof S.version == "number" && S.version !== l.version) { if (l.migrate) { const w = l.migrate( S.state, S.version ); return w instanceof Promise ? w.then((M) => [!0, M]) : [!0, w]; } console.error( "State loaded from storage couldn't be migrated since no migrate function was provided" ); } else return [!1, S.state]; return [!1, void 0]; }).then((S) => { var w; if (C !== s) return; const [M, k] = S; if (b = l.merge( k, (w = n()) != null ? w : m ), a(b, !0), M) return u(); }).then(() => { C === s && (F?.(b, void 0), b = n(), o = !0, c.forEach((S) => S(b))); }).catch((S) => { C === s && F?.(void 0, S); }); }; return r.persist = { setOptions: (v) => { l = { ...l, ...v }, v.storage && (h = v.storage); }, clearStorage: () => { h?.removeItem(l.name); }, getOptions: () => l, rehydrate: () => y(), hasHydrated: () => o, onHydrate: (v) => (d.add(v), () => { d.delete(v); }), onFinishHydration: (v) => (c.add(v), () => { c.delete(v); }) }, l.skipHydration || y(), b || m; }, Yc = Fp, Np = (t) => btoa( JSON.stringify({ productId: t.productId, variantOptions: t.variantOptions, metadata: t.metadata }) ), Pp = (t, e) => !e || e.length === 0 ? null : t.find( (a) => a.variantOptions?.every( (n) => e.some( (r) => n.name === r.name && n.value === r.value ) ) ) || null, Ap = (t, e) => { const a = Pp( t.productVariants ?? [], e?.variantOptions ); return { productId: t.id, productData: t, quantity: e?.quantity ?? 1, selectedVariant: a, variantOptions: e?.variantOptions ?? [], metadata: e?.metadata }; }, _p = (t, e) => t.findIndex((a) => a.id === e), Op = (t, e, a) => { const n = [...t]; return n[e] = { ...n[e], quantity: n[e].quantity + a }, n; }, Tp = (t, e) => [...t, e], Ip = () => bs()( Yc( (t, e) => ({ lineItems: [], /** * Adds an item to the cart. If the item already exists (same product, variant, metadata), * it updates the quantity instead of adding a duplicate. */ addItem: (a, n) => t((r) => { const l = Ap(a, n), o = Np(l), s = _p( r.lineItems, o ); if (s !== -1) return { lineItems: Op( r.lineItems, s, l.quantity ) }; const d = { ...l, id: o }; return { lineItems: Tp(r.lineItems, d) }; }), /** * Removes an item from the cart by its ID */ removeItem: (a) => t((n) => ({ lineItems: n.lineItems.filter((r) => r.id !== a) })), /** * Updates the quantity of a specific line item */ updateQuantity: (a, n) => t((r) => ({ lineItems: r.lineItems.map( (l) => l.id === a ? { ...l, quantity: n } : l ) })), /** * Gets the total quantity of a product across all line items (useful for products with multiple variants) */ getProductQuantity: (a) => e().lineItems.filter( (r) => r.productId === a ).reduce((r, l) => r + l.quantity, 0), /** * Clears all items from the cart */ clearCart: () => t({ lineItems: [] }) }), { name: "cart" } ) ), IO = () => Ip()(), be = (t) => typeof t == "string", Bn = () => { let t, e; const a = new Promise((n, r) => { t = n, e = r; }); return a.resolve = t, a.reject = e, a; }, F1 = (t) => t == null ? "" : "" + t, Rp = (t, e, a) => { t.forEach((n) => { e[n] && (a[n] = e[n]); }); }, Dp = /###/g, N1 = (t) => t && t.indexOf("###") > -1 ? t.replace(Dp, ".") : t, P1 = (t) => !t || be(t), Zn = (t, e, a) => { const n = be(e) ? e.split(".") : e; let r = 0; for (; r < n.length - 1; ) { if (P1(t)) return {}; const l = N1(n[r]); !t[l] && a && (t[l] = new a()), Object.prototype.hasOwnProperty.call(t, l) ? t = t[l] : t = {}, ++r; } return P1(t) ? {} : { obj: t, k: N1(n[r]) }; }, A1 = (t, e, a) => { const { obj: n, k: r } = Zn(t, e, Object); if (n !== void 0 || e.length === 1) { n[r] = a; return; } let l = e[e.length - 1], o = e.slice(0, e.length - 1), s = Zn(t, o, Object); for (; s.obj === void 0 && o.length; ) l = `${o[o.length - 1]}.${l}`, o = o.slice(0, o.length - 1), s = Zn(t, o, Object), s?.obj && typeof s.obj[`${s.k}.${l}`] < "u" && (s.obj = void 0); s.obj[`${s.k}.${l}`] = a; }, Lp = (t, e, a, n) => { const { obj: r, k: l } = Zn(t, e, Object); r[l] = r[l] || [], r[l].push(a); }, ni = (t, e) => { const { obj: a, k: n } = Zn(t, e); if (a && Object.prototype.hasOwnProperty.call(a, n)) return a[n]; }, Hp = (t, e, a) => { const n = ni(t, a); return n !== void 0 ? n : ni(e, a); }, Xc = (t, e, a) => { for (const n in e) n !== "__proto__" && n !== "constructor" && (n in t ? be(t[n]) || t[n] instanceof String || be(e[n]) || e[n] instanceof String ? a && (t[n] = e[n]) : Xc(t[n], e[n], a) : t[n] = e[n]); return t; }, Ka = (t) => t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); var Bp = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;", "/": "&#x2F;" }; const Vp = (t) => be(t) ? t.replace(/[&<>"'\/]/g, (e) => Bp[e]) : t; class jp { constructor(e) { this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = []; } getRegExp(e) { const a = this.regExpMap.get(e); if (a !== void 0) return a; const 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; } } const Up = [" ", ",", "?", "!", ";"], Gp = new jp(20), Wp = (t, e, a) => { e = e || "", a = a || ""; const n = Up.filter((o) => e.indexOf(o) < 0 && a.indexOf(o) < 0); if (n.length === 0) return !0; const r = Gp.getRegExp(`(${n.map((o) => o === "?" ? "\\?" : o).join("|")})`); let l = !r.test(t); if (!l) { const o = t.indexOf(a); o > 0 && !r.test(t.substring(0, o)) && (l = !0); } return l; }, xo = function(t, e) { let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "."; if (!t) return; if (t[e]) return Object.prototype.hasOwnProperty.call(t, e) ? t[e] : void 0; const n = e.split(a); let r = t; for (let l = 0; l < n.length; ) { if (!r || typeof r != "object") return; let o, s = ""; for (let d = l; d < n.length; ++d) if (d !== l && (s += a), s += n[d], o = r[s], o !== void 0) { if (["string", "number", "boolean"].indexOf(typeof o) > -1 && d < n.length - 1) continue; l += d - l + 1; break; } r = o; } return r; }, ri = (t) => t?.replace("_", "-"), Kp = { type: "logger", log(t) { this.output("log", t); }, warn(t) { this.output("warn", t); }, error(t) { this.output("error", t); }, output(t, e) { console?.[t]?.apply?.(console, e); } }; class ii { constructor(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; this.init(e, a); } init(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; this.prefix = a.prefix || "i18next:", this.logger = e || Kp, this.options = a, this.debug = a.debug; } log() { for (var e = arguments.length, a = new Array(e), n = 0; n < e; n++) a[n] = arguments[n]; return this.forward(a, "log", "", !0); } warn() { for (var e = arguments.length, a = new Array(e), n = 0; n < e; n++) a[n] = arguments[n]; return this.forward(a, "warn", "", !0); } error() { for (var e = arguments.length, a = new Array(e), n = 0; n < e; n++) a[n] = arguments[n]; return this.forward(a, "error", ""); } deprecate() { for (var e = arguments.length, a = new Array(e), n = 0; n < e; n++) a[n] = arguments[n]; return this.forward(a, "warn", "WARNING DEPRECATED: ", !0); } forward(e, a, n, r) { return r && !this.debug ? null : (be(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[a](e)); } create(e) { return new ii(this.logger, { prefix: `${this.prefix}:${e}:`, ...this.options }); } clone(e) { return e = e || this.options, e.prefix = e.prefix || this.prefix, new ii(this.logger, e); } } var Wt = new ii(); class Hi { constructor() { this.observers = {}; } on(e, a) { return e.split(" ").forEach((n) => { this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map()); const r = this.observers[n].get(a) || 0; this.observers[n].set(a, r + 1); }), this; } off(e, a) { if (this.observers[e]) { if (!a) { delete this.observers[e]; return; } this.observers[e].delete(a); } } emit(e) { for (var a = arguments.length, n = new Array(a > 1 ? a - 1 : 0), r = 1; r < a; r++) n[r - 1] = arguments[r]; this.observers[e] && Array.from(this.observers[e].entries()).forEach((o) => { let [s, d] = o; for (let c = 0; c < d; c++) s(...n); }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((o) => { let [s, d] = o; for (let c = 0; c < d; c++) s.apply(s, [e, ...n]); }); } } class _1 extends Hi { constructor(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { ns: ["translation"], defaultNS: "translation" }; super(), this.data = e || {}, this.options = a, 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 a = this.options.ns.indexOf(e); a > -1 && this.options.ns.splice(a, 1); } getResource(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; const l = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator, o = r.ignoreJSONStructure !== void 0 ? r.ignoreJSONStructure : this.options.ignoreJSONStructure; let s; e.indexOf(".") > -1 ? s = e.split(".") : (s = [e, a], n && (Array.isArray(n) ? s.push(...n) : be(n) && l ? s.push(...n.split(l)) : s.push(n))); const d = ni(this.data, s); return !d && !a && !n && e.indexOf(".") > -1 && (e = s[0], a = s[1], n = s.slice(2).join(".")), d || !o || !be(n) ? d : xo(this.data?.[e]?.[a], n, l); } addResource(e, a, n, r) { let l = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : { silent: !1 }; const o = l.keySeparator !== void 0 ? l.keySeparator : this.options.keySeparator; let s = [e, a]; n && (s = s.concat(o ? n.split(o) : n)), e.indexOf(".") > -1 && (s = e.split("."), r = a, a = s[1]), this.addNamespaces(a), A1(this.data, s, r), l.silent || this.emit("added", e, a, n, r); } addResources(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : { silent: !1 }; for (const l in n) (be(n[l]) || Array.isArray(n[l])) && this.addResource(e, a, l, n[l], { silent: !0 }); r.silent || this.emit("added", e, a, n); } addResourceBundle(e, a, n, r, l) { let o = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : { silent: !1, skipCopy: !1 }, s = [e, a]; e.indexOf(".") > -1 && (s = e.split("."), r = n, n = a, a = s[1]), this.addNamespaces(a); let d = ni(this.data, s) || {}; o.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? Xc(d, n, l) : d = { ...d, ...n }, A1(this.data, s, d), o.silent || this.emit("added", e, a, n); } removeResourceBundle(e, a) { this.hasResourceBundle(e, a) && delete this.data[e][a], this.removeNamespaces(a), this.emit("removed", e, a); } hasResourceBundle(e, a) { return this.getResource(e, a) !== void 0; } getResourceBundle(e, a) { return a || (a = this.options.defaultNS), this.getResource(e, a); } getDataByLanguage(e) { return this.data[e]; } hasLanguageSomeTranslations(e) { const a = this.getDataByLanguage(e); return !!(a && Object.keys(a) || []).find((r) => a[r] && Object.keys(a[r]).length > 0); } toJSON() { return this.data; } } var Jc = { processors: {}, addPostProcessor(t) { this.processors[t.name] = t; }, handle(t, e, a, n, r) { return t.forEach((l) => { e = this.processors[l]?.process(e, a, n, r) ?? e; }), e; } }; const O1 = {}, T1 = (t) => !be(t) && typeof t != "boolean" && typeof t != "number"; class li extends Hi { constructor(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; super(), Rp(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = a, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = Wt.create("translator"); } changeLanguage(e) { e && (this.language = e); } exists(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { interpolation: {} }; return e == null ? !1 : this.resolve(e, a)?.res !== void 0; } extractFromKey(e, a) { let n = a.nsSeparator !== void 0 ? a.nsSeparator : this.options.nsSeparator; n === void 0 && (n = ":"); const r = a.keySeparator !== void 0 ? a.keySeparator : this.options.keySeparator; let l = a.ns || this.options.defaultNS || []; const o = n && e.indexOf(n) > -1, s = !this.options.userDefinedKeySeparator && !a.keySeparator && !this.options.userDefinedNsSeparator && !a.nsSeparator && !Wp(e, n, r); if (o && !s) { const d = e.match(this.interpolator.nestingRegexp); if (d && d.length > 0) return { key: e, namespaces: be(l) ? [l] : l }; const c = e.split(n); (n !== r || n === r && this.options.ns.indexOf(c[0]) > -1) && (l = c.shift()), e = c.join(r); } return { key: e, namespaces: be(l) ? [l] : l }; } translate(e, a, n) { if (typeof a != "object" && this.options.overloadTranslationOptionHandler && (a = this.options.overloadTranslationOptionHandler(arguments)), typeof a == "object" && (a = { ...a }), a || (a = {}), e == null) return ""; Array.isArray(e) || (e = [String(e)]); const r = a.returnDetails !== void 0 ? a.returnDetails : this.options.returnDetails, l = a.keySeparator !== void 0 ? a.keySeparator : this.options.keySeparator, { key: o, namespaces: s } = this.extractFromKey(e[e.length - 1], a), d = s[s.length - 1], c = a.lng || this.language, h = a.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode; if (c?.toLowerCase() === "cimode") { if (h) { const te = a.nsSeparator || this.options.nsSeparator; return r ? { res: `${d}${te}${o}`, usedKey: o, exactUsedKey: o, usedLng: c, usedNS: d, usedParams: this.getUsedParamsDetails(a) } : `${d}${te}${o}`; } return r ? { res: o, usedKey: o, exactUsedKey: o, usedLng: c, usedNS: d, usedParams: this.getUsedParamsDetails(a) } : o; } const u = this.resolve(e, a); let p = u?.res; const m = u?.usedKey || o, b = u?.exactUsedKey || o, y = ["[object Number]", "[object Function]", "[object RegExp]"], v = a.joinArrays !== void 0 ? a.joinArrays : this.options.joinArrays, $ = !this.i18nFormat || this.i18nFormat.handleAsObject, C = a.count !== void 0 && !be(a.count), F = li.hasDefaultValue(a), S = C ? this.pluralResolver.getSuffix(c, a.count, a) : "", w = a.ordinal && C ? this.pluralResolver.getSuffix(c, a.count, { ordinal: !1 }) : "", M = C && !a.ordinal && a.count === 0, k = M && a[`defaultValue${this.options.pluralSeparator}zero`] || a[`defaultValue${S}`] || a[`defaultValue${w}`] || a.defaultValue; let O = p; $ && !p && F && (O = k); const V = T1(O), q = Object.prototype.toString.apply(O); if ($ && O && V && y.indexOf(q) < 0 && !(be(v) && Array.isArray(O))) { if (!a.returnObjects && !this.options.returnObjects) { this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!"); const te = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, O, { ...a, ns: s }) : `key '${o} (${this.language})' returned an object instead of string.`; return r ? (u.res = te, u.usedParams = this.getUsedParamsDetails(a), u) : te; } if (l) { const te = Array.isArray(O), j = te ? [] : {}, G = te ? b : m; for (const W in O) if (Object.prototype.hasOwnProperty.call(O, W)) { const Y = `${G}${l}${W}`; F && !p ? j[W] = this.translate(Y, { ...a, defaultValue: T1(k) ? k[W] : void 0, joinArrays: !1, ns: s }) : j[W] = this.translate(Y, { ...a, joinArrays: !1, ns: s }), j[W] === Y && (j[W] = O[W]); } p = j; } } else if ($ && be(v) && Array.isArray(p)) p = p.join(v), p && (p = this.extendTranslation(p, e, a, n)); else { let te = !1, j = !1; !this.isValidLookup(p) && F && (te = !0, p = k), this.isValidLookup(p) || (j = !0, p = o); const W = (a.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && j ? void 0 : p, Y = F && k !== p && this.options.updateMissing; if (j || te || Y) { if (this.logger.log(Y ? "updateKey" : "missingKey", c, d, o, Y ? k : p), l) { const oe = this.resolve(o, { ...a, keySeparator: !1 }); oe && oe.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 B = []; const D = this.languageUtils.getFallbackCodes(this.options.fallbackLng, a.lng || this.language); if (this.options.saveMissingTo === "fallback" && D && D[0]) for (let oe = 0; oe < D.length; oe++) B.push(D[oe]); else this.options.saveMissingTo === "all" ? B = this.languageUtils.toResolveHierarchy(a.lng || this.language) : B.push(a.lng || this.language); const H = (oe, P, T) => { const A = F && T !== p ? T : W; this.options.missingKeyHandler ? this.options.missingKeyHandler(oe, d, P, A, Y, a) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(oe, d, P, A, Y, a), this.emit("missingKey", oe, d, P, p); }; this.options.saveMissing && (this.options.saveMissingPlurals && C ? B.forEach((oe) => { const P = this.pluralResolver.getSuffixes(oe, a); M && a[`defaultValue${this.options.pluralSeparator}zero`] && P.indexOf(`${this.options.pluralSeparator}zero`) < 0 && P.push(`${this.options.pluralSeparator}zero`), P.forEach((T) => { H([oe], o + T, a[`defaultValue${T}`] || k); }); }) : H(B, o, k)); } p = this.extendTranslation(p, e, a, u, n), j && p === o && this.options.appendNamespaceToMissingKey && (p = `${d}:${o}`), (j || te) && this.options.parseMissingKeyHandler && (p = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${d}:${o}` : o, te ? p : void 0)); } return r ? (u.res = p, u.usedParams = this.getUsedParamsDetails(a), u) : p; } extendTranslation(e, a, n, r, l) { var o = this; 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 } }); const c = be(e) && (n?.interpolation?.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables); let h; if (c) { const p = e.match(this.interpolator.nestingRegexp); h = p && p.length; } let u = n.replace && !be(n.replace) ? n.replace : n; if (this.options.interpolation.defaultVariables && (u = { ...this.options.interpolation.defaultVariables, ...u }), e = this.interpolator.interpolate(e, u, n.lng || this.language || r.usedLng, n), c) { const p = e.match(this.interpolator.nestingRegexp), m = p && p.length; h < m && (n.nest = !1); } !n.lng && r && r.res && (n.lng = this.language || r.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() { for (var p = arguments.length, m = new Array(p), b = 0; b < p; b++) m[b] = arguments[b]; return l?.[0] === m[0] && !n.context ? (o.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${a[0]}`), null) : o.translate(...m, a); }, n)), n.interpolation && this.interpolator.reset(); } const s = n.postProcess || this.options.postProcess, d = be(s) ? [s] : s; return e != null && d?.length && n.applyPostProcessor !== !1 && (e = Jc.handle(d, e, a, this.options && this.options.postProcessPassResolved ? { i18nResolved: { ...r, usedParams: this.getUsedParamsDetails(n) }, ...n } : n, this)), e; } resolve(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, r, l, o, s; return be(e) && (e = [e]), e.forEach((d) => { if (this.isValidLookup(n)) return; const c = this.extractFromKey(d, a), h = c.key; r = h; let u = c.namespaces; this.options.fallbackNS && (u = u.concat(this.options.fallbackNS)); const p = a.count !== void 0 && !be(a.count), m = p && !a.ordinal && a.count === 0, b = a.context !== void 0 && (be(a.context) || typeof a.context == "number") && a.context !== "", y = a.lngs ? a.lngs : this.languageUtils.toResolveHierarchy(a.lng || this.language, a.fallbackLng); u.forEach((v) => { this.isValidLookup(n) || (s = v, !O1[`${y[0]}-${v}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (O1[`${y[0]}-${v}`] = !0, this.logger.warn(`key "${r}" for languages "${y.join(", ")}" won't get resolved as namespace "${s}" 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(($) => { if (this.isValidLookup(n)) return; o = $; const C = [h]; if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(C, h, $, v, a); else { let S; p && (S = this.pluralResolver.getSuffix($, a.count, a)); const w = `${this.options.pluralSeparator}zero`, M = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`; if (p && (C.push(h + S), a.ordinal && S.indexOf(M) === 0 && C.push(h + S.replace(M, this.options.pluralSeparator)), m && C.push(h + w)), b) { const k = `${h}${this.options.contextSeparator}${a.context}`; C.push(k), p && (C.push(k + S), a.ordinal && S.indexOf(M) === 0 && C.push(k + S.replace(M, this.options.pluralSeparator)), m && C.push(k + w)); } } let F; for (; F = C.pop(); ) this.isValidLookup(n) || (l = F, n = this.getResource($, v, F, a)); })); }); }), { res: n, usedKey: r, exactUsedKey: l, usedLng: o, usedNS: s }; } isValidLookup(e) { return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === ""); } getResource(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, a, n, r) : this.resourceStore.getResource(e, a, n, r); } getUsedParamsDetails() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; const a = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && !be(e.replace); let r = n ? e.replace : e; if (n && typeof e.count < "u" && (r.count = e.count), this.options.interpolation.defaultVariables && (r = { ...this.options.interpolation.defaultVariables, ...r }), !n) { r = { ...r }; for (const l of a) delete r[l]; } return r; } static hasDefaultValue(e) { const a = "defaultValue"; for (const n in e) if (Object.prototype.hasOwnProperty.call(e, n) && a === n.substring(0, a.length) && e[n] !== void 0) return !0; return !1; } } class I1 { constructor(e) { this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = Wt.create("languageUtils"); } getScriptPartFromCode(e) { if (e = ri(e), !e || e.indexOf("-") < 0) return null; const a = e.split("-"); return a.length === 2 || (a.pop(), a[a.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(a.join("-")); } getLanguagePartFromCode(e) { if (e = ri(e), !e || e.indexOf("-") < 0) return e; const a = e.split("-"); return this.formatLanguageCode(a[0]); } formatLanguageCode(e) { if (be(e) && e.indexOf("-") > -1) { let a; try { a = Intl.getCanonicalLocales(e)[0]; } catch { } return a && this.options.lowerCaseLng && (a = a.toLowerCase()), a || (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 a; return e.forEach((n) => { if (a) return; const r = this.formatLanguageCode(n); (!this.options.supportedLngs || this.isSupportedCode(r)) && (a = r); }), !a && this.options.supportedLngs && e.forEach((n) => { if (a) return; const r = this.getLanguagePartFromCode(n); if (this.isSupportedCode(r)) return a = r; a = this.options.supportedLngs.find((l) => { if (l === r) return l; if (!(l.indexOf("-") < 0 && r.indexOf("-") < 0) && (l.indexOf("-") > 0 && r.indexOf("-") < 0 && l.substring(0, l.indexOf("-")) === r || l.indexOf(r) === 0 && r.length > 1)) return l; }); }), a || (a = this.getFallbackCodes(this.options.fallbackLng)[0]), a; } getFallbackCodes(e, a) { if (!e) return []; if (typeof e == "function" && (e = e(a)), be(e) && (e = [e]), Array.isArray(e)) return e; if (!a) return e.default || []; let n = e[a]; return n || (n = e[this.getScriptPartFromCode(a)]), n || (n = e[this.formatLanguageCode(a)]), n || (n = e[this.getLanguagePartFromCode(a)]), n || (n = e.default), n || []; } toResolveHierarchy(e, a) { const n = this.getFallbackCodes(a || this.options.fallbackLng || [], e), r = [], l = (o) => { o && (this.isSupportedCode(o) ? r.push(o) : this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`)); }; return be(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && l(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && l(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && l(this.getLanguagePartFromCode(e))) : be(e) && l(this.formatLanguageCode(e)), n.forEach((o) => { r.indexOf(o) < 0 && l(this.formatLanguageCode(o)); }), r; } } const R1 = { zero: 0, one: 1, two: 2, few: 3, many: 4, other: 5 }, D1 = { select: (t) => t === 1 ? "one" : "other", resolvedOptions: () => ({ pluralCategories: ["one", "other"] }) }; class qp { constructor(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; this.languageUtils = e, this.options = a, this.logger = Wt.create("pluralResolver"), this.pluralRulesCache = {}; } addRule(e, a) { this.rules[e] = a; } clearCache() { this.pluralRulesCache = {}; } getRule(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; const n = ri(e === "dev" ? "en" : e), r = a.ordinal ? "ordinal" : "cardinal", l = JSON.stringify({ cleanedCode: n, type: r }); if (l in this.pluralRulesCache) return this.pluralRulesCache[l]; let o; try { o = new Intl.PluralRules(n, { type: r }); } catch { if (!Intl) return this.logger.error("No Intl support, please use an Intl polyfill!"), D1; if (!e.match(/-|_/)) return D1; const d = this.languageUtils.getLanguagePartFromCode(e); o = this.getRule(d, a); } return this.pluralRulesCache[l] = o, o; } needsPlural(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, a); return n || (n = this.getRule("dev", a)), n?.resolvedOptions().pluralCategories.length > 1; } getPluralFormsOfKey(e, a) { let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; return this.getSuffixes(e, n).map((r) => `${a}${r}`); } getSuffixes(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, a); return n || (n = this.getRule("dev", a)), n ? n.resolvedOptions().pluralCategories.sort((r, l) => R1[r] - R1[l]).map((r) => `${this.options.prepend}${a.ordinal ? `ordinal${this.options.prepend}` : ""}${r}`) : []; } getSuffix(e, a) { let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; const r = this.getRule(e, n); return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(a)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", a, n)); } } const L1 = function(t, e, a) { let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, l = Hp(t, e, a); return !l && r && be(a) && (l = xo(t, a, n), l === void 0 && (l = xo(e, a, n))), l; }, El = (t) => t.replace(/\$/g, "$$$$"); class Zp { constructor() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; this.logger = Wt.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((a) => a), this.init(e); } init() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; e.interpolation || (e.interpolation = { escapeValue: !0 }); const { escape: a, escapeValue: n, useRawValueToEscape: r, prefix: l, prefixEscaped: o, suffix: s, suffixEscaped: d, formatSeparator: c, unescapeSuffix: h, unescapePrefix: u, nestingPrefix: p, nestingPrefixEscaped: m, nestingSuffix: b, nestingSuffixEscaped: y, nestingOptionsSeparator: v, maxReplaces: $, alwaysFormat: C } = e.interpolation; this.escape = a !== void 0 ? a : Vp, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = r !== void 0 ? r : !1, this.prefix = l ? Ka(l) : o || "{{", this.suffix = s ? Ka(s) : d || "}}", this.formatSeparator = c || ",", this.unescapePrefix = h ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = p ? Ka(p) : m || Ka("$t("), this.nestingSuffix = b ? Ka(b) : y || Ka(")"), this.nestingOptionsSeparator = v || ",", this.maxReplaces = $ || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp(); } reset() { this.options && this.init(this.options); } resetRegExp() { const e = (a, n) => a?.source === n ? (a.lastIndex = 0, a) : new RegExp(n, "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, a, n, r) { let l, o, s; const d = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (m) => { if (m.indexOf(this.formatSeparator) < 0) { const $ = L1(a, d, m, this.options.keySeparator, this.options.ignoreJSONStructure); return this.alwaysFormat ? this.format($, void 0, n, { ...r, ...a, interpolationkey: m }) : $; } const b = m.split(this.formatSeparator), y = b.shift().trim(), v = b.join(this.formatSeparator).trim(); return this.format(L1(a, d, y, this.options.keySeparator, this.options.ignoreJSONStructure), v, n, { ...r, ...a, interpolationkey: y }); }; this.resetRegExp(); const h = r?.missingInterpolationHandler || this.options.missingInterpolationHandler, u = r?.interpolation?.skipOnVariables !== void 0 ? r.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables; return [{ regex: this.regexpUnescape, safeValue: (m) => El(m) }, { regex: this.regexp, safeValue: (m) => this.escapeValue ? El(this.escape(m)) : El(m) }].forEach((m) => { for (s = 0; l = m.regex.exec(e); ) { const b = l[1].trim(); if (o = c(b), o === void 0) if (typeof h == "function") { const v = h(e, l, r); o = be(v) ? v : ""; } else if (r && Object.prototype.hasOwnProperty.call(r, b)) o = ""; else if (u) { o = l[0]; continue; } else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`), o = ""; else !be(o) && !this.useRawValueToEscape && (o = F1(o)); const y = m.safeValue(o); if (e = e.replace(l[0], y), u ? (m.regex.lastIndex += o.length, m.regex.lastIndex -= l[0].length) : m.regex.lastIndex = 0, s++, s >= this.maxReplaces) break; } }), e; } nest(e, a) { let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r, l, o; const s = (d, c) => { const h = this.nestingOptionsSeparator; if (d.indexOf(h) < 0) return d; const u = d.split(new RegExp(`${h}[ ]*{`)); let p = `{${u[1]}`; d = u[0], p = this.interpolate(p, o); const m = p.match(/'/g), b = p.match(/"/g); ((m?.length ?? 0) % 2 === 0 && !b || b.length % 2 !== 0) && (p = p.replace(/'/g, '"')); try { o = JSON.parse(p), c && (o = { ...c, ...o }); } catch (y) { return this.logger.warn(`failed parsing options string in nesting for key ${d}`, y), `${d}${h}${p}`; } return o.defaultValue && o.defaultValue.indexOf(this.prefix) > -1 && delete o.defaultValue, d; }; for (; r = this.nestingRegexp.exec(e); ) { let d = []; o = { ...n }, o = o.replace && !be(o.replace) ? o.replace : o, o.applyPostProcessor = !1, delete o.defaultValue; let c = !1; if (r[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(r[1])) { const h = r[1].split(this.formatSeparator).map((u) => u.trim()); r[1] = h.shift(), d = h, c = !0; } if (l = a(s.call(this, r[1].trim(), o), o), l && r[0] === e && !be(l)) return l; be(l) || (l = F1(l)), l || (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), l = ""), c && (l = d.reduce((h, u) => this.format(h, u, n.lng, { ...n, interpolationkey: r[1].trim() }), l.trim())), e = e.replace(r[0], l), this.regexp.lastIndex = 0; } return e; } } const Yp = (t) => { let e = t.toLowerCase().trim(); const a = {}; if (t.indexOf("(") > -1) { const n = t.split("("); e = n[0].toLowerCase().trim(); const r = n[1].substring(0, n[1].length - 1); e === "currency" && r.indexOf(":") < 0 ? a.currency || (a.currency = r.trim()) : e === "relativetime" && r.indexOf(":") < 0 ? a.range || (a.range = r.trim()) : r.split(";").forEach((o) => { if (o) { const [s, ...d] = o.split(":"), c = d.join(":").trim().replace(/^'+|'+$/g, ""), h = s.trim(); a[h] || (a[h] = c), c === "false" && (a[h] = !1), c === "true" && (a[h] = !0), isNaN(c) || (a[h] = parseInt(c, 10)); } }); } return { formatName: e, formatOptions: a }; }, qa = (t) => { const e = {}; return (a, n, r) => { let l = r; r && r.interpolationkey && r.formatParams && r.formatParams[r.interpolationkey] && r[r.interpolationkey] && (l = { ...l, [r.interpolationkey]: void 0 }); const o = n + JSON.stringify(l); let s = e[o]; return s || (s = t(ri(n), r), e[o] = s), s(a); }; }; class Xp { constructor() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; this.logger = Wt.create("formatter"), this.options = e, this.formats = { number: qa((a, n) => { const r = new Intl.NumberFormat(a, { ...n }); return (l) => r.format(l); }), currency: qa((a, n) => { const r = new Intl.NumberFormat(a, { ...n, style: "currency" }); return (l) => r.format(l); }), datetime: qa((a, n) => { const r = new Intl.DateTimeFormat(a, { ...n }); return (l) => r.format(l); }), relativetime: qa((a, n) => { const r = new Intl.RelativeTimeFormat(a, { ...n }); return (l) => r.format(l, n.range || "day"); }), list: qa((a, n) => { const r = new Intl.ListFormat(a, { ...n }); return (l) => r.format(l); }) }, this.init(e); } init(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { interpolation: {} }; this.formatSeparator = a.interpolation.formatSeparator || ","; } add(e, a) { this.formats[e.toLowerCase().trim()] = a; } addCached(e, a) { this.formats[e.toLowerCase().trim()] = qa(a); } format(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; const l = a.split(this.formatSeparator); if (l.length > 1 && l[0].indexOf("(") > 1 && l[0].indexOf(")") < 0 && l.find((s) => s.indexOf(")") > -1)) { const s = l.findIndex((d) => d.indexOf(")") > -1); l[0] = [l[0], ...l.splice(1, s)].join(this.formatSeparator); } return l.reduce((s, d) => { const { formatName: c, formatOptions: h } = Yp(d); if (this.formats[c]) { let u = s; try { const p = r?.formatParams?.[r.interpolationkey] || {}, m = p.locale || p.lng || r.locale || r.lng || n; u = this.formats[c](s, m, { ...h, ...r, ...p }); } catch (p) { this.logger.warn(p); } return u; } else this.logger.warn(`there was no format function for ${c}`); return s; }, e); } } const Jp = (t, e) => { t.pending[e] !== void 0 && (delete t.pending[e], t.pendingCount--); }; class Qp extends Hi { constructor(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; super(), this.backend = e, this.store = a, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = Wt.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, a, n, r) { const l = {}, o = {}, s = {}, d = {}; return e.forEach((c) => { let h = !0; a.forEach((u) => { const p = `${c}|${u}`; !n.reload && this.store.hasResourceBundle(c, u) ? this.state[p] = 2 : this.state[p] < 0 || (this.state[p] === 1 ? o[p] === void 0 && (o[p] = !0) : (this.state[p] = 1, h = !1, o[p] === void 0 && (o[p] = !0), l[p] === void 0 && (l[p] = !0), d[u] === void 0 && (d[u] = !0))); }), h || (s[c] = !0); }), (Object.keys(l).length || Object.keys(o).length) && this.queue.push({ pending: o, pendingCount: Object.keys(o).length, loaded: {}, errors: [], callback: r }), { toLoad: Object.keys(l), pending: Object.keys(o), toLoadLanguages: Object.keys(s), toLoadNamespaces: Object.keys(d) }; } loaded(e, a, n) { const r = e.split("|"), l = r[0], o = r[1]; a && this.emit("failedLoading", l, o, a), !a && n && this.store.addResourceBundle(l, o, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = a ? -1 : 2, a && n && (this.state[e] = 0); const s = {}; this.queue.forEach((d) => { Lp(d.loaded, [l], o), Jp(d, e), a && d.errors.push(a), d.pendingCount === 0 && !d.done && (Object.keys(d.loaded).forEach((c) => { s[c] || (s[c] = {}); const h = d.loaded[c]; h.length && h.forEach((u) => { s[c][u] === void 0 && (s[c][u] = !0); }); }), d.done = !0, d.errors.length ? d.callback(d.errors) : d.callback()); }), this.emit("loaded", s), this.queue = this.queue.filter((d) => !d.done); } read(e, a, n) { let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, l = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, o = arguments.length > 5 ? arguments[5] : void 0; if (!e.length) return o(null, {}); if (this.readingCalls >= this.maxParallelReads) { this.waitingReads.push({ lng: e, ns: a, fcName: n, tried: r, wait: l, callback: o }); return; } this.readingCalls++; const s = (c, h) => { if (this.readingCalls--, this.waitingReads.length > 0) { const u = this.waitingReads.shift(); this.read(u.lng, u.ns, u.fcName, u.tried, u.wait, u.callback); } if (c && h && r < this.maxRetries) { setTimeout(() => { this.read.call(this, e, a, n, r + 1, l * 2, o); }, l); return; } o(c, h); }, d = this.backend[n].bind(this.backend); if (d.length === 2) { try { const c = d(e, a); c && typeof c.then == "function" ? c.then((h) => s(null, h)).catch(s) : s(null, c); } catch (c) { s(c); } return; } return d(e, a, s); } prepareLoading(e, a) { let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = arguments.length > 3 ? arguments[3] : void 0; if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), r && r(); be(e) && (e = this.languageUtils.toResolveHierarchy(e)), be(a) && (a = [a]); const l = this.queueLoad(e, a, n, r); if (!l.toLoad.length) return l.pending.length || r(), null; l.toLoad.forEach((o) => { this.loadOne(o); }); } load(e, a, n) { this.prepareLoading(e, a, {}, n); } reload(e, a, n) { this.prepareLoading(e, a, { reload: !0 }, n); } loadOne(e) { let a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ""; const n = e.split("|"), r = n[0], l = n[1]; this.read(r, l, "read", void 0, void 0, (o, s) => { o && this.logger.warn(`${a}loading namespace ${l} for language ${r} failed`, o), !o && s && this.logger.log(`${a}loaded namespace ${l} for language ${r}`, s), this.loaded(e, o, s); }); } saveMissing(e, a, n, r, l) { let o = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, s = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => { }; if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(a)) { this.logger.warn(`did not save key "${n}" as the 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!!!"); return; } if (!(n == null || n === "")) { if (this.backend?.create) { const d = { ...o, isUpdate: l }, c = this.backend.create.bind(this.backend); if (c.length < 6) try { let h; c.length === 5 ? h = c(e, a, n, r, d) : h = c(e, a, n, r), h && typeof h.then == "function" ? h.then((u) => s(null, u)).catch(s) : s(null, h); } catch (h) { s(h); } else c(e, a, n, r, s, d); } !e || !e[0] || this.store.addResource(e[0], a, n, r); } } } const H1 = () => ({ 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: