finance-shared 0.0.14 → 0.0.15

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.
@@ -1,2467 +1,18 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import i18next from "i18next";
5
+ import { default as default2 } from "i18next";
4
6
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
5
- import { Dialog as Dialog$1, DialogTitle, DialogContent as DialogContent$1, DialogContentText, DialogActions as DialogActions$1, Button as Button$1, Typography as Typography$1, IconButton as IconButton$1, Box as Box$1, Tooltip, Zoom, TextField as TextField$1, Paper as Paper$1, Grid as Grid$1, styled as styled$3, CircularProgress as CircularProgress$1, Autocomplete as Autocomplete$1, Badge, Checkbox as Checkbox$1, Chip as Chip$1, Divider, RadioGroup, FormControlLabel, Radio, Popover as Popover$1 } from "@mui/material";
7
+ import { Dialog as Dialog$1, DialogTitle, DialogContent as DialogContent$1, DialogContentText, DialogActions as DialogActions$1, Button as Button$1, Typography as Typography$1, IconButton as IconButton$1, Box as Box$1, Tooltip, Zoom, TextField as TextField$1, Paper as Paper$1, Grid as Grid$1, styled as styled$3, CircularProgress as CircularProgress$1, Autocomplete as Autocomplete$1, Badge, Checkbox as Checkbox$1, Chip as Chip$1, Divider, RadioGroup, FormControlLabel, Radio, Grid2, Popover as Popover$1 } from "@mui/material";
8
+ import { useTranslation } from "react-i18next";
6
9
  import * as React from "react";
7
- import React__default, { createContext, useContext, useCallback, useState, useRef, useEffect, isValidElement, cloneElement, Children, memo, createElement, useMemo } from "react";
10
+ import React__default, { useState, isValidElement, cloneElement, Children, useEffect, memo, createElement, useRef, useCallback, useMemo, createContext, useContext } from "react";
8
11
  import { unstable_createGetCssVar, createSpacing as createSpacing$1, useTheme as useTheme$3, GlobalStyles as GlobalStyles$1, unstable_memoTheme, css, keyframes, styled as styled$2, createBox, darken as darken$1, unstable_resolveBreakpointValues, handleBreakpoints as handleBreakpoints$1, alpha as alpha$1 } from "@mui/system";
9
12
  import emStyled from "@emotion/styled";
10
13
  import { ThemeContext } from "@emotion/react";
11
14
  import * as ReactDOM from "react-dom";
12
15
  import ReactDOM__default from "react-dom";
