define(["exports","./../modules/common/playback/playbackmanager.js","./../modules/layoutmanager.js","./../modules/listview/listview.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-elements/emby-button/paper-icon-button-light.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js"],function(_exports,_playbackmanager,_layoutmanager,_listview,_embyScroller,_paperIconButtonLight,_embyItemscontainer){function OsdPlayQueue(options){(this.options=options).parent=function(parent){return parent.insertAdjacentHTML("afterbegin",'<div is="emby-scroller" class="osdPlayQueue flex flex-grow osdPlaylist-scroller osdPlaylist flex-direction-column hide osdContentSection osdContentSection-split osdPlayQueue-autosmall padded-left padded-right" data-contentsection="playqueue" data-mousewheel="true" data-horizontal="false" data-forcescrollbar="true" data-focusscroll="true"><div class="scrollSlider osdPlaylist-scrollSlider flex-grow flex-direction-column"><div is="emby-itemscontainer" class="flex-grow flex-direction-column vertical-list itemsContainer osdPlaylistItemsContainer" data-skipplaycommands="true" data-dragreorder="true" data-virtualscrolllayout="vertical-grid"></div></div></div>'),parent.querySelector(".osdPlayQueue")}(options.parent);var parent=options.parent;this.playlistElement=options.parent,this.itemsContainer=parent.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.afterRefresh=function(){this.setScrollToTrack=!0,this.scrollToTrack&&(this.scrollToTrack=null,this.scrollCurrentTrackToTop())}.bind(this),this.itemsContainer.getListOptions=function(items){return{renderer:_listview.default,options:{smallIcon:!0,action:"setplaylistindex",playAction:"setplaylistindex",fields:["Name","ParentName"],enableUserDataButtons:!1,moreButton:!1,removeFromPlayQueueButton:!0,dragReorder:!_layoutmanager.default.tv,playQueueIndicator:!0,autoHideBorderOnTouch:!0,hideMoreButtonOnTouch:!0,autoMoveParentName:!0,buttonCommands:["removefromplayqueue"]},virtualScrollLayout:"vertical-list"}}.bind(this),this.itemsContainer.scrollResizeObserver=!0,this.itemsContainer.addEventListener("itemdrop",function(e){e.preventDefault();var newIndex=e.detail.newIndex,e=e.detail.items[0].PlaylistItemId;_playbackmanager.default.movePlaylistItem(e,newIndex,this.currentPlayer)}.bind(this))}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!videoosd/playqueue.css"]),OsdPlayQueue.prototype.scrollCurrentTrackToTop=function(){var itemsContainer,index=_playbackmanager.default.getCurrentPlaylistIndex(this.currentPlayer);-1!==index&&(itemsContainer=this.playlistElement.querySelector(".itemsContainer"))&&itemsContainer.scrollToIndex(index,{behavior:"instant",skipWhenVisibleY:!0},!1)},OsdPlayQueue.prototype.setPausedState=function(paused){var elem=this.playlistElement.querySelector(".playlistIndexIndicatorImage");elem&&(paused?elem.classList.add("playlistIndexIndicatorImage-paused"):elem.classList.remove("playlistIndexIndicatorImage-paused"))},OsdPlayQueue.prototype.updatePlaylist=function(player,playlistItemId,playlistIndex,playlistLength){this.currentPlayer=player,!1!==this.setScrollToTrack&&(this.scrollToTrack=!0),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,this.playlistElement=null};_exports.default=OsdPlayQueue});