adminjs
Version:
Admin panel for apps written in node.js
1,155 lines (1,036 loc) • 4.13 MB
JavaScript
var AdminJS = (function (styledComponents, React$1, require$$3, reactRouterDom, reactRouter, DesignSystem, require$$1, require$$0$1) {
'use strict';
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
function _mergeNamespaces(n, m) {
m.forEach(function (e) {
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
if (k !== 'default' && !(k in n)) {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
});
return Object.freeze(n);
}
var React__default$1 = /*#__PURE__*/_interopDefault(React$1);
var require$$3__default = /*#__PURE__*/_interopDefault(require$$3);
var DesignSystem__namespace = /*#__PURE__*/_interopNamespace(DesignSystem);
var require$$1__default = /*#__PURE__*/_interopDefault(require$$1);
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0$1);
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var f = n.default;
if (typeof f == "function") {
var a = function a () {
if (this instanceof a) {
var args = [null];
args.push.apply(args, arguments);
var Ctor = Function.bind.apply(f, args);
return new Ctor();
}
return f.apply(this, arguments);
};
a.prototype = f.prototype;
} else a = {};
Object.defineProperty(a, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
var regeneratorRuntimeExports = {};
var regeneratorRuntime$1 = {
get exports(){ return regeneratorRuntimeExports; },
set exports(v){ regeneratorRuntimeExports = v; },
};
var _typeofExports = {};
var _typeof$4 = {
get exports(){ return _typeofExports; },
set exports(v){ _typeofExports = v; },
};
(function (module) {
function _typeof(obj) {
"@babel/helpers - typeof";
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
} (_typeof$4));
(function (module) {
var _typeof = _typeofExports["default"];
function _regeneratorRuntime() {
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
return exports;
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function define(obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function value(method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (val) {
var object = Object(val),
keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function reset(skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function stop() {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function dispatchException(exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function abrupt(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function complete(record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function finish(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
"catch": function _catch(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
} (regeneratorRuntime$1));
// TODO(Babel 8): Remove this file.
var runtime = regeneratorRuntimeExports();
var regenerator = runtime;
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
if (typeof globalThis === "object") {
globalThis.regeneratorRuntime = runtime;
} else {
Function("r", "regeneratorRuntime = r")(runtime);
}
}
function _typeof$3(obj) {
"@babel/helpers - typeof";
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof$3(obj);
}
function _toPrimitive$1(input, hint) {
if (_typeof$3(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_typeof$3(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey$1(arg) {
var key = _toPrimitive$1(arg, "string");
return _typeof$3(key) === "symbol" ? key : String(key);
}
function _defineProperty$2(obj, key, value) {
key = _toPropertyKey$1(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
/**
* This file automatically generated from `pre-publish.js`.
* Do not manually edit.
*/
var voidElements = {
"area": true,
"base": true,
"br": true,
"col": true,
"embed": true,
"hr": true,
"img": true,
"input": true,
"link": true,
"meta": true,
"param": true,
"source": true,
"track": true,
"wbr": true
};
var e,t=(e=voidElements)&&"object"==typeof e&&"default"in e?e.default:e,n=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function r(e){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=e.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(t[i[1]]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=e.indexOf("--\x3e");return {type:"comment",comment:-1!==s?e.slice(4,s):""}}for(var c=new RegExp(n),a=null;null!==(a=c.exec(e));)if(a[0].trim())if(a[1]){var o=a[1].trim(),u=[o,""];o.indexOf("=")>-1&&(u=o.split("=")),r.attrs[u[0]]=u[1],c.lastIndex--;}else a[2]&&(r.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return r}var i$1=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,s=/^\s*$/,c=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var htmlParseStringify={parse:function(e,t){t||(t={}),t.components||(t.components=c);var n,a=[],o=[],u=-1,l=!1;if(0!==e.indexOf("<")){var m=e.indexOf("<");a.push({type:"text",content:-1===m?e:e.substring(0,m)});}return e.replace(i$1,function(i,c){if(l){if(i!=="</"+n.name+">")return;l=!1;}var m,d="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),h=c+i.length,p=e.charAt(h);if(f){var v=r(i);return u<0?(a.push(v),a):((m=o[u]).children.push(v),a)}if(d&&(u++,"tag"===(n=r(i)).type&&t.components[n.name]&&(n.type="component",l=!0),n.voidElement||l||!p||"<"===p||n.children.push({type:"text",content:e.slice(h,e.indexOf("<",h))}),0===u&&a.push(n),(m=o[u-1])&&m.children.push(n),o[u]=n),(!d||n.voidElement)&&(u>-1&&(n.voidElement||n.name===i.slice(2,-1))&&(u--,n=-1===u?a:o[u]),!l&&"<"!==p&&p)){m=-1===u?a:o[u].children;var x=e.indexOf("<",h),g=e.slice(h,-1===x?void 0:x);s.test(g)&&(g=" "),(x>-1&&u+m.length>=0||" "!==g)&&m.push({type:"text",content:g});}}),a},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
function warn() {
if (console && console.warn) {
var _console;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (typeof args[0] === 'string') args[0] = "react-i18next:: ".concat(args[0]);
(_console = console).warn.apply(_console, args);
}
}
var alreadyWarned = {};
function warnOnce() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
warn.apply(void 0, args);
}
function loadNamespaces(i18n, ns, cb) {
i18n.loadNamespaces(ns, function () {
if (i18n.isInitialized) {
cb();
} else {
var initialized = function initialized() {
setTimeout(function () {
i18n.off('initialized', initialized);
}, 0);
cb();
};
i18n.on('initialized', initialized);
}
});
}
function oldI18nextHasLoadedNamespace(ns, i18n) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var lng = i18n.languages[0];
var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
var lastLng = i18n.languages[i18n.languages.length - 1];
if (lng.toLowerCase() === 'cimode') return true;
var loadNotPending = function loadNotPending(l, n) {
var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
return loadState === -1 || loadState === 2;
};
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
if (i18n.hasResourceBundle(lng, ns)) return true;
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
return false;
}
function hasLoadedNamespace(ns, i18n) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!i18n.languages || !i18n.languages.length) {
warnOnce('i18n.languages were undefined or empty', i18n.languages);
return true;
}
var isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
if (!isNewerI18next) {
return oldI18nextHasLoadedNamespace(ns, i18n, options);
}
return i18n.hasLoadedNamespace(ns, {
precheck: function precheck(i18nInstance, loadNotPending) {
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
}
});
}
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
var htmlEntities = {
'&': '&',
'&': '&',
'<': '<',
'<': '<',
'>': '>',
'>': '>',
''': "'",
''': "'",
'"': '"',
'"': '"',
' ': ' ',
' ': ' ',
'©': '©',
'©': '©',
'®': '®',
'®': '®',
'…': '…',
'…': '…',
'/': '/',
'/': '/'
};
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
return htmlEntities[m];
};
var unescape$1 = function unescape(text) {
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
};
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var defaultOptions = {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transWrapTextNodes: '',
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
useSuspense: true,
unescape: unescape$1
};
function setDefaults() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
defaultOptions = _objectSpread$a(_objectSpread$a({}, defaultOptions), options);
}
function getDefaults$2() {
return defaultOptions;
}
var i18nInstance;
function setI18n(instance) {
i18nInstance = instance;
}
function getI18n() {
return i18nInstance;
}
var _excluded$1 = ["format"],
_excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function hasChildren(node, checkLength) {
if (!node) return false;
var base = node.props ? node.props.children : node.children;
if (checkLength) return base.length > 0;
return !!base;
}
function getChildren(node) {
if (!node) return [];
return node.props ? node.props.children : node.children;
}
function hasValidReactChildren(children) {
if (Object.prototype.toString.call(children) !== '[object Array]') return false;
return children.every(function (child) {
return React$1.isValidElement(child);
});
}
function getAsArray(data) {
return Array.isArray(data) ? data : [data];
}
function mergeProps(source, target) {
var newTarget = _objectSpread$9({}, target);
newTarget.props = Object.assign(source.props, target.props);
return newTarget;
}
function nodesToString(children, i18nOptions) {
if (!children) return '';
var stringNode = '';
var childrenArray = getAsArray(children);
var keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
childrenArray.forEach(function (child, childIndex) {
if (typeof child === 'string') {
stringNode += "".concat(child);
} else if (React$1.isValidElement(child)) {
var childPropsCount = Object.keys(child.props).length;
var shouldKeepChild = keepArray.indexOf(child.type) > -1;
var childChildren = child.props.children;
if (!childChildren && shouldKeepChild && childPropsCount === 0) {
stringNode += "<".concat(child.type, "/>");
} else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
} else if (child.props.i18nIsDynamicList) {
stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
} else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
stringNode += "<".concat(child.type, ">").concat(childChildren, "</").concat(child.type, ">");
} else {
var content = nodesToString(childChildren, i18nOptions);
stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
}
} else if (child === null) {
warn("Trans: the passed in value is invalid - seems you passed in a null child.");
} else if (_typeof$3(child) === 'object') {
var format = child.format,
clone = _objectWithoutProperties(child, _excluded$1);
var keys = Object.keys(clone);
if (keys.length === 1) {
var value = format ? "".concat(keys[0], ", ").concat(format) : keys[0];
stringNode += "{{".concat(value, "}}");
} else {
warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
}
} else {
warn("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", child);
}
});
return stringNode;
}
function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
if (targetString === '') return [];
var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
var emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
if (!children && !emptyChildrenButNeedsHandling) return [targetString];
var data = {};
function getData(childs) {
var childrenArray = getAsArray(childs);
childrenArray.forEach(function (child) {
if (typeof child === 'string') return;
if (hasChildren(child)) getData(getChildren(child));else if (_typeof$3(child) === 'object' && !React$1.isValidElement(child)) Object.assign(data, child);
});
}
getData(children);
var ast = htmlParseStringify.parse("<0>".concat(targetString, "</0>"));
var opts = _objectSpread$9(_objectSpread$9({}, data), combinedTOpts);
function renderInner(child, node, rootReactNode) {
var childs = getChildren(child);
var mappedChildren = mapAST(childs, node.children, rootReactNode);
return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
}
function pushTranslatedJSX(child, inner, mem, i, isVoid) {
if (child.dummy) child.children = inner;
mem.push(React$1.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
key: i
}), isVoid ? undefined : inner));
}
function mapAST(reactNode, astNode, rootReactNode) {
var reactNodes = getAsArray(reactNode);
var astNodes = getAsArray(astNode);
return astNodes.reduce(function (mem, node, i) {
var translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
if (node.type === 'tag') {
var tmp = reactNodes[parseInt(node.name, 10)];
if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
if (!tmp) tmp = {};
var child = Object.keys(node.attrs).length !== 0 ? mergeProps({
props: node.attrs
}, tmp) : tmp;
var isElement = React$1.isValidElement(child);
var isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
var isEmptyTransWithHTML = emptyChildrenButNeedsHandling && _typeof$3(child) === 'object' && child.dummy && !isElement;
var isKnownComponent = _typeof$3(children) === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
if (typeof child === 'string') {
var value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
mem.push(value);
} else if (hasChildren(child) || isValidTranslationWithChildren) {
var inner = renderInner(child, node, rootReactNode);
pushTranslatedJSX(child, inner, mem, i);
} else if (isEmptyTransWithHTML) {
var _inner = mapAST(reactNodes, node.children, rootReactNode);
mem.push(React$1.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
key: i
}), _inner));
} else if (Number.isNaN(parseFloat(node.name))) {
if (isKnownComponent) {
var _inner2 = renderInner(child, node, rootReactNode);
pushTranslatedJSX(child, _inner2, mem, i, node.voidElement);
} else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
if (node.voidElement) {
mem.push(React$1.createElement(node.name, {
key: "".concat(node.name, "-").concat(i)
}));
} else {
var _inner3 = mapAST(reactNodes, node.children, rootReactNode);
mem.push(React$1.createElement(node.name, {
key: "".concat(node.name, "-").concat(i)
}, _inner3));
}
} else if (node.voidElement) {
mem.push("<".concat(node.name, " />"));
} else {
var _inner4 = mapAST(reactNodes, node.children, rootReactNode);
mem.push("<".concat(node.name, ">").concat(_inner4, "</").concat(node.name, ">"));
}
} else if (_typeof$3(child) === 'object' && !isElement) {
var content = node.children[0] ? translationContent : null;
if (content) mem.push(content);
} else if (node.children.length === 1 && translationContent) {
mem.push(React$1.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
key: i
}), translationContent));
} else {
mem.push(React$1.cloneElement(child, _objectSpread$9(_objectSpread$9({}, child.props), {}, {
key: i
})));
}
} else if (node.type === 'text') {
var wrapTextNodes = i18nOptions.transWrapTextNodes;
var _content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
if (wrapTextNodes) {
mem.push(React$1.createElement(wrapTextNodes, {
key: "".concat(node.name, "-").concat(i)
}, _content));
} else {
mem.push(_content);
}
}
return mem;
}, []);
}
var result = mapAST([{
dummy: true,
children: children || []
}], ast, getAsArray(children || []));
return getChildren(result[0]);
}
function Trans$1(_ref) {
var children = _ref.children,
count = _ref.count,
parent = _ref.parent,
i18nKey = _ref.i18nKey,
context = _ref.context,
_ref$tOptions = _ref.tOptions,
tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
values = _ref.values,
defaults = _ref.defaults,
components = _ref.components,
ns = _ref.ns,
i18nFromProps = _ref.i18n,
tFromProps = _ref.t,
shouldUnescape = _ref.shouldUnescape,
additionalProps = _objectWithoutProperties(_ref, _excluded2);
var i18n = i18nFromProps || getI18n();
if (!i18n) {
warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
return children;
}
var t = tFromProps || i18n.t.bind(i18n) || function (k) {
return k;
};
if (context) tOptions.context = context;
var reactI18nextOptions = _objectSpread$9(_objectSpread$9({}, getDefaults$2()), i18n.options && i18n.options.react);
var namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
var hashTransKey = reactI18nextOptions.hashTransKey;
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
var interpolationOverride = values ? tOptions.interpolation : {
interpolation: _objectSpread$9(_objectSpread$9({}, tOptions.interpolation), {}, {
prefix: '#$?',
suffix: '?$#'
})
};
var combinedTOpts = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, tOptions), {}, {
count: count
}, values), interpolationOverride), {}, {
defaultValue: defaultValue,
ns: namespaces
});
var translation = key ? t(key, combinedTOpts) : defaultValue;
var content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
return useAsParent ? React$1.createElement(useAsParent, additionalProps, content) : content;
}
function _classCallCheck$1(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
var initReactI18next = {
type: '3rdParty',
init: function init(instance) {
setDefaults(instance.options.react);
setI18n(instance);
}
};
var I18nContext = React$1.createContext();
var ReportNamespaces = function () {
function ReportNamespaces() {
_classCallCheck$1(this, ReportNamespaces);
this.usedNamespaces = {};
}
_createClass$1(ReportNamespaces, [{
key: "addUsedNamespaces",
value: function addUsedNamespaces(namespaces) {
var _this = this;
namespaces.forEach(function (ns) {
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
});
}
}, {
key: "getUsedNamespaces",
value: function getUsedNamespaces() {
return Object.keys(this.usedNamespaces);
}
}]);
return ReportNamespaces;
}();
var _excluded = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function Trans(_ref) {
var children = _ref.children,
count = _ref.count,
parent = _ref.parent,
i18nKey = _ref.i18nKey,
context = _ref.context,
_ref$tOptions = _ref.tOptions,
tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
values = _ref.values,
defaults = _ref.defaults,
components = _ref.components,
ns = _ref.ns,
i18nFromProps = _ref.i18n,
tFromProps = _ref.t,
shouldUnescape = _ref.shouldUnescape,
additionalProps = _objectWithoutProperties(_ref, _excluded);
var _ref2 = React$1.useContext(I18nContext) || {},
i18nFromContext = _ref2.i18n,
defaultNSFromContext = _ref2.defaultNS;
var i18n = i18nFromProps || i18nFromContext || getI18n();
var t = tFromProps || i18n && i18n.t.bind(i18n);
return Trans$1(_objectSpread$8({
children: children,
count: count,
parent: parent,
i18nKey: i18nKey,
context: context,
tOptions: tOptions,
values: values,
defaults: defaults,
components: components,
ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
i18n: i18n,
t: tFromProps,
shouldUnescape: shouldUnescape
}, additionalProps));
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
if (null != _i) {
var _s,
_e,
_x,
_r,
_arr = [],
_n = !0,
_d = !1;
try {
if (_x = (_i = _i.call(arr)).next, 0 === i) {
if (Object(_i) !== _i) return;
_n = !1;
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
} catch (err) {
_d = !0, _e = err;
} finally {
try {
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
} finally {
if (_d) throw _e;
}
}
return _arr;
}
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var usePrevious$1 = function usePrevious(value, ignore) {
var ref = React$1.useRef();
React$1.useEffect(function () {
ref.current = ignore ? ref.current : value;
}, [value, ignore]);
return ref.current;
};
function useTranslation$1(ns) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var i18nFromProps = props.i18n;
var _ref = React$1.useContext(I18nContext) || {},
i18nFromContext = _ref.i18n,
defaultNSFromContext = _ref.defaultNS;
var i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
if (!i18n) {
warnOnce('You will need to pass in an i18next instance by using initReactI18next');
var notReadyT = function notReadyT(k, optsOrDefaultValue) {
if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
if (optsOrDefaultValue && _typeof$3(optsOrDefaultValue) === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
return Array.isArray(k) ? k[k.length - 1] : k;
};
var retNotReady = [notReadyT, {}, false];
retNotReady.t = notReadyT;
retNotReady.i18n = {};
retNotReady.ready = false;
return retNotReady;
}
if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
var i18nOptions = _objectSpread$7(_objectSpread$7(_objectSpread$7({}, getDefaults$2()), i18n.options.react), props);
var useSuspense = i18nOptions.useSuspense,
keyPrefix = i18nOptions.keyPrefix;
var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
return hasLoadedNamespace(n, i18n, i18nOptions);
});
function getT() {
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
}
var _useState = React$1.useState(getT),
_useState2 = _slicedToArray(_useState, 2),
t = _useState2[0],
setT = _useState2[1];
var joinedNS = namespaces.join();
var previousJoinedNS = usePrevious$1(joinedNS);
var isMounted = React$1.useRef(true);
React$1.useEffect(function () {
var bindI18n = i18nOptions.bindI18n,
bindI18nStore = i18nOptions.bindI18nStore;
isMounted.current = true;
if (!ready && !useSuspense) {
loadNamespaces(i18n, namespaces, function () {
if (isMounted.current) setT(getT);
});
}
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.cur