@itwin/core-i18n 5.15.0-dev.15 → 5.15.0-dev.16

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.
@@ -2032,7 +2032,7 @@ cov_1wctd2lw3r().s[3]++;
2032
2032
  exports.ITwinLocalization = void 0;
2033
2033
  const i18next_1 = (cov_1wctd2lw3r().s[4]++, __importDefault(__webpack_require__(/*! i18next */ "../../common/temp/node_modules/.pnpm/i18next@21.10.0/node_modules/i18next/dist/cjs/i18next.js")));
2034
2034
  const i18next_browser_languagedetector_1 = (cov_1wctd2lw3r().s[5]++, __importDefault(__webpack_require__(/*! i18next-browser-languagedetector */ "../../common/temp/node_modules/.pnpm/i18next-browser-languagedetector@6.1.8/node_modules/i18next-browser-languagedetector/dist/cjs/i18nextBrowserLanguageDetector.js")));
2035
- const i18next_http_backend_1 = (cov_1wctd2lw3r().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js")));
2035
+ const i18next_http_backend_1 = (cov_1wctd2lw3r().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.5/node_modules/i18next-http-backend/esm/index.js")));
2036
2036
  const core_bentley_1 = (cov_1wctd2lw3r().s[7]++, __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js"));
2037
2037
  const DEFAULT_MAX_RETRIES = (cov_1wctd2lw3r().s[8]++, 1); // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
2038
2038
  /** Supplies localizations for iTwin.js
@@ -25012,534 +25012,377 @@ module.exports = _unsupportedIterableToArray, module.exports.__esModule = true,
25012
25012
 
25013
25013
  /***/ },
25014
25014
 
25015
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js"
25015
+ /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.5/node_modules/i18next-http-backend/esm/index.js"
25016
25016
  /*!**********************************************************************************************************************!*\
25017
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js ***!
25017
+ !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.5/node_modules/i18next-http-backend/esm/index.js ***!
25018
25018
  \**********************************************************************************************************************/
25019
25019
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25020
25020
 
25021
25021
  "use strict";
25022
25022
  __webpack_require__.r(__webpack_exports__);
25023
25023
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25024
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
25024
+ /* harmony export */ "default": () => (/* binding */ Backend)
25025
25025
  /* harmony export */ });
