define(["loading","dialogHelper","dom","jQuery","components/libraryoptionseditor/libraryoptionseditor","emby-input","emby-select","paper-icon-button-light","listViewStyle","formDialogStyle","emby-linkbutton"],function(loading,dialogHelper,dom,$,libraryoptionseditor){"use strict";function onSubmit(e){if(e.preventDefault(),e.stopPropagation(),0==pathInfos.length)return require(["alert"],function(alert){alert({text:Globalize.translate("PleaseAddAtLeastOneFolder"),type:"error"})}),!1;var form=this,dlg=$(form).parents(".dialog")[0],name=$("#txtValue",form).val(),type=$("#selectCollectionType",form).val();"mixed"==type&&(type=null);var libraryOptions=libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));return libraryOptions.PathInfos=pathInfos,ApiClient.addVirtualFolder(name,type,currentOptions.refresh,libraryOptions).then(function(){hasChanges=!0,dialogHelper.close(dlg)},function(){require(["toast"],function(toast){toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))})}),!1}function getCollectionTypeOptionsHtml(collectionTypeOptions){return collectionTypeOptions.filter(function(i){return i.isSelectable!==!1}).map(function(i){return'"}).join("")}function initEditor(page,collectionTypeOptions){$("#selectCollectionType",page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val("").on("change",function(){var value=this.value,dlg=$(this).parents(".dialog")[0];if(libraryoptionseditor.setContentType(dlg.querySelector(".libraryOptions"),"mixed"==value?"":value),value?dlg.querySelector(".libraryOptions").classList.remove("hide"):dlg.querySelector(".libraryOptions").classList.add("hide"),"mixed"!=value){var index=this.selectedIndex;if(index!=-1){var name=this.options[index].innerHTML.replace("*","").replace("&","&");$("#txtValue",dlg).val(name);var folderOption=collectionTypeOptions.filter(function(i){return i.value==value})[0];$(".collectionTypeFieldDescription",dlg).html(folderOption.message||"")}}}),page.querySelector(".btnAddFolder").addEventListener("click",onAddButtonClick),page.querySelector("form").addEventListener("submit",onSubmit),page.querySelector(".folderList").addEventListener("click",onRemoveClick)}function onAddButtonClick(){var page=dom.parentWithClass(this,"dlg-librarycreator");require(["directorybrowser"],function(directoryBrowser){var picker=new directoryBrowser;picker.show({enableNetworkSharePath:!0,callback:function(path,networkSharePath){path&&addMediaLocation(page,path,networkSharePath),picker.close()}})})}function getFolderHtml(pathInfo,index){var html="";html+='