!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).i18nextLocalStorageBackend=e()}(this,(function(){"use strict";function t(e){return(t="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})(e)}function e(e){var n=function(e,n){if("object"!==t(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"===t(n)?n:String(n)}function n(t,n,r){return(n=e(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};r(this,t),this.init(e,n),this.type="backend"}return i(t,[{key:"init",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=t,this.options=a(a(a({},u()),this.options),e),this.storage=new c(this.options)}},{key:"read",value:function(t,e,n){var r=Date.now();if(!this.storage.store)return n(null,null);var o=this.storage.getItem("".concat(this.options.prefix).concat(t,"-").concat(e));if(o){o=JSON.parse(o);var i=this.getVersion(t);if(o.i18nStamp&&o.i18nStamp+this.options.expirationTime>r&&i===o.i18nVersion){var s=o.i18nStamp;return delete o.i18nVersion,delete o.i18nStamp,n(null,o,s)}}return n(null,null)}},{key:"save",value:function(t,e,n){if(this.storage.store){n.i18nStamp=Date.now();var r=this.getVersion(t);r&&(n.i18nVersion=r),this.storage.setItem("".concat(this.options.prefix).concat(t,"-").concat(e),JSON.stringify(n))}}},{key:"getVersion",value:function(t){return this.options.versions[t]||this.options.defaultVersion}}]),t}();return f.type="backend",f}));