UNPKG

@supercast/plyr

Version:

A simple, accessible and customizable HTML5, YouTube and Vimeo media player

1 lines 111 kB
"object"==typeof navigator&&function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Plyr",t):(e="undefined"!=typeof globalThis?globalThis:e||self).Plyr=t()}(this,(function(){"use strict";function e(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(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 i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(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 n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var a={addCSS:!0,thumbWidth:15,watch:!0};var l=function(e){return null!=e?e.constructor:null},r=function(e,t){return!!(e&&t&&e instanceof t)},o=function(e){return null==e},c=function(e){return l(e)===Object},h=function(e){return l(e)===String},u=function(e){return Array.isArray(e)},d=function(e){return r(e,NodeList)},p=h,m=u,g=d,f=function(e){return r(e,Element)},y=function(e){return r(e,Event)},b=function(e){return o(e)||(h(e)||u(e)||d(e))&&!e.length||c(e)&&!Object.keys(e).length};function v(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}var w=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:p(t)&&(this.element=document.querySelector(t)),f(this.element)&&b(this.element.rangeTouch)&&(this.config=n({},a,{},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||!y(t))return null;var i,s=t.target,n=t.changedTouches[0],a=parseFloat(s.getAttribute("min"))||0,l=parseFloat(s.getAttribute("max"))||100,r=parseFloat(s.getAttribute("step"))||1,o=s.getBoundingClientRect(),c=100/o.width*(this.config.thumbWidth/2)/100;return 0>(i=100/o.width*(n.clientX-o.left))?i=0:100<i&&(i=100),50>i?i-=(100-2*i)*c:50<i&&(i+=2*(i-50)*c),a+v(i/100*(l-a),r)}},{key:"set",value:function(t){e.enabled&&y(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(b(t)||p(t)?s=Array.from(document.querySelectorAll(p(t)?t:'input[type="range"]')):f(t)?s=[t]:g(t)?s=Array.from(t):m(t)&&(s=t.filter(f)),b(s))return null;var l=n({},a,{},i);if(p(t)&&l.watch){var r=new MutationObserver((function(i){Array.from(i).forEach((function(i){Array.from(i.addedNodes).forEach((function(i){f(i)&&function(e,t){return function(){return Array.from(document.querySelectorAll(t)).includes(this)}.call(e,t)}(i,t)&&new e(i,l)}))}))}));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 T=e=>null!=e?e.constructor:null,k=(e,t)=>Boolean(e&&t&&e instanceof t),C=e=>null==e,A=e=>T(e)===Object,S=e=>T(e)===String,E=e=>"function"==typeof e,P=e=>Array.isArray(e),M=e=>k(e,NodeList),x=e=>C(e)||(S(e)||P(e)||M(e))&&!e.length||A(e)&&!Object.keys(e).length;var N=C,I=A,L=e=>T(e)===Number&&!Number.isNaN(e),$=S,_=e=>T(e)===Boolean,O=E,j=P,q=M,D=e=>null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument,H=e=>k(e,Event),R=e=>k(e,KeyboardEvent),F=e=>k(e,TextTrack)||!C(e)&&S(e.kind),V=e=>k(e,Promise)&&E(e.then),B=e=>{if(k(e,window.URL))return!0;if(!S(e))return!1;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t=`http://${e}`);try{return!x(new URL(t).hostname)}catch(e){return!1}},U=x;const W=(()=>{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!!$(i)&&t[i]})();function z(e,t){setTimeout((()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch(e){}}),t)}var K={isIE:Boolean(window.document.documentMode),isEdge:/Edge/g.test(navigator.userAgent),isWebKit:"WebkitAppearance"in document.documentElement.style&&!/Edge/g.test(navigator.userAgent),isIPhone:/iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1,isIPadOS:"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function Y(e,t){return t.split(".").reduce(((e,t)=>e&&e[t]),e)}function Q(e={},...t){if(!t.length)return e;const i=t.shift();return I(i)?(Object.keys(i).forEach((t=>{I(i[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),Q(e[t],i[t])):Object.assign(e,{[t]:i[t]})})),Q(e,...t)):e}function X(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 J(e,t){D(e)&&!U(t)&&Object.entries(t).filter((([,e])=>!N(e))).forEach((([t,i])=>e.setAttribute(t,i)))}function G(e,t,i){const s=document.createElement(e);return I(t)&&J(s,t),$(i)&&(s.innerText=i),s}function Z(e,t,i,s){D(t)&&t.appendChild(G(e,i,s))}function ee(e){q(e)||j(e)?Array.from(e).forEach(ee):D(e)&&D(e.parentNode)&&e.parentNode.removeChild(e)}function te(e){if(!D(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),t-=1}function ie(e,t){return D(t)&&D(t.parentNode)&&D(e)?(t.parentNode.replaceChild(e,t),e):null}function se(e,t){if(!$(e)||U(e))return{};const i={},s=Q({},t);return e.split(",").forEach((e=>{const t=e.trim(),n=t.replace(".",""),a=t.replace(/[[\]]/g,"").split("="),[l]=a,r=a.length>1?a[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":$(s.class)?i.class=`${s.class} ${n}`:i.class=n;break;case"#":i.id=t.replace("#","");break;case"[":i[l]=r}})),Q(s,i)}function ne(e,t){if(!D(e))return;let i=t;_(i)||(i=!e.hidden),e.hidden=i}function ae(e,t,i){if(q(e))return Array.from(e).map((e=>ae(e,t,i)));if(D(e)){let s="toggle";return void 0!==i&&(s=i?"add":"remove"),e.classList[s](t),e.classList.contains(t)}return!1}function le(e,t){return D(e)&&e.classList.contains(t)}function re(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 oe(e){return this.elements.container.querySelectorAll(e)}function ce(e){return this.elements.container.querySelector(e)}function he(e=null,t=!1){D(e)&&e.focus({preventScroll:!0,focusVisible:t})}const ue={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},de={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,t){const i=de[e]||"html5"!==t;return{api:i,ui:i&&de.rangeInput}},pip:document.pictureInPictureEnabled&&!G("video").disablePictureInPicture,airplay:O(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(U(e))return!1;const[t]=e.split("/");let i=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(ue).includes(i)&&(i+=`; codecs="${ue[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!==W,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},pe=(()=>{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 me(e,t,i,s=!1,n=!0,a=!1){if(!e||!("addEventListener"in e)||U(t)||!O(i))return;const l=t.split(" ");let r=a;pe&&(r={passive:n,capture:a}),l.forEach((t=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:t,callback:i,options:r}),e[s?"addEventListener":"removeEventListener"](t,i,r)}))}function ge(e,t="",i,s=!0,n=!1){me.call(this,e,t,i,!0,s,n)}function fe(e,t="",i,s=!0,n=!1){me.call(this,e,t,i,!1,s,n)}function ye(e,t="",i,s=!0,n=!1){const a=(...l)=>{fe(e,t,a,s,n),i.apply(this,l)};me.call(this,e,t,a,!0,s,n)}function be(e,t="",i=!1,s={}){if(!D(e)||U(t))return;const n=new CustomEvent(t,{bubbles:i,detail:{...s,plyr:this}});e.dispatchEvent(n)}function ve(){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 we(){return new Promise((e=>this.ready?setTimeout(e,0):ge.call(this,this.elements.container,"ready",e))).then((()=>{}))}function Te(e){V(e)&&e.then(null,(()=>{}))}function ke(e){return j(e)?e.filter(((t,i)=>e.indexOf(t)===i)):e}function Ce(e,t){return j(e)&&e.length?e.reduce(((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e)):null}function Ae(e){return!(!window||!window.CSS)&&window.CSS.supports(e)}const Se=[[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 Ee(e){if(!(j(e)||$(e)&&e.includes(":")))return!1;return(j(e)?e:e.split(":")).map(Number).every(L)}function Pe(e){if(!j(e)||!e.every(L))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 Me(e){const t=e=>Ee(e)?e.split(":").map(Number):null;let i=t(e);if(null===i&&(i=t(this.config.ratio)),null===i&&!U(this.embed)&&j(this.embed.ratio)&&({ratio:i}=this.embed),null===i&&this.isHTML5){const{videoWidth:e,videoHeight:t}=this.media;i=[e,t]}return Pe(i)}function xe(e){if(!this.isVideo)return{};const{wrapper:t}=this.elements,i=Me.call(this,e);if(!j(i))return{};const[s,n]=Pe(i),a=100/s*n;if(Ae(`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=Ce(Object.keys(Se),s);return Math.abs(n-s)<=i?Se[n]:[e,t]}const Ie={getSources(){if(!this.isHTML5)return[];return Array.from(this.media.querySelectorAll("source")).filter((e=>{const t=e.getAttribute("type");return!!U(t)||de.mime.call(this,t)}))},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:Ie.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,U(this.config.ratio)||xe.call(e),Object.defineProperty(e.media,"quality",{get(){const t=Ie.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&&O(e.config.quality.onChange))e.config.quality.onChange(t);else{const i=Ie.getSources.call(e).find((e=>Number(e.getAttribute("size"))===t));if(!i)return;const{currentTime:s,paused:n,preload:a,readyState:l,playbackRate:r}=e.media;e.media.src=i.getAttribute("src"),("none"!==a||l)&&(e.once("loadedmetadata",(()=>{e.speed=r,e.currentTime=s,n||Te(e.play())})),e.media.load())}be.call(e,e.media,"qualitychange",!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(ee(Ie.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function Le(e,...t){return U(e)?e:e.toString().replace(/{(\d+)}/g,((e,i)=>t[i].toString()))}const $e=(e="",t="",i="")=>e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString()),_e=(e="")=>e.toString().replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()));function Oe(e=""){let t=e.toString();return t=function(e=""){let t=e.toString();return t=$e(t,"-"," "),t=$e(t,"_"," "),t=_e(t),$e(t," ","")}(t),t.charAt(0).toLowerCase()+t.slice(1)}function je(e){const t=document.createElement("div");return t.appendChild(e),t.innerHTML}const qe={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},De={get(e="",t={}){if(U(e)||U(t))return"";let i=Y(t.i18n,e);if(U(i))return Object.keys(qe).includes(e)?qe[e]:"";const s={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(s).forEach((([e,t])=>{i=$e(i,e,t)})),i}};class He{constructor(t){e(this,"get",(e=>{if(!He.supported||!this.enabled)return null;const t=window.localStorage.getItem(this.key);if(U(t))return null;const i=JSON.parse(t);return $(e)&&e.length?i[e]:i})),e(this,"set",(e=>{if(!He.supported||!this.enabled)return;if(!I(e))return;let t=this.get();U(t)&&(t={}),Q(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 Re(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 Fe(e,t){if(!$(e))return;const i="cache",s=$(t);let n=!1;const a=()=>null!==document.getElementById(t),l=(e,t)=>{e.innerHTML=t,s&&a()||document.body.insertAdjacentElement("afterbegin",e)};if(!s||!a()){const a=He.supported,r=document.createElement("div");if(r.setAttribute("hidden",""),s&&r.setAttribute("id",t),a){const e=window.localStorage.getItem(`${i}-${t}`);if(n=null!==e,n){const t=JSON.parse(e);l(r,t.content)}}Re(e).then((e=>{if(!U(e)){if(a)try{window.localStorage.setItem(`${i}-${t}`,JSON.stringify({content:e}))}catch(e){}l(r,e)}})).catch((()=>{}))}}const Ve=e=>Math.trunc(e/60/60%60,10);function Be(e=0,t=!1,i=!1){if(!L(e))return Be(void 0,t,i);const s=e=>`0${e}`.slice(-2);let n=Ve(e);const a=(l=e,Math.trunc(l/60%60,10));var l;const r=(e=>Math.trunc(e%60,10))(e);return n=t||n>0?`${n}:`:"",`${i&&e>0?"-":""}${n}${s(a)}:${s(r)}`}const Ue={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||K.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:i}},findElements(){try{return this.elements.controls=ce.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:oe.call(this,this.config.selectors.buttons.play),pause:ce.call(this,this.config.selectors.buttons.pause),restart:ce.call(this,this.config.selectors.buttons.restart),rewind:ce.call(this,this.config.selectors.buttons.rewind),fastForward:ce.call(this,this.config.selectors.buttons.fastForward),mute:ce.call(this,this.config.selectors.buttons.mute),pip:ce.call(this,this.config.selectors.buttons.pip),airplay:ce.call(this,this.config.selectors.buttons.airplay),settings:ce.call(this,this.config.selectors.buttons.settings),captions:ce.call(this,this.config.selectors.buttons.captions),fullscreen:ce.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=ce.call(this,this.config.selectors.progress),this.elements.inputs={seek:ce.call(this,this.config.selectors.inputs.seek),volume:ce.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:ce.call(this,this.config.selectors.display.buffer),currentTime:ce.call(this,this.config.selectors.display.currentTime),duration:ce.call(this,this.config.selectors.display.duration)},D(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=Ue.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,a=document.createElementNS(i,"svg");J(a,Q(t,{"aria-hidden":"true",focusable:"false"}));const l=document.createElementNS(i,"use"),r=`${n}-${e}`;return"href"in l&&l.setAttributeNS("http://www.w3.org/1999/xlink","href",r),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(l),a},createLabel(e,t={}){const i=De.get(e,this.config);return G("span",{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")},i)},createBadge(e){if(U(e))return null;const t=G("span",{class:this.config.classNames.menu.value});return t.appendChild(G("span",{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){const i=Q({},t);let s=Oe(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))||Q(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:U(n.label)&&(n.label=s),U(n.icon)&&(n.icon=e)}const a=G(n.element);return n.toggle?(a.appendChild(Ue.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),a.appendChild(Ue.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),a.appendChild(Ue.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),a.appendChild(Ue.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(a.appendChild(Ue.createIcon.call(this,n.icon)),a.appendChild(Ue.createLabel.call(this,n.label))),Q(i,se(this.config.selectors.buttons[s],i)),J(a,i),"play"===s?(j(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=G("input",Q(se(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":De.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=i,Ue.updateRangeFill.call(this,i),w.setup(i),i},createProgress(e,t){const i=G("progress",Q(se(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){i.appendChild(G("span",null,"0"));const t={played:"played",buffer:"buffered"}[e],s=t?De.get(t,this.config):"";i.innerText=`% ${s.toLowerCase()}`}return this.elements.display[e]=i,i},createTime(e,t){const i=se(this.config.selectors.display[e],t),s=G("div",Q(i,{class:`${i.class?i.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":De.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,t){ge.call(this,e,"keydown keyup",(i=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(i.key))return;if(i.preventDefault(),i.stopPropagation(),"keydown"===i.type)return;const s=re(e,'[role="menuitemradio"]');if(!s&&[" ","ArrowRight"].includes(i.key))Ue.showMenuPanel.call(this,t,!0);else{let t;" "!==i.key&&("ArrowDown"===i.key||s&&"ArrowRight"===i.key?(t=e.nextElementSibling,D(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,D(t)||(t=e.parentNode.lastElementChild)),he.call(this,t,!0))}}),!1),ge.call(this,e,"keyup",(e=>{"Return"===e.key&&Ue.focusFirstMenuItem.call(this,null,!0)}))},createMenuItem({value:e,list:t,type:i,title:s,badge:n=null,checked:a=!1}){const l=se(this.config.selectors.inputs[i]),r=G("button",Q(l,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${l.class?l.class:""}`.trim(),"aria-checked":a,value:e})),o=G("span");o.innerHTML=s,D(n)&&o.appendChild(n),r.appendChild(o),Object.defineProperty(r,"checked",{enumerable:!0,get:()=>"true"===r.getAttribute("aria-checked"),set(e){e&&Array.from(r.parentNode.children).filter((e=>re(e,'[role="menuitemradio"]'))).forEach((e=>e.setAttribute("aria-checked","false"))),r.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(r,"click keyup",(t=>{if(!R(t)||" "===t.key){switch(t.preventDefault(),t.stopPropagation(),r.checked=!0,i){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=parseFloat(e)}Ue.showMenuPanel.call(this,"home",R(t))}}),i,!1),Ue.bindMenuItemShortcuts.call(this,r,i),t.appendChild(r)},formatTime(e=0,t=!1){if(!L(e))return e;return Be(e,Ve(this.duration)>0,t)},updateTimeDisplay(e=null,t=0,i=!1){D(e)&&L(t)&&(e.innerText=Ue.formatTime(t,i))},updateVolume(){this.supported.ui&&(D(this.elements.inputs.volume)&&Ue.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),D(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(e,t=0){D(e)&&(e.value=t,Ue.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!H(e))return;let t=0;const i=(e,t)=>{const i=L(t)?t:0,s=D(e)?e:this.elements.display.buffer;if(D(s)){s.value=i;const e=s.getElementsByTagName("span")[0];D(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&&Ue.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=H(e)?e.target:e;if(D(t)&&"range"===t.getAttribute("type")){if(re(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);const e=Ue.formatTime(this.currentTime),i=Ue.formatTime(this.duration),s=De.get("seekLabel",this.config);t.setAttribute("aria-valuetext",s.replace("{currentTime}",e).replace("{duration}",i))}else if(re(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);(K.isWebKit||K.isIPadOS)&&t.style.setProperty("--value",t.value/t.max*100+"%")}},updateSeekTooltip(e){var t,i;if(!this.config.tooltips.seek||!D(this.elements.inputs.seek)||!D(this.elements.display.seekTooltip)||0===this.duration)return;const s=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,a=e=>ae(s,n,e);if(this.touch)return void a(!1);let l=0;const r=this.elements.progress.getBoundingClientRect();if(H(e))l=100/r.width*(e.pageX-r.left);else{if(!le(s,n))return;l=parseFloat(s.style.left,10)}l<0?l=0:l>100&&(l=100);const o=this.duration/100*l;s.innerText=Ue.formatTime(o);const c=null===(t=this.config.markers)||void 0===t||null===(i=t.points)||void 0===i?void 0:i.find((({time:e})=>e===Math.round(o)));c&&s.insertAdjacentHTML("afterbegin",`${c.label}<br>`),s.style.left=`${l}%`,H(e)&&["mouseenter","mouseleave"].includes(e.type)&&a("mouseenter"===e.type)},timeUpdate(e){const t=!D(this.elements.display.duration)&&this.config.invertTime;Ue.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||Ue.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return ne(this.elements.display.currentTime,!0),void ne(this.elements.progress,!0);D(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=D(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&Ue.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&Ue.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&Ue.setMarkers.call(this),Ue.updateSeekTooltip.call(this)},toggleMenuButton(e,t){ne(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=U(i)?this[e]:i,U(n)&&(n=this.config[e].default),!U(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(D(a)||(a=s&&s.querySelector('[role="menu"]')),!D(a))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=Ue.getLabel.call(this,e,n);const l=a&&a.querySelector(`[value="${n}"]`);D(l)&&(l.checked=!0)},getLabel(e,t){switch(e){case"speed":return 1===t?De.get("normal",this.config):`${t}&times;`;case"quality":if(L(t)){const e=De.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return _e(t);case"captions":return Ke.getLabel.call(this);default:return null}},setQualityMenu(e){if(!D(this.elements.settings.panels.quality))return;const t="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]');j(e)&&(this.options.quality=ke(e).filter((e=>this.config.quality.options.includes(e))));const s=!U(this.options.quality)&&this.options.quality.length>1;if(Ue.toggleMenuButton.call(this,t,s),te(i),Ue.checkMenu.call(this),!s)return;const n=e=>{const t=De.get(`qualityBadge.${e}`,this.config);return t.length?Ue.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=>{Ue.createMenuItem.call(this,{value:e,list:i,type:t,title:Ue.getLabel.call(this,"quality",e),badge:n(e)})})),Ue.updateSetting.call(this,t,i)},setCaptionsMenu(){if(!D(this.elements.settings.panels.captions))return;const e="captions",t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=Ke.getTracks.call(this),s=Boolean(i.length);if(Ue.toggleMenuButton.call(this,e,s),te(t),Ue.checkMenu.call(this),!s)return;const n=i.map(((e,i)=>({value:i,checked:this.captions.toggled&&this.currentTrack===i,title:Ke.getLabel.call(this,e),badge:e.language&&Ue.createBadge.call(this,e.language.toUpperCase()),list:t,type:"language"})));n.unshift({value:-1,checked:!this.captions.toggled,title:De.get("disabled",this.config),list:t,type:"language"}),n.forEach(Ue.createMenuItem.bind(this)),Ue.updateSetting.call(this,e,t)},setSpeedMenu(){if(!D(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=!U(this.options.speed)&&this.options.speed.length>1;Ue.toggleMenuButton.call(this,e,i),te(t),Ue.checkMenu.call(this),i&&(this.options.speed.forEach((i=>{Ue.createMenuItem.call(this,{value:i,list:t,type:e,title:Ue.getLabel.call(this,"speed",i)})})),Ue.updateSetting.call(this,e,t))},checkMenu(){const{buttons:e}=this.elements.settings,t=!U(e)&&Object.values(e).some((e=>!e.hidden));ne(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let i=e;D(i)||(i=Object.values(this.elements.settings.panels).find((e=>!e.hidden)));const s=i.querySelector('[role^="menuitem"]');he.call(this,s,t)},toggleMenu(e){const{popup:t}=this.elements.settings,i=this.elements.buttons.settings;if(!D(t)||!D(i))return;const{hidden:s}=t;let n=s;if(_(e))n=e;else if(R(e)&&"Escape"===e.key)n=!1;else if(H(e)){const s=O(e.composedPath)?e.composedPath()[0]:e.target,a=t.contains(s);if(a||!a&&e.target!==i&&n)return}i.setAttribute("aria-expanded",n),ne(t,!n),ae(this.elements.container,this.config.classNames.menu.open,n),n&&R(e)?Ue.focusFirstMenuItem.call(this,null,!0):n||s||he.call(this,i,R(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 ee(t),{width:i,height:s}},showMenuPanel(e="",t=!1){const i=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!D(i))return;const s=i.parentNode,n=Array.from(s.children).find((e=>!e.hidden));if(de.transitions&&!de.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const e=Ue.getMenuSize.call(this,i),t=e=>{e.target===s&&["width","height"].includes(e.propertyName)&&(s.style.width="",s.style.height="",fe.call(this,s,W,t))};ge.call(this,s,W,t),s.style.width=`${e.width}px`,s.style.height=`${e.height}px`}ne(n,!0),ne(i,!1),Ue.focusFirstMenuItem.call(this,i,t)},setDownloadUrl(){const e=this.elements.buttons.download;D(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:t,createButton:i,createProgress:s,createRange:n,createTime:a,setQualityMenu:l,setSpeedMenu:r,showMenuPanel:o}=Ue;this.elements.controls=null,j(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(i.call(this,"play-large"));const c=G("div",se(this.config.selectors.controls.wrapper));this.elements.controls=c;const h={class:"plyr__controls__item"};return ke(j(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=G("div",{class:`${h.class} plyr__progress__container`}),i=G("div",se(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=G("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(D(t)&&c.contains(t)||(t=G("div",Q({},h,{class:`${h.class} plyr__volume`.trim()})),this.elements.volume=t,c.appendChild(t)),"mute"===l&&t.appendChild(i.call(this,"mute")),"volume"===l&&!K.isIos&&!K.isIPadOS){const i={max:1,step:.05,value:this.config.volume};t.appendChild(n.call(this,"volume",Q(i,{id:`plyr-volume-${e.id}`})))}}if("captions"===l&&c.appendChild(i.call(this,"captions",h)),"settings"===l&&!U(this.config.settings)){const s=G("div",Q({},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=G("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),a=G("div"),l=G("div",{id:`plyr-settings-${e.id}-home`}),r=G("div",{role:"menu"});l.appendChild(r),a.appendChild(l),this.elements.settings.panels.home=l,this.config.settings.forEach((i=>{const s=G("button",Q(se(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),ge.call(this,s,"click",(()=>{o.call(this,i,!1)}));const n=G("span",null,De.get(i,this.config)),l=G("span",{class:this.config.classNames.menu.value});l.innerHTML=e[i],n.appendChild(l),s.appendChild(n),r.appendChild(s);const c=G("div",{id:`plyr-settings-${e.id}-${i}`,hidden:""}),h=G("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});h.appendChild(G("span",{"aria-hidden":!0},De.get(i,this.config))),h.appendChild(G("span",{class:this.config.classNames.hidden},De.get("menuBack",this.config))),ge.call(this,c,"keydown",(e=>{"ArrowLeft"===e.key&&(e.preventDefault(),e.stopPropagation(),o.call(this,"home",!0))}),!1),ge.call(this,h,"click",(()=>{o.call(this,"home",!1)})),c.appendChild(h),c.appendChild(G("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&&de.pip&&c.appendChild(i.call(this,"pip",h)),"airplay"===l&&de.airplay&&c.appendChild(i.call(this,"airplay",h)),"download"===l){const e=Q({},h,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(e.download="");const{download:t}=this.config.urls;!B(t)&&this.isEmbed&&Q(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,Ie.getQualityOptions.call(this)),r.call(this),c},inject(){if(this.config.loadSprite){const e=Ue.getIconUrl.call(this);e.cors&&Fe(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=!0;O(this.config.controls)&&(this.config.controls=this.config.controls.call(this,t)),this.config.controls||(this.config.controls=[]),D(this.config.controls)||$(this.config.controls)?e=this.config.controls:(e=Ue.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:Ke.getLabel.call(this)}),i=!1);let s;i&&$(this.config.controls)&&(e=(e=>{let i=e;return Object.entries(t).forEach((([e,t])=>{i=$e(i,`{${e}}`,t)})),i})(e)),$(this.config.selectors.controls.container)&&(s=document.querySelector(this.config.selectors.controls.container)),D(s)||(s=this.elements.container);if(s[D(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),D(this.elements.controls)||Ue.findElements.call(this),!U(this.elements.buttons)){const e=e=>{const t=this.config.classNames.controlPressed;e.setAttribute("aria-pressed","false"),Object.defineProperty(e,"pressed",{configurable:!0,enumerable:!0,get:()=>le(e,t),set(i=!1){ae(e,t,i),e.setAttribute("aria-pressed",i?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach((t=>{j(t)||q(t)?Array.from(t).filter(Boolean).forEach(e):e(t)}))}if(K.isEdge&&z(s),this.config.tooltips.controls){const{classNames:e,selectors:t}=this.config,i=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,s=oe.call(this,i);Array.from(s).forEach((e=>{ae(e,this.config.classNames.hidden,!1),ae(e,this.config.classNames.tooltip,!0)}))}},setMediaMetadata(){try{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new window.MediaMetadata({title:this.config.mediaMetadata.title,artist:this.config.mediaMetadata.artist,album:this.config.mediaMetadata.album,artwork:this.config.mediaMetadata.artwork}))}catch(e){}},setMarkers(){var e,t;if(!this.duration||this.elements.markers)return;const i=null===(e=this.config.markers)||void 0===e||null===(t=e.points)||void 0===t?void 0:t.filter((({time:e})=>e>0&&e<this.duration));if(null==i||!i.length)return;const s=document.createDocumentFragment(),n=document.createDocumentFragment();let a=null;const l=`${this.config.classNames.tooltip}--visible`,r=e=>ae(a,l,e);i.forEach((e=>{const t=G("span",{class:this.config.classNames.marker},""),i=e.time/this.duration*100+"%";a&&(t.addEventListener("mouseenter",(()=>{e.label||(a.style.left=i,a.innerHTML=e.label,r(!0))})),t.addEventListener("mouseleave",(()=>{r(!1)}))),t.addEventListener("click",(()=>{this.currentTime=e.time})),t.style.left=i,n.appendChild(t)})),s.appendChild(n),this.config.tooltips.seek||(a=G("span",{class:this.config.classNames.tooltip},""),s.appendChild(a)),this.elements.markers={points:n,tip:a},this.elements.progress.appendChild(s)}};function We(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 ze(e){const t=new URLSearchParams;return I(e)&&Object.entries(e).forEach((([e,i])=>{t.set(e,i)})),t}const Ke={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!de.textTracks)return void(j(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Ue.setCaptionsMenu.call(this));var e,t;if(D(this.elements.captions)||(this.elements.captions=G("div",se(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),e=this.elements.captions,t=this.elements.wrapper,D(e)&&D(t)&&t.parentNode.insertBefore(e,t.nextSibling)),K.isIE&&window.URL){const e=this.media.querySelectorAll("track");Array.from(e).forEach((e=>{const t=e.getAttribute("src"),i=We(t);null!==i&&i.hostname!==window.location.href.hostname&&["http:","https:"].includes(i.protocol)&&Re(t,"blob").then((t=>{e.setAttribute("src",window.URL.createObjectURL(t))})).catch((()=>{ee(e)}))}))}const i=ke((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";ge.call(this,this.media.textTracks,e,Ke.update.bind(this))}setTimeout(Ke.update.bind(this),0)},update(){const e=Ke.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"),ge.call(this,e,"cuechange",(()=>Ke.updateCues.call(this)))})),(a&&this.language!==i||!e.includes(n))&&(Ke.setLanguage.call(this,i),Ke.toggle.call(this,t&&a)),this.elements&&ae(this.elements.container,this.config.classNames.captions.enabled,!U(e)),j(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Ue.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;const{toggled:i}=this.captions,s=this.config.classNames.captions.active,n=N(e)?!i:e;if(n!==i){if(t||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!t){const e=Ke.getTracks.call(this),t=Ke.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=t.language,void Ke.set.call(this,e.indexOf(t))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),ae(this.elements.container,s,n),this.captions.toggled=n,Ue.updateSetting.call(this,"captions"),be.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout((()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")}))},set(e,t=!0){const i=Ke.getTracks.call(this);if(-1!==e)if(L(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,Ue.updateSetting.call(this,"captions"),t||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n),be.call(this,this.media,"languagechange")}Ke.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&Ke.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else Ke.toggle.call(this,!1,t)},setLanguage(e,t=!0){if(!$(e))return void this.debug.warn("Invalid language argument",e);const i=e.toLowerCase();this.captions.language=i;const s=Ke.getTracks.call(this),n=Ke.findTrack.call(this,[i]);Ke.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=Ke.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 Ke.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!F(t)&&de.textTracks&&this.captions.toggled&&(t=Ke.getCurrentTrack.call(this)),F(t)?U(t.label)?U(t.language)?De.get("enabled",this.config):e.language.toUpperCase():t.label:De.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!D(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!N(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let t=e;if(!t){const e=Ke.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map((e=>e.getCueAsHTML())).map(je)}const i=t.map((e=>e.trim())).join("\n");if(i!==this.elements.captions.innerHTML){te(this.elements.captions);const e=G("span",se(this.config.selectors.caption));e.innerHTML=i,this.elements.captions.appendChild(e),be.call(this,this.media,"cuechange")}}},Ye={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.7.8/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",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",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"},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},mediaMetadata:{title:"",artist:"",album:"",artwork:[]},markers:{enabled:!1,points:[]}},Qe="picture-in-picture",Xe="inline",Je={html5:"html5",youtube:"youtube",vimeo:"vimeo"},Ge="audio",Ze="video";const et=()=>{};class tt{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):et}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):et}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):et}}class it{constructor(t){e(this,"onChange",(()=>{if(!this.supported)return;const e=this.player.elements.buttons.fullscreen;D(e)&&(e.pressed=this.active);const t=this.target===this.player.media?this.target:this.player.elements.container;be.call(this.player,t,this.active?"enterfullscreen":"exitfullscreen",!0)})),e(this,"toggleFallback",((e=!1)=>{var t,i;e?this.scrollPosition={x:null!==(t=window.scrollX)&&void 0!==t?t:0,y:null!==(i=window.scrollY)&&void 0!==i?i:0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y);if(docume