define(["tabbedView","registrationServices","require","globalize","userSettings","emby-itemscontainer","emby-tabs","emby-button","emby-scroller","emby-linkbutton"],function(TabbedView,registrationServices,require,globalize,userSettings){"use strict";function getDefaultTabIndex(folderId){switch(userSettings.get("landing-livetv")){case"channels":return 2;case"guide":return 1;default:return 0}}function getTabs(){return[{name:globalize.translate("Programs")},{name:globalize.translate("Guide")},{name:globalize.translate("Channels")},{name:globalize.translate("Recordings")},{name:globalize.translate("Schedule")},{name:globalize.translate("Series")}]}function getRequirePromise(deps){return new Promise(function(resolve,reject){require(deps,resolve)})}function getTabController(index){if(null==index)throw new Error("index cannot be null");var depends=[];switch(index){case 0:depends.push("./suggestions");break;case 1:depends.push("./guide");break;case 2:depends.push("./channels");break;case 3:depends.push("./recordings");break;case 4:depends.push("./schedule");break;case 5:depends.push("./series")}var instance=this;return getRequirePromise(depends).then(function(controllerFactory){var controller=instance.tabControllers[index];if(!controller){controller=new controllerFactory(instance.view.querySelector(".tabContent[data-index='"+index+"']"),instance.params),instance.tabControllers[index]=controller}return controller})}function hideShowAll(view,className,hide){for(var elems=view.querySelectorAll("."+className),i=0,length=elems.length;i<length;i++)hide?elems[i].classList.add("hide"):elems[i].classList.remove("hide")}function validateUnlock(view,showDialog){return registrationServices.validateFeature("livetv",{showDialog:showDialog,viewOnly:!0}).then(function(){hideShowAll(view,"liveTvContainer",!1),view.querySelector(".unlockContainer").classList.add("hide")},function(){hideShowAll(view,"liveTvContainer",!0),view.querySelector(".unlockContainer").classList.remove("hide"),view.querySelector(".btnUnlock").focus()})}function validateTabLoad(index){return validateUnlock(this.view,!1)}function LiveTVView(view,params){TabbedView.call(this,view,params),view.querySelector(".unlockText").innerHTML=globalize.translate("sharedcomponents#LiveTvRequiresUnlock"),view.querySelector(".btnUnlockText").innerHTML=globalize.translate("sharedcomponents#HeaderBecomeProjectSupporter"),validateUnlock(view,!1),view.querySelector(".btnUnlock").addEventListener("click",function(){validateUnlock(view,!0)})}return Object.assign(LiveTVView.prototype,TabbedView.prototype),LiveTVView.prototype.getTabs=getTabs,LiveTVView.prototype.getDefaultTabIndex=getDefaultTabIndex,LiveTVView.prototype.getTabController=getTabController,LiveTVView.prototype.validateTabLoad=validateTabLoad,LiveTVView.prototype.getTitle=function(){return globalize.translate("HeaderLiveTV")},LiveTVView});