define(["exports","./../modules/viewmanager/basesettingsview.js","./../modules/loading/loading.js","./../modules/common/globalize.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-elements/emby-select/emby-select.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/emby-elements/emby-input/emby-input.js","./../modules/emby-elements/emby-toggle/emby-toggle.js","./subtitleappearanceeditor.js"],function(_exports,_basesettingsview,_loading,_globalize,_embyScroller,_embySelect,_embyButton,_embyInput,_embyToggle,_subtitleappearanceeditor){function onTrackSelectionsCleared(){_loading.default.hide()}function onClearSavedTrackSelectionsClick(e){var options,instance=this,mode=e.target.closest("button").getAttribute("data-mode");return options={title:_globalize.default.translate("HeaderClearTrackSelections"),text:_globalize.default.translate("QuestionClearSavedTracks"),confirmText:_globalize.default.translate("HeaderClearTrackSelections"),primary:"cancel"},Emby.importModule("./modules/common/dialogs/confirm.js").then(function(confirm){return confirm(options)}).then(function(){_loading.default.show();var userId=instance.getUserConfigurationUserId();return instance.getApiClient().clearUserTrackSelections(userId,mode).then(onTrackSelectionsCleared,onTrackSelectionsCleared)})}function View(view,params){_basesettingsview.default.apply(this,arguments),function(view,apiClient){var html="",html=(html=(html+='<option value="Default" data-description="'+_globalize.default.translate("DefaultSubtitlesHelp")+'">'+_globalize.default.translate("Default")+"</option>")+('<option value="Smart" data-description="'+_globalize.default.translate("SmartSubtitlesHelp")+'">'+_globalize.default.translate("Smart")+"</option>"))+('<option value="OnlyForced" data-description="'+_globalize.default.translate("OnlyForcedSubtitlesHelp")+'">'+_globalize.default.translate("OnlyForcedSubtitles")+"</option>");apiClient.isMinServerVersion("4.8.0.67")&&(html+='<option value="HearingImpaired" data-description="'+_globalize.default.translate("AutoSelectHearingImpairedHelp")+'">'+_globalize.default.translate("HearingImpaired")+"</option>"),html=(html+='<option value="Always" data-description="'+_globalize.default.translate("AlwaysPlaySubtitlesHelp")+'">'+_globalize.default.translate("AlwaysPlaySubtitles")+"</option>")+'<option value="None" data-description="'+_globalize.default.translate("NoSubtitlesHelp")+'">'+_globalize.default.translate("NoSubtitles")+"</option>",view.querySelector(".selectSubtitlePlaybackMode").innerHTML=html}(view,this.getApiClient()),view.querySelector("form").addEventListener("submit",function(e){return e.preventDefault(),!1}.bind(this)),view.querySelector(".btnClearTrackSelections").addEventListener("click",onClearSavedTrackSelectionsClick.bind(this)),view.querySelector(".selectSubtitleLanguage").getItems=function(query){var instance=this;return this.getApiClient().getCultures().then(function(cultures){var selectedValues=instance.view.querySelector(".selectSubtitleLanguage").values;Array.isArray(selectedValues)||(selectedValues=null!=selectedValues&&selectedValues.split?selectedValues.split(","):[]);(items=cultures.map(function(c){return{Name:c.DisplayName,Id:c.TwoLetterISOLanguageName,Type:"GenericListItem",CanReorder:-1!==selectedValues.indexOf(c.TwoLetterISOLanguageName)&&1<selectedValues.length}})).sort(function(a,b){a=selectedValues.indexOf(a.Id),b=selectedValues.indexOf(b.Id);return(a=a<0?items.length:a)===(b=b<0?items.length:b)?0:a<b?-1:1});var cultures=items.length,items=items.slice(query.StartIndex||0);return null!=query.Limit&&items.length>query.Limit&&(items.length=Math.min(items.length,query.Limit)),{TotalRecordCount:cultures,Items:items}})}.bind(this)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(View.prototype,_basesettingsview.default.prototype),View.prototype.loadSettingsInternal=function(){var instance=this;return function(instance){var context=instance.view,subtitleAppearanceEditor=new _subtitleappearanceeditor.default({settingsContainer:instance});return(instance.subtitleAppearanceEditor=subtitleAppearanceEditor).embed(context.querySelector(".fieldsetSubtitles"),"afterend").then(function(){_loading.default.hide()})}(instance).then(function(){return instance.loadAutoSettings().then(function(){instance.subtitleAppearanceEditor.bindEvents()})})},View.prototype.getUserConfigurationUserId=function(){return this.params.userId||this.getApiClient().getCurrentUserId()},View.prototype.destroy=function(){_basesettingsview.default.prototype.destroy.apply(this,arguments);var subtitleAppearanceEditor=this.subtitleAppearanceEditor;subtitleAppearanceEditor&&(subtitleAppearanceEditor.destroy(),this.subtitleAppearanceEditor=null)};_exports.default=View});