"use strict";var _utils=require("../../utils/utils");function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var formatProgramTime=function(t){var e=1e3*normalizeSeconds(t);if(!e)return"";var r=new Date(e),o=String(r.getHours()).padStart(2,"0"),n=String(r.getMinutes()).padStart(2,"0");return"".concat(o,":").concat(n)},normalizeSeconds=function(t){var e=Number(t||0);return e?e>1e11?Math.floor(e/1e3):Math.floor(e):0},getProgramEndTime=function(t,e){var r=normalizeSeconds((null==t?void 0:t.PlayEndTime)||(null==t?void 0:t.EndTime)||(null==t?void 0:t.AutoEndTime));if(r)return r;var o=normalizeSeconds(null==t?void 0:t.PlayStartTime),n=normalizeSeconds(null==e?void 0:e.PlayStartTime);if(n>o)return n;var i=Number((null==t?void 0:t.VideoTime)||(null==t?void 0:t.Duration)||(null==t?void 0:t.MediaDuration)||0);return o&&i>0?Math.floor(o+i):0};Component({properties:{sdkInstance:{type:Object,value:null},themeColor:{type:Object,value:null}},data:{programList:[]},observers:{sdkInstance:function(t){var e=this;t&&("function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.sdkInstance=t,this.store=t.store,this.unsub=this.store.get({liveInfo:function(t){var r,o,n=(null===(r=e.store)||void 0===r||null===(o=r.get)||void 0===o?void 0:o.call(r,"PullStreamUrl"))||(null==t?void 0:t.PullStreamUrl)||[],i=(0,_utils.getCurrentLoopVideoProgram)(t,n),u=Array.isArray(null==i?void 0:i.LoopVideos)?i.LoopVideos:[],l=u.map(function(t,e){return _objectSpread(_objectSpread({},t),{},{startTimeText:formatProgramTime(null==t?void 0:t.PlayStartTime),endTimeText:formatProgramTime(getProgramEndTime(t,u[e+1])),videoNameText:(0,_utils.getBySplit)(null==t?void 0:t.VideoName)})});JSON.stringify(e.data.programList)!==JSON.stringify(l)&&e.setData({programList:l})}}))}},lifetimes:{detached:function(){"function"==typeof this.unsub&&this.unsub(),this.unsub=null}}});