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"],function(_exports,_basesettingsview,_loading,_globalize,_embyScroller,_embySelect,_embyButton,_embyInput,_embyToggle){function fillSkipLengths(select){var formatter=new Intl.DurationFormat(_globalize.default.getCurrentLocales(),{style:"long"});select.innerHTML=[5,10,15,20,25,30].map(function(option){return{name:formatter.format({seconds:option}),value:1e3*option}}).map(function(o){return'<option value="'+o.value+'">'+o.name+"</option>"}).join("")}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(){return _loading.default.show(),instance.getApiClient().clearUserTrackSelections(instance.getUserConfigurationUserId(),mode).then(onTrackSelectionsCleared,onTrackSelectionsCleared)})}function View(view,params){var select,formatter;_basesettingsview.default.apply(this,arguments),view.querySelector("form").addEventListener("submit",function(e){return e.preventDefault(),!1}.bind(this)),view.querySelector(".btnClearTrackSelections").addEventListener("click",onClearSavedTrackSelectionsClick.bind(this)),select=view.querySelector(".selectResumeRewind"),formatter=new Intl.DurationFormat(_globalize.default.getCurrentLocales(),{style:"long"}),select.innerHTML=[0,5,10,15,20].map(function(option){return{name:formatter.format({seconds:option}),value:option}}).map(function(o){return'<option value="'+o.value+'">'+o.name+"</option>"}).join(""),fillSkipLengths(view.querySelector(".selectSkipForwardLength")),fillSkipLengths(view.querySelector(".selectSkipBackLength")),view.querySelector(".selectAudioLanguage").getItems=function(query){var instance=this;return instance.getApiClient().getCultures().then(function(cultures){var selectedValues=instance.view.querySelector(".selectAudioLanguage").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(){return this.loadAutoSettings()},View.prototype.getUserConfigurationUserId=function(){return this.params.userId||this.getApiClient().getCurrentUserId()};_exports.default=View});