plyr
Version:
A simple, accessible and customizable HTML5, YouTube and Vimeo media player
3 lines • 131 kB
JavaScript
function _defineProperties(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),e}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach((function(t){_defineProperty(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var i,n,s={},a=Object.keys(e);for(n=0;n<a.length;n++)i=a[n],t.indexOf(i)>=0||(s[i]=e[i]);return s}function _objectWithoutProperties(e,t){if(null==e)return{};var i,n,s=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)i=a[n],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var i=[],n=!0,s=!1,a=void 0;try{for(var r,o=e[Symbol.iterator]();!(n=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);n=!0);}catch(e){s=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(s)throw a}}return i}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$1(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass$1(e,t,i){return t&&_defineProperties$1(e.prototype,t),i&&_defineProperties$1(e,i),e}function _defineProperty$1(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ownKeys$1(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread2$1(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$1(Object(i),!0).forEach((function(t){_defineProperty$1(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys$1(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var defaults={addCSS:!0,thumbWidth:15,watch:!0};function matches(e,t){return function(){return Array.from(document.querySelectorAll(t)).includes(this)}.call(e,t)}function trigger(e,t){if(e&&t){var i=new Event(t,{bubbles:!0});e.dispatchEvent(i)}}var getConstructor=function(e){return null!=e?e.constructor:null},instanceOf=function(e,t){return!!(e&&t&&e instanceof t)},isNullOrUndefined=function(e){return null==e},isObject=function(e){return getConstructor(e)===Object},isNumber=function(e){return getConstructor(e)===Number&&!Number.isNaN(e)},isString=function(e){return getConstructor(e)===String},isBoolean=function(e){return getConstructor(e)===Boolean},isFunction=function(e){return getConstructor(e)===Function},isArray=function(e){return Array.isArray(e)},isNodeList=function(e){return instanceOf(e,NodeList)},isElement=function(e){return instanceOf(e,Element)},isEvent=function(e){return instanceOf(e,Event)},isEmpty=function(e){return isNullOrUndefined(e)||(isString(e)||isArray(e)||isNodeList(e))&&!e.length||isObject(e)&&!Object.keys(e).length},is={nullOrUndefined:isNullOrUndefined,object:isObject,number:isNumber,string:isString,boolean:isBoolean,function:isFunction,array:isArray,nodeList:isNodeList,element:isElement,event:isEvent,empty:isEmpty};function getDecimalPlaces(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}function round(e,t){if(1>t){var i=getDecimalPlaces(t);return parseFloat(e.toFixed(i))}return Math.round(e/t)*t}var RangeTouch=function(){function e(t,i){_classCallCheck$1(this,e),is.element(t)?this.element=t:is.string(t)&&(this.element=document.querySelector(t)),is.element(this.element)&&is.empty(this.element.rangeTouch)&&(this.config=_objectSpread2$1({},defaults,{},i),this.init())}return _createClass$1(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||!is.event(t))return null;var i,n=t.target,s=t.changedTouches[0],a=parseFloat(n.getAttribute("min"))||0,r=parseFloat(n.getAttribute("max"))||100,o=parseFloat(n.getAttribute("step"))||1,l=n.getBoundingClientRect(),c=100/l.width*(this.config.thumbWidth/2)/100;return 0>(i=100/l.width*(s.clientX-l.left))?i=0:100<i&&(i=100),50>i?i-=(100-2*i)*c:50<i&&(i+=2*(i-50)*c),a+round(i/100*(r-a),o)}},{key:"set",value:function(t){e.enabled&&is.event(t)&&!t.target.disabled&&(t.preventDefault(),t.target.value=this.get(t),trigger(t.target,"touchend"===t.type?"change":"input"))}}],[{key:"setup",value:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=null;if(is.empty(t)||is.string(t)?n=Array.from(document.querySelectorAll(is.string(t)?t:'input[type="range"]')):is.element(t)?n=[t]:is.nodeList(t)?n=Array.from(t):is.array(t)&&(n=t.filter(is.element)),is.empty(n))return null;var s=_objectSpread2$1({},defaults,{},i);if(is.string(t)&&s.watch){var a=new MutationObserver((function(i){Array.from(i).forEach((function(i){Array.from(i.addedNodes).forEach((function(i){is.element(i)&&matches(i,t)&&new e(i,s)}))}))}));a.observe(document.body,{childList:!0,subtree:!0})}return n.map((function(t){return new e(t,i)}))}},{key:"enabled",get:function(){return"ontouchstart"in document.documentElement}}]),e}(),getConstructor$1=function(e){return null!=e?e.constructor:null},instanceOf$1=function(e,t){return Boolean(e&&t&&e instanceof t)},isNullOrUndefined$1=function(e){return null==e},isObject$1=function(e){return getConstructor$1(e)===Object},isNumber$1=function(e){return getConstructor$1(e)===Number&&!Number.isNaN(e)},isString$1=function(e){return getConstructor$1(e)===String},isBoolean$1=function(e){return getConstructor$1(e)===Boolean},isFunction$1=function(e){return getConstructor$1(e)===Function},isArray$1=function(e){return Array.isArray(e)},isWeakMap=function(e){return instanceOf$1(e,WeakMap)},isNodeList$1=function(e){return instanceOf$1(e,NodeList)},isElement$1=function(e){return instanceOf$1(e,Element)},isTextNode=function(e){return getConstructor$1(e)===Text},isEvent$1=function(e){return instanceOf$1(e,Event)},isKeyboardEvent=function(e){return instanceOf$1(e,KeyboardEvent)},isCue=function(e){return instanceOf$1(e,window.TextTrackCue)||instanceOf$1(e,window.VTTCue)},isTrack=function(e){return instanceOf$1(e,TextTrack)||!isNullOrUndefined$1(e)&&isString$1(e.kind)},isPromise=function(e){return instanceOf$1(e,Promise)&&isFunction$1(e.then)},isEmpty$1=function(e){return isNullOrUndefined$1(e)||(isString$1(e)||isArray$1(e)||isNodeList$1(e))&&!e.length||isObject$1(e)&&!Object.keys(e).length},isUrl=function(e){if(instanceOf$1(e,window.URL))return!0;if(!isString$1(e))return!1;var t=e;e.startsWith("http://")&&e.startsWith("https://")||(t="http://".concat(e));try{return!isEmpty$1(new URL(t).hostname)}catch(e){return!1}},is$1={nullOrUndefined:isNullOrUndefined$1,object:isObject$1,number:isNumber$1,string:isString$1,boolean:isBoolean$1,function:isFunction$1,array:isArray$1,weakMap:isWeakMap,nodeList:isNodeList$1,element:isElement$1,textNode:isTextNode,event:isEvent$1,keyboardEvent:isKeyboardEvent,cue:isCue,track:isTrack,promise:isPromise,url:isUrl,empty:isEmpty$1},transitionEndEvent=function(){var e=document.createElement("span"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},i=Object.keys(t).find((function(t){return void 0!==e.style[t]}));return!!is$1.string(i)&&t[i]}();function repaint(e,t){setTimeout((function(){try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch(e){}}),t)}var browser={isIE:
/* @cc_on!@ */
!!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:/(iPad|iPhone|iPod)/gi.test(navigator.platform)};function cloneDeep(e){return JSON.parse(JSON.stringify(e))}function getDeep(e,t){return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}function extend(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];if(!i.length)return e;var s=i.shift();return is$1.object(s)?(Object.keys(s).forEach((function(t){is$1.object(s[t])?(Object.keys(e).includes(t)||Object.assign(e,_defineProperty({},t,{})),extend(e[t],s[t])):Object.assign(e,_defineProperty({},t,s[t]))})),extend.apply(void 0,[e].concat(i))):e}function wrap(e,t){var i=e.length?e:[e];Array.from(i).reverse().forEach((function(e,i){var n=i>0?t.cloneNode(!0):t,s=e.parentNode,a=e.nextSibling;n.appendChild(e),a?s.insertBefore(n,a):s.appendChild(n)}))}function setAttributes(e,t){is$1.element(e)&&!is$1.empty(t)&&Object.entries(t).filter((function(e){var t=_slicedToArray(e,2)[1];return!is$1.nullOrUndefined(t)})).forEach((function(t){var i=_slicedToArray(t,2),n=i[0],s=i[1];return e.setAttribute(n,s)}))}function createElement(e,t,i){var n=document.createElement(e);return is$1.object(t)&&setAttributes(n,t),is$1.string(i)&&(n.innerText=i),n}function insertAfter(e,t){is$1.element(e)&&is$1.element(t)&&t.parentNode.insertBefore(e,t.nextSibling)}function insertElement(e,t,i,n){is$1.element(t)&&t.appendChild(createElement(e,i,n))}function removeElement(e){is$1.nodeList(e)||is$1.array(e)?Array.from(e).forEach(removeElement):is$1.element(e)&&is$1.element(e.parentNode)&&e.parentNode.removeChild(e)}function emptyElement(e){if(is$1.element(e))for(var t=e.childNodes.length;t>0;)e.removeChild(e.lastChild),t-=1}function replaceElement(e,t){return is$1.element(t)&&is$1.element(t.parentNode)&&is$1.element(e)?(t.parentNode.replaceChild(e,t),e):null}function getAttributesFromSelector(e,t){if(!is$1.string(e)||is$1.empty(e))return{};var i={},n=extend({},t);return e.split(",").forEach((function(e){var t=e.trim(),s=t.replace(".",""),a=t.replace(/[[\]]/g,"").split("="),r=_slicedToArray(a,1)[0],o=a.length>1?a[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":is$1.string(n.class)?i.class="".concat(n.class," ").concat(s):i.class=s;break;case"#":i.id=t.replace("#","");break;case"[":i[r]=o}})),extend(n,i)}function toggleHidden(e,t){if(is$1.element(e)){var i=t;is$1.boolean(i)||(i=!e.hidden),e.hidden=i}}function toggleClass(e,t,i){if(is$1.nodeList(e))return Array.from(e).map((function(e){return toggleClass(e,t,i)}));if(is$1.element(e)){var n="toggle";return void 0!==i&&(n=i?"add":"remove"),e.classList[n](t),e.classList.contains(t)}return!1}function hasClass(e,t){return is$1.element(e)&&e.classList.contains(t)}function matches$1(e,t){var i=Element.prototype;return(i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function closest(e,t){return(Element.prototype.closest||function(){var e=this;do{if(matches$1.matches(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}).call(e,t)}function getElements(e){return this.elements.container.querySelectorAll(e)}function getElement(e){return this.elements.container.querySelector(e)}function setFocus(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];is$1.element(e)&&(e.focus({preventScroll:!0}),t&&toggleClass(e,this.config.classNames.tabFocus))}var defaultCodecs={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},support={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check:function(e,t,i){var n=browser.isIPhone&&i&&support.playsinline,s=support[e]||"html5"!==t;return{api:s,ui:s&&support.rangeInput&&("video"!==e||!browser.isIPhone||n)}},pip:!(browser.isIPhone||!is$1.function(createElement("video").webkitSetPresentationMode)&&(!document.pictureInPictureEnabled||createElement("video").disablePictureInPicture)),airplay:is$1.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime:function(e){if(is$1.empty(e))return!1;var t=_slicedToArray(e.split("/"),1)[0],i=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(defaultCodecs).includes(i)&&(i+='; codecs="'.concat(defaultCodecs[e],'"'));try{return Boolean(i&&this.media.canPlayType(i).replace(/no/,""))}catch(e){return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:function(){var e=document.createElement("input");return e.type="range","range"===e.type}(),touch:"ontouchstart"in document.documentElement,transitions:!1!==transitionEndEvent,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},supportsPassiveListeners=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0,null}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e}();function toggleListener(e,t,i){var n=this,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(e&&"addEventListener"in e&&!is$1.empty(t)&&is$1.function(i)){var o=t.split(" "),l=r;supportsPassiveListeners&&(l={passive:a,capture:r}),o.forEach((function(t){n&&n.eventListeners&&s&&n.eventListeners.push({element:e,type:t,callback:i,options:l}),e[s?"addEventListener":"removeEventListener"](t,i,l)}))}}function on(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];toggleListener.call(this,e,t,i,!0,n,s)}function off(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];toggleListener.call(this,e,t,i,!1,n,s)}function once(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=function r(){off(e,i,r,s,a);for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];n.apply(t,l)};toggleListener.call(this,e,i,r,!0,s,a)}function triggerEvent(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(is$1.element(e)&&!is$1.empty(t)){var s=new CustomEvent(t,{bubbles:i,detail:_objectSpread2(_objectSpread2({},n),{},{plyr:this})});e.dispatchEvent(s)}}function unbindListeners(){this&&this.eventListeners&&(this.eventListeners.forEach((function(e){var t=e.element,i=e.type,n=e.callback,s=e.options;t.removeEventListener(i,n,s)})),this.eventListeners=[])}function ready(){var e=this;return new Promise((function(t){return e.ready?setTimeout(t,0):on.call(e,e.elements.container,"ready",t)})).then((function(){}))}function silencePromise(e){is$1.promise(e)&&e.then(null,(function(){}))}function validateRatio(e){return!!(is$1.array(e)||is$1.string(e)&&e.includes(":"))&&(is$1.array(e)?e:e.split(":")).map(Number).every(is$1.number)}function reduceAspectRatio(e){if(!is$1.array(e)||!e.every(is$1.number))return null;var t=_slicedToArray(e,2),i=t[0],n=t[1],s=function e(t,i){return 0===i?t:e(i,t%i)}(i,n);return[i/s,n/s]}function getAspectRatio(e){var t=function(e){return validateRatio(e)?e.split(":").map(Number):null},i=t(e);if(null===i&&(i=t(this.config.ratio)),null===i&&!is$1.empty(this.embed)&&is$1.array(this.embed.ratio)&&(i=this.embed.ratio),null===i&&this.isHTML5){var n=this.media;i=reduceAspectRatio([n.videoWidth,n.videoHeight])}return i}function setAspectRatio(e){if(!this.isVideo)return{};var t=this.elements.wrapper,i=getAspectRatio.call(this,e),n=_slicedToArray(is$1.array(i)?i:[0,0],2),s=100/n[0]*n[1];if(t.style.paddingBottom="".concat(s,"%"),this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){var a=100/this.media.offsetWidth*parseInt(window.getComputedStyle(this.media).paddingBottom,10),r=(a-s)/(a/50);this.media.style.transform="translateY(-".concat(r,"%)")}else this.isHTML5&&t.classList.toggle(this.config.classNames.videoFixedRatio,null!==i);return{padding:s,ratio:i}}var html5={getSources:function(){var e=this;return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter((function(t){var i=t.getAttribute("type");return!!is$1.empty(i)||support.mime.call(e,i)})):[]},getQualityOptions:function(){return this.config.quality.forced?this.config.quality.options:html5.getSources.call(this).map((function(e){return Number(e.getAttribute("size"))})).filter(Boolean)},setup:function(){if(this.isHTML5){var e=this;e.options.speed=e.config.speed.options,is$1.empty(this.config.ratio)||setAspectRatio.call(e),Object.defineProperty(e.media,"quality",{get:function(){var t=html5.getSources.call(e).find((function(t){return t.getAttribute("src")===e.source}));return t&&Number(t.getAttribute("size"))},set:function(t){if(e.quality!==t){if(e.config.quality.forced&&is$1.function(e.config.quality.onChange))e.config.quality.onChange(t);else{var i=html5.getSources.call(e).find((function(e){return Number(e.getAttribute("size"))===t}));if(!i)return;var n=e.media,s=n.currentTime,a=n.paused,r=n.preload,o=n.readyState,l=n.playbackRate;e.media.src=i.getAttribute("src"),("none"!==r||o)&&(e.once("loadedmetadata",(function(){e.speed=l,e.currentTime=s,a||silencePromise(e.play())})),e.media.load())}triggerEvent.call(e,e.media,"qualitychange",!1,{quality:t})}}})}},cancelRequests:function(){this.isHTML5&&(removeElement(html5.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function dedupe(e){return is$1.array(e)?e.filter((function(t,i){return e.indexOf(t)===i})):e}function closest$1(e,t){return is$1.array(e)&&e.length?e.reduce((function(e,i){return Math.abs(i-t)<Math.abs(e-t)?i:e})):null}function generateId(e){return"".concat(e,"-").concat(Math.floor(1e4*Math.random()))}function format(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return is$1.empty(e)?e:e.toString().replace(/{(\d+)}/g,(function(e,t){return i[t].toString()}))}function getPercentage(e,t){return 0===e||0===t||Number.isNaN(e)||Number.isNaN(t)?0:(e/t*100).toFixed(2)}var replaceAll=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString())},toTitleCase=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toString().replace(/\w\S*/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}))};function toPascalCase(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.toString();return t=replaceAll(t,"-"," "),t=replaceAll(t,"_"," "),t=toTitleCase(t),replaceAll(t," ","")}function toCamelCase(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.toString();return(t=toPascalCase(t)).charAt(0).toLowerCase()+t.slice(1)}function stripHTML(e){var t=document.createDocumentFragment(),i=document.createElement("div");return t.appendChild(i),i.innerHTML=e,t.firstChild.innerText}function getHTML(e){var t=document.createElement("div");return t.appendChild(e),t.innerHTML}var resources={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},i18n={get:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(is$1.empty(e)||is$1.empty(t))return"";var i=getDeep(t.i18n,e);if(is$1.empty(i))return Object.keys(resources).includes(e)?resources[e]:"";var n={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(n).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],s=t[1];i=replaceAll(i,n,s)})),i}},Storage=function(){function e(t){_classCallCheck(this,e),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}return _createClass(e,[{key:"get",value:function(t){if(!e.supported||!this.enabled)return null;var i=window.localStorage.getItem(this.key);if(is$1.empty(i))return null;var n=JSON.parse(i);return is$1.string(t)&&t.length?n[t]:n}},{key:"set",value:function(t){if(e.supported&&this.enabled&&is$1.object(t)){var i=this.get();is$1.empty(i)&&(i={}),extend(i,t),window.localStorage.setItem(this.key,JSON.stringify(i))}}}],[{key:"supported",get:function(){try{if(!("localStorage"in window))return!1;return window.localStorage.setItem("___test","___test"),window.localStorage.removeItem("___test"),!0}catch(e){return!1}}}]),e}();function fetch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";return new Promise((function(i,n){try{var s=new XMLHttpRequest;if(!("withCredentials"in s))return;s.addEventListener("load",(function(){if("text"===t)try{i(JSON.parse(s.responseText))}catch(e){i(s.responseText)}else i(s.response)})),s.addEventListener("error",(function(){throw new Error(s.status)})),s.open("GET",e,!0),s.responseType=t,s.send()}catch(e){n(e)}}))}function loadSprite(e,t){if(is$1.string(e)){var i=is$1.string(t),n=function(){return null!==document.getElementById(t)},s=function(e,t){e.innerHTML=t,i&&n()||document.body.insertAdjacentElement("afterbegin",e)};if(!i||!n()){var a=Storage.supported,r=document.createElement("div");if(r.setAttribute("hidden",""),i&&r.setAttribute("id",t),a){var o=window.localStorage.getItem("".concat("cache","-").concat(t));if(null!==o){var l=JSON.parse(o);s(r,l.content)}}fetch(e).then((function(e){is$1.empty(e)||(a&&window.localStorage.setItem("".concat("cache","-").concat(t),JSON.stringify({content:e})),s(r,e))})).catch((function(){}))}}}var getHours=function(e){return Math.trunc(e/60/60%60,10)},getMinutes=function(e){return Math.trunc(e/60%60,10)},getSeconds=function(e){return Math.trunc(e%60,10)};function formatTime(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!is$1.number(e))return formatTime(void 0,t,i);var n=function(e){return"0".concat(e).slice(-2)},s=getHours(e),a=getMinutes(e),r=getSeconds(e);return s=t||s>0?"".concat(s,":"):"","".concat(i&&e>0?"-":"").concat(s).concat(n(a),":").concat(n(r))}var controls={getIconUrl:function(){var e=new URL(this.config.iconUrl,window.location).host!==window.location.host||browser.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:e}},findElements:function(){try{return this.elements.controls=getElement.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:getElements.call(this,this.config.selectors.buttons.play),pause:getElement.call(this,this.config.selectors.buttons.pause),restart:getElement.call(this,this.config.selectors.buttons.restart),rewind:getElement.call(this,this.config.selectors.buttons.rewind),fastForward:getElement.call(this,this.config.selectors.buttons.fastForward),mute:getElement.call(this,this.config.selectors.buttons.mute),pip:getElement.call(this,this.config.selectors.buttons.pip),airplay:getElement.call(this,this.config.selectors.buttons.airplay),settings:getElement.call(this,this.config.selectors.buttons.settings),captions:getElement.call(this,this.config.selectors.buttons.captions),fullscreen:getElement.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=getElement.call(this,this.config.selectors.progress),this.elements.inputs={seek:getElement.call(this,this.config.selectors.inputs.seek),volume:getElement.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:getElement.call(this,this.config.selectors.display.buffer),currentTime:getElement.call(this,this.config.selectors.display.currentTime),duration:getElement.call(this,this.config.selectors.display.duration)},is$1.element(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(".".concat(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:function(e,t){var i=controls.getIconUrl.call(this),n="".concat(i.cors?"":i.url,"#").concat(this.config.iconPrefix),s=document.createElementNS("http://www.w3.org/2000/svg","svg");setAttributes(s,extend(t,{"aria-hidden":"true",focusable:"false"}));var a=document.createElementNS("http://www.w3.org/2000/svg","use"),r="".concat(n,"-").concat(e);return"href"in a&&a.setAttributeNS("http://www.w3.org/1999/xlink","href",r),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),s.appendChild(a),s},createLabel:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=i18n.get(e,this.config),n=_objectSpread2(_objectSpread2({},t),{},{class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")});return createElement("span",n,i)},createBadge:function(e){if(is$1.empty(e))return null;var t=createElement("span",{class:this.config.classNames.menu.value});return t.appendChild(createElement("span",{class:this.config.classNames.menu.badge},e)),t},createButton:function(e,t){var i=this,n=extend({},t),s=toCamelCase(e),a={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach((function(e){Object.keys(n).includes(e)&&(a[e]=n[e],delete n[e])})),"button"!==a.element||Object.keys(n).includes("type")||(n.type="button"),Object.keys(n).includes("class")?n.class.split(" ").some((function(e){return e===i.config.classNames.control}))||extend(n,{class:"".concat(n.class," ").concat(this.config.classNames.control)}):n.class=this.config.classNames.control,e){case"play":a.toggle=!0,a.label="play",a.labelPressed="pause",a.icon="play",a.iconPressed="pause";break;case"mute":a.toggle=!0,a.label="mute",a.labelPressed="unmute",a.icon="volume",a.iconPressed="muted";break;case"captions":a.toggle=!0,a.label="enableCaptions",a.labelPressed="disableCaptions",a.icon="captions-off",a.iconPressed="captions-on";break;case"fullscreen":a.toggle=!0,a.label="enterFullscreen",a.labelPressed="exitFullscreen",a.icon="enter-fullscreen",a.iconPressed="exit-fullscreen";break;case"play-large":n.class+=" ".concat(this.config.classNames.control,"--overlaid"),s="play",a.label="play",a.icon="play";break;default:is$1.empty(a.label)&&(a.label=s),is$1.empty(a.icon)&&(a.icon=e)}var r=createElement(a.element);return a.toggle?(r.appendChild(controls.createIcon.call(this,a.iconPressed,{class:"icon--pressed"})),r.appendChild(controls.createIcon.call(this,a.icon,{class:"icon--not-pressed"})),r.appendChild(controls.createLabel.call(this,a.labelPressed,{class:"label--pressed"})),r.appendChild(controls.createLabel.call(this,a.label,{class:"label--not-pressed"}))):(r.appendChild(controls.createIcon.call(this,a.icon)),r.appendChild(controls.createLabel.call(this,a.label))),extend(n,getAttributesFromSelector(this.config.selectors.buttons[s],n)),setAttributes(r,n),"play"===s?(is$1.array(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(r)):this.elements.buttons[s]=r,r},createRange:function(e,t){var i=createElement("input",extend(getAttributesFromSelector(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":i18n.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=i,controls.updateRangeFill.call(this,i),RangeTouch.setup(i),i},createProgress:function(e,t){var i=createElement("progress",extend(getAttributesFromSelector(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){i.appendChild(createElement("span",null,"0"));var n={played:"played",buffer:"buffered"}[e],s=n?i18n.get(n,this.config):"";i.innerText="% ".concat(s.toLowerCase())}return this.elements.display[e]=i,i},createTime:function(e,t){var i=getAttributesFromSelector(this.config.selectors.display[e],t),n=createElement("div",extend(i,{class:"".concat(i.class?i.class:""," ").concat(this.config.classNames.display.time," ").trim(),"aria-label":i18n.get(e,this.config)}),"00:00");return this.elements.display[e]=n,n},bindMenuItemShortcuts:function(e,t){var i=this;on.call(this,e,"keydown keyup",(function(n){if([32,38,39,40].includes(n.which)&&(n.preventDefault(),n.stopPropagation(),"keydown"!==n.type)){var s,a=matches$1(e,'[role="menuitemradio"]');if(!a&&[32,39].includes(n.which))controls.showMenuPanel.call(i,t,!0);else 32!==n.which&&(40===n.which||a&&39===n.which?(s=e.nextElementSibling,is$1.element(s)||(s=e.parentNode.firstElementChild)):(s=e.previousElementSibling,is$1.element(s)||(s=e.parentNode.lastElementChild)),setFocus.call(i,s,!0))}}),!1),on.call(this,e,"keyup",(function(e){13===e.which&&controls.focusFirstMenuItem.call(i,null,!0)}))},createMenuItem:function(e){var t=this,i=e.value,n=e.list,s=e.type,a=e.title,r=e.badge,o=void 0===r?null:r,l=e.checked,c=void 0!==l&&l,u=getAttributesFromSelector(this.config.selectors.inputs[s]),d=createElement("button",extend(u,{type:"button",role:"menuitemradio",class:"".concat(this.config.classNames.control," ").concat(u.class?u.class:"").trim(),"aria-checked":c,value:i})),h=createElement("span");h.innerHTML=a,is$1.element(o)&&h.appendChild(o),d.appendChild(h),Object.defineProperty(d,"checked",{enumerable:!0,get:function(){return"true"===d.getAttribute("aria-checked")},set:function(e){e&&Array.from(d.parentNode.children).filter((function(e){return matches$1(e,'[role="menuitemradio"]')})).forEach((function(e){return e.setAttribute("aria-checked","false")})),d.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(d,"click keyup",(function(e){if(!is$1.keyboardEvent(e)||32===e.which){switch(e.preventDefault(),e.stopPropagation(),d.checked=!0,s){case"language":t.currentTrack=Number(i);break;case"quality":t.quality=i;break;case"speed":t.speed=parseFloat(i)}controls.showMenuPanel.call(t,"home",is$1.keyboardEvent(e))}}),s,!1),controls.bindMenuItemShortcuts.call(this,d,s),n.appendChild(d)},formatTime:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!is$1.number(e))return e;var i=getHours(this.duration)>0;return formatTime(e,i,t)},updateTimeDisplay:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];is$1.element(e)&&is$1.number(t)&&(e.innerText=controls.formatTime(t,i))},updateVolume:function(){this.supported.ui&&(is$1.element(this.elements.inputs.volume)&&controls.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),is$1.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;is$1.element(e)&&(e.value=t,controls.updateRangeFill.call(this,e))},updateProgress:function(e){var t=this;if(this.supported.ui&&is$1.event(e)){var i=0;if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":i=getPercentage(this.currentTime,this.duration),"timeupdate"===e.type&&controls.setRange.call(this,this.elements.inputs.seek,i);break;case"playing":case"progress":!function(e,i){var n=is$1.number(i)?i:0,s=is$1.element(e)?e:t.elements.display.buffer;if(is$1.element(s)){s.value=n;var a=s.getElementsByTagName("span")[0];is$1.element(a)&&(a.childNodes[0].nodeValue=n)}}(this.elements.display.buffer,100*this.buffered)}}},updateRangeFill:function(e){var t=is$1.event(e)?e.target:e;if(is$1.element(t)&&"range"===t.getAttribute("type")){if(matches$1(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);var i=controls.formatTime(this.currentTime),n=controls.formatTime(this.duration),s=i18n.get("seekLabel",this.config);t.setAttribute("aria-valuetext",s.replace("{currentTime}",i).replace("{duration}",n))}else if(matches$1(t,this.config.selectors.inputs.volume)){var a=100*t.value;t.setAttribute("aria-valuenow",a),t.setAttribute("aria-valuetext","".concat(a.toFixed(1),"%"))}else t.setAttribute("aria-valuenow",t.value);browser.isWebkit&&t.style.setProperty("--value","".concat(t.value/t.max*100,"%"))}},updateSeekTooltip:function(e){var t=this;if(this.config.tooltips.seek&&is$1.element(this.elements.inputs.seek)&&is$1.element(this.elements.display.seekTooltip)&&0!==this.duration){var i="".concat(this.config.classNames.tooltip,"--visible"),n=function(e){return toggleClass(t.elements.display.seekTooltip,i,e)};if(this.touch)n(!1);else{var s=0,a=this.elements.progress.getBoundingClientRect();if(is$1.event(e))s=100/a.width*(e.pageX-a.left);else{if(!hasClass(this.elements.display.seekTooltip,i))return;s=parseFloat(this.elements.display.seekTooltip.style.left,10)}s<0?s=0:s>100&&(s=100),controls.updateTimeDisplay.call(this,this.elements.display.seekTooltip,this.duration/100*s),this.elements.display.seekTooltip.style.left="".concat(s,"%"),is$1.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&n("mouseenter"===e.type)}}},timeUpdate:function(e){var t=!is$1.element(this.elements.display.duration)&&this.config.invertTime;controls.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||controls.updateProgress.call(this,e)},durationUpdate:function(){if(this.supported.ui&&(this.config.invertTime||!this.currentTime)){if(this.duration>=Math.pow(2,32))return toggleHidden(this.elements.display.currentTime,!0),void toggleHidden(this.elements.progress,!0);is$1.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);var e=is$1.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&controls.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&controls.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),controls.updateSeekTooltip.call(this)}},toggleMenuButton:function(e,t){toggleHidden(this.elements.settings.buttons[e],!t)},updateSetting:function(e,t,i){var n=this.elements.settings.panels[e],s=null,a=t;if("captions"===e)s=this.currentTrack;else{if(s=is$1.empty(i)?this[e]:i,is$1.empty(s)&&(s=this.config[e].default),!is$1.empty(this.options[e])&&!this.options[e].includes(s))return void this.debug.warn("Unsupported value of '".concat(s,"' for ").concat(e));if(!this.config[e].options.includes(s))return void this.debug.warn("Disabled value of '".concat(s,"' for ").concat(e))}if(is$1.element(a)||(a=n&&n.querySelector('[role="menu"]')),is$1.element(a)){this.elements.settings.buttons[e].querySelector(".".concat(this.config.classNames.menu.value)).innerHTML=controls.getLabel.call(this,e,s);var r=a&&a.querySelector('[value="'.concat(s,'"]'));is$1.element(r)&&(r.checked=!0)}},getLabel:function(e,t){switch(e){case"speed":return 1===t?i18n.get("normal",this.config):"".concat(t,"×");case"quality":if(is$1.number(t)){var i=i18n.get("qualityLabel.".concat(t),this.config);return i.length?i:"".concat(t,"p")}return toTitleCase(t);case"captions":return captions.getLabel.call(this);default:return null}},setQualityMenu:function(e){var t=this;if(is$1.element(this.elements.settings.panels.quality)){var i=this.elements.settings.panels.quality.querySelector('[role="menu"]');is$1.array(e)&&(this.options.quality=dedupe(e).filter((function(e){return t.config.quality.options.includes(e)})));var n=!is$1.empty(this.options.quality)&&this.options.quality.length>1;if(controls.toggleMenuButton.call(this,"quality",n),emptyElement(i),controls.checkMenu.call(this),n){var s=function(e){var i=i18n.get("qualityBadge.".concat(e),t.config);return i.length?controls.createBadge.call(t,i):null};this.options.quality.sort((function(e,i){var n=t.config.quality.options;return n.indexOf(e)>n.indexOf(i)?1:-1})).forEach((function(e){controls.createMenuItem.call(t,{value:e,list:i,type:"quality",title:controls.getLabel.call(t,"quality",e),badge:s(e)})})),controls.updateSetting.call(this,"quality",i)}}},setCaptionsMenu:function(){var e=this;if(is$1.element(this.elements.settings.panels.captions)){var t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=captions.getTracks.call(this),n=Boolean(i.length);if(controls.toggleMenuButton.call(this,"captions",n),emptyElement(t),controls.checkMenu.call(this),n){var s=i.map((function(i,n){return{value:n,checked:e.captions.toggled&&e.currentTrack===n,title:captions.getLabel.call(e,i),badge:i.language&&controls.createBadge.call(e,i.language.toUpperCase()),list:t,type:"language"}}));s.unshift({value:-1,checked:!this.captions.toggled,title:i18n.get("disabled",this.config),list:t,type:"language"}),s.forEach(controls.createMenuItem.bind(this)),controls.updateSetting.call(this,"captions",t)}}},setSpeedMenu:function(){var e=this;if(is$1.element(this.elements.settings.panels.speed)){var t=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter((function(t){return t>=e.minimumSpeed&&t<=e.maximumSpeed}));var i=!is$1.empty(this.options.speed)&&this.options.speed.length>1;controls.toggleMenuButton.call(this,"speed",i),emptyElement(t),controls.checkMenu.call(this),i&&(this.options.speed.forEach((function(i){controls.createMenuItem.call(e,{value:i,list:t,type:"speed",title:controls.getLabel.call(e,"speed",i)})})),controls.updateSetting.call(this,"speed",t))}},checkMenu:function(){var e=this.elements.settings.buttons,t=!is$1.empty(e)&&Object.values(e).some((function(e){return!e.hidden}));toggleHidden(this.elements.settings.menu,!t)},focusFirstMenuItem:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.elements.settings.popup.hidden){var i=e;is$1.element(i)||(i=Object.values(this.elements.settings.panels).find((function(e){return!e.hidden})));var n=i.querySelector('[role^="menuitem"]');setFocus.call(this,n,t)}},toggleMenu:function(e){var t=this.elements.settings.popup,i=this.elements.buttons.settings;if(is$1.element(t)&&is$1.element(i)){var n=t.hidden,s=n;if(is$1.boolean(e))s=e;else if(is$1.keyboardEvent(e)&&27===e.which)s=!1;else if(is$1.event(e)){var a=is$1.function(e.composedPath)?e.composedPath()[0]:e.target,r=t.contains(a);if(r||!r&&e.target!==i&&s)return}i.setAttribute("aria-expanded",s),toggleHidden(t,!s),toggleClass(this.elements.container,this.config.classNames.menu.open,s),s&&is$1.keyboardEvent(e)?controls.focusFirstMenuItem.call(this,null,!0):s||n||setFocus.call(this,i,is$1.keyboardEvent(e))}},getMenuSize:function(e){var t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);var i=t.scrollWidth,n=t.scrollHeight;return removeElement(t),{width:i,height:n}},showMenuPanel:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.elements.container.querySelector("#plyr-settings-".concat(this.id,"-").concat(t));if(is$1.element(n)){var s=n.parentNode,a=Array.from(s.children).find((function(e){return!e.hidden}));if(support.transitions&&!support.reducedMotion){s.style.width="".concat(a.scrollWidth,"px"),s.style.height="".concat(a.scrollHeight,"px");var r=controls.getMenuSize.call(this,n),o=function t(i){i.target===s&&["width","height"].includes(i.propertyName)&&(s.style.width="",s.style.height="",off.call(e,s,transitionEndEvent,t))};on.call(this,s,transitionEndEvent,o),s.style.width="".concat(r.width,"px"),s.style.height="".concat(r.height,"px")}toggleHidden(a,!0),toggleHidden(n,!1),controls.focusFirstMenuItem.call(this,n,i)}},setDownloadUrl:function(){var e=this.elements.buttons.download;is$1.element(e)&&e.setAttribute("href",this.download)},create:function(e){var t=this,i=controls.bindMenuItemShortcuts,n=controls.createButton,s=controls.createProgress,a=controls.createRange,r=controls.createTime,o=controls.setQualityMenu,l=controls.setSpeedMenu,c=controls.showMenuPanel;this.elements.controls=null,is$1.array(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(n.call(this,"play-large"));var u=createElement("div",getAttributesFromSelector(this.config.selectors.controls.wrapper));this.elements.controls=u;var d={class:"plyr__controls__item"};return dedupe(is$1.array(this.config.controls)?this.config.controls:[]).forEach((function(o){if("restart"===o&&u.appendChild(n.call(t,"restart",d)),"rewind"===o&&u.appendChild(n.call(t,"rewind",d)),"play"===o&&u.appendChild(n.call(t,"play",d)),"fast-forward"===o&&u.appendChild(n.call(t,"fast-forward",d)),"progress"===o){var l=createElement("div",{class:"".concat(d.class," plyr__progress__container")}),h=createElement("div",getAttributesFromSelector(t.config.selectors.progress));if(h.appendChild(a.call(t,"seek",{id:"plyr-seek-".concat(e.id)})),h.appendChild(s.call(t,"buffer")),t.config.tooltips.seek){var m=createElement("span",{class:t.config.classNames.tooltip},"00:00");h.appendChild(m),t.elements.display.seekTooltip=m}t.elements.progress=h,l.appendChild(t.elements.progress),u.appendChild(l)}if("current-time"===o&&u.appendChild(r.call(t,"currentTime",d)),"duration"===o&&u.appendChild(r.call(t,"duration",d)),"mute"===o||"volume"===o){var p=t.elements.volume;if(is$1.element(p)&&u.contains(p)||(p=createElement("div",extend({},d,{class:"".concat(d.class," plyr__volume").trim()})),t.elements.volume=p,u.appendChild(p)),"mute"===o&&p.appendChild(n.call(t,"mute")),"volume"===o&&!browser.isIos){var g={max:1,step:.05,value:t.config.volume};p.appendChild(a.call(t,"volume",extend(g,{id:"plyr-volume-".concat(e.id)})))}}if("captions"===o&&u.appendChild(n.call(t,"captions",d)),"settings"===o&&!is$1.empty(t.config.settings)){var f=createElement("div",extend({},d,{class:"".concat(d.class," plyr__menu").trim(),hidden:""}));f.appendChild(n.call(t,"settings",{"aria-haspopup":!0,"aria-controls":"plyr-settings-".concat(e.id),"aria-expanded":!1}));var y=createElement("div",{class:"plyr__menu__container",id:"plyr-settings-".concat(e.id),hidden:""}),v=createElement("div"),b=createElement("div",{id:"plyr-settings-".concat(e.id,"-home")}),w=createElement("div",{role:"menu"});b.appendChild(w),v.appendChild(b),t.elements.settings.panels.home=b,t.config.settings.forEach((function(n){var s=createElement("button",extend(getAttributesFromSelector(t.config.selectors.buttons.settings),{type:"button",class:"".concat(t.config.classNames.control," ").concat(t.config.classNames.control,"--forward"),role:"menuitem","aria-haspopup":!0,hidden:""}));i.call(t,s,n),on.call(t,s,"click",(function(){c.call(t,n,!1)}));var a=createElement("span",null,i18n.get(n,t.config)),r=createElement("span",{class:t.config.classNames.menu.value});r.innerHTML=e[n],a.appendChild(r),s.appendChild(a),w.appendChild(s);var o=createElement("div",{id:"plyr-settings-".concat(e.id,"-").concat(n),hidden:""}),l=createElement("button",{type:"button",class:"".concat(t.config.classNames.control," ").concat(t.config.classNames.control,"--back")});l.appendChild(createElement("span",{"aria-hidden":!0},i18n.get(n,t.config))),l.appendChild(createElement("span",{class:t.config.classNames.hidden},i18n.get("menuBack",t.config))),on.call(t,o,"keydown",(function(e){37===e.which&&(e.preventDefault(),e.stopPropagation(),c.call(t,"home",!0))}),!1),on.call(t,l,"click",(function(){c.call(t,"home",!1)})),o.appendChild(l),o.appendChild(createElement("div",{role:"menu"})),v.appendChild(o),t.elements.settings.buttons[n]=s,t.elements.settings.panels[n]=o})),y.appendChild(v),f.appendChild(y),u.appendChild(f),t.elements.settings.popup=y,t.elements.settings.menu=f}if("pip"===o&&support.pip&&u.appendChild(n.call(t,"pip",d)),"airplay"===o&&support.airplay&&u.appendChild(n.call(t,"airplay",d)),"download"===o){var k=extend({},d,{element:"a",href:t.download,target:"_blank"});t.isHTML5&&(k.download="");var T=t.config.urls.download;!is$1.url(T)&&t.isEmbed&&extend(k,{icon:"logo-".concat(t.provider),label:t.provider}),u.appendChild(n.call(t,"download",k))}"fullscreen"===o&&u.appendChild(n.call(t,"fullscreen",d))})),this.isHTML5&&o.call(this,html5.getQualityOptions.call(this)),l.call(this),u},inject:function(){var e=this;if(this.config.loadSprite){var t=controls.getIconUrl.call(this);t.cors&&loadSprite(t.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());var i=null;this.elements.controls=null;var n={id:this.id,seektime:this.config.seekTime,title:this.config.title},s=!0;is$1.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this,n)),this.config.controls||(this.config.controls=[]),is$1.element(this.config.controls)||is$1.string(this.config.controls)?i=this.config.controls:(i=controls.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:captions.getLabel.call(this)}),s=!1);var a,r;if(s&&is$1.string(this.config.controls)&&(a=i,Object.entries(n).forEach((function(e){var t=_slicedToArray(e,2),i=t[0],n=t[1];a=replaceAll(a,"{".concat(i,"}"),n)})),i=a),is$1.string(this.config.selectors.controls.container)&&(r=document.querySelector(this.config.selectors.controls.container)),is$1.element(r)||(r=this.elements.container),r[is$1.element(i)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",i),is$1.element(this.elements.controls)||controls.findElements.call(this),!is$1.empty(this.elements.buttons)){var o=function(t){var i=e.config.classNames.controlPressed;Object.defineProperty(t,"pressed",{enumerable:!0,get:function(){return hasClass(t,i)},set:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];toggleClass(t,i,e)}})};Object.values(this.elements.buttons).filter(Boolean).forEach((function(e){is$1.array(e)||is$1.nodeList(e)?Array.from(e).filter(Boolean).forEach(o):o(e)}))}if(browser.isEdge&&repaint(r),this.config.tooltips.controls){var l=this.config,c=l.classNames,u=l.selectors,d="".concat(u.controls.wrapper," ").concat(u.labels," .").concat(c.hidden),h=getElements.call(this,d);Array.from(h).forEach((function(t){toggleClass(t,e.config.classNames.hidden,!1),toggleClass(t,e.config.classNames.tooltip,!0)}))}}};function parseUrl(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=e;if(t){var n=document.createElement("a");n.href=i,i=n.href}try{return new URL(i)}catch(e){return null}}function buildUrlParams(e){var t=new URLSearchParams;return is$1.object(e)&&Object.entries(e).forEach((function(e){var i=_slicedToArray(e,2),n=i[0],s=i[1];t.set(n,s)})),t}var captions={setup:function(){if(this.supported.ui)if(!this.isVideo||this.isYouTube||this.isHTML5&&!support.textTracks)is$1.array(this.config.controls)&&this.config.controls.i