willba-component-library 0.0.35 → 0.0.37

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/lib/index.umd.js CHANGED
@@ -116,8 +116,8 @@
116
116
  }
117
117
  }
118
118
 
119
- var css_248z$8 = ".storybook-button {\r\n font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;\r\n font-weight: 700;\r\n border: 0;\r\n border-radius: 3em;\r\n cursor: pointer;\r\n display: inline-block;\r\n line-height: 1;\r\n}\r\n.storybook-button--primary {\r\n color: white;\r\n background-color: #1ea7fd;\r\n}\r\n.storybook-button--secondary {\r\n color: #333;\r\n background-color: transparent;\r\n box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;\r\n}\r\n.storybook-button--small {\r\n font-size: 12px;\r\n padding: 10px 16px;\r\n}\r\n.storybook-button--medium {\r\n font-size: 14px;\r\n padding: 11px 20px;\r\n}\r\n.storybook-button--large {\r\n font-size: 16px;\r\n padding: 12px 24px;\r\n}";
120
- styleInject(css_248z$8);
119
+ var css_248z$9 = ".storybook-button {\r\n font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;\r\n font-weight: 700;\r\n border: 0;\r\n border-radius: 3em;\r\n cursor: pointer;\r\n display: inline-block;\r\n line-height: 1;\r\n}\r\n.storybook-button--primary {\r\n color: white;\r\n background-color: #1ea7fd;\r\n}\r\n.storybook-button--secondary {\r\n color: #333;\r\n background-color: transparent;\r\n box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;\r\n}\r\n.storybook-button--small {\r\n font-size: 12px;\r\n padding: 10px 16px;\r\n}\r\n.storybook-button--medium {\r\n font-size: 14px;\r\n padding: 11px 20px;\r\n}\r\n.storybook-button--large {\r\n font-size: 16px;\r\n padding: 12px 24px;\r\n}";
120
+ styleInject(css_248z$9);
121
121
 
