define(["exports","./playbackmanager.js","./../globalize.js","./../../emby-apiclient/connectionmanager.js"],function(_exports,_playbackmanager,_globalize,_connectionmanager){function promptUserToPlayActiveRecording(timer,displayItem,options){var items=[];return items.push({name:_globalize.default.translate("PlayFromLivePosition"),id:"playlive",icon:"&#xe037;"}),items.push({name:_globalize.default.translate("PlayFromStartOfRecording"),id:"playrecording",icon:"&#xe037;"}),function(options){return Emby.importModule("./modules/actionsheet/actionsheet.js").then(function(ActionSheet){return ActionSheet.show(options)})}({items:items,item:displayItem,text:_globalize.default.translate("ThisChannelIsActivelyRecording"),hasItemIcon:!0,longPreview:!0}).then(function(result){return"playrecording"===result?function(timer,options){return _connectionmanager.default.getApiClient(timer).getLiveTvRecordings({TimerId:timer.Id,IsInProgress:!0}).then(function(result){result=result.Items.filter(function(i){return i.TimerId===timer.Id})[0];return result?_playbackmanager.default.play({items:[result]}):_playbackmanager.default.play(options)})}(timer,options):"playlive"===result?_playbackmanager.default.play(options):options.cancelResult?Promise.reject(options.cancelResult):Promise.reject()})}function playChannelWithTimerId(displayItem,timerId,options){return _connectionmanager.default.getApiClient(displayItem).getLiveTvTimer(timerId).then(function(timer){return function(timer,displayItem,options){var now=Date.now();return now>=Date.parse(timer.StartDate)&&now<Date.parse(timer.EndDate)?promptUserToPlayActiveRecording(timer,displayItem,options):_playbackmanager.default.play(options)}(timer,displayItem,options)})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;_exports.default={play:function(options){var _options$items;if(1===(null==(_options$items=options.items)?void 0:_options$items.length)){var item=options.items[0];switch(item.Type){case"TvChannel":return function(item,options){var _item$CurrentProgram=null==(_item$CurrentProgram=item.CurrentProgram)?void 0:_item$CurrentProgram.TimerId;return _item$CurrentProgram?playChannelWithTimerId(item.CurrentProgram||item,_item$CurrentProgram,options):_playbackmanager.default.play(options)}(item,options);case"Program":return function(item,options){var timerId=item.TimerId;return timerId?playChannelWithTimerId(item,timerId,options):_playbackmanager.default.play(options)}(item,options)}}return _playbackmanager.default.play(options)}}});