@flowplayer/player 3.0.3-rc.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/plugins/health.js CHANGED
@@ -13,4 +13,4 @@
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function v(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}const E=navigator;function y(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R=[1e7]+""+-1e3+-4e3+-8e3+-1e11,O=()=>"undefined"==typeof crypto?"":R.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),D="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),w=window,N=w._flowplayerTimekeeper||(w._flowplayerTimekeeper={});var T;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(T||(T={}));const A=e=>{switch(e){case!0:return T.ON;case!1:return T.OFF;default:return e}},I=O(),b=[];function S(e){const t=b.slice(0);b.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g("https://health.flowplayer.com/v1/health/events",t))}function U(e,t,n){return v(this,void 0,void 0,(function*(){const i=yield C();b.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),b.length<10&&!n||S(e)}))}const k=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},C=()=>v(void 0,void 0,void 0,(function*(){try{const e=yield function(){return v(this,void 0,void 0,(function*(){const e=N.cachedServerOffset;if(e)return e;const t=N.pendingRequest||(N.pendingRequest=fetch(D)),n=yield t,i=parseInt(n.headers.get("age")||"0"),o=yield n.json(),s=Date.now()-o.millisUtc-1e3*i;return N.cachedServerOffset=s,N.cachedServerOffset}))}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}})),x=(e,t)=>Object.assign(e,{detail:t}),M=(e,{event:t,media_session_id:n})=>({event:t,media_session_id:n,device_id:e.deviceId(),session_id:I,version:"3.0.3-rc.2",commit:"327a8ec27fc367bf10ecde8375237c65f312d2d3",ima_sdk_version:k(),preload:e.opt("preload"),autoplay:A(e.opt("autoplay")),live:e.opt("live"),source:e.original_src,downlink_mbs:y(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),B=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function j(e,t,n,i){const o=M(t,{event:n,media_session_id:e.media_session_id}),{before:s,after:r}=i;U(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,B(s),B(r)))}var F;function L(e){switch(e){case F.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case F.MEDIA_ERR_NETWORK:return"a network error occurred";case F.MEDIA_ERR_DECODE:return"unable to decode media content";case F.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case F.NO_INTERNET:return"no internet connection detected";case F.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(F||(F={}));const H=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}};class Health{constructor(e,t){this.logger=function(e,t){return{log:(...n)=>{const i=e.opt("debug");i&&t.match(i)&&console.log(t,...n)}}}(t,"health"),this.media_session_id=O();const n=setInterval(()=>S(this),1e3);if(t.on("reap",()=>clearInterval(n)),!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=M(E,{event:e.event,media_session_id:this.media_session_id});Object.assign(t,e.detail||{}),U(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),[l,c,p,h,f,i,o].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),E.on("volumechange",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return j(this,E,e,t)}});let y=Date.now()+1e3;E.on("timeupdate",e=>{if(Date.now()<y)return;y=Date.now()+1e3;const t=M(E,{event:e.type,media_session_id:this.media_session_id});var n;U(this,x(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id}),n=e.error||E.error;if(!n)return U(this,t,!0);const i=n.code,o={error_message:n.message||L(i),error_code:i,error_stack:n.stack||""};return U(this,x(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=O();U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(this)}),E.on("visibilitychange",e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
16
+ function v(e,t,n,i){return new(n||(n=Promise))((function(o,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function a(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}const E=navigator;function y(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=E.connection)||void 0===n?void 0:n.downlink)||-1}function g(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R=[1e7]+""+-1e3+-4e3+-8e3+-1e11,O=()=>"undefined"==typeof crypto?"":R.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),D="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),w=window,N=w._flowplayerTimekeeper||(w._flowplayerTimekeeper={});var T;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(T||(T={}));const A=e=>{switch(e){case!0:return T.ON;case!1:return T.OFF;default:return e}},I=O(),b=[];function S(e){const t=b.slice(0);b.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),g("https://health.flowplayer.com/v1/health/events",t))}function U(e,t,n){return v(this,void 0,void 0,(function*(){const i=yield C();b.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),b.length<10&&!n||S(e)}))}const k=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},C=()=>v(void 0,void 0,void 0,(function*(){try{const e=yield function(){return v(this,void 0,void 0,(function*(){const e=N.cachedServerOffset;if(e)return e;const t=N.pendingRequest||(N.pendingRequest=fetch(D)),n=yield t,i=parseInt(n.headers.get("age")||"0"),o=yield n.json(),s=Date.now()-o.millisUtc-1e3*i;return N.cachedServerOffset=s,N.cachedServerOffset}))}();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}})),x=(e,t)=>Object.assign(e,{detail:t}),M=(e,{event:t,media_session_id:n})=>({event:t,media_session_id:n,device_id:e.deviceId(),session_id:I,version:"3.0.4",commit:"50f911c0b47619fff2f252e74facea559b02d763",ima_sdk_version:k(),preload:e.opt("preload"),autoplay:A(e.opt("autoplay")),live:e.opt("live"),source:e.original_src,downlink_mbs:y(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),B=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function j(e,t,n,i){const o=M(t,{event:n,media_session_id:e.media_session_id}),{before:s,after:r}=i;U(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,B(s),B(r)))}var F;function L(e){switch(e){case F.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case F.MEDIA_ERR_NETWORK:return"a network error occurred";case F.MEDIA_ERR_DECODE:return"unable to decode media content";case F.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case F.NO_INTERNET:return"no internet connection detected";case F.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(F||(F={}));const H=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}};class Health{constructor(e,t){this.logger=function(e,t){return{log:(...n)=>{const i=e.opt("debug");i&&t.match(i)&&console.log(t,...n)}}}(t,"health"),this.media_session_id=O();const n=setInterval(()=>S(this),1e3);if(t.on("reap",()=>clearInterval(n)),!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}init(t,v,E){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(E),E.on("health:record",({detail:e})=>{const t=M(E,{event:e.event,media_session_id:this.media_session_id});Object.assign(t,e.detail||{}),U(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),[l,c,p,h,f,i,o].forEach(e=>{E.on(e,e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id}))})}),E.on("volumechange",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{volume:parseFloat(E.volume.toFixed(2)),muted:E.muted}))})),E.on("resize",H(800,e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id});U(this,x(t,{height:v.clientHeight,width:v.clientWidth}))})),E.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return j(this,E,e,t)}});let y=Date.now()+1e3;E.on("timeupdate",e=>{if(Date.now()<y)return;y=Date.now()+1e3;const t=M(E,{event:e.type,media_session_id:this.media_session_id});var n;U(this,x(t,{duration:(n=E.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),E.addEventListener("error",e=>{const t=M(E,{event:e.type,media_session_id:this.media_session_id}),n=e.error||E.error;if(!n)return U(this,t,!0);const i=n.code,o={error_message:n.message||L(i),error_code:i,error_stack:n.stack||""};return U(this,x(t,o),!0)}),E.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!m(E.original_src))return;if(!m(n))return;if(n==E.original_src)return;this.media_session_id=O();U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(this)}),E.on("visibilitychange",e=>{U(this,M(E,{event:e.type,media_session_id:this.media_session_id})),S(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
package/plugins/hls.js CHANGED
@@ -354,4 +354,4 @@
354
354
  /*!*********************************!*\
355
355
  !*** ./src/utils/xhr-loader.ts ***!
356
356
  \*********************************/
357
- /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;function p(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r));a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const o=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",o),t.on(u,l),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",o),t.off(u,l)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&m(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){if(!t.hls)return;void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));if("none"===e.preload&&!e.autoplay)return;m(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=null===(r=e.networkDetails)||void 0===r?void 0:r.status;t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const h=t.opt("start_time");h&&t.once("loadedmetadata",(function(){t.currentTime=h})),"none"===r.preload&&t.once("beforeplay",()=>{m(t,r.start_time||-1)})}function m(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));class HLS{init(){}onload(t,e,r,i){p(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
357
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var r=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const i="com.widevine.alpha";const n="application/vnd.apple.mpegURL",s=[n,"application/x-mpegurl"],a=document.createElement("video").canPlayType(n);function o(t){const{pathname:e}=function(t){const e=document.createElement("a");return e.href=t,e}(t);return e.endsWith(".m3u8")}function l({src:t="",type:e="",drm:r},n){const l=(null==n?void 0:n.hls)||{},u="native"in l&&l.native;return(!a||!u)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[i].filter((function(t){return t===e})).length;var e}))&&(!(!e||!s.includes(e))||o(t)))}var u="audio:set",d="audio:update",c="audio:tracks";const h=[e.Events.SUBTITLE_TRACKS_UPDATED,e.Events.SUBTITLE_TRACK_SWITCH,e.Events.LEVEL_SWITCHED];function f(t,e){h.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var g=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});var v;function p(t,r,i){if(!t.reaper||!i.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in r==0,s={is_audio_only:!1,fragDuration:-1};if(i.drm&&"https:"!==location.protocol&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit("error",{message:"Secure page required for DRM"});const a=t.hls=new e(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(r)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(i.src),t.emit("hls:attached",{hls:a}),function(t,r){t.on(e.Events.AUDIO_TRACKS_UPDATED,(function(t,e){r.emit(c,e.audioTracks)})),t.on(e.Events.AUDIO_TRACK_SWITCHING,(function(t,e){r.emit(d,e)})),t.on(e.Events.MANIFEST_PARSED,(function(t,e){e.audioTracks&&r.emit(c,e.audioTracks)})),t.on(e.Events.LEVEL_SWITCHED,(function(e,i){const n=t.levels[i.level];n&&r.emit(c,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),f(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},h=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(u,h),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(u,h)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on("reap",(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&m(t)}),n&&a.on(e.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(e.Events.MANIFEST_PARSED,(function(e,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){if(!t.hls)return;void 0!==e.start_quality&&(v.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),v.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),v.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));if("none"===e.preload&&!e.autoplay)return;m(t,e.start_time||-1)}(t,r,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(e.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(e.Events.ERROR,(function(r,i){!function(t,r,i,n){if(0==t.reaper)return;if(0==r.fatal)return;switch(r.type){case e.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit("error",{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case e.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const i=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit("error",{fatal:!0,code:"http:"+i.toString(),message:g[i]||"an error occurred while loading this video"})}(t,r);case e.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit("error",{fatal:!0,message:g[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,r)}}(t,i,t.original_src,a.config)})),a.on(e.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(e.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(e.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const p=t.opt("start_time");p&&t.once("loadedmetadata",(function(){t.currentTime=p})),"none"===r.preload&&t.once("beforeplay",()=>{m(t,r.start_time||-1)})}function m(t,e){var r;t.setState("is-loading",!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(v||(v={}));class HLS{init(){}onload(t,e,r,i){p(r,t,i)}wants(t,r,i){return e.isSupported()&&l(r,i)}}return HLS.events=r,HLS.version=e.version,function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;"function"==typeof r?r(e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e))}(window,HLS),HLS}));
package/plugins/ovp.js CHANGED
@@ -12,4 +12,4 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function t(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(i=>{if(e(t[i])&&e(o[i]))return t[i]=n(t[i],o[i]);t[i]=o[i]}),t):t,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const o="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),i=window,r=i._flowplayerTimekeeper||(i._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),l()+"/web/public/native/config"+t}const l=()=>"https://ljsp.lwcdn.com";function c(e){(function(){return t(this,void 0,void 0,(function*(){const t=r.cachedServerOffset;if(t)return t;const e=r.pendingRequest||(r.pendingRequest=fetch(o)),n=yield e,i=parseInt(n.headers.get("age")||"0"),s=yield n.json(),a=Date.now()-s.millisUtc-1e3*i;return r.cachedServerOffset=a,r.cachedServerOffset}))})().then(t=>Object.assign(e,{server_time_offset:t}))}function d(t){return~t.indexOf("/")?t:"/media/"+t}var u={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function p(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function f(t,e){var o,i;e="object"==typeof e?e:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=e.embed||{};return delete a.src,n(s,r,t,(delete(l=e).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),a);var l}const m=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function v(t){return"object"==typeof t&&"ovp/base64"==t.type}function y(t,e){return function(t,e){return!(~t.indexOf(".")||!m.test(t))&&(e.type="video/ovp",!0)}(t,e)||v(e)}function h(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function w(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function _(t){return t.live}var g=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function b(t,e){const n=null==e?void 0:e.src;if(v(e))return function(t,e){const n=h(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);O(t,n)}(t,e);n&&Pipe.of(n).fmap(d).fmap(a).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?O(t,n):E(t,n)))}function O(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=n(e,i),s=((null==r?void 0:r.playlist)||[]).map(t=>f(t,o));return Object.assign(r,{playlist:s})}(t.opts,e))}(t,e):_(e)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(w).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(f,t.opts).fmap(p).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(f,t.opts).fmap(p).unwrap())}(t,e)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(u[e.status])):t.emit("ovp:error",e)}const P={};function j(t,e,n){"object"!=typeof P[e]&&(P[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let A=!1;function T(t,e,n){L()||Pipe.of("recommendation").fmap(a,e,n).fmap(s).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(x))}function L(){return A}function x(t){A=!0,console.error("Failed to load recommendations: %j",t)}function S(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function C(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const M="flowplayer-live-countdown";function D(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function I(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=C(t,M);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,s,a;r=t,s=t.root,a=i,s.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:k(a+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}c(e),i(),n=setInterval(i,250)}function k(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+S(e.hours)+":"+S(e.minutes)+":"+S(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const q=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,M,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||v(o)||(o.src=[t.player_id,o.src].join("/")),b(n,o)}wants(t,e,n){return y(t,e)}init(t,e,o){const i=new WebsocketBridge(o);let r=Object.assign({},t);const l=function(t){if(!r)return t;delete r.src;const e=n(t,r);return r=!1,e};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,s=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(s,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=w(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(_(n)){if(V(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||D(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:n}){var i,r;if("string"==typeof t.src&&y(t.src,{}))return;if(t.src&&R(t.src))return;if((null==n?void 0:n.domains)&&(null==n?void 0:n.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(window.location.hostname,n.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.innerHTML=`\n <h2>Playback Error</h2>\n <p>Are you the site owner?</p>\n <a class="troubleshoot" target="_blank" href="https://flowplayer.com/help/developers/troubleshooting#${n.reason}">Troubleshoot?</a>\n <img src=""https://flowplayer.com/user/pages/images/logo-white.png""/>\n `}({root:e,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=n.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==n?void 0:n.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.player_id)!==t.player_id?function(t,e){if("object"==typeof P[e])return console.debug("using Cache(%s)",e),j(t,e,P[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>j(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const s={type:"flowplayer/playlist",items:n};o.setSrc(s)})),o.on("ovp:live:countdown:start",(function(n){const i=n.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!D(i))return o.emit("ovp:request:media:complete",i);C(o,M)||(e.appendChild(q(o,M)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;_(r)?V(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&((null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)||Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||L()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&T(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function V(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||w(o)>Date.now()}OVP.events=g;const R=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));
15
+ ***************************************************************************** */function t(t,e,n,o){return new(n||(n=Promise))((function(i,r){function a(t){try{l(o.next(t))}catch(t){r(t)}}function s(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}l((o=o.apply(t,e||[])).next())}))}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(i=>{if(e(t[i])&&e(o[i]))return t[i]=n(t[i],o[i]);t[i]=o[i]}),t):t,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}const o="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),i=window,r=i._flowplayerTimekeeper||(i._flowplayerTimekeeper={});function a(t){return fetch(t).then(t=>t.json())}function s(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),l()+"/web/public/native/config"+t}const l=()=>"https://ljsp.lwcdn.com";function c(e){(function(){return t(this,void 0,void 0,(function*(){const t=r.cachedServerOffset;if(t)return t;const e=r.pendingRequest||(r.pendingRequest=fetch(o)),n=yield e,i=parseInt(n.headers.get("age")||"0"),a=yield n.json(),s=Date.now()-a.millisUtc-1e3*i;return r.cachedServerOffset=s,r.cachedServerOffset}))})().then(t=>Object.assign(e,{server_time_offset:t}))}function d(t){return~t.indexOf("/")?t:"/media/"+t}var u={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function p(t){const e=t.ima,n=t.duration;if(!e||!n)return t;const o=null==e?void 0:e.ads;return Array.isArray(o)&&(e.ads=o.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*n),t}))),t}function m(t,e){var o,i;e="object"==typeof e?e:{};const r={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},a={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:i,ad_keywords:r}){return{ad_keywords:r||"",media_id:t||"",category:i||"",media_name:n||"",media_tags:o||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},s=e.embed||{};return delete s.src,n(a,r,t,(delete(l=e).src,delete l.metadata,delete l.title,delete l.description,delete l.duration,delete l.poster,l),s);var l}const f=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function v(t){return"object"==typeof t&&"ovp/base64"==t.type}function y(t,e){return function(t,e){return!(~t.indexOf(".")||!f.test(t))&&(e.type="video/ovp",!0)}(t,e)||v(e)}function h(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function w(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function _(t){return t.live}var g=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function b(t,e){const n=null==e?void 0:e.src;if(v(e))return function(t,e){const n=h(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);O(t,n)}(t,e);n&&Pipe.of(n).fmap(d).fmap(s).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,n])=>200==e?O(t,n):E(t,n)))}function O(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),E(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},r=n(e,i),a=((null==r?void 0:r.playlist)||[]).map(t=>m(t,o));return Object.assign(r,{playlist:a})}(t.opts,e))}(t,e):_(e)?function(t,e){var n,o;const i=(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.live_start_time)||(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.starttime);i&&(e.live_start_time=Pipe.of(i).fmap(w).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(m,t.opts).fmap(p).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(m,t.opts).fmap(p).unwrap())}(t,e)}function E(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(u[e.status])):t.emit("ovp:error",e)}const P={};function j(t,e,n){"object"!=typeof P[e]&&(P[e]=n);const o=t.opts,i=(null==o?void 0:o.metadata)||{};i.player_id=e,o.metadata=i,n.title&&delete n.title,n.description&&delete n.description;const r=Object.assign(o,n);t.setOpts(r),n.autoplay&&t.togglePlay(!0)}let A=!1;function T(t,e,n){L()||Pipe.of("recommendation").fmap(s,e,n).fmap(a).fmap(e=>e.then(e=>function(t,e){const n=e.playlist;if(t.opts.recommendations=n,!n.length)return;t.emit("recommendationsready",{playlist:n.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(x))}function L(){return A}function x(t){A=!0,console.error("Failed to load recommendations: %j",t)}function S(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function C(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const M="flowplayer-live-countdown";function D(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function I(t,e){let n=0;function o(){return function(t,e){const n=Date.now()-e;return Math.floor((t-n)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function i(){const i=o();if(i<0||isNaN(i)||0===t.reaper)return clearInterval(n),function(t,e){t.emit("ovp:live:countdown:complete");const n=C(t,M);n&&n.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);var r,a,s;r=t,a=t.root,s=i,a.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:k(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}c(e),i(),n=setInterval(i,250)}function k(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const n=Math.floor(t/3600);t-=3600*n;const o=Math.floor(t/60);return{days:e,hours:n,minutes:o,seconds:t-=60*o}}(t);let n="";return e.days&&(n+=e.days+":"),n+S(e.hours)+":"+S(e.minutes)+":"+S(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}const q=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const o=window.customElements.get(e);if(!o)throw new Error(`no default flowplayer component with the name ${e} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(t._customElements,e))(t);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=function(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}("fp-inner");this.append(e);const n=document.createElement("p");n.innerText=t.i18n("ovp.starting_in"),e.append(n);const o=document.createElement("p");o.classList.add("fp-countdown"),e.append(o),t.on("ovp:live:countdown:tick",e=>{const n=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),o.innerText=n})}}const V=["*.lwcdn.com","*.flowplayer.com"];function R(){try{return window.location.hostname!==window.parent.location.hostname?function(t){const e=document.createElement("a");return e.href=t,e}(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}class OVP{constructor(t){((t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)})(t,M,FlowplayerLiveCountdown)}onload(t,e,n,o){if("string"==typeof o.src)return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||v(o)||(o.src=[t.player_id,o.src].join("/")),b(n,o)}wants(t,e,n){return y(t,e)}init(t,e,o){const i=new WebsocketBridge(o);let r=Object.assign({},t);const l=function(t){if(!r)return t;delete r.src;const e=n(t,r);return r=!1,e};o.on("ovp:error",(function(t){o.emit("error",t.data)})),o.on("ovp:request:start",(function(){o.setState("is-waiting",!0),t.recommendations&&(t.recommendations=!1)})),o.on("ovp:media:changed",(function({data:t}){var e;const n=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&n&&(i.disconnect(),i.connect(n))})),o.on("ovp:message:realtime",(function({data:e}){var n;const i=null==e?void 0:e.event,r=null==e?void 0:e.value,a=o.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const e=Object.assign(a,r),i=Object.assign(t,{metadata:e});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=w(i.metadata.live_start_time)),o.setOpts(i);break}}})),o.on("beforeplay",(function(e){const n=t;if(_(n)){if(N(n))return;e.preventDefault()}})),o.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==o.reaper||"object"!=typeof t.data||D(t.data))return;const n=l(e);o.setOpts(n),o.setAttrs(n),n.src&&o.setSrc(n.src),n.autoplay&&o.togglePlay(!0)})),o.on("config",(function({data:n}){var i,r;if("string"==typeof t.src&&y(t.src,{}))return;if(t.src&&U(t.src))return;if((null==n?void 0:n.domains)&&(null==n?void 0:n.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(V).some(t=>{const e=t.split(".").reverse(),o="*"===e[e.length-1];return o&&e.pop(),(o||e.length===n.length)&&e.every((t,e)=>n[e]===t)})})(R(),n.domains))return function({root:t,video:e,data:n}){e&&e.destroy(),console.error(new Error(n.details||n.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image"),t.innerHTML=`\n <h2>Playback Error</h2>\n <p>Are you the site owner?</p>\n <a class="troubleshoot" target="_blank" href="https://flowplayer.com/help/developers/troubleshooting#${n.reason}">Troubleshoot?</a>\n <img src=""https://flowplayer.com/user/pages/images/logo-white.png""/>\n `}({root:e,video:o,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=n.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const l=null==n?void 0:n.brand_color;return l&&o.root.style.setProperty("--fp-brand-color","#"==l[0]?l:"#"+l),"string"==typeof t.player_id&&(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.player_id)!==t.player_id?function(t,e){if("object"==typeof P[e])return console.debug("using Cache(%s)",e),j(t,e,P[e]);Pipe.of(e).fmap(s).fmap(a).fmap(n=>n.then(n=>j(t,e,n)).catch(console.error))}(o,t.player_id):void 0})),o.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==o.reaper)return;const{playlist:n}=e,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(e,["playlist"]),r=l({playlist:i});Array.isArray(r.playlist)&&(r.playlist=i),o.setOpts(r);const a={type:"flowplayer/playlist",items:n};o.setSrc(a)})),o.on("ovp:live:countdown:start",(function(n){const i=n.data;if(!i||0==o.reaper)return;const r=l(i);if(o.setOpts(r),o.setAttrs(r),!D(i))return o.emit("ovp:request:media:complete",i);C(o,M)||(e.appendChild(q(o,M)),I(o,t))})),o.on("timeupdate",(function(){var e,n,i;const r=t;_(r)?N(r)||(o.togglePlay(!1),o.emit("ended")):t.recommendations&&((null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)||Array.isArray(t.recommendations)||o.currentTime/o.duration<.8||L()||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.player_id)&&T(o,t.metadata.media_id,t.metadata.player_id))})),o.on("reap",(function(){i.disconnect()}))}}function N(t){var e,n;const o=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!o)return!0;return!!(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.allow_after_stop_time)||w(o)>Date.now()}OVP.events=g;const U=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,OVP),OVP}));