define(["listView","cardBuilder","imageLoader","libraryBrowser","emby-itemscontainer"],function(listView,cardBuilder,imageLoader,libraryBrowser){"use strict";function renderItems(page,item){var sections=[];item.ArtistCount&§ions.push({name:Globalize.translate("TabArtists"),type:"MusicArtist"}),item.ProgramCount&&"Person"==item.Type&§ions.push({name:Globalize.translate("HeaderUpcomingOnTV"),type:"Program"}),item.MovieCount&§ions.push({name:Globalize.translate("TabMovies"),type:"Movie"}),item.SeriesCount&§ions.push({name:Globalize.translate("TabShows"),type:"Series"}),item.EpisodeCount&§ions.push({name:Globalize.translate("TabEpisodes"),type:"Episode"}),item.TrailerCount&§ions.push({name:Globalize.translate("TabTrailers"),type:"Trailer"}),item.GameCount&§ions.push({name:Globalize.translate("TabGames"),type:"Game"}),item.AlbumCount&§ions.push({name:Globalize.translate("TabAlbums"),type:"MusicAlbum"}),item.SongCount&§ions.push({name:Globalize.translate("TabSongs"),type:"Audio"}),item.MusicVideoCount&§ions.push({name:Globalize.translate("TabMusicVideos"),type:"MusicVideo"});var elem=page.querySelector("#childrenContent");elem.innerHTML=sections.map(function(section){var html="";return html+='
',html+='
',html+='

',html+=section.name,html+="

",html+='",html+="
",html+='
',html+="
",html+="
"}).join("");for(var sectionElems=elem.querySelectorAll(".verticalSection"),i=0,length=sectionElems.length;iquery.Limit){var link=element.querySelector("a");link.classList.remove("hide"),link.setAttribute("href",getMoreItemsHref(item,type))}else element.querySelector("a").classList.add("hide");listOptions.items=result.Items;var itemsContainer=element.querySelector(".itemsContainer");"Audio"==type?(html=listView.getListViewHtml(listOptions),itemsContainer.classList.remove("vertical-wrap"),itemsContainer.classList.add("vertical-list")):(html=cardBuilder.getCardsHtml(listOptions),itemsContainer.classList.add("vertical-wrap"),itemsContainer.classList.remove("vertical-list")),itemsContainer.innerHTML=html,imageLoader.lazyChildren(itemsContainer)})}function getMoreItemsHref(item,type){return"Genre"==item.Type||"MusicGenre"==item.Type||"GameGenre"==item.Type?"secondaryitems.html?type="+type+"&genreId="+item.Id:"Studio"==item.Type?"secondaryitems.html?type="+type+"&studioId="+item.Id:"MusicArtist"==item.Type?"secondaryitems.html?type="+type+"&artistId="+item.Id:"Person"==item.Type?"secondaryitems.html?type="+type+"&personId="+item.Id:"secondaryitems.html?type="+type+"&parentId="+item.Id}function addCurrentItemToQuery(query,item){"Person"==item.Type?query.PersonIds=item.Id:"Genre"==item.Type?query.Genres=item.Name:"MusicGenre"==item.Type?query.Genres=item.Name:"GameGenre"==item.Type?query.Genres=item.Name:"Studio"==item.Type?query.StudioIds=item.Id:"MusicArtist"==item.Type&&(query.ArtistIds=item.Id,query.SortBy="ProductionYear,SortName")}function getQuery(options,item){var query={SortBy:"SortName",SortOrder:"Ascending",IncludeItemTypes:"",Recursive:!0,Fields:"AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo",Limit:libraryBrowser.getDefaultPageSize(),StartIndex:0,CollapseBoxSetItems:!1};return query=Object.assign(query,options||{}),addCurrentItemToQuery(query,item),"Audio"==query.IncludeItemTypes&&(query.SortBy="AlbumArtist,Album,SortName"),query}function getItemsFunction(options,item){var query=getQuery(options,item);return function(index,limit,fields){return query.StartIndex=index,query.Limit=limit,fields&&(query.Fields+=","+fields),ApiClient.getItems(Dashboard.getCurrentUserId(),query)}}window.ItemsByName={renderItems:renderItems}});