define(["exports","./../appsettings.js","./../../emby-apiclient/events.js"],function(_exports,_appsettings,_events){function UserSettings(){}function getHomeSection(instance,index){instance=instance.get("homesection"+index)||instance.getDefaultHomeScreenSection(index);return instance="librarytiles"!==instance&&"smalllibrarytiles-automobile"!==instance&&"librarytiles-automobile"!==instance?instance:"smalllibrarytiles"}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,UserSettings.prototype.setUserInfo=function(userId,apiClient){var self;return this.saveTimeout&&clearTimeout(this.saveTimeout),this.currentUserId=userId,this.currentApiClient=apiClient,this.supportsPartialSave=null==apiClient?void 0:apiClient.isMinServerVersion("4.9.0.23"),userId?(self=this,apiClient.getDisplayPreferences(userId).then(function(result){self.displayPrefs=result,_events.default.trigger(self,"load")})):(this.displayPrefs=null,Promise.resolve())},UserSettings.prototype.getData=function(){return this.displayPrefs},UserSettings.prototype.importFrom=function(instance){this.displayPrefs=instance.getData()},UserSettings.prototype.set=function(name,value,enableOnServer){var currentValue,userId=this.currentUserId;if(userId)return currentValue=this.get(name,enableOnServer),userId=_appsettings.default.set(name,value=null==value?null:value,userId),!1!==enableOnServer&&this.displayPrefs&&(enableOnServer=null==value?value:value.toString(),this.displayPrefs[name]=enableOnServer,function(instance,name,value){var obj;instance.supportsPartialSave?((obj={})[name]=value,instance.currentApiClient.updatePartialDisplayPreferences(obj,instance.currentUserId)):(instance.saveTimeout&&clearTimeout(instance.saveTimeout),instance.saveTimeout=setTimeout(function(){this.saveTimeout=null,this.currentApiClient.updateDisplayPreferences(this.displayPrefs,this.currentUserId)}.bind(instance),50))}(this,name,enableOnServer)),currentValue!==value&&_events.default.trigger(this,"change",[name,value]),userId;throw new Error("userId cannot be null")},UserSettings.prototype.remove=function(name,enableOnServer){return this.set(name,null,enableOnServer)},UserSettings.prototype.get=function(name,enableOnServer){var userId=this.currentUserId;return userId?!1!==enableOnServer&&this.displayPrefs?this.displayPrefs[name]:_appsettings.default.get(name,userId):null},UserSettings.prototype.serverConfig=function(config){var apiClient=this.currentApiClient;return config?apiClient.updateUserConfiguration(this.currentUserId,config):apiClient.getUser(this.currentUserId).then(function(user){return user.Configuration})},UserSettings.prototype.enableNextVideoInfoOverlay=function(val){return null!=val?this.set("enableNextVideoInfoOverlay",val.toString()):"false"!==(val=this.get("enableNextVideoInfoOverlay"))},UserSettings.prototype.getEnableLogoAsTitle=function(displayLanguage){var val=this.get("enableLogoAsTitle");return val?"true"===val:displayLanguage&&displayLanguage.toLowerCase().startsWith("en")},UserSettings.prototype.hideEpisodeSpoilerInfo=function(val){return null!=val?this.set("hideEpisodeSpoilerInfo",val.toString(),!0):"true"===(val=this.get("hideEpisodeSpoilerInfo",!0))},UserSettings.prototype.setEnableLogoAsTitle=function(val){return this.set("enableLogoAsTitle",val.toString())},UserSettings.prototype.groupCollectionItems=function(val){return null!=val?this.set("groupCollectionItems",val.toString(),!0):"false"!==(val=this.get("groupCollectionItems",!0))},UserSettings.prototype.enableAutoFolderJumpThrough=function(val){return null!=val?this.set("enableAutoFolderJumpThrough",val.toString(),!0):"false"!==(val=this.get("enableAutoFolderJumpThrough",!0))},UserSettings.prototype.enableHomescreenFocusPreviews=function(val){return null!=val?this.set("enableHomescreenFocusPreviews",val.toString(),!0):"true"===(val=this.get("enableHomescreenFocusPreviews",!0))},UserSettings.prototype.genreLimitForListsOnDetails=function(val){return null!=val?this.set("genreLimitForListsOnDetails",val.toString(),!0):parseInt(this.get("genreLimitForListsOnDetails",!0)||"3")},UserSettings.prototype.genreLimitOnDetails=function(val){return null!=val?this.set("genreLimitOnDetails",val.toString(),!0):parseInt(this.get("genreLimitOnDetails",!0)||"1")},UserSettings.prototype.showDetailPoster=function(isTvLayout,val){var key="showDetailPoster"+(isTvLayout?"tv":"");if(null!=val)return this.set(key,val.toString(),!0);switch(val=this.get(key,!0)){case"true":return!0;case"false":return!1;default:return!isTvLayout}},UserSettings.prototype.showEndsAtOnDetails=function(val){return null!=val?this.set("showEndsAtOnDetails",val.toString(),!0):"false"!==(val=this.get("showEndsAtOnDetails",!0))},UserSettings.prototype.enableRatingInfoOnPlaybackStart=function(val){return null!=val?this.set("enableRatingInfoOnPlaybackStart",val.toString(),!0):"false"!==(val=this.get("enableRatingInfoOnPlaybackStart",!0))},UserSettings.prototype.skipBackLength=function(val){return null!=val?this.set("skipBackLength",val.toString()):parseInt(this.get("skipBackLength")||"10000")},UserSettings.prototype.skipForwardLength=function(val){return null!=val?this.set("skipForwardLength",val.toString()):parseInt(this.get("skipForwardLength")||"10000")},UserSettings.prototype.settingsTheme=function(val){return null!=val?this.set("settingsTheme",val,!1):this.get("settingsTheme",!1)},UserSettings.prototype.theme=function(val){return null!=val?this.set("appTheme",val,!1):this.get("appTheme",!1)||null},UserSettings.prototype.accentColor=function(val){return null!=val?this.set("accentColor",val,!0):this.get("accentColor",!0)||"emby"},UserSettings.prototype.useSystemAccentColor=function(val){return null!=val?this.set("useSystemAccentColor",val.toString(),!1):"true"===this.get("useSystemAccentColor",!1)},UserSettings.prototype.osdContentSection=function(type,val){return null!=val?this.set("osdcontentsection-"+type,val,!1):this.get("osdcontentsection-"+type,!1)},UserSettings.prototype.drawerStyle=function(val){return null!=val?this.set("drawerstyle",val,!1):this.get("drawerstyle",!1)||"docked"},UserSettings.prototype.settingsDrawerStyle=function(val){return null!=val?this.set("settingsdrawerstyle",val,!1):this.get("settingsdrawerstyle",!1)||"docked"},UserSettings.prototype.videoScreenUpAction=function(val){return null!=val?this.set("videoScreenUpAction",val,!0):this.get("videoScreenUpAction",!0)},UserSettings.prototype.nowPlayingAudioBackgroundStyle=function(val){return null!=val?this.set("nowPlayingAudioBackgroundStyle",val,!0):this.get("nowPlayingAudioBackgroundStyle",!0)||"blur"},UserSettings.prototype.nowPlayingVideoBackgroundStyle=function(val){return null!=val?this.set("nowPlayingVideoBackgroundStyle",val,!0):this.get("nowPlayingVideoBackgroundStyle",!0)||"backdrop"},UserSettings.prototype.stillWatchingTimeMs=function(val){return null!=val?this.set("stillwatchingms",val,!0):parseInt(this.get("stillwatchingms",!0)||"14400000")},UserSettings.prototype.tvHome=function(val){return null!=val?this.set("tvhome",val,!0):this.get("tvhome",!0)||"vertical"},UserSettings.prototype.tvScrollDirection=function(val){return null!=val?this.set("tvScrollDirection",val,!0):this.get("tvScrollDirection",!0)||"vertical"},UserSettings.prototype.itemSortBy=function(itemId,val){itemId="sortitems-"+itemId+"-by";return null!=val?this.set(itemId,val,!1):this.get(itemId,!1)||""},UserSettings.prototype.itemSortOrder=function(itemId,val){itemId="sortitems-"+itemId+"-order";return null!=val?this.set(itemId,val,!1):this.get(itemId,!1)||"Ascending"},UserSettings.prototype.enableStillWatching=function(val){return null!=val?this.stillWatchingTimeMs(val?144e5:0):0