"use strict";window.SbcUserPreferences=function(n){var t=function(){if(window===this&&console.error("dont call from window!"),this._storage=n,this._config=this.constructor.config,this._config||console.error("component in not working state! static property config must be set!"),delete this.constructor.config,this._config.use)this._storage[this._config.storagePrefix]||this._refresh();else{this._storage.removeItem(this._config.storagePrefix);for(var t=0;t<this._config.allowedKeys.length;t++)this._storage.removeItem(this._addPrefix(this._config.allowedKeys[t]))}};return t.prototype._refresh=function(){this._storage[this._config.storagePrefix]=!0;var n=this;$.ajax({type:"GET",url:this._config.baseUrl,context:{SuppressDefaultAjaxError:!0},contentType:"application/json; charset=utf-8"}).done(function(t){n._storage[n._config.storagePrefix]="1";Object.keys(t).forEach(function(i){n._storage[n._addPrefix(i)]=t[i]})}).fail(function(){this._storage.removeItem(this._config.storagePrefix);console.error("error loading SbcUserPreferences !")})},t.prototype._addPrefix=function(n){return this._config.storagePrefix+n},t.prototype._stripPrefix=function(n){return n.substring(this._config.storagePrefix.length)},t.prototype._saveKey=function(n,t){if(this._config.allowedKeys.indexOf(n)<0){console.warn("string "+n+" not allowed for component SbcUserPreferences");return}if(!this._storage[this._config.storagePrefix]||"true"===this._storage[this._config.storagePrefix])return!1;var i=this._addPrefix(n),u=i in this._storage?JSON.parse(this._storage[i]):undefined,r=JSON.stringify(t);return undefined===t?(this._storage.removeItem(i),r=undefined):this._storage[i]=r,$.ajax({type:"POST",url:this._config.baseUrl+"/"+n,contentType:"application/json; charset=utf-8",context:{SuppressDefaultAjaxError:!0},data:JSON.stringify({value:r})}),u},t.prototype.remove=function(n){return this._saveKey(n)},t.prototype.set=function(n,t){return this._saveKey(n,t)},t.prototype.getAll=function(){if(!this._storage[this._config.storagePrefix])return undefined;if("true"===this._storage[this._config.storagePrefix])return console.warn("SbcUserPreferences is being loaded"),null;var t={},n=this;return Object.keys(this._storage).forEach(function(i){i.startsWith(n._config.storagePrefix)&&n._config.storagePrefix!==i&&(t[n._stripPrefix(i)]=JSON.parse(n._storage[i]))}),t},t.prototype.get=function(n,t){if(this._config.allowedKeys.indexOf(n)<0){console.warn("string "+n+" not allowed for SbcUserPreferences !");return}return this._storage[this._config.storagePrefix]?"true"===this._storage[this._config.storagePrefix]?(console.warn("SbcUserPreferences is being loaded"),t):(n=this._addPrefix(n),n in this._storage?JSON.parse(this._storage[n]):t):t},t}(window.sessionStorage)