13
- const isString$3 = (obj) => typeof obj === "string";
14
- const defer = () => {
15
- let res;
16
- let rej;
17
- const promise = new Promise((resolve, reject) => {
18
- res = resolve;
19
- rej = reject;
20
- });
21
- promise.resolve = res;
22
- promise.reject = rej;
23
- return promise;
24
- };
25
- const makeString = (object2) => {
26
- if (object2 == null) return "";
27
- return "" + object2;
28
- };
29
- const copy = (a3, s4, t2) => {
30
- a3.forEach((m3) => {
31
- if (s4[m3]) t2[m3] = s4[m3];
32
- });
33
- };
34
- const lastOfPathSeparatorRegExp = /###/g;
35
- const cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
36
- const canNotTraverseDeeper = (object2) => !object2 || isString$3(object2);
37
- const getLastOfPath = (object2, path, Empty) => {
38
- const stack = !isString$3(path) ? path : path.split(".");
39
- let stackIndex = 0;
40
- while (stackIndex < stack.length - 1) {
41
- if (canNotTraverseDeeper(object2)) return {};
42
- const key = cleanKey(stack[stackIndex]);
43
- if (!object2[key] && Empty) object2[key] = new Empty();
44
- if (Object.prototype.hasOwnProperty.call(object2, key)) {
45
- object2 = object2[key];
46
- } else {
47
- object2 = {};
48
- }
49
- ++stackIndex;
50
- }
51
- if (canNotTraverseDeeper(object2)) return {};
52
- return {
53
- obj: object2,
54
- k: cleanKey(stack[stackIndex])
55
- };
56
- };
57
- const setPath = (object2, path, newValue) => {
58
- const {
59
- obj,
60
- k: k2
61
- } = getLastOfPath(object2, path, Object);
62
- if (obj !== void 0 || path.length === 1) {
63
- obj[k2] = newValue;
64
- return;
65
- }
66
- let e2 = path[path.length - 1];
67
- let p = path.slice(0, path.length - 1);
68
- let last = getLastOfPath(object2, p, Object);
69
- while (last.obj === void 0 && p.length) {
70
- e2 = `${p[p.length - 1]}.${e2}`;
71
- p = p.slice(0, p.length - 1);
72
- last = getLastOfPath(object2, p, Object);
73
- if ((last == null ? void 0 : last.obj) && typeof last.obj[`${last.k}.${e2}`] !== "undefined") {
74
- last.obj = void 0;
75
- }
76
- }
77
- last.obj[`${last.k}.${e2}`] = newValue;
78
- };
79
- const pushPath = (object2, path, newValue, concat) => {
80
- const {
81
- obj,
82
- k: k2
83
- } = getLastOfPath(object2, path, Object);
84
- obj[k2] = obj[k2] || [];
85
- obj[k2].push(newValue);
86
- };
87
- const getPath$1 = (object2, path) => {
88
- const {
89
- obj,
90
- k: k2
91
- } = getLastOfPath(object2, path);
92
- if (!obj) return void 0;
93
- if (!Object.prototype.hasOwnProperty.call(obj, k2)) return void 0;
94
- return obj[k2];
95
- };
96
- const getPathWithDefaults = (data, defaultData, key) => {
97
- const value = getPath$1(data, key);
98
- if (value !== void 0) {
99
- return value;
100
- }
101
- return getPath$1(defaultData, key);
102
- };
103
- const deepExtend = (target, source, overwrite) => {
104
- for (const prop in source) {
105
- if (prop !== "__proto__" && prop !== "constructor") {
106
- if (prop in target) {
107
- if (isString$3(target[prop]) || target[prop] instanceof String || isString$3(source[prop]) || source[prop] instanceof String) {
108
- if (overwrite) target[prop] = source[prop];
109
- } else {
110
- deepExtend(target[prop], source[prop], overwrite);
111
- }
112
- } else {
113
- target[prop] = source[prop];
114
- }
115
- }
116
- }
117
- return target;
118
- };
119
- const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
120
- var _entityMap = {
121
- "&": "&amp;",
122
- "<": "&lt;",
123
- ">": "&gt;",
124
- '"': "&quot;",
125
- "'": "&#39;",
126
- "/": "&#x2F;"
127
- };
128
- const escape = (data) => {
129
- if (isString$3(data)) {
130
- return data.replace(/[&<>"'\/]/g, (s4) => _entityMap[s4]);
131
- }
132
- return data;
133
- };
134
- class RegExpCache {
135
- constructor(capacity) {
136
- this.capacity = capacity;
137
- this.regExpMap = /* @__PURE__ */ new Map();
138
- this.regExpQueue = [];
139
- }
140
- getRegExp(pattern) {
141
- const regExpFromCache = this.regExpMap.get(pattern);
142
- if (regExpFromCache !== void 0) {
143
- return regExpFromCache;
144
- }
145
- const regExpNew = new RegExp(pattern);
146
- if (this.regExpQueue.length === this.capacity) {
147
- this.regExpMap.delete(this.regExpQueue.shift());
148
- }
149
- this.regExpMap.set(pattern, regExpNew);
150
- this.regExpQueue.push(pattern);
151
- return regExpNew;
152
- }
153
- }
154
- const chars = [" ", ",", "?", "!", ";"];
155
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
156
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
157
- nsSeparator = nsSeparator || "";
158
- keySeparator = keySeparator || "";
159
- const possibleChars = chars.filter((c2) => nsSeparator.indexOf(c2) < 0 && keySeparator.indexOf(c2) < 0);
160
- if (possibleChars.length === 0) return true;
161
- const r2 = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c2) => c2 === "?" ? "\\?" : c2).join("|")})`);
162
- let matched = !r2.test(key);
163
- if (!matched) {
164
- const ki = key.indexOf(keySeparator);
165
- if (ki > 0 && !r2.test(key.substring(0, ki))) {
166
- matched = true;
167
- }
168
- }
169
- return matched;
170
- };
171
- const deepFind = (obj, path, keySeparator = ".") => {
172
- if (!obj) return void 0;
173
- if (obj[path]) {
174
- if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
175
- return obj[path];
176
- }
177
- const tokens = path.split(keySeparator);
178
- let current2 = obj;
179
- for (let i3 = 0; i3 < tokens.length; ) {
180
- if (!current2 || typeof current2 !== "object") {
181
- return void 0;
182
- }
183
- let next;
184
- let nextPath = "";
185
- for (let j = i3; j < tokens.length; ++j) {
186
- if (j !== i3) {
187
- nextPath += keySeparator;
188
- }
189
- nextPath += tokens[j];
190
- next = current2[nextPath];
191
- if (next !== void 0) {
192
- if (["string", "number", "boolean"].indexOf(typeof next) > -1 && j < tokens.length - 1) {
193
- continue;
194
- }
195
- i3 += j - i3 + 1;
196
- break;
197
- }
198
- }
199
- current2 = next;
200
- }
201
- return current2;
202
- };
203
- const getCleanedCode = (code) => code == null ? void 0 : code.replace("_", "-");
204
- const consoleLogger = {
205
- type: "logger",
206
- log(args) {
207
- this.output("log", args);
208
- },
209
- warn(args) {
210
- this.output("warn", args);
211
- },
212
- error(args) {
213
- this.output("error", args);
214
- },
215
- output(type, args) {
216
- var _a, _b;
217
- (_b = (_a = console == null ? void 0 : console[type]) == null ? void 0 : _a.apply) == null ? void 0 : _b.call(_a, console, args);
218
- }
219
- };
220
- class Logger {
221
- constructor(concreteLogger, options = {}) {
222
- this.init(concreteLogger, options);
223
- }
224
- init(concreteLogger, options = {}) {
225
- this.prefix = options.prefix || "i18next:";
226
- this.logger = concreteLogger || consoleLogger;
227
- this.options = options;
228
- this.debug = options.debug;
229
- }
230
- log(...args) {
231
- return this.forward(args, "log", "", true);
232
- }
233
- warn(...args) {
234
- return this.forward(args, "warn", "", true);
235
- }
236
- error(...args) {
237
- return this.forward(args, "error", "");
238
- }
239
- deprecate(...args) {
240
- return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
241
- }
242
- forward(args, lvl, prefix, debugOnly) {
243
- if (debugOnly && !this.debug) return null;
244
- if (isString$3(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
245
- return this.logger[lvl](args);
246
- }
247
- create(moduleName) {
248
- return new Logger(this.logger, {
249
- ...{
250
- prefix: `${this.prefix}:${moduleName}:`
251
- },
252
- ...this.options
253
- });
254
- }
255
- clone(options) {
256
- options = options || this.options;
257
- options.prefix = options.prefix || this.prefix;
258
- return new Logger(this.logger, options);
259
- }
260
- }
261
- var baseLogger = new Logger();
262
- class EventEmitter {
263
- constructor() {
264
- this.observers = {};
265
- }
266
- on(events, listener) {
267
- events.split(" ").forEach((event) => {
268
- if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
269
- const numListeners = this.observers[event].get(listener) || 0;
270
- this.observers[event].set(listener, numListeners + 1);
271
- });
272
- return this;
273
- }
274
- off(event, listener) {
275
- if (!this.observers[event]) return;
276
- if (!listener) {
277
- delete this.observers[event];
278
- return;
279
- }
280
- this.observers[event].delete(listener);
281
- }
282
- emit(event, ...args) {
283
- if (this.observers[event]) {
284
- const cloned = Array.from(this.observers[event].entries());
285
- cloned.forEach(([observer, numTimesAdded]) => {
286
- for (let i3 = 0; i3 < numTimesAdded; i3++) {
287
- observer(...args);
288
- }
289
- });
290
- }
291
- if (this.observers["*"]) {
292
- const cloned = Array.from(this.observers["*"].entries());
293
- cloned.forEach(([observer, numTimesAdded]) => {
294
- for (let i3 = 0; i3 < numTimesAdded; i3++) {
295
- observer.apply(observer, [event, ...args]);
296
- }
297
- });
298
- }
299
- }
300
- }
301
- class ResourceStore extends EventEmitter {
302
- constructor(data, options = {
303
- ns: ["translation"],
304
- defaultNS: "translation"
305
- }) {
306
- super();
307
- this.data = data || {};
308
- this.options = options;
309
- if (this.options.keySeparator === void 0) {
310
- this.options.keySeparator = ".";
311
- }
312
- if (this.options.ignoreJSONStructure === void 0) {
313
- this.options.ignoreJSONStructure = true;
314
- }
315
- }
316
- addNamespaces(ns) {
317
- if (this.options.ns.indexOf(ns) < 0) {
318
- this.options.ns.push(ns);
319
- }
320
- }
321
- removeNamespaces(ns) {
322
- const index = this.options.ns.indexOf(ns);
323
- if (index > -1) {
324
- this.options.ns.splice(index, 1);
325
- }
326
- }
327
- getResource(lng, ns, key, options = {}) {
328
- var _a, _b;
329
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
330
- const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
331
- let path;
332
- if (lng.indexOf(".") > -1) {
333
- path = lng.split(".");
334
- } else {
335
- path = [lng, ns];
336
- if (key) {
337
- if (Array.isArray(key)) {
338
- path.push(...key);
339
- } else if (isString$3(key) && keySeparator) {
340
- path.push(...key.split(keySeparator));
341
- } else {
342
- path.push(key);
343
- }
344
- }
345
- }
346
- const result = getPath$1(this.data, path);
347
- if (!result && !ns && !key && lng.indexOf(".") > -1) {
348
- lng = path[0];
349
- ns = path[1];
350
- key = path.slice(2).join(".");
351
- }
352
- if (result || !ignoreJSONStructure || !isString$3(key)) return result;
353
- return deepFind((_b = (_a = this.data) == null ? void 0 : _a[lng]) == null ? void 0 : _b[ns], key, keySeparator);
354
- }
355
- addResource(lng, ns, key, value, options = {
356
- silent: false
357
- }) {
358
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
359
- let path = [lng, ns];
360
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
361
- if (lng.indexOf(".") > -1) {
362
- path = lng.split(".");
363
- value = ns;
364
- ns = path[1];
365
- }
366
- this.addNamespaces(ns);
367
- setPath(this.data, path, value);
368
- if (!options.silent) this.emit("added", lng, ns, key, value);
369
- }
370
- addResources(lng, ns, resources2, options = {
371
- silent: false
372
- }) {
373
- for (const m3 in resources2) {
374
- if (isString$3(resources2[m3]) || Array.isArray(resources2[m3])) this.addResource(lng, ns, m3, resources2[m3], {
375
- silent: true
376
- });
377
- }
378
- if (!options.silent) this.emit("added", lng, ns, resources2);
379
- }
380
- addResourceBundle(lng, ns, resources2, deep, overwrite, options = {
381
- silent: false,
382
- skipCopy: false
383
- }) {
384
- let path = [lng, ns];
385
- if (lng.indexOf(".") > -1) {
386
- path = lng.split(".");
387
- deep = resources2;
388
- resources2 = ns;
389
- ns = path[1];
390
- }
391
- this.addNamespaces(ns);
392
- let pack = getPath$1(this.data, path) || {};
393
- if (!options.skipCopy) resources2 = JSON.parse(JSON.stringify(resources2));
394
- if (deep) {
395
- deepExtend(pack, resources2, overwrite);
396
- } else {
397
- pack = {
398
- ...pack,
399
- ...resources2
400
- };
401
- }
402
- setPath(this.data, path, pack);
403
- if (!options.silent) this.emit("added", lng, ns, resources2);
404
- }
405
- removeResourceBundle(lng, ns) {
406
- if (this.hasResourceBundle(lng, ns)) {
407
- delete this.data[lng][ns];
408
- }
409
- this.removeNamespaces(ns);
410
- this.emit("removed", lng, ns);
411
- }
412
- hasResourceBundle(lng, ns) {
413
- return this.getResource(lng, ns) !== void 0;
414
- }
415
- getResourceBundle(lng, ns) {
416
- if (!ns) ns = this.options.defaultNS;
417
- return this.getResource(lng, ns);
418
- }
419
- getDataByLanguage(lng) {
420
- return this.data[lng];
421
- }
422
- hasLanguageSomeTranslations(lng) {
423
- const data = this.getDataByLanguage(lng);
424
- const n2 = data && Object.keys(data) || [];
425
- return !!n2.find((v) => data[v] && Object.keys(data[v]).length > 0);
426
- }
427
- toJSON() {
428
- return this.data;
429
- }
430
- }
431
- var postProcessor = {
432
- processors: {},
433
- addPostProcessor(module) {
434
- this.processors[module.name] = module;
435
- },
436
- handle(processors, value, key, options, translator) {
437
- processors.forEach((processor) => {
438
- var _a;
439
- value = ((_a = this.processors[processor]) == null ? void 0 : _a.process(value, key, options, translator)) ?? value;
440
- });
441
- return value;
442
- }
443
- };
444
- const PATH_KEY = Symbol("i18next/PATH_KEY");
445
- function createProxy$1() {
446
- const state = [];
447
- const handler = /* @__PURE__ */ Object.create(null);
448
- let proxy;
449
- handler.get = (target, key) => {
450
- var _a;
451
- (_a = proxy == null ? void 0 : proxy.revoke) == null ? void 0 : _a.call(proxy);
452
- if (key === PATH_KEY) return state;
453
- state.push(key);
454
- proxy = Proxy.revocable(target, handler);
455
- return proxy.proxy;
456
- };
457
- return Proxy.revocable(/* @__PURE__ */ Object.create(null), handler).proxy;
458
- }
459
- function keysFromSelector(selector, opts) {
460
- const {
461
- [PATH_KEY]: path
462
- } = selector(createProxy$1());
463
- return path.join((opts == null ? void 0 : opts.keySeparator) ?? ".");
464
- }
465
- const checkedLoadedFor = {};
466
- const shouldHandleAsObject = (res) => !isString$3(res) && typeof res !== "boolean" && typeof res !== "number";
467
- class Translator extends EventEmitter {
468
- constructor(services, options = {}) {
469
- super();
470
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
471
- this.options = options;
472
- if (this.options.keySeparator === void 0) {
473
- this.options.keySeparator = ".";
474
- }
475
- this.logger = baseLogger.create("translator");
476
- }
477
- changeLanguage(lng) {
478
- if (lng) this.language = lng;
479
- }
480
- exists(key, o2 = {
481
- interpolation: {}
482
- }) {
483
- const opt = {
484
- ...o2
485
- };
486
- if (key == null) return false;
487
- const resolved = this.resolve(key, opt);
488
- if ((resolved == null ? void 0 : resolved.res) === void 0) return false;
489
- const isObject2 = shouldHandleAsObject(resolved.res);
490
- if (opt.returnObjects === false && isObject2) {
491
- return false;
492
- }
493
- return true;
494
- }
495
- extractFromKey(key, opt) {
496
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
497
- if (nsSeparator === void 0) nsSeparator = ":";
498
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
499
- let namespaces = opt.ns || this.options.defaultNS || [];
500
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
501
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
502
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
503
- const m3 = key.match(this.interpolator.nestingRegexp);
504
- if (m3 && m3.length > 0) {
505
- return {
506
- key,
507
- namespaces: isString$3(namespaces) ? [namespaces] : namespaces
508
- };
509
- }
510
- const parts = key.split(nsSeparator);
511
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
512
- key = parts.join(keySeparator);
513
- }
514
- return {
515
- key,
516
- namespaces: isString$3(namespaces) ? [namespaces] : namespaces
517
- };
518
- }
519
- translate(keys, o2, lastKey) {
520
- let opt = typeof o2 === "object" ? {
521
- ...o2
522
- } : o2;
523
- if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
524
- opt = this.options.overloadTranslationOptionHandler(arguments);
525
- }
526
- if (typeof opt === "object") opt = {
527
- ...opt
528
- };
529
- if (!opt) opt = {};
530
- if (keys == null) return "";
531
- if (typeof keys === "function") keys = keysFromSelector(keys, {
532
- ...this.options,
533
- ...opt
534
- });
535
- if (!Array.isArray(keys)) keys = [String(keys)];
536
- const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
537
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
538
- const {
539
- key,
540
- namespaces
541
- } = this.extractFromKey(keys[keys.length - 1], opt);
542
- const namespace = namespaces[namespaces.length - 1];
543
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
544
- if (nsSeparator === void 0) nsSeparator = ":";
545
- const lng = opt.lng || this.language;
546
- const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
547
- if ((lng == null ? void 0 : lng.toLowerCase()) === "cimode") {
548
- if (appendNamespaceToCIMode) {
549
- if (returnDetails) {
550
- return {
551
- res: `${namespace}${nsSeparator}${key}`,
552
- usedKey: key,
553
- exactUsedKey: key,
554
- usedLng: lng,
555
- usedNS: namespace,
556
- usedParams: this.getUsedParamsDetails(opt)
557
- };
558
- }
559
- return `${namespace}${nsSeparator}${key}`;
560
- }
561
- if (returnDetails) {
562
- return {
563
- res: key,
564
- usedKey: key,
565
- exactUsedKey: key,
566
- usedLng: lng,
567
- usedNS: namespace,
568
- usedParams: this.getUsedParamsDetails(opt)
569
- };
570
- }
571
- return key;
572
- }
573
- const resolved = this.resolve(keys, opt);
574
- let res = resolved == null ? void 0 : resolved.res;
575
- const resUsedKey = (resolved == null ? void 0 : resolved.usedKey) || key;
576
- const resExactUsedKey = (resolved == null ? void 0 : resolved.exactUsedKey) || key;
577
- const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
578
- const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
579
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
580
- const needsPluralHandling = opt.count !== void 0 && !isString$3(opt.count);
581
- const hasDefaultValue = Translator.hasDefaultValue(opt);
582
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
583
- const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
584
- ordinal: false
585
- }) : "";
586
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
587
- const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
588
- let resForObjHndl = res;
589
- if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
590
- resForObjHndl = defaultValue;
591
- }
592
- const handleAsObject = shouldHandleAsObject(resForObjHndl);
593
- const resType = Object.prototype.toString.apply(resForObjHndl);
594
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$3(joinArrays) && Array.isArray(resForObjHndl))) {
595
- if (!opt.returnObjects && !this.options.returnObjects) {
596
- if (!this.options.returnedObjectHandler) {
597
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
598
- }
599
- const r2 = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
600
- ...opt,
601
- ns: namespaces
602
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
603
- if (returnDetails) {
604
- resolved.res = r2;
605
- resolved.usedParams = this.getUsedParamsDetails(opt);
606
- return resolved;
607
- }
608
- return r2;
609
- }
610
- if (keySeparator) {
611
- const resTypeIsArray = Array.isArray(resForObjHndl);
612
- const copy2 = resTypeIsArray ? [] : {};
613
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
614
- for (const m3 in resForObjHndl) {
615
- if (Object.prototype.hasOwnProperty.call(resForObjHndl, m3)) {
616
- const deepKey = `${newKeyToUse}${keySeparator}${m3}`;
617
- if (hasDefaultValue && !res) {
618
- copy2[m3] = this.translate(deepKey, {
619
- ...opt,
620
- defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m3] : void 0,
621
- ...{
622
- joinArrays: false,
623
- ns: namespaces
624
- }
625
- });
626
- } else {
627
- copy2[m3] = this.translate(deepKey, {
628
- ...opt,
629
- ...{
630
- joinArrays: false,
631
- ns: namespaces
632
- }
633
- });
634
- }
635
- if (copy2[m3] === deepKey) copy2[m3] = resForObjHndl[m3];
636
- }
637
- }
638
- res = copy2;
639
- }
640
- } else if (handleAsObjectInI18nFormat && isString$3(joinArrays) && Array.isArray(res)) {
641
- res = res.join(joinArrays);
642
- if (res) res = this.extendTranslation(res, keys, opt, lastKey);
643
- } else {
644
- let usedDefault = false;
645
- let usedKey = false;
646
- if (!this.isValidLookup(res) && hasDefaultValue) {
647
- usedDefault = true;
648
- res = defaultValue;
649
- }
650
- if (!this.isValidLookup(res)) {
651
- usedKey = true;
652
- res = key;
653
- }
654
- const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
655
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
656
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
657
- if (usedKey || usedDefault || updateMissing) {
658
- this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
659
- if (keySeparator) {
660
- const fk = this.resolve(key, {
661
- ...opt,
662
- keySeparator: false
663
- });
664
- 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.");
665
- }
666
- let lngs = [];
667
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
668
- if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
669
- for (let i3 = 0; i3 < fallbackLngs.length; i3++) {
670
- lngs.push(fallbackLngs[i3]);
671
- }
672
- } else if (this.options.saveMissingTo === "all") {
673
- lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
674
- } else {
675
- lngs.push(opt.lng || this.language);
676
- }
677
- const send = (l, k2, specificDefaultValue) => {
678
- var _a;
679
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
680
- if (this.options.missingKeyHandler) {
681
- this.options.missingKeyHandler(l, namespace, k2, defaultForMissing, updateMissing, opt);
682
- } else if ((_a = this.backendConnector) == null ? void 0 : _a.saveMissing) {
683
- this.backendConnector.saveMissing(l, namespace, k2, defaultForMissing, updateMissing, opt);
684
- }
685
- this.emit("missingKey", l, namespace, k2, res);
686
- };
687
- if (this.options.saveMissing) {
688
- if (this.options.saveMissingPlurals && needsPluralHandling) {
689
- lngs.forEach((language) => {
690
- const suffixes = this.pluralResolver.getSuffixes(language, opt);
691
- if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
692
- suffixes.push(`${this.options.pluralSeparator}zero`);
693
- }
694
- suffixes.forEach((suffix) => {
695
- send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
696
- });
697
- });
698
- } else {
699
- send(lngs, key, defaultValue);
700
- }
701
- }
702
- }
703
- res = this.extendTranslation(res, keys, opt, resolved, lastKey);
704
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
705
- res = `${namespace}${nsSeparator}${key}`;
706
- }
707
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
708
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
709
- }
710
- }
711
- if (returnDetails) {
712
- resolved.res = res;
713
- resolved.usedParams = this.getUsedParamsDetails(opt);
714
- return resolved;
715
- }
716
- return res;
717
- }
718
- extendTranslation(res, key, opt, resolved, lastKey) {
719
- var _a, _b;
720
- if ((_a = this.i18nFormat) == null ? void 0 : _a.parse) {
721
- res = this.i18nFormat.parse(res, {
722
- ...this.options.interpolation.defaultVariables,
723
- ...opt
724
- }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
725
- resolved
726
- });
727
- } else if (!opt.skipInterpolation) {
728
- if (opt.interpolation) this.interpolator.init({
729
- ...opt,
730
- ...{
731
- interpolation: {
732
- ...this.options.interpolation,
733
- ...opt.interpolation
734
- }
735
- }
736
- });
737
- const skipOnVariables = isString$3(res) && (((_b = opt == null ? void 0 : opt.interpolation) == null ? void 0 : _b.skipOnVariables) !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
738
- let nestBef;
739
- if (skipOnVariables) {
740
- const nb = res.match(this.interpolator.nestingRegexp);
741
- nestBef = nb && nb.length;
742
- }
743
- let data = opt.replace && !isString$3(opt.replace) ? opt.replace : opt;
744
- if (this.options.interpolation.defaultVariables) data = {
745
- ...this.options.interpolation.defaultVariables,
746
- ...data
747
- };
748
- res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
749
- if (skipOnVariables) {
750
- const na = res.match(this.interpolator.nestingRegexp);
751
- const nestAft = na && na.length;
752
- if (nestBef < nestAft) opt.nest = false;
753
- }
754
- if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
755
- if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
756
- if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !opt.context) {
757
- this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
758
- return null;
759
- }
760
- return this.translate(...args, key);
761
- }, opt);
762
- if (opt.interpolation) this.interpolator.reset();
763
- }
764
- const postProcess = opt.postProcess || this.options.postProcess;
765
- const postProcessorNames = isString$3(postProcess) ? [postProcess] : postProcess;
766
- if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) && opt.applyPostProcessor !== false) {
767
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
768
- i18nResolved: {
769
- ...resolved,
770
- usedParams: this.getUsedParamsDetails(opt)
771
- },
772
- ...opt
773
- } : opt, this);
774
- }
775
- return res;
776
- }
777
- resolve(keys, opt = {}) {
778
- let found;
779
- let usedKey;
780
- let exactUsedKey;
781
- let usedLng;
782
- let usedNS;
783
- if (isString$3(keys)) keys = [keys];
784
- keys.forEach((k2) => {
785
- if (this.isValidLookup(found)) return;
786
- const extracted = this.extractFromKey(k2, opt);
787
- const key = extracted.key;
788
- usedKey = key;
789
- let namespaces = extracted.namespaces;
790
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
791
- const needsPluralHandling = opt.count !== void 0 && !isString$3(opt.count);
792
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
793
- const needsContextHandling = opt.context !== void 0 && (isString$3(opt.context) || typeof opt.context === "number") && opt.context !== "";
794
- const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
795
- namespaces.forEach((ns) => {
796
- var _a, _b;
797
- if (this.isValidLookup(found)) return;
798
- usedNS = ns;
799
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && ((_a = this.utils) == null ? void 0 : _a.hasLoadedNamespace) && !((_b = this.utils) == null ? void 0 : _b.hasLoadedNamespace(usedNS))) {
800
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
801
- 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!!!");
802
- }
803
- codes.forEach((code) => {
804
- var _a2;
805
- if (this.isValidLookup(found)) return;
806
- usedLng = code;
807
- const finalKeys = [key];
808
- if ((_a2 = this.i18nFormat) == null ? void 0 : _a2.addLookupKeys) {
809
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
810
- } else {
811
- let pluralSuffix;
812
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
813
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
814
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
815
- if (needsPluralHandling) {
816
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
817
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
818
- }
819
- finalKeys.push(key + pluralSuffix);
820
- if (needsZeroSuffixLookup) {
821
- finalKeys.push(key + zeroSuffix);
822
- }
823
- }
824
- if (needsContextHandling) {
825
- const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
826
- finalKeys.push(contextKey);
827
- if (needsPluralHandling) {
828
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
829
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
830
- }
831
- finalKeys.push(contextKey + pluralSuffix);
832
- if (needsZeroSuffixLookup) {
833
- finalKeys.push(contextKey + zeroSuffix);
834
- }
835
- }
836
- }
837
- }
838
- let possibleKey;
839
- while (possibleKey = finalKeys.pop()) {
840
- if (!this.isValidLookup(found)) {
841
- exactUsedKey = possibleKey;
842
- found = this.getResource(code, ns, possibleKey, opt);
843
- }
844
- }
845
- });
846
- });
847
- });
848
- return {
849
- res: found,
850
- usedKey,
851
- exactUsedKey,
852
- usedLng,
853
- usedNS
854
- };
855
- }
856
- isValidLookup(res) {
857
- return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
858
- }
859
- getResource(code, ns, key, options = {}) {
860
- var _a;
861
- if ((_a = this.i18nFormat) == null ? void 0 : _a.getResource) return this.i18nFormat.getResource(code, ns, key, options);
862
- return this.resourceStore.getResource(code, ns, key, options);
863
- }
864
- getUsedParamsDetails(options = {}) {
865
- const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
866
- const useOptionsReplaceForData = options.replace && !isString$3(options.replace);
867
- let data = useOptionsReplaceForData ? options.replace : options;
868
- if (useOptionsReplaceForData && typeof options.count !== "undefined") {
869
- data.count = options.count;
870
- }
871
- if (this.options.interpolation.defaultVariables) {
872
- data = {
873
- ...this.options.interpolation.defaultVariables,
874
- ...data
875
- };
876
- }
877
- if (!useOptionsReplaceForData) {
878
- data = {
879
- ...data
880
- };
881
- for (const key of optionsKeys) {
882
- delete data[key];
883
- }
884
- }
885
- return data;
886
- }
887
- static hasDefaultValue(options) {
888
- const prefix = "defaultValue";
889
- for (const option in options) {
890
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && void 0 !== options[option]) {
891
- return true;
892
- }
893
- }
894
- return false;
895
- }
896
- }
897
- class LanguageUtil {
898
- constructor(options) {
899
- this.options = options;
900
- this.supportedLngs = this.options.supportedLngs || false;
901
- this.logger = baseLogger.create("languageUtils");
902
- }
903
- getScriptPartFromCode(code) {
904
- code = getCleanedCode(code);
905
- if (!code || code.indexOf("-") < 0) return null;
906
- const p = code.split("-");
907
- if (p.length === 2) return null;
908
- p.pop();
909
- if (p[p.length - 1].toLowerCase() === "x") return null;
910
- return this.formatLanguageCode(p.join("-"));
911
- }
912
- getLanguagePartFromCode(code) {
913
- code = getCleanedCode(code);
914
- if (!code || code.indexOf("-") < 0) return code;
915
- const p = code.split("-");
916
- return this.formatLanguageCode(p[0]);
917
- }
918
- formatLanguageCode(code) {
919
- if (isString$3(code) && code.indexOf("-") > -1) {
920
- let formattedCode;
921
- try {
922
- formattedCode = Intl.getCanonicalLocales(code)[0];
923
- } catch (e2) {
924
- }
925
- if (formattedCode && this.options.lowerCaseLng) {
926
- formattedCode = formattedCode.toLowerCase();
927
- }
928
- if (formattedCode) return formattedCode;
929
- if (this.options.lowerCaseLng) {
930
- return code.toLowerCase();
931
- }
932
- return code;
933
- }
934
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
935
- }
936
- isSupportedCode(code) {
937
- if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
938
- code = this.getLanguagePartFromCode(code);
939
- }
940
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
941
- }
942
- getBestMatchFromCodes(codes) {
943
- if (!codes) return null;
944
- let found;
945
- codes.forEach((code) => {
946
- if (found) return;
947
- const cleanedLng = this.formatLanguageCode(code);
948
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
949
- });
950
- if (!found && this.options.supportedLngs) {
951
- codes.forEach((code) => {
952
- if (found) return;
953
- const lngScOnly = this.getScriptPartFromCode(code);
954
- if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
955
- const lngOnly = this.getLanguagePartFromCode(code);
956
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
957
- found = this.options.supportedLngs.find((supportedLng) => {
958
- if (supportedLng === lngOnly) return supportedLng;
959
- if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
960
- if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
961
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
962
- });
963
- });
964
- }
965
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
966
- return found;
967
- }
968
- getFallbackCodes(fallbacks, code) {
969
- if (!fallbacks) return [];
970
- if (typeof fallbacks === "function") fallbacks = fallbacks(code);
971
- if (isString$3(fallbacks)) fallbacks = [fallbacks];
972
- if (Array.isArray(fallbacks)) return fallbacks;
973
- if (!code) return fallbacks.default || [];
974
- let found = fallbacks[code];
975
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
976
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
977
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
978
- if (!found) found = fallbacks.default;
979
- return found || [];
980
- }
981
- toResolveHierarchy(code, fallbackCode) {
982
- const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
983
- const codes = [];
984
- const addCode = (c2) => {
985
- if (!c2) return;
986
- if (this.isSupportedCode(c2)) {
987
- codes.push(c2);
988
- } else {
989
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c2}`);
990
- }
991
- };
992
- if (isString$3(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
993
- if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
994
- if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
995
- if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
996
- } else if (isString$3(code)) {
997
- addCode(this.formatLanguageCode(code));
998
- }
999
- fallbackCodes.forEach((fc) => {
1000
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
1001
- });
1002
- return codes;
1003
- }
1004
- }
1005
- const suffixesOrder = {
1006
- zero: 0,
1007
- one: 1,
1008
- two: 2,
1009
- few: 3,
1010
- many: 4,
1011
- other: 5
1012
- };
1013
- const dummyRule = {
1014
- select: (count) => count === 1 ? "one" : "other",
1015
- resolvedOptions: () => ({
1016
- pluralCategories: ["one", "other"]
1017
- })
1018
- };
1019
- class PluralResolver {
1020
- constructor(languageUtils, options = {}) {
1021
- this.languageUtils = languageUtils;
1022
- this.options = options;
1023
- this.logger = baseLogger.create("pluralResolver");
1024
- this.pluralRulesCache = {};
1025
- }
1026
- addRule(lng, obj) {
1027
- this.rules[lng] = obj;
1028
- }
1029
- clearCache() {
1030
- this.pluralRulesCache = {};
1031
- }
1032
- getRule(code, options = {}) {
1033
- const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
1034
- const type = options.ordinal ? "ordinal" : "cardinal";
1035
- const cacheKey = JSON.stringify({
1036
- cleanedCode,
1037
- type
1038
- });
1039
- if (cacheKey in this.pluralRulesCache) {
1040
- return this.pluralRulesCache[cacheKey];
1041
- }
1042
- let rule;
1043
- try {
1044
- rule = new Intl.PluralRules(cleanedCode, {
1045
- type
1046
- });
1047
- } catch (err) {
1048
- if (!Intl) {
1049
- this.logger.error("No Intl support, please use an Intl polyfill!");
1050
- return dummyRule;
1051
- }
1052
- if (!code.match(/-|_/)) return dummyRule;
1053
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1054
- rule = this.getRule(lngPart, options);
1055
- }
1056
- this.pluralRulesCache[cacheKey] = rule;
1057
- return rule;
1058
- }
1059
- needsPlural(code, options = {}) {
1060
- let rule = this.getRule(code, options);
1061
- if (!rule) rule = this.getRule("dev", options);
1062
- return (rule == null ? void 0 : rule.resolvedOptions().pluralCategories.length) > 1;
1063
- }
1064
- getPluralFormsOfKey(code, key, options = {}) {
1065
- return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
1066
- }
1067
- getSuffixes(code, options = {}) {
1068
- let rule = this.getRule(code, options);
1069
- if (!rule) rule = this.getRule("dev", options);
1070
- if (!rule) return [];
1071
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
1072
- }
1073
- getSuffix(code, count, options = {}) {
1074
- const rule = this.getRule(code, options);
1075
- if (rule) {
1076
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
1077
- }
1078
- this.logger.warn(`no plural rule found for: ${code}`);
1079
- return this.getSuffix("dev", count, options);
1080
- }
1081
- }
1082
- const deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
1083
- let path = getPathWithDefaults(data, defaultData, key);
1084
- if (!path && ignoreJSONStructure && isString$3(key)) {
1085
- path = deepFind(data, key, keySeparator);
1086
- if (path === void 0) path = deepFind(defaultData, key, keySeparator);
1087
- }
1088
- return path;
1089
- };
1090
- const regexSafe = (val) => val.replace(/\$/g, "$$$$");
1091
- class Interpolator {
1092
- constructor(options = {}) {
1093
- var _a;
1094
- this.logger = baseLogger.create("interpolator");
1095
- this.options = options;
1096
- this.format = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.format) || ((value) => value);
1097
- this.init(options);
1098
- }
1099
- init(options = {}) {
1100
- if (!options.interpolation) options.interpolation = {
1101
- escapeValue: true
1102
- };
1103
- const {
1104
- escape: escape$1,
1105
- escapeValue,
1106
- useRawValueToEscape,
1107
- prefix,
1108
- prefixEscaped,
1109
- suffix,
1110
- suffixEscaped,
1111
- formatSeparator,
1112
- unescapeSuffix,
1113
- unescapePrefix,
1114
- nestingPrefix,
1115
- nestingPrefixEscaped,
1116
- nestingSuffix,
1117
- nestingSuffixEscaped,
1118
- nestingOptionsSeparator,
1119
- maxReplaces,
1120
- alwaysFormat
1121
- } = options.interpolation;
1122
- this.escape = escape$1 !== void 0 ? escape$1 : escape;
1123
- this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
1124
- this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
1125
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
1126
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
1127
- this.formatSeparator = formatSeparator || ",";
1128
- this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
1129
- this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
1130
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
1131
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
1132
- this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
1133
- this.maxReplaces = maxReplaces || 1e3;
1134
- this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
1135
- this.resetRegExp();
1136
- }
1137
- reset() {
1138
- if (this.options) this.init(this.options);
1139
- }
1140
- resetRegExp() {
1141
- const getOrResetRegExp = (existingRegExp, pattern) => {
1142
- if ((existingRegExp == null ? void 0 : existingRegExp.source) === pattern) {
1143
- existingRegExp.lastIndex = 0;
1144
- return existingRegExp;
1145
- }
1146
- return new RegExp(pattern, "g");
1147
- };
1148
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1149
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1150
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
1151
- }
1152
- interpolate(str, data, lng, options) {
1153
- var _a;
1154
- let match2;
1155
- let value;
1156
- let replaces;
1157
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1158
- const handleFormat = (key) => {
1159
- if (key.indexOf(this.formatSeparator) < 0) {
1160
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1161
- return this.alwaysFormat ? this.format(path, void 0, lng, {
1162
- ...options,
1163
- ...data,
1164
- interpolationkey: key
1165
- }) : path;
1166
- }
1167
- const p = key.split(this.formatSeparator);
1168
- const k2 = p.shift().trim();
1169
- const f = p.join(this.formatSeparator).trim();
1170
- return this.format(deepFindWithDefaults(data, defaultData, k2, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1171
- ...options,
1172
- ...data,
1173
- interpolationkey: k2
1174
- });
1175
- };
1176
- this.resetRegExp();
1177
- const missingInterpolationHandler = (options == null ? void 0 : options.missingInterpolationHandler) || this.options.missingInterpolationHandler;
1178
- const skipOnVariables = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.skipOnVariables) !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1179
- const todos = [{
1180
- regex: this.regexpUnescape,
1181
- safeValue: (val) => regexSafe(val)
1182
- }, {
1183
- regex: this.regexp,
1184
- safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1185
- }];
1186
- todos.forEach((todo) => {
1187
- replaces = 0;
1188
- while (match2 = todo.regex.exec(str)) {
1189
- const matchedVar = match2[1].trim();
1190
- value = handleFormat(matchedVar);
1191
- if (value === void 0) {
1192
- if (typeof missingInterpolationHandler === "function") {
1193
- const temp = missingInterpolationHandler(str, match2, options);
1194
- value = isString$3(temp) ? temp : "";
1195
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1196
- value = "";
1197
- } else if (skipOnVariables) {
1198
- value = match2[0];
1199
- continue;
1200
- } else {
1201
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1202
- value = "";
1203
- }
1204
- } else if (!isString$3(value) && !this.useRawValueToEscape) {
1205
- value = makeString(value);
1206
- }
1207
- const safeValue = todo.safeValue(value);
1208
- str = str.replace(match2[0], safeValue);
1209
- if (skipOnVariables) {
1210
- todo.regex.lastIndex += value.length;
1211
- todo.regex.lastIndex -= match2[0].length;
1212
- } else {
1213
- todo.regex.lastIndex = 0;
1214
- }
1215
- replaces++;
1216
- if (replaces >= this.maxReplaces) {
1217
- break;
1218
- }
1219
- }
1220
- });
1221
- return str;
1222
- }
1223
- nest(str, fc, options = {}) {
1224
- let match2;
1225
- let value;
1226
- let clonedOptions;
1227
- const handleHasOptions = (key, inheritedOptions) => {
1228
- const sep = this.nestingOptionsSeparator;
1229
- if (key.indexOf(sep) < 0) return key;
1230
- const c2 = key.split(new RegExp(`${sep}[ ]*{`));
1231
- let optionsString = `{${c2[1]}`;
1232
- key = c2[0];
1233
- optionsString = this.interpolate(optionsString, clonedOptions);
1234
- const matchedSingleQuotes = optionsString.match(/'/g);
1235
- const matchedDoubleQuotes = optionsString.match(/"/g);
1236
- if (((matchedSingleQuotes == null ? void 0 : matchedSingleQuotes.length) ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1237
- optionsString = optionsString.replace(/'/g, '"');
1238
- }
1239
- try {
1240
- clonedOptions = JSON.parse(optionsString);
1241
- if (inheritedOptions) clonedOptions = {
1242
- ...inheritedOptions,
1243
- ...clonedOptions
1244
- };
1245
- } catch (e2) {
1246
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e2);
1247
- return `${key}${sep}${optionsString}`;
1248
- }
1249
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1250
- return key;
1251
- };
1252
- while (match2 = this.nestingRegexp.exec(str)) {
1253
- let formatters2 = [];
1254
- clonedOptions = {
1255
- ...options
1256
- };
1257
- clonedOptions = clonedOptions.replace && !isString$3(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1258
- clonedOptions.applyPostProcessor = false;
1259
- delete clonedOptions.defaultValue;
1260
- const keyEndIndex = /{.*}/.test(match2[1]) ? match2[1].lastIndexOf("}") + 1 : match2[1].indexOf(this.formatSeparator);
1261
- if (keyEndIndex !== -1) {
1262
- formatters2 = match2[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
1263
- match2[1] = match2[1].slice(0, keyEndIndex);
1264
- }
1265
- value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
1266
- if (value && match2[0] === str && !isString$3(value)) return value;
1267
- if (!isString$3(value)) value = makeString(value);
1268
- if (!value) {
1269
- this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
1270
- value = "";
1271
- }
1272
- if (formatters2.length) {
1273
- value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
1274
- ...options,
1275
- interpolationkey: match2[1].trim()
1276
- }), value.trim());
1277
- }
1278
- str = str.replace(match2[0], value);
1279
- this.regexp.lastIndex = 0;
1280
- }
1281
- return str;
1282
- }
1283
- }
1284
- const parseFormatStr = (formatStr) => {
1285
- let formatName = formatStr.toLowerCase().trim();
1286
- const formatOptions = {};
1287
- if (formatStr.indexOf("(") > -1) {
1288
- const p = formatStr.split("(");
1289
- formatName = p[0].toLowerCase().trim();
1290
- const optStr = p[1].substring(0, p[1].length - 1);
1291
- if (formatName === "currency" && optStr.indexOf(":") < 0) {
1292
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1293
- } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
1294
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1295
- } else {
1296
- const opts = optStr.split(";");
1297
- opts.forEach((opt) => {
1298
- if (opt) {
1299
- const [key, ...rest] = opt.split(":");
1300
- const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
1301
- const trimmedKey = key.trim();
1302
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1303
- if (val === "false") formatOptions[trimmedKey] = false;
1304
- if (val === "true") formatOptions[trimmedKey] = true;
1305
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1306
- }
1307
- });
1308
- }
1309
- }
1310
- return {
1311
- formatName,
1312
- formatOptions
1313
- };
1314
- };
1315
- const createCachedFormatter = (fn2) => {
1316
- const cache = {};
1317
- return (v, l, o2) => {
1318
- let optForCache = o2;
1319
- if (o2 && o2.interpolationkey && o2.formatParams && o2.formatParams[o2.interpolationkey] && o2[o2.interpolationkey]) {
1320
- optForCache = {
1321
- ...optForCache,
1322
- [o2.interpolationkey]: void 0
1323
- };
1324
- }
1325
- const key = l + JSON.stringify(optForCache);
1326
- let frm = cache[key];
1327
- if (!frm) {
1328
- frm = fn2(getCleanedCode(l), o2);
1329
- cache[key] = frm;
1330
- }
1331
- return frm(v);
1332
- };
1333
- };
1334
- const createNonCachedFormatter = (fn2) => (v, l, o2) => fn2(getCleanedCode(l), o2)(v);
1335
- class Formatter {
1336
- constructor(options = {}) {
1337
- this.logger = baseLogger.create("formatter");
1338
- this.options = options;
1339
- this.init(options);
1340
- }
1341
- init(services, options = {
1342
- interpolation: {}
1343
- }) {
1344
- this.formatSeparator = options.interpolation.formatSeparator || ",";
1345
- const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1346
- this.formats = {
1347
- number: cf((lng, opt) => {
1348
- const formatter = new Intl.NumberFormat(lng, {
1349
- ...opt
1350
- });
1351
- return (val) => formatter.format(val);
1352
- }),
1353
- currency: cf((lng, opt) => {
1354
- const formatter = new Intl.NumberFormat(lng, {
1355
- ...opt,
1356
- style: "currency"
1357
- });
1358
- return (val) => formatter.format(val);
1359
- }),
1360
- datetime: cf((lng, opt) => {
1361
- const formatter = new Intl.DateTimeFormat(lng, {
1362
- ...opt
1363
- });
1364
- return (val) => formatter.format(val);
1365
- }),
1366
- relativetime: cf((lng, opt) => {
1367
- const formatter = new Intl.RelativeTimeFormat(lng, {
1368
- ...opt
1369
- });
1370
- return (val) => formatter.format(val, opt.range || "day");
1371
- }),
1372
- list: cf((lng, opt) => {
1373
- const formatter = new Intl.ListFormat(lng, {
1374
- ...opt
1375
- });
1376
- return (val) => formatter.format(val);
1377
- })
1378
- };
1379
- }
1380
- add(name, fc) {
1381
- this.formats[name.toLowerCase().trim()] = fc;
1382
- }
1383
- addCached(name, fc) {
1384
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1385
- }
1386
- format(value, format2, lng, options = {}) {
1387
- const formats = format2.split(this.formatSeparator);
1388
- if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
1389
- const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
1390
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1391
- }
1392
- const result = formats.reduce((mem, f) => {
1393
- var _a;
1394
- const {
1395
- formatName,
1396
- formatOptions
1397
- } = parseFormatStr(f);
1398
- if (this.formats[formatName]) {
1399
- let formatted = mem;
1400
- try {
1401
- const valOptions = ((_a = options == null ? void 0 : options.formatParams) == null ? void 0 : _a[options.interpolationkey]) || {};
1402
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1403
- formatted = this.formats[formatName](mem, l, {
1404
- ...formatOptions,
1405
- ...options,
1406
- ...valOptions
1407
- });
1408
- } catch (error) {
1409
- this.logger.warn(error);
1410
- }
1411
- return formatted;
1412
- } else {
1413
- this.logger.warn(`there was no format function for ${formatName}`);
1414
- }
1415
- return mem;
1416
- }, value);
1417
- return result;
1418
- }
1419
- }
1420
- const removePending = (q2, name) => {
1421
- if (q2.pending[name] !== void 0) {
1422
- delete q2.pending[name];
1423
- q2.pendingCount--;
1424
- }
1425
- };
1426
- class Connector extends EventEmitter {
1427
- constructor(backend, store, services, options = {}) {
1428
- var _a, _b;
1429
- super();
1430
- this.backend = backend;
1431
- this.store = store;
1432
- this.services = services;
1433
- this.languageUtils = services.languageUtils;
1434
- this.options = options;
1435
- this.logger = baseLogger.create("backendConnector");
1436
- this.waitingReads = [];
1437
- this.maxParallelReads = options.maxParallelReads || 10;
1438
- this.readingCalls = 0;
1439
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1440
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1441
- this.state = {};
1442
- this.queue = [];
1443
- (_b = (_a = this.backend) == null ? void 0 : _a.init) == null ? void 0 : _b.call(_a, services, options.backend, options);
1444
- }
1445
- queueLoad(languages, namespaces, options, callback) {
1446
- const toLoad = {};
1447
- const pending = {};
1448
- const toLoadLanguages = {};
1449
- const toLoadNamespaces = {};
1450
- languages.forEach((lng) => {
1451
- let hasAllNamespaces = true;
1452
- namespaces.forEach((ns) => {
1453
- const name = `${lng}|${ns}`;
1454
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1455
- this.state[name] = 2;
1456
- } else if (this.state[name] < 0) ;
1457
- else if (this.state[name] === 1) {
1458
- if (pending[name] === void 0) pending[name] = true;
1459
- } else {
1460
- this.state[name] = 1;
1461
- hasAllNamespaces = false;
1462
- if (pending[name] === void 0) pending[name] = true;
1463
- if (toLoad[name] === void 0) toLoad[name] = true;
1464
- if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
1465
- }
1466
- });
1467
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1468
- });
1469
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
1470
- this.queue.push({
1471
- pending,
1472
- pendingCount: Object.keys(pending).length,
1473
- loaded: {},
1474
- errors: [],
1475
- callback
1476
- });
1477
- }
1478
- return {
1479
- toLoad: Object.keys(toLoad),
1480
- pending: Object.keys(pending),
1481
- toLoadLanguages: Object.keys(toLoadLanguages),
1482
- toLoadNamespaces: Object.keys(toLoadNamespaces)
1483
- };
1484
- }
1485
- loaded(name, err, data) {
1486
- const s4 = name.split("|");
1487
- const lng = s4[0];
1488
- const ns = s4[1];
1489
- if (err) this.emit("failedLoading", lng, ns, err);
1490
- if (!err && data) {
1491
- this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
1492
- skipCopy: true
1493
- });
1494
- }
1495
- this.state[name] = err ? -1 : 2;
1496
- if (err && data) this.state[name] = 0;
1497
- const loaded = {};
1498
- this.queue.forEach((q2) => {
1499
- pushPath(q2.loaded, [lng], ns);
1500
- removePending(q2, name);
1501
- if (err) q2.errors.push(err);
1502
- if (q2.pendingCount === 0 && !q2.done) {
1503
- Object.keys(q2.loaded).forEach((l) => {
1504
- if (!loaded[l]) loaded[l] = {};
1505
- const loadedKeys = q2.loaded[l];
1506
- if (loadedKeys.length) {
1507
- loadedKeys.forEach((n2) => {
1508
- if (loaded[l][n2] === void 0) loaded[l][n2] = true;
1509
- });
1510
- }
1511
- });
1512
- q2.done = true;
1513
- if (q2.errors.length) {
1514
- q2.callback(q2.errors);
1515
- } else {
1516
- q2.callback();
1517
- }
1518
- }
1519
- });
1520
- this.emit("loaded", loaded);
1521
- this.queue = this.queue.filter((q2) => !q2.done);
1522
- }
1523
- read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1524
- if (!lng.length) return callback(null, {});
1525
- if (this.readingCalls >= this.maxParallelReads) {
1526
- this.waitingReads.push({
1527
- lng,
1528
- ns,
1529
- fcName,
1530
- tried,
1531
- wait,
1532
- callback
1533
- });
1534
- return;
1535
- }
1536
- this.readingCalls++;
1537
- const resolver = (err, data) => {
1538
- this.readingCalls--;
1539
- if (this.waitingReads.length > 0) {
1540
- const next = this.waitingReads.shift();
1541
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1542
- }
1543
- if (err && data && tried < this.maxRetries) {
1544
- setTimeout(() => {
1545
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1546
- }, wait);
1547
- return;
1548
- }
1549
- callback(err, data);
1550
- };
1551
- const fc = this.backend[fcName].bind(this.backend);
1552
- if (fc.length === 2) {
1553
- try {
1554
- const r2 = fc(lng, ns);
1555
- if (r2 && typeof r2.then === "function") {
1556
- r2.then((data) => resolver(null, data)).catch(resolver);
1557
- } else {
1558
- resolver(null, r2);
1559
- }
1560
- } catch (err) {
1561
- resolver(err);
1562
- }
1563
- return;
1564
- }
1565
- return fc(lng, ns, resolver);
1566
- }
1567
- prepareLoading(languages, namespaces, options = {}, callback) {
1568
- if (!this.backend) {
1569
- this.logger.warn("No backend was added via i18next.use. Will not load resources.");
1570
- return callback && callback();
1571
- }
1572
- if (isString$3(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1573
- if (isString$3(namespaces)) namespaces = [namespaces];
1574
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
1575
- if (!toLoad.toLoad.length) {
1576
- if (!toLoad.pending.length) callback();
1577
- return null;
1578
- }
1579
- toLoad.toLoad.forEach((name) => {
1580
- this.loadOne(name);
1581
- });
1582
- }
1583
- load(languages, namespaces, callback) {
1584
- this.prepareLoading(languages, namespaces, {}, callback);
1585
- }
1586
- reload(languages, namespaces, callback) {
1587
- this.prepareLoading(languages, namespaces, {
1588
- reload: true
1589
- }, callback);
1590
- }
1591
- loadOne(name, prefix = "") {
1592
- const s4 = name.split("|");
1593
- const lng = s4[0];
1594
- const ns = s4[1];
1595
- this.read(lng, ns, "read", void 0, void 0, (err, data) => {
1596
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1597
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1598
- this.loaded(name, err, data);
1599
- });
1600
- }
1601
- saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
1602
- }) {
1603
- var _a, _b, _c, _d, _e;
1604
- if (((_b = (_a = this.services) == null ? void 0 : _a.utils) == null ? void 0 : _b.hasLoadedNamespace) && !((_d = (_c = this.services) == null ? void 0 : _c.utils) == null ? void 0 : _d.hasLoadedNamespace(namespace))) {
1605
- 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!!!");
1606
- return;
1607
- }
1608
- if (key === void 0 || key === null || key === "") return;
1609
- if ((_e = this.backend) == null ? void 0 : _e.create) {
1610
- const opts = {
1611
- ...options,
1612
- isUpdate
1613
- };
1614
- const fc = this.backend.create.bind(this.backend);
1615
- if (fc.length < 6) {
1616
- try {
1617
- let r2;
1618
- if (fc.length === 5) {
1619
- r2 = fc(languages, namespace, key, fallbackValue, opts);
1620
- } else {
1621
- r2 = fc(languages, namespace, key, fallbackValue);
1622
- }
1623
- if (r2 && typeof r2.then === "function") {
1624
- r2.then((data) => clb(null, data)).catch(clb);
1625
- } else {
1626
- clb(null, r2);
1627
- }
1628
- } catch (err) {
1629
- clb(err);
1630
- }
1631
- } else {
1632
- fc(languages, namespace, key, fallbackValue, clb, opts);
1633
- }
1634
- }
1635
- if (!languages || !languages[0]) return;
1636
- this.store.addResource(languages[0], namespace, key, fallbackValue);
1637
- }
1638
- }
1639
- const get$1 = () => ({
1640
- debug: false,
1641
- initAsync: true,
1642
- ns: ["translation"],
1643
- defaultNS: ["translation"],
1644
- fallbackLng: ["dev"],
1645
- fallbackNS: false,
1646
- supportedLngs: false,
1647
- nonExplicitSupportedLngs: false,
1648
- load: "all",
1649
- preload: false,
1650
- simplifyPluralSuffix: true,
1651
- keySeparator: ".",
1652
- nsSeparator: ":",
1653
- pluralSeparator: "_",
1654
- contextSeparator: "_",
1655
- partialBundledLanguages: false,
1656
- saveMissing: false,
1657
- updateMissing: false,
1658
- saveMissingTo: "fallback",
1659
- saveMissingPlurals: true,
1660
- missingKeyHandler: false,
1661
- missingInterpolationHandler: false,
1662
- postProcess: false,
1663
- postProcessPassResolved: false,
1664
- returnNull: false,
1665
- returnEmptyString: true,
1666
- returnObjects: false,
1667
- joinArrays: false,
1668
- returnedObjectHandler: false,
1669
- parseMissingKeyHandler: false,
1670
- appendNamespaceToMissingKey: false,
1671
- appendNamespaceToCIMode: false,
1672
- overloadTranslationOptionHandler: (args) => {
1673
- let ret = {};
1674
- if (typeof args[1] === "object") ret = args[1];
1675
- if (isString$3(args[1])) ret.defaultValue = args[1];
1676
- if (isString$3(args[2])) ret.tDescription = args[2];
1677
- if (typeof args[2] === "object" || typeof args[3] === "object") {
1678
- const options = args[3] || args[2];
1679
- Object.keys(options).forEach((key) => {
1680
- ret[key] = options[key];
1681
- });
1682
- }
1683
- return ret;
1684
- },
1685
- interpolation: {
1686
- escapeValue: true,
1687
- format: (value) => value,
1688
- prefix: "{{",
1689
- suffix: "}}",
1690
- formatSeparator: ",",
1691
- unescapePrefix: "-",
1692
- nestingPrefix: "$t(",
1693
- nestingSuffix: ")",
1694
- nestingOptionsSeparator: ",",
1695
- maxReplaces: 1e3,
1696
- skipOnVariables: true
1697
- },
1698
- cacheInBuiltFormats: true
1699
- });
1700
- const transformOptions = (options) => {
1701
- var _a, _b;
1702
- if (isString$3(options.ns)) options.ns = [options.ns];
1703
- if (isString$3(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1704
- if (isString$3(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1705
- if (((_b = (_a = options.supportedLngs) == null ? void 0 : _a.indexOf) == null ? void 0 : _b.call(_a, "cimode")) < 0) {
1706
- options.supportedLngs = options.supportedLngs.concat(["cimode"]);
1707
- }
1708
- if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
1709
- return options;
1710
- };
1711
- const noop$5 = () => {
1712
- };
1713
- const bindMemberFunctions = (inst) => {
1714
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1715
- mems.forEach((mem) => {
1716
- if (typeof inst[mem] === "function") {
1717
- inst[mem] = inst[mem].bind(inst);
1718
- }
1719
- });
1720
- };
1721
- class I18n extends EventEmitter {
1722
- constructor(options = {}, callback) {
1723
- super();
1724
- this.options = transformOptions(options);
1725
- this.services = {};
1726
- this.logger = baseLogger;
1727
- this.modules = {
1728
- external: []
1729
- };
1730
- bindMemberFunctions(this);
1731
- if (callback && !this.isInitialized && !options.isClone) {
1732
- if (!this.options.initAsync) {
1733
- this.init(options, callback);
1734
- return this;
1735
- }
1736
- setTimeout(() => {
1737
- this.init(options, callback);
1738
- }, 0);
1739
- }
1740
- }
1741
- init(options = {}, callback) {
1742
- this.isInitializing = true;
1743
- if (typeof options === "function") {
1744
- callback = options;
1745
- options = {};
1746
- }
1747
- if (options.defaultNS == null && options.ns) {
1748
- if (isString$3(options.ns)) {
1749
- options.defaultNS = options.ns;
1750
- } else if (options.ns.indexOf("translation") < 0) {
1751
- options.defaultNS = options.ns[0];
1752
- }
1753
- }
1754
- const defOpts = get$1();
1755
- this.options = {
1756
- ...defOpts,
1757
- ...this.options,
1758
- ...transformOptions(options)
1759
- };
1760
- this.options.interpolation = {
1761
- ...defOpts.interpolation,
1762
- ...this.options.interpolation
1763
- };
1764
- if (options.keySeparator !== void 0) {
1765
- this.options.userDefinedKeySeparator = options.keySeparator;
1766
- }
1767
- if (options.nsSeparator !== void 0) {
1768
- this.options.userDefinedNsSeparator = options.nsSeparator;
1769
- }
1770
- const createClassOnDemand = (ClassOrObject) => {
1771
- if (!ClassOrObject) return null;
1772
- if (typeof ClassOrObject === "function") return new ClassOrObject();
1773
- return ClassOrObject;
1774
- };
1775
- if (!this.options.isClone) {
1776
- if (this.modules.logger) {
1777
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1778
- } else {
1779
- baseLogger.init(null, this.options);
1780
- }
1781
- let formatter;
1782
- if (this.modules.formatter) {
1783
- formatter = this.modules.formatter;
1784
- } else {
1785
- formatter = Formatter;
1786
- }
1787
- const lu = new LanguageUtil(this.options);
1788
- this.store = new ResourceStore(this.options.resources, this.options);
1789
- const s4 = this.services;
1790
- s4.logger = baseLogger;
1791
- s4.resourceStore = this.store;
1792
- s4.languageUtils = lu;
1793
- s4.pluralResolver = new PluralResolver(lu, {
1794
- prepend: this.options.pluralSeparator,
1795
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1796
- });
1797
- const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1798
- if (usingLegacyFormatFunction) {
1799
- this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
1800
- }
1801
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1802
- s4.formatter = createClassOnDemand(formatter);
1803
- if (s4.formatter.init) s4.formatter.init(s4, this.options);
1804
- this.options.interpolation.format = s4.formatter.format.bind(s4.formatter);
1805
- }
1806
- s4.interpolator = new Interpolator(this.options);
1807
- s4.utils = {
1808
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1809
- };
1810
- s4.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s4.resourceStore, s4, this.options);
1811
- s4.backendConnector.on("*", (event, ...args) => {
1812
- this.emit(event, ...args);
1813
- });
1814
- if (this.modules.languageDetector) {
1815
- s4.languageDetector = createClassOnDemand(this.modules.languageDetector);
1816
- if (s4.languageDetector.init) s4.languageDetector.init(s4, this.options.detection, this.options);
1817
- }
1818
- if (this.modules.i18nFormat) {
1819
- s4.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1820
- if (s4.i18nFormat.init) s4.i18nFormat.init(this);
1821
- }
1822
- this.translator = new Translator(this.services, this.options);
1823
- this.translator.on("*", (event, ...args) => {
1824
- this.emit(event, ...args);
1825
- });
1826
- this.modules.external.forEach((m3) => {
1827
- if (m3.init) m3.init(this);
1828
- });
1829
- }
1830
- this.format = this.options.interpolation.format;
1831
- if (!callback) callback = noop$5;
1832
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1833
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1834
- if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
1835
- }
1836
- if (!this.services.languageDetector && !this.options.lng) {
1837
- this.logger.warn("init: no languageDetector is used and no lng is defined");
1838
- }
1839
- const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
1840
- storeApi.forEach((fcName) => {
1841
- this[fcName] = (...args) => this.store[fcName](...args);
1842
- });
1843
- const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
1844
- storeApiChained.forEach((fcName) => {
1845
- this[fcName] = (...args) => {
1846
- this.store[fcName](...args);
1847
- return this;
1848
- };
1849
- });
1850
- const deferred = defer();
1851
- const load = () => {
1852
- const finish = (err, t2) => {
1853
- this.isInitializing = false;
1854
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
1855
- this.isInitialized = true;
1856
- if (!this.options.isClone) this.logger.log("initialized", this.options);
1857
- this.emit("initialized", this.options);
1858
- deferred.resolve(t2);
1859
- callback(err, t2);
1860
- };
1861
- if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1862
- this.changeLanguage(this.options.lng, finish);
1863
- };
1864
- if (this.options.resources || !this.options.initAsync) {
1865
- load();
1866
- } else {
1867
- setTimeout(load, 0);
1868
- }
1869
- return deferred;
1870
- }
1871
- loadResources(language, callback = noop$5) {
1872
- var _a, _b;
1873
- let usedCallback = callback;
1874
- const usedLng = isString$3(language) ? language : this.language;
1875
- if (typeof language === "function") usedCallback = language;
1876
- if (!this.options.resources || this.options.partialBundledLanguages) {
1877
- if ((usedLng == null ? void 0 : usedLng.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1878
- const toLoad = [];
1879
- const append2 = (lng) => {
1880
- if (!lng) return;
1881
- if (lng === "cimode") return;
1882
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1883
- lngs.forEach((l) => {
1884
- if (l === "cimode") return;
1885
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
1886
- });
1887
- };
1888
- if (!usedLng) {
1889
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1890
- fallbacks.forEach((l) => append2(l));
1891
- } else {
1892
- append2(usedLng);
1893
- }
1894
- (_b = (_a = this.options.preload) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (l) => append2(l));
1895
- this.services.backendConnector.load(toLoad, this.options.ns, (e2) => {
1896
- if (!e2 && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1897
- usedCallback(e2);
1898
- });
1899
- } else {
1900
- usedCallback(null);
1901
- }
1902
- }
1903
- reloadResources(lngs, ns, callback) {
1904
- const deferred = defer();
1905
- if (typeof lngs === "function") {
1906
- callback = lngs;
1907
- lngs = void 0;
1908
- }
1909
- if (typeof ns === "function") {
1910
- callback = ns;
1911
- ns = void 0;
1912
- }
1913
- if (!lngs) lngs = this.languages;
1914
- if (!ns) ns = this.options.ns;
1915
- if (!callback) callback = noop$5;
1916
- this.services.backendConnector.reload(lngs, ns, (err) => {
1917
- deferred.resolve();
1918
- callback(err);
1919
- });
1920
- return deferred;
1921
- }
1922
- use(module) {
1923
- if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1924
- if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1925
- if (module.type === "backend") {
1926
- this.modules.backend = module;
1927
- }
1928
- if (module.type === "logger" || module.log && module.warn && module.error) {
1929
- this.modules.logger = module;
1930
- }
1931
- if (module.type === "languageDetector") {
1932
- this.modules.languageDetector = module;
1933
- }
1934
- if (module.type === "i18nFormat") {
1935
- this.modules.i18nFormat = module;
1936
- }
1937
- if (module.type === "postProcessor") {
1938
- postProcessor.addPostProcessor(module);
1939
- }
1940
- if (module.type === "formatter") {
1941
- this.modules.formatter = module;
1942
- }
1943
- if (module.type === "3rdParty") {
1944
- this.modules.external.push(module);
1945
- }
1946
- return this;
1947
- }
1948
- setResolvedLanguage(l) {
1949
- if (!l || !this.languages) return;
1950
- if (["cimode", "dev"].indexOf(l) > -1) return;
1951
- for (let li = 0; li < this.languages.length; li++) {
1952
- const lngInLngs = this.languages[li];
1953
- if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
1954
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1955
- this.resolvedLanguage = lngInLngs;
1956
- break;
1957
- }
1958
- }
1959
- if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1960
- this.resolvedLanguage = l;
1961
- this.languages.unshift(l);
1962
- }
1963
- }
1964
- changeLanguage(lng, callback) {
1965
- this.isLanguageChangingTo = lng;
1966
- const deferred = defer();
1967
- this.emit("languageChanging", lng);
1968
- const setLngProps = (l) => {
1969
- this.language = l;
1970
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
1971
- this.resolvedLanguage = void 0;
1972
- this.setResolvedLanguage(l);
1973
- };
1974
- const done = (err, l) => {
1975
- if (l) {
1976
- if (this.isLanguageChangingTo === lng) {
1977
- setLngProps(l);
1978
- this.translator.changeLanguage(l);
1979
- this.isLanguageChangingTo = void 0;
1980
- this.emit("languageChanged", l);
1981
- this.logger.log("languageChanged", l);
1982
- }
1983
- } else {
1984
- this.isLanguageChangingTo = void 0;
1985
- }
1986
- deferred.resolve((...args) => this.t(...args));
1987
- if (callback) callback(err, (...args) => this.t(...args));
1988
- };
1989
- const setLng = (lngs) => {
1990
- var _a, _b;
1991
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
1992
- const fl = isString$3(lngs) ? lngs : lngs && lngs[0];
1993
- const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString$3(lngs) ? [lngs] : lngs);
1994
- if (l) {
1995
- if (!this.language) {
1996
- setLngProps(l);
1997
- }
1998
- if (!this.translator.language) this.translator.changeLanguage(l);
1999
- (_b = (_a = this.services.languageDetector) == null ? void 0 : _a.cacheUserLanguage) == null ? void 0 : _b.call(_a, l);
2000
- }
2001
- this.loadResources(l, (err) => {
2002
- done(err, l);
2003
- });
2004
- };
2005
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2006
- setLng(this.services.languageDetector.detect());
2007
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2008
- if (this.services.languageDetector.detect.length === 0) {
2009
- this.services.languageDetector.detect().then(setLng);
2010
- } else {
2011
- this.services.languageDetector.detect(setLng);
2012
- }
2013
- } else {
2014
- setLng(lng);
2015
- }
2016
- return deferred;
2017
- }
2018
- getFixedT(lng, ns, keyPrefix) {
2019
- const fixedT = (key, opts, ...rest) => {
2020
- let o2;
2021
- if (typeof opts !== "object") {
2022
- o2 = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2023
- } else {
2024
- o2 = {
2025
- ...opts
2026
- };
2027
- }
2028
- o2.lng = o2.lng || fixedT.lng;
2029
- o2.lngs = o2.lngs || fixedT.lngs;
2030
- o2.ns = o2.ns || fixedT.ns;
2031
- if (o2.keyPrefix !== "") o2.keyPrefix = o2.keyPrefix || keyPrefix || fixedT.keyPrefix;
2032
- const keySeparator = this.options.keySeparator || ".";
2033
- let resultKey;
2034
- if (o2.keyPrefix && Array.isArray(key)) {
2035
- resultKey = key.map((k2) => {
2036
- if (typeof k2 === "function") k2 = keysFromSelector(k2, {
2037
- ...this.options,
2038
- ...opts
2039
- });
2040
- return `${o2.keyPrefix}${keySeparator}${k2}`;
2041
- });
2042
- } else {
2043
- if (typeof key === "function") key = keysFromSelector(key, {
2044
- ...this.options,
2045
- ...opts
2046
- });
2047
- resultKey = o2.keyPrefix ? `${o2.keyPrefix}${keySeparator}${key}` : key;
2048
- }
2049
- return this.t(resultKey, o2);
2050
- };
2051
- if (isString$3(lng)) {
2052
- fixedT.lng = lng;
2053
- } else {
2054
- fixedT.lngs = lng;
2055
- }
2056
- fixedT.ns = ns;
2057
- fixedT.keyPrefix = keyPrefix;
2058
- return fixedT;
2059
- }
2060
- t(...args) {
2061
- var _a;
2062
- return (_a = this.translator) == null ? void 0 : _a.translate(...args);
2063
- }
2064
- exists(...args) {
2065
- var _a;
2066
- return (_a = this.translator) == null ? void 0 : _a.exists(...args);
2067
- }
2068
- setDefaultNamespace(ns) {
2069
- this.options.defaultNS = ns;
2070
- }
2071
- hasLoadedNamespace(ns, options = {}) {
2072
- if (!this.isInitialized) {
2073
- this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
2074
- return false;
2075
- }
2076
- if (!this.languages || !this.languages.length) {
2077
- this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
2078
- return false;
2079
- }
2080
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
2081
- const fallbackLng = this.options ? this.options.fallbackLng : false;
2082
- const lastLng = this.languages[this.languages.length - 1];
2083
- if (lng.toLowerCase() === "cimode") return true;
2084
- const loadNotPending = (l, n2) => {
2085
- const loadState = this.services.backendConnector.state[`${l}|${n2}`];
2086
- return loadState === -1 || loadState === 0 || loadState === 2;
2087
- };
2088
- if (options.precheck) {
2089
- const preResult = options.precheck(this, loadNotPending);
2090
- if (preResult !== void 0) return preResult;
2091
- }
2092
- if (this.hasResourceBundle(lng, ns)) return true;
2093
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2094
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2095
- return false;
2096
- }
2097
- loadNamespaces(ns, callback) {
2098
- const deferred = defer();
2099
- if (!this.options.ns) {
2100
- if (callback) callback();
2101
- return Promise.resolve();
2102
- }
2103
- if (isString$3(ns)) ns = [ns];
2104
- ns.forEach((n2) => {
2105
- if (this.options.ns.indexOf(n2) < 0) this.options.ns.push(n2);
2106
- });
2107
- this.loadResources((err) => {
2108
- deferred.resolve();
2109
- if (callback) callback(err);
2110
- });
2111
- return deferred;
2112
- }
2113
- loadLanguages(lngs, callback) {
2114
- const deferred = defer();
2115
- if (isString$3(lngs)) lngs = [lngs];
2116
- const preloaded = this.options.preload || [];
2117
- const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2118
- if (!newLngs.length) {
2119
- if (callback) callback();
2120
- return Promise.resolve();
2121
- }
2122
- this.options.preload = preloaded.concat(newLngs);
2123
- this.loadResources((err) => {
2124
- deferred.resolve();
2125
- if (callback) callback(err);
2126
- });
2127
- return deferred;
2128
- }
2129
- dir(lng) {
2130
- var _a, _b;
2131
- if (!lng) lng = this.resolvedLanguage || (((_a = this.languages) == null ? void 0 : _a.length) > 0 ? this.languages[0] : this.language);
2132
- if (!lng) return "rtl";
2133
- try {
2134
- const l = new Intl.Locale(lng);
2135
- if (l && l.getTextInfo) {
2136
- const ti = l.getTextInfo();
2137
- if (ti && ti.direction) return ti.direction;
2138
- }
2139
- } catch (e2) {
2140
- }
2141
- 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"];
2142
- const languageUtils = ((_b = this.services) == null ? void 0 : _b.languageUtils) || new LanguageUtil(get$1());
2143
- if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
2144
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
2145
- }
2146
- static createInstance(options = {}, callback) {
2147
- return new I18n(options, callback);
2148
- }
2149
- cloneInstance(options = {}, callback = noop$5) {
2150
- const forkResourceStore = options.forkResourceStore;
2151
- if (forkResourceStore) delete options.forkResourceStore;
2152
- const mergedOptions = {
2153
- ...this.options,
2154
- ...options,
2155
- ...{
2156
- isClone: true
2157
- }
2158
- };
2159
- const clone2 = new I18n(mergedOptions);
2160
- if (options.debug !== void 0 || options.prefix !== void 0) {
2161
- clone2.logger = clone2.logger.clone(options);
2162
- }
2163
- const membersToCopy = ["store", "services", "language"];
2164
- membersToCopy.forEach((m3) => {
2165
- clone2[m3] = this[m3];
2166
- });
2167
- clone2.services = {
2168
- ...this.services
2169
- };
2170
- clone2.services.utils = {
2171
- hasLoadedNamespace: clone2.hasLoadedNamespace.bind(clone2)
2172
- };
2173
- if (forkResourceStore) {
2174
- const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2175
- prev[l] = {
2176
- ...this.store.data[l]
2177
- };
2178
- prev[l] = Object.keys(prev[l]).reduce((acc, n2) => {
2179
- acc[n2] = {
2180
- ...prev[l][n2]
2181
- };
2182
- return acc;
2183
- }, prev[l]);
2184
- return prev;
2185
- }, {});
2186
- clone2.store = new ResourceStore(clonedData, mergedOptions);
2187
- clone2.services.resourceStore = clone2.store;
2188
- }
2189
- clone2.translator = new Translator(clone2.services, mergedOptions);
2190
- clone2.translator.on("*", (event, ...args) => {
2191
- clone2.emit(event, ...args);
2192
- });
2193
- clone2.init(mergedOptions, callback);
2194
- clone2.translator.options = mergedOptions;
2195
- clone2.translator.backendConnector.services.utils = {
2196
- hasLoadedNamespace: clone2.hasLoadedNamespace.bind(clone2)
2197
- };
2198
- return clone2;
2199
- }
2200
- toJSON() {
2201
- return {
2202
- options: this.options,
2203
- store: this.store,
2204
- language: this.language,
2205
- languages: this.languages,
2206
- resolvedLanguage: this.resolvedLanguage
2207
- };
2208
- }
2209
- }
2210
- const instance = I18n.createInstance();
2211
- instance.createInstance = I18n.createInstance;
2212
- instance.createInstance;
2213
- instance.dir;
2214
- instance.init;
2215
- instance.loadResources;
2216
- instance.reloadResources;
2217
- instance.use;
2218
- instance.changeLanguage;
2219
- instance.getFixedT;
2220
- instance.t;
2221
- instance.exists;
2222
- instance.setDefaultNamespace;
2223
- instance.hasLoadedNamespace;
2224
- instance.loadNamespaces;
2225
- instance.loadLanguages;
2226
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2227
- function getDefaultExportFromCjs(x2) {
2228
- return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
2229
- }
2230
- const warn = (i18n, code, msg, rest) => {
2231
- var _a, _b, _c, _d;
2232
- const args = [msg, {
2233
- code,
2234
- ...rest || {}
2235
- }];
2236
- if ((_b = (_a = i18n == null ? void 0 : i18n.services) == null ? void 0 : _a.logger) == null ? void 0 : _b.forward) {
2237
- return i18n.services.logger.forward(args, "warn", "react-i18next::", true);
2238
- }
2239
- if (isString$2(args[0])) args[0] = `react-i18next:: ${args[0]}`;
2240
- if ((_d = (_c = i18n == null ? void 0 : i18n.services) == null ? void 0 : _c.logger) == null ? void 0 : _d.warn) {
2241
- i18n.services.logger.warn(...args);
2242
- } else if (console == null ? void 0 : console.warn) {
2243
- console.warn(...args);
2244
- }
2245
- };
2246
- const alreadyWarned = {};
2247
- const warnOnce = (i18n, code, msg, rest) => {
2248
- if (isString$2(msg) && alreadyWarned[msg]) return;
2249
- if (isString$2(msg)) alreadyWarned[msg] = /* @__PURE__ */ new Date();
2250
- warn(i18n, code, msg, rest);
2251
- };
2252
- const loadedClb = (i18n, cb) => () => {
2253
- if (i18n.isInitialized) {
2254
- cb();
2255
- } else {
2256
- const initialized = () => {
2257
- setTimeout(() => {
2258
- i18n.off("initialized", initialized);
2259
- }, 0);
2260
- cb();
2261
- };
2262
- i18n.on("initialized", initialized);
2263
- }
2264
- };
2265
- const loadNamespaces = (i18n, ns, cb) => {
2266
- i18n.loadNamespaces(ns, loadedClb(i18n, cb));
2267
- };
2268
- const loadLanguages = (i18n, lng, ns, cb) => {
2269
- if (isString$2(ns)) ns = [ns];
2270
- if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
2271
- ns.forEach((n2) => {
2272
- if (i18n.options.ns.indexOf(n2) < 0) i18n.options.ns.push(n2);
2273
- });
2274
- i18n.loadLanguages(lng, loadedClb(i18n, cb));
2275
- };
2276
- const hasLoadedNamespace = (ns, i18n, options = {}) => {
2277
- if (!i18n.languages || !i18n.languages.length) {
2278
- warnOnce(i18n, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
2279
- languages: i18n.languages
2280
- });
2281
- return true;
2282
- }
2283
- return i18n.hasLoadedNamespace(ns, {
2284
- lng: options.lng,
2285
- precheck: (i18nInstance2, loadNotPending) => {
2286
- if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
2287
- }
2288
- });
2289
- };
2290
- const isString$2 = (obj) => typeof obj === "string";
2291
- const isObject$3 = (obj) => typeof obj === "object" && obj !== null;
2292
- const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
2293
- const htmlEntities = {
2294
- "&amp;": "&",
2295
- "&#38;": "&",
2296
- "&lt;": "<",
2297
- "&#60;": "<",
2298
- "&gt;": ">",
2299
- "&#62;": ">",
2300
- "&apos;": "'",
2301
- "&#39;": "'",
2302
- "&quot;": '"',
2303
- "&#34;": '"',
2304
- "&nbsp;": " ",
2305
- "&#160;": " ",
2306
- "&copy;": "©",
2307
- "&#169;": "©",
2308
- "&reg;": "®",
2309
- "&#174;": "®",
2310
- "&hellip;": "…",
2311
- "&#8230;": "…",
2312
- "&#x2F;": "/",
2313
- "&#47;": "/"
2314
- };
2315
- const unescapeHtmlEntity = (m3) => htmlEntities[m3];
2316
- const unescape$1 = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
2317
- let defaultOptions$2 = {
2318
- bindI18n: "languageChanged",
2319
- bindI18nStore: "",
2320
- transEmptyNodeValue: "",
2321
- transSupportBasicHtmlNodes: true,
2322
- transWrapTextNodes: "",
2323
- transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
2324
- useSuspense: true,
2325
- unescape: unescape$1
2326
- };
2327
- const setDefaults = (options = {}) => {
2328
- defaultOptions$2 = {
2329
- ...defaultOptions$2,
2330
- ...options
2331
- };
2332
- };
2333
- const getDefaults = () => defaultOptions$2;
2334
- let i18nInstance;
2335
- const setI18n = (instance2) => {
2336
- i18nInstance = instance2;
2337
- };
2338
- const getI18n = () => i18nInstance;
2339
- const initReactI18next = {
2340
- type: "3rdParty",
2341
- init(instance2) {
2342
- setDefaults(instance2.options.react);
2343
- setI18n(instance2);
2344
- }
2345
- };
2346
- const I18nContext = createContext();
2347
- class ReportNamespaces {
2348
- constructor() {
2349
- this.usedNamespaces = {};
2350
- }
2351
- addUsedNamespaces(namespaces) {
2352
- namespaces.forEach((ns) => {
2353
- if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
2354
- });
2355
- }
2356
- getUsedNamespaces() {
2357
- return Object.keys(this.usedNamespaces);
2358
- }
2359
- }
2360
- const usePrevious = (value, ignore) => {
2361
- const ref = useRef();
2362
- useEffect(() => {
2363
- ref.current = value;
2364
- }, [value, ignore]);
2365
- return ref.current;
2366
- };
2367
- const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
2368
- const useMemoizedT = (i18n, language, namespace, keyPrefix) => useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
2369
- const useTranslation = (ns, props = {}) => {
2370
- var _a, _b, _c, _d;
2371
- const {
2372
- i18n: i18nFromProps
2373
- } = props;
2374
- const {
2375
- i18n: i18nFromContext,
2376
- defaultNS: defaultNSFromContext
2377
- } = useContext(I18nContext) || {};
2378
- const i18n = i18nFromProps || i18nFromContext || getI18n();
2379
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
2380
- if (!i18n) {
2381
- warnOnce(i18n, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
2382
- const notReadyT = (k2, optsOrDefaultValue) => {
2383
- if (isString$2(optsOrDefaultValue)) return optsOrDefaultValue;
2384
- if (isObject$3(optsOrDefaultValue) && isString$2(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
2385
- return Array.isArray(k2) ? k2[k2.length - 1] : k2;
2386
- };
2387
- const retNotReady = [notReadyT, {}, false];
2388
- retNotReady.t = notReadyT;
2389
- retNotReady.i18n = {};
2390
- retNotReady.ready = false;
2391
- return retNotReady;
2392
- }
2393
- if ((_a = i18n.options.react) == null ? void 0 : _a.wait) warnOnce(i18n, "DEPRECATED_OPTION", "useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
2394
- const i18nOptions = {
2395
- ...getDefaults(),
2396
- ...i18n.options.react,
2397
- ...props
2398
- };
2399
- const {
2400
- useSuspense,
2401
- keyPrefix
2402
- } = i18nOptions;
2403
- let namespaces = ns || defaultNSFromContext || ((_b = i18n.options) == null ? void 0 : _b.defaultNS);
2404
- namespaces = isString$2(namespaces) ? [namespaces] : namespaces || ["translation"];
2405
- (_d = (_c = i18n.reportNamespaces).addUsedNamespaces) == null ? void 0 : _d.call(_c, namespaces);
2406
- const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n2) => hasLoadedNamespace(n2, i18n, i18nOptions));
2407
- const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
2408
- const getT = () => memoGetT;
2409
- const getNewT = () => alwaysNewT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
2410
- const [t2, setT] = useState(getT);
2411
- let joinedNS = namespaces.join();
2412
- if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
2413
- const previousJoinedNS = usePrevious(joinedNS);
2414
- const isMounted = useRef(true);
2415
- useEffect(() => {
2416
- const {
2417
- bindI18n,
2418
- bindI18nStore
2419
- } = i18nOptions;
2420
- isMounted.current = true;
2421
- if (!ready && !useSuspense) {
2422
- if (props.lng) {
2423
- loadLanguages(i18n, props.lng, namespaces, () => {
2424
- if (isMounted.current) setT(getNewT);
2425
- });
2426
- } else {
2427
- loadNamespaces(i18n, namespaces, () => {
2428
- if (isMounted.current) setT(getNewT);
2429
- });
2430
- }
2431
- }
2432
- if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
2433
- setT(getNewT);
2434
- }
2435
- const boundReset = () => {
2436
- if (isMounted.current) setT(getNewT);
2437
- };
2438
- if (bindI18n) i18n == null ? void 0 : i18n.on(bindI18n, boundReset);
2439
- if (bindI18nStore) i18n == null ? void 0 : i18n.store.on(bindI18nStore, boundReset);
2440
- return () => {
2441
- isMounted.current = false;
2442
- if (i18n && bindI18n) bindI18n == null ? void 0 : bindI18n.split(" ").forEach((e2) => i18n.off(e2, boundReset));
2443
- if (bindI18nStore && i18n) bindI18nStore.split(" ").forEach((e2) => i18n.store.off(e2, boundReset));
2444
- };
2445
- }, [i18n, joinedNS]);
2446
- useEffect(() => {
2447
- if (isMounted.current && ready) {
2448
- setT(getT);
2449
- }
2450
- }, [i18n, keyPrefix, ready]);
2451
- const ret = [t2, i18n, ready];
2452
- ret.t = t2;
2453
- ret.i18n = i18n;
2454
- ret.ready = ready;
2455
- if (ready) return ret;
2456
- if (!ready && !useSuspense) return ret;
2457
- throw new Promise((resolve) => {
2458
- if (props.lng) {
2459
- loadLanguages(i18n, props.lng, namespaces, () => resolve());
2460
- } else {
2461
- loadNamespaces(i18n, namespaces, () => resolve());
2462
- }
2463
- });
2464
- };
2465
16
  const confirmDialog$1 = { "cancel": "Cancel", "ok": "Ok", "confirm": "Confirm", "delete": "Delete", "save": "Save", "yes": "Yes", "no": "No" };
2466
17
  const en$1 = {
2467
18
  confirmDialog: confirmDialog$1
@@ -2470,22 +21,8 @@ const confirmDialog = { "cancel": "Batal", "ok": "Ok", "confirm": "Sahkan", "del
2470
21
  const ms$1 = {
2471
22
  confirmDialog
2472
23
  };
2473
- const resources = {
2474
- en: {
2475
- translation: en$1
2476
- },
2477
- ms: {
2478
- translation: ms$1
2479
- }
2480
- };
2481
- instance.use(initReactI18next).init({
2482
- resources,
2483
- lng: "en",
2484
- fallbackLng: "en",
2485
- interpolation: {
2486
- escapeValue: false
2487
- }
2488
- });
24
+ i18next.addResourceBundle("en", "translation", en$1, true, true);
25
+ i18next.addResourceBundle("ms", "translation", ms$1, true, true);
2489
26
  const locale$3 = {
2490
27
  CHANGE_DETECT_TITLE: "Are you sure want discard changes?",
2491
28
  CHANGE_DETECT_BUTTON: "Keep Editing",
@@ -2544,9 +81,16 @@ const locale$3 = {
2544
81
  DOCUMENTS_REMARKS: "Documents Remarks",
2545
82
  LOAN_AMOUNT: "Loan Amount",
2546
83
  INTEREST_RATE: "Interest Rate",
2547
- FEES_DEDUCTION: "Fees Deduction",
84
+ INTEREST_FEES: "Interest Fees",
2548
85
  REPAYMENT_AMOUNT: "Repayment Amount",
2549
- CASH_IN_HAND: "Cash In Hand"
86
+ CASH_IN_HAND: "Cash In Hand",
87
+ CONFIRM_INFORMATION_READ: "I confirm that I have read, understood, and agree to the loan amount, interest rate, repayment terms, deductions, tenure, and all related loan details.",
88
+ PDF_PREVIEW_TITLE: "Summary of loan application",
89
+ TOTAL_INTEREST_RATE: "Total Interest Rate",
90
+ DURATION: "Duration",
91
+ STAMP_DUTY: "Stamp Duty",
92
+ LEGAL_FEES: "Legal Fees",
93
+ MONTHS: "Months"
2550
94
  };
2551
95
  const locale$2 = {
2552
96
  CHANGE_DETECT_TITLE: "Adakah anda pasti mahu membuang perubahan?",
@@ -2605,12 +149,19 @@ const locale$2 = {
2605
149
  DOCUMENTS_REMARKS: "Documents Remarks",
2606
150
  LOAN_AMOUNT: "Jumlah Pinjaman",
2607
151
  INTEREST_RATE: "Kadar Faedah",
2608
- FEES_DEDUCTION: "Potongan Yuran",
152
+ INTEREST_FEES: "Yuran Faedah",
2609
153
  REPAYMENT_AMOUNT: "Amaun Bayaran Balik",
2610
- CASH_IN_HAND: "Wang tunai di tangan"
2611
- };
2612
- instance.addResourceBundle("en", "Dialog", locale$3);
2613
- instance.addResourceBundle("ms", "Dialog", locale$2);
154
+ CASH_IN_HAND: "Wang tunai di tangan",
155
+ CONFIRM_INFORMATION_READ: "Saya mengesahkan bahawa saya telah membaca, memahami, dan bersetuju dengan jumlah pinjaman, kadar faedah, terma pembayaran balik, potongan, tempoh pinjaman, serta semua butiran pinjaman yang berkaitan.",
156
+ PDF_PREVIEW_TITLE: "Ringkasan permohonan pinjaman",
157
+ TOTAL_INTEREST_RATE: "Jumlah Kadar Faedah",
158
+ DURATION: "Tempoh",
159
+ STAMP_DUTY: "Duti Setem",
160
+ LEGAL_FEES: "Yuran Guaman",
161
+ MONTHS: "Bulan"
162
+ };
163
+ i18next.addResourceBundle("en", "Dialog", locale$3);
164
+ i18next.addResourceBundle("ms", "Dialog", locale$2);
2614
165
  const ConfirmDialog = ({
2615
166
  open,
2616
167
  title,
@@ -2648,6 +199,10 @@ function chainPropTypes(propType1, propType2) {
2648
199
  return propType1(...args) || propType2(...args);
2649
200
  };
2650
201
  }
202
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
203
+ function getDefaultExportFromCjs(x2) {
204
+ return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
205
+ }
2651
206
  var reactIs$1 = { exports: {} };
2652
207
  var reactIs_production = {};
2653
208
  /**
@@ -4123,19 +1678,19 @@ function useEventCallback$1(fn2) {
4123
1678
  }
4124
1679
  function useForkRef$2(...refs) {
4125
1680
  const cleanupRef = React.useRef(void 0);
4126
- const refEffect = React.useCallback((instance2) => {
1681
+ const refEffect = React.useCallback((instance) => {
4127
1682
  const cleanups = refs.map((ref) => {
4128
1683
  if (ref == null) {
4129
1684
  return null;
4130
1685
  }
4131
1686
  if (typeof ref === "function") {
4132
1687
  const refCallback = ref;
4133
- const refCleanup = refCallback(instance2);
1688
+ const refCleanup = refCallback(instance);
4134
1689
  return typeof refCleanup === "function" ? refCleanup : () => {
4135
1690
  refCallback(null);
4136
1691
  };
4137
1692
  }
4138
- ref.current = instance2;
1693
+ ref.current = instance;
4139
1694
  return () => {
4140
1695
  ref.current = null;
4141
1696
  };
@@ -9664,22 +7219,22 @@ function currentImpl(value) {
9664
7219
  if (!isDraftable(value) || isFrozen(value))
9665
7220
  return value;
9666
7221
  const state = value[DRAFT_STATE];
9667
- let copy2;
7222
+ let copy;
9668
7223
  if (state) {
9669
7224
  if (!state.modified_)
9670
7225
  return state.base_;
9671
7226
  state.finalized_ = true;
9672
- copy2 = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
7227
+ copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
9673
7228
  } else {
9674
- copy2 = shallowCopy(value, true);
7229
+ copy = shallowCopy(value, true);
9675
7230
  }
9676
- each(copy2, (key, childValue) => {
9677
- set$1(copy2, key, currentImpl(childValue));
7231
+ each(copy, (key, childValue) => {
7232
+ set$1(copy, key, currentImpl(childValue));
9678
7233
  });
9679
7234
  if (state) {
9680
7235
  state.finalized_ = false;
9681
7236
  }
9682
- return copy2;
7237
+ return copy;
9683
7238
  }
9684
7239
  var immer = new Immer2();
9685
7240
  var produce = immer.produce;
@@ -12534,13 +10089,13 @@ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
12534
10089
  });
12535
10090
  function createInstance(defaultConfig2) {
12536
10091
  const context = new Axios$1(defaultConfig2);
12537
- const instance2 = bind(Axios$1.prototype.request, context);
12538
- utils$1.extend(instance2, Axios$1.prototype, context, { allOwnKeys: true });
12539
- utils$1.extend(instance2, context, null, { allOwnKeys: true });
12540
- instance2.create = function create(instanceConfig) {
10092
+ const instance = bind(Axios$1.prototype.request, context);
10093
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
10094
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
10095
+ instance.create = function create(instanceConfig) {
12541
10096
  return createInstance(mergeConfig$1(defaultConfig2, instanceConfig));
12542
10097
  };
12543
- return instance2;
10098
+ return instance;
12544
10099
  }
12545
10100
  const axios = createInstance(defaults);
12546
10101
  axios.Axios = Axios$1;
@@ -12992,8 +10547,8 @@ const uploadFile = (file) => async (dispatch) => {
12992
10547
  console.log(error);
12993
10548
  }
12994
10549
  };
12995
- instance.addResourceBundle("en", "Dialog", locale$3);
12996
- instance.addResourceBundle("ms", "Dialog", locale$2);
10550
+ i18next.addResourceBundle("en", "Dialog", locale$3);
10551
+ i18next.addResourceBundle("ms", "Dialog", locale$2);
12997
10552
  const ChangeDetectDialog = ({
12998
10553
  open,
12999
10554
  onClose,
@@ -13029,26 +10584,26 @@ var isPlainObject = (tempObject) => {
13029
10584
  };
13030
10585
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
13031
10586
  function cloneObject(data) {
13032
- let copy2;
10587
+ let copy;
13033
10588
  const isArray2 = Array.isArray(data);
13034
10589
  const isFileListInstance = typeof FileList !== "undefined" ? data instanceof FileList : false;
13035
10590
  if (data instanceof Date) {
13036
- copy2 = new Date(data);
10591
+ copy = new Date(data);
13037
10592
  } else if (!(isWeb && (data instanceof Blob || isFileListInstance)) && (isArray2 || isObject$1(data))) {
13038
- copy2 = isArray2 ? [] : Object.create(Object.getPrototypeOf(data));
10593
+ copy = isArray2 ? [] : Object.create(Object.getPrototypeOf(data));
13039
10594
  if (!isArray2 && !isPlainObject(data)) {
13040
- copy2 = data;
10595
+ copy = data;
13041
10596
  } else {
13042
10597
  for (const key in data) {
13043
10598
  if (data.hasOwnProperty(key)) {
13044
- copy2[key] = cloneObject(data[key]);
10599
+ copy[key] = cloneObject(data[key]);
13045
10600
  }
13046
10601
  }
13047
10602
  }
13048
10603
  } else {
13049
10604
  return data;
13050
10605
  }
13051
- return copy2;
10606
+ return copy;
13052
10607
  }
13053
10608
  var isKey = (value) => /^\w*$/.test(value);
13054
10609
  var isUndefined = (val) => val === void 0;
@@ -15494,33 +13049,33 @@ class ReferenceSet extends Set {
15494
13049
  function clone(src, seen = /* @__PURE__ */ new Map()) {
15495
13050
  if (isSchema(src) || !src || typeof src !== "object") return src;
15496
13051
  if (seen.has(src)) return seen.get(src);
15497
- let copy2;
13052
+ let copy;
15498
13053
  if (src instanceof Date) {
15499
- copy2 = new Date(src.getTime());
15500
- seen.set(src, copy2);
13054
+ copy = new Date(src.getTime());
13055
+ seen.set(src, copy);
15501
13056
  } else if (src instanceof RegExp) {
15502
- copy2 = new RegExp(src);
15503
- seen.set(src, copy2);
13057
+ copy = new RegExp(src);
13058
+ seen.set(src, copy);
15504
13059
  } else if (Array.isArray(src)) {
15505
- copy2 = new Array(src.length);
15506
- seen.set(src, copy2);
15507
- for (let i3 = 0; i3 < src.length; i3++) copy2[i3] = clone(src[i3], seen);
13060
+ copy = new Array(src.length);
13061
+ seen.set(src, copy);
13062
+ for (let i3 = 0; i3 < src.length; i3++) copy[i3] = clone(src[i3], seen);
15508
13063
  } else if (src instanceof Map) {
15509
- copy2 = /* @__PURE__ */ new Map();
15510
- seen.set(src, copy2);
15511
- for (const [k2, v] of src.entries()) copy2.set(k2, clone(v, seen));
13064
+ copy = /* @__PURE__ */ new Map();
13065
+ seen.set(src, copy);
13066
+ for (const [k2, v] of src.entries()) copy.set(k2, clone(v, seen));
15512
13067
  } else if (src instanceof Set) {
15513
- copy2 = /* @__PURE__ */ new Set();
15514
- seen.set(src, copy2);
15515
- for (const v of src) copy2.add(clone(v, seen));
13068
+ copy = /* @__PURE__ */ new Set();
13069
+ seen.set(src, copy);
13070
+ for (const v of src) copy.add(clone(v, seen));
15516
13071
  } else if (src instanceof Object) {
15517
- copy2 = {};
15518
- seen.set(src, copy2);
15519
- for (const [k2, v] of Object.entries(src)) copy2[k2] = clone(v, seen);
13072
+ copy = {};
13073
+ seen.set(src, copy);
13074
+ for (const [k2, v] of Object.entries(src)) copy[k2] = clone(v, seen);
15520
13075
  } else {
15521
13076
  throw Error(`Unable to clone ${src}`);
15522
13077
  }
15523
- return copy2;
13078
+ return copy;
15524
13079
  }
15525
13080
  function createStandardPath(path) {
15526
13081
  if (!(path != null && path.length)) {
@@ -19539,8 +17094,8 @@ const SaveButton = React__default.memo(({
19539
17094
  );
19540
17095
  });
19541
17096
  SaveButton.displayName = "SaveButton";
19542
- instance.addResourceBundle("en", "Dialog", locale$3);
19543
- instance.addResourceBundle("ms", "Dialog", locale$2);
17097
+ i18next.addResourceBundle("en", "Dialog", locale$3);
17098
+ i18next.addResourceBundle("ms", "Dialog", locale$2);
19544
17099
  const defaultValues$2 = {
19545
17100
  password: ""
19546
17101
  };
@@ -19606,8 +17161,8 @@ function ChangePasswordDialog({ userId }) {
19606
17161
  }
19607
17162
  ) }) }) });
