@aslaluroba/help-center-react 3.0.7 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { createContext, useContext, forwardRef, createElement, useMemo, useState, useEffect, useRef, useCallback } from 'react';
4
- import i18next from 'i18next';
5
4
 
6
5
  function _OverloadYield(e, d) {
7
6
  this.v = e, this.k = d;
@@ -3539,9 +3538,9 @@ var iconMap = {
3539
3538
  thumbsUp: IconThumbUp
3540
3539
  };
3541
3540
  var sizeMap = {
3542
- sm: 'w-4 h-4',
3543
- md: 'w-6 h-6',
3544
- lg: 'w-8 h-8'
3541
+ sm: 'babylai-w-4 babylai-h-4',
3542
+ md: 'babylai-w-6 babylai-h-6',
3543
+ lg: 'babylai-w-8 babylai-h-8'
3545
3544
  };
3546
3545
  var Rating = /*#__PURE__*/React.forwardRef((_ref, ref) => {
3547
3546
  var {
@@ -3571,12 +3570,12 @@ var Rating = /*#__PURE__*/React.forwardRef((_ref, ref) => {
3571
3570
  };
3572
3571
  return jsx("div", _objectSpread2(_objectSpread2({
3573
3572
  ref: ref,
3574
- className: cn('flex items-center', className)
3573
+ className: cn('babylai-flex babylai-items-center', className)
3575
3574
  }, props), {}, {
3576
3575
  children: [...Array(max)].map((_, index) => {
3577
3576
  var filled = (hoverValue !== null ? hoverValue : value) > index;
3578
3577
  return jsx(Icon, {
3579
- className: cn(sizeMap[size], 'cursor-pointer transition-colors', filled ? 'text-yellow-400 fill-yellow-400' : 'text-gray-300', readOnly && 'cursor-default'),
3578
+ className: cn(sizeMap[size], 'babylai-cursor-pointer babylai-transition-colors', filled ? 'babylai-text-yellow-400 babylai-fill-yellow-400' : 'babylai-text-gray-300', readOnly && 'babylai-cursor-default'),
3580
3579
  onMouseEnter: () => handleMouseEnter(index + 1),
3581
3580
  onMouseLeave: handleMouseLeave,
3582
3581
  onClick: () => handleClick(index + 1),
@@ -3590,6 +3589,2218 @@ var Rating = /*#__PURE__*/React.forwardRef((_ref, ref) => {
3590
3589
  });
3591
3590
  Rating.displayName = 'Rating';
3592
3591
 
3592
+ var isString$1 = obj => typeof obj === 'string';
3593
+ var defer = () => {
3594
+ var res;
3595
+ var rej;
3596
+ var promise = new Promise((resolve, reject) => {
3597
+ res = resolve;
3598
+ rej = reject;
3599
+ });
3600
+ promise.resolve = res;
3601
+ promise.reject = rej;
3602
+ return promise;
3603
+ };
3604
+ var makeString = object => {
3605
+ if (object == null) return '';
3606
+ return '' + object;
3607
+ };
3608
+ var copy = (a, s, t) => {
3609
+ a.forEach(m => {
3610
+ if (s[m]) t[m] = s[m];
3611
+ });
3612
+ };
3613
+ var lastOfPathSeparatorRegExp = /###/g;
3614
+ var cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
3615
+ var canNotTraverseDeeper = object => !object || isString$1(object);
3616
+ var getLastOfPath = (object, path, Empty) => {
3617
+ var stack = !isString$1(path) ? path : path.split('.');
3618
+ var stackIndex = 0;
3619
+ while (stackIndex < stack.length - 1) {
3620
+ if (canNotTraverseDeeper(object)) return {};
3621
+ var key = cleanKey(stack[stackIndex]);
3622
+ if (!object[key] && Empty) object[key] = new Empty();
3623
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
3624
+ object = object[key];
3625
+ } else {
3626
+ object = {};
3627
+ }
3628
+ ++stackIndex;
3629
+ }
3630
+ if (canNotTraverseDeeper(object)) return {};
3631
+ return {
3632
+ obj: object,
3633
+ k: cleanKey(stack[stackIndex])
3634
+ };
3635
+ };
3636
+ var setPath = (object, path, newValue) => {
3637
+ var {
3638
+ obj,
3639
+ k
3640
+ } = getLastOfPath(object, path, Object);
3641
+ if (obj !== undefined || path.length === 1) {
3642
+ obj[k] = newValue;
3643
+ return;
3644
+ }
3645
+ var e = path[path.length - 1];
3646
+ var p = path.slice(0, path.length - 1);
3647
+ var last = getLastOfPath(object, p, Object);
3648
+ while (last.obj === undefined && p.length) {
3649
+ var _last;
3650
+ e = "".concat(p[p.length - 1], ".").concat(e);
3651
+ p = p.slice(0, p.length - 1);
3652
+ last = getLastOfPath(object, p, Object);
3653
+ if ((_last = last) !== null && _last !== void 0 && _last.obj && typeof last.obj["".concat(last.k, ".").concat(e)] !== 'undefined') {
3654
+ last.obj = undefined;
3655
+ }
3656
+ }
3657
+ last.obj["".concat(last.k, ".").concat(e)] = newValue;
3658
+ };
3659
+ var pushPath = (object, path, newValue, concat) => {
3660
+ var {
3661
+ obj,
3662
+ k
3663
+ } = getLastOfPath(object, path, Object);
3664
+ obj[k] = obj[k] || [];
3665
+ obj[k].push(newValue);
3666
+ };
3667
+ var getPath = (object, path) => {
3668
+ var {
3669
+ obj,
3670
+ k
3671
+ } = getLastOfPath(object, path);
3672
+ if (!obj) return undefined;
3673
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
3674
+ return obj[k];
3675
+ };
3676
+ var getPathWithDefaults = (data, defaultData, key) => {
3677
+ var value = getPath(data, key);
3678
+ if (value !== undefined) {
3679
+ return value;
3680
+ }
3681
+ return getPath(defaultData, key);
3682
+ };
3683
+ var deepExtend = (target, source, overwrite) => {
3684
+ for (var prop in source) {
3685
+ if (prop !== '__proto__' && prop !== 'constructor') {
3686
+ if (prop in target) {
3687
+ if (isString$1(target[prop]) || target[prop] instanceof String || isString$1(source[prop]) || source[prop] instanceof String) {
3688
+ if (overwrite) target[prop] = source[prop];
3689
+ } else {
3690
+ deepExtend(target[prop], source[prop], overwrite);
3691
+ }
3692
+ } else {
3693
+ target[prop] = source[prop];
3694
+ }
3695
+ }
3696
+ }
3697
+ return target;
3698
+ };
3699
+ var regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
3700
+ var _entityMap = {
3701
+ '&': '&amp;',
3702
+ '<': '&lt;',
3703
+ '>': '&gt;',
3704
+ '"': '&quot;',
3705
+ "'": '&#39;',
3706
+ '/': '&#x2F;'
3707
+ };
3708
+ var escape = data => {
3709
+ if (isString$1(data)) {
3710
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
3711
+ }
3712
+ return data;
3713
+ };
3714
+ class RegExpCache {
3715
+ constructor(capacity) {
3716
+ this.capacity = capacity;
3717
+ this.regExpMap = new Map();
3718
+ this.regExpQueue = [];
3719
+ }
3720
+ getRegExp(pattern) {
3721
+ var regExpFromCache = this.regExpMap.get(pattern);
3722
+ if (regExpFromCache !== undefined) {
3723
+ return regExpFromCache;
3724
+ }
3725
+ var regExpNew = new RegExp(pattern);
3726
+ if (this.regExpQueue.length === this.capacity) {
3727
+ this.regExpMap.delete(this.regExpQueue.shift());
3728
+ }
3729
+ this.regExpMap.set(pattern, regExpNew);
3730
+ this.regExpQueue.push(pattern);
3731
+ return regExpNew;
3732
+ }
3733
+ }
3734
+ var chars = [' ', ',', '?', '!', ';'];
3735
+ var looksLikeObjectPathRegExpCache = new RegExpCache(20);
3736
+ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
3737
+ nsSeparator = nsSeparator || '';
3738
+ keySeparator = keySeparator || '';
3739
+ var possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
3740
+ if (possibleChars.length === 0) return true;
3741
+ var r = looksLikeObjectPathRegExpCache.getRegExp("(".concat(possibleChars.map(c => c === '?' ? '\\?' : c).join('|'), ")"));
3742
+ var matched = !r.test(key);
3743
+ if (!matched) {
3744
+ var ki = key.indexOf(keySeparator);
3745
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
3746
+ matched = true;
3747
+ }
3748
+ }
3749
+ return matched;
3750
+ };
3751
+ var deepFind = function deepFind(obj, path) {
3752
+ var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
3753
+ if (!obj) return undefined;
3754
+ if (obj[path]) {
3755
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
3756
+ return obj[path];
3757
+ }
3758
+ var tokens = path.split(keySeparator);
3759
+ var current = obj;
3760
+ for (var i = 0; i < tokens.length;) {
3761
+ if (!current || typeof current !== 'object') {
3762
+ return undefined;
3763
+ }
3764
+ var next = void 0;
3765
+ var nextPath = '';
3766
+ for (var j = i; j < tokens.length; ++j) {
3767
+ if (j !== i) {
3768
+ nextPath += keySeparator;
3769
+ }
3770
+ nextPath += tokens[j];
3771
+ next = current[nextPath];
3772
+ if (next !== undefined) {
3773
+ if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
3774
+ continue;
3775
+ }
3776
+ i += j - i + 1;
3777
+ break;
3778
+ }
3779
+ }
3780
+ current = next;
3781
+ }
3782
+ return current;
3783
+ };
3784
+ var getCleanedCode = code => code === null || code === void 0 ? void 0 : code.replace('_', '-');
3785
+ var consoleLogger = {
3786
+ type: 'logger',
3787
+ log(args) {
3788
+ this.output('log', args);
3789
+ },
3790
+ warn(args) {
3791
+ this.output('warn', args);
3792
+ },
3793
+ error(args) {
3794
+ this.output('error', args);
3795
+ },
3796
+ output(type, args) {
3797
+ var _console, _console$apply;
3798
+ (_console = console) === null || _console === void 0 || (_console = _console[type]) === null || _console === void 0 || (_console$apply = _console.apply) === null || _console$apply === void 0 || _console$apply.call(_console, console, args);
3799
+ }
3800
+ };
3801
+ class Logger {
3802
+ constructor(concreteLogger) {
3803
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3804
+ this.init(concreteLogger, options);
3805
+ }
3806
+ init(concreteLogger) {
3807
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3808
+ this.prefix = options.prefix || 'i18next:';
3809
+ this.logger = concreteLogger || consoleLogger;
3810
+ this.options = options;
3811
+ this.debug = options.debug;
3812
+ }
3813
+ log() {
3814
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3815
+ args[_key] = arguments[_key];
3816
+ }
3817
+ return this.forward(args, 'log', '', true);
3818
+ }
3819
+ warn() {
3820
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3821
+ args[_key2] = arguments[_key2];
3822
+ }
3823
+ return this.forward(args, 'warn', '', true);
3824
+ }
3825
+ error() {
3826
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
3827
+ args[_key3] = arguments[_key3];
3828
+ }
3829
+ return this.forward(args, 'error', '');
3830
+ }
3831
+ deprecate() {
3832
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
3833
+ args[_key4] = arguments[_key4];
3834
+ }
3835
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
3836
+ }
3837
+ forward(args, lvl, prefix, debugOnly) {
3838
+ if (debugOnly && !this.debug) return null;
3839
+ if (isString$1(args[0])) args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
3840
+ return this.logger[lvl](args);
3841
+ }
3842
+ create(moduleName) {
3843
+ return new Logger(this.logger, _objectSpread2(_objectSpread2({}, {
3844
+ prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
3845
+ }), this.options));
3846
+ }
3847
+ clone(options) {
3848
+ options = options || this.options;
3849
+ options.prefix = options.prefix || this.prefix;
3850
+ return new Logger(this.logger, options);
3851
+ }
3852
+ }
3853
+ var baseLogger = new Logger();
3854
+ class EventEmitter {
3855
+ constructor() {
3856
+ this.observers = {};
3857
+ }
3858
+ on(events, listener) {
3859
+ events.split(' ').forEach(event => {
3860
+ if (!this.observers[event]) this.observers[event] = new Map();
3861
+ var numListeners = this.observers[event].get(listener) || 0;
3862
+ this.observers[event].set(listener, numListeners + 1);
3863
+ });
3864
+ return this;
3865
+ }
3866
+ off(event, listener) {
3867
+ if (!this.observers[event]) return;
3868
+ if (!listener) {
3869
+ delete this.observers[event];
3870
+ return;
3871
+ }
3872
+ this.observers[event].delete(listener);
3873
+ }
3874
+ emit(event) {
3875
+ for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
3876
+ args[_key5 - 1] = arguments[_key5];
3877
+ }
3878
+ if (this.observers[event]) {
3879
+ var cloned = Array.from(this.observers[event].entries());
3880
+ cloned.forEach(_ref => {
3881
+ var [observer, numTimesAdded] = _ref;
3882
+ for (var i = 0; i < numTimesAdded; i++) {
3883
+ observer(...args);
3884
+ }
3885
+ });
3886
+ }
3887
+ if (this.observers['*']) {
3888
+ var _cloned = Array.from(this.observers['*'].entries());
3889
+ _cloned.forEach(_ref2 => {
3890
+ var [observer, numTimesAdded] = _ref2;
3891
+ for (var i = 0; i < numTimesAdded; i++) {
3892
+ observer.apply(observer, [event, ...args]);
3893
+ }
3894
+ });
3895
+ }
3896
+ }
3897
+ }
3898
+ class ResourceStore extends EventEmitter {
3899
+ constructor(data) {
3900
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
3901
+ ns: ['translation'],
3902
+ defaultNS: 'translation'
3903
+ };
3904
+ super();
3905
+ this.data = data || {};
3906
+ this.options = options;
3907
+ if (this.options.keySeparator === undefined) {
3908
+ this.options.keySeparator = '.';
3909
+ }
3910
+ if (this.options.ignoreJSONStructure === undefined) {
3911
+ this.options.ignoreJSONStructure = true;
3912
+ }
3913
+ }
3914
+ addNamespaces(ns) {
3915
+ if (this.options.ns.indexOf(ns) < 0) {
3916
+ this.options.ns.push(ns);
3917
+ }
3918
+ }
3919
+ removeNamespaces(ns) {
3920
+ var index = this.options.ns.indexOf(ns);
3921
+ if (index > -1) {
3922
+ this.options.ns.splice(index, 1);
3923
+ }
3924
+ }
3925
+ getResource(lng, ns, key) {
3926
+ var _this$data;
3927
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3928
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
3929
+ var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
3930
+ var path;
3931
+ if (lng.indexOf('.') > -1) {
3932
+ path = lng.split('.');
3933
+ } else {
3934
+ path = [lng, ns];
3935
+ if (key) {
3936
+ if (Array.isArray(key)) {
3937
+ path.push(...key);
3938
+ } else if (isString$1(key) && keySeparator) {
3939
+ path.push(...key.split(keySeparator));
3940
+ } else {
3941
+ path.push(key);
3942
+ }
3943
+ }
3944
+ }
3945
+ var result = getPath(this.data, path);
3946
+ if (!result && !ns && !key && lng.indexOf('.') > -1) {
3947
+ lng = path[0];
3948
+ ns = path[1];
3949
+ key = path.slice(2).join('.');
3950
+ }
3951
+ if (result || !ignoreJSONStructure || !isString$1(key)) return result;
3952
+ return deepFind((_this$data = this.data) === null || _this$data === void 0 || (_this$data = _this$data[lng]) === null || _this$data === void 0 ? void 0 : _this$data[ns], key, keySeparator);
3953
+ }
3954
+ addResource(lng, ns, key, value) {
3955
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
3956
+ silent: false
3957
+ };
3958
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
3959
+ var path = [lng, ns];
3960
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
3961
+ if (lng.indexOf('.') > -1) {
3962
+ path = lng.split('.');
3963
+ value = ns;
3964
+ ns = path[1];
3965
+ }
3966
+ this.addNamespaces(ns);
3967
+ setPath(this.data, path, value);
3968
+ if (!options.silent) this.emit('added', lng, ns, key, value);
3969
+ }
3970
+ addResources(lng, ns, resources) {
3971
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
3972
+ silent: false
3973
+ };
3974
+ for (var m in resources) {
3975
+ if (isString$1(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
3976
+ silent: true
3977
+ });
3978
+ }
3979
+ if (!options.silent) this.emit('added', lng, ns, resources);
3980
+ }
3981
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
3982
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
3983
+ silent: false,
3984
+ skipCopy: false
3985
+ };
3986
+ var path = [lng, ns];
3987
+ if (lng.indexOf('.') > -1) {
3988
+ path = lng.split('.');
3989
+ deep = resources;
3990
+ resources = ns;
3991
+ ns = path[1];
3992
+ }
3993
+ this.addNamespaces(ns);
3994
+ var pack = getPath(this.data, path) || {};
3995
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
3996
+ if (deep) {
3997
+ deepExtend(pack, resources, overwrite);
3998
+ } else {
3999
+ pack = _objectSpread2(_objectSpread2({}, pack), resources);
4000
+ }
4001
+ setPath(this.data, path, pack);
4002
+ if (!options.silent) this.emit('added', lng, ns, resources);
4003
+ }
4004
+ removeResourceBundle(lng, ns) {
4005
+ if (this.hasResourceBundle(lng, ns)) {
4006
+ delete this.data[lng][ns];
4007
+ }
4008
+ this.removeNamespaces(ns);
4009
+ this.emit('removed', lng, ns);
4010
+ }
4011
+ hasResourceBundle(lng, ns) {
4012
+ return this.getResource(lng, ns) !== undefined;
4013
+ }
4014
+ getResourceBundle(lng, ns) {
4015
+ if (!ns) ns = this.options.defaultNS;
4016
+ return this.getResource(lng, ns);
4017
+ }
4018
+ getDataByLanguage(lng) {
4019
+ return this.data[lng];
4020
+ }
4021
+ hasLanguageSomeTranslations(lng) {
4022
+ var data = this.getDataByLanguage(lng);
4023
+ var n = data && Object.keys(data) || [];
4024
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
4025
+ }
4026
+ toJSON() {
4027
+ return this.data;
4028
+ }
4029
+ }
4030
+ var postProcessor = {
4031
+ processors: {},
4032
+ addPostProcessor(module) {
4033
+ this.processors[module.name] = module;
4034
+ },
4035
+ handle(processors, value, key, options, translator) {
4036
+ processors.forEach(processor => {
4037
+ var _this$processors$proc, _this$processors$proc2;
4038
+ value = (_this$processors$proc = (_this$processors$proc2 = this.processors[processor]) === null || _this$processors$proc2 === void 0 ? void 0 : _this$processors$proc2.process(value, key, options, translator)) !== null && _this$processors$proc !== void 0 ? _this$processors$proc : value;
4039
+ });
4040
+ return value;
4041
+ }
4042
+ };
4043
+ var PATH_KEY = Symbol('i18next/PATH_KEY');
4044
+ function createProxy() {
4045
+ var state = [];
4046
+ var handler = Object.create(null);
4047
+ var proxy;
4048
+ handler.get = (target, key) => {
4049
+ var _proxy, _proxy$revoke;
4050
+ (_proxy = proxy) === null || _proxy === void 0 || (_proxy$revoke = _proxy.revoke) === null || _proxy$revoke === void 0 || _proxy$revoke.call(_proxy);
4051
+ if (key === PATH_KEY) return state;
4052
+ state.push(key);
4053
+ proxy = Proxy.revocable(target, handler);
4054
+ return proxy.proxy;
4055
+ };
4056
+ return Proxy.revocable(Object.create(null), handler).proxy;
4057
+ }
4058
+ function keysFromSelector(selector, opts) {
4059
+ var _opts$keySeparator;
4060
+ var {
4061
+ [PATH_KEY]: path
4062
+ } = selector(createProxy());
4063
+ return path.join((_opts$keySeparator = opts === null || opts === void 0 ? void 0 : opts.keySeparator) !== null && _opts$keySeparator !== void 0 ? _opts$keySeparator : '.');
4064
+ }
4065
+ var checkedLoadedFor = {};
4066
+ var shouldHandleAsObject = res => !isString$1(res) && typeof res !== 'boolean' && typeof res !== 'number';
4067
+ class Translator extends EventEmitter {
4068
+ constructor(services) {
4069
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4070
+ super();
4071
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
4072
+ this.options = options;
4073
+ if (this.options.keySeparator === undefined) {
4074
+ this.options.keySeparator = '.';
4075
+ }
4076
+ this.logger = baseLogger.create('translator');
4077
+ }
4078
+ changeLanguage(lng) {
4079
+ if (lng) this.language = lng;
4080
+ }
4081
+ exists(key) {
4082
+ var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
4083
+ interpolation: {}
4084
+ };
4085
+ var opt = _objectSpread2({}, o);
4086
+ if (key == null) return false;
4087
+ var resolved = this.resolve(key, opt);
4088
+ return (resolved === null || resolved === void 0 ? void 0 : resolved.res) !== undefined;
4089
+ }
4090
+ extractFromKey(key, opt) {
4091
+ var nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
4092
+ if (nsSeparator === undefined) nsSeparator = ':';
4093
+ var keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
4094
+ var namespaces = opt.ns || this.options.defaultNS || [];
4095
+ var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
4096
+ var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
4097
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
4098
+ var m = key.match(this.interpolator.nestingRegexp);
4099
+ if (m && m.length > 0) {
4100
+ return {
4101
+ key,
4102
+ namespaces: isString$1(namespaces) ? [namespaces] : namespaces
4103
+ };
4104
+ }
4105
+ var parts = key.split(nsSeparator);
4106
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
4107
+ key = parts.join(keySeparator);
4108
+ }
4109
+ return {
4110
+ key,
4111
+ namespaces: isString$1(namespaces) ? [namespaces] : namespaces
4112
+ };
4113
+ }
4114
+ translate(keys, o, lastKey) {
4115
+ var opt = typeof o === 'object' ? _objectSpread2({}, o) : o;
4116
+ if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
4117
+ opt = this.options.overloadTranslationOptionHandler(arguments);
4118
+ }
4119
+ if (typeof opt === 'object') opt = _objectSpread2({}, opt);
4120
+ if (!opt) opt = {};
4121
+ if (keys == null) return '';
4122
+ if (typeof keys === 'function') keys = keysFromSelector(keys, _objectSpread2(_objectSpread2({}, this.options), opt));
4123
+ if (!Array.isArray(keys)) keys = [String(keys)];
4124
+ var returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
4125
+ var keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
4126
+ var {
4127
+ key,
4128
+ namespaces
4129
+ } = this.extractFromKey(keys[keys.length - 1], opt);
4130
+ var namespace = namespaces[namespaces.length - 1];
4131
+ var nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
4132
+ if (nsSeparator === undefined) nsSeparator = ':';
4133
+ var lng = opt.lng || this.language;
4134
+ var appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
4135
+ if ((lng === null || lng === void 0 ? void 0 : lng.toLowerCase()) === 'cimode') {
4136
+ if (appendNamespaceToCIMode) {
4137
+ if (returnDetails) {
4138
+ return {
4139
+ res: "".concat(namespace).concat(nsSeparator).concat(key),
4140
+ usedKey: key,
4141
+ exactUsedKey: key,
4142
+ usedLng: lng,
4143
+ usedNS: namespace,
4144
+ usedParams: this.getUsedParamsDetails(opt)
4145
+ };
4146
+ }
4147
+ return "".concat(namespace).concat(nsSeparator).concat(key);
4148
+ }
4149
+ if (returnDetails) {
4150
+ return {
4151
+ res: key,
4152
+ usedKey: key,
4153
+ exactUsedKey: key,
4154
+ usedLng: lng,
4155
+ usedNS: namespace,
4156
+ usedParams: this.getUsedParamsDetails(opt)
4157
+ };
4158
+ }
4159
+ return key;
4160
+ }
4161
+ var resolved = this.resolve(keys, opt);
4162
+ var res = resolved === null || resolved === void 0 ? void 0 : resolved.res;
4163
+ var resUsedKey = (resolved === null || resolved === void 0 ? void 0 : resolved.usedKey) || key;
4164
+ var resExactUsedKey = (resolved === null || resolved === void 0 ? void 0 : resolved.exactUsedKey) || key;
4165
+ var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
4166
+ var joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
4167
+ var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
4168
+ var needsPluralHandling = opt.count !== undefined && !isString$1(opt.count);
4169
+ var hasDefaultValue = Translator.hasDefaultValue(opt);
4170
+ var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
4171
+ var defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
4172
+ ordinal: false
4173
+ }) : '';
4174
+ var needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
4175
+ var defaultValue = needsZeroSuffixLookup && opt["defaultValue".concat(this.options.pluralSeparator, "zero")] || opt["defaultValue".concat(defaultValueSuffix)] || opt["defaultValue".concat(defaultValueSuffixOrdinalFallback)] || opt.defaultValue;
4176
+ var resForObjHndl = res;
4177
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
4178
+ resForObjHndl = defaultValue;
4179
+ }
4180
+ var handleAsObject = shouldHandleAsObject(resForObjHndl);
4181
+ var resType = Object.prototype.toString.apply(resForObjHndl);
4182
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString$1(joinArrays) && Array.isArray(resForObjHndl))) {
4183
+ if (!opt.returnObjects && !this.options.returnObjects) {
4184
+ if (!this.options.returnedObjectHandler) {
4185
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
4186
+ }
4187
+ var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, _objectSpread2(_objectSpread2({}, opt), {}, {
4188
+ ns: namespaces
4189
+ })) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
4190
+ if (returnDetails) {
4191
+ resolved.res = r;
4192
+ resolved.usedParams = this.getUsedParamsDetails(opt);
4193
+ return resolved;
4194
+ }
4195
+ return r;
4196
+ }
4197
+ if (keySeparator) {
4198
+ var resTypeIsArray = Array.isArray(resForObjHndl);
4199
+ var _copy = resTypeIsArray ? [] : {};
4200
+ var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
4201
+ for (var m in resForObjHndl) {
4202
+ if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
4203
+ var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
4204
+ if (hasDefaultValue && !res) {
4205
+ _copy[m] = this.translate(deepKey, _objectSpread2(_objectSpread2({}, opt), {}, {
4206
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined
4207
+ }, {
4208
+ joinArrays: false,
4209
+ ns: namespaces
4210
+ }));
4211
+ } else {
4212
+ _copy[m] = this.translate(deepKey, _objectSpread2(_objectSpread2({}, opt), {
4213
+ joinArrays: false,
4214
+ ns: namespaces
4215
+ }));
4216
+ }
4217
+ if (_copy[m] === deepKey) _copy[m] = resForObjHndl[m];
4218
+ }
4219
+ }
4220
+ res = _copy;
4221
+ }
4222
+ } else if (handleAsObjectInI18nFormat && isString$1(joinArrays) && Array.isArray(res)) {
4223
+ res = res.join(joinArrays);
4224
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
4225
+ } else {
4226
+ var usedDefault = false;
4227
+ var usedKey = false;
4228
+ if (!this.isValidLookup(res) && hasDefaultValue) {
4229
+ usedDefault = true;
4230
+ res = defaultValue;
4231
+ }
4232
+ if (!this.isValidLookup(res)) {
4233
+ usedKey = true;
4234
+ res = key;
4235
+ }
4236
+ var missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
4237
+ var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
4238
+ var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
4239
+ if (usedKey || usedDefault || updateMissing) {
4240
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
4241
+ if (keySeparator) {
4242
+ var fk = this.resolve(key, _objectSpread2(_objectSpread2({}, opt), {}, {
4243
+ keySeparator: false
4244
+ }));
4245
+ 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.');
4246
+ }
4247
+ var lngs = [];
4248
+ var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
4249
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
4250
+ for (var i = 0; i < fallbackLngs.length; i++) {
4251
+ lngs.push(fallbackLngs[i]);
4252
+ }
4253
+ } else if (this.options.saveMissingTo === 'all') {
4254
+ lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
4255
+ } else {
4256
+ lngs.push(opt.lng || this.language);
4257
+ }
4258
+ var send = (l, k, specificDefaultValue) => {
4259
+ var _this$backendConnecto;
4260
+ var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
4261
+ if (this.options.missingKeyHandler) {
4262
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
4263
+ } else if ((_this$backendConnecto = this.backendConnector) !== null && _this$backendConnecto !== void 0 && _this$backendConnecto.saveMissing) {
4264
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
4265
+ }
4266
+ this.emit('missingKey', l, namespace, k, res);
4267
+ };
4268
+ if (this.options.saveMissing) {
4269
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
4270
+ lngs.forEach(language => {
4271
+ var suffixes = this.pluralResolver.getSuffixes(language, opt);
4272
+ if (needsZeroSuffixLookup && opt["defaultValue".concat(this.options.pluralSeparator, "zero")] && suffixes.indexOf("".concat(this.options.pluralSeparator, "zero")) < 0) {
4273
+ suffixes.push("".concat(this.options.pluralSeparator, "zero"));
4274
+ }
4275
+ suffixes.forEach(suffix => {
4276
+ send([language], key + suffix, opt["defaultValue".concat(suffix)] || defaultValue);
4277
+ });
4278
+ });
4279
+ } else {
4280
+ send(lngs, key, defaultValue);
4281
+ }
4282
+ }
4283
+ }
4284
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
4285
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
4286
+ res = "".concat(namespace).concat(nsSeparator).concat(key);
4287
+ }
4288
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
4289
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace).concat(nsSeparator).concat(key) : key, usedDefault ? res : undefined, opt);
4290
+ }
4291
+ }
4292
+ if (returnDetails) {
4293
+ resolved.res = res;
4294
+ resolved.usedParams = this.getUsedParamsDetails(opt);
4295
+ return resolved;
4296
+ }
4297
+ return res;
4298
+ }
4299
+ extendTranslation(res, key, opt, resolved, lastKey) {
4300
+ var _this$i18nFormat,
4301
+ _this = this;
4302
+ if ((_this$i18nFormat = this.i18nFormat) !== null && _this$i18nFormat !== void 0 && _this$i18nFormat.parse) {
4303
+ res = this.i18nFormat.parse(res, _objectSpread2(_objectSpread2({}, this.options.interpolation.defaultVariables), opt), opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
4304
+ resolved
4305
+ });
4306
+ } else if (!opt.skipInterpolation) {
4307
+ var _opt$interpolation;
4308
+ if (opt.interpolation) this.interpolator.init(_objectSpread2(_objectSpread2({}, opt), {
4309
+ interpolation: _objectSpread2(_objectSpread2({}, this.options.interpolation), opt.interpolation)
4310
+ }));
4311
+ var skipOnVariables = isString$1(res) && ((opt === null || opt === void 0 || (_opt$interpolation = opt.interpolation) === null || _opt$interpolation === void 0 ? void 0 : _opt$interpolation.skipOnVariables) !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
4312
+ var nestBef;
4313
+ if (skipOnVariables) {
4314
+ var nb = res.match(this.interpolator.nestingRegexp);
4315
+ nestBef = nb && nb.length;
4316
+ }
4317
+ var data = opt.replace && !isString$1(opt.replace) ? opt.replace : opt;
4318
+ if (this.options.interpolation.defaultVariables) data = _objectSpread2(_objectSpread2({}, this.options.interpolation.defaultVariables), data);
4319
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
4320
+ if (skipOnVariables) {
4321
+ var na = res.match(this.interpolator.nestingRegexp);
4322
+ var nestAft = na && na.length;
4323
+ if (nestBef < nestAft) opt.nest = false;
4324
+ }
4325
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
4326
+ if (opt.nest !== false) res = this.interpolator.nest(res, function () {
4327
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
4328
+ args[_key6] = arguments[_key6];
4329
+ }
4330
+ if ((lastKey === null || lastKey === void 0 ? void 0 : lastKey[0]) === args[0] && !opt.context) {
4331
+ _this.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
4332
+ return null;
4333
+ }
4334
+ return _this.translate(...args, key);
4335
+ }, opt);
4336
+ if (opt.interpolation) this.interpolator.reset();
4337
+ }
4338
+ var postProcess = opt.postProcess || this.options.postProcess;
4339
+ var postProcessorNames = isString$1(postProcess) ? [postProcess] : postProcess;
4340
+ if (res != null && postProcessorNames !== null && postProcessorNames !== void 0 && postProcessorNames.length && opt.applyPostProcessor !== false) {
4341
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread2({
4342
+ i18nResolved: _objectSpread2(_objectSpread2({}, resolved), {}, {
4343
+ usedParams: this.getUsedParamsDetails(opt)
4344
+ })
4345
+ }, opt) : opt, this);
4346
+ }
4347
+ return res;
4348
+ }
4349
+ resolve(keys) {
4350
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4351
+ var found;
4352
+ var usedKey;
4353
+ var exactUsedKey;
4354
+ var usedLng;
4355
+ var usedNS;
4356
+ if (isString$1(keys)) keys = [keys];
4357
+ keys.forEach(k => {
4358
+ if (this.isValidLookup(found)) return;
4359
+ var extracted = this.extractFromKey(k, opt);
4360
+ var key = extracted.key;
4361
+ usedKey = key;
4362
+ var namespaces = extracted.namespaces;
4363
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
4364
+ var needsPluralHandling = opt.count !== undefined && !isString$1(opt.count);
4365
+ var needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
4366
+ var needsContextHandling = opt.context !== undefined && (isString$1(opt.context) || typeof opt.context === 'number') && opt.context !== '';
4367
+ var codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
4368
+ namespaces.forEach(ns => {
4369
+ var _this$utils, _this$utils2;
4370
+ if (this.isValidLookup(found)) return;
4371
+ usedNS = ns;
4372
+ if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && (_this$utils = this.utils) !== null && _this$utils !== void 0 && _this$utils.hasLoadedNamespace && !((_this$utils2 = this.utils) !== null && _this$utils2 !== void 0 && _this$utils2.hasLoadedNamespace(usedNS))) {
4373
+ checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
4374
+ this.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(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!!!');
4375
+ }
4376
+ codes.forEach(code => {
4377
+ var _this$i18nFormat2;
4378
+ if (this.isValidLookup(found)) return;
4379
+ usedLng = code;
4380
+ var finalKeys = [key];
4381
+ if ((_this$i18nFormat2 = this.i18nFormat) !== null && _this$i18nFormat2 !== void 0 && _this$i18nFormat2.addLookupKeys) {
4382
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
4383
+ } else {
4384
+ var pluralSuffix;
4385
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
4386
+ var zeroSuffix = "".concat(this.options.pluralSeparator, "zero");
4387
+ var ordinalPrefix = "".concat(this.options.pluralSeparator, "ordinal").concat(this.options.pluralSeparator);
4388
+ if (needsPluralHandling) {
4389
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
4390
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
4391
+ }
4392
+ finalKeys.push(key + pluralSuffix);
4393
+ if (needsZeroSuffixLookup) {
4394
+ finalKeys.push(key + zeroSuffix);
4395
+ }
4396
+ }
4397
+ if (needsContextHandling) {
4398
+ var contextKey = "".concat(key).concat(this.options.contextSeparator || '_').concat(opt.context);
4399
+ finalKeys.push(contextKey);
4400
+ if (needsPluralHandling) {
4401
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
4402
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
4403
+ }
4404
+ finalKeys.push(contextKey + pluralSuffix);
4405
+ if (needsZeroSuffixLookup) {
4406
+ finalKeys.push(contextKey + zeroSuffix);
4407
+ }
4408
+ }
4409
+ }
4410
+ }
4411
+ var possibleKey;
4412
+ while (possibleKey = finalKeys.pop()) {
4413
+ if (!this.isValidLookup(found)) {
4414
+ exactUsedKey = possibleKey;
4415
+ found = this.getResource(code, ns, possibleKey, opt);
4416
+ }
4417
+ }
4418
+ });
4419
+ });
4420
+ });
4421
+ return {
4422
+ res: found,
4423
+ usedKey,
4424
+ exactUsedKey,
4425
+ usedLng,
4426
+ usedNS
4427
+ };
4428
+ }
4429
+ isValidLookup(res) {
4430
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
4431
+ }
4432
+ getResource(code, ns, key) {
4433
+ var _this$i18nFormat3;
4434
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4435
+ if ((_this$i18nFormat3 = this.i18nFormat) !== null && _this$i18nFormat3 !== void 0 && _this$i18nFormat3.getResource) return this.i18nFormat.getResource(code, ns, key, options);
4436
+ return this.resourceStore.getResource(code, ns, key, options);
4437
+ }
4438
+ getUsedParamsDetails() {
4439
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4440
+ var optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
4441
+ var useOptionsReplaceForData = options.replace && !isString$1(options.replace);
4442
+ var data = useOptionsReplaceForData ? options.replace : options;
4443
+ if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
4444
+ data.count = options.count;
4445
+ }
4446
+ if (this.options.interpolation.defaultVariables) {
4447
+ data = _objectSpread2(_objectSpread2({}, this.options.interpolation.defaultVariables), data);
4448
+ }
4449
+ if (!useOptionsReplaceForData) {
4450
+ data = _objectSpread2({}, data);
4451
+ for (var key of optionsKeys) {
4452
+ delete data[key];
4453
+ }
4454
+ }
4455
+ return data;
4456
+ }
4457
+ static hasDefaultValue(options) {
4458
+ var prefix = 'defaultValue';
4459
+ for (var option in options) {
4460
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
4461
+ return true;
4462
+ }
4463
+ }
4464
+ return false;
4465
+ }
4466
+ }
4467
+ class LanguageUtil {
4468
+ constructor(options) {
4469
+ this.options = options;
4470
+ this.supportedLngs = this.options.supportedLngs || false;
4471
+ this.logger = baseLogger.create('languageUtils');
4472
+ }
4473
+ getScriptPartFromCode(code) {
4474
+ code = getCleanedCode(code);
4475
+ if (!code || code.indexOf('-') < 0) return null;
4476
+ var p = code.split('-');
4477
+ if (p.length === 2) return null;
4478
+ p.pop();
4479
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
4480
+ return this.formatLanguageCode(p.join('-'));
4481
+ }
4482
+ getLanguagePartFromCode(code) {
4483
+ code = getCleanedCode(code);
4484
+ if (!code || code.indexOf('-') < 0) return code;
4485
+ var p = code.split('-');
4486
+ return this.formatLanguageCode(p[0]);
4487
+ }
4488
+ formatLanguageCode(code) {
4489
+ if (isString$1(code) && code.indexOf('-') > -1) {
4490
+ var formattedCode;
4491
+ try {
4492
+ formattedCode = Intl.getCanonicalLocales(code)[0];
4493
+ } catch (e) {}
4494
+ if (formattedCode && this.options.lowerCaseLng) {
4495
+ formattedCode = formattedCode.toLowerCase();
4496
+ }
4497
+ if (formattedCode) return formattedCode;
4498
+ if (this.options.lowerCaseLng) {
4499
+ return code.toLowerCase();
4500
+ }
4501
+ return code;
4502
+ }
4503
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
4504
+ }
4505
+ isSupportedCode(code) {
4506
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
4507
+ code = this.getLanguagePartFromCode(code);
4508
+ }
4509
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
4510
+ }
4511
+ getBestMatchFromCodes(codes) {
4512
+ if (!codes) return null;
4513
+ var found;
4514
+ codes.forEach(code => {
4515
+ if (found) return;
4516
+ var cleanedLng = this.formatLanguageCode(code);
4517
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
4518
+ });
4519
+ if (!found && this.options.supportedLngs) {
4520
+ codes.forEach(code => {
4521
+ if (found) return;
4522
+ var lngScOnly = this.getScriptPartFromCode(code);
4523
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
4524
+ var lngOnly = this.getLanguagePartFromCode(code);
4525
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
4526
+ found = this.options.supportedLngs.find(supportedLng => {
4527
+ if (supportedLng === lngOnly) return supportedLng;
4528
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
4529
+ if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
4530
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
4531
+ });
4532
+ });
4533
+ }
4534
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
4535
+ return found;
4536
+ }
4537
+ getFallbackCodes(fallbacks, code) {
4538
+ if (!fallbacks) return [];
4539
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
4540
+ if (isString$1(fallbacks)) fallbacks = [fallbacks];
4541
+ if (Array.isArray(fallbacks)) return fallbacks;
4542
+ if (!code) return fallbacks.default || [];
4543
+ var found = fallbacks[code];
4544
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
4545
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
4546
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
4547
+ if (!found) found = fallbacks.default;
4548
+ return found || [];
4549
+ }
4550
+ toResolveHierarchy(code, fallbackCode) {
4551
+ var fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
4552
+ var codes = [];
4553
+ var addCode = c => {
4554
+ if (!c) return;
4555
+ if (this.isSupportedCode(c)) {
4556
+ codes.push(c);
4557
+ } else {
4558
+ this.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
4559
+ }
4560
+ };
4561
+ if (isString$1(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
4562
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
4563
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
4564
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
4565
+ } else if (isString$1(code)) {
4566
+ addCode(this.formatLanguageCode(code));
4567
+ }
4568
+ fallbackCodes.forEach(fc => {
4569
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
4570
+ });
4571
+ return codes;
4572
+ }
4573
+ }
4574
+ var suffixesOrder = {
4575
+ zero: 0,
4576
+ one: 1,
4577
+ two: 2,
4578
+ few: 3,
4579
+ many: 4,
4580
+ other: 5
4581
+ };
4582
+ var dummyRule = {
4583
+ select: count => count === 1 ? 'one' : 'other',
4584
+ resolvedOptions: () => ({
4585
+ pluralCategories: ['one', 'other']
4586
+ })
4587
+ };
4588
+ class PluralResolver {
4589
+ constructor(languageUtils) {
4590
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4591
+ this.languageUtils = languageUtils;
4592
+ this.options = options;
4593
+ this.logger = baseLogger.create('pluralResolver');
4594
+ this.pluralRulesCache = {};
4595
+ }
4596
+ addRule(lng, obj) {
4597
+ this.rules[lng] = obj;
4598
+ }
4599
+ clearCache() {
4600
+ this.pluralRulesCache = {};
4601
+ }
4602
+ getRule(code) {
4603
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4604
+ var cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
4605
+ var type = options.ordinal ? 'ordinal' : 'cardinal';
4606
+ var cacheKey = JSON.stringify({
4607
+ cleanedCode,
4608
+ type
4609
+ });
4610
+ if (cacheKey in this.pluralRulesCache) {
4611
+ return this.pluralRulesCache[cacheKey];
4612
+ }
4613
+ var rule;
4614
+ try {
4615
+ rule = new Intl.PluralRules(cleanedCode, {
4616
+ type
4617
+ });
4618
+ } catch (err) {
4619
+ if (!Intl) {
4620
+ this.logger.error('No Intl support, please use an Intl polyfill!');
4621
+ return dummyRule;
4622
+ }
4623
+ if (!code.match(/-|_/)) return dummyRule;
4624
+ var lngPart = this.languageUtils.getLanguagePartFromCode(code);
4625
+ rule = this.getRule(lngPart, options);
4626
+ }
4627
+ this.pluralRulesCache[cacheKey] = rule;
4628
+ return rule;
4629
+ }
4630
+ needsPlural(code) {
4631
+ var _rule;
4632
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4633
+ var rule = this.getRule(code, options);
4634
+ if (!rule) rule = this.getRule('dev', options);
4635
+ return ((_rule = rule) === null || _rule === void 0 ? void 0 : _rule.resolvedOptions().pluralCategories.length) > 1;
4636
+ }
4637
+ getPluralFormsOfKey(code, key) {
4638
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4639
+ return this.getSuffixes(code, options).map(suffix => "".concat(key).concat(suffix));
4640
+ }
4641
+ getSuffixes(code) {
4642
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4643
+ var rule = this.getRule(code, options);
4644
+ if (!rule) rule = this.getRule('dev', options);
4645
+ if (!rule) return [];
4646
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => "".concat(this.options.prepend).concat(options.ordinal ? "ordinal".concat(this.options.prepend) : '').concat(pluralCategory));
4647
+ }
4648
+ getSuffix(code, count) {
4649
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4650
+ var rule = this.getRule(code, options);
4651
+ if (rule) {
4652
+ return "".concat(this.options.prepend).concat(options.ordinal ? "ordinal".concat(this.options.prepend) : '').concat(rule.select(count));
4653
+ }
4654
+ this.logger.warn("no plural rule found for: ".concat(code));
4655
+ return this.getSuffix('dev', count, options);
4656
+ }
4657
+ }
4658
+ var deepFindWithDefaults = function deepFindWithDefaults(data, defaultData, key) {
4659
+ var keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
4660
+ var ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
4661
+ var path = getPathWithDefaults(data, defaultData, key);
4662
+ if (!path && ignoreJSONStructure && isString$1(key)) {
4663
+ path = deepFind(data, key, keySeparator);
4664
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
4665
+ }
4666
+ return path;
4667
+ };
4668
+ var regexSafe = val => val.replace(/\$/g, '$$$$');
4669
+ class Interpolator {
4670
+ constructor() {
4671
+ var _options$interpolatio;
4672
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4673
+ this.logger = baseLogger.create('interpolator');
4674
+ this.options = options;
4675
+ this.format = (options === null || options === void 0 || (_options$interpolatio = options.interpolation) === null || _options$interpolatio === void 0 ? void 0 : _options$interpolatio.format) || (value => value);
4676
+ this.init(options);
4677
+ }
4678
+ init() {
4679
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4680
+ if (!options.interpolation) options.interpolation = {
4681
+ escapeValue: true
4682
+ };
4683
+ var {
4684
+ escape: escape$1,
4685
+ escapeValue,
4686
+ useRawValueToEscape,
4687
+ prefix,
4688
+ prefixEscaped,
4689
+ suffix,
4690
+ suffixEscaped,
4691
+ formatSeparator,
4692
+ unescapeSuffix,
4693
+ unescapePrefix,
4694
+ nestingPrefix,
4695
+ nestingPrefixEscaped,
4696
+ nestingSuffix,
4697
+ nestingSuffixEscaped,
4698
+ nestingOptionsSeparator,
4699
+ maxReplaces,
4700
+ alwaysFormat
4701
+ } = options.interpolation;
4702
+ this.escape = escape$1 !== undefined ? escape$1 : escape;
4703
+ this.escapeValue = escapeValue !== undefined ? escapeValue : true;
4704
+ this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
4705
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
4706
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
4707
+ this.formatSeparator = formatSeparator || ',';
4708
+ this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
4709
+ this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
4710
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
4711
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
4712
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
4713
+ this.maxReplaces = maxReplaces || 1000;
4714
+ this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
4715
+ this.resetRegExp();
4716
+ }
4717
+ reset() {
4718
+ if (this.options) this.init(this.options);
4719
+ }
4720
+ resetRegExp() {
4721
+ var getOrResetRegExp = (existingRegExp, pattern) => {
4722
+ if ((existingRegExp === null || existingRegExp === void 0 ? void 0 : existingRegExp.source) === pattern) {
4723
+ existingRegExp.lastIndex = 0;
4724
+ return existingRegExp;
4725
+ }
4726
+ return new RegExp(pattern, 'g');
4727
+ };
4728
+ this.regexp = getOrResetRegExp(this.regexp, "".concat(this.prefix, "(.+?)").concat(this.suffix));
4729
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix));
4730
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, "".concat(this.nestingPrefix, "((?:[^()\"']+|\"[^\"]*\"|'[^']*'|\\((?:[^()]|\"[^\"]*\"|'[^']*')*\\))*?)").concat(this.nestingSuffix));
4731
+ }
4732
+ interpolate(str, data, lng, options) {
4733
+ var _options$interpolatio2;
4734
+ var match;
4735
+ var value;
4736
+ var replaces;
4737
+ var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
4738
+ var handleFormat = key => {
4739
+ if (key.indexOf(this.formatSeparator) < 0) {
4740
+ var path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
4741
+ return this.alwaysFormat ? this.format(path, undefined, lng, _objectSpread2(_objectSpread2(_objectSpread2({}, options), data), {}, {
4742
+ interpolationkey: key
4743
+ })) : path;
4744
+ }
4745
+ var p = key.split(this.formatSeparator);
4746
+ var k = p.shift().trim();
4747
+ var f = p.join(this.formatSeparator).trim();
4748
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, _objectSpread2(_objectSpread2(_objectSpread2({}, options), data), {}, {
4749
+ interpolationkey: k
4750
+ }));
4751
+ };
4752
+ this.resetRegExp();
4753
+ var missingInterpolationHandler = (options === null || options === void 0 ? void 0 : options.missingInterpolationHandler) || this.options.missingInterpolationHandler;
4754
+ var skipOnVariables = (options === null || options === void 0 || (_options$interpolatio2 = options.interpolation) === null || _options$interpolatio2 === void 0 ? void 0 : _options$interpolatio2.skipOnVariables) !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
4755
+ var todos = [{
4756
+ regex: this.regexpUnescape,
4757
+ safeValue: val => regexSafe(val)
4758
+ }, {
4759
+ regex: this.regexp,
4760
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
4761
+ }];
4762
+ todos.forEach(todo => {
4763
+ replaces = 0;
4764
+ while (match = todo.regex.exec(str)) {
4765
+ var matchedVar = match[1].trim();
4766
+ value = handleFormat(matchedVar);
4767
+ if (value === undefined) {
4768
+ if (typeof missingInterpolationHandler === 'function') {
4769
+ var temp = missingInterpolationHandler(str, match, options);
4770
+ value = isString$1(temp) ? temp : '';
4771
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
4772
+ value = '';
4773
+ } else if (skipOnVariables) {
4774
+ value = match[0];
4775
+ continue;
4776
+ } else {
4777
+ this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
4778
+ value = '';
4779
+ }
4780
+ } else if (!isString$1(value) && !this.useRawValueToEscape) {
4781
+ value = makeString(value);
4782
+ }
4783
+ var safeValue = todo.safeValue(value);
4784
+ str = str.replace(match[0], safeValue);
4785
+ if (skipOnVariables) {
4786
+ todo.regex.lastIndex += value.length;
4787
+ todo.regex.lastIndex -= match[0].length;
4788
+ } else {
4789
+ todo.regex.lastIndex = 0;
4790
+ }
4791
+ replaces++;
4792
+ if (replaces >= this.maxReplaces) {
4793
+ break;
4794
+ }
4795
+ }
4796
+ });
4797
+ return str;
4798
+ }
4799
+ nest(str, fc) {
4800
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4801
+ var match;
4802
+ var value;
4803
+ var clonedOptions;
4804
+ var handleHasOptions = (key, inheritedOptions) => {
4805
+ var _matchedSingleQuotes$;
4806
+ var sep = this.nestingOptionsSeparator;
4807
+ if (key.indexOf(sep) < 0) return key;
4808
+ var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
4809
+ var optionsString = "{".concat(c[1]);
4810
+ key = c[0];
4811
+ optionsString = this.interpolate(optionsString, clonedOptions);
4812
+ var matchedSingleQuotes = optionsString.match(/'/g);
4813
+ var matchedDoubleQuotes = optionsString.match(/"/g);
4814
+ if (((_matchedSingleQuotes$ = matchedSingleQuotes === null || matchedSingleQuotes === void 0 ? void 0 : matchedSingleQuotes.length) !== null && _matchedSingleQuotes$ !== void 0 ? _matchedSingleQuotes$ : 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
4815
+ optionsString = optionsString.replace(/'/g, '"');
4816
+ }
4817
+ try {
4818
+ clonedOptions = JSON.parse(optionsString);
4819
+ if (inheritedOptions) clonedOptions = _objectSpread2(_objectSpread2({}, inheritedOptions), clonedOptions);
4820
+ } catch (e) {
4821
+ this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
4822
+ return "".concat(key).concat(sep).concat(optionsString);
4823
+ }
4824
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
4825
+ return key;
4826
+ };
4827
+ while (match = this.nestingRegexp.exec(str)) {
4828
+ var formatters = [];
4829
+ clonedOptions = _objectSpread2({}, options);
4830
+ clonedOptions = clonedOptions.replace && !isString$1(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
4831
+ clonedOptions.applyPostProcessor = false;
4832
+ delete clonedOptions.defaultValue;
4833
+ var keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
4834
+ if (keyEndIndex !== -1) {
4835
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
4836
+ match[1] = match[1].slice(0, keyEndIndex);
4837
+ }
4838
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
4839
+ if (value && match[0] === str && !isString$1(value)) return value;
4840
+ if (!isString$1(value)) value = makeString(value);
4841
+ if (!value) {
4842
+ this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
4843
+ value = '';
4844
+ }
4845
+ if (formatters.length) {
4846
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, _objectSpread2(_objectSpread2({}, options), {}, {
4847
+ interpolationkey: match[1].trim()
4848
+ })), value.trim());
4849
+ }
4850
+ str = str.replace(match[0], value);
4851
+ this.regexp.lastIndex = 0;
4852
+ }
4853
+ return str;
4854
+ }
4855
+ }
4856
+ var parseFormatStr = formatStr => {
4857
+ var formatName = formatStr.toLowerCase().trim();
4858
+ var formatOptions = {};
4859
+ if (formatStr.indexOf('(') > -1) {
4860
+ var p = formatStr.split('(');
4861
+ formatName = p[0].toLowerCase().trim();
4862
+ var optStr = p[1].substring(0, p[1].length - 1);
4863
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
4864
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
4865
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
4866
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
4867
+ } else {
4868
+ var opts = optStr.split(';');
4869
+ opts.forEach(opt => {
4870
+ if (opt) {
4871
+ var [key, ...rest] = opt.split(':');
4872
+ var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
4873
+ var trimmedKey = key.trim();
4874
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
4875
+ if (val === 'false') formatOptions[trimmedKey] = false;
4876
+ if (val === 'true') formatOptions[trimmedKey] = true;
4877
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
4878
+ }
4879
+ });
4880
+ }
4881
+ }
4882
+ return {
4883
+ formatName,
4884
+ formatOptions
4885
+ };
4886
+ };
4887
+ var createCachedFormatter = fn => {
4888
+ var cache = {};
4889
+ return (v, l, o) => {
4890
+ var optForCache = o;
4891
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
4892
+ optForCache = _objectSpread2(_objectSpread2({}, optForCache), {}, {
4893
+ [o.interpolationkey]: undefined
4894
+ });
4895
+ }
4896
+ var key = l + JSON.stringify(optForCache);
4897
+ var frm = cache[key];
4898
+ if (!frm) {
4899
+ frm = fn(getCleanedCode(l), o);
4900
+ cache[key] = frm;
4901
+ }
4902
+ return frm(v);
4903
+ };
4904
+ };
4905
+ var createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
4906
+ class Formatter {
4907
+ constructor() {
4908
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4909
+ this.logger = baseLogger.create('formatter');
4910
+ this.options = options;
4911
+ this.init(options);
4912
+ }
4913
+ init(services) {
4914
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
4915
+ interpolation: {}
4916
+ };
4917
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
4918
+ var cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
4919
+ this.formats = {
4920
+ number: cf((lng, opt) => {
4921
+ var formatter = new Intl.NumberFormat(lng, _objectSpread2({}, opt));
4922
+ return val => formatter.format(val);
4923
+ }),
4924
+ currency: cf((lng, opt) => {
4925
+ var formatter = new Intl.NumberFormat(lng, _objectSpread2(_objectSpread2({}, opt), {}, {
4926
+ style: 'currency'
4927
+ }));
4928
+ return val => formatter.format(val);
4929
+ }),
4930
+ datetime: cf((lng, opt) => {
4931
+ var formatter = new Intl.DateTimeFormat(lng, _objectSpread2({}, opt));
4932
+ return val => formatter.format(val);
4933
+ }),
4934
+ relativetime: cf((lng, opt) => {
4935
+ var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread2({}, opt));
4936
+ return val => formatter.format(val, opt.range || 'day');
4937
+ }),
4938
+ list: cf((lng, opt) => {
4939
+ var formatter = new Intl.ListFormat(lng, _objectSpread2({}, opt));
4940
+ return val => formatter.format(val);
4941
+ })
4942
+ };
4943
+ }
4944
+ add(name, fc) {
4945
+ this.formats[name.toLowerCase().trim()] = fc;
4946
+ }
4947
+ addCached(name, fc) {
4948
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
4949
+ }
4950
+ format(value, format, lng) {
4951
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4952
+ var formats = format.split(this.formatSeparator);
4953
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
4954
+ var lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
4955
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
4956
+ }
4957
+ var result = formats.reduce((mem, f) => {
4958
+ var {
4959
+ formatName,
4960
+ formatOptions
4961
+ } = parseFormatStr(f);
4962
+ if (this.formats[formatName]) {
4963
+ var formatted = mem;
4964
+ try {
4965
+ var _options$formatParams;
4966
+ var valOptions = (options === null || options === void 0 || (_options$formatParams = options.formatParams) === null || _options$formatParams === void 0 ? void 0 : _options$formatParams[options.interpolationkey]) || {};
4967
+ var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
4968
+ formatted = this.formats[formatName](mem, l, _objectSpread2(_objectSpread2(_objectSpread2({}, formatOptions), options), valOptions));
4969
+ } catch (error) {
4970
+ this.logger.warn(error);
4971
+ }
4972
+ return formatted;
4973
+ } else {
4974
+ this.logger.warn("there was no format function for ".concat(formatName));
4975
+ }
4976
+ return mem;
4977
+ }, value);
4978
+ return result;
4979
+ }
4980
+ }
4981
+ var removePending = (q, name) => {
4982
+ if (q.pending[name] !== undefined) {
4983
+ delete q.pending[name];
4984
+ q.pendingCount--;
4985
+ }
4986
+ };
4987
+ class Connector extends EventEmitter {
4988
+ constructor(backend, store, services) {
4989
+ var _this$backend, _this$backend$init;
4990
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4991
+ super();
4992
+ this.backend = backend;
4993
+ this.store = store;
4994
+ this.services = services;
4995
+ this.languageUtils = services.languageUtils;
4996
+ this.options = options;
4997
+ this.logger = baseLogger.create('backendConnector');
4998
+ this.waitingReads = [];
4999
+ this.maxParallelReads = options.maxParallelReads || 10;
5000
+ this.readingCalls = 0;
5001
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
5002
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
5003
+ this.state = {};
5004
+ this.queue = [];
5005
+ (_this$backend = this.backend) === null || _this$backend === void 0 || (_this$backend$init = _this$backend.init) === null || _this$backend$init === void 0 || _this$backend$init.call(_this$backend, services, options.backend, options);
5006
+ }
5007
+ queueLoad(languages, namespaces, options, callback) {
5008
+ var toLoad = {};
5009
+ var pending = {};
5010
+ var toLoadLanguages = {};
5011
+ var toLoadNamespaces = {};
5012
+ languages.forEach(lng => {
5013
+ var hasAllNamespaces = true;
5014
+ namespaces.forEach(ns => {
5015
+ var name = "".concat(lng, "|").concat(ns);
5016
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
5017
+ this.state[name] = 2;
5018
+ } else if (this.state[name] < 0) ;else if (this.state[name] === 1) {
5019
+ if (pending[name] === undefined) pending[name] = true;
5020
+ } else {
5021
+ this.state[name] = 1;
5022
+ hasAllNamespaces = false;
5023
+ if (pending[name] === undefined) pending[name] = true;
5024
+ if (toLoad[name] === undefined) toLoad[name] = true;
5025
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
5026
+ }
5027
+ });
5028
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
5029
+ });
5030
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
5031
+ this.queue.push({
5032
+ pending,
5033
+ pendingCount: Object.keys(pending).length,
5034
+ loaded: {},
5035
+ errors: [],
5036
+ callback
5037
+ });
5038
+ }
5039
+ return {
5040
+ toLoad: Object.keys(toLoad),
5041
+ pending: Object.keys(pending),
5042
+ toLoadLanguages: Object.keys(toLoadLanguages),
5043
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
5044
+ };
5045
+ }
5046
+ loaded(name, err, data) {
5047
+ var s = name.split('|');
5048
+ var lng = s[0];
5049
+ var ns = s[1];
5050
+ if (err) this.emit('failedLoading', lng, ns, err);
5051
+ if (!err && data) {
5052
+ this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
5053
+ skipCopy: true
5054
+ });
5055
+ }
5056
+ this.state[name] = err ? -1 : 2;
5057
+ if (err && data) this.state[name] = 0;
5058
+ var loaded = {};
5059
+ this.queue.forEach(q => {
5060
+ pushPath(q.loaded, [lng], ns);
5061
+ removePending(q, name);
5062
+ if (err) q.errors.push(err);
5063
+ if (q.pendingCount === 0 && !q.done) {
5064
+ Object.keys(q.loaded).forEach(l => {
5065
+ if (!loaded[l]) loaded[l] = {};
5066
+ var loadedKeys = q.loaded[l];
5067
+ if (loadedKeys.length) {
5068
+ loadedKeys.forEach(n => {
5069
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
5070
+ });
5071
+ }
5072
+ });
5073
+ q.done = true;
5074
+ if (q.errors.length) {
5075
+ q.callback(q.errors);
5076
+ } else {
5077
+ q.callback();
5078
+ }
5079
+ }
5080
+ });
5081
+ this.emit('loaded', loaded);
5082
+ this.queue = this.queue.filter(q => !q.done);
5083
+ }
5084
+ read(lng, ns, fcName) {
5085
+ var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
5086
+ var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
5087
+ var callback = arguments.length > 5 ? arguments[5] : undefined;
5088
+ if (!lng.length) return callback(null, {});
5089
+ if (this.readingCalls >= this.maxParallelReads) {
5090
+ this.waitingReads.push({
5091
+ lng,
5092
+ ns,
5093
+ fcName,
5094
+ tried,
5095
+ wait,
5096
+ callback
5097
+ });
5098
+ return;
5099
+ }
5100
+ this.readingCalls++;
5101
+ var resolver = (err, data) => {
5102
+ this.readingCalls--;
5103
+ if (this.waitingReads.length > 0) {
5104
+ var next = this.waitingReads.shift();
5105
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
5106
+ }
5107
+ if (err && data && tried < this.maxRetries) {
5108
+ setTimeout(() => {
5109
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
5110
+ }, wait);
5111
+ return;
5112
+ }
5113
+ callback(err, data);
5114
+ };
5115
+ var fc = this.backend[fcName].bind(this.backend);
5116
+ if (fc.length === 2) {
5117
+ try {
5118
+ var r = fc(lng, ns);
5119
+ if (r && typeof r.then === 'function') {
5120
+ r.then(data => resolver(null, data)).catch(resolver);
5121
+ } else {
5122
+ resolver(null, r);
5123
+ }
5124
+ } catch (err) {
5125
+ resolver(err);
5126
+ }
5127
+ return;
5128
+ }
5129
+ return fc(lng, ns, resolver);
5130
+ }
5131
+ prepareLoading(languages, namespaces) {
5132
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5133
+ var callback = arguments.length > 3 ? arguments[3] : undefined;
5134
+ if (!this.backend) {
5135
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
5136
+ return callback && callback();
5137
+ }
5138
+ if (isString$1(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
5139
+ if (isString$1(namespaces)) namespaces = [namespaces];
5140
+ var toLoad = this.queueLoad(languages, namespaces, options, callback);
5141
+ if (!toLoad.toLoad.length) {
5142
+ if (!toLoad.pending.length) callback();
5143
+ return null;
5144
+ }
5145
+ toLoad.toLoad.forEach(name => {
5146
+ this.loadOne(name);
5147
+ });
5148
+ }
5149
+ load(languages, namespaces, callback) {
5150
+ this.prepareLoading(languages, namespaces, {}, callback);
5151
+ }
5152
+ reload(languages, namespaces, callback) {
5153
+ this.prepareLoading(languages, namespaces, {
5154
+ reload: true
5155
+ }, callback);
5156
+ }
5157
+ loadOne(name) {
5158
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5159
+ var s = name.split('|');
5160
+ var lng = s[0];
5161
+ var ns = s[1];
5162
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
5163
+ if (err) this.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
5164
+ if (!err && data) this.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
5165
+ this.loaded(name, err, data);
5166
+ });
5167
+ }
5168
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
5169
+ var _this$services, _this$services2, _this$backend2;
5170
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
5171
+ var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
5172
+ if ((_this$services = this.services) !== null && _this$services !== void 0 && (_this$services = _this$services.utils) !== null && _this$services !== void 0 && _this$services.hasLoadedNamespace && !((_this$services2 = this.services) !== null && _this$services2 !== void 0 && (_this$services2 = _this$services2.utils) !== null && _this$services2 !== void 0 && _this$services2.hasLoadedNamespace(namespace))) {
5173
+ this.logger.warn("did not save key \"".concat(key, "\" as the namespace \"").concat(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!!!');
5174
+ return;
5175
+ }
5176
+ if (key === undefined || key === null || key === '') return;
5177
+ if ((_this$backend2 = this.backend) !== null && _this$backend2 !== void 0 && _this$backend2.create) {
5178
+ var opts = _objectSpread2(_objectSpread2({}, options), {}, {
5179
+ isUpdate
5180
+ });
5181
+ var fc = this.backend.create.bind(this.backend);
5182
+ if (fc.length < 6) {
5183
+ try {
5184
+ var r;
5185
+ if (fc.length === 5) {
5186
+ r = fc(languages, namespace, key, fallbackValue, opts);
5187
+ } else {
5188
+ r = fc(languages, namespace, key, fallbackValue);
5189
+ }
5190
+ if (r && typeof r.then === 'function') {
5191
+ r.then(data => clb(null, data)).catch(clb);
5192
+ } else {
5193
+ clb(null, r);
5194
+ }
5195
+ } catch (err) {
5196
+ clb(err);
5197
+ }
5198
+ } else {
5199
+ fc(languages, namespace, key, fallbackValue, clb, opts);
5200
+ }
5201
+ }
5202
+ if (!languages || !languages[0]) return;
5203
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
5204
+ }
5205
+ }
5206
+ var get = () => ({
5207
+ debug: false,
5208
+ initAsync: true,
5209
+ ns: ['translation'],
5210
+ defaultNS: ['translation'],
5211
+ fallbackLng: ['dev'],
5212
+ fallbackNS: false,
5213
+ supportedLngs: false,
5214
+ nonExplicitSupportedLngs: false,
5215
+ load: 'all',
5216
+ preload: false,
5217
+ simplifyPluralSuffix: true,
5218
+ keySeparator: '.',
5219
+ nsSeparator: ':',
5220
+ pluralSeparator: '_',
5221
+ contextSeparator: '_',
5222
+ partialBundledLanguages: false,
5223
+ saveMissing: false,
5224
+ updateMissing: false,
5225
+ saveMissingTo: 'fallback',
5226
+ saveMissingPlurals: true,
5227
+ missingKeyHandler: false,
5228
+ missingInterpolationHandler: false,
5229
+ postProcess: false,
5230
+ postProcessPassResolved: false,
5231
+ returnNull: false,
5232
+ returnEmptyString: true,
5233
+ returnObjects: false,
5234
+ joinArrays: false,
5235
+ returnedObjectHandler: false,
5236
+ parseMissingKeyHandler: false,
5237
+ appendNamespaceToMissingKey: false,
5238
+ appendNamespaceToCIMode: false,
5239
+ overloadTranslationOptionHandler: args => {
5240
+ var ret = {};
5241
+ if (typeof args[1] === 'object') ret = args[1];
5242
+ if (isString$1(args[1])) ret.defaultValue = args[1];
5243
+ if (isString$1(args[2])) ret.tDescription = args[2];
5244
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
5245
+ var options = args[3] || args[2];
5246
+ Object.keys(options).forEach(key => {
5247
+ ret[key] = options[key];
5248
+ });
5249
+ }
5250
+ return ret;
5251
+ },
5252
+ interpolation: {
5253
+ escapeValue: true,
5254
+ format: value => value,
5255
+ prefix: '{{',
5256
+ suffix: '}}',
5257
+ formatSeparator: ',',
5258
+ unescapePrefix: '-',
5259
+ nestingPrefix: '$t(',
5260
+ nestingSuffix: ')',
5261
+ nestingOptionsSeparator: ',',
5262
+ maxReplaces: 1000,
5263
+ skipOnVariables: true
5264
+ },
5265
+ cacheInBuiltFormats: true
5266
+ });
5267
+ var transformOptions = options => {
5268
+ var _options$supportedLng, _options$supportedLng2;
5269
+ if (isString$1(options.ns)) options.ns = [options.ns];
5270
+ if (isString$1(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
5271
+ if (isString$1(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
5272
+ if (((_options$supportedLng = options.supportedLngs) === null || _options$supportedLng === void 0 || (_options$supportedLng2 = _options$supportedLng.indexOf) === null || _options$supportedLng2 === void 0 ? void 0 : _options$supportedLng2.call(_options$supportedLng, 'cimode')) < 0) {
5273
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
5274
+ }
5275
+ if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
5276
+ return options;
5277
+ };
5278
+ var noop$1 = () => {};
5279
+ var bindMemberFunctions = inst => {
5280
+ var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
5281
+ mems.forEach(mem => {
5282
+ if (typeof inst[mem] === 'function') {
5283
+ inst[mem] = inst[mem].bind(inst);
5284
+ }
5285
+ });
5286
+ };
5287
+ class I18n extends EventEmitter {
5288
+ constructor() {
5289
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5290
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
5291
+ super();
5292
+ this.options = transformOptions(options);
5293
+ this.services = {};
5294
+ this.logger = baseLogger;
5295
+ this.modules = {
5296
+ external: []
5297
+ };
5298
+ bindMemberFunctions(this);
5299
+ if (callback && !this.isInitialized && !options.isClone) {
5300
+ if (!this.options.initAsync) {
5301
+ this.init(options, callback);
5302
+ return this;
5303
+ }
5304
+ setTimeout(() => {
5305
+ this.init(options, callback);
5306
+ }, 0);
5307
+ }
5308
+ }
5309
+ init() {
5310
+ var _this2 = this;
5311
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5312
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
5313
+ this.isInitializing = true;
5314
+ if (typeof options === 'function') {
5315
+ callback = options;
5316
+ options = {};
5317
+ }
5318
+ if (options.defaultNS == null && options.ns) {
5319
+ if (isString$1(options.ns)) {
5320
+ options.defaultNS = options.ns;
5321
+ } else if (options.ns.indexOf('translation') < 0) {
5322
+ options.defaultNS = options.ns[0];
5323
+ }
5324
+ }
5325
+ var defOpts = get();
5326
+ this.options = _objectSpread2(_objectSpread2(_objectSpread2({}, defOpts), this.options), transformOptions(options));
5327
+ this.options.interpolation = _objectSpread2(_objectSpread2({}, defOpts.interpolation), this.options.interpolation);
5328
+ if (options.keySeparator !== undefined) {
5329
+ this.options.userDefinedKeySeparator = options.keySeparator;
5330
+ }
5331
+ if (options.nsSeparator !== undefined) {
5332
+ this.options.userDefinedNsSeparator = options.nsSeparator;
5333
+ }
5334
+ var createClassOnDemand = ClassOrObject => {
5335
+ if (!ClassOrObject) return null;
5336
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
5337
+ return ClassOrObject;
5338
+ };
5339
+ if (!this.options.isClone) {
5340
+ if (this.modules.logger) {
5341
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
5342
+ } else {
5343
+ baseLogger.init(null, this.options);
5344
+ }
5345
+ var formatter;
5346
+ if (this.modules.formatter) {
5347
+ formatter = this.modules.formatter;
5348
+ } else {
5349
+ formatter = Formatter;
5350
+ }
5351
+ var lu = new LanguageUtil(this.options);
5352
+ this.store = new ResourceStore(this.options.resources, this.options);
5353
+ var s = this.services;
5354
+ s.logger = baseLogger;
5355
+ s.resourceStore = this.store;
5356
+ s.languageUtils = lu;
5357
+ s.pluralResolver = new PluralResolver(lu, {
5358
+ prepend: this.options.pluralSeparator,
5359
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
5360
+ });
5361
+ var usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
5362
+ if (usingLegacyFormatFunction) {
5363
+ this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting");
5364
+ }
5365
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
5366
+ s.formatter = createClassOnDemand(formatter);
5367
+ if (s.formatter.init) s.formatter.init(s, this.options);
5368
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
5369
+ }
5370
+ s.interpolator = new Interpolator(this.options);
5371
+ s.utils = {
5372
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
5373
+ };
5374
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
5375
+ s.backendConnector.on('*', function (event) {
5376
+ for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
5377
+ args[_key7 - 1] = arguments[_key7];
5378
+ }
5379
+ _this2.emit(event, ...args);
5380
+ });
5381
+ if (this.modules.languageDetector) {
5382
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
5383
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
5384
+ }
5385
+ if (this.modules.i18nFormat) {
5386
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
5387
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
5388
+ }
5389
+ this.translator = new Translator(this.services, this.options);
5390
+ this.translator.on('*', function (event) {
5391
+ for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
5392
+ args[_key8 - 1] = arguments[_key8];
5393
+ }
5394
+ _this2.emit(event, ...args);
5395
+ });
5396
+ this.modules.external.forEach(m => {
5397
+ if (m.init) m.init(this);
5398
+ });
5399
+ }
5400
+ this.format = this.options.interpolation.format;
5401
+ if (!callback) callback = noop$1;
5402
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
5403
+ var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
5404
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
5405
+ }
5406
+ if (!this.services.languageDetector && !this.options.lng) {
5407
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
5408
+ }
5409
+ var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
5410
+ storeApi.forEach(fcName => {
5411
+ this[fcName] = function () {
5412
+ return _this2.store[fcName](...arguments);
5413
+ };
5414
+ });
5415
+ var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
5416
+ storeApiChained.forEach(fcName => {
5417
+ this[fcName] = function () {
5418
+ _this2.store[fcName](...arguments);
5419
+ return _this2;
5420
+ };
5421
+ });
5422
+ var deferred = defer();
5423
+ var load = () => {
5424
+ var finish = (err, t) => {
5425
+ this.isInitializing = false;
5426
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
5427
+ this.isInitialized = true;
5428
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
5429
+ this.emit('initialized', this.options);
5430
+ deferred.resolve(t);
5431
+ callback(err, t);
5432
+ };
5433
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
5434
+ this.changeLanguage(this.options.lng, finish);
5435
+ };
5436
+ if (this.options.resources || !this.options.initAsync) {
5437
+ load();
5438
+ } else {
5439
+ setTimeout(load, 0);
5440
+ }
5441
+ return deferred;
5442
+ }
5443
+ loadResources(language) {
5444
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
5445
+ var usedCallback = callback;
5446
+ var usedLng = isString$1(language) ? language : this.language;
5447
+ if (typeof language === 'function') usedCallback = language;
5448
+ if (!this.options.resources || this.options.partialBundledLanguages) {
5449
+ var _this$options$preload, _this$options$preload2;
5450
+ if ((usedLng === null || usedLng === void 0 ? void 0 : usedLng.toLowerCase()) === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
5451
+ var toLoad = [];
5452
+ var append = lng => {
5453
+ if (!lng) return;
5454
+ if (lng === 'cimode') return;
5455
+ var lngs = this.services.languageUtils.toResolveHierarchy(lng);
5456
+ lngs.forEach(l => {
5457
+ if (l === 'cimode') return;
5458
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
5459
+ });
5460
+ };
5461
+ if (!usedLng) {
5462
+ var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
5463
+ fallbacks.forEach(l => append(l));
5464
+ } else {
5465
+ append(usedLng);
5466
+ }
5467
+ (_this$options$preload = this.options.preload) === null || _this$options$preload === void 0 || (_this$options$preload2 = _this$options$preload.forEach) === null || _this$options$preload2 === void 0 || _this$options$preload2.call(_this$options$preload, l => append(l));
5468
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
5469
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
5470
+ usedCallback(e);
5471
+ });
5472
+ } else {
5473
+ usedCallback(null);
5474
+ }
5475
+ }
5476
+ reloadResources(lngs, ns, callback) {
5477
+ var deferred = defer();
5478
+ if (typeof lngs === 'function') {
5479
+ callback = lngs;
5480
+ lngs = undefined;
5481
+ }
5482
+ if (typeof ns === 'function') {
5483
+ callback = ns;
5484
+ ns = undefined;
5485
+ }
5486
+ if (!lngs) lngs = this.languages;
5487
+ if (!ns) ns = this.options.ns;
5488
+ if (!callback) callback = noop$1;
5489
+ this.services.backendConnector.reload(lngs, ns, err => {
5490
+ deferred.resolve();
5491
+ callback(err);
5492
+ });
5493
+ return deferred;
5494
+ }
5495
+ use(module) {
5496
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
5497
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
5498
+ if (module.type === 'backend') {
5499
+ this.modules.backend = module;
5500
+ }
5501
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
5502
+ this.modules.logger = module;
5503
+ }
5504
+ if (module.type === 'languageDetector') {
5505
+ this.modules.languageDetector = module;
5506
+ }
5507
+ if (module.type === 'i18nFormat') {
5508
+ this.modules.i18nFormat = module;
5509
+ }
5510
+ if (module.type === 'postProcessor') {
5511
+ postProcessor.addPostProcessor(module);
5512
+ }
5513
+ if (module.type === 'formatter') {
5514
+ this.modules.formatter = module;
5515
+ }
5516
+ if (module.type === '3rdParty') {
5517
+ this.modules.external.push(module);
5518
+ }
5519
+ return this;
5520
+ }
5521
+ setResolvedLanguage(l) {
5522
+ if (!l || !this.languages) return;
5523
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
5524
+ for (var li = 0; li < this.languages.length; li++) {
5525
+ var lngInLngs = this.languages[li];
5526
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
5527
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
5528
+ this.resolvedLanguage = lngInLngs;
5529
+ break;
5530
+ }
5531
+ }
5532
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
5533
+ this.resolvedLanguage = l;
5534
+ this.languages.unshift(l);
5535
+ }
5536
+ }
5537
+ changeLanguage(lng, callback) {
5538
+ var _this3 = this;
5539
+ this.isLanguageChangingTo = lng;
5540
+ var deferred = defer();
5541
+ this.emit('languageChanging', lng);
5542
+ var setLngProps = l => {
5543
+ this.language = l;
5544
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
5545
+ this.resolvedLanguage = undefined;
5546
+ this.setResolvedLanguage(l);
5547
+ };
5548
+ var done = (err, l) => {
5549
+ if (l) {
5550
+ if (this.isLanguageChangingTo === lng) {
5551
+ setLngProps(l);
5552
+ this.translator.changeLanguage(l);
5553
+ this.isLanguageChangingTo = undefined;
5554
+ this.emit('languageChanged', l);
5555
+ this.logger.log('languageChanged', l);
5556
+ }
5557
+ } else {
5558
+ this.isLanguageChangingTo = undefined;
5559
+ }
5560
+ deferred.resolve(function () {
5561
+ return _this3.t(...arguments);
5562
+ });
5563
+ if (callback) callback(err, function () {
5564
+ return _this3.t(...arguments);
5565
+ });
5566
+ };
5567
+ var setLng = lngs => {
5568
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
5569
+ var fl = isString$1(lngs) ? lngs : lngs && lngs[0];
5570
+ var l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString$1(lngs) ? [lngs] : lngs);
5571
+ if (l) {
5572
+ var _this$services$langua, _this$services$langua2;
5573
+ if (!this.language) {
5574
+ setLngProps(l);
5575
+ }
5576
+ if (!this.translator.language) this.translator.changeLanguage(l);
5577
+ (_this$services$langua = this.services.languageDetector) === null || _this$services$langua === void 0 || (_this$services$langua2 = _this$services$langua.cacheUserLanguage) === null || _this$services$langua2 === void 0 || _this$services$langua2.call(_this$services$langua, l);
5578
+ }
5579
+ this.loadResources(l, err => {
5580
+ done(err, l);
5581
+ });
5582
+ };
5583
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
5584
+ setLng(this.services.languageDetector.detect());
5585
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
5586
+ if (this.services.languageDetector.detect.length === 0) {
5587
+ this.services.languageDetector.detect().then(setLng);
5588
+ } else {
5589
+ this.services.languageDetector.detect(setLng);
5590
+ }
5591
+ } else {
5592
+ setLng(lng);
5593
+ }
5594
+ return deferred;
5595
+ }
5596
+ getFixedT(lng, ns, keyPrefix) {
5597
+ var _this4 = this;
5598
+ var _fixedT = function fixedT(key, opts) {
5599
+ var o;
5600
+ if (typeof opts !== 'object') {
5601
+ for (var _len9 = arguments.length, rest = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
5602
+ rest[_key9 - 2] = arguments[_key9];
5603
+ }
5604
+ o = _this4.options.overloadTranslationOptionHandler([key, opts].concat(rest));
5605
+ } else {
5606
+ o = _objectSpread2({}, opts);
5607
+ }
5608
+ o.lng = o.lng || _fixedT.lng;
5609
+ o.lngs = o.lngs || _fixedT.lngs;
5610
+ o.ns = o.ns || _fixedT.ns;
5611
+ if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || _fixedT.keyPrefix;
5612
+ var keySeparator = _this4.options.keySeparator || '.';
5613
+ var resultKey;
5614
+ if (o.keyPrefix && Array.isArray(key)) {
5615
+ resultKey = key.map(k => {
5616
+ if (typeof k === 'function') k = keysFromSelector(k, _objectSpread2(_objectSpread2({}, _this4.options), opts));
5617
+ return "".concat(o.keyPrefix).concat(keySeparator).concat(k);
5618
+ });
5619
+ } else {
5620
+ if (typeof key === 'function') key = keysFromSelector(key, _objectSpread2(_objectSpread2({}, _this4.options), opts));
5621
+ resultKey = o.keyPrefix ? "".concat(o.keyPrefix).concat(keySeparator).concat(key) : key;
5622
+ }
5623
+ return _this4.t(resultKey, o);
5624
+ };
5625
+ if (isString$1(lng)) {
5626
+ _fixedT.lng = lng;
5627
+ } else {
5628
+ _fixedT.lngs = lng;
5629
+ }
5630
+ _fixedT.ns = ns;
5631
+ _fixedT.keyPrefix = keyPrefix;
5632
+ return _fixedT;
5633
+ }
5634
+ t() {
5635
+ var _this$translator;
5636
+ for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
5637
+ args[_key0] = arguments[_key0];
5638
+ }
5639
+ return (_this$translator = this.translator) === null || _this$translator === void 0 ? void 0 : _this$translator.translate(...args);
5640
+ }
5641
+ exists() {
5642
+ var _this$translator2;
5643
+ for (var _len1 = arguments.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
5644
+ args[_key1] = arguments[_key1];
5645
+ }
5646
+ return (_this$translator2 = this.translator) === null || _this$translator2 === void 0 ? void 0 : _this$translator2.exists(...args);
5647
+ }
5648
+ setDefaultNamespace(ns) {
5649
+ this.options.defaultNS = ns;
5650
+ }
5651
+ hasLoadedNamespace(ns) {
5652
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5653
+ if (!this.isInitialized) {
5654
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
5655
+ return false;
5656
+ }
5657
+ if (!this.languages || !this.languages.length) {
5658
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
5659
+ return false;
5660
+ }
5661
+ var lng = options.lng || this.resolvedLanguage || this.languages[0];
5662
+ var fallbackLng = this.options ? this.options.fallbackLng : false;
5663
+ var lastLng = this.languages[this.languages.length - 1];
5664
+ if (lng.toLowerCase() === 'cimode') return true;
5665
+ var loadNotPending = (l, n) => {
5666
+ var loadState = this.services.backendConnector.state["".concat(l, "|").concat(n)];
5667
+ return loadState === -1 || loadState === 0 || loadState === 2;
5668
+ };
5669
+ if (options.precheck) {
5670
+ var preResult = options.precheck(this, loadNotPending);
5671
+ if (preResult !== undefined) return preResult;
5672
+ }
5673
+ if (this.hasResourceBundle(lng, ns)) return true;
5674
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
5675
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
5676
+ return false;
5677
+ }
5678
+ loadNamespaces(ns, callback) {
5679
+ var deferred = defer();
5680
+ if (!this.options.ns) {
5681
+ if (callback) callback();
5682
+ return Promise.resolve();
5683
+ }
5684
+ if (isString$1(ns)) ns = [ns];
5685
+ ns.forEach(n => {
5686
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
5687
+ });
5688
+ this.loadResources(err => {
5689
+ deferred.resolve();
5690
+ if (callback) callback(err);
5691
+ });
5692
+ return deferred;
5693
+ }
5694
+ loadLanguages(lngs, callback) {
5695
+ var deferred = defer();
5696
+ if (isString$1(lngs)) lngs = [lngs];
5697
+ var preloaded = this.options.preload || [];
5698
+ var newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
5699
+ if (!newLngs.length) {
5700
+ if (callback) callback();
5701
+ return Promise.resolve();
5702
+ }
5703
+ this.options.preload = preloaded.concat(newLngs);
5704
+ this.loadResources(err => {
5705
+ deferred.resolve();
5706
+ if (callback) callback(err);
5707
+ });
5708
+ return deferred;
5709
+ }
5710
+ dir(lng) {
5711
+ var _this$languages, _this$services3;
5712
+ if (!lng) lng = this.resolvedLanguage || (((_this$languages = this.languages) === null || _this$languages === void 0 ? void 0 : _this$languages.length) > 0 ? this.languages[0] : this.language);
5713
+ if (!lng) return 'rtl';
5714
+ try {
5715
+ var l = new Intl.Locale(lng);
5716
+ if (l && l.getTextInfo) {
5717
+ var ti = l.getTextInfo();
5718
+ if (ti && ti.direction) return ti.direction;
5719
+ }
5720
+ } catch (e) {}
5721
+ var 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'];
5722
+ var languageUtils = ((_this$services3 = this.services) === null || _this$services3 === void 0 ? void 0 : _this$services3.languageUtils) || new LanguageUtil(get());
5723
+ if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
5724
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
5725
+ }
5726
+ static createInstance() {
5727
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5728
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
5729
+ return new I18n(options, callback);
5730
+ }
5731
+ cloneInstance() {
5732
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5733
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
5734
+ var forkResourceStore = options.forkResourceStore;
5735
+ if (forkResourceStore) delete options.forkResourceStore;
5736
+ var mergedOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), options), {
5737
+ isClone: true
5738
+ });
5739
+ var clone = new I18n(mergedOptions);
5740
+ if (options.debug !== undefined || options.prefix !== undefined) {
5741
+ clone.logger = clone.logger.clone(options);
5742
+ }
5743
+ var membersToCopy = ['store', 'services', 'language'];
5744
+ membersToCopy.forEach(m => {
5745
+ clone[m] = this[m];
5746
+ });
5747
+ clone.services = _objectSpread2({}, this.services);
5748
+ clone.services.utils = {
5749
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
5750
+ };
5751
+ if (forkResourceStore) {
5752
+ var clonedData = Object.keys(this.store.data).reduce((prev, l) => {
5753
+ prev[l] = _objectSpread2({}, this.store.data[l]);
5754
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
5755
+ acc[n] = _objectSpread2({}, prev[l][n]);
5756
+ return acc;
5757
+ }, prev[l]);
5758
+ return prev;
5759
+ }, {});
5760
+ clone.store = new ResourceStore(clonedData, mergedOptions);
5761
+ clone.services.resourceStore = clone.store;
5762
+ }
5763
+ clone.translator = new Translator(clone.services, mergedOptions);
5764
+ clone.translator.on('*', function (event) {
5765
+ for (var _len10 = arguments.length, args = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
5766
+ args[_key10 - 1] = arguments[_key10];
5767
+ }
5768
+ clone.emit(event, ...args);
5769
+ });
5770
+ clone.init(mergedOptions, callback);
5771
+ clone.translator.options = mergedOptions;
5772
+ clone.translator.backendConnector.services.utils = {
5773
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
5774
+ };
5775
+ return clone;
5776
+ }
5777
+ toJSON() {
5778
+ return {
5779
+ options: this.options,
5780
+ store: this.store,
5781
+ language: this.language,
5782
+ languages: this.languages,
5783
+ resolvedLanguage: this.resolvedLanguage
5784
+ };
5785
+ }
5786
+ }
5787
+ var instance = I18n.createInstance();
5788
+ instance.createInstance = I18n.createInstance;
5789
+ instance.createInstance;
5790
+ instance.dir;
5791
+ instance.init;
5792
+ instance.loadResources;
5793
+ instance.reloadResources;
5794
+ instance.use;
5795
+ instance.changeLanguage;
5796
+ instance.getFixedT;
5797
+ instance.t;
5798
+ instance.exists;
5799
+ instance.setDefaultNamespace;
5800
+ instance.hasLoadedNamespace;
5801
+ instance.loadNamespaces;
5802
+ instance.loadLanguages;
5803
+
3593
5804
  var homeSdk$1 = {
3594
5805
  chatTitle: "Chat with",
3595
5806
  tryBabylAi: "Try Babyl AI for Free 🎉",
@@ -3663,8 +5874,8 @@ var ar = {
3663
5874
  var defaultLanguage = "ar";
3664
5875
  var createHelpCenterI18n = function createHelpCenterI18n() {
3665
5876
  var lng = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultLanguage;
3666
- var instance = i18next.createInstance();
3667
- instance.init({
5877
+ var instance$1 = instance.createInstance();
5878
+ instance$1.init({
3668
5879
  resources: {
3669
5880
  en: {
3670
5881
  translation: en
@@ -3679,7 +5890,7 @@ var createHelpCenterI18n = function createHelpCenterI18n() {
3679
5890
  escapeValue: false
3680
5891
  }
3681
5892
  });
3682
- return instance;
5893
+ return instance$1;
3683
5894
  };
3684
5895
 
3685
5896
  var useLocalTranslation = () => {
@@ -3770,7 +5981,7 @@ var ReviewDialog = props => {
3770
5981
  return jsxs("section", {
3771
5982
  className: "babylai-p-6 babylai-gap-6 babylai-max-w-sm babylai-max-h-[calc(100vh-90px)] babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 dark:babylai-bg-storm-dust-950 babylai-fixed babylai-bottom-20 babylai-right-0 md:babylai-right-4 babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col",
3772
5983
  children: [jsxs("header", {
3773
- className: 'border-b pb-4 babylai-flex babylai-items-center babylai-justify-between babylai-gap-4',
5984
+ className: 'babylai-border-b babylai-pb-4 babylai-flex babylai-items-center babylai-justify-between babylai-gap-4',
3774
5985
  children: [jsx("h2", {
3775
5986
  className: "babylai-text-lg babylai-font-semibold dark:babylai-text-white",
3776
5987
  children: t('homeSdk.ReviewDialog.title')
@@ -3781,7 +5992,7 @@ var ReviewDialog = props => {
3781
5992
  }), jsxs("div", {
3782
5993
  className: "babylai-flex babylai-flex-col babylai-gap-2",
3783
5994
  children: [jsx("p", {
3784
- className: "babylai-text-sm babylai-text-gray-600 mb-3 dark:babylai-text-white",
5995
+ className: "babylai-text-sm babylai-text-gray-600 babylai-mb-3 dark:babylai-text-white",
3785
5996
  children: t('homeSdk.ReviewDialog.description')
3786
5997
  }), jsxs("div", {
3787
5998
  className: "babylai-flex babylai-items-center babylai-gap-2",
@@ -3792,7 +6003,7 @@ var ReviewDialog = props => {
3792
6003
  value: rating,
3793
6004
  onChange: handleRatingChange
3794
6005
  }), jsx("span", {
3795
- className: "babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ".concat(error.rating ? 'opacity-100' : 'opacity-0'),
6006
+ className: "babylai-text-sm babylai-text-red-500 babylai-transition-opacity babylai-duration-300 ".concat(error.rating ? 'babylai-opacity-100' : 'babylai-opacity-0'),
3796
6007
  children: error.rating
3797
6008
  })]
3798
6009
  }), jsxs("div", {
@@ -3809,18 +6020,18 @@ var ReviewDialog = props => {
3809
6020
  value: comment,
3810
6021
  onChange: e => handleCommentChange(e.target.value)
3811
6022
  }), jsx("span", {
3812
- className: "babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ".concat(error.comment ? 'opacity-100' : 'opacity-0'),
6023
+ className: "babylai-text-sm babylai-text-red-500 babylai-transition-opacity babylai-duration-300 ".concat(error.comment ? 'babylai-opacity-100' : 'babylai-opacity-0'),
3813
6024
  children: error.comment
3814
6025
  })]
3815
6026
  })]
3816
6027
  }), jsxs("footer", {
3817
6028
  className: "babylai-flex babylai-justify-between babylai-gap-4 babylai-border-t babylai-pt-4",
3818
6029
  children: [jsx("button", {
3819
- className: "babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-bg-gray-200 babylai-text-gray-700 hover:babylai-bg-gray-300 transition-all",
6030
+ className: "babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-bg-gray-200 babylai-text-gray-700 hover:babylai-bg-gray-300 babylai-transition-all",
3820
6031
  onClick: props.onClose,
3821
6032
  children: t('homeSdk.ReviewDialog.skip_button')
3822
6033
  }), jsx("button", {
3823
- className: 'babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-shadow transition-all babylai-bg-primary-500 babylai-text-white hover:babylai-bg-primary-600',
6034
+ className: 'babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-shadow babylai-transition-all babylai-bg-primary-500 babylai-text-white hover:babylai-bg-primary-600',
3824
6035
  onClick: validateAndSubmit,
3825
6036
  children: t('homeSdk.ReviewDialog.submit_button')
3826
6037
  })]
@@ -13758,7 +15969,7 @@ function FloatingMessage(_ref) {
13758
15969
  className: "babylai-text-xs babylai-font-bold babylai-m-0",
13759
15970
  children: message
13760
15971
  }), jsx("button", {
13761
- className: "babylai-absolute babylai--top-2 babylai--right-2 babylai-w-5 babylai-h-5 babylai-rounded-full babylai-bg-white babylai-border-none babylai-cursor-pointer babylai-flex babylai-items-center babylai-justify-center babylai-text-black-white-700 babylai-p-[3px] babylai-hover:bg-primary-400 babylai-hover:text-white shadow-md",
15972
+ className: "babylai-absolute babylai--top-2 babylai--right-2 babylai-w-5 babylai-h-5 babylai-rounded-full babylai-bg-white babylai-border-none babylai-cursor-pointer babylai-flex babylai-items-center babylai-justify-center babylai-text-black-white-700 babylai-p-[3px] hover:babylai-bg-primary-400 babylai-hover:text-white babylai-shadow-md",
13762
15973
  onClick: onClose,
13763
15974
  children: jsx(CloseIcon, {
13764
15975
  className: "babylai-w-8 babylai-h-8"
@@ -31688,11 +33899,11 @@ var buttonVariants = cva('babylai-inline-flex babylai-items-center babylai-justi
31688
33899
  variants: {
31689
33900
  variant: {
31690
33901
  default: 'babylai-bg-primary-500 babylai-p-2 babylai-text-white babylai-text-xs babylai-font-semibold hover:babylai-bg-primary-600',
31691
- destructive: 'babylai-bg-destructive babylai-p-2 babylai-text-destructive-foreground babylai-shadow-sm babylai-hover:babylai-bg-destructive/90',
33902
+ destructive: 'babylai-bg-destructive babylai-p-2 babylai-text-destructive-foreground babylai-shadow-sm hover:babylai-bg-destructive/90',
31692
33903
  outline: 'babylai-border babylai-border-primary-500 babylai-bg-background-transparent hover:babylai-border-primary-600 hover:babylai-text-primary-600 babylai-text-primary-500 babylai-font-bold',
31693
33904
  secondary: 'babylai-bg-secondary babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm babylai-hover:babylai-bg-secondary/80',
31694
- ghost: 'babylai-bg-transparent babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm babylai-hover:babylai-bg-secondary/80',
31695
- link: 'babylai-text-primary babylai-underline-offset-4 babylai-hover:babylai-underline',
33905
+ ghost: 'babylai-bg-transparent babylai-p-2 babylai-text-secondary-foreground babylai-shadow-sm hover:babylai-bg-secondary/80',
33906
+ link: 'babylai-text-primary babylai-underline-offset-4 hover:babylai-underline',
31696
33907
  'rounded-icon': '!babylai-p-2'
31697
33908
  },
31698
33909
  size: {
@@ -31739,9 +33950,9 @@ var Card$2 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
31739
33950
  } = _ref,
31740
33951
  props = _objectWithoutProperties(_ref, _excluded$9);
31741
33952
  var variantStyles = {
31742
- default: 'rounded-xl border bg-card text-card-foreground shadow',
31743
- rounded: 'rounded-3xl bg-black-white-50 py-4 px-3',
31744
- shadowed: 'rounded-xl border bg-card text-card-foreground shadow-lg'
33953
+ default: 'babylai-rounded-xl babylai-border babylai-bg-card babylai-text-card-foreground babylai-shadow',
33954
+ rounded: 'babylai-rounded-3xl babylai-bg-black-white-50 babylai-py-4 babylai-px-3',
33955
+ shadowed: 'babylai-rounded-xl babylai-border babylai-bg-card babylai-text-card-foreground babylai-shadow-lg'
31745
33956
  };
31746
33957
  return jsx("div", _objectSpread2({
31747
33958
  ref: ref,
@@ -31756,7 +33967,7 @@ var CardHeader = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
31756
33967
  props = _objectWithoutProperties(_ref2, _excluded2);
31757
33968
  return jsx("div", _objectSpread2({
31758
33969
  ref: ref,
31759
- className: cn('flex flex-col space-y-1.5 p-6', className)
33970
+ className: cn('babylai-flex babylai-flex-col babylai-space-y-1.5 babylai-p-6', className)
31760
33971
  }, props));
31761
33972
  });
31762
33973
  CardHeader.displayName = 'CardHeader';
@@ -31767,7 +33978,7 @@ var CardTitle = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
31767
33978
  props = _objectWithoutProperties(_ref3, _excluded3);
31768
33979
  return jsx("div", _objectSpread2({
31769
33980
  ref: ref,
31770
- className: cn('font-semibold leading-none tracking-tight', className)
33981
+ className: cn('babylai-font-semibold babylai-leading-none babylai-tracking-tight', className)
31771
33982
  }, props));
31772
33983
  });
31773
33984
  CardTitle.displayName = 'CardTitle';
@@ -31778,7 +33989,7 @@ var CardDescription = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
31778
33989
  props = _objectWithoutProperties(_ref4, _excluded4);
31779
33990
  return jsx("div", _objectSpread2({
31780
33991
  ref: ref,
31781
- className: cn('text-sm text-muted-foreground', className)
33992
+ className: cn('babylai-text-sm babylai-text-muted-foreground', className)
31782
33993
  }, props));
31783
33994
  });
31784
33995
  CardDescription.displayName = 'CardDescription';
@@ -31789,7 +34000,7 @@ var CardContent = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
31789
34000
  props = _objectWithoutProperties(_ref5, _excluded5);
31790
34001
  return jsx("div", _objectSpread2({
31791
34002
  ref: ref,
31792
- className: cn('p-6 pt-0', className)
34003
+ className: cn('babylai-p-6 babylai-pt-0', className)
31793
34004
  }, props));
31794
34005
  });
31795
34006
  CardContent.displayName = 'CardContent';
@@ -31800,7 +34011,7 @@ var CardFooter = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
31800
34011
  props = _objectWithoutProperties(_ref6, _excluded6);
31801
34012
  return jsx("div", _objectSpread2({
31802
34013
  ref: ref,
31803
- className: cn('flex items-center p-6 pt-0', className)
34014
+ className: cn('babylai-flex babylai-items-center babylai-p-6 babylai-pt-0', className)
31804
34015
  }, props));
31805
34016
  });
31806
34017
  CardFooter.displayName = 'CardFooter';
@@ -31850,7 +34061,7 @@ var ChatWindowFooter = props => {
31850
34061
  size: 'icon',
31851
34062
  onClick: props.handleSendMessage,
31852
34063
  disabled: props === null || props === void 0 ? void 0 : props.isLoading,
31853
- className: 'babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8 babylai-disabled:babylai-opacity-50',
34064
+ className: 'babylai-rounded-full babylai-bg-purple-500 babylai-hover:babylai-bg-purple-600 babylai-w-8 babylai-h-8 disabled:babylai-opacity-50',
31854
34065
  children: jsx(EnvelopeIcon, {
31855
34066
  className: "babylai-w-4 babylai-h-4 ".concat(dir === 'rtl' ? 'babylai-rotate-270' : '')
31856
34067
  })
@@ -31930,7 +34141,7 @@ var MessageComponent = /*#__PURE__*/React__default.memo(_ref => {
31930
34141
  } = _ref;
31931
34142
  var isFirstInSequence = index === 0 || messages[index - 1].senderType !== message.senderType;
31932
34143
  var isFirstHumanAgentMessage = index === firstHumanAgentIndex && message.senderType === 2;
31933
- var textDirection = message.senderType === 1 ? 'justify-end' : 'justify-start';
34144
+ var textDirection = message.senderType === 1 ? 'babylai-justify-end' : 'babylai-justify-start';
31934
34145
  return jsxs("div", {
31935
34146
  children: [isFirstHumanAgentMessage && jsx("div", {
31936
34147
  className: 'babylai-flex babylai-justify-center babylai-items-center babylai-my-4',
@@ -32186,28 +34397,28 @@ var ChatWindowHeader = props => {
32186
34397
  t,
32187
34398
  dir
32188
34399
  } = useLocalTranslation();
32189
- var isRTL = dir === "rtl";
34400
+ var isRTL = String(dir) === "rtl";
32190
34401
  return jsxs("header", {
32191
34402
  className: "babylai-flex babylai-w-full babylai-items-center babylai-py-[18px] babylai-px-[18px] babylai-justify-between babylai-relative babylai-bg-black-white-50 dark:!babylai-bg-storm-dust-900 babylai-rounded-t-3xl",
32192
34403
  children: [jsxs("div", {
32193
34404
  className: "babylai-flex babylai-items-center babylai-gap-2",
32194
- children: [jsxs(Button, {
34405
+ children: [jsx(Button, {
32195
34406
  variant: "rounded-icon",
32196
34407
  size: "icon",
32197
34408
  className: "babylai-bg-primary-500/10 dark:babylai-bg-storm-dust-950",
32198
34409
  onClick: props.handleBack,
32199
- children: [jsx(ArrowRight, {
32200
- className: "!babylai-w-[12px] babylai-h-[12px] ".concat(isRTL ? "" : "babylai-rotate-180", " babylai-text-primary-500 dark:babylai-text-white")
32201
- }), " "]
34410
+ children: jsx(ArrowRight, {
34411
+ className: "babylai-w-3 babylai-h-3 ".concat(isRTL ? "" : "babylai-rotate-180", " babylai-text-primary-500 dark:babylai-text-white")
34412
+ })
32202
34413
  }), jsxs("div", {
32203
- className: "babylai-relative babylai-mr-2",
34414
+ className: "babylai-relative",
32204
34415
  children: [jsx(Button, {
32205
34416
  variant: "rounded-icon",
32206
34417
  size: "icon",
32207
34418
  className: "babylai-bg-primary-500/10 dark:babylai-bg-storm-dust-950",
32208
34419
  onClick: () => setShowMenu(!showMenu),
32209
34420
  children: jsx(ThreeDots, {
32210
- className: "babylai-w-[14px] babylai-h-[4px] babylai-text-primary-500 dark:babylai-text-white"
34421
+ className: "babylai-w-3.5 babylai-h-1 babylai-text-primary-500 dark:babylai-text-white"
32211
34422
  })
32212
34423
  }), showMenu && jsx("div", {
32213
34424
  className: "babylai-absolute babylai-top-10 babylai-start-0 babylai-w-48 babylai-rounded-md babylai-shadow-lg babylai-bg-white dark:!babylai-bg-storm-dust-950 babylai-ring-1 babylai-ring-black-white-700 babylai-ring-opacity-5 babylai-z-10",
@@ -32216,7 +34427,7 @@ var ChatWindowHeader = props => {
32216
34427
  role: "menu",
32217
34428
  "aria-orientation": "vertical",
32218
34429
  children: jsx("button", {
32219
- className: "babylai-block babylai-px-4 babylai-py-2 babylai-text-sm babylai-text-gray-700 dark:babylai-text-white babylai-hover:babylai-bg-gray-100 babylai-w-full babylai-text-left",
34430
+ className: "babylai-block babylai-px-4 babylai-py-2 babylai-text-sm babylai-text-gray-700 dark:babylai-text-white hover:babylai-bg-gray-100 babylai-w-full babylai-text-start",
32220
34431
  role: "menuitem",
32221
34432
  onClick: e => {
32222
34433
  e.stopPropagation();
@@ -32228,11 +34439,8 @@ var ChatWindowHeader = props => {
32228
34439
  })
32229
34440
  })]
32230
34441
  })]
32231
- }), jsx("div", {
32232
- className: "babylai-flex babylai-items-center babylai-gap-2 babylai-absolute babylai-left-1/2 babylai-transform babylai--translate-x-1/2",
32233
- children: jsx(Logo, {
32234
- className: "babylai-w-[124px] babylai-h-auto dark:babylai-text-white"
32235
- })
34442
+ }), jsx(Logo, {
34443
+ className: "babylai-w-[124px] babylai-h-auto dark:babylai-text-white"
32236
34444
  })]
32237
34445
  });
32238
34446
  };
@@ -32257,7 +34465,7 @@ var ChatBotErrorScreen = props => {
32257
34465
  return jsx("div", {
32258
34466
  className: "babylai-w-full babylai-h-full babylai-bg-black-white-50 babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col",
32259
34467
  children: jsxs("div", {
32260
- className: "h-full babylai-rounded-3xl babylai-flex babylai-flex-col babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60 babylai-py-6 md:babylai-py-8 babylai-px-6 gap-4 md:gap-8",
34468
+ className: "babylai-h-full babylai-rounded-3xl babylai-flex babylai-flex-col babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60 babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8",
32261
34469
  children: [jsx(Header, {
32262
34470
  onClose: props.onClose
32263
34471
  }), jsx("div", {
@@ -32278,7 +34486,7 @@ var Card = props => {
32278
34486
  } = useLocalTranslation();
32279
34487
  var isLTR = dir === "ltr";
32280
34488
  return jsxs("div", {
32281
- className: "babylai-flex babylai-items-center babylai-justify-between babylai-gap-4 babylai-bg-black-white-50 babylai-rounded-3xl babylai-p-6",
34489
+ className: "babylai-flex babylai-items-center babylai-justify-between babylai-gap-4 babylai-bg-black-white-50 babylai-rounded-3xl babylai-p-6",
32282
34490
  children: [jsx("p", {
32283
34491
  className: "babylai-text-base md:babylai-text-lg babylai-font-medium babylai-text-black-white-800",
32284
34492
  children: props.text
@@ -32340,14 +34548,14 @@ var HomeScreen = props => {
32340
34548
  window.location.href = url.toString();
32341
34549
  };
32342
34550
  return jsxs("div", {
32343
- className: "babylai-h-full babylai-flex babylai-flex-col babylai-overflow-y-auto babylai-py-6 md:babylai-py-8 babylai-px-6 gap-4 md:gap-8",
34551
+ className: "babylai-h-full babylai-flex babylai-flex-col babylai-overflow-y-auto babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8",
32344
34552
  children: [jsx(Header, {
32345
34553
  onClose: props.onClose
32346
34554
  }), jsxs("h1", {
32347
34555
  className: "babylai-text-2xl md:babylai-text-4xl babylai-font-bold babylai-text-white",
32348
34556
  children: [t('homeSdk.chatTitle'), jsx("br", {}), "BabylAI \uD83D\uDE80"]
32349
34557
  }), jsxs("div", {
32350
- className: "babylai-flex babylai-flex-col gap-3",
34558
+ className: "babylai-flex babylai-flex-col babylai-gap-3",
32351
34559
  children: [jsx(ChatNowCard$1, {
32352
34560
  setIsShowList: props.setIsShowList
32353
34561
  }), jsx(Card$1, {
@@ -32366,7 +34574,7 @@ var ChatBotLoadingScreen = props => {
32366
34574
  return jsx("div", {
32367
34575
  className: "babylai-w-full babylai-h-full babylai-bg-black-white-50 dark:babylai-bg-storm-dust-950 babylai-rounded-3xl babylai-shadow-lg babylai-flex babylai-flex-col",
32368
34576
  children: jsxs("div", {
32369
- className: cn('babylai-rounded-3xl babylai-h-full babylai-flex babylai-flex-col babylai-py-6 md:babylai-py-8 babylai-px-6 gap-4 md:gap-8', {
34577
+ className: cn('babylai-rounded-3xl babylai-h-full babylai-flex babylai-flex-col babylai-py-6 md:babylai-py-8 babylai-px-6 babylai-gap-4 md:babylai-gap-8', {
32370
34578
  'babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60': !props.isShowList,
32371
34579
  'babylai-bg-black-white-100 dark:babylai-bg-storm-dust-950': props.isShowList
32372
34580
  }),
@@ -32475,17 +34683,16 @@ var OptionsListHeader = _ref => {
32475
34683
  var {
32476
34684
  dir
32477
34685
  } = useLocalTranslation();
32478
- var isRTL = dir === "rtl";
34686
+ var isRTL = String(dir) === "rtl";
32479
34687
  return jsxs("header", {
32480
- dir: dir,
32481
- className: "babylai-flex babylai-w-full babylai-items-center mb-2 ".concat(!showHelpScreen ? "babylai-justify-end" : "babylai-justify-between"),
34688
+ className: "babylai-flex babylai-w-full babylai-items-center babylai-mb-2 ".concat(!showHelpScreen ? "babylai-justify-end" : "babylai-justify-between"),
32482
34689
  children: [jsx(Button, {
32483
34690
  variant: "rounded-icon",
32484
34691
  size: "icon",
32485
34692
  className: "!babylai-w-12 !babylai-h-12 babylai-bg-black-white-50 dark:babylai-bg-storm-dust-900 babylai-relative babylai-z-10",
32486
34693
  onClick: handleBack,
32487
34694
  children: showHelpScreen ? jsx(ArrowRight, {
32488
- className: "".concat(isRTL ? "" : "babylai-rotate-180", " babylai-text-primary-500 babylai-w-full babylai-h-full")
34695
+ className: "".concat(!isRTL ? "" : "babylai-rotate-180", " babylai-text-primary-500 babylai-w-full babylai-h-full")
32489
34696
  }) : jsx(CloseCircle, {
32490
34697
  className: "!babylai-w-full !babylai-h-full babylai-cursor-pointer"
32491
34698
  })
@@ -32497,8 +34704,10 @@ var OptionsListHeader = _ref => {
32497
34704
  var OptionsListHeader$1 = OptionsListHeader;
32498
34705
 
32499
34706
  var OptionCard = props => {
32500
- var i18n = useLocalTranslation();
32501
- var isLTR = i18n.dir == "ltr";
34707
+ var {
34708
+ dir
34709
+ } = useLocalTranslation();
34710
+ var isRTL = String(dir) === "rtl";
32502
34711
  return jsxs("div", {
32503
34712
  className: "babylai-flex babylai-items-center babylai-justify-between babylai-p-2",
32504
34713
  children: [jsx("p", {
@@ -32509,7 +34718,7 @@ var OptionCard = props => {
32509
34718
  size: "icon",
32510
34719
  className: "babylai-text-primary-500 hover:babylai-bg-primary-100",
32511
34720
  children: jsx(ArrowRight, {
32512
- className: "babylai-w-[12px] babylai-h-[12px] ".concat(isLTR ? "" : "babylai-rotate-180", " babylai-text-primary-500")
34721
+ className: "babylai-w-3 babylai-h-3 ".concat(!isRTL ? "" : "babylai-rotate-180", " babylai-text-primary-500 dark:babylai-text-white")
32513
34722
  })
32514
34723
  })]
32515
34724
  });
@@ -32534,18 +34743,18 @@ var OptionsListScreen = _ref => {
32534
34743
  }
32535
34744
  };
32536
34745
  return jsxs("div", {
32537
- className: 'babylai-px-8 babylai-pb-12 babylai-pt-8 babylai-overflow-y-auto babylai-h-full',
34746
+ className: 'babylai-px-8 babylai-pb-12 babylai-pt-8 babylai-overflow-y-auto babylai-h-full',
32538
34747
  children: [jsx(OptionsListHeader$1, {
32539
34748
  handleBack: handleBack,
32540
34749
  showHelpScreen: showHelpScreen
32541
34750
  }), jsx("h1", {
32542
- className: 'babylai-text-4xl babylai-font-bold mb-4 babylai-text-black-white-800 dark:babylai-text-white',
34751
+ className: 'babylai-text-4xl babylai-font-bold babylai-mb-4 babylai-text-black-white-800 dark:babylai-text-white',
32543
34752
  children: helpScreen === null || helpScreen === void 0 ? void 0 : helpScreen.title
32544
34753
  }), helpScreen && jsx("div", {
32545
34754
  className: 'babylai-flex babylai-flex-col babylai-gap-3 babylai-mt-3 babylai-mb-3',
32546
34755
  children: (_a = helpScreen === null || helpScreen === void 0 ? void 0 : helpScreen.options) === null || _a === void 0 ? void 0 : _a.map(option => jsxs(Card$2, {
32547
34756
  variant: 'rounded',
32548
- className: 'babylai-cursor-pointer babylai-transition-all babylai-hover:babylai-shadow-md !babylai-px-2 !babylai-py-1 dark:!babylai-bg-storm-dust-900',
34757
+ className: 'babylai-cursor-pointer babylai-transition-all hover:babylai-shadow-md !babylai-px-2 !babylai-py-1 dark:!babylai-bg-storm-dust-900',
32549
34758
  onClick: () => handleToggleExpandOption(option),
32550
34759
  children: [jsx(OptionCard$1, {
32551
34760
  title: option.title
@@ -32813,7 +35022,7 @@ function HelpPopup(_ref) {
32813
35022
  // Early returns for performance - moved after all hooks
32814
35023
  if (status === 'loading' && !helpScreen) {
32815
35024
  return jsx("div", {
32816
- className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-min-w-sm md:babylai-h-[calc(100vh-240px) babylai-max-h-[800px]]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
35025
+ className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
32817
35026
  children: jsx(ChatBotLoadingScreen$1, {
32818
35027
  isShowList: isShowList,
32819
35028
  onClose: onClose
@@ -32822,7 +35031,7 @@ function HelpPopup(_ref) {
32822
35031
  }
32823
35032
  if (error) {
32824
35033
  return jsx("div", {
32825
- className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-min-w-sm md:babylai-h-[calc(100vh-240px) babylai-max-h-[800px]]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
35034
+ className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
32826
35035
  children: jsx(ChatBotErrorScreen$1, {
32827
35036
  onClose: onClose,
32828
35037
  error: error || ''
@@ -32830,7 +35039,7 @@ function HelpPopup(_ref) {
32830
35039
  });
32831
35040
  }
32832
35041
  return jsx("div", {
32833
- className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-min-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
35042
+ className: 'babylai-fixed babylai-inset-0 md:babylai-inset-auto md:babylai-max-w-sm md:babylai-h-[calc(100vh-240px)] babylai-max-h-[800px]\n babylai-overflow-auto babylai-w-full babylai-bg-black-white-50 md:babylai-mb-4\nmd:babylai-bottom-[6rem] md:babylai-right-4 babylai-rounded-none md:babylai-rounded-3xl babylai-shadow-lg babylai-z-50 babylai-flex babylai-flex-col',
32834
35043
  children: jsxs("div", {
32835
35044
  className: cn('babylai-h-full babylai-rounded-none md:babylai-rounded-3xl babylai-flex babylai-flex-col babylai-relative', {
32836
35045
  'babylai-bg-gradient-to-b babylai-from-primary-500 babylai-to-primary-500/60': !isShowList,