diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce217ce..8e623cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### 14.1.3 + +- create a isObject helper function [1766](https://github.com/i18next/react-i18next/pull/1766) +- optimize nodesToString [1765](https://github.com/i18next/react-i18next/pull/1765) +- Simplifies hasValidReactChildren [1764](https://github.com/i18next/react-i18next/pull/1764) +- create a isString helper to avoid code duplication [1763](https://github.com/i18next/react-i18next/pull/1763) +- use arrow functions where possible [1762](https://github.com/i18next/react-i18next/pull/1762) +- use the commented out async code [1761](https://github.com/i18next/react-i18next/pull/1761) + ### 14.1.2 - bring back internal interpolationOverride handling for Trans component (if there are childrens), fixes [1754](https://github.com/i18next/react-i18next/issues/1754) diff --git a/react-i18next.js b/react-i18next.js index cd14f72f..f3c46d20 100644 --- a/react-i18next.js +++ b/react-i18next.js @@ -123,7 +123,7 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`; + if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`; console.warn(...args); } } @@ -132,8 +132,8 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } - if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return; - if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date(); + if (isString(args[0]) && alreadyWarned[args[0]]) return; + if (isString(args[0])) alreadyWarned[args[0]] = new Date(); warn(...args); } const loadedClb = (i18n, cb) => () => { @@ -149,17 +149,17 @@ i18n.on('initialized', initialized); } }; - function loadNamespaces(i18n, ns, cb) { + const loadNamespaces = (i18n, ns, cb) => { i18n.loadNamespaces(ns, loadedClb(i18n, cb)); - } - function loadLanguages(i18n, lng, ns, cb) { - if (typeof ns === 'string') ns = [ns]; + }; + const loadLanguages = (i18n, lng, ns, cb) => { + if (isString(ns)) ns = [ns]; ns.forEach(n => { if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n); }); i18n.loadLanguages(lng, loadedClb(i18n, cb)); - } - function oldI18nextHasLoadedNamespace(ns, i18n) { + }; + const oldI18nextHasLoadedNamespace = function (ns, i18n) { let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; const lng = i18n.languages[0]; const fallbackLng = i18n.options ? i18n.options.fallbackLng : false; @@ -174,8 +174,8 @@ if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true; if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true; return false; - } - function hasLoadedNamespace(ns, i18n) { + }; + const hasLoadedNamespace = function (ns, i18n) { let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; if (!i18n.languages || !i18n.languages.length) { warnOnce('i18n.languages were undefined or empty', i18n.languages); @@ -191,10 +191,10 @@ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false; } }); - } - function getDisplayName(Component) { - return Component.displayName || Component.name || (typeof Component === 'string' && Component.length > 0 ? Component : 'Unknown'); - } + }; + const getDisplayName = Component => Component.displayName || Component.name || (isString(Component) && Component.length > 0 ? Component : 'Unknown'); + const isString = obj => typeof obj === 'string'; + const isObject = obj => typeof obj === 'object' && obj !== null; const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g; const htmlEntities = { @@ -232,77 +232,70 @@ useSuspense: true, unescape }; - function setDefaults() { + const setDefaults = function () { let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; defaultOptions = { ...defaultOptions, ...options }; - } - function getDefaults() { - return defaultOptions; - } + }; + const getDefaults = () => defaultOptions; let i18nInstance; - function setI18n(instance) { + const setI18n = instance => { i18nInstance = instance; - } - function getI18n() { - return i18nInstance; - } + }; + const getI18n = () => i18nInstance; - function hasChildren(node, checkLength) { + const hasChildren = (node, checkLength) => { if (!node) return false; const base = node.props ? node.props.children : node.children; if (checkLength) return base.length > 0; return !!base; - } - function getChildren(node) { + }; + const getChildren = node => { if (!node) return []; const children = node.props ? node.props.children : node.children; return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children; - } - function hasValidReactChildren(children) { - if (Object.prototype.toString.call(children) !== '[object Array]') return false; - return children.every(child => react.isValidElement(child)); - } - function getAsArray(data) { - return Array.isArray(data) ? data : [data]; - } - function mergeProps(source, target) { + }; + const hasValidReactChildren = children => Array.isArray(children) && children.every(react.isValidElement); + const getAsArray = data => Array.isArray(data) ? data : [data]; + const mergeProps = (source, target) => { const newTarget = { ...target }; newTarget.props = Object.assign(source.props, target.props); return newTarget; - } - function nodesToString(children, i18nOptions) { + }; + const nodesToString = (children, i18nOptions) => { if (!children) return ''; let stringNode = ''; const childrenArray = getAsArray(children); const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : []; childrenArray.forEach((child, childIndex) => { - if (typeof child === 'string') { + if (isString(child)) { stringNode += `${child}`; } else if (react.isValidElement(child)) { - const childPropsCount = Object.keys(child.props).length; - const shouldKeepChild = keepArray.indexOf(child.type) > -1; - const childChildren = child.props.children; - if (!childChildren && shouldKeepChild && childPropsCount === 0) { - stringNode += `<${child.type}/>`; - } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) { - stringNode += `<${childIndex}>`; - } else if (child.props.i18nIsDynamicList) { + const { + props, + type + } = child; + const childPropsCount = Object.keys(props).length; + const shouldKeepChild = keepArray.indexOf(type) > -1; + const childChildren = props.children; + if (!childChildren && shouldKeepChild && !childPropsCount) { + stringNode += `<${type}/>`; + } else if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) { stringNode += `<${childIndex}>`; - } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') { - stringNode += `<${child.type}>${childChildren}`; + } else if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) { + stringNode += `<${type}>${childChildren}`; } else { const content = nodesToString(childChildren, i18nOptions); stringNode += `<${childIndex}>${content}`; } } else if (child === null) { warn(`Trans: the passed in value is invalid - seems you passed in a null child.`); - } else if (typeof child === 'object') { + } else if (isObject(child)) { const { format, ...clone @@ -319,32 +312,32 @@ } }); return stringNode; - } - function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) { + }; + const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => { if (targetString === '') return []; const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || []; const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map(keep => `<${keep}`).join('|')).test(targetString); if (!children && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString]; const data = {}; - function getData(childs) { + const getData = childs => { const childrenArray = getAsArray(childs); childrenArray.forEach(child => { - if (typeof child === 'string') return; - if (hasChildren(child)) getData(getChildren(child));else if (typeof child === 'object' && !react.isValidElement(child)) Object.assign(data, child); + if (isString(child)) return; + if (hasChildren(child)) getData(getChildren(child));else if (isObject(child) && !react.isValidElement(child)) Object.assign(data, child); }); - } + }; getData(children); const ast = c.parse(`<0>${targetString}`); const opts = { ...data, ...combinedTOpts }; - function renderInner(child, node, rootReactNode) { + const renderInner = (child, node, rootReactNode) => { const childs = getChildren(child); const mappedChildren = mapAST(childs, node.children, rootReactNode); return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren; - } - function pushTranslatedJSX(child, inner, mem, i, isVoid) { + }; + const pushTranslatedJSX = (child, inner, mem, i, isVoid) => { if (child.dummy) { child.children = inner; mem.push(react.cloneElement(child, { @@ -363,8 +356,8 @@ }, isVoid ? null : inner); })); } - } - function mapAST(reactNode, astNode, rootReactNode) { + }; + const mapAST = (reactNode, astNode, rootReactNode) => { const reactNodes = getAsArray(reactNode); const astNodes = getAsArray(astNode); return astNodes.reduce((mem, node, i) => { @@ -378,9 +371,9 @@ }, tmp) : tmp; const isElement = react.isValidElement(child); const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement; - const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && typeof child === 'object' && child.dummy && !isElement; - const isKnownComponent = typeof children === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name); - if (typeof child === 'string') { + const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && isObject(child) && child.dummy && !isElement; + const isKnownComponent = isObject(children) && Object.hasOwnProperty.call(children, node.name); + if (isString(child)) { const value = i18n.services.interpolator.interpolate(child, opts, i18n.language); mem.push(value); } else if (hasChildren(child) || isValidTranslationWithChildren) { @@ -410,7 +403,7 @@ const inner = mapAST(reactNodes, node.children, rootReactNode); mem.push(`<${node.name}>${inner}`); } - } else if (typeof child === 'object' && !isElement) { + } else if (isObject(child) && !isElement) { const content = node.children[0] ? translationContent : null; if (content) mem.push(content); } else { @@ -429,13 +422,13 @@ } return mem; }, []); - } + }; const result = mapAST([{ dummy: true, children: children || [] }], ast, getAsArray(children || [])); return getChildren(result[0]); - } + }; function Trans$1(_ref) { let { children, @@ -464,7 +457,7 @@ ...(i18n.options && i18n.options.react) }; let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS; - namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; + namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation']; const nodeAsString = nodesToString(children, reactI18nextOptions); const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey; const { @@ -529,26 +522,17 @@ if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true; }); } - getUsedNamespaces() { - return Object.keys(this.usedNamespaces); - } - } - function composeInitialProps(ForComponent) { - return ctx => new Promise(resolve => { - const i18nInitialProps = getInitialProps(); - if (ForComponent.getInitialProps) { - ForComponent.getInitialProps(ctx).then(componentsInitialProps => { - resolve({ - ...componentsInitialProps, - ...i18nInitialProps - }); - }); - } else { - resolve(i18nInitialProps); - } - }); - } - function getInitialProps() { + getUsedNamespaces = () => Object.keys(this.usedNamespaces); + } + const composeInitialProps = ForComponent => async ctx => { + const componentsInitialProps = ForComponent.getInitialProps ? await ForComponent.getInitialProps(ctx) : {}; + const i18nInitialProps = getInitialProps(); + return { + ...componentsInitialProps, + ...i18nInitialProps + }; + }; + const getInitialProps = () => { const i18n = getI18n(); const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : []; const ret = {}; @@ -562,7 +546,7 @@ ret.initialI18nStore = initialI18nStore; ret.initialLanguage = i18n.language; return ret; - } + }; function Trans(_ref) { let { @@ -612,13 +596,9 @@ }, [value, ignore]); return ref.current; }; - function alwaysNewT(i18n, language, namespace, keyPrefix) { - return i18n.getFixedT(language, namespace, keyPrefix); - } - function useMemoizedT(i18n, language, namespace, keyPrefix) { - return react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]); - } - function useTranslation(ns) { + const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix); + const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]); + const useTranslation = function (ns) { let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const { i18n: i18nFromProps @@ -632,8 +612,8 @@ if (!i18n) { warnOnce('You will need to pass in an i18next instance by using initReactI18next'); const notReadyT = (k, optsOrDefaultValue) => { - if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue; - if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue; + if (isString(optsOrDefaultValue)) return optsOrDefaultValue; + if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue; return Array.isArray(k) ? k[k.length - 1] : k; }; const retNotReady = [notReadyT, {}, false]; @@ -653,7 +633,7 @@ keyPrefix } = i18nOptions; let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS; - namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; + namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation']; if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions)); const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix); @@ -684,9 +664,9 @@ if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) { setT(getNewT); } - function boundReset() { + const boundReset = () => { if (isMounted.current) setT(getNewT); - } + }; if (bindI18n && i18n) i18n.on(bindI18n, boundReset); if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset); return () => { @@ -713,9 +693,9 @@ loadNamespaces(i18n, namespaces, () => resolve()); } }); - } + }; - function withTranslation(ns) { + const withTranslation = function (ns) { let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return function Extend(WrappedComponent) { function I18nextWithTranslation(_ref) { @@ -747,7 +727,7 @@ })); return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation; }; - } + }; function Translation(props) { const { @@ -777,7 +757,7 @@ }, children); } - function useSSR(initialI18nStore, initialLanguage) { + const useSSR = function (initialI18nStore, initialLanguage) { let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; const { i18n: i18nFromProps @@ -802,27 +782,25 @@ i18n.changeLanguage(initialLanguage); i18n.initializedLanguageOnce = true; } - } + }; - function withSSR() { - return function Extend(WrappedComponent) { - function I18nextWithSSR(_ref) { - let { - initialI18nStore, - initialLanguage, - ...rest - } = _ref; - useSSR(initialI18nStore, initialLanguage); - return react.createElement(WrappedComponent, { - ...rest - }); - } - I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent); - I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`; - I18nextWithSSR.WrappedComponent = WrappedComponent; - return I18nextWithSSR; - }; - } + const withSSR = () => function Extend(WrappedComponent) { + function I18nextWithSSR(_ref) { + let { + initialI18nStore, + initialLanguage, + ...rest + } = _ref; + useSSR(initialI18nStore, initialLanguage); + return react.createElement(WrappedComponent, { + ...rest + }); + } + I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent); + I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`; + I18nextWithSSR.WrappedComponent = WrappedComponent; + return I18nextWithSSR; + }; const date = () => ''; const time = () => ''; diff --git a/react-i18next.min.js b/react-i18next.min.js index 0d0731a8..03a7699d 100644 --- a/react-i18next.min.js +++ b/react-i18next.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),s=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function o(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(i[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var o=e.indexOf("--\x3e");return{type:"comment",comment:-1!==o?e.slice(4,o):""}}for(var r=new RegExp(s),a=null;null!==(a=r.exec(e));)if(a[0].trim())if(a[1]){var c=a[1].trim(),l=[c,""];c.indexOf("=")>-1&&(l=c.split("=")),n.attrs[l[0]]=l[1],r.lastIndex--}else a[2]&&(n.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,a=/^\s*$/,c=Object.create(null);function l(e,n){switch(n.type){case"text":return e+n.content;case"tag":return e+="<"+n.name+(n.attrs?function(e){var n=[];for(var t in e)n.push(t+'="'+e[t]+'"');return n.length?" "+n.join(" "):""}(n.attrs):"")+(n.voidElement?"/>":">"),n.voidElement?e:e+n.children.reduce(l,"")+"";case"comment":return e+"\x3c!--"+n.comment+"--\x3e"}}var u={parse:function(e,n){n||(n={}),n.components||(n.components=c);var t,i=[],s=[],l=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");i.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(r,(function(r,c){if(u){if(r!=="")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),g=c+r.length,h=e.charAt(g);if(f){var m=o(r);return l<0?(i.push(m),i):((p=s[l]).children.push(m),i)}if(d&&(l++,"tag"===(t=o(r)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!h||"<"===h||t.children.push({type:"text",content:e.slice(g,e.indexOf("<",g))}),0===l&&i.push(t),(p=s[l-1])&&p.children.push(t),s[l]=t),(!d||t.voidElement)&&(l>-1&&(t.voidElement||t.name===r.slice(2,-1))&&(l--,t=-1===l?i:s[l]),!u&&"<"!==h&&h)){p=-1===l?i:s[l].children;var y=e.indexOf("<",g),b=e.slice(g,-1===y?void 0:y);a.test(b)&&(b=" "),(y>-1&&l+p.length>=0||" "!==b)&&p.push({type:"text",content:b})}})),i},stringify:function(e){return e.reduce((function(e,n){return e+l("",n)}),"")}};function p(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}};function h(e,n,t){e.loadNamespaces(n,g(e,t))}function m(e,n,t,i){"string"==typeof t&&(t=[t]),t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,g(e,i))}function y(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}const b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,v={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},x=e=>v[e];let E,N={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,x)};function O(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N={...N,...e}}function $(){return N}function w(e){E=e}function k(){return E}function I(e,n){if(!e)return!1;const t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function S(e){if(!e)return[];const n=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?j(n):n}function j(e){return Array.isArray(e)?e:[e]}function C(e,t){if(!e)return"";let i="";const s=j(e),o=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return s.forEach(((e,s)=>{if("string"==typeof e)i+=`${e}`;else if(n.isValidElement(e)){const n=Object.keys(e.props).length,r=o.indexOf(e.type)>-1,a=e.props.children;if(!a&&r&&0===n)i+=`<${e.type}/>`;else if(a||r&&0===n)if(e.props.i18nIsDynamicList)i+=`<${s}>`;else if(r&&1===n&&"string"==typeof a)i+=`<${e.type}>${a}`;else{const e=C(a,t);i+=`<${s}>${e}`}else i+=`<${s}>`}else if(null===e)p("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"==typeof e){const{format:n,...t}=e,s=Object.keys(t);if(1===s.length){const e=n?`${s[0]}, ${n}`:s[0];i+=`{{${e}}}`}else p("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else p("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)})),i}function R(e,t,i,s,o,r){if(""===t)return[];const a=s.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(a.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!c&&!r)return[t];const l={};!function e(t){j(t).forEach((t=>{"string"!=typeof t&&(I(t)?e(S(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))}))}(e);const p=u.parse(`<0>${t}`),d={...l,...o};function f(e,t,i){const s=S(e),o=h(s,t.children,i);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((e=>n.isValidElement(e)))}(s)&&0===o.length||e.props&&e.props.i18nIsDynamicList?s:o}function g(e,t,i,s,o){e.dummy?(e.children=t,i.push(n.cloneElement(e,{key:s},o?void 0:t))):i.push(...n.Children.map([e],(e=>{const i={...e.props};return delete i.i18nIsDynamicList,n.createElement(e.type,{...i,key:s,ref:e.ref},o?null:t)})))}function h(t,o,l){const u=j(t);return j(o).reduce(((t,o,p)=>{const m=o.children&&o.children[0]&&o.children[0].content&&i.services.interpolator.interpolate(o.children[0].content,d,i.language);if("tag"===o.type){let r=u[parseInt(o.name,10)];1!==l.length||r||(r=l[0][o.name]),r||(r={});const y=0!==Object.keys(o.attrs).length?function(e,n){const t={...n};return t.props=Object.assign(e.props,n.props),t}({props:o.attrs},r):r,b=n.isValidElement(y),v=b&&I(o,!0)&&!o.voidElement,x=c&&"object"==typeof y&&y.dummy&&!b,E="object"==typeof e&&null!==e&&Object.hasOwnProperty.call(e,o.name);if("string"==typeof y){const e=i.services.interpolator.interpolate(y,d,i.language);t.push(e)}else if(I(y)||v){g(y,f(y,o,l),t,p)}else if(x){g(y,h(u,o.children,l),t,p)}else if(Number.isNaN(parseFloat(o.name)))if(E){g(y,f(y,o,l),t,p,o.voidElement)}else if(s.transSupportBasicHtmlNodes&&a.indexOf(o.name)>-1)if(o.voidElement)t.push(n.createElement(o.name,{key:`${o.name}-${p}`}));else{const e=h(u,o.children,l);t.push(n.createElement(o.name,{key:`${o.name}-${p}`},e))}else if(o.voidElement)t.push(`<${o.name} />`);else{const e=h(u,o.children,l);t.push(`<${o.name}>${e}`)}else if("object"!=typeof y||b)g(y,m,t,p,1!==o.children.length||!m);else{const e=o.children[0]?m:null;e&&t.push(e)}}else if("text"===o.type){const e=s.transWrapTextNodes,a=r?s.unescape(i.services.interpolator.interpolate(o.content,d,i.language)):i.services.interpolator.interpolate(o.content,d,i.language);e?t.push(n.createElement(e,{key:`${o.name}-${p}`},a)):t.push(a)}return t}),[])}return S(h([{dummy:!0,children:e||[]}],p,j(e||[]))[0])}function T(e){let{children:t,count:i,parent:s,i18nKey:o,context:r,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:g,shouldUnescape:h,...m}=e;const y=d||k();if(!y)return f("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=g||y.t.bind(y)||(e=>e),v={...$(),...y.options&&y.options.react};let x=p||b.ns||y.options&&y.options.defaultNS;x="string"==typeof x?[x]:x||["translation"];const E=C(t,v),N=l||E||v.transEmptyNodeValue||o,{hashTransKey:O}=v,w=o||(O?O(E||N):E||N);y.options&&y.options.interpolation&&y.options.interpolation.defaultVariables&&(c=c&&Object.keys(c).length>0?{...c,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables});const I=c||void 0!==i||!t?a.interpolation:{interpolation:{...a.interpolation,prefix:"#$?",suffix:"?$#"}},S={...a,context:r||a.context,count:i,...c,...I,defaultValue:N,ns:x},j=w?b(w,S):N;u&&Object.keys(u).forEach((e=>{const t=u[e];"function"==typeof t.type||!t.props||!t.props.children||j.indexOf(`${e}/>`)<0&&j.indexOf(`${e} />`)<0||(u[e]=n.createElement((function(){return n.createElement(n.Fragment,null,t)})))}));const T=R(u||t,j,y,v,S,h),L=void 0!==s?s:v.defaultTransParent;return L?n.createElement(L,m,T):T}const L={type:"3rdParty",init(e){O(e.options.react),w(e)}},P=n.createContext();class V{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function z(e){return n=>new Promise((t=>{const i=A();e.getInitialProps?e.getInitialProps(n).then((e=>{t({...e,...i})})):t(i)}))}function A(){const e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},i={};return e.languages.forEach((t=>{i[t]={},n.forEach((n=>{i[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=i,t.initialLanguage=e.language,t}const B=(e,t)=>{const i=n.useRef();return n.useEffect((()=>{i.current=t?i.current:e}),[e,t]),i.current};function F(e,n,t,i){return e.getFixedT(n,t,i)}function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:i}=t,{i18n:s,defaultNS:o}=n.useContext(P)||{},r=i||s||k();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new V),!r){f("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>"string"==typeof n?n:n&&"object"==typeof n&&"string"==typeof n.defaultValue?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}r.options.react&&void 0!==r.options.react.wait&&f("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...$(),...r.options.react,...t},{useSuspense:c,keyPrefix:l}=a;let u=e||o||r.options&&r.options.defaultNS;u="string"==typeof u?[u]:u||["translation"],r.reportNamespaces.addUsedNamespaces&&r.reportNamespaces.addUsedNamespaces(u);const p=(r.isInitialized||r.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?void 0!==n.options.ignoreJSONStructure?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,i)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!i(n.isLanguageChangingTo,e))return!1}}):function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=n.languages[0],s=!!n.options&&n.options.fallbackLng,o=n.languages[n.languages.length-1];if("cimode"===i.toLowerCase())return!0;const r=(e,t)=>{const i=n.services.backendConnector.state[`${e}|${t}`];return-1===i||2===i};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e)||!n.hasResourceBundle(i,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!r(i,e)||s&&!r(o,e)))}(e,n,t):(f("i18n.languages were undefined or empty",n.languages),!0)}(e,r,a))),d=function(e,t,i,s){return n.useCallback(F(e,t,i,s),[e,t,i,s])}(r,t.lng||null,"fallback"===a.nsMode?u:u[0],l),g=()=>d,y=()=>F(r,t.lng||null,"fallback"===a.nsMode?u:u[0],l),[b,v]=n.useState(g);let x=u.join();t.lng&&(x=`${t.lng}${x}`);const E=B(x),N=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=a;function i(){N.current&&v(y)}return N.current=!0,p||c||(t.lng?m(r,t.lng,u,(()=>{N.current&&v(y)})):h(r,u,(()=>{N.current&&v(y)}))),p&&E&&E!==x&&N.current&&v(y),e&&r&&r.on(e,i),n&&r&&r.store.on(n,i),()=>{N.current=!1,e&&r&&e.split(" ").forEach((e=>r.off(e,i))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,i)))}}),[r,x]),n.useEffect((()=>{N.current&&p&&v(g)}),[r,l,p]);const O=[b,r,p];if(O.t=b,O.i18n=r,O.ready=p,p)return O;if(!p&&!c)return O;throw new Promise((e=>{t.lng?m(r,t.lng,u,(()=>e())):h(r,u,(()=>e()))}))}function K(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:s}=i,{i18n:o}=n.useContext(P)||{},r=s||o||k();r.options&&r.options.isClone||(e&&!r.initializedStoreOnce&&(r.services.resourceStore.data=e,r.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),r.options.ns),r.initializedStoreOnce=!0,r.isInitialized=!0),t&&!r.initializedLanguageOnce&&(r.changeLanguage(t),r.initializedLanguageOnce=!0))}e.I18nContext=P,e.I18nextProvider=function(e){let{i18n:t,defaultNS:i,children:s}=e;const o=n.useMemo((()=>({i18n:t,defaultNS:i})),[t,i]);return n.createElement(P.Provider,{value:o},s)},e.Trans=function(e){let{children:t,count:i,parent:s,i18nKey:o,context:r,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(P)||{},b=d||m||k(),v=f||b&&b.t.bind(b);return T({children:t,count:i,parent:s,i18nKey:o,context:r,tOptions:a,values:c,defaults:l,components:u,ns:p||v&&v.ns||y||b&&b.options&&b.options.defaultNS,i18n:b,t:f,shouldUnescape:g,...h})},e.TransWithoutContext=T,e.Translation=function(e){const{ns:n,children:t,...i}=e,[s,o,r]=U(n,i);return t(s,{i18n:o,lng:o.language},r)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=k,e.getInitialProps=A,e.initReactI18next=L,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=K,e.useTranslation=U,e.withSSR=function(){return function(e){function t(t){let{initialI18nStore:i,initialLanguage:s,...o}=t;return K(i,s),n.createElement(e,{...o})}return t.getInitialProps=z(e),t.displayName=`withI18nextSSR(${y(e)})`,t.WrappedComponent=e,t}},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){function s(s){let{forwardedRef:o,...r}=s;const[a,c,l]=U(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:a,i18n:c,tReady:l};return t.withRef&&o?u.ref=o:!t.withRef&&o&&(u.forwardedRef=o),n.createElement(i,u)}s.displayName=`withI18nextTranslation(${y(i)})`,s.WrappedComponent=i;return t.withRef?n.forwardRef(((e,t)=>n.createElement(s,Object.assign({},e,{forwardedRef:t})))):s}}})); +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),i=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function a(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var a=e.indexOf("--\x3e");return{type:"comment",comment:-1!==a?e.slice(4,a):""}}for(var o=new RegExp(i),r=null;null!==(r=o.exec(e));)if(r[0].trim())if(r[1]){var l=r[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],o.lastIndex--}else r[2]&&(n.attrs[r[2]]=r[3].trim().substring(1,r[3].length-1));return n}var o=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,r=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],i=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(o,(function(o,l){if(u){if(o!=="")return;u=!1}var p,d="/"!==o.charAt(1),f=o.startsWith("\x3c!--"),g=l+o.length,h=e.charAt(g);if(f){var m=a(o);return c<0?(s.push(m),s):((p=i[c]).children.push(m),s)}if(d&&(c++,"tag"===(t=a(o)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!h||"<"===h||t.children.push({type:"text",content:e.slice(g,e.indexOf("<",g))}),0===c&&s.push(t),(p=i[c-1])&&p.children.push(t),i[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===o.slice(2,-1))&&(c--,t=-1===c?s:i[c]),!u&&"<"!==h&&h)){p=-1===c?s:i[c].children;var y=e.indexOf("<",g),b=e.slice(g,-1===y?void 0:y);r.test(b)&&(b=" "),(y>-1&&c+p.length>=0||" "!==b)&&p.push({type:"text",content:b})}})),s};function u(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},g=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},h=(e,n,t,s)=>{y(t)&&(t=[t]),t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},m=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,b=e=>"object"==typeof e&&null!==e,v=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,x={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},E=e=>x[e];let N={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(v,E)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N={...N,...e}},$=()=>N;let k;const w=e=>{k=e},I=()=>k,S=(e,n)=>{if(!e)return!1;const t=e.props?e.props.children:e.children;return n?t.length>0:!!t},C=e=>{if(!e)return[];const n=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?R(n):n},R=e=>Array.isArray(e)?e:[e],j=(e,t)=>{if(!e)return"";let s="";const i=R(e),a=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return i.forEach(((e,i)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:o}=e,r=Object.keys(n).length,l=a.indexOf(o)>-1,c=n.children;if(c||!l||r)if(!c&&(!l||r)||n.i18nIsDynamicList)s+=`<${i}>`;else if(l&&1===r&&y(c))s+=`<${o}>${c}`;else{const e=j(c,t);s+=`<${i}>${e}`}else s+=`<${o}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(b(e)){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];s+=`{{${e}}}`}else u("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else u("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)})),s},T=(e,t,s,i,a,o)=>{if(""===t)return[];const r=i.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(r.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!o)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(C(e)):b(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}`),f={...u,...a},g=(e,t,s)=>{const i=C(e),a=m(i,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(i)&&0===a.length||e.props&&e.props.i18nIsDynamicList?i:a},h=(e,t,s,i,a)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:i},a?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:i,ref:e.ref},a?null:t)})))},m=(t,a,c)=>{const u=R(t);return R(a).reduce(((t,a,p)=>{const d=a.children&&a.children[0]&&a.children[0].content&&s.services.interpolator.interpolate(a.children[0].content,f,s.language);if("tag"===a.type){let o=u[parseInt(a.name,10)];1!==c.length||o||(o=c[0][a.name]),o||(o={});const v=0!==Object.keys(a.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:a.attrs},o):o,x=n.isValidElement(v),E=x&&S(a,!0)&&!a.voidElement,N=l&&b(v)&&v.dummy&&!x,O=b(e)&&Object.hasOwnProperty.call(e,a.name);if(y(v)){const e=s.services.interpolator.interpolate(v,f,s.language);t.push(e)}else if(S(v)||E){const e=g(v,a,c);h(v,e,t,p)}else if(N){const e=m(u,a.children,c);h(v,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=g(v,a,c);h(v,e,t,p,a.voidElement)}else if(i.transSupportBasicHtmlNodes&&r.indexOf(a.name)>-1)if(a.voidElement)t.push(n.createElement(a.name,{key:`${a.name}-${p}`}));else{const e=m(u,a.children,c);t.push(n.createElement(a.name,{key:`${a.name}-${p}`},e))}else if(a.voidElement)t.push(`<${a.name} />`);else{const e=m(u,a.children,c);t.push(`<${a.name}>${e}`)}else if(b(v)&&!x){const e=a.children[0]?d:null;e&&t.push(e)}else h(v,d,t,p,1!==a.children.length||!d)}else if("text"===a.type){const e=i.transWrapTextNodes,r=o?i.unescape(s.services.interpolator.interpolate(a.content,f,s.language)):s.services.interpolator.interpolate(a.content,f,s.language);e?t.push(n.createElement(e,{key:`${a.name}-${p}`},r)):t.push(r)}return t}),[])},v=m([{dummy:!0,children:e||[]}],d,R(e||[]));return C(v[0])};function L(e){let{children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:h,...m}=e;const b=f||I();if(!b)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const v=g||b.t.bind(b)||(e=>e),x={...$(),...b.options&&b.options.react};let E=p||v.ns||b.options&&b.options.defaultNS;E=y(E)?[E]:E||["translation"];const N=j(t,x),O=c||N||x.transEmptyNodeValue||a,{hashTransKey:k}=x,w=a||(k?k(N||O):N||O);b.options&&b.options.interpolation&&b.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables});const S=l||void 0!==s||!t?r.interpolation:{interpolation:{...r.interpolation,prefix:"#$?",suffix:"?$#"}},C={...r,context:o||r.context,count:s,...l,...S,defaultValue:O,ns:E},R=w?v(w,C):O;u&&Object.keys(u).forEach((e=>{const t=u[e];"function"==typeof t.type||!t.props||!t.props.children||R.indexOf(`${e}/>`)<0&&R.indexOf(`${e} />`)<0||(u[e]=n.createElement((function(){return n.createElement(n.Fragment,null,t)})))}));const L=T(u||t,R,b,x,C,h),P=void 0!==i?i:x.defaultTransParent;return P?n.createElement(P,m,L):L}const P={type:"3rdParty",init(e){O(e.options.react),w(e)}},A=n.createContext();class V{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces=()=>Object.keys(this.usedNamespaces)}const z=e=>async n=>({...e.getInitialProps?await e.getInitialProps(n):{},...B()}),B=()=>{const e=I(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},s={};return e.languages.forEach((t=>{s[t]={},n.forEach((n=>{s[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=s,t.initialLanguage=e.language,t};const F=(e,n,t,s)=>e.getFixedT(n,t,s),U=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:i,defaultNS:a}=n.useContext(A)||{},o=s||i||I();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new V),!o){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:b(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}o.options.react&&void 0!==o.options.react.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const r={...$(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=r;let u=e||a||o.options&&o.options.defaultNS;u=y(u)?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const p=(o.isInitialized||o.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?void 0!==n.options.ignoreJSONStructure?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=n.languages[0],i=!!n.options&&n.options.fallbackLng,a=n.languages[n.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(e,t)=>{const s=n.services.backendConnector.state[`${e}|${t}`];return-1===s||2===s};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,e)||!n.hasResourceBundle(s,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!o(s,e)||i&&!o(a,e)))}(e,n,t):(d("i18n.languages were undefined or empty",n.languages),!0)}(e,o,r))),f=((e,t,s,i)=>n.useCallback(F(e,t,s,i),[e,t,s,i]))(o,t.lng||null,"fallback"===r.nsMode?u:u[0],c),m=()=>f,v=()=>F(o,t.lng||null,"fallback"===r.nsMode?u:u[0],c),[x,E]=n.useState(m);let N=u.join();t.lng&&(N=`${t.lng}${N}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=t?s.current:e}),[e,t]),s.current})(N),k=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=r;k.current=!0,p||l||(t.lng?h(o,t.lng,u,(()=>{k.current&&E(v)})):g(o,u,(()=>{k.current&&E(v)}))),p&&O&&O!==N&&k.current&&E(v);const s=()=>{k.current&&E(v)};return e&&o&&o.on(e,s),n&&o&&o.store.on(n,s),()=>{k.current=!1,e&&o&&e.split(" ").forEach((e=>o.off(e,s))),n&&o&&n.split(" ").forEach((e=>o.store.off(e,s)))}}),[o,N]),n.useEffect((()=>{k.current&&p&&E(m)}),[o,c,p]);const w=[x,o,p];if(w.t=x,w.i18n=o,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?h(o,t.lng,u,(()=>e())):g(o,u,(()=>e()))}))};const K=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:i}=s,{i18n:a}=n.useContext(A)||{},o=i||a||I();o.options&&o.options.isClone||(e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),o.options.ns),o.initializedStoreOnce=!0,o.isInitialized=!0),t&&!o.initializedLanguageOnce&&(o.changeLanguage(t),o.initializedLanguageOnce=!0))};e.I18nContext=A,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:i}=e;const a=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(A.Provider,{value:a},i)},e.Trans=function(e){let{children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(A)||{},b=d||m||I(),v=f||b&&b.t.bind(b);return L({children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r,values:l,defaults:c,components:u,ns:p||v&&v.ns||y||b&&b.options&&b.options.defaultNS,i18n:b,t:f,shouldUnescape:g,...h})},e.TransWithoutContext=L,e.Translation=function(e){const{ns:n,children:t,...s}=e,[i,a,o]=U(n,s);return t(i,{i18n:a,lng:a.language},o)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=I,e.getInitialProps=B,e.initReactI18next=P,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=K,e.useTranslation=U,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:i,...a}=t;return K(s,i),n.createElement(e,{...a})}return t.getInitialProps=z(e),t.displayName=`withI18nextSSR(${m(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function i(i){let{forwardedRef:a,...o}=i;const[r,l,c]=U(e,{...o,keyPrefix:t.keyPrefix}),u={...o,t:r,i18n:l,tReady:c};return t.withRef&&a?u.ref=a:!t.withRef&&a&&(u.forwardedRef=a),n.createElement(s,u)}i.displayName=`withI18nextTranslation(${m(s)})`,i.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(i,Object.assign({},e,{forwardedRef:t})))):i}}}));