122
122
  /**
123
123
  * Primary UI component for user interaction
@@ -128,23 +128,282 @@
128
128
  return (React__default.createElement("button", { type: "button", className: classNames("storybook-button", "storybook-button--".concat(size), "storybook-button--".concat(type)), style: textColor ? { color: textColor } : {}, onClick: onClick }, "".concat(label, " ").concat(theState)));
129
129
  };
130
130
 
131
- var css_248z$7 = ".filter-bar-divider {\n width: 1px;\n margin: 0 10px;\n height: 35px;\n background-color: #384265;\n}";
132
- styleInject(css_248z$7);
131
+ function warn() {
132
+ if (console && console.warn) {
133
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
134
+ args[_key] = arguments[_key];
135
+ }
136
+ if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
137
+ console.warn(...args);
138
+ }
139
+ }
140
+ const alreadyWarned = {};
141
+ function warnOnce() {
142
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
143
+ args[_key2] = arguments[_key2];
144
+ }
145
+ if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
146
+ if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
147
+ warn(...args);
148
+ }
149
+ const loadedClb = (i18n, cb) => () => {
150
+ if (i18n.isInitialized) {
151
+ cb();
152
+ } else {
153
+ const initialized = () => {
154
+ setTimeout(() => {
155
+ i18n.off('initialized', initialized);
156
+ }, 0);
157
+ cb();
158
+ };
159
+ i18n.on('initialized', initialized);
160
+ }
161
+ };
162
+ function loadNamespaces(i18n, ns, cb) {
163
+ i18n.loadNamespaces(ns, loadedClb(i18n, cb));
164
+ }
165
+ function loadLanguages(i18n, lng, ns, cb) {
166
+ if (typeof ns === 'string') ns = [ns];
167
+ ns.forEach(n => {
168
+ if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
169
+ });
170
+ i18n.loadLanguages(lng, loadedClb(i18n, cb));
171
+ }
172
+ function oldI18nextHasLoadedNamespace(ns, i18n) {
173
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
174
+ const lng = i18n.languages[0];
175
+ const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
176
+ const lastLng = i18n.languages[i18n.languages.length - 1];
177
+ if (lng.toLowerCase() === 'cimode') return true;
178
+ const loadNotPending = (l, n) => {
179
+ const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
180
+ return loadState === -1 || loadState === 2;
181
+ };
182
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
183
+ if (i18n.hasResourceBundle(lng, ns)) return true;
184
+ if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
185
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
186
+ return false;
187
+ }
188
+ function hasLoadedNamespace(ns, i18n) {
189
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
190
+ if (!i18n.languages || !i18n.languages.length) {
191
+ warnOnce('i18n.languages were undefined or empty', i18n.languages);
192
+ return true;
193
+ }
194
+ const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
195
+ if (!isNewerI18next) {
196
+ return oldI18nextHasLoadedNamespace(ns, i18n, options);
197
+ }
198
+ return i18n.hasLoadedNamespace(ns, {
199
+ lng: options.lng,
200
+ precheck: (i18nInstance, loadNotPending) => {
201
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
202
+ }
203
+ });
204
+ }
205
+
206
+ const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
207
+ const htmlEntities = {
208
+ '&amp;': '&',
209
+ '&#38;': '&',
210
+ '&lt;': '<',
211
+ '&#60;': '<',
212
+ '&gt;': '>',
213
+ '&#62;': '>',
214
+ '&apos;': "'",
215
+ '&#39;': "'",
216
+ '&quot;': '"',
217
+ '&#34;': '"',
218
+ '&nbsp;': ' ',
219
+ '&#160;': ' ',
220
+ '&copy;': '©',
221
+ '&#169;': '©',
222
+ '&reg;': '®',
223
+ '&#174;': '®',
224
+ '&hellip;': '…',
225
+ '&#8230;': '…',
226
+ '&#x2F;': '/',
227
+ '&#47;': '/'
228
+ };
229
+ const unescapeHtmlEntity = m => htmlEntities[m];
230
+ const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
231
+
232
+ let defaultOptions$1 = {
233
+ bindI18n: 'languageChanged',
234
+ bindI18nStore: '',
235
+ transEmptyNodeValue: '',
236
+ transSupportBasicHtmlNodes: true,
237
+ transWrapTextNodes: '',
238
+ transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
239
+ useSuspense: true,
240
+ unescape
241
+ };
242
+ function setDefaults() {
243
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
244
+ defaultOptions$1 = {
245
+ ...defaultOptions$1,
246
+ ...options
247
+ };
248
+ }
249
+ function getDefaults() {
250
+ return defaultOptions$1;
251
+ }
252
+
253
+ let i18nInstance;
254
+ function setI18n(instance) {
255
+ i18nInstance = instance;
256
+ }
257
+ function getI18n() {
258
+ return i18nInstance;
259
+ }
260
+
261
+ const initReactI18next = {
262
+ type: '3rdParty',
263
+ init(instance) {
264
+ setDefaults(instance.options.react);
265
+ setI18n(instance);
266
+ }
267
+ };
268
+
269
+ const I18nContext = React__default.createContext();
270
+ class ReportNamespaces {
271
+ constructor() {
272
+ this.usedNamespaces = {};
273
+ }
274
+ addUsedNamespaces(namespaces) {
275
+ namespaces.forEach(ns => {
276
+ if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
277
+ });
278
+ }
279
+ getUsedNamespaces() {
280
+ return Object.keys(this.usedNamespaces);
281
+ }
282
+ }
283
+
284
+ const usePrevious = (value, ignore) => {
285
+ const ref = React__default.useRef();
286
+ React__default.useEffect(() => {
287
+ ref.current = ignore ? ref.current : value;
288
+ }, [value, ignore]);
289
+ return ref.current;
290
+ };
291
+ function useTranslation(ns) {
292
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
293
+ const {
294
+ i18n: i18nFromProps
295
+ } = props;
296
+ const {
297
+ i18n: i18nFromContext,
298
+ defaultNS: defaultNSFromContext
299
+ } = React__default.useContext(I18nContext) || {};
300
+ const i18n = i18nFromProps || i18nFromContext || getI18n();
301
+ if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
302
+ if (!i18n) {
303
+ warnOnce('You will need to pass in an i18next instance by using initReactI18next');
304
+ const notReadyT = (k, optsOrDefaultValue) => {
305
+ if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
306
+ if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
307
+ return Array.isArray(k) ? k[k.length - 1] : k;
308
+ };
309
+ const retNotReady = [notReadyT, {}, false];
310
+ retNotReady.t = notReadyT;
311
+ retNotReady.i18n = {};
312
+ retNotReady.ready = false;
313
+ return retNotReady;
314
+ }
315
+ 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.');
316
+ const i18nOptions = {
317
+ ...getDefaults(),
318
+ ...i18n.options.react,
319
+ ...props
320
+ };
321
+ const {
322
+ useSuspense,
323
+ keyPrefix
324
+ } = i18nOptions;
325
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
326
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
327
+ if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
328
+ const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
329
+ function getT() {
330
+ return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
331
+ }
332
+ const [t, setT] = React__default.useState(getT);
333
+ let joinedNS = namespaces.join();
334
+ if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
335
+ const previousJoinedNS = usePrevious(joinedNS);
336
+ const isMounted = React__default.useRef(true);
337
+ React__default.useEffect(() => {
338
+ const {
339
+ bindI18n,
340
+ bindI18nStore
341
+ } = i18nOptions;
342
+ isMounted.current = true;
343
+ if (!ready && !useSuspense) {
344
+ if (props.lng) {
345
+ loadLanguages(i18n, props.lng, namespaces, () => {
346
+ if (isMounted.current) setT(getT);
347
+ });
348
+ } else {
349
+ loadNamespaces(i18n, namespaces, () => {
350
+ if (isMounted.current) setT(getT);
351
+ });
352
+ }
353
+ }
354
+ if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
355
+ setT(getT);
356
+ }
357
+ function boundReset() {
358
+ if (isMounted.current) setT(getT);
359
+ }
360
+ if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
361
+ if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
362
+ return () => {
363
+ isMounted.current = false;
364
+ if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
365
+ if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
366
+ };
367
+ }, [i18n, joinedNS]);
368
+ const isInitial = React__default.useRef(true);
369
+ React__default.useEffect(() => {
370
+ if (isMounted.current && !isInitial.current) {
371
+ setT(getT);
372
+ }
373
+ isInitial.current = false;
374
+ }, [i18n, keyPrefix]);
375
+ const ret = [t, i18n, ready];
376
+ ret.t = t;
377
+ ret.i18n = i18n;
378
+ ret.ready = ready;
379
+ if (ready) return ret;
380
+ if (!ready && !useSuspense) return ret;
381
+ throw new Promise(resolve => {
382
+ if (props.lng) {
383
+ loadLanguages(i18n, props.lng, namespaces, () => resolve());
384
+ } else {
385
+ loadNamespaces(i18n, namespaces, () => resolve());
386
+ }
387
+ });
388
+ }
389
+
390
+ var css_248z$8 = ".filter-bar-divider {\n width: 1px;\n margin: 0 10px;\n height: 35px;\n background-color: #384265;\n}";
391
+ styleInject(css_248z$8);
133
392
 
134
393
  function Divider() {
135
394
  return React__default.createElement("div", { className: "filter-bar-divider" });
136
395
  }
137
396
 
138
- var css_248z$6 = ".filter-bar-select-button {\n width: 100%;\n height: auto;\n background-color: transparent;\n border: none;\n padding: 10px 20px;\n border-radius: 20px;\n cursor: pointer;\n}\n";
139
- styleInject(css_248z$6);
397
+ var css_248z$7 = ".filter-bar-select-button {\n width: 100%;\n height: auto;\n background-color: transparent;\n border: none;\n padding: 10px 20px;\n border-radius: 20px;\n cursor: pointer;\n}\n";
398
+ styleInject(css_248z$7);
140
399
 
141
400
  function SelectButton(_a) {
142
401
  var label = _a.label, onClick = _a.onClick;
143
402
  return (React__default.createElement("button", { className: "filter-bar-select-button", onClick: onClick }, label));
144
403
  }
145
404
 
146
- var css_248z$5 = ".filter-bar-submit-button {\n width: auto;\n height: auto;\n background-color: #384265;\n color: #fff;\n padding: 10px 20px;\n border-radius: 20px;\n cursor: pointer;\n border: none;\n white-space: nowrap;\n}";
147
- styleInject(css_248z$5);
405
+ var css_248z$6 = ".filter-bar-submit-button {\n width: auto;\n height: auto;\n background-color: #384265;\n color: #fff;\n padding: 10px 20px;\n border-radius: 20px;\n cursor: pointer;\n border: none;\n white-space: nowrap;\n}";
406
+ styleInject(css_248z$6);
148
407
 
149
408
  function SubmitButton(_a) {
150
409
  var onClick = _a.onClick;
@@ -5706,11 +5965,11 @@
5706
5965
  React__default.createElement(Root, { initialProps: props })));
5707
5966
  }
5708
5967
 
5709
- var css_248z$4 = ".rdp {\n --rdp-cell-size: 40px;\n --rdp-caption-font-size: 18px;\n --rdp-accent-color: #0000ff;\n --rdp-background-color: #e7edff;\n --rdp-accent-color-dark: #3003e1;\n --rdp-background-color-dark: #180270;\n --rdp-outline: 2px solid var(--rdp-accent-color); /* Outline border for focused elements */\n --rdp-outline-selected: 3px solid var(--rdp-accent-color); /* Outline border for focused _and_ selected elements */\n\n margin: 1em;\n}\n\n/* Hide elements for devices that are not screen readers */\n.rdp-vhidden {\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n background: transparent;\n border: 0;\n -moz-appearance: none;\n -webkit-appearance: none;\n appearance: none;\n position: absolute !important;\n top: 0;\n width: 1px !important;\n height: 1px !important;\n padding: 0 !important;\n overflow: hidden !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n border: 0 !important;\n}\n\n/* Buttons */\n.rdp-button_reset {\n appearance: none;\n position: relative;\n margin: 0;\n padding: 0;\n cursor: default;\n color: inherit;\n background: none;\n font: inherit;\n\n -moz-appearance: none;\n -webkit-appearance: none;\n}\n\n.rdp-button_reset:focus-visible {\n /* Make sure to reset outline only when :focus-visible is supported */\n outline: none;\n}\n\n.rdp-button {\n border: 2px solid transparent;\n}\n\n.rdp-button[disabled]:not(.rdp-day_selected) {\n opacity: 0.25;\n}\n\n.rdp-button:not([disabled]) {\n cursor: pointer;\n}\n\n.rdp-button:focus-visible:not([disabled]) {\n color: inherit;\n background-color: var(--rdp-background-color);\n border: var(--rdp-outline);\n}\n\n.rdp-button:hover:not([disabled]):not(.rdp-day_selected) {\n background-color: var(--rdp-background-color);\n}\n\n.rdp-months {\n display: flex;\n}\n\n.rdp-month {\n margin: 0 1em;\n}\n\n.rdp-month:first-child {\n margin-left: 0;\n}\n\n.rdp-month:last-child {\n margin-right: 0;\n}\n\n.rdp-table {\n margin: 0;\n max-width: calc(var(--rdp-cell-size) * 7);\n border-collapse: collapse;\n}\n\n.rdp-with_weeknumber .rdp-table {\n max-width: calc(var(--rdp-cell-size) * 8);\n border-collapse: collapse;\n}\n\n.rdp-caption {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0;\n text-align: left;\n}\n\n.rdp-multiple_months .rdp-caption {\n position: relative;\n display: block;\n text-align: center;\n}\n\n.rdp-caption_dropdowns {\n position: relative;\n display: inline-flex;\n}\n\n.rdp-caption_label {\n position: relative;\n z-index: 1;\n display: inline-flex;\n align-items: center;\n margin: 0;\n padding: 0 0.25em;\n white-space: nowrap;\n color: currentColor;\n border: 0;\n border: 2px solid transparent;\n font-family: inherit;\n font-size: var(--rdp-caption-font-size);\n font-weight: bold;\n}\n\n.rdp-nav {\n white-space: nowrap;\n}\n\n.rdp-multiple_months .rdp-caption_start .rdp-nav {\n position: absolute;\n top: 50%;\n left: 0;\n transform: translateY(-50%);\n}\n\n.rdp-multiple_months .rdp-caption_end .rdp-nav {\n position: absolute;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n}\n\n.rdp-nav_button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--rdp-cell-size);\n height: var(--rdp-cell-size);\n padding: 0.25em;\n border-radius: 100%;\n}\n\n/* ---------- */\n/* Dropdowns */\n/* ---------- */\n\n.rdp-dropdown_year,\n.rdp-dropdown_month {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n\n.rdp-dropdown {\n appearance: none;\n position: absolute;\n z-index: 2;\n top: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n margin: 0;\n padding: 0;\n cursor: inherit;\n opacity: 0;\n border: none;\n background-color: transparent;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n}\n\n.rdp-dropdown[disabled] {\n opacity: unset;\n color: unset;\n}\n\n.rdp-dropdown:focus-visible:not([disabled]) + .rdp-caption_label {\n background-color: var(--rdp-background-color);\n border: var(--rdp-outline);\n border-radius: 6px;\n}\n\n.rdp-dropdown_icon {\n margin: 0 0 0 5px;\n}\n\n.rdp-head {\n border: 0;\n}\n\n.rdp-head_row,\n.rdp-row {\n height: 100%;\n}\n\n.rdp-head_cell {\n vertical-align: middle;\n font-size: 0.75em;\n font-weight: 700;\n text-align: center;\n height: 100%;\n height: var(--rdp-cell-size);\n padding: 0;\n text-transform: uppercase;\n}\n\n.rdp-tbody {\n border: 0;\n}\n\n.rdp-tfoot {\n margin: 0.5em;\n}\n\n.rdp-cell {\n width: var(--rdp-cell-size);\n height: 100%;\n height: var(--rdp-cell-size);\n padding: 0;\n text-align: center;\n}\n\n.rdp-weeknumber {\n font-size: 0.75em;\n}\n\n.rdp-weeknumber,\n.rdp-day {\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: var(--rdp-cell-size);\n max-width: var(--rdp-cell-size);\n height: var(--rdp-cell-size);\n margin: 0;\n border: 2px solid transparent;\n border-radius: 100%;\n}\n\n.rdp-day_today:not(.rdp-day_outside) {\n font-weight: bold;\n}\n\n.rdp-day_selected,\n.rdp-day_selected:focus-visible,\n.rdp-day_selected:hover {\n color: white;\n opacity: 1;\n background-color: var(--rdp-accent-color);\n}\n\n.rdp-day_outside {\n opacity: 0.5;\n}\n\n.rdp-day_selected:focus-visible {\n /* Since the background is the same use again the outline */\n outline: var(--rdp-outline);\n outline-offset: 2px;\n z-index: 1;\n}\n\n.rdp:not([dir='rtl']) .rdp-day_range_start:not(.rdp-day_range_end) {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n.rdp:not([dir='rtl']) .rdp-day_range_end:not(.rdp-day_range_start) {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n\n.rdp[dir='rtl'] .rdp-day_range_start:not(.rdp-day_range_end) {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n\n.rdp[dir='rtl'] .rdp-day_range_end:not(.rdp-day_range_start) {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n.rdp-day_range_end.rdp-day_range_start {\n border-radius: 100%;\n}\n\n.rdp-day_range_middle {\n border-radius: 0;\n}";
5710
- styleInject(css_248z$4);
5968
+ var css_248z$5 = ".rdp {\n --rdp-cell-size: 40px;\n --rdp-caption-font-size: 18px;\n --rdp-accent-color: #0000ff;\n --rdp-background-color: #e7edff;\n --rdp-accent-color-dark: #3003e1;\n --rdp-background-color-dark: #180270;\n --rdp-outline: 2px solid var(--rdp-accent-color); /* Outline border for focused elements */\n --rdp-outline-selected: 3px solid var(--rdp-accent-color); /* Outline border for focused _and_ selected elements */\n\n margin: 1em;\n}\n\n/* Hide elements for devices that are not screen readers */\n.rdp-vhidden {\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n background: transparent;\n border: 0;\n -moz-appearance: none;\n -webkit-appearance: none;\n appearance: none;\n position: absolute !important;\n top: 0;\n width: 1px !important;\n height: 1px !important;\n padding: 0 !important;\n overflow: hidden !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n border: 0 !important;\n}\n\n/* Buttons */\n.rdp-button_reset {\n appearance: none;\n position: relative;\n margin: 0;\n padding: 0;\n cursor: default;\n color: inherit;\n background: none;\n font: inherit;\n\n -moz-appearance: none;\n -webkit-appearance: none;\n}\n\n.rdp-button_reset:focus-visible {\n /* Make sure to reset outline only when :focus-visible is supported */\n outline: none;\n}\n\n.rdp-button {\n border: 2px solid transparent;\n}\n\n.rdp-button[disabled]:not(.rdp-day_selected) {\n opacity: 0.25;\n}\n\n.rdp-button:not([disabled]) {\n cursor: pointer;\n}\n\n.rdp-button:focus-visible:not([disabled]) {\n color: inherit;\n background-color: var(--rdp-background-color);\n border: var(--rdp-outline);\n}\n\n.rdp-button:hover:not([disabled]):not(.rdp-day_selected) {\n background-color: var(--rdp-background-color);\n}\n\n.rdp-months {\n display: flex;\n}\n\n.rdp-month {\n margin: 0 1em;\n}\n\n.rdp-month:first-child {\n margin-left: 0;\n}\n\n.rdp-month:last-child {\n margin-right: 0;\n}\n\n.rdp-table {\n margin: 0;\n max-width: calc(var(--rdp-cell-size) * 7);\n border-collapse: collapse;\n}\n\n.rdp-with_weeknumber .rdp-table {\n max-width: calc(var(--rdp-cell-size) * 8);\n border-collapse: collapse;\n}\n\n.rdp-caption {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0;\n text-align: left;\n}\n\n.rdp-multiple_months .rdp-caption {\n position: relative;\n display: block;\n text-align: center;\n}\n\n.rdp-caption_dropdowns {\n position: relative;\n display: inline-flex;\n}\n\n.rdp-caption_label {\n position: relative;\n z-index: 1;\n display: inline-flex;\n align-items: center;\n margin: 0;\n padding: 0 0.25em;\n white-space: nowrap;\n color: currentColor;\n border: 0;\n border: 2px solid transparent;\n font-family: inherit;\n font-size: var(--rdp-caption-font-size);\n font-weight: bold;\n}\n\n.rdp-nav {\n white-space: nowrap;\n}\n\n.rdp-multiple_months .rdp-caption_start .rdp-nav {\n position: absolute;\n top: 50%;\n left: 0;\n transform: translateY(-50%);\n}\n\n.rdp-multiple_months .rdp-caption_end .rdp-nav {\n position: absolute;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n}\n\n.rdp-nav_button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--rdp-cell-size);\n height: var(--rdp-cell-size);\n padding: 0.25em;\n border-radius: 100%;\n}\n\n/* ---------- */\n/* Dropdowns */\n/* ---------- */\n\n.rdp-dropdown_year,\n.rdp-dropdown_month {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n\n.rdp-dropdown {\n appearance: none;\n position: absolute;\n z-index: 2;\n top: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n margin: 0;\n padding: 0;\n cursor: inherit;\n opacity: 0;\n border: none;\n background-color: transparent;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n}\n\n.rdp-dropdown[disabled] {\n opacity: unset;\n color: unset;\n}\n\n.rdp-dropdown:focus-visible:not([disabled]) + .rdp-caption_label {\n background-color: var(--rdp-background-color);\n border: var(--rdp-outline);\n border-radius: 6px;\n}\n\n.rdp-dropdown_icon {\n margin: 0 0 0 5px;\n}\n\n.rdp-head {\n border: 0;\n}\n\n.rdp-head_row,\n.rdp-row {\n height: 100%;\n}\n\n.rdp-head_cell {\n vertical-align: middle;\n font-size: 0.75em;\n font-weight: 700;\n text-align: center;\n height: 100%;\n height: var(--rdp-cell-size);\n padding: 0;\n text-transform: uppercase;\n}\n\n.rdp-tbody {\n border: 0;\n}\n\n.rdp-tfoot {\n margin: 0.5em;\n}\n\n.rdp-cell {\n width: var(--rdp-cell-size);\n height: 100%;\n height: var(--rdp-cell-size);\n padding: 0;\n text-align: center;\n}\n\n.rdp-weeknumber {\n font-size: 0.75em;\n}\n\n.rdp-weeknumber,\n.rdp-day {\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: var(--rdp-cell-size);\n max-width: var(--rdp-cell-size);\n height: var(--rdp-cell-size);\n margin: 0;\n border: 2px solid transparent;\n border-radius: 100%;\n}\n\n.rdp-day_today:not(.rdp-day_outside) {\n font-weight: bold;\n}\n\n.rdp-day_selected,\n.rdp-day_selected:focus-visible,\n.rdp-day_selected:hover {\n color: white;\n opacity: 1;\n background-color: var(--rdp-accent-color);\n}\n\n.rdp-day_outside {\n opacity: 0.5;\n}\n\n.rdp-day_selected:focus-visible {\n /* Since the background is the same use again the outline */\n outline: var(--rdp-outline);\n outline-offset: 2px;\n z-index: 1;\n}\n\n.rdp:not([dir='rtl']) .rdp-day_range_start:not(.rdp-day_range_end) {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n.rdp:not([dir='rtl']) .rdp-day_range_end:not(.rdp-day_range_start) {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n\n.rdp[dir='rtl'] .rdp-day_range_start:not(.rdp-day_range_end) {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n\n.rdp[dir='rtl'] .rdp-day_range_end:not(.rdp-day_range_start) {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n\n.rdp-day_range_end.rdp-day_range_start {\n border-radius: 100%;\n}\n\n.rdp-day_range_middle {\n border-radius: 0;\n}";
5969
+ styleInject(css_248z$5);
5711
5970
 
5712
- var css_248z$3 = ".filter-bar-calendar {\n display: flex;\n justify-content: center;\n}";
5713
- styleInject(css_248z$3);
5971
+ var css_248z$4 = ".filter-bar-calendar {\n display: flex;\n justify-content: center;\n}";
5972
+ styleInject(css_248z$4);
5714
5973
 
5715
5974
  var currentMonth = new Date();
5716
5975
  function Calendar(_a) {
@@ -5727,34 +5986,36 @@
5727
5986
  React__default.createElement(DayPicker, { id: "test", mode: "range", numberOfMonths: 2, defaultMonth: currentMonth, selected: calendarRange, onSelect: setCalendarRange })));
5728
5987
  }
5729
5988
 
5730
- var css_248z$2 = ".filter-bar-guests {\n text-align: initial;\n}\n\n.guests-filter-container {\n display: flex;\n margin-top: 30px;\n}\n\n.guests-filter-inner {\n display: flex;\n align-items: center;\n}\n\n.guests-filter-inner:not(:last-child) {\n margin-right: 50px;\n}\n\n.guests-filter-inner > span {\n display: block;\n margin-right: 20px;\n font-weight: bold;\n}\n\n.guests-filter-inner > div {\n display: flex;\n align-items: center;\n}\n\n.guests-filter-inner > div > span {\n margin: 0 10px;\n}\n\n.guests-filter-inner > div button {\n border-radius: 50%;\n border: none;\n background-color: #CDEEFF;\n width: 25px;\n height: 25px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 20px;\n}";
5731
- styleInject(css_248z$2);
5989
+ var css_248z$3 = ".filter-bar-guests {\n text-align: initial;\n}\n\n.guests-filter-container {\n display: flex;\n margin-top: 30px;\n}\n\n.guests-filter-inner {\n display: flex;\n align-items: center;\n}\n\n.guests-filter-inner:not(:last-child) {\n margin-right: 50px;\n}\n\n.guests-filter-inner > span {\n display: block;\n margin-right: 20px;\n font-weight: bold;\n}\n\n.guests-filter-inner > div {\n display: flex;\n align-items: center;\n}\n\n.guests-filter-inner > div > span {\n margin: 0 10px;\n}\n\n.guests-filter-inner > div button {\n border-radius: 50%;\n border: none;\n background-color: #CDEEFF;\n width: 25px;\n height: 25px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 20px;\n}";
5990
+ styleInject(css_248z$3);
5732
5991
 
5733
5992
  function Guests(_a) {
5734
5993
  var guestsAdults = _a.guestsAdults, guestsKids = _a.guestsKids, decrementAdults = _a.decrementAdults, incrementAdults = _a.incrementAdults, decrementKids = _a.decrementKids, incrementKids = _a.incrementKids;
5994
+ var t = useTranslation('filterBar').t;
5735
5995
  return (React__default.createElement("div", { className: "filter-bar-guests" },
5736
- React__default.createElement("h3", null, "Guests"),
5737
- React__default.createElement("p", null, "Who's coming?"),
5996
+ React__default.createElement("h3", null, t('guests.title')),
5997
+ React__default.createElement("p", null, t('guests.subtitle')),
5738
5998
  React__default.createElement("div", { className: "guests-filter-container" },
5739
5999
  React__default.createElement("div", { className: "guests-filter-inner" },
5740
- React__default.createElement("span", null, "Adults"),
6000
+ React__default.createElement("span", null, t('guests.adultsLabel')),
5741
6001
  React__default.createElement("div", null,
5742
6002
  React__default.createElement("button", { onClick: decrementAdults, disabled: guestsAdults < 1 }, "-"),
5743
6003
  React__default.createElement("span", null, guestsAdults),
5744
6004
  React__default.createElement("button", { onClick: incrementAdults }, "+"))),
5745
6005
  React__default.createElement("div", { className: "guests-filter-inner" },
5746
- React__default.createElement("span", null, "Kids"),
6006
+ React__default.createElement("span", null, t('guests.kidsLabel')),
5747
6007
  React__default.createElement("div", null,
5748
6008
  React__default.createElement("button", { onClick: decrementKids, disabled: guestsKids < 1 }, "-"),
5749
6009
  React__default.createElement("span", null, guestsKids),
5750
6010
  React__default.createElement("button", { onClick: incrementKids }, "+"))))));
5751
6011
  }
5752
6012
 
5753
- var css_248z$1 = ".filter-bar-categories {\n text-align: center;\n}\n\n.categories-filter-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 20px;\n}\n\n.categories-filter-inner input {\n cursor: pointer;\n margin-right: 10px;\n}\n";
5754
- styleInject(css_248z$1);
6013
+ var css_248z$2 = ".filter-bar-categories {\n text-align: center;\n}\n\n.categories-filter-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 20px;\n}\n\n.categories-filter-inner input {\n cursor: pointer;\n margin-right: 10px;\n}\n";
6014
+ styleInject(css_248z$2);
5755
6015
 
5756
6016
  function Categories(_a) {
5757
6017
  _a.categories; var setCategories = _a.setCategories;
6018
+ var t = useTranslation('filterBar').t;
5758
6019
  var categoriesPlaceholder = [
5759
6020
  'Weekend',
5760
6021
  'Week',
@@ -5767,7 +6028,7 @@
5767
6028
  setCategories(selectedCategory);
5768
6029
  };
5769
6030
  return (React__default.createElement("div", { className: "filter-bar-categories" },
5770
- React__default.createElement("h3", null, "CATEGORY"),
6031
+ React__default.createElement("h3", null, t('categories.label')),
5771
6032
  React__default.createElement("div", { className: "categories-filter-inner" }, categoriesPlaceholder.map(function (itm, idx) { return (React__default.createElement("div", { key: idx },
5772
6033
  React__default.createElement("input", { type: "radio", value: itm, checked: selectedCategory === itm, onChange: function () { return handleCategoryChange(itm); } }),
5773
6034
  React__default.createElement("span", null, itm))); }))));
@@ -5819,20 +6080,2355 @@
5819
6080
  };
5820
6081
  }
5821
6082
 
5822
- var css_248z = ".filter-bar {\r\n box-sizing: border-box;\r\n max-width: 1100px;\r\n position: relative;\r\n}\r\n\r\n.filter-bar-header {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n padding: 10px 20px;\r\n position: relative;\r\n z-index: 222;\r\n \r\n border-radius: 40px;\r\n background-color: #fff;\r\n box-shadow: 0px 6px 11px 0px #a7a4a480;\r\n}\r\n\r\n.filter-bar-container {\r\n background-color: #fff;\r\n min-height: 100px;\r\n \r\n padding: 90px 40px 30px 40px;\r\n position: absolute;\r\n top: 0;\r\n z-index: 111;\r\n border-radius: 40px;\r\n width: -webkit-fill-available;\r\n box-shadow: 0px 6px 11px 0px #a7a4a480;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
6083
+ var css_248z$1 = ".filter-bar {\r\n box-sizing: border-box;\r\n max-width: 1100px;\r\n position: relative;\r\n}\r\n\r\n.filter-bar-header {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n padding: 10px 20px;\r\n position: relative;\r\n z-index: 222;\r\n \r\n border-radius: 40px;\r\n background-color: #fff;\r\n box-shadow: 0px 6px 11px 0px #a7a4a480;\r\n}\r\n\r\n.filter-bar-container {\r\n background-color: #fff;\r\n min-height: 100px;\r\n \r\n padding: 90px 40px 30px 40px;\r\n position: absolute;\r\n top: 0;\r\n z-index: 111;\r\n border-radius: 40px;\r\n width: -webkit-fill-available;\r\n box-shadow: var(--box-shadow);\r\n}";
6084
+ styleInject(css_248z$1);
6085
+
6086
+ var css_248z = ":root {\n --primary-color: #3498db;\n --font-size: 16px;\n --box-shadow: 0px 6px 11px 0px #a7a4a480\n}\n\n* {\n box-sizing: border-box;\n}\n\nhtml {\n background-color: aqua;\n}";
5823
6087
  styleInject(css_248z);
5824
6088
 
5825
- function FilterBar() {
5826
- var _a = useFilterBar(), selectedFilter = _a.selectedFilter, guestsAdults = _a.guestsAdults, guestsKids = _a.guestsKids, categories = _a.categories, calendarRange = _a.calendarRange, setCalendarRange = _a.setCalendarRange, setGuestsAdults = _a.setGuestsAdults, setGuestsKids = _a.setGuestsKids, setCategories = _a.setCategories, handleSelectedFilter = _a.handleSelectedFilter, handleSubmit = _a.handleSubmit;
6089
+ const consoleLogger = {
6090
+ type: 'logger',
6091
+ log(args) {
6092
+ this.output('log', args);
6093
+ },
6094
+ warn(args) {
6095
+ this.output('warn', args);
6096
+ },
6097
+ error(args) {
6098
+ this.output('error', args);
6099
+ },
6100
+ output(type, args) {
6101
+ if (console && console[type]) console[type].apply(console, args);
6102
+ }
6103
+ };
6104
+ class Logger {
6105
+ constructor(concreteLogger) {
6106
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6107
+ this.init(concreteLogger, options);
6108
+ }
6109
+ init(concreteLogger) {
6110
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6111
+ this.prefix = options.prefix || 'i18next:';
6112
+ this.logger = concreteLogger || consoleLogger;
6113
+ this.options = options;
6114
+ this.debug = options.debug;
6115
+ }
6116
+ log() {
6117
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6118
+ args[_key] = arguments[_key];
6119
+ }
6120
+ return this.forward(args, 'log', '', true);
6121
+ }
6122
+ warn() {
6123
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6124
+ args[_key2] = arguments[_key2];
6125
+ }
6126
+ return this.forward(args, 'warn', '', true);
6127
+ }
6128
+ error() {
6129
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
6130
+ args[_key3] = arguments[_key3];
6131
+ }
6132
+ return this.forward(args, 'error', '');
6133
+ }
6134
+ deprecate() {
6135
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
6136
+ args[_key4] = arguments[_key4];
6137
+ }
6138
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
6139
+ }
6140
+ forward(args, lvl, prefix, debugOnly) {
6141
+ if (debugOnly && !this.debug) return null;
6142
+ if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;
6143
+ return this.logger[lvl](args);
6144
+ }
6145
+ create(moduleName) {
6146
+ return new Logger(this.logger, {
6147
+ ...{
6148
+ prefix: `${this.prefix}:${moduleName}:`
6149
+ },
6150
+ ...this.options
6151
+ });
6152
+ }
6153
+ clone(options) {
6154
+ options = options || this.options;
6155
+ options.prefix = options.prefix || this.prefix;
6156
+ return new Logger(this.logger, options);
6157
+ }
6158
+ }
6159
+ var baseLogger = new Logger();
6160
+
6161
+ class EventEmitter {
6162
+ constructor() {
6163
+ this.observers = {};
6164
+ }
6165
+ on(events, listener) {
6166
+ events.split(' ').forEach(event => {
6167
+ this.observers[event] = this.observers[event] || [];
6168
+ this.observers[event].push(listener);
6169
+ });
6170
+ return this;
6171
+ }
6172
+ off(event, listener) {
6173
+ if (!this.observers[event]) return;
6174
+ if (!listener) {
6175
+ delete this.observers[event];
6176
+ return;
6177
+ }
6178
+ this.observers[event] = this.observers[event].filter(l => l !== listener);
6179
+ }
6180
+ emit(event) {
6181
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
6182
+ args[_key - 1] = arguments[_key];
6183
+ }
6184
+ if (this.observers[event]) {
6185
+ const cloned = [].concat(this.observers[event]);
6186
+ cloned.forEach(observer => {
6187
+ observer(...args);
6188
+ });
6189
+ }
6190
+ if (this.observers['*']) {
6191
+ const cloned = [].concat(this.observers['*']);
6192
+ cloned.forEach(observer => {
6193
+ observer.apply(observer, [event, ...args]);
6194
+ });
6195
+ }
6196
+ }
6197
+ }
6198
+
6199
+ function defer() {
6200
+ let res;
6201
+ let rej;
6202
+ const promise = new Promise((resolve, reject) => {
6203
+ res = resolve;
6204
+ rej = reject;
6205
+ });
6206
+ promise.resolve = res;
6207
+ promise.reject = rej;
6208
+ return promise;
6209
+ }
6210
+ function makeString(object) {
6211
+ if (object == null) return '';
6212
+ return '' + object;
6213
+ }
6214
+ function copy(a, s, t) {
6215
+ a.forEach(m => {
6216
+ if (s[m]) t[m] = s[m];
6217
+ });
6218
+ }
6219
+ function getLastOfPath(object, path, Empty) {
6220
+ function cleanKey(key) {
6221
+ return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
6222
+ }
6223
+ function canNotTraverseDeeper() {
6224
+ return !object || typeof object === 'string';
6225
+ }
6226
+ const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
6227
+ while (stack.length > 1) {
6228
+ if (canNotTraverseDeeper()) return {};
6229
+ const key = cleanKey(stack.shift());
6230
+ if (!object[key] && Empty) object[key] = new Empty();
6231
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
6232
+ object = object[key];
6233
+ } else {
6234
+ object = {};
6235
+ }
6236
+ }
6237
+ if (canNotTraverseDeeper()) return {};
6238
+ return {
6239
+ obj: object,
6240
+ k: cleanKey(stack.shift())
6241
+ };
6242
+ }
6243
+ function setPath(object, path, newValue) {
6244
+ const {
6245
+ obj,
6246
+ k
6247
+ } = getLastOfPath(object, path, Object);
6248
+ obj[k] = newValue;
6249
+ }
6250
+ function pushPath(object, path, newValue, concat) {
6251
+ const {
6252
+ obj,
6253
+ k
6254
+ } = getLastOfPath(object, path, Object);
6255
+ obj[k] = obj[k] || [];
6256
+ if (concat) obj[k] = obj[k].concat(newValue);
6257
+ if (!concat) obj[k].push(newValue);
6258
+ }
6259
+ function getPath(object, path) {
6260
+ const {
6261
+ obj,
6262
+ k
6263
+ } = getLastOfPath(object, path);
6264
+ if (!obj) return undefined;
6265
+ return obj[k];
6266
+ }
6267
+ function getPathWithDefaults(data, defaultData, key) {
6268
+ const value = getPath(data, key);
6269
+ if (value !== undefined) {
6270
+ return value;
6271
+ }
6272
+ return getPath(defaultData, key);
6273
+ }
6274
+ function deepExtend(target, source, overwrite) {
6275
+ for (const prop in source) {
6276
+ if (prop !== '__proto__' && prop !== 'constructor') {
6277
+ if (prop in target) {
6278
+ if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
6279
+ if (overwrite) target[prop] = source[prop];
6280
+ } else {
6281
+ deepExtend(target[prop], source[prop], overwrite);
6282
+ }
6283
+ } else {
6284
+ target[prop] = source[prop];
6285
+ }
6286
+ }
6287
+ }
6288
+ return target;
6289
+ }
6290
+ function regexEscape(str) {
6291
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
6292
+ }
6293
+ var _entityMap = {
6294
+ '&': '&amp;',
6295
+ '<': '&lt;',
6296
+ '>': '&gt;',
6297
+ '"': '&quot;',
6298
+ "'": '&#39;',
6299
+ '/': '&#x2F;'
6300
+ };
6301
+ function escape(data) {
6302
+ if (typeof data === 'string') {
6303
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
6304
+ }
6305
+ return data;
6306
+ }
6307
+ const chars = [' ', ',', '?', '!', ';'];
6308
+ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
6309
+ nsSeparator = nsSeparator || '';
6310
+ keySeparator = keySeparator || '';
6311
+ const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
6312
+ if (possibleChars.length === 0) return true;
6313
+ const r = new RegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
6314
+ let matched = !r.test(key);
6315
+ if (!matched) {
6316
+ const ki = key.indexOf(keySeparator);
6317
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
6318
+ matched = true;
6319
+ }
6320
+ }
6321
+ return matched;
6322
+ }
6323
+ function deepFind(obj, path) {
6324
+ let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
6325
+ if (!obj) return undefined;
6326
+ if (obj[path]) return obj[path];
6327
+ const paths = path.split(keySeparator);
6328
+ let current = obj;
6329
+ for (let i = 0; i < paths.length; ++i) {
6330
+ if (!current) return undefined;
6331
+ if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
6332
+ return undefined;
6333
+ }
6334
+ if (current[paths[i]] === undefined) {
6335
+ let j = 2;
6336
+ let p = paths.slice(i, i + j).join(keySeparator);
6337
+ let mix = current[p];
6338
+ while (mix === undefined && paths.length > i + j) {
6339
+ j++;
6340
+ p = paths.slice(i, i + j).join(keySeparator);
6341
+ mix = current[p];
6342
+ }
6343
+ if (mix === undefined) return undefined;
6344
+ if (mix === null) return null;
6345
+ if (path.endsWith(p)) {
6346
+ if (typeof mix === 'string') return mix;
6347
+ if (p && typeof mix[p] === 'string') return mix[p];
6348
+ }
6349
+ const joinedPath = paths.slice(i + j).join(keySeparator);
6350
+ if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
6351
+ return undefined;
6352
+ }
6353
+ current = current[paths[i]];
6354
+ }
6355
+ return current;
6356
+ }
6357
+ function getCleanedCode(code) {
6358
+ if (code && code.indexOf('_') > 0) return code.replace('_', '-');
6359
+ return code;
6360
+ }
6361
+
6362
+ class ResourceStore extends EventEmitter {
6363
+ constructor(data) {
6364
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
6365
+ ns: ['translation'],
6366
+ defaultNS: 'translation'
6367
+ };
6368
+ super();
6369
+ this.data = data || {};
6370
+ this.options = options;
6371
+ if (this.options.keySeparator === undefined) {
6372
+ this.options.keySeparator = '.';
6373
+ }
6374
+ if (this.options.ignoreJSONStructure === undefined) {
6375
+ this.options.ignoreJSONStructure = true;
6376
+ }
6377
+ }
6378
+ addNamespaces(ns) {
6379
+ if (this.options.ns.indexOf(ns) < 0) {
6380
+ this.options.ns.push(ns);
6381
+ }
6382
+ }
6383
+ removeNamespaces(ns) {
6384
+ const index = this.options.ns.indexOf(ns);
6385
+ if (index > -1) {
6386
+ this.options.ns.splice(index, 1);
6387
+ }
6388
+ }
6389
+ getResource(lng, ns, key) {
6390
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
6391
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
6392
+ const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
6393
+ let path = [lng, ns];
6394
+ if (key && typeof key !== 'string') path = path.concat(key);
6395
+ if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
6396
+ if (lng.indexOf('.') > -1) {
6397
+ path = lng.split('.');
6398
+ }
6399
+ const result = getPath(this.data, path);
6400
+ if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
6401
+ return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
6402
+ }
6403
+ addResource(lng, ns, key, value) {
6404
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
6405
+ silent: false
6406
+ };
6407
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
6408
+ let path = [lng, ns];
6409
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
6410
+ if (lng.indexOf('.') > -1) {
6411
+ path = lng.split('.');
6412
+ value = ns;
6413
+ ns = path[1];
6414
+ }
6415
+ this.addNamespaces(ns);
6416
+ setPath(this.data, path, value);
6417
+ if (!options.silent) this.emit('added', lng, ns, key, value);
6418
+ }
6419
+ addResources(lng, ns, resources) {
6420
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
6421
+ silent: false
6422
+ };
6423
+ for (const m in resources) {
6424
+ if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
6425
+ silent: true
6426
+ });
6427
+ }
6428
+ if (!options.silent) this.emit('added', lng, ns, resources);
6429
+ }
6430
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
6431
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
6432
+ silent: false
6433
+ };
6434
+ let path = [lng, ns];
6435
+ if (lng.indexOf('.') > -1) {
6436
+ path = lng.split('.');
6437
+ deep = resources;
6438
+ resources = ns;
6439
+ ns = path[1];
6440
+ }
6441
+ this.addNamespaces(ns);
6442
+ let pack = getPath(this.data, path) || {};
6443
+ if (deep) {
6444
+ deepExtend(pack, resources, overwrite);
6445
+ } else {
6446
+ pack = {
6447
+ ...pack,
6448
+ ...resources
6449
+ };
6450
+ }
6451
+ setPath(this.data, path, pack);
6452
+ if (!options.silent) this.emit('added', lng, ns, resources);
6453
+ }
6454
+ removeResourceBundle(lng, ns) {
6455
+ if (this.hasResourceBundle(lng, ns)) {
6456
+ delete this.data[lng][ns];
6457
+ }
6458
+ this.removeNamespaces(ns);
6459
+ this.emit('removed', lng, ns);
6460
+ }
6461
+ hasResourceBundle(lng, ns) {
6462
+ return this.getResource(lng, ns) !== undefined;
6463
+ }
6464
+ getResourceBundle(lng, ns) {
6465
+ if (!ns) ns = this.options.defaultNS;
6466
+ if (this.options.compatibilityAPI === 'v1') return {
6467
+ ...{},
6468
+ ...this.getResource(lng, ns)
6469
+ };
6470
+ return this.getResource(lng, ns);
6471
+ }
6472
+ getDataByLanguage(lng) {
6473
+ return this.data[lng];
6474
+ }
6475
+ hasLanguageSomeTranslations(lng) {
6476
+ const data = this.getDataByLanguage(lng);
6477
+ const n = data && Object.keys(data) || [];
6478
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
6479
+ }
6480
+ toJSON() {
6481
+ return this.data;
6482
+ }
6483
+ }
6484
+
6485
+ var postProcessor = {
6486
+ processors: {},
6487
+ addPostProcessor(module) {
6488
+ this.processors[module.name] = module;
6489
+ },
6490
+ handle(processors, value, key, options, translator) {
6491
+ processors.forEach(processor => {
6492
+ if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
6493
+ });
6494
+ return value;
6495
+ }
6496
+ };
6497
+
6498
+ const checkedLoadedFor = {};
6499
+ class Translator extends EventEmitter {
6500
+ constructor(services) {
6501
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6502
+ super();
6503
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
6504
+ this.options = options;
6505
+ if (this.options.keySeparator === undefined) {
6506
+ this.options.keySeparator = '.';
6507
+ }
6508
+ this.logger = baseLogger.create('translator');
6509
+ }
6510
+ changeLanguage(lng) {
6511
+ if (lng) this.language = lng;
6512
+ }
6513
+ exists(key) {
6514
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
6515
+ interpolation: {}
6516
+ };
6517
+ if (key === undefined || key === null) {
6518
+ return false;
6519
+ }
6520
+ const resolved = this.resolve(key, options);
6521
+ return resolved && resolved.res !== undefined;
6522
+ }
6523
+ extractFromKey(key, options) {
6524
+ let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
6525
+ if (nsSeparator === undefined) nsSeparator = ':';
6526
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
6527
+ let namespaces = options.ns || this.options.defaultNS || [];
6528
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
6529
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
6530
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
6531
+ const m = key.match(this.interpolator.nestingRegexp);
6532
+ if (m && m.length > 0) {
6533
+ return {
6534
+ key,
6535
+ namespaces
6536
+ };
6537
+ }
6538
+ const parts = key.split(nsSeparator);
6539
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
6540
+ key = parts.join(keySeparator);
6541
+ }
6542
+ if (typeof namespaces === 'string') namespaces = [namespaces];
6543
+ return {
6544
+ key,
6545
+ namespaces
6546
+ };
6547
+ }
6548
+ translate(keys, options, lastKey) {
6549
+ if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
6550
+ options = this.options.overloadTranslationOptionHandler(arguments);
6551
+ }
6552
+ if (typeof options === 'object') options = {
6553
+ ...options
6554
+ };
6555
+ if (!options) options = {};
6556
+ if (keys === undefined || keys === null) return '';
6557
+ if (!Array.isArray(keys)) keys = [String(keys)];
6558
+ const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
6559
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
6560
+ const {
6561
+ key,
6562
+ namespaces
6563
+ } = this.extractFromKey(keys[keys.length - 1], options);
6564
+ const namespace = namespaces[namespaces.length - 1];
6565
+ const lng = options.lng || this.language;
6566
+ const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
6567
+ if (lng && lng.toLowerCase() === 'cimode') {
6568
+ if (appendNamespaceToCIMode) {
6569
+ const nsSeparator = options.nsSeparator || this.options.nsSeparator;
6570
+ if (returnDetails) {
6571
+ return {
6572
+ res: `${namespace}${nsSeparator}${key}`,
6573
+ usedKey: key,
6574
+ exactUsedKey: key,
6575
+ usedLng: lng,
6576
+ usedNS: namespace
6577
+ };
6578
+ }
6579
+ return `${namespace}${nsSeparator}${key}`;
6580
+ }
6581
+ if (returnDetails) {
6582
+ return {
6583
+ res: key,
6584
+ usedKey: key,
6585
+ exactUsedKey: key,
6586
+ usedLng: lng,
6587
+ usedNS: namespace
6588
+ };
6589
+ }
6590
+ return key;
6591
+ }
6592
+ const resolved = this.resolve(keys, options);
6593
+ let res = resolved && resolved.res;
6594
+ const resUsedKey = resolved && resolved.usedKey || key;
6595
+ const resExactUsedKey = resolved && resolved.exactUsedKey || key;
6596
+ const resType = Object.prototype.toString.apply(res);
6597
+ const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
6598
+ const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
6599
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
6600
+ const handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
6601
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
6602
+ if (!options.returnObjects && !this.options.returnObjects) {
6603
+ if (!this.options.returnedObjectHandler) {
6604
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
6605
+ }
6606
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
6607
+ ...options,
6608
+ ns: namespaces
6609
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
6610
+ if (returnDetails) {
6611
+ resolved.res = r;
6612
+ return resolved;
6613
+ }
6614
+ return r;
6615
+ }
6616
+ if (keySeparator) {
6617
+ const resTypeIsArray = resType === '[object Array]';
6618
+ const copy = resTypeIsArray ? [] : {};
6619
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
6620
+ for (const m in res) {
6621
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
6622
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
6623
+ copy[m] = this.translate(deepKey, {
6624
+ ...options,
6625
+ ...{
6626
+ joinArrays: false,
6627
+ ns: namespaces
6628
+ }
6629
+ });
6630
+ if (copy[m] === deepKey) copy[m] = res[m];
6631
+ }
6632
+ }
6633
+ res = copy;
6634
+ }
6635
+ } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
6636
+ res = res.join(joinArrays);
6637
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
6638
+ } else {
6639
+ let usedDefault = false;
6640
+ let usedKey = false;
6641
+ const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
6642
+ const hasDefaultValue = Translator.hasDefaultValue(options);
6643
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
6644
+ const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
6645
+ ordinal: false
6646
+ }) : '';
6647
+ const defaultValue = options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
6648
+ if (!this.isValidLookup(res) && hasDefaultValue) {
6649
+ usedDefault = true;
6650
+ res = defaultValue;
6651
+ }
6652
+ if (!this.isValidLookup(res)) {
6653
+ usedKey = true;
6654
+ res = key;
6655
+ }
6656
+ const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
6657
+ const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
6658
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
6659
+ if (usedKey || usedDefault || updateMissing) {
6660
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
6661
+ if (keySeparator) {
6662
+ const fk = this.resolve(key, {
6663
+ ...options,
6664
+ keySeparator: false
6665
+ });
6666
+ if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
6667
+ }
6668
+ let lngs = [];
6669
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
6670
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
6671
+ for (let i = 0; i < fallbackLngs.length; i++) {
6672
+ lngs.push(fallbackLngs[i]);
6673
+ }
6674
+ } else if (this.options.saveMissingTo === 'all') {
6675
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
6676
+ } else {
6677
+ lngs.push(options.lng || this.language);
6678
+ }
6679
+ const send = (l, k, specificDefaultValue) => {
6680
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
6681
+ if (this.options.missingKeyHandler) {
6682
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
6683
+ } else if (this.backendConnector && this.backendConnector.saveMissing) {
6684
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
6685
+ }
6686
+ this.emit('missingKey', l, namespace, k, res);
6687
+ };
6688
+ if (this.options.saveMissing) {
6689
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
6690
+ lngs.forEach(language => {
6691
+ this.pluralResolver.getSuffixes(language, options).forEach(suffix => {
6692
+ send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
6693
+ });
6694
+ });
6695
+ } else {
6696
+ send(lngs, key, defaultValue);
6697
+ }
6698
+ }
6699
+ }
6700
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
6701
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
6702
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
6703
+ if (this.options.compatibilityAPI !== 'v1') {
6704
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
6705
+ } else {
6706
+ res = this.options.parseMissingKeyHandler(res);
6707
+ }
6708
+ }
6709
+ }
6710
+ if (returnDetails) {
6711
+ resolved.res = res;
6712
+ return resolved;
6713
+ }
6714
+ return res;
6715
+ }
6716
+ extendTranslation(res, key, options, resolved, lastKey) {
6717
+ var _this = this;
6718
+ if (this.i18nFormat && this.i18nFormat.parse) {
6719
+ res = this.i18nFormat.parse(res, {
6720
+ ...this.options.interpolation.defaultVariables,
6721
+ ...options
6722
+ }, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
6723
+ resolved
6724
+ });
6725
+ } else if (!options.skipInterpolation) {
6726
+ if (options.interpolation) this.interpolator.init({
6727
+ ...options,
6728
+ ...{
6729
+ interpolation: {
6730
+ ...this.options.interpolation,
6731
+ ...options.interpolation
6732
+ }
6733
+ }
6734
+ });
6735
+ const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
6736
+ let nestBef;
6737
+ if (skipOnVariables) {
6738
+ const nb = res.match(this.interpolator.nestingRegexp);
6739
+ nestBef = nb && nb.length;
6740
+ }
6741
+ let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
6742
+ if (this.options.interpolation.defaultVariables) data = {
6743
+ ...this.options.interpolation.defaultVariables,
6744
+ ...data
6745
+ };
6746
+ res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
6747
+ if (skipOnVariables) {
6748
+ const na = res.match(this.interpolator.nestingRegexp);
6749
+ const nestAft = na && na.length;
6750
+ if (nestBef < nestAft) options.nest = false;
6751
+ }
6752
+ if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
6753
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
6754
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6755
+ args[_key] = arguments[_key];
6756
+ }
6757
+ if (lastKey && lastKey[0] === args[0] && !options.context) {
6758
+ _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
6759
+ return null;
6760
+ }
6761
+ return _this.translate(...args, key);
6762
+ }, options);
6763
+ if (options.interpolation) this.interpolator.reset();
6764
+ }
6765
+ const postProcess = options.postProcess || this.options.postProcess;
6766
+ const postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
6767
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
6768
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
6769
+ i18nResolved: resolved,
6770
+ ...options
6771
+ } : options, this);
6772
+ }
6773
+ return res;
6774
+ }
6775
+ resolve(keys) {
6776
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6777
+ let found;
6778
+ let usedKey;
6779
+ let exactUsedKey;
6780
+ let usedLng;
6781
+ let usedNS;
6782
+ if (typeof keys === 'string') keys = [keys];
6783
+ keys.forEach(k => {
6784
+ if (this.isValidLookup(found)) return;
6785
+ const extracted = this.extractFromKey(k, options);
6786
+ const key = extracted.key;
6787
+ usedKey = key;
6788
+ let namespaces = extracted.namespaces;
6789
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
6790
+ const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
6791
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
6792
+ const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
6793
+ const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
6794
+ namespaces.forEach(ns => {
6795
+ if (this.isValidLookup(found)) return;
6796
+ usedNS = ns;
6797
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
6798
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
6799
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
6800
+ }
6801
+ codes.forEach(code => {
6802
+ if (this.isValidLookup(found)) return;
6803
+ usedLng = code;
6804
+ const finalKeys = [key];
6805
+ if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
6806
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
6807
+ } else {
6808
+ let pluralSuffix;
6809
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
6810
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
6811
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
6812
+ if (needsPluralHandling) {
6813
+ finalKeys.push(key + pluralSuffix);
6814
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
6815
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
6816
+ }
6817
+ if (needsZeroSuffixLookup) {
6818
+ finalKeys.push(key + zeroSuffix);
6819
+ }
6820
+ }
6821
+ if (needsContextHandling) {
6822
+ const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
6823
+ finalKeys.push(contextKey);
6824
+ if (needsPluralHandling) {
6825
+ finalKeys.push(contextKey + pluralSuffix);
6826
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
6827
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
6828
+ }
6829
+ if (needsZeroSuffixLookup) {
6830
+ finalKeys.push(contextKey + zeroSuffix);
6831
+ }
6832
+ }
6833
+ }
6834
+ }
6835
+ let possibleKey;
6836
+ while (possibleKey = finalKeys.pop()) {
6837
+ if (!this.isValidLookup(found)) {
6838
+ exactUsedKey = possibleKey;
6839
+ found = this.getResource(code, ns, possibleKey, options);
6840
+ }
6841
+ }
6842
+ });
6843
+ });
6844
+ });
6845
+ return {
6846
+ res: found,
6847
+ usedKey,
6848
+ exactUsedKey,
6849
+ usedLng,
6850
+ usedNS
6851
+ };
6852
+ }
6853
+ isValidLookup(res) {
6854
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
6855
+ }
6856
+ getResource(code, ns, key) {
6857
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
6858
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
6859
+ return this.resourceStore.getResource(code, ns, key, options);
6860
+ }
6861
+ static hasDefaultValue(options) {
6862
+ const prefix = 'defaultValue';
6863
+ for (const option in options) {
6864
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
6865
+ return true;
6866
+ }
6867
+ }
6868
+ return false;
6869
+ }
6870
+ }
6871
+
6872
+ function capitalize(string) {
6873
+ return string.charAt(0).toUpperCase() + string.slice(1);
6874
+ }
6875
+ class LanguageUtil {
6876
+ constructor(options) {
6877
+ this.options = options;
6878
+ this.supportedLngs = this.options.supportedLngs || false;
6879
+ this.logger = baseLogger.create('languageUtils');
6880
+ }
6881
+ getScriptPartFromCode(code) {
6882
+ code = getCleanedCode(code);
6883
+ if (!code || code.indexOf('-') < 0) return null;
6884
+ const p = code.split('-');
6885
+ if (p.length === 2) return null;
6886
+ p.pop();
6887
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
6888
+ return this.formatLanguageCode(p.join('-'));
6889
+ }
6890
+ getLanguagePartFromCode(code) {
6891
+ code = getCleanedCode(code);
6892
+ if (!code || code.indexOf('-') < 0) return code;
6893
+ const p = code.split('-');
6894
+ return this.formatLanguageCode(p[0]);
6895
+ }
6896
+ formatLanguageCode(code) {
6897
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
6898
+ const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
6899
+ let p = code.split('-');
6900
+ if (this.options.lowerCaseLng) {
6901
+ p = p.map(part => part.toLowerCase());
6902
+ } else if (p.length === 2) {
6903
+ p[0] = p[0].toLowerCase();
6904
+ p[1] = p[1].toUpperCase();
6905
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
6906
+ } else if (p.length === 3) {
6907
+ p[0] = p[0].toLowerCase();
6908
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
6909
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
6910
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
6911
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
6912
+ }
6913
+ return p.join('-');
6914
+ }
6915
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
6916
+ }
6917
+ isSupportedCode(code) {
6918
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
6919
+ code = this.getLanguagePartFromCode(code);
6920
+ }
6921
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
6922
+ }
6923
+ getBestMatchFromCodes(codes) {
6924
+ if (!codes) return null;
6925
+ let found;
6926
+ codes.forEach(code => {
6927
+ if (found) return;
6928
+ const cleanedLng = this.formatLanguageCode(code);
6929
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
6930
+ });
6931
+ if (!found && this.options.supportedLngs) {
6932
+ codes.forEach(code => {
6933
+ if (found) return;
6934
+ const lngOnly = this.getLanguagePartFromCode(code);
6935
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
6936
+ found = this.options.supportedLngs.find(supportedLng => {
6937
+ if (supportedLng === lngOnly) return supportedLng;
6938
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
6939
+ if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
6940
+ });
6941
+ });
6942
+ }
6943
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
6944
+ return found;
6945
+ }
6946
+ getFallbackCodes(fallbacks, code) {
6947
+ if (!fallbacks) return [];
6948
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
6949
+ if (typeof fallbacks === 'string') fallbacks = [fallbacks];
6950
+ if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
6951
+ if (!code) return fallbacks.default || [];
6952
+ let found = fallbacks[code];
6953
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
6954
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
6955
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
6956
+ if (!found) found = fallbacks.default;
6957
+ return found || [];
6958
+ }
6959
+ toResolveHierarchy(code, fallbackCode) {
6960
+ const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
6961
+ const codes = [];
6962
+ const addCode = c => {
6963
+ if (!c) return;
6964
+ if (this.isSupportedCode(c)) {
6965
+ codes.push(c);
6966
+ } else {
6967
+ this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
6968
+ }
6969
+ };
6970
+ if (typeof code === 'string' && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
6971
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
6972
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
6973
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
6974
+ } else if (typeof code === 'string') {
6975
+ addCode(this.formatLanguageCode(code));
6976
+ }
6977
+ fallbackCodes.forEach(fc => {
6978
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
6979
+ });
6980
+ return codes;
6981
+ }
6982
+ }
6983
+
6984
+ let sets = [{
6985
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
6986
+ nr: [1, 2],
6987
+ fc: 1
6988
+ }, {
6989
+ lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
6990
+ nr: [1, 2],
6991
+ fc: 2
6992
+ }, {
6993
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
6994
+ nr: [1],
6995
+ fc: 3
6996
+ }, {
6997
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
6998
+ nr: [1, 2, 5],
6999
+ fc: 4
7000
+ }, {
7001
+ lngs: ['ar'],
7002
+ nr: [0, 1, 2, 3, 11, 100],
7003
+ fc: 5
7004
+ }, {
7005
+ lngs: ['cs', 'sk'],
7006
+ nr: [1, 2, 5],
7007
+ fc: 6
7008
+ }, {
7009
+ lngs: ['csb', 'pl'],
7010
+ nr: [1, 2, 5],
7011
+ fc: 7
7012
+ }, {
7013
+ lngs: ['cy'],
7014
+ nr: [1, 2, 3, 8],
7015
+ fc: 8
7016
+ }, {
7017
+ lngs: ['fr'],
7018
+ nr: [1, 2],
7019
+ fc: 9
7020
+ }, {
7021
+ lngs: ['ga'],
7022
+ nr: [1, 2, 3, 7, 11],
7023
+ fc: 10
7024
+ }, {
7025
+ lngs: ['gd'],
7026
+ nr: [1, 2, 3, 20],
7027
+ fc: 11
7028
+ }, {
7029
+ lngs: ['is'],
7030
+ nr: [1, 2],
7031
+ fc: 12
7032
+ }, {
7033
+ lngs: ['jv'],
7034
+ nr: [0, 1],
7035
+ fc: 13
7036
+ }, {
7037
+ lngs: ['kw'],
7038
+ nr: [1, 2, 3, 4],
7039
+ fc: 14
7040
+ }, {
7041
+ lngs: ['lt'],
7042
+ nr: [1, 2, 10],
7043
+ fc: 15
7044
+ }, {
7045
+ lngs: ['lv'],
7046
+ nr: [1, 2, 0],
7047
+ fc: 16
7048
+ }, {
7049
+ lngs: ['mk'],
7050
+ nr: [1, 2],
7051
+ fc: 17
7052
+ }, {
7053
+ lngs: ['mnk'],
7054
+ nr: [0, 1, 2],
7055
+ fc: 18
7056
+ }, {
7057
+ lngs: ['mt'],
7058
+ nr: [1, 2, 11, 20],
7059
+ fc: 19
7060
+ }, {
7061
+ lngs: ['or'],
7062
+ nr: [2, 1],
7063
+ fc: 2
7064
+ }, {
7065
+ lngs: ['ro'],
7066
+ nr: [1, 2, 20],
7067
+ fc: 20
7068
+ }, {
7069
+ lngs: ['sl'],
7070
+ nr: [5, 1, 2, 3],
7071
+ fc: 21
7072
+ }, {
7073
+ lngs: ['he', 'iw'],
7074
+ nr: [1, 2, 20, 21],
7075
+ fc: 22
7076
+ }];
7077
+ let _rulesPluralsTypes = {
7078
+ 1: function (n) {
7079
+ return Number(n > 1);
7080
+ },
7081
+ 2: function (n) {
7082
+ return Number(n != 1);
7083
+ },
7084
+ 3: function (n) {
7085
+ return 0;
7086
+ },
7087
+ 4: function (n) {
7088
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
7089
+ },
7090
+ 5: function (n) {
7091
+ return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
7092
+ },
7093
+ 6: function (n) {
7094
+ return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
7095
+ },
7096
+ 7: function (n) {
7097
+ return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
7098
+ },
7099
+ 8: function (n) {
7100
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
7101
+ },
7102
+ 9: function (n) {
7103
+ return Number(n >= 2);
7104
+ },
7105
+ 10: function (n) {
7106
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
7107
+ },
7108
+ 11: function (n) {
7109
+ return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
7110
+ },
7111
+ 12: function (n) {
7112
+ return Number(n % 10 != 1 || n % 100 == 11);
7113
+ },
7114
+ 13: function (n) {
7115
+ return Number(n !== 0);
7116
+ },
7117
+ 14: function (n) {
7118
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
7119
+ },
7120
+ 15: function (n) {
7121
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
7122
+ },
7123
+ 16: function (n) {
7124
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
7125
+ },
7126
+ 17: function (n) {
7127
+ return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
7128
+ },
7129
+ 18: function (n) {
7130
+ return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
7131
+ },
7132
+ 19: function (n) {
7133
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
7134
+ },
7135
+ 20: function (n) {
7136
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
7137
+ },
7138
+ 21: function (n) {
7139
+ return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
7140
+ },
7141
+ 22: function (n) {
7142
+ return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
7143
+ }
7144
+ };
7145
+ const nonIntlVersions = ['v1', 'v2', 'v3'];
7146
+ const intlVersions = ['v4'];
7147
+ const suffixesOrder = {
7148
+ zero: 0,
7149
+ one: 1,
7150
+ two: 2,
7151
+ few: 3,
7152
+ many: 4,
7153
+ other: 5
7154
+ };
7155
+ function createRules() {
7156
+ const rules = {};
7157
+ sets.forEach(set => {
7158
+ set.lngs.forEach(l => {
7159
+ rules[l] = {
7160
+ numbers: set.nr,
7161
+ plurals: _rulesPluralsTypes[set.fc]
7162
+ };
7163
+ });
7164
+ });
7165
+ return rules;
7166
+ }
7167
+ class PluralResolver {
7168
+ constructor(languageUtils) {
7169
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7170
+ this.languageUtils = languageUtils;
7171
+ this.options = options;
7172
+ this.logger = baseLogger.create('pluralResolver');
7173
+ if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
7174
+ this.options.compatibilityJSON = 'v3';
7175
+ this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
7176
+ }
7177
+ this.rules = createRules();
7178
+ }
7179
+ addRule(lng, obj) {
7180
+ this.rules[lng] = obj;
7181
+ }
7182
+ getRule(code) {
7183
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7184
+ if (this.shouldUseIntlApi()) {
7185
+ try {
7186
+ return new Intl.PluralRules(getCleanedCode(code), {
7187
+ type: options.ordinal ? 'ordinal' : 'cardinal'
7188
+ });
7189
+ } catch {
7190
+ return;
7191
+ }
7192
+ }
7193
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
7194
+ }
7195
+ needsPlural(code) {
7196
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7197
+ const rule = this.getRule(code, options);
7198
+ if (this.shouldUseIntlApi()) {
7199
+ return rule && rule.resolvedOptions().pluralCategories.length > 1;
7200
+ }
7201
+ return rule && rule.numbers.length > 1;
7202
+ }
7203
+ getPluralFormsOfKey(code, key) {
7204
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7205
+ return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
7206
+ }
7207
+ getSuffixes(code) {
7208
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7209
+ const rule = this.getRule(code, options);
7210
+ if (!rule) {
7211
+ return [];
7212
+ }
7213
+ if (this.shouldUseIntlApi()) {
7214
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
7215
+ }
7216
+ return rule.numbers.map(number => this.getSuffix(code, number, options));
7217
+ }
7218
+ getSuffix(code, count) {
7219
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7220
+ const rule = this.getRule(code, options);
7221
+ if (rule) {
7222
+ if (this.shouldUseIntlApi()) {
7223
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
7224
+ }
7225
+ return this.getSuffixRetroCompatible(rule, count);
7226
+ }
7227
+ this.logger.warn(`no plural rule found for: ${code}`);
7228
+ return '';
7229
+ }
7230
+ getSuffixRetroCompatible(rule, count) {
7231
+ const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
7232
+ let suffix = rule.numbers[idx];
7233
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
7234
+ if (suffix === 2) {
7235
+ suffix = 'plural';
7236
+ } else if (suffix === 1) {
7237
+ suffix = '';
7238
+ }
7239
+ }
7240
+ const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
7241
+ if (this.options.compatibilityJSON === 'v1') {
7242
+ if (suffix === 1) return '';
7243
+ if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
7244
+ return returnSuffix();
7245
+ } else if (this.options.compatibilityJSON === 'v2') {
7246
+ return returnSuffix();
7247
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
7248
+ return returnSuffix();
7249
+ }
7250
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
7251
+ }
7252
+ shouldUseIntlApi() {
7253
+ return !nonIntlVersions.includes(this.options.compatibilityJSON);
7254
+ }
7255
+ }
7256
+
7257
+ function deepFindWithDefaults(data, defaultData, key) {
7258
+ let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
7259
+ let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
7260
+ let path = getPathWithDefaults(data, defaultData, key);
7261
+ if (!path && ignoreJSONStructure && typeof key === 'string') {
7262
+ path = deepFind(data, key, keySeparator);
7263
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
7264
+ }
7265
+ return path;
7266
+ }
7267
+ class Interpolator {
7268
+ constructor() {
7269
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7270
+ this.logger = baseLogger.create('interpolator');
7271
+ this.options = options;
7272
+ this.format = options.interpolation && options.interpolation.format || (value => value);
7273
+ this.init(options);
7274
+ }
7275
+ init() {
7276
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7277
+ if (!options.interpolation) options.interpolation = {
7278
+ escapeValue: true
7279
+ };
7280
+ const iOpts = options.interpolation;
7281
+ this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
7282
+ this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
7283
+ this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
7284
+ this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
7285
+ this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
7286
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
7287
+ this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
7288
+ this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
7289
+ this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
7290
+ this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
7291
+ this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
7292
+ this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
7293
+ this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
7294
+ this.resetRegExp();
7295
+ }
7296
+ reset() {
7297
+ if (this.options) this.init(this.options);
7298
+ }
7299
+ resetRegExp() {
7300
+ const regexpStr = `${this.prefix}(.+?)${this.suffix}`;
7301
+ this.regexp = new RegExp(regexpStr, 'g');
7302
+ const regexpUnescapeStr = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
7303
+ this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
7304
+ const nestingRegexpStr = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
7305
+ this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
7306
+ }
7307
+ interpolate(str, data, lng, options) {
7308
+ let match;
7309
+ let value;
7310
+ let replaces;
7311
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
7312
+ function regexSafe(val) {
7313
+ return val.replace(/\$/g, '$$$$');
7314
+ }
7315
+ const handleFormat = key => {
7316
+ if (key.indexOf(this.formatSeparator) < 0) {
7317
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
7318
+ return this.alwaysFormat ? this.format(path, undefined, lng, {
7319
+ ...options,
7320
+ ...data,
7321
+ interpolationkey: key
7322
+ }) : path;
7323
+ }
7324
+ const p = key.split(this.formatSeparator);
7325
+ const k = p.shift().trim();
7326
+ const f = p.join(this.formatSeparator).trim();
7327
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
7328
+ ...options,
7329
+ ...data,
7330
+ interpolationkey: k
7331
+ });
7332
+ };
7333
+ this.resetRegExp();
7334
+ const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
7335
+ const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
7336
+ const todos = [{
7337
+ regex: this.regexpUnescape,
7338
+ safeValue: val => regexSafe(val)
7339
+ }, {
7340
+ regex: this.regexp,
7341
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
7342
+ }];
7343
+ todos.forEach(todo => {
7344
+ replaces = 0;
7345
+ while (match = todo.regex.exec(str)) {
7346
+ const matchedVar = match[1].trim();
7347
+ value = handleFormat(matchedVar);
7348
+ if (value === undefined) {
7349
+ if (typeof missingInterpolationHandler === 'function') {
7350
+ const temp = missingInterpolationHandler(str, match, options);
7351
+ value = typeof temp === 'string' ? temp : '';
7352
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
7353
+ value = '';
7354
+ } else if (skipOnVariables) {
7355
+ value = match[0];
7356
+ continue;
7357
+ } else {
7358
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
7359
+ value = '';
7360
+ }
7361
+ } else if (typeof value !== 'string' && !this.useRawValueToEscape) {
7362
+ value = makeString(value);
7363
+ }
7364
+ const safeValue = todo.safeValue(value);
7365
+ str = str.replace(match[0], safeValue);
7366
+ if (skipOnVariables) {
7367
+ todo.regex.lastIndex += value.length;
7368
+ todo.regex.lastIndex -= match[0].length;
7369
+ } else {
7370
+ todo.regex.lastIndex = 0;
7371
+ }
7372
+ replaces++;
7373
+ if (replaces >= this.maxReplaces) {
7374
+ break;
7375
+ }
7376
+ }
7377
+ });
7378
+ return str;
7379
+ }
7380
+ nest(str, fc) {
7381
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7382
+ let match;
7383
+ let value;
7384
+ let clonedOptions;
7385
+ function handleHasOptions(key, inheritedOptions) {
7386
+ const sep = this.nestingOptionsSeparator;
7387
+ if (key.indexOf(sep) < 0) return key;
7388
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
7389
+ let optionsString = `{${c[1]}`;
7390
+ key = c[0];
7391
+ optionsString = this.interpolate(optionsString, clonedOptions);
7392
+ const matchedSingleQuotes = optionsString.match(/'/g);
7393
+ const matchedDoubleQuotes = optionsString.match(/"/g);
7394
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
7395
+ optionsString = optionsString.replace(/'/g, '"');
7396
+ }
7397
+ try {
7398
+ clonedOptions = JSON.parse(optionsString);
7399
+ if (inheritedOptions) clonedOptions = {
7400
+ ...inheritedOptions,
7401
+ ...clonedOptions
7402
+ };
7403
+ } catch (e) {
7404
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
7405
+ return `${key}${sep}${optionsString}`;
7406
+ }
7407
+ delete clonedOptions.defaultValue;
7408
+ return key;
7409
+ }
7410
+ while (match = this.nestingRegexp.exec(str)) {
7411
+ let formatters = [];
7412
+ clonedOptions = {
7413
+ ...options
7414
+ };
7415
+ clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
7416
+ clonedOptions.applyPostProcessor = false;
7417
+ delete clonedOptions.defaultValue;
7418
+ let doReduce = false;
7419
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
7420
+ const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
7421
+ match[1] = r.shift();
7422
+ formatters = r;
7423
+ doReduce = true;
7424
+ }
7425
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
7426
+ if (value && match[0] === str && typeof value !== 'string') return value;
7427
+ if (typeof value !== 'string') value = makeString(value);
7428
+ if (!value) {
7429
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
7430
+ value = '';
7431
+ }
7432
+ if (doReduce) {
7433
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
7434
+ ...options,
7435
+ interpolationkey: match[1].trim()
7436
+ }), value.trim());
7437
+ }
7438
+ str = str.replace(match[0], value);
7439
+ this.regexp.lastIndex = 0;
7440
+ }
7441
+ return str;
7442
+ }
7443
+ }
7444
+
7445
+ function parseFormatStr(formatStr) {
7446
+ let formatName = formatStr.toLowerCase().trim();
7447
+ const formatOptions = {};
7448
+ if (formatStr.indexOf('(') > -1) {
7449
+ const p = formatStr.split('(');
7450
+ formatName = p[0].toLowerCase().trim();
7451
+ const optStr = p[1].substring(0, p[1].length - 1);
7452
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
7453
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
7454
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
7455
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
7456
+ } else {
7457
+ const opts = optStr.split(';');
7458
+ opts.forEach(opt => {
7459
+ if (!opt) return;
7460
+ const [key, ...rest] = opt.split(':');
7461
+ const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
7462
+ if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
7463
+ if (val === 'false') formatOptions[key.trim()] = false;
7464
+ if (val === 'true') formatOptions[key.trim()] = true;
7465
+ if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
7466
+ });
7467
+ }
7468
+ }
7469
+ return {
7470
+ formatName,
7471
+ formatOptions
7472
+ };
7473
+ }
7474
+ function createCachedFormatter(fn) {
7475
+ const cache = {};
7476
+ return function invokeFormatter(val, lng, options) {
7477
+ const key = lng + JSON.stringify(options);
7478
+ let formatter = cache[key];
7479
+ if (!formatter) {
7480
+ formatter = fn(getCleanedCode(lng), options);
7481
+ cache[key] = formatter;
7482
+ }
7483
+ return formatter(val);
7484
+ };
7485
+ }
7486
+ class Formatter {
7487
+ constructor() {
7488
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7489
+ this.logger = baseLogger.create('formatter');
7490
+ this.options = options;
7491
+ this.formats = {
7492
+ number: createCachedFormatter((lng, opt) => {
7493
+ const formatter = new Intl.NumberFormat(lng, {
7494
+ ...opt
7495
+ });
7496
+ return val => formatter.format(val);
7497
+ }),
7498
+ currency: createCachedFormatter((lng, opt) => {
7499
+ const formatter = new Intl.NumberFormat(lng, {
7500
+ ...opt,
7501
+ style: 'currency'
7502
+ });
7503
+ return val => formatter.format(val);
7504
+ }),
7505
+ datetime: createCachedFormatter((lng, opt) => {
7506
+ const formatter = new Intl.DateTimeFormat(lng, {
7507
+ ...opt
7508
+ });
7509
+ return val => formatter.format(val);
7510
+ }),
7511
+ relativetime: createCachedFormatter((lng, opt) => {
7512
+ const formatter = new Intl.RelativeTimeFormat(lng, {
7513
+ ...opt
7514
+ });
7515
+ return val => formatter.format(val, opt.range || 'day');
7516
+ }),
7517
+ list: createCachedFormatter((lng, opt) => {
7518
+ const formatter = new Intl.ListFormat(lng, {
7519
+ ...opt
7520
+ });
7521
+ return val => formatter.format(val);
7522
+ })
7523
+ };
7524
+ this.init(options);
7525
+ }
7526
+ init(services) {
7527
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
7528
+ interpolation: {}
7529
+ };
7530
+ const iOpts = options.interpolation;
7531
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
7532
+ }
7533
+ add(name, fc) {
7534
+ this.formats[name.toLowerCase().trim()] = fc;
7535
+ }
7536
+ addCached(name, fc) {
7537
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
7538
+ }
7539
+ format(value, format, lng) {
7540
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
7541
+ const formats = format.split(this.formatSeparator);
7542
+ const result = formats.reduce((mem, f) => {
7543
+ const {
7544
+ formatName,
7545
+ formatOptions
7546
+ } = parseFormatStr(f);
7547
+ if (this.formats[formatName]) {
7548
+ let formatted = mem;
7549
+ try {
7550
+ const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
7551
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
7552
+ formatted = this.formats[formatName](mem, l, {
7553
+ ...formatOptions,
7554
+ ...options,
7555
+ ...valOptions
7556
+ });
7557
+ } catch (error) {
7558
+ this.logger.warn(error);
7559
+ }
7560
+ return formatted;
7561
+ } else {
7562
+ this.logger.warn(`there was no format function for ${formatName}`);
7563
+ }
7564
+ return mem;
7565
+ }, value);
7566
+ return result;
7567
+ }
7568
+ }
7569
+
7570
+ function removePending(q, name) {
7571
+ if (q.pending[name] !== undefined) {
7572
+ delete q.pending[name];
7573
+ q.pendingCount--;
7574
+ }
7575
+ }
7576
+ class Connector extends EventEmitter {
7577
+ constructor(backend, store, services) {
7578
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
7579
+ super();
7580
+ this.backend = backend;
7581
+ this.store = store;
7582
+ this.services = services;
7583
+ this.languageUtils = services.languageUtils;
7584
+ this.options = options;
7585
+ this.logger = baseLogger.create('backendConnector');
7586
+ this.waitingReads = [];
7587
+ this.maxParallelReads = options.maxParallelReads || 10;
7588
+ this.readingCalls = 0;
7589
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
7590
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
7591
+ this.state = {};
7592
+ this.queue = [];
7593
+ if (this.backend && this.backend.init) {
7594
+ this.backend.init(services, options.backend, options);
7595
+ }
7596
+ }
7597
+ queueLoad(languages, namespaces, options, callback) {
7598
+ const toLoad = {};
7599
+ const pending = {};
7600
+ const toLoadLanguages = {};
7601
+ const toLoadNamespaces = {};
7602
+ languages.forEach(lng => {
7603
+ let hasAllNamespaces = true;
7604
+ namespaces.forEach(ns => {
7605
+ const name = `${lng}|${ns}`;
7606
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
7607
+ this.state[name] = 2;
7608
+ } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
7609
+ if (pending[name] === undefined) pending[name] = true;
7610
+ } else {
7611
+ this.state[name] = 1;
7612
+ hasAllNamespaces = false;
7613
+ if (pending[name] === undefined) pending[name] = true;
7614
+ if (toLoad[name] === undefined) toLoad[name] = true;
7615
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
7616
+ }
7617
+ });
7618
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
7619
+ });
7620
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
7621
+ this.queue.push({
7622
+ pending,
7623
+ pendingCount: Object.keys(pending).length,
7624
+ loaded: {},
7625
+ errors: [],
7626
+ callback
7627
+ });
7628
+ }
7629
+ return {
7630
+ toLoad: Object.keys(toLoad),
7631
+ pending: Object.keys(pending),
7632
+ toLoadLanguages: Object.keys(toLoadLanguages),
7633
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
7634
+ };
7635
+ }
7636
+ loaded(name, err, data) {
7637
+ const s = name.split('|');
7638
+ const lng = s[0];
7639
+ const ns = s[1];
7640
+ if (err) this.emit('failedLoading', lng, ns, err);
7641
+ if (data) {
7642
+ this.store.addResourceBundle(lng, ns, data);
7643
+ }
7644
+ this.state[name] = err ? -1 : 2;
7645
+ const loaded = {};
7646
+ this.queue.forEach(q => {
7647
+ pushPath(q.loaded, [lng], ns);
7648
+ removePending(q, name);
7649
+ if (err) q.errors.push(err);
7650
+ if (q.pendingCount === 0 && !q.done) {
7651
+ Object.keys(q.loaded).forEach(l => {
7652
+ if (!loaded[l]) loaded[l] = {};
7653
+ const loadedKeys = q.loaded[l];
7654
+ if (loadedKeys.length) {
7655
+ loadedKeys.forEach(n => {
7656
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
7657
+ });
7658
+ }
7659
+ });
7660
+ q.done = true;
7661
+ if (q.errors.length) {
7662
+ q.callback(q.errors);
7663
+ } else {
7664
+ q.callback();
7665
+ }
7666
+ }
7667
+ });
7668
+ this.emit('loaded', loaded);
7669
+ this.queue = this.queue.filter(q => !q.done);
7670
+ }
7671
+ read(lng, ns, fcName) {
7672
+ let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
7673
+ let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
7674
+ let callback = arguments.length > 5 ? arguments[5] : undefined;
7675
+ if (!lng.length) return callback(null, {});
7676
+ if (this.readingCalls >= this.maxParallelReads) {
7677
+ this.waitingReads.push({
7678
+ lng,
7679
+ ns,
7680
+ fcName,
7681
+ tried,
7682
+ wait,
7683
+ callback
7684
+ });
7685
+ return;
7686
+ }
7687
+ this.readingCalls++;
7688
+ const resolver = (err, data) => {
7689
+ this.readingCalls--;
7690
+ if (this.waitingReads.length > 0) {
7691
+ const next = this.waitingReads.shift();
7692
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
7693
+ }
7694
+ if (err && data && tried < this.maxRetries) {
7695
+ setTimeout(() => {
7696
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
7697
+ }, wait);
7698
+ return;
7699
+ }
7700
+ callback(err, data);
7701
+ };
7702
+ const fc = this.backend[fcName].bind(this.backend);
7703
+ if (fc.length === 2) {
7704
+ try {
7705
+ const r = fc(lng, ns);
7706
+ if (r && typeof r.then === 'function') {
7707
+ r.then(data => resolver(null, data)).catch(resolver);
7708
+ } else {
7709
+ resolver(null, r);
7710
+ }
7711
+ } catch (err) {
7712
+ resolver(err);
7713
+ }
7714
+ return;
7715
+ }
7716
+ return fc(lng, ns, resolver);
7717
+ }
7718
+ prepareLoading(languages, namespaces) {
7719
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7720
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
7721
+ if (!this.backend) {
7722
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
7723
+ return callback && callback();
7724
+ }
7725
+ if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
7726
+ if (typeof namespaces === 'string') namespaces = [namespaces];
7727
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
7728
+ if (!toLoad.toLoad.length) {
7729
+ if (!toLoad.pending.length) callback();
7730
+ return null;
7731
+ }
7732
+ toLoad.toLoad.forEach(name => {
7733
+ this.loadOne(name);
7734
+ });
7735
+ }
7736
+ load(languages, namespaces, callback) {
7737
+ this.prepareLoading(languages, namespaces, {}, callback);
7738
+ }
7739
+ reload(languages, namespaces, callback) {
7740
+ this.prepareLoading(languages, namespaces, {
7741
+ reload: true
7742
+ }, callback);
7743
+ }
7744
+ loadOne(name) {
7745
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
7746
+ const s = name.split('|');
7747
+ const lng = s[0];
7748
+ const ns = s[1];
7749
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
7750
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
7751
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
7752
+ this.loaded(name, err, data);
7753
+ });
7754
+ }
7755
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
7756
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
7757
+ let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
7758
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
7759
+ this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
7760
+ return;
7761
+ }
7762
+ if (key === undefined || key === null || key === '') return;
7763
+ if (this.backend && this.backend.create) {
7764
+ const opts = {
7765
+ ...options,
7766
+ isUpdate
7767
+ };
7768
+ const fc = this.backend.create.bind(this.backend);
7769
+ if (fc.length < 6) {
7770
+ try {
7771
+ let r;
7772
+ if (fc.length === 5) {
7773
+ r = fc(languages, namespace, key, fallbackValue, opts);
7774
+ } else {
7775
+ r = fc(languages, namespace, key, fallbackValue);
7776
+ }
7777
+ if (r && typeof r.then === 'function') {
7778
+ r.then(data => clb(null, data)).catch(clb);
7779
+ } else {
7780
+ clb(null, r);
7781
+ }
7782
+ } catch (err) {
7783
+ clb(err);
7784
+ }
7785
+ } else {
7786
+ fc(languages, namespace, key, fallbackValue, clb, opts);
7787
+ }
7788
+ }
7789
+ if (!languages || !languages[0]) return;
7790
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
7791
+ }
7792
+ }
7793
+
7794
+ function get() {
7795
+ return {
7796
+ debug: false,
7797
+ initImmediate: true,
7798
+ ns: ['translation'],
7799
+ defaultNS: ['translation'],
7800
+ fallbackLng: ['dev'],
7801
+ fallbackNS: false,
7802
+ supportedLngs: false,
7803
+ nonExplicitSupportedLngs: false,
7804
+ load: 'all',
7805
+ preload: false,
7806
+ simplifyPluralSuffix: true,
7807
+ keySeparator: '.',
7808
+ nsSeparator: ':',
7809
+ pluralSeparator: '_',
7810
+ contextSeparator: '_',
7811
+ partialBundledLanguages: false,
7812
+ saveMissing: false,
7813
+ updateMissing: false,
7814
+ saveMissingTo: 'fallback',
7815
+ saveMissingPlurals: true,
7816
+ missingKeyHandler: false,
7817
+ missingInterpolationHandler: false,
7818
+ postProcess: false,
7819
+ postProcessPassResolved: false,
7820
+ returnNull: false,
7821
+ returnEmptyString: true,
7822
+ returnObjects: false,
7823
+ joinArrays: false,
7824
+ returnedObjectHandler: false,
7825
+ parseMissingKeyHandler: false,
7826
+ appendNamespaceToMissingKey: false,
7827
+ appendNamespaceToCIMode: false,
7828
+ overloadTranslationOptionHandler: function handle(args) {
7829
+ let ret = {};
7830
+ if (typeof args[1] === 'object') ret = args[1];
7831
+ if (typeof args[1] === 'string') ret.defaultValue = args[1];
7832
+ if (typeof args[2] === 'string') ret.tDescription = args[2];
7833
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
7834
+ const options = args[3] || args[2];
7835
+ Object.keys(options).forEach(key => {
7836
+ ret[key] = options[key];
7837
+ });
7838
+ }
7839
+ return ret;
7840
+ },
7841
+ interpolation: {
7842
+ escapeValue: true,
7843
+ format: (value, format, lng, options) => value,
7844
+ prefix: '{{',
7845
+ suffix: '}}',
7846
+ formatSeparator: ',',
7847
+ unescapePrefix: '-',
7848
+ nestingPrefix: '$t(',
7849
+ nestingSuffix: ')',
7850
+ nestingOptionsSeparator: ',',
7851
+ maxReplaces: 1000,
7852
+ skipOnVariables: true
7853
+ }
7854
+ };
7855
+ }
7856
+ function transformOptions(options) {
7857
+ if (typeof options.ns === 'string') options.ns = [options.ns];
7858
+ if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
7859
+ if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
7860
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
7861
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
7862
+ }
7863
+ return options;
7864
+ }
7865
+
7866
+ function noop() {}
7867
+ function bindMemberFunctions(inst) {
7868
+ const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
7869
+ mems.forEach(mem => {
7870
+ if (typeof inst[mem] === 'function') {
7871
+ inst[mem] = inst[mem].bind(inst);
7872
+ }
7873
+ });
7874
+ }
7875
+ class I18n extends EventEmitter {
7876
+ constructor() {
7877
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7878
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
7879
+ super();
7880
+ this.options = transformOptions(options);
7881
+ this.services = {};
7882
+ this.logger = baseLogger;
7883
+ this.modules = {
7884
+ external: []
7885
+ };
7886
+ bindMemberFunctions(this);
7887
+ if (callback && !this.isInitialized && !options.isClone) {
7888
+ if (!this.options.initImmediate) {
7889
+ this.init(options, callback);
7890
+ return this;
7891
+ }
7892
+ setTimeout(() => {
7893
+ this.init(options, callback);
7894
+ }, 0);
7895
+ }
7896
+ }
7897
+ init() {
7898
+ var _this = this;
7899
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7900
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
7901
+ if (typeof options === 'function') {
7902
+ callback = options;
7903
+ options = {};
7904
+ }
7905
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
7906
+ if (typeof options.ns === 'string') {
7907
+ options.defaultNS = options.ns;
7908
+ } else if (options.ns.indexOf('translation') < 0) {
7909
+ options.defaultNS = options.ns[0];
7910
+ }
7911
+ }
7912
+ const defOpts = get();
7913
+ this.options = {
7914
+ ...defOpts,
7915
+ ...this.options,
7916
+ ...transformOptions(options)
7917
+ };
7918
+ if (this.options.compatibilityAPI !== 'v1') {
7919
+ this.options.interpolation = {
7920
+ ...defOpts.interpolation,
7921
+ ...this.options.interpolation
7922
+ };
7923
+ }
7924
+ if (options.keySeparator !== undefined) {
7925
+ this.options.userDefinedKeySeparator = options.keySeparator;
7926
+ }
7927
+ if (options.nsSeparator !== undefined) {
7928
+ this.options.userDefinedNsSeparator = options.nsSeparator;
7929
+ }
7930
+ function createClassOnDemand(ClassOrObject) {
7931
+ if (!ClassOrObject) return null;
7932
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
7933
+ return ClassOrObject;
7934
+ }
7935
+ if (!this.options.isClone) {
7936
+ if (this.modules.logger) {
7937
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
7938
+ } else {
7939
+ baseLogger.init(null, this.options);
7940
+ }
7941
+ let formatter;
7942
+ if (this.modules.formatter) {
7943
+ formatter = this.modules.formatter;
7944
+ } else if (typeof Intl !== 'undefined') {
7945
+ formatter = Formatter;
7946
+ }
7947
+ const lu = new LanguageUtil(this.options);
7948
+ this.store = new ResourceStore(this.options.resources, this.options);
7949
+ const s = this.services;
7950
+ s.logger = baseLogger;
7951
+ s.resourceStore = this.store;
7952
+ s.languageUtils = lu;
7953
+ s.pluralResolver = new PluralResolver(lu, {
7954
+ prepend: this.options.pluralSeparator,
7955
+ compatibilityJSON: this.options.compatibilityJSON,
7956
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
7957
+ });
7958
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
7959
+ s.formatter = createClassOnDemand(formatter);
7960
+ s.formatter.init(s, this.options);
7961
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
7962
+ }
7963
+ s.interpolator = new Interpolator(this.options);
7964
+ s.utils = {
7965
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
7966
+ };
7967
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
7968
+ s.backendConnector.on('*', function (event) {
7969
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7970
+ args[_key - 1] = arguments[_key];
7971
+ }
7972
+ _this.emit(event, ...args);
7973
+ });
7974
+ if (this.modules.languageDetector) {
7975
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
7976
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
7977
+ }
7978
+ if (this.modules.i18nFormat) {
7979
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
7980
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
7981
+ }
7982
+ this.translator = new Translator(this.services, this.options);
7983
+ this.translator.on('*', function (event) {
7984
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
7985
+ args[_key2 - 1] = arguments[_key2];
7986
+ }
7987
+ _this.emit(event, ...args);
7988
+ });
7989
+ this.modules.external.forEach(m => {
7990
+ if (m.init) m.init(this);
7991
+ });
7992
+ }
7993
+ this.format = this.options.interpolation.format;
7994
+ if (!callback) callback = noop;
7995
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
7996
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
7997
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
7998
+ }
7999
+ if (!this.services.languageDetector && !this.options.lng) {
8000
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
8001
+ }
8002
+ const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
8003
+ storeApi.forEach(fcName => {
8004
+ this[fcName] = function () {
8005
+ return _this.store[fcName](...arguments);
8006
+ };
8007
+ });
8008
+ const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
8009
+ storeApiChained.forEach(fcName => {
8010
+ this[fcName] = function () {
8011
+ _this.store[fcName](...arguments);
8012
+ return _this;
8013
+ };
8014
+ });
8015
+ const deferred = defer();
8016
+ const load = () => {
8017
+ const finish = (err, t) => {
8018
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
8019
+ this.isInitialized = true;
8020
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
8021
+ this.emit('initialized', this.options);
8022
+ deferred.resolve(t);
8023
+ callback(err, t);
8024
+ };
8025
+ if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
8026
+ this.changeLanguage(this.options.lng, finish);
8027
+ };
8028
+ if (this.options.resources || !this.options.initImmediate) {
8029
+ load();
8030
+ } else {
8031
+ setTimeout(load, 0);
8032
+ }
8033
+ return deferred;
8034
+ }
8035
+ loadResources(language) {
8036
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
8037
+ let usedCallback = callback;
8038
+ const usedLng = typeof language === 'string' ? language : this.language;
8039
+ if (typeof language === 'function') usedCallback = language;
8040
+ if (!this.options.resources || this.options.partialBundledLanguages) {
8041
+ if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
8042
+ const toLoad = [];
8043
+ const append = lng => {
8044
+ if (!lng) return;
8045
+ const lngs = this.services.languageUtils.toResolveHierarchy(lng);
8046
+ lngs.forEach(l => {
8047
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
8048
+ });
8049
+ };
8050
+ if (!usedLng) {
8051
+ const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
8052
+ fallbacks.forEach(l => append(l));
8053
+ } else {
8054
+ append(usedLng);
8055
+ }
8056
+ if (this.options.preload) {
8057
+ this.options.preload.forEach(l => append(l));
8058
+ }
8059
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
8060
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
8061
+ usedCallback(e);
8062
+ });
8063
+ } else {
8064
+ usedCallback(null);
8065
+ }
8066
+ }
8067
+ reloadResources(lngs, ns, callback) {
8068
+ const deferred = defer();
8069
+ if (!lngs) lngs = this.languages;
8070
+ if (!ns) ns = this.options.ns;
8071
+ if (!callback) callback = noop;
8072
+ this.services.backendConnector.reload(lngs, ns, err => {
8073
+ deferred.resolve();
8074
+ callback(err);
8075
+ });
8076
+ return deferred;
8077
+ }
8078
+ use(module) {
8079
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
8080
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
8081
+ if (module.type === 'backend') {
8082
+ this.modules.backend = module;
8083
+ }
8084
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
8085
+ this.modules.logger = module;
8086
+ }
8087
+ if (module.type === 'languageDetector') {
8088
+ this.modules.languageDetector = module;
8089
+ }
8090
+ if (module.type === 'i18nFormat') {
8091
+ this.modules.i18nFormat = module;
8092
+ }
8093
+ if (module.type === 'postProcessor') {
8094
+ postProcessor.addPostProcessor(module);
8095
+ }
8096
+ if (module.type === 'formatter') {
8097
+ this.modules.formatter = module;
8098
+ }
8099
+ if (module.type === '3rdParty') {
8100
+ this.modules.external.push(module);
8101
+ }
8102
+ return this;
8103
+ }
8104
+ setResolvedLanguage(l) {
8105
+ if (!l || !this.languages) return;
8106
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
8107
+ for (let li = 0; li < this.languages.length; li++) {
8108
+ const lngInLngs = this.languages[li];
8109
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
8110
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
8111
+ this.resolvedLanguage = lngInLngs;
8112
+ break;
8113
+ }
8114
+ }
8115
+ }
8116
+ changeLanguage(lng, callback) {
8117
+ var _this2 = this;
8118
+ this.isLanguageChangingTo = lng;
8119
+ const deferred = defer();
8120
+ this.emit('languageChanging', lng);
8121
+ const setLngProps = l => {
8122
+ this.language = l;
8123
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
8124
+ this.resolvedLanguage = undefined;
8125
+ this.setResolvedLanguage(l);
8126
+ };
8127
+ const done = (err, l) => {
8128
+ if (l) {
8129
+ setLngProps(l);
8130
+ this.translator.changeLanguage(l);
8131
+ this.isLanguageChangingTo = undefined;
8132
+ this.emit('languageChanged', l);
8133
+ this.logger.log('languageChanged', l);
8134
+ } else {
8135
+ this.isLanguageChangingTo = undefined;
8136
+ }
8137
+ deferred.resolve(function () {
8138
+ return _this2.t(...arguments);
8139
+ });
8140
+ if (callback) callback(err, function () {
8141
+ return _this2.t(...arguments);
8142
+ });
8143
+ };
8144
+ const setLng = lngs => {
8145
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
8146
+ const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
8147
+ if (l) {
8148
+ if (!this.language) {
8149
+ setLngProps(l);
8150
+ }
8151
+ if (!this.translator.language) this.translator.changeLanguage(l);
8152
+ if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
8153
+ }
8154
+ this.loadResources(l, err => {
8155
+ done(err, l);
8156
+ });
8157
+ };
8158
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
8159
+ setLng(this.services.languageDetector.detect());
8160
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
8161
+ if (this.services.languageDetector.detect.length === 0) {
8162
+ this.services.languageDetector.detect().then(setLng);
8163
+ } else {
8164
+ this.services.languageDetector.detect(setLng);
8165
+ }
8166
+ } else {
8167
+ setLng(lng);
8168
+ }
8169
+ return deferred;
8170
+ }
8171
+ getFixedT(lng, ns, keyPrefix) {
8172
+ var _this3 = this;
8173
+ const fixedT = function (key, opts) {
8174
+ let options;
8175
+ if (typeof opts !== 'object') {
8176
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
8177
+ rest[_key3 - 2] = arguments[_key3];
8178
+ }
8179
+ options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
8180
+ } else {
8181
+ options = {
8182
+ ...opts
8183
+ };
8184
+ }
8185
+ options.lng = options.lng || fixedT.lng;
8186
+ options.lngs = options.lngs || fixedT.lngs;
8187
+ options.ns = options.ns || fixedT.ns;
8188
+ options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
8189
+ const keySeparator = _this3.options.keySeparator || '.';
8190
+ let resultKey;
8191
+ if (options.keyPrefix && Array.isArray(key)) {
8192
+ resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
8193
+ } else {
8194
+ resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
8195
+ }
8196
+ return _this3.t(resultKey, options);
8197
+ };
8198
+ if (typeof lng === 'string') {
8199
+ fixedT.lng = lng;
8200
+ } else {
8201
+ fixedT.lngs = lng;
8202
+ }
8203
+ fixedT.ns = ns;
8204
+ fixedT.keyPrefix = keyPrefix;
8205
+ return fixedT;
8206
+ }
8207
+ t() {
8208
+ return this.translator && this.translator.translate(...arguments);
8209
+ }
8210
+ exists() {
8211
+ return this.translator && this.translator.exists(...arguments);
8212
+ }
8213
+ setDefaultNamespace(ns) {
8214
+ this.options.defaultNS = ns;
8215
+ }
8216
+ hasLoadedNamespace(ns) {
8217
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8218
+ if (!this.isInitialized) {
8219
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
8220
+ return false;
8221
+ }
8222
+ if (!this.languages || !this.languages.length) {
8223
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
8224
+ return false;
8225
+ }
8226
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
8227
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
8228
+ const lastLng = this.languages[this.languages.length - 1];
8229
+ if (lng.toLowerCase() === 'cimode') return true;
8230
+ const loadNotPending = (l, n) => {
8231
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
8232
+ return loadState === -1 || loadState === 2;
8233
+ };
8234
+ if (options.precheck) {
8235
+ const preResult = options.precheck(this, loadNotPending);
8236
+ if (preResult !== undefined) return preResult;
8237
+ }
8238
+ if (this.hasResourceBundle(lng, ns)) return true;
8239
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
8240
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
8241
+ return false;
8242
+ }
8243
+ loadNamespaces(ns, callback) {
8244
+ const deferred = defer();
8245
+ if (!this.options.ns) {
8246
+ if (callback) callback();
8247
+ return Promise.resolve();
8248
+ }
8249
+ if (typeof ns === 'string') ns = [ns];
8250
+ ns.forEach(n => {
8251
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
8252
+ });
8253
+ this.loadResources(err => {
8254
+ deferred.resolve();
8255
+ if (callback) callback(err);
8256
+ });
8257
+ return deferred;
8258
+ }
8259
+ loadLanguages(lngs, callback) {
8260
+ const deferred = defer();
8261
+ if (typeof lngs === 'string') lngs = [lngs];
8262
+ const preloaded = this.options.preload || [];
8263
+ const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0);
8264
+ if (!newLngs.length) {
8265
+ if (callback) callback();
8266
+ return Promise.resolve();
8267
+ }
8268
+ this.options.preload = preloaded.concat(newLngs);
8269
+ this.loadResources(err => {
8270
+ deferred.resolve();
8271
+ if (callback) callback(err);
8272
+ });
8273
+ return deferred;
8274
+ }
8275
+ dir(lng) {
8276
+ if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
8277
+ if (!lng) return 'rtl';
8278
+ const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
8279
+ const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
8280
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
8281
+ }
8282
+ static createInstance() {
8283
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8284
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
8285
+ return new I18n(options, callback);
8286
+ }
8287
+ cloneInstance() {
8288
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8289
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
8290
+ const forkResourceStore = options.forkResourceStore;
8291
+ if (forkResourceStore) delete options.forkResourceStore;
8292
+ const mergedOptions = {
8293
+ ...this.options,
8294
+ ...options,
8295
+ ...{
8296
+ isClone: true
8297
+ }
8298
+ };
8299
+ const clone = new I18n(mergedOptions);
8300
+ if (options.debug !== undefined || options.prefix !== undefined) {
8301
+ clone.logger = clone.logger.clone(options);
8302
+ }
8303
+ const membersToCopy = ['store', 'services', 'language'];
8304
+ membersToCopy.forEach(m => {
8305
+ clone[m] = this[m];
8306
+ });
8307
+ clone.services = {
8308
+ ...this.services
8309
+ };
8310
+ clone.services.utils = {
8311
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
8312
+ };
8313
+ if (forkResourceStore) {
8314
+ clone.store = new ResourceStore(this.store.data, mergedOptions);
8315
+ clone.services.resourceStore = clone.store;
8316
+ }
8317
+ clone.translator = new Translator(clone.services, mergedOptions);
8318
+ clone.translator.on('*', function (event) {
8319
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
8320
+ args[_key4 - 1] = arguments[_key4];
8321
+ }
8322
+ clone.emit(event, ...args);
8323
+ });
8324
+ clone.init(mergedOptions, callback);
8325
+ clone.translator.options = mergedOptions;
8326
+ clone.translator.backendConnector.services.utils = {
8327
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
8328
+ };
8329
+ return clone;
8330
+ }
8331
+ toJSON() {
8332
+ return {
8333
+ options: this.options,
8334
+ store: this.store,
8335
+ language: this.language,
8336
+ languages: this.languages,
8337
+ resolvedLanguage: this.resolvedLanguage
8338
+ };
8339
+ }
8340
+ }
8341
+ const instance = I18n.createInstance();
8342
+ instance.createInstance = I18n.createInstance;
8343
+
8344
+ instance.createInstance;
8345
+ instance.dir;
8346
+ instance.init;
8347
+ instance.loadResources;
8348
+ instance.reloadResources;
8349
+ instance.use;
8350
+ instance.changeLanguage;
8351
+ instance.getFixedT;
8352
+ instance.t;
8353
+ instance.exists;
8354
+ instance.setDefaultNamespace;
8355
+ instance.hasLoadedNamespace;
8356
+ instance.loadNamespaces;
8357
+ instance.loadLanguages;
8358
+
8359
+ var calendar$1 = {
8360
+ startDate: "Start date",
8361
+ endDate: "End date"
8362
+ };
8363
+ var guests$1 = {
8364
+ label: "Guests",
8365
+ title: "Guests",
8366
+ subtitle: "Who's coming?",
8367
+ adultsLabel: "Adults",
8368
+ kidsLabel: "kids"
8369
+ };
8370
+ var categories$1 = {
8371
+ label: "Categories",
8372
+ title: "Category"
8373
+ };
8374
+ var enFilterBar = {
8375
+ calendar: calendar$1,
8376
+ guests: guests$1,
8377
+ categories: categories$1
8378
+ };
8379
+
8380
+ var calendar = {
8381
+ startDate: "Aloitus päivämäärä",
8382
+ endDate: "Päättymis päivämäärä"
8383
+ };
8384
+ var guests = {
8385
+ label: "Vieraat",
8386
+ title: "Vieraat",
8387
+ subtitle: "Kuka saapuu?",
8388
+ adultsLabel: "Aikuiset",
8389
+ kidsLabel: "lapset"
8390
+ };
8391
+ var categories = {
8392
+ label: "Kategoriat",
8393
+ title: "Kategoria"
8394
+ };
8395
+ var fiFilterBar = {
8396
+ calendar: calendar,
8397
+ guests: guests,
8398
+ categories: categories
8399
+ };
8400
+
8401
+ var urlParams = new URLSearchParams(window.location.search);
8402
+ var localeFromUrl = urlParams.get('locale') || 'fi';
8403
+ console.log(urlParams);
8404
+ var userPreferredLanguage = navigator.language;
8405
+ console.log('User Preferred Language:', userPreferredLanguage);
8406
+ instance.use(initReactI18next).init({
8407
+ resources: {
8408
+ en: { filterBar: enFilterBar },
8409
+ fi: { filterBar: fiFilterBar },
8410
+ },
8411
+ lng: localeFromUrl,
8412
+ fallbackLng: 'fi',
8413
+ interpolation: {
8414
+ escapeValue: false,
8415
+ },
8416
+ });
8417
+
8418
+ function FilterBar(_a) {
8419
+ _a.vendor;
8420
+ // useTheme({ vendor })
8421
+ var t = useTranslation('filterBar').t;
8422
+ var _b = useFilterBar(), selectedFilter = _b.selectedFilter, guestsAdults = _b.guestsAdults, guestsKids = _b.guestsKids, categories = _b.categories, calendarRange = _b.calendarRange, setCalendarRange = _b.setCalendarRange, setGuestsAdults = _b.setGuestsAdults, setGuestsKids = _b.setGuestsKids, setCategories = _b.setCategories, handleSelectedFilter = _b.handleSelectedFilter, handleSubmit = _b.handleSubmit;
5827
8423
  return (React__default.createElement("div", { className: "filter-bar" },
5828
8424
  React__default.createElement("div", { className: "filter-bar-header" },
5829
- React__default.createElement(SelectButton, { label: 'Start date', onClick: function () { return handleSelectedFilter(1); } }),
8425
+ React__default.createElement(SelectButton, { label: t('calendar.startDate'), onClick: function () { return handleSelectedFilter(1); } }),
5830
8426
  React__default.createElement(Divider, null),
5831
- React__default.createElement(SelectButton, { label: 'End date', onClick: function () { return handleSelectedFilter(2); } }),
8427
+ React__default.createElement(SelectButton, { label: t('calendar.endDate'), onClick: function () { return handleSelectedFilter(2); } }),
5832
8428
  React__default.createElement(Divider, null),
5833
- React__default.createElement(SelectButton, { label: "Guests", onClick: function () { return handleSelectedFilter(3); } }),
8429
+ React__default.createElement(SelectButton, { label: t('guests.label'), onClick: function () { return handleSelectedFilter(3); } }),
5834
8430
  React__default.createElement(Divider, null),
5835
- React__default.createElement(SelectButton, { label: "Categories", onClick: function () { return handleSelectedFilter(4); } }),
8431
+ React__default.createElement(SelectButton, { label: t('categories.label'), onClick: function () { return handleSelectedFilter(4); } }),
5836
8432
  React__default.createElement(SubmitButton, { onClick: handleSubmit })),
5837
8433
  selectedFilter && (React__default.createElement("div", { className: "filter-bar-container" },
5838
8434
  (selectedFilter === 1 || selectedFilter === 2) && (React__default.createElement(Calendar, { calendarRange: calendarRange, setCalendarRange: setCalendarRange })),