25026
- /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js");
25027
- /* harmony import */ var _request_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./request.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js");
25028
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
25029
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25030
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25031
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
25032
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
25033
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25034
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25035
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25036
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25037
- ;
25038
-
25039
- var getDefaults = function getDefaults() {
25040
- return {
25041
- loadPath: '/locales/{{lng}}/{{ns}}.json',
25042
- addPath: '/locales/add/{{lng}}/{{ns}}',
25043
- parse: function parse(data) {
25044
- return JSON.parse(data);
25045
- },
25046
- stringify: JSON.stringify,
25047
- parsePayload: function parsePayload(namespace, key, fallbackValue) {
25048
- return _defineProperty({}, key, fallbackValue || '');
25049
- },
25050
- parseLoadPayload: function parseLoadPayload(languages, namespaces) {
25051
- return undefined;
25052
- },
25053
- request: _request_js__WEBPACK_IMPORTED_MODULE_1__["default"],
25054
- reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
25055
- customHeaders: {},
25056
- queryStringParams: {},
25057
- crossDomain: false,
25058
- withCredentials: false,
25059
- overrideMimeType: false,
25060
- requestOptions: {
25061
- mode: 'cors',
25062
- credentials: 'same-origin',
25063
- cache: 'default'
25064
- }
25065
- };
25066
- };
25067
- var Backend = function () {
25068
- function Backend(services) {
25069
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25070
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25071
- _classCallCheck(this, Backend);
25072
- this.services = services;
25073
- this.options = options;
25074
- this.allOptions = allOptions;
25075
- this.type = 'backend';
25076
- this.init(services, options, allOptions);
25077
- }
25078
- return _createClass(Backend, [{
25079
- key: "init",
25080
- value: function init(services) {
25081
- var _this = this;
25082
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25083
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25084
- this.services = services;
25085
- this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
25086
- this.allOptions = allOptions;
25087
- if (this.services && this.options.reloadInterval) {
25088
- var timer = setInterval(function () {
25089
- return _this.reload();
25090
- }, this.options.reloadInterval);
25091
- if (_typeof(timer) === 'object' && typeof timer.unref === 'function') timer.unref();
25092
- }
25093
- }
25094
- }, {
25095
- key: "readMulti",
25096
- value: function readMulti(languages, namespaces, callback) {
25097
- this._readAny(languages, languages, namespaces, namespaces, callback);
25098
- }
25099
- }, {
25100
- key: "read",
25101
- value: function read(language, namespace, callback) {
25102
- this._readAny([language], language, [namespace], namespace, callback);
25103
- }
25104
- }, {
25105
- key: "_readAny",
25106
- value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
25107
- var _this2 = this;
25108
- var loadPath = this.options.loadPath;
25109
- if (typeof this.options.loadPath === 'function') {
25110
- loadPath = this.options.loadPath(languages, namespaces);
25111
- }
25112
- loadPath = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.makePromise)(loadPath);
25113
- loadPath.then(function (resolvedLoadPath) {
25114
- if (!resolvedLoadPath) return callback(null, {});
25115
- var url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.interpolateUrl)(resolvedLoadPath, {
25116
- lng: languages.join('+'),
25117
- ns: namespaces.join('+')
25118
- });
25119
- if (url == null) {
25120
- var safeLngs = languages.map(_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue).join(', ');
25121
- var safeNss = namespaces.map(_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue).join(', ');
25122
- return callback(new Error('i18next-http-backend: unsafe lng/ns value — refusing to build request URL for languages=[' + safeLngs + '] namespaces=[' + safeNss + ']'), false);
25123
- }
25124
- _this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
25125
- });
25126
- }
25127
- }, {
25128
- key: "loadUrl",
25129
- value: function loadUrl(url, callback, languages, namespaces) {
25130
- var _this3 = this;
25131
- var lng = typeof languages === 'string' ? [languages] : languages;
25132
- var ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
25133
- var payload = this.options.parseLoadPayload(lng, ns);
25134
- var safeUrl = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.redactUrlCredentials)(url));
25135
- this.options.request(this.options, url, payload, function (err, res) {
25136
- if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + safeUrl + '; status code: ' + res.status, true);
25137
- if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + safeUrl + '; status code: ' + res.status, false);
25138
- if (!res && err && err.message) {
25139
- var errorMessage = err.message.toLowerCase();
25140
- var isNetworkError = ['failed', 'fetch', 'network', 'load'].find(function (term) {
25141
- return errorMessage.indexOf(term) > -1;
25142
- });
25143
- if (isNetworkError) {
25144
- return callback('failed loading ' + safeUrl + ': ' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue)(err.message), true);
25145
- }
25146
- }
25147
- if (err) return callback(err, false);
25148
- var ret, parseErr;
25149
- try {
25150
- if (typeof res.data === 'string') {
25151
- ret = _this3.options.parse(res.data, languages, namespaces);
25152
- } else {
25153
- ret = res.data;
25154
- }
25155
- } catch (e) {
25156
- parseErr = 'failed parsing ' + safeUrl + ' to json';
25157
- }
25158
- if (parseErr) return callback(parseErr, false);
25159
- callback(null, ret);
25160
- });
25161
- }
25162
- }, {
25163
- key: "create",
25164
- value: function create(languages, namespace, key, fallbackValue, callback) {
25165
- var _this4 = this;
25166
- if (!this.options.addPath) return;
25167
- if (typeof languages === 'string') languages = [languages];
25168
- var payload = this.options.parsePayload(namespace, key, fallbackValue);
25169
- var finished = 0;
25170
- var dataArray = [];
25171
- var resArray = [];
25172
- languages.forEach(function (lng) {
25173
- var addPath = _this4.options.addPath;
25174
- if (typeof _this4.options.addPath === 'function') {
25175
- addPath = _this4.options.addPath(lng, namespace);
25176
- }
25177
- var url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.interpolateUrl)(addPath, {
25178
- lng: lng,
25179
- ns: namespace
25180
- });
25181
- if (url == null) {
25182
- finished += 1;
25183
- if (callback && finished === languages.length) callback(dataArray, resArray);
25184
- return;
25185
- }
25186
- _this4.options.request(_this4.options, url, payload, function (data, res) {
25187
- finished += 1;
25188
- dataArray.push(data);
25189
- resArray.push(res);
25190
- if (finished === languages.length) {
25191
- if (typeof callback === 'function') callback(dataArray, resArray);
25192
- }
25193
- });
25194
- });
25195
- }
25196
- }, {
25197
- key: "reload",
25198
- value: function reload() {
25199
- var _this5 = this;
25200
- var _this$services = this.services,
25201
- backendConnector = _this$services.backendConnector,
25202
- languageUtils = _this$services.languageUtils,
25203
- logger = _this$services.logger;
25204
- var currentLanguage = backendConnector.language;
25205
- if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return;
25206
- var toLoad = [];
25207
- var append = function append(lng) {
25208
- var lngs = languageUtils.toResolveHierarchy(lng);
25209
- lngs.forEach(function (l) {
25210
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
25211
- });
25212
- };
25213
- append(currentLanguage);
25214
- if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
25215
- return append(l);
25216
- });
25217
- toLoad.forEach(function (lng) {
25218
- _this5.allOptions.ns.forEach(function (ns) {
25219
- backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
25220
- if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
25221
- if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
25222
- backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
25223
- });
25224
- });
25225
- });
25226
- }
25227
- }]);
25228
- }();
25229
- Backend.type = 'backend';
25230
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Backend);
25231
-
25232
- /***/ },
25233
-
25234
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js"
25235
- /*!************************************************************************************************************************!*\
25236
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js ***!
25237
- \************************************************************************************************************************/
25238
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25239
-
25240
- "use strict";
25241
- __webpack_require__.r(__webpack_exports__);
25242
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25243
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
25244
- /* harmony export */ });
25245
- /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js");
25246
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25247
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25248
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25249
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25250
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25251
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
25252
- ;
25253
- var fetchApi = typeof fetch === 'function' ? fetch : undefined;
25254
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.fetch) {
25255
- fetchApi = __webpack_require__.g.fetch;
25256
- } else if (typeof window !== 'undefined' && window.fetch) {
25257
- fetchApi = window.fetch;
25258
- }
25259
- var XmlHttpRequestApi;
25260
- if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hasXMLHttpRequest)()) {
25261
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.XMLHttpRequest) {
25262
- XmlHttpRequestApi = __webpack_require__.g.XMLHttpRequest;
25263
- } else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
25264
- XmlHttpRequestApi = window.XMLHttpRequest;
25265
- }
25266
- }
25267
- var ActiveXObjectApi;
25268
- if (typeof ActiveXObject === 'function') {
25269
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.ActiveXObject) {
25270
- ActiveXObjectApi = __webpack_require__.g.ActiveXObject;
25271
- } else if (typeof window !== 'undefined' && window.ActiveXObject) {
25272
- ActiveXObjectApi = window.ActiveXObject;
25273
- }
25274
- }
25275
- if (typeof fetchApi !== 'function') fetchApi = undefined;
25276
- if (!fetchApi && !XmlHttpRequestApi && !ActiveXObjectApi) {
25277
- try {
25278
- __webpack_require__.e(/*! import() */ "vendors-common_temp_node_modules_pnpm_cross-fetch_4_1_0_node_modules_cross-fetch_dist_browser-44272f").then(() => (__webpack_require__.t(/*! cross-fetch */ "../../common/temp/node_modules/.pnpm/cross-fetch@4.1.0/node_modules/cross-fetch/dist/browser-ponyfill.js", 19))).then(function (mod) {
25279
- fetchApi = mod.default;
25280
- }).catch(function () {});
25281
- } catch (e) {}
25282
- }
25283
- var UNSAFE_KEYS = ['__proto__', 'constructor', 'prototype'];
25284
- var addQueryString = function addQueryString(url, params) {
25285
- if (params && _typeof(params) === 'object') {
25286
- var queryString = '';
25287
- for (var _i = 0, _Object$keys = Object.keys(params); _i < _Object$keys.length; _i++) {
25288
- var paramName = _Object$keys[_i];
25289
- if (UNSAFE_KEYS.indexOf(paramName) > -1) continue;
25290
- queryString += '&' + encodeURIComponent(paramName) + '=' + encodeURIComponent(params[paramName]);
25291
- }
25292
- if (!queryString) return url;
25293
- url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
25294
- }
25295
- return url;
25296
- };
25297
- var fetchIt = function fetchIt(url, fetchOptions, callback, altFetch) {
25298
- var resolver = function resolver(response) {
25299
- if (!response.ok) return callback(response.statusText || 'Error', {
25300
- status: response.status
25301
- });
25302
- response.text().then(function (data) {
25303
- callback(null, {
25304
- status: response.status,
25305
- data: data
25306
- });
25307
- }).catch(callback);
25308
- };
25309
- if (altFetch) {
25310
- var altResponse = altFetch(url, fetchOptions);
25311
- if (altResponse instanceof Promise) {
25312
- altResponse.then(resolver).catch(callback);
25313
- return;
25314
- }
25315
- }
25316
- if (typeof fetch === 'function') {
25317
- fetch(url, fetchOptions).then(resolver).catch(callback);
25318
- } else {
25319
- fetchApi(url, fetchOptions).then(resolver).catch(callback);
25320
- }
25321
- };
25322
- var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
25323
- if (options.queryStringParams) {
25324
- url = addQueryString(url, options.queryStringParams);
25325
- }
25326
- var headers = _objectSpread({}, typeof options.customHeaders === 'function' ? options.customHeaders() : options.customHeaders);
25327
- if (typeof window === 'undefined' && typeof __webpack_require__.g !== 'undefined' && typeof __webpack_require__.g.process !== 'undefined' && __webpack_require__.g.process.versions && __webpack_require__.g.process.versions.node) {
25328
- headers['User-Agent'] = "i18next-http-backend (node/".concat(__webpack_require__.g.process.version, "; ").concat(__webpack_require__.g.process.platform, " ").concat(__webpack_require__.g.process.arch, ")");
25329
- }
25330
- if (payload) headers['Content-Type'] = 'application/json';
25331
- var reqOptions = typeof options.requestOptions === 'function' ? options.requestOptions(payload) : options.requestOptions;
25332
- var fetchOptions = _objectSpread({
25333
- method: payload ? 'POST' : 'GET',
25334
- body: payload ? options.stringify(payload) : undefined,
25335
- headers: headers
25336
- }, options._omitFetchOptions ? {} : reqOptions);
25337
- var altFetch = typeof options.alternateFetch === 'function' && options.alternateFetch.length >= 1 ? options.alternateFetch : undefined;
25338
- try {
25339
- fetchIt(url, fetchOptions, callback, altFetch);
25340
- } catch (e) {
25341
- if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf('not implemented') < 0) {
25342
- return callback(e);
25343
- }
25344
- try {
25345
- Object.keys(reqOptions).forEach(function (opt) {
25346
- delete fetchOptions[opt];
25347
- });
25348
- fetchIt(url, fetchOptions, callback, altFetch);
25349
- options._omitFetchOptions = true;
25350
- } catch (err) {
25351
- callback(err);
25352
- }
25353
- }
25354
- };
25355
- var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
25356
- if (payload && _typeof(payload) === 'object') {
25357
- payload = addQueryString('', payload).slice(1);
25358
- }
25359
- if (options.queryStringParams) {
25360
- url = addQueryString(url, options.queryStringParams);
25361
- }
25362
- try {
25363
- var x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi('MSXML2.XMLHTTP.3.0');
25364
- x.open(payload ? 'POST' : 'GET', url, 1);
25365
- if (!options.crossDomain) {
25366
- x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
25367
- }
25368
- x.withCredentials = !!options.withCredentials;
25369
- if (payload) {
25370
- x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
25371
- }
25372
- if (x.overrideMimeType) {
25373
- x.overrideMimeType('application/json');
25374
- }
25375
- var h = options.customHeaders;
25376
- h = typeof h === 'function' ? h() : h;
25377
- if (h) {
25378
- for (var _i2 = 0, _Object$keys2 = Object.keys(h); _i2 < _Object$keys2.length; _i2++) {
25379
- var i = _Object$keys2[_i2];
25380
- if (UNSAFE_KEYS.indexOf(i) > -1) continue;
25381
- x.setRequestHeader(i, h[i]);
25382
- }
25383
- }
25384
- x.onreadystatechange = function () {
25385
- x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
25386
- status: x.status,
25387
- data: x.responseText
25388
- });
25389
- };
25390
- x.send(payload);
25391
- } catch (e) {
25392
- console && console.log(e);
25393
- }
25394
- };
25395
- var request = function request(options, url, payload, callback) {
25396
- if (typeof payload === 'function') {
25397
- callback = payload;
25398
- payload = undefined;
25399
- }
25400
- callback = callback || function () {};
25401
- if (fetchApi && url.indexOf('file:') !== 0) {
25402
- return requestWithFetch(options, url, payload, callback);
25403
- }
25404
- if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hasXMLHttpRequest)() || typeof ActiveXObject === 'function') {
25405
- return requestWithXmlHttpRequest(options, url, payload, callback);
25406
- }
25407
- callback(new Error('No fetch and no xhr implementation found!'));
25408
- };
25409
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (request);
25410
-
25411
- /***/ },
25412
-
25413
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js"
25414
- /*!**********************************************************************************************************************!*\
25415
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js ***!
25416
- \**********************************************************************************************************************/
25417
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25418
-
25419
- "use strict";
25420
- __webpack_require__.r(__webpack_exports__);
25421
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25422
- /* harmony export */ defaults: () => (/* binding */ defaults),
25423
- /* harmony export */ hasXMLHttpRequest: () => (/* binding */ hasXMLHttpRequest),
25424
- /* harmony export */ interpolate: () => (/* binding */ interpolate),
25425
- /* harmony export */ interpolateUrl: () => (/* binding */ interpolateUrl),
25426
- /* harmony export */ isSafeLangUrlSegment: () => (/* binding */ isSafeLangUrlSegment),
25427
- /* harmony export */ isSafeNsUrlSegment: () => (/* binding */ isSafeNsUrlSegment),
25428
- /* harmony export */ isSafeUrlSegment: () => (/* binding */ isSafeUrlSegment),
25429
- /* harmony export */ makePromise: () => (/* binding */ makePromise),
25430
- /* harmony export */ redactUrlCredentials: () => (/* binding */ redactUrlCredentials),
25431
- /* harmony export */ sanitizeLogValue: () => (/* binding */ sanitizeLogValue)
25432
- /* harmony export */ });
25433
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
25434
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
25435
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
25436
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
25437
- var arr = [];
25438
- var each = arr.forEach;
25439
- var slice = arr.slice;
25440
- var UNSAFE_KEYS = ['__proto__', 'constructor', 'prototype'];
25441
- function defaults(obj) {
25442
- each.call(slice.call(arguments, 1), function (source) {
25443
- if (source) {
25444
- for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
25445
- var prop = _Object$keys[_i];
25446
- if (UNSAFE_KEYS.indexOf(prop) > -1) continue;
25447
- if (obj[prop] === undefined) obj[prop] = source[prop];
25448
- }
25449
- }
25450
- });
25451
- return obj;
25452
- }
25026
+ //#region lib/utils.js
25027
+ const arr = [];
25028
+ arr.forEach;
25029
+ arr.slice;
25030
+ const UNSAFE_KEYS$1 = [
25031
+ "__proto__",
25032
+ "constructor",
25033
+ "prototype"
25034
+ ];
25453
25035
  function isSafeUrlSegmentBase(v) {
25454
- if (typeof v !== 'string') return false;
25455
- if (v.length === 0 || v.length > 128) return false;
25456
- if (UNSAFE_KEYS.indexOf(v) > -1) return false;
25457
- if (v.indexOf('..') > -1) return false;
25458
- if (v.indexOf('\\') > -1) return false;
25459
- if (/[?#%\s@]/.test(v)) return false;
25460
- if (/[\x00-\x1F\x7F]/.test(v)) return false;
25461
- return true;
25036
+ if (typeof v !== "string") return false;
25037
+ if (v.length === 0 || v.length > 128) return false;
25038
+ if (UNSAFE_KEYS$1.indexOf(v) > -1) return false;
25039
+ if (v.indexOf("..") > -1) return false;
25040
+ if (v.indexOf("\\") > -1) return false;
25041
+ if (/[?#%:&=;\s]/.test(v)) return false;
25042
+ if (/[\x00-\x1F\x7F]/.test(v)) return false;
25043
+ return true;
25462
25044
  }
25463
25045
  function isSafeLangUrlSegment(v) {
25464
- if (!isSafeUrlSegmentBase(v)) return false;
25465
- if (v.indexOf('/') > -1) return false;
25466
- return true;
25046
+ if (!isSafeUrlSegmentBase(v)) return false;
25047
+ if (v.indexOf("/") > -1 || v.indexOf("@") > -1) return false;
25048
+ return true;
25467
25049
  }
25468
25050
  function isSafeNsUrlSegment(v) {
25469
- return isSafeUrlSegmentBase(v);
25051
+ if (!isSafeUrlSegmentBase(v)) return false;
25052
+ if (v.indexOf("//") > -1) return false;
25053
+ return true;
25470
25054
  }
25471
- var isSafeUrlSegment = isSafeLangUrlSegment;
25472
- var SAFETY_CHECK_BY_KEY = {
25473
- lng: isSafeLangUrlSegment,
25474
- ns: isSafeNsUrlSegment
25055
+ const SAFETY_CHECK_BY_KEY = {
25056
+ lng: isSafeLangUrlSegment,
25057
+ ns: isSafeNsUrlSegment
25475
25058
  };
25476
25059
  function sanitizeLogValue(v) {
25477
- if (typeof v !== 'string') return v;
25478
- return v.replace(/[\r\n\x00-\x1F\x7F]/g, ' ');
25060
+ if (typeof v !== "string") return v;
25061
+ return v.replace(/[\r\n\x00-\x1F\x7F]/g, " ");
25479
25062
  }
25480
25063
  function redactUrlCredentials(u) {
25481
- if (typeof u !== 'string' || u.length === 0) return u;
25482
- try {
25483
- var parsed = new URL(u);
25484
- if (parsed.username || parsed.password) {
25485
- parsed.username = '';
25486
- parsed.password = '';
25487
- return parsed.toString();
25488
- }
25489
- return u;
25490
- } catch (e) {
25491
- return u.replace(/(\/\/)[^/@\s]+@/g, '$1');
25492
- }
25064
+ if (typeof u !== "string" || u.length === 0) return u;
25065
+ try {
25066
+ const parsed = new URL(u);
25067
+ if (parsed.username || parsed.password) {
25068
+ parsed.username = "";
25069
+ parsed.password = "";
25070
+ return parsed.toString();
25071
+ }
25072
+ return u;
25073
+ } catch (e) {
25074
+ return u.replace(/(\/\/)[^/@\s]+@/g, "$1");
25075
+ }
25493
25076
  }
25494
25077
  function hasXMLHttpRequest() {
25495
- return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
25078
+ return typeof XMLHttpRequest === "function" || typeof XMLHttpRequest === "object";
25496
25079
  }
25080
+ /**
25081
+ * Determine whether the given `maybePromise` is a Promise.
25082
+ *
25083
+ * @param {*} maybePromise
25084
+ *
25085
+ * @returns {Boolean}
25086
+ */
25497
25087
  function isPromise(maybePromise) {
25498
- return !!maybePromise && typeof maybePromise.then === 'function';
25088
+ return !!maybePromise && typeof maybePromise.then === "function";
25499
25089
  }
25090
+ /**
25091
+ * Convert any value to a Promise than will resolve to this value.
25092
+ *
25093
+ * @param {*} maybePromise
25094
+ *
25095
+ * @returns {Promise}
25096
+ */
25500
25097
  function makePromise(maybePromise) {
25501
- if (isPromise(maybePromise)) {
25502
- return maybePromise;
25503
- }
25504
- return Promise.resolve(maybePromise);
25505
- }
25506
- var interpolationRegexp = /\{\{(.+?)\}\}/g;
25507
- function interpolate(str, data) {
25508
- return str.replace(interpolationRegexp, function (match, key) {
25509
- var k = key.trim();
25510
- if (UNSAFE_KEYS.indexOf(k) > -1) return match;
25511
- var value = data[k];
25512
- return value != null ? value : match;
25513
- });
25098
+ if (isPromise(maybePromise)) return maybePromise;
25099
+ return Promise.resolve(maybePromise);
25514
25100
  }
25101
+ const interpolationRegexp = /\{\{(.+?)\}\}/g;
25102
+ const LEADING_DOUBLE_SLASH = /^[/\\]{2}/;
25515
25103
  function interpolateUrl(str, data) {
25516
- var unsafe = false;
25517
- var result = str.replace(interpolationRegexp, function (match, key) {
25518
- var k = key.trim();
25519
- if (UNSAFE_KEYS.indexOf(k) > -1) return match;
25520
- var value = data[k];
25521
- if (value == null) return match;
25522
- var check = SAFETY_CHECK_BY_KEY[k] || isSafeLangUrlSegment;
25523
- var segments = String(value).split('+');
25524
- var _iterator = _createForOfIteratorHelper(segments),
25525
- _step;
25526
- try {
25527
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
25528
- var seg = _step.value;
25529
- if (!check(seg)) {
25530
- unsafe = true;
25531
- return match;
25532
- }
25533
- }
25534
- } catch (err) {
25535
- _iterator.e(err);
25536
- } finally {
25537
- _iterator.f();
25538
- }
25539
- return segments.join('+');
25540
- });
25541
- return unsafe ? null : result;
25104
+ let unsafe = false;
25105
+ const result = str.replace(interpolationRegexp, (match, key) => {
25106
+ const k = key.trim();
25107
+ if (UNSAFE_KEYS$1.indexOf(k) > -1) return match;
25108
+ const value = data[k];
25109
+ if (value == null) return match;
25110
+ const check = SAFETY_CHECK_BY_KEY[k] || isSafeLangUrlSegment;
25111
+ const segments = String(value).split("+");
25112
+ for (const seg of segments) if (!check(seg)) {
25113
+ unsafe = true;
25114
+ return match;
25115
+ }
25116
+ return segments.join("+");
25117
+ });
25118
+ if (unsafe) return null;
25119
+ if (LEADING_DOUBLE_SLASH.test(result) && !LEADING_DOUBLE_SLASH.test(str)) return null;
25120
+ return result;
25542
25121
  }
25122
+ //#endregion
25123
+ //#region lib/request.js
25124
+ const g = typeof globalThis !== "undefined" ? globalThis : typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : void 0;
25125
+ let fetchApi;
25126
+ if (typeof fetch === "function") fetchApi = fetch;
25127
+ else if (g && typeof g.fetch === "function") fetchApi = g.fetch;
25128
+ const XmlHttpRequestApi = hasXMLHttpRequest() && g ? g.XMLHttpRequest : void 0;
25129
+ const ActiveXObjectApi = typeof ActiveXObject === "function" && g ? g.ActiveXObject : void 0;
25130
+ const UNSAFE_KEYS = [
25131
+ "__proto__",
25132
+ "constructor",
25133
+ "prototype"
25134
+ ];
25135
+ const addQueryString = (url, params) => {
25136
+ if (params && typeof params === "object") {
25137
+ let queryString = "";
25138
+ for (const paramName of Object.keys(params)) {
25139
+ if (UNSAFE_KEYS.indexOf(paramName) > -1) continue;
25140
+ queryString += "&" + encodeURIComponent(paramName) + "=" + encodeURIComponent(params[paramName]);
25141
+ }
25142
+ if (!queryString) return url;
25143
+ url = url + (url.indexOf("?") !== -1 ? "&" : "?") + queryString.slice(1);
25144
+ }
25145
+ return url;
25146
+ };
25147
+ const fetchIt = (url, fetchOptions, callback, altFetch) => {
25148
+ const resolver = (response) => {
25149
+ if (!response.ok) return callback(response.statusText || "Error", { status: response.status });
25150
+ response.text().then((data) => {
25151
+ callback(null, {
25152
+ status: response.status,
25153
+ data
25154
+ });
25155
+ }).catch(callback);
25156
+ };
25157
+ if (altFetch) {
25158
+ const altResponse = altFetch(url, fetchOptions);
25159
+ if (altResponse instanceof Promise) {
25160
+ altResponse.then(resolver).catch(callback);
25161
+ return;
25162
+ }
25163
+ }
25164
+ if (typeof fetch === "function") fetch(url, fetchOptions).then(resolver).catch(callback);
25165
+ else fetchApi(url, fetchOptions).then(resolver).catch(callback);
25166
+ };
25167
+ const requestWithFetch = (options, url, payload, callback) => {
25168
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
25169
+ const headers = { ...typeof options.customHeaders === "function" ? options.customHeaders() : options.customHeaders };
25170
+ if (typeof window === "undefined" && typeof __webpack_require__.g !== "undefined" && typeof __webpack_require__.g.process !== "undefined" && __webpack_require__.g.process.versions && __webpack_require__.g.process.versions.node) headers["User-Agent"] = `i18next-http-backend (node/${__webpack_require__.g.process.version}; ${__webpack_require__.g.process.platform} ${__webpack_require__.g.process.arch})`;
25171
+ if (payload) headers["Content-Type"] = "application/json";
25172
+ const reqOptions = typeof options.requestOptions === "function" ? options.requestOptions(payload) : options.requestOptions;
25173
+ const fetchOptions = {
25174
+ method: payload ? "POST" : "GET",
25175
+ body: payload ? options.stringify(payload) : void 0,
25176
+ headers,
25177
+ ...options._omitFetchOptions ? {} : reqOptions
25178
+ };
25179
+ const altFetch = typeof options.alternateFetch === "function" && options.alternateFetch.length >= 1 ? options.alternateFetch : void 0;
25180
+ try {
25181
+ fetchIt(url, fetchOptions, callback, altFetch);
25182
+ } catch (e) {
25183
+ if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf("not implemented") < 0) return callback(e);
25184
+ try {
25185
+ Object.keys(reqOptions).forEach((opt) => {
25186
+ delete fetchOptions[opt];
25187
+ });
25188
+ fetchIt(url, fetchOptions, callback, altFetch);
25189
+ options._omitFetchOptions = true;
25190
+ } catch (err) {
25191
+ callback(err);
25192
+ }
25193
+ }
25194
+ };
25195
+ const requestWithXmlHttpRequest = (options, url, payload, callback) => {
25196
+ if (payload && typeof payload === "object") payload = addQueryString("", payload).slice(1);
25197
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
25198
+ try {
25199
+ const x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi("MSXML2.XMLHTTP.3.0");
25200
+ x.open(payload ? "POST" : "GET", url, 1);
25201
+ if (!options.crossDomain) x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
25202
+ x.withCredentials = !!options.withCredentials;
25203
+ if (payload) x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
25204
+ if (x.overrideMimeType) x.overrideMimeType("application/json");
25205
+ let h = options.customHeaders;
25206
+ h = typeof h === "function" ? h() : h;
25207
+ if (h) for (const i of Object.keys(h)) {
25208
+ if (UNSAFE_KEYS.indexOf(i) > -1) continue;
25209
+ x.setRequestHeader(i, h[i]);
25210
+ }
25211
+ x.onreadystatechange = () => {
25212
+ x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
25213
+ status: x.status,
25214
+ data: x.responseText
25215
+ });
25216
+ };
25217
+ x.send(payload);
25218
+ } catch (e) {
25219
+ console && console.log(e);
25220
+ }
25221
+ };
25222
+ const request = (options, url, payload, callback) => {
25223
+ if (typeof payload === "function") {
25224
+ callback = payload;
25225
+ payload = void 0;
25226
+ }
25227
+ callback = callback || (() => {});
25228
+ if (fetchApi && url.indexOf("file:") !== 0) return requestWithFetch(options, url, payload, callback);
25229
+ if (hasXMLHttpRequest() || typeof ActiveXObject === "function") return requestWithXmlHttpRequest(options, url, payload, callback);
25230
+ callback(/* @__PURE__ */ new Error("No fetch and no xhr implementation found!"));
25231
+ };
25232
+ //#endregion
25233
+ //#region lib/index.js
25234
+ const getDefaults = () => {
25235
+ return {
25236
+ loadPath: "/locales/{{lng}}/{{ns}}.json",
25237
+ addPath: "/locales/add/{{lng}}/{{ns}}",
25238
+ parse: (data) => JSON.parse(data),
25239
+ stringify: JSON.stringify,
25240
+ parsePayload: (namespace, key, fallbackValue) => ({ [key]: fallbackValue || "" }),
25241
+ parseLoadPayload: (languages, namespaces) => void 0,
25242
+ request,
25243
+ reloadInterval: typeof window !== "undefined" ? false : 3600 * 1e3,
25244
+ customHeaders: {},
25245
+ queryStringParams: {},
25246
+ crossDomain: false,
25247
+ withCredentials: false,
25248
+ overrideMimeType: false,
25249
+ requestOptions: {
25250
+ mode: "cors",
25251
+ credentials: "same-origin",
25252
+ cache: "default"
25253
+ }
25254
+ };
25255
+ };
25256
+ var Backend = class {
25257
+ constructor(services, options = {}, allOptions = {}) {
25258
+ this.services = services;
25259
+ this.options = options;
25260
+ this.allOptions = allOptions;
25261
+ this.type = "backend";
25262
+ this.init(services, options, allOptions);
25263
+ }
25264
+ init(services, options = {}, allOptions = {}) {
25265
+ this.services = services;
25266
+ this.options = {
25267
+ ...getDefaults(),
25268
+ ...this.options || {},
25269
+ ...options
25270
+ };
25271
+ this.allOptions = allOptions;
25272
+ if (this.services && this.options.reloadInterval) {
25273
+ const timer = setInterval(() => this.reload(), this.options.reloadInterval);
25274
+ if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
25275
+ }
25276
+ }
25277
+ readMulti(languages, namespaces, callback) {
25278
+ this._readAny(languages, languages, namespaces, namespaces, callback);
25279
+ }
25280
+ read(language, namespace, callback) {
25281
+ this._readAny([language], language, [namespace], namespace, callback);
25282
+ }
25283
+ _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
25284
+ let loadPath = this.options.loadPath;
25285
+ if (typeof this.options.loadPath === "function") loadPath = this.options.loadPath(languages, namespaces);
25286
+ loadPath = makePromise(loadPath);
25287
+ loadPath.then((resolvedLoadPath) => {
25288
+ if (!resolvedLoadPath) return callback(null, {});
25289
+ const url = interpolateUrl(resolvedLoadPath, {
25290
+ lng: languages.join("+"),
25291
+ ns: namespaces.join("+")
25292
+ });
25293
+ if (url == null) {
25294
+ const safeLngs = languages.map(sanitizeLogValue).join(", ");
25295
+ const safeNss = namespaces.map(sanitizeLogValue).join(", ");
25296
+ return callback(/* @__PURE__ */ new Error("i18next-http-backend: unsafe lng/ns value — refusing to build request URL for languages=[" + safeLngs + "] namespaces=[" + safeNss + "]"), false);
25297
+ }
25298
+ this.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
25299
+ }, (err) => callback(err, false));
25300
+ }
25301
+ loadUrl(url, callback, languages, namespaces) {
25302
+ const lng = typeof languages === "string" ? [languages] : languages;
25303
+ const ns = typeof namespaces === "string" ? [namespaces] : namespaces;
25304
+ const payload = this.options.parseLoadPayload(lng, ns);
25305
+ const safeUrl = sanitizeLogValue(redactUrlCredentials(url));
25306
+ this.options.request(this.options, url, payload, (err, res) => {
25307
+ if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback("failed loading " + safeUrl + "; status code: " + res.status, true);
25308
+ if (res && res.status >= 400 && res.status < 500) return callback("failed loading " + safeUrl + "; status code: " + res.status, false);
25309
+ if (!res && err && err.message) {
25310
+ const errorMessage = err.message.toLowerCase();
25311
+ if ([
25312
+ "failed",
25313
+ "fetch",
25314
+ "network",
25315
+ "load"
25316
+ ].find((term) => errorMessage.indexOf(term) > -1)) return callback("failed loading " + safeUrl + ": " + sanitizeLogValue(err.message), true);
25317
+ }
25318
+ if (err) return callback(err, false);
25319
+ let ret, parseErr;
25320
+ try {
25321
+ if (typeof res.data === "string") ret = this.options.parse(res.data, languages, namespaces);
25322
+ else ret = res.data;
25323
+ } catch (e) {
25324
+ parseErr = "failed parsing " + safeUrl + " to json";
25325
+ }
25326
+ if (parseErr) return callback(parseErr, false);
25327
+ callback(null, ret);
25328
+ });
25329
+ }
25330
+ create(languages, namespace, key, fallbackValue, callback) {
25331
+ if (!this.options.addPath) return;
25332
+ if (typeof languages === "string") languages = [languages];
25333
+ const payload = this.options.parsePayload(namespace, key, fallbackValue);
25334
+ let finished = 0;
25335
+ const dataArray = [];
25336
+ const resArray = [];
25337
+ languages.forEach((lng) => {
25338
+ let addPath = this.options.addPath;
25339
+ if (typeof this.options.addPath === "function") addPath = this.options.addPath(lng, namespace);
25340
+ const url = interpolateUrl(addPath, {
25341
+ lng,
25342
+ ns: namespace
25343
+ });
25344
+ if (url == null) {
25345
+ finished += 1;
25346
+ if (callback && finished === languages.length) callback(dataArray, resArray);
25347
+ return;
25348
+ }
25349
+ this.options.request(this.options, url, payload, (data, res) => {
25350
+ finished += 1;
25351
+ dataArray.push(data);
25352
+ resArray.push(res);
25353
+ if (finished === languages.length) {
25354
+ if (typeof callback === "function") callback(dataArray, resArray);
25355
+ }
25356
+ });
25357
+ });
25358
+ }
25359
+ reload() {
25360
+ const { backendConnector, languageUtils, logger } = this.services;
25361
+ const currentLanguage = backendConnector.language;
25362
+ if (currentLanguage && currentLanguage.toLowerCase() === "cimode") return;
25363
+ const toLoad = [];
25364
+ const append = (lng) => {
25365
+ languageUtils.toResolveHierarchy(lng).forEach((l) => {
25366
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
25367
+ });
25368
+ };
25369
+ append(currentLanguage);
25370
+ if (this.allOptions.preload) this.allOptions.preload.forEach((l) => append(l));
25371
+ toLoad.forEach((lng) => {
25372
+ this.allOptions.ns.forEach((ns) => {
25373
+ backendConnector.read(lng, ns, "read", null, null, (err, data) => {
25374
+ if (err) logger.warn(`loading namespace ${ns} for language ${lng} failed`, err);
25375
+ if (!err && data) logger.log(`loaded namespace ${ns} for language ${lng}`, data);
25376
+ backendConnector.loaded(`${lng}|${ns}`, err, data);
25377
+ });
25378
+ });
25379
+ });
25380
+ }
25381
+ };
25382
+ Backend.type = "backend";
25383
+ //#endregion
25384
+
25385
+
25543
25386
 
