!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.i18nextXHRBackend=e()}(this,function(){"use strict";function t(t){return a.call(r.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}function e(t,e,n,o,i){if(o&&"object"===("undefined"==typeof o?"undefined":s(o))){var a="",r=encodeURIComponent;for(var l in o)a+="&"+r(l)+"="+r(o[l]);o=a.slice(1)+(i?"":"&_t="+new Date)}try{var u=new(XMLHttpRequest||ActiveXObject)("MSXML2.XMLHTTP.3.0");u.open(o?"POST":"GET",t,1),e.crossDomain||u.setRequestHeader("X-Requested-With","XMLHttpRequest"),u.withCredentials=!!e.withCredentials,o&&u.setRequestHeader("Content-type","application/x-www-form-urlencoded");var c=e.customHeaders;if(c)for(var f in c)u.setRequestHeader(f,c[f]);u.onreadystatechange=function(){u.readyState>3&&n&&n(u.responseText,u)},u.send(o)}catch(t){console&&console.log(t)}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:JSON.parse,crossDomain:!1,ajax:e}}var i=[],a=i.forEach,r=i.slice,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};n(this,e),this.init(t,o),this.type="backend"}return l(e,[{key:"init",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=e,this.options=t(n,this.options||{},o())}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));var i=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(i,n)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));var i=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(i,n)}},{key:"loadUrl",value:function(t,e){var n=this;this.options.ajax(t,this.options,function(o,i){if(i.status>=500&&i.status<600)return e("failed loading "+t,!0);if(i.status>=400&&i.status<500)return e("failed loading "+t,!1);var a=void 0,r=void 0;try{a=n.options.parse(o,t)}catch(e){r="failed parsing "+t+" to json"}return r?e(r,!1):void e(null,a)})}},{key:"create",value:function(t,e,n,o){var i=this;"string"==typeof t&&(t=[t]);var a={};a[n]=o||"",t.forEach(function(t){var n=i.services.interpolator.interpolate(i.options.addPath,{lng:t,ns:e});i.options.ajax(n,i.options,function(t,e){},a)})}}]),e}();return u.type="backend",u});