@flowplayer/player 3.18.0-rc → 3.18.0-rc.2

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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.float_on_scroll=e())}(this,(function(){"use strict";const t="float:pop:in";var e=Object.freeze({__proto__:null,POP_IN:t,POP_OUT:"float:pop:out",EXT_BTN_CLICK:"float:exit"});const n=(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),o=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function i(t){return function(t){const e=t.getBoundingClientRect(),n=window.innerHeight,o=e.y;return o>n||o+e.height<0?0:e.y<0?(e.height+o)/e.height:n-e.y>e.height?1:Math.abs((n-e.y)/e.height)}(t)>.8}function l(t,e){0==e.reaper||e.floating||a(e,t,"float:pop:out")}function s(e,n){0!=n.reaper&&n.floating&&a(n,e,t)}function r(t,e,o){const i=document.createElement("div");return i.classList.add("fp-exit-float"),i.append(Object.assign(n(t,"flowplayer-close-icon"),{role:"button"})),i.addEventListener("click",()=>{if(o.was_user_toggled=!0,!t.opts.float_default)return t.emit("float:exit");t.togglePlay(!1),s(e,t)}),i}function a(e,n,o){o&&e.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper"),l=n.clientWidth/n.clientHeight;if(!i)return;i.style.height=o===t?"auto":i.clientWidth/l+"px";const s=i.querySelector(".fp-ad-container > div");s&&(s.style.position=o==t?"absolute":"static"),e.emit("resize",{contentRect:{height:o===t?n.clientHeight:i.clientHeight,width:i.clientWidth}})}))}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const c={translation_key:"core.mute",name:"fp-mute"},u={translation_key:"core.mute",name:"fp-unmute"},f={translation_key:"core.close",name:"fp-close"};var p;const d=((p=class FloatOnScroll{constructor(t){this.flowplayer=t,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(t){super(t,c)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(t){super(t,u)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(t){super(t,f)}})}init(e,o,c){if(!1===e.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(t){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");void 0===e.float_default&&(e.float_default=!0);if(this.flowplayer.instances.find(t=>t.root.classList.contains(FloatOnScroll.SINGLETON_CLASS)))return e.float_on_scroll=!1,console.warn("disabling float on scroll for player index=%s as it is a singleton behavior\n\tto disable this warning manually configure float_on_scroll: false",this.flowplayer.instances.indexOf(c));o.classList.add(FloatOnScroll.SINGLETON_CLASS),e.autopause&&c.setOpts({autopause:!1});const u={pop_out_container:void 0,was_user_toggled:!1};c.popIn=s.bind(this,o,c),c.popOut=l.bind(this,o,c);const f=window.scrollY;c.on("mount",(function(){u.pop_out_container=function(t,e){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),t.appendChild(n),Array.from(t.childNodes).forEach((function(t){t instanceof Element&&(t===n||t.classList.contains("fp-ratio"))||n.appendChild(t)})),e.getFullsceenTarget=()=>n,n}(o,c)})),c.on("renderplugin",(function(t){var e;t.preventDefault(),t.detail&&(null===(e=u.pop_out_container)||void 0===e||e.append(t.detail));const n=t.detail.querySelector("flowplayer-ad-controls");n&&n.append(r(c,o,u))}));const p=function(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}(c,"flowplayer-header");p&&function(t,e,o,i){const l=document.createElement("div");l.classList.add("fp-mute-float"),l.append(...Object.assign([n(i,"flowplayer-mute-icon"),n(i,"flowplayer-unmute-icon")],{role:"button"})),l.addEventListener("click",(function(){i.toggleMute()})),t.append(r(i,o,e),l)}(p,u,o,c);const d=function(t,e){const n=t||60,o=Math.ceil(1e3/n);let i=Date.now(),l=-1;return function(...t){return l>-1||Date.now()<i||(l=requestAnimationFrame((function(){l=-1,e(),i=Date.now()+o}))),l}}(0,(function(){if(i(o)){if(c.hasState("is-fullscreen"))return;c.popIn()}})),w=function(){a(c,o)};c.on("viewleave",t=>{e.float_default&&window.scrollY!==f&&!u.was_user_toggled&&function(t){return!(Array.from(document.querySelectorAll(".fp-engine")).find(t=>t.hasState("is-popped-out"))||t.paused&&(!t.ads||!t.ads.adPlaying))}(c)&&(t.preventDefault(),c.popOut())}),c.on("viewenter",(function(){u.was_user_toggled=!1})),c.on("float:pop:out",(function(){c.floating=!0,c.setState("is-popped-out",!0),e.float_default&&(window.addEventListener("scroll",d),window.addEventListener("resize",w))})),c.on(t,(function(){c.floating=!1,c.setState("is-popped-out",!1),e.float_default&&(window.removeEventListener("scroll",d),window.removeEventListener("resize",w))}))}}).events=e,p.SINGLETON_CLASS="float-on-scroll-enabled",p);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,d)}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.float_on_scroll=e())}(this,(function(){"use strict";const t="float:pop:in";var e=Object.freeze({__proto__:null,POP_IN:t,POP_OUT:"float:pop:out",EXT_BTN_CLICK:"float:exit"});const n=(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),o=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function i(t){return function(t){const e=t.getBoundingClientRect(),n=window.innerHeight,o=e.y;return o>n||o+e.height<0?0:e.y<0?(e.height+o)/e.height:n-e.y>e.height?1:Math.abs((n-e.y)/e.height)}(t)>.8}function l(t,e){0==e.reaper||e.floating||a(e,t,"float:pop:out")}function s(e,n){0!=n.reaper&&n.floating&&a(n,e,t)}function r(t,e,o){const i=document.createElement("div");return i.classList.add("fp-exit-float"),i.append(Object.assign(n(t,"flowplayer-close-icon"),{role:"button"})),i.addEventListener("click",()=>{if(o.was_user_toggled=!0,!t.opts.float_default)return t.emit("float:exit");t.togglePlay(!1),s(e,t)}),i}function a(e,n,o){o&&e.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper"),l=n.clientWidth/n.clientHeight;if(!i)return;i.style.height=o===t?"auto":i.clientWidth/l+"px";const s=i.querySelector(".fp-ad-container > div");s&&(s.style.position=o==t?"absolute":"static"),e.emit("resize",{contentRect:{height:o===t?n.clientHeight:i.clientHeight,width:i.clientWidth}})}))}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const c={translation_key:"core.mute",name:"fp-mute"},u={translation_key:"core.mute",name:"fp-unmute"},f={translation_key:"core.close",name:"fp-close"};var p;const d=((p=class FloatOnScroll{constructor(t){this.flowplayer=t,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(t){super(t,c)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(t){super(t,u)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(t){super(t,f)}})}init(e,o,c){if(!1===e.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(t){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");void 0===e.float_default&&(e.float_default=!0);if(this.flowplayer.instances.find(t=>t.root.classList.contains(p.SINGLETON_CLASS)))return e.float_on_scroll=!1,console.warn("disabling float on scroll for player index=%s as it is a singleton behavior\n\tto disable this warning manually configure float_on_scroll: false",this.flowplayer.instances.indexOf(c));o.classList.add(p.SINGLETON_CLASS),e.autopause&&c.setOpts({autopause:!1});const u={pop_out_container:void 0,was_user_toggled:!1};c.popIn=s.bind(this,o,c),c.popOut=l.bind(this,o,c);const f=window.scrollY;c.on("mount",(function(){u.pop_out_container=function(t,e){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),t.appendChild(n),Array.from(t.childNodes).forEach((function(t){t instanceof Element&&(t===n||t.classList.contains("fp-ratio"))||n.appendChild(t)})),e.getFullsceenTarget=()=>n,n}(o,c)})),c.on("renderplugin",(function(t){var e;t.preventDefault(),t.detail&&(null===(e=u.pop_out_container)||void 0===e||e.append(t.detail));const n=t.detail.querySelector("flowplayer-ad-controls");n&&n.append(r(c,o,u))}));const d=function(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}(c,"flowplayer-header");d&&function(t,e,o,i){const l=document.createElement("div");l.classList.add("fp-mute-float"),l.append(...Object.assign([n(i,"flowplayer-mute-icon"),n(i,"flowplayer-unmute-icon")],{role:"button"})),l.addEventListener("click",(function(){i.toggleMute()})),t.append(r(i,o,e),l)}(d,u,o,c);const w=function(t,e){const n=t||60,o=Math.ceil(1e3/n);let i=Date.now(),l=-1;return function(...t){return l>-1||Date.now()<i||(l=requestAnimationFrame((function(){l=-1,e(),i=Date.now()+o}))),l}}(0,(function(){if(i(o)){if(c.hasState("is-fullscreen"))return;c.popIn()}})),m=function(){a(c,o)};c.on("viewleave",t=>{e.float_default&&window.scrollY!==f&&!u.was_user_toggled&&function(t){return!(Array.from(document.querySelectorAll(".fp-engine")).find(t=>t.hasState("is-popped-out"))||t.paused&&(!t.ads||!t.ads.adPlaying))}(c)&&(t.preventDefault(),c.popOut())}),c.on("viewenter",(function(){u.was_user_toggled=!1})),c.on("float:pop:out",(function(){c.floating=!0,c.setState("is-popped-out",!0),e.float_default&&(window.addEventListener("scroll",w),window.addEventListener("resize",m))})),c.on(t,(function(){c.floating=!1,c.setState("is-popped-out",!1),e.float_default&&(window.removeEventListener("scroll",w),window.removeEventListener("resize",m))}))}}).events=e,p.SINGLETON_CLASS="float-on-scroll-enabled",p);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,d)}));
package/plugins/iframe.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";var e;const n=((e=class Iframe{constructor(e,n){Iframe.ATTACHED||(n.setState("is-iframe",!0),Iframe.ATTACHED=!0,window.addEventListener("message",(function(n){if(!Iframe.is_flowplayer_message(n.data))return;const t=e.instances||[],r=t[0];if(!r)return;t.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(Iframe.message_body(n.data)){case"pause":return r.togglePlay(!1);case"play":return r.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}).FLOWPLAYER_RPC_PROTOCOL="flowplayer://",e.ATTACHED=!1,e.is_flowplayer_message=function(n){return"string"==typeof n&&n.startsWith(e.FLOWPLAYER_RPC_PROTOCOL)},e.message_body=function(n){return n.slice(e.FLOWPLAYER_RPC_PROTOCOL.length)},e);(function(){try{return window.self!==window.top}catch(e){return!0}})()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;if(null===document.currentScript)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,n);return n}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.iframe=n())}(this,(function(){"use strict";var e;const n=((e=class Iframe{constructor(n,t){e.ATTACHED||(t.setState("is-iframe",!0),e.ATTACHED=!0,window.addEventListener("message",(function(t){if(!e.is_flowplayer_message(t.data))return;const o=n.instances||[],i=o[0];if(!i)return;o.length>1&&console.warn("Multiple player instances in iframe. Messaging supported with first instance only.");switch(e.message_body(t.data)){case"pause":return i.togglePlay(!1);case"play":return i.togglePlay(!0)}})))}init(e,n,t){t.on("fullscreenenter",(function(){document.fullscreenEnabled||"function"==typeof t.webkitEnterFullscreen&&(t.webkitEnterFullscreen(),t.once("webkitendfullscreen",(function(){t.emit("fullscreenexit")})),t.on("ended",(function(){t.webkitExitFullscreen()})))}))}}).FLOWPLAYER_RPC_PROTOCOL="flowplayer://",e.ATTACHED=!1,e.is_flowplayer_message=function(n){return"string"==typeof n&&n.startsWith(e.FLOWPLAYER_RPC_PROTOCOL)},e.message_body=function(n){return n.slice(e.FLOWPLAYER_RPC_PROTOCOL.length)},e);(function(){try{return window.self!==window.top}catch(e){return!0}})()&&function(e,n){if("object"==typeof exports&&"undefined"!=typeof module)return n;if(null===document.currentScript)return n;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;"function"==typeof t?t(n):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(n)||t.extensions.push(n))}(window,n);return n}));
@@ -1 +1 @@
1
- !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.message=s())}(this,(function(){"use strict";var e,s=Object.freeze({__proto__:null,SHOW_MESSAGE:"message:show",DISMISS_MESSAGE:"message:dismiss"});const t=/<trans(.*)trans>/,n=((e=class Message{init(e,s,n){let o="";n.on("message:show",(function(e){var i,a,f;const r=null===(i=e.data)||void 0===i?void 0:i.sticky,d=null===(a=e.data)||void 0===a?void 0:a.timeout;let l=(null===(f=e.data)||void 0===f?void 0:f.message)||"";if(l==o)return;if(o=l||"",t.test(l)){const e=t.exec(l)||["",""];l=n.i18n(e[1].trim())}const u=document.createElement("div");u.classList.add("fp-message");const c=document.createElement("p");c.innerText=l,u.append(c),s.append(u),setTimeout((function(){u.classList.add("fp-shown")}),100),r||setTimeout((function(){n.emit("message:dismiss",u)}),d)})),n.on("message:dismiss",(function(e){o="";const s=e.data;s&&(s.classList.remove("fp-shown"),setTimeout((function(){s.remove()}),1e3))})),n.message={events:Message.events}}}).events=s,e);return function(e,s){if("object"==typeof exports&&"undefined"!=typeof module)return s;if(null===document.currentScript)return s;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;return"function"==typeof t?(t(s),s):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(s)||t.extensions.push(s),s)}(window,n)}));
1
+ !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.message=s())}(this,(function(){"use strict";var e,s=Object.freeze({__proto__:null,SHOW_MESSAGE:"message:show",DISMISS_MESSAGE:"message:dismiss"});const t=/<trans(.*)trans>/,n=((e=class Message{init(s,n,o){let i="";o.on("message:show",(function(e){var s,a,f;const r=null===(s=e.data)||void 0===s?void 0:s.sticky,d=null===(a=e.data)||void 0===a?void 0:a.timeout;let l=(null===(f=e.data)||void 0===f?void 0:f.message)||"";if(l==i)return;if(i=l||"",t.test(l)){const e=t.exec(l)||["",""];l=o.i18n(e[1].trim())}const u=document.createElement("div");u.classList.add("fp-message");const c=document.createElement("p");c.innerText=l,u.append(c),n.append(u),setTimeout((function(){u.classList.add("fp-shown")}),100),r||setTimeout((function(){o.emit("message:dismiss",u)}),d)})),o.on("message:dismiss",(function(e){i="";const s=e.data;s&&(s.classList.remove("fp-shown"),setTimeout((function(){s.remove()}),1e3))})),o.message={events:e.events}}}).events=s,e);return function(e,s){if("object"==typeof exports&&"undefined"!=typeof module)return s;if(null===document.currentScript)return s;"flowplayer"in e||(e.flowplayer={extensions:[]});const t=e.flowplayer;return"function"==typeof t?(t(s),s):(Array.isArray(t.extensions)||(t.extensions=[]),~t.extensions.indexOf(s)||t.extensions.push(s),s)}(window,n)}));
package/plugins/ovp.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),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"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}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,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",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,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,v=/^[A-Za-z0-9]{8}$/,y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function h(t){return"object"==typeof t&&"ovp/base64"==t.type}function w(t,e){return function(t,e){return!(!m.test(t)&&!f.test(t))&&(e.type="video/ovp",!0)}(t,e)||function(t,e){return!/[aeiou]/.test(t.toLowerCase())&&(!(!v.test(t)&&!y.test(t))&&(e&&(e.type="video/ovp"),!0))}(t,e)||h(e)}function g(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 _(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 b(t){return t.live}var E=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",OVP_CONFIG_FINALIZED:"ovp:config:finalized"});function O(t,e){const n=null==e?void 0:e.src;if(h(e))return function(t,e){const n=g(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);j(t,n)}(t,e);n&&(t.setState("is-source-processing",!0),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])=>{return 200==e?j(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function j(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):b(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(_).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const A={};function P(t,e,n){"object"!=typeof A[e]&&(A[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let S=!1;function L(t,e,n){T()||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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(C))}function T(){return S}function C(t){S=!0,console.error("Failed to load recommendations: %j",t)}function x(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function I(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const M="flowplayer-live-countdown";function k(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function D(t,e){let n=0;function o(){const o=k(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=I(t,M);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:q(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function q(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+x(e.hours)+":"+x(e.minutes)+":"+x(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 N=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 R=["*.lwcdn.com","*.flowplayer.com","*.wowza.com"];function V(){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}}function U(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function W(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const $=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?W("video/"+U(n)):""},o)]};function F(t){return $({src:t})}function z(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:$(Object.assign({src:n},r))}var H,B;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(H||(H={}));const G=((B=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(null==o?void 0:o.src))return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||h(o)||(o.src=[t.player_id,o.src].join("/")),O(n,o)}wants(t,e,n){return w(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){if(!c)return t;e.autoplay!==c.autoplay&&(c.autoplay=e.autoplay),delete c.src;const o=n(t,c);return r.emit("ovp:config:finalized",o),o};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.recommendations=!1)})),r.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))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=_(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(b(n)){if(Q(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?F(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=F(e)),"object"!=typeof e||Array.isArray(e)||(e=z(e)),t.concat(e)}),[]):z(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||k(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&w(e.src,{}))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(R).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)})})(V(),t.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");const o=document.createElement("h2");o.textContent="Playback Error";const r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${V()} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});if(e.src&&Z(e.src))return;const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof A[e])return console.debug("using Cache(%s)",e),P(t,e,A[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),k(n)<=0)return r.emit("ovp:request:media:complete",n);I(r,M)||(o.appendChild(N(r,M)),D(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;b(i)?Q(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||T()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&L(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}).events=E,B);function Q(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)||_(o)>Date.now()}const Z=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;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,G)}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ovp=e())}(this,(function(){"use strict";function t(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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}const e=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),n=(...t)=>t.reduce((t,o)=>e(o)?(Object.keys(o).forEach(r=>{if(e(t[r])&&e(o[r]))return t[r]=n(t[r],o[r]);t[r]=o[r]}),t):t,{});class Pipe{static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}constructor(t){this.data=t}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"),r=window,i=r._flowplayerTimekeeper||(r._flowplayerTimekeeper={});function s(t){return fetch(t).then(t=>t.json())}function a(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),c()+"/web/public/native/config"+t}const c=()=>"https://ljsp.lwcdn.com";function l(t){(async function(){const t=i.cachedServerOffset;if(t)return t;const e=i.pendingRequest||(i.pendingRequest=fetch(o)),n=await e,r=parseInt(n.headers.get("age")||"0"),s=await n.json(),a=Date.now()-s.millisUtc-1e3*r;return i.cachedServerOffset=a,i.cachedServerOffset})().then(e=>Object.assign(t,{server_time_offset:e}))}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,e){var o,r;e="object"==typeof e?e:{};const i={title:null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.title,description:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.description},s={ima:{parameters:function({media_id:t,duration:e,title:n,tags:o,category_name:r,ad_keywords:i}){return{ad_keywords:i||"",media_id:t||"",category:r||"",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,i,t,(delete(c=e).src,delete c.metadata,delete c.title,delete c.description,delete c.duration,delete c.poster,c),a);var c}const m=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,v=/^[A-Za-z0-9]{8}$/,y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/[A-Za-z0-9]{8}$/;function h(t){return"object"==typeof t&&"ovp/base64"==t.type}function w(t,e){return function(t,e){return!(!m.test(t)&&!f.test(t))&&(e.type="video/ovp",!0)}(t,e)||function(t,e){return!/[aeiou]/.test(t.toLowerCase())&&(!(!v.test(t)&&!y.test(t))&&(e&&(e.type="video/ovp"),!0))}(t,e)||h(e)}function g(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 _(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 b(t){return t.live}var E=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",OVP_CONFIG_FINALIZED:"ovp:config:finalized"});function O(t,e){const n=null==e?void 0:e.src;if(h(e))return function(t,e){const n=g(e.src||"");if(function(t){return"string"==typeof t.err}(n))return console.error(n.err);j(t,n)}(t,e);n&&(t.setState("is-source-processing",!0),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])=>{return 200==e?j(t,n):(r=n,(o=t).setState("is-source-processing",!1),r.message?o.emit("ovp:error",r):r.status?o.emit("ovp:error",new Error(u[r.status])):o.emit("ovp:error",r));var o,r})))}function j(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){t.emit("ovp:request:playlist:complete",function(t,e){const o=Object.assign({},t),r=(null==t?void 0:t.playlist)||{},i=n(e,r),s=((null==i?void 0:i.playlist)||[]).map(t=>{e.ima&&Object.assign(t,{ima:e.ima});const n=p(t,o);return delete n.playlist,n});return delete i.ima,Object.assign(i,{playlist:s})}(t.opts,e))}(t,e):b(e)?function(t,e){var n,o;const r=(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);r&&(e.live_start_time=Pipe.of(r).fmap(_).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(p,t.opts).unwrap())}(t,e)}const A={};function P(t,e,n){"object"!=typeof A[e]&&(A[e]=n);const o=t.opts,r=(null==o?void 0:o.metadata)||{};r.player_id=e,o.metadata=r,n.title&&delete n.title,n.description&&delete n.description;const i=Object.assign(o,n);t.setOpts(i),n.autoplay&&t.togglePlay(!0)}let S=!1;function L(t,e,n){T()||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,n;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,description:null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.description,metadata:t.metadata||{},chapters:t.chapters,thumbnails:t.thumbnails,subtitles:t.subtitles}}))})}(t,e)).catch(C))}function T(){return S}function C(t){S=!0,console.error("Failed to load recommendations: %j",t)}function x(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function I(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}const M="flowplayer-live-countdown";function k(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function D(t,e){let n=0;function o(){const o=k(e);if(o<0||isNaN(o)||0===t.reaper||void 0===e.live_start_time)return clearInterval(n),function(t,e,n){t.emit("ovp:live:countdown:complete");const o=I(t,M);if(o&&o.remove(),t.root.classList.remove("is-livecountdown"),n)return t.setState("is-source-processing",!1);t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);var r,i,s;r=t,i=t.root,s=o,i.classList.add("is-livecountdown"),r.emit("ovp:live:countdown:tick",{remaining_time:q(s+1)}),r.hasState("is-starting")||r.setState("is-starting",!0)}l(e),o(),n=setInterval(o,250)}function q(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+x(e.hours)+":"+x(e.minutes)+":"+x(e.seconds)}class WebsocketBridge{static of(t){return new WebsocketBridge(t)}constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}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 N=(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 r=window.customElements.get(n);return"function"!=typeof r?o:r})(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 R=["*.lwcdn.com","*.flowplayer.com","*.wowza.com"];function V(){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}}function U(t){const e=document.createElement("a");e.href=t;const n=e.pathname&&e.pathname.split(".");return n.length>1&&n[n.length-1]}function W(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const $=e=>{var{src:n}=e,o=t(e,["src"]);return[Object.assign({src:n,type:n?W("video/"+U(n)):""},o)]};function F(t){return $({src:t})}function z(e){var{src:n,type:o}=e,r=t(e,["src","type"]);return n&&o?[Object.assign({src:n,type:o},r)]:o&&!n?[Object.assign({type:o},r)]:$(Object.assign({src:n},r))}var H,B;!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(H||(H={}));const G=((B=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(null==o?void 0:o.src))return"string"!=typeof t.player_id||0===o.src.indexOf(t.player_id)||h(o)||(o.src=[t.player_id,o.src].join("/")),O(n,o)}wants(t,e,n){return w(t,e)}init(e,o,r){const i=new WebsocketBridge(r);let c=Object.assign({},e);const l=function(t){if(!c)return t;e.autoplay!==c.autoplay&&(c.autoplay=e.autoplay),delete c.src;const o=n(t,c);return r.emit("ovp:config:finalized",o),o};r.on("src",()=>{(r.currentSrc||r.root.classList.contains("is-livecountdown"))&&(c=!1)}),r.on("ovp:error",(function(t){r.emit("error",t.data)})),r.on("ovp:request:start",(function(){r.setState("is-waiting",!0),e.recommendations&&(e.recommendations=!1)})),r.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))})),r.on("ovp:message:realtime",(function({data:t}){var n;const o=null==t?void 0:t.event,i=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(o){case"METADATA":{const t=Object.assign(s,i),o=Object.assign(e,{metadata:t});o.live&&(null===(n=null==o?void 0:o.metadata)||void 0===n?void 0:n.live_start_time)&&(o.live_start_time=_(o.metadata.live_start_time)),r.setOpts(o);break}}})),r.on("beforeplay",(function(t){const n=e;if(b(n)){if(Q(n))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;var n;if(e.src&&(e.src=(n=e.src,"string"==typeof n?F(n):Array.isArray(n)||"object"!=typeof n?n.reduce((function(t,e){return"string"==typeof e&&(e=F(e)),"object"!=typeof e||Array.isArray(e)||(e=z(e)),t.concat(e)}),[]):z(n)).map(t=>(t.src&&t.src.startsWith("//")&&(t.src="https:"+t.src),t))),0==r.reaper||"object"!=typeof e||k(e)>0)return;const o=l(e);r.setOpts(o),r.setAttrs(o),o.src&&r.setSrc(o.src),r.setState("is-source-processing",!1)})),r.on("config",(function({data:t}){var n,i;if("string"==typeof e.src&&w(e.src,{}))return;if((null==t?void 0:t.domains)&&(null==t?void 0:t.domains.length)&&!((t,e)=>{const n=t.split(".").reverse();return e.concat(R).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)})})(V(),t.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");const o=document.createElement("h2");o.textContent="Playback Error";const r=document.createElement("p");r.textContent="Are you the site owner?";const i=document.createElement("a");i.classList.add("troubleshoot"),i.target="_blank",i.href="https://docs.flowplayer.com/troubleshooting/player#"+n.reason,i.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(o,r,i,s)}({root:o,video:r,data:{details:`Hostname ${V()} is not allowed to load player ${null===(n=t.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});if(e.src&&Z(e.src))return;const c=null==t?void 0:t.brand_color;return c&&r.root.style.setProperty("--fp-brand-color","#"==c[0]?c:"#"+c),"string"==typeof e.player_id&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)!==e.player_id?function(t,e){if("object"==typeof A[e])return console.debug("using Cache(%s)",e),P(t,e,A[e]);Pipe.of(e).fmap(a).fmap(s).fmap(n=>n.then(n=>P(t,e,n)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const n=e.data;if(!n||0==r.reaper)return;const{playlist:o}=n,i=t(n,["playlist"]),s=l(i);Array.isArray(s.playlist)&&(s.playlist=i),r.setOpts(s),r.setAttrs(s);const a={type:"flowplayer/playlist",items:o};r.setSrc(a),r.setState("is-source-processing",!1)})),r.on("ovp:live:countdown:start",(function(t){const n=t.data;if(!n||0==r.reaper)return;const i=l(n);if(r.setOpts(i),r.setAttrs(i),k(n)<=0)return r.emit("ovp:request:media:complete",n);I(r,M)||(o.appendChild(N(r,M)),D(r,e))})),r.on("timeupdate",(function(){var t,n,o;const i=e;b(i)?Q(i)||(r.togglePlay(!1),r.emit("ended")):e.recommendations&&(null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)&&(Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||T()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.player_id)&&L(r,e.metadata.media_id,e.metadata.player_id))})),r.on("reap",(function(){i.disconnect()}))}}).events=E,B);function Q(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)||_(o)>Date.now()}const Z=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;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,G)}));
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};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}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function b(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function A(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=b(t,"data.queue",b(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.className=s?"is-current":"is-queued",t.setAttribute("aria-current",""+s)})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","pause"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),n.setAttribute("tabindex","0"),n.setAttribute("role","listitem"),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=A("title",t);n&&e.append(n);const i=A("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var w;function x(t,e){var n,i;const s=e.sort||g,o=null!==(n=e.mode)&&void 0!==n?n:w.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function T(t){return t.idx==t.last_idx}function I(t){const e=t.idx+1;return e>t.last_idx?0:e}function _(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function g(t,e){return(e&w.SHUFFLE)==w.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function S(t){return x(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(w||(w={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const P=["touchstart","touchmove"];function q(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function N(t,e,n,i){Array.isArray(e)?e.forEach(e=>O(t,e,n,i)):O(t,e,n,i)}function O(t,e,n,i){if(s=e,!~P.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function Y(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,o=m(e,"flowplayer-playlist-interstitial");if(!o||!s||!n.delay)return;e.root.classList.add("is-interstitial");const l=s.members[I(s)];q(o,t.INTERSTITIAL_NEXT_ITEM,{next:l})}(e,i);C(e,_(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const o=s.idx,l=s.members[o],r=e.currentSrc;if(l.src&&e.setSrc(l.src),e.emit(t.PLAYLIST_NEXT,{next_index:o}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function k(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=S(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function F(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),N(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),N(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=b(t,"data.queue",b(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!T(t)||0!=(t.mode&w.LOOP))return t.members[I(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&w.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=F(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function R(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?w.SHUFFLE:w.FIFO;return e.loop&&(n|=w.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function M(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=k(e,o),l&&Y(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?T(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=S(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return Y(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&Y(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&q(n,t.INTERSTITIAL_CANCEL)}))}var j;const H=((j=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,_(n,!1))}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),M(i)}onload(e,n,i,s){R(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,j);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,H)}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}constructor(t){this.data=t}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}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function b(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function A(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=b(t,"data.queue",b(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.className=s?"is-current":"is-queued",t.setAttribute("aria-current",""+s)})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","pause"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),n.setAttribute("tabindex","0"),n.setAttribute("role","listitem"),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=A("title",t);n&&e.append(n);const i=A("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var w;function x(t,e){var n,i;const s=e.sort||g,o=null!==(n=e.mode)&&void 0!==n?n:w.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function T(t){return t.idx==t.last_idx}function I(t){const e=t.idx+1;return e>t.last_idx?0:e}function _(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function g(t,e){return(e&w.SHUFFLE)==w.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function S(t){return x(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(w||(w={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const P=["touchstart","touchmove"];function q(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function N(t,e,n,i){Array.isArray(e)?e.forEach(e=>O(t,e,n,i)):O(t,e,n,i)}function O(t,e,n,i){if(s=e,!~P.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function Y(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,o=m(e,"flowplayer-playlist-interstitial");if(!o||!s||!n.delay)return;e.root.classList.add("is-interstitial");const l=s.members[I(s)];q(o,t.INTERSTITIAL_NEXT_ITEM,{next:l})}(e,i);C(e,_(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const o=s.idx,l=s.members[o],r=e.currentSrc;if(l.src&&e.setSrc(l.src),e.emit(t.PLAYLIST_NEXT,{next_index:o}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function k(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=S(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function F(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),N(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),N(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=b(t,"data.queue",b(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!T(t)||0!=(t.mode&w.LOOP))return t.members[I(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&w.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=F(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function R(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?w.SHUFFLE:w.FIFO;return e.loop&&(n|=w.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function M(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=k(e,o),l&&Y(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?T(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=S(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return Y(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&Y(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&q(n,t.INTERSTITIAL_CANCEL)}))}var j;const H=((j=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,_(n,!1))}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),M(i)}onload(e,n,i,s){R(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,j);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,H)}));
package/plugins/qsel.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qsel=t())}(this,(function(){"use strict";function e(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const t=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const n="fp-on",s="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=o(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(i(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||o()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const n=t(this.player,e.summaryIcon);n.setAttribute("tabindex",""),this.summaryEle.append(n)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,s)=>{t.classList.toggle(n,s===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(n)})}toggle_visibility(e){this.classList.toggle(s,e),this.menu.style.setProperty("display",e?"none":"flex")}}function i(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function o(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function l(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(i(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();var r,a=Object.freeze({__proto__:null,SET_QUALITY:"quality:set",TRACKS:"quality:tracks",SWITCH:"quality:update",QUALITIES:"qualities"});const u=((r=class Qsel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-quality-menu",FlowplayerMenu)}init(n,s,i){if(!1===n.qsel)return;const o=t(i,"flowplayer-quality-menu");o instanceof FlowplayerMenu&&o.setMenuAttrs({summaryTitle:"HD",menuTitle:i.i18n("qsel.menu_title"),class:"fp-qsel",options_event:Qsel.events.TRACKS,item_selected_event:Qsel.events.SWITCH}),i.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(i,i.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(o)})),i.on("qualities",t=>{if(!Array.isArray(t.detail))return;const s=t.detail,r=e(n,"qsel.labels",[]);l(o,Qsel.events.TRACKS,s.flatMap((e,t)=>{if("boolean"==typeof r[t]&&!r[t])return[];let n=e.height?e.height+"p":e.text;return"number"==typeof e.height&&e.height>719&&(n+=" HD"),{text:r[t]||n,onclick:c.bind(0,i,e)}})),o instanceof FlowplayerMenu&&o.toggle_visibility(s.length<2)})}}).events=a,r);function c(e,t){e.emit("quality:set",t)}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,u)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.qsel=t())}(this,(function(){"use strict";function e(e,t,n){const s=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;s.length;){if(null==e)return n;const t=s.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}const t=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const n="fp-on",s="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.menuHeader=document.createElement("div"),this.menuTitle=document.createElement("h3"),this.olEle=document.createElement("ol"),this.olEle.id=o(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menuHeader.classList.add("fp-menu-header"),this.menuHeader.append(this.menuTitle,this.closeEle),this.menu.classList.add("fp-menu"),this.menu.append(this.menuHeader,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.classList.add("fp-menu-container"),this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{if(t.defaultPrevented)return;t.preventDefault();const n=this.menuContainer.open;n||(i(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.summaryEle.setAttribute("aria-expanded",n?"false":"true")}),this.addEventListener("focusin",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","true")}),this.addEventListener("focusout",e=>{const t=e.target;t instanceof HTMLLIElement&&t.setAttribute("aria-selected","false")}),this.append(this.menuContainer),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("aria-expanded","false"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.className=e.class,this.toggle_visibility(!0),this.summaryEle.id||(this.summaryEle.id=e.id||o()),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const n=t(this.player,e.summaryIcon);n.setAttribute("tabindex",""),this.summaryEle.append(n)}e.menuTitle&&(this.menuTitle.textContent=e.menuTitle),this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("aria-selected","false"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const s=document.createElement("span");s.textContent=e.text,n.append(s),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n),e.selected&&this.select_item(t)}select_item(e){this.options.forEach((t,s)=>{t.classList.toggle(n,s===e)})}unselect_item(){this.options.forEach(e=>{e.classList.remove(n)})}toggle_visibility(e){this.classList.toggle(s,e),this.menu.style.setProperty("display",e?"none":"flex")}}function i(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function o(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function l(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(i(),this.active_menu=void 0)})),function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();var r,a=Object.freeze({__proto__:null,SET_QUALITY:"quality:set",TRACKS:"quality:tracks",SWITCH:"quality:update",QUALITIES:"qualities"});const u=((r=class Qsel{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-quality-menu",FlowplayerMenu)}init(n,s,i){if(!1===n.qsel)return;const o=t(i,"flowplayer-quality-menu");o instanceof FlowplayerMenu&&o.setMenuAttrs({summaryTitle:"HD",menuTitle:i.i18n("qsel.menu_title"),class:"fp-qsel",options_event:r.events.TRACKS,item_selected_event:r.events.SWITCH}),i.on("mount",(function(){var e;null===(e=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(i,i.hasState("is-tv")?"flowplayer-tv-menu":"flowplayer-control"))||void 0===e||e.append(o)})),i.on("qualities",t=>{if(!Array.isArray(t.detail))return;const s=t.detail,a=e(n,"qsel.labels",[]);l(o,r.events.TRACKS,s.flatMap((e,t)=>{if("boolean"==typeof a[t]&&!a[t])return[];let n=e.height?e.height+"p":e.text;return"number"==typeof e.height&&e.height>719&&(n+=" HD"),{text:a[t]||n,onclick:c.bind(0,i,e)}})),o instanceof FlowplayerMenu&&o.toggle_visibility(s.length<2)})}}).events=a,r);function c(e,t){e.emit("quality:set",t)}return function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,u)}));