define(["exports","./../modules/listview/listview.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../modules/focusmanager.js"],function(_exports,_listview,_embyScroller,_embyItemscontainer,_focusmanager){function ChaptersRenderer(options){options=(this.options=options).parent,function(parent){parent.insertAdjacentHTML("afterbegin",'<div is="emby-scroller" class="flex flex-grow osdChapters-scroller osdChapers flex-direction-column hide osdContentSection osdContentSection-split osd-autofadesection padded-left padded-right" data-contentsection="chapters" data-mousewheel="true" data-horizontal="false" data-forcescrollbar="true" data-focusscroll="true"><div class="scrollSlider osdChapters-scrollSlider flex-grow flex-direction-column"><div is="emby-itemscontainer" class="flex-grow flex-direction-column vertical-list itemsContainer osdChaptersItemsContainer" data-virtualscrolllayout="vertical-grid"></div></div></div>'),parent.querySelector(".osdChapers")}(options),options=options.querySelector(".osdChaptersItemsContainer");options.fetchData=function(query){return this.getItemsInternal().then(function(items){var totalRecordCount=items.length;return{TotalRecordCount:totalRecordCount,Items:items}})}.bind(this),options.virtualChunkSize=30,options.getListOptions=function(items){return{renderer:_listview.default,options:{action:"seektoposition",playAction:"seektoposition",multiSelect:!1,contextMenu:!1,imagePlayButton:!0,mediaInfo:!1,enableSideMediaInfo:!1,enableUserDataButtons:!1,fields:["Name","ChapterTime"],moreButton:!1,highlight:!1,draggable:!1,draggableXActions:!1},virtualScrollLayout:"vertical-grid"}}.bind(this),this.itemsContainer=options,this.currentIndex=-1}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,ChaptersRenderer.prototype.getItemsInternal=function(){return Promise.resolve(this.currentChapters||[])},ChaptersRenderer.prototype.onPlaybackStopped=function(){},ChaptersRenderer.prototype.pause=function(){this.paused=!0,this.itemsContainer&&this.itemsContainer.pause&&this.itemsContainer.pause()},ChaptersRenderer.prototype.focus=function(){this.selectedElement&&_focusmanager.default.focus(this.selectedElement)},ChaptersRenderer.prototype.resume=function(options){this.paused=!1,this.itemsContainer.resume?this.itemsContainer.resume():this.itemsContainer.addEventListener("upgraded",function(e){e.target.resume(this)}.bind(options)),null!=this.currentTime&&this.onTimeUpdate(this.currentTime)},ChaptersRenderer.prototype.refreshEvents=function(events){this.itemsContainer.refreshItems()},ChaptersRenderer.prototype.updateItem=function(item,chapters){var changed=this.currentItem!==item;this.currentItem=item,this.currentChapters=chapters,changed&&this.itemsContainer.notifyRefreshNeeded(!0)},ChaptersRenderer.prototype.onTimeUpdate=function(positionTicks,runtimeTicks){this.currentTime=positionTicks,this.paused||this.itemsContainer},ChaptersRenderer.prototype.destroy=function(){var options=this.options;options&&(options=options.parent)&&(options.innerHTML="",options.classList.add("hide")),this.currentItem=null,this.currentChapters=null,this.currentTime=null,this.paused=null,this.options=null,this.itemsContainer=null,this.currentIndex=null,this.selectedElement=null};_exports.default=ChaptersRenderer});