25544
25387
  /***/ }
25545
25388
 
@@ -25575,40 +25418,7 @@ function interpolateUrl(str, data) {
25575
25418
  /******/ return module.exports;
25576
25419
  /******/ }
25577
25420
  /******/
25578
- /******/ // expose the modules object (__webpack_modules__)
25579
- /******/ __webpack_require__.m = __webpack_modules__;
25580
- /******/
25581
25421
  /************************************************************************/
25582
- /******/ /* webpack/runtime/create fake namespace object */
25583
- /******/ (() => {
25584
- /******/ const getProto = Object.getPrototypeOf;
25585
- /******/ let leafPrototypes;
25586
- /******/ // create a fake namespace object
25587
- /******/ // mode & 1: value is a module id, require it
25588
- /******/ // mode & 2: merge all properties of value into the ns
25589
- /******/ // mode & 4: return value when already ns object
25590
- /******/ // mode & 16: return value when it's Promise-like
25591
- /******/ // mode & 8|1: behave like require
25592
- /******/ __webpack_require__.t = function(value, mode) {
25593
- /******/ if(mode & 1) value = this(value);
25594
- /******/ if(mode & 8) return value;
25595
- /******/ if(typeof value === 'object' && value) {
25596
- /******/ if((mode & 4) && value.__esModule) return value;
25597
- /******/ if((mode & 16) && typeof value.then === 'function') return value;
25598
- /******/ }
25599
- /******/ const ns = Object.create(null);
25600
- /******/ __webpack_require__.r(ns);
25601
- /******/ const def = {};
25602
- /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
25603
- /******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
25604
- /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
25605
- /******/ }
25606
- /******/ def['default'] = () => (value);
25607
- /******/ __webpack_require__.d(ns, def);
25608
- /******/ return ns;
25609
- /******/ };
25610
- /******/ })();
25611
- /******/
25612
25422
  /******/ /* webpack/runtime/define property getters */
