import layoutManager from"./../../layoutmanager.js";import globalize from"./../../common/globalize.js";import userSettings from"./../../common/usersettings/usersettings.js";import itemShortcuts from"./../../shortcuts.js";import connectionManager from"./../../emby-apiclient/connectionmanager.js";import"./../../indicators/indicators.js";import skinManager from"./../../skinmanager.js";import itemManager from"./../../common/itemmanager/itemmanager.js";let supportsCssVariables=CSS.supports("color","var(--fake-var)");function getTimerIndicator(item){let status;if("SeriesTimer"===item.Type)return'';if(item.TimerId||item.SeriesTimerId)status=item.Status||"Cancelled";else{if("Timer"!==item.Type)return"";status=item.Status}return item.SeriesTimerId?"Cancelled"!==status?'':'':''}function parseDates(program){if(!program.StartDateLocalMs)try{program.StartDateLocalMs=Date.parse(program.StartDate)}catch(err){}if(!program.EndDateLocalMs)try{program.EndDateLocalMs=Date.parse(program.EndDate)}catch(err){}return null}let insetInlineStartProp=CSS.supports("inset-inline-start","0")?"inset-inline-start":"left";function getShadedMediaInfoItem(text,itemClass){return'
'+text+"
"}function getProgramHtml(program,options,totalGridMs){let html="";var startMs=options.startMs,endMs=options.endMs,startDateLocalMs=(parseDates(program),program.StartDateLocalMs),endDateLocalMs=program.EndDateLocalMs,renderStartMs=Math.max(startDateLocalMs,startMs),startDateLocalMs=(startDateLocalMs-startMs)/totalGridMs,startMs=(startDateLocalMs*=100,startDateLocalMs=Math.max(startDateLocalMs,0),Math.min(endDateLocalMs,endMs)),endDateLocalMs=(startMs-renderStartMs)/totalGridMs;endDateLocalMs*=100;let cssClass="programCell itemAction",accentCssClass=null,displayInnerContent=!0;var endMs=options.displayMovieContent,startMs=options.displaySportsContent,renderStartMs=options.displayNewsContent,totalGridMs=options.displayKidsContent,displaySeriesContent=options.displaySeriesContent,enableColorCodedBackgrounds=options.enableColorCodedBackgrounds;program.IsKids?(displayInnerContent=totalGridMs,accentCssClass="kids"):program.IsSports?(displayInnerContent=startMs,accentCssClass="sports"):program.IsNews?(displayInnerContent=renderStartMs,accentCssClass="news"):program.IsMovie?(displayInnerContent=endMs,accentCssClass="movie"):displayInnerContent=(program.IsSeries||endMs&&renderStartMs&&startMs&&totalGridMs)&&displaySeriesContent,layoutManager.tv&&(cssClass+=" programCell-tv");let timerAttributes="",programCellInnerClass=(program.TimerId&&(timerAttributes+=' data-timerid="'+program.TimerId+'"'),program.Status&&(timerAttributes+=' data-status="'+program.Status+'"'),program.SeriesTimerId&&(timerAttributes+=' data-seriestimerid="'+program.SeriesTimerId+'"'),html+="',"programCellInner epgCellInner mediaInfoItems programMediaInfoItems");if(enableColorCodedBackgrounds&&accentCssClass&&(programCellInnerClass+=" programCellInner-"+accentCssClass),html+='
',displayInnerContent){endMs=program.EpisodeTitle&&options.showEpisodeTitle&&(!options.conditionalEhowTitle||program.IsSports);if(html+='',endMs&&(html+='
'),html=(html=html+('
'+program.Name)+"
")+getTimerIndicator(program),program.IsLive&&options.showLiveIndicator?html+=getShadedMediaInfoItem(globalize.translate("Live"),"mediaInfoProgramAttribute guideProgramIndicator liveTvProgram"):program.IsPremiere&&options.showPremiereIndicator?html+=getShadedMediaInfoItem(globalize.translate("Premiere"),"mediaInfoProgramAttribute guideProgramIndicator premiereTvProgram"):options.showNewIndicator&&program.IsNew?html+=getShadedMediaInfoItem(globalize.translate("AttributeNew"),"mediaInfoProgramAttribute guideProgramIndicator newTvProgram"):program.IsRepeat&&options.showRepeatIndicator&&(html+=getShadedMediaInfoItem(globalize.translate("Repeat"),"mediaInfoProgramAttribute guideProgramIndicator repeatTvProgram")),(options.showHdIcon||options.show4kIcon)&&program.Width&&1200<=program.Width){let text;program.Width&&3800<=program.Width?options.show4kIcon&&(text="4K"):options.showHdIcon&&(text="HD"),html+=getShadedMediaInfoItem(text,"mediaInfoProgramAttribute guideProgramIndicator")}endMs&&(html=(html=(html+='
')+program.EpisodeTitle)+"
")}return html=html+"
"+""}function getEpgRowHtml(instance,item,index,options){var apiClient=connectionManager.getApiClient(item);let html="";var channel=item.Channel,apiClient=options.showChannelImage?apiClient.getLogoImageUrl(channel,{maxHeight:220},skinManager.getPreferredLogoImageTypes()):null,cssClass=options.channelCellClass,titleText=itemManager.getDisplayName(channel,{}),titleText=(html+='";var programs=item.Programs,totalGridMs=(html+='
',options.endMs-options.startMs);for(let i=0,length=programs.length;i",options.parts)return{attributes:itemShortcuts.getShortcutAttributes(item,options),html:html};let dataAttributes=itemShortcuts.getShortcutAttributesHtml(item,options);titleText=options.tagName,cssClass=options.fixedAttributes;return cssClass&&(dataAttributes+=" "+cssClass),"<"+titleText+dataAttributes+' class="'+options.className+'">'+html+""}function GridRowRenderer(options){this.options=options}GridRowRenderer.prototype.getItemParts=function(item,index,options){return options.parts=!0,getEpgRowHtml(this,item,index,options)},GridRowRenderer.prototype.getItemsHtml=function(items,options){this.setListOptions(items,options);let html="";for(let i=0,length=items.length;i
',options.clickAction="linkdialog",options.startMs=options.startDateMs,options.endMs=options.endDateMs;guideChannelStyle=options.categories||[];options.displayMovieContent=!guideChannelStyle.length||-1!==guideChannelStyle.indexOf("movies"),options.displaySportsContent=!guideChannelStyle.length||-1!==guideChannelStyle.indexOf("sports"),options.displayNewsContent=!guideChannelStyle.length||-1!==guideChannelStyle.indexOf("news"),options.displayKidsContent=!guideChannelStyle.length||-1!==guideChannelStyle.indexOf("kids"),options.displaySeriesContent=!guideChannelStyle.length||-1!==guideChannelStyle.indexOf("series"),options.enableColorCodedBackgrounds="true"===userSettings.get("guide-colorcodedbackgrounds"),options.conditionalEhowTitle=!0,options.showHdIcon="true"===userSettings.get("guide-indicator-hd"),options.show4kIcon="false"!==userSettings.get("guide-indicator-4k"),options.showLiveIndicator="false"!==userSettings.get("guide-indicator-live"),options.showPremiereIndicator="false"!==userSettings.get("guide-indicator-premiere"),options.showNewIndicator="false"!==userSettings.get("guide-indicator-new"),options.showRepeatIndicator="true"===userSettings.get("guide-indicator-repeat");let fixedAttributes='data-focusabletype="nearest"';return options.addTabIndex&&(fixedAttributes+=' tabindex="0"'),options.fixedAttributes=fixedAttributes.trim(),options},GridRowRenderer.prototype.setListClasses=function(elem){},GridRowRenderer.parseDates=parseDates,GridRowRenderer.getProgramHtml=getProgramHtml,GridRowRenderer.virtualChunkSize=30;export default GridRowRenderer;