define(["exports","./../modules/common/playback/playbackmanager.js","./../modules/cardbuilder/cardbuilder.js"],function(_exports,_playbackmanager,_cardbuilder){function scrollOrFocus(instance,focus){var playlistIndex=_playbackmanager.default.getCurrentPlaylistIndex(instance.currentPlayer);instance.itemsContainer.scrollToIndex(playlistIndex=-1===playlistIndex?0:playlistIndex,{},focus)}function OsdPlayQueue(options){(this.options=options).parent=function(parent){return parent.insertAdjacentHTML("afterbegin",'<div is="emby-scroller" class="osdPlayQueue padded-left padded-right flex flex-grow hide osdContentSection padded-top-focusscale padded-bottom-focusscale tvPlayQueueScroller" data-mousewheel="false" data-focusscroll="center" data-contentsection="playqueue"><div is="emby-itemscontainer" class="scrollSlider focuscontainer-x itemsContainer focusable" data-skipplaycommands="true" data-virtualscrolllayout="horizontal-grid"></div></div>'),parent.querySelector(".tvPlayQueueScroller")}(options.parent);options=options.parent;this.itemsContainer=options.querySelector(".itemsContainer"),this.itemsContainer.fetchData=function(query){var player=this.currentPlayer;return this.empty||!player?Promise.resolve({Items:[],TotalRecordCount:0}):_playbackmanager.default.getPlaylist(query||{},player)}.bind(this),this.itemsContainer.getListOptions=function(items){return{renderer:_cardbuilder.default,options:{action:"setplaylistindex",playAction:"setplaylistindex",shape:"autooverflow",fields:["ParentName","Name","ProductionYear"],lines:2,centerText:!0,cardLayout:!1,cardClass:"tvPlayQueueCard",playQueueIndicator:!0,allowBottomPadding:!1},virtualScrollLayout:"horizontal-grid"}}.bind(this),this.itemsContainer.afterRefresh=function(){var focus=this.itemsContainer.contains(document.activeElement);scrollOrFocus(this,focus)}.bind(this),this.itemsContainer.focus=function(){scrollOrFocus(this,!0)}.bind(this),this.itemsContainer.scrollResizeObserver=!0}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!videoosd/tvplayqueue.css"]),OsdPlayQueue.prototype.setPausedState=function(paused){var elem=this.options.parent.querySelector(".activePlaylistCardBox");elem&&(paused?elem.classList.add("paused"):elem.classList.remove("paused"))},OsdPlayQueue.prototype.updatePlaylist=function(player,playlistItemId,playlistIndex,playlistLength){this.currentPlayer=player,this.empty=!playlistLength,this.refreshItems()},OsdPlayQueue.prototype.onPlaybackStopped=function(){this.empty=!0,this.refreshItems()},OsdPlayQueue.prototype.refreshItems=function(){var itemsContainer=this.itemsContainer;if(itemsContainer)return itemsContainer.waitForCustomElementUpgrade().then(function(){itemsContainer.refreshItems()})},OsdPlayQueue.prototype.onPlaylistItemMoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.onPlaylistItemRemoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.pause=function(){this.paused=!0,this.itemsContainer.pause&&this.itemsContainer.pause()},OsdPlayQueue.prototype.resume=function(options){this.paused=!1;var itemsContainer=this.itemsContainer;return itemsContainer.waitForCustomElementUpgrade().then(function(){itemsContainer.resume(options)})},OsdPlayQueue.prototype.destroy=function(){var options=this.options;options&&(options=options.parent)&&options.remove(),this.options=null,this.currentPlayer=null,this.itemsContainer=null};_exports.default=OsdPlayQueue});