define(["exports","./basetab.js","./../modules/cardbuilder/cardbuilder.js","./../modules/layoutmanager.js","./../modules/common/playback/playbackmanager.js"],function(_exports,_basetab,_cardbuilder,_layoutmanager,_playbackmanager){function PlayQueueTab(view){_basetab.default.apply(this,arguments)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(PlayQueueTab.prototype,_basetab.default.prototype);var FocusScrollOffset="-padding-inline-start";function scrollToCurrent(instance,focus,scrollBehavior){var _instance$currentOpti=null==(_instance$currentOpti=instance.currentOptions)?void 0:_instance$currentOpti.currentPlayer;!function(instance,index,focus,scrollBehavior){instance.itemsContainer.scrollToIndex(index,{offsetLeft:FocusScrollOffset,behavior:scrollBehavior},focus)}(instance,_playbackmanager.default.getCurrentPlaylistIndex(_instance$currentOpti),focus,scrollBehavior)}PlayQueueTab.prototype.loadTemplate=function(){var view=this.view;return view.innerHTML='\n                    <div is="emby-scroller" data-mousewheel="false" data-focusscroll="start" data-focusscrolloffset="'+FocusScrollOffset+'" class="padded-top-focusscale padded-bottom-focusscale">\n                        <div is="emby-itemscontainer" data-focusabletype="nearest" class="focusable focuscontainer-x scrollSlider itemsContainer videoosd-padded-left videoosd-padded-right" data-refreshinterval="300000" data-virtualscrolllayout="horizontal-grid"></div>\n                    </div>\n',this.itemsContainer=view.querySelector(".itemsContainer"),this.itemsContainer.fetchData=function(query){var _this$currentOptions=null==(_this$currentOptions=this.currentOptions)?void 0:_this$currentOptions.currentPlayer;return _this$currentOptions?_playbackmanager.default.getPlaylist(query||{},_this$currentOptions):Promise.resolve({Items:[],TotalRecordCount:0})}.bind(this),this.itemsContainer.getListOptions=function(items){var forceBackdrop=!!_layoutmanager.default.tv;return{renderer:_cardbuilder.default,options:{preferThumb:forceBackdrop?null:"auto",inheritThumb:!1,shape:forceBackdrop?"backdrop":"auto",overlayPlayButton:!0,contextMenu:!1,multiSelect:!1,action:"setplaylistindex",playAction:"setplaylistindex",cardClass:"videoOsd-itemstab-card videoOsd-itemstab-card-threeline",fields:["ParentName","Name"],allowBottomPadding:!1,defaultBackground:!0,textLinks:!1,enableFocusScaling:!1},virtualScrollLayout:"horizontal-grid"}}.bind(this),Promise.resolve()},PlayQueueTab.prototype.scrollToCurrentItem=function(focus,scrollBehavior){this.paused||this.itemsContainer.contains(document.activeElement)||scrollToCurrent(this,focus,scrollBehavior)},PlayQueueTab.prototype.onResume=function(options){var instance=this;return _basetab.default.prototype.onResume.apply(this,arguments).then(function(){var optionsWithoutRefresh=Object.assign(Object.assign({},options),{refresh:!1}),hasFocus=instance.itemsContainer.contains(document.activeElement);return instance.itemsContainer.resume(optionsWithoutRefresh).then(function(){options.refresh?instance.refreshItem():instance.scrollToCurrentItem(hasFocus,"instant")})})},PlayQueueTab.prototype.refreshItem=function(){_basetab.default.prototype.refreshItem.apply(this,arguments);var instance=this,hasFocus=instance.itemsContainer.contains(document.activeElement);return instance.itemsContainer.refreshItems().then(function(){instance.scrollToCurrentItem(hasFocus)})},PlayQueueTab.prototype.onPause=function(){_basetab.default.prototype.onPause.apply(this,arguments),this.itemsContainer.pause()},PlayQueueTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),this.itemsContainer=null};_exports.default=PlayQueueTab});