define(["exports","./globalize.js"],function(_exports,_globalize){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var units=[["year",31536e6],["month",2592e6],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];function numberToString(value,maximumFractionDigits){try{return new Intl.NumberFormat(_globalize.default.getCurrentLocales(),{style:"decimal",maximumFractionDigits:null==maximumFractionDigits?1:maximumFractionDigits}).format(value)}catch(err){return console.error("Error in NumberFormat: ",err),value}}function getRawResolutionText(item){return item.Width&&item.Height?item.Width+"x"+item.Height:null}_exports.default={formatRelativeTime:function(date,isPastEvent){for(var unit,date=(date="string"==typeof date?new Date(Date.parse(date)):date).getTime()-Date.now(),elapsedMsAbs=Math.abs(date),i=0,length=units.length;i<length&&!(elapsedMsAbs>=(unit=units[i])[1]);i++);return date=Math.round(date/unit[1]),!1!==isPastEvent&&-1<(date=Math.min(date,1))&&(date=-1,unit=units[units.length-1]),new Intl.RelativeTimeFormat(_globalize.default.getCurrentLocales(),{numeric:"always",style:"long"}).format(date,unit[0])},bitrateToString:function(value){return 1e3<(value/=1e3)?numberToString(value/=1e3,0)+" mbps":numberToString(parseInt(value))+" kbps"},sizeToString:function(size){var gb=1073741824;return gb<=size?numberToString(size/gb,1)+" GB":numberToString(size/1048576,1)+" MB"},numberToString:numberToString,getResolutionText:function(item){var videoStream,width,height;return"Video"===item.MediaType&&(videoStream=function(item){for(var _,mediaStreams=(null==(_=(item.MediaSources||[])[0])?void 0:_.MediaStreams)||item.MediaStreams||[],i=0,length=mediaStreams.length;i<length;i++){var mediaStream=mediaStreams[i];if("Video"===mediaStream.Type)return mediaStream}return null}(item))?(width=videoStream.Width,height=videoStream.Height,width&&height?3800<=width||2e3<=height?"4K":2500<=width||1400<=height?videoStream.IsInterlaced?"1440i":"1440p":1800<=width||1e3<=height?videoStream.IsInterlaced?"1080i":"1080p":1200<=width||700<=height?videoStream.IsInterlaced?"720i":"720p":700<=width||400<=height?videoStream.IsInterlaced?"480i":"480p":"SD":null):getRawResolutionText(item)}}});