react-i18next 14.1.3 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 15.0.0
2
+
3
+ - use optional chaining, nullish coalescing and nullish coalescing assignment [1774](https://github.com/i18next/react-i18next/pull/1774)
4
+ - Build config and optimizations [1769](https://github.com/i18next/react-i18next/pull/1769)
5
+ - some dependency updates [1768](https://github.com/i18next/react-i18next/pull/1768)
6
+ - use modern hasLoadedNamespace code (now requires at least i18next > v19.4.5 (introduced in june 2020))
7
+
1
8
  ### 14.1.3
2
9
 
3
10
  - create a isObject helper function [1766](https://github.com/i18next/react-i18next/pull/1766)
@@ -114,24 +114,24 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
114
114
  }
115
115
  };
116
116
 
117
- function warn() {
118
- if (console && console.warn) {
117
+ const warn = function () {
118
+ if (console?.warn) {
119
119
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
120
120
  args[_key] = arguments[_key];
121
121
  }
122
122
  if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
123
123
  console.warn(...args);
124
124
  }
125
- }
125
+ };
126
126
  const alreadyWarned = {};
127
- function warnOnce() {
127
+ const warnOnce = function () {
128
128
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
129
129
  args[_key2] = arguments[_key2];
130
130
  }
131
131
  if (isString(args[0]) && alreadyWarned[args[0]]) return;
132
132
  if (isString(args[0])) alreadyWarned[args[0]] = new Date();
133
133
  warn(...args);
134
- }
134
+ };
135
135
  const loadedClb = (i18n, cb) => () => {
136
136
  if (i18n.isInitialized) {
137
137
  cb();
@@ -155,36 +155,16 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
155
155
  });
156
156
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
157
157
  };