25613
25423
  /******/ // define getter/value functions for harmony exports
25614
25424
  /******/ __webpack_require__.d = (exports, definition) => {
@@ -25619,20 +25429,6 @@ function interpolateUrl(str, data) {
25619
25429
  /******/ }
25620
25430
  /******/ };
25621
25431
  /******/
25622
- /******/ /* webpack/runtime/ensure chunk */
25623
- /******/ __webpack_require__.f = {};
25624
- /******/ // This file contains only the entry chunk.
25625
- /******/ // The chunk loading function for additional chunks
25626
- /******/ __webpack_require__.e = (chunkId) => {
25627
- /******/ const promises = [];
25628
- /******/ __webpack_require__.f.j(chunkId, promises);
25629
- /******/ return Promise.all(promises);
25630
- /******/ };
25631
- /******/
25632
- /******/ /* webpack/runtime/get javascript chunk filename */
25633
- /******/ // This function allow to reference async chunks
25634
- /******/ __webpack_require__.u = (chunkId) => (chunkId + ".bundled-tests.instrumented.js");
25635
- /******/
25636
25432
  /******/ /* webpack/runtime/global */
25637
25433
  /******/ __webpack_require__.g = (function() {
25638
25434
  /******/ if (typeof globalThis === 'object') return globalThis;
@@ -25646,51 +25442,6 @@ function interpolateUrl(str, data) {
25646
25442
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
25647
25443
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
25648
25444
  /******/
25649
- /******/ /* webpack/runtime/load script */
25650
- /******/ (() => {
25651
- /******/ const inProgress = {};
25652
- /******/ const dataWebpackPrefix = "@itwin/core-i18n:";
25653
- /******/ // loadScript function to load a script via script tag
25654
- /******/ __webpack_require__.l = (url, done, key, chunkId) => {
25655
- /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
25656
- /******/ let script, needAttach;
25657
- /******/ if(key !== undefined) {
25658
- /******/ const scripts = document.getElementsByTagName("script");
25659
- /******/ for(var i = 0; i < scripts.length; i++) {
25660
- /******/ const s = scripts[i];
25661
- /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
25662
- /******/ }
25663
- /******/ }
25664
- /******/ if(!script) {
25665
- /******/ needAttach = true;
25666
- /******/ script = document.createElement('script');
25667
- /******/
25668
- /******/ script.charset = 'utf-8';
25669
- /******/ if (__webpack_require__.nc) {
25670
- /******/ script.setAttribute("nonce", __webpack_require__.nc);
25671
- /******/ }
25672
- /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
25673
- /******/
25674
- /******/ script.src = url;
25675
- /******/ }
25676
- /******/ inProgress[url] = [done];
25677
- /******/ const onScriptComplete = (prev, event) => {
25678
- /******/ // avoid mem leaks in IE.
25679
- /******/ script.onerror = script.onload = null;
25680
- /******/ clearTimeout(timeout);
25681
- /******/ const doneFns = inProgress[url];
25682
- /******/ delete inProgress[url];
25683
- /******/ script.parentNode?.removeChild(script);
25684
- /******/ doneFns?.forEach((fn) => (fn(event)));
25685
- /******/ if(prev) return prev(event);
25686
- /******/ }
25687
- /******/ const timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
25688
- /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
25689
- /******/ script.onload = onScriptComplete.bind(null, script.onload);
25690
- /******/ needAttach && document.head.appendChild(script);
25691
- /******/ };
25692
- /******/ })();
25693
- /******/
25694
25445
  /******/ /* webpack/runtime/make namespace object */
25695
25446
  /******/ // define __esModule on exports
25696
25447
  /******/ __webpack_require__.r = (exports) => {
@@ -25698,118 +25449,6 @@ function interpolateUrl(str, data) {
25698
25449
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
25699
25450
  /******/ };
25700
25451
  /******/
25701
- /******/ /* webpack/runtime/publicPath */
25702
- /******/ (() => {
25703
- /******/ let scriptUrl;
25704
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
25705
- /******/ const document = __webpack_require__.g.document;
25706
- /******/ if (!scriptUrl && document) {
25707
- /******/ if (document.currentScript?.tagName.toUpperCase() === 'SCRIPT')
25708
- /******/ scriptUrl = document.currentScript.src;
25709
- /******/ if (!scriptUrl) {
25710
- /******/ const scripts = document.getElementsByTagName("script");
25711
- /******/ if(scripts.length) {
25712
- /******/ let i = scripts.length - 1;
25713
- /******/ while (i > -1 && (!scriptUrl || !/^https?:/.test(scriptUrl))) scriptUrl = scripts[i--].src;
25714
- /******/ }
25715
- /******/ }
25716
- /******/ }
25717
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
25718
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
25719
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
25720
- /******/ scriptUrl = scriptUrl.replace(/^blob:|[?#].*$/g, "").replace(/\/[^/]+$/, "/");
25721
- /******/ __webpack_require__.p = scriptUrl;
25722
- /******/ })();
25723
- /******/
25724
- /******/ /* webpack/runtime/jsonp chunk loading */
25725
- /******/ (() => {
25726
- /******/ // no baseURI
25727
- /******/
25728
- /******/ // object to store loaded and loading chunks
25729
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
25730
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
25731
- /******/ const installedChunks = {
25732
- /******/ "main": 0
25733
- /******/ };
25734
- /******/
25735
- /******/ __webpack_require__.f.j = (chunkId, promises) => {
25736
- /******/ // JSONP chunk loading for javascript
25737
- /******/ let installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
25738
- /******/ if(installedChunkData !== 0) { // 0 means "already installed".
25739
- /******/
25740
- /******/ // a Promise means "currently loading".
25741
- /******/ if(installedChunkData) {
25742
- /******/ promises.push(installedChunkData[2]);
25743
- /******/ } else {
25744
- /******/ if(true) { // all chunks have JS
25745
- /******/ // setup Promise in chunk cache
25746
- /******/ const promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
25747
- /******/ promises.push(installedChunkData[2] = promise);
25748
- /******/
25749
- /******/ // create error before stack unwound to get useful stacktrace later
25750
- /******/ const error = new Error();
25751
- /******/ const loadingEnded = (event) => {
25752
- /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
25753
- /******/ installedChunkData = installedChunks[chunkId];
25754
- /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
25755
- /******/ if(installedChunkData) {
25756
- /******/ const errorType = event && (event.type === 'load' ? 'missing' : event.type);
25757
- /******/ const realSrc = event && event.target && event.target.src;
25758
- /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
25759
- /******/ error.name = 'ChunkLoadError';
25760
- /******/ error.type = errorType;
25761
- /******/ error.request = realSrc;
25762
- /******/ error.event = event;
25763
- /******/ installedChunkData[1](error);
25764
- /******/ }
25765
- /******/ }
25766
- /******/ };
25767
- /******/ __webpack_require__.l(__webpack_require__.p + __webpack_require__.u(chunkId), loadingEnded, "chunk-" + chunkId, chunkId);
25768
- /******/ }
25769
- /******/ }
25770
- /******/ }
25771
- /******/ };
25772
- /******/
25773
- /******/ // no prefetching
25774
- /******/
25775
- /******/ // no preloaded
25776
- /******/
25777
- /******/ // no HMR
25778
- /******/
25779
- /******/ // no HMR manifest
25780
- /******/
25781
- /******/ // no on chunks loaded
25782
- /******/
25783
- /******/ // install a JSONP callback for chunk loading
25784
- /******/ const webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
25785
- /******/ let [chunkIds, moreModules, runtime] = data;
25786
- /******/ // add "moreModules" to the modules object,
25787
- /******/ // then flag all "chunkIds" as loaded and fire callback
25788
- /******/ var moduleId, chunkId, i = 0;
25789
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
25790
- /******/ for(moduleId in moreModules) {
25791
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
25792
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
25793
- /******/ }
25794
- /******/ }
25795
- /******/ if(runtime) var result = runtime(__webpack_require__);
25796
- /******/ }
25797
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
25798
- /******/ for(;i < chunkIds.length; i++) {
25799
- /******/ chunkId = chunkIds[i];
25800
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
25801
- /******/ installedChunks[chunkId][0]();
25802
- /******/ }
25803
- /******/ installedChunks[chunkId] = 0;
25804
- /******/ }
25805
- /******/
25806
- /******/ }
25807
- /******/
25808
- /******/ const chunkLoadingGlobal = self["webpackChunk_itwin_core_i18n"] = self["webpackChunk_itwin_core_i18n"] || [];
25809
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
25810
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
25811
- /******/ })();
25812
- /******/
25813
25452
  /************************************************************************/
25814
25453
  let __webpack_exports__ = {};
25815
25454
  // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.