19608
17163
  }
19609
- instance.addResourceBundle("en", "Dialog", locale$3);
19610
- instance.addResourceBundle("ms", "Dialog", locale$2);
17164
+ i18next.addResourceBundle("en", "Dialog", locale$3);
17165
+ i18next.addResourceBundle("ms", "Dialog", locale$2);
19611
17166
  const DeleteUserDialog = ({
19612
17167
  open,
19613
17168
  deleteUserId,
@@ -21940,8 +19495,8 @@ const ms = {
21940
19495
  FINANCE_APPLICATION_NUMBER: "Nombor Permohonan Kewangan",
21941
19496
  TENANT: "Penyewa"
21942
19497
  };
21943
- instance.addResourceBundle("en", "Autocomplete", en);
21944
- instance.addResourceBundle("ms", "Autocomplete", ms);
19498
+ i18next.addResourceBundle("en", "Autocomplete", en);
19499
+ i18next.addResourceBundle("ms", "Autocomplete", ms);
21945
19500
  const CustomAutocomplete = React.memo(
21946
19501
  ({
21947
19502
  label,
@@ -24464,14 +22019,14 @@ function requireLodash() {
24464
22019
  });
24465
22020
  });
24466
22021
  }
24467
- function createPadding(length, chars2) {
24468
- chars2 = chars2 === undefined$1 ? " " : baseToString(chars2);
24469
- var charsLength = chars2.length;
22022
+ function createPadding(length, chars) {
22023
+ chars = chars === undefined$1 ? " " : baseToString(chars);
22024
+ var charsLength = chars.length;
24470
22025
  if (charsLength < 2) {
24471
- return charsLength ? baseRepeat(chars2, length) : chars2;
22026
+ return charsLength ? baseRepeat(chars, length) : chars;
24472
22027
  }
24473
- var result2 = baseRepeat(chars2, nativeCeil(length / stringSize(chars2)));
24474
- return hasUnicode(chars2) ? castSlice(stringToArray(result2), 0, length).join("") : result2.slice(0, length);
22028
+ var result2 = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
22029
+ return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length).join("") : result2.slice(0, length);
24475
22030
  }
24476
22031
  function createPartial(func, bitmask, thisArg, partials) {
24477
22032
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
@@ -25975,7 +23530,7 @@ function requireLodash() {
25975
23530
  debounced.flush = flush;
25976
23531
  return debounced;
25977
23532
  }
25978
- var defer2 = baseRest(function(func, args) {
23533
+ var defer = baseRest(function(func, args) {
25979
23534
  return baseDelay(func, 1, args);
25980
23535
  });
25981
23536
  var delay = baseRest(function(func, wait, args) {
@@ -26629,7 +24184,7 @@ function requireLodash() {
26629
24184
  position -= target.length;
26630
24185
  return position >= 0 && string2.slice(position, end2) == target;
26631
24186
  }
26632
- function escape2(string2) {
24187
+ function escape(string2) {
26633
24188
  string2 = toString3(string2);
26634
24189
  return string2 && reHasUnescapedHtml.test(string2) ? string2.replace(reUnescapedHtml, escapeHtmlChar) : string2;
26635
24190
  }
@@ -26644,7 +24199,7 @@ function requireLodash() {
26644
24199
  return result2 + (index ? " " : "") + word.toLowerCase();
26645
24200
  });
26646
24201
  var lowerFirst = createCaseFirst("toLowerCase");
26647
- function pad(string2, length, chars2) {
24202
+ function pad(string2, length, chars) {
26648
24203
  string2 = toString3(string2);
26649
24204
  length = toInteger2(length);
26650
24205
  var strLength = length ? stringSize(string2) : 0;
@@ -26652,19 +24207,19 @@ function requireLodash() {
26652
24207
  return string2;
26653
24208
  }
26654
24209
  var mid = (length - strLength) / 2;
26655
- return createPadding(nativeFloor(mid), chars2) + string2 + createPadding(nativeCeil(mid), chars2);
24210
+ return createPadding(nativeFloor(mid), chars) + string2 + createPadding(nativeCeil(mid), chars);
26656
24211
  }
26657
- function padEnd(string2, length, chars2) {
24212
+ function padEnd(string2, length, chars) {
26658
24213
  string2 = toString3(string2);
26659
24214
  length = toInteger2(length);
26660
24215
  var strLength = length ? stringSize(string2) : 0;
26661
- return length && strLength < length ? string2 + createPadding(length - strLength, chars2) : string2;
24216
+ return length && strLength < length ? string2 + createPadding(length - strLength, chars) : string2;
26662
24217
  }
26663
- function padStart(string2, length, chars2) {
24218
+ function padStart(string2, length, chars) {
26664
24219
  string2 = toString3(string2);
26665
24220
  length = toInteger2(length);
26666
24221
  var strLength = length ? stringSize(string2) : 0;
26667
- return length && strLength < length ? createPadding(length - strLength, chars2) + string2 : string2;
24222
+ return length && strLength < length ? createPadding(length - strLength, chars) + string2 : string2;
26668
24223
  }
26669
24224
  function parseInt2(string2, radix, guard) {
26670
24225
  if (guard || radix == null) {
@@ -26770,37 +24325,37 @@ function requireLodash() {
26770
24325
  function toUpper(value) {
26771
24326
  return toString3(value).toUpperCase();
26772
24327
  }
26773
- function trim2(string2, chars2, guard) {
24328
+ function trim2(string2, chars, guard) {
26774
24329
  string2 = toString3(string2);
26775
- if (string2 && (guard || chars2 === undefined$1)) {
24330
+ if (string2 && (guard || chars === undefined$1)) {
26776
24331
  return baseTrim(string2);
26777
24332
  }
26778
- if (!string2 || !(chars2 = baseToString(chars2))) {
24333
+ if (!string2 || !(chars = baseToString(chars))) {
26779
24334
  return string2;
26780
24335
  }
26781
- var strSymbols = stringToArray(string2), chrSymbols = stringToArray(chars2), start2 = charsStartIndex(strSymbols, chrSymbols), end2 = charsEndIndex(strSymbols, chrSymbols) + 1;
24336
+ var strSymbols = stringToArray(string2), chrSymbols = stringToArray(chars), start2 = charsStartIndex(strSymbols, chrSymbols), end2 = charsEndIndex(strSymbols, chrSymbols) + 1;
26782
24337
  return castSlice(strSymbols, start2, end2).join("");
26783
24338
  }
26784
- function trimEnd(string2, chars2, guard) {
24339
+ function trimEnd(string2, chars, guard) {
26785
24340
  string2 = toString3(string2);
26786
- if (string2 && (guard || chars2 === undefined$1)) {
24341
+ if (string2 && (guard || chars === undefined$1)) {
26787
24342
  return string2.slice(0, trimmedEndIndex(string2) + 1);
26788
24343
  }
26789
- if (!string2 || !(chars2 = baseToString(chars2))) {
24344
+ if (!string2 || !(chars = baseToString(chars))) {
26790
24345
  return string2;
26791
24346
  }
26792
- var strSymbols = stringToArray(string2), end2 = charsEndIndex(strSymbols, stringToArray(chars2)) + 1;
24347
+ var strSymbols = stringToArray(string2), end2 = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
26793
24348
  return castSlice(strSymbols, 0, end2).join("");
26794
24349
  }
26795
- function trimStart(string2, chars2, guard) {
24350
+ function trimStart(string2, chars, guard) {
26796
24351
  string2 = toString3(string2);
26797
- if (string2 && (guard || chars2 === undefined$1)) {
24352
+ if (string2 && (guard || chars === undefined$1)) {
26798
24353
  return string2.replace(reTrimStart, "");
26799
24354
  }
26800
- if (!string2 || !(chars2 = baseToString(chars2))) {
24355
+ if (!string2 || !(chars = baseToString(chars))) {
26801
24356
  return string2;
26802
24357
  }
26803
- var strSymbols = stringToArray(string2), start2 = charsStartIndex(strSymbols, stringToArray(chars2));
24358
+ var strSymbols = stringToArray(string2), start2 = charsStartIndex(strSymbols, stringToArray(chars));
26804
24359
  return castSlice(strSymbols, start2).join("");
26805
24360
  }
26806
24361
  function truncate(string2, options) {
@@ -27091,7 +24646,7 @@ function requireLodash() {
27091
24646
  lodash2.debounce = debounce2;
27092
24647
  lodash2.defaults = defaults2;
27093
24648
  lodash2.defaultsDeep = defaultsDeep;
27094
- lodash2.defer = defer2;
24649
+ lodash2.defer = defer;
27095
24650
  lodash2.delay = delay;
27096
24651
  lodash2.difference = difference;
27097
24652
  lodash2.differenceBy = differenceBy;
@@ -27235,7 +24790,7 @@ function requireLodash() {
27235
24790
  lodash2.divide = divide;
27236
24791
  lodash2.endsWith = endsWith2;
27237
24792
  lodash2.eq = eq;
27238
- lodash2.escape = escape2;
24793
+ lodash2.escape = escape;
27239
24794
  lodash2.escapeRegExp = escapeRegExp;
27240
24795
  lodash2.every = every;
27241
24796
  lodash2.find = find;
@@ -28297,6 +25852,43 @@ const CommonStatusChangeDialog = ({
28297
25852
  }
28298
25853
  );
28299
25854
  };
25855
+ const CustomCheckbox = ({
25856
+ label,
25857
+ onChange,
25858
+ checked: controlledChecked,
25859
+ ...props
25860
+ }) => {
25861
+ const [internalChecked, setInternalChecked] = React__default.useState(false);
25862
+ const isControlled = controlledChecked !== void 0;
25863
+ const isChecked = isControlled ? controlledChecked : internalChecked;
25864
+ const handleChange = (newChecked) => {
25865
+ if (!isControlled) {
25866
+ setInternalChecked(newChecked);
25867
+ }
25868
+ onChange == null ? void 0 : onChange(newChecked);
25869
+ };
25870
+ return /* @__PURE__ */ jsx(Fragment, { children: label ? /* @__PURE__ */ jsx(
25871
+ FormControlLabel,
25872
+ {
25873
+ control: /* @__PURE__ */ jsx(
25874
+ Checkbox$1,
25875
+ {
25876
+ checked: isChecked,
25877
+ onChange: (event) => handleChange(event.target.checked),
25878
+ ...props
25879
+ }
25880
+ ),
25881
+ label
25882
+ }
25883
+ ) : /* @__PURE__ */ jsx(
25884
+ Checkbox$1,
25885
+ {
25886
+ checked: isChecked,
25887
+ onChange: (event) => handleChange(event.target.checked),
25888
+ ...props
25889
+ }
25890
+ ) });
25891
+ };
28300
25892
  function shouldShowButton(loginUserDetail, loginUserRoles2, applicationDetailsData) {
28301
25893
  var _a, _b, _c, _d, _e, _f;
28302
25894
  const isAdmin = ((_a = loginUserDetail == null ? void 0 : loginUserDetail.data) == null ? void 0 : _a.slug) === loginUserRoles2.Admin;
@@ -28318,121 +25910,135 @@ const PDFPreviewForTheSignature = ({
28318
25910
  loginUserDetail,
28319
25911
  loginUserRoles: loginUserRoles2,
28320
25912
  ColoredSubmitButton,
25913
+ dialogTitle,
28321
25914
  financeCalculation,
28322
- t: t2 = (key) => key
25915
+ t: t2 = (key) => key,
25916
+ showConfirmCheckbox = false,
25917
+ ...props
28323
25918
  }) => {
28324
25919
  const showButton = shouldShowButton(
28325
25920
  loginUserDetail,
28326
25921
  loginUserRoles2,
28327
25922
  applicationDetailsData
28328
25923
  );
28329
- return /* @__PURE__ */ jsx(Dialog$1, { open, onClose, maxWidth: "lg", fullWidth: true, children: /* @__PURE__ */ jsxs(DialogContent$1, { className: "p-0", children: [
28330
- /* @__PURE__ */ jsx(
28331
- "embed",
28332
- {
28333
- src: filePath,
28334
- type: "application/pdf",
28335
- width: "100%",
28336
- style: { height: "80vh" }
28337
- }
28338
- ),
28339
- showButton && /* @__PURE__ */ jsxs("div", { className: "sticky bottom-0 bg-white w-full border-t-1 border-solid border-grey-500 px-10 py-10 text-end", children: [
28340
- financeCalculation && /* @__PURE__ */ jsxs(Grid$1, { container: true, spacing: 2, children: [
28341
- /* @__PURE__ */ jsx(Grid$1, { item: true, xs: 12, sm: 12, md: 4, className: "flex justify-start", children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", children: [
25924
+ const [isTermsConfirmed, setIsTermsConfirmed] = useState(false);
25925
+ return /* @__PURE__ */ jsx(Dialog$1, { open, onClose, maxWidth: "lg", fullWidth: true, ...props, children: /* @__PURE__ */ jsxs(DialogContent$1, { className: "p-0", children: [
25926
+ (dialogTitle || financeCalculation) && /* @__PURE__ */ jsxs("div", { className: "px-16 pt-12 pb-16", children: [
25927
+ dialogTitle && /* @__PURE__ */ jsx(Typography$1, { variant: "h6", className: "font-semibold mb-12", children: dialogTitle }),
25928
+ financeCalculation && /* @__PURE__ */ jsxs(Grid2, { container: true, spacing: 2, children: [
25929
+ financeCalculation.loanAmount !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
28342
25930
  /* @__PURE__ */ jsxs("strong", { children: [
28343
25931
  t2("LOAN_AMOUNT"),
28344
25932
  ": "
28345
25933
  ] }),
28346
- formatAmount(financeCalculation == null ? void 0 : financeCalculation.loanAmount)
25934
+ formatAmount(financeCalculation.loanAmount)
28347
25935
  ] }) }),
28348
- /* @__PURE__ */ jsx(Grid$1, { item: true, xs: 12, sm: 12, md: 4, className: "flex justify-start", children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", children: [
25936
+ financeCalculation.totalInterestRate !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
28349
25937
  /* @__PURE__ */ jsxs("strong", { children: [
28350
- t2("INTEREST_RATE"),
25938
+ t2("TOTAL_INTEREST_RATE"),
28351
25939
  ": "
28352
25940
  ] }),
28353
- formatAmount(financeCalculation == null ? void 0 : financeCalculation.interestFees)
25941
+ financeCalculation.totalInterestRate,
25942
+ " %"
28354
25943
  ] }) }),
28355
- /* @__PURE__ */ jsx(Grid$1, { item: true, xs: 12, sm: 12, md: 4, className: "flex justify-start", children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", children: [
25944
+ financeCalculation.interestFees !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
28356
25945
  /* @__PURE__ */ jsxs("strong", { children: [
28357
- t2("FEES_DEDUCTION"),
25946
+ t2("INTEREST_FEES"),
28358
25947
  ": "
28359
25948
  ] }),
28360
- formatAmount(financeCalculation == null ? void 0 : financeCalculation.feesDeduction)
25949
+ formatAmount(financeCalculation.interestFees)
28361
25950
  ] }) }),
28362
- /* @__PURE__ */ jsx(Grid$1, { item: true, xs: 12, sm: 12, md: 4, className: "flex justify-start", children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", children: [
25951
+ financeCalculation.repaymentAmount !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
28363
25952
  /* @__PURE__ */ jsxs("strong", { children: [
28364
25953
  t2("REPAYMENT_AMOUNT"),
28365
25954
  ": "
28366
25955
  ] }),
28367
- formatAmount(financeCalculation == null ? void 0 : financeCalculation.repaymentAmount)
25956
+ formatAmount(financeCalculation.repaymentAmount)
25957
+ ] }) }),
25958
+ financeCalculation.durationMonths !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
25959
+ /* @__PURE__ */ jsxs("strong", { children: [
25960
+ t2("DURATION"),
25961
+ ": "
25962
+ ] }),
25963
+ financeCalculation.durationMonths,
25964
+ " ",
25965
+ t2("MONTHS")
25966
+ ] }) }),
25967
+ financeCalculation.stampDuty !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
25968
+ /* @__PURE__ */ jsxs("strong", { children: [
25969
+ t2("STAMP_DUTY"),
25970
+ ": "
25971
+ ] }),
25972
+ formatAmount(financeCalculation.stampDuty)
25973
+ ] }) }),
25974
+ financeCalculation.legalFee !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
25975
+ /* @__PURE__ */ jsxs("strong", { children: [
25976
+ t2("LEGAL_FEES"),
25977
+ ": "
25978
+ ] }),
25979
+ formatAmount(financeCalculation.legalFee)
28368
25980
  ] }) }),
28369
- /* @__PURE__ */ jsx(Grid$1, { item: true, xs: 12, sm: 12, md: 4, className: "flex justify-start", children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", children: [
25981
+ financeCalculation.cashInHand !== void 0 && /* @__PURE__ */ jsx(Grid2, { size: { xs: 12, sm: 4 }, children: /* @__PURE__ */ jsxs(Typography$1, { variant: "body2", children: [
28370
25982
  /* @__PURE__ */ jsxs("strong", { children: [
28371
25983
  t2("CASH_IN_HAND"),
28372
25984
  ": "
28373
25985
  ] }),
28374
- formatAmount(financeCalculation == null ? void 0 : financeCalculation.cashInHand)
25986
+ formatAmount(financeCalculation.cashInHand)
28375
25987
  ] }) })
28376
- ] }),
28377
- /* @__PURE__ */ jsx("div", { className: "flex justify-end mt-10", children: /* @__PURE__ */ jsx(
25988
+ ] })
25989
+ ] }),
25990
+ /* @__PURE__ */ jsx("div", { className: "px-16 py-12", children: /* @__PURE__ */ jsx(
25991
+ "embed",
25992
+ {
25993
+ src: filePath,
25994
+ type: "application/pdf",
25995
+ width: "100%",
25996
+ style: { height: "70vh" }
25997
+ }
25998
+ ) }),
25999
+ (showButton || showConfirmCheckbox) && /* @__PURE__ */ jsx("div", { className: "sticky bottom-0 bg-white w-full px-16 py-10", children: showConfirmCheckbox ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
26000
+ /* @__PURE__ */ jsx(
26001
+ CustomCheckbox,
26002
+ {
26003
+ label: t2("CONFIRM_INFORMATION_READ"),
26004
+ checked: isTermsConfirmed,
26005
+ onChange: (checked) => setIsTermsConfirmed(checked),
26006
+ "data-test-id": "pdf-confirm-information-checkbox"
26007
+ }
26008
+ ),
26009
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
28378
26010
  ColoredSubmitButton,
28379
26011
  {
28380
26012
  variant: "contained",
28381
- disabled: isButtonLoading,
26013
+ disabled: isButtonLoading || !isTermsConfirmed,
28382
26014
  onClick: onConfirm,
28383
26015
  isLoading: isButtonLoading,
28384
26016
  className: "rounded-6",
28385
26017
  text: bottomButtonLabel
28386
26018
  }
28387
26019
  ) })
28388
- ] })
26020
+ ] }) : /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
26021
+ ColoredSubmitButton,
26022
+ {
26023
+ variant: "contained",
26024
+ disabled: isButtonLoading,
26025
+ onClick: onConfirm,
26026
+ isLoading: isButtonLoading,
26027
+ className: "rounded-6",
26028
+ text: bottomButtonLabel
26029
+ }
26030
+ ) }) })
28389
26031
  ] }) });
