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,QAAS,CACzEW,IAAKA,EACLE,GAAIR,IAGNgB,EAAO5D,QAAQD,KAAKP,EAAKoE,EAAO5D,SAAS,SAAUE,EAAMsD,GAEzD,GAAGK,EACL,GACF,KAGKtC,CACT,CA5FA,GA8FAA,EAAQO,KAAO,UAEfgC,EAAOC,QAAUxC,C","sources":["webpack:///./node_modules/i18next-xhr-backend/dist/cjs/i18nextXHRBackend.js"],"sourcesContent":["'use strict';\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));\nvar _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));\nvar _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));\nvar _typeof = _interopDefault(require('@babel/runtime/helpers/typeof'));\n\nvar arr = [];\nvar each = arr.forEach;\nvar slice = arr.slice;\nfunction defaults(obj) {\n each.call(slice.call(arguments, 1), function (source) {\n if (source) {\n for (var prop in source) {\n if (obj[prop] === undefined) obj[prop] = source[prop];\n }\n }\n });\n return obj;\n}\n\nfunction addQueryString(url, params) {\n if (params && _typeof(params) === 'object') {\n var queryString = '',\n e = encodeURIComponent; // Must encode data\n\n for (var paramName in params) {\n queryString += '&' + e(paramName) + '=' + e(params[paramName]);\n }\n\n if (!queryString) {\n return url;\n }\n\n url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);\n }\n\n return url;\n} // https://gist.github.com/Xeoncross/7663273\n\n\nfunction ajax(url, options, callback, data, cache) {\n if (data && _typeof(data) === 'object') {\n if (!cache) {\n data['_t'] = new Date();\n } // URL encoded form data must be in querystring format\n\n\n data = addQueryString('', data).slice(1);\n }\n\n if (options.queryStringParams) {\n url = addQueryString(url, options.queryStringParams);\n }\n\n try {\n var x;\n\n if (XMLHttpRequest) {\n x = new XMLHttpRequest();\n } else {\n x = new ActiveXObject('MSXML2.XMLHTTP.3.0');\n }\n\n x.open(data ? 'POST' : 'GET', url, 1);\n\n if (!options.crossDomain) {\n x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n }\n\n x.withCredentials = !!options.withCredentials;\n\n if (data) {\n x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n }\n\n if (x.overrideMimeType) {\n x.overrideMimeType(\"application/json\");\n }\n\n var h = options.customHeaders;\n h = typeof h === 'function' ? h() : h;\n\n if (h) {\n for (var i in h) {\n x.setRequestHeader(i, h[i]);\n }\n }\n\n x.onreadystatechange = function () {\n x.readyState > 3 && callback && callback(x.responseText, x);\n };\n\n x.send(data);\n } catch (e) {\n console && console.log(e);\n }\n}\n\nfunction getDefaults() {\n return {\n loadPath: '/locales/{{lng}}/{{ns}}.json',\n addPath: '/locales/add/{{lng}}/{{ns}}',\n allowMultiLoading: false,\n parse: JSON.parse,\n parsePayload: function parsePayload(namespace, key, fallbackValue) {\n return _defineProperty({}, key, fallbackValue || '');\n },\n crossDomain: false,\n ajax: ajax\n };\n}\n\nvar Backend =\n/*#__PURE__*/\nfunction () {\n function Backend(services) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Backend);\n\n this.init(services, options);\n this.type = 'backend';\n }\n\n _createClass(Backend, [{\n key: \"init\",\n value: function init(services) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.services = services;\n this.options = defaults(options, this.options || {}, getDefaults());\n }\n }, {\n key: \"readMulti\",\n value: function readMulti(languages, namespaces, callback) {\n var loadPath = this.options.loadPath;\n\n if (typeof this.options.loadPath === 'function') {\n loadPath = this.options.loadPath(languages, namespaces);\n }\n\n var url = this.services.interpolator.interpolate(loadPath, {\n lng: languages.join('+'),\n ns: namespaces.join('+')\n });\n this.loadUrl(url, callback);\n }\n }, {\n key: \"read\",\n value: function read(language, namespace, callback) {\n var loadPath = this.options.loadPath;\n\n if (typeof this.options.loadPath === 'function') {\n loadPath = this.options.loadPath([language], [namespace]);\n }\n\n var url = this.services.interpolator.interpolate(loadPath, {\n lng: language,\n ns: namespace\n });\n this.loadUrl(url, callback);\n }\n }, {\n key: \"loadUrl\",\n value: function loadUrl(url, callback) {\n var _this = this;\n\n this.options.ajax(url, this.options, function (data, xhr) {\n if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true\n /* retry */\n );\n if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false\n /* no retry */\n );\n var ret, err;\n\n try {\n ret = _this.options.parse(data, url);\n } catch (e) {\n err = 'failed parsing ' + url + ' to json';\n }\n\n if (err) return callback(err, false);\n callback(null, ret);\n });\n }\n }, {\n key: \"create\",\n value: function create(languages, namespace, key, fallbackValue) {\n var _this2 = this;\n\n if (typeof languages === 'string') languages = [languages];\n var payload = this.options.parsePayload(namespace, key, fallbackValue);\n languages.forEach(function (lng) {\n var url = _this2.services.interpolator.interpolate(_this2.options.addPath, {\n lng: lng,\n ns: namespace\n });\n\n _this2.options.ajax(url, _this2.options, function (data, xhr) {//const statusCode = xhr.status.toString();\n // TODO: if statusCode === 4xx do log\n }, payload);\n });\n }\n }]);\n\n return Backend;\n}();\n\nBackend.type = 'backend';\n\nmodule.exports = Backend;\n"],"names":["_interopDefault","ex","_classCallCheck","_createClass","_defineProperty","_typeof","arr","each","forEach","slice","addQueryString","url","params","queryString","e","encodeURIComponent","paramName","indexOf","ajax","options","callback","data","cache","Date","queryStringParams","x","XMLHttpRequest","ActiveXObject","open","crossDomain","setRequestHeader","withCredentials","overrideMimeType","h","customHeaders","i","onreadystatechange","readyState","responseText","send","console","log","Backend","services","arguments","length","undefined","this","init","type","key","value","obj","call","source","prop","defaults","loadPath","addPath","allowMultiLoading","parse","JSON","parsePayload","namespace","fallbackValue","languages","namespaces","interpolator","interpolate","lng","join","ns","loadUrl","language","_this","xhr","status","ret","err","_this2","payload","module","exports"],"sourceRoot":""}