UNPKG

tplayer.js

Version:

Flexible and easy Dash/HLS/DRM integration for HTML5 video.

1 lines 109 kB
(self.webpackChunktplayer_js=self.webpackChunktplayer_js||[]).push([[443],{443:function(e,t,i){"object"==typeof navigator&&(e.exports=function(){"use strict";function e(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function t(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach((function(t){s(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var l={addCSS:!0,thumbWidth:15,watch:!0};function o(e,t){return function(){return Array.from(document.querySelectorAll(t)).includes(this)}.call(e,t)}var r=function(e){return null!=e?e.constructor:null},c=function(e,t){return!!(e&&t&&e instanceof t)},h=function(e){return r(e)===String},u=function(e){return Array.isArray(e)},d=function(e){return c(e,NodeList)},m=h,p=u,g=d,f=function(e){return c(e,Element)},b=function(e){return c(e,Event)},y=function(e){return function(e){return null==e}(e)||(h(e)||u(e)||d(e))&&!e.length||function(e){return r(e)===Object}(e)&&!Object.keys(e).length};var v=function(){function e(t,i){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),f(t)?this.element=t:m(t)&&(this.element=document.querySelector(t)),f(this.element)&&y(this.element.rangeTouch)&&(this.config=a({},l,{},i),this.init())}return function(e,i,s){i&&t(e.prototype,i),s&&t(e,s)}(e,[{key:"init",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="none",this.element.style.webKitUserSelect="none",this.element.style.touchAction="manipulation"),this.listeners(!0),this.element.rangeTouch=this)}},{key:"destroy",value:function(){e.enabled&&(this.config.addCSS&&(this.element.style.userSelect="",this.element.style.webKitUserSelect="",this.element.style.touchAction=""),this.listeners(!1),this.element.rangeTouch=null)}},{key:"listeners",value:function(e){var t=this,i=e?"addEventListener":"removeEventListener";["touchstart","touchmove","touchend"].forEach((function(e){t.element[i](e,(function(e){return t.set(e)}),!1)}))}},{key:"get",value:function(t){if(!e.enabled||!b(t))return null;var i,s=t.target,n=t.changedTouches[0],a=parseFloat(s.getAttribute("min"))||0,l=parseFloat(s.getAttribute("max"))||100,o=parseFloat(s.getAttribute("step"))||1,r=s.getBoundingClientRect(),c=100/r.width*(this.config.thumbWidth/2)/100;return 0>(i=100/r.width*(n.clientX-r.left))?i=0:100<i&&(i=100),50>i?i-=(100-2*i)*c:50<i&&(i+=2*(i-50)*c),a+function(e,t){if(1>t){var i=function(e){var t="".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}(t);return parseFloat(e.toFixed(i))}return Math.round(e/t)*t}(i/100*(l-a),o)}},{key:"set",value:function(t){e.enabled&&b(t)&&!t.target.disabled&&(t.preventDefault(),t.target.value=this.get(t),function(e,t){if(e&&t){var i=new Event(t,{bubbles:!0});e.dispatchEvent(i)}}(t.target,"touchend"===t.type?"change":"input"))}}],[{key:"setup",value:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},s=null;if(y(t)||m(t)?s=Array.from(document.querySelectorAll(m(t)?t:'input[type="range"]')):f(t)?s=[t]:g(t)?s=Array.from(t):p(t)&&(s=t.filter(f)),y(s))return null;var n=a({},l,{},i);if(m(t)&&n.watch){var r=new MutationObserver((function(i){Array.from(i).forEach((function(i){Array.from(i.addedNodes).forEach((function(i){f(i)&&o(i,t)&&new e(i,n)}))}))}));r.observe(document.body,{childList:!0,subtree:!0})}return s.map((function(t){return new e(t,i)}))}},{key:"enabled",get:function(){return"ontouchstart"in document.documentElement}}]),e}();const w=e=>null!=e?e.constructor:null,T=(e,t)=>Boolean(e&&t&&e instanceof t),k=e=>null==e,C=e=>w(e)===Object,A=e=>w(e)===String,S=e=>w(e)===Function,E=e=>Array.isArray(e),P=e=>T(e,NodeList),N=e=>k(e)||(A(e)||E(e)||P(e))&&!e.length||C(e)&&!Object.keys(e).length;var M=k,x=C,I=e=>w(e)===Number&&!Number.isNaN(e),L=A,$=e=>w(e)===Boolean,_=S,O=E,j=P,q=e=>null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument,D=e=>T(e,Event),H=e=>T(e,KeyboardEvent),F=e=>T(e,TextTrack)||!k(e)&&A(e.kind),R=e=>{if(T(e,window.URL))return!0;if(!A(e))return!1;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t=`http://${e}`);try{return!N(new URL(t).hostname)}catch(e){return!1}},V=N;const B=(()=>{const e=document.createElement("span"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},i=Object.keys(t).find((t=>void 0!==e.style[t]));return!!L(i)&&t[i]})();function U(e,t){setTimeout((()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch(e){}}),t)}const W={isIE:Boolean(window.document.documentMode),isEdge:window.navigator.userAgent.includes("Edge"),isWebkit:"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPhone:/(iPhone|iPod)/gi.test(navigator.platform),isIos:"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1||/(iPad|iPhone|iPod)/gi.test(navigator.platform)};function z(e,t){return t.split(".").reduce(((e,t)=>e&&e[t]),e)}function K(e={},...t){if(!t.length)return e;const i=t.shift();return x(i)?(Object.keys(i).forEach((t=>{x(i[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),K(e[t],i[t])):Object.assign(e,{[t]:i[t]})})),K(e,...t)):e}function Y(e,t){const i=e.length?e:[e];Array.from(i).reverse().forEach(((e,i)=>{const s=i>0?t.cloneNode(!0):t,n=e.parentNode,a=e.nextSibling;s.appendChild(e),a?n.insertBefore(s,a):n.appendChild(s)}))}function Q(e,t){q(e)&&!V(t)&&Object.entries(t).filter((([,e])=>!M(e))).forEach((([t,i])=>e.setAttribute(t,i)))}function X(e,t,i){const s=document.createElement(e);return x(t)&&Q(s,t),L(i)&&(s.innerText=i),s}function J(e,t,i,s){q(t)&&t.appendChild(X(e,i,s))}function G(e){j(e)||O(e)?Array.from(e).forEach(G):q(e)&&q(e.parentNode)&&e.parentNode.removeChild(e)}function Z(e){if(!q(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),t-=1}function ee(e,t){return q(t)&&q(t.parentNode)&&q(e)?(t.parentNode.replaceChild(e,t),e):null}function te(e,t){if(!L(e)||V(e))return{};const i={},s=K({},t);return e.split(",").forEach((e=>{const t=e.trim(),n=t.replace(".",""),a=t.replace(/[[\]]/g,"").split("="),[l]=a,o=a.length>1?a[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":L(s.class)?i.class=`${s.class} ${n}`:i.class=n;break;case"#":i.id=t.replace("#","");break;case"[":i[l]=o}})),K(s,i)}function ie(e,t){if(!q(e))return;let i=t;$(i)||(i=!e.hidden),e.hidden=i}function se(e,t,i){if(j(e))return Array.from(e).map((e=>se(e,t,i)));if(q(e)){let s="toggle";return void 0!==i&&(s=i?"add":"remove"),e.classList[s](t),e.classList.contains(t)}return!1}function ne(e,t){return q(e)&&e.classList.contains(t)}function ae(e,t){const{prototype:i}=Element;return(i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function le(e){return this.elements.container.querySelectorAll(e)}function oe(e){return this.elements.container.querySelector(e)}function re(e=null,t=!1){q(e)&&(e.focus({preventScroll:!0}),t&&se(e,this.config.classNames.tabFocus))}const ce={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},he={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,t,i){const s=W.isIPhone&&i&&he.playsinline,n=he[e]||"html5"!==t;return{api:n,ui:n&&he.rangeInput&&("video"!==e||!W.isIPhone||s)}},pip:!(W.isIPhone||!_(X("video").webkitSetPresentationMode)&&(!document.pictureInPictureEnabled||X("video").disablePictureInPicture)),airplay:_(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(V(e))return!1;const[t]=e.split("/");let i=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(ce).includes(i)&&(i+=`; codecs="${ce[e]}"`);try{return Boolean(i&&this.media.canPlayType(i).replace(/no/,""))}catch(e){return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range","range"===e.type})(),touch:"ontouchstart"in document.documentElement,transitions:!1!==B,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},ue=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,null)});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e})();function de(e,t,i,s=!1,n=!0,a=!1){if(!e||!("addEventListener"in e)||V(t)||!_(i))return;const l=t.split(" ");let o=a;ue&&(o={passive:n,capture:a}),l.forEach((t=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:t,callback:i,options:o}),e[s?"addEventListener":"removeEventListener"](t,i,o)}))}function me(e,t="",i,s=!0,n=!1){de.call(this,e,t,i,!0,s,n)}function pe(e,t="",i,s=!0,n=!1){de.call(this,e,t,i,!1,s,n)}function ge(e,t="",i,s=!0,n=!1){const a=(...l)=>{pe(e,t,a,s,n),i.apply(this,l)};de.call(this,e,t,a,!0,s,n)}function fe(e,t="",i=!1,s={}){if(!q(e)||V(t))return;const n=new CustomEvent(t,{bubbles:i,detail:{...s,plyr:this}});e.dispatchEvent(n)}function be(){this&&this.eventListeners&&(this.eventListeners.forEach((e=>{const{element:t,type:i,callback:s,options:n}=e;t.removeEventListener(i,s,n)})),this.eventListeners=[])}function ye(){return new Promise((e=>this.ready?setTimeout(e,0):me.call(this,this.elements.container,"ready",e))).then((()=>{}))}function ve(e){(e=>T(e,Promise)&&S(e.then))(e)&&e.then(null,(()=>{}))}function we(e){return O(e)?e.filter(((t,i)=>e.indexOf(t)===i)):e}function Te(e,t){return O(e)&&e.length?e.reduce(((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e)):null}function ke(e){return!(!window||!window.CSS)&&window.CSS.supports(e)}const Ce=[[1,1],[4,3],[3,4],[5,4],[4,5],[3,2],[2,3],[16,10],[10,16],[16,9],[9,16],[21,9],[9,21],[32,9],[9,32]].reduce(((e,[t,i])=>({...e,[t/i]:[t,i]})),{});function Ae(e){return!!(O(e)||L(e)&&e.includes(":"))&&(O(e)?e:e.split(":")).map(Number).every(I)}function Se(e){if(!O(e)||!e.every(I))return null;const[t,i]=e,s=(e,t)=>0===t?e:s(t,e%t),n=s(t,i);return[t/n,i/n]}function Ee(e){const t=e=>Ae(e)?e.split(":").map(Number):null;let i=t(e);if(null===i&&(i=t(this.config.ratio)),null===i&&!V(this.embed)&&O(this.embed.ratio)&&({ratio:i}=this.embed),null===i&&this.isHTML5){const{videoWidth:e,videoHeight:t}=this.media;i=[e,t]}return Se(i)}function Pe(e){if(!this.isVideo)return{};const{wrapper:t}=this.elements,i=Ee.call(this,e);if(!O(i))return{};const[s,n]=Se(i),a=100/s*n;if(ke(`aspect-ratio: ${s}/${n}`)?t.style.aspectRatio=`${s}/${n}`:t.style.paddingBottom=`${a}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const e=100/this.media.offsetWidth*parseInt(window.getComputedStyle(this.media).paddingBottom,10),i=(e-a)/(e/50);this.fullscreen.active?t.style.paddingBottom=null:this.media.style.transform=`translateY(-${i}%)`}else this.isHTML5&&t.classList.add(this.config.classNames.videoFixedRatio);return{padding:a,ratio:i}}function Ne(e,t,i=.05){const s=e/t,n=Te(Object.keys(Ce),s);return Math.abs(n-s)<=i?Ce[n]:[e,t]}const Me={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter((e=>{const t=e.getAttribute("type");return!!V(t)||he.mime.call(this,t)})):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:Me.getSources.call(this).map((e=>Number(e.getAttribute("size")))).filter(Boolean)},setup(){if(!this.isHTML5)return;const e=this;e.options.speed=e.config.speed.options,V(this.config.ratio)||Pe.call(e),Object.defineProperty(e.media,"quality",{get(){const t=Me.getSources.call(e).find((t=>t.getAttribute("src")===e.source));return t&&Number(t.getAttribute("size"))},set(t){if(e.quality!==t){if(e.config.quality.forced&&_(e.config.quality.onChange))e.config.quality.onChange(t);else{const i=Me.getSources.call(e).find((e=>Number(e.getAttribute("size"))===t));if(!i)return;const{currentTime:s,paused:n,preload:a,readyState:l,playbackRate:o}=e.media;e.media.src=i.getAttribute("src"),("none"!==a||l)&&(e.once("loadedmetadata",(()=>{e.speed=o,e.currentTime=s,n||ve(e.play())})),e.media.load())}fe.call(e,e.media,"qualitychange",!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(G(Me.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function xe(e,...t){return V(e)?e:e.toString().replace(/{(\d+)}/g,((e,i)=>t[i].toString()))}const Ie=(e="",t="",i="")=>e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString()),Le=(e="")=>e.toString().replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()));function $e(e){const t=document.createElement("div");return t.appendChild(e),t.innerHTML}const _e={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},Oe={get(e="",t={}){if(V(e)||V(t))return"";let i=z(t.i18n,e);if(V(i))return Object.keys(_e).includes(e)?_e[e]:"";const s={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(s).forEach((([e,t])=>{i=Ie(i,e,t)})),i}};class je{constructor(t){e(this,"get",(e=>{if(!je.supported||!this.enabled)return null;const t=window.localStorage.getItem(this.key);if(V(t))return null;const i=JSON.parse(t);return L(e)&&e.length?i[e]:i})),e(this,"set",(e=>{if(!je.supported||!this.enabled)return;if(!x(e))return;let t=this.get();V(t)&&(t={}),K(t,e);try{window.localStorage.setItem(this.key,JSON.stringify(t))}catch(e){}})),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const e="___test";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch(e){return!1}}}function qe(e,t="text"){return new Promise(((i,s)=>{try{const s=new XMLHttpRequest;if(!("withCredentials"in s))return;s.addEventListener("load",(()=>{if("text"===t)try{i(JSON.parse(s.responseText))}catch(e){i(s.responseText)}else i(s.response)})),s.addEventListener("error",(()=>{throw new Error(s.status)})),s.open("GET",e,!0),s.responseType=t,s.send()}catch(e){s(e)}}))}function De(e,t){if(!L(e))return;const i=L(t);let s=!1;const n=()=>null!==document.getElementById(t),a=(e,t)=>{e.innerHTML=t,i&&n()||document.body.insertAdjacentElement("afterbegin",e)};if(!i||!n()){const n=je.supported,l=document.createElement("div");if(l.setAttribute("hidden",""),i&&l.setAttribute("id",t),n){const e=window.localStorage.getItem(`cache-${t}`);if(s=null!==e,s){const t=JSON.parse(e);a(l,t.content)}}qe(e).then((e=>{if(!V(e)){if(n)try{window.localStorage.setItem(`cache-${t}`,JSON.stringify({content:e}))}catch(e){}a(l,e)}})).catch((()=>{}))}}const He=e=>Math.trunc(e/60/60%60,10);function Fe(e=0,t=!1,i=!1){if(!I(e))return Fe(void 0,t,i);const s=e=>`0${e}`.slice(-2);let n=He(e);const a=(l=e,Math.trunc(l/60%60,10));var l;const o=(e=>Math.trunc(e%60,10))(e);return n=t||n>0?`${n}:`:"",`${i&&e>0?"-":""}${n}${s(a)}:${s(o)}`}const Re={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),t=window.location.host?window.location.host:window.top.location.host,i=e.host!==t||W.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:i}},findElements(){try{return this.elements.controls=oe.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:le.call(this,this.config.selectors.buttons.play),pause:oe.call(this,this.config.selectors.buttons.pause),restart:oe.call(this,this.config.selectors.buttons.restart),rewind:oe.call(this,this.config.selectors.buttons.rewind),fastForward:oe.call(this,this.config.selectors.buttons.fastForward),mute:oe.call(this,this.config.selectors.buttons.mute),pip:oe.call(this,this.config.selectors.buttons.pip),airplay:oe.call(this,this.config.selectors.buttons.airplay),settings:oe.call(this,this.config.selectors.buttons.settings),captions:oe.call(this,this.config.selectors.buttons.captions),fullscreen:oe.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=oe.call(this,this.config.selectors.progress),this.elements.inputs={seek:oe.call(this,this.config.selectors.inputs.seek),volume:oe.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:oe.call(this,this.config.selectors.display.buffer),currentTime:oe.call(this,this.config.selectors.display.currentTime),duration:oe.call(this,this.config.selectors.display.duration)},q(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},createIcon(e,t){const i="http://www.w3.org/2000/svg",s=Re.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,a=document.createElementNS(i,"svg");Q(a,K(t,{"aria-hidden":"true",focusable:"false"}));const l=document.createElementNS(i,"use"),o=`${n}-${e}`;return"href"in l&&l.setAttributeNS("http://www.w3.org/1999/xlink","href",o),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o),a.appendChild(l),a},createLabel(e,t={}){const i=Oe.get(e,this.config);return X("span",{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")},i)},createBadge(e){if(V(e))return null;const t=X("span",{class:this.config.classNames.menu.value});return t.appendChild(X("span",{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){const i=K({},t);let s=function(e=""){let t=e.toString();return t=function(e=""){let t=e.toString();return t=Ie(t,"-"," "),t=Ie(t,"_"," "),t=Le(t),Ie(t," ","")}(t),t.charAt(0).toLowerCase()+t.slice(1)}(e);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach((e=>{Object.keys(i).includes(e)&&(n[e]=i[e],delete i[e])})),"button"!==n.element||Object.keys(i).includes("type")||(i.type="button"),Object.keys(i).includes("class")?i.class.split(" ").some((e=>e===this.config.classNames.control))||K(i,{class:`${i.class} ${this.config.classNames.control}`}):i.class=this.config.classNames.control,e){case"play":n.toggle=!0,n.label="play",n.labelPressed="pause",n.icon="play",n.iconPressed="pause";break;case"mute":n.toggle=!0,n.label="mute",n.labelPressed="unmute",n.icon="volume",n.iconPressed="muted";break;case"captions":n.toggle=!0,n.label="enableCaptions",n.labelPressed="disableCaptions",n.icon="captions-off",n.iconPressed="captions-on";break;case"fullscreen":n.toggle=!0,n.label="enterFullscreen",n.labelPressed="exitFullscreen",n.icon="enter-fullscreen",n.iconPressed="exit-fullscreen";break;case"play-large":i.class+=` ${this.config.classNames.control}--overlaid`,s="play",n.label="play",n.icon="play";break;default:V(n.label)&&(n.label=s),V(n.icon)&&(n.icon=e)}const a=X(n.element);return n.toggle?(a.appendChild(Re.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),a.appendChild(Re.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),a.appendChild(Re.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),a.appendChild(Re.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(a.appendChild(Re.createIcon.call(this,n.icon)),a.appendChild(Re.createLabel.call(this,n.label))),K(i,te(this.config.selectors.buttons[s],i)),Q(a,i),"play"===s?(O(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(a)):this.elements.buttons[s]=a,a},createRange(e,t){const i=X("input",K(te(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":Oe.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=i,Re.updateRangeFill.call(this,i),v.setup(i),i},createProgress(e,t){const i=X("progress",K(te(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){i.appendChild(X("span",null,"0"));const t={played:"played",buffer:"buffered"}[e],s=t?Oe.get(t,this.config):"";i.innerText=`% ${s.toLowerCase()}`}return this.elements.display[e]=i,i},createTime(e,t){const i=te(this.config.selectors.display[e],t),s=X("div",K(i,{class:`${i.class?i.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":Oe.get(e,this.config)}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,t){me.call(this,e,"keydown keyup",(i=>{if(![32,38,39,40].includes(i.which))return;if(i.preventDefault(),i.stopPropagation(),"keydown"===i.type)return;const s=ae(e,'[role="menuitemradio"]');if(!s&&[32,39].includes(i.which))Re.showMenuPanel.call(this,t,!0);else{let t;32!==i.which&&(40===i.which||s&&39===i.which?(t=e.nextElementSibling,q(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,q(t)||(t=e.parentNode.lastElementChild)),re.call(this,t,!0))}}),!1),me.call(this,e,"keyup",(e=>{13===e.which&&Re.focusFirstMenuItem.call(this,null,!0)}))},createMenuItem({value:e,list:t,type:i,title:s,badge:n=null,checked:a=!1}){const l=te(this.config.selectors.inputs[i]),o=X("button",K(l,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${l.class?l.class:""}`.trim(),"aria-checked":a,value:e})),r=X("span");r.innerHTML=s,q(n)&&r.appendChild(n),o.appendChild(r),Object.defineProperty(o,"checked",{enumerable:!0,get:()=>"true"===o.getAttribute("aria-checked"),set(e){e&&Array.from(o.parentNode.children).filter((e=>ae(e,'[role="menuitemradio"]'))).forEach((e=>e.setAttribute("aria-checked","false"))),o.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(o,"click keyup",(t=>{if(!H(t)||32===t.which){switch(t.preventDefault(),t.stopPropagation(),o.checked=!0,i){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=parseFloat(e)}Re.showMenuPanel.call(this,"home",H(t))}}),i,!1),Re.bindMenuItemShortcuts.call(this,o,i),t.appendChild(o)},formatTime(e=0,t=!1){return I(e)?Fe(e,He(this.duration)>0,t):e},updateTimeDisplay(e=null,t=0,i=!1){q(e)&&I(t)&&(e.innerText=Re.formatTime(t,i))},updateVolume(){this.supported.ui&&(q(this.elements.inputs.volume)&&Re.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),q(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(e,t=0){q(e)&&(e.value=t,Re.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!D(e))return;let t=0;const i=(e,t)=>{const i=I(t)?t:0,s=q(e)?e:this.elements.display.buffer;if(q(s)){s.value=i;const e=s.getElementsByTagName("span")[0];q(e)&&(e.childNodes[0].nodeValue=i)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":s=this.currentTime,n=this.duration,t=0===s||0===n||Number.isNaN(s)||Number.isNaN(n)?0:(s/n*100).toFixed(2),"timeupdate"===e.type&&Re.setRange.call(this,this.elements.inputs.seek,t);break;case"playing":case"progress":i(this.elements.display.buffer,100*this.buffered)}var s,n},updateRangeFill(e){const t=D(e)?e.target:e;if(q(t)&&"range"===t.getAttribute("type")){if(ae(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);const e=Re.formatTime(this.currentTime),i=Re.formatTime(this.duration),s=Oe.get("seekLabel",this.config);t.setAttribute("aria-valuetext",s.replace("{currentTime}",e).replace("{duration}",i))}else if(ae(t,this.config.selectors.inputs.volume)){const e=100*t.value;t.setAttribute("aria-valuenow",e),t.setAttribute("aria-valuetext",`${e.toFixed(1)}%`)}else t.setAttribute("aria-valuenow",t.value);W.isWebkit&&t.style.setProperty("--value",t.value/t.max*100+"%")}},updateSeekTooltip(e){if(!this.config.tooltips.seek||!q(this.elements.inputs.seek)||!q(this.elements.display.seekTooltip)||0===this.duration)return;const t=`${this.config.classNames.tooltip}--visible`,i=e=>se(this.elements.display.seekTooltip,t,e);if(this.touch)return void i(!1);let s=0;const n=this.elements.progress.getBoundingClientRect();if(D(e))s=100/n.width*(e.pageX-n.left);else{if(!ne(this.elements.display.seekTooltip,t))return;s=parseFloat(this.elements.display.seekTooltip.style.left,10)}s<0?s=0:s>100&&(s=100),Re.updateTimeDisplay.call(this,this.elements.display.seekTooltip,this.duration/100*s),this.elements.display.seekTooltip.style.left=`${s}%`,D(e)&&["mouseenter","mouseleave"].includes(e.type)&&i("mouseenter"===e.type)},timeUpdate(e){const t=!q(this.elements.display.duration)&&this.config.invertTime;Re.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||Re.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return ie(this.elements.display.currentTime,!0),void ie(this.elements.progress,!0);q(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=q(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&Re.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&Re.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),Re.updateSeekTooltip.call(this)},toggleMenuButton(e,t){ie(this.elements.settings.buttons[e],!t)},updateSetting(e,t,i){const s=this.elements.settings.panels[e];let n=null,a=t;if("captions"===e)n=this.currentTrack;else{if(n=V(i)?this[e]:i,V(n)&&(n=this.config[e].default),!V(this.options[e])&&!this.options[e].includes(n))return void this.debug.warn(`Unsupported value of '${n}' for ${e}`);if(!this.config[e].options.includes(n))return void this.debug.warn(`Disabled value of '${n}' for ${e}`)}if(q(a)||(a=s&&s.querySelector('[role="menu"]')),!q(a))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=Re.getLabel.call(this,e,n);const l=a&&a.querySelector(`[value="${n}"]`);q(l)&&(l.checked=!0)},getLabel(e,t){switch(e){case"speed":return 1===t?Oe.get("normal",this.config):`${t}&times;`;case"quality":if(I(t)){const e=Oe.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return Le(t);case"captions":return Ue.getLabel.call(this);default:return null}},setQualityMenu(e){if(!q(this.elements.settings.panels.quality))return;const t="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]');O(e)&&(this.options.quality=we(e).filter((e=>this.config.quality.options.includes(e))));const s=!V(this.options.quality)&&this.options.quality.length>1;if(Re.toggleMenuButton.call(this,t,s),Z(i),Re.checkMenu.call(this),!s)return;const n=e=>{const t=Oe.get(`qualityBadge.${e}`,this.config);return t.length?Re.createBadge.call(this,t):null};this.options.quality.sort(((e,t)=>{const i=this.config.quality.options;return i.indexOf(e)>i.indexOf(t)?1:-1})).forEach((e=>{Re.createMenuItem.call(this,{value:e,list:i,type:t,title:Re.getLabel.call(this,"quality",e),badge:n(e)})})),Re.updateSetting.call(this,t,i)},setCaptionsMenu(){if(!q(this.elements.settings.panels.captions))return;const e="captions",t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=Ue.getTracks.call(this),s=Boolean(i.length);if(Re.toggleMenuButton.call(this,e,s),Z(t),Re.checkMenu.call(this),!s)return;const n=i.map(((e,i)=>({value:i,checked:this.captions.toggled&&this.currentTrack===i,title:Ue.getLabel.call(this,e),badge:e.language&&Re.createBadge.call(this,e.language.toUpperCase()),list:t,type:"language"})));n.unshift({value:-1,checked:!this.captions.toggled,title:Oe.get("disabled",this.config),list:t,type:"language"}),n.forEach(Re.createMenuItem.bind(this)),Re.updateSetting.call(this,e,t)},setSpeedMenu(){if(!q(this.elements.settings.panels.speed))return;const e="speed",t=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter((e=>e>=this.minimumSpeed&&e<=this.maximumSpeed));const i=!V(this.options.speed)&&this.options.speed.length>1;Re.toggleMenuButton.call(this,e,i),Z(t),Re.checkMenu.call(this),i&&(this.options.speed.forEach((i=>{Re.createMenuItem.call(this,{value:i,list:t,type:e,title:Re.getLabel.call(this,"speed",i)})})),Re.updateSetting.call(this,e,t))},checkMenu(){const{buttons:e}=this.elements.settings,t=!V(e)&&Object.values(e).some((e=>!e.hidden));ie(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let i=e;q(i)||(i=Object.values(this.elements.settings.panels).find((e=>!e.hidden)));const s=i.querySelector('[role^="menuitem"]');re.call(this,s,t)},toggleMenu(e){const{popup:t}=this.elements.settings,i=this.elements.buttons.settings;if(!q(t)||!q(i))return;const{hidden:s}=t;let n=s;if($(e))n=e;else if(H(e)&&27===e.which)n=!1;else if(D(e)){const s=_(e.composedPath)?e.composedPath()[0]:e.target,a=t.contains(s);if(a||!a&&e.target!==i&&n)return}i.setAttribute("aria-expanded",n),ie(t,!n),se(this.elements.container,this.config.classNames.menu.open,n),n&&H(e)?Re.focusFirstMenuItem.call(this,null,!0):n||s||re.call(this,i,H(e))},getMenuSize(e){const t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);const i=t.scrollWidth,s=t.scrollHeight;return G(t),{width:i,height:s}},showMenuPanel(e="",t=!1){const i=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!q(i))return;const s=i.parentNode,n=Array.from(s.children).find((e=>!e.hidden));if(he.transitions&&!he.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const e=Re.getMenuSize.call(this,i),t=e=>{e.target===s&&["width","height"].includes(e.propertyName)&&(s.style.width="",s.style.height="",pe.call(this,s,B,t))};me.call(this,s,B,t),s.style.width=`${e.width}px`,s.style.height=`${e.height}px`}ie(n,!0),ie(i,!1),Re.focusFirstMenuItem.call(this,i,t)},setDownloadUrl(){const e=this.elements.buttons.download;q(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:t,createButton:i,createProgress:s,createRange:n,createTime:a,setQualityMenu:l,setSpeedMenu:o,showMenuPanel:r}=Re;this.elements.controls=null,O(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(i.call(this,"play-large"));const c=X("div",te(this.config.selectors.controls.wrapper));this.elements.controls=c;const h={class:"plyr__controls__item"};return we(O(this.config.controls)?this.config.controls:[]).forEach((l=>{if("restart"===l&&c.appendChild(i.call(this,"restart",h)),"rewind"===l&&c.appendChild(i.call(this,"rewind",h)),"play"===l&&c.appendChild(i.call(this,"play",h)),"fast-forward"===l&&c.appendChild(i.call(this,"fast-forward",h)),"progress"===l){const t=X("div",{class:`${h.class} plyr__progress__container`}),i=X("div",te(this.config.selectors.progress));if(i.appendChild(n.call(this,"seek",{id:`plyr-seek-${e.id}`})),i.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const e=X("span",{class:this.config.classNames.tooltip},"00:00");i.appendChild(e),this.elements.display.seekTooltip=e}this.elements.progress=i,t.appendChild(this.elements.progress),c.appendChild(t)}if("current-time"===l&&c.appendChild(a.call(this,"currentTime",h)),"duration"===l&&c.appendChild(a.call(this,"duration",h)),"mute"===l||"volume"===l){let{volume:t}=this.elements;if(q(t)&&c.contains(t)||(t=X("div",K({},h,{class:`${h.class} plyr__volume`.trim()})),this.elements.volume=t,c.appendChild(t)),"mute"===l&&t.appendChild(i.call(this,"mute")),"volume"===l&&!W.isIos){const i={max:1,step:.05,value:this.config.volume};t.appendChild(n.call(this,"volume",K(i,{id:`plyr-volume-${e.id}`})))}}if("captions"===l&&c.appendChild(i.call(this,"captions",h)),"settings"===l&&!V(this.config.settings)){const s=X("div",K({},h,{class:`${h.class} plyr__menu`.trim(),hidden:""}));s.appendChild(i.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const n=X("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),a=X("div"),l=X("div",{id:`plyr-settings-${e.id}-home`}),o=X("div",{role:"menu"});l.appendChild(o),a.appendChild(l),this.elements.settings.panels.home=l,this.config.settings.forEach((i=>{const s=X("button",K(te(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));t.call(this,s,i),me.call(this,s,"click",(()=>{r.call(this,i,!1)}));const n=X("span",null,Oe.get(i,this.config)),l=X("span",{class:this.config.classNames.menu.value});l.innerHTML=e[i],n.appendChild(l),s.appendChild(n),o.appendChild(s);const c=X("div",{id:`plyr-settings-${e.id}-${i}`,hidden:""}),h=X("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});h.appendChild(X("span",{"aria-hidden":!0},Oe.get(i,this.config))),h.appendChild(X("span",{class:this.config.classNames.hidden},Oe.get("menuBack",this.config))),me.call(this,c,"keydown",(e=>{37===e.which&&(e.preventDefault(),e.stopPropagation(),r.call(this,"home",!0))}),!1),me.call(this,h,"click",(()=>{r.call(this,"home",!1)})),c.appendChild(h),c.appendChild(X("div",{role:"menu"})),a.appendChild(c),this.elements.settings.buttons[i]=s,this.elements.settings.panels[i]=c})),n.appendChild(a),s.appendChild(n),c.appendChild(s),this.elements.settings.popup=n,this.elements.settings.menu=s}if("pip"===l&&he.pip&&c.appendChild(i.call(this,"pip",h)),"airplay"===l&&he.airplay&&c.appendChild(i.call(this,"airplay",h)),"download"===l){const e=K({},h,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(e.download="");const{download:t}=this.config.urls;!R(t)&&this.isEmbed&&K(e,{icon:`logo-${this.provider}`,label:this.provider}),c.appendChild(i.call(this,"download",e))}"fullscreen"===l&&c.appendChild(i.call(this,"fullscreen",h))})),this.isHTML5&&l.call(this,Me.getQualityOptions.call(this)),o.call(this),c},inject(){if(this.config.loadSprite){const e=Re.getIconUrl.call(this);e.cors&&De(e.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let e=null;this.elements.controls=null;const t={id:this.id,seektime:this.config.seekTime,title:this.config.title};let i,s=!0;if(_(this.config.controls)&&(this.config.controls=this.config.controls.call(this,t)),this.config.controls||(this.config.controls=[]),q(this.config.controls)||L(this.config.controls)?e=this.config.controls:(e=Re.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:Ue.getLabel.call(this)}),s=!1),s&&L(this.config.controls)&&(e=(e=>{let i=e;return Object.entries(t).forEach((([e,t])=>{i=Ie(i,`{${e}}`,t)})),i})(e)),L(this.config.selectors.controls.container)&&(i=document.querySelector(this.config.selectors.controls.container)),q(i)||(i=this.elements.container),i[q(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),q(this.elements.controls)||Re.findElements.call(this),!V(this.elements.buttons)){const e=e=>{const t=this.config.classNames.controlPressed;Object.defineProperty(e,"pressed",{enumerable:!0,get:()=>ne(e,t),set(i=!1){se(e,t,i)}})};Object.values(this.elements.buttons).filter(Boolean).forEach((t=>{O(t)||j(t)?Array.from(t).filter(Boolean).forEach(e):e(t)}))}if(W.isEdge&&U(i),this.config.tooltips.controls){const{classNames:e,selectors:t}=this.config,i=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,s=le.call(this,i);Array.from(s).forEach((e=>{se(e,this.config.classNames.hidden,!1),se(e,this.config.classNames.tooltip,!0)}))}}};function Ve(e,t=!0){let i=e;if(t){const e=document.createElement("a");e.href=i,i=e.href}try{return new URL(i)}catch(e){return null}}function Be(e){const t=new URLSearchParams;return x(e)&&Object.entries(e).forEach((([e,i])=>{t.set(e,i)})),t}const Ue={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!he.textTracks)return void(O(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Re.setCaptionsMenu.call(this));var e,t;if(q(this.elements.captions)||(this.elements.captions=X("div",te(this.config.selectors.captions)),e=this.elements.captions,t=this.elements.wrapper,q(e)&&q(t)&&t.parentNode.insertBefore(e,t.nextSibling)),W.isIE&&window.URL){const e=this.media.querySelectorAll("track");Array.from(e).forEach((e=>{const t=e.getAttribute("src"),i=Ve(t);null!==i&&i.hostname!==window.location.href.hostname&&["http:","https:"].includes(i.protocol)&&qe(t,"blob").then((t=>{e.setAttribute("src",window.URL.createObjectURL(t))})).catch((()=>{G(e)}))}))}const i=we((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map((e=>e.split("-")[0])));let s=(this.storage.get("language")||this.config.captions.language||"auto").toLowerCase();"auto"===s&&([s]=i);let n=this.storage.get("captions");if($(n)||({active:n}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:n,language:s,languages:i}),this.isHTML5){const e=this.config.captions.update?"addtrack removetrack":"removetrack";me.call(this,this.media.textTracks,e,Ue.update.bind(this))}setTimeout(Ue.update.bind(this),0)},update(){const e=Ue.getTracks.call(this,!0),{active:t,language:i,meta:s,currentTrackNode:n}=this.captions,a=Boolean(e.find((e=>e.language===i)));this.isHTML5&&this.isVideo&&e.filter((e=>!s.get(e))).forEach((e=>{this.debug.log("Track added",e),s.set(e,{default:"showing"===e.mode}),"showing"===e.mode&&(e.mode="hidden"),me.call(this,e,"cuechange",(()=>Ue.updateCues.call(this)))})),(a&&this.language!==i||!e.includes(n))&&(Ue.setLanguage.call(this,i),Ue.toggle.call(this,t&&a)),this.elements&&se(this.elements.container,this.config.classNames.captions.enabled,!V(e)),O(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Re.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;const{toggled:i}=this.captions,s=this.config.classNames.captions.active,n=M(e)?!i:e;if(n!==i){if(t||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!t){const e=Ue.getTracks.call(this),t=Ue.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=t.language,void Ue.set.call(this,e.indexOf(t))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),se(this.elements.container,s,n),this.captions.toggled=n,Re.updateSetting.call(this,"captions"),fe.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout((()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")}))},set(e,t=!0){const i=Ue.getTracks.call(this);if(-1!==e)if(I(e))if(e in i){if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const s=i[e],{language:n}=s||{};this.captions.currentTrackNode=s,Re.updateSetting.call(this,"captions"),t||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n),fe.call(this,this.media,"languagechange")}Ue.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&Ue.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else Ue.toggle.call(this,!1,t)},setLanguage(e,t=!0){if(!L(e))return void this.debug.warn("Invalid language argument",e);const i=e.toLowerCase();this.captions.language=i;const s=Ue.getTracks.call(this),n=Ue.findTrack.call(this,[i]);Ue.set.call(this,s.indexOf(n),t)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter((t=>!this.isHTML5||e||this.captions.meta.has(t))).filter((e=>["captions","subtitles"].includes(e.kind)))},findTrack(e,t=!1){const i=Ue.getTracks.call(this),s=e=>Number((this.captions.meta.get(e)||{}).default),n=Array.from(i).sort(((e,t)=>s(t)-s(e)));let a;return e.every((e=>(a=n.find((t=>t.language===e)),!a))),a||(t?n[0]:void 0)},getCurrentTrack(){return Ue.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!F(t)&&he.textTracks&&this.captions.toggled&&(t=Ue.getCurrentTrack.call(this)),F(t)?V(t.label)?V(t.language)?Oe.get("enabled",this.config):e.language.toUpperCase():t.label:Oe.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!q(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!M(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let t=e;if(!t){const e=Ue.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map((e=>e.getCueAsHTML())).map($e)}const i=t.map((e=>e.trim())).join("\n");if(i!==this.elements.captions.innerHTML){Z(this.elements.captions);const e=X("span",te(this.config.selectors.caption));e.innerHTML=i,this.elements.captions.appendChild(e),fe.call(this,this.media,"cuechange")}}},We={enabled:!0,title:"",debug:!1,autoplay:!1,autopause:!0,playsinline:!0,seekTime:10,volume:1,muted:!1,duration:null,displayDuration:!0,invertTime:!0,toggleInvert:!0,ratio:null,clickToPlay:!0,hideControls:!0,resetOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/3.6.12/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isIos:"plyr--is-ios",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},tabFocus:"plyr__tab-focus",previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:""},vimeo:{byline:!1,portrait:!1,title:!1,speed:!0,transparent:!1,customControls:!0,referrerPolicy:null,premium:!1},youtube:{rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,customControls:!0,noCookie:!1}},ze="picture-in-picture",Ke={html5:"html5",youtube:"youtube",vimeo:"vimeo"},Ye="video",Qe=()=>{};class Xe{constructor(e=!1){this.enabled=window.console&&e,this.enabled&&this.log("Debugging enabled")}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):Qe}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):Qe}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):Qe}}class Je{constructor(t){e(this,"onChange",(()=>{if(!this.enabled)return;const e=this.player.elements.buttons.fullscreen;q(e)&&(e.pressed=this.active);const t=this.target===this.player.media?this.target:this.player.elements.container;fe.call(this.player,t,this.active?"enterfullscreen":"exitfullscreen",!0)})),e(this,"toggleFallback",((e=!1)=>{if(e?this.scrollPosition={x:window.scrollX||0,y:window.scrollY||0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=e?"hidden":"",se(this.target,this.player.config.classNames.fullscreen.fallback,e),W.isIos){let t=document.head.querySelector('meta[name="viewport"]');const i="viewport-fit=cover";t||(t=document.createElement("meta"),t.setAttribute("name","viewport"));const s=L(t.content)&&t.content.includes(i);e?(this.cleanupViewport=!s,s||(t.content+=`,${i}`)):this.cleanupViewport&&(t.content=t.content.split(",").filter((e=>e.trim()!==i)).join(","))}this.onChange()})),e(this,"trapFocus",(e=>{if(W.isIos||!this.active||"Tab"!==e.key||9!==e.keyCode)return;const t=document.activeElement,i=le.call(this.player,"a[href], button:not(:disabled), input:not(:disabled), [tabindex]"),[s]=i,n=i[i.length-1];t!==n||e.shiftKey?t===s&&e.shiftKey&&(n.focus(),e.preventDefault()):(s.focus(),e.preventDefault())})),e(this,"update",(()=>{if(this.enabled){let e;e=this.forceFallback?"Fallback (forced)":Je.native?"Native":"Fallback",this.player.debug.log(`${e} fullscreen enabled`)}else this.player.debug.log("Fullscreen not supported and fallback disabled");se(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.enabled)})),e(this,"enter",(()=>{this.enabled&&(W.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!Je.native||this.forceFallback?this.toggleFallback(!0):this.prefix?V(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:"hide"}))})),e(this,"exit",(()=>{if(this.enabled)if(W.isIos&&this.player.config.fullscreen.iosNative)this.target.webkitExitFullscreen(),ve(this.player.play());else if(!Je.native||this.forceFallback)this.toggleFallback(!1);else if(this.prefix){if(!V(this.prefix)){const e="moz"===this.prefix?"Cancel":"Exit";document[`${this.prefix}${e}${this.property}`]()}}else(document.cancelFullScreen||document.exitFullscreen).call(document)})),e(this,"toggle",(()=>{this.active?this.exit():this.enter()})),this.player=t,this.prefix=Je.prefix,this.property=Je.property,this.scrollPosition={x:0,y:0},this.forceFallback="force"===t.config.fullscreen.fall