28390
26032
  };
28391
- const CustomCheckbox = ({
28392
- label,
28393
- onChange,
28394
- checked: controlledChecked,
28395
- ...props
28396
- }) => {
28397
- const [internalChecked, setInternalChecked] = React__default.useState(false);
28398
- const isControlled = controlledChecked !== void 0;
28399
- const isChecked = isControlled ? controlledChecked : internalChecked;
28400
- const handleChange = (newChecked) => {
28401
- if (!isControlled) {
28402
- setInternalChecked(newChecked);
28403
- }
28404
- onChange == null ? void 0 : onChange(newChecked);
28405
- };
28406
- return /* @__PURE__ */ jsx(Fragment, { children: label ? /* @__PURE__ */ jsx(
28407
- FormControlLabel,
28408
- {
28409
- control: /* @__PURE__ */ jsx(
28410
- Checkbox$1,
28411
- {
28412
- checked: isChecked,
28413
- onChange: (event) => handleChange(event.target.checked),
28414
- ...props
28415
- }
28416
- ),
28417
- label
28418
- }
28419
- ) : /* @__PURE__ */ jsx(
28420
- Checkbox$1,
28421
- {
28422
- checked: isChecked,
28423
- onChange: (event) => handleChange(event.target.checked),
28424
- ...props
28425
- }
28426
- ) });
28427
- };
28428
- instance.addResourceBundle("en", "Dialog", locale$3);
28429
- instance.addResourceBundle("ms", "Dialog", locale$2);
26033
+ i18next.addResourceBundle("en", "Dialog", locale$3);
26034
+ i18next.addResourceBundle("ms", "Dialog", locale$2);
28430
26035
  function DocumentSigningDialog({
28431
26036
  financeDetail,
28432
26037
  loginUserDetail,
28433
26038
  digitalSignatureRole,
28434
26039
  ColoredSubmitButton,
28435
- financeCalculation
26040
+ financeCalculation,
26041
+ showConfirmCheckbox = false
28436
26042
  }) {
28437
26043
  const { t: t2 } = useTranslation("Dialog");
28438
26044
  const open = useSelector(getIsDocumentSignatureDialogOpen);
@@ -28564,7 +26170,9 @@ function DocumentSigningDialog({
28564
26170
  loginUserRoles,
28565
26171
  ColoredSubmitButton,
28566
26172
  financeCalculation,
28567
- t: t2
26173
+ t: t2,
26174
+ dialogTitle: t2("PDF_PREVIEW_TITLE"),
26175
+ showConfirmCheckbox
28568
26176
  }
28569
26177
  )
28570
26178
  ] })
