define(["datetime","itemHelper","css!./indicators.css","material-icons"],function(datetime,itemHelper){"use strict";var progressBarRequired;return{getProgressBarHtml:function(item,options){var itemType=item.Type;if(!item.IsFolder&&"Recording"!==itemType){var userData=options&&options.userData||item.UserData;if(userData&&(pct=userData.PlayedPercentage)&&pct<100)return function(pct,options){var containerClass="itemProgressBar";return options&&options.containerClass&&(containerClass+=" "+options.containerClass),'<div class="'+containerClass+'"><div class="itemProgressBarForeground" style="width:'+pct+'%;"></div></div>'}(pct,options)}if(item=item.CurrentProgram||item,("Program"===itemType||"Timer"===itemType||"Recording"===itemType||"TvChannel"===itemType)&&item.StartDate&&item.EndDate){var pct,startDate=0,endDate=1;try{startDate=datetime.parseISO8601Date(item.StartDate).getTime()}catch(err){}try{endDate=datetime.parseISO8601Date(item.EndDate).getTime()}catch(err){}if(0<(pct=(Date.now()-startDate)/(endDate-startDate)*100)&&pct<100)return function(pct,options,isRecording,start,end){progressBarRequired||(progressBarRequired=!0,require(["emby-progressbar"]));var containerClass="itemProgressBar";options&&options.containerClass&&(containerClass+=" "+options.containerClass);var foregroundClass="itemProgressBarForeground";return isRecording&&(foregroundClass+=" itemProgressBarForeground-recording"),'<div is="emby-progressbar" data-automode="time" data-starttime="'+start+'" data-endtime="'+end+'" class="'+containerClass+'"><div class="'+foregroundClass+'" style="width:'+pct+'%;"></div></div>'}(pct,options,"Timer"===itemType||"Recording"===itemType||item.TimerId,startDate,endDate)}return""},getPlayedIndicatorHtml:function(item,classNamePrefix){var userData=item.UserData;if(userData){if(userData.Played&&itemHelper.canMarkPlayed(item)&&(!item.IsFolder||"MusicAlbum"===item.Type))return'<i class="'+(classNamePrefix?classNamePrefix+"PlayedIndicator ":"")+'playedIndicator md-icon">&#xE5CA;</i>';if(userData.UnplayedItemCount&&itemHelper.canMarkPlayed(item))return'<div class="'+(classNamePrefix?classNamePrefix+"CountIndicator ":"")+'CountIndicator countIndicator">'+userData.UnplayedItemCount+"</div>"}return""},getTimerIndicator:function(item,classNamePrefix){var status,itemType=(item=item.CurrentProgram||item).Type,className=classNamePrefix?classNamePrefix+"TimerIndicator ":"";if("SeriesTimer"===itemType)return'<i class="'+className+'md-icon timerIndicator indicatorIcon">&#xE062;</i>';if(item.TimerId||item.SeriesTimerId)status=item.Status||"Cancelled";else{if("Timer"!==itemType)return"";status=item.Status}return item.SeriesTimerId?"Cancelled"!==status?'<i class="'+className+'md-icon timerIndicator indicatorIcon">&#xE062;</i>':'<i class="'+className+'md-icon timerIndicator timerIndicator-inactive indicatorIcon">&#xE062;</i>':'<i class="'+className+'md-icon timerIndicator indicatorIcon">&#xE061;</i>'},getMissingIndicator:function(item,className){if("Episode"!==item.Type||"Virtual"!==item.LocationType)return"";if(className&&(className+=" "),item.PremiereDate)try{if(datetime.parseISO8601Date(item.PremiereDate).getTime()>Date.now())return'<div class="'+className+'unairedIndicator">Unaired</div>'}catch(err){}return'<div class="'+className+'missingIndicator">Missing</div>'}}});