define(["exports","./../modules/emby-apiclient/connectionmanager.js","./../modules/tabbedview/basetab.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/common/globalize.js","./../modules/common/datetime.js","./../modules/tabbedview/sectionscontroller.js"],function(_exports,_connectionmanager,_basetab,_embyItemscontainer,_embyScroller,_globalize,_datetime,_sectionscontroller){function UpcomingTab(view,params){_basetab.default.apply(this,arguments),_sectionscontroller.default.apply(this,arguments),this.view=view,this.params=params,this.apiClient=_connectionmanager.default.getApiClient(params.serverId)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(UpcomingTab.prototype,_basetab.default.prototype),Object.assign(UpcomingTab.prototype,_sectionscontroller.default.prototype),UpcomingTab.prototype.fetchSections=function(){var instance=this,enableFocusPreview=instance.enableFocusPreview(),parentId=this.params.parentId,apiClient=this.getApiClient();return apiClient.getUpcomingEpisodes({Limit:100,UserId:apiClient.getCurrentUserId(),ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Thumb",EnableTotalRecordCount:!1,parentId:parentId,Fields:"Overview"}).then(function(result){for(var sections=[],currentGroupName="",currentGroup=[],items=result.Items,parentId=instance.params.parentId,i=0,length=items.length;i<length;i++){var item=items[i],dateText="";if(item.PremiereDate)try{var premiereDate=new Date(Date.parse(item.PremiereDate)),dateText=_datetime.default.isRelativeDay(premiereDate,-1)?_globalize.default.translate("Yesterday"):_datetime.default.toLocaleDateString(premiereDate,{weekday:"long",month:"short",day:"numeric"})}catch(err){dateText=item.PremiereDate}dateText!==currentGroupName?(currentGroup.length&&sections.push({Name:currentGroupName,CollectionType:"tvshows",Monitor:[],ListOptions:{fields:enableFocusPreview?[]:["ParentName","Name"],preferThumb:!0,action:"overview"},QueryOptions:{ParentId:parentId,Recursive:!0},Items:currentGroup}),currentGroupName=dateText,currentGroup=[item]):currentGroup.push(item)}return sections})},UpcomingTab.prototype.onResume=function(options){return _basetab.default.prototype.onResume.apply(this,arguments),_sectionscontroller.default.prototype.onResume.apply(this,arguments)},UpcomingTab.prototype.onPause=function(){_basetab.default.prototype.onPause.apply(this,arguments),_sectionscontroller.default.prototype.onPause.apply(this,arguments)},UpcomingTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),_sectionscontroller.default.prototype.destroy.apply(this,arguments)};_exports.default=UpcomingTab});