define(["exports","./basetab.js","./../modules/cardbuilder/cardbuilder.js","./../modules/common/usersettings/usersettings.js","./../modules/common/globalize.js","./../modules/layoutmanager.js","./../modules/focusmanager.js"],function(_exports,_basetab,_cardbuilder,_usersettings,_globalize,_layoutmanager,_focusmanager){function OnNowTab(view){_basetab.default.apply(this,arguments)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(OnNowTab.prototype,_basetab.default.prototype);OnNowTab.prototype.loadTemplate=function(){var view=this.view;return view.innerHTML='\n                    <div is="emby-scroller" data-mousewheel="false" data-focusscroll="start" data-focusscrolloffset="-padding-inline-start" 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 apiClient=this.apiClient;return query=Object.assign({UserId:apiClient.getCurrentUserId(),IsAiring:!0,ImageTypeLimit:1,EnableImageTypes:"Primary,Thumb,Backdrop",Fields:"ProgramPrimaryImageAspectRatio",EnableUserData:!1,SortBy:"ChannelNumber,SortName"},query),_usersettings.default.addLiveTvChannelSortingToQuery(query,_globalize.default),apiClient.getLiveTvChannels(query)}.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,programsAsSeries:!1,showCurrentProgramImage:!0,defaultShape:"portrait",action:"play",cardClass:"videoOsd-itemstab-card videoOsd-itemstab-card-threeline",fields:["CurrentProgramName","CurrentProgramParentName","CurrentProgramTime"],allowBottomPadding:!1,defaultBackground:!0,textLinks:!1,enableFocusScaling:!1},virtualScrollLayout:"horizontal-grid"}}.bind(this),Promise.resolve()},OnNowTab.prototype.scrollToCurrentItem=function(focus){this.paused||this.itemsContainer.contains(document.activeElement)||(focus?_focusmanager.default.focus(this.itemsContainer):function(instance,focus){instance.itemsContainer.scrollToIndex(instance.getCurrentIndex(),{offset:"-padding-inline-start"},focus)}(this,focus))},OnNowTab.prototype.getCurrentIndex=function(){return 0},OnNowTab.prototype.onResume=function(options){var instance=this;return _basetab.default.prototype.onResume.apply(this,arguments).then(function(){var hasFocus=instance.itemsContainer.contains(document.activeElement);return instance.itemsContainer.resume(options).then(function(){instance.scrollToCurrentItem(hasFocus)})})},OnNowTab.prototype.onItemUpdated=function(options){var instance,hasFocus;if(_basetab.default.prototype.onItemUpdated.apply(this,arguments),!this.paused)return hasFocus=(instance=this).itemsContainer.contains(document.activeElement),instance.itemsContainer.refreshItems().then(function(){instance.scrollToCurrentItem(hasFocus)})},OnNowTab.prototype.onPause=function(){_basetab.default.prototype.onPause.apply(this,arguments),this.itemsContainer.pause()},OnNowTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),this.itemsContainer=null},_exports.default=OnNowTab});