define(["exports","./../modules/common/globalize.js","./../modules/common/subtitleappearancehelper.js","./../modules/emby-apiclient/events.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,_globalize,_subtitleappearancehelper,_events,_embySelect,_embyButton,_embyInput,_embyToggle){function numberToPercentString(value){try{return new Intl.NumberFormat(_globalize.default.getCurrentLocales(),{style:"percent"}).format(value/100)}catch(err){return console.log("Error in NumberFormat: "+err),value+"%"}}function onUserSettingsChange(e,name){var appearanceSettings;"localplayersubtitleappearance3"===name&&(name={window:(name=this.view).querySelector(".subtitleappearance-preview-window"),text:name.querySelector(".subtitleappearance-preview-text")},appearanceSettings=this.options.settingsContainer.getNamedSettingsOwner("usersettings").getSubtitleAppearanceSettings(),_subtitleappearancehelper.default.applyStyles(name,appearanceSettings))}function SubtitleAppearanceEditor(options){this.options=options}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!settings/subtitles.css"]),SubtitleAppearanceEditor.prototype.embed=function(context,position){var instance=this;return require(["text!./settings/subtitleappearanceeditor.template.html"]).then(function(responses){context.insertAdjacentHTML(position,_globalize.default.translateDocument(responses[0])),context=context.parentNode.querySelector(".fieldsetSubtitleAppearance");var options,responses=(instance.view=context).querySelector(".selectVerticalPosition");responses=responses,(options=[{name:numberToPercentString(90),value:90},{name:numberToPercentString(80),value:80},{name:numberToPercentString(70),value:70},{name:numberToPercentString(60),value:60},{name:numberToPercentString(50),value:50},{name:numberToPercentString(40),value:40},{name:numberToPercentString(30),value:30},{name:numberToPercentString(20),value:20},{name:numberToPercentString(10),value:10},{name:_globalize.default.translate("Bottom"),value:0}]).reverse(),responses.innerHTML=options.map(function(o){return'<option value="'+o.value+'">'+o.name+"</option>"}).join(""),context.addEventListener("change",function(e){onUserSettingsChange.call(this,{},"localplayersubtitleappearance3");var form=e.target.closest(".fieldsetSubtitleAppearance");(e=e.target.closest(".selectBackgroundColor"))&&("transparent"===e.value?form.querySelector(".fldBackgroundOpacity").classList.add("hide"):form.querySelector(".fldBackgroundOpacity").classList.remove("hide"))}.bind(instance)),!1!==instance.options.preview&&context.querySelector(".previewContainer").classList.remove("hide"),!1!==instance.options.title&&context.querySelector(".appearanceTitle").classList.remove("hide")})},SubtitleAppearanceEditor.prototype.bindEvents=function(){this.boundOnUserSettingsChange||(this.boundOnUserSettingsChange=onUserSettingsChange.bind(this),_events.default.on(this.options.settingsContainer.getNamedSettingsOwner("usersettings"),"change",this.boundOnUserSettingsChange))},SubtitleAppearanceEditor.prototype.destroy=function(){var boundOnUserSettingsChange=this.boundOnUserSettingsChange;boundOnUserSettingsChange&&(_events.default.off(this.options.settingsContainer.getNamedSettingsOwner("usersettings"),"change",boundOnUserSettingsChange),this.boundOnUserSettingsChange=null),this.options=null,this.view=null};_exports.default=SubtitleAppearanceEditor});