@@ -29344,16 +26952,16 @@ function useAutocomplete(props) {
29344
26952
  let groupedOptions = filteredOptions;
29345
26953
  if (groupBy) {
29346
26954
  const indexBy = /* @__PURE__ */ new Map();
29347
- let warn2 = false;
26955
+ let warn = false;
29348
26956
  groupedOptions = filteredOptions.reduce((acc, option, index) => {
29349
26957
  const group = groupBy(option);
29350
26958
  if (acc.length > 0 && acc[acc.length - 1].group === group) {
29351
26959
  acc[acc.length - 1].options.push(option);
29352
26960
  } else {
29353
26961
  if (process.env.NODE_ENV !== "production") {
29354
- if (indexBy.get(group) && !warn2) {
26962
+ if (indexBy.get(group) && !warn) {
29355
26963
  console.warn(`MUI: The options provided combined with the \`groupBy\` method of ${componentName} returns duplicated headers.`, "You can solve the issue by sorting the options with the output of `groupBy`.");
29356
- warn2 = true;
26964
+ warn = true;
29357
26965
  }
29358
26966
  indexBy.set(group, true);
29359
26967
  }
@@ -29949,26 +27557,26 @@ var passive = {
29949
27557
  passive: true
29950
27558
  };
29951
27559
  function effect(_ref) {
29952
- var state = _ref.state, instance2 = _ref.instance, options = _ref.options;
27560
+ var state = _ref.state, instance = _ref.instance, options = _ref.options;
29953
27561
  var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
29954
27562
  var window2 = getWindow(state.elements.popper);
29955
27563
  var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
29956
27564
  if (scroll) {
29957
27565
  scrollParents.forEach(function(scrollParent) {
29958
- scrollParent.addEventListener("scroll", instance2.update, passive);
27566
+ scrollParent.addEventListener("scroll", instance.update, passive);
29959
27567
  });
29960
27568
  }
29961
27569
  if (resize) {
29962
- window2.addEventListener("resize", instance2.update, passive);
27570
+ window2.addEventListener("resize", instance.update, passive);
29963
27571
  }
29964
27572
  return function() {
29965
27573
  if (scroll) {
29966
27574
  scrollParents.forEach(function(scrollParent) {
29967
- scrollParent.removeEventListener("scroll", instance2.update, passive);
27575
+ scrollParent.removeEventListener("scroll", instance.update, passive);
29968
27576
  });
29969
27577
  }
29970
27578
  if (resize) {
29971
- window2.removeEventListener("resize", instance2.update, passive);
27579
+ window2.removeEventListener("resize", instance.update, passive);
29972
27580
  }
29973
27581
  };
29974
27582
  }
@@ -30705,7 +28313,7 @@ function popperGenerator(generatorOptions) {
30705
28313
  };
30706
28314
  var effectCleanupFns = [];
30707
28315
  var isDestroyed = false;
30708
- var instance2 = {
28316
+ var instance = {
30709
28317
  state,
30710
28318
  setOptions: function setOptions(setOptionsAction) {
30711
28319
  var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
@@ -30720,7 +28328,7 @@ function popperGenerator(generatorOptions) {
30720
28328
  return m3.enabled;
30721
28329
  });
30722
28330
  runModifierEffects();
30723
- return instance2.update();
28331
+ return instance.update();
30724
28332
  },
30725
28333
  // Sync update – it will always be executed, even if not necessary. This
30726
28334
  // is useful for low frequency updates where sync behavior simplifies the
@@ -30756,7 +28364,7 @@ function popperGenerator(generatorOptions) {
30756
28364
  state,
30757
28365
  options: _options,
30758
28366
  name,
30759
- instance: instance2
28367
+ instance
30760
28368
  }) || state;
30761
28369
  }
30762
28370
  }
@@ -30765,7 +28373,7 @@ function popperGenerator(generatorOptions) {
30765
28373
  // not necessary (debounced to run at most once-per-tick)
30766
28374
  update: debounce(function() {
30767
28375
  return new Promise(function(resolve) {
30768
- instance2.forceUpdate();
28376
+ instance.forceUpdate();
30769
28377
  resolve(state);
30770
28378
  });
30771
28379
  }),
@@ -30775,9 +28383,9 @@ function popperGenerator(generatorOptions) {
30775
28383
  }
30776
28384
  };
30777
28385
  if (!areValidElements(reference2, popper2)) {
30778
- return instance2;
28386
+ return instance;
30779
28387
  }
30780
- instance2.setOptions(options).then(function(state2) {
28388
+ instance.setOptions(options).then(function(state2) {
30781
28389
  if (!isDestroyed && options.onFirstUpdate) {
30782
28390
  options.onFirstUpdate(state2);
30783
28391
  }
@@ -30789,7 +28397,7 @@ function popperGenerator(generatorOptions) {
30789
28397
  var cleanupFn = effect2({
30790
28398
  state,
30791
28399
  name,
30792
- instance: instance2,
28400
+ instance,
30793
28401
  options: options2
30794
28402
  });
30795
28403
  var noopFn = function noopFn2() {
@@ -30804,7 +28412,7 @@ function popperGenerator(generatorOptions) {
30804
28412
  });
30805
28413
  effectCleanupFns = [];
30806
28414
  }
30807
- return instance2;
28415
+ return instance;
30808
28416
  };
30809
28417
  }
30810
28418
  var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
@@ -32898,9 +30506,9 @@ const InputBase = /* @__PURE__ */ React.forwardRef(function InputBase2(inProps,
32898
30506
  current: isControlled
32899
30507
  } = React.useRef(value != null);
32900
30508
  const inputRef = React.useRef();
32901
- const handleInputRefWarning = React.useCallback((instance2) => {
30509
+ const handleInputRefWarning = React.useCallback((instance) => {
32902
30510
  if (process.env.NODE_ENV !== "production") {
32903
- if (instance2 && instance2.nodeName !== "INPUT" && !instance2.focus) {
30511
+ if (instance && instance.nodeName !== "INPUT" && !instance.focus) {
32904
30512
  console.error(["MUI: You have provided a `inputComponent` to the input component", "that does not correctly handle the `ref` prop.", "Make sure the `ref` prop is called with a HTMLInputElement."].join("\n"));
32905
30513
  }
32906
30514
  }
@@ -41920,9 +39528,9 @@ function useForkRef$1(...refs) {
41920
39528
  if (refs.every((ref) => ref == null)) {
41921
39529
  return null;
41922
39530
  }
41923
- return (instance2) => {
39531
+ return (instance) => {
41924
39532
  refs.forEach((ref) => {
41925
- setRef$1(ref, instance2);
39533
+ setRef$1(ref, instance);
41926
39534
  });
41927
39535
  };
41928
39536
  }, refs);
@@ -43091,9 +40699,9 @@ function useForkRef(...refs) {
43091
40699
  if (refs.every((ref) => ref == null)) {
43092
40700
  return null;
43093
40701
  }
43094
- return (instance2) => {
40702
+ return (instance) => {
43095
40703
  refs.forEach((ref) => {
43096
- setRef(ref, instance2);
40704
+ setRef(ref, instance);
43097
40705
  });
43098
40706
  };
43099
40707
  }, refs);
@@ -43515,7 +41123,7 @@ const useUtilityClasses$m = (ownerState) => {
43515
41123
  };
43516
41124
  return composeClasses$1(slots, getGridUtilityClass, classes);
43517
41125
  };
43518
- const Grid = /* @__PURE__ */ React.forwardRef(function Grid2(inProps, ref) {
41126
+ const Grid = /* @__PURE__ */ React.forwardRef(function Grid3(inProps, ref) {
43519
41127
  const themeProps = useDefaultProps({
43520
41128
  props: inProps,
43521
41129
  name: "MuiGrid"
@@ -46479,11 +44087,11 @@ const usePickerLayoutProps = ({
46479
44087
  };
46480
44088
  };
46481
44089
  const buildWarning = (message, gravity = "warning") => {
46482
- let alreadyWarned2 = false;
44090
+ let alreadyWarned = false;
46483
44091
  const cleanMessage = Array.isArray(message) ? message.join("\n") : message;
46484
44092
  return () => {
46485
- if (!alreadyWarned2) {
46486
- alreadyWarned2 = true;
44093
+ if (!alreadyWarned) {
44094
+ alreadyWarned = true;
46487
44095
  if (gravity === "error") {
46488
44096
  console.error(cleanMessage);
46489
44097
  } else {
@@ -57577,7 +55185,7 @@ export {
57577
55185
  getRemarkListData,
57578
55186
  getSelectedMediaFilePath,
57579
55187
  hideMessage,
57580
- instance as i18n,
55188
+ default2 as i18n,
57581
55189
  reassignStaffMember,
57582
55190
  setActiveFinanceDetail,
57583
55191
  setDocumentSignJPDF,