define(["appSettings","events","globalize","loading","connectionManager","cameraUpload","emby-checkbox","emby-scroller","indicators"],function(appSettings,events,globalize,loading,connectionManager,cameraUpload){"use strict";function saveUser(page){for(var chkUploadServer=page.querySelectorAll(".chkUploadServer"),cameraUploadServers=[],i=0,length=chkUploadServer.length;i<length;i++)chkUploadServer[i].checked&&cameraUploadServers.push(chkUploadServer[i].getAttribute("data-id"));appSettings.cameraUploadServers(cameraUploadServers),appSettings.cameraUploadOnlyOnWifi(page.querySelector("#chkWifi").checked),loading.hide()}return function(view,params){var progressContainer=view.querySelector(".progressContainer"),itemProgressBarForeground=view.querySelector(".itemProgressBarForeground"),progressDescription=view.querySelector(".progressDescription");function onUploadProgress(e,progressInfo){var numItems=progressInfo.numItems||0,numItemsComplete=progressInfo.numItemsComplete||0,pctComplete=progressInfo.totalPercentComplete||0;itemProgressBarForeground.style.width=pctComplete+"%",progressDescription.innerHTML=globalize.translate("UploadingNumItems",numItemsComplete+1,numItems),numItems&&pctComplete<100?progressContainer.classList.remove("hide"):progressContainer.classList.add("hide")}view.querySelector(".premiereInfo").innerHTML=globalize.translate("FeatureRequiresEmbyPremiere",'<a href="#" data-preset="premiereinfo" is="emby-linkbutton" type="button" class="button-link">',"</a>"),view.querySelector("form").addEventListener("submit",function(e){return loading.show(),saveUser(view),e.preventDefault(),!1}),view.addEventListener("viewshow",function(){!function(page){var uploadServers=appSettings.cameraUploadServers();page.querySelector("#chkWifi").checked=appSettings.cameraUploadOnlyOnWifi(),page.querySelector(".uploadServerList").innerHTML=connectionManager.getSavedServers().map(function(s){return'<label><input type="checkbox" is="emby-checkbox"'+(-1===uploadServers.indexOf(s.Id)?"":" checked")+' class="chkUploadServer" data-id="'+s.Id+'"/><span>'+s.Name+"</span></label>"}).join("")}(this),cameraUpload.start(),events.on(cameraUpload,"progress",onUploadProgress),cameraUpload.setProgressUpdatesEnabled(!0)}),view.addEventListener("viewbeforehide",function(){saveUser(this),events.off(cameraUpload,"progress",onUploadProgress),cameraUpload.setProgressUpdatesEnabled(!1)})}});