158
- const oldI18nextHasLoadedNamespace = function (ns, i18n) {
159
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
160
- const lng = i18n.languages[0];
161
- const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
162
- const lastLng = i18n.languages[i18n.languages.length - 1];
163
- if (lng.toLowerCase() === 'cimode') return true;
164
- const loadNotPending = (l, n) => {
165
- const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
166
- return loadState === -1 || loadState === 2;
167
- };
168
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
169
- if (i18n.hasResourceBundle(lng, ns)) return true;
170
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
171
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
172
- return false;
173
- };
174
158
  const hasLoadedNamespace = function (ns, i18n) {
175
159
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
176
160
  if (!i18n.languages || !i18n.languages.length) {
177
161
  warnOnce('i18n.languages were undefined or empty', i18n.languages);
178
162
  return true;
179
163
  }
180
- const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
181
- if (!isNewerI18next) {
182
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
183
- }
184
164
  return i18n.hasLoadedNamespace(ns, {
185
165
  lng: options.lng,
186
166
  precheck: (i18nInstance, loadNotPending) => {
187
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
167
+ if (options.bindI18n?.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
188
168
  }
189
169
  });
190
170
  };
@@ -245,14 +225,14 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
245
225
 
246
226
  const hasChildren = (node, checkLength) => {
247
227
  if (!node) return false;
248
- const base = node.props ? node.props.children : node.children;
228
+ const base = node.props?.children ?? node.children;
249
229
  if (checkLength) return base.length > 0;
250
230
  return !!base;
251
231
  };
252
232
  const getChildren = node => {
253
233
  if (!node) return [];
254
- const children = node.props ? node.props.children : node.children;
255
- return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
234
+ const children = node.props?.children ?? node.children;
235
+ return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
256
236
  };
257
237
  const hasValidReactChildren = children => Array.isArray(children) && children.every(react.isValidElement);
258
238
  const getAsArray = data => Array.isArray(data) ? data : [data];
@@ -267,7 +247,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
267
247
  if (!children) return '';
268
248
  let stringNode = '';
269
249
  const childrenArray = getAsArray(children);
270
- const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
250
+ const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : [];
271
251
  childrenArray.forEach((child, childIndex) => {
272
252
  if (isString(child)) {
273
253
  stringNode += `${child}`;
@@ -331,7 +311,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
331
311
  const renderInner = (child, node, rootReactNode) => {
332
312
  const childs = getChildren(child);
333
313
  const mappedChildren = mapAST(childs, node.children, rootReactNode);
334
- return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
314
+ return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
335
315
  };
336
316
  const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
337
317
  if (child.dummy) {
@@ -357,7 +337,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
357
337
  const reactNodes = getAsArray(reactNode);
358
338
  const astNodes = getAsArray(astNode);
359
339
  return astNodes.reduce((mem, node, i) => {
360
- const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
340
+ const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
361
341
  if (node.type === 'tag') {
362
342
  let tmp = reactNodes[parseInt(node.name, 10)];
363
343
  if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
@@ -450,9 +430,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
450
430
  const t = tFromProps || i18n.t.bind(i18n) || (k => k);
451
431
  const reactI18nextOptions = {
452
432
  ...getDefaults(),
453
- ...(i18n.options && i18n.options.react)
433
+ ...i18n.options?.react
454
434
  };
455
- let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
435
+ let namespaces = ns || t.ns || i18n.options?.defaultNS;
456
436
  namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
457
437
  const nodeAsString = nodesToString(children, reactI18nextOptions);
458
438
  const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
@@ -460,7 +440,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
460
440
  hashTransKey
461
441
  } = reactI18nextOptions;
462
442
  const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
463
- if (i18n.options && i18n.options.interpolation && i18n.options.interpolation.defaultVariables) {
443
+ if (i18n.options?.interpolation?.defaultVariables) {
464
444
  values = values && Object.keys(values).length > 0 ? {
465
445
  ...values,
466
446
  ...i18n.options.interpolation.defaultVariables
@@ -496,7 +476,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
496
476
  });
497
477
  }
498
478
  const content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
499
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
479
+ const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
500
480
  return useAsParent ? react.createElement(useAsParent, additionalProps, content) : content;
501
481
  }
502
482
 
@@ -515,13 +495,13 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
515
495
  }
516
496
  addUsedNamespaces(namespaces) {
517
497
  namespaces.forEach(ns => {
518
- if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
498
+ this.usedNamespaces[ns] ??= true;
519
499
  });
520
500
  }
521
501
  getUsedNamespaces = () => Object.keys(this.usedNamespaces);
522
502
  }
523
503
  const composeInitialProps = ForComponent => async ctx => {
524
- const componentsInitialProps = ForComponent.getInitialProps ? await ForComponent.getInitialProps(ctx) : {};
504
+ const componentsInitialProps = (await ForComponent.getInitialProps?.(ctx)) ?? {};
525
505
  const i18nInitialProps = getInitialProps();
526
506
  return {
527
507
  ...componentsInitialProps,
@@ -530,7 +510,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
530
510
  };
531
511
  const getInitialProps = () => {
532
512
  const i18n = getI18n();
533
- const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
513
+ const namespaces = i18n.reportNamespaces?.getUsedNamespaces() ?? [];
534
514
  const ret = {};
535
515
  const initialI18nStore = {};
536
516
  i18n.languages.forEach(l => {
@@ -566,7 +546,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
566
546
  defaultNS: defaultNSFromContext
567
547
  } = react.useContext(I18nContext) || {};
568
548
  const i18n = i18nFromProps || i18nFromContext || getI18n();
569
- const t = tFromProps || i18n && i18n.t.bind(i18n);
549
+ const t = tFromProps || i18n?.t.bind(i18n);
570
550
  return Trans$1({
571
551
  children,
572
552
  count,
@@ -577,7 +557,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
577
557
  values,
578
558
  defaults,
579
559
  components,
580
- ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
560
+ ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
581
561
  i18n,
582
562
  t: tFromProps,
583
563
  shouldUnescape,
@@ -588,7 +568,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
588
568
  const usePrevious = (value, ignore) => {
589
569
  const ref = react.useRef();
590
570
  react.useEffect(() => {
591
- ref.current = ignore ? ref.current : value;
571
+ ref.current = value;
592
572
  }, [value, ignore]);
593
573
  return ref.current;
594
574
  };
@@ -618,7 +598,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
618
598
  retNotReady.ready = false;
619
599
  return retNotReady;
620
600
  }
621
- if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
601
+ if (i18n.options.react?.wait) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
622
602
  const i18nOptions = {
623
603
  ...getDefaults(),
624
604
  ...i18n.options.react,
@@ -628,9 +608,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
628
608
  useSuspense,
629
609
  keyPrefix
630
610
  } = i18nOptions;
631
- let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
611
+ let namespaces = ns || defaultNSFromContext || i18n.options?.defaultNS;
632
612
  namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
633
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
613
+ i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
634
614
  const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
635
615
  const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
636
616
  const getT = () => memoGetT;
@@ -663,11 +643,11 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
663
643
  const boundReset = () => {
664
644
  if (isMounted.current) setT(getNewT);
665
645
  };
666
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
667
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
646
+ if (bindI18n) i18n?.on(bindI18n, boundReset);
647
+ if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
668
648
  return () => {
669
649
  isMounted.current = false;
670
- if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
650
+ if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
671
651
  if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
672
652
  };
673
653
  }, [i18n, joinedNS]);
@@ -725,18 +705,18 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
725
705
  };
726
706
  };
727
707
 
728
- function Translation(props) {
729
- const {
708
+ const Translation = _ref => {
709
+ let {
730
710
  ns,
731
711
  children,
732
712
  ...options
733
- } = props;
713
+ } = _ref;
734
714
  const [t, i18n, ready] = useTranslation(ns, options);
735
715
  return children(t, {
736
716
  i18n,
737
717
  lng: i18n.language
738
718
  }, ready);
739
- }
719
+ };
740
720
 
741
721
  function I18nextProvider(_ref) {
742
722
  let {
@@ -762,7 +742,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
762
742
  i18n: i18nFromContext
763
743
  } = react.useContext(I18nContext) || {};
764
744
  const i18n = i18nFromProps || i18nFromContext || getI18n();
765
- if (i18n.options && i18n.options.isClone) return;
745
+ if (i18n.options?.isClone) return;
766
746
  if (initialI18nStore && !i18n.initializedStoreOnce) {
767
747
  i18n.services.resourceStore.data = initialI18nStore;
768
748
  i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
@@ -1 +1 @@
1
- define(["exports","react"],(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}),a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(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 i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var r=new RegExp(a),o=null;null!==(o=r.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],r.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],a=[],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(r,(function(r,l){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),g=l+r.length,h=e.charAt(g);if(f){var m=i(r);return c<0?(s.push(m),s):((p=a[c]).children.push(m),s)}if(d&&(c++,"tag"===(t=i(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===c&&s.push(t),(p=a[c-1])&&p.children.push(t),a[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===r.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==h&&h)){p=-1===c?s:a[c].children;var y=e.indexOf("<",g),v=e.slice(g,-1===y?void 0:y);o.test(v)&&(v=" "),(y>-1&&c+p.length>=0||" "!==v)&&p.push({type:"text",content:v})}})),s};function u(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),console.warn(...n)}}const p={};function d(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&p[n[0]]||(y(n[0])&&(p[n[0]]=new Date),u(...n))}const f=(e,n)=>()=>{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,v=e=>"object"==typeof e&&null!==e,b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,x={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>x[e];let N={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,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?j(n):n},j=e=>Array.isArray(e)?e:[e],R=(e,t)=>{if(!e)return"";let s="";const a=j(e),i=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return a.forEach(((e,a)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:r}=e,o=Object.keys(n).length,l=i.indexOf(r)>-1,c=n.children;if(c||!l||o)if(!c&&(!l||o)||n.i18nIsDynamicList)s+=`<${a}></${a}>`;else if(l&&1===o&&y(c))s+=`<${r}>${c}</${r}>`;else{const e=R(c,t);s+=`<${a}>${e}</${a}>`}else s+=`<${r}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(v(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[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},L=(e,t,s,a,i,r)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},p=e=>{j(e).forEach((e=>{y(e)||(S(e)?p(C(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},g=(e,t,s)=>{const a=C(e),i=m(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===i.length||e.props&&e.props.i18nIsDynamicList?a:i},h=(e,t,s,a,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:a,ref:e.ref},i?null:t)})))},m=(t,i,c)=>{const u=j(t);return j(i).reduce(((t,i,p)=>{const d=i.children&&i.children[0]&&i.children[0].content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let r=u[parseInt(i.name,10)];1!==c.length||r||(r=c[0][i.name]),r||(r={});const b=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},r):r,x=n.isValidElement(b),E=x&&S(i,!0)&&!i.voidElement,N=l&&v(b)&&b.dummy&&!x,O=v(e)&&Object.hasOwnProperty.call(e,i.name);if(y(b)){const e=s.services.interpolator.interpolate(b,f,s.language);t.push(e)}else if(S(b)||E){const e=g(b,i,c);h(b,e,t,p)}else if(N){const e=m(u,i.children,c);h(b,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(O){const e=g(b,i,c);h(b,e,t,p,i.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=m(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=m(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(v(b)&&!x){const e=i.children[0]?d:null;e&&t.push(e)}else h(b,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=a.transWrapTextNodes,o=r?a.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},b=m([{dummy:!0,children:e||[]}],d,j(e||[]));return C(b[0])};function T(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:h,...m}=e;const v=f||I();if(!v)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=g||v.t.bind(v)||(e=>e),x={...$(),...v.options&&v.options.react};let E=p||b.ns||v.options&&v.options.defaultNS;E=y(E)?[E]:E||["translation"];const N=R(t,x),O=c||N||x.transEmptyNodeValue||i,{hashTransKey:k}=x,w=i||(k?k(N||O):N||O);v.options&&v.options.interpolation&&v.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables});const S=l||void 0!==s||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},C={...o,context:r||o.context,count:s,...l,...S,defaultValue:O,ns:E},j=w?b(w,C):O;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=L(u||t,j,v,x,C,h),P=void 0!==a?a:x.defaultTransParent;return P?n.createElement(P,m,T):T}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:a,defaultNS:i}=n.useContext(A)||{},r=s||a||I();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new V),!r){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:v(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}r.options.react&&void 0!==r.options.react.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...$(),...r.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||r.options&&r.options.defaultNS;u=y(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,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],a=!!n.options&&n.options.fallbackLng,i=n.languages[n.languages.length-1];if("cimode"===s.toLowerCase())return!0;const r=(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&&!r(n.isLanguageChangingTo,e)||!n.hasResourceBundle(s,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!r(s,e)||a&&!r(i,e)))}(e,n,t):(d("i18n.languages were undefined or empty",n.languages),!0)}(e,r,o))),f=((e,t,s,a)=>n.useCallback(F(e,t,s,a),[e,t,s,a]))(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),m=()=>f,b=()=>F(r,t.lng||null,"fallback"===o.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}=o;k.current=!0,p||l||(t.lng?h(r,t.lng,u,(()=>{k.current&&E(b)})):g(r,u,(()=>{k.current&&E(b)}))),p&&O&&O!==N&&k.current&&E(b);const s=()=>{k.current&&E(b)};return e&&r&&r.on(e,s),n&&r&&r.store.on(n,s),()=>{k.current=!1,e&&r&&e.split(" ").forEach((e=>r.off(e,s))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,s)))}}),[r,N]),n.useEffect((()=>{k.current&&p&&E(m)}),[r,c,p]);const w=[x,r,p];if(w.t=x,w.i18n=r,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?h(r,t.lng,u,(()=>e())):g(r,u,(()=>e()))}))};const K=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:i}=n.useContext(A)||{},r=a||i||I();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=A,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(A.Provider,{value:i},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(A)||{},v=d||m||I(),b=f||v&&v.t.bind(v);return T({children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o,values:l,defaults:c,components:u,ns:p||b&&b.ns||y||v&&v.options&&v.options.defaultNS,i18n:v,t:f,shouldUnescape:g,...h})},e.TransWithoutContext=T,e.Translation=function(e){const{ns:n,children:t,...s}=e,[a,i,r]=U(n,s);return t(a,{i18n:i,lng:i.language},r)},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:a,...i}=t;return K(s,a),n.createElement(e,{...i})}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 a(a){let{forwardedRef:i,...r}=a;const[o,l,c]=U(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${m(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
1
+ define(["exports","react"],(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}),a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(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 i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var r=new RegExp(a),o=null;null!==(o=r.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],r.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],a=[],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(r,(function(r,l){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),h=l+r.length,m=e.charAt(h);if(f){var g=i(r);return c<0?(s.push(g),s):((p=a[c]).children.push(g),s)}if(d&&(c++,"tag"===(t=i(r)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!m||"<"===m||t.children.push({type:"text",content:e.slice(h,e.indexOf("<",h))}),0===c&&s.push(t),(p=a[c-1])&&p.children.push(t),a[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===r.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==m&&m)){p=-1===c?s:a[c].children;var y=e.indexOf("<",h),v=e.slice(h,-1===y?void 0:y);o.test(v)&&(v=" "),(y>-1&&c+p.length>=0||" "!==v)&&p.push({type:"text",content:v})}})),s};const u=function(){if(console?.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),console.warn(...n)}},p={},d=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&p[n[0]]||(y(n[0])&&(p[n[0]]=new Date),u(...n))},f=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},h=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},m=(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))},g=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,v=e=>"object"==typeof e&&null!==e,x=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>b[e];let O={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,E)};const N=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O={...O,...e}},$=()=>O;let w;const I=e=>{w=e},k=()=>w,S=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},j=e=>{if(!e)return[];const n=e.props?.children??e.children;return e.props?.i18nIsDynamicList?R(n):n},R=e=>Array.isArray(e)?e:[e],C=(e,t)=>{if(!e)return"";let s="";const a=R(e),i=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:r}=e,o=Object.keys(n).length,l=i.indexOf(r)>-1,c=n.children;if(c||!l||o)if(!c&&(!l||o)||n.i18nIsDynamicList)s+=`<${a}></${a}>`;else if(l&&1===o&&y(c))s+=`<${r}>${c}</${r}>`;else{const e=C(c,t);s+=`<${a}>${e}</${a}>`}else s+=`<${r}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(v(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[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,a,i,r)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(j(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},h=(e,t,s)=>{const a=j(e),i=g(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===i.length||e.props?.i18nIsDynamicList?a:i},m=(e,t,s,a,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:a,ref:e.ref},i?null:t)})))},g=(t,i,c)=>{const u=R(t);return R(i).reduce(((t,i,p)=>{const d=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let r=u[parseInt(i.name,10)];1!==c.length||r||(r=c[0][i.name]),r||(r={});const x=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},r):r,b=n.isValidElement(x),E=b&&S(i,!0)&&!i.voidElement,O=l&&v(x)&&x.dummy&&!b,N=v(e)&&Object.hasOwnProperty.call(e,i.name);if(y(x)){const e=s.services.interpolator.interpolate(x,f,s.language);t.push(e)}else if(S(x)||E){const e=h(x,i,c);m(x,e,t,p)}else if(O){const e=g(u,i.children,c);m(x,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(N){const e=h(x,i,c);m(x,e,t,p,i.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=g(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=g(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(v(x)&&!b){const e=i.children[0]?d:null;e&&t.push(e)}else m(x,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=a.transWrapTextNodes,o=r?a.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},x=g([{dummy:!0,children:e||[]}],d,R(e||[]));return j(x[0])};function P(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:h,shouldUnescape:m,...g}=e;const v=f||k();if(!v)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const x=h||v.t.bind(v)||(e=>e),b={...$(),...v.options?.react};let E=p||x.ns||v.options?.defaultNS;E=y(E)?[E]:E||["translation"];const O=C(t,b),N=c||O||b.transEmptyNodeValue||i,{hashTransKey:w}=b,I=i||(w?w(O||N):O||N);v.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables});const S=l||void 0!==s||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},j={...o,context:r||o.context,count:s,...l,...S,defaultValue:N,ns:E},R=I?x(I,j):N;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 P=T(u||t,R,v,b,j,m),L=a??b.defaultTransParent;return L?n.createElement(L,g,P):P}const L={type:"3rdParty",init(e){N(e.options.react),I(e)}},A=n.createContext();class V{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]??=!0}))}getUsedNamespaces=()=>Object.keys(this.usedNamespaces)}const z=e=>async n=>({...await(e.getInitialProps?.(n))??{},...F()}),F=()=>{const e=k(),n=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 U=(e,n,t,s)=>e.getFixedT(n,t,s),B=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:a,defaultNS:i}=n.useContext(A)||{},r=s||a||k();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new V),!r){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:v(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}r.options.react?.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...$(),...r.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||r.options?.defaultNS;u=y(u)?[u]:u||["translation"],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?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n?.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(d("i18n.languages were undefined or empty",n.languages),!0)}(e,r,o))),f=((e,t,s,a)=>n.useCallback(U(e,t,s,a),[e,t,s,a]))(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),g=()=>f,x=()=>U(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[b,E]=n.useState(g);let O=u.join();t.lng&&(O=`${t.lng}${O}`);const N=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(O),w=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;w.current=!0,p||l||(t.lng?m(r,t.lng,u,(()=>{w.current&&E(x)})):h(r,u,(()=>{w.current&&E(x)}))),p&&N&&N!==O&&w.current&&E(x);const s=()=>{w.current&&E(x)};return e&&r?.on(e,s),n&&r?.store.on(n,s),()=>{w.current=!1,r&&e?.split(" ").forEach((e=>r.off(e,s))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,s)))}}),[r,O]),n.useEffect((()=>{w.current&&p&&E(g)}),[r,c,p]);const I=[b,r,p];if(I.t=b,I.i18n=r,I.ready=p,p)return I;if(!p&&!l)return I;throw new Promise((e=>{t.lng?m(r,t.lng,u,(()=>e())):h(r,u,(()=>e()))}))};const D=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:i}=n.useContext(A)||{},r=a||i||k();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=A,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(A.Provider,{value:i},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:h,...m}=e;const{i18n:g,defaultNS:y}=n.useContext(A)||{},v=d||g||k(),x=f||v?.t.bind(v);return P({children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o,values:l,defaults:c,components:u,ns:p||x?.ns||y||v?.options?.defaultNS,i18n:v,t:f,shouldUnescape:h,...m})},e.TransWithoutContext=P,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[a,i,r]=B(n,s);return t(a,{i18n:i,lng:i.language},r)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=k,e.getInitialProps=F,e.initReactI18next=L,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=N,e.setI18n=I,e.time=()=>"",e.useSSR=D,e.useTranslation=B,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:a,...i}=t;return D(s,a),n.createElement(e,{...i})}return t.getInitialProps=z(e),t.displayName=`withI18nextSSR(${g(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function a(a){let{forwardedRef:i,...r}=a;const[o,l,c]=B(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${g(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
@@ -35,7 +35,7 @@ function Trans(_ref) {
35
35
  defaultNS: defaultNSFromContext
36
36
  } = (0, _react.useContext)(_context.I18nContext) || {};
37
37
  const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
38
- const t = tFromProps || i18n && i18n.t.bind(i18n);
38
+ const t = tFromProps || i18n?.t.bind(i18n);
39
39
  return (0, _TransWithoutContext.Trans)({
40
40
  children,
41
41
  count,
@@ -46,7 +46,7 @@ function Trans(_ref) {
46
46
  values,
47
47
  defaults,
48
48
  components,
49
- ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
49
+ ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
50
50
  i18n,
51
51
  t: tFromProps,
52
52
  shouldUnescape,
@@ -13,14 +13,14 @@ var _defaults = require("./defaults.js");
13
13
  var _i18nInstance = require("./i18nInstance.js");
14
14
  const hasChildren = (node, checkLength) => {
15
15
  if (!node) return false;
16
- const base = node.props ? node.props.children : node.children;
16
+ const base = node.props?.children ?? node.children;
17
17
  if (checkLength) return base.length > 0;
18
18
  return !!base;
19
19
  };
20
20
  const getChildren = node => {
21
21
  if (!node) return [];
22
- const children = node.props ? node.props.children : node.children;
23
- return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
22
+ const children = node.props?.children ?? node.children;
23
+ return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
24
24
  };
25
25
  const hasValidReactChildren = children => Array.isArray(children) && children.every(_react.isValidElement);
26
26
  const getAsArray = data => Array.isArray(data) ? data : [data];
@@ -35,7 +35,7 @@ const nodesToString = (children, i18nOptions) => {
35
35
  if (!children) return '';
36
36
  let stringNode = '';
37
37
  const childrenArray = getAsArray(children);
38
- const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
38
+ const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : [];
39
39
  childrenArray.forEach((child, childIndex) => {
40
40
  if ((0, _utils.isString)(child)) {
41
41
  stringNode += `${child}`;
@@ -100,7 +100,7 @@ const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, s
100
100
  const renderInner = (child, node, rootReactNode) => {
101
101
  const childs = getChildren(child);
102
102
  const mappedChildren = mapAST(childs, node.children, rootReactNode);
103
- return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
103
+ return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
104
104
  };
105
105
  const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
106
106
  if (child.dummy) {
@@ -126,7 +126,7 @@ const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, s
126
126
  const reactNodes = getAsArray(reactNode);
127
127
  const astNodes = getAsArray(astNode);
128
128
  return astNodes.reduce((mem, node, i) => {
129
- const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
129
+ const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
130
130
  if (node.type === 'tag') {
131
131
  let tmp = reactNodes[parseInt(node.name, 10)];
132
132
  if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
@@ -219,9 +219,9 @@ function Trans(_ref) {
219
219
  const t = tFromProps || i18n.t.bind(i18n) || (k => k);
220
220
  const reactI18nextOptions = {
221
221
  ...(0, _defaults.getDefaults)(),
222
- ...(i18n.options && i18n.options.react)
222
+ ...i18n.options?.react
223
223
  };
224
- let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
224
+ let namespaces = ns || t.ns || i18n.options?.defaultNS;
225
225
  namespaces = (0, _utils.isString)(namespaces) ? [namespaces] : namespaces || ['translation'];
226
226
  const nodeAsString = nodesToString(children, reactI18nextOptions);
227
227
  const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
@@ -229,7 +229,7 @@ function Trans(_ref) {
229
229
  hashTransKey
230
230
  } = reactI18nextOptions;
231
231
  const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
232
- if (i18n.options && i18n.options.interpolation && i18n.options.interpolation.defaultVariables) {
232
+ if (i18n.options?.interpolation?.defaultVariables) {
233
233
  values = values && Object.keys(values).length > 0 ? {
234
234
  ...values,
235
235
  ...i18n.options.interpolation.defaultVariables
@@ -265,6 +265,6 @@ function Trans(_ref) {
265
265
  });
266
266
  }
267
267
  const content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
268
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
268
+ const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
269
269
  return useAsParent ? (0, _react.createElement)(useAsParent, additionalProps, content) : content;
270
270
  }
@@ -3,17 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Translation = Translation;
6
+ exports.Translation = void 0;
7
7
  var _useTranslation = require("./useTranslation.js");
8
- function Translation(props) {
9
- const {
8
+ const Translation = _ref => {
9
+ let {
10
10
  ns,
11
11
  children,
12
12
  ...options
13
- } = props;
13
+ } = _ref;
14
14
  const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, options);
15
15
  return children(t, {
16
16
  i18n,
17
17
  lng: i18n.language
18
18
  }, ready);
19
- }
19
+ };
20
+ exports.Translation = Translation;
@@ -46,14 +46,14 @@ class ReportNamespaces {
46
46
  }
47
47
  addUsedNamespaces(namespaces) {
48
48
  namespaces.forEach(ns => {
49
- if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
49
+ this.usedNamespaces[ns] ??= true;
50
50
  });
51
51
  }
52
52
  getUsedNamespaces = () => Object.keys(this.usedNamespaces);
53
53
  }
54
54
  exports.ReportNamespaces = ReportNamespaces;
55
55
  const composeInitialProps = ForComponent => async ctx => {
56
- const componentsInitialProps = ForComponent.getInitialProps ? await ForComponent.getInitialProps(ctx) : {};
56
+ const componentsInitialProps = (await ForComponent.getInitialProps?.(ctx)) ?? {};
57
57
  const i18nInitialProps = getInitialProps();
58
58
  return {
59
59
  ...componentsInitialProps,
@@ -63,7 +63,7 @@ const composeInitialProps = ForComponent => async ctx => {
63
63
  exports.composeInitialProps = composeInitialProps;
64
64
  const getInitialProps = () => {
65
65
  const i18n = (0, _i18nInstance.getI18n)();
66
- const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
66
+ const namespaces = i18n.reportNamespaces?.getUsedNamespaces() ?? [];
67
67
  const ret = {};
68
68
  const initialI18nStore = {};
69
69
  i18n.languages.forEach(l => {
@@ -15,7 +15,7 @@ const useSSR = function (initialI18nStore, initialLanguage) {
15
15
  i18n: i18nFromContext
16
16
  } = (0, _react.useContext)(_context.I18nContext) || {};
17
17
  const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
18
- if (i18n.options && i18n.options.isClone) return;
18
+ if (i18n.options?.isClone) return;
19
19
  if (initialI18nStore && !i18n.initializedStoreOnce) {
20
20
  i18n.services.resourceStore.data = initialI18nStore;
21
21
  i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
@@ -40,7 +40,7 @@ const useTranslation = function (ns) {
40
40
  retNotReady.ready = false;
41
41
  return retNotReady;
42
42
  }
43
- if (i18n.options.react && i18n.options.react.wait !== undefined) (0, _utils.warnOnce)('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
43
+ if (i18n.options.react?.wait) (0, _utils.warnOnce)('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
44
44
  const i18nOptions = {
45
45
  ...(0, _context.getDefaults)(),
46
46
  ...i18n.options.react,
@@ -50,9 +50,9 @@ const useTranslation = function (ns) {
50
50
  useSuspense,
51
51
  keyPrefix
52
52
  } = i18nOptions;
53
- let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
53
+ let namespaces = ns || defaultNSFromContext || i18n.options?.defaultNS;
54
54
  namespaces = (0, _utils.isString)(namespaces) ? [namespaces] : namespaces || ['translation'];
55
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
55
+ i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
56
56
  const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => (0, _utils.hasLoadedNamespace)(n, i18n, i18nOptions));
57
57
  const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
58
58
  const getT = () => memoGetT;
@@ -85,11 +85,11 @@ const useTranslation = function (ns) {
85
85
  const boundReset = () => {
86
86
  if (isMounted.current) setT(getNewT);
87
87
  };
88
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
89
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
88
+ if (bindI18n) i18n?.on(bindI18n, boundReset);
89
+ if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
90
90
  return () => {
91
91
  isMounted.current = false;
92
- if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
92
+ if (i18n) bindI18n?.split(' ').forEach(e => i18n.off(e, boundReset));
93
93
  if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
94
94
  };
95
95
  }, [i18n, joinedNS]);
@@ -3,27 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.loadNamespaces = exports.loadLanguages = exports.isString = exports.isObject = exports.hasLoadedNamespace = exports.getDisplayName = void 0;
7
- exports.warn = warn;
8
- exports.warnOnce = warnOnce;
9
- function warn() {
10
- if (console && console.warn) {
6
+ exports.warnOnce = exports.warn = exports.loadNamespaces = exports.loadLanguages = exports.isString = exports.isObject = exports.hasLoadedNamespace = exports.getDisplayName = void 0;
7
+ const warn = function () {
8
+ if (console?.warn) {
11
9
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
10
  args[_key] = arguments[_key];
13
11
  }
14
12
  if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
15
13
  console.warn(...args);
16
14
  }
17
- }
15
+ };
16
+ exports.warn = warn;
18
17
  const alreadyWarned = {};
19
- function warnOnce() {
18
+ const warnOnce = function () {
20
19
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
21
20
  args[_key2] = arguments[_key2];
22
21
  }
23
22
  if (isString(args[0]) && alreadyWarned[args[0]]) return;
24
23
  if (isString(args[0])) alreadyWarned[args[0]] = new Date();
25
24
  warn(...args);
26
- }
25
+ };
26
+ exports.warnOnce = warnOnce;
27
27
  const loadedClb = (i18n, cb) => () => {
28
28
  if (i18n.isInitialized) {
29
29
  cb();
@@ -49,36 +49,16 @@ const loadLanguages = (i18n, lng, ns, cb) => {
49
49
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
50
50
  };
51
51
  exports.loadLanguages = loadLanguages;
52
- const oldI18nextHasLoadedNamespace = function (ns, i18n) {
53
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54
- const lng = i18n.languages[0];
55
- const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
56
- const lastLng = i18n.languages[i18n.languages.length - 1];
57
- if (lng.toLowerCase() === 'cimode') return true;
58
- const loadNotPending = (l, n) => {
59
- const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
60
- return loadState === -1 || loadState === 2;
61
- };
62
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
63
- if (i18n.hasResourceBundle(lng, ns)) return true;
64
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
65
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
66
- return false;
67
- };
68
52
  const hasLoadedNamespace = function (ns, i18n) {
69
53
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
70
54
  if (!i18n.languages || !i18n.languages.length) {
71
55
  warnOnce('i18n.languages were undefined or empty', i18n.languages);
72
56
  return true;
73
57
  }
74
- const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
75
- if (!isNewerI18next) {
76
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
77
- }
78
58
  return i18n.hasLoadedNamespace(ns, {
79
59
  lng: options.lng,
80
60
  precheck: (i18nInstance, loadNotPending) => {
81
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
61
+ if (options.bindI18n?.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
82
62
  }
83
63
  });
84
64
  };
@@ -1,11 +1,10 @@
1
1
  import { createElement, useMemo } from 'react';
2
2
  import { I18nContext } from './context.js';
3
- export function I18nextProvider(_ref) {
4
- let {
5
- i18n,
6
- defaultNS,
7
- children
8
- } = _ref;
3
+ export function I18nextProvider({
4
+ i18n,
5
+ defaultNS,
6
+ children
7
+ }) {
9
8
  const value = useMemo(() => ({
10
9
  i18n,
11
10
  defaultNS