define(["components/categorysyncbuttons","cardBuilder","apphost","imageLoader","scripts/livetvcomponents","emby-button","listViewStyle","emby-itemscontainer"],function(categorysyncbuttons,cardBuilder,appHost,imageLoader){"use strict";function getRecordingGroupHtml(group){var html="";return html+='
',html+='',html+='
',html+='',html+="
",html+=group.Name,html+="
",html+='
',html+=1==group.RecordingCount?Globalize.translate("ValueItemCount",group.RecordingCount):Globalize.translate("ValueItemCountPlural",group.RecordingCount),html+="
",html+="
",html+="
",html+="
"}function renderRecordingGroups(context,groups){groups.length?context.querySelector("#recordingGroups").classList.remove("hide"):context.querySelector("#recordingGroups").classList.add("hide");var html="";html+='
';for(var i=0,length=groups.length;i",context.querySelector("#recordingGroupItems").innerHTML=html,Dashboard.hideLoadingMsg()}function enableScrollX(){return browserInfo.mobile}function renderRecordings(elem,recordings,cardOptions){recordings.length?elem.classList.remove("hide"):elem.classList.add("hide");var recordingItems=elem.querySelector(".recordingItems");enableScrollX()?(recordingItems.classList.add("hiddenScrollX"),recordingItems.classList.remove("vertical-wrap")):(recordingItems.classList.remove("hiddenScrollX"),recordingItems.classList.add("vertical-wrap"));var supportsImageAnalysis=appHost.supports("imageanalysis"),cardLayout=appHost.preferVisualCards||supportsImageAnalysis;recordingItems.innerHTML=cardBuilder.getCardsHtml(Object.assign({items:recordings,shape:enableScrollX()?"autooverflow":"auto",showTitle:!0,showParentTitle:!0,coverImage:!0,lazy:!0,cardLayout:cardLayout,centerText:!cardLayout,vibrant:supportsImageAnalysis,allowBottomPadding:!enableScrollX(),preferThumb:"auto",overlayText:!1},cardOptions||{})),imageLoader.lazyChildren(recordingItems)}function getBackdropShape(){return enableScrollX()?"overflowBackdrop":"backdrop"}function renderActiveRecordings(context,promise){promise.then(function(result){result.Items.length&&"InProgress"!=result.Items[0].Status&&(result.Items=[]),renderRecordings(context.querySelector("#activeRecordings"),result.Items,{shape:getBackdropShape(),showParentTitle:!1,showTitle:!0,showAirTime:!0,showAirEndTime:!0,showChannelName:!0,cardLayout:!0,vibrant:!0,preferThumb:!0,coverImage:!0})})}function renderLatestRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#latestRecordings"),result.Items,{shape:enableScrollX()?"overflowBackdrop":"backdrop",showYear:!0,lines:2}),Dashboard.hideLoadingMsg()})}function renderMovieRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#movieRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderEpisodeRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#episodeRecordings"),result.Items,{showSeriesYear:!0,showParentTitle:!1})})}function renderSportsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#sportsRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderKidsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#kidsRecordings"),result.Items,{shape:enableScrollX()?"overflowBackdrop":"backdrop",showYear:!0,lines:2})})}function onMoreClick(e){var type=this.getAttribute("data-type");switch(type){case"latest":Dashboard.navigate("livetvitems.html?type=Recordings");break;case"movies":Dashboard.navigate("livetvitems.html?type=Recordings&IsMovie=true");break;case"episodes":Dashboard.navigate("livetvitems.html?type=RecordingSeries");break;case"programs":Dashboard.navigate("livetvitems.html?type=Recordings&IsSeries=false&IsMovie=false");break;case"kids":Dashboard.navigate("livetvitems.html?type=Recordings&IsKids=true");break;case"sports":Dashboard.navigate("livetvitems.html?type=Recordings&IsSports=true")}}return function(view,params,tabContent){function enableFullRender(){return(new Date).getTime()-lastFullRender>3e5}var activeRecordingsPromise,sportsPromise,kidsPromise,moviesPromise,seriesPromise,latestPromise,self=this,lastFullRender=0;categorysyncbuttons.init(tabContent);for(var moreButtons=tabContent.querySelectorAll(".more"),i=0,length=moreButtons.length;i