define(["baseView","appHeader","globalize","connectionManager","loading","./tabbedpage","focusManager","layoutManager","browser","dom","require","css!./home"],function(BaseView,appHeader,globalize,connectionManager,loading,tabbedPage,focusManager,layoutManager,browser,dom,require){"use strict";function renderTabs(view,pageInstance){var apiClient=connectionManager.currentApiClient();apiClient.getUserViews({},apiClient.getCurrentUserId()).then(function(result){var tabbedPageInstance=new tabbedPage(view,{handleFocus:!0});tabbedPageInstance.loadViewContent=function(page,id,type){var instance=this;return new Promise(function(resolve,reject){type=(type||"").toLowerCase();var viewName="";switch(type){case"tvshows":viewName="tv";break;case"movies":viewName="movies";break;case"channels":viewName="channels";break;case"music":viewName="music";break;case"playlists":case"boxsets":viewName="generic";break;case"livetv":viewName="livetv";break;default:viewName="generic"}require(["text!./views."+viewName+".html"],function(html){var activeElement;instance.autoFocusTabContent||((activeElement=document.activeElement)&&"BODY"!==activeElement.tagName&&document.body.contains(activeElement)||(instance.autoFocusTabContent=!0)),function(page,parentId,html,viewName,autoFocus,instance){var homeScrollContent=page.querySelector(".contentScrollSlider");homeScrollContent.innerHTML=globalize.translateDocument(html),require(["./views."+viewName],function(viewBuilder){var homePanel=homeScrollContent,tabView=new viewBuilder(homePanel,connectionManager.currentApiClient(),parentId);tabView.element=homePanel,tabView.resume({refresh:!0,autoFocus:autoFocus}),instance.tabView=tabView})}(page,id,html,viewName,instance.autoFocusTabContent,instance),instance.autoFocusTabContent=!1,resolve()})})}.bind(pageInstance),tabbedPageInstance.renderTabs(result.Items),pageInstance.tabbedPage=tabbedPageInstance})}function HomeView(view,params){BaseView.apply(this,arguments),this.autoFocusTabContent=!0}return Object.assign(HomeView.prototype,BaseView.prototype),HomeView.prototype.onResume=function(options){appHeader.setTitle(""),BaseView.prototype.onResume.apply(this,arguments),this.tabView?this.tabView.resume(options):renderTabs(this.view,this)},HomeView.prototype.onPause=function(){BaseView.prototype.onPause.apply(this,arguments),this.tabView&&this.tabView.pause()},HomeView.prototype.destroy=function(){BaseView.prototype.destroy.apply(this,arguments),this.tabbedPage&&(this.tabbedPage.destroy(),this.tabbedPage=null),this.tabView&&(this.tabView.destroy(),this.tabView=null)},HomeView});